diff --git a/.checkov.yml b/.checkov.yml new file mode 100644 index 00000000000..12f0d8b3841 --- /dev/null +++ b/.checkov.yml @@ -0,0 +1,6 @@ +--- +# You can see all available properties here: https://github.com/bridgecrewio/checkov#configuration-using-a-config-file +quiet: true +skip-check: + - CKV_DOCKER_2 + - CKV_GHA_7 diff --git a/.clang-format b/.clang-format index 14c0a235995..c5979d77ba1 100644 --- a/.clang-format +++ b/.clang-format @@ -24,6 +24,7 @@ ExperimentalAutoDetectBinPacking: false IndentCaseLabels: true IndentFunctionDeclarationAfterType: true IndentWidth: 2 +InsertNewlineAtEOF: true # It is broken on windows. Breaks all #include "header.h" --- Language: Cpp diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000000..b58bc4a81db --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,68 @@ +--- +alice3: + - changed-files: + - any-glob-to-any-file: ['ALICE3/**'] + +common: + - changed-files: + - any-glob-to-any-file: ['Common/**'] + +infrastructure: + - changed-files: + - any-glob-to-any-file: + - '.clang-format' + - '.clang-tidy' + - '.flake8' + - '.github/**' + - '.checkov.yml' + - '.mega-linter.yml' + - 'cmake/**' + - 'CODEOWNERS' + - 'CPPLINT.cfg' + - 'dependencies/**' + - 'packaging/**' + - 'pyproject.toml' + +datamodel: + - changed-files: + - any-glob-to-any-file: ['DataModel/**', '*/DataModel/**'] + +dpg: + - changed-files: + - any-glob-to-any-file: ['DPG/**'] + +pwgcf: + - changed-files: + - any-glob-to-any-file: ['PWGCF/**', '*/PWGCF/**'] + +pwgdq: + - changed-files: + - any-glob-to-any-file: ['PWGDQ/**', '*/PWGDQ/**'] + +pwgem: + - changed-files: + - any-glob-to-any-file: ['PWGEM/**', '*/PWGEM/**'] + +pwghf: + - changed-files: + - any-glob-to-any-file: ['PWGHF/**', '*/PWGHF/**'] + +pwgje: + - changed-files: + - any-glob-to-any-file: ['PWGJE/**', '*/PWGJE/**'] + +pwglf: + - changed-files: + - any-glob-to-any-file: ['PWGLF/**', '*/PWGLF/**', 'PWGMM/**', '*/PWGMM/**'] + +pwgud: + - changed-files: + - any-glob-to-any-file: ['PWGUD/**', '*/PWGUD/**'] + +trigger: + - changed-files: + - any-glob-to-any-file: ['EventFiltering/**'] + +tutorial: + - changed-files: + - any-glob-to-any-file: ['Tutorials/**'] diff --git a/.github/workflows/clean-test.yml b/.github/workflows/clean-test.yml new file mode 100644 index 00000000000..c6c9bc12067 --- /dev/null +++ b/.github/workflows/clean-test.yml @@ -0,0 +1,51 @@ +--- +name: Clean PR checks + +'on': + workflow_dispatch: + inputs: + pr: + description: PR number in this repo to be cleaned + type: string # can't use number here + required: true + message: + description: Human-readable message displayed on the new pending status + type: string + required: false + default: '' + + # Warning: GitHub limits the total number of inputs to 10, so a maximum of + # 8 checks is allowed here! + # Warning: the check_* keys are magic and must consist of the string + # "check_" followed by the applicable check name exactly. The + # "description" field is only the human-readable label for the input. + 'check_build/O2Physics/o2/macOS-arm': + description: build/O2Physics/o2/macOS-arm + type: boolean + default: true + + 'check_build/O2Physics/o2/macOS': + description: build/O2Physics/o2/macOS + type: boolean + default: true + + 'check_build/O2Physics/o2': + description: build/O2Physics/o2 + type: boolean + default: true + +permissions: {} + +jobs: + clean: + name: Clean PR checks + uses: alisw/ali-bot/.github/workflows/clean-pr-checks.yml@master + with: + owner: ${{ github.event.repository.owner.login }} + repo: ${{ github.event.repository.name }} + pr: ${{ github.event.inputs.pr }} + message: ${{ github.event.inputs.message }} + checks: ${{ toJSON(github.event.inputs) }} + permissions: + pull-requests: read # to get last commit for pr (octokit/graphql-action) + statuses: write # for set-github-status diff --git a/.github/workflows/codeowner-self-approval.yml b/.github/workflows/codeowner-self-approval.yml index bd4d3182682..149213effc5 100644 --- a/.github/workflows/codeowner-self-approval.yml +++ b/.github/workflows/codeowner-self-approval.yml @@ -13,7 +13,7 @@ permissions: jobs: approve: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # Only run if the PR author enabled auto-merge, not someone else. # Also run if a new approval was created, as this affects whether we can # auto-approve. There is a risk of infinite loops here, though -- when we diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000000..3f8fa9bc1b6 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,122 @@ +--- +name: "Pull Request Labeler" +'on': + pull_request_target: + types: [opened, synchronize, reopened, edited] +permissions: read-all + +jobs: + labeler: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + outputs: + labels: ${{ steps.labeler.outputs.all-labels }} + steps: + - name: Label the PR + id: labeler + uses: actions/labeler@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + sync-labels: true + title-prefix-checker: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + needs: labeler + steps: + - name: Check the PR title prefix + id: check-prefix + env: + title: ${{ github.event.pull_request.title }} + labels: ${{ needs.labeler.outputs.labels }} + shell: python + run: | + import os + import re + import sys + title = os.environ['title'] + labels = os.environ['labels'] + tags = { + "infrastructure": "Infrastructure", + "common": "Common", + "alice3": "ALICE3", + "pwgcf": "PWGCF", + "pwgdq": "PWGDQ", + "pwgem": "PWGEM", + "pwghf": "PWGHF", + "pwgje": "PWGJE", + "pwglf": "PWGLF", + "pwgud": "PWGUD", + "dpg": "DPG", + "trigger": "Trigger", + "tutorial": "Tutorial", + } + print(f'PR title: "{title}"') + print(f'PR labels: "{labels}"') + tags_relevant = [tags[label] for label in tags if label in labels.split(",")] + print("Relevant title tags:", ",".join(tags_relevant)) + passed = True + prefix_good = ",".join(tags_relevant) + prefix_good = f"[{prefix_good}] " + print(f"Generated prefix: {prefix_good}") + replace_title = 0 + title_new = title + # If there is a prefix which contains a known tag, check it for correct tags, and reformat it if needed. + # If there is a prefix which does not contain any known tag, add the tag prefix. + # If there is no prefix, add the tag prefix. + if match := re.match(r"\[?(\w[\w, /\+-]+)[\]:]+ ", title): + prefix_title = match.group(1) + words_prefix_title = prefix_title.replace(",", " ").replace("/", " ").split() + title_stripped = title[len(match.group()) :] + print(f'PR title prefix: "{prefix_title}" -> tags: {words_prefix_title}') + print(f'Stripped PR title: "{title_stripped}"') + if any(tag in words_prefix_title for tag in tags.values()): + for tag in tags.values(): + if tag in tags_relevant and tag not in words_prefix_title: + print(f'::error::Relevant tag "{tag}" not found in the prefix of the PR title.') + passed = False + if tag not in tags_relevant and tag in words_prefix_title: + print(f'::error::Irrelevant tag "{tag}" found in the prefix of the PR title.') + passed = False + # Format a valid prefix. + if passed: + prefix_good = ",".join(w for w in prefix_title.replace(",", " ").split() if w) + prefix_good = f"[{prefix_good}] " + print(f"::notice::Reformatted prefix: {prefix_good}") + if match.group() != prefix_good: + replace_title = 1 + title_new = prefix_good + title_stripped + else: + print("::warning::No known tags found in the prefix.") + if tags_relevant: + replace_title = 1 + title_new = prefix_good + title + else: + print("::warning::No valid prefix found in the PR title.") + if tags_relevant: + replace_title = 1 + title_new = prefix_good + title + if not passed: + print("::error::Problems were found in the PR title prefix.") + print('::notice::Use the form "tags: title" or "[tags] title".') + sys.exit(1) + if replace_title: + print("::warning::The PR title prefix with tags needs to be added or adjusted.") + print(f'::warning::New title: "{title_new}".') + else: + print("::notice::The PR title prefix is fine.") + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: + print(f"replace={replace_title}", file=fh) + print(f"title={title_new}", file=fh) + - name: Fix the PR title prefix + if: ${{ steps.check-prefix.outputs.replace == 1 }} + uses: the-wright-jamie/Update-PR-Info-Action@v1.1.0 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + base-branch-regex: master + error-on-fail: false + title-template: "${{ steps.check-prefix.outputs.title }}" + title-update-action: replace diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml index 88d5e20cf96..28bb7877865 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@v7 + uses: oxsecurity/megalinter@v8.1.0 env: # All available variables are described in documentation: # https://megalinter.io/configuration/ @@ -47,6 +47,16 @@ jobs: VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Upload MegaLinter artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + if: success() || failure() + with: + name: MegaLinter reports + path: | + megalinter-reports + mega-linter.log + # Create or delete the cleanup branch - name: Update cleanup branch if: ${{ github.event.repository.owner.login == 'AliceO2Group' }} diff --git a/.github/workflows/o2-linter.yml b/.github/workflows/o2-linter.yml new file mode 100644 index 00000000000..3f124b56750 --- /dev/null +++ b/.github/workflows/o2-linter.yml @@ -0,0 +1,30 @@ +--- +# Find issues in O2 code +name: O2 linter + +'on': [pull_request, push] +permissions: {} +env: + MAIN_BRANCH: master + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + o2-linter: + name: O2 linter + runs-on: ubuntu-24.04 + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # needed to get the full history + - name: Run tests + 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 }}...) + [ ${{ github.event_name }} == 'pull_request' ] && 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." diff --git a/ALICE3/Core/CMakeLists.txt b/ALICE3/Core/CMakeLists.txt index 6db27c117d8..788711ac277 100644 --- a/ALICE3/Core/CMakeLists.txt +++ b/ALICE3/Core/CMakeLists.txt @@ -15,6 +15,14 @@ o2physics_add_library(ALICE3Core PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) o2physics_target_root_dictionary(ALICE3Core - HEADERS TOFResoALICE3.h - DelphesO2TrackSmearer.h - LINKDEF ALICE3CoreLinkDef.h) + HEADERS TOFResoALICE3.h + DelphesO2TrackSmearer.h + LINKDEF ALICE3CoreLinkDef.h) + +o2physics_add_library(FastTracker + SOURCES FastTracker.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) + +o2physics_target_root_dictionary(FastTracker + HEADERS FastTracker.h + LINKDEF FastTrackerLinkDef.h) diff --git a/ALICE3/Core/DetLayer.h b/ALICE3/Core/DetLayer.h new file mode 100644 index 00000000000..6b9fea14c06 --- /dev/null +++ b/ALICE3/Core/DetLayer.h @@ -0,0 +1,52 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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.h +/// \author David Dobrigkeit Chinellato +/// \since 11/03/2021 +/// \brief Basic struct to hold information regarding a detector layer to be used in fast simulation +/// + +#ifndef ALICE3_CORE_DETLAYER_H_ +#define ALICE3_CORE_DETLAYER_H_ + +#include "TString.h" + +namespace o2::fastsim +{ + +struct DetLayer { + // TString for holding name + TString name; + + // position variables + float r; // radius in centimeters + float z; // z dimension in centimeters + + // material variables + float x0; // radiation length + float xrho; // density + + // resolution variables for active layers + float resRPhi; // RPhi resolution in centimeters + float resZ; // Z resolution in centimeters + + // efficiency + float eff; // detection efficiency + + // layer type + int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc +}; + +} // namespace o2::fastsim + +#endif // ALICE3_CORE_DETLAYER_H_ diff --git a/ALICE3/Core/FastTracker.cxx b/ALICE3/Core/FastTracker.cxx new file mode 100644 index 00000000000..715ed9343e2 --- /dev/null +++ b/ALICE3/Core/FastTracker.cxx @@ -0,0 +1,395 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "TMath.h" +#include "TMatrixD.h" +#include "TRandom.h" +#include "TMatrixDSymEigen.h" +#include "FastTracker.h" + +namespace o2 +{ +namespace fastsim +{ + +// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + +FastTracker::FastTracker() +{ + // 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; +} + +void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type) +{ + DetLayer newLayer{name.Data(), r, z, x0, xrho, resRPhi, resZ, eff, type}; + layers.push_back(newLayer); +} + +void FastTracker::Print() +{ + // print out layer setup + 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) << "+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+"; +} + +void FastTracker::AddSiliconALICE3v4() +{ + LOG(info) << " Adding ALICE 3 v4 ITS 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 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}); +} + +void FastTracker::AddSiliconALICE3v1() +{ + LOG(info) << " Adding ALICE 3 v1 ITS layers"; + float x0IT = 0.001; // 0.1% + float x0OT = 0.005; // 0.5% + 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 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}); +} + +void FastTracker::AddTPC(float phiResMean, float zResMean) +{ + LOG(info) << " Adding standard time projection chamber"; + + // porting of DetectorK::AddTPC + // see here: + // https://github.com/AliceO2Group/DelphesO2/blob/master/src/DetectorK/DetectorK.cxx + // % Radiation Lengths ... Average per TPC row (i.e. total/159 ) + const int kNPassiveBound = 2; + const float radLBoundary[kNPassiveBound] = {1.692612e-01, 8.711904e-02}; + const float xrhoBoundary[kNPassiveBound] = {6.795774e+00, 3.111401e+00}; + const float rBoundary[kNPassiveBound] = {50, 70.0}; // cm + + float radLPerRow = 0.000036; + + float tpcInnerRadialPitch = 0.75; // cm + float tpcMiddleRadialPitch = 1.0; // cm + float tpcOuterRadialPitch = 1.5; // cm + float innerRows = 63; + float middleRows = 64; + float outerRows = 32; + float tpcRows = (innerRows + middleRows + outerRows); + float rowOneRadius = 85.2; // cm + float row64Radius = 135.1; // cm + float row128Radius = 199.2; // cm + + float zLength = 250.0f; // to be checked + + // add boundaries between ITS and TPC + for (int i = 0; i < kNPassiveBound; i++) { + AddLayer(Form("tpc_boundary%d", i), rBoundary[i], zLength, radLBoundary[i], xrhoBoundary[i], 0); // dummy errors + } + for (Int_t k = 0; k < tpcRows; k++) { + Float_t rowRadius = 0; + if (k < innerRows) + rowRadius = rowOneRadius + k * tpcInnerRadialPitch; + else if (k >= innerRows && k < (innerRows + middleRows)) + rowRadius = row64Radius + (k - innerRows + 1) * tpcMiddleRadialPitch; + else if (k >= (innerRows + middleRows) && k < tpcRows) + rowRadius = row128Radius + (k - innerRows - middleRows + 1) * tpcOuterRadialPitch; + + AddLayer(Form("tpc_%d", k), rowRadius, zLength, radLPerRow, 0, phiResMean, zResMean, 1.0f, 2); + } +} + +// 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) +{ + 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]); + + // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + // Outward pass to find intercepts + int firstLayerReached = -1; + int lastLayerReached = -1; + for (uint32_t il = 0; il < layers.size(); il++) { + // check if layer is doable + if (layers[il].r < 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) + break; // failed to find intercept + + if (!inputTrack.propagateTo(targetX, magneticField)) { + break; // failed to propagate + } + if (std::abs(inputTrack.getZ()) > layers[il].z && applyZacceptance) { + break; // out of acceptance bounds + } + + // layer is reached + if (firstLayerReached < 0) + firstLayerReached = il; + lastLayerReached = il; + nIntercepts++; + } + + // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + // initialize track at outer point + new (&outputTrack)(o2::track::TrackParCov)(inputTrack); + + // Enlarge covariance matrix + std::array trPars = {0.}; + for (int ip = 0; ip < 5; 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--;) + largeCov[ic] = 0.; + largeCov[kY2] = largeCov[kZ2] = kLargeErr2Coord; + largeCov[kSnp2] = largeCov[kTgl2] = kLargeErr2Dir; + largeCov[kPtI2] = kLargeErr2PtI * trPars[kPtI] * trPars[kPtI]; + + outputTrack.setCov(largeCov); + outputTrack.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); + 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) { + continue; // out of acceptance bounds but continue inwards + } + + // get perfect data point position + std::array spacePoint; + inputTrack.getXYZGlo(spacePoint); + 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], + spacePoint[2]}; + if (!(outputTrack.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].type == 1) + nSiliconPoints++; // count silicon hits + if (layers[il].type == 2) + nGasPoints++; // count TPC/gas hits + + hits.push_back(thisHit); + } + + // backpropagate to original radius + float finalX = 1e+3; + outputTrack.getXatLabR(initialRadius, finalX, magneticField); + if (finalX > 999) + return -3; // failed to find intercept + + if (!outputTrack.propagateTo(finalX, magneticField)) { + return -4; // failed to propagate + } + + // only attempt to continue if intercepts are at least four + if (nIntercepts < 4) + return nIntercepts; + + // Use covariance matrix based smearing + std::array covMat = {0.}; + for (int ii = 0; ii < 15; ii++) + covMat[ii] = outputTrack.getCov()[ii]; + TMatrixDSym m(5); + double fcovm[5][5]; + + for (int ii = 0, k = 0; ii < 5; ++ii) { + for (int j = 0; j < ii + 1; ++j, ++k) { + fcovm[ii][j] = covMat[k]; + fcovm[j][ii] = covMat[k]; + } + } + + // evaluate ruben's conditional, regularise + bool makePositiveDefinite = (covMatFactor > -1e-5); // apply fix + bool rubenConditional = false; + for (int ii = 0; ii < 5; ii++) { + for (int jj = 0; jj < 5; jj++) { + if (ii == jj) + continue; // don't evaluate diagonals + if (fcovm[ii][jj] * fcovm[ii][jj] > std::abs(fcovm[ii][ii] * fcovm[jj][jj])) { + rubenConditional = true; + if (makePositiveDefinite) { + fcovm[ii][jj] = TMath::Sign(1, fcovm[ii][jj]) * covMatFactor * sqrt(std::abs(fcovm[ii][ii] * fcovm[jj][jj])); + } + } + } + } + + // Should have a valid cov matrix now + m.SetMatrixArray(reinterpret_cast(fcovm)); + TMatrixDSymEigen eigen(m); + TMatrixD eigVec = eigen.GetEigenVectors(); + TVectorD eigVal = eigen.GetEigenValues(); + bool negEigVal = false; + for (int ii = 0; ii < 5; ii++) { + if (eigVal[ii] < 0.0f) + negEigVal = true; + } + + if (negEigVal && rubenConditional && makePositiveDefinite) { + if (verboseLevel > 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; + LOG(info) << "Cov matrix: "; + m.Print(); + } + covMatNotOK++; + nIntercepts = -1; // mark as problematic so that it isn't used + return -1; + } + covMatOK++; + + // transform parameter vector and smear + double params_[5]; + for (int ii = 0; ii < 5; ++ii) { + double val = 0.; + for (int j = 0; j < 5; ++j) + val += eigVec[j][ii] * outputTrack.getParam(j); + // smear parameters according to eigenvalues + params_[ii] = gRandom->Gaus(val, sqrt(eigVal[ii])); + } + + // invert eigenvector matrix + eigVec.Invert(); + // transform back params vector + for (int ii = 0; ii < 5; ++ii) { + double val = 0.; + for (int j = 0; j < 5; ++j) + val += eigVec[j][ii] * params_[j]; + outputTrack.setParam(val, ii); + } + // should make a sanity check that par[2] sin(phi) is in [-1, 1] + if (fabs(outputTrack.getParam(2)) > 1.) { + LOG(info) << " --- smearTrack failed sin(phi) sanity check: " << outputTrack.getParam(2); + return -2; + } + + return nIntercepts; +} +// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + +} /* namespace fastsim */ +} /* namespace o2 */ + +ClassImp(o2::fastsim::FastTracker); diff --git a/ALICE3/Core/FastTracker.h b/ALICE3/Core/FastTracker.h new file mode 100644 index 00000000000..ecd7d19cb98 --- /dev/null +++ b/ALICE3/Core/FastTracker.h @@ -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. + +#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" + +namespace o2 +{ +namespace fastsim +{ + +// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + +// this class implements a synthetic smearer that allows +// for on-demand smearing of TrackParCovs in a certain flexible t +// detector layout. +class FastTracker +{ + public: + // Constructor/destructor + FastTracker(); + virtual ~FastTracker() {} + + 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(); + void AddTPC(float phiResMean, float zResMean); + + void Print(); + int FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackParCov& outputTrack); + + // 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 + + ClassDef(FastTracker, 1); +}; + +// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+ + +} // namespace fastsim +} // namespace o2 + +#endif // ALICE3_CORE_FASTTRACKER_H_ diff --git a/ALICE3/Core/FastTrackerLinkDef.h b/ALICE3/Core/FastTrackerLinkDef.h new file mode 100644 index 00000000000..a69755b7e92 --- /dev/null +++ b/ALICE3/Core/FastTrackerLinkDef.h @@ -0,0 +1,21 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 ALICE3_CORE_FASTTRACKERLINKDEF_H_ +#define ALICE3_CORE_FASTTRACKERLINKDEF_H_ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class o2::fastsim::FastTracker + ; + +#endif // ALICE3_CORE_FASTTRACKERLINKDEF_H_ diff --git a/ALICE3/DataModel/A3DecayFinderTables.h b/ALICE3/DataModel/A3DecayFinderTables.h index cc7e8f3d3c7..05eb5ad9307 100644 --- a/ALICE3/DataModel/A3DecayFinderTables.h +++ b/ALICE3/DataModel/A3DecayFinderTables.h @@ -43,7 +43,10 @@ enum a3selectionBit : uint32_t { kDCAxy = 0, kTruePrPlusFromLc, kTruePiMinusFromLc, kTrueKaMinusFromLc, - kTruePrMinusFromLc }; + kTruePrMinusFromLc, + kTrueXiFromXiC, + kTruePiFromXiC, + kTruePiFromXiCC }; namespace o2::aod { @@ -51,7 +54,7 @@ namespace a3DecayMap { DECLARE_SOA_COLUMN(DecayMap, decayMap, uint32_t); //! simple map to process passing / not passing criteria } // namespace a3DecayMap -DECLARE_SOA_TABLE(Alice3DecayMaps, "AOD", "ALICE3DECAYMAP", +DECLARE_SOA_TABLE(Alice3DecayMaps, "AOD", "ALICE3DECAYMAPS", a3DecayMap::DecayMap); using Alice3DecayMap = Alice3DecayMaps::iterator; diff --git a/ALICE3/DataModel/OTFMcTrackExtra.h b/ALICE3/DataModel/OTFMcTrackExtra.h new file mode 100644 index 00000000000..bb75c86746c --- /dev/null +++ b/ALICE3/DataModel/OTFMcTrackExtra.h @@ -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. + +/// +/// \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 new file mode 100644 index 00000000000..7dbde7bdc9a --- /dev/null +++ b/ALICE3/DataModel/OTFMulticharm.h @@ -0,0 +1,116 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 OTFStrangeness.h +/// \author David Dobrigkeit Chinellato +/// \since 05/08/2024 +/// \brief Set of tables for the ALICE3 strangeness information +/// + +#ifndef ALICE3_DATAMODEL_OTFMULTICHARM_H_ +#define ALICE3_DATAMODEL_OTFMULTICHARM_H_ + +// O2 includes +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace otfmulticharm +{ +DECLARE_SOA_INDEX_COLUMN_FULL(Cascade, cascade, int, UpgradeCascades, "_Cascade"); +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); + +// 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); + +} // namespace otfmulticharm +DECLARE_SOA_TABLE(MCharmIndices, "AOD", "MCharmIndices", + o2::soa::Index<>, + otfmulticharm::CascadeId, + otfmulticharm::XiCPion1Id, + otfmulticharm::XiCPion2Id, + 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); + +} // namespace o2::aod + +#endif // ALICE3_DATAMODEL_OTFMULTICHARM_H_ diff --git a/ALICE3/DataModel/OTFStrangeness.h b/ALICE3/DataModel/OTFStrangeness.h new file mode 100644 index 00000000000..861ec3a7af8 --- /dev/null +++ b/ALICE3/DataModel/OTFStrangeness.h @@ -0,0 +1,70 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 OTFStrangeness.h +/// \author David Dobrigkeit Chinellato +/// \since 05/08/2024 +/// \brief Set of tables for the ALICE3 strangeness information +/// + +#ifndef ALICE3_DATAMODEL_OTFSTRANGENESS_H_ +#define ALICE3_DATAMODEL_OTFSTRANGENESS_H_ + +// O2 includes +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace otfcascade +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! +DECLARE_SOA_INDEX_COLUMN_FULL(CascadeTrack, cascadeTrack, int, Tracks, "_Cascade"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(PosTrack, posTrack, int, Tracks, "_Pos"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(NegTrack, negTrack, int, Tracks, "_Neg"); //! +DECLARE_SOA_INDEX_COLUMN_FULL(BachTrack, bachTrack, int, Tracks, "_Bach"); //! + +// topo vars +DECLARE_SOA_COLUMN(DCAV0Daughters, dcaV0Daughters, float); +DECLARE_SOA_COLUMN(DCACascadeDaughters, dcaCascadeDaughters, float); +DECLARE_SOA_COLUMN(V0Radius, v0Radius, float); +DECLARE_SOA_COLUMN(CascRadius, cascRadius, float); +DECLARE_SOA_COLUMN(CascRadiusMC, cascRadiusMC, float); +DECLARE_SOA_COLUMN(MLambda, mLambda, float); +DECLARE_SOA_COLUMN(MXi, mXi, float); + +// strangeness tracking +DECLARE_SOA_COLUMN(FindableClusters, findableClusters, int); +DECLARE_SOA_COLUMN(FoundClusters, foundClusters, int); + +} // namespace otfcascade +DECLARE_SOA_TABLE(UpgradeCascades, "AOD", "UPGRADECASCADES", + o2::soa::Index<>, + otfcascade::CollisionId, + otfcascade::CascadeTrackId, + otfcascade::PosTrackId, + otfcascade::NegTrackId, + otfcascade::BachTrackId, + otfcascade::DCAV0Daughters, + otfcascade::DCACascadeDaughters, + otfcascade::V0Radius, + otfcascade::CascRadius, + otfcascade::CascRadiusMC, + otfcascade::MLambda, + otfcascade::MXi, + otfcascade::FindableClusters, + otfcascade::FoundClusters); + +using UpgradeCascade = UpgradeCascades::iterator; + +} // namespace o2::aod + +#endif // ALICE3_DATAMODEL_OTFSTRANGENESS_H_ diff --git a/ALICE3/DataModel/tracksAlice3.h b/ALICE3/DataModel/tracksAlice3.h index c3a3e82a994..280c5ccb110 100644 --- a/ALICE3/DataModel/tracksAlice3.h +++ b/ALICE3/DataModel/tracksAlice3.h @@ -27,12 +27,18 @@ namespace o2::aod namespace track_alice3 { DECLARE_SOA_COLUMN(IsReconstructed, isReconstructed, bool); //! is reconstructed or not +DECLARE_SOA_COLUMN(NSiliconHits, nSiliconHits, int); //! number of silicon hits +DECLARE_SOA_COLUMN(NTPCHits, nTPCHits, int); //! number of tpc hits } // namespace track_alice3 DECLARE_SOA_TABLE(TracksAlice3, "AOD", "TRACKSALICE3", track_alice3::IsReconstructed); - using TrackAlice3 = TracksAlice3::iterator; +DECLARE_SOA_TABLE(TracksExtraA3, "AOD", "TracksExtraA3", + track_alice3::NSiliconHits, + track_alice3::NTPCHits); +using TrackExtraA3 = TracksExtraA3::iterator; + } // namespace o2::aod #endif // ALICE3_DATAMODEL_TRACKSALICE3_H_ diff --git a/ALICE3/TableProducer/CMakeLists.txt b/ALICE3/TableProducer/CMakeLists.txt index 52300bfc644..9c3d710d358 100644 --- a/ALICE3/TableProducer/CMakeLists.txt +++ b/ALICE3/TableProducer/CMakeLists.txt @@ -31,8 +31,17 @@ o2physics_add_dpl_workflow(alice3-centrality PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(alice3-decaypreselector + SOURCES alice3-decaypreselector.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(alice3-decayfinder SOURCES alice3-decayfinder.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(alice3-multicharm + SOURCES alice3-multicharm.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 305fcce4b66..d20b6c6ba5c 100644 --- a/ALICE3/TableProducer/OTF/CMakeLists.txt +++ b/ALICE3/TableProducer/OTF/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(onthefly-tracker SOURCES onTheFlyTracker.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2::DetectorsVertexing O2Physics::ALICE3Core + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2::DetectorsVertexing O2::DCAFitter O2Physics::ALICE3Core O2Physics::FastTracker COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(onthefly-tofpid diff --git a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx index 2953ff1f591..9a77c9e682a 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx @@ -24,14 +24,20 @@ /// #include +#include #include +#include +#include +#include #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 "ReconstructionDataFormats/DCA.h" @@ -42,12 +48,22 @@ #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 "ALICE3/Core/DelphesO2TrackSmearer.h" +#include "ALICE3/Core/FastTracker.h" #include "ALICE3/DataModel/collisionAlice3.h" #include "ALICE3/DataModel/tracksAlice3.h" +#include "ALICE3/DataModel/OTFStrangeness.h" using namespace o2; using namespace o2::framework; +using std::array; struct OnTheFlyTracker { Produces collisions; @@ -61,20 +77,29 @@ struct OnTheFlyTracker { Produces tracksDCACov; Produces collisionsAlice3; Produces TracksAlice3; + Produces TracksExtraA3; + Produces upgradeCascades; // optionally produced, empty (to be tuned later) - Produces tracksExtra; // base table, extend later + Produces tracksExtra; // base table, extend later Produces trackSelection; Produces trackSelectionExtension; + Configurable seed{"seed", 0, "TGenPhaseSpace seed"}; Configurable magneticField{"magneticField", 20.0f, "magnetic field in kG"}; Configurable maxEta{"maxEta", 1.5, "maximum eta to consider viable"}; Configurable multEtaRange{"multEtaRange", 0.8, "eta range to compute the multiplicity"}; Configurable minPt{"minPt", 0.1, "minimum pt to consider viable"}; Configurable enableLUT{"enableLUT", false, "Enable track smearing"}; + Configurable enablePrimarySmearing{"enablePrimarySmearing", false, "Enable smearing of primary particles"}; + Configurable enableSecondarySmearing{"enableSecondarySmearing", false, "Enable smearing of weak decay daughters"}; 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"}; @@ -84,6 +109,7 @@ struct OnTheFlyTracker { 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"}; @@ -94,15 +120,42 @@ struct OnTheFlyTracker { Configurable lutTr{"lutTr", "lutCovm.tr.dat", "LUT for tritons"}; Configurable lutHe3{"lutHe3", "lutCovm.he3.dat", "LUT for Helium-3"}; - ConfigurableAxis axisMomentum{"axisMomentum", {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}, "#it{p} (GeV/#it{c})"}; - ConfigurableAxis axisNVertices{"axisNVertices", {20, -0.5, 19.5}, "N_{vertices}"}; - ConfigurableAxis axisMultiplicity{"axisMultiplicity", {100, -0.5, 99.5}, "N_{contributors}"}; - ConfigurableAxis axisVertexZ{"axisVertexZ", {40, -20, 20}, "vertex Z (cm)"}; - ConfigurableAxis axisDCA{"axisDCA", {400, -200, 200}, "DCA (#mum)"}; - ConfigurableAxis axisX{"axisX", {250, -50, 200}, "track X (cm)"}; + struct : ConfigurableGroup { + ConfigurableAxis axisMomentum{"axisMomentum", {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}, "#it{p} (GeV/#it{c})"}; + ConfigurableAxis axisNVertices{"axisNVertices", {20, -0.5, 19.5}, "N_{vertices}"}; + ConfigurableAxis axisMultiplicity{"axisMultiplicity", {100, -0.5, 99.5}, "N_{contributors}"}; + ConfigurableAxis axisVertexZ{"axisVertexZ", {40, -20, 20}, "vertex Z (cm)"}; + ConfigurableAxis axisDCA{"axisDCA", {400, -200, 200}, "DCA (#mum)"}; + ConfigurableAxis axisX{"axisX", {250, -50, 200}, "track X (cm)"}; + ConfigurableAxis axisDecayRadius{"axisDecayRadius", {55, 0.01, 100}, "decay radius"}; + ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, ""}; + ConfigurableAxis axisXiMass{"axisXiMass", {200, 1.22f, 1.42f}, ""}; + + ConfigurableAxis axisDeltaPt{"axisDeltaPt", {200, -1.0f, +1.0f}, "#Delta p_{T}"}; + ConfigurableAxis axisDeltaEta{"axisDeltaEta", {200, -0.5f, +0.5f}, "#Delta #eta"}; + + ConfigurableAxis axisRadius{"axisRadius", {2500, 0.0f, +250.0f}, "R (cm)"}; + ConfigurableAxis axisZ{"axisZ", {100, -250.0f, +250.0f}, "Z (cm)"}; + } axes; + + // 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 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"}; + } fastTrackerSettings; // allows for gap between peak and bg in case someone wants to using PVertex = o2::dataformats::PrimaryVertex; + // for secondary vertex finding + o2::vertexing::DCAFitterN<2> fitter; + + // FastTracker machinery + o2::fastsim::FastTracker fastTracker; + // Class to hold the track information for the O2 vertexing class TrackAlice3 : public o2::track::TrackParCov { @@ -112,12 +165,52 @@ struct OnTheFlyTracker { TrackAlice3() = default; ~TrackAlice3() = default; TrackAlice3(const TrackAlice3& src) = default; - TrackAlice3(const o2::track::TrackParCov& src, const int64_t label, const float t = 0, const float te = 1, bool decayDauInput = false) : o2::track::TrackParCov(src), mcLabel{label}, timeEst{t, te}, isDecayDau(decayDauInput) {} + TrackAlice3(const o2::track::TrackParCov& src, const int64_t label, + const float t = 0, + const float te = 1, + bool decayDauInput = false, + bool weakDecayDauInput = false, + int isUsedInCascadingInput = 0, + int nSiliconHitsInput = 0, + int nTPCHitsInput = 0) : o2::track::TrackParCov(src), + mcLabel{label}, + timeEst{t, te}, + isDecayDau(decayDauInput), + isWeakDecayDau(weakDecayDauInput), + isUsedInCascading(isUsedInCascadingInput), + nSiliconHits(nSiliconHitsInput), + nTPCHits(nTPCHitsInput) {} const TimeEst& getTimeMUS() const { return timeEst; } int64_t mcLabel; TimeEst timeEst; ///< time estimate in ns bool isDecayDau; + bool isWeakDecayDau; + int isUsedInCascading; // 0: not at all, 1: is a cascade, 2: is a bachelor, 3: is a pion, 4: is a proton + int nSiliconHits; + int nTPCHits; + }; + + // Helper struct to pass cascade information + struct cascadecandidate { + int cascadeTrackId; // track index in the Tracks table + int positiveId; // track index in the Tracks table + int negativeId; // track index in the Tracks table + int bachelorId; // track index in the Tracks table + + float dcaV0dau; + float dcacascdau; + float v0radius; + float cascradius; + float cascradiusMC; + + // for tracking + int findableClusters; + int foundClusters; + + float mLambda; + float mXi; }; + cascadecandidate thisCascade; // necessary for particle charges Service pdgDB; @@ -130,12 +223,24 @@ 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; std::vector bcData; o2::steer::InteractionSampler irSampler; o2::vertexing::PVertexer vertexer; + std::vector cascadesAlice3; + + // For TGenPhaseSpace seed + TRandom3 rand; void init(o2::framework::InitContext&) { @@ -180,31 +285,76 @@ struct OnTheFlyTracker { } // Basic QA - histos.add("hPtGenerated", "hPtGenerated", kTH1F, {axisMomentum}); - histos.add("hPtGeneratedEl", "hPtGeneratedEl", kTH1F, {axisMomentum}); - histos.add("hPtGeneratedPi", "hPtGeneratedPi", kTH1F, {axisMomentum}); - histos.add("hPtGeneratedKa", "hPtGeneratedKa", kTH1F, {axisMomentum}); - histos.add("hPtGeneratedPr", "hPtGeneratedPr", kTH1F, {axisMomentum}); - histos.add("hPtReconstructed", "hPtReconstructed", kTH1F, {axisMomentum}); - histos.add("hPtReconstructedEl", "hPtReconstructedEl", kTH1F, {axisMomentum}); - histos.add("hPtReconstructedPi", "hPtReconstructedPi", kTH1F, {axisMomentum}); - histos.add("hPtReconstructedKa", "hPtReconstructedKa", kTH1F, {axisMomentum}); - histos.add("hPtReconstructedPr", "hPtReconstructedPr", kTH1F, {axisMomentum}); + auto hNaN = histos.add("hNaNBookkeeping", "hNaNBookkeeping", kTH2F, {{10, -0.5f, 9.5f}, {10, -0.5f, 9.5f}}); + + hNaN->GetXaxis()->SetBinLabel(1, "Primary"); + hNaN->GetXaxis()->SetBinLabel(2, "Bachelor"); + hNaN->GetXaxis()->SetBinLabel(3, "Pi from La"); + hNaN->GetXaxis()->SetBinLabel(4, "Pr from La"); + + hNaN->GetYaxis()->SetBinLabel(1, "Smear NaN"); + hNaN->GetYaxis()->SetBinLabel(2, "Smear OK"); + + auto hCovMatOK = histos.add("hCovMatOK", "hCovMatOK", kTH1D, {{2, -0.5f, 1.5f}}); + hCovMatOK->GetXaxis()->SetBinLabel(1, "Not OK"); + hCovMatOK->GetXaxis()->SetBinLabel(2, "OK"); + + histos.add("hPtGenerated", "hPtGenerated", kTH1F, {axes.axisMomentum}); + histos.add("hPtGeneratedEl", "hPtGeneratedEl", kTH1F, {axes.axisMomentum}); + histos.add("hPtGeneratedPi", "hPtGeneratedPi", kTH1F, {axes.axisMomentum}); + histos.add("hPtGeneratedKa", "hPtGeneratedKa", kTH1F, {axes.axisMomentum}); + histos.add("hPtGeneratedPr", "hPtGeneratedPr", kTH1F, {axes.axisMomentum}); + histos.add("hPtReconstructed", "hPtReconstructed", kTH1F, {axes.axisMomentum}); + histos.add("hPtReconstructedEl", "hPtReconstructedEl", kTH1F, {axes.axisMomentum}); + histos.add("hPtReconstructedPi", "hPtReconstructedPi", kTH1F, {axes.axisMomentum}); + histos.add("hPtReconstructedKa", "hPtReconstructedKa", kTH1F, {axes.axisMomentum}); + histos.add("hPtReconstructedPr", "hPtReconstructedPr", kTH1F, {axes.axisMomentum}); // Collision QA - histos.add("hPVz", "hPVz", kTH1F, {axisVertexZ}); - histos.add("hLUTMultiplicity", "hLUTMultiplicity", kTH1F, {axisMultiplicity}); - histos.add("hSimMultiplicity", "hSimMultiplicity", kTH1F, {axisMultiplicity}); - histos.add("hRecoMultiplicity", "hRecoMultiplicity", kTH1F, {axisMultiplicity}); + histos.add("hPVz", "hPVz", kTH1F, {axes.axisVertexZ}); + histos.add("hLUTMultiplicity", "hLUTMultiplicity", kTH1F, {axes.axisMultiplicity}); + histos.add("hSimMultiplicity", "hSimMultiplicity", kTH1F, {axes.axisMultiplicity}); + histos.add("hRecoMultiplicity", "hRecoMultiplicity", kTH1F, {axes.axisMultiplicity}); if (doExtraQA) { - histos.add("h2dVerticesVsContributors", "h2dVerticesVsContributors", kTH2F, {axisMultiplicity, axisNVertices}); - histos.add("hRecoVsSimMultiplicity", "hRecoVsSimMultiplicity", kTH2F, {axisMultiplicity, axisMultiplicity}); - histos.add("h2dDCAxy", "h2dDCAxy", kTH2F, {axisMomentum, axisDCA}); + 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("hSimTrackX", "hSimTrackX", kTH1F, {axisX}); - histos.add("hRecoTrackX", "hRecoTrackX", kTH1F, {axisX}); - histos.add("hTrackXatDCA", "hTrackXatDCA", kTH1F, {axisX}); + histos.add("hSimTrackX", "hSimTrackX", kTH1F, {axes.axisX}); + histos.add("hRecoTrackX", "hRecoTrackX", kTH1F, {axes.axisX}); + histos.add("hTrackXatDCA", "hTrackXatDCA", kTH1F, {axes.axisX}); + } + + if (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("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}); + + // basic mass histograms to see if we're in business + histos.add("hMassLambda", "hMassLambda", kTH1F, {axes.axisLambdaMass}); + histos.add("hMassXi", "hMassXi", kTH1F, {axes.axisXiMass}); + + // OTF strangeness tracking QA + histos.add("hFoundVsFindable", "hFoundVsFindable", kTH2F, {{10, -0.5f, 9.5f}, {10, -0.5f, 9.5f}}); + + histos.add("h2dDCAxyCascade", "h2dDCAxyCascade", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAxyCascadeBachelor", "h2dDCAxyCascadeBachelor", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAxyCascadeNegative", "h2dDCAxyCascadeNegative", kTH2F, {axes.axisMomentum, axes.axisDCA}); + histos.add("h2dDCAxyCascadePositive", "h2dDCAxyCascadePositive", 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}); } LOGF(info, "Initializing magnetic field to value: %.3f kG", static_cast(magneticField)); @@ -237,6 +387,110 @@ struct OnTheFlyTracker { vertexer.setValidateWithIR(kFALSE); vertexer.setBunchFilling(irSampler.getBunchFilling()); vertexer.init(); + + // initialize O2 2-prong fitter + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxDXYIni(4); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + fitter.setWeightedFinalPCA(false); + fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrNONE); // such a light detector here + + // Set seed for TGenPhaseSpace + rand.SetSeed(seed); + + // configure FastTracker + fastTracker.magneticField = magneticField; + fastTracker.applyZacceptance = fastTrackerSettings.applyZacceptance; + + if (fastTrackerSettings.alice3detector == 0) { + fastTracker.AddSiliconALICE3v1(); + } + if (fastTrackerSettings.alice3detector == 1) { + fastTracker.AddSiliconALICE3v4(); + fastTracker.AddTPC(0.1, 0.1); + } + + // print fastTracker settings + fastTracker.Print(); + } + + /// Function to decay the xi + /// \param particle the particle to decay + /// \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 + template + void decayParticle(McParticleType particle, o2::track::TrackParCov track, std::vector& decayDaughters, std::vector& xiDecayVertex, std::vector& l0DecayVertex) + { + double u = rand.Uniform(0, 1); + double xi_ctau = 4.91; // xi + double xi_rxyz = (-xi_ctau * log(1 - u)); + float sna, csa; + o2::math_utils::CircleXYf_t xi_circle; + track.getCircleParams(magneticField, xi_circle, sna, csa); + double xi_rxy = xi_rxyz / sqrt(1. + track.getTgl() * track.getTgl()); + double theta = xi_rxy / xi_circle.rC; + double newX = ((particle.vx() - xi_circle.xC) * std::cos(theta) - (particle.vy() - xi_circle.yC) * std::sin(theta)) + xi_circle.xC; + double newY = ((particle.vy() - xi_circle.yC) * std::cos(theta) + (particle.vx() - xi_circle.xC) * std::sin(theta)) + xi_circle.yC; + double newPx = particle.px() * std::cos(theta) - particle.py() * std::sin(theta); + double newPy = particle.py() * std::cos(theta) + particle.px() * std::sin(theta); + xiDecayVertex.push_back(newX); + xiDecayVertex.push_back(newY); + xiDecayVertex.push_back(particle.vz() + xi_rxyz * (particle.pz() / particle.p())); + + std::vector xiDaughters = {1.115, 0.139570}; + 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 @@ -268,9 +522,12 @@ struct OnTheFlyTracker { float dNdEta = 0.f; // Charged particle multiplicity to use in the efficiency evaluation void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) { + int lastTrackIndex = tracksParCov.lastIndex() + 1; // bookkeep the last added track + tracksAlice3.clear(); ghostTracksAlice3.clear(); bcData.clear(); + cascadesAlice3.clear(); o2::dataformats::DCA dcaInfo; o2::dataformats::VertexBase vtx; @@ -289,7 +546,11 @@ struct OnTheFlyTracker { } const auto pdg = std::abs(mcParticle.pdgCode()); if (pdg != kElectron && pdg != kMuonMinus && pdg != kPiPlus && pdg != kKPlus && pdg != kProton) { - continue; + if (!treatXi) { + continue; + } else if (pdg != 3312) { + continue; + } } const auto& pdgInfo = pdgDB->GetParticle(mcParticle.pdgCode()); if (!pdgInfo) { @@ -305,14 +566,38 @@ struct OnTheFlyTracker { dNdEta /= (multEtaRange * 2.0f); uint32_t multiplicityCounter = 0; histos.fill(HIST("hLUTMultiplicity"), dNdEta); + gRandom->SetSeed(seed); for (const auto& mcParticle : mcParticles) { - if (!mcParticle.isPhysicalPrimary()) { - continue; + double xiDecayRadius2D = 0; + double l0DecayRadius2D = 0; + std::vector decayProducts; + std::vector xiDecayVertex, l0DecayVertex; + std::vector layers = {0.50, 1.20, 2.50, 3.75, 7.00, 12.0, 20.0}; + if (treatXi) { + if (mcParticle.pdgCode() == 3312) { + o2::track::TrackParCov xiTrackParCov; + convertMCParticleToO2Track(mcParticle, xiTrackParCov); + decayParticle(mcParticle, xiTrackParCov, decayProducts, xiDecayVertex, l0DecayVertex); + xiDecayRadius2D = sqrt(xiDecayVertex[0] * xiDecayVertex[0] + xiDecayVertex[1] * xiDecayVertex[1]); + l0DecayRadius2D = sqrt(l0DecayVertex[0] * l0DecayVertex[0] + l0DecayVertex[1] * l0DecayVertex[1]); + } } + const auto pdg = std::abs(mcParticle.pdgCode()); + if (!mcParticle.isPhysicalPrimary()) { + if (!treatXi) { + continue; + } else if (pdg != 3312) { + continue; + } + } if (pdg != kElectron && pdg != kMuonMinus && pdg != kPiPlus && pdg != kKPlus && pdg != kProton) { - continue; + if (!treatXi) { + continue; + } else if (pdg != 3312) { + continue; + } } if (std::fabs(mcParticle.eta()) > maxEta) { continue; @@ -328,29 +613,291 @@ struct OnTheFlyTracker { if (TMath::Abs(mcParticle.pdgCode()) == 2212) histos.fill(HIST("hPtGeneratedPr"), mcParticle.pt()); + if (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()); + } + if (mcParticle.pt() < minPt) { continue; } + o2::track::TrackParCov trackParCov; + convertMCParticleToO2Track(mcParticle, trackParCov); + bool isDecayDaughter = false; if (mcParticle.getProcess() == 4) isDecayDaughter = true; multiplicityCounter++; - o2::track::TrackParCov trackParCov; - convertMCParticleToO2Track(mcParticle, trackParCov); + const float t = (ir.timeInBCNS + 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 (xiDecayRadius2D > 20) { + continue; + } + + convertTLorentzVectorToO2Track(-211, decayProducts[0], xiDecayVertex, xiDaughterTrackParCovsPerfect[0]); + convertTLorentzVectorToO2Track(-211, decayProducts[1], l0DecayVertex, xiDaughterTrackParCovsPerfect[1]); + convertTLorentzVectorToO2Track(2212, decayProducts[2], l0DecayVertex, xiDaughterTrackParCovsPerfect[2]); + + for (int i = 0; i < 3; i++) { + isReco[i] = false; + nHits[i] = 0; + nSiliconHits[i] = 0; + nTPCHits[i] = 0; + if (enableSecondarySmearing) { + + nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i]); + nSiliconHits[i] = fastTracker.nSiliconPoints; + nTPCHits[i] = fastTracker.nGasPoints; + + 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])); + } + } else { + isReco[i] = true; + xiDaughterTrackParCovsTracked[i] = xiDaughterTrackParCovsPerfect[i]; + } + + if (TMath::IsNaN(xiDaughterTrackParCovsTracked[i].getZ())) { + continue; + } else { + histos.fill(HIST("hNaNBookkeeping"), i + 1, 1.0f); + } + if (isReco[i]) { + tracksAlice3.push_back(TrackAlice3{xiDaughterTrackParCovsTracked[i], mcParticle.globalIndex(), t, 100.f * 1e-3, true, true, i + 2, nSiliconHits[i], nTPCHits[i]}); + } else { + ghostTracksAlice3.push_back(TrackAlice3{xiDaughterTrackParCovsTracked[i], mcParticle.globalIndex(), t, 100.f * 1e-3, true, true, i + 2}); + } + } + + if (doXiQA && mcParticle.pdgCode() == 3312) { + if (isReco[0] && isReco[1] && isReco[2]) { + histos.fill(HIST("hXiBuilding"), 2.0f); + histos.fill(HIST("hRecoXi"), xiDecayRadius2D, mcParticle.pt()); + } + if (isReco[0]) + histos.fill(HIST("hRecoPiFromXi"), xiDecayRadius2D, decayProducts[0].Pt()); + if (isReco[1]) + histos.fill(HIST("hRecoPiFromL0"), l0DecayRadius2D, decayProducts[1].Pt()); + if (isReco[2]) + histos.fill(HIST("hRecoPrFromL0"), l0DecayRadius2D, 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); + // assign indices of the particles we've used + // they should be the last ones to be filled, in order: + // n-1: proton from lambda + // n-2: pion from lambda + // n-3: pion from xi + thisCascade.positiveId = lastTrackIndex + tracksAlice3.size() - 1; + thisCascade.negativeId = lastTrackIndex + tracksAlice3.size() - 2; + thisCascade.bachelorId = lastTrackIndex + tracksAlice3.size() - 3; + + // use DCA fitters + int nCand = 0; + bool dcaFitterOK_V0 = true; + try { + nCand = fitter.process(xiDaughterTrackParCovsTracked[1], xiDaughterTrackParCovsTracked[2]); + } catch (...) { + // LOG(error) << "Exception caught in DCA fitter process call!"; + dcaFitterOK_V0 = false; + } + if (nCand == 0) { + dcaFitterOK_V0 = false; + } + // V0 found successfully + if (dcaFitterOK_V0) { + histos.fill(HIST("hXiBuilding"), 4.0f); + std::array pos; + std::array posCascade; + std::array posP; + std::array negP; + std::array bachP; + + o2::track::TrackParCov pTrackAtPCA = fitter.getTrack(1); // proton (positive) + o2::track::TrackParCov nTrackAtPCA = fitter.getTrack(0); // pion (negative) + pTrackAtPCA.getPxPyPzGlo(posP); + nTrackAtPCA.getPxPyPzGlo(negP); + + // get decay vertex coordinates + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + pos[i] = vtx[i]; + } + + // calculate basic V0 properties here + // DCA to PV taken care of in daughter tracks already, not necessary + thisCascade.dcaV0dau = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + thisCascade.v0radius = std::hypot(pos[0], pos[1]); + thisCascade.mLambda = RecoDecay::m(array{array{posP[0], posP[1], posP[2]}, array{negP[0], negP[1], negP[2]}}, array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); + + // go for cascade: create V0 (pseudo)track from reconstructed V0 + 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]] = 1e-6; + covV[i] = 1e-6; + } + o2::track::TrackParCov v0Track = o2::track::TrackParCov( + {pos[0], pos[1], pos[2]}, + {posP[0] + negP[0], posP[1] + negP[1], posP[2] + negP[2]}, + covV, 0, true); + v0Track.setAbsCharge(0); + v0Track.setPID(o2::track::PID::Lambda); + + // dca fitter step + nCand = 0; + bool dcaFitterOK_Cascade = true; + try { + nCand = fitter.process(v0Track, xiDaughterTrackParCovsTracked[0]); + } catch (...) { + // LOG(error) << "Exception caught in DCA fitter process call!"; + dcaFitterOK_Cascade = false; + } + if (nCand == 0) { + dcaFitterOK_Cascade = false; + } + + // Cascade found successfully + if (dcaFitterOK_Cascade) { + histos.fill(HIST("hXiBuilding"), 5.0f); + o2::track::TrackParCov bachelorTrackAtPCA = fitter.getTrack(1); + + const auto& vtxCascade = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + posCascade[i] = vtxCascade[i]; + } + + // basic properties of the cascade + thisCascade.dcacascdau = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + thisCascade.cascradius = std::hypot(posCascade[0], posCascade[1]); + bachelorTrackAtPCA.getPxPyPzGlo(bachP); + + thisCascade.mXi = RecoDecay::m(array{array{bachP[0], bachP[1], bachP[2]}, array{posP[0] + negP[0], posP[1] + negP[1], posP[2] + negP[2]}}, array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassLambda}); + + // initialize cascade track + o2::track::TrackParCov cascadeTrack = fitter.createParentTrackParCov(); + cascadeTrack.setAbsCharge(-1); // may require more adjustments + cascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas + + thisCascade.cascradiusMC = xiDecayRadius2D; + thisCascade.findableClusters = 0; + thisCascade.foundClusters = 0; + + if (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--) { + if (thisCascade.cascradiusMC > layers[i]) { + // will add this layer, since cascade decayed after the corresponding radius + thisCascade.findableClusters++; // add to findable + + // find perfect intercept XYZ + float targetX = 1e+3; + trackParCov.getXatLabR(layers[i], targetX, magneticField); + if (targetX > 999) + continue; // failed to find intercept + + if (!trackParCov.propagateTo(targetX, magneticField)) { + continue; // failed to propagate + } + + // get potential cluster position + 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}; + + if (pixelResolution > 1e-8) { // catch zero (though should not really happen...) + phi = gRandom->Gaus(phi, std::asin(pixelResolution / r)); + posClusterCandidate[0] = r * std::cos(phi); + posClusterCandidate[1] = r * std::sin(phi); + posClusterCandidate[2] = gRandom->Gaus(posClusterCandidate[2], pixelResolution); + } + + // towards adding cluster: move to track alpha + double alpha = cascadeTrack.getAlpha(); + double xyz1[3]{ + TMath::Cos(alpha) * posClusterCandidate[0] + TMath::Sin(alpha) * posClusterCandidate[1], + -TMath::Sin(alpha) * posClusterCandidate[0] + TMath::Cos(alpha) * posClusterCandidate[1], + posClusterCandidate[2]}; + + if (!(cascadeTrack.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 = {pixelResolution * pixelResolution, 0.f, pixelResolution * pixelResolution}; + cascadeTrack.update(hitpoint, hitpointcov); + thisCascade.foundClusters++; // add to findable + } + } + } + + // 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) { + histos.fill(HIST("h2dDeltaPtVsPt"), trackParCov.getPt(), cascadeTrack.getPt() - trackParCov.getPt()); + histos.fill(HIST("h2dDeltaEtaVsPt"), trackParCov.getPt(), cascadeTrack.getEta() - trackParCov.getEta()); + + histos.fill(HIST("hMassLambda"), thisCascade.mLambda); + histos.fill(HIST("hMassXi"), thisCascade.mXi); + histos.fill(HIST("hFoundVsFindable"), thisCascade.findableClusters, thisCascade.foundClusters); + } + + // add this cascade to vector (will fill cursor later with collision ID) + cascadesAlice3.push_back(thisCascade); + } + } + } // end cascade building + // +-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+-~-+ + + continue; // Not filling the tables with the xi itself + } if (doExtraQA) { histos.fill(HIST("hSimTrackX"), trackParCov.getX()); } - bool reconstructed = mSmearer.smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta); + bool reconstructed = true; + if (enablePrimarySmearing) { + reconstructed = mSmearer.smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta); + } + if (!reconstructed && !processUnreconstructedTracks) { continue; } if (TMath::IsNaN(trackParCov.getZ())) { // capture rare smearing mistakes / corrupted tracks + histos.fill(HIST("hNaNBookkeeping"), 0.0f, 0.0f); continue; + } else { + histos.fill(HIST("hNaNBookkeeping"), 0.0f, 1.0f); // ok! } // Base QA (note: reco pT here) @@ -369,7 +916,6 @@ struct OnTheFlyTracker { } // populate vector with track if we reco-ed it - const float t = (ir.timeInBCNS + gRandom->Gaus(0., 100.)) * 1e-3; if (reconstructed) { tracksAlice3.push_back(TrackAlice3{trackParCov, mcParticle.globalIndex(), t, 100.f * 1e-3, isDecayDaughter}); } else { @@ -465,6 +1011,16 @@ struct OnTheFlyTracker { histos.fill(HIST("h2dDCAxy"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please histos.fill(HIST("hTrackXatDCA"), trackParametrization.getX()); } + if (doXiQA) { + if (trackParCov.isUsedInCascading == 1) + histos.fill(HIST("h2dDCAxyCascade"), trackParametrization.getPt(), dcaXY * 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("h2dDCAxyCascadeNegative"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please + if (trackParCov.isUsedInCascading == 4) + histos.fill(HIST("h2dDCAxyCascadePositive"), trackParametrization.getPt(), dcaXY * 1e+4); // in microns, please + } tracksDCA(dcaXY, dcaZ); if (populateTracksDCACov) { tracksDCACov(dcaInfo.getSigmaY2(), dcaInfo.getSigmaZ2()); @@ -481,6 +1037,7 @@ struct OnTheFlyTracker { trackParCov.getSigmaTgl2(), trackParCov.getSigma1PtY(), trackParCov.getSigma1PtZ(), trackParCov.getSigma1PtSnp(), trackParCov.getSigma1PtTgl(), trackParCov.getSigma1Pt2()); tracksLabels(trackParCov.mcLabel, 0); + TracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits); // populate extra tables if required to do so if (populateTracksExtra) { @@ -528,6 +1085,7 @@ struct OnTheFlyTracker { trackParCov.getSigmaTgl2(), trackParCov.getSigma1PtY(), trackParCov.getSigma1PtZ(), trackParCov.getSigma1PtSnp(), trackParCov.getSigma1PtTgl(), trackParCov.getSigma1Pt2()); tracksLabels(trackParCov.mcLabel, 0); + TracksExtraA3(trackParCov.nSiliconHits, trackParCov.nTPCHits); // populate extra tables if required to do so if (populateTracksExtra) { @@ -542,7 +1100,30 @@ struct OnTheFlyTracker { } TracksAlice3(false); } - } + + for (const auto& cascade : cascadesAlice3) { + upgradeCascades( + collisions.lastIndex(), // now we know the collision index -> populate table + cascade.cascadeTrackId, + cascade.positiveId, + cascade.negativeId, + cascade.bachelorId, + cascade.dcaV0dau, + cascade.dcacascdau, + cascade.v0radius, + cascade.cascradius, + cascade.cascradiusMC, + cascade.mLambda, + cascade.mXi, + cascade.findableClusters, + cascade.foundClusters); + } + + // do bookkeeping of fastTracker tracking + histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.covMatNotOK); + histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.covMatOK); + + } // end process }; /// Extends TracksExtra if necessary diff --git a/ALICE3/TableProducer/alice3-decayfinder.cxx b/ALICE3/TableProducer/alice3-decayfinder.cxx index 80b9de80238..4b88305fb60 100644 --- a/ALICE3/TableProducer/alice3-decayfinder.cxx +++ b/ALICE3/TableProducer/alice3-decayfinder.cxx @@ -65,149 +65,6 @@ using tofTracks = soa::Join; using richTracks = soa::Join; using alice3tracks = soa::Join; -struct alice3decayPreselector { - Produces a3decayMaps; - - // Operation and minimisation criteria - Configurable nSigmaTOF{"nSigmaTOF", 4.0f, "Nsigma for TOF PID (if enabled)"}; - Configurable nSigmaRICH{"nSigmaRICH", 4.0f, "Nsigma for RICH PID (if enabled)"}; - - // Define o2 fitter, 2-prong, active memory (no need to redefine per event) - o2::vertexing::DCAFitterN<2> fitter; - - // for bit-packed maps - std::vector selectionMap; - - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - /// function to check PDG + PDG mother - template - bool checkPDG(TTrack const& track, int pdgMother, int pdg) - { - bool returnValue = false; - // Association check - if (track.has_mcParticle()) { - auto mcParticle = track.template mcParticle_as(); - if (mcParticle.has_mothers()) { - for (auto& mcParticleMother : mcParticle.template mothers_as()) { - if (mcParticle.pdgCode() == pdg && mcParticleMother.pdgCode() == pdgMother) - returnValue = true; - } - } - } // end association check - return returnValue; - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - - void init(InitContext&) - { - // future dev if needed - } - - // go declarative: use partitions instead of "if", then just toggle bits to allow for mask selection later - Partition pInnerTOFPi = nabs(aod::upgrade_tof::nSigmaPionInnerTOF) > nSigmaTOF; - Partition pInnerTOFKa = nabs(aod::upgrade_tof::nSigmaKaonInnerTOF) > nSigmaTOF; - Partition pInnerTOFPr = nabs(aod::upgrade_tof::nSigmaProtonInnerTOF) > nSigmaTOF; - 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; - - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - /// Initialization of mask vectors if uninitialized - void initializeMasks(int size) - { - selectionMap.clear(); - selectionMap.resize(size, 0xFFFFFFFF); // all bits 1, please - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - /// This process function ensures that all V0s are built. It will simply tag everything as true. - void processInitialize(aod::Tracks const& tracks) - { - initializeMasks(tracks.size()); - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processFilterInnerTOF(tofTracks const&) - { - for (auto const& track : pInnerTOFPi) - bitoff(selectionMap[track.globalIndex()], kInnerTOFPion); - for (auto const& track : pInnerTOFKa) - bitoff(selectionMap[track.globalIndex()], kInnerTOFKaon); - for (auto const& track : pInnerTOFPr) - bitoff(selectionMap[track.globalIndex()], kInnerTOFProton); - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processFilterOuterTOF(tofTracks const&) - { - for (auto const& track : pOuterTOFPi) - bitoff(selectionMap[track.globalIndex()], kOuterTOFPion); - for (auto const& track : pOuterTOFKa) - bitoff(selectionMap[track.globalIndex()], kOuterTOFKaon); - for (auto const& track : pOuterTOFPr) - bitoff(selectionMap[track.globalIndex()], kOuterTOFProton); - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processFilterRICH(richTracks const&) - { - for (auto const& track : pRICHPi) - bitoff(selectionMap[track.globalIndex()], kRICHPion); - for (auto const& track : pRICHKa) - bitoff(selectionMap[track.globalIndex()], kRICHKaon); - for (auto const& track : pRICHPr) - bitoff(selectionMap[track.globalIndex()], kRICHProton); - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processFilterOnMonteCarloTruth(labeledTracks const& tracks, aod::McParticles const&) - { - for (auto const& track : tracks) { - // D mesons - if (!checkPDG(track, 421, -321)) //+421 -> -321 +211 - bitoff(selectionMap[track.globalIndex()], kTrueKaMinusFromD); - if (!checkPDG(track, -421, +321)) //-421 -> +321 -211 - bitoff(selectionMap[track.globalIndex()], kTrueKaPlusFromD); - if (!checkPDG(track, 421, +211)) //+421 -> -321 +211 - bitoff(selectionMap[track.globalIndex()], kTruePiPlusFromD); - if (!checkPDG(track, -421, -211)) //-421 -> +321 -211 - bitoff(selectionMap[track.globalIndex()], kTruePiMinusFromD); - - // Lambdac baryons - if (!checkPDG(track, +4122, +2212)) //+4122 -> +2212 -321 +211 - bitoff(selectionMap[track.globalIndex()], kTruePrPlusFromLc); - if (!checkPDG(track, +4122, -321)) //+4122 -> +2212 -321 +211 - bitoff(selectionMap[track.globalIndex()], kTrueKaMinusFromLc); - if (!checkPDG(track, +4122, +211)) //+4122 -> +2212 -321 +211 - bitoff(selectionMap[track.globalIndex()], kTruePiPlusFromLc); - if (!checkPDG(track, -4122, -2212)) //-4122 -> -2212 +321 -211 - bitoff(selectionMap[track.globalIndex()], kTruePrMinusFromLc); - if (!checkPDG(track, -4122, +321)) //-4122 -> -2212 +321 -211 - bitoff(selectionMap[track.globalIndex()], kTrueKaPlusFromLc); - if (!checkPDG(track, -4122, -211)) //-4122 -> -2212 +321 -211 - bitoff(selectionMap[track.globalIndex()], kTruePiMinusFromLc); - } - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void processPublishDecision(aod::Tracks const& tracks) - { - for (uint32_t i = 0; i < tracks.size(); i++) { - a3decayMaps(selectionMap[i]); - } - selectionMap.clear(); - } - //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - - //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* - PROCESS_SWITCH(alice3decayPreselector, processInitialize, "Initialize (MUST be on)", true); - PROCESS_SWITCH(alice3decayPreselector, processFilterInnerTOF, "Switch to use inner TOF PID", false); - PROCESS_SWITCH(alice3decayPreselector, processFilterOuterTOF, "Switch to use outer TOF PID", false); - PROCESS_SWITCH(alice3decayPreselector, processFilterRICH, "Switch to use RICH", false); - PROCESS_SWITCH(alice3decayPreselector, processFilterOnMonteCarloTruth, "Switch to use MC truth", false); - PROCESS_SWITCH(alice3decayPreselector, processPublishDecision, "Fill decision mask table (MUST be on)", true); - //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* -}; - struct alice3decayFinder { SliceCache cache; @@ -355,9 +212,9 @@ struct alice3decayFinder { } //}-{}-{}-{}-{}-{}-{}-{}-{}-{} - t0 = fitter.getTrack(0); - t1 = fitter.getTrack(1); - t2 = fitter.getTrack(2); + t0 = fitter3.getTrack(0); + t1 = fitter3.getTrack(1); + t2 = fitter3.getTrack(2); std::array P0; std::array P1; std::array P2; @@ -593,6 +450,5 @@ struct alice3decayFinder { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc)}; } diff --git a/ALICE3/TableProducer/alice3-decaypreselector.cxx b/ALICE3/TableProducer/alice3-decaypreselector.cxx new file mode 100644 index 00000000000..66569360db9 --- /dev/null +++ b/ALICE3/TableProducer/alice3-decaypreselector.cxx @@ -0,0 +1,222 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +#include +#include +#include +#include +#include + +#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 "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/TrackSelectionTables.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsCalibration/MeanVertexObject.h" +#include "ALICE3/DataModel/OTFTOF.h" +#include "ALICE3/DataModel/RICH.h" +#include "ALICE3/DataModel/A3DecayFinderTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +// simple checkers +// #define biton(var, nbit) ((var) |= (static_cast(1) << (nbit))) +#define bitoff(var, nbit) ((var) &= ~(static_cast(1) << (nbit))) //((a) &= ~(1ULL<<(b))) +// #define bitcheck(var, nbit) ((var) & (static_cast(1) << (nbit))) + +using FullTracksExt = soa::Join; + +// For MC association in pre-selection +using labeledTracks = soa::Join; +using tofTracks = soa::Join; +using richTracks = soa::Join; + +struct alice3decaypreselector { + Produces a3decayMaps; + + // Operation and minimisation criteria + Configurable nSigmaTOF{"nSigmaTOF", 4.0f, "Nsigma for TOF PID (if enabled)"}; + Configurable nSigmaRICH{"nSigmaRICH", 4.0f, "Nsigma for RICH PID (if enabled)"}; + + // Define o2 fitter, 2-prong, active memory (no need to redefine per event) + o2::vertexing::DCAFitterN<2> fitter; + + // for bit-packed maps + std::vector selectionMap; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + /// function to check PDG + PDG mother + template + bool checkPDG(TTrack const& track, int pdgMother, int pdg) + { + bool returnValue = false; + // Association check + if (track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + if (mcParticle.has_mothers()) { + for (auto& mcParticleMother : mcParticle.template mothers_as()) { + if (mcParticle.pdgCode() == pdg && mcParticleMother.pdgCode() == pdgMother) + returnValue = true; + } + } + } // end association check + return returnValue; + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + + void init(InitContext&) + { + // future dev if needed + } + + // go declarative: use partitions instead of "if", then just toggle bits to allow for mask selection later + Partition pInnerTOFPi = nabs(aod::upgrade_tof::nSigmaPionInnerTOF) > nSigmaTOF; + Partition pInnerTOFKa = nabs(aod::upgrade_tof::nSigmaKaonInnerTOF) > nSigmaTOF; + Partition pInnerTOFPr = nabs(aod::upgrade_tof::nSigmaProtonInnerTOF) > nSigmaTOF; + 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; + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + /// Initialization of mask vectors if uninitialized + void initializeMasks(int size) + { + selectionMap.clear(); + selectionMap.resize(size, 0xFFFFFFFF); // all bits 1, please + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + /// This process function ensures that all V0s are built. It will simply tag everything as true. + void processInitialize(aod::Tracks const& tracks) + { + initializeMasks(tracks.size()); + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processFilterInnerTOF(tofTracks const&) + { + for (auto const& track : pInnerTOFPi) + bitoff(selectionMap[track.globalIndex()], kInnerTOFPion); + for (auto const& track : pInnerTOFKa) + bitoff(selectionMap[track.globalIndex()], kInnerTOFKaon); + for (auto const& track : pInnerTOFPr) + bitoff(selectionMap[track.globalIndex()], kInnerTOFProton); + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processFilterOuterTOF(tofTracks const&) + { + for (auto const& track : pOuterTOFPi) + bitoff(selectionMap[track.globalIndex()], kOuterTOFPion); + for (auto const& track : pOuterTOFKa) + bitoff(selectionMap[track.globalIndex()], kOuterTOFKaon); + for (auto const& track : pOuterTOFPr) + bitoff(selectionMap[track.globalIndex()], kOuterTOFProton); + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processFilterRICH(richTracks const&) + { + for (auto const& track : pRICHPi) + bitoff(selectionMap[track.globalIndex()], kRICHPion); + for (auto const& track : pRICHKa) + bitoff(selectionMap[track.globalIndex()], kRICHKaon); + for (auto const& track : pRICHPr) + bitoff(selectionMap[track.globalIndex()], kRICHProton); + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processFilterOnMonteCarloTruth(labeledTracks const& tracks, aod::McParticles const&) + { + for (auto const& track : tracks) { + // D mesons + if (!checkPDG(track, 421, -321)) //+421 -> -321 +211 + bitoff(selectionMap[track.globalIndex()], kTrueKaMinusFromD); + if (!checkPDG(track, -421, +321)) //-421 -> +321 -211 + bitoff(selectionMap[track.globalIndex()], kTrueKaPlusFromD); + if (!checkPDG(track, 421, +211)) //+421 -> -321 +211 + bitoff(selectionMap[track.globalIndex()], kTruePiPlusFromD); + if (!checkPDG(track, -421, -211)) //-421 -> +321 -211 + bitoff(selectionMap[track.globalIndex()], kTruePiMinusFromD); + + // Lambdac baryons + if (!checkPDG(track, +4122, +2212)) //+4122 -> +2212 -321 +211 + bitoff(selectionMap[track.globalIndex()], kTruePrPlusFromLc); + if (!checkPDG(track, +4122, -321)) //+4122 -> +2212 -321 +211 + bitoff(selectionMap[track.globalIndex()], kTrueKaMinusFromLc); + if (!checkPDG(track, +4122, +211)) //+4122 -> +2212 -321 +211 + bitoff(selectionMap[track.globalIndex()], kTruePiPlusFromLc); + if (!checkPDG(track, -4122, -2212)) //-4122 -> -2212 +321 -211 + bitoff(selectionMap[track.globalIndex()], kTruePrMinusFromLc); + if (!checkPDG(track, -4122, +321)) //-4122 -> -2212 +321 -211 + bitoff(selectionMap[track.globalIndex()], kTrueKaPlusFromLc); + if (!checkPDG(track, -4122, -211)) //-4122 -> -2212 +321 -211 + bitoff(selectionMap[track.globalIndex()], kTruePiMinusFromLc); + + // XiCC daughters + if (!checkPDG(track, 4422, 211)) // 4422 -> 4232 211, pi from xicc + bitoff(selectionMap[track.globalIndex()], kTruePiFromXiCC); + if (!checkPDG(track, 4232, 3312)) // 4232 -> 3312 211 211, xi from xic + bitoff(selectionMap[track.globalIndex()], kTrueXiFromXiC); + if (!checkPDG(track, 4232, 211)) // 4232 -> 3312 211 211, pi from xic + bitoff(selectionMap[track.globalIndex()], kTruePiFromXiC); + } + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processPublishDecision(aod::Tracks const& tracks) + { + for (uint32_t i = 0; i < tracks.size(); i++) { + a3decayMaps(selectionMap[i]); + } + selectionMap.clear(); + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + + //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* + PROCESS_SWITCH(alice3decaypreselector, processInitialize, "Initialize (MUST be on)", true); + PROCESS_SWITCH(alice3decaypreselector, processFilterInnerTOF, "Switch to use inner TOF PID", false); + PROCESS_SWITCH(alice3decaypreselector, processFilterOuterTOF, "Switch to use outer TOF PID", false); + PROCESS_SWITCH(alice3decaypreselector, processFilterRICH, "Switch to use RICH", false); + PROCESS_SWITCH(alice3decaypreselector, processFilterOnMonteCarloTruth, "Switch to use MC truth", false); + PROCESS_SWITCH(alice3decaypreselector, processPublishDecision, "Fill decision mask table (MUST be on)", true); + //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/ALICE3/TableProducer/alice3-multicharm.cxx b/ALICE3/TableProducer/alice3-multicharm.cxx new file mode 100644 index 00000000000..71be5256362 --- /dev/null +++ b/ALICE3/TableProducer/alice3-multicharm.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. +// +// *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* +// 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 +#include +#include +#include +#include +#include + +#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 "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/TrackSelectionTables.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/BasicCCDBManager.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 "DetectorsVertexing/PVertexer.h" +#include "DetectorsVertexing/PVertexerHelpers.h" +#include "CommonConstants/PhysicsConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +// simple checkers +// #define biton(var, nbit) ((var) |= (static_cast(1) << (nbit))) +#define bitoff(var, nbit) ((var) &= ~(static_cast(1) << (nbit))) //((a) &= ~(1ULL<<(b))) +#define bitcheck(var, nbit) ((var) & (static_cast(1) << (nbit))) + +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; + +struct alice3multicharm { + SliceCache cache; + + Produces multiCharmIdx; + Produces multiCharmCore; + + // 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 piFromXiC_dcaXYconstant{"piFromXiC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiC_dcaXYpTdep{"piFromXiC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiCC_dcaXYconstant{"piFromXiCC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable piFromXiCC_dcaXYpTdep{"piFromXiCC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiFromXiC_dcaXYconstant{"xiFromXiC_dcaXYconstant", 0.001f, "[0] in |DCAxy| > [0]+[1]/pT"}; + Configurable xiFromXiC_dcaXYpTdep{"xiFromXiC_dcaXYpTdep", 0.0, "[1] in |DCAxy| > [0]+[1]/pT"}; + + Configurable minPiCPt{"minPiCPt", 0.15, "Minimum pT for XiC pions"}; + Configurable minPiCCPt{"minPiCCPt", 0.3, "Minimum pT for XiCC pions"}; + + 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"}; + + 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 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 axisNConsidered{"axisNConsidered", {200, -0.5f, 199.5f}, "Number of considered track combinations"}; + + o2::vertexing::DCAFitterN<2> fitter; + o2::vertexing::DCAFitterN<3> fitter3; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Partition trueXi = aod::mcparticle::pdgCode == 3312; + Partition trueXiC = aod::mcparticle::pdgCode == 4232; + Partition trueXiCC = aod::mcparticle::pdgCode == 4422; + + // filter expressions for D mesons + static constexpr uint32_t trackSelectionPiFromXiC = 1 << kInnerTOFPion | 1 << kOuterTOFPion | 1 << kRICHPion | 1 << kTruePiFromXiC; + static constexpr uint32_t trackSelectionPiFromXiCC = 1 << kInnerTOFPion | 1 << kOuterTOFPion | 1 << kRICHPion | 1 << kTruePiFromXiCC; + + // 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); + + // Helper struct to pass candidate information + struct { + // decay properties + float dca; + float mass; + float pt; + float eta; + std::array xyz; + std::array prong0mom; + std::array prong1mom; + std::array prong2mom; + std::array parentTrackCovMatrix; + } thisXiCcandidate; + + struct { + float dca; + float mass; + float pt; + float eta; + std::array xyz; + std::array prong0mom; + std::array prong1mom; + std::array parentTrackCovMatrix; + + float etaPiCC; + + // charm daughters + int nSiliconHitsPiCC; + int nTPCHitsPiCC; + } thisXiCCcandidate; + + template + bool buildDecayCandidateTwoBody(TTrackType const& t0, TTrackType const& t1, float mass0, float mass1) + { + //}-{}-{}-{}-{}-{}-{}-{}-{}-{} + // Move close to minima + int nCand = 0; + try { + nCand = fitter.process(t0, t1); + } catch (...) { + return false; + } + if (nCand == 0) { + return false; + } + //}-{}-{}-{}-{}-{}-{}-{}-{}-{} + + o2::track::TrackParCov t0new = fitter.getTrack(0); + o2::track::TrackParCov t1new = fitter.getTrack(1); + t0new.getPxPyPzGlo(thisXiCCcandidate.prong0mom); + t1new.getPxPyPzGlo(thisXiCCcandidate.prong1mom); + + // get decay vertex coordinates + const auto& vtx = fitter.getPCACandidate(); + for (int i = 0; i < 3; i++) { + thisXiCCcandidate.xyz[i] = vtx[i]; + } + + // compute cov mat + for (int ii = 0; ii < 21; ii++) + thisXiCCcandidate.parentTrackCovMatrix[ii] = 0.0f; + + std::array covA = {0}; + std::array covB = {0}; + fitter.getTrack(0).getCovXYZPxPyPzGlo(covA); + fitter.getTrack(1).getCovXYZPxPyPzGlo(covB); + + const int momInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + int j = momInd[i]; + thisXiCCcandidate.parentTrackCovMatrix[j] = covA[j] + covB[j]; + } + + auto covVtx = fitter.calcPCACovMatrix(); + thisXiCCcandidate.parentTrackCovMatrix[0] = covVtx(0, 0); + thisXiCCcandidate.parentTrackCovMatrix[1] = covVtx(1, 0); + thisXiCCcandidate.parentTrackCovMatrix[2] = covVtx(1, 1); + thisXiCCcandidate.parentTrackCovMatrix[3] = covVtx(2, 0); + thisXiCCcandidate.parentTrackCovMatrix[4] = covVtx(2, 1); + thisXiCCcandidate.parentTrackCovMatrix[5] = covVtx(2, 2); + + // set relevant values + thisXiCCcandidate.dca = TMath::Sqrt(fitter.getChi2AtPCACandidate()); + if (thisXiCCcandidate.dca > dcaXiCCDaughtersSelection) { + return false; + } + + thisXiCCcandidate.mass = RecoDecay::m(array{array{thisXiCCcandidate.prong0mom[0], thisXiCCcandidate.prong0mom[1], thisXiCCcandidate.prong0mom[2]}, array{thisXiCCcandidate.prong1mom[0], thisXiCCcandidate.prong1mom[1], thisXiCCcandidate.prong1mom[2]}}, array{mass0, mass1}); + thisXiCCcandidate.pt = std::hypot(thisXiCCcandidate.prong0mom[0] + thisXiCCcandidate.prong1mom[0], thisXiCCcandidate.prong0mom[1] + thisXiCCcandidate.prong1mom[1]); + thisXiCCcandidate.eta = RecoDecay::eta(array{thisXiCCcandidate.prong0mom[0] + thisXiCCcandidate.prong1mom[0], thisXiCCcandidate.prong0mom[1] + thisXiCCcandidate.prong1mom[1], thisXiCCcandidate.prong0mom[2] + thisXiCCcandidate.prong1mom[2]}); + return true; + } + + template + bool buildDecayCandidateThreeBody(TTrackType1 const& prong0, TTrackType2 const& prong1, TTrackType3 const& prong2, float p0mass, float p1mass, float p2mass) + { + o2::track::TrackParCov t0 = getTrackParCov(prong0); + o2::track::TrackParCov t1 = getTrackParCov(prong1); + o2::track::TrackParCov t2 = getTrackParCov(prong2); + + //}-{}-{}-{}-{}-{}-{}-{}-{}-{} + // Move close to minima + int nCand = 0; + try { + nCand = fitter3.process(t0, t1, t2); + } catch (...) { + return false; + } + if (nCand == 0) { + return false; + } + //}-{}-{}-{}-{}-{}-{}-{}-{}-{} + + t0 = fitter3.getTrack(0); + t1 = fitter3.getTrack(1); + t2 = fitter3.getTrack(2); + t0.getPxPyPzGlo(thisXiCcandidate.prong0mom); + t1.getPxPyPzGlo(thisXiCcandidate.prong1mom); + t2.getPxPyPzGlo(thisXiCcandidate.prong2mom); + + // get decay vertex coordinates + const auto& vtx = fitter3.getPCACandidate(); + for (int i = 0; i < 3; i++) { + thisXiCcandidate.xyz[i] = vtx[i]; + } + + // compute cov mat + for (int ii = 0; ii < 21; ii++) + thisXiCcandidate.parentTrackCovMatrix[ii] = 0.0f; + + std::array covA = {0}; + std::array covB = {0}; + std::array covC = {0}; + fitter3.getTrack(0).getCovXYZPxPyPzGlo(covA); + fitter3.getTrack(1).getCovXYZPxPyPzGlo(covB); + fitter3.getTrack(2).getCovXYZPxPyPzGlo(covC); + + const int momInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (int i = 0; i < 6; i++) { + int j = momInd[i]; + thisXiCcandidate.parentTrackCovMatrix[j] = covA[j] + covB[j] + covC[j]; + } + + auto covVtx = fitter3.calcPCACovMatrix(); + thisXiCcandidate.parentTrackCovMatrix[0] = covVtx(0, 0); + thisXiCcandidate.parentTrackCovMatrix[1] = covVtx(1, 0); + thisXiCcandidate.parentTrackCovMatrix[2] = covVtx(1, 1); + thisXiCcandidate.parentTrackCovMatrix[3] = covVtx(2, 0); + thisXiCcandidate.parentTrackCovMatrix[4] = covVtx(2, 1); + thisXiCcandidate.parentTrackCovMatrix[5] = covVtx(2, 2); + + // set relevant values + thisXiCcandidate.dca = TMath::Sqrt(fitter3.getChi2AtPCACandidate()); + if (thisXiCcandidate.dca > dcaXiCDaughtersSelection) { + return false; + } + thisXiCcandidate.mass = RecoDecay::m(array{array{thisXiCcandidate.prong0mom[0], thisXiCcandidate.prong0mom[1], thisXiCcandidate.prong0mom[2]}, array{thisXiCcandidate.prong1mom[0], thisXiCcandidate.prong1mom[1], thisXiCcandidate.prong1mom[2]}, array{thisXiCcandidate.prong2mom[0], thisXiCcandidate.prong2mom[1], thisXiCcandidate.prong2mom[2]}}, array{p0mass, p1mass, p2mass}); + thisXiCcandidate.pt = std::hypot(thisXiCcandidate.prong0mom[0] + thisXiCcandidate.prong1mom[0] + thisXiCcandidate.prong2mom[0], thisXiCcandidate.prong0mom[1] + thisXiCcandidate.prong1mom[1] + thisXiCcandidate.prong2mom[1]); + thisXiCcandidate.eta = RecoDecay::eta(array{thisXiCcandidate.prong0mom[0] + thisXiCcandidate.prong1mom[0] + thisXiCcandidate.prong2mom[0], thisXiCcandidate.prong0mom[1] + thisXiCcandidate.prong1mom[1] + thisXiCcandidate.prong2mom[1], thisXiCcandidate.prong0mom[2] + thisXiCcandidate.prong1mom[2] + thisXiCcandidate.prong2mom[2]}); + return true; + } + + /// function to check if tracks have the same mother in MC + template + bool checkSameMother(TTrackType1 const& track1, TTrackType2 const& track2) + { + bool returnValue = false; + // Association check + // There might be smarter ways of doing this in the future + if (track1.has_mcParticle() && track2.has_mcParticle()) { + auto mcParticle1 = track1.template mcParticle_as(); + auto mcParticle2 = track2.template mcParticle_as(); + if (mcParticle1.has_mothers() && mcParticle2.has_mothers()) { + for (auto& mcParticleMother1 : mcParticle1.template mothers_as()) { + for (auto& mcParticleMother2 : mcParticle2.template mothers_as()) { + if (mcParticleMother1.globalIndex() == mcParticleMother2.globalIndex()) { + returnValue = true; + } + } + } + } + } // end association check + return returnValue; + } + + // Association check for the XiCC pion + template + bool checkSameMotherExtra(TTrackType1 const& track1, TTrackType2 const& track2) + { + bool returnValue = false; + // This might perhaps be a bit excessive + // Could be joined with `checkSameMother` but leaving as is for now + if (track1.has_mcParticle() && track2.has_mcParticle()) { + auto mcParticle1 = track1.template mcParticle_as(); + auto mcParticle2 = track2.template mcParticle_as(); + if (mcParticle1.has_mothers() && mcParticle2.has_mothers()) { + for (auto& mcParticleMother1 : mcParticle1.template mothers_as()) { + if (mcParticleMother1.has_mothers()) { + for (auto& mcParticleGrandMother1 : mcParticleMother1.template mothers_as()) { + for (auto& mcParticleMother2 : mcParticle2.template mothers_as()) { + if (mcParticleGrandMother1.globalIndex() == mcParticleMother2.globalIndex()) { + returnValue = true; + } + } + } + } + } + } + } // end association check + return returnValue; + } + + void init(InitContext&) + { + // initialize O2 2-prong fitter (only once) + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + fitter.setWeightedFinalPCA(false); + fitter.setBz(magneticField); + fitter.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrNONE); + + fitter3.setPropagateToPCA(true); + fitter3.setMaxR(200.); + fitter3.setMinParamChange(1e-3); + fitter3.setMinRelChi2Change(0.9); + fitter3.setMaxDZIni(1e9); + fitter3.setMaxChi2(1e9); + fitter3.setUseAbsDCA(true); + fitter3.setWeightedFinalPCA(false); + fitter3.setBz(magneticField); + fitter3.setMatCorrType(o2::base::Propagator::MatCorrType::USEMatCorrNONE); + + // This histogram bookkeeps the attempts at DCA minimization and their eventual + // failure rates. + // --- 0: attempt XiC, 1: success XiC + // --- 2: attempt XiCC, 3: success XiCC + histos.add("hCharmBuilding", "hCharmBuilding", kTH1D, {{10, -0.5, 9.5f}}); + + histos.add("h2dGenXi", "h2dGenXi", kTH2D, {axisPt, axisEta}); + histos.add("h2dGenXiC", "h2dGenXiC", kTH2D, {axisPt, axisEta}); + histos.add("h2dGenXiCC", "h2dGenXiCC", kTH2D, {axisPt, axisEta}); + + histos.add("hMassXi", "hMassXi", kTH1D, {axisXiMass}); + histos.add("hMassXiC", "hMassXiC", kTH1D, {axisXiCMass}); + histos.add("hMassXiCC", "hMassXiCC", kTH1D, {axisXiCCMass}); + + 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}); + + // 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}); + + if (doDCAplots) { + histos.add("h2dDCAxyVsPtXiFromXiC", "h2dDCAxyVsPtXiFromXiC", kTH2D, {axisPt, axisDCA}); + histos.add("h2dDCAxyVsPtPiFromXiC", "h2dDCAxyVsPtPiFromXiC", kTH2D, {axisPt, axisDCA}); + histos.add("h2dDCAxyVsPtPiFromXiCC", "h2dDCAxyVsPtPiFromXiCC", kTH2D, {axisPt, axisDCA}); + } + } + + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + void processGenerated(aod::McParticles const&) + { + for (auto const& mcParticle : trueXi) + histos.fill(HIST("h2dGenXi"), mcParticle.pt(), mcParticle.eta()); + for (auto const& mcParticle : trueXiC) + 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) + { + // 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); + auto tracksPiFromXiCCgrouped = tracksPiFromXiCC->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + if (doDCAplots) { + for (auto const& cascade : cascades) { + if (cascade.has_cascadeTrack()) { + auto track = cascade.cascadeTrack_as(); // de-reference cascade track + histos.fill(HIST("h2dDCAxyVsPtXiFromXiC"), track.pt(), track.dcaXY() * 1e+4); + } else { + LOGF(info, "Damn, something is wrong"); + } + } + for (auto const& track : tracks) { + if (bitcheck(track.decayMap(), kTruePiFromXiC)) + histos.fill(HIST("h2dDCAxyVsPtPiFromXiC"), track.pt(), track.dcaXY() * 1e+4); + if (bitcheck(track.decayMap(), kTruePiFromXiCC)) + histos.fill(HIST("h2dDCAxyVsPtPiFromXiCC"), track.pt(), track.dcaXY() * 1e+4); + } + } + + for (auto const& xiCand : cascades) { + histos.fill(HIST("hMassXi"), xiCand.mXi()); + + if (std::abs(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 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 + + if (!bitcheck(xi.decayMap(), kTrueXiFromXiC)) + continue; + + 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; + + // 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; + + // 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)) + continue; // failed at building candidate + + if (std::abs(thisXiCcandidate.mass - o2::constants::physics::MassXiCPlus) > massWindowXiC) + continue; // out of mass region + histos.fill(HIST("hCharmBuilding"), 1.0f); + + const std::array momentumC = { + thisXiCcandidate.prong0mom[0] + thisXiCcandidate.prong1mom[0] + thisXiCcandidate.prong2mom[0], + thisXiCcandidate.prong0mom[1] + thisXiCcandidate.prong1mom[1] + thisXiCcandidate.prong2mom[1], + 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) + continue; // do not take if radius too small, likely a primary combination + + o2::dataformats::DCA dcaInfo; + float xicdcaXY = 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(); + } + + 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 (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; + o2::track::TrackParCov piccTrack = getTrackParCov(picc); + nCombinationsCC++; + histos.fill(HIST("hCharmBuilding"), 2.0f); + if (!buildDecayCandidateTwoBody(xicTrack, piccTrack, 2.46793, 0.139570)) + 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); + + const std::array momentumCC = { + thisXiCCcandidate.prong0mom[0] + thisXiCCcandidate.prong1mom[0], + thisXiCCcandidate.prong0mom[1] + thisXiCCcandidate.prong1mom[1], + thisXiCCcandidate.prong0mom[2] + thisXiCCcandidate.prong1mom[2]}; + + o2::track::TrackParCov xiccTrack(thisXiCCcandidate.xyz, momentumCC, thisXiCCcandidate.parentTrackCovMatrix, +2); + + float xiccdcaXY = 1e+10; + if (xiccTrack.propagateToDCA(primaryVertex, magneticField, &dcaInfo)) { + xiccdcaXY = dcaInfo.getY(); + } + + // produce multi-charm table for posterior analysis + if (fillDerivedTable) { + 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()); + } + } + histos.fill(HIST("hCombinationsXiCC"), nCombinationsCC); + } + } + histos.fill(HIST("hCombinationsXiC"), nCombinationsC); + } + } + //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* + + //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* + PROCESS_SWITCH(alice3multicharm, processGenerated, "fill MC-only histograms", true); + PROCESS_SWITCH(alice3multicharm, processFindXiCC, "find XiCC baryons", true); + //*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<*>-~-<* +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/CODEOWNERS b/CODEOWNERS index 07560bc8813..253fbdc4690 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -15,42 +15,54 @@ /Common/CCDB @alibuild @jgrosseo @iarsene @ekryshen @ddobrigk /Common/Tools/Multiplicity @alibuild @ddobrigk @victor-gonzalez /ALICE3 @alibuild @njacazio @hscheid -/DPG @alibuild @chiarazampolli @noferini +/DPG @alibuild @chiarazampolli @alcaliva @catalinristea /DPG/Tasks/AOTEvent @alibuild @ekryshen @strogolo @altsybee /DPG/Tasks/AOTTrack @alibuild @mfaggin @iouribelikov @njacazio /DPG/Tasks/TOF @alibuild @noferini @njacazio /DPG/Tasks/FT0 @alibuild @afurs -/EventFiltering @alibuild @mpuccio @strogolo -/EventFiltering/PWGHF @alibuild @fgrosa @zhangbiao-phy @mpuccio @strogolo -/EventFiltering/PWGUD @alibuild @pbuehler @mpuccio @strogolo -/EventFiltering/PWGLF @alibuild @mpuccio @ercolessi @ChiaraDeMartin95 @strogolo -/EventFiltering/PWGCF @alibuild @lauraser @mpuccio @strogolo -/EventFiltering/PWGMM @alibuild @aortizve @mpuccio @strogolo -/EventFiltering/PWGJE @alibuild @fkrizek @nzardosh @mpuccio @strogolo -/PWGCF @alibuild @saganatt @victor-gonzalez @zchochul -/PWGCF/Core @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul -/PWGCF/DataModel @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul -/PWGCF/TableProducer @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul -/PWGCF/Tasks @alibuild @jgrosseo @saganatt @victor-gonzalez @zchochul +/EventFiltering @alibuild @mpuccio @lietava +/EventFiltering/PWGHF @alibuild @fgrosa @zhangbiao-phy @mpuccio @lietava +/EventFiltering/PWGUD @alibuild @pbuehler @mpuccio @lietava +/EventFiltering/PWGLF @alibuild @mpuccio @ercolessi @ChiaraDeMartin95 @lietava +/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 /PWGEM @alibuild @mikesas @rbailhac @feisenhu /PWGEM/Dilepton @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu /PWGEM/PhotonMeson @alibuild @mikesas @rbailhac @m-c-danisch @novitzky @mhemmer-cern @dsekihat -/PWGHF @alibuild @vkucera @fcolamar @fgrosa @fcatalan92 @mfaggin @mmazzilli @deepathoms @nzardosh @NicoleBastid @hahassan7 @jpxrk -/PWGLF @alibuild @ercolessi @fmazzasc @chiarapinto @BongHwi @smaff92 @mbombara @ChiaraDeMartin95 @njacazio @skundu692 -/PWGMM @alibuild @aalkin +/PWGHF @alibuild @vkucera @fcolamar @fgrosa @fcatalan92 @mfaggin @mmazzilli @deepathoms @NicoleBastid @hahassan7 @jpxrk @apalasciano +# 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 @BongHwi @smaff92 +/PWGLF/TableProducer/Resonances @alibuild @njacazio @skundu692 @BongHwi @smaff92 +/PWGLF/Tasks/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95 +/PWGLF/TableProducer/Strangeness @alibuild @njacazio @skundu692 @ercolessi @ChiaraDeMartin95 + +# PWG-MM +/PWGMM @alibuild @njacazio @skundu692 @aalkin +/PWGMM/Mult @alibuild @njacazio @skundu692 @aalkin @aortizve @ddobrigk /PWGMM/Lumi @alibuild @aalkin -/PWGMM/Mult @alibuild @aalkin @aortizve @ddobrigk -/PWGMM/UE @alibuild @aalkin @aortizve +/PWGMM/UE @alibuild @aalkin @aortizve + /PWGUD @alibuild @pbuehler @abylinkin @rolavick -/PWGJE @alibuild @lhavener @maoyx @nzardosh @ddobrigk @mfasDa +/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/PWGEM @alibuild @mikesas @rbailhac @dsekihat @ivorobye @feisenhu /Tutorials/PWGHF @alibuild @vkucera @fcolamar @fgrosa -/Tutorials/PWGJE @alibuild @lhavener @maoyx @nzardosh @ddobrigk @mfasDa +/Tutorials/PWGJE @alibuild @lhavener @maoyx @nzardosh @mfasDa @fjonasALICE /Tutorials/PWGLF @alibuild @alcaliva @lbariogl @chiarapinto @BongHwi @lbarnby @mbombara @iravasen @njacazio @ChiaraDeMartin95 @skundu692 /Tutorials/PWGMM @alibuild @aalkin @ddobrigk /Tutorials/PWGUD @alibuild @pbuehler diff --git a/CPPLINT.cfg b/CPPLINT.cfg index e050d1df67c..7f7d3c357c3 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/line_length,-whitespace/semicolon,-whitespace/todo +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 diff --git a/Common/CCDB/EventSelectionParams.cxx b/Common/CCDB/EventSelectionParams.cxx index 55ff1d04af1..86bf76a6419 100644 --- a/Common/CCDB/EventSelectionParams.cxx +++ b/Common/CCDB/EventSelectionParams.cxx @@ -55,13 +55,12 @@ const char* selectionLabels[kNsel] = { "kIsVertexITSTPC", "kIsVertexTOFmatched", "kIsVertexTRDmatched", - "kNoHighOccupancyAgressive", - "kNoHighOccupancyStrict", - "kNoHighOccupancyMedium", - "kNoHighOccupancyRelaxed", - "kNoHighOccupancyGentle", + "kNoCollInTimeRangeNarrow", + "kNoCollInTimeRangeStrict", "kNoCollInTimeRangeStandard", - "kNoCollInTimeRangeNarrow"}; + "kNoCollInTimeRangeVzDependent", + "kNoCollInRofStrict", + "kNoCollInRofStandard"}; } // namespace o2::aod::evsel using namespace o2::aod::evsel; diff --git a/Common/CCDB/EventSelectionParams.h b/Common/CCDB/EventSelectionParams.h index dfedfd1e12f..143de878bc5 100644 --- a/Common/CCDB/EventSelectionParams.h +++ b/Common/CCDB/EventSelectionParams.h @@ -19,55 +19,54 @@ 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 - kNoHighOccupancyAgressive, // no occupancy according to the agressive cuts - kNoHighOccupancyStrict, // no occupancy according to the strict cuts - kNoHighOccupancyMedium, // no occupancy according to the medium cuts - kNoHighOccupancyRelaxed, // no occupancy according to the relaxed cuts - kNoHighOccupancyGentle, // no occupancy according to the gentle cuts - kNoCollInTimeRangeStandard, // no collisions in specified time range - kNoCollInTimeRangeNarrow, // no collisions in specified time range (narrower than Standard) - 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 + 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 + kNsel // counter }; extern const char* selectionLabels[kNsel]; diff --git a/Common/Core/AnalysisCoreLinkDef.h b/Common/Core/AnalysisCoreLinkDef.h index b376ccc7f10..ae4c91e9589 100644 --- a/Common/Core/AnalysisCoreLinkDef.h +++ b/Common/Core/AnalysisCoreLinkDef.h @@ -26,4 +26,6 @@ #pragma link C++ class OrbitRange + ; +#pragma link C++ class FFitWeights + ; + #endif // COMMON_CORE_ANALYSISCORELINKDEF_H_ diff --git a/Common/Core/CMakeLists.txt b/Common/Core/CMakeLists.txt index 61ca933740c..c51c9dbfa2a 100644 --- a/Common/Core/CMakeLists.txt +++ b/Common/Core/CMakeLists.txt @@ -18,6 +18,8 @@ o2physics_add_library(AnalysisCore EventPlaneHelper.cxx TableHelper.cxx MetadataHelper.cxx + CollisionTypeHelper.cxx + FFitWeights.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsParameters ROOT::EG O2::CCDB ROOT::Physics O2::FT0Base O2::FV0Base) o2physics_target_root_dictionary(AnalysisCore @@ -31,4 +33,10 @@ o2physics_target_root_dictionary(AnalysisCore PID/DetectorResponse.h PID/PIDTOF.h PID/TPCPIDResponse.h + CollisionTypeHelper.h + FFitWeights.h LINKDEF AnalysisCoreLinkDef.h) + +o2physics_add_header_only_library(TPCDriftManager + HEADERS TPCVDriftManager.h + INTERFACE_LINK_LIBRARIES O2::DataFormatsTPC) diff --git a/Common/Core/CollisionTypeHelper.cxx b/Common/Core/CollisionTypeHelper.cxx new file mode 100644 index 00000000000..c22510ec82e --- /dev/null +++ b/Common/Core/CollisionTypeHelper.cxx @@ -0,0 +1,58 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 CollisionTypeHelper.h +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Utility to handle the collision type from the GRP information +/// + +#include "Common/Core/CollisionTypeHelper.h" +#include +#include +#include "DataFormatsParameters/GRPLHCIFData.h" + +std::string CollisionSystemType::getCollisionSystemName(collType collSys) +{ + switch (collSys) { + case kCollSyspp: + return "pp"; + case kCollSysPbPb: + return "PbPb"; + case kCollSysXeXe: + return "XeXe"; + case kCollSyspPb: + return "pPb"; + default: + return "Undefined"; + } +} + +int 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) { + case 1: // pp 1*1 + return kCollSyspp; + case 6724: // Pb-Pb 82*82 + return kCollSysPbPb; + case 225: // Xe-Xe 54*54 + return kCollSysXeXe; + case 82: // p-Pb 82*1 + return kCollSyspPb; + default: + LOG(fatal) << "Undefined collision system in getCollisionTypeFromGrp with BeamA = " << ZBeamA << " and BeamC = " << ZBeamC; + return kCollSysUndef; + } + return kCollSysUndef; +} diff --git a/Common/Core/CollisionTypeHelper.h b/Common/Core/CollisionTypeHelper.h new file mode 100644 index 00000000000..0196fdc03bb --- /dev/null +++ b/Common/Core/CollisionTypeHelper.h @@ -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. + +/// +/// \file CollisionTypeHelper.h +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \brief Utility to handle the collision type from the GRP information +/// + +#ifndef COMMON_CORE_COLLISIONTYPEHELPER_H_ +#define COMMON_CORE_COLLISIONTYPEHELPER_H_ + +#include +#include "DataFormatsParameters/GRPLHCIFData.h" + +// Container for the collision system type +struct CollisionSystemType { + // Enum type for the collision system + typedef int collType; + + static constexpr collType kCollSysUndef = -1; // Undefined collision system + static constexpr collType kCollSyspp = 0; // pp + 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 std::string getCollisionSystemName(collType collSys); + + static int getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* grplhcif); +}; + +#endif // COMMON_CORE_COLLISIONTYPEHELPER_H_ diff --git a/Common/Core/FFitWeights.cxx b/Common/Core/FFitWeights.cxx new file mode 100644 index 00000000000..9c98479627d --- /dev/null +++ b/Common/Core/FFitWeights.cxx @@ -0,0 +1,170 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 FFitWeights.cxx +/// \brief Implementation file for FFitWeights.h, see the header for more information +/// +/// \author Joachim C. K. B. Hansen + +#include "FFitWeights.h" + +#include + +ClassImp(FFitWeights) + + FFitWeights::FFitWeights() : TNamed("", ""), + fW_data{nullptr}, + CentBin{100}, + qAxis{nullptr}, + nResolution{3000}, + qnTYPE{0} +{ +} + +FFitWeights::FFitWeights(const char* name) : TNamed(name, name), + fW_data{nullptr}, + CentBin{100}, + qAxis{nullptr}, + nResolution{3000}, + qnTYPE{0} {} + +FFitWeights::~FFitWeights() +{ + delete fW_data; + if (qAxis) + delete qAxis; +}; + +void FFitWeights::Init() +{ + fW_data = new TObjArray(); + fW_data->SetName("FFitWeights_Data"); + fW_data->SetOwner(kTRUE); + + if (!qAxis) + 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())); + } +}; + +void FFitWeights::Fill(float centrality, float qn, int nh, const char* pf) +{ + TObjArray* tar{nullptr}; + + tar = fW_data; + if (!tar) + return; + + 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())); + th2 = reinterpret_cast(tar->At(tar->GetEntries() - 1)); + } + th2->Fill(centrality, qn); +}; + +Long64_t FFitWeights::Merge(TCollection* collist) +{ + Long64_t nmerged = 0; + if (!fW_data) { + fW_data = new TObjArray(); + fW_data->SetName("FFitWeights_Data"); + fW_data->SetOwner(kTRUE); + } + FFitWeights* l_w = 0; + TIter all_w(collist); + while ((l_w = (reinterpret_cast(all_w())))) { + AddArray(fW_data, l_w->GetDataArray()); + nmerged++; + } + return nmerged; +}; +void FFitWeights::AddArray(TObjArray* targ, TObjArray* sour) +{ + if (!sour) { + printf("Source array does not exist!\n"); + return; + } + for (int i = 0; i < sour->GetEntries(); i++) { + TH2D* sourh = reinterpret_cast(sour->At(i)); + TH2D* targh = reinterpret_cast(targ->FindObject(sourh->GetName())); + if (!targh) { + targh = reinterpret_cast(sourh->Clone(sourh->GetName())); + targh->SetDirectory(0); + targ->Add(targh); + } else { + targh->Add(sourh); + } + } +}; + +void FFitWeights::qSelectionSpline(std::vector nhv, std::vector stv) /* only execute OFFLINE */ +{ + TObjArray* tar{nullptr}; + + tar = fW_data; + if (!tar) + return; + + for (const auto& pf : stv) { + for (const auto& nh : nhv) { + 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; + 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); + std::vector yq(nResolution); + for (int i{0}; i < nResolution; i++) + xq[i] = static_cast(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); + } + } + } +}; + +float FFitWeights::EvalSplines(float centr, const float& dqn, const int nh, const char* pf) +{ + TObjArray* tar{nullptr}; + + tar = fW_data; + if (!tar) + return -1; + + 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))); + if (!spline) { + return -1; + } + + float qn_val = 100. * spline->Eval(dqn); + if (qn_val < 0) { + return -1; + } + + return qn_val; +}; diff --git a/Common/Core/FFitWeights.h b/Common/Core/FFitWeights.h new file mode 100644 index 00000000000..0a3d285176e --- /dev/null +++ b/Common/Core/FFitWeights.h @@ -0,0 +1,82 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 FFitWeights.h +/// \brief Class for handling fit weights for ESE framework. Hold methods for loading and calculating all ESE splines. Supports FT0C, in the future it will support FT0A, FV0A and TPC. +/// +/// \author Joachim C. K. B. Hansen + +#ifndef COMMON_CORE_FFITWEIGHTS_H_ +#define COMMON_CORE_FFITWEIGHTS_H_ + +#include +#include +#include +#include +#include +#include + +#include "TNamed.h" +#include "TObjArray.h" +#include "TH3D.h" +#include "TH2D.h" +#include "TH1D.h" +#include "TFile.h" +#include "TCollection.h" +#include "TString.h" +#include "TMath.h" + +class FFitWeights : public TNamed +{ + public: + FFitWeights(); + 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 SetCentBin(int bin) { CentBin = bin; } + void SetBinAxis(int bin, float min, float max) + { + qAxis = new TAxis(bin, min, max); + } + 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; } + + private: + TObjArray* fW_data; + + int CentBin; + TAxis* qAxis; //! + int nResolution; + + std::vector> qnTYPE; + + 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 = "") + { + return Form(";Centrality;q_{%i}^{%s}", nh, pf); + }; + void AddArray(TObjArray* targ, TObjArray* sour); + + ClassDef(FFitWeights, 1); // calibration class +}; +#endif // COMMON_CORE_FFITWEIGHTS_H_ diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 34f80c959f1..a8e4de1216f 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -20,10 +20,12 @@ #include // std::find #include // std::array #include // std::abs, std::sqrt +#include #include // std::move #include // std::vector #include "TMCProcess.h" // for VMC Particle Production Process +#include "TPDGCode.h" // for PDG codes #include "CommonConstants/MathConstants.h" /// Base class for calculating properties of reconstructed decays @@ -662,6 +664,8 @@ struct RecoDecay { /// 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 acceptTrackDecay switch to accept candidates with daughter tracks of pions and kaons which decayed /// \param particlesMC table with MC particles /// \param arrDaughters array of candidate daughters /// \param PDGMother expected mother PDG code @@ -669,19 +673,25 @@ struct RecoDecay { /// \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 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 /// \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, bool acceptAntiParticles = false, int8_t* sign = nullptr, - int depthMax = 1) + 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 @@ -707,6 +717,21 @@ struct RecoDecay { return -1; } auto particleI = arrDaughters[iProng].mcParticle(); // 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(); + auto pdgI = std::abs(particleI.pdgCode()); + auto pdgMotherI = std::abs(motherI.pdgCode()); + if (pdgI == kMuonMinus && pdgMotherI == kPiPlus) { + // π → μ + nPiToMuLocal++; + particleI = motherI; + } else if (pdgI == kPiPlus && pdgMotherI == kKPlus) { + // K → π + nKaToPiLocal++; + particleI = motherI; + } + } arrDaughtersIndex[iProng] = particleI.globalIndex(); // Get the list of daughter indices from the mother of the first prong. if (iProng == 0) { @@ -726,7 +751,7 @@ struct RecoDecay { return -1; } // Check that the number of direct daughters is not larger than the number of expected final daughters. - if constexpr (!checkProcess) { + if constexpr (!acceptIncompleteReco && !checkProcess) { if (particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1 > static_cast(N)) { // Printf("MC Rec: Rejected: too many direct daughters: %d (expected %ld final)", particleMother.daughtersIds().back() - particleMother.daughtersIds().front() + 1, N); return -1; @@ -740,7 +765,7 @@ struct RecoDecay { // } // printf("\n"); // Check whether the number of actual final daughters is equal to the number of expected final daughters (i.e. the number of provided prongs). - if (arrAllDaughtersIndex.size() != N) { + if (!acceptIncompleteReco && arrAllDaughtersIndex.size() != N) { // Printf("MC Rec: Rejected: incorrect number of final daughters: %ld (expected %ld)", arrAllDaughtersIndex.size(), N); return -1; } @@ -779,6 +804,14 @@ struct RecoDecay { if (sign) { *sign = sgn; } + if constexpr (acceptTrackDecay) { + if (nPiToMu) { + *nPiToMu = nPiToMuLocal; + } + if (nKaToPi) { + *nKaToPi = nKaToPiLocal; + } + } return indexMother; } @@ -935,6 +968,16 @@ struct RecoDecay { for (auto& iPart : arrayIds[-stage]) { // check all the particles that were the mothers at the previous stage 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)) { + return OriginType::Prompt; + } + } + for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again continue; @@ -992,6 +1035,119 @@ struct RecoDecay { } return OriginType::None; } + + /// based on getCharmHardronOrigin in order to extend general particle + /// Finding the origin (from charm hadronisation or beauty-hadron decay) of paritcle (b, c and others) + /// \param particlesMC table with MC particles + /// \param particle MC particle + /// \param searchUpToQuark if true tag origin based on charm/beauty quark otherwise on the presence of a b-hadron or c-hadron + /// \param idxBhadMothers optional vector of b-hadron indices (might be more than one in case of searchUpToQuark in case of beauty resonances) + /// \return an integer corresponding to the origin (0: none(others), 1: charm, 2: beauty) as in OriginType + template + static int getParticleOrigin(const T& particlesMC, + const typename T::iterator& particle, + const bool searchUpToQuark = false, + std::vector* idxBhadMothers = nullptr) + { + int stage = 0; // mother tree level (just for debugging) + + // vector of vectors with mother indices; each line corresponds to a "stage" + 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()); + bool couldBeCharm = false; + if (PDGParticle / 100 == 4 || PDGParticle / 1000 == 4) { + 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 + 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 PDGPaticle = std::abs(particleMother.pdgCode()); + if ( + (PDGParticleIMother / 100 == 5 || // b mesons + PDGParticleIMother / 1000 == 5) // b baryons + ) { + return OriginType::NonPrompt; // beauty + } + if ( + (PDGParticleIMother / 100 == 4 || // c mesons + PDGParticleIMother / 1000 == 4) // c baryons + ) { + return OriginType::Prompt; // charm + } + break; + } + } + + for (auto iMother = particleMother.mothersIds().front(); iMother <= particleMother.mothersIds().back(); ++iMother) { // loop over the mother particles of the analysed particle + if (std::find(arrayIdsStage.begin(), arrayIdsStage.end(), iMother) != arrayIdsStage.end()) { // if a mother is still present in the vector, do not check it again + continue; + } + 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 + // 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); + + if (searchUpToQuark) { + if (idxBhadMothers) { + if (PDGParticleIMother / 100 == 5 || // b mesons + PDGParticleIMother / 1000 == 5) // b baryons + { + idxBhadMothers->push_back(iMother); + } + } + if (PDGParticleIMother == 5) { // b quark + return OriginType::NonPrompt; // beauty + } + if (PDGParticleIMother == 4) { // c quark + return OriginType::Prompt; // charm + } + } else { + if ( + (PDGParticleIMother / 100 == 5 || // b mesons + PDGParticleIMother / 1000 == 5) // b baryons + ) { + if (idxBhadMothers) { + idxBhadMothers->push_back(iMother); + } + return OriginType::NonPrompt; // beauty + } + if ( + (PDGParticleIMother / 100 == 4 || // c mesons + PDGParticleIMother / 1000 == 4) // c baryons + ) { + couldBeCharm = true; + } + } + // add mother index in the vector for the current stage + arrayIdsStage.push_back(iMother); + } + } + } + // add vector of mother indices for the current stage + arrayIds.push_back(arrayIdsStage); + stage--; + } + if (couldBeCharm) { + return OriginType::Prompt; // charm + } + return OriginType::None; + } }; /// Calculations using (pT, η, φ) coordinates, aka (transverse momentum, pseudorapidity, azimuth) diff --git a/Common/Core/TPCVDriftManager.h b/Common/Core/TPCVDriftManager.h new file mode 100644 index 00000000000..5d35db5ea99 --- /dev/null +++ b/Common/Core/TPCVDriftManager.h @@ -0,0 +1,171 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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_CORE_TPCVDRIFTMANAGER_H_ +#define COMMON_CORE_TPCVDRIFTMANAGER_H_ + +#include + +#include "CCDB/BasicCCDBManager.h" +#include "Framework/Logger.h" +#include "Framework/DataTypes.h" +#include "DataFormatsTPC/VDriftCorrFact.h" +#include "CommonConstants/LHCConstants.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "ReconstructionDataFormats/Track.h" + +namespace o2::aod::common +{ + +// Thin wrapper for vdrift ccdb queries should partially mirror VDriftHelper class. +// Allows to move TPC standalone tracks under the assumption of a different +// collision than the track is associated to. +class TPCVDriftManager +{ + public: + void init(o2::ccdb::BasicCCDBManager* ccdb) noexcept + { + mCCDB = ccdb; + } + + void update(uint64_t timestamp) noexcept + { + // Check validity of already present obj, otherwise update + if (mVD != nullptr && (timestamp > static_cast(mVD->firstTime) || timestamp < static_cast(mVD->lastTime))) { + return; + } + + // Update Obj + mVD = mCCDB->getForTimeStamp("TPC/Calib/VDriftTgl", timestamp); + if (mVD == nullptr || mVD->firstTime < 0 || mVD->lastTime < 0) { + LOGP(error, "Got invalid VDriftCorrFact for {}", timestamp); + mValid = false; + return; + } + + // TODO account for laser calib + + // Update factors + mTPCVDriftNS = mVD->refVDrift * mVD->corrFact * 1e-3; + + mValid = true; + LOGP(info, "Updated VDrift for timestamp {} with vdrift={:.7f} (cm/ns)", mVD->creationTime, mTPCVDriftNS); + } + + template + [[nodiscard]] bool moveTPCTrack(const Collision& col, const TrackExtra& trackExtra, Track& track) noexcept + { + ++mCalls; + + // Check if there is a good object available otherwise pretend everything is fine + if (!mValid) { + if (mInvalid < mWarningLimit) { + LOGP(warn, "No VDrift object available, pretending track to be correct"); + if (mInvalid == mWarningLimit - 1) { + LOGP(warn, "Silencing further warnings!"); + } + } + ++mInvalid; + return true; + } + + // track is fine, or cannot be moved has information is not available + if (!(trackExtra.flags() & o2::aod::track::TrackFlags::TrackTimeAsym)) { + ++mNoFlag; + return true; + } + + // TPC time is given relative to the closest BC in ns + float tTB, tTBErr; + if (col.collisionTimeRes() < 0.f) { // use track data + ++mColResNeg; + tTB = trackExtra.trackTime(); + o2::aod::track::extensions::TPCTimeErrEncoding enc; + enc.encoding.timeErr = trackExtra.trackTimeRes(); + tTBErr = 0.5f * (enc.getDeltaTFwd() + enc.getDeltaTBwd()); + } else { + ++mColResPos; + // The TPC track can be associated to a different BC than the one the collision under assumption is; + // we need to calculate the difference and subtract this from the trackTime() + const auto trackBC = trackExtra.template collision_as().template foundBC_as().globalBC(); + const auto colBC = col.template foundBC_as().globalBC(); + float sign{1.f}; + uint64_t diffBC{0}; + if (colBC < trackBC) { + sign = -1.f; + diffBC = (trackBC - colBC); + } else { + diffBC = (colBC - trackBC); + } + float diffBCNS = sign * static_cast(diffBC) * static_cast(o2::constants::lhc::LHCBunchSpacingNS); + tTB = col.collisionTime() + diffBCNS; + tTBErr = col.collisionTimeRes(); + } + float dTime = tTB - trackExtra.trackTime(); + float dDrift = dTime * mTPCVDriftNS; + float dDriftErr = tTBErr * mTPCVDriftNS; + if (dDriftErr < 0.f || dDrift > 250.f) { // we cannot move a track outside the drift volume + if (mOutside < mWarningLimit) { + LOGP(warn, "Skipping correction outside of tpc volume with dDrift={} +- {}", dDrift, dDriftErr); + const auto trackBC = trackExtra.template collision_as().template foundBC_as().globalBC(); + const auto colBC = col.template foundBC_as().globalBC(); + int diffBC = colBC - trackBC; + LOGP(info, "ct={}; ctr={}; tTB={}; t0={}; dTime={}; dDrift={}; tgl={}: colBC={} trackBC={} diffBC={}", col.collisionTime(), col.collisionTimeRes(), tTB, trackExtra.trackTime(), dTime, dDrift, track.getTgl(), colBC, trackBC, diffBC); + if (mOutside == mWarningLimit - 1) { + LOGP(warn, "Silencing further warnings!"); + } + } + ++mOutside; + return false; + } + + // impose new Z coordinate + track.setZ(track.getZ() + ((track.getTgl() < 0.) ? -dDrift : dDrift)); + if constexpr (std::is_base_of_v) { + track.setCov(track.getSigmaZ2() + dDriftErr * dDriftErr, o2::track::kSigZ2); + } + + ++mMovedTrks; + + return true; + } + + void print() noexcept + { + LOGP(info, "TPC corrections called: {}; Moved Tracks: {}; Constrained Tracks={}; No Flag: {}; NULL: {}; Outside: {}; ColResPos {}; ColResNeg {};", mCalls, mMovedTrks, mConstrained, mNoFlag, mInvalid, mOutside, mColResPos, mColResNeg); + } + + private: + bool mValid{false}; + // Factors + float mTPCVDriftNS{0.f}; // drift velocity in cm/ns + + // CCDB + const o2::tpc::VDriftCorrFact* mVD{}; // reference to drift correction + o2::ccdb::BasicCCDBManager* mCCDB{}; // reference to initialized ccdb manager + + static constexpr unsigned int mWarningLimit{10}; + + // Counters + unsigned int mCalls{0}; // total number of calls + unsigned int mMovedTrks{0}; // number of moved tracks + unsigned int mInvalid{0}; // number of tracks where no drift object was available + unsigned int mColResNeg{0}; // number of collisions with negative resolution + unsigned int mColResPos{0}; // number of collisions with positive resolution + unsigned int mNoFlag{0}; // number of tracks without flag set + unsigned int mOutside{0}; // number of tracks moved but outside of sensible volume + unsigned int mConstrained{0}; // number of constrained tracks +}; + +} // namespace o2::aod::common + +#endif // COMMON_CORE_TPCVDRIFTMANAGER_H_ diff --git a/Common/Core/TrackSelection.h b/Common/Core/TrackSelection.h index 618124f638f..351b662c48d 100644 --- a/Common/Core/TrackSelection.h +++ b/Common/Core/TrackSelection.h @@ -195,10 +195,10 @@ class TrackSelection return (isRun2 && mRequireGoldenChi2) ? (track.flags() & o2::aod::track::GoldenChi2) : true; case TrackCuts::kDCAxy: - return abs(track.dcaXY()) <= ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); + return std::fabs(track.dcaXY()) <= ((mMaxDcaXYPtDep) ? mMaxDcaXYPtDep(track.pt()) : mMaxDcaXY); case TrackCuts::kDCAz: - return abs(track.dcaZ()) <= mMaxDcaZ; + return std::fabs(track.dcaZ()) <= mMaxDcaZ; default: return false; diff --git a/Common/Core/TrackSelectorPID.h b/Common/Core/TrackSelectorPID.h index e09969ba946..214627a2d72 100644 --- a/Common/Core/TrackSelectorPID.h +++ b/Common/Core/TrackSelectorPID.h @@ -103,9 +103,10 @@ class TrackSelectorPidBase /// Checks if track is compatible with given particle species hypothesis within given TPC nσ range. /// \param track track /// \param conditionalTof variable to store the result of selection with looser cuts for conditional accepting of track if combined with TOF + /// \param tpcNSigmaCustom custom TPC nσ value to be used for the selection, in case the desired value cannot be taken from the track table /// \return true if track satisfies TPC PID hypothesis for given TPC nσ range template - bool isSelectedByTpc(const T& track, bool& conditionalTof) + bool isSelectedByTpc(const T& track, bool& conditionalTof, float tpcNSigmaCustom = -999.f) { // Accept if selection is disabled via large values. if (mNSigmaTpcMin < -999. && mNSigmaTpcMax > 999.) { @@ -128,6 +129,11 @@ class TrackSelectorPidBase errorPdg(); } + /// use custom TPC nσ, if a valid value is provided + if (tpcNSigmaCustom > -999.f) { + nSigma = tpcNSigmaCustom; + } + if (mNSigmaTpcMinCondTof < -999. && mNSigmaTpcMaxCondTof > 999.) { conditionalTof = true; } else { @@ -140,13 +146,13 @@ class TrackSelectorPidBase /// \param track track /// \return TPC selection status (see TrackSelectorPID::Status) template - TrackSelectorPID::Status statusTpc(const T& track) + TrackSelectorPID::Status statusTpc(const T& track, float tpcNSigmaCustom = -999.f) { if (!isValidForTpc(track)) { return TrackSelectorPID::NotApplicable; } bool condTof = false; - if (isSelectedByTpc(track, condTof)) { + if (isSelectedByTpc(track, condTof, tpcNSigmaCustom)) { return TrackSelectorPID::Accepted; } else if (condTof) { return TrackSelectorPID::Conditional; // potential to be accepted if combined with TOF @@ -191,9 +197,10 @@ class TrackSelectorPidBase /// Checks if track is compatible with given particle species hypothesis within given TOF nσ range. /// \param track track /// \param conditionalTpc variable to store the result of selection with looser cuts for conditional accepting of track if combined with TPC + /// \param tofNSigmaCustom custom TOF nσ value to be used for the selection, in case the desired value cannot be taken from the track table /// \return true if track satisfies TOF PID hypothesis for given TOF nσ range template - bool isSelectedByTof(const T& track, bool& conditionalTpc) + bool isSelectedByTof(const T& track, bool& conditionalTpc, float tofNSigmaCustom = -999.f) { // Accept if selection is disabled via large values. if (mNSigmaTofMin < -999. && mNSigmaTofMax > 999.) { @@ -216,6 +223,11 @@ class TrackSelectorPidBase errorPdg(); } + /// use custom TOF nσ, if a valid value is provided + if (tofNSigmaCustom > -999.f) { + nSigma = tofNSigmaCustom; + } + if (mNSigmaTofMinCondTpc < -999. && mNSigmaTofMaxCondTpc > 999.) { conditionalTpc = true; } else { @@ -228,13 +240,13 @@ class TrackSelectorPidBase /// \param track track /// \return TOF selection status (see TrackSelectorPID::Status) template - TrackSelectorPID::Status statusTof(const T& track) + TrackSelectorPID::Status statusTof(const T& track, float tofNSigmaCustom = -999.f) { if (!isValidForTof(track)) { return TrackSelectorPID::NotApplicable; } bool condTpc = false; - if (isSelectedByTof(track, condTpc)) { + if (isSelectedByTof(track, condTpc, tofNSigmaCustom)) { return TrackSelectorPID::Accepted; } else if (condTpc) { return TrackSelectorPID::Conditional; // potential to be accepted if combined with TPC @@ -391,10 +403,10 @@ class TrackSelectorPidBase /// \param track track /// \return status of combined PID (TPC or TOF) (see TrackSelectorPID::Status) template - TrackSelectorPID::Status statusTpcOrTof(const T& track) + TrackSelectorPID::Status statusTpcOrTof(const T& track, float tpcNSigmaCustom = -999.f, float tofNSigmaCustom = -999.f) { - int pidTpc = statusTpc(track); - int pidTof = statusTof(track); + int pidTpc = statusTpc(track, tpcNSigmaCustom); + int pidTof = statusTof(track, tofNSigmaCustom); if (pidTpc == TrackSelectorPID::Accepted || pidTof == TrackSelectorPID::Accepted) { return TrackSelectorPID::Accepted; @@ -412,15 +424,15 @@ class TrackSelectorPidBase /// \param track track /// \return status of combined PID (TPC and TOF) (see TrackSelectorPID::Status) template - TrackSelectorPID::Status statusTpcAndTof(const T& track) + TrackSelectorPID::Status statusTpcAndTof(const T& track, float tpcNSigmaCustom = -999.f, float tofNSigmaCustom = -999.f) { int pidTpc = TrackSelectorPID::NotApplicable; if (track.hasTPC()) { - pidTpc = statusTpc(track); + pidTpc = statusTpc(track, tpcNSigmaCustom); } int pidTof = TrackSelectorPID::NotApplicable; if (track.hasTOF()) { - pidTof = statusTof(track); + pidTof = statusTof(track, tofNSigmaCustom); } if (pidTpc == TrackSelectorPID::Accepted && pidTof == TrackSelectorPID::Accepted) { diff --git a/Common/DataModel/CMakeLists.txt b/Common/DataModel/CMakeLists.txt index 312e9c15225..39e83d2a2dd 100644 --- a/Common/DataModel/CMakeLists.txt +++ b/Common/DataModel/CMakeLists.txt @@ -20,4 +20,7 @@ o2physics_add_header_only_library(DataModel TrackSelectionTables.h McCollisionExtra.h Qvectors.h - MftmchMatchingML.h) + MatchMFTFT0.h + MftmchMatchingML.h + ZDCInterCalib.h + EseTable.h) diff --git a/Common/DataModel/Centrality.h b/Common/DataModel/Centrality.h index f89e6b23e71..a4701ef56a3 100644 --- a/Common/DataModel/Centrality.h +++ b/Common/DataModel/Centrality.h @@ -54,6 +54,23 @@ using CentFT0A = CentFT0As::iterator; using CentFT0C = CentFT0Cs::iterator; using CentFDDM = CentFDDMs::iterator; using CentNTPV = CentNTPVs::iterator; + +template +concept HasRun2Centrality = requires(T&& t) { + { t.centRun2V0M() }; + { t.centRun2CL0() }; + { t.centRun2CL1() }; +}; + +template +concept HasCentrality = requires(T&& t) { + { t.centFV0A() }; + { t.centFT0M() }; + { t.centFT0A() }; + { t.centFT0C() }; + { t.centNTPV() }; +}; + } // namespace o2::aod #endif // COMMON_DATAMODEL_CENTRALITY_H_ diff --git a/Common/DataModel/EseTable.h b/Common/DataModel/EseTable.h new file mode 100644 index 00000000000..ca9bd41357e --- /dev/null +++ b/Common/DataModel/EseTable.h @@ -0,0 +1,49 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// q vector framework with ESE (20/08/2024) +// +/// \author Joachim Hansen +// + +#ifndef COMMON_DATAMODEL_ESETABLE_H_ +#define COMMON_DATAMODEL_ESETABLE_H_ + +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +namespace o2::aod +{ +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); +} // 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); + +using QPercentileFT0C = QPercentileFT0Cs::iterator; +using QPercentileFT0A = QPercentileFT0As::iterator; +using QPercentileFV0A = QPercentileFV0As::iterator; +using QPercentileTPC = QPercentileTPCs::iterator; +using FEseCol = FEseCols::iterator; + +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_ESETABLE_H_ diff --git a/Common/DataModel/EventSelection.h b/Common/DataModel/EventSelection.h index ea1cce4ebbb..7b7b4ac9ae0 100644 --- a/Common/DataModel/EventSelection.h +++ b/Common/DataModel/EventSelection.h @@ -54,7 +54,9 @@ 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(NumTracksInTimeRange, trackOccupancyInTimeRange, int); //! Occupancy in specified time interval +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 } // namespace evsel // bc-joinable event selection decisions @@ -64,7 +66,18 @@ using BcSel = BcSels::iterator; // collision-joinable event selection decisions DECLARE_SOA_TABLE(EvSels, "AOD", "EVSEL", //! - evsel::Alias, evsel::Selection, evsel::Sel7, evsel::Sel8, evsel::FoundBCId, evsel::FoundFT0Id, evsel::FoundFV0Id, evsel::FoundFDDId, evsel::FoundZDCId, evsel::NumTracksInTimeRange); + evsel::Alias, + evsel::Selection, + evsel::Sel7, + evsel::Sel8, + evsel::FoundBCId, + evsel::FoundFT0Id, + evsel::FoundFV0Id, + evsel::FoundFDDId, + evsel::FoundZDCId, + evsel::BcInTF, + evsel::NumTracksInTimeRange, + evsel::SumAmpFT0CInTimeRange); using EvSel = EvSels::iterator; } // namespace o2::aod diff --git a/Common/DataModel/MatchMFTFT0.h b/Common/DataModel/MatchMFTFT0.h new file mode 100644 index 00000000000..21ee19b696f --- /dev/null +++ b/Common/DataModel/MatchMFTFT0.h @@ -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. + +// \file MatchMFTFT0.h +// \author Sarah Herrmann +// +// \brief Declaration of tables useful for the matching of MFT tracks to FT0-C signals +// \date 03/09/24 + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace indices +{ // For bctoft0c +DECLARE_SOA_ARRAY_INDEX_COLUMN(FT0, ft0s); // has_ft0s works now, without it doesn't +DECLARE_SOA_ARRAY_INDEX_COLUMN(BC, bcs); // has_bcs works now, without it doesn't +} // namespace indices +namespace ambii +{ // for MA2T +DECLARE_SOA_INDEX_COLUMN(MFTTrack, track); +} // namespace ambii +DECLARE_SOA_TABLE(MatchedToFT0, "AOD", "MAFT", indices::BCId, indices::FT0Ids); + +DECLARE_SOA_TABLE(BCofMFT, "AOD", "BCOFMFT", ambii::MFTTrackId, indices::BCIds); +} // namespace o2::aod diff --git a/Common/DataModel/Multiplicity.h b/Common/DataModel/Multiplicity.h index 97d6661bb6a..3583095ee67 100644 --- a/Common/DataModel/Multiplicity.h +++ b/Common/DataModel/Multiplicity.h @@ -51,6 +51,7 @@ DECLARE_SOA_COLUMN(MultMCFT0C, multMCFT0C, int); //! DECLARE_SOA_COLUMN(MultMCNParticlesEta10, multMCNParticlesEta10, int); //! DECLARE_SOA_COLUMN(MultMCNParticlesEta08, multMCNParticlesEta08, int); //! DECLARE_SOA_COLUMN(MultMCNParticlesEta05, multMCNParticlesEta05, int); //! +DECLARE_SOA_COLUMN(MultMCPVz, multMCPVz, float); //! // complementary / MultsExtra table DECLARE_SOA_COLUMN(MultPVTotalContributors, multPVTotalContributors, int); //! @@ -72,8 +73,9 @@ DECLARE_SOA_COLUMN(MultNTracksITSTPC, multNTracksITSTPC, int); //! DECLARE_SOA_COLUMN(MultAllTracksTPCOnly, multAllTracksTPCOnly, int); //! DECLARE_SOA_COLUMN(MultAllTracksITSTPC, multAllTracksITSTPC, int); //! DECLARE_SOA_COLUMN(MultNTracksGlobal, multNTracksGlobal, int); //! - -DECLARE_SOA_COLUMN(BCNumber, bcNumber, int); //! +DECLARE_SOA_COLUMN(MultNGlobalTracksPV, multNGlobalTracksPV, int); +DECLARE_SOA_COLUMN(MultNGlobalTracksPVeta1, multNGlobalTracksPVeta1, int); +DECLARE_SOA_COLUMN(MultNGlobalTracksPVetaHalf, multNGlobalTracksPVetaHalf, int); // even further QA: timing information for neighboring events DECLARE_SOA_COLUMN(TimeToPrePrevious, timeToPrePrevious, float); //! @@ -105,15 +107,27 @@ DECLARE_SOA_TABLE(PVMults, "AOD", "PVMULT", //! Multiplicity from the PV contrib mult::IsInelGt1); using BarrelMults = soa::Join; using Mults = soa::Join; +using FT0Mult = FT0Mults::iterator; using Mult = Mults::iterator; -// for QA purposes -DECLARE_SOA_TABLE(MultsExtra, "AOD", "MULTEXTRA", //! +DECLARE_SOA_TABLE(MultsExtra_000, "AOD", "MULTEXTRA", //! mult::MultPVTotalContributors, mult::MultPVChi2, mult::MultCollisionTimeRes, mult::MultRunNumber, mult::MultPVz, mult::MultSel8, mult::MultNTracksHasITS, mult::MultNTracksHasTPC, mult::MultNTracksHasTOF, mult::MultNTracksHasTRD, mult::MultNTracksITSOnly, mult::MultNTracksTPCOnly, mult::MultNTracksITSTPC, mult::MultAllTracksTPCOnly, mult::MultAllTracksITSTPC, - mult::BCNumber, evsel::NumTracksInTimeRange); + evsel::NumTracksInTimeRange, + collision::Flags); + +DECLARE_SOA_TABLE_VERSIONED(MultsExtra_001, "AOD", "MULTEXTRA", 1, //! debug information + mult::MultPVTotalContributors, mult::MultPVChi2, mult::MultCollisionTimeRes, mult::MultRunNumber, mult::MultPVz, mult::MultSel8, + mult::MultNTracksHasITS, mult::MultNTracksHasTPC, mult::MultNTracksHasTOF, mult::MultNTracksHasTRD, + mult::MultNTracksITSOnly, mult::MultNTracksTPCOnly, mult::MultNTracksITSTPC, + mult::MultAllTracksTPCOnly, mult::MultAllTracksITSTPC, + evsel::NumTracksInTimeRange, + evsel::SumAmpFT0CInTimeRange, + collision::Flags); + +using MultsExtra = MultsExtra_001; DECLARE_SOA_TABLE(MultNeighs, "AOD", "MULTNEIGH", //! mult::TimeToPrePrevious, mult::TimeToPrevious, @@ -121,20 +135,36 @@ DECLARE_SOA_TABLE(MultNeighs, "AOD", "MULTNEIGH", //! // for QA purposes DECLARE_SOA_TABLE(MultsGlobal, "AOD", "MULTGLOBAL", //! counters that use Track Selection (optional) - mult::MultNTracksGlobal); + mult::MultNTracksGlobal, + mult::MultNGlobalTracksPV, + mult::MultNGlobalTracksPVeta1, + mult::MultNGlobalTracksPVetaHalf); DECLARE_SOA_TABLE(MultSelections, "AOD", "MULTSELECTIONS", //! evsel::Selection); // for derived data / QA studies using MultExtra = MultsExtra::iterator; -DECLARE_SOA_TABLE(MultsExtraMC, "AOD", "MULTEXTRAMC", //! Table for the MC information + +// mc collisions table - indexed to Mult +DECLARE_SOA_TABLE(MultMCExtras, "AOD", "MULTMCEXTRA", //! Table for the MC information mult::MultMCFT0A, mult::MultMCFT0C, mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10, + mult::MultMCPVz, mult::IsInelGt0, mult::IsInelGt1, o2::soa::Marker<1>); -using MultExtraMC = MultsExtraMC::iterator; +using MultMCExtra = MultMCExtras::iterator; +using MultsExtraMC = MultMCExtras; // for backwards compatibility with previous naming scheme + +// crosslinks +namespace mult +{ +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); namespace multZeq { @@ -164,12 +194,12 @@ DECLARE_SOA_COLUMN(MultBCFV0A, multBCFV0A, float); //! DECLARE_SOA_COLUMN(MultBCFDDA, multBCFDDA, float); //! DECLARE_SOA_COLUMN(MultBCFDDC, multBCFDDC, float); //! -DECLARE_SOA_COLUMN(MultBCFZNA, multBCFZNA, float); //! -DECLARE_SOA_COLUMN(MultBCFZNC, multBCFZNC, float); //! -DECLARE_SOA_COLUMN(MultBCFZEM1, multBCFZEM1, float); //! -DECLARE_SOA_COLUMN(MultBCFZEM2, multBCFZEM2, float); //! -DECLARE_SOA_COLUMN(MultBCFZPA, multBCFZPA, float); //! -DECLARE_SOA_COLUMN(MultBCFZPC, multBCFZPC, float); //! +DECLARE_SOA_COLUMN(MultBCZNA, multBCZNA, float); //! +DECLARE_SOA_COLUMN(MultBCZNC, multBCZNC, float); //! +DECLARE_SOA_COLUMN(MultBCZEM1, multBCZEM1, float); //! +DECLARE_SOA_COLUMN(MultBCZEM2, multBCZEM2, float); //! +DECLARE_SOA_COLUMN(MultBCZPA, multBCZPA, float); //! +DECLARE_SOA_COLUMN(MultBCZPC, multBCZPC, float); //! DECLARE_SOA_COLUMN(MultBCTVX, multBCTVX, bool); //! DECLARE_SOA_COLUMN(MultBCFV0OrA, multBCFV0OrA, bool); //! @@ -178,27 +208,50 @@ DECLARE_SOA_COLUMN(MultBCT0triggerBits, multBCT0triggerBits, uint8_t); //! DECLARE_SOA_COLUMN(MultBCFDDtriggerBits, multBCFDDtriggerBits, uint8_t); //! DECLARE_SOA_COLUMN(MultBCTriggerMask, multBCTriggerMask, uint64_t); //! CTP trigger mask DECLARE_SOA_COLUMN(MultBCColliding, multBCColliding, bool); //! CTP trigger mask + +DECLARE_SOA_COLUMN(MultBCFT0PosZ, multBCFT0PosZ, float); //! Position along Z computed with the FT0 information within the BC +DECLARE_SOA_COLUMN(MultBCFT0PosZValid, multBCFT0PosZValid, bool); //! Validity of the position along Z computed with the FT0 information within the BC + } // namespace multBC -DECLARE_SOA_TABLE(MultsBC, "AOD", "MULTBC", //! +DECLARE_SOA_TABLE(MultBCs, "AOD", "MULTBC", //! multBC::MultBCFT0A, multBC::MultBCFT0C, + multBC::MultBCFT0PosZ, + multBC::MultBCFT0PosZValid, multBC::MultBCFV0A, multBC::MultBCFDDA, multBC::MultBCFDDC, - multBC::MultBCFZNA, - multBC::MultBCFZNC, - multBC::MultBCFZEM1, - multBC::MultBCFZEM2, - multBC::MultBCFZPA, - multBC::MultBCFZPC, + multBC::MultBCZNA, + multBC::MultBCZNC, + multBC::MultBCZEM1, + multBC::MultBCZEM2, + multBC::MultBCZPA, + multBC::MultBCZPC, multBC::MultBCTVX, multBC::MultBCFV0OrA, multBC::MultBCV0triggerBits, multBC::MultBCT0triggerBits, multBC::MultBCFDDtriggerBits, multBC::MultBCTriggerMask, - multBC::MultBCColliding); -using MultBC = MultsBC::iterator; + multBC::MultBCColliding, + bc::Flags); +using MultBC = MultBCs::iterator; + +// crosslinks +namespace mult +{ +DECLARE_SOA_INDEX_COLUMN(MultBC, multBC); +} +namespace multBC +{ +DECLARE_SOA_INDEX_COLUMN(FT0Mult, ft0Mult); +} + +// for QA purposes +DECLARE_SOA_TABLE(Mults2BC, "AOD", "MULTS2BC", //! Relate mult -> BC + o2::soa::Index<>, mult::MultBCId); +DECLARE_SOA_TABLE(BC2Mults, "AOD", "BC2MULTS", //! Relate BC -> mult + o2::soa::Index<>, multBC::FT0MultId); } // namespace o2::aod diff --git a/Common/DataModel/PIDResponseITS.h b/Common/DataModel/PIDResponseITS.h new file mode 100644 index 00000000000..44c029fcb75 --- /dev/null +++ b/Common/DataModel/PIDResponseITS.h @@ -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 PIDResponseITS.h +/// \since 2024-11-12 +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \author Francesco Mazzaschi francesco.mazzaschi@cern.ch +/// \author Giorgio Alberto Lucia giorgio.alberto.lucia@cern.ch +/// \brief Set of tables, tasks and utilities to provide the interface between +/// the analysis data model and the PID response of the ITS +/// + +#ifndef COMMON_DATAMODEL_PIDRESPONSEITS_H_ +#define COMMON_DATAMODEL_PIDRESPONSEITS_H_ + +// O2 includes +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/PID.h" +#include "Framework/Logger.h" + +namespace o2::aod +{ + +struct ITSResponse { + static float averageClusterSize(uint32_t itsClusterSizes) + { + float average = 0; + int nclusters = 0; + + 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 / nclusters; + }; + + template + static float expSignal(const float momentum) + { + 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; + if (id == o2::track::PID::Helium3 || id == o2::track::PID::Alpha) { + return (mITSRespParamsZ2[0] / (std::pow(bg, mITSRespParamsZ2[1])) + mITSRespParamsZ2[2]); + } + return (mITSRespParams[0] / (std::pow(bg, mITSRespParams[1])) + mITSRespParams[2]); + } + + template + static float expResolution(const float momentum) + { + 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; + } + + template + static float nSigmaITS(uint32_t itsClusterSizes, float momentum, float eta) + { + const float exp = expSignal(momentum); + const float average = averageClusterSize(itsClusterSizes); + const float coslInv = 1. / std::cosh(eta); + const float resolution = expResolution(momentum) * exp; + return (average * coslInv - exp) / resolution; + }; + + 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) + { + if (mIsInitialized) { + LOG(fatal) << "ITSResponse parameters already initialized"; + } + mIsInitialized = true; + mITSRespParams[0] = p0; + mITSRespParams[1] = p1; + mITSRespParams[2] = p2; + mITSRespParamsZ2[0] = p0_Z2; + mITSRespParamsZ2[1] = p1_Z2; + mITSRespParamsZ2[2] = p2_Z2; + mResolutionParams[0] = p0_res; + mResolutionParams[1] = p1_res; + mResolutionParams[2] = p2_res; + } + + private: + static std::array mITSRespParams; + static std::array mITSRespParamsZ2; + static std::array mResolutionParams; + static bool mIsInitialized; +}; + +std::array ITSResponse::mITSRespParams = {1.1576, 1.684, 1.9453}; +std::array ITSResponse::mITSRespParamsZ2 = {2.8752, 1.1246, 5.0259}; +// relative resolution is modelled with an erf function: [0]*TMath::Erf((x-[1])/[2]) +std::array ITSResponse::mResolutionParams = {0.2431, -0.3293, 1.533}; +bool ITSResponse::mIsInitialized = false; + +namespace pidits +{ +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaElImp, itsNSigmaEl, //! Nsigma separation with the ITS detector for electrons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaMuImp, itsNSigmaMu, //! Nsigma separation with the ITS detector for muons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaPiImp, itsNSigmaPi, //! Nsigma separation with the ITS detector for pions + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaKaImp, itsNSigmaKa, //! Nsigma separation with the ITS detector for kaons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaPrImp, itsNSigmaPr, //! Nsigma separation with the ITS detector for protons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaDeImp, itsNSigmaDe, //! Nsigma separation with the ITS detector for deuterons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaTrImp, itsNSigmaTr, //! Nsigma separation with the ITS detector for tritons + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaHeImp, itsNSigmaHe, //! Nsigma separation with the ITS detector for helium3 + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +DECLARE_SOA_DYNAMIC_COLUMN(ITSNSigmaAlImp, itsNSigmaAl, //! Nsigma separation with the ITS detector for alphas + [](uint32_t itsClusterSizes, float momentum, float eta) -> float { + return ITSResponse::nSigmaITS(itsClusterSizes, momentum, eta); + }); + +// Define user friendly names for the columns to join with the tracks +using ITSNSigmaEl = ITSNSigmaElImp; +using ITSNSigmaMu = ITSNSigmaMuImp; +using ITSNSigmaPi = ITSNSigmaPiImp; +using ITSNSigmaKa = ITSNSigmaKaImp; +using ITSNSigmaPr = ITSNSigmaPrImp; +using ITSNSigmaDe = ITSNSigmaDeImp; +using ITSNSigmaTr = ITSNSigmaTrImp; +using ITSNSigmaHe = ITSNSigmaHeImp; +using ITSNSigmaAl = ITSNSigmaAlImp; + +} // namespace pidits +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_PIDRESPONSEITS_H_ diff --git a/Common/DataModel/Qvectors.h b/Common/DataModel/Qvectors.h index 2185e1bb7c2..423c2648e89 100644 --- a/Common/DataModel/Qvectors.h +++ b/Common/DataModel/Qvectors.h @@ -43,12 +43,12 @@ DECLARE_SOA_COLUMN(QvecFT0MReVec, qvecFT0MReVec, std::vector); DECLARE_SOA_COLUMN(QvecFT0MImVec, qvecFT0MImVec, std::vector); DECLARE_SOA_COLUMN(QvecFV0AReVec, qvecFV0AReVec, std::vector); DECLARE_SOA_COLUMN(QvecFV0AImVec, qvecFV0AImVec, std::vector); -DECLARE_SOA_COLUMN(QvecBPosReVec, qvecBPosReVec, std::vector); -DECLARE_SOA_COLUMN(QvecBPosImVec, qvecBPosImVec, std::vector); -DECLARE_SOA_COLUMN(QvecBNegReVec, qvecBNegReVec, std::vector); -DECLARE_SOA_COLUMN(QvecBNegImVec, qvecBNegImVec, std::vector); -DECLARE_SOA_COLUMN(QvecBTotReVec, qvecBTotReVec, std::vector); -DECLARE_SOA_COLUMN(QvecBTotImVec, qvecBTotImVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCposReVec, qvecTPCposReVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCposImVec, qvecTPCposImVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCnegReVec, qvecTPCnegReVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCnegImVec, qvecTPCnegImVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCallReVec, qvecTPCallReVec, std::vector); +DECLARE_SOA_COLUMN(QvecTPCallImVec, qvecTPCallImVec, std::vector); DECLARE_SOA_COLUMN(QvecFT0CRe, qvecFT0CRe, float); DECLARE_SOA_COLUMN(QvecFT0CIm, qvecFT0CIm, float); @@ -58,6 +58,32 @@ DECLARE_SOA_COLUMN(QvecFT0MRe, qvecFT0MRe, float); DECLARE_SOA_COLUMN(QvecFT0MIm, qvecFT0MIm, float); DECLARE_SOA_COLUMN(QvecFV0ARe, qvecFV0ARe, float); DECLARE_SOA_COLUMN(QvecFV0AIm, qvecFV0AIm, float); +DECLARE_SOA_COLUMN(QvecTPCposRe, qvecTPCposRe, float); +DECLARE_SOA_COLUMN(QvecTPCposIm, qvecTPCposIm, float); +DECLARE_SOA_COLUMN(QvecTPCnegRe, qvecTPCnegRe, float); +DECLARE_SOA_COLUMN(QvecTPCnegIm, qvecTPCnegIm, float); +DECLARE_SOA_COLUMN(QvecTPCallRe, qvecTPCallRe, float); +DECLARE_SOA_COLUMN(QvecTPCallIm, qvecTPCallIm, float); + +DECLARE_SOA_COLUMN(SumAmplFT0C, sumAmplFT0C, float); +DECLARE_SOA_COLUMN(SumAmplFT0A, sumAmplFT0A, float); +DECLARE_SOA_COLUMN(SumAmplFT0M, sumAmplFT0M, float); +DECLARE_SOA_COLUMN(SumAmplFV0A, sumAmplFV0A, float); +DECLARE_SOA_COLUMN(NTrkTPCpos, nTrkTPCpos, int); +DECLARE_SOA_COLUMN(NTrkTPCneg, nTrkTPCneg, int); +DECLARE_SOA_COLUMN(NTrkTPCall, nTrkTPCall, int); +DECLARE_SOA_COLUMN(LabelsTPCpos, labelsTPCpos, std::vector); +DECLARE_SOA_COLUMN(LabelsTPCneg, labelsTPCneg, std::vector); +DECLARE_SOA_COLUMN(LabelsTPCall, labelsTPCall, std::vector); + +// Deprecated, will be removed in future after transition time // +DECLARE_SOA_COLUMN(QvecBPosReVec, qvecBPosReVec, std::vector); +DECLARE_SOA_COLUMN(QvecBPosImVec, qvecBPosImVec, std::vector); +DECLARE_SOA_COLUMN(QvecBNegReVec, qvecBNegReVec, std::vector); +DECLARE_SOA_COLUMN(QvecBNegImVec, qvecBNegImVec, std::vector); +DECLARE_SOA_COLUMN(QvecBTotReVec, qvecBTotReVec, std::vector); +DECLARE_SOA_COLUMN(QvecBTotImVec, qvecBTotImVec, std::vector); + DECLARE_SOA_COLUMN(QvecBPosRe, qvecBPosRe, float); DECLARE_SOA_COLUMN(QvecBPosIm, qvecBPosIm, float); DECLARE_SOA_COLUMN(QvecBNegRe, qvecBNegRe, float); @@ -65,16 +91,13 @@ DECLARE_SOA_COLUMN(QvecBNegIm, qvecBNegIm, float); DECLARE_SOA_COLUMN(QvecBTotRe, qvecBTotRe, float); DECLARE_SOA_COLUMN(QvecBTotIm, qvecBTotIm, float); -DECLARE_SOA_COLUMN(SumAmplFT0C, sumAmplFT0C, float); -DECLARE_SOA_COLUMN(SumAmplFT0A, sumAmplFT0A, float); -DECLARE_SOA_COLUMN(SumAmplFT0M, sumAmplFT0M, float); -DECLARE_SOA_COLUMN(SumAmplFV0A, sumAmplFV0A, float); DECLARE_SOA_COLUMN(NTrkBPos, nTrkBPos, int); DECLARE_SOA_COLUMN(NTrkBNeg, nTrkBNeg, int); DECLARE_SOA_COLUMN(NTrkBTot, nTrkBTot, int); DECLARE_SOA_COLUMN(LabelsBPos, labelsBPos, std::vector); DECLARE_SOA_COLUMN(LabelsBNeg, labelsBNeg, std::vector); DECLARE_SOA_COLUMN(LabelsBTot, labelsBTot, std::vector); +///////////////////////////////////////////////////////////////// } // namespace qvec DECLARE_SOA_TABLE(Qvectors, "AOD", "QVECTORDEVS", //! Table with all Qvectors. @@ -85,33 +108,51 @@ DECLARE_SOA_TABLE(QvectorFT0Cs, "AOD", "QVECTORSFT0C", qvec::IsCalibrated, qvec: DECLARE_SOA_TABLE(QvectorFT0As, "AOD", "QVECTORSFT0A", qvec::IsCalibrated, qvec::QvecFT0ARe, qvec::QvecFT0AIm, qvec::SumAmplFT0A); DECLARE_SOA_TABLE(QvectorFT0Ms, "AOD", "QVECTORSFT0M", qvec::IsCalibrated, qvec::QvecFT0MRe, qvec::QvecFT0MIm, qvec::SumAmplFT0M); DECLARE_SOA_TABLE(QvectorFV0As, "AOD", "QVECTORSFV0A", qvec::IsCalibrated, qvec::QvecFV0ARe, qvec::QvecFV0AIm, qvec::SumAmplFV0A); -DECLARE_SOA_TABLE(QvectorBPoss, "AOD", "QVECTORSBPOS", qvec::IsCalibrated, qvec::QvecBPosRe, qvec::QvecBPosIm, qvec::NTrkBPos, qvec::LabelsBPos); -DECLARE_SOA_TABLE(QvectorBNegs, "AOD", "QVECTORSBNEG", qvec::IsCalibrated, qvec::QvecBNegRe, qvec::QvecBNegIm, qvec::NTrkBNeg, qvec::LabelsBNeg); -DECLARE_SOA_TABLE(QvectorBTots, "AOD", "QVECTORSBTOT", qvec::IsCalibrated, qvec::QvecBTotRe, qvec::QvecBTotIm, qvec::NTrkBTot, qvec::LabelsBTot); +DECLARE_SOA_TABLE(QvectorTPCposs, "AOD", "QVECTORSTPCPOS", qvec::IsCalibrated, qvec::QvecTPCposRe, qvec::QvecTPCposIm, qvec::NTrkTPCpos, qvec::LabelsTPCpos); +DECLARE_SOA_TABLE(QvectorTPCnegs, "AOD", "QVECTORSTPCNEG", qvec::IsCalibrated, qvec::QvecTPCnegRe, qvec::QvecTPCnegIm, qvec::NTrkTPCneg, qvec::LabelsTPCneg); +DECLARE_SOA_TABLE(QvectorTPCalls, "AOD", "QVECTORSTPCALL", qvec::IsCalibrated, qvec::QvecTPCallRe, qvec::QvecTPCallIm, qvec::NTrkTPCall, qvec::LabelsTPCall); DECLARE_SOA_TABLE(QvectorFT0CVecs, "AOD", "QVECTORSFT0CVEC", qvec::IsCalibrated, qvec::QvecFT0CReVec, qvec::QvecFT0CImVec, qvec::SumAmplFT0C); DECLARE_SOA_TABLE(QvectorFT0AVecs, "AOD", "QVECTORSFT0AVEC", qvec::IsCalibrated, qvec::QvecFT0AReVec, qvec::QvecFT0AImVec, qvec::SumAmplFT0A); DECLARE_SOA_TABLE(QvectorFT0MVecs, "AOD", "QVECTORSFT0MVEC", qvec::IsCalibrated, qvec::QvecFT0MReVec, qvec::QvecFT0MImVec, qvec::SumAmplFT0M); DECLARE_SOA_TABLE(QvectorFV0AVecs, "AOD", "QVECTORSFV0AVEC", qvec::IsCalibrated, qvec::QvecFV0AReVec, qvec::QvecFV0AImVec, qvec::SumAmplFV0A); -DECLARE_SOA_TABLE(QvectorBPosVecs, "AOD", "QVECTORSBPOSVEC", qvec::IsCalibrated, qvec::QvecBPosReVec, qvec::QvecBPosImVec, qvec::NTrkBPos, qvec::LabelsBPos); -DECLARE_SOA_TABLE(QvectorBNegVecs, "AOD", "QVECTORSBNEGVEC", qvec::IsCalibrated, qvec::QvecBNegReVec, qvec::QvecBNegImVec, qvec::NTrkBNeg, qvec::LabelsBNeg); -DECLARE_SOA_TABLE(QvectorBTotVecs, "AOD", "QVECTORSBTOTVEC", qvec::IsCalibrated, qvec::QvecBTotReVec, qvec::QvecBTotImVec, qvec::NTrkBTot, qvec::LabelsBTot); +DECLARE_SOA_TABLE(QvectorTPCposVecs, "AOD", "QVECTORSTPCPVEC", qvec::IsCalibrated, qvec::QvecTPCposReVec, qvec::QvecTPCposImVec, qvec::NTrkTPCpos, qvec::LabelsTPCpos); +DECLARE_SOA_TABLE(QvectorTPCnegVecs, "AOD", "QVECTORSTPCNVEC", qvec::IsCalibrated, qvec::QvecTPCnegReVec, qvec::QvecTPCnegImVec, qvec::NTrkTPCneg, qvec::LabelsTPCneg); +DECLARE_SOA_TABLE(QvectorTPCallVecs, "AOD", "QVECTORSTPCAVEC", qvec::IsCalibrated, qvec::QvecTPCallReVec, qvec::QvecTPCallImVec, qvec::NTrkTPCall, qvec::LabelsTPCall); using QvectorFT0C = QvectorFT0Cs::iterator; using QvectorFT0A = QvectorFT0As::iterator; using QvectorFT0M = QvectorFT0Ms::iterator; using QvectorFV0A = QvectorFV0As::iterator; -using QvectorBPos = QvectorBPoss::iterator; -using QvectorBNeg = QvectorBNegs::iterator; -using QvectorBTot = QvectorBTots::iterator; +using QvectorTPCpos = QvectorTPCposs::iterator; +using QvectorTPCneg = QvectorTPCnegs::iterator; +using QvectorTPCall = QvectorTPCalls::iterator; using QvectorFT0CVec = QvectorFT0CVecs::iterator; using QvectorFT0AVec = QvectorFT0AVecs::iterator; using QvectorFT0MVec = QvectorFT0MVecs::iterator; using QvectorFV0AVec = QvectorFV0AVecs::iterator; +using QvectorTPCposVec = QvectorTPCposVecs::iterator; +using QvectorTPCnegVec = QvectorTPCnegVecs::iterator; +using QvectorTPCallVec = QvectorTPCallVecs::iterator; + +// Deprecated, will be removed in future after transition time // +DECLARE_SOA_TABLE(QvectorBPoss, "AOD", "QVECTORSBPOS", qvec::IsCalibrated, qvec::QvecBPosRe, qvec::QvecBPosIm, qvec::NTrkBPos, qvec::LabelsBPos); +DECLARE_SOA_TABLE(QvectorBNegs, "AOD", "QVECTORSBNEG", qvec::IsCalibrated, qvec::QvecBNegRe, qvec::QvecBNegIm, qvec::NTrkBNeg, qvec::LabelsBNeg); +DECLARE_SOA_TABLE(QvectorBTots, "AOD", "QVECTORSBTOT", qvec::IsCalibrated, qvec::QvecBTotRe, qvec::QvecBTotIm, qvec::NTrkBTot, qvec::LabelsBTot); + +DECLARE_SOA_TABLE(QvectorBPosVecs, "AOD", "QVECTORSBPOSVEC", qvec::IsCalibrated, qvec::QvecBPosReVec, qvec::QvecBPosImVec, qvec::NTrkBPos, qvec::LabelsBPos); +DECLARE_SOA_TABLE(QvectorBNegVecs, "AOD", "QVECTORSBNEGVEC", qvec::IsCalibrated, qvec::QvecBNegReVec, qvec::QvecBNegImVec, qvec::NTrkBNeg, qvec::LabelsBNeg); +DECLARE_SOA_TABLE(QvectorBTotVecs, "AOD", "QVECTORSBTOTVEC", qvec::IsCalibrated, qvec::QvecBTotReVec, qvec::QvecBTotImVec, qvec::NTrkBTot, qvec::LabelsBTot); + +using QvectorBPos = QvectorBPoss::iterator; +using QvectorBNeg = QvectorBNegs::iterator; +using QvectorBTot = QvectorBTots::iterator; + using QvectorBPosVec = QvectorBPosVecs::iterator; using QvectorBNegVec = QvectorBNegVecs::iterator; using QvectorBTotVec = QvectorBTotVecs::iterator; +///////////////////////////////////////////////////////////////// } // namespace o2::aod diff --git a/Common/DataModel/TrackSelectionTables.h b/Common/DataModel/TrackSelectionTables.h index cc27e06bfe7..46ebf03868f 100644 --- a/Common/DataModel/TrackSelectionTables.h +++ b/Common/DataModel/TrackSelectionTables.h @@ -60,6 +60,7 @@ struct TrackSelectionFlags { static constexpr flagtype kGlobalTrackWoTPCCluster = kQualityTracksWoTPCCluster | kPrimaryTracks | kInAcceptanceTracks; static constexpr flagtype kGlobalTrackWoPtEta = kQualityTracks | kPrimaryTracks; static constexpr flagtype kGlobalTrackWoDCA = kQualityTracks | kInAcceptanceTracks; + static constexpr flagtype kGlobalTrackWoDCAxy = kQualityTracks | kInAcceptanceTracks | kDCAz; static constexpr flagtype kGlobalTrackWoDCATPCCluster = kQualityTracksWoTPCCluster | kInAcceptanceTracks; /// @brief Function to check flag content diff --git a/Common/DataModel/ZDCInterCalib.h b/Common/DataModel/ZDCInterCalib.h new file mode 100644 index 00000000000..5ab722452af --- /dev/null +++ b/Common/DataModel/ZDCInterCalib.h @@ -0,0 +1,46 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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_DATAMODEL_ZDCINTERCALIB_H_ +#define COMMON_DATAMODEL_ZDCINTERCALIB_H_ + +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace znoutput +{ +DECLARE_SOA_COLUMN(pmcZNA, ZNAcommonPM, float); //! PMC ZNA +DECLARE_SOA_COLUMN(pm1ZNA, ZNAPM1, float); //! PM1 ZNA +DECLARE_SOA_COLUMN(pm2ZNA, ZNAPM2, float); //! PM2 ZNA +DECLARE_SOA_COLUMN(pm3ZNA, ZNAPM3, float); //! PM3 ZNA +DECLARE_SOA_COLUMN(pm4ZNA, ZNAPM4, float); //! PM4 ZNA +DECLARE_SOA_COLUMN(pmcZNC, ZNCcommonPM, float); //! PMC ZNC +DECLARE_SOA_COLUMN(pm1ZNC, ZNCPM1, float); //! PM1 ZNC +DECLARE_SOA_COLUMN(pm2ZNC, ZNCPM2, float); //! PM2 ZNC +DECLARE_SOA_COLUMN(pm3ZNC, ZNCPM3, float); //! PM3 ZNC +DECLARE_SOA_COLUMN(pm4ZNC, ZNCPM4, float); //! PM4 ZNC + +} // namespace znoutput + +DECLARE_SOA_TABLE(ZDCInterCalib, "AOD", "ZDCIC", o2::soa::Index<>, + znoutput::pmcZNA, + znoutput::pm1ZNA, + znoutput::pm2ZNA, + znoutput::pm3ZNA, + znoutput::pm4ZNA, + znoutput::pmcZNC, + znoutput::pm1ZNC, + znoutput::pm2ZNC, + znoutput::pm3ZNC, + znoutput::pm4ZNC); +} // namespace o2::aod + +#endif // COMMON_DATAMODEL_ZDCINTERCALIB_H_ diff --git a/Common/TableProducer/CMakeLists.txt b/Common/TableProducer/CMakeLists.txt index 7cd53628f18..91513029f73 100644 --- a/Common/TableProducer/CMakeLists.txt +++ b/Common/TableProducer/CMakeLists.txt @@ -112,3 +112,25 @@ o2physics_add_dpl_workflow(mftmchmatchingml O2::CCDB O2Physics::MLCore O2::ReconstructionDataFormats COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(match-mft-ft0 + SOURCES match-mft-ft0.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + O2::ReconstructionDataFormats + O2::DetectorsBase O2::DetectorsCommonDataFormats + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(zdc-task-intercalib + SOURCES zdc-task-intercalib.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(ese-table-producer + SOURCES eseTableProducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +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 + COMPONENT_NAME Analysis) diff --git a/Common/TableProducer/Converters/CMakeLists.txt b/Common/TableProducer/Converters/CMakeLists.txt index cbec8fc2d1e..aedc7257229 100644 --- a/Common/TableProducer/Converters/CMakeLists.txt +++ b/Common/TableProducer/Converters/CMakeLists.txt @@ -39,11 +39,21 @@ o2physics_add_dpl_workflow(collision-converter PUBLIC_LINK_LIBRARIES COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(mccollision-converter + SOURCES mcCollisionConverter.cxx + PUBLIC_LINK_LIBRARIES + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(bc-converter SOURCES bcConverter.cxx PUBLIC_LINK_LIBRARIES O2::Framework COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(bc-flags-creator + SOURCES bcFlagsCreator.cxx + PUBLIC_LINK_LIBRARIES O2::Framework + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(calo-label-converter SOURCES caloLabelConverter.cxx PUBLIC_LINK_LIBRARIES @@ -59,3 +69,8 @@ o2physics_add_dpl_workflow(hmpid-converter PUBLIC_LINK_LIBRARIES COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(multsextra-converter + SOURCES multsExtraConverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/Common/TableProducer/Converters/bcFlagsCreator.cxx b/Common/TableProducer/Converters/bcFlagsCreator.cxx new file mode 100644 index 00000000000..972832716b5 --- /dev/null +++ b/Common/TableProducer/Converters/bcFlagsCreator.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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +using namespace o2; +using namespace o2::framework; + +// Creates an empty BCFlags for data that doesn't have it to be used seamlessly +// n.b. this will overwrite existing BCFlags, to be discussed if data in mixed condition +struct bcFlagsCreator { + Produces bcFlags; + + void process(aod::BCs const& bcTable) + { + for (int64_t i = 0; i < bcTable.size(); ++i) { + bcFlags(0); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/Common/TableProducer/Converters/mcCollisionConverter.cxx b/Common/TableProducer/Converters/mcCollisionConverter.cxx new file mode 100644 index 00000000000..b965a092117 --- /dev/null +++ b/Common/TableProducer/Converters/mcCollisionConverter.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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +using namespace o2; +using namespace o2::framework; + +struct mcCollisionConverter { + Produces mcCollisions_001; + + void process(aod::McCollisions_000 const& mcCollisionTable) + { + for (auto& mcCollision : mcCollisionTable) { + + // Repopulate new table + mcCollisions_001( + mcCollision.bcId(), + mcCollision.generatorsID(), + mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), + mcCollision.t(), mcCollision.weight(), + mcCollision.impactParameter(), + 0.0f); // dummy event plane, not available in _000 + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/Common/TableProducer/Converters/multsExtraConverter.cxx b/Common/TableProducer/Converters/multsExtraConverter.cxx new file mode 100644 index 00000000000..d62b34508b8 --- /dev/null +++ b/Common/TableProducer/Converters/multsExtraConverter.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. + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/Multiplicity.h" + +using namespace o2; +using namespace o2::framework; + +struct MultsExtraConverter { + Produces multsExtra_001; + void process(aod::MultsExtra_000 const& multsExtra_000) + { + for (const auto& r : multsExtra_000) { + multsExtra_001(r.multPVTotalContributors(), r.multPVChi2(), + r.multCollisionTimeRes(), r.multRunNumber(), r.multPVz(), r.multSel8(), + r.multNTracksHasITS(), r.multNTracksHasTPC(), r.multNTracksHasTOF(), + r.multNTracksHasTRD(), r.multNTracksITSOnly(), + r.multNTracksTPCOnly(), r.multNTracksITSTPC(), + r.multAllTracksTPCOnly(), r.multAllTracksITSTPC(), + r.trackOccupancyInTimeRange(), + 0.0f, + r.flags()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/PID/CMakeLists.txt b/Common/TableProducer/PID/CMakeLists.txt index dc8a89337d4..d28a3268954 100644 --- a/Common/TableProducer/PID/CMakeLists.txt +++ b/Common/TableProducer/PID/CMakeLists.txt @@ -9,8 +9,13 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -# TOF +# ITS +o2physics_add_dpl_workflow(pid-its + SOURCES pidITS.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) +# TOF o2physics_add_dpl_workflow(pid-tof-base SOURCES pidTOFBase.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFBase diff --git a/Common/TableProducer/PID/pidITS.cxx b/Common/TableProducer/PID/pidITS.cxx new file mode 100644 index 00000000000..58ac57984fe --- /dev/null +++ b/Common/TableProducer/PID/pidITS.cxx @@ -0,0 +1,122 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 pidITS.cxx +/// \since 2024-11-12 +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// \author Francesco Mazzaschi francesco.mazzaschi@cern.ch +/// \author Giorgio Alberto Lucia giorgio.alberto.lucia@cern.ch +/// \brief Task to produce PID tables for ITS split for each particle. +/// Only the tables for the mass hypotheses requested are filled, the others are sent empty. +/// + +#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 "Common/DataModel/PIDResponseITS.h" +#include "MetadataHelper.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::track; + +MetadataHelper metadataInfo; + +static constexpr int nCases = 2; +static constexpr int nParameters = 9; +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}}; + +/// 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) +struct itsPid { + + Configurable> itsParams{"itsParams", + {defaultParameters[0], nCases, nParameters, casesNames, parameterNames}, + "Response parameters"}; + Configurable getFromCCDB{"getFromCCDB", false, "Get the parameters from CCDB"}; + + Service ccdb; + Configurable paramfile{"param-file", "", "Path to the parametrization object, if empty the parametrization is not taken from file"}; + Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable ccdbPath{"ccdbPath", "Analysis/PID/TPC/Response", "Path of the TPC parametrization on the CCDB"}; + Configurable recoPass{"recoPass", "", "Reconstruction pass name for CCDB query (automatically takes latest object for timestamp if blank)"}; + 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"}; + + void init(o2::framework::InitContext&) + { + if (getFromCCDB) { + ccdb->setURL(url.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + 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")); + } + } + + /// Dummy process function for BCs, needed in case both Run2 and Run3 process functions are disabled + void process(aod::Timestamps const&) {} + + void processTest(o2::soa::Join const& tracks) + { + auto tracksWithPid = soa::Attach, + aod::pidits::ITSNSigmaEl, aod::pidits::ITSNSigmaMu, aod::pidits::ITSNSigmaPi, + aod::pidits::ITSNSigmaKa, aod::pidits::ITSNSigmaPr, aod::pidits::ITSNSigmaDe, + aod::pidits::ITSNSigmaTr, aod::pidits::ITSNSigmaHe, aod::pidits::ITSNSigmaAl>(tracks); + + for (const auto& track : tracksWithPid) { + LOG(info) << track.itsNSigmaEl(); + LOG(info) << track.itsNSigmaPi(); + LOG(info) << track.itsNSigmaPr(); + } + } + PROCESS_SWITCH(itsPid, processTest, "Produce a test", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata + metadataInfo.initMetadata(cfgc); + auto workflow = WorkflowSpec{adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Common/TableProducer/PID/pidTOFBase.cxx b/Common/TableProducer/PID/pidTOFBase.cxx index e82ea651304..f0f9722fc6b 100644 --- a/Common/TableProducer/PID/pidTOFBase.cxx +++ b/Common/TableProducer/PID/pidTOFBase.cxx @@ -46,16 +46,13 @@ float trackDistanceForGoodMatch = 999.f; float trackDistanceForGoodMatchLowMult = 999.f; int multiplicityThreshold = 0; using Run3Trks = o2::soa::Join; -using Run3Cols = o2::soa::Join; +using Run3Cols = aod::Collisions; bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr, const Run3Cols& /*ev*/) { if (!tr.hasTOF()) { return false; } - if (tr.has_collision() && tr.collision_as().multNTracksPVeta1() < multiplicityThreshold) { - return tr.tofChi2() < trackDistanceForGoodMatchLowMult; - } - return tr.tofChi2() < trackDistanceForGoodMatch; + return true; } /// Task to produce the TOF signal from the trackTime information diff --git a/Common/TableProducer/PID/pidTOFMerge.cxx b/Common/TableProducer/PID/pidTOFMerge.cxx index 7fc99517fdb..cfd3c566c2b 100644 --- a/Common/TableProducer/PID/pidTOFMerge.cxx +++ b/Common/TableProducer/PID/pidTOFMerge.cxx @@ -31,6 +31,7 @@ // O2Physics includes #include "TableHelper.h" #include "MetadataHelper.h" +#include "CollisionTypeHelper.h" #include "pidTOFBase.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" @@ -45,133 +46,224 @@ using namespace o2::track; MetadataHelper metadataInfo; +// Input data types +using Run3Trks = o2::soa::Join; +using Run3Cols = aod::Collisions; +using Run3TrksWtof = soa::Join; +using Run3TrksWtofWevTime = soa::Join; + +using EvTimeCollisions = soa::Join; +using EvTimeCollisionsFT0 = soa::Join; + +using Run2Trks = o2::soa::Join; +using Run2TrksWtofWevTime = soa::Join; + // Configuration common to all tasks -struct TOFCalibConfig : ConfigurableGroup { - Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable timestamp{"ccdb-timestamp", -1, "timestamp of the object"}; - Configurable timeShiftCCDBPath{"timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"}; - 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 fatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; - - void inheritFromBaseTask(o2::framework::InitContext& initContext) +struct TOFCalibConfig { + template + void init(const CfgType& opt) { - 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"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "paramFileName", paramFileName.value, true)) { - LOG(fatal) << "Could not get paramFileName from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "parametrizationPath", parametrizationPath.value, true)) { - LOG(fatal) << "Could not get parametrizationPath from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "passName", passName.value, true)) { - LOG(fatal) << "Could not get passName from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "timeShiftCCDBPath", timeShiftCCDBPath.value, true)) { - LOG(fatal) << "Could not get timeShiftCCDBPath from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "loadResponseFromCCDB", loadResponseFromCCDB.value, true)) { - LOG(fatal) << "Could not get loadResponseFromCCDB from tof-signal task"; - } - if (!getTaskOptionValue(initContext, "tof-signal", "fatalOnPassNotAvailable", fatalOnPassNotAvailable.value, true)) { - LOG(fatal) << "Could not get fatalOnPassNotAvailable from tof-signal task"; + mUrl = opt.cfgUrl.value; + mPathGrpLhcIf = opt.cfgPathGrpLhcIf.value; + mTimestamp = opt.cfgTimestamp.value; + mTimeShiftCCDBPathPos = opt.cfgTimeShiftCCDBPathPos.value; + mTimeShiftCCDBPathNeg = opt.cfgTimeShiftCCDBPathNeg.value; + mParamFileName = opt.cfgParamFileName.value; + mParametrizationPath = opt.cfgParametrizationPath.value; + mReconstructionPass = opt.cfgReconstructionPass.value; + mLoadResponseFromCCDB = opt.cfgLoadResponseFromCCDB.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, true)) { + 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", mTimeShiftCCDBPathPos, task); + getCfg(initContext, "paramFileName", mParamFileName, task); + getCfg(initContext, "parametrizationPath", mParametrizationPath, task); + getCfg(initContext, "reconstructionPass", mReconstructionPass, task); + getCfg(initContext, "loadResponseFromCCDB", mLoadResponseFromCCDB, 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 setUp(o2::pid::tof::TOFResoParamsV3& mRespParamsV3, CCDBObject ccdb) + void initSetup(o2::pid::tof::TOFResoParamsV3& mRespParamsV3, + CCDBObject ccdb) { + mInitMode = 1; // First we set the CCDB manager - ccdb->setURL(url.value); - ccdb->setTimestamp(timestamp.value); + 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 (passName.value == "metadata") { + if (mReconstructionPass == "metadata") { LOG(info) << "Getting pass from metadata"; if (metadataInfo.isMC()) { - passName.value = metadataInfo.get("AnchorPassName"); + mReconstructionPass = metadataInfo.get("AnchorPassName"); } else { - passName.value = metadataInfo.get("RecoPassName"); + mReconstructionPass = metadataInfo.get("RecoPassName"); } - LOG(info) << "Passed autodetect mode for pass. Taking '" << passName.value << "'"; + LOG(info) << "Passed autodetect mode for pass. Taking '" << mReconstructionPass << "'"; } - LOG(info) << "Using parameter collection, starting from pass '" << passName.value << "'"; + LOG(info) << "Using parameter collection, starting from pass '" << mReconstructionPass << "'"; - const std::string fname = paramFileName.value; + const std::string fname = mParamFileName; if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << parametrizationPath.value; + LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << mParametrizationPath; if (1) { o2::tof::ParameterCollection paramCollection; - paramCollection.loadParamFromFile(fname, parametrizationPath.value); + paramCollection.loadParamFromFile(fname, mParametrizationPath); LOG(info) << "+++ Loaded parameter collection from file +++"; - if (!paramCollection.retrieveParameters(mRespParamsV3, passName.value)) { - if (fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", passName.value.data()); + 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", passName.value.data()); + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } } else { - mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(passName.value)); + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass)); mRespParamsV3.printMomentumChargeShiftParameters(); } } else { - mRespParamsV3.loadParamFromFile(fname.data(), parametrizationPath.value); + mRespParamsV3.loadParamFromFile(fname.data(), mParametrizationPath); } - } 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->template getForTimeStamp(parametrizationPath.value, timestamp.value); + } else if (mLoadResponseFromCCDB) { // Loading it from CCDB + LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << mParametrizationPath << " for timestamp " << mTimestamp; + o2::tof::ParameterCollection* paramCollection = ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp); paramCollection->print(); - if (!paramCollection->retrieveParameters(mRespParamsV3, 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()); + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass)) { // Attempt at loading the parameters with the pass defined + 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", passName.value.data()); + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } } else { // Pass is available, load non standard parameters - mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(passName.value)); + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); mRespParamsV3.printMomentumChargeShiftParameters(); } } + // Calibration object is defined mRespParamsV3.print(); - if (timeShiftCCDBPath.value != "") { - if (timeShiftCCDBPath.value.find(".root") != std::string::npos) { - mRespParamsV3.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Pos", true); - mRespParamsV3.setTimeShiftParameters(timeShiftCCDBPath.value, "gmean_Neg", false); + + // Loading additional calibration objects + if (mTimeShiftCCDBPathPos != "") { + if (mTimeShiftCCDBPathPos.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathPos, "ccdb_object", true); + } else { + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathPos, mTimestamp), true); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathPos, mTimestamp, metadata), true); + } + } + } + if (mTimeShiftCCDBPathNeg != "") { + if (mTimeShiftCCDBPathNeg.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathNeg, "ccdb_object", false); } else { - mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(Form("%s/pos", timeShiftCCDBPath.value.c_str()), timestamp.value), true); - mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(Form("%s/neg", timeShiftCCDBPath.value.c_str()), timestamp.value), false); + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathNeg, mTimestamp), false); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathNeg, mTimestamp, metadata), false); + } } } } + + 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; + } + mLastRunNumber = bc.runNumber(); + mTimestamp = bc.timestamp(); + + // Check the beam type + if (mCollisionSystem == -1) { + o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp(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(debug) << "Updating parametrization from path '" << mParametrizationPath << "' and timestamp " << mTimestamp; + if (!ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp)->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", mReconstructionPass.data()); + } + } + return; + } + + bool autoSetProcessFunctions() const { return mAutoSetProcessFunctions; } + int collisionSystem() const { return mCollisionSystem; } + + 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 mParamFileName; + std::string mParametrizationPath; + std::string mReconstructionPass; + bool mLoadResponseFromCCDB; + bool mFatalOnPassNotAvailable; + bool mEnableTimeDependentResponse; + int mCollisionSystem; + bool mAutoSetProcessFunctions; }; // Part 1 TOF signal definition /// Selection criteria for tracks used for TOF event time -float trackDistanceForGoodMatch = 999.f; -float trackDistanceForGoodMatchLowMult = 999.f; -int multiplicityThreshold = 0; -using Run3Trks = o2::soa::Join; -using Run3Cols = o2::soa::Join; -bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr, const Run3Cols& /*ev*/) +bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr) { if (!tr.hasTOF()) { return false; } - if (tr.has_collision() && tr.collision_as().multNTracksPVeta1() < multiplicityThreshold) { - return tr.tofChi2() < trackDistanceForGoodMatchLowMult; - } - return tr.tofChi2() < trackDistanceForGoodMatch; + return true; } /// Task to produce the TOF signal from the trackTime information @@ -182,16 +274,33 @@ struct tofSignal { // Running flags bool enableTableTOFSignal = false; // Flag to check if the TOF signal table is requested or not bool enableTablepidTOFFlags = false; // Flag to check if the TOF signal flags table is requested or not - TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration - Configurable distanceForGoodMatch{"distanceForGoodMatch", 999.f, "Maximum distance to consider a good match"}; - Configurable distanceForGoodMatchLowMult{"distanceForGoodMatchLowMult", 999.f, "Maximum distance to consider a good match for low multiplicity events"}; - Configurable multThreshold{"multThreshold", 0, "Multiplicity threshold to consider a low multiplicity event"}; // Output histograms Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + // Detector response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + Service ccdb; + struct : ConfigurableGroup { + Configurable cfgUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; + Configurable cfgTimestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + Configurable cfgTimeShiftCCDBPathPos{"timeShiftCCDBPathPos", "", "Path of the TOF time shift vs eta for pos. tracks. If empty none is taken"}; + Configurable cfgTimeShiftCCDBPathNeg{"timeShiftCCDBPathNeg", "", "Path of the TOF time shift vs eta for neg. tracks. If empty none is taken"}; + Configurable cfgParamFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; + Configurable cfgParametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; + Configurable cfgReconstructionPass{"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."}}; + Configurable cfgLoadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; + Configurable cfgFatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; + Configurable cfgEnableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; + Configurable cfgCollisionSystem{"collisionSystem", -1, "Collision system: -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"}; + Configurable cfgAutoSetProcessFunctions{"autoSetProcessFunctions", true, "Flag to autodetect the process functions to use"}; + } cfg; // Configurables (only defined here and inherited from other tasks) + + TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.init(cfg); // Checking that the table is requested in the workflow and enabling it enableTableTOFSignal = isTableRequiredInWorkflow(initContext, "TOFSignal"); if (enableTableTOFSignal) { @@ -207,11 +316,14 @@ struct tofSignal { LOG(info) << "No table or process is enabled. Disabling task"; return; } - 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 (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions"; + 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; + } } } @@ -222,11 +334,7 @@ struct tofSignal { if (!doprocessRun2 && !doprocessRun3) { LOG(fatal) << "Neither processRun2 nor processRun3 are enabled. Pick one of the two"; } - - trackDistanceForGoodMatch = distanceForGoodMatch; - trackDistanceForGoodMatchLowMult = distanceForGoodMatchLowMult; - multiplicityThreshold = multThreshold; - LOG(info) << "Configuring selections for good match: " << trackDistanceForGoodMatch << " low mult " << trackDistanceForGoodMatchLowMult << " mult. threshold " << multiplicityThreshold; + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters if (!enableQaHistograms) { return; } @@ -239,7 +347,7 @@ struct tofSignal { /// Dummy process function for BCs, needed in case both Run2 and Run3 process functions are disabled void process(aod::BCs const&) {} - void processRun3(Run3Trks const& tracks, Run3Cols const& collisions) + void processRun3(Run3Trks const& tracks) { if (!enableTableTOFSignal) { return; @@ -248,26 +356,25 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& t : tracks) { - const auto s = o2::pid::tof::TOFSignal::GetTOFSignal(t); + for (auto& trk : tracks) { + const float& sig = o2::pid::tof::TOFSignal::GetTOFSignal(trk); if (enableQaHistograms) { - histos.fill(HIST("tofSignal"), s); + histos.fill(HIST("tofSignal"), sig); } - table(s); + table(sig); if (!enableTablepidTOFFlags) { continue; } - const auto b = isTrackGoodMatchForTOFPID(t, collisions); + const auto& b = isTrackGoodMatchForTOFPID(trk); if (enableQaHistograms) { - histos.fill(HIST("goodForPIDFlags"), s); + histos.fill(HIST("goodForPIDFlags"), sig); } tableFlags(b); } } PROCESS_SWITCH(tofSignal, processRun3, "Process Run3 data i.e. input is TrackIU. Set to false to autodetect from metadata.", false); - using TrksRun2 = o2::soa::Join; - void processRun2(TrksRun2 const& tracks) + void processRun2(Run2Trks const& tracks) { if (!enableTableTOFSignal) { return; @@ -276,8 +383,8 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& t : tracks) { - table(o2::pid::tof::TOFSignal::GetTOFSignal(t)); + for (auto& trk : tracks) { + table(o2::pid::tof::TOFSignal::GetTOFSignal(trk)); if (!enableTablepidTOFFlags) { continue; } @@ -293,7 +400,11 @@ 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 @@ -334,10 +445,13 @@ struct tofEventTime { 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"}; void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.inheritFromBaseTask(initContext); // Checking that the table is requested in the workflow and enabling it enableTableTOFEvTime = isTableRequiredInWorkflow(initContext, "TOFEvTime"); @@ -356,8 +470,24 @@ struct tofEventTime { return; } - if (metadataInfo.isFullyDefined() && metadataInfo.isRun3() && doprocessRun2) { - LOG(fatal) << "Run2 process function is enabled but the metadata says it is Run3"; + if (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions"; + if (metadataInfo.isFullyDefined()) { + if (metadataInfo.isRun3()) { + doprocessRun3.value = true; + } else { + doprocessRun2.value = true; + } + } + } + + if (metadataInfo.isFullyDefined()) { + if (metadataInfo.isRun3() && doprocessRun2) { + LOG(fatal) << "Run2 process function is enabled but the metadata says it is Run3"; + } + if (!metadataInfo.isRun3() && doprocessRun3) { + LOG(fatal) << "Run3 process function is enabled but the metadata says it is Run2"; + } } trackSampleMinMomentum = minMomentum; @@ -369,16 +499,8 @@ struct tofEventTime { LOGF(info, "Enabling process function: processRun2"); nEnabled++; } - 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"); + if (doprocessRun3 == true) { + LOGF(info, "Enabling process function: processRun3"); nEnabled++; } if (nEnabled > 1) { @@ -388,7 +510,7 @@ struct tofEventTime { if (sel8TOFEvTime.value == true) { LOG(info) << "TOF event time will be computed for collisions that pass the event selection only!"; } - mTOFCalibConfig.setUp(mRespParamsV3, ccdb); // Getting the parametrization parameters + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters o2::tof::eventTimeContainer::setMaxNtracksInSet(maxNtracksInSet.value); o2::tof::eventTimeContainer::printConfig(); @@ -418,210 +540,213 @@ struct tofEventTime { tableEvTime(t.collision().collisionTime() * 1000.f, t.collision().collisionTimeRes() * 1000.f); } } - PROCESS_SWITCH(tofEventTime, processRun2, "Process with Run2 data", false); + PROCESS_SWITCH(tofEventTime, processRun2, "Process with Run2 data", true); /// /// Process function to prepare the event for each track on Run 3 data without the FT0 - using TrksEvTime = soa::Join; // Define slice per collision - Preslice perCollision = aod::track::collisionId; + Preslice perCollision = aod::track::collisionId; template - using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; - using EvTimeCollisions = soa::Join; - void processNoFT0(TrksEvTime const& tracks, - EvTimeCollisions const&) + using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; + void processRun3(Run3TrksWtof& tracks, + aod::FT0s const&, + EvTimeCollisionsFT0 const&, + aod::BCsWithTimestamps const&) { if (!enableTableTOFEvTime) { return; } + LOG(debug) << "Processing Run3 data for TOF event time"; tableEvTime.reserve(tracks.size()); tableFlags.reserve(tracks.size()); if (enableTableEvTimeTOFOnly) { tableEvTimeTOFOnly.reserve(tracks.size()); } - - 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 - tableFlags(0); - tableEvTime(0.f, 999.f); - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); - } + bool calibUpdated = false; + for (auto const& track : tracks) { // Loop on all tracks + if (!track.has_collision()) { // Skipping tracks without collisions continue; } - if (t.collisionId() == lastCollisionId) { // Event time from this collision is already in the table + const auto& coll = track.collision_as(); + if (!coll.has_bc()) { continue; } - /// Create new table for the tracks in a collision - lastCollisionId = t.collisionId(); /// Cache last collision ID - - const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); - - // First make table for event time - const auto evTimeTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); - int nGoodTracksForTOF = 0; - float et = evTimeTOF.mEventTime; - float erret = evTimeTOF.mEventTimeError; + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + calibUpdated = true; + break; + } - for (auto const& trk : tracksInCollision) { // Loop on Tracks - if constexpr (removeTOFEvTimeBias) { - evTimeTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); - } - uint8_t flags = 0; - if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { - flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; - } else { - et = 0.f; - erret = errDiamond; - } - tableFlags(flags); - tableEvTime(et, erret); - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), et, erret, evTimeTOF.mEventTimeMultiplicity); + // Autoset the processing mode for the event time computation + if (calibUpdated) { + 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; } } + } else { + LOG(warning) << "Calibration not updated on " << tracks.size() << " tracks !!"; } - } - PROCESS_SWITCH(tofEventTime, processNoFT0, "Process without FT0", false); + LOG(debug) << "Running on " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " mComputeEvTimeWithTOF " << mComputeEvTimeWithTOF.value << " mComputeEvTimeWithFT0 " << mComputeEvTimeWithFT0.value; - /// - /// Process function to prepare the event for each track on Run 3 data with the FT0 - using EvTimeCollisionsFT0 = soa::Join; - void processFT0(TrksEvTime& tracks, - aod::FT0s const&, - EvTimeCollisionsFT0 const&) - { - if (!enableTableTOFEvTime) { - return; - } - - tableEvTime.reserve(tracks.size()); - tableFlags.reserve(tracks.size()); - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly.reserve(tracks.size()); - } - - 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 - tableFlags(0); - tableEvTime(0.f, 999.f); - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + 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 + tableFlags(0); + tableEvTime(0.f, 999.f); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + continue; } - 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 - - const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); - const auto& collision = t.collision_as(); - - // Compute the TOF event time - const auto evTimeTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); - - float t0AC[2] = {.0f, 999.f}; // Value and error of T0A or T0C or T0AC - float t0TOF[2] = {static_cast(evTimeTOF.mEventTime), static_cast(evTimeTOF.mEventTimeError)}; // Value and error of TOF - - uint8_t flags = 0; - int nGoodTracksForTOF = 0; - float eventTime = 0.f; - float sumOfWeights = 0.f; - float weight = 0.f; - - for (auto const& trk : tracksInCollision) { // Loop on Tracks - // Reset the flag - flags = 0; - // Reset the event time - eventTime = 0.f; - sumOfWeights = 0.f; - weight = 0.f; - // Remove the bias on TOF ev. time - if constexpr (removeTOFEvTimeBias) { - evTimeTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); + if (t.collisionId() == lastCollisionId) { // Event time from this collision is already in the table + continue; } - if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { - flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; + /// Create new table for the tracks in a collision + lastCollisionId = t.collisionId(); /// Cache last collision ID - weight = 1.f / (t0TOF[1] * t0TOF[1]); - eventTime += t0TOF[0] * weight; - sumOfWeights += weight; - } + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); + const auto& collision = t.collision_as(); - 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; - flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC; + // Compute the TOF event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + + 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 + + uint8_t flags = 0; + int nGoodTracksForTOF = 0; + float eventTime = 0.f; + float sumOfWeights = 0.f; + float weight = 0.f; + + for (auto const& trk : tracksInCollision) { // Loop on Tracks + // Reset the flag + flags = 0; + // Reset the event time + eventTime = 0.f; + sumOfWeights = 0.f; + weight = 0.f; + // Remove the bias on TOF ev. time + if constexpr (removeTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); } + if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; - weight = 1.f / (t0AC[1] * t0AC[1]); - eventTime += t0AC[0] * weight; - sumOfWeights += weight; - } + 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; + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC; + } + + 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; + if (sumOfWeights < weightDiamond) { // avoiding sumOfWeights = 0 or worse that diamond + eventTime = 0; + sumOfWeights = weightDiamond; + tableFlags(0); + } else { + tableFlags(flags); + } + tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights)); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), t0TOF[0], t0TOF[1], evTimeMakerTOF.mEventTimeMultiplicity); + } + } + } + } 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 tableFlags(0); - } else { - tableFlags(flags); + tableEvTime(0.f, 999.f); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + continue; } - tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights)); - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), t0TOF[0], t0TOF[1], evTimeTOF.mEventTimeMultiplicity); + if (t.collisionId() == lastCollisionId) { // Event time from this collision is already in the table + continue; } - } - } - } - PROCESS_SWITCH(tofEventTime, processFT0, "Process with FT0", false); + /// Create new table for the tracks in a collision + lastCollisionId = t.collisionId(); /// Cache last collision ID - /// - /// Process function to prepare the event for each track on Run 3 data with only the FT0 - void processOnlyFT0(TrksEvTime& tracks, - aod::FT0s const&, - EvTimeCollisionsFT0 const&) - { - if (!enableTableTOFEvTime) { - return; - } + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); - tableEvTime.reserve(tracks.size()); - tableFlags.reserve(tracks.size()); - if (!enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly.reserve(tracks.size()); - } + // First make table for event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + int nGoodTracksForTOF = 0; + float et = evTimeMakerTOF.mEventTime; + float erret = evTimeMakerTOF.mEventTimeError; - for (auto const& t : tracks) { // Loop on collisions - if (enableTableEvTimeTOFOnly) { - tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); - } - if (!t.has_collision()) { // Track was not assigned, cannot compute event time - tableFlags(0); - tableEvTime(0.f, 999.f); - continue; + for (auto const& trk : tracksInCollision) { // Loop on Tracks + if constexpr (removeTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); + } + uint8_t flags = 0; + if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; + } else { + et = 0.f; + erret = errDiamond; + } + tableFlags(flags); + tableEvTime(et, erret); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), et, erret, evTimeMakerTOF.mEventTimeMultiplicity); + } + } } - const auto& collision = t.collision_as(); - - if (collision.has_foundFT0()) { // T0 measurement is available - // const auto& ft0 = collision.foundFT0(); - if (collision.t0ACValid()) { - tableFlags(o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC); - tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + } else if (mComputeEvTimeWithTOF == 0 && mComputeEvTimeWithFT0 == 1) { + for (auto const& t : tracks) { // Loop on collisions + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + if (!t.has_collision()) { // Track was not assigned, cannot compute event time + tableFlags(0); + tableEvTime(0.f, 999.f); continue; } + const auto& collision = t.collision_as(); + + if (collision.has_foundFT0()) { // T0 measurement is available + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + tableFlags(o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC); + tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + continue; + } + } + tableFlags(0); + tableEvTime(0.f, 999.f); } - tableFlags(0); - tableEvTime(0.f, 999.f); + } else { + LOG(fatal) << "Invalid configuration for TOF event time computation"; } } - PROCESS_SWITCH(tofEventTime, processOnlyFT0, "Process only with FT0", false); + PROCESS_SWITCH(tofEventTime, processRun3, "Process the Run3 data", true); }; // Part 3 Nsigma computation @@ -676,9 +801,7 @@ struct tofPidMerge { o2::pid::tof::TOFResoParamsV3 mRespParamsV3; Service ccdb; TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration - // Configurable inheritFromBaseTask{"inheritFromBaseTask", true, "Flag to iherit all common configurables from the TOF base task"}; Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; - Configurable enableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; // Configuration flags to include and exclude particle hypotheses Configurable> enableParticle{"enableParticle", @@ -696,6 +819,7 @@ struct tofPidMerge { std::vector mEnabledParticlesFull; // Vector of enabled PID hypotheses to loop on when making full tables void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.inheritFromBaseTask(initContext); // Checking the tables are requested in the workflow and enabling them for (int i = 0; i < nSpecies; i++) { // First checking tiny @@ -714,12 +838,24 @@ struct tofPidMerge { } if (mEnabledParticlesFull.size() == 0 && mEnabledParticles.size() == 0) { LOG(info) << "No PID tables are required, disabling the task"; - doprocessData.value = false; + doprocessRun3.value = false; + doprocessRun2.value = false; return; - } else if (doprocessData.value == false) { + } else if (doprocessRun3.value == false && doprocessRun2.value == false) { LOG(fatal) << "PID tables are required but process data is disabled. Please enable it"; } - mTOFCalibConfig.setUp(mRespParamsV3, ccdb); // Getting the parametrization parameters + 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"; + } + if (!metadataInfo.isRun3() && doprocessRun3) { + LOG(fatal) << "Run3 process function is enabled but the metadata says it is Run2"; + } + } + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters // Printing enabled tables and enabling QA histograms if needed LOG(info) << "++ Enabled tables:"; @@ -907,10 +1043,11 @@ struct tofPidMerge { void process(aod::BCs const&) {} - using Trks = soa::Join; template - using ResponseImplementation = o2::pid::tof::ExpTimes; - void processData(Trks const& tracks, aod::Collisions const&, aod::BCsWithTimestamps const&) + using ResponseImplementation = o2::pid::tof::ExpTimes; + void processRun3(Run3TrksWtofWevTime const& tracks, + Run3Cols const&, + aod::BCsWithTimestamps const&) { constexpr auto responseEl = ResponseImplementation(); constexpr auto responseMu = ResponseImplementation(); @@ -926,17 +1063,183 @@ struct tofPidMerge { if (!track.has_collision()) { // Skipping tracks without collisions continue; } - mTOFCalibConfig.timestamp.value = track.collision().bc_as().timestamp(); - if (enableTimeDependentResponse) { - LOG(debug) << "Updating parametrization from path '" << mTOFCalibConfig.parametrizationPath.value << "' and timestamp " << mTOFCalibConfig.timestamp.value; - if (!ccdb->getForTimeStamp(mTOFCalibConfig.parametrizationPath.value, mTOFCalibConfig.timestamp.value)->retrieveParameters(mRespParamsV3, mTOFCalibConfig.passName.value)) { - if (mTOFCalibConfig.fatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mTOFCalibConfig.passName.value.data()); - } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mTOFCalibConfig.passName.value.data()); + const auto& coll = track.collision(); + if (!coll.has_bc()) { + continue; + } + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + break; + } + + for (auto const& pidId : mEnabledParticles) { + reserveTable(pidId, tracks.size(), false); + } + + for (auto const& pidId : mEnabledParticlesFull) { + reserveTable(pidId, tracks.size(), true); + } + + float resolution = 1.f; // Last resolution assigned + float nsigma = 0; + for (auto const& trk : tracks) { // Loop on all tracks + if (!trk.has_collision()) { // Track was not assigned, cannot compute NSigma (no event time) -> filling with empty table + for (auto const& pidId : mEnabledParticles) { + makeTableEmpty(pidId, false); + } + for (auto const& pidId : mEnabledParticlesFull) { + makeTableEmpty(pidId, true); + } + continue; + } + + for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses + switch (pidId) { + case idxEl: { + nsigma = responseEl.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDEl); + break; } + case idxMu: { + nsigma = responseMu.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDMu); + break; + } + case idxPi: { + nsigma = responsePi.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDPi); + break; + } + case idxKa: { + nsigma = responseKa.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDKa); + break; + } + case idxPr: { + nsigma = responsePr.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDPr); + break; + } + case idxDe: { + nsigma = responseDe.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDDe); + break; + } + case idxTr: { + nsigma = responseTr.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDTr); + break; + } + case idxHe: { + nsigma = responseHe.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDHe); + break; + } + case idxAl: { + nsigma = responseAl.GetSeparation(mRespParamsV3, trk); + aod::pidutils::packInTable(nsigma, tablePIDAl); + break; + } + default: + LOG(fatal) << "Wrong particle ID for standard tables"; + break; } + if (enableQaHistograms) { + hnsigma[pidId]->Fill(trk.p(), nsigma); + } + } + for (auto const& pidId : mEnabledParticlesFull) { // Loop on enabled particle hypotheses with full tables + switch (pidId) { + case idxEl: { + resolution = responseEl.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseEl.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullEl(resolution, nsigma); + break; + } + case idxMu: { + resolution = responseMu.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseMu.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullMu(resolution, nsigma); + break; + } + case idxPi: { + resolution = responsePi.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responsePi.GetSeparation(mRespParamsV3, trk); + tablePIDFullPi(resolution, nsigma); + break; + } + case idxKa: { + resolution = responseKa.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseKa.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullKa(resolution, nsigma); + break; + } + case idxPr: { + resolution = responsePr.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responsePr.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullPr(resolution, nsigma); + break; + } + case idxDe: { + resolution = responseDe.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseDe.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullDe(resolution, nsigma); + break; + } + case idxTr: { + resolution = responseTr.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseTr.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullTr(resolution, nsigma); + break; + } + case idxHe: { + resolution = responseHe.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseHe.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullHe(resolution, nsigma); + break; + } + case idxAl: { + resolution = responseAl.GetExpectedSigma(mRespParamsV3, trk); + nsigma = responseAl.GetSeparation(mRespParamsV3, trk, resolution); + tablePIDFullAl(resolution, nsigma); + break; + } + default: + LOG(fatal) << "Wrong particle ID for full tables"; + break; + } + if (enableQaHistograms) { + hnsigmaFull[pidId]->Fill(trk.p(), nsigma); + } + } + } + } + PROCESS_SWITCH(tofPidMerge, processRun3, "Produce tables. Set to off if the tables are not required", true); + + template + using ResponseImplementationRun2 = o2::pid::tof::ExpTimes; + void processRun2(Run2TrksWtofWevTime const& tracks, + Run3Cols const&, + aod::BCsWithTimestamps const&) + { + constexpr auto responseEl = ResponseImplementationRun2(); + constexpr auto responseMu = ResponseImplementationRun2(); + constexpr auto responsePi = ResponseImplementationRun2(); + constexpr auto responseKa = ResponseImplementationRun2(); + constexpr auto responsePr = ResponseImplementationRun2(); + constexpr auto responseDe = ResponseImplementationRun2(); + constexpr auto responseTr = ResponseImplementationRun2(); + constexpr auto responseHe = ResponseImplementationRun2(); + constexpr auto responseAl = ResponseImplementationRun2(); + + for (auto const& track : tracks) { // Loop on all tracks + if (!track.has_collision()) { // Skipping tracks without collisions + continue; + } + const auto& coll = track.collision(); + if (!coll.has_bc()) { + continue; } + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters break; } @@ -1082,7 +1385,7 @@ struct tofPidMerge { } } } - PROCESS_SWITCH(tofPidMerge, processData, "Produce tables. Set to off if the tables are not required", true); + PROCESS_SWITCH(tofPidMerge, processRun2, "Produce tables. Set to off if the tables are not required", false); }; // Part 4 Beta and TOF mass computation @@ -1101,17 +1404,22 @@ struct tofPidBeta { 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 (metadataInfo.isFullyDefined()) { - if (metadataInfo.isRun3()) { - doprocessRun3.value = true; - } else { - doprocessRun2.value = true; + + if (mTOFCalibConfig.autoSetProcessFunctions()) { + LOG(info) << "Autodetecting process functions"; + if (metadataInfo.isFullyDefined()) { + if (metadataInfo.isRun3()) { + doprocessRun3.value = true; + } else { + doprocessRun2.value = true; + } } } @@ -1119,14 +1427,13 @@ struct tofPidBeta { if (!enableTOFParams) { return; } - mTOFCalibConfig.setUp(mRespParamsV3, ccdb); // Getting the parametrization parameters + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters } void process(aod::BCs const&) {} - using TrksRun2 = soa::Join; - o2::pid::tof::Beta responseBetaRun2; - void processRun2(TrksRun2 const& tracks) + o2::pid::tof::Beta responseBetaRun2; + void processRun2(Run2TrksWtofWevTime const& tracks) { if (!enableTableBeta && !enableTableMass) { return; @@ -1140,18 +1447,17 @@ struct tofPidBeta { } if (enableTableMass) { if (enableTOFParams) { - tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV3.getMomentumChargeShift(trk.eta())), beta)); + 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)); + tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk, beta)); } } } } - PROCESS_SWITCH(tofPidBeta, processRun2, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", false); + PROCESS_SWITCH(tofPidBeta, processRun2, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true); - using Trks = soa::Join; - o2::pid::tof::Beta responseBeta; - void processRun3(Trks const& tracks) + o2::pid::tof::Beta responseBeta; + void processRun3(Run3TrksWtofWevTime const& tracks) { if (!enableTableBeta && !enableTableMass) { return; @@ -1166,14 +1472,14 @@ struct tofPidBeta { } if (enableTableMass) { if (enableTOFParams) { - tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV3.getMomentumChargeShift(trk.eta())), beta)); + 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)); + tablePIDTOFMass(o2::pid::tof::TOFMass::GetTOFMass(trk, beta)); } } } } - PROCESS_SWITCH(tofPidBeta, processRun3, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", false); + PROCESS_SWITCH(tofPidBeta, processRun3, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/Common/TableProducer/centralityTable.cxx b/Common/TableProducer/centralityTable.cxx index 871978a851c..6b18bcf6882 100644 --- a/Common/TableProducer/centralityTable.cxx +++ b/Common/TableProducer/centralityTable.cxx @@ -23,13 +23,15 @@ #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; +MetadataHelper metadataInfo; // Metadata helper + static constexpr int kCentRun2V0Ms = 0; static constexpr int kCentRun2V0As = 1; static constexpr int kCentRun2SPDTrks = 2; @@ -76,12 +78,15 @@ struct CentralityTable { Configurable> enabledTables{"enabledTables", {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)"}; - 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"}}; + 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 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 fatalizeMultCalibSanity{"fatalizeMultCalibSanity", false, {"Option to do fatalize the sanity check on the multiplicity calibration"}}; 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"}; @@ -208,7 +213,7 @@ struct CentralityTable { doprocessRun3.value = false; } - ccdb->setURL(ccdbUrl); + ccdb->setURL(ccdbConfig.ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); @@ -233,6 +238,7 @@ struct CentralityTable { histos.addClone("FT0C/", "sel8FT0C/"); histos.addClone("FT0A/", "sel8FT0A/"); + histos.print(); listCalib.setObject(new TList); } @@ -243,8 +249,22 @@ struct CentralityTable { /* check the previous run number */ auto bc = collision.bc_as(); if (bc.runNumber() != mRunNumber) { + mRunNumber = bc.runNumber(); // mark that this run has been attempted already regardless of outcome LOGF(debug, "timestamp=%llu", bc.timestamp()); - TList* callst = ccdb->getForTimeStamp(ccdbPath, bc.timestamp()); + TList* callst = nullptr; + if (ccdbConfig.reconstructionPass.value == "") { + callst = ccdb->getForRun(ccdbConfig.ccdbPath, bc.runNumber()); + } 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")); + callst = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, bc.runNumber(), metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = ccdbConfig.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", ccdbConfig.reconstructionPass.value); + callst = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, bc.runNumber(), metadata); + } Run2V0MInfo.mCalibrationStored = false; Run2V0AInfo.mCalibrationStored = false; @@ -266,9 +286,9 @@ struct CentralityTable { 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()); + Run2V0MInfo.mMCScale = getformulaccdb(TString::Format("%s-V0M", ccdbConfig.genName->c_str()).Data()); if ((Run2V0MInfo.mhVtxAmpCorrV0A != nullptr) && (Run2V0MInfo.mhVtxAmpCorrV0C != nullptr) && (Run2V0MInfo.mhMultSelCalib != nullptr)) { - if (genName->length() != 0) { + if (ccdbConfig.genName->length() != 0) { if (Run2V0MInfo.mMCScale != nullptr) { for (int ixpar = 0; ixpar < 6; ++ixpar) { Run2V0MInfo.mMCScalePars[ixpar] = Run2V0MInfo.mMCScale->GetParameter(ixpar); @@ -333,15 +353,11 @@ struct CentralityTable { LOGF(fatal, "Calibration information from CL1 multiplicity for run %d corrupted", bc.runNumber()); } } - if (Run2V0MInfo.mCalibrationStored || Run2V0AInfo.mCalibrationStored || Run2SPDTksInfo.mCalibrationStored || Run2SPDClsInfo.mCalibrationStored || Run2CL0Info.mCalibrationStored || Run2CL1Info.mCalibrationStored) { - mRunNumber = bc.runNumber(); - } } else { - if (!doNotCrashOnNull) { // default behaviour: crash + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash LOGF(fatal, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); } else { // only if asked: continue filling with non-valid values (105) 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()); - mRunNumber = bc.runNumber(); } } } @@ -456,8 +472,33 @@ struct CentralityTable { /* check the previous run number */ auto bc = collision.template bc_as(); if (bc.runNumber() != mRunNumber) { + mRunNumber = bc.runNumber(); // mark that this run has been attempted already regardless of outcome LOGF(info, "timestamp=%llu, run number=%d", bc.timestamp(), bc.runNumber()); - TList* callst = ccdb->getForTimeStamp(ccdbPath, bc.timestamp()); + TList* callst = nullptr; + // Check if the ccdb path is a root file + if (ccdbConfig.ccdbPath.value.find(".root") != std::string::npos) { + TFile f(ccdbConfig.ccdbPath.value.c_str(), "READ"); + f.GetObject(ccdbConfig.reconstructionPass.value.c_str(), callst); + if (!callst) { + f.ls(); + LOG(fatal) << "No calibration list " << ccdbConfig.reconstructionPass.value << " found in the file " << ccdbConfig.ccdbPath.value; + } + } else { + if (ccdbConfig.reconstructionPass.value == "") { + callst = ccdb->getForRun(ccdbConfig.ccdbPath, bc.runNumber()); + } 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")); + callst = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, bc.runNumber(), metadata); + } else { + std::map metadata; + metadata["RecoPassName"] = ccdbConfig.reconstructionPass.value; + LOGF(info, "Loading CCDB for reconstruction pass (from provided argument): %s", ccdbConfig.reconstructionPass.value); + callst = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, bc.runNumber(), metadata); + } + } + FV0AInfo.mCalibrationStored = false; FT0MInfo.mCalibrationStored = false; FT0AInfo.mCalibrationStored = false; @@ -494,35 +535,33 @@ struct CentralityTable { for (auto const& table : mEnabledTables) { switch (table) { case kCentFV0As: - getccdb(FV0AInfo, genName); + getccdb(FV0AInfo, ccdbConfig.genName); break; case kCentFT0Ms: - getccdb(FT0MInfo, genName); + getccdb(FT0MInfo, ccdbConfig.genName); break; case kCentFT0As: - getccdb(FT0AInfo, genName); + getccdb(FT0AInfo, ccdbConfig.genName); break; case kCentFT0Cs: - getccdb(FT0CInfo, genName); + getccdb(FT0CInfo, ccdbConfig.genName); break; case kCentFDDMs: - getccdb(FDDMInfo, genName); + getccdb(FDDMInfo, ccdbConfig.genName); break; case kCentNTPVs: - getccdb(NTPVInfo, genName); + getccdb(NTPVInfo, ccdbConfig.genName); break; default: LOGF(fatal, "Table %d not supported in Run3", table); break; } } - mRunNumber = bc.runNumber(); } else { - if (!doNotCrashOnNull) { // default behaviour: crash + if (!ccdbConfig.doNotCrashOnNull) { // default behaviour: crash LOGF(fatal, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); } else { // only if asked: continue filling with non-valid values (105) 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()); - mRunNumber = bc.runNumber(); } } } @@ -585,11 +624,11 @@ struct CentralityTable { if (produceHistograms.value) { histos.fill(HIST("FT0A/percentile"), perC); histos.fill(HIST("FT0A/percentilevsPV"), perC, collision.multNTracksPV()); - histos.fill(HIST("FT0A/MultvsPV"), collision.multZeqFT0A(), collision.multNTracksPV()); + histos.fill(HIST("FT0A/MultvsPV"), collision.multZeqFT0A() + collision.multZeqFT0C(), collision.multNTracksPV()); if (collision.sel8()) { histos.fill(HIST("sel8FT0A/percentile"), perC); histos.fill(HIST("sel8FT0A/percentilevsPV"), perC, collision.multNTracksPV()); - histos.fill(HIST("sel8FT0A/MultvsPV"), collision.multZeqFT0A(), collision.multNTracksPV()); + histos.fill(HIST("sel8FT0A/MultvsPV"), collision.multZeqFT0A() + collision.multZeqFT0C(), collision.multNTracksPV()); } } } @@ -600,11 +639,11 @@ struct CentralityTable { if (produceHistograms.value) { histos.fill(HIST("FT0C/percentile"), perC); histos.fill(HIST("FT0C/percentilevsPV"), perC, collision.multNTracksPV()); - histos.fill(HIST("FT0C/MultvsPV"), collision.multZeqFT0C(), collision.multNTracksPV()); + histos.fill(HIST("FT0C/MultvsPV"), collision.multZeqFT0A() + collision.multZeqFT0C(), collision.multNTracksPV()); if (collision.sel8()) { histos.fill(HIST("sel8FT0C/percentile"), perC); histos.fill(HIST("sel8FT0C/percentilevsPV"), perC, collision.multNTracksPV()); - histos.fill(HIST("sel8FT0C/MultvsPV"), collision.multZeqFT0C(), collision.multNTracksPV()); + histos.fill(HIST("sel8FT0C/MultvsPV"), collision.multZeqFT0A() + collision.multZeqFT0C(), collision.multNTracksPV()); } } } @@ -646,4 +685,8 @@ struct CentralityTable { PROCESS_SWITCH(CentralityTable, processRun3FT0, "Provide Run3 calibrated centrality/multiplicity percentiles tables for FT0 only", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/eseTableProducer.cxx b/Common/TableProducer/eseTableProducer.cxx new file mode 100644 index 00000000000..34f534dc700 --- /dev/null +++ b/Common/TableProducer/eseTableProducer.cxx @@ -0,0 +1,236 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 eseTableProducer.cxx +/// \brief Producer for the ESE table +/// +/// \author Joachim C. K. B. Hansen + +#include + +#include +#include +#include +#include +#include + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/Centrality.h" + +#include "Common/DataModel/EseTable.h" +#include "Common/DataModel/Qvectors.h" +#include "FFitWeights.h" + +using namespace o2; +using namespace o2::framework; + +using CollWithMults = soa::Join; + +struct EseTableProducer { + Produces qPercsFT0C; + Produces qPercsFT0A; + Produces qPercsFV0A; + Produces qPercsTPC; + Produces fEseCol; + + 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 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> cfgaxisqn{"cfgaxisqn", {500, 0, 25}, "q_n amplitude range"}; + Configurable cfgnResolution{"cfgnResolution", 3000, "resolution of splines"}; + + int runNumber{-1}; + + FFitWeights* splines{nullptr}; + + Service ccdb; + + void init(o2::framework::InitContext&) + { + + LOGF(info, "ESETable::init()"); + + registry.add("hEventCounter", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + registry.add("hESEstat", "ese status;ese status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + + 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); + + 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}); + } + } + 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) + { + + 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"); + } + } + + float Calcqn(const float& Qx, const float& Qy, const float& Mult) + { + float dqn{0.0f}; + float qn{0.0f}; + + dqn = Qx * Qx + Qy * Qy; + qn = TMath::Sqrt(dqn) / TMath::Sqrt(Mult); + return qn; + } + + bool validQvec(const float& qVec) + { + if (qVec == 999. || qVec == -999) { + return false; + } else { + return true; + } + }; + + void doSpline(float& splineVal, int& eseval, const float& centr, const float& nHarm, const char* pf, const auto& QX, const auto& QY, const auto& Ampl) + { + 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 (cfgESE) { + splineVal = splines->EvalSplines(centr, qnval, nHarm, pf); + eseval = cfgFT0C ? 1 : 0; + } + } + } + + template + void calculateESE(T const& collision, + std::vector& qnpFT0C, + std::vector& qnpFT0A, + std::vector& qnpFV0A, + std::vector& qnpTPC, + std::vector& fIsEseAvailable) + { + + 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); + } + qnpFV0A.push_back(splineValFV0A); + } + }; + + void processESE(CollWithMults::iterator const& collision, aod::BCsWithTimestamps const&, aod::FV0As const&, aod::FT0s const&) + { + float counter{0.5}; + registry.fill(HIST("hEventCounter"), counter++); + + std::vector qnpFT0C{}; + std::vector qnpFT0A{}; + std::vector qnpFV0A{}; + std::vector qnpTPC{}; + + std::vector fIsEseAvailable{}; + + 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); + + qPercsFT0C(qnpFT0C); + qPercsFT0A(qnpFT0A); + qPercsFV0A(qnpFV0A); + qPercsTPC(qnpTPC); + fEseCol(fIsEseAvailable); + registry.fill(HIST("hEventCounter"), counter++); + } + PROCESS_SWITCH(EseTableProducer, processESE, "proccess q vectors to calculate reduced q-vector", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/eventSelection.cxx b/Common/TableProducer/eventSelection.cxx index 64ae7df4d4e..ff55f0e4299 100644 --- a/Common/TableProducer/eventSelection.cxx +++ b/Common/TableProducer/eventSelection.cxx @@ -23,6 +23,8 @@ #include "DataFormatsParameters/GRPLHCIFData.h" #include "DataFormatsParameters/GRPECSObject.h" #include "ITSMFTBase/DPLAlpideParam.h" +#include "MetadataHelper.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" #include "TH1D.h" @@ -30,11 +32,15 @@ using namespace o2; using namespace o2::framework; using namespace o2::aod::evsel; +MetadataHelper metadataInfo; // Metadata helper + using BCsWithRun2InfosTimestampsAndMatches = soa::Join; using BCsWithRun3Matchings = soa::Join; using BCsWithBcSelsRun2 = soa::Join; -using BCsWithBcSelsRun3 = soa::Join; +using BCsWithBcSelsRun3 = soa::Join; +using FullTracks = soa::Join; using FullTracksIU = soa::Join; +const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; struct BcSelectionTask { Produces bcsel; @@ -45,6 +51,7 @@ struct BcSelectionTask { Configurable confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; Configurable confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", -1, "Number of bcs to cut at the start of the Time Frame. Take from CCDB if -1"}; Configurable confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", -1, "Number of bcs to cut at the end of the Time Frame. Take from CCDB if -1"}; + Configurable confCheckRunDurationLimits{"checkRunDurationLimits", false, "Check if the BCs are within the run duration limits"}; int lastRunNumber = -1; int64_t bcSOR = -1; // global bc of the start of the first orbit @@ -56,6 +63,15 @@ struct BcSelectionTask { 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); @@ -69,6 +85,7 @@ struct BcSelectionTask { 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.}}); @@ -216,10 +233,14 @@ struct BcSelectionTask { bcsel.reserve(bcs.size()); // extract ITS time frame parameters - - int64_t ts = bcs.iteratorAt(0).timestamp(); + int run = bcs.iteratorAt(0).runNumber(); + auto timestamps = ccdb->getRunDuration(run, true); /// fatalise if timestamps are not found + int64_t sorTimestamp = timestamps.first; // timestamp of the SOR/SOX/STF in ms + int64_t eorTimestamp = timestamps.second; // timestamp of the EOR/EOX/ETF in ms + int64_t ts = eorTimestamp / 2 + sorTimestamp / 2; // timestamp of the middle of the run auto alppar = ccdb->getForTimeStamp>("ITS/Config/AlpideParam", ts); - + EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); + TriggerAliases* aliases = ccdb->getForTimeStamp("EventSelection/TriggerAliases", ts); // map from GlobalBC to BcId needed to find triggerBc std::map mapGlobalBCtoBcId; for (auto& bc : bcs) { @@ -227,12 +248,10 @@ struct BcSelectionTask { } int triggerBcShift = confTriggerBcShift; if (confTriggerBcShift == 999) { - int run = bcs.iteratorAt(0).runNumber(); triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294; } // extract run number and related information - int run = bcs.iteratorAt(0).runNumber(); if (run != lastRunNumber) { lastRunNumber = run; // do it only once if (run >= 500000) { // access CCDB for data or anchored MC only @@ -243,31 +262,17 @@ struct BcSelectionTask { mITSROFrameEndBorderMargin = confITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : confITSROFrameEndBorderMargin; mTimeFrameStartBorderMargin = confTimeFrameStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : confTimeFrameStartBorderMargin; mTimeFrameEndBorderMargin = confTimeFrameEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : confTimeFrameEndBorderMargin; - // access orbit-reset timestamp - auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", ts); - int64_t tsOrbitReset = (*ctpx)[0]; // us - // access TF duration, start-of-run and end-of-run timestamps from ECS GRP - std::map metadata; - metadata["runNumber"] = Form("%d", run); - auto grpecs = ccdb->getSpecific("GLO/Config/GRPECS", ts, metadata); - uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023 - int64_t tsSOR = grpecs->getTimeStart(); // ms - // calculate SOR orbit - int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; - // adjust to the nearest TF edge - orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; - // first bc of the first orbit (should coincide with TF start) - bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches; + + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); + // first bc of the first orbit + bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches; // duration of TF in bcs - nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; - LOGP(info, "tsOrbitReset={} us, SOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, orbitSOR, nBCsPerTF); + nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches; } } // bc loop for (auto bc : bcs) { - EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", bc.timestamp()); - TriggerAliases* aliases = ccdb->getForTimeStamp("EventSelection/TriggerAliases", bc.timestamp()); uint32_t alias{0}; // workaround for pp2022 (trigger info is shifted by -294 bcs) int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift]; @@ -338,8 +343,7 @@ struct BcSelectionTask { selection |= !(fabs(timeZNC) > par->fZNCBGlower && fabs(timeZNC) < par->fZNCBGupper) ? BIT(kNoBGZNC) : 0; selection |= (bc.has_ft0() ? (bc.ft0().triggerMask() & BIT(o2::ft0::Triggers::bitVertex)) > 0 : 0) ? BIT(kIsTriggerTVX) : 0; - // check if bc is far (at least confITSROFrameBorderMargin) from the end of ITS RO Frame border - // 2bc margin is also introduced at ehe beginning of ITS RO Frame to account for the uncertainty of the roFrameBiasInBC + // check if bc is far from start and end of the ITS RO Frame border uint16_t bcInITSROF = (globalBC + 3564 - alppar->roFrameBiasInBC) % alppar->roFrameLengthInBC; LOGP(debug, "bcInITSROF={}", bcInITSROF); selection |= bcInITSROF > mITSROFrameStartBorderMargin && bcInITSROF < alppar->roFrameLengthInBC - mITSROFrameEndBorderMargin ? BIT(kNoITSROFrameBorder) : 0; @@ -410,6 +414,15 @@ struct BcSelectionTask { } } + if (bc.timestamp() < static_cast(sorTimestamp) || bc.timestamp() > static_cast(eorTimestamp)) { + histos.get(HIST("hCounterInvalidBCTimestamp"))->Fill(srun, 1); + if (confCheckRunDurationLimits.value) { + LOGF(warn, "Invalid BC timestamp: %d, run: %d, sor: %d, eor: %d", bc.timestamp(), run, sorTimestamp, eorTimestamp); + alias = 0u; + selection = 0u; + } + } + // Fill bc selection columns bcsel(alias, selection, foundFT0, foundFV0, foundFDD, foundZDC); } @@ -420,20 +433,26 @@ struct BcSelectionTask { struct EventSelectionTask { SliceCache cache; Produces evsel; - Configurable syst{"syst", "PbPb", "pp, pPb, Pbp, PbPb, XeXe"}; // TODO determine from AOD metadata or from CCDB Configurable muonSelection{"muonSelection", 0, "0 - barrel, 1 - muon selection with pileup cuts, 2 - muon selection without pileup cuts"}; Configurable maxDiffZvtxFT0vsPV{"maxDiffZvtxFT0vsPV", 1., "maximum difference (in cm) between z-vertex from FT0 and PV"}; - Configurable isMC{"isMC", 0, "0 - data, 1 - MC"}; + Configurable isMC{"isMC", 0, "-1 - autoset, 0 - data, 1 - MC"}; + 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"}; Configurable confTimeIntervalForOccupancyCalculationMax{"TimeIntervalForOccupancyCalculationMax", 100, "Max time diff window for TPC occupancy calculation, us"}; - Configurable> confTimeBinsForOccupancyCalculation{"TimeBinsForOccupancyCalculation", {-40, -20, 0, 25, 50, 75, 100}, "Time bins for occupancy calculation and corresponding cuts (us)"}; - Configurable> confReferenceOccupanciesInTimeBins{"ReferenceOccupanciesInTimeBins", {3000, 1400, 750, 1000, 1750, 4000}, "Occupancy cuts in time bins (n tracks)"}; - Configurable confTimeRangeVetoOnCollStandard{"TimeRangeVetoOnCollStandard", 10, "Exclusion of a collision if there are other collisions nearby, +/- us"}; - Configurable confTimeRangeVetoOnCollNarrow{"TimeRangeVetoOnCollNarrow", 4, "Exclusion of a collision if there are other collisions nearby, +/- 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 confFT0CamplCutVetoOnCollInTimeRange{"FT0CamplPerCollCutVetoOnCollInTimeRange", 8000, "Max allowed FT0C amplitude 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 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"}; - Partition tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); + Partition tracklets = (aod::track::trackType == static_cast(o2::aod::track::TrackTypeEnum::Run2Tracklet)); + + Preslice perCollision = aod::track::collisionId; + Preslice perCollisionIU = aod::track::collisionId; Service ccdb; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -443,6 +462,8 @@ struct EventSelectionTask { 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 int32_t findClosest(int64_t globalBC, std::map& bcs) { @@ -458,9 +479,65 @@ struct EventSelectionTask { 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 * 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 = pow((it->second - zVtxCol) / zVtxSigma, 2) + pow(static_cast(it->first - meanBC) / sigmaBC, 2.); + if (chi2 < bestChi2) { + bestChi2 = chi2; + bestGlobalBC = it->first; + } + } + + return bestGlobalBC; + } + void init(InitContext&) { - // ccdb->setURL("http://ccdb-test.cern.ch:8080"); + 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()) { + isMC.value = 1; + } else { + isMC.value = 0; + } + } + } + ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); @@ -468,7 +545,6 @@ struct EventSelectionTask { histos.add("hColCounterAll", "", kTH1D, {{1, 0., 1.}}); histos.add("hColCounterTVX", "", kTH1D, {{1, 0., 1.}}); histos.add("hColCounterAcc", "", kTH1D, {{1, 0., 1.}}); - // histos.add("hOccupancy", "", kTH1D, {{200, 0., 10000}}); } void process(aod::Collisions const& collisions) @@ -476,12 +552,12 @@ struct EventSelectionTask { evsel.reserve(collisions.size()); } - void processRun2(aod::Collision const& col, BCsWithBcSelsRun2 const&, aod::Tracks const&, aod::FV0Cs const&) + void processRun2(aod::Collision const& col, BCsWithBcSelsRun2 const&, FullTracks const&, aod::FV0Cs const&) { auto bc = col.bc_as(); EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", bc.timestamp()); bool* applySelection = par->GetSelection(muonSelection); - if (isMC) { + if (isMC == 1) { applySelection[kIsBBZAC] = 0; applySelection[kNoV0MOnVsOfPileup] = 0; applySelection[kNoSPDOnVsOfPileup] = 0; @@ -537,69 +613,59 @@ struct EventSelectionTask { bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582); // fill counters - if (isMC || (!isINT1period && bc.alias_bit(kINT7)) || (isINT1period && bc.alias_bit(kINT1))) { + if (isMC == 1 || (!isINT1period && bc.alias_bit(kINT7)) || (isINT1period && bc.alias_bit(kINT1))) { histos.get(HIST("hColCounterAll"))->Fill(Form("%d", bc.runNumber()), 1); if ((!isINT1period && sel7) || (isINT1period && sel1)) { histos.get(HIST("hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1); } } - evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0); + evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, 0, 0, 0); } PROCESS_SWITCH(EventSelectionTask, processRun2, "Process Run2 event selection", true); - Preslice perCollision = aod::track::collisionId; - void processRun3(aod::Collisions const& cols, FullTracksIU const& tracks, BCsWithBcSelsRun3 const& bcs, aod::FT0s const&) + Partition pvTracks = ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); + void processRun3(aod::Collisions const& cols, FullTracksIU const&, BCsWithBcSelsRun3 const& bcs, aod::FT0s const&) { int run = bcs.iteratorAt(0).runNumber(); // extract bc pattern from CCDB for data or anchored MC only if (run != lastRun && run >= 500000) { lastRun = run; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); + // 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; + // colliding bc pattern int64_t ts = bcs.iteratorAt(0).timestamp(); auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); bcPatternB = grplhcif->getBunchFilling().getBCPattern(); - // - EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); - // access orbit-reset timestamp - auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", ts); - int64_t tsOrbitReset = (*ctpx)[0]; // us - // access TF duration, start-of-run timestamp from ECS GRP - std::map metadata; - metadata["runNumber"] = Form("%d", run); - auto grpecs = ccdb->getSpecific("GLO/Config/GRPECS", ts, metadata); - uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023 - int64_t tsSOR = grpecs->getTimeStart(); // ms - // calculate SOR orbit - int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; - // adjust to the nearest TF edge - orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; - // first bc of the first orbit (should coincide with TF start) - bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches; - // duration of TF in bcs - nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; + // extract ITS ROF parameters + auto alppar = ccdb->getForTimeStamp>("ITS/Config/AlpideParam", ts); + rofOffset = alppar->roFrameBiasInBC; + rofLength = alppar->roFrameLengthInBC; + LOGP(debug, "ITS ROF Offset={} ITS ROF Length={}", rofOffset, rofLength); } - // create maps from globalBC to bc index for TVX or FT0-OR fired bcs - // to be used for closest TVX (FT0-OR) searches + // create maps from globalBC to bc index for TVX-fired bcs + // to be used for closest TVX searches std::map mapGlobalBcWithTVX; - std::map mapGlobalBcWithTOR; + std::map mapGlobalBcVtxZ; for (auto& bc : bcs) { int64_t globalBC = bc.globalBC(); // skip non-colliding bcs for data and anchored runs if (run >= 500000 && bcPatternB[globalBC % o2::constants::lhc::LHCMaxBunches] == 0) { continue; } - if (bc.selection_bit(kIsBBT0A) || bc.selection_bit(kIsBBT0C)) { - mapGlobalBcWithTOR[globalBC] = bc.globalIndex(); - } if (bc.selection_bit(kIsTriggerTVX)) { mapGlobalBcWithTVX[globalBC] = bc.globalIndex(); + mapGlobalBcVtxZ[globalBC] = bc.has_ft0() ? bc.ft0().posZ() : 0; } } // protection against empty FT0 maps - if (mapGlobalBcWithTOR.size() == 0 || mapGlobalBcWithTVX.size() == 0) { + if (mapGlobalBcWithTVX.size() == 0) { LOGP(error, "FT0 table is empty or corrupted. Filling evsel table with dummy values"); for (auto& col : cols) { auto bc = col.bc_as(); @@ -608,114 +674,212 @@ struct EventSelectionTask { int32_t foundFV0 = bc.foundFV0Id(); int32_t foundFDD = bc.foundFDDId(); int32_t foundZDC = bc.foundZDCId(); - evsel(bc.alias_raw(), bc.selection_raw(), kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, -1); + int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; + evsel(bc.alias_raw(), bc.selection_raw(), kFALSE, kFALSE, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, -1, -1); } return; } - - std::vector vFoundBCindex(cols.size(), -1); // indices of found bcs - 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 - - // for the occupancy study - std::vector vFoundGlobalBC(cols.size(), 0); // global BCs for collisions - std::vector vTracksITS567perColl(cols.size(), 0); // counter of tracks per found bc for occupancy studies + 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 = confTimeIntervalForOccupancyCalculationMin * 1e3; // ns const float timeWinOccupancyCalcMaxNS = confTimeIntervalForOccupancyCalculationMax * 1e3; // ns - // const double timeWinOccupancyExclusionRangeNS = confExclusionIntervalForOccupancyCalculation * 1e3; // ns - const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; - - // loop to find nearest bc with FT0 entry -> foundBC index + 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 (auto& col : cols) { + int32_t colIndex = col.globalIndex(); auto bc = col.bc_as(); - int64_t meanBC = bc.globalBC(); - const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; - int64_t deltaBC = std::ceil(col.collisionTimeRes() / bcNS * 4); - - // count tracks of different types - int nITS567cls = 0; - int nITSTPCtracks = 0; - int nTOFtracks = 0; - int nTRDtracks = 0; - double timeFromTOFtracks = 0; - auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); - for (auto& track : tracksGrouped) { - if (!track.isPVContributor()) { - continue; - } - nITSTPCtracks += track.hasITS() && track.hasTPC(); - nTOFtracks += track.hasTOF(); - nTRDtracks += track.hasTRD(); - // calculate average time using TOF tracks - if (track.hasTOF()) { - timeFromTOFtracks += track.trackTime(); - } + 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 (auto& track : colPvTracks) { + float trackTime = track.trackTime(); if (track.itsNCls() >= 5) - nITS567cls++; + 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++; + } + } } - LOGP(debug, "nContrib={} nITSTPCtracks={} nTOFtracks={} nTRDtracks={}", col.numContrib(), nITSTPCtracks, nTOFtracks, nTRDtracks); - - if (nTOFtracks > 0) { - meanBC += TMath::FloorNint(timeFromTOFtracks / nTOFtracks / bcNS); // assign collision bc using TOF-matched tracks - deltaBC = 4; // use precise bc from TOF tracks with +/-4 bc margin - } else if (nITSTPCtracks > 0) { - deltaBC += 30; // extend deltaBC for collisions built with ITS-TPC tracks only + vWeightedTimesTPCnoTOFnoTRD[colIndex] = sumW > 0 ? sumTime / sumW : 0; + vWeightedSigmaTPCnoTOFnoTRD[colIndex] = sumW > 0 ? 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, confSigmaBCforHighPtTracks, vNcontributors[colIndex], col.posZ(), mapGlobalBcVtxZ); + if (bestGlobalBC > 0) { + foundGlobalBC = bestGlobalBC; + foundBCindex = mapGlobalBcWithTVX[bestGlobalBC]; + } } - int64_t minBC = meanBC - deltaBC; - int64_t maxBC = meanBC + deltaBC; + // 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; - int32_t indexClosestTVX = findClosest(meanBC, mapGlobalBcWithTVX); - int64_t tvxBC = bcs.iteratorAt(indexClosestTVX).globalBC(); - if (tvxBC >= minBC && tvxBC <= maxBC) { // closest TVX within search region - bc.setCursor(indexClosestTVX); - } else { // no TVX within search region, searching for TOR = T0A | T0C - int32_t indexClosestTOR = findClosest(meanBC, mapGlobalBcWithTOR); - int64_t torBC = bcs.iteratorAt(indexClosestTOR).globalBC(); - if (torBC >= minBC && torBC <= maxBC) { - bc.setCursor(indexClosestTOR); - } - } - int32_t foundBC = bc.globalIndex(); + // 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 (auto& col : cols) { int32_t colIndex = col.globalIndex(); - LOGP(debug, "foundBC = {} globalBC = {}", foundBC, bc.globalBC()); - vFoundBCindex[colIndex] = foundBC; - vIsVertexITSTPC[colIndex] = nITSTPCtracks > 0; - vIsVertexTOFmatched[colIndex] = nTOFtracks > 0; - vIsVertexTRDmatched[colIndex] = nTRDtracks > 0; - vCollisionsPerBc[foundBC]++; - vTracksITS567perColl[colIndex] = nITS567cls; - vFoundGlobalBC[colIndex] = bc.globalBC(); - - // check that this collision has full information inside the time window (taking into account TF borders) - int64_t bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; - vIsFullInfoForOccupancy[colIndex] = ((bcInTF - 300) * bcNS > -timeWinOccupancyCalcMinNS) && ((nBCsPerTF - 4000 - bcInTF) * bcNS > timeWinOccupancyCalcMaxNS) ? true : false; + if (vIsVertexTPC[colIndex] > 0 && vIsVertexTOF[colIndex] == 0 && vIsVertexHighPtTPC[colIndex] == 0) { + float weightedTime = vWeightedTimesTPCnoTOFnoTRD[colIndex]; + float weightedSigma = vWeightedSigmaTPCnoTOFnoTRD[colIndex]; + auto bc = col.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 in time range for occupancy calculation + // save indices of collisions for occupancy calculation (both in ROF and in time range) std::vector> vCollsInTimeWin; + std::vector> vCollsInSameITSROF; std::vector> vTimeDeltaForColls; // delta time wrt a given collision for (auto& col : cols) { int32_t colIndex = col.globalIndex(); + int64_t foundGlobalBC = vFoundGlobalBC[colIndex]; + auto bc = bcs.iteratorAt(vFoundBCindex[colIndex]); + if (bc.has_foundFT0()) + vAmpFT0CperColl[colIndex] = bc.foundFT0().sumAmpC(); + + int64_t TFid = (foundGlobalBC - bcSOR) / nBCsPerTF; + int64_t rofId = (foundGlobalBC + 3564 - rofOffset) / rofLength; + + // ### for in-ROF occupancy + 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; + // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; + 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; + // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; + int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; + if (thisRofId != rofId) + break; + vAssocToSameROF.push_back(maxColIndex); + maxColIndex++; + } + vCollsInSameITSROF.push_back(vAssocToSameROF); + + // ### 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; } - - int64_t foundGlobalBC = vFoundGlobalBC[colIndex]; - int64_t TFid = (foundGlobalBC - bcSOR) / nBCsPerTF; - - // find all collisions in time window before the current one (start with the current collision) - int32_t minColIndex = colIndex; + // 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 @@ -723,7 +887,6 @@ struct EventSelectionTask { if (thisTFid != TFid) break; float dt = (thisBC - foundGlobalBC) * bcNS; // ns - // check if we are within the chosen time range if (dt < timeWinOccupancyCalcMinNS) break; @@ -732,7 +895,7 @@ struct EventSelectionTask { minColIndex--; } // find all collisions in time window after the current one - int32_t maxColIndex = colIndex + 1; + maxColIndex = colIndex + 1; while (maxColIndex < cols.size()) { int64_t thisBC = vFoundGlobalBC[maxColIndex]; int64_t thisTFid = (thisBC - bcSOR) / nBCsPerTF; @@ -749,83 +912,118 @@ struct EventSelectionTask { vTimeDeltaForColls.push_back(vCollsTimeDeltaWrtGivenColl); } - // perform the occupancy calculation in the pre-defined time window - std::vector vNumTracksITS567inFullTimeWin(cols.size(), 0); // counter of tracks in full time window for occupancy studies - std::vector vNoOccupAggressiveCuts(cols.size(), 0); // no occupancy according to the agressive cuts - std::vector vNoOccupStrictCuts(cols.size(), 0); // no occupancy according to the strict cuts - std::vector vNoOccupMediumCuts(cols.size(), 0); // no occupancy according to the medium cuts - std::vector vNoOccupRelaxedCuts(cols.size(), 0); // no occupancy according to the relaxed cuts - std::vector vNoOccupGentleCuts(cols.size(), 0); // no occupancy according to the gentle cuts - std::vector vNoCollInTimeRangeStandard(cols.size(), 0); // no collisions in a specified time range - std::vector vNoCollInTimeRangeNarrow(cols.size(), 0); // no collisions in a specified time range + // 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 vNoCollInVzDependentTimeRange(cols.size(), 0); // no collisions in a vZ-dependent time range - // time ranges for occupancy calculation - const int nTimeIntervals = 6; - const float coeffOccupInTimeBins[] = {0.2, 0.4, 0.6, 1.}; + 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 for (auto& col : cols) { int32_t colIndex = col.globalIndex(); + float vZ = col.posZ(); + + // ### in-ROF occupancy + std::vector vAssocToSameROF = vCollsInSameITSROF[colIndex]; + int nITS567tracksForRofVetoStrict = 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 < vAssocToSameROF.size(); iCol++) { + int thisColIndex = vAssocToSameROF[iCol]; + nITS567tracksForRofVetoStrict += vTracksITS567perColl[thisColIndex]; + if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInROF) + nCollsInRofWithFT0CAboveVetoStandard++; + if (fabs(vCollVz[thisColIndex] - vZ) < confEpsilonVzDiffVetoInROF) + nITS567tracksForRofVetoOnCloseVz += vTracksITS567perColl[thisColIndex]; + } + // in-ROF occupancy flags + vNoCollInSameRofStrict[colIndex] = (nITS567tracksForRofVetoStrict == 0); + vNoCollInSameRofStandard[colIndex] = (nCollsInRofWithFT0CAboveVetoStandard == 0); + vNoCollInSameRofWithCloseVz[colIndex] = (nITS567tracksForRofVetoOnCloseVz == 0); + + // ### occupancy in time windows // protection against TF borders - if (!vIsFullInfoForOccupancy[colIndex]) { - vNumTracksITS567inFullTimeWin[colIndex] = -1; // occupancy in undefined (too close to 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; - int nITS567tracksInTimeBins[nTimeIntervals] = {}; - int nITS567tracksForVetoStandard = 0; // to veto events with nearby collisions - int nITS567tracksForVetoNarrow = 0; // to veto events with nearby collisions (narrower range) - for (int iCol = 0; iCol < vAssocToThisCol.size(); iCol++) { + 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 + 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]; - if (thisColIndex == colIndex) // skip the same collision - continue; float dt = vCollsTimeDeltaWrtGivenColl[iCol] / 1e3; // ns -> us - - if (!confUseWeightsForOccupancyVariable) { - nITS567tracksInFullTimeWindow += vTracksITS567perColl[thisColIndex]; - } else { + float wOccup = 1.; + if (confUseWeightsForOccupancyVariable) { // weighted occupancy - float wOccup = 0; + 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 wOccup = 1; - else if (dt >= 15 && dt < 100) // collisions from the future - wOccup = -1. / 85 * dt + 20. / 17; - if (wOccup > 0) - nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex]; + // 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; } - - for (int iTime = 0; iTime < nTimeIntervals; iTime++) { - if (confTimeBinsForOccupancyCalculation->at(iTime) < dt && dt <= confTimeBinsForOccupancyCalculation->at(iTime + 1)) - nITS567tracksInTimeBins[iTime] += vTracksITS567perColl[thisColIndex]; - if (fabs(dt) < confTimeRangeVetoOnCollStandard) - nITS567tracksForVetoStandard += vTracksITS567perColl[thisColIndex]; - if (fabs(dt) < confTimeRangeVetoOnCollNarrow) - nITS567tracksForVetoNarrow += vTracksITS567perColl[thisColIndex]; + nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex]; + sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex]; + + // counting tracks from other collisions in fixed time windows + if (fabs(dt) < confTimeRangeVetoOnCollNarrow) + nITS567tracksForVetoNarrow += vTracksITS567perColl[thisColIndex]; + if (fabs(dt) < 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 (fabs(dt) < 2.0) { // us, complete veto on other collisions + nCollsWithFT0CAboveVetoStandard++; + } else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more + if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange / 5) + nCollsWithFT0CAboveVetoStandard++; + } else if (fabs(dt) < 8 + fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm + // counting number of other collisions with multiplicity above threshold + if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange) + nCollsWithFT0CAboveVetoStandard++; } - } - vNumTracksITS567inFullTimeWin[colIndex] = nITS567tracksInFullTimeWindow; // occupancy (without a current collision) - // decisions based on occupancies in time bins - bool decisions[4]; - for (int iCut = 0; iCut < 4; iCut++) { - decisions[iCut] = true; - for (int iTime = 0; iTime < nTimeIntervals; iTime++) { - if (nITS567tracksInTimeBins[iTime] >= coeffOccupInTimeBins[iCut] * confReferenceOccupanciesInTimeBins->at(iTime)) { - decisions[iCut] = false; - break; + // vZ-dependent time cut to avoid collinear tracks from other collisions (experimental) + if (fabs(dt) < 8 + 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)) + nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; + } 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)) + nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; } } } - vNoOccupStrictCuts[colIndex] = decisions[0]; - vNoOccupMediumCuts[colIndex] = decisions[1]; - vNoOccupRelaxedCuts[colIndex] = decisions[2]; - vNoOccupGentleCuts[colIndex] = decisions[3]; - vNoOccupAggressiveCuts[colIndex] = ((nITS567tracksInTimeBins[0] < 300) && (nITS567tracksInTimeBins[1] == 0) && (nITS567tracksInTimeBins[2] == 0) && (nITS567tracksInTimeBins[3] == 0) && (nITS567tracksInTimeBins[4] < 200) && (nITS567tracksInTimeBins[5] < 400)); - vNoCollInTimeRangeStandard[colIndex] = (nITS567tracksForVetoStandard == 0); + 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); + vNoCollInVzDependentTimeRange[colIndex] = (nITS567tracksForVetoVzDependent == 0); // experimental } for (auto& col : cols) { @@ -851,14 +1049,15 @@ struct EventSelectionTask { selection |= vIsVertexTRDmatched[colIndex] ? BIT(kIsVertexTRDmatched) : 0; selection |= isGoodZvtxFT0vsPV ? BIT(kIsGoodZvtxFT0vsPV) : 0; - // selection bits based on occupancy pattern - selection |= vNoOccupAggressiveCuts[colIndex] ? BIT(kNoHighOccupancyAgressive) : 0; - selection |= vNoOccupStrictCuts[colIndex] && vNoCollInTimeRangeStandard[colIndex] ? BIT(kNoHighOccupancyStrict) : 0; - selection |= vNoOccupMediumCuts[colIndex] && vNoCollInTimeRangeStandard[colIndex] ? BIT(kNoHighOccupancyMedium) : 0; - selection |= vNoOccupRelaxedCuts[colIndex] && vNoCollInTimeRangeStandard[colIndex] ? BIT(kNoHighOccupancyRelaxed) : 0; - selection |= vNoOccupGentleCuts[colIndex] && vNoCollInTimeRangeNarrow[colIndex] ? BIT(kNoHighOccupancyGentle) : 0; - selection |= vNoCollInTimeRangeStandard[colIndex] ? BIT(kNoCollInTimeRangeStandard) : 0; + // selection bits based on occupancy time pattern 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; // apply int7-like selections bool sel7 = 0; @@ -877,10 +1076,10 @@ struct EventSelectionTask { histos.get(HIST("hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1); } - int nTracksITS567inFullTimeWin = vNumTracksITS567inFullTimeWin[colIndex]; - // histos.get(HIST("hOccupancy"))->Fill(nTracksITS567inFullTimeWin); + int bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; - evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, nTracksITS567inFullTimeWin); + evsel(alias, selection, sel7, sel8, foundBC, foundFT0, foundFV0, foundFDD, foundZDC, bcInTF, + vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); } } @@ -889,6 +1088,9 @@ struct EventSelectionTask { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + // Parse the metadata + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{ adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc)}; diff --git a/Common/TableProducer/ft0CorrectedTable.cxx b/Common/TableProducer/ft0CorrectedTable.cxx index 49e6e8bea1c..877cb40111f 100644 --- a/Common/TableProducer/ft0CorrectedTable.cxx +++ b/Common/TableProducer/ft0CorrectedTable.cxx @@ -10,38 +10,89 @@ // or submit itself to any jurisdiction. #include -#include "Common/DataModel/FT0Corrected.h" #include "Framework/ConfigParamSpec.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" -#include "Common/DataModel/EventSelection.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/EventSelection.h" #include "CommonConstants/LHCConstants.h" #include "CommonConstants/PhysicsConstants.h" #include "DataFormatsFT0/Digit.h" +#include "CCDB/BasicCCDBManager.h" +#include "CollisionTypeHelper.h" +#include "TRandom3.h" using namespace o2; using namespace o2::framework; - using namespace o2::aod; -struct FT0CorrectedTable { + +struct ft0CorrectedTable { + // Configurables + Configurable resoFT0A{"resoFT0A", 20.f, "FT0A resolution"}; + Configurable resoFT0C{"resoFT0C", 20.f, "FT0C resolution"}; + Configurable addHistograms{"addHistograms", false, "Add QA histograms"}; + Configurable cfgCollisionSystem{"collisionSystem", -2, "Collision system: -2 (use cfg values), -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"}; + Configurable cfgUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; + Configurable cfgTimestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + Service ccdb; + + // Producer Produces table; using BCsWithMatchings = soa::Join; using CollisionEvSel = soa::Join::iterator; + static constexpr float invLightSpeedCm2NS = 1.f / o2::constants::physics::LightSpeedCm2NS; - void process(BCsWithMatchings const&, soa::Join const& collisions, aod::FT0s const&) + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + void init(o2::framework::InitContext&) { + if (doprocessStandard && doprocessWithBypassFT0timeInMC) { + LOG(fatal) << "Both processStandard and processWithBypassFT0timeInMC are enabled. Pick one of the two"; + } + if (!doprocessStandard && !doprocessWithBypassFT0timeInMC) { + LOG(fatal) << "No process is enabled. Pick one"; + } + ccdb->setURL(cfgUrl); + ccdb->setTimestamp(cfgTimestamp); + 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()); + + if (!addHistograms) { + return; + } + 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)"}}); + if (doprocessWithBypassFT0timeInMC) { + histos.add("MC/deltat0A", "t0A", kTH1D, {{1000, -50, 50, "t0A (ps)"}}); + histos.add("MC/deltat0C", "t0C", kTH1D, {{1000, -50, 50, "t0C (ps)"}}); + histos.add("MC/deltat0AC", "t0AC", kTH1D, {{1000, -50, 50, "t0AC (ps)"}}); + } + } + + void processStandard(soa::Join const& collisions, + BCsWithMatchings const&, + aod::FT0s const&) + { + table.reserve(collisions.size()); + float t0A = 1e10f; + float t0C = 1e10f; for (auto& collision : collisions) { - float vertexPV = collision.posZ(); - float vertex_corr = vertexPV / o2::constants::physics::LightSpeedCm2NS; - float t0A = 1e10; - float t0C = 1e10; + t0A = 1e10f; + t0C = 1e10f; + const float vertexPV = collision.posZ(); + const float vertex_corr = vertexPV * invLightSpeedCm2NS; constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns if (collision.has_foundFT0()) { - auto ft0 = collision.foundFT0(); - std::bitset<8> triggers = ft0.triggerMask(); - bool ora = triggers[o2::ft0::Triggers::bitA]; - bool orc = triggers[o2::ft0::Triggers::bitC]; + const auto& ft0 = collision.foundFT0(); + const std::bitset<8>& triggers = ft0.triggerMask(); + const bool ora = triggers[o2::ft0::Triggers::bitA]; + const bool orc = triggers[o2::ft0::Triggers::bitC]; LOGF(debug, "triggers OrA %i OrC %i ", ora, orc); LOGF(debug, " T0A = %f, T0C %f, vertex_corr %f", ft0.timeA(), ft0.timeC(), vertex_corr); if (ora && ft0.timeA() < dummyTime) { @@ -52,11 +103,100 @@ struct FT0CorrectedTable { } } LOGF(debug, " T0 collision time T0A = %f, T0C = %f", t0A, t0C); + 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); + } + table(t0A, t0C); + } + } + PROCESS_SWITCH(ft0CorrectedTable, processStandard, "Process standard table (default)", true); + + void processWithBypassFT0timeInMC(soa::Join const& collisions, + soa::Join const& bcs, + aod::FT0s const&, + aod::McCollisions const&) + { + if (cfgCollisionSystem.value == -1) { + o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp(cfgPathGrpLhcIf, + bcs.iteratorAt(0).timestamp()); + cfgCollisionSystem.value = CollisionSystemType::getCollisionTypeFromGrp(grpo); + switch (cfgCollisionSystem.value) { + case CollisionSystemType::kCollSyspp: + resoFT0A.value = 24.f; + resoFT0C.value = 24.f; + break; + case CollisionSystemType::kCollSysPbPb: + resoFT0A.value = 5.65f; + resoFT0C.value = 5.65f; + break; + default: + break; + } + } + table.reserve(collisions.size()); + float t0A = 1e10f; + float t0C = 1e10f; + float eventtimeMC = 1e10f; + float posZMC = 0; + bool hasMCcoll = false; + + for (auto& collision : collisions) { + hasMCcoll = false; + eventtimeMC = 1e10f; + t0A = 1e10f; + t0C = 1e10f; + posZMC = 0; + const float vertexPV = collision.posZ(); + const float vertex_corr = vertexPV * invLightSpeedCm2NS; + constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns + if (collision.has_mcCollision()) { + hasMCcoll = true; + const auto& collisionMC = collision.mcCollision(); + eventtimeMC = collisionMC.t(); + posZMC = collisionMC.posZ(); + } + if (collision.has_foundFT0()) { + const auto& ft0 = collision.foundFT0(); + const std::bitset<8>& triggers = ft0.triggerMask(); + const bool ora = triggers[o2::ft0::Triggers::bitA]; + const bool orc = triggers[o2::ft0::Triggers::bitC]; + + if (ora && ft0.timeA() < dummyTime) { + t0A = ft0.timeA(); + if (hasMCcoll) { + const float diff = eventtimeMC - posZMC * invLightSpeedCm2NS + gRandom->Gaus(0.f, resoFT0A); + t0A = diff; + } + t0A += vertex_corr; + } + if (orc && ft0.timeC() < dummyTime) { + t0C = ft0.timeC(); + if (hasMCcoll) { + const float diff = eventtimeMC + posZMC * invLightSpeedCm2NS + gRandom->Gaus(0.f, resoFT0C); + t0C = diff; + } + t0C -= vertex_corr; + } + } + LOGF(debug, " T0 collision time T0A = %f, T0C = %f", t0A, t0C); + 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 (hasMCcoll) { + histos.fill(HIST("MC/deltat0A"), (t0A - eventtimeMC) * 1000.f); + histos.fill(HIST("MC/deltat0C"), (t0C - eventtimeMC) * 1000.f); + histos.fill(HIST("MC/deltat0AC"), ((t0A + t0C) * 0.5f - eventtimeMC) * 1000.f); + } + } table(t0A, t0C); } } + PROCESS_SWITCH(ft0CorrectedTable, processWithBypassFT0timeInMC, "Process MC with bypass of the AO2D information. Use with care!", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"ft0-corrected-table"})}; -} + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/match-mft-ft0.cxx b/Common/TableProducer/match-mft-ft0.cxx new file mode 100644 index 00000000000..a4b208a03c9 --- /dev/null +++ b/Common/TableProducer/match-mft-ft0.cxx @@ -0,0 +1,545 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 match-mft-ft0.cxx +// \author Sarah Herrmann +// +// \brief This code loops over every MFT tracks (except orphan tracks) and propagates +// them to the FT0-C, matching the signals in some BC to reduce track ambiguity +// It produces a table containing for each MFT track a list of BCs with an FT0C match +// called aod::BCofMFT +// \date 03/09/24 + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" + +#include "MathUtils/Utils.h" +#include "CommonConstants/LHCConstants.h" +#include "Common/Core/trackUtilities.h" //for getTrackPar() +#include "ReconstructionDataFormats/TrackFwd.h" //for propagate +// https://github.com/AliceO2Group/AliceO2/blob/dev/DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackFwd.h +#include "CommonConstants/LHCConstants.h" +#include "Math/MatrixFunctions.h" +#include "Math/SMatrix.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" + +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "Field/MagneticField.h" +#include "TGeoGlobalMagField.h" + +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" + +#include "Common/DataModel/MatchMFTFT0.h" + +using SMatrix55 = ROOT::Math::SMatrix>; +using SMatrix5 = ROOT::Math::SVector; + +using namespace o2; +using namespace o2::framework; + +// Creating a table BC to FT0 and filling it +struct bctoft0c { + Produces mf; + struct { + std::vector ft0ids; + } filler; + void process(aod::BCs::iterator const& bc, soa::SmallGroups const& ft0s) + { + filler.ft0ids.clear(); + for (auto const& ft0 : ft0s) { + filler.ft0ids.emplace_back(ft0.globalIndex()); + } + mf(bc.globalIndex(), filler.ft0ids); + } +}; + +using ExtBCs = soa::Join; + +template +T getCompatibleBCs(aod::AmbiguousMFTTrack const& atrack, aod::Collision const& collOrig, T const& bcs, int deltaBC) +{ + // this method is unused for now, MFTtracks with no collisions (orphan tracks) are not considered for the matching with FT0C + auto compBCs = atrack.bc_as(); // BC + info on FT0 + auto bcIter = compBCs.begin(); // first element of compBC + uint64_t firstBC = bcIter.globalBC(); + + bcIter.moveToEnd(); // does it move to the end or the next one after the end ? + --bcIter; // to avoid a seg fault + uint64_t lastBC = bcIter.globalBC(); // gives the last COMPATIBLE BC in compBCs + + auto bcIt = collOrig.bc_as(); + + int64_t minBCId = bcIt.globalIndex(); + auto minGlobalBC = bcIt.globalBC(); + + if (bcIt.globalBC() < firstBC + deltaBC) { + while (bcIt != bcs.end() && bcIt.globalBC() < firstBC + deltaBC) { + minBCId = bcIt.globalIndex(); + minGlobalBC = bcIt.globalBC(); + + ++bcIt; + } + if (bcIt == bcs.end()) { + --bcIt; + minBCId = bcIt.globalIndex(); + minGlobalBC = bcIt.globalBC(); + } + } else { + // here bcIt.globalBC() >= firstBC + deltaBC + + while (bcIt != bcs.begin() && bcIt.globalBC() > firstBC + deltaBC) { + minBCId = bcIt.globalIndex(); + minGlobalBC = bcIt.globalBC(); + + --bcIt; + } + } + + int64_t maxBCId = bcIt.globalIndex(); + + while (bcIt != bcs.end() && bcIt.globalBC() < lastBC + deltaBC) { + maxBCId = bcIt.globalIndex(); + + ++bcIt; + } + + if (bcIt != bcs.end() && maxBCId >= minBCId) { + T slice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, (uint64_t)minBCId}; + bcs.copyIndexBindings(slice); + return slice; + } else { + T slice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId)}, (uint64_t)minBCId}; + bcs.copyIndexBindings(slice); + return slice; + } +} + +template +T getCompatibleBCs(aod::MFTTracks::iterator const& track, aod::Collision const& collOrig, T const& bcs, int deltaBC) +{ + + // define firstBC and lastBC (globalBC of beginning and end of the range, when no shift is applied) + + auto bcIt = collOrig.bc_as(); + // auto timstp = bcIt.timestamp(); + + int64_t firstBC = bcIt.globalBC() + (track.trackTime() - track.trackTimeRes()) / o2::constants::lhc::LHCBunchSpacingNS; + int64_t lastBC = firstBC + 2 * track.trackTimeRes() / o2::constants::lhc::LHCBunchSpacingNS + 1; // to have a delta = 198 BC + + // printf(">>>>>>>>>>>>>>>>>>>>>>>>>>> last-first %lld\n", lastBC-firstBC); + + // int collTimeResInBC = collOrig.collisionTimeRes()/o2::constants::lhc::LHCBunchSpacingNS; + + // int64_t collFirstBC = bcIt.globalBC() + (collOrig.collisionTime() - collOrig.collisionTimeRes())/o2::constants::lhc::LHCBunchSpacingNS; + // int64_t collLastBC = collFirstBC + 2*collOrig.collisionTimeRes()/o2::constants::lhc::LHCBunchSpacingNS +1; + + int64_t minBCId = bcIt.globalIndex(); + + if ((int64_t)bcIt.globalBC() < firstBC + deltaBC) { + while (bcIt != bcs.end() && (int64_t)bcIt.globalBC() < firstBC + deltaBC) { + minBCId = bcIt.globalIndex(); + + ++bcIt; + } + if (bcIt == bcs.end()) { + --bcIt; + // allows to avoid bcIt==bcs.end() in the following + } + // minGlobalBC needs to be >= to firstBC+deltaBC + minBCId = bcIt.globalIndex(); + + } else { + // here bcIt.globalBC() >= firstBC + deltaBC + + while (bcIt != bcs.begin() && (int64_t)bcIt.globalBC() >= (int64_t)firstBC + deltaBC) { + minBCId = bcIt.globalIndex(); + --bcIt; + } + if (bcIt == bcs.begin() && (int64_t)bcIt.globalBC() >= (int64_t)firstBC + deltaBC) { + minBCId = bcIt.globalIndex(); + } + ++bcIt; // retrieve the pointer which gave minBCId and minGlobalBC + if (bcIt == bcs.end()) { + --bcIt; // go back if we got to the end of the list + } + } + + int64_t maxBCId = bcIt.globalIndex(); + + if ((int64_t)bcIt.globalBC() > (int64_t)lastBC + deltaBC) { + // the previous minimum is actually bigger than the right boundary + + if (bcIt != bcs.begin()) { + --bcIt; // let's check the previous element in the BC list + if ((int64_t)bcIt.globalBC() < (int64_t)firstBC + deltaBC) // if this previous element is smaller than the left boundary + { + // means that the slice of compatible BCs is empty + + T slice{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + // bcs.copyIndexBindings(slice); REMOVED IT BECAUSE I DON'T KNOW WHAT IT DOES HERE + return slice; // returns an empty slice + } + } + } + + if ((int64_t)bcIt.globalBC() < (int64_t)firstBC + deltaBC) { + // the previous minimum is actually smaller than the right boundary + ++bcIt; + + if (bcIt != bcs.end() && ((int64_t)bcIt.globalBC() > (int64_t)lastBC + deltaBC)) { + // check the following element + + T slice{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + // bcs.copyIndexBindings(slice); REMOVED IT BECAUSE I DON'T KNOW WHAT IT DOES HERE + return slice; // returns an empty slice + } + } + + while (bcIt != bcs.end() && (int64_t)bcIt.globalBC() <= (int64_t)lastBC + deltaBC) { + maxBCId = bcIt.globalIndex(); + + ++bcIt; + } + + if (maxBCId < minBCId) { + if (bcIt == bcs.end()) { + printf("at the end of the bcs iterator %d\n", 1); + } + T slice{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; + // bcs.copyIndexBindings(slice); REMOVED IT BECAUSE I DON'T KNOW WHAT IT DOES HERE + return slice; // returns an empty slice + } + + T slice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, (uint64_t)minBCId}; + bcs.copyIndexBindings(slice); + return slice; +} + +struct matchmftft0 { + Produces BcMft; + struct { + std::vector BCids; + } filler; + + Service ccdb; + + int runNumber = -1; + float Bz = 0; // Magnetic field for MFT + static constexpr double centerMFT[3] = {0, 0, -61.4}; // Field at center of MFT + int count = 0; + o2::parameters::GRPMagField* grpmag = nullptr; + + Configurable strictBCSel{"strictBCSel", false, "force the BC of the match to have FT0A&C signals"}; + Configurable shiftBC{"shiftBC", 0, "shift in BC wrt normal"}; // should be kept at zero except if the time-alignment MFT-FT0C must be redone + + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + + std::vector> channelCoord = {{103.2, 17.8, -813.1}, {76.9, 17.8, -815.9}, {103.1, 44.2, -812.1}, {76.8, 44.2, -814.9}, {103.2, 78.7, -810}, {76.8, 79, -812.9}, {103.2, 105, -807.1}, {76.8, 105.3, -810}, {43.2, 78.8, -815}, {43.2, 105.1, -812.1}, {16.8, 78.9, -815.9}, {16.8, 105.2, -813}, {-16.8, 105.2, -813}, {-16.8, 78.9, -815.9}, {-43.2, 105.1, -812.1}, {-43.2, 78.8, -815}, {-76.8, 105.3, -810}, {-76.8, 79, -812.9}, {-103.2, 105, -807.1}, {-103.2, 78.7, -810}, {-76.8, 44.2, -814.9}, {-103.1, 44.2, -812.1}, {-76.9, 17.8, -815.9}, {-103.2, 17.8, -813.1}, {-103.2, -17.8, -813.1}, {-76.9, -17.8, -815.9}, {-103.1, -44.2, -812.1}, {-76.8, -44.2, -814.9}, {-103.2, -78.7, -810}, {-76.8, -79, -812.9}, {-103.2, -105, -807.1}, {-76.8, -105.3, -810}, {-43.2, -78.8, -815}, {-43.2, -105.1, -812.1}, {-16.8, -78.9, -815.9}, {-16.8, -105.2, -813}, {16.8, -105.2, -813}, {16.8, -78.9, -815.9}, {43.2, -105.1, -812.1}, {43.2, -78.8, -815}, {76.8, -105.3, -810}, {76.8, -79, -812.9}, {103.2, -105, -807.1}, {103.2, -78.7, -810}, {76.8, -44.2, -814.9}, {103.1, -44.2, -812.1}, {76.9, -17.8, -815.9}, {103.2, -17.8, -813.1}, {163, 18.7, -804.1}, {137, 18.9, -808.9}, {163, 45.2, -803.1}, {137, 45.3, -807.9}, {163, 78.6, -800.1}, {137, 79.1, -804.9}, {163, 104.9, -797.2}, {137, 105.4, -801.9}, {103.4, 138, -802}, {102.9, 164, -797.2}, {77.1, 138, -804.9}, {76.6, 164, -800}, {43.3, 139, -807}, {43.2, 165, -802.1}, {16.9, 139, -807.9}, {16.7, 165, -803}, {-16.7, 165, -803}, {-16.9, 139, -807.9}, {-43.2, 165, -802.1}, {-43.3, 139, -807}, {-76.6, 164, -800}, {-77.1, 138, -804.9}, {-102.9, 164, -797.2}, {-103.4, 138, -802}, {-137, 105.4, -801.9}, {-163, 104.9, -797.2}, {-137, 79.1, -804.9}, {-163, 78.6, -800.1}, {-137, 45.3, -807.9}, {-163, 45.2, -803.1}, {-137, 18.9, -808.9}, {-163, 18.7, -804.1}, {-163, -18.7, -804.1}, {-137, -18.9, -808.9}, {-163, -45.2, -803.1}, {-137, -45.3, -807.9}, {-163, -78.6, -800.1}, {-137, -79.1, -804.9}, {-163, -104.9, -797.2}, {-137, -105.4, -801.9}, {-103.4, -138, -802}, {-102.9, -164, -797.2}, {-77.1, -138, -804.9}, {-76.6, -164, -800}, {-43.3, -139, -807}, {-43.2, -165, -802.1}, {-16.9, -139, -807.9}, {-16.7, -165, -803}, {16.7, -165, -803}, {16.9, -139, -807.9}, {43.2, -165, -802.1}, {43.3, -139, -807}, {76.6, -164, -800}, {77.1, -138, -804.9}, {102.9, -164, -797.2}, {103.4, -138, -802}, {137, -105.4, -801.9}, {163, -104.9, -797.2}, {137, -79.1, -804.9}, {163, -78.6, -800.1}, {137, -45.3, -807.9}, {163, -45.2, -803.1}, {137, -18.9, -808.9}, {163, -18.7, -804.1}}; + + HistogramRegistry registry{ + "registry", + {{"UnMatchedTracksXY", "; #it{x} (cm); #it{y} (cm);", {HistType::kTH2F, {{701, -35.05, 35.05}, {701, -35.05, 35.05}}}}, + {"MatchedTracksXY", "; #it{x} (cm); #it{y} (cm);", {HistType::kTH2F, {{701, -35.05, 35.05}, {701, -35.05, 35.05}}}}, + {"AllTracksXY", "; #it{x} (cm); #it{y} (cm);", {HistType::kTH2F, {{701, -35.05, 35.05}, {701, -35.05, 35.05}}}}, + {"DistChannelToProp", "; D (cm); #count", {HistType::kTH1D, {{101, 0, 100}}}}, + {"NchannelsPerBC", "; N_{channelC}; #count", {HistType::kTH1D, {{101, 0, 100}}}}, + {"NgoodBCperTrack", "; N_{goodBC}; #count", {HistType::kTH1D, {{11, 0, 10}}}}, + {"NgoodBCperTrackINDIV", "; N_{goodBC}; #count", {HistType::kTH1D, {{11, 0, 10}}}}, + {"NCompBCwFT0C", "; N_{compBC}; #count", {HistType::kTH1D, {{21, -0.5, 20.5}}}}, + {"NCompBCwFT0s", "; N_{compBC}; #count", {HistType::kTH1D, {{21, -0.5, 20.5}}}}, + {"DiffInBCINDIV", "; indivBC-firstBC (globalBC); #count", {HistType::kTH1I, {{199, 0, 199}}}}, + {"DiffInBC", "; goodBC-firstBC (globalBC); #count", {HistType::kTH1I, {{199, 0, 199}}}}}}; + + void init(InitContext const&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + } + + void initCCDB(ExtBCs::iterator const& bc) + { + + 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); // for some reason this is necessary for the next next line + runNumber = bc.runNumber(); + + o2::field::MagneticField* field = static_cast(TGeoGlobalMagField::Instance()->GetField()); + + Bz = field->getBz(centerMFT); // gives error if the propagator is not initFielded + LOG(info) << "The field at the center of the MFT is Bz = " << Bz; + } + + bool isInFT0Acc(double x, double y) + { + // returns true if the propagated x and y positions are in an active zone of the FT0-C, false if they in a dead zone + + if ((abs(x) < 6.365) && (abs(y) < 6.555)) { + // track outside the FT0-C acceptance (in the central hole) + return false; + } + + if (((x > -12.75) && (x < -11.85)) || ((x > -6.55) && (x < -5.75)) || ((x > -0.35) && (x < 0.45)) || ((x > 5.75) && (x < 6.55)) || ((x > 11.85) && (x < 12.75))) { + // track outside the FT0-C acceptance (in the vertical line holes) + return false; + } + + if (((y > -12.95) && (y < -11.95)) || ((y > -6.65) && (y < -5.85)) || ((y > -0.55) && (y < 0.45)) || ((y > 5.75) && (y < 6.65)) || ((y > 11.95) && (y < 12.85))) { + // track outside the FT0-C acceptance (in the horizontal line holes) + return false; + } + + return true; + } + + void processMFT(aod::MFTTracks const& mfttracks, + aod::Collisions const&, ExtBCs const& bcs, + aod::FT0s const&) + { + initCCDB(bcs.begin()); + + int i = 0; // counts the number of channels having non-zero amplitude + // for a particular BC + double D = 0.0; // distance between (xe,ye,ze) and (xc,yc,zc) + double minD; + double globalMinD; + + for (auto& track : mfttracks) { + filler.BCids.clear(); + globalMinD = 999.; // minimum D for all BC + ExtBCs::iterator closestBC; // compatible BC with the D the smallest + // beware: there could be several BC with the same smallest D + // not a very useful variable + + if (!track.has_collision()) { + BcMft(track.globalIndex(), filler.BCids); // empty + continue; + } + auto collOrig = track.collision(); + + auto bcSlice = getCompatibleBCs(track, collOrig, bcs, shiftBC); + + // firstBC= global BC of the beginning of the ROF (shifted by shiftBC) + int64_t firstBC = collOrig.bc_as().globalBC() + (track.trackTime() - track.trackTimeRes()) / o2::constants::lhc::LHCBunchSpacingNS + shiftBC; + + bool rofHasBoth = false; // ROF with both FT0C and FT0A signal in the same BC + + std::vector v1; // Temporary null vector for the computation of the covariance matrix + SMatrix55 tcovs(v1.begin(), v1.end()); + SMatrix5 tpars(track.x(), track.y(), track.phi(), track.tgl(), track.signed1Pt()); + + o2::track::TrackParCovFwd trackPar{track.z(), tpars, tcovs, track.chi2()}; + + // we propagate the MFT track to the mean z position of FT0-C + // getTrackPar() doesn't work because mft tracks don't have alpha + trackPar.propagateToZhelix(-82.6, Bz); // z in cm + + if (!isInFT0Acc(trackPar.getX(), trackPar.getY())) { + // track outside the FT0-C acceptance + BcMft(track.globalIndex(), filler.BCids); // empty + continue; + } + + std::vector goodBC; // contains the BCs matched with the current MFT track + int nCompBCwft0C = 0; + int nCompBCwft0s = 0; // Number of compatible BCs with FT0A AND C signals + + bool hasft0A = false; + bool hasft0C = false; + for (auto& bc : bcSlice) { + hasft0C = false; + hasft0A = false; + // printf("----------bcId %lld\n", bc.globalIndex()); + if (!bc.has_ft0s()) { + continue; + } + + auto ft0s = bc.ft0s(); + i = 0; // reinitialise + D = 0.0; + minD = 999.9; + for (auto const& ft0 : ft0s) { + // printf("---------ft0.bcId %d\n", ft0.bcId()); + if (ft0.channelA().size() > 0) { + // BC with signals in FT0A + hasft0A = true; + } + + if (ft0.channelC().size() > 0) { + hasft0C = true; + } + for (auto channelId : ft0.channelC()) { + + std::vector Xc = channelCoord[channelId]; //(xc,yc,zc) coordinates + // D in cm + D = sqrt(pow(Xc[0] * 0.1 - trackPar.getX(), 2) + pow(Xc[1] * 0.1 - trackPar.getY(), 2) + pow(Xc[2] * 0.1 - 1.87 - trackPar.getZ(), 2)); + // printf("----channelId %u, D %f, n %d\n", channelId, D, n);//should be between 96 and 207 + if (D < minD) { + minD = D; + } + + registry.fill(HIST("DistChannelToProp"), D); + } + + i += ft0.channelC().size(); + } + + registry.fill(HIST("NchannelsPerBC"), i); + if (hasft0C) { + nCompBCwft0C++; // number of compatible BCs that have ft0-C signal + } + + //----------------------- BC selection here ------------------------ + // if strictBCSel true we are only considering BC with signals from both FT0A and FT0C + if (!(hasft0A && hasft0C) && strictBCSel) { + continue; + // we go to the next BC + } + nCompBCwft0s++; + if (hasft0A && hasft0C) { + rofHasBoth = true; + } + + //----------------------- end of BC selection ------------------------ + + if (minD < 2) // 20 mm + { + goodBC.push_back(bc); // goodBC is a vector of bc + filler.BCids.emplace_back(bc.globalIndex()); + } + if (minD < globalMinD) { + globalMinD = minD; + closestBC = bc; + } + } + + if (!rofHasBoth) { + // there isn't a coincidence of FT0A and C inside the considered MFT ROF + // MFT track is probably noise, we don't select it + filler.BCids.clear(); + BcMft(track.globalIndex(), filler.BCids); // empty + continue; + } + registry.fill(HIST("NgoodBCperTrack"), goodBC.size()); + if (goodBC.size() == 0) { + registry.fill(HIST("UnMatchedTracksXY"), trackPar.getX(), trackPar.getY()); + } + if (goodBC.size() > 0) { + registry.fill(HIST("MatchedTracksXY"), trackPar.getX(), trackPar.getY()); + int64_t diff = goodBC[0].globalBC() - firstBC; + registry.fill(HIST("DiffInBC"), diff); + } + registry.fill(HIST("AllTracksXY"), trackPar.getX(), trackPar.getY()); + registry.fill(HIST("NCompBCwFT0C"), nCompBCwft0C); + registry.fill(HIST("NCompBCwFT0s"), nCompBCwft0s); + + if (nCompBCwft0s == 1) { + registry.fill(HIST("NgoodBCperTrackINDIV"), goodBC.size()); + + // position of the goodBC in the ROF for isolated colliding BCs + if (goodBC.size() > 0) { + int64_t diff = goodBC[0].globalBC() - firstBC; + registry.fill(HIST("DiffInBCINDIV"), diff); + } + } + + BcMft(track.globalIndex(), filler.BCids); + } // loop of mfttracks + } + PROCESS_SWITCH(matchmftft0, processMFT, "Process MFT tracks with collisions", true); +}; + +struct checkmatchinmc { + // checks if the matching works as expected in MC + // only doprocessMFTMCcheck==true if you are analysing MC + + HistogramRegistry registryMC{ + "registryMC", + {}}; + + void init(InitContext const&) + { + if (doprocessMFTMCcheck) { + registryMC.add({"TrackIsMatched", "; isMFTTrackMatched; #count", {HistType::kTH1I, {{2, 0, 2}}}}); + registryMC.add({"DiffInBCTrue", "; goodBC-trueBC (globalBC); #count", {HistType::kTH1I, {{800, -400, 400}}}}); + registryMC.add({"TrueBCAmongMatched", "; isTrueBCAmongMatchedOnes; #count", {HistType::kTH1D, {{2, 0, 2}}}}); + } + } + + using MFTTracksLabeledWithFT0 = soa::Join; + + void processMFTMCcheck(MFTTracksLabeledWithFT0 const& mfttracks, + aod::McCollisions const&, ExtBCs const&, aod::McParticles const&) + { + + for (auto& mfttrack : mfttracks) { + + if (!mfttrack.has_bcs()) // mft tracks having a match in FT0-C + { + registryMC.fill(HIST("TrackIsMatched"), 0); + continue; + } + + registryMC.fill(HIST("TrackIsMatched"), 1); // around 50% of all MFT tracks are matched with FT0-C in data + // around 90% of MFT tracks falling in the active FT0-C regions are matched + if (!mfttrack.has_mcParticle()) { + continue; + } + + o2::aod::McParticle particle = mfttrack.mcParticle(); + int64_t trueMFTBC = particle.mcCollision().bc_as().globalBC(); + ; + bool isTrueBCAmongMatchedOnes = false; + + for (auto& bc : mfttrack.bcs_as()) { // + int64_t bcDiffTrue = bc.globalBC() - trueMFTBC; // difference between the muon's BC and the MFT track's BC + registryMC.fill(HIST("DiffInBCTrue"), bcDiffTrue); + if (bcDiffTrue == 0) { + isTrueBCAmongMatchedOnes = true; + } + } + if (isTrueBCAmongMatchedOnes) { + registryMC.fill(HIST("TrueBCAmongMatched"), 1); + } else { + registryMC.fill(HIST("TrueBCAmongMatched"), 0); + } + } + } + PROCESS_SWITCH(checkmatchinmc, processMFTMCcheck, "Process MFT tracks and check matching with MC information", false); + + void processDummy(aod::Collisions const&) + { + // do nothing + } + PROCESS_SWITCH(checkmatchinmc, processDummy, "Do nothing if not MC", true); +}; + +WorkflowSpec + defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; + return workflow; +} diff --git a/Common/TableProducer/match-mft-mch-data.cxx b/Common/TableProducer/match-mft-mch-data.cxx new file mode 100644 index 00000000000..affa18f325d --- /dev/null +++ b/Common/TableProducer/match-mft-mch-data.cxx @@ -0,0 +1,886 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/DataTypes.h" +#include "Framework/runDataProcessing.h" +#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/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 "TDatabasePDG.h" + +using namespace o2; +using namespace o2::soa; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using SMatrix55 = ROOT::Math::SMatrix>; +using SMatrix5 = ROOT::Math::SVector; + +// 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 MyMuons = soa::Join; +using MyMFTs = aod::MFTTracks; +// using MyMuonsWithCov = soa::Join; +// using MyMuonsColl = soa::Join; +// using MyMuonsCollWithCov = soa::Join; +using MyBCs = soa::Join; +using ExtBCs = soa::Join; + +float mMu = TDatabasePDG::Instance()->GetParticle(13)->Mass(); + +TRandom* rnd = new TRandom(); + +TLorentzVector muon1LV; +TLorentzVector muon2LV; +TLorentzVector dimuonLV; + +TVector3 V1; +TVector3 V2; + +namespace o2::aod +{ + +namespace muon_params +{ +DECLARE_SOA_COLUMN(TRACKCHI2, trackChi2, float); +DECLARE_SOA_COLUMN(RABS, rabs, float); +DECLARE_SOA_COLUMN(Q, q, int16_t); + +DECLARE_SOA_COLUMN(PT, pt, float); +DECLARE_SOA_COLUMN(ETA, eta, float); +DECLARE_SOA_COLUMN(PHI, phi, float); + +DECLARE_SOA_COLUMN(PT_AT_PV, pt_pv, float); +DECLARE_SOA_COLUMN(ETA_AT_PV, eta_pv, float); +DECLARE_SOA_COLUMN(PHI_AT_PV, phi_pv, float); + +DECLARE_SOA_COLUMN(PT_AT_DCA, pt_dca, float); +DECLARE_SOA_COLUMN(ETA_AT_DCA, eta_dca, float); +DECLARE_SOA_COLUMN(PHI_AT_DCA, phi_dca, float); +DECLARE_SOA_COLUMN(DCA, dca, float); + +DECLARE_SOA_COLUMN(HASMFT, has_mft, bool); +} // namespace muon_params + +DECLARE_SOA_TABLE(MUONParams, "AOD", "MUON", + muon_params::TRACKCHI2, + muon_params::RABS, + muon_params::Q, + muon_params::PT, + muon_params::ETA, + muon_params::PHI, + muon_params::PT_AT_PV, + muon_params::ETA_AT_PV, + muon_params::PHI_AT_PV, + muon_params::PT_AT_DCA, + muon_params::ETA_AT_DCA, + muon_params::PHI_AT_DCA, + muon_params::DCA, + muon_params::HASMFT); + +namespace mft_params +{ +DECLARE_SOA_COLUMN(NCLUST, nclust, int); +DECLARE_SOA_COLUMN(ISCA, isCA, bool); +DECLARE_SOA_COLUMN(TRACKCHI2, trackChi2, float); +DECLARE_SOA_COLUMN(Q, q, int16_t); +DECLARE_SOA_COLUMN(PT, pt, float); +DECLARE_SOA_COLUMN(ETA, eta, float); +DECLARE_SOA_COLUMN(PHI, phi, float); +DECLARE_SOA_COLUMN(PT_AT_DCA, pt_dca, float); +DECLARE_SOA_COLUMN(ETA_AT_DCA, eta_dca, float); +DECLARE_SOA_COLUMN(PHI_AT_DCA, phi_dca, float); +DECLARE_SOA_COLUMN(DCA, dca, float); +DECLARE_SOA_COLUMN(DCAx, dcax, float); +DECLARE_SOA_COLUMN(DCAy, dcay, float); +} // namespace mft_params + +DECLARE_SOA_TABLE(MFTParams, "AOD", "MFT", + mft_params::NCLUST, + mft_params::ISCA, + mft_params::TRACKCHI2, + mft_params::Q, + mft_params::PT, + mft_params::ETA, + mft_params::PHI, + mft_params::PT_AT_DCA, + mft_params::ETA_AT_DCA, + mft_params::PHI_AT_DCA, + mft_params::DCAx, + mft_params::DCAy, + mft_params::DCA); + +namespace matching_params +{ +// matching parameters +DECLARE_SOA_COLUMN(NClustMFTTracks, nClustMFT, int); +DECLARE_SOA_COLUMN(Chi2MFTTracks, chi2MFT, float); + +DECLARE_SOA_COLUMN(DeltaP, dp_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPt, dpt_mchplane, float); +DECLARE_SOA_COLUMN(DeltaEta, deta_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPhi, dphi_mchplane, float); +DECLARE_SOA_COLUMN(DeltaX, dx_mchplane, float); +DECLARE_SOA_COLUMN(DeltaY, dy_mchplane, float); + +DECLARE_SOA_COLUMN(MchPt, mchpt, float); +DECLARE_SOA_COLUMN(MchEta, mcheta, float); +DECLARE_SOA_COLUMN(MchPhi, mchphi, float); +DECLARE_SOA_COLUMN(MchQ, mchq, float); + +DECLARE_SOA_COLUMN(MftPt, mftpt, float); +DECLARE_SOA_COLUMN(MftEta, mfteta, float); +DECLARE_SOA_COLUMN(MftPhi, mftphi, float); +DECLARE_SOA_COLUMN(MftQ, mftq, float); + +DECLARE_SOA_COLUMN(MftDCA, mftdca, float); + +} // namespace matching_params + +DECLARE_SOA_TABLE(MatchParams, "AOD", "MATCHING", + matching_params::NClustMFTTracks, + matching_params::Chi2MFTTracks, + matching_params::DeltaP, + matching_params::DeltaPt, + matching_params::DeltaEta, + matching_params::DeltaPhi, + matching_params::DeltaX, + matching_params::DeltaY, + matching_params::MchPt, + matching_params::MchEta, + matching_params::MchPhi, + matching_params::MchQ, + matching_params::MftPt, + matching_params::MftEta, + matching_params::MftPhi, + matching_params::MftQ, + matching_params::MftDCA); + +namespace mix_matching_params +{ +// matching parameters +DECLARE_SOA_COLUMN(NClustMFTTracks, nClustMFT, int); +DECLARE_SOA_COLUMN(Chi2MFTTracks, chi2MFT, float); + +DECLARE_SOA_COLUMN(DeltaP, dp_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPt, dpt_mchplane, float); +DECLARE_SOA_COLUMN(DeltaEta, deta_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPhi, dphi_mchplane, float); +DECLARE_SOA_COLUMN(DeltaX, dx_mchplane, float); +DECLARE_SOA_COLUMN(DeltaY, dy_mchplane, float); + +DECLARE_SOA_COLUMN(MchPt, mchpt, float); +DECLARE_SOA_COLUMN(MchEta, mcheta, float); +DECLARE_SOA_COLUMN(MchPhi, mchphi, float); +DECLARE_SOA_COLUMN(MchQ, mchq, float); + +DECLARE_SOA_COLUMN(MftPt, mftpt, float); +DECLARE_SOA_COLUMN(MftEta, mfteta, float); +DECLARE_SOA_COLUMN(MftPhi, mftphi, float); +DECLARE_SOA_COLUMN(MftQ, mftq, float); +DECLARE_SOA_COLUMN(MftDCA, mftdca, float); +} // namespace mix_matching_params + +namespace tag_matching_params +{ +// matching parameters +DECLARE_SOA_COLUMN(NClustMFTTracks, nClustMFT, int); +DECLARE_SOA_COLUMN(Chi2MFTTracks, chi2MFT, float); + +DECLARE_SOA_COLUMN(DeltaP, dp_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPt, dpt_mchplane, float); +DECLARE_SOA_COLUMN(DeltaEta, deta_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPhi, dphi_mchplane, float); +DECLARE_SOA_COLUMN(DeltaX, dx_mchplane, float); +DECLARE_SOA_COLUMN(DeltaY, dy_mchplane, float); + +DECLARE_SOA_COLUMN(MchPt, mchpt, float); +DECLARE_SOA_COLUMN(MchEta, mcheta, float); +DECLARE_SOA_COLUMN(MchPhi, mchphi, float); +DECLARE_SOA_COLUMN(MchQ, mchq, float); + +DECLARE_SOA_COLUMN(MftPt, mftpt, float); +DECLARE_SOA_COLUMN(MftEta, mfteta, float); +DECLARE_SOA_COLUMN(MftPhi, mftphi, float); +DECLARE_SOA_COLUMN(MftQ, mftq, float); +DECLARE_SOA_COLUMN(MftDCA, mftdca, float); + +DECLARE_SOA_COLUMN(IsTaged, isTaged, bool); +} // namespace tag_matching_params + +DECLARE_SOA_TABLE(TagMatchParams, "AOD", "TAGMATCHING", + tag_matching_params::NClustMFTTracks, + tag_matching_params::Chi2MFTTracks, + tag_matching_params::DeltaP, + tag_matching_params::DeltaPt, + tag_matching_params::DeltaEta, + tag_matching_params::DeltaPhi, + tag_matching_params::DeltaX, + tag_matching_params::DeltaY, + tag_matching_params::MchPt, + tag_matching_params::MchEta, + tag_matching_params::MchPhi, + tag_matching_params::MchQ, + tag_matching_params::MftPt, + tag_matching_params::MftEta, + tag_matching_params::MftPhi, + tag_matching_params::MftQ, + tag_matching_params::MftDCA, + tag_matching_params::IsTaged); + +namespace probe_matching_params +{ +// matching parameters +DECLARE_SOA_COLUMN(NMFTCandTagMuon, nTagMFT, int); +DECLARE_SOA_COLUMN(TagMuonP, tagmuonp, float); + +DECLARE_SOA_COLUMN(NClustMFTTracks, nClustMFT, int); +DECLARE_SOA_COLUMN(Chi2MFTTracks, chi2MFT, float); + +DECLARE_SOA_COLUMN(DeltaP, dp_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPt, dpt_mchplane, float); +DECLARE_SOA_COLUMN(DeltaEta, deta_mchplane, float); +DECLARE_SOA_COLUMN(DeltaPhi, dphi_mchplane, float); +DECLARE_SOA_COLUMN(DeltaX, dx_mchplane, float); +DECLARE_SOA_COLUMN(DeltaY, dy_mchplane, float); + +DECLARE_SOA_COLUMN(MchPt, mchpt, float); +DECLARE_SOA_COLUMN(MchEta, mcheta, float); +DECLARE_SOA_COLUMN(MchPhi, mchphi, float); +DECLARE_SOA_COLUMN(MchQ, mchq, float); + +DECLARE_SOA_COLUMN(MftPt, mftpt, float); +DECLARE_SOA_COLUMN(MftEta, mfteta, float); +DECLARE_SOA_COLUMN(MftPhi, mftphi, float); +DECLARE_SOA_COLUMN(MftQ, mftq, float); +DECLARE_SOA_COLUMN(MftDCA, mftdca, float); +} // namespace probe_matching_params + +DECLARE_SOA_TABLE(ProbeMatchParams, "AOD", "PROBEMATCHING", + probe_matching_params::NMFTCandTagMuon, + probe_matching_params::TagMuonP, + probe_matching_params::NClustMFTTracks, + probe_matching_params::Chi2MFTTracks, + probe_matching_params::DeltaP, + probe_matching_params::DeltaPt, + probe_matching_params::DeltaEta, + probe_matching_params::DeltaPhi, + probe_matching_params::DeltaX, + probe_matching_params::DeltaY, + probe_matching_params::MchPt, + probe_matching_params::MchEta, + probe_matching_params::MchPhi, + probe_matching_params::MchQ, + probe_matching_params::MftPt, + probe_matching_params::MftEta, + probe_matching_params::MftPhi, + probe_matching_params::MftQ, + probe_matching_params::MftDCA); + +DECLARE_SOA_TABLE(MixMatchParams, "AOD", "MIXMATCHING", + mix_matching_params::NClustMFTTracks, + mix_matching_params::Chi2MFTTracks, + mix_matching_params::DeltaP, + mix_matching_params::DeltaPt, + mix_matching_params::DeltaEta, + mix_matching_params::DeltaPhi, + mix_matching_params::DeltaX, + mix_matching_params::DeltaY, + mix_matching_params::MchPt, + mix_matching_params::MchEta, + mix_matching_params::MchPhi, + mix_matching_params::MchQ, + mix_matching_params::MftPt, + mix_matching_params::MftEta, + mix_matching_params::MftPhi, + mix_matching_params::MftQ, + mix_matching_params::MftDCA); + +namespace muon_pair +{ +DECLARE_SOA_COLUMN(NMFT, nMft, int); +DECLARE_SOA_COLUMN(Q, q, int16_t); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Rap, rap, float); +} // namespace muon_pair + +DECLARE_SOA_TABLE(MuonPair, "AOD", "DIMUON", muon_pair::NMFT, muon_pair::Q, muon_pair::M, muon_pair::Pt, muon_pair::Rap); + +namespace tag_muon_pair +{ +DECLARE_SOA_COLUMN(NMFT, nMft, int); +DECLARE_SOA_COLUMN(Q, q, int16_t); +DECLARE_SOA_COLUMN(M, m, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Rap, rap, float); +} // namespace tag_muon_pair + +DECLARE_SOA_TABLE(TagMuonPair, "AOD", "TAGDIMUON", tag_muon_pair::NMFT, tag_muon_pair::Q, tag_muon_pair::M, tag_muon_pair::Pt, tag_muon_pair::Rap); + +} // namespace o2::aod + +struct match_mft_mch_data { + + Produces matchingParams; + Produces tagmatchingParams; + Produces probematchingParams; + Produces mixmatchingParams; + Produces muonPairs; + Produces tagmuonPairs; + Produces muonParams; + Produces mftParams; + + HistogramRegistry registry{ + "registry", + {{"hMchP", "MCH track total momentum (at the first station); p [GeV/c]; Counts", {HistType::kTH1F, {{2000, 0, 200}}}}, + {"hMchCorrP", "MCH track total momentum (propagated to PV); p [GeV/c]; Counts", {HistType::kTH1F, {{2000, 0, 200}}}}, + {"hMassCorrMchPair", "Corrected MCH track pair mass (propagated to PV); m [GeV/c^{2}]; Counts", {HistType::kTH1F, {{1000, 0, 10}}}}}}; + + Configurable fEtaMchLow{"cfgEtaMchLow", -4.0f, ""}; + Configurable fEtaMchUp{"cfgEtaMchUp", -2.5f, ""}; + Configurable fEtaMftLow{"cfgEtaMftlow", -3.6f, ""}; + Configurable fEtaMftUp{"cfgEtaMftup", -2.5f, ""}; + // Filter etaMchFilter = (fEtaMchLow < aod::fwdtrack::eta) && (aod::fwdtrack::eta < fEtaMchUp); + + Configurable fRabsLow1{"cfgRabsLow1", 17.6f, ""}; + Configurable fRabsUp1{"cfgRabsUp1", 26.5f, ""}; + Configurable fRabsLow2{"cfgRabsLow2", 26.5f, ""}; + Configurable fRabsUp2{"cfgRabsUp2", 89.5f, ""}; + Configurable fPdcaUp1{"cfgPdcaUp1", 594.f, ""}; + Configurable fPdcaUp2{"cfgPdcaUp2", 324.f, ""}; + // Filter rAbsFilter = (fRabsLow1 < aod::fwdtrack::rAtAbsorberEnd && aod::fwdtrack::rAtAbsorberEnd < fRabsUp1 && aod::fwdtrack::pDca < fPdcaUp1) || (fRabsLow2 < aod::fwdtrack::rAtAbsorberEnd && aod::fwdtrack::rAtAbsorberEnd < fRabsUp2 && aod::fwdtrack::pDca < fPdcaUp2); + + Configurable fTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""}; + // Filter trackChi2MchFilter = aod::fwdtrack::chi2 < fTrackChi2MchUp; + + Configurable fMatchingChi2MchMidUp{"cfgMatchingChi2MchMidUp", 999.f, ""}; + // Filter matchingChi2MchMidFilter = aod::fwdtrack::chi2MatchMCHMID < fMatchingChi2MchMidUp; + + // Configurable fSaveMixedMatchingParamsRate{"cfgSaveMixedMatchingParamsRate", 0.002f, ""}; + + Configurable fPreselectMatchingX{"cfgPreselectMatchingX", 999.f, ""}; + Configurable fPreselectMatchingY{"cfgPreselectMatchingY", 999.f, ""}; + + Configurable fTagMassWindowMin{"cfgTagMassWindowMin", 2.8f, ""}; + Configurable fTagMassWindowMax{"cfgTagMassWindowMax", 3.3f, ""}; + + Configurable fEventMaxDeltaNMFT{"cfgEventMaxDeltaNMFT", 1, ""}; + Configurable fEventMaxDeltaVtxZ{"cfgEventMaxDeltaVtxZ", 1.f, ""}; + + Configurable fTagRWindow{"cfgTagRWindow", 3.f, ""}; + Configurable fTagPhiWindow{"cfgTagPhiWindow", 0.1f, ""}; + Configurable fTagEtaWindow{"cfgTagEtaWindow", 0.1f, ""}; + + Service 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 geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + + // o2::parameters::GRPMagField* grpmag = nullptr; + o2::globaltracking::MatchGlobalFwd mMatching; + o2::field::MagneticField* fieldB; + + o2::ccdb::CcdbApi ccdbApi; + int mRunNumber; + + void init(o2::framework::InitContext&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + ccdbApi.init(ccdburl); + mRunNumber = 0; + } + + void initCCDB(ExtBCs::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + 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); + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + } + o2::mch::TrackExtrap::setField(); + fieldB = static_cast(TGeoGlobalMagField::Instance()->GetField()); + } + + enum ProagationPoint { ToVtx, + ToDCA }; + + template + o2::dataformats::GlobalFwdTrack PropagateMuon(T const& muon, int PropType) + { + + auto collision = muon.collision(); + + o2::dataformats::GlobalFwdTrack propmuon; + + 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()}; + if (isGoodFwdTrack(muon)) { + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd fwdtrack{muon.z(), tpars, tcovs, chi2}; + + o2::dataformats::GlobalFwdTrack track; + track.setParameters(tpars); + track.setZ(fwdtrack.getZ()); + track.setCovariances(tcovs); + auto mchTrack = mMatching.FwdtoMCH(track); + if (PropType == ProagationPoint::ToVtx) + o2::mch::TrackExtrap::extrapToVertex(mchTrack, collision.posX(), collision.posY(), collision.posZ(), collision.covXX(), collision.covYY()); + else if (PropType == ProagationPoint::ToDCA) + o2::mch::TrackExtrap::extrapToVertexWithoutBranson(mchTrack, collision.posZ()); + + auto proptrack = mMatching.MCHtoFwd(mchTrack); + propmuon.setParameters(proptrack.getParameters()); + propmuon.setZ(proptrack.getZ()); + propmuon.setCovariances(proptrack.getCovariances()); + } + + v1.clear(); + v1.shrink_to_fit(); + + return propmuon; + } + + template + o2::track::TrackParCovFwd PropagateMFT(T const& mfttrack, int PropType) + { + std::vector mftv1; + SMatrix55 mftcovs{mftv1.begin(), mftv1.end()}; + SMatrix5 mftpars = {mfttrack.x(), mfttrack.y(), mfttrack.phi(), mfttrack.tgl(), mfttrack.signed1Pt()}; + o2::track::TrackParCovFwd mftpartrack = {mfttrack.z(), mftpars, mftcovs, mfttrack.chi2()}; + if (PropType == ProagationPoint::ToDCA) { + auto collision = mfttrack.collision(); + double propVec[3] = {fabs(mfttrack.x() - collision.posX()), fabs(mfttrack.y() - collision.posY()), fabs(mfttrack.z() - collision.posZ())}; + double centerZ[3] = {mfttrack.x() - propVec[0] / 2., mfttrack.y() - propVec[1] / 2., mfttrack.z() - propVec[2] / 2.}; + float Bz = fieldB->getBz(centerZ); + mftpartrack.propagateToZ(collision.posZ(), Bz); + } + return mftpartrack; + } + + template + o2::track::TrackParCovFwd PropagateMFTtoMatchingPlane(MFT const& mfttrack, FWD const& fwdtrack) + { + std::vector v1; // Temporary null vector for the computation of the covariance matrix + double propVec[3] = {fwdtrack.x() - mfttrack.x(), fwdtrack.y() - mfttrack.y(), fwdtrack.z() - mfttrack.z()}; + double centerZ[3] = {mfttrack.x() + propVec[0] / 2., mfttrack.y() + propVec[1] / 2., mfttrack.z() + propVec[2] / 2.}; + float Bz = fieldB->getBz(centerZ); // gives error if the propagator is not initFielded + SMatrix55 tmftcovs(v1.begin(), v1.end()); + SMatrix5 tmftpars(mfttrack.x(), mfttrack.y(), mfttrack.phi(), mfttrack.tgl(), mfttrack.signed1Pt()); + o2::track::TrackParCovFwd extrap_mfttrack{mfttrack.z(), tmftpars, tmftcovs, mfttrack.chi2()}; + extrap_mfttrack.propagateToZ(fwdtrack.z(), Bz); // z in cm + return extrap_mfttrack; + } + + template + bool isGoodFwdTrack(T track) + { + if (!track.has_collision()) + return false; + if (track.trackType() != o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) + return false; + if (track.chi2() > fTrackChi2MchUp) + return false; + if (17.6 > track.rAtAbsorberEnd() || track.rAtAbsorberEnd() > 89.5) + return false; + if (track.rAtAbsorberEnd() < 26.5 && 594. < track.pDca()) + return false; + if (track.rAtAbsorberEnd() > 26.5 && 324. < track.pDca()) + return false; + return true; + } + + template + int selectTagMuon(T track1, T track2) + { + if (track1.pt() > track2.pt()) { + return track1.globalIndex(); + } else { + return track2.globalIndex(); + } + } + + template + int selectProbeMuon(T track1, T track2) + { + if (track1.pt() < track2.pt()) { + return track1.globalIndex(); + } else { + return track2.globalIndex(); + } + } + + bool isGoodKenematicTrack(o2::dataformats::GlobalFwdTrack track) + { + if (fEtaMchLow > track.getEta() || track.getEta() > fEtaMchUp) + return false; + return true; + } + + void process(aod::Collisions const& collisions, ExtBCs const& ebcs, + MyMuons const& fwdtracks, MyMFTs const& mfttracks) + { + initCCDB(ebcs.begin()); + + std::unordered_set bcs_mfttrack; + std::unordered_map map_vtxZ; + std::unordered_map nmfttracks; + std::unordered_map> map_mfttraks; + + for (const auto& mfttrack : mfttracks) { + + if (!mfttrack.has_collision()) + continue; + bcs_mfttrack.insert(mfttrack.collisionId()); + std::vector& tracks = map_mfttraks[mfttrack.collisionId()]; + tracks.push_back(mfttrack.globalIndex()); + + o2::track::TrackParCovFwd mftpartrack = PropagateMFT(mfttrack, ProagationPoint::ToDCA); + + auto collision = mfttrack.collision(); + + map_vtxZ[mfttrack.collisionId()] = collision.posZ(); + + float dx = mftpartrack.getX() - collision.posX(); + float dy = mftpartrack.getY() - collision.posY(); + float dca = sqrt(dx * dx + dy * dy); + + mftParams(mfttrack.nClusters(), mfttrack.isCA(), + mfttrack.chi2(), mfttrack.sign(), + mfttrack.pt(), mfttrack.eta(), mfttrack.phi(), + mftpartrack.getPt(), mftpartrack.getEta(), mftpartrack.getPhi(), + dx, dy, dca); + + nmfttracks[mfttrack.collisionId()]++; + } + + std::unordered_map nfwdtracks; + std::unordered_map> map_fwdtraks; + + for (auto fwdtrack : fwdtracks) { + + if (!isGoodFwdTrack(fwdtrack)) + continue; + + o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(fwdtrack, ProagationPoint::ToVtx); + o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(fwdtrack, ProagationPoint::ToDCA); + if (!isGoodKenematicTrack(propmuonAtPV)) + continue; + std::vector& tracks = map_fwdtraks[fwdtrack.collisionId()]; + tracks.push_back(fwdtrack.globalIndex()); + + auto collision = fwdtrack.collision(); + + float dx = propmuonAtDCA.getX() - collision.posX(); + float dy = propmuonAtDCA.getY() - collision.posY(); + float DCA = sqrt(dx * dx + dy * dy); + + bool hasMFT = false; + + std::vector& mfttracks = map_mfttraks[fwdtrack.collisionId()]; + + if (mfttracks.size() > 0) + hasMFT = true; + + muonParams(fwdtrack.chi2(), fwdtrack.rAtAbsorberEnd(), fwdtrack.sign(), fwdtrack.pt(), fwdtrack.eta(), fwdtrack.phi(), + propmuonAtPV.getPt(), propmuonAtPV.getEta(), propmuonAtPV.getPhi(), + propmuonAtDCA.getPt(), propmuonAtDCA.getEta(), propmuonAtDCA.getPhi(), + DCA, hasMFT); + + nfwdtracks[fwdtrack.collisionId()]++; + } + + for (auto fwdtrack1 : fwdtracks) { + + if (!isGoodFwdTrack(fwdtrack1)) + continue; + + int ibc = fwdtrack1.collisionId(); + auto collision = fwdtrack1.collision(); + + o2::dataformats::GlobalFwdTrack fwdtrackAtPV1 = PropagateMuon(fwdtrack1, ProagationPoint::ToVtx); + if (!isGoodKenematicTrack(fwdtrackAtPV1)) + continue; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////// MIXED EVENT /////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + for (auto bc_mfttrack : bcs_mfttrack) { + + if (ibc == bc_mfttrack) + continue; + if (fabs(nmfttracks[ibc] - nmfttracks[bc_mfttrack]) > fEventMaxDeltaNMFT) + continue; + if (fabs(map_vtxZ[bc_mfttrack] - collision.posZ()) > fEventMaxDeltaVtxZ) + continue; + + std::vector& mfttrackGlobalIndex = map_mfttraks[bc_mfttrack]; + + for (int idmfttrack1 = 0; idmfttrack1 < static_cast(mfttrackGlobalIndex.size()); ++idmfttrack1) { + + auto mfttrack1 = mfttracks.rawIteratorAt(mfttrackGlobalIndex[idmfttrack1]); + o2::track::TrackParCovFwd mfttrack_at_matching = PropagateMFTtoMatchingPlane(mfttrack1, fwdtrack1); + + V1.SetPtEtaPhi(mfttrack_at_matching.getPt(), mfttrack_at_matching.getEta(), mfttrack_at_matching.getPhi()); + V2.SetPtEtaPhi(fwdtrack1.pt(), fwdtrack1.eta(), fwdtrack1.phi()); + + double deltaP = mfttrack_at_matching.getP() - fwdtrack1.p(); + double deltaPt = mfttrack_at_matching.getPt() - fwdtrack1.pt(); + double deltaX = mfttrack_at_matching.getX() - fwdtrack1.x(); + double deltaY = mfttrack_at_matching.getY() - fwdtrack1.y(); + double deltaPhi = V1.DeltaPhi(V2); + double deltaEta = mfttrack_at_matching.getEta() - fwdtrack1.eta(); + + if (fabs(deltaX) > fPreselectMatchingX) + continue; + if (fabs(deltaY) > fPreselectMatchingY) + continue; + + o2::track::TrackParCovFwd mfttrack_at_dca = PropagateMFT(mfttrack1, ProagationPoint::ToDCA); + float dx = mfttrack_at_dca.getX() - collision.posX(); + float dy = mfttrack_at_dca.getY() - collision.posY(); + float DCA = sqrt(dx * dx + dy * dy); + + mixmatchingParams(mfttrack1.nClusters(), mfttrack1.chi2(), + deltaP, deltaPt, deltaEta, deltaPhi, deltaX, deltaY, + fwdtrackAtPV1.getPt(), fwdtrackAtPV1.getEta(), fwdtrackAtPV1.getPhi(), fwdtrack1.sign(), + mfttrack_at_dca.getPt(), mfttrack_at_dca.getEta(), mfttrack_at_dca.getPhi(), mfttrack1.sign(), DCA); + } + } // end of loop bc_mfttrack + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////// SAME EVENT /////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + std::vector& mfttrackGlobalIndex = map_mfttraks[ibc]; + + for (int idmfttrack1 = 0; idmfttrack1 < static_cast(mfttrackGlobalIndex.size()); ++idmfttrack1) { + + auto mfttrack1 = mfttracks.rawIteratorAt(mfttrackGlobalIndex[idmfttrack1]); + o2::track::TrackParCovFwd mfttrack_at_matching = PropagateMFTtoMatchingPlane(mfttrack1, fwdtrack1); + V1.SetPtEtaPhi(mfttrack_at_matching.getPt(), mfttrack_at_matching.getEta(), mfttrack_at_matching.getPhi()); + V2.SetPtEtaPhi(fwdtrack1.pt(), fwdtrack1.eta(), fwdtrack1.phi()); + + double deltaP = mfttrack_at_matching.getP() - fwdtrack1.p(); + double deltaPt = mfttrack_at_matching.getPt() - fwdtrack1.pt(); + double deltaX = mfttrack_at_matching.getX() - fwdtrack1.x(); + double deltaY = mfttrack_at_matching.getY() - fwdtrack1.y(); + double deltaPhi = V1.DeltaPhi(V2); + double deltaEta = mfttrack_at_matching.getEta() - fwdtrack1.eta(); + + if (fabs(deltaX) > fPreselectMatchingX) + continue; + if (fabs(deltaY) > fPreselectMatchingY) + continue; + + o2::track::TrackParCovFwd mfttrack_at_dca = PropagateMFT(mfttrack1, ProagationPoint::ToDCA); + float dx = mfttrack_at_dca.getX() - collision.posX(); + float dy = mfttrack_at_dca.getY() - collision.posY(); + float DCA = sqrt(dx * dx + dy * dy); + + matchingParams(mfttrack1.nClusters(), mfttrack1.chi2(), + deltaP, deltaPt, deltaEta, deltaPhi, deltaX, deltaY, + fwdtrackAtPV1.getPt(), fwdtrackAtPV1.getEta(), fwdtrackAtPV1.getPhi(), fwdtrack1.sign(), + mfttrack_at_dca.getPt(), mfttrack_at_dca.getEta(), mfttrack_at_dca.getPhi(), mfttrack1.sign(), DCA); + } // end of loop idmfttrack1 + + std::vector& fwdtrackGlobalIndex = map_fwdtraks[ibc]; + + for (int idfwdtrack2 = 0; idfwdtrack2 < static_cast(fwdtrackGlobalIndex.size()); ++idfwdtrack2) { + + if (fwdtrack1.globalIndex() == fwdtrackGlobalIndex[idfwdtrack2]) + continue; + + auto fwdtrack2 = fwdtracks.rawIteratorAt(fwdtrackGlobalIndex[idfwdtrack2]); + + if (!isGoodFwdTrack(fwdtrack2)) + continue; + + o2::dataformats::GlobalFwdTrack fwdtrackAtPV2 = PropagateMuon(fwdtrack2, ProagationPoint::ToVtx); + if (!isGoodKenematicTrack(fwdtrackAtPV2)) + continue; + + muon1LV.SetPtEtaPhiM(fwdtrackAtPV1.getPt(), fwdtrackAtPV1.getEta(), fwdtrackAtPV1.getPhi(), mMu); + muon2LV.SetPtEtaPhiM(fwdtrackAtPV2.getPt(), fwdtrackAtPV2.getEta(), fwdtrackAtPV2.getPhi(), mMu); + dimuonLV = muon1LV + muon2LV; + + muonPairs(nmfttracks[ibc], fwdtrack1.sign() + fwdtrack2.sign(), dimuonLV.M(), dimuonLV.Pt(), dimuonLV.Rapidity()); + + if (fabs(fwdtrack1.sign() + fwdtrack2.sign()) > 0) + continue; + if (fTagMassWindowMin > dimuonLV.M() || dimuonLV.M() > fTagMassWindowMax) + continue; + if (nmfttracks[ibc] < 1) + continue; + + tagmuonPairs(nmfttracks[ibc], fwdtrack1.sign() + fwdtrack2.sign(), dimuonLV.M(), dimuonLV.Pt(), dimuonLV.Rapidity()); + + bool isGoodTag = false; + int nMFTCandsTagMuon = 0; + + auto tagfwdtrack = fwdtracks.rawIteratorAt(selectTagMuon(fwdtrack1, fwdtrack2)); + o2::dataformats::GlobalFwdTrack tagfwdtrackAtPV = PropagateMuon(tagfwdtrack, ProagationPoint::ToVtx); + + for (int idmfttrack1 = 0; idmfttrack1 < static_cast(mfttrackGlobalIndex.size()); ++idmfttrack1) { + + auto mfttrack1 = mfttracks.rawIteratorAt(mfttrackGlobalIndex[idmfttrack1]); + o2::track::TrackParCovFwd mfttrack_at_matching = PropagateMFTtoMatchingPlane(mfttrack1, tagfwdtrack); + + V1.SetPtEtaPhi(mfttrack_at_matching.getPt(), mfttrack_at_matching.getEta(), mfttrack_at_matching.getPhi()); + V2.SetPtEtaPhi(tagfwdtrack.pt(), tagfwdtrack.eta(), tagfwdtrack.phi()); + + double deltaP = mfttrack_at_matching.getP() - tagfwdtrack.p(); + double deltaPt = mfttrack_at_matching.getPt() - tagfwdtrack.pt(); + double deltaX = mfttrack_at_matching.getX() - tagfwdtrack.x(); + double deltaY = mfttrack_at_matching.getY() - tagfwdtrack.y(); + double deltaPhi = V1.DeltaPhi(V2); + double deltaEta = mfttrack_at_matching.getEta() - tagfwdtrack.eta(); + + double deltaR = sqrt(deltaX * deltaX + deltaY * deltaY); + if (fabs(deltaX) > fPreselectMatchingX) + continue; + if (fabs(deltaY) > fPreselectMatchingY) + continue; + + o2::track::TrackParCovFwd mfttrack_at_dca = PropagateMFT(mfttrack1, ProagationPoint::ToDCA); + float dx = mfttrack_at_dca.getX() - collision.posX(); + float dy = mfttrack_at_dca.getY() - collision.posY(); + float DCA = sqrt(dx * dx + dy * dy); + + bool dummyTag = false; + + if (fabs(deltaR) < fTagRWindow && fabs(deltaPhi) < fTagPhiWindow && fabs(deltaEta) < fTagEtaWindow) { + isGoodTag = true; + dummyTag = true; + nMFTCandsTagMuon++; + } + + tagmatchingParams(mfttrack1.nClusters(), mfttrack1.chi2(), + deltaP, deltaPt, deltaEta, deltaPhi, deltaX, deltaY, + tagfwdtrackAtPV.getPt(), tagfwdtrackAtPV.getEta(), tagfwdtrackAtPV.getPhi(), tagfwdtrack.sign(), + mfttrack_at_dca.getPt(), mfttrack_at_dca.getEta(), mfttrack_at_dca.getPhi(), mfttrack1.sign(), DCA, dummyTag); + } + + if (!isGoodTag) + continue; + + auto probefwdtrack = fwdtracks.rawIteratorAt(selectProbeMuon(fwdtrack1, fwdtrack2)); + o2::dataformats::GlobalFwdTrack probefwdtrackAtPV = PropagateMuon(probefwdtrack, ProagationPoint::ToVtx); + + for (int idmfttrack1 = 0; idmfttrack1 < static_cast(mfttrackGlobalIndex.size()); ++idmfttrack1) { + + auto mfttrack1 = mfttracks.rawIteratorAt(mfttrackGlobalIndex[idmfttrack1]); + o2::track::TrackParCovFwd mfttrack_at_matching = PropagateMFTtoMatchingPlane(mfttrack1, probefwdtrack); + + V1.SetPtEtaPhi(mfttrack_at_matching.getPt(), mfttrack_at_matching.getEta(), mfttrack_at_matching.getPhi()); + V2.SetPtEtaPhi(probefwdtrack.pt(), probefwdtrack.eta(), probefwdtrack.phi()); + + double deltaP = mfttrack_at_matching.getP() - probefwdtrack.p(); + double deltaPt = mfttrack_at_matching.getPt() - probefwdtrack.pt(); + double deltaX = mfttrack_at_matching.getX() - probefwdtrack.x(); + double deltaY = mfttrack_at_matching.getY() - probefwdtrack.y(); + double deltaPhi = V1.DeltaPhi(V2); + double deltaEta = mfttrack_at_matching.getEta() - probefwdtrack.eta(); + + if (fabs(deltaX) > fPreselectMatchingX) + continue; + if (fabs(deltaY) > fPreselectMatchingY) + continue; + + o2::track::TrackParCovFwd mfttrack_at_dca = PropagateMFT(mfttrack1, ProagationPoint::ToDCA); + float dx = mfttrack_at_dca.getX() - collision.posX(); + float dy = mfttrack_at_dca.getY() - collision.posY(); + float DCA = sqrt(dx * dx + dy * dy); + + probematchingParams(nMFTCandsTagMuon, tagfwdtrack.p(), mfttrack1.nClusters(), mfttrack1.chi2(), + deltaP, deltaPt, deltaEta, deltaPhi, deltaX, deltaY, + probefwdtrackAtPV.getPt(), probefwdtrackAtPV.getEta(), probefwdtrackAtPV.getPhi(), probefwdtrack.sign(), + mfttrack_at_dca.getPt(), mfttrack_at_dca.getEta(), mfttrack_at_dca.getPhi(), mfttrack1.sign(), DCA); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/TableProducer/mcCollsExtra.cxx b/Common/TableProducer/mcCollsExtra.cxx index 3ad7a143acd..c085969c5af 100644 --- a/Common/TableProducer/mcCollsExtra.cxx +++ b/Common/TableProducer/mcCollsExtra.cxx @@ -12,9 +12,10 @@ // Quick and dirty task to correlate MC <-> data // -#include #include +#include #include +#include #include "Math/Vector4D.h" #include @@ -135,8 +136,8 @@ struct mcCollisionExtra { auto iter = std::find(sortedIndices.begin(), sortedIndices.end(), mcCollision.index()); if (iter != sortedIndices.end()) { auto index = std::distance(iter, sortedIndices.begin()); - for (size_t iMcColl = index + 1; iMcColl < index + 17; iMcColl++) { - if (iMcColl >= sortedIndices.size()) + for (auto iMcColl = index + 1; iMcColl < index + 17; iMcColl++) { + if (iMcColl >= std::ssize(sortedIndices)) continue; if (mcCollisionHasPoI[sortedIndices[iMcColl]]) bitset(forwardHistory, iMcColl - index - 1); diff --git a/Common/TableProducer/multiplicityExtraTable.cxx b/Common/TableProducer/multiplicityExtraTable.cxx index cc37a39e34b..216a1b7acc6 100644 --- a/Common/TableProducer/multiplicityExtraTable.cxx +++ b/Common/TableProducer/multiplicityExtraTable.cxx @@ -30,12 +30,25 @@ using BCPattern = std::bitset; const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; struct MultiplicityExtraTable { - Produces multBC; + Produces multBC; Produces multNeigh; + Produces mult2bc; + Produces bc2mult; + // Allow for downscaling of BC table for less space use in derived data Configurable bcDownscaleFactor{"bcDownscaleFactor", 2, "Downscale factor for BC table (0: save nothing, 1: save all)"}; Configurable minFT0CforBCTable{"minFT0CforBCTable", 25.0f, "Minimum FT0C amplitude to fill BC table to reduce data"}; + Configurable saveOnlyBCsWithCollisions{"saveOnlyBCsWithCollisions", true, "save only BCs with collisions in them"}; + + Configurable bcTableFloatPrecision{"bcTableFloatPrecision", 0.1, "float precision in bc table for data reduction"}; + + float tru(float value) + { + if (bcTableFloatPrecision < 1e-4) + return value; // make sure nothing bad happens in case zero (best precision) + return bcTableFloatPrecision * std::round(value / bcTableFloatPrecision) + 0.5f * bcTableFloatPrecision; + }; // needed for downscale unsigned int randomSeed = 0; @@ -59,117 +72,181 @@ struct MultiplicityExtraTable { using BCsWithRun3Matchings = soa::Join; - void processBCs(BCsWithRun3Matchings::iterator const& bc, aod::FV0As const&, aod::FT0s const&, aod::FDDs const&, aod::Zdcs const&) + void processBCs(soa::Join const& bcs, aod::FV0As const&, aod::FT0s const&, aod::FDDs const&, aod::Zdcs const&, soa::Join const& collisions) { - // downscale if requested to do so - if (bcDownscaleFactor < 1.f && (static_cast(rand_r(&randomSeed)) / static_cast(RAND_MAX)) > bcDownscaleFactor) { - return; + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + // determine saved BCs and corresponding new BC table index + std::vector bcHasCollision(bcs.size()); + std::vector newBCindex(bcs.size()); + std::vector bc2multArray(bcs.size()); + int atIndex = 0; + for (const auto& bc : bcs) { + bcHasCollision[bc.globalIndex()] = false; + newBCindex[bc.globalIndex()] = -1; + bc2multArray[bc.globalIndex()] = -1; } - bool Tvx = false; - bool isFV0OrA = false; - float multFT0C = 0.f; - float multFT0A = 0.f; - float multFV0A = 0.f; - float multFDDA = 0.f; - float multFDDC = 0.f; - - // ZDC amplitudes - float multZEM1 = -1.f; - float multZEM2 = -1.f; - float multZNA = -1.f; - float multZNC = -1.f; - float multZPA = -1.f; - float multZPC = -1.f; - - uint8_t multFT0TriggerBits = 0; - uint8_t multFV0TriggerBits = 0; - uint8_t multFDDTriggerBits = 0; - uint64_t multBCTriggerMask = bc.triggerMask(); - - // initialize - from Arvind - newRunNumber = bc.runNumber(); - int localBC = bc.globalBC() % nBCsPerOrbit; - - if (newRunNumber != oldRunNumber) { - auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, newRunNumber); - auto ts = soreor.first; - - LOG(info) << " newRunNumber " << newRunNumber << " time stamp " << ts; - oldRunNumber = newRunNumber; - auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); - CollidingBunch = grplhcif->getBunchFilling().getBCPattern(); - } // new run number - - bool collidingBC = CollidingBunch.test(localBC); - - if (bc.has_ft0()) { - auto ft0 = bc.ft0(); - std::bitset<8> triggers = ft0.triggerMask(); - Tvx = triggers[o2::fit::Triggers::bitVertex]; - multFT0TriggerBits = static_cast(triggers.to_ulong()); - - // calculate T0 charge - for (auto amplitude : ft0.amplitudeA()) { - multFT0A += amplitude; - } - for (auto amplitude : ft0.amplitudeC()) { - multFT0C += amplitude; - } - } else { - multFT0A = -999.0f; - multFT0C = -999.0f; + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + // tag BCs that have a collision (from evsel foundBC) + for (const auto& collision : collisions) { + bcHasCollision[collision.foundBCId()] = true; } - if (bc.has_fv0a()) { - auto fv0 = bc.fv0a(); - std::bitset<8> fV0Triggers = fv0.triggerMask(); - multFV0TriggerBits = static_cast(fV0Triggers.to_ulong()); + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ - for (auto amplitude : fv0.amplitude()) { - multFV0A += amplitude; + for (const auto& bc : bcs) { + // downscale if requested to do so + if (bcDownscaleFactor < 1.f && (static_cast(rand_r(&randomSeed)) / static_cast(RAND_MAX)) > bcDownscaleFactor) { + continue; } - isFV0OrA = fV0Triggers[o2::fit::Triggers::bitA]; - } else { - multFV0A = -999.0f; - } - if (bc.has_fdd()) { - auto fdd = bc.fdd(); - std::bitset<8> fFDDTriggers = fdd.triggerMask(); - multFDDTriggerBits = static_cast(fFDDTriggers.to_ulong()); + float multFT0C = 0.f; + if (bc.has_ft0()) { + auto ft0 = bc.ft0(); + for (auto amplitude : ft0.amplitudeC()) { + multFT0C += amplitude; + } + } else { + multFT0C = -999.0f; + } - for (auto amplitude : fdd.chargeA()) { - multFDDA += amplitude; + if (multFT0C < minFT0CforBCTable) { + continue; // skip this event } - for (auto amplitude : fdd.chargeC()) { - multFDDC += amplitude; + + if (saveOnlyBCsWithCollisions && !bcHasCollision[bc.globalIndex()]) { + continue; // skip if no collision is assigned to this BC (from evSel assignment) } - } else { - multFDDA = -999.0f; - multFDDC = -999.0f; - } - if (bc.has_zdc()) { - multZNA = bc.zdc().amplitudeZNA(); - multZNC = bc.zdc().amplitudeZNC(); - multZEM1 = bc.zdc().amplitudeZEM1(); - multZEM2 = bc.zdc().amplitudeZEM2(); - multZPA = bc.zdc().amplitudeZPA(); - multZPC = bc.zdc().amplitudeZPC(); - } else { - multZNA = -999.f; - multZNC = -999.f; - multZEM1 = -999.f; - multZEM2 = -999.f; - multZPA = -999.f; - multZPC = -999.f; + newBCindex[bc.globalIndex()] = atIndex++; } + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ - if (multFT0C < minFT0CforBCTable) { - return; // skip this event + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + // interlink: collision -> valid BC, BC -> collision + for (const auto& collision : collisions) { + mult2bc(newBCindex[collision.foundBCId()]); + bc2multArray[collision.foundBCId()] = collision.globalIndex(); } + //+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + + for (const auto& bc : bcs) { + if (newBCindex[bc.globalIndex()] < 0) { + continue; // don't keep if low mult or downsampled out + } + + bool Tvx = false; + bool isFV0OrA = false; + float multFT0C = 0.f; + float multFT0A = 0.f; + float multFV0A = 0.f; + float multFDDA = 0.f; + float multFDDC = 0.f; + + // ZDC amplitudes + float multZEM1 = -1.f; + float multZEM2 = -1.f; + float multZNA = -1.f; + float multZNC = -1.f; + float multZPA = -1.f; + float multZPC = -1.f; + + float posZFT0 = -1e+3; + bool posZFT0valid = false; + + uint8_t multFT0TriggerBits = 0; + uint8_t multFV0TriggerBits = 0; + uint8_t multFDDTriggerBits = 0; + uint64_t multBCTriggerMask = bc.triggerMask(); + + // initialize - from Arvind + newRunNumber = bc.runNumber(); + int localBC = bc.globalBC() % nBCsPerOrbit; + + if (newRunNumber != oldRunNumber) { + auto soreor = o2::ccdb::BasicCCDBManager::getRunDuration(ccdbApi, newRunNumber); + auto ts = soreor.first; + + LOG(info) << " newRunNumber " << newRunNumber << " time stamp " << ts; + oldRunNumber = newRunNumber; + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); + CollidingBunch = grplhcif->getBunchFilling().getBCPattern(); + } // new run number + + bool collidingBC = CollidingBunch.test(localBC); + + if (bc.has_ft0()) { + const auto& ft0 = bc.ft0(); + std::bitset<8> triggers = ft0.triggerMask(); + Tvx = triggers[o2::fit::Triggers::bitVertex]; + multFT0TriggerBits = static_cast(triggers.to_ulong()); + + // calculate T0 charge + for (auto amplitude : ft0.amplitudeA()) { + multFT0A += amplitude; + } + for (auto amplitude : ft0.amplitudeC()) { + multFT0C += amplitude; + } + posZFT0 = ft0.posZ(); + posZFT0valid = ft0.isValidTime(); + } else { + multFT0A = -999.0f; + multFT0C = -999.0f; + } + if (bc.has_fv0a()) { + auto fv0 = bc.fv0a(); + std::bitset<8> fV0Triggers = fv0.triggerMask(); + multFV0TriggerBits = static_cast(fV0Triggers.to_ulong()); + + for (auto amplitude : fv0.amplitude()) { + multFV0A += amplitude; + } + isFV0OrA = fV0Triggers[o2::fit::Triggers::bitA]; + } else { + multFV0A = -999.0f; + } - multBC(multFT0A, multFT0C, multFV0A, multFDDA, multFDDC, multZNA, multZNC, multZEM1, multZEM2, multZPA, multZPC, Tvx, isFV0OrA, multFV0TriggerBits, multFT0TriggerBits, multFDDTriggerBits, multBCTriggerMask, collidingBC); + if (bc.has_fdd()) { + auto fdd = bc.fdd(); + std::bitset<8> fFDDTriggers = fdd.triggerMask(); + multFDDTriggerBits = static_cast(fFDDTriggers.to_ulong()); + + for (auto amplitude : fdd.chargeA()) { + multFDDA += amplitude; + } + for (auto amplitude : fdd.chargeC()) { + multFDDC += amplitude; + } + } else { + multFDDA = -999.0f; + multFDDC = -999.0f; + } + + if (bc.has_zdc()) { + multZNA = bc.zdc().amplitudeZNA(); + multZNC = bc.zdc().amplitudeZNC(); + multZEM1 = bc.zdc().amplitudeZEM1(); + multZEM2 = bc.zdc().amplitudeZEM2(); + multZPA = bc.zdc().amplitudeZPA(); + multZPC = bc.zdc().amplitudeZPC(); + } else { + multZNA = -999.f; + multZNC = -999.f; + multZEM1 = -999.f; + multZEM2 = -999.f; + multZPA = -999.f; + multZPC = -999.f; + } + + bc2mult(bc2multArray[bc.globalIndex()]); + multBC( + tru(multFT0A), tru(multFT0C), + tru(posZFT0), posZFT0valid, tru(multFV0A), + tru(multFDDA), tru(multFDDC), tru(multZNA), tru(multZNC), tru(multZEM1), + tru(multZEM2), tru(multZPA), tru(multZPC), Tvx, isFV0OrA, + multFV0TriggerBits, multFT0TriggerBits, multFDDTriggerBits, multBCTriggerMask, collidingBC, + bc.flags()); + } } void processCollisionNeighbors(aod::Collisions const& collisions) diff --git a/Common/TableProducer/multiplicityTable.cxx b/Common/TableProducer/multiplicityTable.cxx index baf9ab6eb4b..30ae0c226fd 100644 --- a/Common/TableProducer/multiplicityTable.cxx +++ b/Common/TableProducer/multiplicityTable.cxx @@ -43,7 +43,7 @@ static constexpr int kFV0MultZeqs = 9; static constexpr int kFT0MultZeqs = 10; static constexpr int kFDDMultZeqs = 11; static constexpr int kPVMultZeqs = 12; -static constexpr int kMultsExtraMC = 13; +static constexpr int kMultMCExtras = 13; static constexpr int nTables = 14; // Checking that the Zeq tables are after the normal ones @@ -66,7 +66,7 @@ static const std::vector tableNames{"FV0Mults", // 0 "FT0MultZeqs", // 10 "FDDMultZeqs", // 11 "PVMultZeqs", // 12 - "MultsExtraMC"}; // 13 + "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}}; @@ -85,7 +85,8 @@ struct MultiplicityTable { Produces tableFT0Zeqs; // 10 Produces tableFDDZeqs; // 11 Produces tablePVZeqs; // 12 - Produces tableExtraMc; // 13 + Produces tableExtraMc; // 13 + Produces tableExtraMult2MCExtras; Produces multsGlobal; // Not accounted for, produced based on process function processGlobalTrackingCounters // For vertex-Z corrections in calibration @@ -109,8 +110,12 @@ struct MultiplicityTable { {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)"}; - 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"}; + 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 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"}}; int mRunNumber; @@ -159,10 +164,10 @@ struct MultiplicityTable { } } // Handle the custom cases. - if (tEnabled[kMultsExtraMC]) { - if (enabledTables->get(tableNames[kMultsExtraMC].c_str(), "Enable") == -1) { + if (tEnabled[kMultMCExtras]) { + if (enabledTables->get(tableNames[kMultMCExtras].c_str(), "Enable") == -1) { doprocessMC.value = true; - LOG(info) << "Enabling MC processing due to " << tableNames[kMultsExtraMC] << " table being enabled."; + LOG(info) << "Enabling MC processing due to " << tableNames[kMultMCExtras] << " table being enabled."; } } @@ -195,7 +200,7 @@ struct MultiplicityTable { hVtxZFDDC = nullptr; hVtxZNTracks = nullptr; - ccdb->setURL(ccdbUrl); + ccdb->setURL(ccdbConfig.ccdburl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); // don't fatal, please - exception is caught explicitly (as it should) @@ -274,14 +279,15 @@ struct MultiplicityTable { tablePv(multNContribs, multNContribsEta1, multNContribsEtaHalf); } - using Run3Tracks = 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); + 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); + void processRun3(soa::Join const& collisions, - Run3Tracks const&, + Run3TracksIU const&, BCsWithRun3Matchings const&, aod::Zdcs const&, aod::FV0As const&, @@ -330,7 +336,7 @@ struct MultiplicityTable { case kPVMultZeqs: // Equalized multiplicity for PV tablePVZeqs.reserve(collisions.size()); break; - case kMultsExtraMC: // MC extra information (nothing to do in the data) + case kMultMCExtras: // MC extra information (nothing to do in the data) break; default: LOG(fatal) << "Unknown table requested: " << i; @@ -372,7 +378,20 @@ struct MultiplicityTable { if (doVertexZeq > 0) { if (bc.runNumber() != mRunNumber) { mRunNumber = bc.runNumber(); // mark this run as at least tried - lCalibObjects = ccdb->getForTimeStamp(ccdbPath, bc.timestamp()); + if (ccdbConfig.reconstructionPass.value == "") { + lCalibObjects = ccdb->getForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, mRunNumber, metadata); + } + if (lCalibObjects) { if (produceHistograms) { listCalib->Add(lCalibObjects->Clone(Form("%i", bc.runNumber()))); @@ -499,11 +518,14 @@ struct MultiplicityTable { const auto& tracksThisCollision = pvContribTracksIUEta1.sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); multNContribsEta1 = tracksThisCollision.size(); for (auto track : tracksThisCollision) { - if (std::abs(track.eta()) < 0.8) + if (std::abs(track.eta()) < 0.8) { multNContribs++; - if (std::abs(track.eta()) < 0.5) + } + if (std::abs(track.eta()) < 0.5) { multNContribsEtaHalf++; + } } + tablePv(multNContribs, multNContribsEta1, multNContribsEtaHalf); LOGF(debug, "multNContribs=%i, multNContribsEta1=%i, multNContribsEtaHalf=%i", multNContribs, multNContribsEta1, multNContribsEtaHalf); } break; @@ -543,12 +565,13 @@ struct MultiplicityTable { } } - int bcNumber = bc.globalBC() % 3564; - tableExtra(collision.numContrib(), collision.chi2(), collision.collisionTimeRes(), mRunNumber, collision.posZ(), collision.sel8(), nHasITS, nHasTPC, nHasTOF, nHasTRD, nITSonly, nTPConly, nITSTPC, - nAllTracksTPCOnly, nAllTracksITSTPC, bcNumber, collision.trackOccupancyInTimeRange()); + nAllTracksTPCOnly, nAllTracksITSTPC, + collision.trackOccupancyInTimeRange(), + collision.ft0cOccupancyInTimeRange(), + collision.flags()); } break; case kMultSelections: // Multiplicity selections { @@ -590,7 +613,7 @@ struct MultiplicityTable { } tablePVZeqs(multZeqNContribs); } break; - case kMultsExtraMC: // MC only (nothing to do) + case kMultMCExtras: // MC only (nothing to do) { } break; default: // Default @@ -608,7 +631,7 @@ struct MultiplicityTable { Filter mcParticleFilter = (aod::mcparticle::eta < 4.9f) && (aod::mcparticle::eta > -3.3f); using mcParticlesFiltered = soa::Filtered; - void processMC(aod::McCollision const&, mcParticlesFiltered const& mcParticles) + void processMC(aod::McCollision const& mcCollision, mcParticlesFiltered const& mcParticles) { int multFT0A = 0; int multFT0C = 0; @@ -643,23 +666,57 @@ struct MultiplicityTable { if (3.5 < mcPart.eta() && mcPart.eta() < 4.9) multFT0A++; } - tableExtraMc(multFT0A, multFT0C, multBarrelEta05, multBarrelEta08, multBarrelEta10); + tableExtraMc(multFT0A, multFT0C, multBarrelEta05, multBarrelEta08, multBarrelEta10, mcCollision.posZ()); } - void processGlobalTrackingCounters(aod::Collision const&, - soa::Join const& tracks) + void processMC2Mults(soa::Join::iterator const& collision) + { + 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"}; + + 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(); + + void processGlobalTrackingCounters(aod::Collision const& collision, soa::Join const& tracksIU, Run3Tracks const&) { // counter from Igor int nGlobalTracks = 0; - for (auto& track : tracks) { + int multNContribsEta05_kGlobalTrackWoDCA = 0; + int multNContribsEta08_kGlobalTrackWoDCA = 0; + int multNContribsEta10_kGlobalTrackWoDCA = 0; + + auto pvContribGlobalTracksEta1_per_collision = 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) { + continue; + } + multNContribsEta10_kGlobalTrackWoDCA++; + + if (std::abs(track.eta()) < 0.8) { + multNContribsEta08_kGlobalTrackWoDCA++; + } + if (std::abs(track.eta()) < 0.5) { + multNContribsEta05_kGlobalTrackWoDCA++; + } + } + + for (auto& track : tracksIU) { if (fabs(track.eta()) < 0.8 && track.tpcNClsFound() >= 80 && track.tpcNClsCrossedRows() >= 100) { if (track.isGlobalTrack()) { nGlobalTracks++; } } } - multsGlobal(nGlobalTracks); + + LOGF(debug, "nGlobalTracks = %d, multNContribsEta08_kGlobalTrackWoDCA = %d, multNContribsEta10_kGlobalTrackWoDCA = %d, multNContribsEta05_kGlobalTrackWoDCA = %d", nGlobalTracks, multNContribsEta08_kGlobalTrackWoDCA, multNContribsEta10_kGlobalTrackWoDCA, multNContribsEta05_kGlobalTrackWoDCA); + + multsGlobal(nGlobalTracks, multNContribsEta08_kGlobalTrackWoDCA, multNContribsEta10_kGlobalTrackWoDCA, multNContribsEta05_kGlobalTrackWoDCA); } // Process switches @@ -667,6 +724,7 @@ struct MultiplicityTable { PROCESS_SWITCH(MultiplicityTable, processRun3, "Produce Run 3 multiplicity tables", 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); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/Common/TableProducer/qVectorsTable.cxx b/Common/TableProducer/qVectorsTable.cxx index da2e8e96deb..9de8faf028f 100644 --- a/Common/TableProducer/qVectorsTable.cxx +++ b/Common/TableProducer/qVectorsTable.cxx @@ -59,9 +59,9 @@ struct qVectorsTable { kFT0A = 1, kFT0M, kFV0A, - kBPos, - kBNeg, - kBTot + kTPCpos, + kTPCneg, + kTPCall }; // Configurables. @@ -80,7 +80,9 @@ struct qVectorsTable { Configurable cfgMaxPtOnTPC{"cfgMaxPtOnTPC", 5., "maximum transverse momentum selection for TPC tracks participating in Q-vector reconstruction"}; 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"}; + Configurable useCorrectionForRun{"useCorrectionForRun", true, "Get Qvector corrections based on run number instead of timestamp"}; Configurable cfgGainEqPath{"cfgGainEqPath", "Users/j/junlee/Qvector/GainEq", "CCDB path for gain equalization constants"}; Configurable cfgQvecCalibPath{"cfgQvecCalibPath", "Analysis/EventPlane/QVecCorrections", "CCDB pasth for Q-vecteor calibration constants"}; @@ -90,9 +92,9 @@ struct qVectorsTable { Configurable cfgUseFT0A{"cfgUseFT0A", false, "Initial value for using FT0A. By default obtained from DataModel."}; Configurable cfgUseFT0M{"cfgUseFT0M", false, "Initial value for using FT0M. By default obtained from DataModel."}; Configurable cfgUseFV0A{"cfgUseFV0A", false, "Initial value for using FV0A. By default obtained from DataModel."}; - Configurable cfgUseBPos{"cfgUseBPos", false, "Initial value for using BPos. By default obtained from DataModel."}; - Configurable cfgUseBNeg{"cfgUseBNeg", false, "Initial value for using BNeg. By default obtained from DataModel."}; - Configurable cfgUseBTot{"cfgUseBTot", false, "Initial value for using BTot. By default obtained from DataModel."}; + Configurable cfgUseTPCpos{"cfgUseTPCpos", false, "Initial value for using TPCpos. By default obtained from DataModel."}; + Configurable cfgUseTPCneg{"cfgUseTPCneg", false, "Initial value for using TPCneg. By default obtained from DataModel."}; + Configurable cfgUseTPCall{"cfgUseTPCall", false, "Initial value for using TPCall. By default obtained from DataModel."}; // Table. Produces qVector; @@ -100,17 +102,17 @@ struct qVectorsTable { Produces qVectorFT0A; Produces qVectorFT0M; Produces qVectorFV0A; - Produces qVectorBPos; - Produces qVectorBNeg; - Produces qVectorBTot; + Produces qVectorTPCpos; + Produces qVectorTPCneg; + Produces qVectorTPCall; Produces qVectorFT0CVec; Produces qVectorFT0AVec; Produces qVectorFT0MVec; Produces qVectorFV0AVec; - Produces qVectorBPosVec; - Produces qVectorBNegVec; - Produces qVectorBTotVec; + Produces qVectorTPCposVec; + Produces qVectorTPCnegVec; + Produces qVectorTPCallVec; std::vector FT0RelGainConst{}; std::vector FV0RelGainConst{}; @@ -133,10 +135,27 @@ struct qVectorsTable { std::vector objQvec{}; + // Deprecated, will be removed in future after transition time // + Configurable cfgUseBPos{"cfgUseBPos", false, "Initial value for using BPos. By default obtained from DataModel."}; + Configurable cfgUseBNeg{"cfgUseBNeg", false, "Initial value for using BNeg. By default obtained from DataModel."}; + Configurable cfgUseBTot{"cfgUseBTot", false, "Initial value for using BTot. By default obtained from DataModel."}; + + Produces qVectorBPos; + Produces qVectorBNeg; + Produces qVectorBTot; + + Produces qVectorBPosVec; + Produces qVectorBNegVec; + Produces qVectorBTotVec; + ///////////////////////////////////////////////////////////////// + std::unordered_map useDetector = { {"QvectorBTots", cfgUseBTot}, {"QvectorBNegs", cfgUseBNeg}, {"QvectorBPoss", cfgUseBPos}, + {"QvectorTPCalls", cfgUseTPCall}, + {"QvectorTPCnegs", cfgUseTPCneg}, + {"QvectorTPCposs", cfgUseTPCpos}, {"QvectorFV0As", cfgUseFV0A}, {"QvectorFT0Ms", cfgUseFT0M}, {"QvectorFT0As", cfgUseFT0A}, @@ -201,9 +220,10 @@ struct qVectorsTable { std::string fullPath; auto timestamp = bc.timestamp(); + auto runnumber = bc.runNumber(); - auto offsetFT0 = ccdb->getForTimeStamp>("FT0/Calib/Align", timestamp); - auto offsetFV0 = ccdb->getForTimeStamp>("FV0/Calib/Align", timestamp); + auto offsetFT0 = getForTsOrRun>("FT0/Calib/Align", timestamp, runnumber); + auto offsetFV0 = getForTsOrRun>("FV0/Calib/Align", timestamp, runnumber); if (offsetFT0 != nullptr) { helperEP.SetOffsetFT0A((*offsetFT0)[0].getX(), (*offsetFT0)[0].getY()); @@ -225,17 +245,17 @@ struct qVectorsTable { fullPath = cfgQvecCalibPath; fullPath += "/v"; fullPath += std::to_string(ind); - auto objqvec = ccdb->getForTimeStamp(fullPath, timestamp); + auto objqvec = getForTsOrRun(fullPath, timestamp, runnumber); if (!objqvec) { fullPath = cfgQvecCalibPath; fullPath += "/v2"; - objqvec = ccdb->getForTimeStamp(fullPath, timestamp); + objqvec = getForTsOrRun(fullPath, timestamp, runnumber); } objQvec.push_back(objqvec); } fullPath = cfgGainEqPath; fullPath += "/FT0"; - auto objft0Gain = ccdb->getForTimeStamp>(fullPath, timestamp); + auto objft0Gain = getForTsOrRun>(fullPath, timestamp, runnumber); if (!objft0Gain || cfgCorrLevel == 0) { for (auto i{0u}; i < 208; i++) { FT0RelGainConst.push_back(1.); @@ -246,7 +266,7 @@ struct qVectorsTable { fullPath = cfgGainEqPath; fullPath += "/FV0"; - auto objfv0Gain = ccdb->getForTimeStamp>(fullPath, timestamp); + auto objfv0Gain = getForTsOrRun>(fullPath, timestamp, runnumber); if (!objfv0Gain || cfgCorrLevel == 0) { for (auto i{0u}; i < 48; i++) { FV0RelGainConst.push_back(1.); @@ -281,16 +301,31 @@ struct qVectorsTable { return true; } + /// Function to get corrections from CCDB eithr using the timestamp or the runnumber + /// \param fullPath is the path to correction in CCDB + /// \param timestamp is the collision timestamp + /// \param runNumber is the collision run number + /// \return CCDB correction + template + CorrectionType* getForTsOrRun(std::string const& fullPath, int64_t timestamp, int runNumber) + { + if (useCorrectionForRun) { + return ccdb->getForRun(fullPath, runNumber); + } else { + return ccdb->getForTimeStamp(fullPath, timestamp); + } + } + template - void CalQvec(const Nmode nmode, const CollType& coll, const TrackType& track, std::vector& QvecRe, std::vector& QvecIm, std::vector& QvecAmp, std::vector& TrkBPosLabel, std::vector& TrkBNegLabel, std::vector& TrkBTotLabel) + void CalQvec(const Nmode nmode, const CollType& coll, const TrackType& track, std::vector& QvecRe, std::vector& QvecIm, std::vector& QvecAmp, std::vector& TrkTPCposLabel, std::vector& TrkTPCnegLabel, std::vector& TrkTPCallLabel) { float qVectFT0A[2] = {0.}; float qVectFT0C[2] = {0.}; float qVectFT0M[2] = {0.}; float qVectFV0A[2] = {0.}; - float qVectBPos[2] = {0.}; - float qVectBNeg[2] = {0.}; - float qVectBTot[2] = {0.}; + float qVectTPCpos[2] = {0.}; + float qVectTPCneg[2] = {0.}; + float qVectTPCall[2] = {0.}; TComplex QvecDet(0); TComplex QvecFT0M(0); @@ -393,9 +428,9 @@ struct qVectorsTable { qVectFV0A[1] = -999.; } - int nTrkBPos = 0; - int nTrkBNeg = 0; - int nTrkBTot = 0; + int nTrkTPCpos = 0; + int nTrkTPCneg = 0; + int nTrkTPCall = 0; for (auto& trk : track) { if (!SelTrack(trk)) { @@ -405,47 +440,47 @@ struct qVectorsTable { if (std::abs(trk.eta()) > 0.8) { continue; } - qVectBTot[0] += trk.pt() * std::cos(trk.phi() * nmode); - qVectBTot[1] += trk.pt() * std::sin(trk.phi() * nmode); - TrkBTotLabel.push_back(trk.globalIndex()); - nTrkBTot++; + qVectTPCall[0] += trk.pt() * std::cos(trk.phi() * nmode); + qVectTPCall[1] += trk.pt() * std::sin(trk.phi() * nmode); + TrkTPCallLabel.push_back(trk.globalIndex()); + nTrkTPCall++; if (std::abs(trk.eta()) < 0.1) { continue; } - if (trk.eta() > 0 && useDetector["QvectorBPoss"]) { - qVectBPos[0] += trk.pt() * std::cos(trk.phi() * nmode); - qVectBPos[1] += trk.pt() * std::sin(trk.phi() * nmode); - TrkBPosLabel.push_back(trk.globalIndex()); - nTrkBPos++; - } else if (trk.eta() < 0 && useDetector["QvectorBNegs"]) { - qVectBNeg[0] += trk.pt() * std::cos(trk.phi() * nmode); - qVectBNeg[1] += trk.pt() * std::sin(trk.phi() * nmode); - TrkBNegLabel.push_back(trk.globalIndex()); - nTrkBNeg++; + if (trk.eta() > 0 && (useDetector["QvectorTPCposs"] || useDetector["QvectorBPoss"])) { + qVectTPCpos[0] += trk.pt() * std::cos(trk.phi() * nmode); + qVectTPCpos[1] += trk.pt() * std::sin(trk.phi() * nmode); + TrkTPCposLabel.push_back(trk.globalIndex()); + nTrkTPCpos++; + } else if (trk.eta() < 0 && (useDetector["QvectorTPCnegs"] || useDetector["QvectorBNegs"])) { + qVectTPCneg[0] += trk.pt() * std::cos(trk.phi() * nmode); + qVectTPCneg[1] += trk.pt() * std::sin(trk.phi() * nmode); + TrkTPCnegLabel.push_back(trk.globalIndex()); + nTrkTPCneg++; } } - if (nTrkBPos > 0) { - qVectBPos[0] /= nTrkBPos; - qVectBPos[1] /= nTrkBPos; + if (nTrkTPCpos > 0) { + qVectTPCpos[0] /= nTrkTPCpos; + qVectTPCpos[1] /= nTrkTPCpos; } else { - qVectBPos[0] = 999.; - qVectBPos[1] = 999.; + qVectTPCpos[0] = 999.; + qVectTPCpos[1] = 999.; } - if (nTrkBNeg > 0) { - qVectBNeg[0] /= nTrkBNeg; - qVectBNeg[1] /= nTrkBNeg; + if (nTrkTPCneg > 0) { + qVectTPCneg[0] /= nTrkTPCneg; + qVectTPCneg[1] /= nTrkTPCneg; } else { - qVectBNeg[0] = 999.; - qVectBNeg[1] = 999.; + qVectTPCneg[0] = 999.; + qVectTPCneg[1] = 999.; } - if (nTrkBTot > 0) { - qVectBTot[0] /= nTrkBTot; - qVectBTot[1] /= nTrkBTot; + if (nTrkTPCall > 0) { + qVectTPCall[0] /= nTrkTPCall; + qVectTPCall[1] /= nTrkTPCall; } else { - qVectBTot[0] = 999.; - qVectBTot[1] = 999.; + qVectTPCall[0] = 999.; + qVectTPCall[1] = 999.; } for (auto i{0u}; i < 4; i++) { @@ -465,32 +500,32 @@ struct qVectorsTable { QvecIm.push_back(qVectFV0A[1]); } for (auto i{0u}; i < 4; i++) { - QvecRe.push_back(qVectBPos[0]); - QvecIm.push_back(qVectBPos[1]); + QvecRe.push_back(qVectTPCpos[0]); + QvecIm.push_back(qVectTPCpos[1]); } for (auto i{0u}; i < 4; i++) { - QvecRe.push_back(qVectBNeg[0]); - QvecIm.push_back(qVectBNeg[1]); + QvecRe.push_back(qVectTPCneg[0]); + QvecIm.push_back(qVectTPCneg[1]); } for (auto i{0u}; i < 4; i++) { - QvecRe.push_back(qVectBTot[0]); - QvecIm.push_back(qVectBTot[1]); + QvecRe.push_back(qVectTPCall[0]); + QvecIm.push_back(qVectTPCall[1]); } QvecAmp.push_back(sumAmplFT0C); QvecAmp.push_back(sumAmplFT0A); QvecAmp.push_back(sumAmplFT0M); QvecAmp.push_back(sumAmplFV0A); - QvecAmp.push_back(static_cast(nTrkBPos)); - QvecAmp.push_back(static_cast(nTrkBNeg)); - QvecAmp.push_back(static_cast(nTrkBTot)); + QvecAmp.push_back(static_cast(nTrkTPCpos)); + QvecAmp.push_back(static_cast(nTrkTPCneg)); + QvecAmp.push_back(static_cast(nTrkTPCall)); } void process(MyCollisions::iterator const& coll, aod::BCsWithTimestamps const&, aod::FT0s const&, aod::FV0As const&, MyTracks const& tracks) { - std::vector TrkBPosLabel{}; - std::vector TrkBNegLabel{}; - std::vector TrkBTotLabel{}; + std::vector TrkTPCposLabel{}; + std::vector TrkTPCnegLabel{}; + std::vector TrkTPCallLabel{}; std::vector qvecRe{}; std::vector qvecIm{}; std::vector qvecAmp{}; @@ -503,12 +538,12 @@ struct qVectorsTable { std::vector qvecImFT0M{}; std::vector qvecReFV0A{}; std::vector qvecImFV0A{}; - std::vector qvecReBPos{}; - std::vector qvecImBPos{}; - std::vector qvecReBNeg{}; - std::vector qvecImBNeg{}; - std::vector qvecReBTot{}; - std::vector qvecImBTot{}; + std::vector qvecReTPCpos{}; + std::vector qvecImTPCpos{}; + std::vector qvecReTPCneg{}; + std::vector qvecImTPCneg{}; + std::vector qvecReTPCall{}; + std::vector qvecImTPCall{}; auto bc = coll.bc_as(); int currentRun = bc.runNumber(); @@ -522,46 +557,46 @@ struct qVectorsTable { coll.centFV0A()}; cent = centAllEstim[cfgCentEsti]; bool IsCalibrated = true; - if (cent < 0. || cent > 80.) { + if (cent < 0. || cent > cfgMaxCentrality) { cent = 110.; IsCalibrated = false; } for (std::size_t id = 0; id < cfgnMods->size(); id++) { int ind = cfgnMods->at(id); - CalQvec(ind, coll, tracks, qvecRe, qvecIm, qvecAmp, TrkBPosLabel, TrkBNegLabel, TrkBTotLabel); - if (cent < 80) { - for (auto i{0u}; i < kBTot + 1; i++) { - helperEP.DoRecenter(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 1], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 1], + CalQvec(ind, coll, tracks, qvecRe, qvecIm, qvecAmp, TrkTPCposLabel, TrkTPCnegLabel, TrkTPCallLabel); + if (cent < cfgMaxCentrality) { + for (auto i{0u}; i < kTPCall + 1; i++) { + helperEP.DoRecenter(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 1], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 1], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 1, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 2, i + 1)); - helperEP.DoRecenter(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 2], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 2], + helperEP.DoRecenter(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 2], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 2], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 1, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 2, i + 1)); - helperEP.DoTwist(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 2], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 2], + helperEP.DoTwist(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 2], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 2], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 3, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 4, i + 1)); - helperEP.DoRecenter(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 3], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 3], + helperEP.DoRecenter(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 3], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 3], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 1, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 2, i + 1)); - helperEP.DoTwist(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 3], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 3], + helperEP.DoTwist(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 3], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 3], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 3, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 4, i + 1)); - helperEP.DoRescale(qvecRe[(kBTot + 1) * 4 * id + i * 4 + 3], qvecIm[(kBTot + 1) * 4 * id + i * 4 + 3], + helperEP.DoRescale(qvecRe[(kTPCall + 1) * 4 * id + i * 4 + 3], qvecIm[(kTPCall + 1) * 4 * id + i * 4 + 3], objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 5, i + 1), objQvec.at(id)->GetBinContent(static_cast(cent) + 1, 6, i + 1)); } } int CorrLevel = cfgCorrLevel == 0 ? 0 : cfgCorrLevel - 1; - qvecReFT0C.push_back(qvecRe[(kBTot + 1) * 4 * id + kFT0C * 4 + CorrLevel]); - qvecImFT0C.push_back(qvecIm[(kBTot + 1) * 4 * id + kFT0C * 4 + CorrLevel]); - qvecReFT0A.push_back(qvecRe[(kBTot + 1) * 4 * id + kFT0A * 4 + CorrLevel]); - qvecImFT0A.push_back(qvecIm[(kBTot + 1) * 4 * id + kFT0A * 4 + CorrLevel]); - qvecReFT0M.push_back(qvecRe[(kBTot + 1) * 4 * id + kFT0M * 4 + CorrLevel]); - qvecImFT0M.push_back(qvecIm[(kBTot + 1) * 4 * id + kFT0M * 4 + CorrLevel]); - qvecReFV0A.push_back(qvecRe[(kBTot + 1) * 4 * id + kFV0A * 4 + CorrLevel]); - qvecImFV0A.push_back(qvecIm[(kBTot + 1) * 4 * id + kFV0A * 4 + CorrLevel]); - qvecReBPos.push_back(qvecRe[(kBTot + 1) * 4 * id + kBPos * 4 + CorrLevel]); - qvecImBPos.push_back(qvecIm[(kBTot + 1) * 4 * id + kBPos * 4 + CorrLevel]); - qvecReBNeg.push_back(qvecRe[(kBTot + 1) * 4 * id + kBNeg * 4 + CorrLevel]); - qvecImBNeg.push_back(qvecIm[(kBTot + 1) * 4 * id + kBNeg * 4 + CorrLevel]); - qvecReBTot.push_back(qvecRe[(kBTot + 1) * 4 * id + kBTot * 4 + CorrLevel]); - qvecImBTot.push_back(qvecIm[(kBTot + 1) * 4 * id + kBTot * 4 + CorrLevel]); + qvecReFT0C.push_back(qvecRe[(kTPCall + 1) * 4 * id + kFT0C * 4 + CorrLevel]); + qvecImFT0C.push_back(qvecIm[(kTPCall + 1) * 4 * id + kFT0C * 4 + CorrLevel]); + qvecReFT0A.push_back(qvecRe[(kTPCall + 1) * 4 * id + kFT0A * 4 + CorrLevel]); + qvecImFT0A.push_back(qvecIm[(kTPCall + 1) * 4 * id + kFT0A * 4 + CorrLevel]); + qvecReFT0M.push_back(qvecRe[(kTPCall + 1) * 4 * id + kFT0M * 4 + CorrLevel]); + qvecImFT0M.push_back(qvecIm[(kTPCall + 1) * 4 * id + kFT0M * 4 + CorrLevel]); + qvecReFV0A.push_back(qvecRe[(kTPCall + 1) * 4 * id + kFV0A * 4 + CorrLevel]); + qvecImFV0A.push_back(qvecIm[(kTPCall + 1) * 4 * id + kFV0A * 4 + CorrLevel]); + qvecReTPCpos.push_back(qvecRe[(kTPCall + 1) * 4 * id + kTPCpos * 4 + CorrLevel]); + qvecImTPCpos.push_back(qvecIm[(kTPCall + 1) * 4 * id + kTPCpos * 4 + CorrLevel]); + qvecReTPCneg.push_back(qvecRe[(kTPCall + 1) * 4 * id + kTPCneg * 4 + CorrLevel]); + qvecImTPCneg.push_back(qvecIm[(kTPCall + 1) * 4 * id + kTPCneg * 4 + CorrLevel]); + qvecReTPCall.push_back(qvecRe[(kTPCall + 1) * 4 * id + kTPCall * 4 + CorrLevel]); + qvecImTPCall.push_back(qvecIm[(kTPCall + 1) * 4 * id + kTPCall * 4 + CorrLevel]); } // Fill the columns of the Qvectors table. @@ -574,20 +609,34 @@ struct qVectorsTable { qVectorFT0M(IsCalibrated, qvecReFT0M.at(0), qvecImFT0M.at(0), qvecAmp[kFT0M]); if (useDetector["QvectorFV0As"]) qVectorFV0A(IsCalibrated, qvecReFV0A.at(0), qvecImFV0A.at(0), qvecAmp[kFV0A]); - if (useDetector["QvectorBPoss"]) - qVectorBPos(IsCalibrated, qvecReBPos.at(0), qvecImBPos.at(0), qvecAmp[kBPos], TrkBPosLabel); - if (useDetector["QvectorBNegs"]) - qVectorBNeg(IsCalibrated, qvecReBNeg.at(0), qvecImBNeg.at(0), qvecAmp[kBNeg], TrkBNegLabel); - if (useDetector["QvectorBTots"]) - qVectorBTot(IsCalibrated, qvecReBTot.at(0), qvecImBTot.at(0), qvecAmp[kBTot], TrkBTotLabel); + if (useDetector["QvectorTPCposs"]) + qVectorTPCpos(IsCalibrated, qvecReTPCpos.at(0), qvecImTPCpos.at(0), qvecAmp[kTPCpos], TrkTPCposLabel); + if (useDetector["QvectorTPCnegs"]) + qVectorTPCneg(IsCalibrated, qvecReTPCneg.at(0), qvecImTPCneg.at(0), qvecAmp[kTPCneg], TrkTPCnegLabel); + if (useDetector["QvectorTPCalls"]) + qVectorTPCall(IsCalibrated, qvecReTPCall.at(0), qvecImTPCall.at(0), qvecAmp[kTPCall], TrkTPCallLabel); qVectorFT0CVec(IsCalibrated, qvecReFT0C, qvecImFT0C, qvecAmp[kFT0C]); qVectorFT0AVec(IsCalibrated, qvecReFT0A, qvecImFT0A, qvecAmp[kFT0A]); qVectorFT0MVec(IsCalibrated, qvecReFT0M, qvecImFT0M, qvecAmp[kFT0M]); qVectorFV0AVec(IsCalibrated, qvecReFV0A, qvecImFV0A, qvecAmp[kFV0A]); - qVectorBPosVec(IsCalibrated, qvecReBPos, qvecImBPos, qvecAmp[kBPos], TrkBPosLabel); - qVectorBNegVec(IsCalibrated, qvecReBNeg, qvecImBNeg, qvecAmp[kBNeg], TrkBNegLabel); - qVectorBTotVec(IsCalibrated, qvecReBTot, qvecImBTot, qvecAmp[kBTot], TrkBTotLabel); + qVectorTPCposVec(IsCalibrated, qvecReTPCpos, qvecImTPCpos, qvecAmp[kTPCpos], TrkTPCposLabel); + qVectorTPCnegVec(IsCalibrated, qvecReTPCneg, qvecImTPCneg, qvecAmp[kTPCneg], TrkTPCnegLabel); + qVectorTPCallVec(IsCalibrated, qvecReTPCall, qvecImTPCall, qvecAmp[kTPCall], TrkTPCallLabel); + + // Deprecated, will be removed in future after transition time // + if (useDetector["QvectorBPoss"]) + qVectorBPos(IsCalibrated, qvecReTPCpos.at(0), qvecImTPCpos.at(0), qvecAmp[kTPCpos], TrkTPCposLabel); + if (useDetector["QvectorBNegs"]) + qVectorBNeg(IsCalibrated, qvecReTPCneg.at(0), qvecImTPCneg.at(0), qvecAmp[kTPCneg], TrkTPCnegLabel); + if (useDetector["QvectorBTots"]) + qVectorBTot(IsCalibrated, qvecReTPCall.at(0), qvecImTPCall.at(0), qvecAmp[kTPCall], TrkTPCallLabel); + + qVectorBPosVec(IsCalibrated, qvecReTPCpos, qvecImTPCpos, qvecAmp[kTPCpos], TrkTPCposLabel); + qVectorBNegVec(IsCalibrated, qvecReTPCneg, qvecImTPCneg, qvecAmp[kTPCneg], TrkTPCnegLabel); + qVectorBTotVec(IsCalibrated, qvecReTPCall, qvecImTPCall, qvecAmp[kTPCall], TrkTPCallLabel); + ///////////////////////////////////////////////////////////////// + } // End process. }; diff --git a/Common/TableProducer/timestamp.cxx b/Common/TableProducer/timestamp.cxx index c108bf32713..e3d37f7129b 100644 --- a/Common/TableProducer/timestamp.cxx +++ b/Common/TableProducer/timestamp.cxx @@ -23,25 +23,31 @@ #include "CCDB/BasicCCDBManager.h" #include "CommonDataFormat/InteractionRecord.h" #include "DetectorsRaw/HBFUtils.h" +#include "MetadataHelper.h" using namespace o2::framework; using namespace o2::header; using namespace o2; +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 fatalOnInvalidTimestamp{"fatalOnInvalidTimestamp", false, "Generate fatal error for invalid timestamps"}; std::map mapRunToOrbitReset; /// Cache of orbit reset timestamps + std::map> mapRunToRunDuration; /// Cache of run duration timestamps int lastRunNumber = 0; /// Last run number processed int64_t orbitResetTimestamp = 0; /// Orbit-reset timestamp in us + std::pair runDuration; /// Pair of SOR and EOR timestamps // Configurables Configurable verbose{"verbose", false, "verbose mode"}; Configurable rct_path{"rct-path", "RCT/Info/RunInformation", "path to the ccdb RCT objects for the SOR timestamps"}; Configurable orbit_reset_path{"orbit-reset-path", "CTP/Calib/OrbitReset", "path to the ccdb orbit-reset objects"}; Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "URL of the CCDB database"}; - Configurable isRun2MC{"isRun2MC", false, "Running mode: enable only for Run 2 MC. Timestamps are set to SOR timestamp"}; + 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)"}; void init(o2::framework::InitContext&) { @@ -51,6 +57,14 @@ struct TimestampTask { if (!ccdb_api.isHostReachable()) { LOGF(fatal, "CCDB host %s is not reacheable, cannot go forward", url.value.data()); } + if (isRun2MC.value == -1) { + if ((!metadataInfo.isRun3()) && metadataInfo.isMC()) { + isRun2MC.value = 1; + LOG(info) << "Autosetting the Run2 MC mode based on metadata"; + } else { + isRun2MC.value = 0; + } + } } void process(aod::BC const& bc) @@ -64,14 +78,15 @@ struct TimestampTask { } 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"); - auto timestamps = ccdb->getRunDuration(runNumber, true); /// fatalise if timestamps are not found - int64_t sorTimestamp = timestamps.first; // timestamp of the SOR in ms - int64_t eorTimestamp = timestamps.second; // timestamp of the EOR in ms + 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 - bool isUnanchoredRun3MC = runNumber >= 300000 && runNumber < 500000; - if (isRun2MC || isUnanchoredRun3MC) { + const bool isUnanchoredRun3MC = runNumber >= 300000 && runNumber < 500000; + if (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 @@ -83,7 +98,7 @@ struct TimestampTask { } 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->getForTimeStamp>(orbit_reset_path.value.data(), eorTimestamp); + auto ctp = ccdb->getForTimeStamp>(orbit_reset_path.value.data(), eorTimestamp / 2 + sorTimestamp / 2); orbitResetTimestamp = (*ctp)[0]; } @@ -93,18 +108,29 @@ struct TimestampTask { if (!check.second) { LOGF(fatal, "Run number %i already existed with a orbit-reset timestamp of %llu", runNumber, check.first->second); } - LOGF(info, "Add new run number %i with orbit-reset timestamp %llu to cache", runNumber, orbitResetTimestamp); + 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 (verbose.value) { LOGF(info, "Orbit-reset timestamp for run number %i found: %llu us", runNumber, orbitResetTimestamp); } - - timestampTable((orbitResetTimestamp + int64_t(bc.globalBC() * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000); // us -> ms + 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 (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); + } + } + timestampTable(timestamp); } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + // Parse the metadata + metadataInfo.initMetadata(cfgc); + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Common/TableProducer/trackPropagation.cxx b/Common/TableProducer/trackPropagation.cxx index ac8a4e60e0e..378a2ac06a2 100644 --- a/Common/TableProducer/trackPropagation.cxx +++ b/Common/TableProducer/trackPropagation.cxx @@ -62,6 +62,7 @@ struct TrackPropagation { // for TrackTuner only (MC smearing) Configurable useTrackTuner{"useTrackTuner", false, "Apply track tuner corrections to MC"}; Configurable fillTrackTunerTable{"fillTrackTunerTable", false, "flag to fill track tuner table"}; + Configurable trackTunerConfigSource{"trackTunerConfigSource", aod::track_tuner::InputString, "1: input string; 2: TrackTuner Configurables"}; 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: =|=)"}; ConfigurableAxis axisPtQA{"axisPtQA", {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"}; OutputObj trackTunedTracks{TH1D("trackTunedTracks", "", 1, 0.5, 1.5), OutputObjHandlingPolicy::AnalysisObject}; @@ -119,13 +120,23 @@ struct TrackPropagation { /// TrackTuner initialization if (useTrackTuner) { - std::string outputStringParams = trackTunerObj.configParams(trackTunerParams); + std::string outputStringParams = ""; + switch (trackTunerConfigSource) { + case aod::track_tuner::InputString: + outputStringParams = trackTunerObj.configParams(trackTunerParams); + break; + case 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->SetTitle(outputStringParams.c_str()); trackTunedTracks->GetXaxis()->SetBinLabel(1, "all tracks"); - trackTunedTracks->GetXaxis()->SetBinLabel(2, "tracks tuned (no negative detXY)"); - trackTunedTracks->GetXaxis()->SetBinLabel(3, "untouched tracks due to negative detXY"); - trackTunedTracks->GetXaxis()->SetBinLabel(4, "original detXY<0"); } } diff --git a/Common/TableProducer/zdc-task-intercalib.cxx b/Common/TableProducer/zdc-task-intercalib.cxx new file mode 100644 index 00000000000..e8b541c45b8 --- /dev/null +++ b/Common/TableProducer/zdc-task-intercalib.cxx @@ -0,0 +1,150 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 ZDC tower inter-calibration +/// \author chiara.oppedisano@cern.ch +// Minimal example to run this task: +// export OPTIONS="-b --configuration json://config.json --aod-file AO2D.root" +// o2-analysis-timestamp ${OPTIONS} | +// o2-analysis-event-selection ${OPTIONS} | +// o2-analysis-track-propagation ${OPTIONS} | +// o2-analysis-mm-zdc-task-intercalib ${OPTIONS} + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/ZDCInterCalib.h" + +#include "TH1F.h" +#include "TH2F.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::evsel; + +constexpr double kVeryNegative = -1.e12; + +using BCsRun3 = soa::Join; +using ColEvSels = soa::Join; + +struct zdcInterCalib { + + Produces zTab; + + // Configurable parameters + // + Configurable nBins{"nBins", 400, "n bins"}; + Configurable MaxZN{"MaxZN", 399.5, "Max ZN signal"}; + // + HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext const&) + { + registry.add("ZNApmc", "ZNApmc; ZNA PMC; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNCpmc", "ZNCpmc; ZNC PMC; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNApm1", "ZNApm1; ZNA PM1; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNApm2", "ZNApm2; ZNA PM2; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNApm3", "ZNApm3; ZNA PM3; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNApm4", "ZNApm4; ZNA PM4; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNCpm1", "ZNCpm1; ZNC PM1; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNCpm2", "ZNCpm2; ZNC PM2; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + registry.add("ZNCpm3", "ZNCpm3; ZNC PM3; Entries", {HistType::kTH1F, {{nBins, -0.5, MaxZN}}}); + 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}}}); + } + + void process(ColEvSels const& cols, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/) + { + // collision-based event selection + for (auto& collision : cols) { + const auto& foundBC = collision.foundBC_as(); + if (foundBC.has_zdc()) { + const auto& zdc = foundBC.zdc(); + + // 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) + // If this is not the case, signals are set to kVeryNegative values + double pmcZNC = zdc.energyCommonZNC(); + double pmcZNA = zdc.energyCommonZNA(); + // + // double tdcZNC = zdc.zdc.timeZNC(); + // double tdcZNA = zdc.zdc.timeZNA(); + // + bool isZNChit = true, isZNAhit = true; + if (pmcZNC < kVeryNegative) { + pmcZNC = kVeryNegative; + isZNChit = false; + } + if (pmcZNA < kVeryNegative) { + pmcZNA = kVeryNegative; + isZNAhit = false; + } + // + double sumZNC = 0; + double sumZNA = 0; + double pmqZNC[4] = { + 0, + 0, + 0, + 0, + }; + double pmqZNA[4] = { + 0, + 0, + 0, + 0, + }; + // + if (isZNChit) { + for (int it = 0; it < 4; it++) { + pmqZNC[it] = (zdc.energySectorZNC())[it]; + sumZNC += pmqZNC[it]; + } + registry.get(HIST("ZNCpmc"))->Fill(pmcZNC); + registry.get(HIST("ZNCpm1"))->Fill(pmqZNC[0]); + registry.get(HIST("ZNCpm2"))->Fill(pmqZNC[1]); + registry.get(HIST("ZNCpm3"))->Fill(pmqZNC[2]); + registry.get(HIST("ZNCpm4"))->Fill(pmqZNC[3]); + registry.get(HIST("ZNCsumq"))->Fill(sumZNC); + } + if (isZNAhit) { + for (int it = 0; it < 4; it++) { + pmqZNA[it] = (zdc.energySectorZNA())[it]; + sumZNA += pmqZNA[it]; + } + // + registry.get(HIST("ZNApmc"))->Fill(pmcZNA); + registry.get(HIST("ZNApm1"))->Fill(pmqZNA[0]); + registry.get(HIST("ZNApm2"))->Fill(pmqZNA[1]); + registry.get(HIST("ZNApm3"))->Fill(pmqZNA[2]); + registry.get(HIST("ZNApm4"))->Fill(pmqZNA[3]); + registry.get(HIST("ZNAsumq"))->Fill(sumZNA); + } + if (isZNAhit || isZNChit) + zTab(pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3]); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Common/Tasks/centralityStudy.cxx b/Common/Tasks/centralityStudy.cxx index f24fa99f9e2..9d5fe997fbc 100644 --- a/Common/Tasks/centralityStudy.cxx +++ b/Common/Tasks/centralityStudy.cxx @@ -46,13 +46,32 @@ struct centralityStudy { 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 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)"}; + Configurable rejectITSinROFpileupStrict{"rejectITSinROFpileupStrict", false, "reject collisions in case of in-ROF ITS pileup (strict)"}; + Configurable rejectCollInTimeRangeNarrow{"rejectCollInTimeRangeNarrow", false, "reject if extra colls in time range (narrow)"}; + + Configurable selectUPCcollisions{"selectUPCcollisions", false, "select collisions tagged with UPC flag"}; + + Configurable selectCollidingBCs{"selectCollidingBCs", true, "BC analysis: select colliding BCs"}; + Configurable selectTVX{"selectTVX", true, "BC analysis: select TVX"}; + Configurable selectFV0OrA{"selectFV0OrA", true, "BC analysis: select FV0OrA"}; + 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 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 Axes ConfigurableAxis axisMultFT0C{"axisMultFT0C", {2000, 0, 100000}, "FT0C amplitude"}; ConfigurableAxis axisMultPVContributors{"axisMultPVContributors", {200, 0, 6000}, "Number of PV Contributors"}; // For one-dimensional plots, where binning is no issue + ConfigurableAxis axisMultUltraFineFV0A{"axisMultUltraFineFV0A", {60000, 0, 60000}, "FV0A amplitude"}; + ConfigurableAxis axisMultUltraFineFT0M{"axisMultUltraFineFT0M", {50000, 0, 200000}, "FT0M amplitude"}; ConfigurableAxis axisMultUltraFineFT0C{"axisMultUltraFineFT0C", {60000, 0, 60000}, "FT0C amplitude"}; ConfigurableAxis axisMultUltraFinePVContributors{"axisMultUltraFinePVContributors", {10000, 0, 10000}, "Number of PV Contributors"}; @@ -64,6 +83,9 @@ struct centralityStudy { ConfigurableAxis axisPVChi2{"axisPVChi2", {300, 0, 30}, "FT0C percentile"}; ConfigurableAxis axisDeltaTime{"axisDeltaTime", {300, 0, 300}, "#Delta time"}; + // For profile Z + ConfigurableAxis axisPVz{"axisPVz", {400, -20.0f, +20.0f}, "PVz (cm)"}; + void init(InitContext&) { if (doprocessCollisions || doprocessCollisionsWithCentrality) { @@ -80,14 +102,28 @@ struct centralityStudy { histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(9, "kIsVertexTRDmatched"); histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(10, "kNoSameBunchPileup"); histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(11, "Neighbour rejection"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(12, "no ITS in-ROF pileup (standard)"); + histos.get(HIST("hCollisionSelection"))->GetXaxis()->SetBinLabel(13, "no ITS in-ROF pileup (strict)"); histos.add("hFT0C_Collisions", "hFT0C_Collisions", kTH1D, {axisMultUltraFineFT0C}); + histos.add("hFT0M_Collisions", "hFT0M_Collisions", kTH1D, {axisMultUltraFineFT0M}); + histos.add("hFV0A_Collisions", "hFV0A_Collisions", kTH1D, {axisMultUltraFineFV0A}); histos.add("hNPVContributors", "hNPVContributors", kTH1D, {axisMultUltraFinePVContributors}); + + histos.add("hFT0CvsPVz_Collisions_All", "hFT0CvsPVz_Collisions_All", kTProfile, {axisPVz}); + histos.add("hFT0CvsPVz_Collisions", "hFT0CvsPVz_Collisions", kTProfile, {axisPVz}); } if (doprocessBCs) { - histos.add("hBCSelection", "hBCSelection", kTH1D, {{10, -0.5, 9.5f}}); + histos.add("hBCSelection", "hBCSelection", kTH1D, {{20, -0.5, 19.5f}}); histos.add("hFT0C_BCs", "hFT0C_BCs", kTH1D, {axisMultUltraFineFT0C}); + histos.add("hFT0M_BCs", "hFT0M_BCs", kTH1D, {axisMultUltraFineFT0M}); + histos.add("hFV0A_BCs", "hFV0A_BCs", kTH1D, {axisMultUltraFineFV0A}); + + histos.add("hFT0CvsPVz_BCs_All", "hFT0CvsPVz_BCs_All", kTProfile, {axisPVz}); + histos.add("hFT0CvsPVz_BCs", "hFT0CvsPVz_BCs", kTProfile, {axisPVz}); + + histos.add("hVertexZ_BCvsCO", "hVertexZ_BCvsCO", kTH2D, {axisPVz, axisPVz}); } if (do2DPlots) { @@ -97,6 +133,7 @@ struct centralityStudy { if (doprocessCollisionsWithCentrality) { // in case requested: do vs centrality debugging + histos.add("hCentrality", "hCentrality", kTH1F, {axisCentrality}); histos.add("hNContribsVsCentrality", "hNContribsVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); histos.add("hNITSTPCTracksVsCentrality", "hNITSTPCTracksVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); histos.add("hNITSOnlyTracksVsCentrality", "hNITSOnlyTracksVsCentrality", kTH2F, {axisCentrality, axisMultPVContributors}); @@ -168,18 +205,44 @@ struct centralityStudy { histos.fill(HIST("hCollisionSelection"), 10 /* has suspicious neighbour */); } + if (rejectITSinROFpileupStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 11 /* Not ITS ROF pileup (standard) */); + + if (rejectITSinROFpileupStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 12 /* Not ITS ROF pileup (strict) */); + + if (selectUPCcollisions && collision.flags() < 1) { // if zero then NOT upc, otherwise UPC + return; + } + histos.fill(HIST("hCollisionSelection"), 13 /* is UPC event */); + + if (rejectCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return; + } + histos.fill(HIST("hCollisionSelection"), 14 /* Not ITS ROF pileup (strict) */); + // if we got here, we also finally fill the FT0C histogram, please histos.fill(HIST("hNPVContributors"), collision.multPVTotalContributors()); - histos.fill(HIST("hFT0C_Collisions"), collision.multFT0C()); - + 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); + histos.fill(HIST("hFT0CvsPVz_Collisions_All"), collision.multPVz(), collision.multFT0C() * scaleSignalFT0C); + if (collision.multFT0C() > minFT0CforVertexZ) { + histos.fill(HIST("hFT0CvsPVz_Collisions"), collision.multPVz(), collision.multFT0C() * scaleSignalFT0C); + } if (do2DPlots) { - histos.fill(HIST("hFT0CvsNContribs"), collision.multNTracksPV(), collision.multFT0C()); + histos.fill(HIST("hFT0CvsNContribs"), collision.multNTracksPV(), collision.multFT0C() * scaleSignalFT0C); histos.fill(HIST("hMatchedVsITSOnly"), collision.multNTracksITSOnly(), collision.multNTracksITSTPC()); } // if the table has centrality information if constexpr (requires { collision.centFT0C(); }) { // process FT0C centrality plots + histos.fill(HIST("hCentrality"), collision.centFT0C()); histos.fill(HIST("hNContribsVsCentrality"), collision.centFT0C(), collision.multPVTotalContributors()); histos.fill(HIST("hNITSTPCTracksVsCentrality"), collision.centFT0C(), collision.multNTracksITSTPC()); histos.fill(HIST("hNITSOnlyTracksVsCentrality"), collision.centFT0C(), collision.multNTracksITSOnly()); @@ -203,23 +266,45 @@ struct centralityStudy { genericProcessCollision(collision); } - void processBCs(aod::MultsBC::iterator const& multbc) + void processBCs(soa::Join::iterator const& multbc, soa::Join const&) { // process BCs, calculate FT0C distribution // conditionals suggested by FIT team (Jacek O. et al) histos.fill(HIST("hBCSelection"), 0); // all BCs - if (!multbc.multBCColliding()) + if (selectCollidingBCs && !multbc.multBCColliding()) return; histos.fill(HIST("hBCSelection"), 1); // colliding - if (!multbc.multBCTVX()) + if (selectTVX && !multbc.multBCTVX()) return; histos.fill(HIST("hBCSelection"), 2); // TVX - if (!multbc.multBCFV0OrA()) + if (selectFV0OrA && !multbc.multBCFV0OrA()) return; histos.fill(HIST("hBCSelection"), 3); // FV0OrA + if (vertexZwithT0 < 100.0f) { + if (!multbc.multBCFT0PosZValid()) + return; + if (TMath::Abs(multbc.multBCFT0PosZ()) > vertexZwithT0) + return; + } + histos.fill(HIST("hBCSelection"), 4); // FV0OrA // if we got here, we also finally fill the FT0C histogram, please - histos.fill(HIST("hFT0C_BCs"), multbc.multBCFT0C()); + histos.fill(HIST("hFT0C_BCs"), multbc.multBCFT0C() * scaleSignalFT0C); + histos.fill(HIST("hFT0M_BCs"), (multbc.multBCFT0A() + multbc.multBCFT0C()) * scaleSignalFT0M); + histos.fill(HIST("hFV0A_BCs"), multbc.multBCFV0A() * scaleSignalFV0A); + if (multbc.multBCFT0PosZValid()) { + histos.fill(HIST("hFT0CvsPVz_BCs_All"), multbc.multBCFT0PosZ(), multbc.multBCFT0C() * scaleSignalFT0C); + if (multbc.multBCFT0C() > minFT0CforVertexZ) { + histos.fill(HIST("hFT0CvsPVz_BCs"), multbc.multBCFT0PosZ(), multbc.multBCFT0C() * scaleSignalFT0C); + } + } + + if (multbc.has_ft0Mult()) { + auto multco = multbc.ft0Mult_as>(); + if (multbc.multBCFT0PosZValid()) { + histos.fill(HIST("hVertexZ_BCvsCO"), multco.multPVz(), multbc.multBCFT0PosZ()); + } + } } PROCESS_SWITCH(centralityStudy, processCollisions, "per-collision analysis", false); diff --git a/Common/Tasks/multiplicityQa.cxx b/Common/Tasks/multiplicityQa.cxx index 72fc827606a..3bf0f769b79 100644 --- a/Common/Tasks/multiplicityQa.cxx +++ b/Common/Tasks/multiplicityQa.cxx @@ -402,7 +402,7 @@ struct MultiplicityQa { histos.fill(HIST("multiplicityQa/h2dFT0MVsNchT0M"), nchFT0, biggestFT0); } - void processFIT(aod::MultsBC const& multsdebug) + void processFIT(aod::MultBCs const& multsdebug) { for (auto& mult : multsdebug) { histos.fill(HIST("multiplicityQa/hIsolatedFT0A"), mult.multBCFT0A()); diff --git a/Common/Tasks/qVectorsCorrection.cxx b/Common/Tasks/qVectorsCorrection.cxx index 31c7f2ebbf8..10e37a4c210 100644 --- a/Common/Tasks/qVectorsCorrection.cxx +++ b/Common/Tasks/qVectorsCorrection.cxx @@ -25,6 +25,7 @@ #include #include #include +#include // o2Physics includes. #include "Framework/AnalysisDataModel.h" @@ -37,7 +38,11 @@ #include "Common/DataModel/Qvectors.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" #include "Common/Core/EventPlaneHelper.h" +#include "Common/Core/TrackSelection.h" + +#include "CommonConstants/PhysicsConstants.h" // o2 includes. @@ -45,6 +50,7 @@ using namespace o2; using namespace o2::framework; using MyCollisions = soa::Join; +using MyTracks = soa::Join; struct qVectorsCorrection { // No correction = recenter, recentered Qvectors = twist, twisted Qvectors = rescale. @@ -58,18 +64,36 @@ struct qVectorsCorrection { Configurable> cfgnMods{"cfgnMods", {2, 3}, "Modulation of interest"}; Configurable cfgDetName{"cfgDetName", "FT0C", "The name of detector to be analyzed"}; - Configurable cfgRefAName{"cfgRefAName", "BPos", "The name of detector for reference A"}; - Configurable cfgRefBName{"cfgRefBName", "BNeg", "The name of detector for reference B"}; + Configurable cfgRefAName{"cfgRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgRefBName{"cfgRefBName", "TPCneg", "The name of detector for reference B"}; Configurable cfgAddEvtSel{"cfgAddEvtSel", true, "event selection"}; Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number"}; + Configurable cfgNbinsEP{"cfgNbinsEP", 360, "nbins for EP histograms"}; + + Configurable cfgQAAll{"cfgQAAll", false, "draw all q-vector steps"}; + Configurable cfgQAFinal{"cfgQAFinal", false, "draw final q-vector steps"}; + Configurable cfgQAFlowStudy{"cfgQAFlowStudy", false, "configurable for flow study"}; + Configurable cfgQAOccupancyStudy{"cfgQAOccupancyStudy", false, "configurable for occupancy study"}; + Configurable cfgAddEvtSelPileup{"cfgAddEvtSelPileup", false, "configurable for pileup selection"}; + + 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"}; + + 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"}; ConfigurableAxis cfgaxisQvecF{"cfgaxisQvecF", {300, -1, 1}, ""}; ConfigurableAxis cfgaxisQvec{"cfgaxisQvec", {100, -3, 3}, ""}; - ConfigurableAxis cfgaxisCent{"cfgaxisCent", {90, 0, 90}, ""}; + ConfigurableAxis cfgaxisCent{"cfgaxisCent", {100, 0, 100}, ""}; - Configurable cfgQAAll{"cfgQAAll", false, "draw all q-vector steps"}; - Configurable cfgQAFinal{"cfgQAFinal", false, "draw final q-vector steps"}; + ConfigurableAxis cfgaxiscos{"cfgaxiscos", {102, -1.02, 1.02}, ""}; + ConfigurableAxis cfgaxispt{"cfgaxispt", {100, 0, 10}, ""}; + ConfigurableAxis cfgaxisCentMerged{"cfgaxisCentMerged", {20, 0, 100}, ""}; + ConfigurableAxis cfgaxisAzimuth{"cfgaxisAzimuth", {72, 0, 2.0 * constants::math::PI}, ""}; + ConfigurableAxis cfgaxisOccupancy{"cfgaxisOccupancy", {VARIABLE_WIDTH, -1, 0, 100, 500, 1000, 2000, 3000, 4000, 5000, 10000, 99999}, ""}; // Helper variables. EventPlaneHelper helperEP; @@ -81,6 +105,9 @@ struct qVectorsCorrection { 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") { @@ -89,17 +116,40 @@ struct qVectorsCorrection { return 2; } else if (name.value == "FV0A") { return 3; - } else if (name.value == "BPos") { + } else if (name.value == "TPCpos" || name.value == "BPos") { return 4; - } else if (name.value == "BNeg") { + } else if (name.value == "TPCneg" || name.value == "BNeg") { return 5; - } else if (name.value == "BTot") { + } else if (name.value == "TPCall" || name.value == "BTot") { return 6; } else { return 0; } } + template + bool SelTrack(const TrackType track) + { + if (track.pt() < 0.15) + 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; + } + void init(InitContext const&) { DetId = GetDetId(cfgDetName); @@ -107,7 +157,7 @@ struct qVectorsCorrection { 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 BPos and BNeg 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; @@ -117,12 +167,18 @@ struct qVectorsCorrection { AxisSpec axisCent{cfgaxisCent, "centrality"}; AxisSpec axisQvec{cfgaxisQvec, "Q"}; AxisSpec axisQvecF{cfgaxisQvecF, "Q"}; - AxisSpec axisEvtPl{360, -constants::math::PI, constants::math::PI}; + AxisSpec axisEvtPl{cfgNbinsEP, -constants::math::PI, constants::math::PI}; + + AxisSpec axisCos{cfgaxiscos, "angle function"}; + AxisSpec axisPt{cfgaxispt, "trasverse momentum"}; + AxisSpec axisCentMerged{cfgaxisCentMerged, "merged centrality"}; + AxisSpec axisAzimuth{cfgaxisAzimuth, "relative azimuthal angle"}; + AxisSpec axisOccupancy{cfgaxisOccupancy, "Occupancy"}; histosQA.add("histCentFull", "Centrality distribution for valid events", HistType::kTH1F, {axisCent}); - for (auto i = 0; i < cfgnMods->size(); i++) { + for (uint i = 0; i < cfgnMods->size(); i++) { histosQA.add(Form("histQvecUncorV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); histosQA.add(Form("histQvecRefAUncorV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); histosQA.add(Form("histQvecRefBUncorV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvecF, axisQvecF, axisCent}}); @@ -131,11 +187,27 @@ struct qVectorsCorrection { histosQA.add(Form("histEvtPlRefAUncorV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); histosQA.add(Form("histEvtPlRefBUncorV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); + if (cfgQAOccupancyStudy) { + histosQA.add(Form("histQvecOccUncorV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + histosQA.add(Form("histQvecRefAOccUncorV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + histosQA.add(Form("histQvecRefBOccUncorV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + } + if (cfgQAFinal) { histosQA.add(Form("histQvecFinalV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvec, axisQvec, axisCent}}); histosQA.add(Form("histQvecRefAFinalV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvec, axisQvec, axisCent}}); histosQA.add(Form("histQvecRefBFinalV%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisQvec, axisQvec, axisCent}}); + if (cfgQAOccupancyStudy) { + histosQA.add(Form("histQvecOccFinalV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + histosQA.add(Form("histQvecRefAOccFinalV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + histosQA.add(Form("histQvecRefBOccFinalV%d", cfgnMods->at(i)), "", {HistType::kTHnSparseF, {axisQvecF, axisQvecF, axisCent, axisOccupancy}}); + } + + histosQA.add(Form("histQvecRes_SigRefAV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("histQvecRes_SigRefBV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("histQvecRes_RefARefBV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisQvecF, axisCent}}); + histosQA.add(Form("histEvtPlFinalV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); histosQA.add(Form("histEvtPlRefAFinalV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); histosQA.add(Form("histEvtPlRefBFinalV%d", cfgnMods->at(i)), "", {HistType::kTH2F, {axisEvtPl, axisCent}}); @@ -144,6 +216,18 @@ struct qVectorsCorrection { 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(Form("hist_EP_cos_Det_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_sin_Det_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_azimuth_Det_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisAzimuth}}); + + histosQA.add(Form("hist_EP_cos_RefA_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_sin_RefA_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_azimuth_RefA_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisAzimuth}}); + + histosQA.add(Form("hist_EP_cos_RefB_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_sin_RefB_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisCos}}); + histosQA.add(Form("hist_EP_azimuth_RefB_v%d", cfgnMods->at(i)), "", {HistType::kTH3F, {axisCentMerged, axisPt, axisAzimuth}}); + if (cfgQAAll) { 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}}); @@ -167,6 +251,65 @@ struct qVectorsCorrection { } } // End void init(InitContext const&) + template + void fillHistosFlow(const CollType& coll, const TrackType& track, int nmode) + { + if (coll.qvecAmp()[DetId] < 1e-8 || coll.qvecAmp()[RefAId] < 1e-8 || coll.qvecAmp()[RefBId] < 1e-8) { + return; + } + int DetInd = DetId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int RefAInd = RefAId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + int RefBInd = RefBId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + for (auto& trk : track) { + if (!SelTrack(trk)) { + continue; + } + + if (std::abs(trk.eta()) > 0.8) { + continue; + } + + if (nmode == 2) { + histosQA.fill(HIST("hist_EP_cos_Det_v2"), coll.cent(), trk.pt(), std::cos(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_Det_v2"), coll.cent(), trk.pt(), std::sin(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_Det_v2"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefA_v2"), coll.cent(), trk.pt(), std::cos(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefA_v2"), coll.cent(), trk.pt(), std::sin(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefA_v2"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefB_v2"), coll.cent(), trk.pt(), std::cos(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefB_v2"), coll.cent(), trk.pt(), std::sin(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefB_v2"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(2.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + } else if (nmode == 3) { + histosQA.fill(HIST("hist_EP_cos_Det_v3"), coll.cent(), trk.pt(), std::cos(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_Det_v3"), coll.cent(), trk.pt(), std::sin(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_Det_v3"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefA_v3"), coll.cent(), trk.pt(), std::cos(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefA_v3"), coll.cent(), trk.pt(), std::sin(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefA_v3"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefB_v3"), coll.cent(), trk.pt(), std::cos(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefB_v3"), coll.cent(), trk.pt(), std::sin(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefB_v3"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(3.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + } else if (nmode == 4) { + histosQA.fill(HIST("hist_EP_cos_Det_v4"), coll.cent(), trk.pt(), std::cos(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_Det_v4"), coll.cent(), trk.pt(), std::sin(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_Det_v4"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[DetInd + 3], coll.qvecIm()[DetInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefA_v4"), coll.cent(), trk.pt(), std::cos(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefA_v4"), coll.cent(), trk.pt(), std::sin(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefA_v4"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefAInd + 3], coll.qvecIm()[RefAInd + 3], nmode)))); + + histosQA.fill(HIST("hist_EP_cos_RefB_v4"), coll.cent(), trk.pt(), std::cos(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_sin_RefB_v4"), coll.cent(), trk.pt(), std::sin(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + histosQA.fill(HIST("hist_EP_azimuth_RefB_v4"), coll.cent(), trk.pt(), TVector2::Phi_0_2pi(4.0 * (trk.phi() - helperEP.GetEventPlane(coll.qvecRe()[RefBInd + 3], coll.qvecIm()[RefBInd + 3], nmode)))); + } + } + } + // Definition of all the needed template functions. template void fillHistosQvec(const T& vec, int nmode) @@ -178,9 +321,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[DetId] > 1e-8) { histosQA.fill(HIST("histQvecUncorV2"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent()); histosQA.fill(HIST("histEvtPlUncorV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccUncorV2"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecFinalV2"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlFinalV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccFinalV2"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRectrV2"), vec.qvecRe()[DetInd + 1], vec.qvecIm()[DetInd + 1], vec.cent()); histosQA.fill(HIST("histQvecTwistV2"), vec.qvecRe()[DetInd + 2], vec.qvecIm()[DetInd + 2], vec.cent()); @@ -193,9 +342,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefAId] > 1e-8) { histosQA.fill(HIST("histQvecRefAUncorV2"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefAUncorV2"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccUncorV2"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefAFinalV2"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefAFinalV2"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccFinalV2"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefARectrV2"), vec.qvecRe()[RefAInd + 1], vec.qvecIm()[RefAInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefATwistV2"), vec.qvecRe()[RefAInd + 2], vec.qvecIm()[RefAInd + 2], vec.cent()); @@ -208,9 +363,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefBId] > 1e-8) { histosQA.fill(HIST("histQvecRefBUncorV2"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefBUncorV2"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccUncorV2"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefBFinalV2"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefBFinalV2"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccFinalV2"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefBRectrV2"), vec.qvecRe()[RefBInd + 1], vec.qvecIm()[RefBInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefBTwistV2"), vec.qvecRe()[RefBInd + 2], vec.qvecIm()[RefBInd + 2], vec.cent()); @@ -221,6 +382,10 @@ struct qVectorsCorrection { } } if (vec.qvecAmp()[DetId] > 1e-8 && vec.qvecAmp()[RefAId] > 1e-8 && vec.qvecAmp()[RefBId] > 1e-8 && cfgQAFinal) { + histosQA.fill(HIST("histQvecRes_SigRefAV2"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefAInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefAInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_SigRefBV2"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_RefARefBV2"), vec.qvecRe()[RefAInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[RefAInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefAV2"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_SigRefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_RefARefBV2"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); @@ -229,7 +394,13 @@ struct qVectorsCorrection { if (vec.qvecAmp()[DetId] > 1e-8) { histosQA.fill(HIST("histQvecUncorV3"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent()); histosQA.fill(HIST("histEvtPlUncorV3"), helperEP.GetEventPlane(vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccUncorV3"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccFinalV3"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } histosQA.fill(HIST("histQvecFinalV3"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlFinalV3"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), vec.cent()); if (cfgQAAll) { @@ -244,9 +415,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefAId] > 1e-8) { histosQA.fill(HIST("histQvecRefAUncorV3"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefAUncorV3"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccUncorV3"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefAFinalV3"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefAFinalV3"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccFinalV3"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefARectrV3"), vec.qvecRe()[RefAInd + 1], vec.qvecIm()[RefAInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefATwistV3"), vec.qvecRe()[RefAInd + 2], vec.qvecIm()[RefAInd + 2], vec.cent()); @@ -259,9 +436,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefBId] > 1e-8) { histosQA.fill(HIST("histQvecRefBUncorV3"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefBUncorV3"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccUncorV3"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefBFinalV3"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefBFinalV3"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccFinalV3"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefBRectrV3"), vec.qvecRe()[RefBInd + 1], vec.qvecIm()[RefBInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefBTwistV3"), vec.qvecRe()[RefBInd + 2], vec.qvecIm()[RefBInd + 2], vec.cent()); @@ -272,6 +455,10 @@ struct qVectorsCorrection { } } if (vec.qvecAmp()[DetId] > 1e-8 && vec.qvecAmp()[RefAId] > 1e-8 && vec.qvecAmp()[RefBId] > 1e-8 && cfgQAFinal) { + histosQA.fill(HIST("histQvecRes_SigRefAV3"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefAInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefAInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_SigRefBV3"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_RefARefBV3"), vec.qvecRe()[RefAInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[RefAInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefAV3"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_SigRefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_RefARefBV3"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); @@ -280,9 +467,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[DetId] > 1e-8) { histosQA.fill(HIST("histQvecUncorV4"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent()); histosQA.fill(HIST("histEvtPlUncorV4"), helperEP.GetEventPlane(vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccUncorV4"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecFinalV4"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlFinalV4"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecOccFinalV4"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRectrV4"), vec.qvecRe()[DetInd + 1], vec.qvecIm()[DetInd + 1], vec.cent()); histosQA.fill(HIST("histQvecTwistV4"), vec.qvecRe()[DetInd + 2], vec.qvecIm()[DetInd + 2], vec.cent()); @@ -295,9 +488,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefAId] > 1e-8) { histosQA.fill(HIST("histQvecRefAUncorV4"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefAUncorV4"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccUncorV4"), vec.qvecRe()[RefAInd], vec.qvecIm()[RefAInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefAFinalV4"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefAFinalV4"), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefAOccFinalV4"), vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefARectrV4"), vec.qvecRe()[RefAInd + 1], vec.qvecIm()[RefAInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefATwistV4"), vec.qvecRe()[RefAInd + 2], vec.qvecIm()[RefAInd + 2], vec.cent()); @@ -310,9 +509,15 @@ struct qVectorsCorrection { if (vec.qvecAmp()[RefBId] > 1e-8) { histosQA.fill(HIST("histQvecRefBUncorV4"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent()); histosQA.fill(HIST("histEvtPlRefBUncorV4"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccUncorV4"), vec.qvecRe()[RefBInd], vec.qvecIm()[RefBInd], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAFinal) { histosQA.fill(HIST("histQvecRefBFinalV4"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent()); histosQA.fill(HIST("histEvtPlRefBFinalV4"), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), vec.cent()); + if (cfgQAOccupancyStudy) { + histosQA.fill(HIST("histQvecRefBOccFinalV4"), vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], vec.cent(), vec.trackOccupancyInTimeRange()); + } if (cfgQAAll) { histosQA.fill(HIST("histQvecRefBRectrV4"), vec.qvecRe()[RefBInd + 1], vec.qvecIm()[RefBInd + 1], vec.cent()); histosQA.fill(HIST("histQvecRefBTwistV4"), vec.qvecRe()[RefBInd + 2], vec.qvecIm()[RefBInd + 2], vec.cent()); @@ -323,13 +528,17 @@ struct qVectorsCorrection { } } if (vec.qvecAmp()[DetId] > 1e-8 && vec.qvecAmp()[RefAId] > 1e-8 && vec.qvecAmp()[RefBId] > 1e-8 && cfgQAFinal) { + histosQA.fill(HIST("histQvecRes_SigRefAV4"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefAInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefAInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_SigRefBV4"), vec.qvecRe()[DetInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[DetInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histQvecRes_RefARefBV4"), vec.qvecRe()[RefAInd + 3] * vec.qvecRe()[RefBInd + 3] + vec.qvecIm()[RefAInd + 3] * vec.qvecIm()[RefBInd + 3], vec.cent()); + histosQA.fill(HIST("histEvtPlRes_SigRefAV4"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_SigRefBV4"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); histosQA.fill(HIST("histEvtPlRes_RefARefBV4"), helperEP.GetResolution(helperEP.GetEventPlane(vec.qvecRe()[RefAInd + 3], vec.qvecIm()[RefAInd + 3], nmode), helperEP.GetEventPlane(vec.qvecRe()[RefBInd + 3], vec.qvecIm()[RefBInd + 3], nmode), nmode), vec.cent()); } } } - void process(MyCollisions::iterator const& qVec) + void process(MyCollisions::iterator const& qVec, MyTracks const& tracks) { histosQA.fill(HIST("histCentFull"), qVec.cent()); if (cfgAddEvtSel && (!qVec.sel8() || @@ -337,8 +546,18 @@ struct qVectorsCorrection { !qVec.selection_bit(aod::evsel::kNoSameBunchPileup))) { return; } - for (auto i = 0; i < cfgnMods->size(); i++) { + if (cfgAddEvtSel && (qVec.trackOccupancyInTimeRange() > cfgMaxOccupancy || qVec.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + return; + } + if (cfgAddEvtSelPileup && !qVec.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return; + } + + for (uint i = 0; i < cfgnMods->size(); i++) { fillHistosQvec(qVec, cfgnMods->at(i)); + if (cfgQAFinal && cfgQAFlowStudy) { + fillHistosFlow(qVec, tracks, cfgnMods->at(i)); + } } } // End void process(...) }; diff --git a/Common/Tools/CMakeLists.txt b/Common/Tools/CMakeLists.txt index 5140596629d..29950466a85 100644 --- a/Common/Tools/CMakeLists.txt +++ b/Common/Tools/CMakeLists.txt @@ -12,9 +12,9 @@ add_subdirectory(Multiplicity) add_subdirectory(PID) -o2physics_add_executable(aod-data-model-graph - SOURCES aodDataModelGraph.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) +#o2physics_add_executable(aod-data-model-graph +# SOURCES aodDataModelGraph.cxx +# PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) o2physics_add_library(trackSelectionRequest SOURCES trackSelectionRequest.cxx diff --git a/Common/Tools/TrackTuner.h b/Common/Tools/TrackTuner.h index 0d5d8452c68..4d6876eaf39 100644 --- a/Common/Tools/TrackTuner.h +++ b/Common/Tools/TrackTuner.h @@ -37,6 +37,7 @@ #include "DetectorsBase/GeometryManager.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" #include "Framework/RunningWorkflowInfo.h" @@ -49,13 +50,34 @@ namespace o2::aod namespace track_tuner { DECLARE_SOA_COLUMN(TunedQOverPt, tunedQOverPt, float); + +/// configuration source +enum configSource : int { InputString = 1, + Configurables }; } // namespace track_tuner DECLARE_SOA_TABLE(TrackTunerTable, "AOD", "TRACKTUNERTABLE", //! track_tuner::TunedQOverPt); } // namespace o2::aod -struct TrackTuner { +struct TrackTuner : o2::framework::ConfigurableGroup { + + std::string prefix = "trackTuner"; // JSON group name + o2::framework::Configurable cfgDebugInfo{"debugInfo", false, "Flag to switch on the debug printout"}; + o2::framework::Configurable cfgUpdateTrackDCAs{"updateTrackDCAs", false, "Flag to enable the DCA smearing"}; + o2::framework::Configurable cfgUpdateTrackCovMat{"updateTrackCovMat", false, "Flag to enable the DCA covariance-matrix smearing"}; + o2::framework::Configurable cfgUpdateCurvature{"updateCurvature", false, "Flag to enable the Q/Pt smearing after the propagation to the production point"}; + o2::framework::Configurable cfgUpdateCurvatureIU{"updateCurvatureIU", false, "Flag to enable the Q/Pt smearing before the propagation to the production point"}; + o2::framework::Configurable cfgUpdatePulls{"updatePulls", false, "Flag to enable the pulls smearing"}; + o2::framework::Configurable cfgIsInputFileFromCCDB{"isInputFileFromCCDB", false, "True: files from CCDB; False: fils from local path (debug)"}; + o2::framework::Configurable cfgPathInputFile{"pathInputFile", "", "Path to file containing DCAxy, DCAz graphs from data and MC"}; + o2::framework::Configurable cfgNameInputFile{"nameInputFile", "", "Name of the file containing DCAxy, DCAz graphs from data and MC"}; + o2::framework::Configurable cfgPathFileQoverPt{"pathFileQoverPt", "", "Path to file containing Q/Pt correction graphs from data and MC"}; + o2::framework::Configurable cfgNameFileQoverPt{"nameFileQoverPt", "", "Name of file containing Q/Pt correction graphs from data and MC"}; + 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"}; + /////////////////////////////// /// parameters to be configured bool debugInfo = false; @@ -66,13 +88,15 @@ struct TrackTuner { bool updatePulls = false; bool isInputFileFromCCDB = false; // query input file from CCDB or local folder std::string pathInputFile = ""; // Path to file containing DCAxy, DCAz graphs from data and MC - std::string nameInputFile = ""; // Common Name of different files containing graphs, found in the above paths - std::string pathFileQoverPt = ""; // Path to file containing D0 sigma graphs from data and MC + std::string nameInputFile = ""; // Name of the file containing DCAxy, DCAz graphs from data and MC + std::string pathFileQoverPt = ""; // Path to file containing Q/Pt correction graphs from data and MC (only one proxy provided, i.e. D0 sigma graphs from data and MC) std::string nameFileQoverPt = ""; // file name containing Q/Pt correction graphs from data and MC bool usePvRefitCorrections = false; // establish whether to use corrections obtained with or w/o PV refit - float qOverPtMC = -1.; // 1/pt old - float qOverPtData = -1.; // 1/pt new + float qOverPtMC = -1.; // 1/pt MC + float qOverPtData = -1.; // 1/pt data /////////////////////////////// + bool isConfigFromString = false; + bool isConfigFromConfigurables = false; o2::ccdb::CcdbApi ccdbApi; std::map metadata; @@ -98,11 +122,31 @@ struct TrackTuner { std::unique_ptr grDcaZPullVsPtPionMC; std::unique_ptr grDcaZPullVsPtPionData; - /// @brief Function to configure the TrackTuner parameters + /// @brief Function doing a few sanity-checks on the configurations + void checkConfig() + { + /// check configuration source + if (isConfigFromString && isConfigFromConfigurables) { + LOG(fatal) << " [ isConfigFromString==kTRUE and isConfigFromConfigurables==kTRUE ] Configuration done both via string and via configurables -> Only one of them can be set to kTRUE at once! Please refer to the trackTuner documentation."; + } + /// check Q/pt update + if ((updateCurvatureIU) && (updateCurvature)) { + LOG(fatal) << " [ updateCurvatureIU==kTRUE and updateCurvature==kTRUE ] -> Only one of them can be set to kTRUE at once! Please refer to the trackTuner documentation."; + } + } + + /// @brief Function to configure the TrackTuner parameters with an input string /// @param inputString Input string with all parameter configuration. Format: =|= /// @return String with the values of all parameters after configurations are listed, to cross check that everything worked well std::string configParams(std::string inputString) { + + LOG(info) << "[TrackTuner] /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/"; + LOG(info) << "[TrackTuner] /*/*/ /*/*/"; + LOG(info) << "[TrackTuner] /*/*/ Configuring the TrackTuner via a string /*/*/"; + LOG(info) << "[TrackTuner] /*/*/ /*/*/"; + LOG(info) << "[TrackTuner] /*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/"; + std::string delimiter = "|"; std::string assignmentSymbol = "="; @@ -167,7 +211,7 @@ struct TrackTuner { LOG(info) << "[TrackTuner]"; LOG(info) << "[TrackTuner] >>> Parameters before the custom settings"; LOG(info) << "[TrackTuner] debugInfo = " << debugInfo; - LOG(info) << "[TrackTuner] updateTrackDCAs = " << UpdateTrackDCAs; + LOG(info) << "[TrackTuner] updateTrackDCAs = " << updateTrackDCAs; LOG(info) << "[TrackTuner] updateTrackCovMat = " << updateTrackCovMat; LOG(info) << "[TrackTuner] updateCurvature = " << updateCurvature; LOG(info) << "[TrackTuner] updateCurvatureIU = " << updateCurvatureIU; @@ -294,9 +338,91 @@ struct TrackTuner { outputString += ", qOverPtData=" + std::to_string(qOverPtData); LOG(info) << "[TrackTuner] qOverPtData = " << qOverPtData; - if ((updateCurvatureIU) && (updateCurvature)) { - LOG(fatal) << " [ updateCurvatureIU==kTRUE and updateCurvature==kTRUE ] -> Only one of them can be set to kTRUE at once! Please refer to the trackTuner documentation."; - } + /// declare that the configuration is done via an input string + isConfigFromString = true; + + /// sanity-checks on the configurations + checkConfig(); + + return outputString; + } + + /// @brief Function to configure the TrackTuner parameters with an input string + /// @return String with the values of all parameters after configurations are listed, to cross check that everything worked well + std::string configParams() + { + + LOG(info) << "[TrackTuner] /=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#"; + LOG(info) << "[TrackTuner] /=/#/ /=/#/"; + LOG(info) << "[TrackTuner] /=/#/ Configuring the TrackTuner using the input Configurables /=/#/"; + LOG(info) << "[TrackTuner] /=/#/ /=/#/"; + LOG(info) << "[TrackTuner] /=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/=/#/"; + + std::string outputString = ""; + LOG(info) << "[TrackTuner] "; + LOG(info) << "[TrackTuner] >>> Parameters after the custom settings"; + // Configure debugInfo + debugInfo = cfgDebugInfo; + LOG(info) << "[TrackTuner] debugInfo = " << debugInfo; + outputString += "debugInfo=" + std::to_string(debugInfo); + // Configure updateTrackDCAs + updateTrackDCAs = cfgUpdateTrackDCAs; + LOG(info) << "[TrackTuner] updateTrackDCAs = " << updateTrackDCAs; + outputString += ", updateTrackDCAs=" + std::to_string(updateTrackDCAs); + // Configure updateTrackCovMat + updateTrackCovMat = cfgUpdateTrackCovMat; + LOG(info) << "[TrackTuner] updateTrackCovMat = " << updateTrackCovMat; + outputString += ", updateTrackCovMat=" + std::to_string(updateTrackCovMat); + // Configure updateCurvature + updateCurvature = cfgUpdateCurvature; + LOG(info) << "[TrackTuner] updateCurvature = " << updateCurvature; + outputString += ", updateCurvature=" + std::to_string(updateCurvature); + // Configure updateCurvatureIU + updateCurvatureIU = cfgUpdateCurvatureIU; + LOG(info) << "[TrackTuner] updateCurvatureIU = " << updateCurvatureIU; + outputString += ", updateCurvatureIU=" + std::to_string(updateCurvatureIU); + // Configure updatePulls + updatePulls = cfgUpdatePulls; + LOG(info) << "[TrackTuner] updatePulls = " << updatePulls; + outputString += ", updatePulls=" + std::to_string(updatePulls); + // Configure isInputFileFromCCDB + isInputFileFromCCDB = cfgIsInputFileFromCCDB; + LOG(info) << "[TrackTuner] isInputFileFromCCDB = " << isInputFileFromCCDB; + outputString += ", isInputFileFromCCDB=" + std::to_string(isInputFileFromCCDB); + // Configure pathInputFile + pathInputFile = cfgPathInputFile; + outputString += ", pathInputFile=" + pathInputFile; + LOG(info) << "[TrackTuner] pathInputFile = " << pathInputFile; + // Configure pathInputFile + pathFileQoverPt = cfgPathFileQoverPt; + outputString += ", pathFileQoverPt=" + pathFileQoverPt; + LOG(info) << "[TrackTuner] pathFileQoverPt = " << pathFileQoverPt; + // Configure nameInputFile + nameInputFile = cfgNameInputFile; + outputString += ", nameInputFile=" + nameInputFile; + LOG(info) << "[TrackTuner] nameInputFile = " << nameInputFile; + // Configure nameFileQoverPt + nameFileQoverPt = cfgNameFileQoverPt; + outputString += ", nameFileQoverPt=" + nameFileQoverPt; + LOG(info) << "[TrackTuner] nameFileQoverPt = " << nameFileQoverPt; + // Configure usePvRefitCorrections + usePvRefitCorrections = cfgUsePvRefitCorrections; + outputString += ", usePvRefitCorrections=" + std::to_string(usePvRefitCorrections); + LOG(info) << "[TrackTuner] usePvRefitCorrections = " << usePvRefitCorrections; + // Configure qOverPtMC + qOverPtMC = cfgQOverPtMC; + outputString += ", qOverPtMC=" + std::to_string(qOverPtMC); + LOG(info) << "[TrackTuner] qOverPtMC = " << qOverPtMC; + // Configure qOverPtData + qOverPtData = cfgQOverPtData; + outputString += ", qOverPtData=" + std::to_string(qOverPtData); + LOG(info) << "[TrackTuner] qOverPtData = " << qOverPtData; + + /// declare that the configuration is done via the Configurables + isConfigFromConfigurables = true; + + /// sanity-checks on the configurations + checkConfig(); return outputString; } @@ -431,7 +557,7 @@ struct TrackTuner { qOverPtMC = std::max(0.0, evalGraph(ptMC, grOneOverPtPionMC.get())); qOverPtData = std::max(0.0, evalGraph(ptMC, grOneOverPtPionData.get())); } // qOverPtMC, qOverPtData block ends here - } // updateCurvature, updateCurvatureIU block ends here + } // updateCurvature, updateCurvatureIU block ends here if (updateTrackDCAs) { dcaXYMeanMC = evalGraph(ptMC, grDcaXYMeanVsPtPionMC.get()); @@ -586,7 +712,7 @@ struct TrackTuner { double trackParDcaZTuned = trackParDcaZMC + deltaDcaZTuned; // double dd0rpo=d0rpo-d0rpmc; - double deltaDcaXY = trackParDcaXYRec - trackParDcaXYMC; + double deltaDcaXY = trackParDcaXYRec - trackParDcaXYMC - dcaXYMeanMC; // double dd0rpn=dd0rpo*(sd0rpo>0. ? (sd0rpn/sd0rpo) : 1.); double deltaDcaXYTuned = deltaDcaXY * (dcaXYResMC > 0. ? (dcaXYResData / dcaXYResMC) : 1.); @@ -600,7 +726,7 @@ struct TrackTuner { if (debugInfo) { LOG(info) << dcaZResMC << ", " << dcaZResData << ", diff(DcaZ - DcaZMC): " << deltaDcaZ << ", diff upgraded: " << deltaDcaZTuned << ", DcaZ Data : " << trackParDcaZTuned; - LOG(info) << dcaXYResMC << ", " << dcaXYResData << ", diff(DcaY - DcaYMC): " << deltaDcaXY << ", diff upgraded: " << deltaDcaXYTuned << ", DcaY Data :" << trackParDcaXYTuned; + LOG(info) << dcaXYResMC << ", " << dcaXYResData << ", " << dcaXYMeanMC << ", diff(DcaY - DcaYMC - dcaXYMeanMC): " << deltaDcaXY << ", diff upgraded: " << deltaDcaXYTuned << ", DcaY Data :" << trackParDcaXYTuned; } // option mimic data // ---------------------- @@ -720,7 +846,7 @@ struct TrackTuner { trackParCov.setCov(sigma1Pt2, 14); } } // ---> track cov matrix elements for 1/Pt ends here - } // ---> updateTrackCovMat block ends here + } // ---> updateTrackCovMat block ends here if (updatePulls) { double ratioDCAxyPulls = 1.0; diff --git a/DPG/Tasks/AOTEvent/CMakeLists.txt b/DPG/Tasks/AOTEvent/CMakeLists.txt index 97476f860a4..3c537de6b47 100644 --- a/DPG/Tasks/AOTEvent/CMakeLists.txt +++ b/DPG/Tasks/AOTEvent/CMakeLists.txt @@ -28,8 +28,18 @@ o2physics_add_dpl_workflow(detector-occupancy-qa SOURCES detectorOccupancyQa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(rof-border-qa SOURCES rofBorderQa.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(matching-qa + SOURCES matchingQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(rof-occupancy-qa + SOURCES rofOccupancyQa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2::DetectorsBase + COMPONENT_NAME Analysis) diff --git a/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx b/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx index b41bc1faef4..81bf34ae73c 100644 --- a/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx +++ b/DPG/Tasks/AOTEvent/detectorOccupancyQa.cxx @@ -9,6 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include #include "map" #include "Framework/runDataProcessing.h" @@ -26,6 +27,7 @@ #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" @@ -39,7 +41,8 @@ using BCsRun2 = soa::Join; // using ColEvSels = soa::Join; using ColEvSels = soa::Join; -using FullTracksIU = soa::Join; +// using FullTracksIU = soa::Join; +using FullTracksIU = soa::Join; struct DetectorOccupancyQaTask { // configurables for study of occupancy in time windows @@ -78,6 +81,8 @@ struct DetectorOccupancyQaTask { Configurable nBinsOccupancy{"nBinsOccupancy", 150, "N bins for occupancy axis"}; Configurable nMaxOccupancy{"nMaxOccupancy", 15000, "N for max of the occupancy axis"}; + Configurable nMaxBcInTFforAnalysis{"nMaxBcInTFforAnalysis", -1, "When to stop taking collisions in TF, if -1: take all collisions"}; + uint64_t minGlobalBC = 0; Service ccdb; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -101,21 +106,15 @@ struct DetectorOccupancyQaTask { ccdb->setCaching(true); 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}); + // histograms for occupancy-in-time-window study double kMaxOccup = confOccupancyHistCoeffNtracksForOccupancy; double kMaxThisEv = confCoeffMaxNtracksThisEvent; - AxisSpec axisBC{3601, -0.5, 3600.5, "bc"}; - histos.add("h2D_diff_FoundBC_vs_BC", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_multAbove10", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_multAbove20", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_multAbove50", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_multAbove100", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_hasTOF", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_hasTRD", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_hasTOF_multAbove10", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - histos.add("h2D_diff_FoundBC_vs_BC_hasTRD_multAbove10", "", kTH2D, {axisBC, {201, -100.5, 100.5, "foundBC-BC"}}); - + // 1D, dE/dx, etc. if (confAddBasicQAhistos) { int nMax1D = kMaxThisEv * 8000; histos.add("hNumITS567tracksPerCollision", ";n tracks;n events", kTH1D, {{nMax1D, -0.5, nMax1D - 0.5}}); @@ -132,8 +131,72 @@ struct DetectorOccupancyQaTask { histos.add("hNumCollInTimeWindowSel", ";n collisions;n events", kTH1D, {{201, -0.5, 200.5}}); histos.add("hNumCollInTimeWindowSelITSTPC", ";n collisions;n events", kTH1D, {{201, -0.5, 200.5}}); histos.add("hNumCollInTimeWindowSelIfTOF", ";n collisions;n events", kTH1D, {{201, -0.5, 200.5}}); + histos.add("hNumCollInTimeWindowVsOrbit", ";orbit id;n collisions;n events", kTH2F, {{128, -0.5, 127.5}, {201, -0.5, 200.5}}); histos.add("hNumUniqueBCInTimeWindow", ";n collisions;n events", kTH1D, {{201, -0.5, 200.5}}); + + // 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 axisBinsOccupStudy_dEdx{{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.)"}, axisBinsOccupStudy_dEdx}); + 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.)"}, axisBinsOccupStudy_dEdx}); + 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.)"}, axisBinsOccupStudy_dEdx}); + + 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.)"}}); + + // ### 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; + histos.add("track_distr_nITStrThisEv_10_200/hPhi_lowOccupInTPC", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInRecentPast", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInCloseFuture", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInDistantFuture", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_10_200/hPhi_highOccupInNeighbourEvents", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + + histos.add("track_distr_nITStrThisEv_above_2000/hPhi_lowOccupInTPC", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInRecentPast", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInCloseFuture", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInDistantFuture", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + histos.add("track_distr_nITStrThisEv_above_2000/hPhi_highOccupInNeighbourEvents", ";#varphi;n tracks", kTH1D, {{nPhiBins, 0, TMath::TwoPi()}}); + + // const int nPtBins = 800; + AxisSpec axisLogPt{200, 0.05, 40, "p_{T}"}; + axisLogPt.makeLogarithmic(); + histos.add("track_distr_nITStrThisEv_10_200/hPt_lowOccupInTPC", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_10_200/hPt_highOccupInRecentPast", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_10_200/hPt_highOccupInCloseFuture", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_10_200/hPt_highOccupInDistantFuture", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_10_200/hPt_highOccupInNeighbourEvents", ";p_{T};n tracks", kTH1D, {axisLogPt}); + + histos.add("track_distr_nITStrThisEv_above_2000/hPt_lowOccupInTPC", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_above_2000/hPt_highOccupInRecentPast", ";p_{T};n tracks", kTH1D, {axisLogPt}); + histos.add("track_distr_nITStrThisEv_above_2000/hPt_highOccupInCloseFuture", ";p_{T};n tracks", kTH1D, {axisLogPt}); + 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}); + + // 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}); } // 2D int nBins3D = 80 * confOccupancyHistCoeffNbins3D; @@ -156,8 +219,15 @@ struct DetectorOccupancyQaTask { histos.add("hNumITSTPCtracks_vs_ITS567tracks_ThisEvent", ";n ITS tracks with 5,6,7 hits;n ITS-TPC tracks", kTH2D, {{nBins2D, 0, kMaxThisEv * 8000}, {nBins2D, 0, kMaxThisEv * 8000}}); // 3D - histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow", ";n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); + histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_ITS567tracksInTimeWindow_BEFORE_sel", ";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", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 25000}}); + histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow_BEFORE_sel", ";n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); + histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_ITS567tracksInTimeWindow", ";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", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 25000}}); + histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow", ";n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); + histos.add("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow", ";n ITS tracks with 5,6,7 cls, this collision;n ITS-TPC tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); + + histos.add("hNumITSTPC_vs_FT0CthisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow", ";FT0C this collision;n ITS-TPC tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 80000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); + histos.add("hNumITS567_vs_FT0CthisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow", ";FT0C this collision;n ITS567cls tracks, this collision;FT0C ampl. sum in time window", kTH3D, {{nBins3D, 0, kMaxThisEv * 80000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 250000}}); } // nD, time bins to cover the range -confTimeIntervalForSmallBins... +confTimeIntervalForSmallBins (us) double timeBinSize = 2 * confTimeIntervalForSmallBins / confNumberOfSmallTimeBins; @@ -165,68 +235,77 @@ struct DetectorOccupancyQaTask { for (int i = 0; i < confNumberOfSmallTimeBins + 1; i++) arrTimeBins.push_back(-confTimeIntervalForSmallBins + i * timeBinSize); const AxisSpec axisTimeBins{arrTimeBins, "#Delta t, #mus"}; - 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, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3D, 0, kMaxThisEv * 8000}, {nBins3DoccupancyAxis, 0, kMaxOccup * 10000}}); + 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}}); + histos.add("thisEventITStracksInTimeBins", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); histos.add("thisEventITSTPCtracksInTimeBins", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); + histos.add("thisEventFT0CInTimeBins", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); + + histos.add("qaForHighOccupITStracksInTimeBinPast", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); + histos.add("qaForHighOccupITStracksInTimeBinFuture1", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); + histos.add("qaForHighOccupITStracksInTimeBinFuture2", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); + histos.add("qaForHighOccupITStracksForNeighbourEvents", ";time bin (#mus);n tracks", kTH1F, {axisTimeBins}); // save dt information for several first collisions for QA histos.add("histOccupInTimeBinsQA", ";dt;this coll id", kTH2F, {axisTimeBins, {nCollisionsForTimeBinQA, -0.5, nCollisionsForTimeBinQA - 0.5}}); // QA of occupancy-based event selection histos.add("hOccupancy", "", kTH1D, {{15002, -1.5, 15000.5}}); + histos.add("hOccupancyVsOrbit", ";orbit id;weighted occupancy;n events", kTH2F, {{128, -0.5, 127.5}, {600, 0, 15000}}); - AxisSpec axisOccupancy{nBinsOccupancy, 0., nMaxOccupancy, "occupancy (n ITS tracks weighted)"}; + AxisSpec axisOccupancyTracks{nBinsOccupancy, 0., nMaxOccupancy, "occupancy (n ITS tracks weighted)"}; AxisSpec axisCentrality{100, 0, 100, "centrality, %"}; - histos.add("hCentrVsOccupancy", "hCentrVsOccupancy", kTH2F, {axisCentrality, axisOccupancy}); + 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"}; AxisSpec axisNtracksGlobal{nBinsTracks, -0.5, nMaxGlobalTracks - 0.5, "n tracks"}; - AxisSpec axisMultFw{nBinsMultFwd, 0., static_cast(nMaxMultFwd), "mult Fwd"}; - - histos.add("nTracksPV_vs_V0A_kNoHighOccupancyAgressive", "nTracksPV_vs_V0A_kNoHighOccupancyAgressive", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoHighOccupancyStrict", "nTracksPV_vs_V0A_kNoHighOccupancyStrict", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoHighOccupancyMedium", "nTracksPV_vs_V0A_kNoHighOccupancyMedium", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoHighOccupancyRelaxed", "nTracksPV_vs_V0A_kNoHighOccupancyRelaxed", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoHighOccupancyGentle", "nTracksPV_vs_V0A_kNoHighOccupancyGentle", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_kNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_250", "nTracksPV_vs_V0A_occup_0_250", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_500", "nTracksPV_vs_V0A_occup_0_500", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_750", "nTracksPV_vs_V0A_occup_0_750", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_noOccupSel", "nTracksPV_vs_V0A_noOccupSel", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_ABOVE_750", "nTracksPV_vs_V0A_occup_ABOVE_750", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_occup_Minus1", "nTracksPV_vs_V0A_occup_Minus1", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_AntiNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_AntiNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracks}); - histos.add("nTracksPV_vs_V0A_AntiNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_AntiNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracks}); - - histos.add("nTracksGlobal_vs_V0A_kNoHighOccupancyAgressive", "nTracksGlobal_vs_V0A_kNoHighOccupancyAgressive", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoHighOccupancyStrict", "nTracksGlobal_vs_V0A_kNoHighOccupancyStrict", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoHighOccupancyMedium", "nTracksGlobal_vs_V0A_kNoHighOccupancyMedium", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoHighOccupancyRelaxed", "nTracksGlobal_vs_V0A_kNoHighOccupancyRelaxed", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoHighOccupancyGentle", "nTracksGlobal_vs_V0A_kNoHighOccupancyGentle", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_kNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_kNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_250", "nTracksGlobal_vs_V0A_occup_0_250", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_500", "nTracksGlobal_vs_V0A_occup_0_500", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_750", "nTracksGlobal_vs_V0A_occup_0_750", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_noOccupSel", "nTracksGlobal_vs_V0A_noOccupSel", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_ABOVE_750", "nTracksGlobal_vs_V0A_occup_ABOVE_750", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_occup_Minus1", "nTracksGlobal_vs_V0A_occup_Minus1", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeStandard", kTH2F, {axisMultFw, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeNarrow", kTH2F, {axisMultFw, axisNtracksGlobal}); - - histos.add("nTracksGlobal_vs_nPV_kNoHighOccupancyAgressive", "nTracksGlobal_vs_nPV_kNoHighOccupancyAgressive", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_kNoHighOccupancyStrict", "nTracksGlobal_vs_nPV_kNoHighOccupancyStrict", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_kNoHighOccupancyMedium", "nTracksGlobal_vs_nPV_kNoHighOccupancyMedium", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_kNoHighOccupancyRelaxed", "nTracksGlobal_vs_nPV_kNoHighOccupancyRelaxed", kTH2F, {axisNtracks, axisNtracksGlobal}); - histos.add("nTracksGlobal_vs_nPV_kNoHighOccupancyGentle", "nTracksGlobal_vs_nPV_kNoHighOccupancyGentle", kTH2F, {axisNtracks, axisNtracksGlobal}); + AxisSpec axisMultV0A{nBinsMultFwd, 0., static_cast(nMaxMultFwd), "mult V0A"}; + AxisSpec axisMultFT0C{nBinsMultFwd, 0., static_cast(nMaxMultFwd * 0.4), "mult FT0C"}; + + histos.add("nTracksPV_vs_V0A_kNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_kNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_250", "nTracksPV_vs_V0A_occup_0_250", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_500", "nTracksPV_vs_V0A_occup_0_500", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_750", "nTracksPV_vs_V0A_occup_0_750", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_noOccupSel", "nTracksPV_vs_V0A_noOccupSel", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", "nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_ABOVE_750", "nTracksPV_vs_V0A_occup_ABOVE_750", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_occup_Minus1", "nTracksPV_vs_V0A_occup_Minus1", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_AntiNoCollInTimeRangeStandard", "nTracksPV_vs_V0A_AntiNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracks}); + histos.add("nTracksPV_vs_V0A_AntiNoCollInTimeRangeNarrow", "nTracksPV_vs_V0A_AntiNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracks}); + + histos.add("nTracksGlobal_vs_V0A_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_kNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_kNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_250", "nTracksGlobal_vs_V0A_occup_0_250", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_500", "nTracksGlobal_vs_V0A_occup_0_500", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_750", "nTracksGlobal_vs_V0A_occup_0_750", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_noOccupSel", "nTracksGlobal_vs_V0A_noOccupSel", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", "nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard_extraCuts", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_ABOVE_750", "nTracksGlobal_vs_V0A_occup_ABOVE_750", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_occup_Minus1", "nTracksGlobal_vs_V0A_occup_Minus1", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeStandard", "nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeStandard", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeNarrow", "nTracksGlobal_vs_V0A_AntiNoCollInTimeRangeNarrow", kTH2F, {axisMultV0A, axisNtracksGlobal}); + histos.add("nTracksGlobal_vs_nPV_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_nPV_kNoCollInTimeRangeStandard", kTH2F, {axisNtracks, axisNtracksGlobal}); histos.add("nTracksGlobal_vs_nPV_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_nPV_kNoCollInTimeRangeNarrow", kTH2F, {axisNtracks, axisNtracksGlobal}); histos.add("nTracksGlobal_vs_nPV_occup_0_250", "nTracksGlobal_vs_nPV_occup_0_250", kTH2F, {axisNtracks, axisNtracksGlobal}); @@ -246,10 +325,28 @@ struct DetectorOccupancyQaTask { 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}); + // 3D histograms with occupancy axis - histos.add("nTracksGlobal_vs_nPV_vs_occup_pure", "nTracksGlobal_vs_nPV_vs_occup_pure", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancy}); - histos.add("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancy}); - histos.add("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeNarrow", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancy}); + histos.add("nTracksGlobal_vs_nPV_vs_occup_pure", "nTracksGlobal_vs_nPV_vs_occup_pure", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancyTracks}); + histos.add("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard", "nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancyTracks}); + histos.add("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeNarrow", "nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeNarrow", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancyTracks}); + histos.add("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard_extraCuts", "nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard_extraCuts", kTH3F, {axisNtracks, axisNtracksGlobal, axisOccupancyTracks}); + + // 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_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultV0A, axisNtracksGlobal, axisOccupancyTracks}); + // FT0C as x-axis: + histos.add("nTracksGlobal_vs_FT0C_vs_occup_pure", "", kTH3F, {axisMultFT0C, axisNtracksGlobal, axisOccupancyTracks}); + histos.add("nTracksGlobal_vs_FT0C_vs_occup_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultFT0C, axisNtracksGlobal, axisOccupancyTracks}); + + // 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_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultV0A, axisNtracks, axisOccupancyTracks}); + // FT0C as x-axis: + histos.add("nPV_vs_FT0C_vs_occup_pure", "", kTH3F, {axisMultFT0C, axisNtracks, axisOccupancyTracks}); + histos.add("nPV_vs_FT0C_vs_occup_kNoCollInTimeRangeStandard_extraCuts", "", kTH3F, {axisMultFT0C, axisNtracks, axisOccupancyTracks}); } } @@ -262,40 +359,17 @@ struct DetectorOccupancyQaTask { aod::FT0s const&) { int runNumber = bcs.iteratorAt(0).runNumber(); - uint32_t nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023 if (runNumber != lastRunNumber) { lastRunNumber = runNumber; // do it only once - int64_t tsSOR = 0; - int64_t tsEOR = 1; - - if (runNumber >= 500000) { // access CCDB for data or anchored MC only - int64_t ts = bcs.iteratorAt(0).timestamp(); - - EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); - // access orbit-reset timestamp - auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", ts); - int64_t tsOrbitReset = (*ctpx)[0]; // us - // access TF duration, start-of-run and end-of-run timestamps from ECS GRP - std::map metadata; - metadata["runNumber"] = Form("%d", runNumber); - auto grpecs = ccdb->getSpecific("GLO/Config/GRPECS", ts, metadata); - nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023 - tsSOR = grpecs->getTimeStart(); // ms - tsEOR = grpecs->getTimeEnd(); // ms - // calculate SOR and EOR orbits - int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; - int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; - // adjust to the nearest TF edge - orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; - orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; - // set nOrbits and minOrbit used for orbit-axis binning - nOrbits = orbitEOR - orbitSOR; - minOrbit = orbitSOR; - // first bc of the first orbit (should coincide with TF start) - bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches; + + 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 = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches; - LOGP(info, "tsOrbitReset={} us, SOR = {} ms, EOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, tsEOR, orbitSOR, nBCsPerTF); + nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches; + + LOGP(info, "bcSOR = {}, nBCsPerTF = {}", bcSOR, nBCsPerTF); } } @@ -308,8 +382,13 @@ 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 vAmpFT0CperColl(cols.size(), 0); // amplitude FT0C per collision + std::vector vTFids(cols.size(), 0); std::vector vIsFullInfoForOccupancy(cols.size(), 0); + std::vector vIsMarkedCollForAnalysis(cols.size(), 0); // cut on the max bcId in the time frame + + std::vector vFlagsForEtaQAvsOccupancyInDeltaTimeWins(cols.size(), 0); const double timeWinOccupancyCalcNS = confTimeIntervalForOccupancyCalculation * 1e3; // ns, to be compared with TPC drift time const double bcNS = o2::constants::lhc::LHCBunchSpacingNS; @@ -324,7 +403,7 @@ struct DetectorOccupancyQaTask { int nITSTPCtracks = 0; int nITSTPCtracksPtEtaCuts = 0; int nTOFtracks = 0; - int nTRDtracks = 0; + // int nTRDtracks = 0; auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); for (auto& track : tracksGrouped) { if (!track.isPVContributor()) { @@ -334,7 +413,7 @@ struct DetectorOccupancyQaTask { nITS567cls++; nITSTPCtracks += track.hasITS() && track.hasTPC(); nTOFtracks += track.hasTOF(); - nTRDtracks += track.hasTRD(); + // nTRDtracks += track.hasTRD(); if (track.pt() < confCutPtMinThisEvent || track.pt() > confCutPtMaxThisEvent) continue; @@ -358,6 +437,9 @@ struct DetectorOccupancyQaTask { vFoundBCindex[colIndex] = foundBC; vFoundGlobalBC[colIndex] = bc.globalBC(); + if (bc.has_foundFT0()) + vAmpFT0CperColl[colIndex] = bc.foundFT0().sumAmpC(); + vIsVertexTOFmatched[colIndex] = nTOFtracks > 0; vTracksITS567perColl[colIndex] += nITS567cls; @@ -375,34 +457,9 @@ struct DetectorOccupancyQaTask { int64_t bcInTF = (bc.globalBC() - bcSOR) % nBCsPerTF; vIsFullInfoForOccupancy[colIndex] = ((bcInTF - 300) * bcNS > timeWinOccupancyCalcNS) && ((nBCsPerTF - 4000 - bcInTF) * bcNS > timeWinOccupancyCalcNS) ? true : false; + // cut on the max bc in the time frame + vIsMarkedCollForAnalysis[colIndex] = nMaxBcInTFforAnalysis == -1 ? 1 : (bcInTF >= 300 && bcInTF < nMaxBcInTFforAnalysis); LOGP(debug, "### check bcInTF cut: colIndex={} bcInTF={} vIsFullInfoForOccupancy={}", colIndex, bcInTF, static_cast(vIsFullInfoForOccupancy[colIndex])); - - // additional QA: - if (col.selection_bit(kNoTimeFrameBorder) && col.selection_bit(kNoITSROFrameBorder)) { - auto bcFoundId = bc.globalBC() % 3564; - auto bcNonFound = col.bc_as(); - auto bcNonFoundId = bcNonFound.globalBC() % 3564; - int64_t diffFoundBC_vs_BC = (int64_t)bcFoundId - (int64_t)bcNonFoundId; - histos.fill(HIST("h2D_diff_FoundBC_vs_BC"), bcNonFoundId, diffFoundBC_vs_BC); - if (nITS567cls > 10) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_multAbove10"), bcNonFoundId, diffFoundBC_vs_BC); - if (nITS567cls > 20) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_multAbove20"), bcNonFoundId, diffFoundBC_vs_BC); - if (nITS567cls > 50) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_multAbove50"), bcNonFoundId, diffFoundBC_vs_BC); - if (nITS567cls > 100) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_multAbove100"), bcNonFoundId, diffFoundBC_vs_BC); - - if (nTOFtracks > 0) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_hasTOF"), bcNonFoundId, diffFoundBC_vs_BC); - if (nTRDtracks > 0) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_hasTRD"), bcNonFoundId, diffFoundBC_vs_BC); - - if (nITS567cls > 10 && nTOFtracks > 0) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_hasTOF_multAbove10"), bcNonFoundId, diffFoundBC_vs_BC); - if (nITS567cls > 10 && nTRDtracks > 0) - histos.fill(HIST("h2D_diff_FoundBC_vs_BC_hasTRD_multAbove10"), bcNonFoundId, diffFoundBC_vs_BC); - } } // find for each collision all collisions within the defined time window @@ -476,6 +533,10 @@ struct DetectorOccupancyQaTask { if (!vIsFullInfoForOccupancy[colIndex]) continue; + // cut on the max bcId in the time frame (to avoid the artificial fade-out tail in the MC productions) + if (!vIsMarkedCollForAnalysis[colIndex]) + continue; + // cut on vZ for a given collision if (col.posZ() < confCutVertZMinThisEvent || col.posZ() > confCutVertZMaxThisEvent) continue; @@ -514,7 +575,7 @@ struct DetectorOccupancyQaTask { bool sel = col.selection_bit(kIsTriggerTVX); // loop over nearby collisions - for (int iCol = 0; iCol < vCollsAssocToGivenColl.size(); iCol++) { + for (unsigned int iCol = 0; iCol < vCollsAssocToGivenColl.size(); iCol++) { int thisColIndex = vCollsAssocToGivenColl[iCol]; int64_t thisGlobBC = vFoundGlobalBC[thisColIndex]; float thisColTimeDiff = vCollsTimeDeltaWrtGivenColl[iCol] / 1e3; // ns -> us @@ -523,6 +584,7 @@ struct DetectorOccupancyQaTask { if (thisColIndex != colIndex && fabs(thisColTimeDiff) < confTimeIntervalForSmallBins) { LOGP(debug, " iCol={}/{}, thisColIndex={}, colIndex={}, thisColTimeDiff={} nITS={}", iCol, vCollsAssocToGivenColl.size(), thisColIndex, colIndex, thisColTimeDiff, vTracksITS567perColl[thisColIndex]); histos.fill(HIST("thisEventITStracksInTimeBins"), thisColTimeDiff, vTracksITS567perColl[thisColIndex]); + histos.fill(HIST("thisEventFT0CInTimeBins"), thisColTimeDiff, vAmpFT0CperColl[thisColIndex]); // histos.fill(HIST("thisEventITSTPCtracksInTimeBins"), thisColTimeDiff, vTracksITSTPCperColl[thisColIndex]); } nCollInTimeWindow++; @@ -557,47 +619,93 @@ struct DetectorOccupancyQaTask { LOGP(debug, " --> ### summary: colIndex={}/{} BC={} orbit={} nCollInTimeWindow={} nCollInTimeWindowSel={} nITSTPCtracksInTimeWindow={} ", colIndex, cols.size(), foundGlobalBC, orbit - orbitAtCollIndexZero, nCollInTimeWindow, nCollInTimeWindowSel, nITSTPCtracksInTimeWindow); if (confAddBasicQAhistos) { - histos.get(HIST("hNumITS567tracksInTimeWindow"))->Fill(nITS567tracksInTimeWindow); - histos.get(HIST("hNumITSTPCtracksInTimeWindow"))->Fill(nITSTPCtracksInTimeWindow); + histos.fill(HIST("hNumITS567tracksInTimeWindow"), nITS567tracksInTimeWindow); + histos.fill(HIST("hNumITSTPCtracksInTimeWindow"), nITSTPCtracksInTimeWindow); + + histos.fill(HIST("hNumITSTPCtracksPerCollision"), vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("hNumITS567tracksPerCollision"), vTracksITS567perColl[colIndex]); + + histos.fill(HIST("hNumITSTPCtracksInTimeWindow_vs_TracksPerColl"), vTracksITSTPCperColl[colIndex], nITSTPCtracksInTimeWindow); + histos.fill(HIST("hNumITSTPCtracksInTimeWindow_vs_TracksPerColl_withoutThisCol"), vTracksITSTPCperColl[colIndex], nITSTPCtracksInTimeWindow - vTracksITSTPCperColl[colIndex]); - histos.get(HIST("hNumITSTPCtracksPerCollision"))->Fill(vTracksITSTPCperColl[colIndex]); - histos.get(HIST("hNumITS567tracksPerCollision"))->Fill(vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNumITS567tracksInTimeWindow_vs_TracksPerColl"), vTracksITS567perColl[colIndex], nITS567tracksInTimeWindow); + histos.fill(HIST("hNumITS567tracksInTimeWindow_vs_TracksPerColl_withoutThisCol"), vTracksITS567perColl[colIndex], nITS567tracksInTimeWindow - vTracksITS567perColl[colIndex]); - histos.get(HIST("hNumITSTPCtracksInTimeWindow_vs_TracksPerColl"))->Fill(vTracksITSTPCperColl[colIndex], nITSTPCtracksInTimeWindow); - histos.get(HIST("hNumITSTPCtracksInTimeWindow_vs_TracksPerColl_withoutThisCol"))->Fill(vTracksITSTPCperColl[colIndex], nITSTPCtracksInTimeWindow - vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("hNumCollInTimeWindow"), nCollInTimeWindow); - histos.get(HIST("hNumITS567tracksInTimeWindow_vs_TracksPerColl"))->Fill(vTracksITS567perColl[colIndex], nITS567tracksInTimeWindow); - histos.get(HIST("hNumITS567tracksInTimeWindow_vs_TracksPerColl_withoutThisCol"))->Fill(vTracksITS567perColl[colIndex], nITS567tracksInTimeWindow - vTracksITS567perColl[colIndex]); + int64_t bcInTF = (vFoundGlobalBC[colIndex] - bcSOR) % nBCsPerTF; + int orbitId = bcInTF / o2::constants::lhc::LHCMaxBunches; + histos.fill(HIST("hNumCollInTimeWindowVsOrbit"), orbitId, nCollInTimeWindow); - histos.get(HIST("hNumCollInTimeWindow"))->Fill(nCollInTimeWindow); + histos.fill(HIST("hNumUniqueBCInTimeWindow"), mUniqueBC.size()); - histos.get(HIST("hNumUniqueBCInTimeWindow"))->Fill(mUniqueBC.size()); + // 3D before ev quality cut: + histos.fill(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_ITS567tracksInTimeWindow_BEFORE_sel"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], nITS567tracksInTimeWindow - vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow_BEFORE_sel"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); - if (sel) { - histos.get(HIST("hNumITS567tracksInTimeWindowSel"))->Fill(nITS567tracksInTimeWindowSel); - histos.get(HIST("hNumITSTPCtracksInTimeWindowSel"))->Fill(nITSTPCtracksInTimeWindowSel); + if (sel && fabs(col.posZ()) < 10) { + histos.fill(HIST("hNumITS567tracksInTimeWindowSel"), nITS567tracksInTimeWindowSel); + histos.fill(HIST("hNumITSTPCtracksInTimeWindowSel"), nITSTPCtracksInTimeWindowSel); - histos.get(HIST("hNumITS567tracksPerCollisionSel"))->Fill(vTracksITS567perColl[colIndex]); - histos.get(HIST("hNumITSTPCtracksPerCollisionSel"))->Fill(vTracksITSTPCperCollPtEtaCuts[colIndex]); + histos.fill(HIST("hNumITS567tracksPerCollisionSel"), vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNumITSTPCtracksPerCollisionSel"), vTracksITSTPCperCollPtEtaCuts[colIndex]); - histos.get(HIST("hNumCollInTimeWindowSel"))->Fill(nCollInTimeWindowSel); - histos.get(HIST("hNumCollInTimeWindowSelITSTPC"))->Fill(nCollInTimeWindowSelITSTPC); - histos.get(HIST("hNumCollInTimeWindowSelIfTOF"))->Fill(nCollInTimeWindowSelIfTOF); + histos.fill(HIST("hNumCollInTimeWindowSel"), nCollInTimeWindowSel); + histos.fill(HIST("hNumCollInTimeWindowSelITSTPC"), nCollInTimeWindowSelITSTPC); + histos.fill(HIST("hNumCollInTimeWindowSelIfTOF"), nCollInTimeWindowSelIfTOF); + + // 3D histograms: ITS vs ITSTPC in this event vs occupancy from other events + histos.fill(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_ITS567tracksInTimeWindow"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], nITS567tracksInTimeWindow - vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); + if (col.selection_bit(kNoCollInTimeRangeNarrow)) { + histos.fill(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); + + histos.fill(HIST("hNumITSTPC_vs_FT0CthisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow"), multFT0CmainCollision, vTracksITSTPCperCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); + histos.fill(HIST("hNumITS567_vs_FT0CthisCol_vs_FT0CamplInTimeWindow_kNoCollInTimeRangeNarrow"), multFT0CmainCollision, vTracksITS567perCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); + } } // 2D histograms - histos.get(HIST("hNumITS567tracksInTimeWindow_vs_FT0Campl"))->Fill(multFT0CInTimeWindow, nITS567tracksInTimeWindow); - histos.get(HIST("hNumITSTPCtracksInTimeWindow_vs_FT0Campl"))->Fill(multFT0CInTimeWindow, nITSTPCtracksInTimeWindow); - histos.get(HIST("hNumITSTPCtracksInTimeWindow_vs_ITS567tracks"))->Fill(nITS567tracksInTimeWindow, nITSTPCtracksInTimeWindow); + histos.fill(HIST("hNumITS567tracksInTimeWindow_vs_FT0Campl"), multFT0CInTimeWindow, nITS567tracksInTimeWindow); + histos.fill(HIST("hNumITSTPCtracksInTimeWindow_vs_FT0Campl"), multFT0CInTimeWindow, nITSTPCtracksInTimeWindow); + histos.fill(HIST("hNumITSTPCtracksInTimeWindow_vs_ITS567tracks"), nITS567tracksInTimeWindow, nITSTPCtracksInTimeWindow); - histos.get(HIST("hNumITS567tracks_vs_FT0Campl_ThisEvent"))->Fill(multFT0CmainCollision, vTracksITS567perCollPtEtaCuts[colIndex]); - histos.get(HIST("hNumITSTPCtracks_vs_FT0Campl_ThisEvent"))->Fill(multFT0CmainCollision, vTracksITSTPCperCollPtEtaCuts[colIndex]); - histos.get(HIST("hNumITSTPCtracks_vs_ITS567tracks_ThisEvent"))->Fill(vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex]); - - // 3D histograms: ITS vs ITSTPC in this event vs occupancy from other events - histos.get(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_FT0CamplInTimeWindow"))->Fill(vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], multFT0CInTimeWindow - multFT0CmainCollision); - histos.get(HIST("hNumITSTPC_vs_ITS567tracksThisCol_vs_ITS567tracksInTimeWindow"))->Fill(vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex], nITS567tracksInTimeWindow - vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNumITS567tracks_vs_FT0Campl_ThisEvent"), multFT0CmainCollision, vTracksITS567perCollPtEtaCuts[colIndex]); + histos.fill(HIST("hNumITSTPCtracks_vs_FT0Campl_ThisEvent"), multFT0CmainCollision, vTracksITSTPCperCollPtEtaCuts[colIndex]); + histos.fill(HIST("hNumITSTPCtracks_vs_ITS567tracks_ThisEvent"), vTracksITS567perCollPtEtaCuts[colIndex], vTracksITSTPCperCollPtEtaCuts[colIndex]); } + + // counters of occupancy in specified delta-time ranges, to monitor eta, phi, pt distributions later + float integralFullDeltaTime = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(); + int binMin = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(-39.5); // us + int binMax = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(-10.5); + float integralPast = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(binMin, binMax); + binMin = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(20.5); + binMax = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(49.5); + float integralFuture1 = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(binMin, binMax); + binMin = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(50.5); + binMax = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(79.5); + float integralFuture2 = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(binMin, binMax); + binMin = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(-9.5); + binMax = histos.get(HIST("thisEventITStracksInTimeBins"))->FindBin(19.5); + float integralNeighbourEvents = histos.get(HIST("thisEventITStracksInTimeBins"))->Integral(binMin, binMax); + + // recent past + if (integralFullDeltaTime < 150) // ~empty detector + vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 1; + // recent past + if (integralPast > /*3000*/ 2500 && (integralFullDeltaTime - integralPast) < 120) // low occupancy outside the dt region of interest + vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 2; + // close future + if (integralFuture1 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture1) < 120) + vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 3; + // distant future + if (integralFuture2 > /*3000*/ 2500 && (integralFullDeltaTime - integralFuture2) < 120) + vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 4; + // neighbour events + if (integralNeighbourEvents > /*3000*/ 2500 && (integralFullDeltaTime - integralNeighbourEvents) < 120) + vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] = 5; + // loop over time axis in nD histograms: for (int iT = 0; iT < histos.get(HIST("thisEventITStracksInTimeBins"))->GetNbinsX(); iT++) { int nITStrInTimeBin = histos.get(HIST("thisEventITStracksInTimeBins"))->GetBinContent(iT + 1); @@ -606,13 +714,48 @@ struct DetectorOccupancyQaTask { // int nITSTPCtInTimeBin = histos.get(HIST("thisEventITSTPCtracksInTimeBins"))->GetBinContent(iT + 1); float dt = histos.get(HIST("thisEventITStracksInTimeBins"))->GetBinCenter(iT + 1); - histos.get(HIST("occupancyInTimeBins"))->Fill(dt, vTracksITS567perCollPtEtaCuts[colIndex], confFlagUseGlobalTracks ? vTracksGlobalPerCollPtEtaCuts[colIndex] : vTracksITSTPCperCollPtEtaCuts[colIndex], nITStrInTimeBin); + + 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 (sel && fabs(col.posZ()) < 10) { + 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 (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 (counterQAtimeOccupHistos < nCollisionsForTimeBinQA) histos.fill(HIST("histOccupInTimeBinsQA"), dt, counterQAtimeOccupHistos + 1, nITStrInTimeBin); + + // QA for high occup in time bins + if (vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] == 2) + histos.fill(HIST("qaForHighOccupITStracksInTimeBinPast"), dt, nITStrInTimeBin); + if (vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] == 3) + histos.fill(HIST("qaForHighOccupITStracksInTimeBinFuture1"), dt, nITStrInTimeBin); + if (vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] == 4) + histos.fill(HIST("qaForHighOccupITStracksInTimeBinFuture2"), dt, nITStrInTimeBin); + if (vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex] == 5) + histos.fill(HIST("qaForHighOccupITStracksForNeighbourEvents"), dt, nITStrInTimeBin); } + + // reset delta time hist for this event histos.get(HIST("thisEventITStracksInTimeBins"))->Reset(); // histos.get(HIST("thisEventITSTPCtracksInTimeBins"))->Reset(); + histos.get(HIST("thisEventFT0CInTimeBins"))->Reset(); counterQAtimeOccupHistos++; } // end of occupancy calculation @@ -623,17 +766,28 @@ struct DetectorOccupancyQaTask { // } 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); + + // 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); + auto multV0A = col.multFV0A(); // auto multT0A = col.multFT0A(); - // auto multT0C = col.multFT0C(); + auto multT0C = col.multFT0C(); int nPV = 0; // col.multNTracksPV(); int nGlobalTracks = 0; + int occupancy = col.trackOccupancyInTimeRange(); + auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); for (auto& track : tracksGrouped) { if (!track.isPVContributor()) @@ -646,8 +800,34 @@ struct DetectorOccupancyQaTask { continue; nPV++; - if (track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls) + if (track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls) { nGlobalTracks++; + + if (track.passedTPCRefit()) { + float signedP = track.sign() * track.tpcInnerParam(); + histos.fill(HIST("dEdx_vs_Momentum"), signedP, track.tpcSignal()); + if (occupancy >= 0 && occupancy < 200) { + histos.fill(HIST("dEdx_vs_Momentum_occupBelow200"), signedP, track.tpcSignal()); + if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) + histos.fill(HIST("dEdx_vs_Momentum_occupBelow200_kNoCollStd"), signedP, track.tpcSignal()); + } + if (occupancy > 4000) + histos.fill(HIST("dEdx_vs_Momentum_occupAbove4000"), signedP, track.tpcSignal()); + + if (occupancy >= 0) { + 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); + + // dE/dx in narrow mom bin vs centrality and occupancy + if (signedP > 0.38 && signedP < 0.4) + histos.fill(HIST("dEdx_vs_centr_vs_occup_narrow_p_win"), nPV, occupancy, track.tpcSignal()); + } + } + } } if (confAddTracksVsFwdHistos) @@ -664,11 +844,113 @@ struct DetectorOccupancyQaTask { if (confFlagApplyROFborderCut && !col.selection_bit(kNoITSROFrameBorder)) continue; - int occupancy = col.trackOccupancyInTimeRange(); histos.fill(HIST("hOccupancy"), occupancy); + if (occupancy >= 0) { + int orbitId = bcInTF / o2::constants::lhc::LHCMaxBunches; + histos.fill(HIST("hOccupancyVsOrbit"), orbitId, occupancy); + } + + // another track loop to fill track-level histograms + if (confAddBasicQAhistos) { + int flagWhichDeltaTimeWin = vFlagsForEtaQAvsOccupancyInDeltaTimeWins[colIndex]; + bool flagNoCollNearby = col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); + + if (occupancy >= 0) { + if (nPV >= 10 && nPV < 200) { + if (flagNoCollNearby && flagWhichDeltaTimeWin != 5) + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEventCount"), flagWhichDeltaTimeWin); + if (flagWhichDeltaTimeWin == 5) // nearby collisions --> avoid checking the flagNoCollNearby flag + histos.fill(HIST("track_distr_nITStrThisEv_10_200/hEventCount"), flagWhichDeltaTimeWin); + } + if (nPV >= 2000) { + if (flagNoCollNearby && flagWhichDeltaTimeWin != 5) + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEventCount"), flagWhichDeltaTimeWin); + if (flagWhichDeltaTimeWin == 5) // nearby collisions --> avoid checking the flagNoCollNearby flag + histos.fill(HIST("track_distr_nITStrThisEv_above_2000/hEventCount"), flagWhichDeltaTimeWin); + } + } + for (auto& track : tracksGrouped) { + if (!track.isPVContributor()) + continue; + if (track.itsNCls() < 5) + continue; + if (!(track.isGlobalTrack() && track.tpcNClsFound() >= confCutMinTPCcls)) + continue; + + // 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()); + } + + 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()); + } + } 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 (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 + + // occupancy vs centrality auto t0cCentr = col.centFT0C(); - histos.fill(HIST("hCentrVsOccupancy"), t0cCentr, occupancy); + 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) { continue; @@ -679,40 +961,29 @@ struct DetectorOccupancyQaTask { histos.fill(HIST("nTracksGlobal_vs_V0A_noOccupSel"), multV0A, nGlobalTracks); histos.fill(HIST("nTracksGlobal_vs_nPV_noOccupSel"), nPV, nGlobalTracks); - if (occupancy >= 0) + if (occupancy >= 0) { histos.fill(HIST("nTracksGlobal_vs_nPV_vs_occup_pure"), nPV, nGlobalTracks, occupancy); + histos.fill(HIST("nTracksGlobal_vs_V0A_vs_occup_pure"), multV0A, nGlobalTracks, occupancy); + histos.fill(HIST("nTracksGlobal_vs_FT0C_vs_occup_pure"), multT0C, nGlobalTracks, occupancy); - if (col.selection_bit(o2::aod::evsel::kNoHighOccupancyAgressive)) { - histos.fill(HIST("nTracksPV_vs_V0A_kNoHighOccupancyAgressive"), multV0A, nPV); - histos.fill(HIST("nTracksGlobal_vs_V0A_kNoHighOccupancyAgressive"), multV0A, nGlobalTracks); - histos.fill(HIST("nTracksGlobal_vs_nPV_kNoHighOccupancyAgressive"), nPV, nGlobalTracks); - } - if (col.selection_bit(o2::aod::evsel::kNoHighOccupancyStrict)) { - histos.fill(HIST("nTracksPV_vs_V0A_kNoHighOccupancyStrict"), multV0A, nPV); - histos.fill(HIST("nTracksGlobal_vs_V0A_kNoHighOccupancyStrict"), multV0A, nGlobalTracks); - histos.fill(HIST("nTracksGlobal_vs_nPV_kNoHighOccupancyStrict"), nPV, nGlobalTracks); - } - if (col.selection_bit(o2::aod::evsel::kNoHighOccupancyMedium)) { - histos.fill(HIST("nTracksPV_vs_V0A_kNoHighOccupancyMedium"), multV0A, nPV); - histos.fill(HIST("nTracksGlobal_vs_V0A_kNoHighOccupancyMedium"), multV0A, nGlobalTracks); - histos.fill(HIST("nTracksGlobal_vs_nPV_kNoHighOccupancyMedium"), nPV, nGlobalTracks); - } - if (col.selection_bit(o2::aod::evsel::kNoHighOccupancyRelaxed)) { - histos.fill(HIST("nTracksPV_vs_V0A_kNoHighOccupancyRelaxed"), multV0A, nPV); - histos.fill(HIST("nTracksGlobal_vs_V0A_kNoHighOccupancyRelaxed"), multV0A, nGlobalTracks); - histos.fill(HIST("nTracksGlobal_vs_nPV_kNoHighOccupancyRelaxed"), nPV, nGlobalTracks); - } - if (col.selection_bit(o2::aod::evsel::kNoHighOccupancyGentle)) { - histos.fill(HIST("nTracksPV_vs_V0A_kNoHighOccupancyGentle"), multV0A, nPV); - histos.fill(HIST("nTracksGlobal_vs_V0A_kNoHighOccupancyGentle"), multV0A, nGlobalTracks); - histos.fill(HIST("nTracksGlobal_vs_nPV_kNoHighOccupancyGentle"), nPV, nGlobalTracks); + histos.fill(HIST("nPV_vs_V0A_vs_occup_pure"), multV0A, nPV, occupancy); + histos.fill(HIST("nPV_vs_FT0C_vs_occup_pure"), multT0C, nPV, occupancy); } + if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { histos.fill(HIST("nTracksPV_vs_V0A_kNoCollInTimeRangeStandard"), multV0A, nPV); histos.fill(HIST("nTracksGlobal_vs_V0A_kNoCollInTimeRangeStandard"), multV0A, nGlobalTracks); histos.fill(HIST("nTracksGlobal_vs_nPV_kNoCollInTimeRangeStandard"), nPV, nGlobalTracks); if (occupancy >= 0) histos.fill(HIST("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard"), nPV, nGlobalTracks, occupancy); + if (occupancy >= 0 && col.selection_bit(kNoSameBunchPileup) && col.selection_bit(kIsGoodZvtxFT0vsPV)) { + histos.fill(HIST("nTracksGlobal_vs_nPV_vs_occup_kNoCollInTimeRangeStandard_extraCuts"), nPV, nGlobalTracks, occupancy); + histos.fill(HIST("nTracksGlobal_vs_V0A_vs_occup_kNoCollInTimeRangeStandard_extraCuts"), multV0A, nGlobalTracks, occupancy); + histos.fill(HIST("nTracksGlobal_vs_FT0C_vs_occup_kNoCollInTimeRangeStandard_extraCuts"), multT0C, nGlobalTracks, occupancy); + + histos.fill(HIST("nPV_vs_V0A_vs_occup_kNoCollInTimeRangeStandard_extraCuts"), multV0A, nPV, occupancy); + histos.fill(HIST("nPV_vs_FT0C_vs_occup_kNoCollInTimeRangeStandard_extraCuts"), multT0C, nPV, occupancy); + } } if (col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { histos.fill(HIST("nTracksPV_vs_V0A_kNoCollInTimeRangeNarrow"), multV0A, nPV); @@ -739,6 +1010,15 @@ struct DetectorOccupancyQaTask { if (occupancy >= 0 && occupancy < 2000) { histos.fill(HIST("nTracksGlobal_vs_nPV_occup_0_2000"), nPV, nGlobalTracks); } + // ### now vs FT0C occupancy: + float occupByFT0C = col.ft0cOccupancyInTimeRange(); + if (occupByFT0C >= 0 && occupByFT0C < 2500) { + histos.fill(HIST("nTracksGlobal_vs_nPV_occupByFT0C_0_2500"), nPV, nGlobalTracks); + } + if (occupByFT0C >= 0 && occupByFT0C < 20000) { + histos.fill(HIST("nTracksGlobal_vs_nPV_occupByFT0C_0_20000"), nPV, nGlobalTracks); + } + // if (occupancy >= 0 && occupancy < 500 && col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { histos.fill(HIST("nTracksPV_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard"), multV0A, nPV); histos.fill(HIST("nTracksGlobal_vs_V0A_occup_0_500_kNoCollInTimeRangeStandard"), multV0A, nGlobalTracks); diff --git a/DPG/Tasks/AOTEvent/eventSelectionQa.cxx b/DPG/Tasks/AOTEvent/eventSelectionQa.cxx index 9946e871840..82230b44d2c 100644 --- a/DPG/Tasks/AOTEvent/eventSelectionQa.cxx +++ b/DPG/Tasks/AOTEvent/eventSelectionQa.cxx @@ -336,14 +336,14 @@ struct EventSelectionQaTask { } // bc-based event selection qa - for (auto& bc : bcs) { + for (const auto& bc : bcs) { for (int iAlias = 0; iAlias < kNaliases; iAlias++) { histos.fill(HIST("hBcCounterAll"), iAlias, bc.alias_bit(iAlias)); } } // collision-based event selection qa - for (auto& col : cols) { + for (const auto& col : cols) { bool sel1 = col.selection_bit(kIsINT1) && col.selection_bit(kNoBGV0A) && col.selection_bit(kNoBGV0C) && col.selection_bit(kNoTPCLaserWarmUp) && col.selection_bit(kNoTPCHVdip); for (int iAlias = 0; iAlias < kNaliases; iAlias++) { @@ -367,7 +367,7 @@ struct EventSelectionQaTask { histos.fill(HIST("hSelCounter"), i, col.selection_bit(i)); } - auto bc = col.bc_as(); + const auto& bc = col.bc_as(); uint64_t globalBC = bc.globalBC(); // uint64_t orbit = globalBC / nBCsPerOrbit; int localBC = globalBC % nBCsPerOrbit; @@ -665,7 +665,7 @@ struct EventSelectionQaTask { std::vector vGlobalBCs(nBCs, 0); // bc-based event selection qa - for (auto& bc : bcs) { + for (const auto& bc : bcs) { if (!bc.has_ft0()) continue; float multT0A = bc.ft0().sumAmpA(); @@ -684,7 +684,7 @@ struct EventSelectionQaTask { } // bc-based event selection qa - for (auto& bc : bcs) { + for (const auto& bc : bcs) { for (int iAlias = 0; iAlias < kNaliases; iAlias++) { histos.fill(HIST("hBcCounterAll"), iAlias, bc.alias_bit(iAlias)); } @@ -810,7 +810,7 @@ struct EventSelectionQaTask { // map for pileup checks std::vector vCollisionsPerBc(bcs.size(), 0); - for (auto& col : cols) { + for (const auto& col : cols) { if (col.foundBCId() < 0 || col.foundBCId() >= bcs.size()) continue; vCollisionsPerBc[col.foundBCId()]++; @@ -826,7 +826,7 @@ struct EventSelectionQaTask { // to be used for closest TVX (FT0-OR) searches std::map mapGlobalBcWithTVX; std::map mapGlobalBcWithTOR; - for (auto& bc : bcs) { + for (const auto& bc : bcs) { int64_t globalBC = bc.globalBC(); // skip non-colliding bcs for data and anchored runs if (runNumber >= 500000 && bcPatternB[globalBC % o2::constants::lhc::LHCMaxBunches] == 0) { @@ -859,7 +859,7 @@ struct EventSelectionQaTask { } // collision-based event selection qa - for (auto& col : cols) { + for (const auto& col : cols) { for (int iAlias = 0; iAlias < kNaliases; iAlias++) { if (!col.alias_bit(iAlias)) { continue; @@ -893,7 +893,7 @@ struct EventSelectionQaTask { // count tracks of different types auto tracksGrouped = tracks.sliceBy(perCollision, col.globalIndex()); int nContributorsAfterEtaTPCCuts = 0; - for (auto& track : tracksGrouped) { + for (const auto& track : tracksGrouped) { int trackBcDiff = bcDiff + track.trackTime() / o2::constants::lhc::LHCBunchSpacingNS; if (!track.isPVContributor()) continue; @@ -1078,7 +1078,7 @@ struct EventSelectionQaTask { void processMCRun3(aod::McCollisions const& mcCols, soa::Join const& cols, BCsRun3 const&, aod::FT0s const&) { - for (auto& mcCol : mcCols) { + for (const auto& mcCol : mcCols) { auto bc = mcCol.bc_as(); uint64_t globalBC = bc.globalBC(); uint64_t orbit = globalBC / nBCsPerOrbit; @@ -1094,7 +1094,7 @@ struct EventSelectionQaTask { } // check fraction of collisions matched to wrong bcs - for (auto& col : cols) { + for (const auto& col : cols) { if (!col.has_mcCollision()) { continue; } diff --git a/DPG/Tasks/AOTEvent/matchingQa.cxx b/DPG/Tasks/AOTEvent/matchingQa.cxx new file mode 100644 index 00000000000..b59b8faba0c --- /dev/null +++ b/DPG/Tasks/AOTEvent/matchingQa.cxx @@ -0,0 +1,818 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "MetadataHelper.h" + +using namespace o2; +using namespace o2::framework; + +using BCsRun3 = soa::Join; +using FullTracksIU = soa::Join; +using FullTracksIUwithLabels = soa::Join; +float bcNS = o2::constants::lhc::LHCBunchSpacingNS; +int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; + +MetadataHelper metadataInfo; // Metadata helper + +struct MatchingQaTask { + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Preslice perCollision = aod::track::collisionId; + Configurable customOrbitOffset{"customOrbitOffset", 0, "customOrbitOffset for MC"}; + Configurable isLowFlux{"isLowFlux", 0, "1 - low flux (pp, pPb), 0 - high flux (PbPb)"}; + Configurable useTimeDiff{"useTimeDiff", 1, "use time difference for selection"}; + Configurable useVtxDiff{"useVtxDiff", 1, "use vertex difference for selection"}; + Configurable removeTOFmatches{"removeTOFmatches", 1, "remove TVX bcs matched to collisions with TOF tracks"}; + Configurable removeHighPtmatches{"removeHighPtmatches", 1, "remove TVX bcs matched to collisions with high-pt ITS-TPC tracks"}; + Configurable removeColsWithAmbiguousTOF{"removeColsWithAmbiguousTOF", 0, "remove collisions with ambiguous TOF signals"}; + Configurable removeNoncollidingBCs{"removeNoncollidingBCs", 1, "Remove TVX from non-colliding bcs"}; + Configurable useITSROFconstraint{"useITSROFconstraint", 1, "use ITS ROF constraints for ITS-TPC vertices"}; + Configurable additionalDeltaBC{"additionalDeltaBC", 0, "Additional BC margin added to deltaBC for ITS-TPC vertices"}; + Configurable deltaBCforTOFcollisions{"deltaBCforTOFcollisions", 1, "bc margin for TOF-matched collisions"}; + Configurable minimumDeltaBC{"minimumDeltaBC", -1, "minimum delta BC for ITS-TPC vertices"}; + Configurable deltaBCforHighPtTracks{"deltaBCforHighPtTracks", 10, "delta BC for high-pt ITS-TPC tracks"}; + + std::bitset bcPatternB; // bc pattern of colliding bunches + int lastRun = -1; + int64_t bcSOR = -1; // global bc of the start of the first orbit + int32_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564 + int32_t offsetITSROF = 64; + int32_t nBCsPerITSROF = 198; + std::vector vFoundBCindex; + std::vector vNumITStracks; + std::vector vNumTOFtracks; + std::vector vNumTRDtracks; + std::vector vNumTPCtracks; + std::vector vNumTPCtracksHighPt; + + bool isGoodBC(int64_t globalBC, bool fillHistos = 0) + { + // kNoTimeFrameBorder + int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF; + if (fillHistos) + histos.fill(HIST("hBcInTFall"), bcInTF); + if (bcInTF < 300 || bcInTF > nBCsPerTF - 4000) + return 0; + if (fillHistos) + histos.fill(HIST("hBcInTFcut"), bcInTF); + // kNoITSROFrameBorder + uint16_t bcInITSROF = (globalBC + nBCsPerOrbit - offsetITSROF) % nBCsPerITSROF; + if (fillHistos) + histos.fill(HIST("hBcInITSROFall"), bcInITSROF); + if (bcInITSROF < 10 || bcInITSROF > nBCsPerITSROF - 20) + return 0; + if (fillHistos) + histos.fill(HIST("hBcInITSROFcut"), bcInITSROF); + return 1; + } + + void init(InitContext&) + { + if (metadataInfo.isFullyDefined()) { + if (!metadataInfo.isMC()) { + doprocessMC.value = false; + } + } + + const AxisSpec axisNcontrib{isLowFlux ? 200 : 8000, 0., isLowFlux ? 200. : 8000., "n contributors"}; + const AxisSpec axisColTimeRes{1500, 0., 1500., "collision time resolution (ns)"}; + const AxisSpec axisFraction{1000, 0., 1., ""}; + const AxisSpec axisBcDiff{800, -400., 400., "bc diff"}; + const AxisSpec axisBcs{nBCsPerOrbit, 0., static_cast(nBCsPerOrbit), "bc"}; + const AxisSpec axisMultT0C{200, 0., isLowFlux ? 2000. : 60000., "Rec. mult. T0C"}; + const AxisSpec axisZvtxDiff{200, -20., 20., "Zvtx difference, cm"}; + const AxisSpec axisTime{600, -25., 35., "Time, ns"}; + const AxisSpec axisPt{100, 0., 10., "p_{T}, GeV"}; + + histos.add("hTimeT0AHighMultT0C", "", kTH1F, {axisTime}); + histos.add("hTimeT0CHighMultT0C", "", kTH1F, {axisTime}); + histos.add("hTimeV0AHighMultT0C", "", kTH1F, {axisTime}); + histos.add("hTimeFDAHighMultT0C", "", kTH1F, {axisTime}); + histos.add("hTimeFDCHighMultT0C", "", kTH1F, {axisTime}); + + histos.add("hRecMultT0C", "", kTH1D, {axisMultT0C}); + + histos.add("hRecMultT0CvsNcontrib", "", kTH2D, {axisMultT0C, axisNcontrib}); + histos.add("hRecMultT0CvsNcontribTPC", "", kTH2D, {axisMultT0C, axisNcontrib}); + histos.add("hRecMultT0CvsNcontribTOF", "", kTH2D, {axisMultT0C, axisNcontrib}); + histos.add("hRecMultT0CvsNcontribTRD", "", kTH2D, {axisMultT0C, axisNcontrib}); + histos.add("hRecMultT0CvsNcontribTPCHighPt", "", kTH2D, {axisMultT0C, axisNcontrib}); + + histos.add("hBCsITS", "", kTH1F, {axisBcs}); + + histos.add("hNcontribCandidatesHighPt", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribCountsHighPt", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribCandidates", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribCounts", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribSigma", "", kTH2F, {axisNcontrib, axisColTimeRes}); + + histos.add("hNcontribAll", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribCol", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColITS", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColTPCHighPt", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribAcc", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAccTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAccTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAccTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAccITS", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAccTPCHighPt", "", kTH1F, {axisNcontrib}); + + histos.add("hTrackBcDiffVsPt", "", kTH2F, {axisPt, axisBcDiff}); + histos.add("hTrackBcResVsPt", "", kTH2F, {axisPt, axisBcDiff}); + + histos.add("hColBcDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisBcDiff}); + histos.add("hColBcDiffVsNcontribTOF", "", kTH2F, {axisNcontrib, axisBcDiff}); + histos.add("hColBcDiffVsNcontribTRD", "", kTH2F, {axisNcontrib, axisBcDiff}); + histos.add("hColBcDiffVsNcontribTPC", "", kTH2F, {axisNcontrib, axisBcDiff}); + + histos.add("hZvtxDiffVsNcontrib", "", kTH2F, {axisNcontrib, axisZvtxDiff}); + histos.add("hZvtxDiffVsNcontribTOF", "", kTH2F, {axisNcontrib, axisZvtxDiff}); + histos.add("hZvtxDiffVsNcontribTPC", "", kTH2F, {axisNcontrib, axisZvtxDiff}); + histos.add("hZvtxDiffVsNcontribTRD", "", kTH2F, {axisNcontrib, axisZvtxDiff}); + + histos.add("hNcontribUnambiguous", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribUnambiguousTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribUnambiguousTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribUnambiguousTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribUnambiguousITS", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribMis", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribMisTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribMisTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribMisTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribMisITS", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribColMostlyOk", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkITS", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribColMostlyOkMis", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkMisTOF", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkMisTPC", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkMisTRD", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribColMostlyOkMisITS", "", kTH1F, {axisNcontrib}); + + histos.add("hNcontribAllContribAll", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAllContribWrong", "", kTH1F, {axisNcontrib}); + histos.add("hNcontribAllFractionWrong", "", kTH2F, {axisNcontrib, axisFraction}); + histos.add("hNcontribTvxMostlyOk", "", kTH1F, {axisNcontrib}); + } + + 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 process(aod::Collisions const& cols, FullTracksIU const& tracks, BCsRun3 const& bcs, aod::FT0s const& ft0s, aod::FV0As const& /*fv0as*/, aod::FDDs const& /*FDDs*/) + { + int run = bcs.iteratorAt(0).runNumber(); + if (run != lastRun) { + lastRun = run; + auto runDuration = ccdb->getRunDuration(run, true); + int64_t tsSOR = runDuration.first; + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", tsSOR); + bcPatternB = grplhcif->getBunchFilling().getBCPattern(); + + auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", tsSOR); + int64_t tsOrbitReset = (*ctpx)[0]; + uint32_t nOrbitsPerTF = run < 534133 ? 128 : 32; + int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; + orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF; + bcSOR = orbitSOR * nBCsPerOrbit + customOrbitOffset * nBCsPerOrbit; + nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit; + nBCsPerITSROF = (run >= 543437 && run <= 545367) ? 594 : 198; + const AxisSpec axisBcDiff{800, -400., 400., "bc diff"}; + const AxisSpec axisBcsInTF{nBCsPerTF, 0., static_cast(nBCsPerTF), "bc"}; + const AxisSpec axisBcsInITSROF{nBCsPerITSROF, 0., static_cast(nBCsPerITSROF), "bc"}; + histos.add("hBcInTFall", "", kTH1F, {axisBcsInTF}); + histos.add("hBcInTFcut", "", kTH1F, {axisBcsInTF}); + histos.add("hBcInITSROFall", "", kTH1F, {axisBcsInITSROF}); + histos.add("hBcInITSROFcut", "", kTH1F, {axisBcsInITSROF}); + + histos.add("hBcInTFITS", "", kTH1F, {axisBcsInTF}); + histos.add("hBcInTFTPC", "", kTH1F, {axisBcsInTF}); + + histos.add("hBcInITSROFITS", "", kTH1F, {axisBcsInITSROF}); + histos.add("hBcInITSROFTPC", "", kTH1F, {axisBcsInITSROF}); + + histos.add("hBcInITSROFTPCDiff", "", kTH2F, {axisBcsInITSROF, axisBcDiff}); + } + + int nCols = cols.size(); + vFoundBCindex.resize(nCols); + vNumITStracks.resize(nCols); + vNumTOFtracks.resize(nCols); + vNumTRDtracks.resize(nCols); + vNumTPCtracks.resize(nCols); + vNumTPCtracksHighPt.resize(nCols); + std::fill(vFoundBCindex.begin(), vFoundBCindex.end(), -1); + std::fill(vNumITStracks.begin(), vNumITStracks.end(), 0); + std::fill(vNumTOFtracks.begin(), vNumTOFtracks.end(), 0); + std::fill(vNumTRDtracks.begin(), vNumTRDtracks.end(), 0); + std::fill(vNumTPCtracks.begin(), vNumTPCtracks.end(), 0); + std::fill(vNumTPCtracksHighPt.begin(), vNumTPCtracksHighPt.end(), 0); + + std::vector> vTPCtracksPts(cols.size()); + std::vector> vTOFtracksTimes(cols.size()); + std::vector> vTPCtracksTimes(cols.size()); + std::vector> vITStracksTimes(cols.size()); + std::vector> vTPCtracksTimeRes(cols.size()); + + std::vector vTOFtracksSumWeightedTimes(cols.size(), 0); + std::vector vTRDtracksSumWeightedTimes(cols.size(), 0); + std::vector vTPCtracksSumWeightedTimes(cols.size(), 0); + std::vector vITStracksSumWeightedTimes(cols.size(), 0); + std::vector vTOFtracksSumWeights(cols.size(), 0); + std::vector vTRDtracksSumWeights(cols.size(), 0); + std::vector vTPCtracksSumWeights(cols.size(), 0); + std::vector vITStracksSumWeights(cols.size(), 0); + std::vector vMinTimeTOFtracks(cols.size(), 10000); + std::vector vMaxTimeTOFtracks(cols.size(), -10000); + std::vector vWeightedSigma(cols.size(), 0); + std::map mapGlobalBcWithT0B; + std::map mapGlobalBcWithTVX; + std::map mapGlobalBcVtxZ; + std::map mapGlobalBcMultT0C; + std::map mapGlobalBcVtxZ2; + + int nBCs = bcs.size(); + std::vector vGlobalBCs(nBCs, 0); + + for (auto& bc : bcs) { + vGlobalBCs[bc.globalIndex()] = bc.globalBC(); + } + + for (auto& ft0 : ft0s) { + auto bc = ft0.bc_as(); + int64_t globalBC = bc.globalBC(); + // remove noise from non-colliding bcs + if (removeNoncollidingBCs && bcPatternB[globalBC % o2::constants::lhc::LHCMaxBunches] == 0) + continue; + if (ft0.triggerMask() & BIT(o2::ft0::Triggers::bitVertex)) { + mapGlobalBcWithTVX[globalBC] = bc.globalIndex(); + mapGlobalBcVtxZ[globalBC] = ft0.posZ(); + mapGlobalBcVtxZ2[globalBC] = ft0.posZ(); + mapGlobalBcMultT0C[globalBC] = ft0.sumAmpC(); + } + if (fabs(ft0.timeA()) < 1 && fabs(ft0.timeC()) < 1) { + mapGlobalBcWithT0B[globalBC] = bc.globalIndex(); + } + } + + for (auto& track : tracks) { + // DataFormats/Detectors/GlobalTracking/include/DataFormatsGlobalTracking/RecoContainerCreateTracksVariadic.h + // Time for different track types: + // ITS-TPC-TRD-TOF: time from TOF +/- 10 ns + // ITS-TPC-TRD: time from TRD +/- 5 ns + // ITS-TPC: time from ITS-TPC matching + + // ITS and colId requirements are redundant for contributors + int32_t colId = track.collisionId(); + + if (!track.isPVContributor() || colId < 0 || !track.hasITS()) + continue; + + float trackPt = track.pt(); + float trackTime = track.trackTime(); + float trackTimeRes = track.trackTimeRes(); + float w = 1. / (trackTimeRes * trackTimeRes); + if (track.hasTOF()) { + vTOFtracksTimes[colId].push_back(trackTime); + vNumTOFtracks[colId]++; + vTOFtracksSumWeightedTimes[colId] += trackTime * w; + vTOFtracksSumWeights[colId] += w; + if (vMinTimeTOFtracks[colId] > trackTime) + vMinTimeTOFtracks[colId] = trackTime; + if (vMaxTimeTOFtracks[colId] < trackTime) + vMaxTimeTOFtracks[colId] = trackTime; + } else if (track.hasTRD()) { + vNumTRDtracks[colId]++; + vTRDtracksSumWeightedTimes[colId] += trackTime * w; + vTRDtracksSumWeights[colId] += w; + } else if (track.hasTPC()) { + vTPCtracksPts[colId].push_back(trackPt); + vTPCtracksTimes[colId].push_back(trackTime); + vTPCtracksTimeRes[colId].push_back(trackTimeRes); + vNumTPCtracks[colId]++; + if (trackPt > 1) + vNumTPCtracksHighPt[colId]++; + vTPCtracksSumWeightedTimes[colId] += trackTime * w; + vTPCtracksSumWeights[colId] += w; + } else { + vITStracksTimes[colId].push_back(trackTime); + vNumITStracks[colId]++; + vITStracksSumWeightedTimes[colId] += trackTime * w; + vITStracksSumWeights[colId] += w; + } + } + + for (auto& col : cols) { + int32_t colId = col.globalIndex(); + + if (vNumTOFtracks[colId] == 0) + continue; + auto bc = col.bc_as(); + int64_t globalBC = bc.globalBC(); + + // todo: bypass ambiguous collisions with TOF tracks pointing to different bcs + // float weightedTime = vTOFtracksSumWeightedTimes[colId] / vTOFtracksSumWeights[colId]; + + // TOF track time median calculation using std::nth_element + auto& vTOFtracks = vTOFtracksTimes[colId]; + int median = vTOFtracks.size() / 2; + std::nth_element(vTOFtracks.begin(), vTOFtracks.begin() + median, vTOFtracks.end()); + float medianTime = vTOFtracks[median]; + + // int64_t tofGlobalBC = globalBC + TMath::Nint(weightedTime / bcNS); + int64_t tofGlobalBC = globalBC + TMath::Nint(medianTime / bcNS); + + int32_t foundBC = findClosest(tofGlobalBC, mapGlobalBcWithTVX); + int64_t foundGlobalBC = bcs.iteratorAt(foundBC).globalBC(); + // todo: check what to do if foundBC is too far from tofGlobalBC + if (fabs(foundGlobalBC - tofGlobalBC) > deltaBCforTOFcollisions) { + foundBC = -1; + int32_t nContrib = col.numContrib(); + if (nContrib > 100) { + int32_t foundBCwithT0B = findClosest(tofGlobalBC, mapGlobalBcWithT0B); + int64_t foundGlobalBCwithT0B = bcs.iteratorAt(foundBCwithT0B).globalBC(); + + LOGP(info, "Total number of TOF tracks: {}", vTOFtracks.size()); + LOGP(info, "Median time: {}", medianTime); + LOGP(info, "globalBC: {}", globalBC % 3564); + LOGP(info, "TOF global BC: {}", tofGlobalBC % 3564); + LOGP(info, "Found global BC: {}", foundGlobalBC % 3564); + LOGP(info, "Found global BC with T0B: {}", foundGlobalBCwithT0B % 3564); + sort(vTOFtracks.begin(), vTOFtracks.end()); + for (float t : vTOFtracks) { + LOGP(info, " {}", t); + } + } + } + + vFoundBCindex[colId] = foundBC; + if (removeTOFmatches && foundBC >= 0) { + mapGlobalBcVtxZ.erase(foundGlobalBC); + } + } + + // second loop to match collisions with high-pt ITS-TPC tracks + for (auto& col : cols) { + int32_t colId = col.globalIndex(); + if (vNumTOFtracks[colId] > 0) + continue; + if (vNumTPCtracksHighPt[colId] == 0) + continue; + + auto bc = col.bc_as(); + int64_t globalBC = bc.globalBC(); + float sumTime = 0; + int nTracks = 0; + for (uint32_t i = 0; i < vTPCtracksTimes[colId].size(); ++i) { + if (vTPCtracksPts[colId][i] < 1.0) + continue; + sumTime += vTPCtracksTimes[colId][i]; + nTracks++; + } + if (nTracks == 0) { + LOGP(info, "Warning: nTracks = 0"); + continue; + } + + int64_t deltaBC = deltaBCforHighPtTracks; + int64_t tpcGlobalBC = globalBC + TMath::Nint(sumTime / nTracks / bcNS); + int64_t minBC = tpcGlobalBC - deltaBC; + int64_t maxBC = tpcGlobalBC + deltaBC; + int32_t nContrib = col.numContrib(); + float zVtxCol = col.posZ(); + float zVtxSigma = 2.7 * pow(nContrib, -0.466) + 0.024; + zVtxSigma += 1.0; // additional uncertainty due to imperfectections of FT0 time calibration + + // todo: check upper bound + auto itMin = mapGlobalBcVtxZ.lower_bound(minBC); + auto itMax = mapGlobalBcVtxZ.upper_bound(maxBC); + + float bestChi2 = 1e+10; + int64_t globalBcBest = 0; + + int nCandidates = 0; + for (std::map::iterator it = itMin; it != itMax; ++it) { + float zVtxFT0 = it->second; + float zVtxDiff = zVtxFT0 - zVtxCol; + float bcDiff = tpcGlobalBC - globalBC; + float chi2 = 0; + chi2 += useVtxDiff ? pow(zVtxDiff / zVtxSigma, 2) : 0.; + chi2 += useTimeDiff ? pow(bcDiff / (deltaBCforHighPtTracks / 3.), 2) : 0.; + + if (chi2 < bestChi2) { + bestChi2 = chi2; + globalBcBest = it->first; + } + nCandidates++; + } + histos.fill(HIST("hNcontribCandidatesHighPt"), nContrib, nCandidates); + histos.fill(HIST("hNcontribCountsHighPt"), nContrib); + + if (globalBcBest != 0) + vFoundBCindex[colId] = mapGlobalBcWithTVX[globalBcBest]; + + if (removeHighPtmatches && vFoundBCindex[colId] >= 0) + mapGlobalBcVtxZ.erase(globalBC); + } // second loop + + // third loop to match collisions with poor time resolution + for (auto& col : cols) { + int32_t colId = col.globalIndex(); + if (vNumTOFtracks[colId] > 0) + continue; + if (vNumTPCtracks[colId] == 0) + continue; + if (vFoundBCindex[colId] >= 0) // found in the previous step + continue; + + auto bc = col.bc_as(); + int64_t globalBC = bc.globalBC(); + + float weightedTime = vTPCtracksSumWeightedTimes[colId] / vTPCtracksSumWeights[colId]; + float weightedSigma = sqrt(1. / vTPCtracksSumWeights[colId]); + + int64_t minROF = 0; + int64_t maxROF = 0; + if (useITSROFconstraint) { + float medianTime = 0; + auto vTPCtracks = vTPCtracksTimes[colId]; + int median = vTPCtracks.size() / 2; + std::nth_element(vTPCtracks.begin(), vTPCtracks.begin() + median, vTPCtracks.end()); + medianTime = vTPCtracks[median]; + + int64_t itsGlobalBC = globalBC + TMath::Nint(medianTime / bcNS); + minROF = (itsGlobalBC - offsetITSROF) / nBCsPerITSROF * nBCsPerITSROF + offsetITSROF; + maxROF = minROF + nBCsPerITSROF; + LOGP(debug, "{} {}", minROF, maxROF); + float sumTime = 0; + float sumW = 0; + for (uint32_t i = 0; i < vTPCtracksTimes[colId].size(); ++i) { + float trackTime = vTPCtracksTimes[colId][i]; + int64_t trackGlobalBC = globalBC + TMath::Nint(trackTime / bcNS); + LOGP(debug, " {}", trackGlobalBC); + if (trackGlobalBC < minROF || trackGlobalBC > maxROF) + continue; + float r = vTPCtracksTimeRes[colId][i]; + float w = 1. / (r * r); + sumTime += trackTime * w; + sumW += w; + } + weightedTime = sumTime / sumW; + weightedSigma = sqrt(1. / sumW); + } + + int64_t deltaBC = std::ceil(weightedSigma / bcNS * 3); + int64_t tpcGlobalBC = globalBC + TMath::Nint(weightedTime / bcNS); + + LOGP(debug, "{} {}", tpcGlobalBC, deltaBC); + + deltaBC += additionalDeltaBC; + + if (minimumDeltaBC >= 0) { + deltaBC = deltaBC < minimumDeltaBC ? minimumDeltaBC : deltaBC; + } + + int64_t minBC = tpcGlobalBC - deltaBC; + int64_t maxBC = tpcGlobalBC + deltaBC; + + if (useITSROFconstraint) { + minBC = minBC < minROF ? minROF : minBC; + maxBC = maxBC > maxROF ? maxROF : maxBC; + if (minBC > maxBC) { + LOGP(debug, "{} {} {} {}", minBC, maxBC, minROF, maxROF); + continue; + } + } + + int32_t nContrib = col.numContrib(); + float zVtxCol = col.posZ(); + float zVtxSigma = 2.7 * pow(nContrib, -0.466) + 0.024; + zVtxSigma += 1.0; // additional uncertainty due to imperfectections of FT0 time calibration + + // QA + vWeightedSigma[colId] = weightedSigma; + + // todo: check upper bound + auto itMin = mapGlobalBcVtxZ.lower_bound(minBC); + auto itMax = mapGlobalBcVtxZ.upper_bound(maxBC); + + float bestChi2 = 1e+10; + int64_t globalBcBest = 0; + + int nCandidates = 0; + for (std::map::iterator it = itMin; it != itMax; ++it) { + float zVtxFT0 = it->second; + float zVtxDiff = zVtxFT0 - zVtxCol; + float timeDiff = bcNS * (tpcGlobalBC - globalBC); + float chi2 = 0; + chi2 += useVtxDiff ? pow(zVtxDiff / zVtxSigma, 2) : 0.; + chi2 += useTimeDiff ? pow(timeDiff / weightedSigma, 2) : 0.; + + if (chi2 < bestChi2) { + bestChi2 = chi2; + globalBcBest = it->first; + } + nCandidates++; + } + if (nCandidates > 100) + LOGP(info, "{} {}", minBC, maxBC); + + histos.fill(HIST("hNcontribCandidates"), nContrib, nCandidates); + histos.fill(HIST("hNcontribCounts"), nContrib); + + if (globalBcBest != 0) + vFoundBCindex[colId] = mapGlobalBcWithTVX[globalBcBest]; + + } // third loop + + // QA + for (auto& ft0 : ft0s) { + auto bc = ft0.bc_as(); + int64_t globalBC = bc.globalBC(); + // remove noise from non-colliding bcs + if (removeNoncollidingBCs && bcPatternB[globalBC % o2::constants::lhc::LHCMaxBunches] == 0) + continue; + if (!(ft0.triggerMask() & BIT(o2::ft0::Triggers::bitVertex))) + continue; + float multT0C = ft0.sumAmpC(); + histos.fill(HIST("hRecMultT0C"), ft0.sumAmpC()); + if (multT0C < 1800) + continue; + histos.fill(HIST("hTimeT0AHighMultT0C"), ft0.timeA()); + histos.fill(HIST("hTimeT0CHighMultT0C"), ft0.timeC()); + if (bc.has_fv0a()) { + auto fv0 = bc.fv0a(); + histos.fill(HIST("hTimeV0AHighMultT0C"), fv0.time()); + } + if (bc.has_fdd()) { + auto fdd = bc.fdd(); + histos.fill(HIST("hTimeFDAHighMultT0C"), fdd.timeA()); + histos.fill(HIST("hTimeFDCHighMultT0C"), fdd.timeC()); + } + } + + for (auto& col : cols) { + int64_t globalBC = col.bc_as().globalBC(); + if (!isGoodBC(globalBC, 1)) + continue; + + int32_t colId = col.globalIndex(); + int32_t nContrib = col.numContrib(); + // float timeRes = col.collisionTimeRes(); + int32_t foundBC = vFoundBCindex[colId]; + bool isGoodTOF = vMaxTimeTOFtracks[colId] - vMinTimeTOFtracks[colId] < 50; + bool isFoundTVX = foundBC >= 0; + + float zVtxDiff = 1e+10; + float multT0C = 0; + int64_t foundGlobalBC = 0; + + if (foundBC >= 0 && foundBC < bcs.size()) { + auto bc = bcs.iteratorAt(foundBC); + foundGlobalBC = bc.globalBC(); + // LOGP(info,"{}",bc.has_ft0()); + if (bc.has_ft0()) { + zVtxDiff = bc.ft0().posZ() - col.posZ(); + multT0C = bc.ft0().sumAmpC(); + } + } + + histos.fill(HIST("hNcontribAll"), nContrib); + if (removeColsWithAmbiguousTOF && !isGoodTOF) { + continue; + } + + histos.fill(HIST("hNcontribCol"), nContrib); + if (isFoundTVX) { + histos.fill(HIST("hNcontribAcc"), nContrib); + histos.fill(HIST("hRecMultT0CvsNcontrib"), multT0C, nContrib); + histos.fill(HIST("hZvtxDiffVsNcontrib"), nContrib, zVtxDiff); + } + + // search for nearest ft0a&ft0c entry + int32_t indexClosestTVX = findClosest(globalBC, mapGlobalBcWithTVX); + int bcDiff = static_cast(globalBC - vGlobalBCs[indexClosestTVX]); + histos.fill(HIST("hColBcDiffVsNcontrib"), nContrib, bcDiff); + + if (vNumTOFtracks[colId] > 0) { + histos.fill(HIST("hNcontribColTOF"), nContrib); + if (isFoundTVX) { + histos.fill(HIST("hNcontribAccTOF"), nContrib); + histos.fill(HIST("hRecMultT0CvsNcontribTOF"), multT0C, nContrib); + histos.fill(HIST("hZvtxDiffVsNcontribTOF"), nContrib, zVtxDiff); + } + histos.fill(HIST("hColBcDiffVsNcontribTOF"), nContrib, bcDiff); + + for (uint32_t i = 0; i < vTPCtracksTimes[colId].size(); i++) { + float pt = vTPCtracksPts[colId][i]; + auto t = vTPCtracksTimes[colId][i]; + int foundBCinITSROF = (foundGlobalBC + nBCsPerOrbit - offsetITSROF) % nBCsPerITSROF; + int64_t tpcTrackGlobalBC = globalBC + TMath::Nint(t / bcNS); + int64_t deltaBC = tpcTrackGlobalBC - foundGlobalBC; + histos.fill(HIST("hBcInITSROFTPCDiff"), foundBCinITSROF, deltaBC); + histos.fill(HIST("hTrackBcDiffVsPt"), pt, deltaBC); + histos.fill(HIST("hTrackBcResVsPt"), pt, vTPCtracksTimeRes[colId][i] / bcNS); + } + } else if (vNumTPCtracksHighPt[colId] > 0) { + histos.fill(HIST("hNcontribColTPCHighPt"), nContrib); + if (isFoundTVX) { + histos.fill(HIST("hNcontribAccTPCHighPt"), nContrib); + histos.fill(HIST("hRecMultT0CvsNcontribTPCHighPt"), multT0C, nContrib); + } + } else if (vNumTPCtracks[colId] > 0) { + histos.fill(HIST("hNcontribSigma"), nContrib, vWeightedSigma[colId]); + histos.fill(HIST("hNcontribColTPC"), nContrib); + histos.fill(HIST("hColBcDiffVsNcontribTPC"), nContrib, bcDiff); + if (nContrib > 180) { + histos.fill(HIST("hBcInTFTPC"), (globalBC - bcSOR) % nBCsPerTF); + histos.fill(HIST("hBcInITSROFTPC"), (globalBC + nBCsPerOrbit - offsetITSROF) % nBCsPerITSROF); + } + if (isFoundTVX) { + histos.fill(HIST("hNcontribAccTPC"), nContrib); + histos.fill(HIST("hRecMultT0CvsNcontribTPC"), multT0C, nContrib); + histos.fill(HIST("hZvtxDiffVsNcontribTPC"), nContrib, zVtxDiff); + } + } else if (vNumTRDtracks[colId] > 0) { + histos.fill(HIST("hNcontribColTRD"), nContrib); + if (isFoundTVX) { + histos.fill(HIST("hNcontribAccTRD"), nContrib); + histos.fill(HIST("hRecMultT0CvsNcontribTRD"), multT0C, nContrib); + histos.fill(HIST("hZvtxDiffVsNcontribTRD"), nContrib, zVtxDiff); + } + histos.fill(HIST("hColBcDiffVsNcontribTRD"), nContrib, bcDiff); + } else if (vNumITStracks[colId] > 0) { + histos.fill(HIST("hNcontribColITS"), nContrib); + if (nContrib > 180) { + histos.fill(HIST("hBcInTFITS"), (globalBC - bcSOR) % nBCsPerTF); + histos.fill(HIST("hBcInITSROFITS"), (globalBC + nBCsPerOrbit - offsetITSROF) % nBCsPerITSROF); + } + + if (isFoundTVX) + histos.fill(HIST("hNcontribAccITS"), nContrib); + } + } + } + + void processMC( + aod::McCollisions const& mcCols, + soa::Join const& cols, + FullTracksIUwithLabels const& tracks, + BCsRun3 const& /*bcs*/, + aod::FT0s const& /*ft0s*/, + aod::McParticles const& mcParts) + { + + std::vector vLabel(cols.size(), -1); + std::vector vIsAmbiguousLabel(cols.size(), 0); + std::vector vNumWrongContributors(cols.size(), 0); + + for (auto& track : tracks) { + if (!track.isPVContributor()) + continue; + int32_t colId = track.collisionId(); + auto col = cols.iteratorAt(colId); + int32_t mcColIdFromCollision = col.mcCollisionId(); + if (mcColIdFromCollision < 0) + continue; + int mcId = track.mcParticleId(); + if (mcId < 0 || mcId >= mcParts.size()) + continue; + auto mcPart = mcParts.iteratorAt(mcId); + int32_t mcColId = mcPart.mcCollisionId(); + if (mcColId < 0) + continue; + if (mcColIdFromCollision != mcColId) + vNumWrongContributors[colId]++; + + if (vLabel[colId] != -1 && vLabel[colId] != mcColId) { + vIsAmbiguousLabel[colId] = 1; + } + vLabel[colId] = mcColId; + } + + for (auto& col : cols) { + int64_t globalBC = col.bc_as().globalBC(); + if (!isGoodBC(globalBC)) + continue; + + int32_t colId = col.globalIndex(); + int32_t nContrib = col.numContrib(); + + histos.fill(HIST("hNcontribAllContribAll"), nContrib, nContrib); + histos.fill(HIST("hNcontribAllContribWrong"), nContrib, vNumWrongContributors[colId]); + histos.fill(HIST("hNcontribAllFractionWrong"), nContrib, static_cast(vNumWrongContributors[colId]) / nContrib); + + if (static_cast(vNumWrongContributors[colId]) / nContrib > 0.1) + continue; + + histos.fill(HIST("hNcontribColMostlyOk"), nContrib); + if (vNumTOFtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkTOF"), nContrib); + } else if (vNumTPCtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkTPC"), nContrib); + } else if (vNumTRDtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkTRD"), nContrib); + } else if (vNumITStracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkITS"), nContrib); + } + + int32_t foundBC = vFoundBCindex[colId]; + int32_t mcColId = vLabel[colId]; + auto mcCol = mcCols.iteratorAt(mcColId); + auto mcBC = mcCol.bc_as(); + // int64_t mcGlobalBC = mcBC.globalBC(); + bool isMcTVX = mcBC.has_ft0() ? mcBC.ft0().triggerMask() & BIT(o2::ft0::Triggers::bitVertex) : 0; + if (isMcTVX) + histos.fill(HIST("hNcontribTvxMostlyOk"), nContrib); + + if (foundBC >= 0 && foundBC != mcBC.globalIndex()) { + // Analyse mismatches + histos.fill(HIST("hNcontribColMostlyOkMis"), nContrib); + if (vNumTOFtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkMisTOF"), nContrib); + } else if (vNumTPCtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkMisTPC"), nContrib); + } else if (vNumTRDtracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkMisTRD"), nContrib); + } else if (vNumITStracks[colId] > 0) { + histos.fill(HIST("hNcontribColMostlyOkMisITS"), nContrib); + } + } + + if (vIsAmbiguousLabel[colId]) + continue; + + histos.fill(HIST("hNcontribUnambiguous"), nContrib); + if (vNumTOFtracks[colId] > 0) { + histos.fill(HIST("hNcontribUnambiguousTOF"), nContrib); + } else if (vNumTPCtracks[colId] > 0) { + histos.fill(HIST("hNcontribUnambiguousTPC"), nContrib); + } else if (vNumTRDtracks[colId] > 0) { + histos.fill(HIST("hNcontribUnambiguousTRD"), nContrib); + } else if (vNumITStracks[colId] > 0) { + histos.fill(HIST("hNcontribUnambiguousITS"), nContrib); + } + + if (foundBC >= 0 && foundBC != mcBC.globalIndex()) { + // Analyse mismatches + histos.fill(HIST("hNcontribMis"), nContrib); + if (vNumTOFtracks[colId] > 0) { + histos.fill(HIST("hNcontribMisTOF"), nContrib); + } else if (vNumTPCtracks[colId] > 0) { + histos.fill(HIST("hNcontribMisTPC"), nContrib); + } else if (vNumTRDtracks[colId] > 0) { + histos.fill(HIST("hNcontribMisTRD"), nContrib); + } else if (vNumITStracks[colId] > 0) { + histos.fill(HIST("hNcontribMisITS"), nContrib); + } + } + } + } + + PROCESS_SWITCH(MatchingQaTask, processMC, "", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata + metadataInfo.initMetadata(cfgc); + + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx b/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx new file mode 100644 index 00000000000..790174ef6c8 --- /dev/null +++ b/DPG/Tasks/AOTEvent/rofOccupancyQa.cxx @@ -0,0 +1,1359 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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/ConfigParamSpec.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/LHCConstants.h" +#include "Framework/HistogramRegistry.h" +// #include "DataFormatsParameters/GRPLHCIFData.h" +#include "ITSMFTBase/DPLAlpideParam.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod::evsel; + +using BCsWithBcSelsRun3 = soa::Join; +using FullTracksIU = soa::Join; +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"}; + + Service ccdb; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + 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 + + void init(InitContext&) + { + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + float k = confFactorForHistRange; + histos.add("hDeltaTime", "", kTH1D, {{1500, -50, 100}}); + histos.add("hDeltaTimeAboveNtracksCut", "", kTH1D, {{1500, -50, 100}}); + histos.add("hDeltaTime_vZ10cm", "", kTH1D, {{1500, -50, 100}}); + histos.add("hDeltaTime_sel8", "", kTH1D, {{1500, -50, 100}}); + histos.add("hDeltaTime_sel8_vZ10cm", "", kTH1D, {{1500, -50, 100}}); + histos.add("hDeltaTimeAboveNtracksCut_sel8_vZ10cm", "", kTH1D, {{1500, -50, 100}}); + + histos.add("hOccupancyWeights", "", kTH1D, {{150, -50, 100}}); + histos.add("hOccupancyByTracks", "", kTH1D, {{250, 0., 25000 * k}}); + histos.add("hOccupancyByFT0C", "", kTH1D, {{250, 0., 2.5e5 * k}}); + histos.add("hOccupancyByTrInROF", "", kTH1D, {{250, 0., 25000 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks_vZ_TF_ROF_border_cuts", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks_afterNarrowDeltaTimeCut", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks_afterStrictDeltaTimeCut", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks_afterStandardDeltaTimeCut", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + histos.add("hOccupancyByFT0C_vs_ByTracks_afterVzDependentDeltaTimeCut", "", kTH2D, {{500, 0., 25000 * k}, {500, 0., 2.5e5 * k}}); + + histos.add("hOccupancyByTracks_CROSSCHECK", "", kTH1D, {{250, 0., 25000 * k}}); + histos.add("hOccupancyByFT0C_CROSSCHECK", "", kTH1D, {{250, 0., 2.5e5 * k}}); + + // this ev nITStr vs FT0C + histos.add("hThisEvITSTr_vs_ThisEvFT0C/all", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/vZ_TF_ROF_border_cuts", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/afterNarrowDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/afterStrictDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/afterStandardDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/afterVzDependentDeltaTimeCut", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + + histos.add("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofStrict", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofStandard", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofWithCloseVz", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + + histos.add("hThisEvITSTr_vs_ThisEvFT0C/NarrowDeltaCut_StdTimeAndRofCuts", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + + histos.add("hThisEvITSTr_vs_ThisEvFT0C/occupBelow2000", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/hThisEvITSTPCTr_vs_ThisEvFT0C_occupBelow2000", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/NarrowDeltaCut_StdTimeAndRofCuts_occupBelow2000", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + histos.add("hThisEvITSTr_vs_ThisEvFT0C/hThisEvITSTPCTr_vs_ThisEvFT0C_NarrowDeltaCut_StdTimeAndRofCuts_occupBelow2000", "", kTH2D, {{250, 0., 1e5 * k}, {250, 0., 10000 * k}}); + + // CROSS-CHECK SEL BITS: + 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}}); + // histos.add("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_kNoCollInRofWithCloseVz", "", kTH2D, {{250, 0., 1e5*k}, {250, 0., 10000*k}}); + + // this ev nITSTPCtr vs nITStr + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/all", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/vZ_TF_ROF_border_cuts", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/afterNarrowDeltaTimeCut", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/afterStrictDeltaTimeCut", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/afterStandardDeltaTimeCut", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/afterVzDependentDeltaTimeCut", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofStrict", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofStandard", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofWithCloseVz", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/NarrowDeltaCut_StdTimeAndRofCuts", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000_NarrowDeltaCut_StdTimeAndRofCuts", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + histos.add("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000_StrictDeltaTimeCutAndRofCuts", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 5000 * k}}); + + histos.add("hThisEvITStr_vs_vZcut", "", kTH2D, {{200, 0., 10.}, {200, 0., 8000 * k}}); + histos.add("hThisEvITSTPCtr_vs_vZcut", "", kTH2D, {{200, 0., 10.}, {200, 0., 5000 * k}}); + + histos.add("hThisEvITStr_vs_vZ", "", kTH2D, {{400, -20, 20.}, {200, 0., 8000 * k}}); + histos.add("hThisEvITSTPCtr_vs_vZ", "", kTH2D, {{400, -20, 20.}, {200, 0., 5000 * k}}); + + histos.add("hVz", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVz", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVzAfterCuts", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVzAfterTFandROFborderCuts", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVzGivenCollAbove100NearbyBelow100", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVzGivenCollBelow100NearbyAbove100", "", kTH1D, {{1600, -40, 40.}}); + histos.add("hDeltaVzAfterAllCuts", "", kTH1D, {{1600, -40, 40.}}); + + // + histos.add("hDeltaVzVsDeltaTime1", "", kTH2D, {{400, -25, 25}, {100, -20, 20}}); + histos.add("hDeltaVzVsDeltaTime2", "", kTH2D, {{400, -25, 25}, {100, -20, 20}}); + histos.add("hDeltaVzVsDeltaTime3", "", kTH2D, {{400, -25, 25}, {100, -20, 20}}); + histos.add("hDeltaVzVsDeltaTime4", "", kTH2D, {{400, -25, 25}, {100, -20, 20}}); + + histos.add("hEtaVz02", "", kTH1D, {{500, -2.5, 2.5}}); + histos.add("hEtaVzPlus10", "", kTH1D, {{500, -2.5, 2.5}}); + histos.add("hEtaVzMinus10", "", kTH1D, {{500, -2.5, 2.5}}); + histos.add("hEtaVzPlus15", "", kTH1D, {{500, -2.5, 2.5}}); + histos.add("hEtaVzMinus15", "", kTH1D, {{500, -2.5, 2.5}}); + histos.add("hEtaVsVz", "", kTH2D, {{250, -25, 25}, {250, -2.5, 2.5}}); + histos.add("hNPVcontribVsVz", "", kTH2D, {{250, -25, 25}, {500, 0., 8000}}); + histos.add("hNPVcontribVsVz_eta08", "", kTH2D, {{250, -25, 25}, {500, 0., 8000}}); + + // + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterStrictDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterStrictDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterStrictDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterStrictDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterStandardDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterStandardDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterStandardDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterStandardDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterVzDependentDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterVzDependentDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("afterVzDependentDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("afterVzDependentDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStrict/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStrict/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStrict/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStrict/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStandard/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStandard/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStandard/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofStandard/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTPCTr_vs_occupancyByTracks", "", kTH2D, {{250, 0., 25000 * k}, {250, 0., 8000}}); + histos.add("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + histos.add("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTPCTr_vs_occupancyByFT0C", "", kTH2D, {{250, 0., 2.5e5 * k}, {250, 0., 8000}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyInROF", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyInROF", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_HasNeighbours", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_HasNeighbours", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyInROF_HasNeighbours", "", kTH2D, {{250, 0., 12000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyFT0CInROF", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyFT0CInROF", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyFT0CInROF", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyFT0CInROF", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyInROF_2coll", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvFT0C_vs_occupancyFT0CInROF_2coll", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvFT0C_vs_occupancyFT0CInROF_2coll", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + histos.add("kNoCollInRofWithCloseVz/hThisEvFT0C_vs_occupancyFT0CInROF_2coll", "", kTH2D, {{250, 0., 100000 * k}, {250, 0., 100000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInAnotherEarlierROF_1collPerROF", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInAnotherEarlierROF_1collPerROF", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + // histos.add("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyInAnotherEarlierROF_1collPerROF", "", kTH2D, {{250, 0., 8000*k}, {250, 0., 8000*k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPrevPrevROF_1collPerROF", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + // coll on x axis always has more tracks: + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + // 2,3,4 colls in ROF + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_noVzCutOnOtherVertices", "", kTH2D, {{500, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_3coll_noVzCutOnOtherVertices", "", kTH2D, {{500, 0., 20000 * k}, {250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_4coll_noVzCutOnOtherVertices", "", kTH2D, {{500, 0., 20000 * k}, {250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_1coll_in_ROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_2coll_in_ROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_3coll_in_ROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_4coll_in_ROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_5collOrMore_in_ROF", "", kTH1D, {{250, 0., 8000 * k}}); + + // 1D + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_allOccup_2coll_inROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_lowOccup_2coll_inROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_highOccup_2coll_inROF", "", kTH1D, {{250, 0., 8000 * k}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_allOccup_1collPerROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_lowOccup_1collPerROF", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_highOccup_1collPerROF", "", kTH1D, {{250, 0., 8000 * k}}); + + // now with the ratio on y-axis: + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1", "", kTH2D, {{250, 0., 8000 * k}, {220, 0., 1.1}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1", "", kTH2D, {{250, 0., 8000 * k}, {220, 0., 1.1}}); + + histos.add("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1", "", kTH2D, {{250, 0., 8000 * k}, {220, 0., 1.1}}); + histos.add("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1", "", kTH2D, {{250, 0., 8000 * k}, {220, 0., 1.1}}); + + histos.add("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_inROF", "", kTH1D, {{500, 0., 15000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFprevROF", "", kTH1D, {{500, 0., 15000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFprevPrevROF", "", kTH1D, {{500, 0., 15000 * k}}); + histos.add("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFearlierThanPrevPrevROF", "", kTH1D, {{500, 0., 15000 * k}}); + + // + histos.add("hNcollPerROF", "", kTH1D, {{16, -0.5, 15.5}}); + + // ROF-by-ROF study: + histos.add("ROFbyROF/nPV_vs_ROFid", "", kTH2D, {{800, 0., 8000 * k}, {10, -0.5, 9.5}}); + histos.add("ROFbyROF/nPV_vs_subROFid", "", kTH2D, {{800, 0., 8000 * k}, {20, -0.5, 19.5}}); + + histos.add("ROFbyROF/FT0C_vs_ROFid", "", kTH2D, {{800, 0., 80000 * k}, {10, -0.5, 9.5}}); + histos.add("ROFbyROF/FT0C_vs_subROFid", "", kTH2D, {{800, 0., 80000 * k}, {20, -0.5, 19.5}}); + + histos.add("ROFbyROF/nPV_00x00", "", kTH1D, {{250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_10x00", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_01x00", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x10", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x01", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_11x00", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_01x10", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x11", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_10x00_nearbyByFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_01x00_nearbyByFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x10_nearbyByFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x01_nearbyByFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_10x00_thisFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_01x00_thisFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x10_thisFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_00x01_thisFT0C", "", kTH2D, {{250, 0., 80000 * k}, {250, 0., 8000 * k}}); + + // histos.add("ROFbyROF/nPV_11x11", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + // ### sub-ROFs: + histos.add("ROFbyROF/nPV_0_x00_0", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_0x0_0", "", kTH1D, {{250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_00x_0", "", kTH1D, {{250, 0., 8000 * k}}); + + // corr with prev subROFs: + histos.add("ROFbyROF/nPV_0_00x_y00_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_0x0_y00_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_x00_y00_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_0_00x_0y0_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_0x0_0y0_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_x00_0y0_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_0_00x_00y_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_0x0_00y_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_0_x00_00y_000", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + // corr with next subROFs: + histos.add("ROFbyROF/nPV_000_y00_00x_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_y00_0x0_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_y00_x00_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_000_0y0_00x_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_0y0_0x0_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_0y0_x00_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + histos.add("ROFbyROF/nPV_000_00y_00x_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_00y_0x0_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + histos.add("ROFbyROF/nPV_000_00y_x00_0", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + + // #### new occupancy studies + histos.add("nPV_vs_occupancyByTracks/sel8", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeNarrow", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeRangeVzDependent", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInRofStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInRofStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + histos.add("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStrict_vZ_5cm", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 25000 * k}}); + + histos.add("nPV_vs_occupancyByFT0C/sel8", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeNarrow", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeRangeVzDependent", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInRofStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInRofStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStandard", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStrict", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + histos.add("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStrict_vZ_5cm", "", kTH2D, {{250, 0., 8000 * k}, {100, 0., 2.5e5 * k}}); + } + + Partition pvTracks = ((aod::track::flags & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); + // Partition pvTracks = ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); + Preslice perCollision = aod::track::collisionId; + + using ColEvSels = soa::Join; //, aod::Mults, aod::CentFT0Cs>; + void processRun3(ColEvSels const& cols, FullTracksIU const&, BCsWithBcSelsRun3 const& bcs, aod::FT0s const&) + { + int run = bcs.iteratorAt(0).runNumber(); + // extract bc pattern from CCDB for data or anchored MC only + if (run != lastRun && run >= 500000) { + lastRun = run; + auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run); + // 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; + + // 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); + } + + std::vector vTracksITS567perColl(cols.size(), 0); // counter of tracks per collision for occupancy studies + std::vector vTracksITSTPCperColl(cols.size(), 0); // counter of tracks per collision for occupancy studies + std::vector vTracksITS567eta08perColl(cols.size(), 0); // counter of tracks per collision for occupancy studies + std::vector vAmpFT0CperColl(cols.size(), 0); // amplitude FT0C per 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 = confTimeIntervalForOccupancyCalculationMin * 1e3; // ns + const float timeWinOccupancyCalcMaxNS = 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 vCollVz(cols.size(), 0); // vector with vZ positions for each collision + std::vector vIsSel8(cols.size(), 0); + std::vector vCombCond(cols.size(), 0); + + std::vector vCollRofId(cols.size(), 0); // rof Id for each collision + std::vector vCollRofIdPerOrbit(cols.size(), 0); // rof Id for each collision, per orbit + std::vector vCollRofSubId(cols.size(), 0); // rof sub-Id for each collision + std::vector vCollRofSubIdPerOrbit(cols.size(), 0); // rof sub-Id for each collision, per orbit + + // first loop over collisions - collecting info + for (auto& col : cols) { + int32_t colIndex = col.globalIndex(); + // auto bc = col.bc_as(); + const auto& bc = col.foundBC_as(); + int64_t globalBC = bc.globalBC(); + + int32_t foundBC = bc.globalIndex(); + vFoundBCindex[colIndex] = foundBC; + vFoundGlobalBC[colIndex] = globalBC; // bc.globalBC(); + + if (bc.has_foundFT0()) + vAmpFT0CperColl[colIndex] = bc.foundFT0().sumAmpC(); + + vCollVz[colIndex] = col.posZ(); + vIsSel8[colIndex] = col.sel8(); + vCombCond[colIndex] = vIsSel8[colIndex] && (fabs(vCollVz[colIndex]) < 8) && (vAmpFT0CperColl[colIndex] > 500 /* a.u.*/); + + int bcInTF = col.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; + int rofId = (bcInTF - rofOffset) / rofLength; + vCollRofId[colIndex] = rofId; + + int rofIdPerOrbit = rofId % (3564 / rofLength); + vCollRofIdPerOrbit[colIndex] = rofIdPerOrbit; + + int bcInITSROF = (globalBC + 3564 - rofOffset) % rofLength; + int subRofId = bcInITSROF / (rofLength / 3); + vCollRofSubId[colIndex] = subRofId; + vCollRofSubIdPerOrbit[colIndex] = 3 * rofIdPerOrbit + subRofId; + // LOGP(info, ">> rofId={} rofIdPerOrbit={} subRofId={} vCollRofSubId={}", rofId, rofIdPerOrbit, subRofId, vCollRofSubId[colIndex]); + + auto colPvTracks = pvTracks.sliceBy(perCollision, col.globalIndex()); + + for (auto& track : colPvTracks) { + if (track.itsNCls() >= 5) { + vTracksITS567perColl[colIndex]++; + if (fabs(track.eta()) < 0.8) + vTracksITS567eta08perColl[colIndex]++; + if (track.tpcNClsFound() > 70) + vTracksITSTPCperColl[colIndex]++; + if (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()); + else if (col.posZ() > -10.5 && col.posZ() < -9.5) + histos.fill(HIST("hEtaVzMinus10"), track.eta()); + else if (col.posZ() > 14.5 && col.posZ() < 15.5) + histos.fill(HIST("hEtaVzPlus15"), track.eta()); + else if (col.posZ() > -15.5 && col.posZ() < -14.5) + histos.fill(HIST("hEtaVzMinus15"), track.eta()); + + histos.fill(HIST("hEtaVsVz"), col.posZ(), track.eta()); + } + if (track.hasTRD()) + vIsVertexTRDmatched[colIndex] = 1; + if (track.hasTPC()) + vIsVertexITSTPC[colIndex] = 1; + if (track.hasTOF()) { + vIsVertexTOFmatched[colIndex] = 1; + } + } + + if (col.sel8()) { + histos.fill(HIST("hNPVcontribVsVz"), col.posZ(), vTracksITS567perColl[colIndex]); + histos.fill(HIST("hNPVcontribVsVz_eta08"), col.posZ(), vTracksITS567eta08perColl[colIndex]); + } + } + + // ROF-by-ROF study: + int nColls = vCombCond.size(); + for (auto& col : cols) { + int32_t k = col.globalIndex(); + + if (k - 2 < 0 || k + 2 > nColls - 1) + continue; + + // the "purest case" + if (vCombCond[k]) { + if (vCollRofId[k - 1] < vCollRofId[k] - 2 && /* next coll is far */ vCollRofId[k + 1] > vCollRofId[k] + 2) // 00x00 + histos.fill(HIST("ROFbyROF/nPV_00x00"), vTracksITS567perColl[k]); + + if (vCollRofId[k - 1] < vCollRofId[k] - 1 && /* next coll is far */ vCollRofId[k + 1] > vCollRofId[k] + 1) // 0x0 + { + if (vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_0_x00_0"), vTracksITS567perColl[k]); + if (vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_0_0x0_0"), vTracksITS567perColl[k]); + if (vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_0_00x_0"), vTracksITS567perColl[k]); + } + } + + // prev 1 coll + if (vCombCond[k] && vCombCond[k - 1]) { + if (vCollRofId[k - 2] < vCollRofId[k] - 2 && vCollRofId[k - 1] == vCollRofId[k] - 2 && /* next coll is far */ vCollRofId[k + 1] > vCollRofId[k] + 2) // 10x00 + { + histos.fill(HIST("ROFbyROF/nPV_10x00"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_10x00_nearbyByFT0C"), vAmpFT0CperColl[k - 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_10x00_thisFT0C"), vAmpFT0CperColl[k], vTracksITS567perColl[k]); + } + if (vCollRofId[k - 2] < vCollRofId[k] - 2 && vCollRofId[k - 1] == vCollRofId[k] - 1 && /* next coll is far */ vCollRofId[k + 1] > vCollRofId[k] + 2) // 01x00 + { + histos.fill(HIST("ROFbyROF/nPV_01x00"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_01x00_nearbyByFT0C"), vAmpFT0CperColl[k - 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_01x00_thisFT0C"), vAmpFT0CperColl[k], vTracksITS567perColl[k]); + } + + if (vCollRofId[k - 2] < vCollRofId[k] - 2 && vCollRofId[k - 1] == vCollRofId[k] - 1 && /* next coll is far */ vCollRofId[k + 1] > vCollRofId[k] + 1) // 01x0 + { + // sub-ROFs: + if (vCollRofSubId[k - 1] == 2 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_0_00x_y00_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 1 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_0_0x0_y00_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 0 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_0_x00_y00_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + + if (vCollRofSubId[k - 1] == 2 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_0_00x_0y0_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 1 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_0_0x0_0y0_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 0 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_0_x00_0y0_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + + if (vCollRofSubId[k - 1] == 2 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_0_00x_00y_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 1 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_0_0x0_00y_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k - 1] == 0 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_0_x00_00y_000"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + } + } + // next 1 coll + if (vCombCond[k] && vCombCond[k + 1]) { + if (vCollRofId[k - 1] < vCollRofId[k] - 2 /* prev coll is far */ && vCollRofId[k + 1] == vCollRofId[k] + 1 && vCollRofId[k + 2] > vCollRofId[k] + 2) // 00x10 + { + histos.fill(HIST("ROFbyROF/nPV_00x10"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_00x10_nearbyByFT0C"), vAmpFT0CperColl[k + 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_00x10_thisFT0C"), vAmpFT0CperColl[k], vTracksITS567perColl[k]); + } + + if (vCollRofId[k - 1] < vCollRofId[k] - 1 /* prev coll is far */ && vCollRofId[k + 1] == vCollRofId[k] + 1 && vCollRofId[k + 2] > vCollRofId[k] + 2) // 0x10 + { + // sub-ROFs: + if (vCollRofSubId[k + 1] == 2 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_000_y00_00x_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 1 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_000_y00_0x0_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 0 && vCollRofSubId[k] == 0) + histos.fill(HIST("ROFbyROF/nPV_000_y00_x00_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + + if (vCollRofSubId[k + 1] == 2 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_000_0y0_00x_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 1 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_000_0y0_0x0_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 0 && vCollRofSubId[k] == 1) + histos.fill(HIST("ROFbyROF/nPV_000_0y0_x00_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + + if (vCollRofSubId[k + 1] == 2 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_000_00y_00x_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 1 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_000_00y_0x0_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + if (vCollRofSubId[k + 1] == 0 && vCollRofSubId[k] == 2) + histos.fill(HIST("ROFbyROF/nPV_000_00y_x00_0"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + } + + if (vCollRofId[k - 1] < vCollRofId[k] - 2 /* prev coll is far */ && vCollRofId[k + 1] == vCollRofId[k] + 2 && vCollRofId[k + 2] > vCollRofId[k] + 2) // 00x01 + { + histos.fill(HIST("ROFbyROF/nPV_00x01"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_00x01_nearbyByFT0C"), vAmpFT0CperColl[k + 1], vTracksITS567perColl[k]); + histos.fill(HIST("ROFbyROF/nPV_00x01_thisFT0C"), vAmpFT0CperColl[k], vTracksITS567perColl[k]); + } + } + + // 2 colls + if (vCombCond[k] && vCombCond[k - 1] && vCombCond[k - 2]) { + if (vCollRofId[k - 2] == vCollRofId[k] - 2 && vCollRofId[k - 1] == vCollRofId[k] - 1 && vCollRofId[k + 1] > vCollRofId[k] + 2) // 11x00 + histos.fill(HIST("ROFbyROF/nPV_11x00"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + } + + if (vCombCond[k] && vCombCond[k - 1] && vCombCond[k + 1]) { + if (vCollRofId[k - 2] < vCollRofId[k] - 2 && vCollRofId[k - 1] == vCollRofId[k] - 1 && vCollRofId[k + 1] == vCollRofId[k] + 1 && vCollRofId[k + 2] > vCollRofId[k] + 2) // 01x10 + histos.fill(HIST("ROFbyROF/nPV_01x10"), vTracksITS567perColl[k - 1], vTracksITS567perColl[k]); + } + + if (vCombCond[k] && vCombCond[k + 1] && vCombCond[k + 2]) { + if (vCollRofId[k - 1] < vCollRofId[k] - 2 && vCollRofId[k + 1] == vCollRofId[k] + 1 && vCollRofId[k + 2] == vCollRofId[k] + 2) // 00x11 + histos.fill(HIST("ROFbyROF/nPV_00x11"), vTracksITS567perColl[k + 1], vTracksITS567perColl[k]); + } + + // many colls around + // histos.add("ROFbyROF/nPV_11x11", "", kTH2D, {{250, 0., 8000 * k}, {250, 0., 8000 * k}}); + } + + // save indices of collisions in time range for occupancy calculation + std::vector> vCollsInTimeWin; + std::vector> vCollsInSameITSROF; + std::vector> vTimeDeltaForColls; // delta time wrt a given collision + for (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 rofId = (foundGlobalBC + 3564 - rofOffset) / rofLength; + // int rofIdInTF = (bcInTF - rofOffset) / rofLength; + + // ### in-ROF occupancy + 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; + // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; + 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; + // int thisRofIdInTF = (thisBC - rofOffset) / rofLength; + int64_t thisRofId = (thisBC + 3564 - rofOffset) / rofLength; + if (thisRofId != rofId) + break; + vAssocToSameROF.push_back(maxColIndex); + maxColIndex++; + } + vCollsInSameITSROF.push_back(vAssocToSameROF); + + // ### 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 vNumTracksITS567inROF(cols.size(), 0); // counter of tracks in given ROF (excluding given event) + std::vector vSumAmpFT0CinROF(cols.size(), 0); // counter of tracks in given ROF (excluding given event) + std::vector vNumCollinROF(cols.size(), 0); // counter of tracks in given ROF (excluding given event) + std::vector vNumCollinROFinVz10(cols.size(), 0); // counter of tracks in given ROF (excluding given event) + std::vector vInROFcollIndex(cols.size(), 0); // counter of tracks in given ROF (excluding given event) + std::vector vROFidThisColl(cols.size(), 0); // counter of tracks in given ROF (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 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> vArrNoCollInSameRofWithCloseVz; //(cols.size(), 0); // to veto events with nearby collisions with close vZ + + for (auto& col : cols) { + int32_t colIndex = col.globalIndex(); + float vZ = col.posZ(); + + // QA: + if (vAmpFT0CperColl[colIndex] > 5000) { + histos.fill(HIST("hThisEvITStr_vs_vZ"), vZ, vTracksITS567perColl[colIndex]); + histos.fill(HIST("hThisEvITSTPCtr_vs_vZ"), vZ, vTracksITSTPCperColl[colIndex]); + } + + // ### in-ROF occupancy + // int64_t rofId = (vFoundGlobalBC[colIndex] + 3564 - rofOffset) / rofLength; + // int bcInTF = (vFoundGlobalBC[colIndex] - bcSOR) % nBCsPerTF; + int bcInITSROF = (vFoundGlobalBC[colIndex] + 3564 - rofOffset) % rofLength; + int rofIdInTF = (vFoundGlobalBC[colIndex] + 3564 - rofOffset) / rofLength; + // auto bc = bcs.iteratorAt(vFoundBCindex[colIndex]); + // LOGP(info, "#### starting new coll: bc={} bcInTF={} bcInITSROF={} rofId={}; noROFborder={}; rofOffset={} rofLength={}", vFoundGlobalBC[colIndex], bcInTF, bcInITSROF, rofId, bc.selection_bit(kNoITSROFrameBorder), rofOffset, rofLength); + // LOGP(info, "#### starting new coll: bcInTF={} bcInITSROF={} rofIdInTF={}; noROFborder={}, vZ={} mult={}; rofOffset={} rofLength={}", bcInTF, bcInITSROF, rofIdInTF, bc.selection_bit(kNoITSROFrameBorder), vZ, vTracksITS567perColl[colIndex], rofOffset, rofLength); + + std::vector vAssocToSameROF = vCollsInSameITSROF[colIndex]; + int nITS567tracksForRofVetoStrict = 0; // to veto events with other collisions in the same ITS ROF + float nSumAmplFT0CforRofVetoStrict = 0; // to veto events with other collisions in the same ITS ROF + // int nITS567tracksForRofVetoStandard = 0; // to veto events with other collisions in the same ITS ROF, with per-collision multiplicity above threshold + 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 + int nArrITS567tracksForRofVetoOnCloseVz[200] = {}; // to veto events with nearby collisions with close vZ + vNumCollinROF[colIndex] = 1; + vInROFcollIndex[colIndex] = 0; + vROFidThisColl[colIndex] = rofIdInTF; + + if (fabs(vZ) < 10) + vNumCollinROFinVz10[colIndex] = 1; + for (uint32_t iCol = 0; iCol < vAssocToSameROF.size(); iCol++) { + int thisColIndex = vAssocToSameROF[iCol]; + // int64_t thisRofId = (vFoundGlobalBC[thisColIndex] + 3564 - rofOffset) / rofLength; + // int thisBcInTF = (vFoundGlobalBC[thisColIndex] - bcSOR) % nBCsPerTF; + int thisBcInITSROF = (vFoundGlobalBC[thisColIndex] + 3564 - rofOffset) % rofLength; + // int thisRofIdInTF = (vFoundGlobalBC[thisColIndex] + 3564 - rofOffset) / rofLength; + // auto bcAssoc = bcs.iteratorAt(vFoundBCindex[thisColIndex]); + // 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) + nITS567tracksForRofVetoStrict += vTracksITS567perColl[thisColIndex]; + nSumAmplFT0CforRofVetoStrict += vAmpFT0CperColl[thisColIndex]; + vNumCollinROF[colIndex]++; + if (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 + + // if (vTracksITS567perColl[thisColIndex] > confNtracksCutVetoOnCollInROF) + // nITS567tracksForRofVetoStandard += vTracksITS567perColl[thisColIndex]; + + if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInROF) + nCollsInRofWithFT0CAboveVetoStandard++; + + if (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 (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)) + nArrITS567tracksForRofVetoOnCloseVz[i]++; + } + + if (fabs(vZ) < 10) { + histos.fill(HIST("hDeltaVz"), vCollVz[thisColIndex] - vZ); + if (vTracksITS567perColl[colIndex] >= 100 && vTracksITS567perColl[thisColIndex] < 100) + histos.fill(HIST("hDeltaVzGivenCollAbove100NearbyBelow100"), vCollVz[thisColIndex] - vZ); + if (vTracksITS567perColl[colIndex] <= 100 && vTracksITS567perColl[thisColIndex] > 100) + histos.fill(HIST("hDeltaVzGivenCollBelow100NearbyAbove100"), vCollVz[thisColIndex] - vZ); + if (vTracksITS567perColl[colIndex] > 20 && vTracksITS567perColl[thisColIndex] > 20) + histos.fill(HIST("hDeltaVzAfterCuts"), vCollVz[thisColIndex] - vZ); + if (col.sel8()) // bc.selection_bit(kIsTriggerTVX) && bc.selection_bit(kNoTimeFrameBorder) && bc.selection_bit(kNoITSROFrameBorder)) + histos.fill(HIST("hDeltaVzAfterTFandROFborderCuts"), vCollVz[thisColIndex] - vZ); + if (vTracksITS567perColl[colIndex] > 20 && vTracksITS567perColl[thisColIndex] > 20 && col.sel8()) // bc.selection_bit(kIsTriggerTVX) && bc.selection_bit(kNoTimeFrameBorder) && bc.selection_bit(kNoITSROFrameBorder)) + histos.fill(HIST("hDeltaVzAfterAllCuts"), vCollVz[thisColIndex] - vZ); + } + } + vNumTracksITS567inROF[colIndex] = nITS567tracksForRofVetoStrict; // occupancy in ROF (excluding a given collision) + vSumAmpFT0CinROF[colIndex] = nSumAmplFT0CforRofVetoStrict; // occupancy in ROF (excluding a given collision) + + // in-ROF occupancy flags + vNoCollInSameRofStrict[colIndex] = (nITS567tracksForRofVetoStrict == 0); + // vNoCollInSameRofStandard[colIndex] = (nITS567tracksForRofVetoStandard == 0); + vNoCollInSameRofStandard[colIndex] = (nCollsInRofWithFT0CAboveVetoStandard == 0); + vNoCollInSameRofWithCloseVz[colIndex] = (nITS567tracksForRofVetoOnCloseVz == 0); + + std::vector vVzCutThisColl; + + // ### 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; + // vNumTracksITS567inROF[colIndex] = -1; + vArrNoCollInSameRofWithCloseVz.push_back(vVzCutThisColl); + continue; + } + std::vector vAssocToThisCol = vCollsInTimeWin[colIndex]; + std::vector vCollsTimeDeltaWrtGivenColl = vTimeDeltaForColls[colIndex]; + int nITS567tracksInFullTimeWindow = 0; + int sumAmpFT0CInFullTimeWindow = 0; + int nITS567tracksForVetoNarrow = 0; // to veto events with nearby collisions (narrower range) + int nITS567tracksForVetoStrict = 0; // to veto events with nearby collisions + int nITS567tracksForVetoStandard = 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 + histos.fill(HIST("hDeltaTime"), dt); + if (vTracksITS567perColl[colIndex] > 50 && vTracksITS567perColl[thisColIndex] > 50) + histos.fill(HIST("hDeltaTimeAboveNtracksCut"), dt); + + if (fabs(vCollVz[colIndex]) < 10 && 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]) { + histos.fill(HIST("hDeltaTime_sel8_vZ10cm"), dt); + if (vTracksITS567perColl[colIndex] > 50 && vTracksITS567perColl[thisColIndex] > 50) + histos.fill(HIST("hDeltaTimeAboveNtracksCut_sel8_vZ10cm"), dt); + } + + float wOccup = 1.; + 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 + 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; + if (wOccup > 0) + histos.fill(HIST("hOccupancyWeights"), dt, wOccup); + } + nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex]; + sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex]; + + // counting tracks from other collisions in fixed time windows + if (fabs(dt) < confTimeRangeVetoOnCollNarrow) + nITS567tracksForVetoNarrow += vTracksITS567perColl[thisColIndex]; + if (fabs(dt) < confTimeRangeVetoOnCollStandard) + nITS567tracksForVetoStrict += vTracksITS567perColl[thisColIndex]; + + // if (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 + 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 + // 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 (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)) + 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); + + } 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)) + nITS567tracksForVetoVzDependent += vTracksITS567perColl[thisColIndex]; + + // FOR QA: + if (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) + histos.fill(HIST("hDeltaVzVsDeltaTime4"), vZ + dt * driftV - vCollVz[thisColIndex], dt); + } + } + } + vNumTracksITS567inFullTimeWin[colIndex] = nITS567tracksInFullTimeWindow; // occupancy by ITS tracks (without a current collision) + vSumAmpFT0CinFullTimeWin[colIndex] = sumAmpFT0CInFullTimeWindow; // occupancy by FT0C (without a current collision) + // occupancy flags based on nearby collisions + vNoCollInTimeRangeNarrow[colIndex] = (nITS567tracksForVetoNarrow == 0); + vNoCollInTimeRangeStrict[colIndex] = (nITS567tracksForVetoStrict == 0); + vNoHighMultCollInTimeRange[colIndex] = (nITS567tracksForVetoStandard == 0); + vNoCollInVzDependentTimeRange[colIndex] = (nITS567tracksForVetoVzDependent == 0); + + for (int i = 0; i < 200; i++) + vVzCutThisColl.push_back(nArrITS567tracksForRofVetoOnCloseVz[i] == 0); + vArrNoCollInSameRofWithCloseVz.push_back(vVzCutThisColl); + } + + for (auto& col : cols) { + int32_t colIndex = col.globalIndex(); + bool sel8 = col.sel8(); // bc.selection_bit(kIsTriggerTVX) && bc.selection_bit(kNoTimeFrameBorder) && bc.selection_bit(kNoITSROFrameBorder); + + float vZ = vCollVz[colIndex]; + int occTracks = col.trackOccupancyInTimeRange(); + float occFT0C = col.ft0cOccupancyInTimeRange(); + + if (sel8) { + // histos.fill(HIST("hColCounterAcc"),Form("%d", bc.runNumber()), 1); + if (vInROFcollIndex[colIndex] == 0) + histos.fill(HIST("hNcollPerROF"), vNumCollinROF[colIndex]); + + histos.fill(HIST("hVz"), vZ); + + int nPV = vTracksITS567perColl[colIndex]; + float ft0C = vAmpFT0CperColl[colIndex]; + + // ROF-by-ROF + if (fabs(vZ) < 8) { + histos.fill(HIST("ROFbyROF/nPV_vs_ROFid"), nPV, vCollRofIdPerOrbit[colIndex]); + histos.fill(HIST("ROFbyROF/nPV_vs_subROFid"), nPV, vCollRofSubIdPerOrbit[colIndex]); + + histos.fill(HIST("ROFbyROF/FT0C_vs_ROFid"), ft0C, vCollRofIdPerOrbit[colIndex]); + histos.fill(HIST("ROFbyROF/FT0C_vs_subROFid"), ft0C, vCollRofSubIdPerOrbit[colIndex]); + } + // vs occupancy + if (occTracks >= 0 && 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); + if (col.selection_bit(kNoCollInTimeRangeStrict)) + 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)) + histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInRofStandard"), nPV, occTracks); + if (col.selection_bit(kNoCollInTimeRangeStandard) && col.selection_bit(kNoCollInRofStandard)) + 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) + histos.fill(HIST("nPV_vs_occupancyByTracks/NoCollInTimeAndRofStrict_vZ_5cm"), nPV, occTracks); + } + if (occFT0C >= 0 && 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); + if (col.selection_bit(kNoCollInTimeRangeStrict)) + 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)) + histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInRofStandard"), nPV, occFT0C); + if (col.selection_bit(kNoCollInTimeRangeStandard) && col.selection_bit(kNoCollInRofStandard)) + 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) + histos.fill(HIST("nPV_vs_occupancyByFT0C/NoCollInTimeAndRofStrict_vZ_5cm"), nPV, occFT0C); + } + } + + if (occTracks >= 0) + histos.fill(HIST("hOccupancyByTracks_CROSSCHECK"), occTracks); + if (occFT0C >= 0) + histos.fill(HIST("hOccupancyByFT0C_CROSSCHECK"), occFT0C); + + if (vNumTracksITS567inFullTimeWin[colIndex] >= 0) { + histos.fill(HIST("hOccupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex]); + histos.fill(HIST("hOccupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex]); + + histos.fill(HIST("hOccupancyByTrInROF"), vNumTracksITS567inROF[colIndex]); + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + 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) { + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_vZ_TF_ROF_border_cuts"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + + // if (vAmpFT0CperColl[colIndex] > 5000 && vAmpFT0CperColl[colIndex] < 10000) { + // if (vAmpFT0CperColl[colIndex] > 500) { + if (vAmpFT0CperColl[colIndex] > 0) { // 50) { + + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTPCTr_vs_occupancyInROF"), vNumTracksITS567inROF[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNumTracksITS567inROF[colIndex] > 0) { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_HasNeighbours"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vTracksITS567perColl[colIndex]); + + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + } + + // two collisions in one ROF (both with |vZ|<10 cm) + if (vNumCollinROF[colIndex] == 2 && vNumCollinROFinVz10[colIndex] == 2 && vInROFcollIndex[colIndex] == 1) { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvFT0C_vs_occupancyFT0CInROF_2coll"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + + if (vNumTracksITS567inROF[colIndex] > vTracksITS567perColl[colIndex]) { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + if (vNumTracksITS567inROF[colIndex] > 0) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1"), vNumTracksITS567inROF[colIndex], 1.0 * vTracksITS567perColl[colIndex] / vNumTracksITS567inROF[colIndex]); + + } else { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins"), vTracksITS567perColl[colIndex], vNumTracksITS567inROF[colIndex]); + + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_allOccup_2coll_inROF"), vTracksITS567perColl[colIndex]); + if (occTracks < 500) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_lowOccup_2coll_inROF"), vTracksITS567perColl[colIndex]); + else if (occTracks > 1000) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_highOccup_2coll_inROF"), vTracksITS567perColl[colIndex]); + + if (vTracksITS567perColl[colIndex] > 0) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex], 1.0 * vNumTracksITS567inROF[colIndex] / vTracksITS567perColl[colIndex]); + } + } + + // 3 or 4 collisions in one ROF + if (vNumCollinROF[colIndex] == 2 && vInROFcollIndex[colIndex] == 1) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_2coll_noVzCutOnOtherVertices"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] == 3 && vInROFcollIndex[colIndex] == 1) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_3coll_noVzCutOnOtherVertices"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] == 4 && vInROFcollIndex[colIndex] == 1) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInROF_4coll_noVzCutOnOtherVertices"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + + // now 1D histograms vs nCollInROF + if (vNumCollinROF[colIndex] == 1) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_1coll_in_ROF"), vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] == 2) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_2coll_in_ROF"), vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] == 3) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_3coll_in_ROF"), vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] == 4) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_4coll_in_ROF"), vTracksITS567perColl[colIndex]); + if (vNumCollinROF[colIndex] >= 5) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_5collOrMore_in_ROF"), vTracksITS567perColl[colIndex]); + + // compare with previous ROF + if (colIndex - 1 >= 0) { + if (vNumCollinROF[colIndex] == 1 && vNumCollinROFinVz10[colIndex] == 1 && vInROFcollIndex[colIndex] == 0 && vNumCollinROF[colIndex - 1] == 1 && vNumCollinROFinVz10[colIndex - 1] == 1 && vInROFcollIndex[colIndex - 1] == 0) { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInAnotherEarlierROF_1collPerROF"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vROFidThisColl[colIndex] == vROFidThisColl[colIndex - 1] + 1) // one ROF right after the previous + { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vTracksITS567perColl[colIndex - 1] > vTracksITS567perColl[colIndex]) { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vTracksITS567perColl[colIndex - 1] > 0) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex - 1], 1.0 * vTracksITS567perColl[colIndex] / vTracksITS567perColl[colIndex - 1]); + } else { + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins"), vTracksITS567perColl[colIndex], vTracksITS567perColl[colIndex - 1]); + + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_allOccup_1collPerROF"), vTracksITS567perColl[colIndex]); + if (occTracks < 500) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_lowOccup_1collPerROF"), vTracksITS567perColl[colIndex]); + else if (occTracks > 1000) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_highOccup_1collPerROF"), vTracksITS567perColl[colIndex]); + + if (vTracksITS567perColl[colIndex] > 0) + histos.fill(HIST("vZ_TF_ROF_border_cuts/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex], 1.0 * vTracksITS567perColl[colIndex - 1] / vTracksITS567perColl[colIndex]); + } + } + } + } + } + + if (vNoCollInTimeRangeNarrow[colIndex]) + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_afterNarrowDeltaTimeCut"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + if (vNoCollInTimeRangeStrict[colIndex]) + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_afterStrictDeltaTimeCut"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + if (vNoHighMultCollInTimeRange[colIndex]) + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_afterStandardDeltaTimeCut"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + if (vNoCollInVzDependentTimeRange[colIndex]) + histos.fill(HIST("hOccupancyByFT0C_vs_ByTracks_afterVzDependentDeltaTimeCut"), vNumTracksITS567inFullTimeWin[colIndex], vSumAmpFT0CinFullTimeWin[colIndex]); + + // same-event 2D correlations: + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/vZ_TF_ROF_border_cuts"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + + if (vNoCollInTimeRangeNarrow[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/afterNarrowDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (vNoCollInTimeRangeStrict[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/afterStrictDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (vNoHighMultCollInTimeRange[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/afterStandardDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (vNoCollInVzDependentTimeRange[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/afterVzDependentDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + + if (vNoCollInSameRofStrict[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofStrict"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (vNoCollInSameRofStandard[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofStandard"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (vNoCollInSameRofWithCloseVz[colIndex]) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/kNoCollInRofWithCloseVz"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + + // CROSS CHECK WITH SEL BITS: + if (col.selection_bit(kNoCollInTimeRangeNarrow)) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_afterNarrowDeltaTimeCut"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + if (col.selection_bit(kNoCollInTimeRangeStrict)) + 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]); + if (col.selection_bit(kNoCollInRofStandard)) + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/CROSSCHECK_kNoCollInRofStandard"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + + if (vNumTracksITS567inFullTimeWin[colIndex] < 2000) { + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/occupBelow2000"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/hThisEvITSTPCTr_vs_ThisEvFT0C_occupBelow2000"), vAmpFT0CperColl[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInTimeRangeNarrow[colIndex] && vNoHighMultCollInTimeRange[colIndex] && vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) { + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/NarrowDeltaCut_StdTimeAndRofCuts"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + + if (vNumTracksITS567inFullTimeWin[colIndex] < 2000) { + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/NarrowDeltaCut_StdTimeAndRofCuts_occupBelow2000"), vAmpFT0CperColl[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("hThisEvITSTr_vs_ThisEvFT0C/hThisEvITSTPCTr_vs_ThisEvFT0C_NarrowDeltaCut_StdTimeAndRofCuts_occupBelow2000"), vAmpFT0CperColl[colIndex], vTracksITSTPCperColl[colIndex]); + } + } + + // now ITSTPC vs ITS tr (this event) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/vZ_TF_ROF_border_cuts"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNoCollInTimeRangeNarrow[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/afterNarrowDeltaTimeCut"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNoCollInTimeRangeStrict[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/afterStrictDeltaTimeCut"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNoHighMultCollInTimeRange[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/afterStandardDeltaTimeCut"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNoCollInVzDependentTimeRange[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/afterVzDependentDeltaTimeCut"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNoCollInSameRofStrict[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofStrict"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNoCollInSameRofStandard[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofStandard"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNoCollInSameRofWithCloseVz[colIndex]) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/kNoCollInRofWithCloseVz"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNumTracksITS567inFullTimeWin[colIndex] < 2000) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNoCollInTimeRangeNarrow[colIndex] && vNoHighMultCollInTimeRange[colIndex] && vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) { + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/NarrowDeltaCut_StdTimeAndRofCuts"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + if (vNumTracksITS567inFullTimeWin[colIndex] < 2000) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000_NarrowDeltaCut_StdTimeAndRofCuts"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInTimeRangeStrict[colIndex] && vNoCollInSameRofStrict[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) { + if (vNumTracksITS567inFullTimeWin[colIndex] < 2000) + histos.fill(HIST("hThisEvITSTPCTr_vs_ThisEvITStr/occupBelow2000_StrictDeltaTimeCutAndRofCuts"), vTracksITS567perColl[colIndex], vTracksITSTPCperColl[colIndex]); + } + + // vZ bins to tune vZthresh cut + if (vNoCollInTimeRangeNarrow[colIndex]) { + + for (int i = 0; i < 200; i++) { + if (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]); + } + } + } + + // ### this event vs Occupancy 2D histos + // if (vAmpFT0CperColl[colIndex] > 5000 && vAmpFT0CperColl[colIndex] < 10000) { + // if (vAmpFT0CperColl[colIndex] > 500) { + if (vAmpFT0CperColl[colIndex] > 0) { // 100) { + + if (vNoCollInTimeRangeNarrow[colIndex]) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyInROF"), vNumTracksITS567inROF[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNumTracksITS567inROF[colIndex] > 0) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_HasNeighbours"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vTracksITS567perColl[colIndex]); + + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + } + + if (vNumCollinROF[colIndex] == 2 && vNumCollinROFinVz10[colIndex] == 2 && vInROFcollIndex[colIndex] == 1) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvFT0C_vs_occupancyFT0CInROF_2coll"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + + if (vNumTracksITS567inROF[colIndex] > vTracksITS567perColl[colIndex]) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + if (vNumTracksITS567inROF[colIndex] > 0) + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1"), vNumTracksITS567inROF[colIndex], 1.0 * vTracksITS567perColl[colIndex] / vNumTracksITS567inROF[colIndex]); + } else { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins"), vTracksITS567perColl[colIndex], vNumTracksITS567inROF[colIndex]); + if (vTracksITS567perColl[colIndex] > 0) + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInROF_2coll_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex], 1.0 * vNumTracksITS567inROF[colIndex] / vTracksITS567perColl[colIndex]); + } + + // the sum of v1 and v2: + if (vSumAmpFT0CinROF[colIndex] > 4000 && vAmpFT0CperColl[colIndex] > 4000) + histos.fill(HIST("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_inROF"), vTracksITS567perColl[colIndex] + vNumTracksITS567inROF[colIndex]); + } + // compare with previous ROF + if (colIndex - 1 >= 0) { + if (vNumCollinROF[colIndex] == 1 && vNumCollinROFinVz10[colIndex] == 1 && vInROFcollIndex[colIndex] == 0 && vNumCollinROF[colIndex - 1] == 1 && vNumCollinROFinVz10[colIndex - 1] == 1 && vInROFcollIndex[colIndex - 1] == 0) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInAnotherEarlierROF_1collPerROF"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vROFidThisColl[colIndex] == vROFidThisColl[colIndex - 1] + 1) // one ROF right after the previous + { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + + if (vTracksITS567perColl[colIndex - 1] > vTracksITS567perColl[colIndex]) { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vTracksITS567perColl[colIndex - 1] > 0) + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex - 1], 1.0 * vTracksITS567perColl[colIndex] / vTracksITS567perColl[colIndex - 1]); + } else { + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins"), vTracksITS567perColl[colIndex], vTracksITS567perColl[colIndex - 1]); + if (vTracksITS567perColl[colIndex] > 0) + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPreviousROF_1collPerROF_XaxisWins_RatioV2toV1"), vTracksITS567perColl[colIndex], 1.0 * vTracksITS567perColl[colIndex - 1] / vTracksITS567perColl[colIndex]); + } + // the sum of v1 and v2: + if (vAmpFT0CperColl[colIndex] > 4000 && vAmpFT0CperColl[colIndex - 1] > 4000) + histos.fill(HIST("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFprevROF"), vTracksITS567perColl[colIndex] + vTracksITS567perColl[colIndex - 1]); + } else if (vROFidThisColl[colIndex] == vROFidThisColl[colIndex - 1] + 2) { + // ROF vs ROF-2 + histos.fill(HIST("afterNarrowDeltaTimeCut/hThisEvITSTr_vs_occupancyInPrevPrevROF_1collPerROF"), vTracksITS567perColl[colIndex - 1], vTracksITS567perColl[colIndex]); + if (vAmpFT0CperColl[colIndex] > 4000 && vAmpFT0CperColl[colIndex - 1] > 4000) + histos.fill(HIST("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFprevPrevROF"), vTracksITS567perColl[colIndex] + vTracksITS567perColl[colIndex - 1]); + } else { + // ROF is earlier than previous + // the sum of v1 and v2: + if (vAmpFT0CperColl[colIndex] > 4000 && vAmpFT0CperColl[colIndex - 1] > 4000) + histos.fill(HIST("afterNarrowDeltaTimeCut/hSum_2coll_withFT0above4000_thisROFearlierThanPrevPrevROF"), vTracksITS567perColl[colIndex] + vTracksITS567perColl[colIndex - 1]); + } + } + } + } + if (vNoCollInTimeRangeStrict[colIndex]) { + histos.fill(HIST("afterStrictDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterStrictDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("afterStrictDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterStrictDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + if (vNoHighMultCollInTimeRange[colIndex]) { + histos.fill(HIST("afterStandardDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterStandardDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("afterStandardDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterStandardDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInVzDependentTimeRange[colIndex]) { + histos.fill(HIST("afterVzDependentDeltaTimeCut/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterVzDependentDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("afterVzDependentDeltaTimeCut/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("afterVzDependentDeltaTimeCut/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInSameRofStrict[colIndex]) { + histos.fill(HIST("kNoCollInRofStrict/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofStrict/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("kNoCollInRofStrict/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofStrict/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInSameRofStandard[colIndex]) { + histos.fill(HIST("kNoCollInRofStandard/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofStandard/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("kNoCollInRofStandard/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofStandard/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + + if (vNoCollInSameRofWithCloseVz[colIndex]) { + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + + if (vNumTracksITS567inROF[colIndex] > 0) { + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyInROF_HasNeighbours"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vTracksITS567perColl[colIndex]); + + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvFT0C_vs_occupancyFT0CInROF_HasNeighbours"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + } + + if (vNumCollinROF[colIndex] == 2 && vNumCollinROFinVz10[colIndex] == 2 && vInROFcollIndex[colIndex] == 1) { + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvITSTr_vs_occupancyInROF_2coll"), vNumTracksITS567inROF[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("kNoCollInRofWithCloseVz/hThisEvFT0C_vs_occupancyFT0CInROF_2coll"), vSumAmpFT0CinROF[colIndex], vAmpFT0CperColl[colIndex]); + } + } + + if (vNoCollInTimeRangeNarrow[colIndex] && vNoHighMultCollInTimeRange[colIndex] && vNoCollInSameRofStandard[colIndex] && vNoCollInSameRofWithCloseVz[colIndex]) { + histos.fill(HIST("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTPCTr_vs_occupancyByFT0C"), vSumAmpFT0CinFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + histos.fill(HIST("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITS567perColl[colIndex]); + histos.fill(HIST("NarrowDeltaCut_StdTimeAndRofCuts/hThisEvITSTPCTr_vs_occupancyByTracks"), vNumTracksITS567inFullTimeWin[colIndex], vTracksITSTPCperColl[colIndex]); + } + } + } + } + } + } + + PROCESS_SWITCH(RofOccupancyQaTask, processRun3, "Process Run3 ROF occupancy QA", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/DPG/Tasks/AOTTrack/PID/HMPID/CMakeLists.txt b/DPG/Tasks/AOTTrack/PID/HMPID/CMakeLists.txt index 9d153069976..763c9105528 100644 --- a/DPG/Tasks/AOTTrack/PID/HMPID/CMakeLists.txt +++ b/DPG/Tasks/AOTTrack/PID/HMPID/CMakeLists.txt @@ -14,3 +14,8 @@ o2physics_add_dpl_workflow(pid-hmpid-qa SOURCES qaHMPID.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(pid-hmpid + SOURCES analysisHMPID.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/DPG/Tasks/AOTTrack/PID/HMPID/analysisHMPID.cxx b/DPG/Tasks/AOTTrack/PID/HMPID/analysisHMPID.cxx new file mode 100644 index 00000000000..c5a6b9d0597 --- /dev/null +++ b/DPG/Tasks/AOTTrack/PID/HMPID/analysisHMPID.cxx @@ -0,0 +1,137 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +#include "ReconstructionDataFormats/Track.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "ReconstructionDataFormats/TrackParametrization.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" +#include "ReconstructionDataFormats/PID.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/ASoA.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ + +namespace variables_table // declaration of columns to create +{ +DECLARE_SOA_COLUMN(ChAngle, chAngle, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(MomentumHMPID, momentumHMPID, float); +DECLARE_SOA_COLUMN(MomentumTrack, momentumTrack, float); +DECLARE_SOA_COLUMN(Xtrack, xtrack, float); +DECLARE_SOA_COLUMN(Ytrack, ytrack, float); +DECLARE_SOA_COLUMN(Xmip, xmip, float); +DECLARE_SOA_COLUMN(Ymip, ymip, float); +DECLARE_SOA_COLUMN(Nphotons, nphotons, float); +DECLARE_SOA_COLUMN(ChargeMIP, chargeMIP, float); +DECLARE_SOA_COLUMN(ClusterSize, clustersize, float); +DECLARE_SOA_COLUMN(Chamber, chamber, float); +DECLARE_SOA_COLUMN(Photons_charge, photons_charge, float[10]); + +DECLARE_SOA_COLUMN(EtaTrack, etatrack, float); +DECLARE_SOA_COLUMN(PhiTrack, phitrack, float); + +DECLARE_SOA_COLUMN(ITSNcluster, itsNcluster, float); +DECLARE_SOA_COLUMN(TPCNcluster, tpcNcluster, float); +DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, float); +DECLARE_SOA_COLUMN(TPCchi2, tpcChi2, float); +DECLARE_SOA_COLUMN(ITSchi2, itsChi2, float); + +DECLARE_SOA_COLUMN(DCAxy, dcaxy, float); +DECLARE_SOA_COLUMN(DCAz, dcaz, float); + +DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNsigmaPi, float); +DECLARE_SOA_COLUMN(TOFNSigmaPi, tofNsigmaPi, float); +DECLARE_SOA_COLUMN(TPCNSigmaKa, tpcNsigmaKa, float); +DECLARE_SOA_COLUMN(TOFNSigmaKa, tofNsigmaKa, float); +DECLARE_SOA_COLUMN(TPCNSigmaPr, tpcNsigmaPr, float); +DECLARE_SOA_COLUMN(TOFNSigmaPr, tofNsigmaPr, float); +DECLARE_SOA_COLUMN(TPCNSigmaDe, tpcNsigmaDe, float); +DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNsigmaDe, float); + +} // namespace variables_table + +DECLARE_SOA_TABLE(HMPID_analysis, "AOD", "HMPIDANALYSIS", + variables_table::ChAngle, variables_table::Phi, variables_table::Eta, variables_table::MomentumHMPID, + variables_table::MomentumTrack, variables_table::Xtrack, variables_table::Ytrack, variables_table::Xmip, + variables_table::Ymip, variables_table::Nphotons, variables_table::ChargeMIP, variables_table::ClusterSize, + variables_table::Chamber, variables_table::Photons_charge, variables_table::EtaTrack, variables_table::PhiTrack, + variables_table::ITSNcluster, variables_table::TPCNcluster, variables_table::TPCNClsCrossedRows, + variables_table::TPCchi2, variables_table::ITSchi2, variables_table::DCAxy, variables_table::DCAz, + variables_table::TPCNSigmaPi, variables_table::TOFNSigmaPi, variables_table::TPCNSigmaKa, variables_table::TOFNSigmaKa, + variables_table::TPCNSigmaPr, variables_table::TOFNSigmaPr, variables_table::TPCNSigmaDe, variables_table::TOFNSigmaDe); +} // namespace o2::aod + +struct pidHmpidAnalysis { + + Produces HMPID_analysis; + + // using TrackCandidates = soa::Join; + + using CollisionCandidates = o2::soa::Join; + + using TrackCandidates = soa::Join; + + void process(const aod::HMPIDs& hmpids, + TrackCandidates const&, + CollisionCandidates const&) + { + + for (const auto& t : hmpids) { + if (t.track_as().isGlobalTrack() != (uint8_t) true) { + continue; + } + + const auto& track = t.track_as(); + + if (!track.hasITS() || !track.hasTPC() || !track.hasTOF()) { + continue; + } + + float hmpidPhotsCharge2[10]; + + for (int i = 0; i < 10; i++) { + hmpidPhotsCharge2[i] = t.hmpidPhotsCharge()[i]; + } + + /////FILL TABLE + HMPID_analysis(t.hmpidSignal(), t.track_as().phi(), t.track_as().eta(), t.hmpidMom(), + track.p(), t.hmpidXTrack(), t.hmpidYTrack(), t.hmpidXMip(), + t.hmpidYMip(), t.hmpidNPhotons(), t.hmpidQMip(), (t.hmpidClusSize() % 1000000) / 1000, t.hmpidClusSize() / 1000000, + hmpidPhotsCharge2, track.eta(), track.phi(), track.itsNCls(), track.tpcNClsFound(), track.tpcNClsCrossedRows(), + track.tpcChi2NCl(), track.itsChi2NCl(), track.dcaXY(), track.dcaZ(), + track.tpcNSigmaPi(), track.tofNSigmaPi(), track.tpcNSigmaKa(), track.tofNSigmaKa(), + track.tpcNSigmaPr(), track.tofNSigmaPr(), track.tpcNSigmaDe(), track.tofNSigmaDe()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfg) { return WorkflowSpec{adaptAnalysisTask(cfg)}; } diff --git a/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx b/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx index aff95a901dd..78aeb2be252 100644 --- a/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx +++ b/DPG/Tasks/AOTTrack/PID/HMPID/qaHMPID.cxx @@ -14,16 +14,74 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" +#include "ReconstructionDataFormats/TrackParametrization.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" +#include "ReconstructionDataFormats/PID.h" +#include "Common/Core/trackUtilities.h" +#include "ReconstructionDataFormats/DCA.h" #include "Framework/ASoAHelpers.h" +#include "Framework/ASoA.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +namespace o2::aod +{ + +namespace variables_table // declaration of columns to create +{ +DECLARE_SOA_COLUMN(ChAngle, chAngle, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(MomHMPID, momMPID, float); +DECLARE_SOA_COLUMN(MomTrackX, momTrackX, float); +DECLARE_SOA_COLUMN(MomTrackY, momTrackY, float); +DECLARE_SOA_COLUMN(MomTrackZ, momTrackZ, float); +DECLARE_SOA_COLUMN(Xtrack, xtrack, float); +DECLARE_SOA_COLUMN(Ytrack, ytrack, float); +DECLARE_SOA_COLUMN(Xmip, xmip, float); +DECLARE_SOA_COLUMN(Ymip, ymip, float); +DECLARE_SOA_COLUMN(Nphotons, nphotons, float); +DECLARE_SOA_COLUMN(ChargeMIP, chargeMIP, float); +DECLARE_SOA_COLUMN(ClusterSize, clustersize, float); +DECLARE_SOA_COLUMN(Chamber, chamber, float); +DECLARE_SOA_COLUMN(Photons_charge, photons_charge, float[10]); + +DECLARE_SOA_COLUMN(EtaTrack, etatrack, float); +DECLARE_SOA_COLUMN(PhiTrack, phitrack, float); + +DECLARE_SOA_COLUMN(ITSNcluster, itsNcluster, float); +DECLARE_SOA_COLUMN(TPCNcluster, tpcNcluster, float); +DECLARE_SOA_COLUMN(TPCNClsCrossedRows, tpcNClsCrossedRows, float); +DECLARE_SOA_COLUMN(TPCchi2, tpcChi2, float); +DECLARE_SOA_COLUMN(ITSchi2, itsChi2, float); + +DECLARE_SOA_COLUMN(DCAxy, dcaxy, float); +DECLARE_SOA_COLUMN(DCAz, dcaz, float); + +} // namespace variables_table + +DECLARE_SOA_TABLE(HMPID_analysis, "AOD", "HMPIDANALYSIS", + variables_table::ChAngle, variables_table::Phi, variables_table::Eta, variables_table::MomHMPID, + variables_table::MomTrackX, variables_table::MomTrackY, variables_table::MomTrackZ, + variables_table::Xtrack, variables_table::Ytrack, variables_table::Xmip, + variables_table::Ymip, variables_table::Nphotons, variables_table::ChargeMIP, variables_table::ClusterSize, + variables_table::Chamber, variables_table::Photons_charge, variables_table::EtaTrack, variables_table::PhiTrack, + variables_table::ITSNcluster, variables_table::TPCNcluster, variables_table::TPCNClsCrossedRows, + variables_table::TPCchi2, variables_table::ITSchi2, variables_table::DCAxy, variables_table::DCAz); +} // namespace o2::aod + struct pidHmpidQa { + + Produces HMPID_analysis; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Configurable nBinsP{"nBinsP", 500, "Number of momentum bins"}; Configurable minP{"minP", 0.01f, "Minimum momentum plotted (GeV/c)"}; @@ -73,21 +131,37 @@ struct pidHmpidQa { void process(const aod::HMPIDs& hmpids, const TrackCandidates& /*tracks*/, const aod::Collisions& /*colls*/) + { for (const auto& t : hmpids) { if (t.track_as().isGlobalTrack() != (uint8_t) true) { continue; } - if (abs(t.track_as().dcaXY()) > maxDCA) { + + const auto& track = t.track_as(); + + if (!track.hasITS() || !track.hasTPC() || !track.hasTOF()) { continue; } + float hmpidPhotsCharge2[10]; + + for (int i = 0; i < 10; i++) { + hmpidPhotsCharge2[i] = t.hmpidPhotsCharge()[i]; + } + + HMPID_analysis(t.hmpidSignal(), t.track_as().phi(), t.track_as().eta(), t.hmpidMom(), + track.px(), track.py(), track.pz(), t.hmpidXTrack(), t.hmpidYTrack(), t.hmpidXMip(), + t.hmpidYMip(), t.hmpidNPhotons(), t.hmpidQMip(), (t.hmpidClusSize() % 1000000) / 1000, t.hmpidClusSize() / 1000000, + hmpidPhotsCharge2, track.eta(), track.phi(), track.itsNCls(), track.tpcNClsFound(), track.tpcNClsCrossedRows(), + track.tpcChi2NCl(), track.itsChi2NCl(), track.dcaXY(), track.dcaZ()); + 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("hmpidXTrack"), t.hmpidYTrack()); + histos.fill(HIST("hmpidXTrack"), t.hmpidXTrack()); histos.fill(HIST("hmpidYTrack"), t.hmpidYTrack()); histos.fill(HIST("hmpidXMip"), t.hmpidXMip()); histos.fill(HIST("hmpidYMip"), t.hmpidYMip()); diff --git a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx index 8c1aeca6483..d1420da31fc 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOF.cxx @@ -137,6 +137,8 @@ struct tofPidQa { 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 requireGoodMatchTracks{"requireGoodMatchTracks", false, "Require good match tracks"}; + Configurable pvContributorsMin{"pvContributorsMin", -10, "Minimum pvContributors"}; + Configurable pvContributorsMax{"pvContributorsMax", 10000, "Maximum pvContributors"}; template void initPerParticle(const AxisSpec& pAxis, @@ -282,6 +284,8 @@ struct tofPidQa { h->GetXaxis()->SetBinLabel(1, "Events read"); h->GetXaxis()->SetBinLabel(2, "Passed ev. sel."); h->GetXaxis()->SetBinLabel(3, "Passed vtx Z"); + h->GetXaxis()->SetBinLabel(4, Form("Passed pvContributorsMin %f", pvContributorsMin.value)); + h->GetXaxis()->SetBinLabel(5, Form("Passed pvContributorsMax %f", pvContributorsMax.value)); h = histos.add("event/trackselection", "", kTH1D, {{10, 0.5, 10.5, "Selection passed"}}); h->GetXaxis()->SetBinLabel(1, "Tracks read"); @@ -375,11 +379,30 @@ struct tofPidQa { } } } - if (abs(collision.posZ()) > 10.f) { + if (std::abs(collision.posZ()) > 10.f) { return false; } + // Count the number of contributors + int pvContributors = 0; + for (const auto& trk : tracks) { + if (trk.isPVContributor()) { + pvContributors++; + } + } + if (pvContributors < pvContributorsMin) { + return false; + } + if constexpr (fillHistograms) { + histos.fill(HIST("event/evsel"), 4); + } + if (pvContributors > pvContributorsMax) { + return false; + } + if constexpr (fillHistograms) { + histos.fill(HIST("event/evsel"), 5); + } if constexpr (fillHistograms) { - histos.fill(HIST("event/evsel"), 3); + histos.fill(HIST("event/evsel"), 6); histos.fill(HIST("event/vertexz"), collision.posZ()); histos.fill(HIST("event/evtime/colltime"), collision.collisionTime() * 1000.f); @@ -505,7 +528,7 @@ struct tofPidQa { } 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/TOF/qaPIDTOFBeta.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx index a550dfbd120..fe928c0ddc3 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFBeta.cxx @@ -48,6 +48,8 @@ struct tofPidBetaQa { 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&) { @@ -61,7 +63,7 @@ struct tofPidBetaQa { 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, "#it{p}/z (GeV/#it{c})"}; + 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) { @@ -126,51 +128,51 @@ struct tofPidBetaQa { // TOF beta if (splitSignalPerCharge) { - histos.add("tofbeta/inclusive", "", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); + histos.add("tofbeta/inclusive", "", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); if (splitSignalPerEvTime) { - histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); + 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, {pAxisPosNeg, betaAxis, chargeAxis}); + histos.add("tofbeta/trd/inclusive", "(hasTRD)", HistType::kTH3F, {pAxis, betaAxis, chargeAxis}); if (splitSignalPerEvTime) { - histos.add("tofbeta/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); + 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, {pAxisPosNeg, 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, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); - histos.add("tofbeta/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH3F, {pAxisPosNeg, betaAxis, chargeAxis}); + 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, {pAxis, betaAxis}); + histos.add("tofbeta/inclusive", "", HistType::kTH2F, {pAxisPosNeg, betaAxis}); if (splitSignalPerEvTime) { - histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, betaAxis}); + 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, {pAxis, betaAxis}); + histos.add("tofbeta/trd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); if (splitSignalPerEvTime) { - histos.add("tofbeta/trd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/trd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/trd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/trd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); + 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, {pAxis, betaAxis}); + histos.add("tofbeta/notrd/inclusive", "(hasTRD)", HistType::kTH2F, {pAxisPosNeg, betaAxis}); if (splitSignalPerEvTime) { - histos.add("tofbeta/notrd/EvTimeTOF", "Ev. Time TOF (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/notrd/EvTimeTOFOnly", "Ev. Time TOF Only (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/notrd/EvTimeT0AC", "Ev. Time T0AC (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/notrd/EvTimeT0ACOnly", "Ev. Time T0AC Only (hasTRD)", HistType::kTH2F, {pAxis, betaAxis}); + 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}); } } } @@ -193,7 +195,7 @@ struct tofPidBetaQa { h->GetXaxis()->SetBinLabel(1, "Tracks read"); h->GetXaxis()->SetBinLabel(2, "hasTOF"); h->GetXaxis()->SetBinLabel(3, "isGlobalTrack"); - h->GetXaxis()->SetBinLabel(4, "goodTOFMatch"); + h->GetXaxis()->SetBinLabel(4, TString::Format("TOF chi2 < %.2f", mMaxTOFChi2.value)); } Filter eventFilter = (applyEvSel.node() == 0) || @@ -205,6 +207,7 @@ struct tofPidBetaQa { ((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 mMaxTOFChi2) { // Skipping tracks with large Chi2 continue; } histos.fill(HIST("event/trackselection"), 4.f); @@ -327,24 +330,25 @@ struct tofPidBetaQa { } } } else { - histos.fill(HIST("tofmass/notrd/inclusive"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/notrd/inclusive"), track.p(), track.beta()); + const float signedp = track.p() * track.sign(); + histos.fill(HIST("tofmass/notrd/inclusive"), signedp, track.mass()); + histos.fill(HIST("tofbeta/notrd/inclusive"), signedp, track.beta()); if (splitSignalPerEvTime) { if (track.isEvTimeTOF()) { - histos.fill(HIST("tofmass/notrd/EvTimeTOF"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/notrd/EvTimeTOF"), track.p(), track.beta()); + histos.fill(HIST("tofmass/notrd/EvTimeTOF"), signedp, track.mass()); + histos.fill(HIST("tofbeta/notrd/EvTimeTOF"), signedp, track.beta()); } if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { - histos.fill(HIST("tofmass/notrd/EvTimeTOFOnly"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/notrd/EvTimeTOFOnly"), track.p(), track.beta()); + histos.fill(HIST("tofmass/notrd/EvTimeTOFOnly"), signedp, track.mass()); + histos.fill(HIST("tofbeta/notrd/EvTimeTOFOnly"), signedp, track.beta()); } if (track.isEvTimeT0AC()) { - histos.fill(HIST("tofmass/notrd/EvTimeT0AC"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/notrd/EvTimeT0AC"), track.p(), track.beta()); + histos.fill(HIST("tofmass/notrd/EvTimeT0AC"), signedp, track.mass()); + histos.fill(HIST("tofbeta/notrd/EvTimeT0AC"), signedp, track.beta()); } if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { - histos.fill(HIST("tofmass/notrd/EvTimeT0ACOnly"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/notrd/EvTimeT0ACOnly"), track.p(), track.beta()); + histos.fill(HIST("tofmass/notrd/EvTimeT0ACOnly"), signedp, track.mass()); + histos.fill(HIST("tofbeta/notrd/EvTimeT0ACOnly"), signedp, track.beta()); } } } @@ -384,24 +388,25 @@ struct tofPidBetaQa { } } } else { - histos.fill(HIST("tofmass/trd/inclusive"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/trd/inclusive"), track.p(), track.beta()); + const float signedp = track.p() * track.sign(); + histos.fill(HIST("tofmass/trd/inclusive"), signedp, track.mass()); + histos.fill(HIST("tofbeta/trd/inclusive"), signedp, track.beta()); if (splitSignalPerEvTime) { if (track.isEvTimeTOF()) { - histos.fill(HIST("tofmass/trd/EvTimeTOF"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/trd/EvTimeTOF"), track.p(), track.beta()); + histos.fill(HIST("tofmass/trd/EvTimeTOF"), signedp, track.mass()); + histos.fill(HIST("tofbeta/trd/EvTimeTOF"), signedp, track.beta()); } if (track.isEvTimeTOF() && !track.isEvTimeT0AC()) { - histos.fill(HIST("tofmass/trd/EvTimeTOFOnly"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/trd/EvTimeTOFOnly"), track.p(), track.beta()); + histos.fill(HIST("tofmass/trd/EvTimeTOFOnly"), signedp, track.mass()); + histos.fill(HIST("tofbeta/trd/EvTimeTOFOnly"), signedp, track.beta()); } if (track.isEvTimeT0AC()) { - histos.fill(HIST("tofmass/trd/EvTimeT0AC"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/trd/EvTimeT0AC"), track.p(), track.beta()); + histos.fill(HIST("tofmass/trd/EvTimeT0AC"), signedp, track.mass()); + histos.fill(HIST("tofbeta/trd/EvTimeT0AC"), signedp, track.beta()); } if (track.isEvTimeT0AC() && !track.isEvTimeTOF()) { - histos.fill(HIST("tofmass/trd/EvTimeT0ACOnly"), track.p(), track.mass()); - histos.fill(HIST("tofbeta/trd/EvTimeT0ACOnly"), track.p(), track.beta()); + histos.fill(HIST("tofmass/trd/EvTimeT0ACOnly"), signedp, track.mass()); + histos.fill(HIST("tofbeta/trd/EvTimeT0ACOnly"), signedp, track.beta()); } } } @@ -410,7 +415,4 @@ struct tofPidBetaQa { } }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFEvTime.cxx b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFEvTime.cxx index 9895afab68a..e5ca7df21cc 100644 --- a/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFEvTime.cxx +++ b/DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFEvTime.cxx @@ -28,6 +28,7 @@ #include "Common/TableProducer/PID/pidTOFBase.h" #include "Framework/runDataProcessing.h" #include "CommonConstants/LHCConstants.h" +#include "DataFormatsFT0/Digit.h" using namespace o2; using namespace o2::framework; @@ -68,166 +69,170 @@ struct tofPidCollisionTimeQa { const AxisSpec deltaAxis{1000, -10000, 10000, "t-t_{ev}-t_{exp}(#pi) (ps)"}; const AxisSpec lengthAxis{1000, 0, 600, "Track length (cm)"}; - auto h = histos.add("eventSelection", "eventSelection", kTH1F, {{10, 0, 10, "Cut passed"}}); - h->GetXaxis()->SetBinLabel(1, "Events read"); - h->GetXaxis()->SetBinLabel(2, "Event selection"); - h->GetXaxis()->SetBinLabel(3, "#sigma_{Ev. time} < 200 ps"); - h->GetXaxis()->SetBinLabel(4, "#sigma_{Ev. time} > 200 ps"); - h = histos.add("trackSelection", "trackSelection", kTH1F, {{10, 0, 10, "Cut passed"}}); - h->GetXaxis()->SetBinLabel(1, "Tracks read"); - h->GetXaxis()->SetBinLabel(2, "Track selection"); - h->GetXaxis()->SetBinLabel(3, "hasITS"); - h->GetXaxis()->SetBinLabel(4, "hasTPC"); - h->GetXaxis()->SetBinLabel(5, "hasTOF"); - histos.add("deltaEvTimeTOFT0A", "deltaEvTimeTOFT0A", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); - histos.add("deltaEvTimeTOFT0C", "deltaEvTimeTOFT0C", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); - histos.add("deltaEvTimeTOFT0AC", "deltaEvTimeTOFT0AC", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0AC} (ps)"); - auto h2 = histos.add("deltaEvTimeTOFT0AvsT0C", "deltaEvTimeTOFT0AvsT0C", kTH2F, {evTimeDeltaAxis, evTimeDeltaAxis}); - h2->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); - h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); - h2 = histos.add("deltaEvTimeTOFT0AvsTOF", "deltaEvTimeTOFT0AvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); - h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); - h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); - h2 = histos.add("deltaEvTimeTOFT0CvsTOF", "deltaEvTimeTOFT0CvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); - h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); - h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); - h2 = histos.add("deltaEvTimeTOFT0ACvsTOF", "deltaEvTimeTOFT0ACvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); - h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); - h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0AC} (ps)"); - - histos.add("eventTime", "eventTime", kTH1F, {evTimeAxis}); - histos.add("eventTimeReso", "eventTimeReso", kTH1F, {evTimeResoAxis}); - histos.add("eventTimeVsMult", "eventTimeVsMult", kTH2F, {multAxis, evTimeAxis}); - histos.add("eventTimeResoVsMult", "eventTimeResoVsMult", kTH2F, {multAxis, evTimeResoAxis}); - - histos.add("eventTimeTOFMult", "eventTimeTOFMult", kTH1F, {multAxis}); - histos.add("eventTimeTOF", "eventTimeTOF", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); - histos.add("eventTimeTOFReso", "eventTimeTOFReso", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} resolution (ps)"); - histos.add("eventTimeTOFVsMult", "eventTimeTOFVsMult", kTH2F, {multAxis, evTimeAxis})->GetYaxis()->SetTitle("Ev. time_{TOF} (ps)"); - histos.add("eventTimeTOFResoVsMult", "eventTimeTOFResoVsMult", kTH2F, {multAxis, evTimeResoAxis})->GetYaxis()->SetTitle("Ev. time_{TOF} resolution (ps)"); - - histos.add("eventTimeT0A", "eventTimeT0A", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0A event time (ps)"); - histos.add("eventTimeT0C", "eventTimeT0C", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0C event time (ps)"); - histos.add("eventTimeT0AC", "eventTimeT0AC", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0AC event time (ps)"); - histos.add("eventTimeT0ACReso", "eventTimeT0ACReso", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("T0AC event time resolution (ps)"); - - histos.add("collisionTime", "collisionTime", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Collision time (ps)"); - histos.add("collisionTimeRes", "collisionTimeRes", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Collision time resolution (ps)"); - - histos.add("tracks/p", "p", kTH1F, {pAxis}); - histos.add("tracks/pt", "pt", kTH1F, {ptAxis}); - histos.add("tracks/length", "length", kTH1F, {lengthAxis}); - - histos.add("deltaVsMult/pi", Form("pi %.2f < #it{p} < %.2f", minPReso.value, maxPReso.value), kTH2F, {multAxis, deltaAxis}); - histos.add("deltaVsReso/pi", Form("pi %.2f < #it{p} < %.2f", minPReso.value, maxPReso.value), kTH2F, {evTimeResoAxis, deltaAxis}); - - histos.add("tofbeta/inclusive", "", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0AOnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0COnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, betaAxis}); - histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, betaAxis}); - - histos.add("tofmass/inclusive", "", HistType::kTH2F, {pAxis, massAxis}); - 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/EvTimeT0AOnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, massAxis}); - histos.add("tofmass/EvTimeT0COnly", "Ev. Time T0C Only", HistType::kTH2F, {pAxis, massAxis}); - histos.add("tofmass/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, massAxis}); - - if (enableDebug) { - histos.add("withtof/p", "p", kTH1F, {pAxis}); - histos.add("withtof/pt", "pt", kTH1F, {ptAxis}); - histos.add("withtof/length", "length", kTH1F, {lengthAxis}); - histos.add("withtof/tofSignal", "tofSignal", kTH1F, {tofSignalAxis}); - histos.add("withtof/beta", "beta", kTH2F, {pAxis, betaAxis}); - histos.add("withtof/delta", "delta", kTH2F, {pAxis, deltaAxis}); - histos.add("withtof/expP", "expP", kTH2F, {pAxis, pAxis}); - histos.add("withtof/mass", "mass", kTH1F, {massAxis}); - histos.add("withtof/tofSignalPerCollision", "tofSignalPerCollision", kTH2S, {collisionAxis, tofSignalAxis}); - - histos.add("goodreso/p", "p", kTH1F, {pAxis}); - histos.add("goodreso/pt", "pt", kTH1F, {ptAxis}); - histos.add("goodreso/ptden", "ptden", kTH1F, {ptAxis}); - histos.add("goodreso/length", "length", kTH1F, {lengthAxis}); - histos.add("goodreso/tofSignal", "tofSignal", kTH1F, {tofSignalAxis}); - histos.add("goodreso/beta", "beta", kTH2F, {pAxis, betaAxis}); - histos.add("goodreso/delta", "delta", kTH2F, {pAxis, deltaAxis}); - histos.add("goodreso/expP", "expP", kTH2F, {pAxis, pAxis}); - histos.add("goodreso/mass", "mass", kTH1F, {massAxis}); - histos.add("goodreso/tofSignalPerCollision", "tofSignalPerCollision", kTH2S, {collisionAxis, tofSignalAxis}); - - histos.add("badreso/p", "p", kTH1F, {pAxis}); - histos.add("badreso/pt", "pt", kTH1F, {ptAxis}); - histos.add("badreso/ptden", "ptden", kTH1F, {ptAxis}); - histos.add("badreso/length", "length", kTH1F, {lengthAxis}); - histos.add("badreso/tofSignal", "tofSignal", kTH1F, {tofSignalAxis}); - histos.add("badreso/beta", "beta", kTH2F, {pAxis, betaAxis}); - histos.add("badreso/delta", "delta", kTH2F, {pAxis, deltaAxis}); - histos.add("badreso/expP", "expP", kTH2F, {pAxis, pAxis}); - histos.add("badreso/mass", "mass", kTH1F, {massAxis}); - histos.add("badreso/tofSignalPerCollision", "tofSignalPerCollision", kTH2S, {collisionAxis, tofSignalAxis}); - - histos.add("goodforevtime/tofSignal", "tofSignal", kTH1F, {tofSignalAxis}); - histos.add("goodforevtime/p", "p", kTH1F, {pAxis}); - histos.add("goodforevtime/pt", "pt", kTH1F, {ptAxis}); - histos.add("goodforevtime/length", "length", kTH1F, {lengthAxis}); - histos.add("goodforevtime/beta", "beta", kTH2F, {pAxis, betaAxis}); - histos.add("goodforevtime/delta", "delta", kTH2F, {pAxis, deltaAxis}); - histos.add("goodforevtime/expP", "expP", kTH2F, {pAxis, pAxis}); - histos.add("goodforevtime/mass", "mass", kTH1F, {massAxis}); - histos.add("goodforevtime/tofSignalPerCollision", "tofSignalPerCollision", kTH2S, {collisionAxis, tofSignalAxis}); - - histos.add("withqualitycuts/p", "p", kTH1F, {pAxis}); - histos.add("withqualitycuts/pt", "pt", kTH1F, {ptAxis}); - histos.add("withqualitycuts/length", "length", kTH1F, {lengthAxis}); - histos.add("withqualitycuts/mass", "mass", kTH1F, {massAxis}); - } + if (doprocessData) { + auto h = histos.add("eventSelection", "eventSelection", kTH1F, {{10, 0, 10, "Cut passed"}}); + h->GetXaxis()->SetBinLabel(1, "Events read"); + h->GetXaxis()->SetBinLabel(2, "Event selection"); + h->GetXaxis()->SetBinLabel(3, "#sigma_{Ev. time} < 200 ps"); + h->GetXaxis()->SetBinLabel(4, "#sigma_{Ev. time} > 200 ps"); + h = histos.add("trackSelection", "trackSelection", kTH1F, {{10, 0, 10, "Cut passed"}}); + h->GetXaxis()->SetBinLabel(1, "Tracks read"); + h->GetXaxis()->SetBinLabel(2, "Track selection"); + h->GetXaxis()->SetBinLabel(3, "hasITS"); + h->GetXaxis()->SetBinLabel(4, "hasTPC"); + h->GetXaxis()->SetBinLabel(5, "hasTOF"); + histos.add("deltaEvTimeTOFT0A", "deltaEvTimeTOFT0A", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); + histos.add("deltaEvTimeTOFT0C", "deltaEvTimeTOFT0C", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); + histos.add("deltaEvTimeTOFT0AC", "deltaEvTimeTOFT0AC", kTH1F, {evTimeDeltaAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0AC} (ps)"); + auto h2 = histos.add("deltaEvTimeTOFT0AvsT0C", "deltaEvTimeTOFT0AvsT0C", kTH2F, {evTimeDeltaAxis, evTimeDeltaAxis}); + h2->GetXaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); + h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); + h2 = histos.add("deltaEvTimeTOFT0AvsTOF", "deltaEvTimeTOFT0AvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); + h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); + h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0A} (ps)"); + h2 = histos.add("deltaEvTimeTOFT0CvsTOF", "deltaEvTimeTOFT0CvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); + h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); + h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0C} (ps)"); + h2 = histos.add("deltaEvTimeTOFT0ACvsTOF", "deltaEvTimeTOFT0ACvsTOF", kTH2F, {evTimeAxis, evTimeDeltaAxis}); + h2->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); + h2->GetYaxis()->SetTitle("Ev. time_{TOF} - Ev. time_{T0AC} (ps)"); + + histos.add("eventTime", "eventTime", kTH1F, {evTimeAxis}); + histos.add("eventTimeReso", "eventTimeReso", kTH1F, {evTimeResoAxis}); + histos.add("eventTimeVsMult", "eventTimeVsMult", kTH2F, {multAxis, evTimeAxis}); + histos.add("eventTimeResoVsMult", "eventTimeResoVsMult", kTH2F, {multAxis, evTimeResoAxis}); + + histos.add("eventTimeTOFMult", "eventTimeTOFMult", kTH1F, {multAxis}); + histos.add("eventTimeTOF", "eventTimeTOF", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} (ps)"); + histos.add("eventTimeTOFReso", "eventTimeTOFReso", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Ev. time_{TOF} resolution (ps)"); + histos.add("eventTimeTOFVsMult", "eventTimeTOFVsMult", kTH2F, {multAxis, evTimeAxis})->GetYaxis()->SetTitle("Ev. time_{TOF} (ps)"); + histos.add("eventTimeTOFResoVsMult", "eventTimeTOFResoVsMult", kTH2F, {multAxis, evTimeResoAxis})->GetYaxis()->SetTitle("Ev. time_{TOF} resolution (ps)"); + + histos.add("eventTimeT0A", "eventTimeT0A", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0A event time (ps)"); + histos.add("eventTimeT0C", "eventTimeT0C", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0C event time (ps)"); + histos.add("eventTimeT0AC", "eventTimeT0AC", kTH1F, {evTimeAxis})->GetXaxis()->SetTitle("T0AC event time (ps)"); + histos.add("eventTimeT0ACReso", "eventTimeT0ACReso", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("T0AC event time resolution (ps)"); + + histos.add("collisionTime", "collisionTime", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Collision time (ps)"); + histos.add("collisionTimeRes", "collisionTimeRes", kTH1F, {evTimeResoAxis})->GetXaxis()->SetTitle("Collision time resolution (ps)"); + + histos.add("tracks/p", "p", kTH1F, {pAxis}); + histos.add("tracks/pt", "pt", kTH1F, {ptAxis}); + histos.add("tracks/length", "length", kTH1F, {lengthAxis}); + + histos.add("deltaVsMult/pi", Form("pi %.2f < #it{p} < %.2f", minPReso.value, maxPReso.value), kTH2F, {multAxis, deltaAxis}); + histos.add("deltaVsReso/pi", Form("pi %.2f < #it{p} < %.2f", minPReso.value, maxPReso.value), kTH2F, {evTimeResoAxis, deltaAxis}); + + histos.add("tofbeta/inclusive", "", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeTOF", "Ev. Time TOF", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeTOFOnly", "Ev. Time TOF Only", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeT0AC", "Ev. Time T0AC", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeT0AOnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeT0COnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, betaAxis}); + histos.add("tofbeta/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, betaAxis}); + + histos.add("tofmass/inclusive", "", HistType::kTH2F, {pAxis, massAxis}); + 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/EvTimeT0AOnly", "Ev. Time T0A Only", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/EvTimeT0COnly", "Ev. Time T0C Only", HistType::kTH2F, {pAxis, massAxis}); + histos.add("tofmass/EvTimeT0ACOnly", "Ev. Time T0AC Only", HistType::kTH2F, {pAxis, massAxis}); + if (enableDebug) { + histos.add("withtof/p", "p", kTH1F, {pAxis}); + histos.add("withtof/pt", "pt", kTH1F, {ptAxis}); + histos.add("withtof/length", "length", kTH1F, {lengthAxis}); + histos.add("withtof/tofSignal", "tofSignal", kTH1F, {tofSignalAxis}); + histos.add("withtof/beta", "beta", kTH2F, {pAxis, betaAxis}); + histos.add("withtof/delta", "delta", kTH2F, {pAxis, deltaAxis}); + histos.add("withtof/expP", "expP", kTH2F, {pAxis, pAxis}); + histos.add("withtof/mass", "mass", kTH1F, {massAxis}); + histos.add("withtof/tofSignalPerCollision", "tofSignalPerCollision", kTH2S, {collisionAxis, tofSignalAxis}); + + histos.addClone("withtof/", "goodreso/"); + histos.addClone("withtof/", "badreso/"); + histos.addClone("withtof/", "goodforevtime/"); + histos.addClone("withtof/", "withqualitycuts/"); + } - listEfficiency.setObject(new THashList); - auto makeEfficiency = [&](TString effname, TString efftitle) { - listEfficiency->Add(new TEfficiency(effname, efftitle + ";TOF multiplicity;Efficiency", nBinsMultiplicity, 0, rangeMultiplicity)); - }; + listEfficiency.setObject(new THashList); + auto makeEfficiency = [&](TString effname, TString efftitle) { + listEfficiency->Add(new TEfficiency(effname, efftitle + ";TOF multiplicity;Efficiency", nBinsMultiplicity, 0, rangeMultiplicity)); + }; - makeEfficiency("effTOFEvTime", "Efficiency of the TOF Event Time"); - makeEfficiency("effT0ACEvTime", "Efficiency of the T0AC Event Time"); - makeEfficiency("effTOFT0ACEvTime", "Efficiency of the TOF+T0AC Event Time"); - makeEfficiency("effT0AEvTime", "Efficiency of the T0A Event Time"); - makeEfficiency("effT0CEvTime", "Efficiency of the T0C Event Time"); + makeEfficiency("effTOFEvTime", "Efficiency of the TOF Event Time"); + makeEfficiency("effT0ACEvTime", "Efficiency of the T0AC Event Time"); + makeEfficiency("effTOFT0ACEvTime", "Efficiency of the TOF+T0AC Event Time"); + makeEfficiency("effT0AEvTime", "Efficiency of the T0A Event Time"); + makeEfficiency("effT0CEvTime", "Efficiency of the T0C Event Time"); + } if (!doprocessMC) { return; } const AxisSpec diffAxis{1000, -1000, 1000, "Difference"}; - histos.add("MC/diff", "", HistType::kTH1F, {diffAxis}); + histos.add("MC/diff/All", "All", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t^{All}_{ev} (ps)"); + histos.add("MC/diff/FT0", "FT0", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{FT0}_{ev} (ps)"); + histos.add("MC/diff/TOF", "TOF", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{TOF}_{ev} (ps)"); + + histos.add("MC/diffvsZ/All", "All", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t^{All}_{ev}_{ev} (ps)"); + histos.add("MC/diffvsZ/FT0", "FT0", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{FT0}_{ev} (ps)"); + histos.add("MC/diffvsZ/TOF", "TOF", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{TOF}_{ev} (ps)"); // pion - histos.add("MC/pdg211/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/pdgNeg211/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdg211/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdgNeg211/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); + histos.add("MC/particle/pdg211/all/particleDiff", "particleDiff", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t^{MC}_{ev}-t^{part}_{MC} (ps)"); + histos.add("MC/particle/pdg211/all/delta", "delta", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)"); + histos.add("MC/particle/pdg211/all/deltaTRD", "deltaTRD", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)"); + histos.add("MC/particle/pdg211/all/deltaNoTRD", "deltaNoTRD", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)"); + histos.addClone("MC/particle/pdg211/all/", "MC/particle/pdg211/prm/"); + + histos.addClone("MC/particle/pdg211/", "MC/particle/pdgNeg211/"); + // kaon - histos.add("MC/pdg321/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/pdgNeg321/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdg321/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdgNeg321/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); + histos.addClone("MC/particle/pdg211/", "MC/particle/pdg321/"); + histos.addClone("MC/particle/pdg211/", "MC/particle/pdgNeg321/"); // proton - histos.add("MC/pdg2212/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/pdgNeg2212/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdg2212/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - histos.add("MC/prm/pdgNeg2212/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis}); - - histos.add("MC/t", "", HistType::kTH1F, {{1000, -1000, 1000, "MC time"}}); + histos.addClone("MC/particle/pdg211/", "MC/particle/pdg2212/"); + histos.addClone("MC/particle/pdg211/", "MC/particle/pdgNeg2212/"); + + const AxisSpec mcTimeAxis{1000, -1000, 1000, "MC coll time (ps)"}; + + histos.add("MC/CollisionTime/eventtimeMC", "", HistType::kTH1F, {mcTimeAxis}); + histos.add("MC/CollisionTime/All", "", HistType::kTH1F, {mcTimeAxis})->GetXaxis()->SetTitle("All (ps)"); + histos.add("MC/CollisionTime/FT0", "", HistType::kTH1F, {mcTimeAxis})->GetXaxis()->SetTitle("FT0 (ps)"); + histos.add("MC/CollisionTime/TOF", "", HistType::kTH1F, {mcTimeAxis})->GetXaxis()->SetTitle("TOF (ps)"); + histos.add("MC/CollisionTime/eventtimeMCvsAll", "", HistType::kTH2F, {mcTimeAxis, mcTimeAxis})->GetYaxis()->SetTitle("All (ps)"); + histos.add("MC/CollisionTime/eventtimeMCvsFT0", "", HistType::kTH2F, {mcTimeAxis, mcTimeAxis})->GetYaxis()->SetTitle("FT0 (ps)"); + histos.add("MC/CollisionTime/eventtimeMCvsTOF", "", HistType::kTH2F, {mcTimeAxis, mcTimeAxis})->GetYaxis()->SetTitle("TOF (ps)"); + + const AxisSpec axisBCID{o2::constants::lhc::LHCMaxBunches, -0.5, -0.5 + o2::constants::lhc::LHCMaxBunches, "BC ID in orbit"}; + const AxisSpec axisBCIDMC{o2::constants::lhc::LHCMaxBunches, -0.5, -0.5 + o2::constants::lhc::LHCMaxBunches, "MC BC ID in orbit"}; + + histos.add("collisions/Reco/BCvsMCBC", "BC vs MC BC", kTH2D, {axisBCID, axisBCIDMC}); + histos.add("collisions/Reco/FoundBCvsMCBC", "Found BC vs MC BC", kTH2D, {axisBCID, axisBCIDMC})->GetXaxis()->SetTitle("Found BC ID in orbit"); + histos.add("collisions/Reco/FoundBCvsBC", "Found BC vs MC BC", kTH2D, {axisBCID, axisBCID})->GetXaxis()->SetTitle("Found BC ID in orbit"); + histos.add("collisions/Reco/bcMinusfoundBc", "bcMinusfoundBc", kTH1D, {{1600, -1000, 1000, "bc - foundBc (ns)"}}); + histos.add("collisions/Reco/bcMinusfoundBcRatio", "bcMinusfoundBcRatio", kTH1D, {{1600, -40, 40, "(bc - foundBc)/collisionTimeRes"}}); + histos.add("collisions/Reco/bcMinusMcBc", "bcMinusMcBc", kTH1D, {{1600, -1000, 1000, "bc - mcBc (ns)"}}); + histos.add("collisions/Reco/foundbcMinusMcBc", "foundbcMinusMcBc", kTH1D, {{1600, -1000, 1000, "foundBc - mcBc (ns)"}}); + histos.add("collisions/Reco/bcMinusMcBcRatio", "bcMinusMcBcRatio", kTH1D, {{1600, -40, 40, "(bc - mcBc)/collisionTimeRes"}}); + histos.add("collisions/Reco/foundbcMinusMcBcRatio", "foundbcMinusMcBcRatio", kTH1D, {{1600, -40, 40, "(foundBc-mcBc)/collisionTimeRes"}}); + + histos.add("ft0/FT0AMinusFT0ACorrected", "", kTH1D, {{1600, -1000, 1000, "FT0A - FT0A_{corr} (ps)"}}); + histos.add("ft0/FT0CMinusFT0CCorrected", "", kTH1D, {{1600, -1000, 1000, "FT0C - FT0C_{corr} (ps)"}}); + histos.add("ft0/FT0ACMinusFT0ACCorrected", "", kTH1D, {{1600, -1000, 1000, "FT0AC - FT0AC_{corr} (ps)"}}); + histos.add("ft0/diffPosZ", "", kTH1D, {{100, -10, 10, "z_{mc} - z_{FT0} (cm)"}}); } - using Trks = soa::Join; + using Trks = soa::Join; + using TrksData = soa::Join; using EvTimeCollisions = soa::Join; // Define slice per collision Preslice perCollision = aod::track::collisionId; - void processData(Trks const& tracks, EvTimeCollisions const&) + void processData(TrksData const& tracks, EvTimeCollisions const&) { static int ncolls = 0; int lastCollisionId = -1; // Last collision ID analysed @@ -330,17 +335,17 @@ struct tofPidCollisionTimeQa { histos.fill(HIST("trackSelection"), 4.5f); // Recompute quantities with event times - const float& betaTOF = trk.evTimeTOFMult() > 1 ? o2::pid::tof::Beta::GetBeta(trk, trk.evTimeTOF()) : 999.f; - const float& betaT0A = collision.t0ACorrectedValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0ACorrected() * 1000.f) : 999.f; - const float& betaT0C = collision.t0CCorrectedValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0CCorrected() * 1000.f) : 999.f; - const float& betaT0AC = collision.t0ACValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0AC() * 1000.f) : 999.f; + const float& betaTOF = trk.evTimeTOFMult() > 1 ? o2::pid::tof::Beta::GetBeta(trk, trk.evTimeTOF()) : 999.f; + const float& betaT0A = collision.t0ACorrectedValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0ACorrected() * 1000.f) : 999.f; + const float& betaT0C = collision.t0CCorrectedValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0CCorrected() * 1000.f) : 999.f; + const float& betaT0AC = collision.t0ACValid() ? o2::pid::tof::Beta::GetBeta(trk, collision.t0AC() * 1000.f) : 999.f; - const float& massTOF = trk.evTimeTOFMult() > 1 ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaTOF) : 999.f; - const float& massT0A = collision.t0ACorrectedValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0A) : 999.f; - const float& massT0C = collision.t0CCorrectedValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0C) : 999.f; - const float& massT0AC = collision.t0ACValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0AC) : 999.f; + const float& massTOF = trk.evTimeTOFMult() > 1 ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaTOF) : 999.f; + const float& massT0A = collision.t0ACorrectedValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0A) : 999.f; + const float& massT0C = collision.t0CCorrectedValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0C) : 999.f; + const float& massT0AC = collision.t0ACValid() ? o2::pid::tof::TOFMass::GetTOFMass(trk, betaT0AC) : 999.f; - const float& deltaPi = trk.tofSignal() - trk.tofEvTime() - o2::pid::tof::ExpTimes::GetExpectedSignal(trk); + const float& deltaPi = trk.tofSignal() - trk.tofEvTime() - o2::pid::tof::ExpTimes::GetExpectedSignal(trk); histos.fill(HIST("tofbeta/inclusive"), trk.p(), trk.beta()); histos.fill(HIST("tofmass/inclusive"), trk.p(), trk.mass()); @@ -435,80 +440,165 @@ struct tofPidCollisionTimeQa { EvTimeCollisionsMC const&, aod::McParticles const&, aod::BCs const&, + aod::FT0s const&, aod::McCollisions const&) { // static int ncolls = 0; int lastCollisionId = -1; // Last collision ID analysed - for (auto& t : tracks) { - if (!t.has_collision()) { // Track was not assigned to a collision - continue; - } else if (t.collisionId() == lastCollisionId) { // Event was already processed + for (auto& trk : tracks) { + if (!trk.has_collision()) { // Track was not assigned to a collision continue; } - lastCollisionId = t.collisionId(); /// Cache last collision ID - const auto& collision = t.collision_as(); + const auto& collision = trk.collision_as(); if (!collision.has_mcCollision()) { continue; } const auto& collisionMC = collision.mcCollision_as(); - // timeInBCNS + bc2ns(); - const auto& mcBC = collisionMC.bc(); - // bc* o2::constants::lhc::LHCBunchSpacingNS + orbit* o2::constants::lhc::LHCOrbitNS; - // int64_t(mcBC.globalBC() * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) - const int64_t bcMCtime = static_cast((collisionMC.t() + 2.f) / o2::constants::lhc::LHCBunchSpacingNS); - const float eventtimeMC = collisionMC.t() - bcMCtime * o2::constants::lhc::LHCBunchSpacingNS; - LOG(info) << mcBC.globalBC() - bcMCtime << " MC collision time: " << eventtimeMC << " collision time: " << collision.collisionTime() << " TOF event time: " << t.tofEvTime(); - histos.fill(HIST("MC/t"), eventtimeMC); - histos.fill(HIST("MC/diff"), eventtimeMC - t.tofEvTime()); - if (!t.has_mcParticle()) { + const float eventtimeMC = collisionMC.t() * 1000.f; + + if (trk.has_mcParticle()) { + const auto& particle = trk.mcParticle(); + const auto& mcCollTimeMinusFormationTime = particle.vt() - collisionMC.t(); + const auto& mcTOFvalue = trk.tofSignal() - eventtimeMC - trk.tofExpTimePi(); + LOG(debug) << "Track " << particle.vt() << " vs " << eventtimeMC; + switch (particle.pdgCode()) { + case 211: + histos.fill(HIST("MC/particle/pdg211/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + histos.fill(HIST("MC/particle/pdg211/all/delta"), particle.pt(), mcTOFvalue); + if (trk.hasTRD()) { + histos.fill(HIST("MC/particle/pdg211/all/deltaTRD"), particle.pt(), mcTOFvalue); + } else { + histos.fill(HIST("MC/particle/pdg211/all/deltaNoTRD"), particle.pt(), mcTOFvalue); + } + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdg211/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + case -211: + histos.fill(HIST("MC/particle/pdgNeg211/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + histos.fill(HIST("MC/particle/pdgNeg211/all/delta"), particle.pt(), mcTOFvalue); + histos.fill(HIST("MC/particle/pdgNeg211/all/delta"), particle.pt(), mcTOFvalue); + if (trk.hasTRD()) { + histos.fill(HIST("MC/particle/pdgNeg211/all/deltaTRD"), particle.pt(), mcTOFvalue); + } else { + histos.fill(HIST("MC/particle/pdgNeg211/all/deltaNoTRD"), particle.pt(), mcTOFvalue); + } + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdgNeg211/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + case 321: + histos.fill(HIST("MC/particle/pdg321/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdg321/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + case -321: + histos.fill(HIST("MC/particle/pdgNeg321/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdgNeg321/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + case 2212: + histos.fill(HIST("MC/particle/pdg2212/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdg2212/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + case -2212: + histos.fill(HIST("MC/particle/pdgNeg2212/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + if (particle.isPhysicalPrimary()) { + histos.fill(HIST("MC/particle/pdgNeg2212/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime); + } + break; + default: + break; + } + } + + if (trk.collisionId() == lastCollisionId) { // Event was already processed continue; } - const auto& particle = t.mcParticle(); - LOG(info) << "Track " << particle.vt() << " vs " << eventtimeMC; - switch (particle.pdgCode()) { - case 211: - histos.fill(HIST("MC/pdg211/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdg211/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - case -211: - histos.fill(HIST("MC/pdgNeg211/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdgNeg211/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - case 321: - histos.fill(HIST("MC/pdg321/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdg321/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - case -321: - histos.fill(HIST("MC/pdgNeg321/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdgNeg321/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - case 2212: - histos.fill(HIST("MC/pdg2212/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdg2212/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - case -2212: - histos.fill(HIST("MC/pdgNeg2212/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - if (particle.isPhysicalPrimary()) { - histos.fill(HIST("MC/prm/pdgNeg2212/particleDiff"), particle.pt(), collisionMC.t() - particle.vt()); - } - break; - default: - break; + lastCollisionId = trk.collisionId(); /// Cache last collision ID + + float t0AC[2] = {0.f, 0.f}; + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + t0AC[0] = collision.t0AC() * 1000.f; + t0AC[1] = collision.t0resolution() * 1000.f; + } + + float t0A = 1e10; + float t0C = 1e10; + + constexpr float dummyTime = 30.; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns + if (collision.has_foundFT0()) { // Get the non corrected FT0AC + const auto& ft0 = collision.foundFT0(); + const std::bitset<8>& triggers = ft0.triggerMask(); + const bool ora = triggers[o2::ft0::Triggers::bitA]; + const bool orc = triggers[o2::ft0::Triggers::bitC]; + if (ora && ft0.timeA() < dummyTime) { + t0A = ft0.timeA(); + } + if (orc && ft0.timeC() < dummyTime) { + t0C = ft0.timeC(); + } + if (ft0.isValidTime()) { + histos.fill(HIST("ft0/diffPosZ"), ft0.posZ() - collisionMC.posZ()); + } + } + if (collision.t0ACorrectedValid()) { + histos.fill(HIST("ft0/FT0AMinusFT0ACorrected"), (t0A - collision.t0ACorrected()) * 1000.f); } + if (collision.t0CCorrectedValid()) { + histos.fill(HIST("ft0/FT0CMinusFT0CCorrected"), (t0C - collision.t0CCorrected()) * 1000.f); + } + if (collision.t0ACValid()) { + histos.fill(HIST("ft0/FT0ACMinusFT0ACCorrected"), (0.5 * (t0A + t0C) - collision.t0AC()) * 1000.f); + } + + const auto& recoBC = collision.bc(); + const auto& foundBC = collision.foundBC(); + const auto& mcBC = collisionMC.bc(); + + const auto& recoBCid = recoBC.globalBC() % o2::constants::lhc::LHCMaxBunches; + const auto& mcBCid = mcBC.globalBC() % o2::constants::lhc::LHCMaxBunches; + const auto& foundBCid = foundBC.globalBC() % o2::constants::lhc::LHCMaxBunches; + const int diffRecoFoundBC = foundBC.globalBC() - recoBC.globalBC(); + const int diffRecoMCBC = recoBC.globalBC() - mcBC.globalBC(); + const int diffFoundMCBC = foundBC.globalBC() - mcBC.globalBC(); + histos.fill(HIST("collisions/Reco/BCvsMCBC"), recoBCid, mcBCid); + histos.fill(HIST("collisions/Reco/FoundBCvsMCBC"), foundBCid, mcBCid); + histos.fill(HIST("collisions/Reco/FoundBCvsBC"), foundBCid, recoBCid); + histos.fill(HIST("collisions/Reco/bcMinusMcBc"), (diffRecoMCBC)*o2::constants::lhc::LHCBunchSpacingNS); + histos.fill(HIST("collisions/Reco/foundbcMinusMcBc"), (diffFoundMCBC)*o2::constants::lhc::LHCBunchSpacingNS); + histos.fill(HIST("collisions/Reco/bcMinusfoundBc"), (diffRecoFoundBC)*o2::constants::lhc::LHCBunchSpacingNS); + histos.fill(HIST("collisions/Reco/bcMinusfoundBcRatio"), (diffRecoFoundBC)*o2::constants::lhc::LHCBunchSpacingNS / collision.collisionTimeRes()); + histos.fill(HIST("collisions/Reco/foundbcMinusMcBcRatio"), (diffFoundMCBC)*o2::constants::lhc::LHCBunchSpacingNS / collision.collisionTimeRes()); + histos.fill(HIST("collisions/Reco/bcMinusMcBcRatio"), (diffRecoMCBC)*o2::constants::lhc::LHCBunchSpacingNS / collision.collisionTimeRes()); + + // timeInBCNS + bc2ns(); + // bc* o2::constants::lhc::LHCBunchSpacingNS + orbit* o2::constants::lhc::LHCOrbitNS; + // int64_t(mcBC.globalBC() * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) + + histos.fill(HIST("MC/CollisionTime/eventtimeMC"), eventtimeMC); + histos.fill(HIST("MC/CollisionTime/All"), trk.tofEvTime()); + histos.fill(HIST("MC/CollisionTime/FT0"), t0AC[0]); + histos.fill(HIST("MC/CollisionTime/TOF"), trk.evTimeTOF()); + histos.fill(HIST("MC/CollisionTime/eventtimeMCvsAll"), eventtimeMC, trk.tofEvTime()); + histos.fill(HIST("MC/CollisionTime/eventtimeMCvsFT0"), eventtimeMC, t0AC[0]); + histos.fill(HIST("MC/CollisionTime/eventtimeMCvsTOF"), eventtimeMC, trk.evTimeTOF()); + + histos.fill(HIST("MC/diff/All"), eventtimeMC - trk.tofEvTime()); + histos.fill(HIST("MC/diff/FT0"), eventtimeMC - t0AC[0]); + histos.fill(HIST("MC/diff/TOF"), eventtimeMC - trk.evTimeTOF()); + histos.fill(HIST("MC/diffvsZ/All"), eventtimeMC - trk.tofEvTime(), collisionMC.posZ()); + histos.fill(HIST("MC/diffvsZ/FT0"), eventtimeMC - t0AC[0], collisionMC.posZ()); + histos.fill(HIST("MC/diffvsZ/TOF"), eventtimeMC - trk.evTimeTOF(), collisionMC.posZ()); } } - PROCESS_SWITCH(tofPidCollisionTimeQa, processMC, "Process MC", true); + PROCESS_SWITCH(tofPidCollisionTimeQa, processMC, "Process MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCMC.cxx b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCMC.cxx index e99f6a9116c..993c2f7b24c 100644 --- a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCMC.cxx +++ b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCMC.cxx @@ -303,6 +303,7 @@ struct pidTpcQaMc { histos.add(hnsigmaMCmat[mcID * Np + massID].data(), Form("True Secondary %s from material", pT[mcID]), HistType::kTH2F, {ptAxis, nSigmaAxis}); if constexpr (mcID == massID) { + histos.add(hsignalMC[mcID].data(), Form("%s", pT[mcID]), HistType::kTH2F, {pAxis, signalAxis}); histos.add(hsignalMCprm[mcID].data(), Form("Primary %s", pT[mcID]), HistType::kTH2F, {pAxis, signalAxis}); histos.add(hsignalMCstr[mcID].data(), Form("Secondary %s from decay", pT[mcID]), HistType::kTH2F, {pAxis, signalAxis}); histos.add(hsignalMCmat[mcID].data(), Form("Secondary %s from material", pT[mcID]), HistType::kTH2F, {pAxis, signalAxis}); diff --git a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx index bbae2f60cd5..bc80df4b71a 100644 --- a/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx +++ b/DPG/Tasks/AOTTrack/PID/TPC/qaPIDTPCSignal.cxx @@ -281,7 +281,7 @@ struct tpcPidQaSignal { void processNoEvSel(soa::Filtered const& tracks, aod::Collisions const& collisions) { histos.fill(HIST("event/evsel"), 1, collisions.size()); - LOG(info) << "Processing " << collisions.size() << " collisions with " << tracks.size() << " tracks"; + LOG(debug) << "Processing " << collisions.size() << " collisions with " << tracks.size() << " tracks"; processTracks(tracks); } PROCESS_SWITCH(tpcPidQaSignal, processNoEvSel, "Process without event selection", true); @@ -290,7 +290,7 @@ struct tpcPidQaSignal { void processMoreTrkSel(soa::Filtered> const& tracks, aod::Collisions const& collisions) { histos.fill(HIST("event/evsel"), 1, collisions.size()); - LOG(info) << "Processing " << collisions.size() << " collisions with " << tracks.size() << " tracks"; + LOG(debug) << "Processing " << collisions.size() << " collisions with " << tracks.size() << " tracks"; processTracks(tracks); } PROCESS_SWITCH(tpcPidQaSignal, processMoreTrkSel, "Process without event selection", false); diff --git a/DPG/Tasks/AOTTrack/qaDcaMC.cxx b/DPG/Tasks/AOTTrack/qaDcaMC.cxx index a71bbff8dcd..4054c59b33a 100644 --- a/DPG/Tasks/AOTTrack/qaDcaMC.cxx +++ b/DPG/Tasks/AOTTrack/qaDcaMC.cxx @@ -110,7 +110,8 @@ struct QaDcaMc { ConfigurableAxis etaBins{"etaBins", {200, -3.f, 3.f}, "Eta binning"}; ConfigurableAxis phiBins{"phiBins", {200, 0.f, 6.284f}, "Phi binning"}; ConfigurableAxis yBins{"yBins", {200, -0.5f, 0.5f}, "Y binning"}; - ConfigurableAxis dcaBins{"dcaBins", {2000, -1.f, 1.f}, "DCA binning"}; + ConfigurableAxis dcaBinsxy{"dcaBinsxy", {500, -1.f, 1.f}, "DCAxy binning"}; + ConfigurableAxis dcaBinsz{"dcaBinsz", {100, -0.1f, 0.1f}, "DCAz binning"}; Configurable doPVContributorCut{"doPVContributorCut", false, "Select tracks used for primary vertex recostruction (isPVContributor)"}; // Histograms @@ -149,8 +150,8 @@ struct QaDcaMc { const AxisSpec axisEta{etaBins, "#it{#eta}"}; const AxisSpec axisY{yBins, "#it{y}"}; const AxisSpec axisPhi{phiBins, "#it{#varphi} (rad)"}; - const AxisSpec axisDCAxy{dcaBins, "DCA_{xy} (cm)"}; - const AxisSpec axisDCAz{dcaBins, "DCA_{z} (cm)"}; + const AxisSpec axisDCAxy{dcaBinsxy, "DCA_{xy} (cm)"}; + const AxisSpec axisDCAz{dcaBinsz, "DCA_{z} (cm)"}; const char* partName = particleName(pdgSign, id); LOG(info) << "Preparing histograms for particle: " << partName << " pdgSign " << pdgSign; diff --git a/DPG/Tasks/AOTTrack/qaEfficiency.cxx b/DPG/Tasks/AOTTrack/qaEfficiency.cxx index 0fee8840eee..0e1c023fc6e 100644 --- a/DPG/Tasks/AOTTrack/qaEfficiency.cxx +++ b/DPG/Tasks/AOTTrack/qaEfficiency.cxx @@ -153,6 +153,26 @@ std::array, nParticles> hPtEtaItsTpc; std::array, nParticles> hPtEtaTrkItsTpc; std::array, nParticles> hPtEtaItsTpcTof; std::array, nParticles> hPtEtaGenerated; +// 2D Pt vs Radius +std::array, nParticles> hPtRadiusItsTpc; +std::array, nParticles> hPtRadiusTrkItsTpc; +std::array, nParticles> hPtRadiusItsTpcTof; +std::array, nParticles> hPtRadiusGenerated; + +std::array, nParticles> hPtRadiusItsTpcPrm; +std::array, nParticles> hPtRadiusTrkItsTpcPrm; +std::array, nParticles> hPtRadiusItsTpcTofPrm; +std::array, nParticles> hPtRadiusGeneratedPrm; + +std::array, nParticles> hPtRadiusItsTpcStr; +std::array, nParticles> hPtRadiusTrkItsTpcStr; +std::array, nParticles> hPtRadiusItsTpcTofStr; +std::array, nParticles> hPtRadiusGeneratedStr; + +std::array, nParticles> hPtRadiusItsTpcTer; +std::array, nParticles> hPtRadiusTrkItsTpcTer; +std::array, nParticles> hPtRadiusItsTpcTofTer; +std::array, nParticles> hPtRadiusGeneratedTer; struct QaEfficiency { // Track/particle selection @@ -193,9 +213,11 @@ struct QaEfficiency { ConfigurableAxis etaBins{"etaBins", {200, -3.f, 3.f}, "Eta binning"}; ConfigurableAxis phiBins{"phiBins", {200, 0.f, 6.284f}, "Phi binning"}; ConfigurableAxis yBins{"yBins", {200, -0.5f, 0.5f}, "Y binning"}; + ConfigurableAxis radiusBins{"radiusBins", {200, 0.f, 100.f}, "Radius binning"}; // Task configuration Configurable makeEff{"make-eff", false, "Flag to produce the efficiency with TEfficiency"}; 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"}; // Custom track cuts for debug purposes TrackSelection customTrackCuts; @@ -268,6 +290,7 @@ struct QaEfficiency { const AxisSpec axisEta{etaBins, "#it{#eta}"}; const AxisSpec axisY{yBins, "#it{y}"}; const AxisSpec axisPhi{phiBins, "#it{#varphi} (rad)"}; + const AxisSpec axisRadius{radiusBins, "Radius (cm)"}; const char* partName = particleName(pdgSign, id); LOG(info) << "Preparing histograms for particle: " << partName << " pdgSign " << pdgSign; @@ -300,7 +323,6 @@ struct QaEfficiency { partName, phiMin, phiMax, yMin, yMax); - const int histogramIndex = id + pdgSign * nSpecies; // Pt @@ -385,6 +407,24 @@ struct QaEfficiency { hPtEtaGenerated[histogramIndex] = histos.add(Form("MC/pdg%i/pt/asd", PDGs[histogramIndex]), "Generated " + tagPtEta, kTH2D, {axisPt, axisEta}); } + if (doPtRadius) { + hPtRadiusItsTpc[histogramIndex] = histos.add(Form("MC/pdg%i/pt/radius/its_tpc", PDGs[histogramIndex]), "ITS-TPC tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusItsTpcTof[histogramIndex] = histos.add(Form("MC/pdg%i/pt/radius/its_tpc_tof", PDGs[histogramIndex]), "ITS-TPC-TOF tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusGenerated[histogramIndex] = histos.add(Form("MC/pdg%i/pt/radius/generated", PDGs[histogramIndex]), "Generated " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + + hPtRadiusItsTpcPrm[histogramIndex] = histos.add(Form("MC/pdg%i/pt/prm/radius/its_tpc", PDGs[histogramIndex]), "ITS-TPC tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusItsTpcTofPrm[histogramIndex] = histos.add(Form("MC/pdg%i/pt/prm/radius/its_tpc_tof", PDGs[histogramIndex]), "ITS-TPC-TOF tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusGeneratedPrm[histogramIndex] = histos.add(Form("MC/pdg%i/pt/prm/radius/generated", PDGs[histogramIndex]), "Generated " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + + hPtRadiusItsTpcStr[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/radius/its_tpc", PDGs[histogramIndex]), "ITS-TPC tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusItsTpcTofStr[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/radius/its_tpc_tof", PDGs[histogramIndex]), "ITS-TPC-TOF tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusGeneratedStr[histogramIndex] = histos.add(Form("MC/pdg%i/pt/str/radius/generated", PDGs[histogramIndex]), "Generated " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + + hPtRadiusItsTpcTer[histogramIndex] = histos.add(Form("MC/pdg%i/pt/ter/radius/its_tpc", PDGs[histogramIndex]), "ITS-TPC tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusItsTpcTofTer[histogramIndex] = histos.add(Form("MC/pdg%i/pt/ter/radius/its_tpc_tof", PDGs[histogramIndex]), "ITS-TPC-TOF tracks " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + hPtRadiusGeneratedTer[histogramIndex] = histos.add(Form("MC/pdg%i/pt/ter/radius/generated", PDGs[histogramIndex]), "Generated " + tagPt + " vs Radius", kTH2D, {axisPt, axisRadius}); + } + LOG(info) << "Done with making histograms for particle: " << partName; } @@ -499,6 +539,16 @@ struct QaEfficiency { makeEfficiency2D("ITS-TPC_vsPt_vsEta_Trk", hPtEtaTrkItsTpc[histogramIndex]); makeEfficiency2D("ITS-TPC-TOF_vsPt_vsEta", hPtEtaItsTpcTof[histogramIndex]); } + if (doPtRadius) { + makeEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpc[histogramIndex]); + makeEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTof[histogramIndex]); + makeEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcPrm[histogramIndex]); + makeEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofPrm[histogramIndex]); + makeEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcStr[histogramIndex]); + makeEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofStr[histogramIndex]); + makeEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcTer[histogramIndex]); + makeEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofTer[histogramIndex]); + } LOG(info) << "Done with making histograms for particle: " << partName << " for efficiencies"; } @@ -925,24 +975,11 @@ struct QaEfficiency { } bool isFinal(const o2::aod::McParticles::iterator& mcParticle) { - // Example conditions to determine if a particle is final (tertiary) - // Here, we assume that final state particles are those not originating from primary vertex - // and not further decaying into other particles - // Check if the particle has no daughters - if (!mcParticle.has_daughters()) { - - // Check if the particle is not a primary particle - if (!mcParticle.isPhysicalPrimary()) { - // Check if the particle is produced in a secondary decay - if (mcParticle.getProcess() == 4) { - // Get the mother particle's index and the mother particle itself - auto mothers = mcParticle.mothers_as(); - for (const auto& mother : mothers) { - // Check if the mother particle is not primary and produced in a weak decay - if (!mother.isPhysicalPrimary() && mother.getProcess() == 4) { - return true; // Consider it as a tertiary particle - } - } + if (!mcParticle.has_daughters() && !mcParticle.isPhysicalPrimary() && mcParticle.getProcess() == 4) { + auto mothers = mcParticle.mothers_as(); + for (const auto& mother : mothers) { + if (!mother.isPhysicalPrimary() && mother.getProcess() == 4) { + return true; } } } @@ -969,6 +1006,7 @@ struct QaEfficiency { LOG(debug) << "fillMCTrackHistograms for pdgSign '" << pdgSign << "' and id '" << static_cast(id) << "' " << particleName(pdgSign, id) << " with index " << histogramIndex; const o2::aod::McParticles::iterator& mcParticle = track.mcParticle(); const CollisionCandidatesMC::iterator& collision = track.collision_as(); + float radius = std::sqrt(mcParticle.vx() * mcParticle.vx() + mcParticle.vy() * mcParticle.vy()); if (numSameCollision) { if (!collision.has_mcCollision()) { return; @@ -1010,6 +1048,12 @@ struct QaEfficiency { hPtEtaItsTpcTof[histogramIndex]->Fill(mcParticle.pt(), mcParticle.eta()); } } + if (doPtRadius) { + hPtRadiusItsTpc[histogramIndex]->Fill(mcParticle.pt(), radius); + if (passedTOF) { + hPtRadiusItsTpcTof[histogramIndex]->Fill(mcParticle.pt(), radius); + } + } } if (passedITS && passedTOF) { hPtItsTof[histogramIndex]->Fill(mcParticle.pt()); @@ -1047,6 +1091,12 @@ struct QaEfficiency { hEtaItsTpcTofPrm[histogramIndex]->Fill(mcParticle.eta()); hPhiItsTpcTofPrm[histogramIndex]->Fill(mcParticle.phi()); } + if (doPtRadius) { + hPtRadiusItsTpcPrm[histogramIndex]->Fill(mcParticle.pt(), radius); + if (passedTOF) { + hPtRadiusItsTpcTofPrm[histogramIndex]->Fill(mcParticle.pt(), radius); + } + } } } else if (mcParticle.getProcess() == 4) { // Particle decay // Checking mothers @@ -1072,6 +1122,12 @@ struct QaEfficiency { if (passedTOF) { hPtItsTpcTofStr[histogramIndex]->Fill(mcParticle.pt()); } + if (doPtRadius) { + hPtRadiusItsTpcStr[histogramIndex]->Fill(mcParticle.pt(), radius); + if (passedTOF) { + hPtRadiusItsTpcTofStr[histogramIndex]->Fill(mcParticle.pt(), radius); + } + } } if (isFinal(mcParticle)) { if (passedITS && passedTPC && motherIsAccepted) { @@ -1080,6 +1136,12 @@ struct QaEfficiency { if (passedTOF) { hPtItsTpcTofTer[histogramIndex]->Fill(mcParticle.pt()); } + if (doPtRadius) { + hPtRadiusItsTpcTer[histogramIndex]->Fill(mcParticle.pt(), radius); + if (passedTOF) { + hPtRadiusItsTpcTofTer[histogramIndex]->Fill(mcParticle.pt(), radius); + } + } } } } else { // Material @@ -1113,6 +1175,7 @@ struct QaEfficiency { constexpr int histogramIndex = id + pdgSign * nSpecies; LOG(debug) << "fillMCParticleHistograms for pdgSign '" << pdgSign << "' and id '" << static_cast(id) << "' " << particleName(pdgSign, id) << " with index " << histogramIndex; + float radius = std::sqrt(mcParticle.vx() * mcParticle.vx() + mcParticle.vy() * mcParticle.vy()); if (!isPdgSelected(mcParticle)) { // Selecting PDG code return; } @@ -1132,6 +1195,9 @@ struct QaEfficiency { hPtGeneratedPrm[histogramIndex]->Fill(mcParticle.pt()); hEtaGeneratedPrm[histogramIndex]->Fill(mcParticle.eta()); hPhiGeneratedPrm[histogramIndex]->Fill(mcParticle.phi()); + if (doPtRadius) { + hPtRadiusGeneratedPrm[histogramIndex]->Fill(mcParticle.pt(), radius); + } } else { if (mcParticle.getProcess() == 4) { // Particle decay // Checking mothers @@ -1153,8 +1219,14 @@ struct QaEfficiency { } if (motherIsAccepted) { hPtGeneratedStr[histogramIndex]->Fill(mcParticle.pt()); + if (doPtRadius) { + hPtRadiusGeneratedStr[histogramIndex]->Fill(mcParticle.pt(), radius); + } if (isFinal(mcParticle)) { hPtGeneratedTer[histogramIndex]->Fill(mcParticle.pt()); + if (doPtRadius) { + hPtRadiusGeneratedTer[histogramIndex]->Fill(mcParticle.pt(), radius); + } } } } else { // Material @@ -1167,6 +1239,9 @@ struct QaEfficiency { if (doPtEta) { hPtEtaGenerated[histogramIndex]->Fill(mcParticle.pt(), mcParticle.eta()); } + if (doPtRadius) { + hPtRadiusGenerated[histogramIndex]->Fill(mcParticle.pt(), radius); + } } template @@ -1283,8 +1358,18 @@ struct QaEfficiency { fillEfficiency2D("ITS-TPC_vsPt_vsEta", hPtEtaItsTpc[histogramIndex], hPtEtaGenerated[histogramIndex]); fillEfficiency2D("ITS-TPC_vsPt_vsEta_Trk", hPtEtaTrkItsTpc[histogramIndex], hPtEtaGenerated[histogramIndex]); fillEfficiency2D("ITS-TPC-TOF_vsPt_vsEta", hPtEtaItsTpcTof[histogramIndex], hPtEtaGenerated[histogramIndex]); + if (!doPtRadius) { + return; + } + fillEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpc[histogramIndex], hPtRadiusGenerated[histogramIndex]); + fillEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTof[histogramIndex], hPtRadiusGenerated[histogramIndex]); + fillEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcPrm[histogramIndex], hPtRadiusGeneratedPrm[histogramIndex]); + fillEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofPrm[histogramIndex], hPtRadiusGeneratedPrm[histogramIndex]); + fillEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcStr[histogramIndex], hPtRadiusGeneratedStr[histogramIndex]); + fillEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofStr[histogramIndex], hPtRadiusGeneratedStr[histogramIndex]); + fillEfficiency2D("ITS-TPC_vsPt_vsRadius", hPtRadiusItsTpcTer[histogramIndex], hPtRadiusGeneratedTer[histogramIndex]); + fillEfficiency2D("ITS-TPC-TOF_vsPt_vsRadius", hPtRadiusItsTpcTofTer[histogramIndex], hPtRadiusGeneratedTer[histogramIndex]); } - template bool isCollisionSelected(const CollType& collision) { diff --git a/DPG/Tasks/AOTTrack/qaEventTrack.cxx b/DPG/Tasks/AOTTrack/qaEventTrack.cxx index afab3403224..bfd106f4b8b 100644 --- a/DPG/Tasks/AOTTrack/qaEventTrack.cxx +++ b/DPG/Tasks/AOTTrack/qaEventTrack.cxx @@ -93,6 +93,13 @@ struct qaEventTrack { // options to check the track variables only for PV contributors Configurable checkOnlyPVContributor{"checkOnlyPVContributor", false, "check the track variables only for primary vertex contributors"}; + // options to force or not the presence of TRD (debug) + struct : ConfigurableGroup { + Configurable activateChecksTRD{"activateChecksTRD", false, "Activate the checks wityh TRD - force the track to have or not have TRD"}; + Configurable forceTRD{"forceTRD", false, "Force the track to have TRD"}; + Configurable forceNotTRD{"forceNotTRD", false, "Force the track not to have TRD"}; + } checksTRD; + // configurable binning of 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, 2.0, 5.0, 10.0, 20.0, 50.0}, ""}; ConfigurableAxis binsInvPt{"binsInvPt", {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}, ""}; @@ -152,6 +159,13 @@ struct qaEventTrack { return; } + if (checksTRD.activateChecksTRD) { + std::array casesTRD = {checksTRD.forceTRD, checksTRD.forceNotTRD}; + if (std::accumulate(casesTRD.begin(), casesTRD.end(), 0) != 1) { + LOGP(fatal, "One and only one case between forceTRD and forceNotTRD can be true at a time. Fix it!"); + } + } + // // Next section setups overwrite of configurableAxis if overwriteAxisRangeForPbPb is used. // @@ -1498,6 +1512,17 @@ void qaEventTrack::fillRecoHistogramsGroupedTracks(const C& collision, const T& if (!isSelectedTrack(track)) { continue; } + // TRD checks (debug) + if (checksTRD.activateChecksTRD) { + if (checksTRD.forceTRD && !track.hasTRD()) { + /// We want only tracks that match TRD, but the current one does not match it. Let's skip it. + continue; + } + if (checksTRD.forceNotTRD && track.hasTRD()) { + /// We want only tracks that do not match TRD, but the current one matches it. Let's skip it. + continue; + } + } // fill kinematic variables histos.fill(HIST("Tracks/Kine/pt"), track.pt()); if (track.sign() > 0) { diff --git a/DPG/Tasks/AOTTrack/qaFakeHits.cxx b/DPG/Tasks/AOTTrack/qaFakeHits.cxx index ee913462785..1da3a6a6674 100644 --- a/DPG/Tasks/AOTTrack/qaFakeHits.cxx +++ b/DPG/Tasks/AOTTrack/qaFakeHits.cxx @@ -114,7 +114,6 @@ struct QaFakeHits { const int histogramIndex = id + pdgSign * nSpecies; const TString tagPt = Form("%s ", partName); - hPtAll[histogramIndex] = histos.add(Form("MC/pdg%i/pt/all", PDGs[histogramIndex]), "All tracks " + tagPt, kTH1D, {axisPt}); hPtITS[histogramIndex] = histos.add(Form("MC/pdg%i/pt/mismatched/its", PDGs[histogramIndex]), "ITS mismatch " + tagPt, kTH1D, {axisPt}); hPtTPC[histogramIndex] = histos.add(Form("MC/pdg%i/pt/mismatched/tpc", PDGs[histogramIndex]), "TPC mismatch " + tagPt, kTH1D, {axisPt}); diff --git a/DPG/Tasks/AOTTrack/qaImpPar.cxx b/DPG/Tasks/AOTTrack/qaImpPar.cxx index 452e6448d70..fd5737ebbe8 100644 --- a/DPG/Tasks/AOTTrack/qaImpPar.cxx +++ b/DPG/Tasks/AOTTrack/qaImpPar.cxx @@ -65,12 +65,16 @@ struct QaImpactPar { ConfigurableAxis binningPhi{"binningPhi", {24, 0.f, TMath::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 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"}; @@ -108,6 +112,7 @@ struct QaImpactPar { Configurable keepAllTracksPVrefit{"keepAllTracksPVrefit", false, "Keep all tracks for PV refit (for debug)"}; Configurable use_customITSHitMap{"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"}; @@ -125,15 +130,16 @@ struct QaImpactPar { ((trackSelection.node() == 2) && requireGlobalTrackWoPtEtaInFilter()) || ((trackSelection.node() == 3) && requireGlobalTrackWoDCAInFilter()) || ((trackSelection.node() == 4) && requireQualityTracksInFilter()) || - ((trackSelection.node() == 5) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)); + ((trackSelection.node() == 5) && requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks)) || + ((trackSelection.node() == 6) && requireTrackCutInFilter(TrackSelectionFlags::kGlobalTrackWoDCAxy)); // Pt selection Filter ptMinFilter = o2::aod::track::pt > ptMin; /// Histogram registry (from o2::framework) HistogramRegistry histograms{"HistogramsImpParQA"}; - bool isPIDPionApplied = ((nSigmaTPCPionMin > -10.001 && nSigmaTPCPionMax < 10.001) || (nSigmaTOFPionMin > -10.001 && nSigmaTOFPionMax < 10.001)); - bool isPIDKaonApplied = ((nSigmaTPCKaonMin > -10.001 && nSigmaTPCKaonMax < 10.001) || (nSigmaTOFKaonMin > -10.001 && nSigmaTOFKaonMax < 10.001)); - bool isPIDProtonApplied = ((nSigmaTPCProtonMin > -10.001 && nSigmaTPCProtonMax < 10.001) || (nSigmaTOFProtonMin > -10.001 && nSigmaTOFProtonMax < 10.001)); + bool isPIDPionApplied; + bool isPIDKaonApplied; + bool isPIDProtonApplied; // Needed for PV refitting Service ccdb; @@ -151,14 +157,16 @@ struct QaImpactPar { 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, o2::aod::BCsWithTimestamps const&) { /// here call the template processReco function auto bc = collision.bc_as(); - processReco(collision, tracksUnfiltered, tracks, 0, bc); + processReco(collision, tracksUnfiltered, tracks, tracksIU, 0, bc); } PROCESS_SWITCH(QaImpactPar, processData, "process data", true); @@ -168,13 +176,14 @@ struct QaImpactPar { void processMC(o2::soa::Filtered::iterator& 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, mcParticles, bc); + processReco(collision, tracksUnfiltered, tracks, tracksIU, mcParticles, bc); } PROCESS_SWITCH(QaImpactPar, processMC, "process MC", false); @@ -232,7 +241,7 @@ struct QaImpactPar { // } mRunNumber = -1; - /// Custom cut selection objects + /// 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++) { @@ -251,11 +260,33 @@ struct QaImpactPar { selector_ITShitmap.SetRequireHitsInITSLayers(n_customMinITShits, 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)); + } + } + 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 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}})"}; @@ -281,6 +312,10 @@ struct QaImpactPar { histograms.get(HIST("Reco/refitRun3"))->GetXaxis()->SetBinLabel(5, "hasTPC && hasITS"); 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/h4ImpParIU", "", kTHnSparseD, {trackPaxis, trackImpParRPhiAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); + histograms.add("Reco/h4ImpParZIU", "", kTHnSparseD, {trackPaxis, trackImpParZAxis, trackIUposXaxis, trackIUposYaxis, trackIUposZaxis}); + } // if(fEnablePulls && !doPVrefit) { // LOGF(fatal, ">>> dca errors not stored after track propagation at the moment. Use fEnablePulls only if doPVrefit!"); // } @@ -288,14 +323,17 @@ struct QaImpactPar { histograms.add("Reco/h4ImpParPulls", "", kTHnSparseD, {trackPtAxis, trackImpParRPhiPullsAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); histograms.add("Reco/h4ImpParZPulls", "", kTHnSparseD, {trackPtAxis, trackImpParZPullsAxis, trackEtaAxis, trackPhiAxis, trackPDGAxis, trackChargeAxis, axisVertexNumContrib, trackIsPvContrib}); } + isPIDPionApplied = ((nSigmaTPCPionMin > -10.001 && nSigmaTPCPionMax < 10.001) || (nSigmaTOFPionMin > -10.001 && nSigmaTOFPionMax < 10.001)); if (isPIDPionApplied) { 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) { 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) { 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}); @@ -320,7 +358,7 @@ struct QaImpactPar { /// core template process function template void processReco(const C& collision, const trackTable& unfilteredTracks, const T& tracks, - const T_MC& /*mcParticles*/, + const trackTableIU& tracksIU, const T_MC& /*mcParticles*/, o2::aod::BCsWithTimestamps::iterator const& bc) { constexpr float toMicrometers = 10000.f; // Conversion from [cm] to [mum] @@ -441,6 +479,7 @@ struct QaImpactPar { /// loop over tracks float pt = -999.f; + float p = -999.f; float impParRPhi = -999.f; float impParZ = -999.f; float impParRPhiSigma = 999.f; @@ -451,6 +490,10 @@ struct QaImpactPar { 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 ntr = tracks.size(); int cnt = 0; for (const auto& track : tracks) { @@ -534,6 +577,7 @@ struct QaImpactPar { } pt = track.pt(); + p = track.p(); tpcNSigmaPion = track.tpcNSigmaPi(); tpcNSigmaKaon = track.tpcNSigmaKa(); tpcNSigmaProton = track.tpcNSigmaPr(); @@ -638,9 +682,26 @@ struct QaImpactPar { } } + /// 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]; + } + } + } + /// 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 (addTrackIUinfo) { + 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()); diff --git a/DPG/Tasks/AOTTrack/qaMatchEff.cxx b/DPG/Tasks/AOTTrack/qaMatchEff.cxx index fb1fbe7791f..ddcdf65766e 100644 --- a/DPG/Tasks/AOTTrack/qaMatchEff.cxx +++ b/DPG/Tasks/AOTTrack/qaMatchEff.cxx @@ -31,7 +31,10 @@ #include "Framework/AnalysisTask.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/runDataProcessing.h" - +// +#include "string" +#include "vector" +#include "set" // namespace extConfPar { @@ -76,6 +79,9 @@ struct qaMatchEff { Service ccdb; using BCsWithTimeStamp = soa::Join; + Configurable makethn{"makethn", false, "choose if produce thnsparse"}; + Configurable makehistos{"makehistos", true, "choose if produce histos"}; + Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable enableMonitorVsTime{"enableMonitorVsTime", false, "Enable the storage of ITS-TPC matching efficiency vs. time"}; Configurable enableTHnSparseMonitorVsTime{"enableTHnSparseMonitorVsTime", false, "Enable the storage of ITS-TPC matching efficiency vs. time"}; @@ -87,6 +93,7 @@ struct qaMatchEff { Configurable isPbPb{"isPbPb", false, "Boolean to tag if the data is PbPb collisions. If false, it is pp"}; Configurable isEnableEventSelection{"isEnableEventSelection", true, "Boolean to switch the event selection on/off."}; Configurable isCentralityRequired{"isCentralityRequired", false, "Boolean to switch the centrality selection on/off."}; + Configurable isRejectNearByEvent{"isRejectNearByEvent", false, "Boolean to switch the rejection of near by events on/off."}; Configurable isEnableOccupancyCut{"isEnableOccupancyCut", false, "Boolean to switch the occupancy cut on/off."}; struct : ConfigurableGroup { Configurable centralityMinCut{"centralityMinCut", 0.0f, "Minimum centrality"}; @@ -94,7 +101,7 @@ struct qaMatchEff { } centralityCuts; struct : ConfigurableGroup { Configurable minTracksInTimeRange{"minTracksInTimeRange", 0, "Minimum number of tracks in the time range"}; - Configurable maxTracksInTimeRange{"maxTracksInTimeRange", 1000, "Maximum number of tracks in the time range"}; + Configurable maxTracksInTimeRange{"maxTracksInTimeRange", 999999, "Maximum number of tracks in the time range"}; } occupancyCuts; // // Track selections @@ -119,6 +126,7 @@ struct qaMatchEff { Configurable etaMaxCut{"etaMaxCut", 2.0f, "Maximum pseudorapidity"}; } kineCuts; // + // // DCA and PID cuts Configurable> dcaMaxCut{"dcaMaxCut", {parTableDCA[0], nParDCA, nParVaDCA, parClassDCA, parNameDCA}, "Track DCA cuts"}; Configurable> nSigmaPID{"nSigmaPID", {parTablePID[0], nParPID, nParVaPID, parClassPID, parNamePID}, "PID nSigma cuts TPC and TOF"}; @@ -134,6 +142,7 @@ struct qaMatchEff { // Other track settings // TRD presence Configurable isTRDThere{"isTRDThere", 2, "Integer to turn the presence of TRD off, on, don't care (0,1,anything else)"}; + Configurable isTOFThere{"isTOFThere", 2, "Integer to turn the presence of TOF off, on, don't care (0,1,anything else)"}; // Configurable isitMC{"isitMC", false, "Reading MC files, data if false"}; Configurable doDebug{"doDebug", false, "Flag of debug information"}; @@ -158,28 +167,26 @@ struct qaMatchEff { ConfigurableAxis posZBinsVsTime{"posZBinsVsTime", {2, -100, 100}, "posZ primary vertex binning for monitoring vs time"}; ConfigurableAxis tpcClstBinsVsTime{"tpcClstBinsVsTime", {40, 0, 160}, "TPC cluster binning for monitoring vs time"}; ConfigurableAxis itsClstBinsVsTime{"itsClstBinsVsTime", {9, 0, 9}, "ITS cluster binning for monitoring vs time"}; + // pdg codes vector + std::vector pdgChoice = {211, 213, 215, 217, 219, 221, 223, 321, 411, 521, 2212, 1114, 2214}; + // - AxisSpec axisPDG{pdgBins, 0, pdgBins + 1.000, "pdgclass"}; - // - AxisSpec axisPt{ptBins, "#it{p}_{T} (GeV/#it{c})"}; - // - AxisSpec axisX{XBins, "track x (cm)"}; + // Tracks selection object + TrackSelection cutObject; // - AxisSpec axisZ{ZBins, "track z (cm)"}; + // do you want pt comparison 2d's ? + Configurable makept2d{"makept2d", false, "choose if produce pt reco/TPC derived pt 2dims "}; // - AxisSpec axisQoPt{qoptBins, -20, 20, "#Q/it{p}_{T} (GeV/#it{c})^{-1}"}; + // common flags for PID + Configurable isPIDPionRequired{"isPIDPionRequired", false, "choose if apply pion PID"}; + Configurable isPIDKaonRequired{"isPIDKaonRequired", false, "choose if apply kaon PID"}; + Configurable isPIDProtonRequired{"isPIDProtonRequired", false, "choose if apply proton PID"}; // - AxisSpec axisEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "#eta"}; - AxisSpec axisPhi{phiBins, 0.f, TwoPI, "#it{#varphi} (rad)"}; - AxisSpec axisDEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "D#eta"}; - AxisSpec axisDPh{phiBins, -PI, PI, "D#it{#varphi} (rad)"}; - // pdg codes vector - std::vector pdgChoice = {211, 213, 215, 217, 219, 221, 223, 321, 411, 521, 2212, 1114, 2214}; + // limit for z position of primary vertex + Configurable zPrimVtxMax{"zPrimVtxax", 999.f, "Maximum asbolute value of z of primary vertex"}; // // configuration for THnSparse's // - Configurable makethn{"makethn", false, "choose if produce thnsparse"}; - Configurable makehistos{"makehistos", true, "choose if produce histos"}; ConfigurableAxis thnd0{"thnd0", {150, -3.0f, 3.0f}, "impact parameter in xy [cm]"}; ConfigurableAxis thndz{"thndz", {150, -10.0f, 10.0f}, "impact parameter in z [cm]"}; ConfigurableAxis thnPt{"thnPt", {80, 0.0f, 20.0f}, "pt [GeV/c]"}; @@ -191,31 +198,6 @@ struct qaMatchEff { // ConfigurableAxis thnITSclumap{"thnITSclumap", {128, -0.5f, 127.5f}, "ITS cluster map"}; // ConfigurableAxis thnTPCclu{"thnTPCclu", {81, -0.5f, 160.5f}, "TPC nclust found"}; ConfigurableAxis thnHasDet{"thnHasDet", {12, -0.5f, 11.5f}, "presence of ITS, TPC, TOF, TRD"}; - AxisSpec thnd0Axis{thnd0, "#it{d}_{r#it{#varphi}} [cm]"}; - AxisSpec thndzAxis{thndz, "#it{d}_{z} [cm]"}; - AxisSpec thnPtAxis{thnPt, "#it{p}_{T}^{reco} [GeV/#it{c}]"}; - AxisSpec thnPhiAxis{thnPhi, "#it{#phi}"}; - AxisSpec thnEtaAxis{thnEta, "#it{#eta}"}; - AxisSpec thnTypeAxis{thnType, "0:prim-1:sec-2:matsec"}; - AxisSpec thnSpecAxis{thnSpec, "particle ID"}; - AxisSpec thnSignAxis{thnSign, "track sign"}; - // AxisSpec thnITSclumapAxis{thnITSclumap, "ITS cluster map"}; - // AxisSpec thnTPCcluAxis{thnTPCclu, "TPC nclust found"}; - AxisSpec thnHasDetAxis{thnHasDet, "presence of ITS, TPC, TOF, TRD"}; - // - // Tracks selection object - TrackSelection cutObject; - // - // do you want pt comparison 2d's ? - Configurable makept2d{"makept2d", false, "choose if produce pt reco/TPC derived pt 2dims "}; - // - // common flags for PID - Configurable isPIDPionRequired{"isPIDPionRequired", false, "choose if apply pion PID"}; - Configurable isPIDKaonRequired{"isPIDKaonRequired", false, "choose if apply kaon PID"}; - Configurable isPIDProtonRequired{"isPIDProtonRequired", false, "choose if apply proton PID"}; - // - // limit for z position of primary vertex - Configurable zPrimVtxMax{"zPrimVtxax", 999.f, "Maximum asbolute value of z of primary vertex"}; // // // ****** BE VERY CAREFUL! -- FILTERS !!! ***** @@ -231,6 +213,8 @@ struct qaMatchEff { if (doDebug) LOG(info) << "===========================================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> is it MC? = " << isitMC; // + // + // // let's know if it's MC or data if (isitMC) initMC(); @@ -321,6 +305,32 @@ struct qaMatchEff { { if (doDebug) LOGF(info, "*********************************************************** DATA ***************************************************"); + + // + const AxisSpec axisPDG{pdgBins, 0, pdgBins + 1.000, "pdgclass"}; + const AxisSpec axisPt{ptBins, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisX{XBins, "track x (cm)"}; + const AxisSpec axisZ{ZBins, "track z (cm)"}; + const AxisSpec axisQoPt{qoptBins, -20, 20, "#Q/it{p}_{T} (GeV/#it{c})^{-1}"}; + const AxisSpec axisEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "#eta"}; + const AxisSpec axisPhi{phiBins, 0.f, TwoPI, "#it{#varphi} (rad)"}; + const AxisSpec axisDEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "D#eta"}; + const AxisSpec axisDPh{phiBins, -PI, PI, "D#it{#varphi} (rad)"}; + // + // configuration for THnSparse's + // + const AxisSpec thnd0Axis{thnd0, "#it{d}_{r#it{#varphi}} [cm]"}; + const AxisSpec thndzAxis{thndz, "#it{d}_{z} [cm]"}; + const AxisSpec thnPtAxis{thnPt, "#it{p}_{T}^{reco} [GeV/#it{c}]"}; + const AxisSpec thnPhiAxis{thnPhi, "#it{#phi}"}; + const AxisSpec thnEtaAxis{thnEta, "#it{#eta}"}; + const AxisSpec thnTypeAxis{thnType, "0:prim-1:sec-2:matsec"}; + const AxisSpec thnSpecAxis{thnSpec, "particle ID"}; + const AxisSpec thnSignAxis{thnSign, "track sign"}; + const AxisSpec thnHasDetAxis{thnHasDet, "presence of ITS, TPC, TOF, TRD"}; + // const AxisSpec thnITSclumapAxis{thnITSclumap, "ITS cluster map"}; + // const AxisSpec thnTPCcluAxis{thnTPCclu, "TPC nclust found"}; + // // // data histos // @@ -805,6 +815,31 @@ struct qaMatchEff { { if (doDebug) LOGF(info, " +++++++++++++++++++++++ MC ++++++++++++++++++++++++"); + // + const AxisSpec axisPDG{pdgBins, 0, pdgBins + 1.000, "pdgclass"}; + const AxisSpec axisPt{ptBins, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec axisX{XBins, "track x (cm)"}; + const AxisSpec axisZ{ZBins, "track z (cm)"}; + const AxisSpec axisQoPt{qoptBins, -20, 20, "#Q/it{p}_{T} (GeV/#it{c})^{-1}"}; + const AxisSpec axisEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "#eta"}; + const AxisSpec axisPhi{phiBins, 0.f, TwoPI, "#it{#varphi} (rad)"}; + const AxisSpec axisDEta{etaBins, kineCuts.etaMinCut, kineCuts.etaMaxCut, "D#eta"}; + const AxisSpec axisDPh{phiBins, -PI, PI, "D#it{#varphi} (rad)"}; + // + // + // configuration for THnSparse's + // + const AxisSpec thnd0Axis{thnd0, "#it{d}_{r#it{#varphi}} [cm]"}; + const AxisSpec thndzAxis{thndz, "#it{d}_{z} [cm]"}; + const AxisSpec thnPtAxis{thnPt, "#it{p}_{T}^{reco} [GeV/#it{c}]"}; + const AxisSpec thnPhiAxis{thnPhi, "#it{#phi}"}; + const AxisSpec thnEtaAxis{thnEta, "#it{#eta}"}; + const AxisSpec thnTypeAxis{thnType, "0:prim-1:sec-2:matsec"}; + const AxisSpec thnSpecAxis{thnSpec, "particle ID"}; + const AxisSpec thnSignAxis{thnSign, "track sign"}; + // const AxisSpec thnITSclumapAxis{thnITSclumap, "ITS cluster map"}; + // const AxisSpec thnTPCcluAxis{thnTPCclu, "TPC nclust found"}; + const AxisSpec thnHasDetAxis{thnHasDet, "presence of ITS, TPC, TOF, TRD"}; // // adding histos to the registry @@ -1473,6 +1508,11 @@ struct qaMatchEff { continue; if ((isTRDThere == 0) && track.hasTRD()) continue; + // choose if we keep the track according to the TOF presence requirement + if ((isTOFThere == 1) && !track.hasTOF()) + continue; + if ((isTOFThere == 0) && track.hasTOF()) + continue; // kinematic track seletions for all tracks if (!isTrackSelectedKineCuts(track)) @@ -2332,7 +2372,7 @@ struct qaMatchEff { histos.get(HIST("data/PID/etahist_tpc_noidminus"))->Fill(track.eta()); } } // not pions, nor kaons, nor protons - } // end if DATA + } // end if DATA // if (trkWITS && isTrackSelectedITSCuts(track)) { //////////////////////////////////////////// ITS tag inside TPC tagged if constexpr (IS_MC) { //////////////////////// MC @@ -2672,7 +2712,7 @@ struct qaMatchEff { // } } } // end if ITS - } // end if TPC + } // end if TPC // // // if (trkWITS) { @@ -2799,9 +2839,9 @@ struct qaMatchEff { histos.get(HIST("data/etahist_tpcits_pos"))->Fill(track.eta()); } } // end if ITS - } // end if TPC - // - } // end positive + } // end if TPC + // + } // end positive // // negative only if (track.signed1Pt() < 0) { @@ -2826,9 +2866,9 @@ struct qaMatchEff { histos.get(HIST("data/etahist_tpcits_neg"))->Fill(track.eta()); } } // end if ITS - } // end if TPC - // - } // end negative + } // end if TPC + // + } // end negative if constexpr (IS_MC) { // MC auto mcpart = track.mcParticle(); @@ -2852,7 +2892,7 @@ struct qaMatchEff { histos.get(HIST("MC/primsec/phihist_tpcits_prim"))->Fill(track.phi()); histos.get(HIST("MC/primsec/etahist_tpcits_prim"))->Fill(track.eta()); } // end if ITS - } // end if TPC + } // end if TPC // end if primaries } else if (mcpart.getProcess() == 4) { // @@ -2874,7 +2914,7 @@ struct qaMatchEff { histos.get(HIST("MC/primsec/phihist_tpcits_secd"))->Fill(track.phi()); histos.get(HIST("MC/primsec/etahist_tpcits_secd"))->Fill(track.eta()); } // end if ITS - } // end if TPC + } // end if TPC // end if secondaries from decay } else { // @@ -2896,8 +2936,8 @@ struct qaMatchEff { histos.get(HIST("MC/primsec/phihist_tpcits_secm"))->Fill(track.phi()); histos.get(HIST("MC/primsec/etahist_tpcits_secm"))->Fill(track.eta()); } // end if ITS - } // end if TPC - } // end if secondaries from material + } // end if TPC + } // end if secondaries from material // // protons only if (tpPDGCode == 2212) { @@ -2964,7 +3004,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/etahist_tpcits_prminus"))->Fill(track.eta()); } } // end if ITS - } // end if TPC + } // end if TPC } // // pions only @@ -3032,7 +3072,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/etahist_tpcits_piminus"))->Fill(track.eta()); } } // end if ITS - } // end if TPC + } // end if TPC // // only primary pions if (mcpart.isPhysicalPrimary()) { @@ -3045,7 +3085,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/phihist_tpcits_pi_prim"))->Fill(track.phi()); histos.get(HIST("MC/PID/etahist_tpcits_pi_prim"))->Fill(track.eta()); } // end if ITS - } // end if TPC + } // end if TPC // end if primaries } else if (mcpart.getProcess() == 4) { // @@ -3059,7 +3099,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/phihist_tpcits_pi_secd"))->Fill(track.phi()); histos.get(HIST("MC/PID/etahist_tpcits_pi_secd"))->Fill(track.eta()); } // end if ITS - } // end if TPC + } // end if TPC // end if secondaries from decay } else { // @@ -3073,9 +3113,9 @@ struct qaMatchEff { histos.get(HIST("MC/PID/phihist_tpcits_pi_secm"))->Fill(track.phi()); histos.get(HIST("MC/PID/etahist_tpcits_pi_secm"))->Fill(track.eta()); } // end if ITS - } // end if TPC - } // end if secondaries from material // - } // end pions only + } // end if TPC + } // end if secondaries from material // + } // end pions only // // no primary/sec-d pions if (!((tpPDGCode == 211) && (mcpart.isPhysicalPrimary()))) { @@ -3099,8 +3139,8 @@ struct qaMatchEff { histos.get(HIST("MC/PID/etahist_tpcits_nopi"))->Fill(track.eta()); histos.get(HIST("MC/PID/pdghist_num"))->Fill(pdg_fill); } // end if ITS - } // end if TPC - } // end if not prim/sec-d pi + } // end if TPC + } // end if not prim/sec-d pi // // kaons only if (tpPDGCode == 321) { @@ -3167,7 +3207,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/etahist_tpcits_kaminus"))->Fill(track.eta()); } } // end if ITS - } // end if TPC + } // end if TPC } // // pions and kaons together @@ -3181,7 +3221,7 @@ struct qaMatchEff { histos.get(HIST("MC/PID/phihist_tpcits_piK"))->Fill(track.phi()); histos.get(HIST("MC/PID/etahist_tpcits_piK"))->Fill(track.eta()); } // end if ITS - } // end if TPC + } // end if TPC } } // @@ -3363,6 +3403,13 @@ struct qaMatchEff { return; } } + if (isRejectNearByEvent) { + if (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + if (doDebug) + LOGF(info, "Nearby event found, skipping..."); + return; + } + } if (isEnableOccupancyCut) { if (occupancy < occupancyCuts.minTracksInTimeRange || occupancy > occupancyCuts.maxTracksInTimeRange) { if (doDebug) diff --git a/DPG/Tasks/AOTTrack/qaTrackSplitting.cxx b/DPG/Tasks/AOTTrack/qaTrackSplitting.cxx index ca73e9006fd..3125f1e7c03 100644 --- a/DPG/Tasks/AOTTrack/qaTrackSplitting.cxx +++ b/DPG/Tasks/AOTTrack/qaTrackSplitting.cxx @@ -22,7 +22,9 @@ #include "Common/Core/TrackSelectionDefaults.h" #include "Common/DataModel/TrackSelectionTables.h" +using namespace o2; using namespace o2::framework; +using namespace o2::framework::expressions; struct qaTrackSplitting { Configurable pdg{"pdg", 2212, "PDG code of the particle to be analysed"}; @@ -40,6 +42,14 @@ struct qaTrackSplitting { Configurable maxDcaXY{"maxDcaXY", 10000.f, "Additional cut on the maximum abs value of the DCA xy"}; Configurable maxDcaZ{"maxDcaZ", 2.f, "Additional cut on the maximum abs 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 windowEta{"windowEta", 0.f, "Position in eta of the window"}; + Configurable windowEtaWidth{"windowEtaWidth", 0.1f, "Width of the eta window"}; + Configurable windowPhi{"windowPhi", 0.785f, "Position in phi of the window"}; + Configurable windowPhiWidth{"windowPhiWidth", 0.1f, "Width of the phi window"}; + Configurable windowPt{"windowPt", 1.f, "Position in pt of the window"}; + Configurable windowPtWidth{"windowPtWidth", 0.1f, "Width of the pt window"}; + } cfgCustomTrackCuts; // Histograms @@ -51,6 +61,7 @@ struct qaTrackSplitting { histos.add("tracks", "tracsk", kTH1D, {{10, -0.5, 9.5, "Track selection"}}); histos.add("numberOfRecoed", "recoed", kTH1D, {{10, -0.5, 9.5, "Number of tracks associated to a particle"}}); histos.add("map", "map", kTH3D, {{100, -1, 1, "#Delta #eta"}, {100, -1, 1, "#Delta #varphi"}, {100, -1, 1, "#Delta #it{p}_{T}"}}); + histos.add("deltaPt", "deltaPt", kTH2D, {{100, 0, 5, "#it{p}_{T}"}, {100, -1, 1, "#Delta #it{p}_{T}"}}); histos.add("mapMC", "mapMC", kTH3D, {{100, -1, 1, "#Delta #eta"}, {100, -1, 1, "#Delta #varphi"}, {100, -1, 1, "#Delta #it{p}_{T}"}}); customTrackCuts = getGlobalTrackSelectionRun3ITSMatch(cfgCustomTrackCuts.itsPattern); @@ -69,16 +80,46 @@ struct qaTrackSplitting { customTrackCuts.print(); } - // Global process - using TrackCandidates = o2::soa::Join; - void process(o2::soa::Join::iterator const& collision, - TrackCandidates const& tracks, - o2::aod::McParticles const&) + using CollisionCandidates = o2::soa::Join; + using TrackCandidates = o2::soa::Join; + Filter trackFilterEta = nabs(aod::track::eta - cfgCustomTrackCuts.windowEta) < cfgCustomTrackCuts.windowEtaWidth; + Filter trackFilterPhi = nabs(aod::track::phi - cfgCustomTrackCuts.windowPhi) < cfgCustomTrackCuts.windowPhiWidth; + Filter trackFilterITS = (aod::track::itsClusterSizes > (uint32_t)0); + Filter trackFilterTPC = (aod::track::tpcNClsFindable > (uint8_t)0); + // Filter trackFilterType = (aod::track::TrackType == aod::track::Track); + // Filter filterPt = nabs(aod::track::pt - cfgCustomTrackCuts.windowPt) < cfgCustomTrackCuts.windowPtWidth; + void processData(CollisionCandidates const& collisions, + soa::Filtered const& filteredTracks) + { + for (const auto& coll1 : collisions) { + for (const auto& coll2 : collisions) { + if (coll1.globalIndex() == coll2.globalIndex()) { + continue; + } + for (const auto& track2 : filteredTracks) { + // Compute the delta in pT + for (const auto& track1 : filteredTracks) { + if (track1.globalIndex() == track2.globalIndex()) { + continue; + } + histos.fill(HIST("deltaPt"), track1.pt(), track1.pt() - track2.pt()); + } + } + } + } + } + PROCESS_SWITCH(qaTrackSplitting, processData, "Process Data", true); + + using CollisionCandidatesMC = soa::Join; + using TrackCandidatesMC = o2::soa::Join; + void processMC(CollisionCandidatesMC::iterator const& collision, + TrackCandidatesMC const& tracks, + o2::aod::McParticles const&) { if (!collision.sel8()) { return; } - typedef std::shared_ptr trkType; + typedef std::shared_ptr trkType; std::map> particleUsageCounter; for (auto track : tracks) { @@ -87,11 +128,12 @@ struct qaTrackSplitting { continue; } histos.fill(HIST("tracks"), 1); - if (track.mcParticle().pdgCode() != pdg) { + const auto& mcParticle = track.mcParticle(); + if (mcParticle.pdgCode() != pdg) { continue; } histos.fill(HIST("tracks"), 2); - if (!track.mcParticle().isPhysicalPrimary()) { + if (!mcParticle.isPhysicalPrimary()) { continue; } histos.fill(HIST("tracks"), 3); @@ -101,21 +143,28 @@ struct qaTrackSplitting { histos.fill(HIST("tracks"), 4); particleUsageCounter[track.mcParticleId()].push_back(std::make_shared(track)); } - for (const auto& [mcId, tracks] : particleUsageCounter) { - histos.fill(HIST("numberOfRecoed"), tracks.size()); - if (tracks.size() > 1) { + for (const auto& [mcId, tracksMatched] : particleUsageCounter) { + histos.fill(HIST("numberOfRecoed"), tracksMatched.size()); + if (tracksMatched.size() > 1) { bool isFirst = true; - for (const auto& track : tracks) { + for (const auto& track : tracksMatched) { if (isFirst) { isFirst = false; - histos.fill(HIST("mapMC"), track->eta() - track->mcParticle().eta(), track->phi() - track->mcParticle().phi(), track->pt() - track->mcParticle().pt()); + histos.fill(HIST("mapMC"), + track->eta() - track->mcParticle().eta(), + track->phi() - track->mcParticle().phi(), + track->pt() - track->mcParticle().pt()); continue; } - histos.fill(HIST("map"), track->eta() - tracks[0]->eta(), track->phi() - tracks[0]->phi(), track->pt() - tracks[0]->pt()); + histos.fill(HIST("map"), + track->eta() - tracksMatched[0]->eta(), + track->phi() - tracksMatched[0]->phi(), + track->pt() - tracksMatched[0]->pt()); } } } } + PROCESS_SWITCH(qaTrackSplitting, processMC, "Process MC", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx b/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx index 7bb4692131d..2d236ee0230 100644 --- a/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx +++ b/DPG/Tasks/AOTTrack/tagAndProbeDmesons.cxx @@ -30,6 +30,7 @@ #include "Framework/runDataProcessing.h" #include "PWGHF/Utils/utilsAnalysis.h" #include "Tools/ML/MlResponse.h" +#include using namespace o2; using namespace o2::framework; @@ -60,7 +61,8 @@ enum SignalFlags : uint8_t { Bkg = 0, Prompt, NonPrompt, - Resonant + Resonant, + BkgFromNoHf }; static constexpr int nBinsPt = 7; @@ -187,7 +189,7 @@ struct TagTwoProngDisplacedVertices { Produces tagVarsTable; SliceCache cache; - Configurable fillTopoVarsTable{"fillTopoVarsTable", 0, "flag to fill tag table with topological variables (0 -> disabled, 1 -> signal only, 2 -> bkg only, 3 -> both)"}; + Configurable fillTopoVarsTable{"fillTopoVarsTable", 0, "flag to fill tag table with topological variables (0 -> disabled, 1 -> signal only, 2 -> bkg only, 3 -> bkg from no HF only, 4 -> all)"}; Configurable downsamplingForTopoVarTable{"downsamplingForTopoVarTable", 1.1, "fraction of tag candidates to downscale in filling table with topological variables"}; Configurable ptTagMaxForDownsampling{"ptTagMaxForDownsampling", 5., "maximum pT for downscaling of tag candidates in filling table with topological variables"}; Configurable applyTofPid{"applyTofPid", true, "flag to enable TOF PID selection"}; @@ -226,6 +228,8 @@ struct TagTwoProngDisplacedVertices { Configurable> onnxFileNamesDzeroFromDstar{"onnxFileNamesDzeroFromDstar", std::vector{"ModelHandler_onnx_DzeroToKPi.onnx"}, "ONNX file names for Kpi pairs from D0 <- D*+ decays"}; Configurable> onnxFileNamesDzeroKaKaFromDstar{"onnxFileNamesDzeroKaKaFromDstar", std::vector{"ModelHandler_onnx_DzeroToKK.onnx"}, "ONNX file names for KK pairs from D0 <- D*+ decays"}; // ML cuts + Configurable numMlClasses{"numMlClasses", 3, "Number of classes for the ML models"}; + Configurable> cutDirMl{"cutDirMl", std::vector{o2::cuts_ml::CutDirection::CutGreater, o2::cuts_ml::CutDirection::CutSmaller, o2::cuts_ml::CutDirection::CutSmaller}, "Whether to reject score values greater or smaller than the threshold"}; Configurable> mlCutsPiPiFromDplus{"mlCutsPiPiFromDplus", {aod::tagandprobe::mlCuts[0], aod::tagandprobe::nBinsPt, 3, aod::tagandprobe::labelsEmpty, aod::tagandprobe::labelsMlScores}, "ML Selections for pipi pairs from D+ decays"}; Configurable> mlCutsKaKaFromDsOrDplus{"mlCutsKaKaFromDsOrDplus", {aod::tagandprobe::mlCuts[0], aod::tagandprobe::nBinsPt, 3, aod::tagandprobe::labelsEmpty, aod::tagandprobe::labelsMlScores}, "ML Selections for KK pairs from Ds or D+ decays"}; 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"}; @@ -269,6 +273,10 @@ struct TagTwoProngDisplacedVertices { std::array, aod::tagandprobe::TagChannels::NTagChannels> topologicalCuts{}; std::array, aod::tagandprobe::TagChannels::NTagChannels> ptBinsForTopologicalCuts{}; + std::vector> hBkgMlScore{}; + std::vector> hPromptMlScore{}; + std::vector> hNonPromptMlScore{}; + std::vector> hDataMlScore{}; HistogramRegistry registry{"registry"}; @@ -302,6 +310,7 @@ struct TagTwoProngDisplacedVertices { const AxisSpec axisReflFlag{3, 0.5f, 3.5f}; const AxisSpec axisMassKaKa{200, constants::physics::MassPhi - 0.05f, constants::physics::MassPhi + 0.05f}; const AxisSpec axisMassKaPi{400, constants::physics::MassD0 - 0.2f, constants::physics::MassD0 + 0.2f}; + const AxisSpec axisMlScore{1000, 0.f, 1.f}; if (doprocessPiPiFromDplus || doprocessPiPiFromDplusMc) { registry.add("hMassPiPiVsPt", ";#it{p}_{T}(#pi#pi) (GeV/#it{c}); #it{M}(#pi#pi) (GeV/#it{c}^{2})", HistType::kTH2D, {axisPt, axisMassPiPi}); @@ -320,14 +329,27 @@ struct TagTwoProngDisplacedVertices { registry.add("hMassDzeroKaKaVsPt", ";#it{p}_{T}(K#pi) (GeV/#it{c}); #it{M}(K#pi) (GeV/#it{c}^{2})", HistType::kTH2D, {axisPt, axisMassKaPi}); } - const std::vector cutDirMl = {o2::cuts_ml::CutDirection::CutGreater, o2::cuts_ml::CutDirection::CutSmaller, o2::cuts_ml::CutDirection::CutSmaller}; + if (mlConfig.applyMlPiPiFromDplus || mlConfig.applyMlDzeroFromDstar || mlConfig.applyMlKaKaFromDsOrDplus || mlConfig.applyMlDzeroKaKaFromDstar) { + if (doprocessPiPiFromDplusMc || doprocessKaKaFromDsOrDplusMc || doprocessKaPiFromDstarMc) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hBkgMlScore.push_back(registry.add(Form("hBkgMlScore%d", iScore), Form(";#it{p}_{T}(tag) (GeV/#it{c});ML score %d; counts", iScore), HistType::kTH2D, {axisPt, axisMlScore})); + hPromptMlScore.push_back(registry.add(Form("hPromptMlScore%d", iScore), Form(";#it{p}_{T}(tag) (GeV/#it{c});ML score %d; counts", iScore), HistType::kTH2D, {axisPt, axisMlScore})); + hNonPromptMlScore.push_back(registry.add(Form("hNonPromptMlScore%d", iScore), Form(";#it{p}_{T}(tag) (GeV/#it{c});ML score %d; counts", iScore), HistType::kTH2D, {axisPt, axisMlScore})); + } + } else { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hDataMlScore.push_back(registry.add(Form("hMlScore%d", iScore), Form(";#it{p}_{T}(tag) (GeV/#it{c});ML score %d; counts", iScore), HistType::kTH2D, {axisPt, axisMlScore})); + } + } + } + const std::array, aod::tagandprobe::TagChannels::NTagChannels> mlCuts = {mlConfig.mlCutsPiPiFromDplus, mlConfig.mlCutsKaKaFromDsOrDplus, mlConfig.mlCutsDzeroFromDstar, mlConfig.mlCutsDzeroFromDstar, mlConfig.mlCutsDzeroKaKaFromDstar}; const std::array, aod::tagandprobe::TagChannels::NTagChannels> onnxFileNames = {mlConfig.onnxFileNamesPiPiFromDplus, mlConfig.onnxFileNamesKaKaFromDsOrDplus, mlConfig.onnxFileNamesDzeroFromDstar, mlConfig.onnxFileNamesDzeroFromDstar, mlConfig.onnxFileNamesDzeroKaKaFromDstar}; const std::array, aod::tagandprobe::TagChannels::NTagChannels> modelPathsCcdb = {mlConfig.modelPathsCcdbPiPiFromDplus, mlConfig.modelPathsCcdbKaKaFromDsOrDplus, mlConfig.modelPathsCcdbDzeroFromDstar, mlConfig.modelPathsCcdbDzeroFromDstar, mlConfig.modelPathsCcdbDzeroKaKaFromDstar}; applyMl = {mlConfig.applyMlPiPiFromDplus, mlConfig.applyMlKaKaFromDsOrDplus, mlConfig.applyMlDzeroFromDstar, mlConfig.applyMlDzeroFromDstar, mlConfig.applyMlDzeroKaKaFromDstar}; for (auto iChannel{0u}; iChannel < aod::tagandprobe::TagChannels::NTagChannels; ++iChannel) { if (applyMl[iChannel]) { - mlResponse[iChannel].configure(ptBinsForTopologicalCuts[iChannel], mlCuts[iChannel], cutDirMl, 3); + mlResponse[iChannel].configure(ptBinsForTopologicalCuts[iChannel], mlCuts[iChannel], mlConfig.cutDirMl, mlConfig.numMlClasses); if (mlConfig.loadMlModelsFromCcdb) { mlResponse[iChannel].setModelPathsCCDB(onnxFileNames[iChannel], ccdbApi, modelPathsCcdb[iChannel], mlConfig.timestampCcdbForMlModels); } else { @@ -397,7 +419,9 @@ struct TagTwoProngDisplacedVertices { } if (!firsTrack.has_mcParticle() || !secondTrack.has_mcParticle()) { - return BIT(aod::tagandprobe::SignalFlags::Bkg); + SETBIT(signalFlag, aod::tagandprobe::SignalFlags::Bkg); + SETBIT(signalFlag, aod::tagandprobe::SignalFlags::BkgFromNoHf); + return signalFlag; } else { auto firstMcTrack = firsTrack.template mcParticle_as(); auto secondMcTrack = secondTrack.template mcParticle_as(); @@ -469,7 +493,16 @@ struct TagTwoProngDisplacedVertices { return signalFlag; } - return BIT(aod::tagandprobe::SignalFlags::Bkg); + // if not signal, it must be background + SETBIT(signalFlag, aod::tagandprobe::SignalFlags::Bkg); + + auto originFirstTrack = RecoDecay::getCharmHadronOrigin(mcParticles, firstMcTrack, true); + auto originSecondTrack = RecoDecay::getCharmHadronOrigin(mcParticles, secondMcTrack, true); + if (originFirstTrack == RecoDecay::OriginType::None && originSecondTrack == RecoDecay::OriginType::None) { + SETBIT(signalFlag, aod::tagandprobe::SignalFlags::BkgFromNoHf); + } + + return signalFlag; } } @@ -655,9 +688,36 @@ struct TagTwoProngDisplacedVertices { continue; } + uint8_t isSignal{0u}; + int motherIdx{-1}; + if constexpr (doMc) { + isSignal = getTagOrigin(trackFirst, trackSecond, mcParticles, channel, pdgDecayMothers, pdgResonances, motherIdx); + } + std::vector mlScoresTag{}; if (applyMl[channel]) { - if (!mlResponse[channel].isSelectedMl(topoVars, ptTag, mlScoresTag)) { // for the time being all the topological variables used for all channels (decLen, decLenXy, normDecLen, normDecLenXy, cosp, cospXy, dcaXyTrack0, dcaXyTrack1, dcaProd) + bool isMlSelected = mlResponse[channel].isSelectedMl(topoVars, ptTag, mlScoresTag); + // we fill control histograms + if constexpr (doMc) { + if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Bkg)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hBkgMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } else if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Prompt)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hPromptMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } else if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::NonPrompt)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hNonPromptMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } + } else { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hDataMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } + if (!isMlSelected) { // for the time being all the topological variables used for all channels (decLen, decLenXy, normDecLen, normDecLenXy, cosp, cospXy, dcaXyTrack0, dcaXyTrack1, dcaProd) continue; } } @@ -665,18 +725,14 @@ struct TagTwoProngDisplacedVertices { float invMass{std::sqrt(invMass2)}; registry.fill(HIST("hMassPiPiVsPt"), ptTag, invMass); // only channel with same sign tracks for the moment - uint8_t isSignal{0u}; - int motherIdx{-1}; - if constexpr (doMc) { - isSignal = getTagOrigin(trackFirst, trackSecond, mcParticles, channel, pdgDecayMothers, pdgResonances, motherIdx); - } - if (fillTopoVarsTable) { bool fillTable{true}; if (fillTopoVarsTable == 1 && !(TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Prompt) || TESTBIT(isSignal, aod::tagandprobe::SignalFlags::NonPrompt))) { // only signal fillTable = false; } else if (fillTopoVarsTable == 2 && !TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Bkg)) { // only background fillTable = false; + } 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); if (ptTag < ptTagMaxForDownsampling && pseudoRndm >= downsamplingForTopoVarTable) { @@ -755,9 +811,36 @@ struct TagTwoProngDisplacedVertices { continue; } + uint8_t isSignal{0u}; + int motherIdx{-1}; + if constexpr (doMc) { + isSignal = getTagOrigin(trackPos, trackNeg, mcParticles, channel, pdgDecayMothers, pdgResonances, motherIdx); + } + std::vector mlScoresTag{}; if (applyMl[channel]) { - if (!mlResponse[channel].isSelectedMl(topoVars, ptTag, mlScoresTag)) { // for the time being all the topological variables used for all channels (decLen, decLenXy, normDecLen, normDecLenXy, cosp, cospXy, dcaXyTrack0, dcaXyTrack1, dcaProd) + bool isMlSelected = mlResponse[channel].isSelectedMl(topoVars, ptTag, mlScoresTag); + // we fill control histograms + if constexpr (doMc) { + if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Bkg)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hBkgMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } else if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Prompt)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hPromptMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } else if (TESTBIT(isSignal, aod::tagandprobe::SignalFlags::NonPrompt)) { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hNonPromptMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } + } else { + for (int iScore{0}; iScore < mlConfig.numMlClasses; ++iScore) { + hDataMlScore.at(iScore)->Fill(ptTag, mlScoresTag.at(iScore)); + } + } + if (!isMlSelected) { // for the time being all the topological variables used for all channels (decLen, decLenXy, normDecLen, normDecLenXy, cosp, cospXy, dcaXyTrack0, dcaXyTrack1, dcaProd) continue; } } @@ -807,18 +890,14 @@ struct TagTwoProngDisplacedVertices { registry.fill(HIST("hMassDzeroKaKaVsPt"), ptTag, invMass); } - uint8_t isSignal{0u}; - int motherIdx{-1}; - if constexpr (doMc) { - isSignal = getTagOrigin(trackPos, trackNeg, mcParticles, channel, pdgDecayMothers, pdgResonances, motherIdx); - } - if (fillTopoVarsTable) { bool fillTable{true}; if (fillTopoVarsTable == 1 && !(TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Prompt) || TESTBIT(isSignal, aod::tagandprobe::SignalFlags::NonPrompt))) { // only signal fillTable = false; } else if (fillTopoVarsTable == 2 && !TESTBIT(isSignal, aod::tagandprobe::SignalFlags::Bkg)) { // only background fillTable = false; + } 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); if (ptTag < ptTagMaxForDownsampling && pseudoRndm >= downsamplingForTopoVarTable) { @@ -1070,8 +1149,20 @@ struct ProbeThirdTrack { Configurable> mlCutsKaKaFromDsOrDplus{"mlCutsKaKaFromDsOrDplus", {aod::tagandprobe::mlCuts[0], aod::tagandprobe::nBinsPt, 3, aod::tagandprobe::labelsEmpty, aod::tagandprobe::labelsMlScores}, "ML Selections for KK pairs from Ds or D+ decays"}; 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"}; - Filter tagMcFilter = aod::tagandprobe::isSignal > 0; + 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"}; + ConfigurableAxis axisPtD{"axisPtD", {VARIABLE_WIDTH, 0.f, 0.5f, 1.f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f, 5.5f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 8.5f, 9.0f, 9.5f, 10.f, 11.f, 12.f, 14.f, 16.f, 20.f, 24.f, 36.f, 50.f}, "Axis for pt D"}; + ConfigurableAxis axisYD{"axisYD", {20, -1.f, 1.f}, "Axis for YD"}; + ConfigurableAxis axisEtaProbe{"axisEtaProbe", {20, -1.f, 1.f}, "Axis for Eta Probe"}; + ConfigurableAxis axisNumCrossRowTpc{"axisNumCrossRowTpc", {51, 49.5f, 100.5f}, "Axis for Number of CrossRowTpc"}; + ConfigurableAxis axisTpcChi2PerClus{"axisTpcChi2PerClus", {8, 2.f, 10.f}, "Axis for TpcChi2 Per Cluster"}; + ConfigurableAxis axisNumCluIts{"axisNumCluIts", {5, 2.5f, 7.5f}, "Axis for Number of Cluster ITS"}; + ConfigurableAxis axisPtMinTagdaught{"axisPtMinTagdaught", {10, 0.f, 1.f}, "Axis for Pt Min of Tag daughter"}; + ConfigurableAxis axisAbsEtaMaxTagdaught{"axisAbsEtaMaxTagdaught", {10, 0.f, 1.f}, "Axis for AbsEtaMax for Tag daughter"}; + + Filter tagMcFilter = aod::tagandprobe::isSignal > static_cast(0); using TracksWithDca = soa::Join; using TracksWithDcaMc = soa::Join; @@ -1098,8 +1189,11 @@ struct ProbeThirdTrack { std::array trackSelector{}; // define the track selectors std::array applyMl{}; + std::array minInvMass{}; + std::array maxInvMass{}; std::array, aod::tagandprobe::TrackTypes::NTrackTypes>, aod::tagandprobe::TagChannels::NTagChannels> histos{}; + std::array, aod::tagandprobe::TagChannels::NTagChannels> histosGen{}; HistogramRegistry registry{"registry"}; void init(InitContext&) @@ -1148,13 +1242,6 @@ struct ProbeThirdTrack { trackSelector[aod::tagandprobe::TrackTypes::GlobalWoDcaWoTpc].SetMaxChi2PerClusterITS(36.f); trackSelector[aod::tagandprobe::TrackTypes::GlobalWoDcaWoTpc].SetMaxDcaZ(2.f); - const AxisSpec axisPtProbe{{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}}; - const AxisSpec axisPtTag{{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}}; - const AxisSpec axisPtD{{0.f, 0.5f, 1.f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.5f, 5.0f, 5.5f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 8.5f, 9.0f, 9.5f, 10.f, 11.f, 12.f, 14.f, 16.f, 20.f, 24.f, 36.f, 50.f}}; - const AxisSpec axisEtaProbe{20, -1.f, 1.f}; - const AxisSpec axisNumCrossRowTpc{51, 49.5f, 100.5f}; - const AxisSpec axisTpcChi2PerClus{8, 2.f, 10.f}; - const AxisSpec axisNumCluIts{5, 2.5f, 7.5f}; std::array axisMass = {AxisSpec{225, 1.65f, 2.10f}, AxisSpec{225, 1.65f, 2.10f}, AxisSpec{350, 0.135f, 0.17f}, AxisSpec{350, 0.135f, 0.17f}, AxisSpec{350, 0.135f, 0.17f}}; std::array axisMassTag = {AxisSpec{125, 0.f, 2.5f}, AxisSpec{100, constants::physics::MassPhi - 0.05f, constants::physics::MassPhi + 0.05f}, AxisSpec{200, constants::physics::MassD0 - 0.2f, constants::physics::MassD0 + 0.2f}, AxisSpec{200, constants::physics::MassD0 - 0.2f, constants::physics::MassD0 + 0.2f}, AxisSpec{200, constants::physics::MassD0 - 0.2f, constants::physics::MassD0 + 0.2f}}; @@ -1166,9 +1253,14 @@ struct ProbeThirdTrack { 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}); + auto invMassBins = axisMass[iChannel].binEdges; + minInvMass[iChannel] = invMassBins.front(); + maxInvMass[iChannel] = invMassBins.back(); } } - + for (int iChannel{0}; iChannel < aod::tagandprobe::TagChannels::NTagChannels; ++iChannel) { + histosGen[iChannel] = registry.add(Form("hGen%s", tagChannels[iChannel].data()), ";#it{p}_{T}(D_{parent}) (GeV/#it{c}); #it{y}(D_{parent});#it{p}_{T}(tag) (GeV/#it{c}); #it{y}(tag);#it{p}_{T}(probe) (GeV/#it{c}); #it{#eta}(probe);#it{p}_{T}^{min}(tag daughters);#it{#eta}_{max}(tag daughters)", HistType::kTHnSparseF, {axisPtD, axisYD, axisPtTag, axisYD, axisPtProbe, axisEtaProbe, axisPtMinTagdaught, axisAbsEtaMaxTagdaught}); + } applyMl = {mlConfig.applyMlPiPiFromDplus, mlConfig.applyMlKaKaFromDsOrDplus, mlConfig.applyMlDzeroFromDstar}; } @@ -1246,14 +1338,12 @@ struct ProbeThirdTrack { auto numItsCluTrackThird = trackThird.itsNCls(); float invMass{-1.f}, invMassTag{-1.f}, ptTag{-1.f}, ptD{-1.f}; computeInvariantMass(trackFirst, trackSecond, trackThird, channel, ptTag, invMassTag, ptD, invMass); - if constexpr (channel == aod::tagandprobe::TagChannels::DstarPlusToDzeroPi || channel == aod::tagandprobe::TagChannels::DstarMinusToDzeroBarPi) { - if (invMass > 0.17f) { - continue; - } - } else if constexpr (channel == aod::tagandprobe::TagChannels::DplusToKPiPi || channel == aod::tagandprobe::TagChannels::DsOrDplusToKKPi) { - if ((invMass < 1.65f || invMass > 2.10f)) { - continue; - } + if (invMass < minInvMass[channel] || invMass > maxInvMass[channel]) { + continue; + } + if (ptD < ptCandMin) { + /// candidate pt lower than the minimum allowed value, let's skip it + continue; } for (int iTrackType{0}; iTrackType < aod::tagandprobe::TrackTypes::NTrackTypes; ++iTrackType) { if (trackSelector[iTrackType].IsSelected(trackThird)) { @@ -1392,6 +1482,59 @@ struct ProbeThirdTrack { void processDummy(aod::Collisions const&) {} PROCESS_SWITCH(ProbeThirdTrack, processDummy, "Dummy process function that does nothing", false); + + void processGeneratedDstarToDzeroPi(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) + { + + if (std::abs(mcCollision.posZ()) > 10.) + return; + std::array arrDstar = {kPiPlus, kKMinus, kPiPlus}; + int8_t* sign = nullptr; + std::vector listIndexDaughters; + float ptDzero = -1, yDzero = -999, ptSoftPion = -1, etaSoftPion = -999, ptminTagDaughers = 9999., etamaxTagDaugthers = 0.; + int indexProbe; + for (auto const& mcPart : mcParticles) { + // LOGP(info, "particle id: {}", mcPart.pdgCode()); + if (RecoDecay::isMatchedMCGen(mcParticles, mcPart, constants::physics::Pdg::kDStar, arrDstar, true, sign, 2, &listIndexDaughters)) { + // LOGP(info, "Selected particle id: {}", mcPart.pdgCode()); + ptDzero = -1; + yDzero = -999; + ptSoftPion = -1; + etaSoftPion = -999; + ptminTagDaughers = 9999.; + etamaxTagDaugthers = 0.; + indexProbe = -1; + for (auto const& iDaughtIndex : mcPart.daughtersIds()) { + // Printf("mcpart.daugthersIds, index: %d",idaughtindex); + auto mcPartDstarDaught = mcParticles.rawIteratorAt(iDaughtIndex - mcParticles.offset()); + if (std::abs(mcPartDstarDaught.pdgCode()) == constants::physics::Pdg::kD0) { + ptDzero = mcPartDstarDaught.pt(); + yDzero = mcPartDstarDaught.y(); + } else if (std::abs(mcPartDstarDaught.pdgCode()) == kPiPlus) { + ptSoftPion = mcPartDstarDaught.pt(); + etaSoftPion = mcPartDstarDaught.eta(); + indexProbe = iDaughtIndex; + } + } + for (auto const& idx : listIndexDaughters) { + // LOGP(info, "listIndexDaughters, index: {}", idx); + if (idx == indexProbe) { + continue; + } + auto mcPartDaught = mcParticles.rawIteratorAt(idx - mcParticles.offset()); + ptminTagDaughers = std::min(mcPartDaught.pt(), ptminTagDaughers); + etamaxTagDaugthers = std::max(std::abs(mcPartDaught.eta()), etamaxTagDaugthers); + } + // registry.fill(HIST(Form("hGen%s",tagChannels[aod::tagandprobe::DstarPlusToDzeroPi].data())), + if (mcPart.pdgCode() > 0) { + histosGen[aod::tagandprobe::DstarPlusToDzeroPi]->Fill(mcPart.pt(), mcPart.y(), ptDzero, yDzero, ptSoftPion, etaSoftPion, ptminTagDaughers, etamaxTagDaugthers); + } else { + histosGen[aod::tagandprobe::DstarMinusToDzeroBarPi]->Fill(mcPart.pt(), mcPart.y(), ptDzero, yDzero, ptSoftPion, etaSoftPion, ptminTagDaughers, etamaxTagDaugthers); + } + } + } + } + PROCESS_SWITCH(ProbeThirdTrack, processGeneratedDstarToDzeroPi, "Count generated particles", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/DPG/Tasks/FV0/qaFV0.cxx b/DPG/Tasks/FV0/qaFV0.cxx index 29a5b763211..295f981b0b7 100644 --- a/DPG/Tasks/FV0/qaFV0.cxx +++ b/DPG/Tasks/FV0/qaFV0.cxx @@ -394,7 +394,7 @@ struct fv0Qa { FillConditionHistograms("FV0BC", localCollisionBCFV0); - for (int i = 0; i < fv0.amplitude().size(); i++) { + for (std::size_t i = 0; i < fv0.amplitude().size(); i++) { FillConditionHistograms("FV0ChannelAmplitude", fv0.amplitude()[i]); FillConditionHistograms("FV0AmplitudePerChannel", fv0.channel()[i], fv0.amplitude()[i]); sum(totalAmplitudes, fv0.amplitude()[i]); diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx index 6dd7f5ab79b..67480f2c6d7 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.cxx @@ -61,6 +61,9 @@ struct TreeWriterTpcV0 { Configurable downsamplingTsalisPions{"downsamplingTsalisPions", -1., "Downsampling factor to reduce the number of pions"}; Configurable downsamplingTsalisProtons{"downsamplingTsalisProtons", -1., "Downsampling factor to reduce the number of protons"}; Configurable downsamplingTsalisElectrons{"downsamplingTsalisElectrons", -1., "Downsampling factor to reduce the number of electrons"}; + Configurable maxPt4dwnsmplTsalisPions{"maxPt4dwnsmplTsalisPions", 100., "Maximum Pt for applying downsampling factor of pions"}; + Configurable maxPt4dwnsmplTsalisProtons{"maxPt4dwnsmplTsalisProtons", 100., "Maximum Pt for applying downsampling factor of protons"}; + Configurable maxPt4dwnsmplTsalisElectrons{"maxPt4dwnsmplTsalisElectrons", 100., "Maximum Pt for applying downsampling factor of electrons"}; Filter trackFilter = (trackSelection.node() == 0) || ((trackSelection.node() == 1) && requireGlobalTrackInFilter()) || @@ -79,6 +82,8 @@ struct TreeWriterTpcV0 { 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(); @@ -87,7 +92,7 @@ struct TreeWriterTpcV0 { const float v0radius = v0.v0radius(); const float gammapsipair = v0.psipair(); - const double pseudoRndm = track.pt() * 1000. - (int64_t)(track.pt() * 1000); + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { rowTPCTree(track.tpcSignal(), 1. / dEdxExp, @@ -110,7 +115,9 @@ struct TreeWriterTpcV0 { pT, v0radius, gammapsipair, - runnumber); + runnumber, + trackocc, + ft0occ); } }; @@ -129,11 +136,14 @@ struct TreeWriterTpcV0 { /// Random downsampling trigger function using Tsalis/Hagedorn spectra fit (sqrt(s) = 62.4 GeV to 13 TeV) /// as in https://iopscience.iop.org/article/10.1088/2399-6528/aab00f/pdf TRandom3* fRndm = new TRandom3(0); - bool downsampleTsalisCharged(double pt, double factor1Pt, double sqrts, double mass) + bool downsampleTsalisCharged(double pt, double factor1Pt, double sqrts, double mass, double maxPt) { if (factor1Pt < 0.) { return true; } + if (pt > maxPt) { + return true; + } const double prob = tsalisCharged(pt, mass, sqrts) * pt; const double probNorm = tsalisCharged(1., mass, sqrts); if ((fRndm->Rndm() * ((prob / probNorm) * pt * pt)) > factor1Pt) { @@ -181,37 +191,37 @@ struct TreeWriterTpcV0 { auto negTrack = v0.negTrack_as>(); // 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])) { + 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.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El); } - if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisElectrons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Electron])) { + 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.tpcSignal()), o2::track::PID::Electron, runnumber, dwnSmplFactor_El); } } // 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])) { + 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.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi); } - if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + 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.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi); } } // 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])) { + if (downsampleTsalisCharged(posTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { fillSkimmedV0Table(v0, posTrack, collision, posTrack.tpcNSigmaPr(), posTrack.tofNSigmaPr(), posTrack.tpcExpSignalPr(posTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr); } - if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisPions, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Pion])) { + 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.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi); } } // 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])) { + 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.tpcSignal()), o2::track::PID::Pion, runnumber, dwnSmplFactor_Pi); } - if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton])) { + if (downsampleTsalisCharged(negTrack.pt(), downsamplingTsalisProtons, sqrtSNN, o2::track::pid_constants::sMasses[o2::track::PID::Proton], maxPt4dwnsmplTsalisProtons)) { fillSkimmedV0Table(v0, negTrack, collision, negTrack.tpcNSigmaPr(), negTrack.tofNSigmaPr(), negTrack.tpcExpSignalPr(negTrack.tpcSignal()), o2::track::PID::Proton, runnumber, dwnSmplFactor_Pr); } } @@ -318,8 +328,10 @@ struct TreeWriterTPCTOF { 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. - (int64_t)(track.pt() * 1000); + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < dwnSmplFactor) { rowTPCTOFTree(track.tpcSignal(), 1. / dEdxExp, @@ -336,7 +348,9 @@ struct TreeWriterTPCTOF { id, nSigmaTPC, nSigmaTOF, - runnumber); + runnumber, + trackocc, + ft0occ); } }; diff --git a/DPG/Tasks/TPC/tpcSkimsTableCreator.h b/DPG/Tasks/TPC/tpcSkimsTableCreator.h index c8cce4750de..2f65dccc589 100644 --- a/DPG/Tasks/TPC/tpcSkimsTableCreator.h +++ b/DPG/Tasks/TPC/tpcSkimsTableCreator.h @@ -41,6 +41,8 @@ DECLARE_SOA_COLUMN(PtV0, ptV0, float); DECLARE_SOA_COLUMN(RadiusV0, radiusV0, float); DECLARE_SOA_COLUMN(GammaPsiPair, gammaPsiPair, float); DECLARE_SOA_COLUMN(RunNumber, runNumber, int); +DECLARE_SOA_COLUMN(TrackOcc, trackOcc, float); +DECLARE_SOA_COLUMN(Ft0Occ, ft0Occ, float); } // namespace tpcskims DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", o2::aod::track::TPCSignal, @@ -64,7 +66,9 @@ DECLARE_SOA_TABLE(SkimmedTPCV0Tree, "AOD", "TPCSKIMV0TREE", tpcskims::PtV0, tpcskims::RadiusV0, tpcskims::GammaPsiPair, - tpcskims::RunNumber); + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ); DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", o2::aod::track::TPCSignal, @@ -82,6 +86,8 @@ DECLARE_SOA_TABLE(SkimmedTPCTOFTree, "AOD", "TPCTOFSKIMTREE", tpcskims::PidIndex, tpcskims::NSigTPC, tpcskims::NSigTOF, - tpcskims::RunNumber); + tpcskims::RunNumber, + tpcskims::TrackOcc, + tpcskims::Ft0Occ); } // namespace o2::aod #endif // DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_ diff --git a/EventFiltering/CMakeLists.txt b/EventFiltering/CMakeLists.txt index 951f02f0930..31cd58f40ed 100644 --- a/EventFiltering/CMakeLists.txt +++ b/EventFiltering/CMakeLists.txt @@ -108,9 +108,10 @@ o2physics_add_dpl_workflow(lf-f1proton-filter COMPONENT_NAME Analysis) o2physics_add_library(EventFilteringUtils - SOURCES Zorro.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) + SOURCES Zorro.cxx ZorroSummary.cxx + INSTALL_HEADERS ZorroHelper.h ZorroSummary.h + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore Arrow::arrow_shared) o2physics_target_root_dictionary(EventFilteringUtils - HEADERS Zorro.h + HEADERS ZorroHelper.h ZorroSummary.h LINKDEF EventFilteringUtilsLinkDef.h) \ No newline at end of file diff --git a/EventFiltering/EventFilteringUtilsLinkDef.h b/EventFiltering/EventFilteringUtilsLinkDef.h index e06cef4e78a..3f029b8aa9a 100644 --- a/EventFiltering/EventFilteringUtilsLinkDef.h +++ b/EventFiltering/EventFilteringUtilsLinkDef.h @@ -13,4 +13,6 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ; +#pragma link C++ class ZorroHelper + ; +#pragma link C++ class ZorroSummary + ; +#pragma link C++ class std::vector < ZorroHelper> + ; diff --git a/EventFiltering/PWGCF/CFFilterAll.cxx b/EventFiltering/PWGCF/CFFilterAll.cxx index ca7b90fc0ca..80832e661b1 100644 --- a/EventFiltering/PWGCF/CFFilterAll.cxx +++ b/EventFiltering/PWGCF/CFFilterAll.cxx @@ -53,6 +53,7 @@ enum CFThreeBodyTriggers { kPPP, kPPL, kPLL, kLLL, + kPPPhi, kNThreeBodyTriggers }; enum CFTwoBodyTriggers { kPD, kLD, @@ -83,7 +84,7 @@ enum PIDLimits { kTPCMin, }; // For configurable tables -static const std::vector CFTriggerNamesALL{"ppp", "ppL", "pLL", "LLL", "pd", "Ld"}; +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"}; @@ -97,17 +98,17 @@ static const std::vector PidCutsName{"TPC min", "TPC max", "TOF min 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"}; +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", "PD", "aPaD", "LD", "aLaD"}; +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 = 6; -static const int nTriggerAllNames = 12; +static const int nAllTriggers = 7; +static const int nTriggerAllNames = 14; static const int nMomCorCuts = 2; static const float pidcutsTable[nTracks][kNPIDLimits]{ @@ -143,17 +144,17 @@ static const float ITSCutsTable[1][nTracks] = { {1, 1}}; static const float triggerSwitches[1][nAllTriggers]{ - {1, 1, 1, 1, 1, 1}}; + {1, 1, 1, 1, 1, 1, 1}}; static const float Q3Limits[1][kNThreeBodyTriggers]{ - {0.6f, 0.6f, 0.6f, 0.6f}}; + {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., -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 @@ -466,6 +467,25 @@ struct CFFilter { {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; + // Trigger selections Configurable> ConfTriggerSwitches{ "ConfTriggerSwitches", @@ -515,8 +535,8 @@ struct CFFilter { } // global histograms - registry.add("fProcessedEvents", "CF - event filtered;;Events", HistType::kTH1F, {{8, -0.5, 7.5}}); - std::vector eventTitles = {"all", "rejected", "ppp", "ppL", "pLL", "LLL", "pD", "LD"}; + 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()); } @@ -742,6 +762,61 @@ struct CFFilter { 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()}}); + // 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}}); @@ -786,6 +861,18 @@ struct CFFilter { 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}}}); + // 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}}); + // 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}}); @@ -816,6 +903,10 @@ struct CFFilter { 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; + int currentRunNumber = -999; int lastRunNumber = -999; @@ -1179,6 +1270,21 @@ struct CFFilter { return true; } + template + bool isSelectedTrackKaon(T const& track) + { + 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; + } + } + return isSelected; + } + float getkstar(const ROOT::Math::PtEtaPhiMVector part1, const ROOT::Math::PtEtaPhiMVector part2) { @@ -1335,7 +1441,7 @@ struct CFFilter { std::vector AntiProtonIndex = {}; // Prepare vectors for different species - std::vector protons, antiprotons, deuterons, antideuterons, lambdas, antilambdas; + std::vector protons, antiprotons, deuterons, antideuterons, lambdas, antilambdas, kaons, antikaons, phi; // create deuteron and proton vectors (and corresponding antiparticles) for pair and triplet creation for (auto& track : tracks) { @@ -1516,6 +1622,54 @@ struct CFFilter { registry.fill(HIST("TrackCuts/AntiDeuteron/fTPCnclsAntiDeuteron"), track.tpcNClsFound()); } } + // 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()); + } + 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()); + } + } + } } // keep track of daugher indices to avoid selfcorrelations @@ -1627,6 +1781,38 @@ struct CFFilter { } } + 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()); + } + } + } + } + float Q3 = 999.f, kstar = 999.f; if (ConfTriggerSwitches->get("Switch", "ppp") > 0.) { // ppp trigger @@ -1892,6 +2078,54 @@ struct CFFilter { } } } + 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; + } + } + } + } + } + // 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; + } + } + } + } + } + } if (ConfTriggerSwitches->get("Switch", "pd") > 0.) { // pd trigger for (auto iProton = protons.begin(); iProton != protons.end(); ++iProton) { @@ -1998,17 +2232,23 @@ struct CFFilter { 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()); + } // create tags for two body triggers if (lowKstarPairs[CFTrigger::kPD] > 0) { keepEvent2N[CFTrigger::kPD] = true; - registry.fill(HIST("fProcessedEvents"), 6); + registry.fill(HIST("fProcessedEvents"), 7); registry.fill(HIST("pd/fMultiplicity"), col.multNTracksPV()); registry.fill(HIST("pd/fZvtx"), col.posZ()); } if (lowKstarPairs[CFTrigger::kLD] > 0) { keepEvent2N[CFTrigger::kLD] = true; - registry.fill(HIST("fProcessedEvents"), 7); + registry.fill(HIST("fProcessedEvents"), 8); registry.fill(HIST("ld/fMultiplicity"), col.multNTracksPV()); registry.fill(HIST("ld/fZvtx"), col.posZ()); } @@ -2017,10 +2257,11 @@ struct CFFilter { 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] && + 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); } diff --git a/EventFiltering/PWGCF/CFFilterPPPhi.cxx b/EventFiltering/PWGCF/CFFilterPPPhi.cxx index 71487754b29..623b5cb9086 100644 --- a/EventFiltering/PWGCF/CFFilterPPPhi.cxx +++ b/EventFiltering/PWGCF/CFFilterPPPhi.cxx @@ -72,23 +72,32 @@ struct CFFillterPPPhi { false, "Evt sel: check for offline selection"}; - Configurable InvMassCutWidth{"InvMassCutWidth", 0.024, "Phi Inv Mass Cut Width (GeV)"}; + 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 Q3Max{"Q3Max", 1.f, "Max Q3"}; /*track selection*/ - Configurable ConfTrkEta{"ConfTrkEta", 0.85, "Eta"}; // 0.8 - Configurable ConfTrkDCAxy{"ConfTrkDCAxy", 0.15, "DCAxy"}; // 0.1 - Configurable ConfTrkDCAz{"ConfTrkDCAz", 0.3, "DCAz"}; // 0.2 - Configurable ConfNClus{"ConfNClus", 70, "NClusters"}; // 0.2 - Configurable ConfNCrossed{"ConfNCrossed", 65, "NCrossedRows"}; // 0.2 + Configurable ConfTrkEtaPr{"ConfTrkEtaPr", 0.85, "Et protona"}; // 0.8 + Configurable ConfTrkDCAxyPr{"ConfTrkDCAxyPr", 0.15, "DCAxy proton"}; // 0.1 + Configurable ConfTrkDCAzPr{"ConfTrkDCAzPr", 0.3, "DCAz proton"}; // 0.2 + Configurable ConfNClusPr{"ConfNClusPr", 70, "NClusters proton"}; // 0.2 + Configurable ConfNCrossedPr{"ConfNCrossedPr", 65, "NCrossedRows proton"}; // 0.2 + Configurable ConfTrkTPCfClsPr{"ConfTrkTPCfClsPr", 0.83, "Minimum fraction of crossed rows over findable clusters proton"}; // 0.2 Configurable ConfTrkPtPrUp{"ConfTrkPtPrUp", 6.0, "Pt_up proton"}; // 2.0 Configurable ConfTrkPtPrDown{"ConfTrkPtPrDown", 0.35, "Pt_down proton"}; // 0.5 Configurable ConfTrkPTPCPrThr{"ConfTrkPTPCPrThr", 0.8, "p_TPC,Thr proton"}; // 0.75 Configurable ConfTrkPrSigmaPID{"ConfTrkPrSigmaPID", 3.50, "n_sigma proton"}; // 3.0 + Configurable ConfTrkEtaKa{"ConfTrkEtaKa", 0.85, "Eta kaon"}; // 0.8 + Configurable ConfTrkDCAxyKa{"ConfTrkDCAxyKa", 0.15, "DCAxy kaon"}; // 0.1 + Configurable ConfTrkDCAzKa{"ConfTrkDCAzKa", 0.3, "DCAz kaon"}; // 0.2 + Configurable ConfNClusKa{"ConfNClusKa", 70, "NClusters kaon"}; // 0.2 + Configurable ConfNCrossedKa{"ConfNCrossedKa", 65, "NCrossedRows kaon"}; // 0.2 + Configurable ConfTrkTPCfClsKa{"ConfTrkTPCfClsKa", 0.80, "Minimum fraction of crossed rows over findable clusters kaon"}; // 0.2 + Configurable ConfTrkPtKaUp{"ConfTrkPtKaUp", 6.0, "Pt_up kaon"}; // 2.0 Configurable ConfTrkPtKaDown{"ConfTrkPtKaDown", 0.05, "Pt_down kaon"}; // 0.15 Configurable ConfTrkPTPCKaThr{"ConfTrkPTPCKaThr", 0.40, "p_TPC,Thr kaon"}; // 0.4 @@ -193,6 +202,7 @@ struct CFFillterPPPhi { // phi cuts registry.add("TrackCuts/Phi/fPtPhiBefore", "Transverse momentum V0s;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); registry.add("TrackCuts/Phi/fInvMassPhiBefore", "Invariant mass V0s;M_{KK};Entries", HistType::kTH1F, {{7000, 0.8, 1.5}}); + registry.add("TrackCuts/Phi/fEtaPhiBefore", "Pseudorapidity of V0;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); registry.add("TrackCuts/Phi/fPhiPhiBefore", "Azimuthal angle of V0;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); @@ -202,12 +212,13 @@ struct CFFillterPPPhi { registry.add("TrackCuts/Phi/fPhiPhi", "Azimuthal angle of V0;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); // phi daughter + registry.add("TrackCuts/Phi/PosDaughter/Pt", "Transverse momentum Pos Daugh tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); registry.add("TrackCuts/Phi/PosDaughter/Eta", "Phi Pos Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/PosDaughter/DCAXY", "Phi Pos Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/Phi/PosDaughter/fTPCncls", "Phi Pos Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); + registry.add("TrackCuts/Phi/PosDaughter/Phi", "Azimuthal angle of Pos Daugh tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); + + registry.add("TrackCuts/Phi/NegDaughter/Pt", "Transverse momentum Neg Daugh tracks;p_{T} (GeV/c);Entries", HistType::kTH1F, {{1000, 0, 10}}); registry.add("TrackCuts/Phi/NegDaughter/Eta", "Phi Neg Daugh Eta;#eta;Entries", HistType::kTH1F, {{1000, -2, 2}}); - registry.add("TrackCuts/Phi/NegDaughter/DCAXY", "Phi Neg Daugh DCAXY;DCA_{XY};Entries", HistType::kTH1F, {{1000, -2.5f, 2.5f}}); - registry.add("TrackCuts/Phi/NegDaughter/fTPCncls", "Phi Neg Daugh TPCncls;TPC Clusters;Entries", HistType::kTH1F, {{163, -1.0f, 162.0f}}); + registry.add("TrackCuts/Phi/NegDaughter/Phi", "Azimuthal angle of Neg Daugh tracks;#phi;Entries", HistType::kTH1F, {{720, 0, TMath::TwoPi()}}); // triggers registry.add("ppphi/fMultiplicity", "Multiplicity of all triggered events;Mult;Entries", HistType::kTH1F, {{1000, 0, 1000}}); @@ -236,11 +247,11 @@ struct CFFillterPPPhi { bool isSelectedTrackProton(T const& track) { bool isSelected = false; - if (track.pt() < ConfTrkPtPrUp.value && track.pt() > ConfTrkPtPrDown.value && std::abs(track.eta()) < ConfTrkEta.value && std::abs(track.dcaXY()) < ConfTrkDCAxy.value && std::abs(track.dcaZ()) < ConfTrkDCAz.value && track.tpcNClsCrossedRows() >= ConfNCrossed.value && track.tpcNClsFound() >= ConfNClus.value) { - if (track.tpcInnerParam() < ConfTrkPTPCPrThr.value && std::abs(track.tpcNSigmaPr()) < ConfTrkPrSigmaPID.value) { + if (track.pt() <= ConfTrkPtPrUp.value && track.pt() >= ConfTrkPtPrDown.value && std::abs(track.eta()) <= ConfTrkEtaPr.value && std::abs(track.dcaXY()) <= ConfTrkDCAxyPr.value && std::abs(track.dcaZ()) <= ConfTrkDCAzPr.value && track.tpcNClsCrossedRows() >= ConfNCrossedPr.value && track.tpcNClsFound() >= ConfNClusPr.value && track.tpcCrossedRowsOverFindableCls() >= ConfTrkTPCfClsPr.value) { + if (track.tpcInnerParam() < ConfTrkPTPCPrThr.value && std::abs(track.tpcNSigmaPr()) <= ConfTrkPrSigmaPID.value) { isSelected = true; } - if (track.tpcInnerParam() >= ConfTrkPTPCPrThr.value && std::abs(std::sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr())) < ConfTrkPrSigmaPID.value) { + if (track.tpcInnerParam() >= ConfTrkPTPCPrThr.value && std::abs(std::sqrt(track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr())) <= ConfTrkPrSigmaPID.value) { isSelected = true; } } @@ -251,11 +262,11 @@ struct CFFillterPPPhi { bool isSelectedTrackKaon(T const& track) { bool isSelected = false; - if (track.pt() < ConfTrkPtKaUp.value && track.pt() > ConfTrkPtKaDown.value && std::abs(track.eta()) < ConfTrkEta.value && std::abs(track.dcaXY()) < ConfTrkDCAxy.value && std::abs(track.dcaZ()) < ConfTrkDCAz.value && track.tpcNClsCrossedRows() >= ConfNCrossed.value && track.tpcNClsFound() >= ConfNClus.value) { - if (track.tpcInnerParam() < ConfTrkPTPCKaThr.value && std::abs(track.tpcNSigmaKa()) < ConfTrkKaSigmaPID.value) { + if (track.pt() <= ConfTrkPtKaUp.value && track.pt() >= ConfTrkPtKaDown.value && std::abs(track.eta()) <= ConfTrkEtaKa.value && std::abs(track.dcaXY()) <= ConfTrkDCAxyKa.value && std::abs(track.dcaZ()) <= ConfTrkDCAzKa.value && track.tpcNClsCrossedRows() >= ConfNCrossedKa.value && track.tpcNClsFound() >= ConfNClusKa.value && track.tpcCrossedRowsOverFindableCls() >= ConfTrkTPCfClsKa.value) { + if (track.tpcInnerParam() < ConfTrkPTPCKaThr.value && std::abs(track.tpcNSigmaKa()) <= ConfTrkKaSigmaPID.value) { isSelected = true; } - if (track.tpcInnerParam() >= ConfTrkPTPCKaThr.value && std::abs(std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())) < ConfTrkKaSigmaPID.value) { + if (track.tpcInnerParam() >= ConfTrkPTPCKaThr.value && std::abs(std::sqrt(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa())) <= ConfTrkKaSigmaPID.value) { isSelected = true; } } @@ -263,38 +274,10 @@ struct CFFillterPPPhi { } float mMassProton = o2::constants::physics::MassProton; - float mMassKaon = o2::constants::physics::MassKPlus; - float mMassPhi = o2::constants::physics::MassPhi; - - // float getInvMass(const ROOT::Math::PtEtaPhiMVector part1, - // const ROOT::Math::PtEtaPhiMVector part2) - // { - // const ROOT::Math::PtEtaPhiMVector trackSum = part1 + part2; - // return trackSum.M(); - // } - - float CalculateInvMass(const ROOT::Math::PtEtaPhiMVector part1, - const ROOT::Math::PtEtaPhiMVector part2) - { - Double_t invMass = 0; - - float massDP = mMassKaon; - float massDN = mMassKaon; + float mMassKaonPlus = o2::constants::physics::MassKPlus; + float mMassKaonMinus = o2::constants::physics::MassKMinus; - float EDaugP = TMath::Sqrt( - massDP * massDP + part1.Px() * part1.Px() + part1.Py() * part1.Py() + part1.Pz() * part1.Pz()); - float EDaugN = TMath::Sqrt( - massDN * massDN + part2.Px() * part2.Px() + part2.Py() * part2.Py() + part2.Pz() * part2.Pz()); - - float energysum = EDaugP + EDaugN; - float pSum2 = (part2.Px() + part1.Px()) * (part2.Px() + part1.Px()) + - - (part2.Py() + part1.Py()) * (part2.Py() + part1.Py()) + - - (part2.Pz() + part1.Pz()) * (part2.Pz() + part1.Pz()); - invMass = TMath::Sqrt(energysum * energysum - pSum2); - return invMass; - } + float mMassPhi = o2::constants::physics::MassPhi; float getkstar(const ROOT::Math::PtEtaPhiMVector part1, const ROOT::Math::PtEtaPhiMVector part2) @@ -412,8 +395,9 @@ struct CFFillterPPPhi { } if (isSelectedTrackKaon(track)) { - ROOT::Math::PtEtaPhiMVector temp(track.pt(), track.eta(), track.phi(), mMassKaon); + 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/Kaon/fPKaon"), track.p()); registry.fill(HIST("TrackCuts/Kaon/fPTPCKaon"), track.tpcInnerParam()); @@ -436,6 +420,8 @@ struct CFFillterPPPhi { // KaonIndex.push_back(track.globalIndex()); } if (track.sign() < 0) { + temp.SetM(mMassKaonMinus); + antikaons.push_back(temp); registry.fill(HIST("TrackCuts/AntiKaon/fPAntiKaon"), track.p()); registry.fill(HIST("TrackCuts/AntiKaon/fPTPCAntiKaon"), track.tpcInnerParam()); @@ -463,29 +449,31 @@ struct CFFillterPPPhi { for (const auto& postrack : kaons) { for (const auto& negtrack : antikaons) { + ROOT::Math::PtEtaPhiMVector temp = postrack + negtrack; - temp.SetM(mMassPhi); + // temp.SetM(mMassPhi); + registry.fill(HIST("TrackCuts/Phi/fInvMassPhiBefore"), temp.M()); - registry.fill(HIST("TrackCuts/Phi/fInvMassPhiBefore"), CalculateInvMass(postrack, negtrack)); registry.fill(HIST("TrackCuts/Phi/fPtPhiBefore"), temp.pt()); registry.fill(HIST("TrackCuts/Phi/fEtaPhiBefore"), temp.eta()); registry.fill(HIST("TrackCuts/Phi/fPhiPhiBefore"), temp.phi()); - if ((CalculateInvMass(postrack, negtrack) > mMassPhi - InvMassCutWidth.value) && CalculateInvMass(postrack, negtrack) < (mMassPhi + InvMassCutWidth.value)) { + if ((temp.M() >= ConfResoInvMassLowLimit.value) && (temp.M() <= ConfResoInvMassUpLimit.value)) { // ROOT::Math::PtEtaPhiMVector temp = postrack + negtrack; phi.push_back(temp); registry.fill(HIST("TrackCuts/Phi/fPtPhi"), temp.pt()); registry.fill(HIST("TrackCuts/Phi/fEtaPhi"), temp.eta()); registry.fill(HIST("TrackCuts/Phi/fPhiPhi"), temp.phi()); - registry.fill(HIST("TrackCuts/Phi/fInvMassPhi"), CalculateInvMass(postrack, negtrack)); + registry.fill(HIST("TrackCuts/Phi/fInvMassPhi"), temp.M()); + registry.fill(HIST("TrackCuts/Phi/PosDaughter/Pt"), postrack.pt()); registry.fill(HIST("TrackCuts/Phi/PosDaughter/Eta"), postrack.eta()); - // registry.fill(HIST("TrackCuts/Phi/PosDaughter/DCAXY"), postrack.dcaXY()); - // registry.fill(HIST("TrackCuts/Phi/PosDaughter/fTPCncls"), postrack.tpcNClsFound()); + registry.fill(HIST("TrackCuts/Phi/PosDaughter/Phi"), postrack.phi()); + + registry.fill(HIST("TrackCuts/Phi/NegDaughter/Pt"), negtrack.pt()); registry.fill(HIST("TrackCuts/Phi/NegDaughter/Eta"), negtrack.eta()); - // registry.fill(HIST("TrackCuts/Phi/NegDaughter/DCAXY"), negtrack.dcaXY()); - // registry.fill(HIST("TrackCuts/Phi/NegDaughter/fTPCncls"), negtrack.tpcNClsFound()); + registry.fill(HIST("TrackCuts/Phi/NegDaughter/Phi"), negtrack.phi()); } } } diff --git a/EventFiltering/PWGHF/HFFilter.cxx b/EventFiltering/PWGHF/HFFilter.cxx index 82293e0138c..3abef8e28a9 100644 --- a/EventFiltering/PWGHF/HFFilter.cxx +++ b/EventFiltering/PWGHF/HFFilter.cxx @@ -19,6 +19,8 @@ /// \author Biao Zhang , CCNU /// \author Federica Zanone , Heidelberg University +#include "TRandom3.h" + #include "CommonConstants/PhysicsConstants.h" #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPMagField.h" @@ -126,6 +128,10 @@ struct HfFilter { // Main struct for HF triggers // parameter for Optimisation Tree Configurable applyOptimisation{"applyOptimisation", false, "Flag to enable or disable optimisation"}; + // manual downscale factors + 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)"}; + // array of BDT thresholds std::array, kNCharmParticles> thresholdBDTScores; @@ -289,8 +295,7 @@ struct HfFilter { // Main struct for HF triggers bool keepEvent[kNtriggersHF]{false}; if (applyEventSelection && (!collision.sel8() || std::fabs(collision.posZ()) > 11.f || (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && applyTimeFrameBorderCut))) { // 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]); + 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]); continue; } @@ -376,6 +381,11 @@ struct HfFilter { // Main struct for HF triggers continue; } + keepEvent[kSingleCharm2P] = true; + if (isBeautyTagged) { + keepEvent[kSingleNonPromptCharm2P] = true; + } + auto pVec2Prong = RecoDecay::pVec(pVecPos, pVecNeg); auto pt2Prong = RecoDecay::pt(pVec2Prong); @@ -418,7 +428,7 @@ struct HfFilter { // Main struct for HF triggers if (!keepEvent[kBeauty3P] && isBeautyTagged) { auto isTrackSelected = helper.isSelectedTrackForSoftPionOrBeauty(track, trackParThird, dcaThird, kBeauty3P); - if (isTrackSelected && ((TESTBIT(selD0, 0) && track.sign() > 0) || (TESTBIT(selD0, 1) && track.sign() < 0))) { + 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}); auto pVecBeauty3Prong = RecoDecay::pVec(pVec2Prong, pVecThird); auto ptCand = RecoDecay::pt(pVecBeauty3Prong); @@ -431,47 +441,50 @@ struct HfFilter { // Main struct for HF triggers if (activateQA) { hMassVsPtB[kBplus]->Fill(ptCand, massCand); } - } else if (TESTBIT(isTrackSelected, kSoftPionForBeauty)) { - std::array massDausD0{massPi, massKa}; - auto massD0dau = massD0Cand; - if (track.sign() < 0) { - massDausD0[0] = massKa; - massDausD0[1] = massPi; - massD0dau = massD0BarCand; + } + } + if (!keepEvent[kBeauty3P] && TESTBIT(isTrackSelected, kSoftPionForBeauty) && ((TESTBIT(selD0, 0) && track.sign() > 0) || (TESTBIT(selD0, 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}; + auto massD0dau = massD0Cand; + if (track.sign() < 0) { + massDausD0[0] = massKa; + massDausD0[1] = massPi; + massD0dau = massD0BarCand; + } + auto massDstarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecThird}, std::array{massDausD0[0], massDausD0[1], massPi}); + auto massDiffDstar = massDstarCand - massD0dau; + if (cutsPtDeltaMassCharmReso->get(0u, 0u) <= massDiffDstar && massDiffDstar <= cutsPtDeltaMassCharmReso->get(1u, 0u) && ptCand > cutsPtDeltaMassCharmReso->get(2u, 0u)) { // additional check for B0->D*pi polarization studies + if (activateQA) { + hMassVsPtC[kNCharmParticles]->Fill(ptCand, massDiffDstar); } - auto massDstarCand = RecoDecay::m(std::array{pVecPos, pVecNeg, pVecThird}, std::array{massDausD0[0], massDausD0[1], massPi}); - auto massDiffDstar = massDstarCand - massD0dau; - if (cutsPtDeltaMassCharmReso->get(0u, 0u) <= massDiffDstar && massDiffDstar <= cutsPtDeltaMassCharmReso->get(1u, 0u) && ptCand > cutsPtDeltaMassCharmReso->get(2u, 0u)) { // additional check for B0->D*pi polarization studies - if (activateQA) { - hMassVsPtC[kNCharmParticles]->Fill(ptCand, massDiffDstar); + for (const auto& trackIdB : trackIdsThisCollision) { // start loop over tracks + auto trackB = trackIdB.track_as(); + if (track.globalIndex() == trackB.globalIndex()) { + continue; + } + auto trackParFourth = getTrackPar(trackB); + o2::gpu::gpustd::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); } - for (const auto& trackIdB : trackIdsThisCollision) { // start loop over tracks - auto trackB = trackIdB.track_as(); - if (track.globalIndex() == trackB.globalIndex()) { - continue; - } - auto trackParFourth = getTrackPar(trackB); - o2::gpu::gpustd::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); - if (track.sign() * trackB.sign() < 0 && TESTBIT(isTrackFourthSelected, kForBeauty)) { - auto massCandB0 = RecoDecay::m(std::array{pVecBeauty3Prong, pVecFourth}, std::array{massDStar, massPi}); - if (std::fabs(massCandB0 - massB0) <= deltaMassBeauty->get(0u, 2u)) { - keepEvent[kBeauty3P] = true; - // fill optimisation tree for D0 - if (applyOptimisation) { - optimisationTreeBeauty(thisCollId, 413, pt2Prong, scores[0], scores[1], scores[2], dcaFourth[0]); // pdgCode of D*(2010)+: 413 - } - if (activateQA) { - auto pVecBeauty4Prong = RecoDecay::pVec(pVec2Prong, pVecThird, pVecFourth); - auto ptCandBeauty4Prong = RecoDecay::pt(pVecBeauty4Prong); - hMassVsPtB[kB0toDStar]->Fill(ptCandBeauty4Prong, massCandB0); - } + auto isTrackFourthSelected = helper.isSelectedTrackForSoftPionOrBeauty(trackB, trackParFourth, dcaFourth, kBeauty3P); + if (track.sign() * trackB.sign() < 0 && TESTBIT(isTrackFourthSelected, kForBeauty)) { + auto massCandB0 = RecoDecay::m(std::array{pVecBeauty3Prong, pVecFourth}, std::array{massDStar, massPi}); + if (std::fabs(massCandB0 - massB0) <= deltaMassBeauty->get(0u, 2u)) { + keepEvent[kBeauty3P] = true; + // fill optimisation tree for D0 + if (applyOptimisation) { + optimisationTreeBeauty(thisCollId, 413, pt2Prong, scores[0], scores[1], scores[2], dcaFourth[0]); // pdgCode of D*(2010)+: 413 + } + if (activateQA) { + auto pVecBeauty4Prong = RecoDecay::pVec(pVec2Prong, pVecThird, pVecFourth); + auto ptCandBeauty4Prong = RecoDecay::pt(pVecBeauty4Prong); + hMassVsPtB[kB0toDStar]->Fill(ptCandBeauty4Prong, massCandB0); } } } @@ -768,6 +781,11 @@ struct HfFilter { // Main struct for HF triggers continue; } + keepEvent[kSingleCharm3P] = true; + if (std::accumulate(isBeautyTagged.begin(), isBeautyTagged.end(), 0)) { + keepEvent[kSingleNonPromptCharm3P] = true; + } + if ((!keepOnlyDplusForDouble3Prongs && std::accumulate(isCharmTagged.begin(), isCharmTagged.end(), 0)) || (keepOnlyDplusForDouble3Prongs && isCharmTagged[kDplus - 1])) { indicesDau3Prong.push_back(std::vector{trackFirst.globalIndex(), trackSecond.globalIndex(), trackThird.globalIndex()}); } // end multiple 3-prong selection @@ -1282,7 +1300,17 @@ struct HfFilter { // Main struct for HF triggers keepEvent[kDoubleCharmMix] = true; } - 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]); + // apply downscale factors, if required + if (applyDownscale) { + auto rndValue = gRandom->Rndm(); + for (int iTrigger{0}; iTrigger < kNtriggersHF; ++iTrigger) { + if (rndValue > downscaleFactors->get(iTrigger, 0u)) { + keepEvent[iTrigger] = false; + } + } + } + + 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 (!std::accumulate(keepEvent, keepEvent + kNtriggersHF, 0)) { hProcessedEvents->Fill(1); diff --git a/EventFiltering/PWGHF/HFFilterHelpers.h b/EventFiltering/PWGHF/HFFilterHelpers.h index e0dd03f3b75..921bb98103e 100644 --- a/EventFiltering/PWGHF/HFFilterHelpers.h +++ b/EventFiltering/PWGHF/HFFilterHelpers.h @@ -75,6 +75,10 @@ enum HfTriggers { kSigmaC0K0, kPhotonCharm2P, kPhotonCharm3P, + kSingleCharm2P, + kSingleCharm3P, + kSingleNonPromptCharm2P, + kSingleNonPromptCharm3P, kNtriggersHF }; @@ -129,7 +133,7 @@ static const std::array charmParticleNames{"D0", static const std::array beautyParticleNames{"Bplus", "B0toDStar", "B0", "Bs", "Lb", "Xib"}; static const std::array pdgCodesCharm{421, 411, 431, 4122, 4232}; static const std::array eventTitles = {"all", "rejected"}; -static const std::array 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()}; +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::array v0Labels{"#gamma", "K_{S}^{0}", "#Lambda", "#bar{#Lambda}"}; static const std::array v0Names{"Photon", "K0S", "Lambda", "AntiLambda"}; @@ -226,6 +230,10 @@ 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}; +// 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 +static const std::vector labelsDownscaleFactor = {"Downscale factor"}; + // Main helper class class HfFilterHelper @@ -402,6 +410,8 @@ class HfFilterHelper int8_t isBDTSelected(const T& scores, const U& thresholdBDTScores); template bool isSelectedKaonFromXicResoToSigmaC(const T& track); + template + inline bool isCharmHadronMassInSbRegions(T1 const& massHypo1, T1 const& massHypo2, const float& lowLimitSB, const float& upLimitSB); // helpers template @@ -1607,6 +1617,23 @@ inline bool HfFilterHelper::isSelectedKaon4Charm3Prong(const T& track) return true; } +/// 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 +/// \param lowLimitSB is the dca of the D daughter track +/// \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) +{ + + if ((massHypo1 < lowLimitSB || massHypo1 > upLimitSB) && (massHypo2 < lowLimitSB || massHypo2 > upLimitSB)) { + return false; + } + + return true; +} + /// Update the TPC PID baesd on the spline of particles /// \param track is a track parameter /// \param pidSpecies is the particle species to be considered diff --git a/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx b/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx index 1441782031e..5e62416a75d 100644 --- a/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx +++ b/EventFiltering/PWGHF/HFFilterPrepareMLSamples.cxx @@ -17,7 +17,9 @@ /// \author Marcel Lesch , TUM /// \author Alexandre Bigot , Strasbourg University /// \author Biao Zhang , CCNU +/// \author Antonio Palasciano , INFN Bari +#include #if __has_include() #include // needed for HFFilterHelpers, to be fixed #else @@ -54,8 +56,12 @@ struct HfFilterPrepareMlSamples { // Main struct // parameters for production of training samples Configurable fillSignal{"fillSignal", true, "Flag to fill derived tables with signal for ML trainings"}; - Configurable fillBackground{"fillBackground", true, "Flag to fill derived tables with background 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"}; + Configurable massSbLeftMax{"massSbLeftMax", 1.78, "Left Sideband Upper Minv limit 2 Prong"}; + Configurable massSbRightMin{"massSbRightMin", 1.94, "Right Sideband Lower Minv limit 2 Prong"}; + Configurable massSbRightMax{"massSbRightMax", 1.98, "Right Sideband Upper Minv limit 2 Prong"}; // CCDB configuration o2::ccdb::CcdbApi ccdbApi; @@ -67,6 +73,9 @@ struct HfFilterPrepareMlSamples { // Main struct o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; int currentRun = 0; // needed to detect if the run changed and trigger update of calibrations etc. + // helper object + HfFilterHelper helper; + void init(InitContext&) { ccdb->setURL(url.value); @@ -76,14 +85,147 @@ struct HfFilterPrepareMlSamples { // Main struct ccdbApi.init(url); } + using BigTracksPID = soa::Join; using BigTracksMCPID = soa::Join; - void process(aod::Hf2Prongs const& cand2Prongs, - aod::Hf3Prongs const& cand3Prongs, - aod::McParticles const& mcParticles, - soa::Join const& collisions, - BigTracksMCPID const&, - aod::BCsWithTimestamps const&) + void processData2Prong(aod::Hf2Prongs const& cand2Prongs, + aod::Collisions const& collisions, + BigTracksPID const&, + aod::BCsWithTimestamps const&) + { + for (const auto& cand2Prong : cand2Prongs) { // start loop over 2 prongs + + auto thisCollId = cand2Prong.collisionId(); + auto collision = collisions.rawIteratorAt(thisCollId); + auto bc = collision.bc_as(); + + if (currentRun != bc.runNumber()) { + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, bc.timestamp()); + o2::base::Propagator::initFieldFromGRP(grpo); + currentRun = bc.runNumber(); + } + + auto trackPos = cand2Prong.prong0_as(); // positive daughter + auto trackNeg = cand2Prong.prong1_as(); // negative daughter + + 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 pVecPos{trackPos.pVector()}; + std::array pVecNeg{trackNeg.pVector()}; + if (trackPos.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParPos, 2.f, noMatCorr, &dcaPos); + getPxPyPz(trackParPos, pVecPos); + } + if (trackNeg.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParNeg, 2.f, noMatCorr, &dcaNeg); + getPxPyPz(trackParNeg, pVecNeg); + } + + auto pVec2Prong = RecoDecay::pVec(pVecPos, pVecNeg); + auto pt2Prong = RecoDecay::pt(pVec2Prong); + + auto invMassD0 = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massPi, massKa}); + auto invMassD0bar = RecoDecay::m(std::array{pVecPos, pVecNeg}, std::array{massKa, massPi}); + + auto flag = RecoDecay::OriginType::None; + + if (fillOnlyBackground && !(isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbLeftMin, massSbLeftMax) || (isCharmHadronMassInSbRegions(invMassD0, invMassD0bar, massSbRightMin, massSbRightMax)))) + continue; + float pseudoRndm = trackPos.pt() * 1000. - static_cast(trackPos.pt() * 1000); + if (pseudoRndm < downSampleBkgFactor) { + train2P(invMassD0, invMassD0bar, pt2Prong, trackParPos.getPt(), dcaPos[0], dcaPos[1], trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), trackPos.tofNSigmaPi(), trackPos.tofNSigmaKa(), + trackParNeg.getPt(), dcaNeg[0], dcaNeg[1], trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaPi(), trackNeg.tofNSigmaKa(), flag, true); + } + } // end loop over 2-prong candidates + } + PROCESS_SWITCH(HfFilterPrepareMlSamples, processData2Prong, "Store 2prong(D0) data tables", true); + + void processData3Prong(aod::Hf3Prongs const& cand3Prongs, + aod::Collisions const& collisions, + BigTracksPID const&, + aod::BCsWithTimestamps const&) + { + for (const auto& cand3Prong : cand3Prongs) { // start loop over 2 prongs + + auto thisCollId = cand3Prong.collisionId(); + auto collision = collisions.rawIteratorAt(thisCollId); + auto bc = collision.bc_as(); + + if (currentRun != bc.runNumber()) { + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp(ccdbPathGrpMag, bc.timestamp()); + o2::base::Propagator::initFieldFromGRP(grpo); + currentRun = bc.runNumber(); + } + + auto trackFirst = cand3Prong.prong0_as(); // first daughter + auto trackSecond = cand3Prong.prong1_as(); // second daughter + auto trackThird = cand3Prong.prong2_as(); // third daughter + // auto arrayDaughters = std::array{trackFirst, trackSecond, trackThird}; + + 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 pVecFirst{trackFirst.pVector()}; + std::array pVecSecond{trackSecond.pVector()}; + std::array pVecThird{trackThird.pVector()}; + if (trackFirst.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParFirst, 2.f, noMatCorr, &dcaFirst); + getPxPyPz(trackParFirst, pVecFirst); + } + if (trackSecond.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParSecond, 2.f, noMatCorr, &dcaSecond); + getPxPyPz(trackParSecond, pVecSecond); + } + if (trackThird.collisionId() != thisCollId) { + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParThird, 2.f, noMatCorr, &dcaThird); + getPxPyPz(trackParThird, pVecThird); + } + + auto pVec3Prong = RecoDecay::pVec(pVecFirst, pVecSecond, pVecThird); + auto pt3Prong = RecoDecay::pt(pVec3Prong); + + auto invMassDplus = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massPi, massKa, massPi}); + + auto invMassDsToKKPi = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massKa, massKa, massPi}); + auto invMassDsToPiKK = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massPi, massKa, massKa}); + + auto invMassLcToPKPi = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massProton, massKa, massPi}); + auto invMassLcToPiKP = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massPi, massKa, massProton}); + + auto invMassXicToPKPi = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massProton, massKa, massPi}); + auto invMassXicToPiKP = RecoDecay::m(std::array{pVecFirst, pVecSecond, pVecThird}, std::array{massPi, massKa, massProton}); + + float deltaMassKKFirst = -1.f; + float deltaMassKKSecond = -1.f; + if (TESTBIT(cand3Prong.hfflag(), o2::aod::hf_cand_3prong::DecayType::DsToKKPi)) { + deltaMassKKFirst = std::abs(RecoDecay::m(std::array{pVecFirst, pVecSecond}, std::array{massKa, massKa}) - massPhi); + deltaMassKKSecond = std::abs(RecoDecay::m(std::array{pVecThird, pVecSecond}, std::array{massKa, massKa}) - massPhi); + } + // int8_t sign = 0; + auto flag = RecoDecay::OriginType::None; + + float pseudoRndm = trackFirst.pt() * 1000. - static_cast(trackFirst.pt() * 1000); + if (pseudoRndm < downSampleBkgFactor) { + train3P(invMassDplus, invMassDsToKKPi, invMassDsToPiKK, invMassLcToPKPi, invMassLcToPiKP, invMassXicToPKPi, invMassXicToPiKP, pt3Prong, deltaMassKKFirst, deltaMassKKSecond, + trackParFirst.getPt(), dcaFirst[0], dcaFirst[1], trackFirst.tpcNSigmaPi(), trackFirst.tpcNSigmaKa(), trackFirst.tpcNSigmaPr(), trackFirst.tofNSigmaPi(), trackFirst.tofNSigmaKa(), trackFirst.tofNSigmaPr(), + trackParSecond.getPt(), dcaSecond[0], dcaSecond[1], trackSecond.tpcNSigmaPi(), trackSecond.tpcNSigmaKa(), trackSecond.tpcNSigmaPr(), trackSecond.tofNSigmaPi(), trackSecond.tofNSigmaKa(), trackSecond.tofNSigmaPr(), + trackParThird.getPt(), dcaThird[0], dcaThird[1], trackThird.tpcNSigmaPi(), trackThird.tpcNSigmaKa(), trackThird.tpcNSigmaPr(), trackThird.tofNSigmaPi(), trackThird.tofNSigmaKa(), trackThird.tofNSigmaPr(), + flag, 0, cand3Prong.hfflag(), 0); + } + } // end loop over 3-prong candidates + } + PROCESS_SWITCH(HfFilterPrepareMlSamples, processData3Prong, "Store 3prong(D0)-data tables", true); + + void processMC2Prong(aod::Hf2Prongs const& cand2Prongs, + aod::McParticles const& mcParticles, + soa::Join const& collisions, + BigTracksMCPID const&, + aod::BCsWithTimestamps const&) { for (const auto& cand2Prong : cand2Prongs) { // start loop over 2 prongs @@ -136,13 +278,19 @@ struct HfFilterPrepareMlSamples { // Main struct } } - float pseudoRndm = trackPos.pt() * 1000. - (int64_t)(trackPos.pt() * 1000); - if ((fillSignal && indexRec > -1) || (fillBackground && indexRec < 0 && pseudoRndm < downSampleBkgFactor)) { - train2P(invMassD0, invMassD0bar, pt2Prong, trackParPos.getPt(), dcaPos[0], dcaPos[1], trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), trackPos.tofNSigmaPi(), trackPos.tofNSigmaKa(), - trackParNeg.getPt(), dcaNeg[0], dcaNeg[1], trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaPi(), trackNeg.tofNSigmaKa(), flag, isInCorrectColl); - } + train2P(invMassD0, invMassD0bar, pt2Prong, trackParPos.getPt(), dcaPos[0], dcaPos[1], trackPos.tpcNSigmaPi(), trackPos.tpcNSigmaKa(), trackPos.tofNSigmaPi(), trackPos.tofNSigmaKa(), + trackParNeg.getPt(), dcaNeg[0], dcaNeg[1], trackNeg.tpcNSigmaPi(), trackNeg.tpcNSigmaKa(), trackNeg.tofNSigmaPi(), trackNeg.tofNSigmaKa(), flag, isInCorrectColl); + } // end loop over 2-prong candidates + } + PROCESS_SWITCH(HfFilterPrepareMlSamples, processMC2Prong, "Store 2 prong(D0) MC tables", false); + void processMC3Prong(aod::Hf3Prongs const& cand3Prongs, + aod::McParticles const& mcParticles, + soa::Join const& collisions, + BigTracksMCPID const&, + aod::BCsWithTimestamps const&) + { for (const auto& cand3Prong : cand3Prongs) { // start loop over 3 prongs auto thisCollId = cand3Prong.collisionId(); @@ -243,16 +391,15 @@ struct HfFilterPrepareMlSamples { // Main struct } } - float pseudoRndm = trackFirst.pt() * 1000. - (int64_t)(trackFirst.pt() * 1000); - if ((fillSignal && indexRec > -1) || (fillBackground && indexRec < 0 && pseudoRndm < downSampleBkgFactor)) { - train3P(invMassDplus, invMassDsToKKPi, invMassDsToPiKK, invMassLcToPKPi, invMassLcToPiKP, invMassXicToPKPi, invMassXicToPiKP, pt3Prong, deltaMassKKFirst, deltaMassKKSecond, - trackParFirst.getPt(), dcaFirst[0], dcaFirst[1], trackFirst.tpcNSigmaPi(), trackFirst.tpcNSigmaKa(), trackFirst.tpcNSigmaPr(), trackFirst.tofNSigmaPi(), trackFirst.tofNSigmaKa(), trackFirst.tofNSigmaPr(), - trackParSecond.getPt(), dcaSecond[0], dcaSecond[1], trackSecond.tpcNSigmaPi(), trackSecond.tpcNSigmaKa(), trackSecond.tpcNSigmaPr(), trackSecond.tofNSigmaPi(), trackSecond.tofNSigmaKa(), trackSecond.tofNSigmaPr(), - trackParThird.getPt(), dcaThird[0], dcaThird[1], trackThird.tpcNSigmaPi(), trackThird.tpcNSigmaKa(), trackThird.tpcNSigmaPr(), trackThird.tofNSigmaPi(), trackThird.tofNSigmaKa(), trackThird.tofNSigmaPr(), - flag, channel, cand3Prong.hfflag(), isInCorrectColl); - } + train3P(invMassDplus, invMassDsToKKPi, invMassDsToPiKK, invMassLcToPKPi, invMassLcToPiKP, invMassXicToPKPi, invMassXicToPiKP, pt3Prong, deltaMassKKFirst, deltaMassKKSecond, + trackParFirst.getPt(), dcaFirst[0], dcaFirst[1], trackFirst.tpcNSigmaPi(), trackFirst.tpcNSigmaKa(), trackFirst.tpcNSigmaPr(), trackFirst.tofNSigmaPi(), trackFirst.tofNSigmaKa(), trackFirst.tofNSigmaPr(), + trackParSecond.getPt(), dcaSecond[0], dcaSecond[1], trackSecond.tpcNSigmaPi(), trackSecond.tpcNSigmaKa(), trackSecond.tpcNSigmaPr(), trackSecond.tofNSigmaPi(), trackSecond.tofNSigmaKa(), trackSecond.tofNSigmaPr(), + trackParThird.getPt(), dcaThird[0], dcaThird[1], trackThird.tpcNSigmaPi(), trackThird.tpcNSigmaKa(), trackThird.tpcNSigmaPr(), trackThird.tofNSigmaPi(), trackThird.tofNSigmaKa(), trackThird.tofNSigmaPr(), + flag, channel, cand3Prong.hfflag(), isInCorrectColl); + } // end loop over 3-prong candidates } + PROCESS_SWITCH(HfFilterPrepareMlSamples, processMC3Prong, "Store 3 prong MC tables", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfg) diff --git a/EventFiltering/PWGJE/jetFilter.cxx b/EventFiltering/PWGJE/jetFilter.cxx index 60e67d39073..54c24ee627d 100644 --- a/EventFiltering/PWGJE/jetFilter.cxx +++ b/EventFiltering/PWGJE/jetFilter.cxx @@ -286,13 +286,13 @@ struct jetFilter { tags(keepEvent[kJetChLowPt], keepEvent[kJetChHighPt], keepEvent[kTrackLowPt], keepEvent[kTrackHighPt]); } - void processWithoutRho(soa::Join::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered const& tracks) + void processWithoutRho(soa::Join::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered const& tracks) { doTriggering(collision, jets, tracks); } PROCESS_SWITCH(jetFilter, processWithoutRho, "Do charged jet triggering without background estimation for filling histograms", true); - void processWithRho(soa::Join::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered const& tracks) + void processWithRho(soa::Join::iterator const& collision, o2::aod::ChargedJets const& jets, soa::Filtered const& tracks) { doTriggering(collision, jets, tracks); } diff --git a/EventFiltering/PWGJE/jetHFFilter.cxx b/EventFiltering/PWGJE/jetHFFilter.cxx index ab6539372b8..6657e785751 100644 --- a/EventFiltering/PWGJE/jetHFFilter.cxx +++ b/EventFiltering/PWGJE/jetHFFilter.cxx @@ -75,7 +75,7 @@ struct JetHFFilterTask { registry.add("h_collisions", "Collision ;entries", {HistType::kTH1F, {{5, 0.0, 5.0}}}); } - void processJets(soa::Join::iterator const& /*collision*/, soa::Join const& d0Jets, CandidatesD0Data const& /*d0Candidates*/, soa::Join const& lcJets, CandidatesLcData const& /*lcCandidates*/, JetTracks const& /*tracks*/) + void processJets(soa::Join::iterator const& /*collision*/, soa::Join const& d0Jets, aod::CandidatesD0Data const& /*d0Candidates*/, soa::Join const& lcJets, aod::CandidatesLcData const& /*lcCandidates*/, aod::JetTracks const& /*tracks*/) { registry.fill(HIST("h_collisions"), 0.5); bool keepEvent[kAllObjects]{false}; diff --git a/EventFiltering/PWGLF/nucleiFilter.cxx b/EventFiltering/PWGLF/nucleiFilter.cxx index ee3ec9a1683..914f5d9ca9c 100644 --- a/EventFiltering/PWGLF/nucleiFilter.cxx +++ b/EventFiltering/PWGLF/nucleiFilter.cxx @@ -36,6 +36,7 @@ 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, @@ -44,7 +45,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{"fH2", "fH3", o2::aod::filtering::He::columnLabel(), o2::aod::filtering::H3L3Body::columnLabel()}; +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 cutsNames{ "TPCnSigmaMin", "TPCnSigmaMax", "TOFnSigmaMin", "TOFnSigmaMax", "TOFpidStartPt"}; constexpr double betheBlochDefault[nNuclei][6]{ @@ -52,16 +53,16 @@ constexpr double betheBlochDefault[nNuclei][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}}; static constexpr float cutsPID[nNuclei][nCutsPID]{ - {-3.f, +3.f, -4.f, +4.f, 1.0f}, /*H2*/ - {-3.f, +3.f, -4.f, +4.f, 1.6f}, /*H3*/ - {-5.f, +5.f, -4.f, +4.f, 14000.f}, /*He3*/ + {-3.f, +400.f, -4.f, +400.f, 1.0f}, /*H2*/ + {-3.f, +3.f, -4.f, +4.f, 1.6f}, /*H3*/ + {-5.f, +400.f, -4.f, +4.f, 14000.f}, /*He3*/ }; constexpr double bbMomScalingDefault[nNuclei][2]{ {1., 1.}, {1., 1.}, {1., 1.}}; constexpr double minTPCmom[nNuclei][2]{ - {0., 0.}, + {0.8, 0.}, {0., 0.}, {0.8, 0.}}; static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; @@ -80,6 +81,10 @@ struct nucleiFilter { Configurable cfgCutEta{"cfgCutEta", 1.f, "Eta range for tracks"}; Configurable cfgCutNclusITS{"cfgCutNclusITS", 2, "Minimum number of ITS clusters"}; + Configurable cfgCutNclusExtremeIonisationITS{"cfgCutNclusExtremeIonisationITS", 5, "Minimum number of ITS clusters for the extreme ionisation trigger"}; + Configurable cfgMomentumCutExtremeIonisation{"cfgMomentumCutExtremeIonisation", 1.2, "Minimum momentum for the extreme ionisation trigger"}; + Configurable cfgCutClsSizeExtremeIonisation{"cfgCutClsSizeExtremeIonisation", 8, "Minimum average size of ITS clusters for the extreme ionisation trigger"}; + Configurable cfgCutClsSizeMildIonisation{"cfgCutClsSizeMildIonisation", 5, "Minimum average size of ITS clusters for the mild ionisation trigger"}; Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 80, "Minimum number of TPC clusters"}; Configurable cfgCutDCAxy{"cfgCutDCAxy", 3, "Max DCAxy"}; Configurable cfgCutDCAz{"cfgCutDCAz", 10, "Max DCAz"}; @@ -113,7 +118,7 @@ struct nucleiFilter { Configurable fixTPCinnerParam{"fixTPCinnerParam", false, "Fix TPC inner param"}; HistogramRegistry qaHists{"qaHists", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";;Number of filtered events", nNuclei + nHyperNuclei + 1, -0.5, nNuclei + nHyperNuclei + 0.5)}; + OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";;Number of filtered events", nNuclei + nHyperNuclei + nITStriggers + 1, -0.5, nNuclei + nHyperNuclei + nITStriggers + 0.5)}; void init(o2::framework::InitContext&) { @@ -125,7 +130,9 @@ struct nucleiFilter { qaHists.add("fTPCsignalAll", "Specific energy loss (before filter)", HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); qaHists.add("fTPCsignal", "Specific energy loss", HistType::kTH2F, {{1200, -6, 6, "#it{p} (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); 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("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) { h2TPCsignal[iN] = qaHists.add(Form("fTPCsignal_%s", nucleiNames[iN].data()), "Specific energy loss", HistType::kTH2F, {{1200, -6, 6., "#it{p}/Z (GeV/#it{c})"}, {1400, 0, 1400, "d#it{E} / d#it{X} (a. u.)"}}); @@ -138,19 +145,17 @@ struct nucleiFilter { } } - // Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta); - // using TrackCandidates = soa::Filtered>; using TrackCandidates = soa::Join; void process(soa::Join::iterator const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, TrackCandidates const& tracks) { // collision process loop - bool keepEvent[nNuclei + nHyperNuclei]{false}; + bool keepEvent[nNuclei + nHyperNuclei + nITStriggers]{false}; // qaHists.fill(HIST("fCollZpos"), collision.posZ()); hProcessedEvents->Fill(0); // if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - tags(keepEvent[2], keepEvent[3]); + tags(keepEvent[0], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5]); return; } // @@ -160,6 +165,17 @@ struct nucleiFilter { {charges[2] * cfgMomentumScalingBetheBloch->get(2u, 0u) / masses[2], charges[2] * cfgMomentumScalingBetheBloch->get(2u, 1u) / masses[2]}}; for (auto& track : tracks) { // start loop over tracks + if (track.itsNCls() >= cfgCutNclusExtremeIonisationITS) { + double avgClsSize{0.}; + double cosL{std::sqrt(1. / (1. + track.tgl() * track.tgl()))}; + for (int iC{0}; iC < 7; ++iC) { + avgClsSize += track.itsClsSizeInLayer(iC); + } + 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; + } if (track.itsNCls() < cfgCutNclusITS || track.tpcNClsFound() < cfgCutNclusTPC) { continue; @@ -223,6 +239,8 @@ struct nucleiFilter { auto track1 = vtx.track1_as(); auto track2 = vtx.track2_as(); + qaHists.fill(HIST("fBachDeuTOFNsigma"), track2.p() * track2.sign(), vtx.tofNSigmaBachDe()); + if (vtx.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()) < minCosPA3body) { continue; } @@ -233,7 +251,7 @@ struct nucleiFilter { if (vtx.dcaVtxdaughters() > dcavtxdau) { continue; } - if ((track2.tofNSigmaDe() < TofPidNsigmaMin || track2.tofNSigmaDe() > TofPidNsigmaMax) && track2.p() > minDeuteronPUseTOF) { + if ((vtx.tofNSigmaBachDe() < TofPidNsigmaMin || vtx.tofNSigmaBachDe() > TofPidNsigmaMax) && track2.p() > minDeuteronPUseTOF) { continue; } if (std::abs(track0.tpcNSigmaPr()) < TpcPidNsigmaCut && std::abs(track1.tpcNSigmaPi()) < TpcPidNsigmaCut && std::abs(track2.tpcNSigmaDe()) < TpcPidNsigmaCut && vtx.mHypertriton() > h3LMassLowerlimit && vtx.mHypertriton() < h3LMassUpperlimit) { @@ -254,12 +272,12 @@ struct nucleiFilter { } } // end loop over hypertriton 3body decay candidates - for (int iDecision{0}; iDecision < nNuclei + nHyperNuclei; ++iDecision) { + for (int iDecision{0}; iDecision < nNuclei + nHyperNuclei + nITStriggers; ++iDecision) { if (keepEvent[iDecision]) { hProcessedEvents->Fill(iDecision + 1); } } - tags(keepEvent[2], keepEvent[3]); + tags(keepEvent[0], keepEvent[2], keepEvent[3], keepEvent[4], keepEvent[5]); } }; diff --git a/EventFiltering/PWGLF/strangenessFilter.cxx b/EventFiltering/PWGLF/strangenessFilter.cxx index 106e0f90bb7..1f615a54706 100644 --- a/EventFiltering/PWGLF/strangenessFilter.cxx +++ b/EventFiltering/PWGLF/strangenessFilter.cxx @@ -68,7 +68,7 @@ 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", 14, -1., 13.)}; + OutputObj hProcessedEvents{TH1D("hProcessedEvents", "Strangeness - event filtered;; Number of events", 16, -1., 15.)}; 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.)}; @@ -195,6 +195,8 @@ struct strangenessFilter { hProcessedEvents->GetXaxis()->SetBinLabel(12, aod::filtering::TrackedXi::columnLabel()); hProcessedEvents->GetXaxis()->SetBinLabel(13, aod::filtering::TrackedOmega::columnLabel()); hProcessedEvents->GetXaxis()->SetBinLabel(14, aod::filtering::OmegaHighMult::columnLabel()); + hProcessedEvents->GetXaxis()->SetBinLabel(15, aod::filtering::DoubleOmega::columnLabel()); + hProcessedEvents->GetXaxis()->SetBinLabel(16, aod::filtering::OmegaXi::columnLabel()); hCandidate->GetXaxis()->SetBinLabel(1, "All"); hCandidate->GetXaxis()->SetBinLabel(2, "Has_V0"); @@ -403,270 +405,17 @@ struct strangenessFilter { 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]); + 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]); } - void processRun2(CollisionCandidates const& collision, TrackCandidates const& tracks, Cascades const& fullCasc, DaughterTracks& /*dtracks*/) - { - // Is event good? [0] = Omega, [1] = high-pT hadron + Xi, [2] = 2Xi, [3] = 3Xi, [4] = 4Xi, [5] single-Xi, [6] Omega with high radius - // [7] tracked Xi, [8] tracked Omega, [9] tracked V0, [10] tracked 3Body - bool keepEvent[9]{}; // explicitly zero-initialised - - if (kint7 && !collision.alias_bit(kINT7)) { - fillTriggerTable(keepEvent); - return; - } - if (sel7 && !collision.sel7()) { - fillTriggerTable(keepEvent); - return; - } - if (sel8 && !collision.sel8()) { - fillTriggerTable(keepEvent); - return; - } - if (TMath::Abs(collision.posZ()) > cutzvertex) { - fillTriggerTable(keepEvent); - return; - } - - if (doextraQA) { - EventsvsMultiplicity.fill(HIST("AllEventsvsMultiplicity"), collision.centRun2V0M()); - QAHistos.fill(HIST("hCentrality"), collision.centRun2V0M()); - } - hProcessedEvents->Fill(0.5); - - // constants - const float ctauxi = 4.91; // from PDG - const float ctauomega = 2.461; // from PDG - - // variables - float xipos = -1.; - float xiproperlifetime = -1.; - float omegaproperlifetime = -1.; - float xiptotmom = -1.; - int xicounter = 0; - int xicounterYN = 0; - int omegacounter = 0; - int omegalargeRcounter = 0; - int triggcounterForEstimates = 0; - // int triggcounter = 0; - - for (auto& casc : fullCasc) { // loop over cascades - triggcounterForEstimates = 0; - auto bachelor = casc.bachelor_as(); - auto posdau = casc.posTrack_as(); - auto negdau = casc.negTrack_as(); - - bool isXi = false; - bool isXiYN = false; - bool isOmega = false; - bool isOmegalargeR = false; - - // Position - xipos = std::hypot(casc.x() - collision.posX(), casc.y() - collision.posY(), casc.z() - collision.posZ()); - // Total momentum - xiptotmom = std::hypot(casc.px(), casc.py(), casc.pz()); - // Proper lifetime - xiproperlifetime = o2::constants::physics::MassXiMinus * xipos / (xiptotmom + 1e-13); - omegaproperlifetime = o2::constants::physics::MassOmegaMinus * xipos / (xiptotmom + 1e-13); - - if (casc.sign() == 1) { - if (TMath::Abs(casc.dcapostopv()) < dcamesontopv) { - continue; - } - if (TMath::Abs(casc.dcanegtopv()) < dcabaryontopv) { - continue; - } - if (TMath::Abs(posdau.tpcNSigmaPi()) > nsigmatpcpi) { - continue; - } - if (TMath::Abs(negdau.tpcNSigmaPr()) > nsigmatpcpr) { - continue; - } - } else { - if (TMath::Abs(casc.dcanegtopv()) < dcamesontopv) { - continue; - } - if (TMath::Abs(casc.dcapostopv()) < dcabaryontopv) { - continue; - } - if (TMath::Abs(posdau.tpcNSigmaPr()) > nsigmatpcpr) { - continue; - } - if (TMath::Abs(negdau.tpcNSigmaPi()) > nsigmatpcpi) { - continue; - } - } - // these selection differ for Xi and Omegas: - if (TMath::Abs(posdau.eta()) > etadau) { - continue; - } - if (TMath::Abs(negdau.eta()) > etadau) { - continue; - } - if (TMath::Abs(bachelor.eta()) > etadau) { - continue; - } - if (TMath::Abs(casc.dcabachtopv()) < dcabachtopv) { - continue; - } - if (casc.v0radius() < v0radius) { - continue; - } - if (casc.cascradius() < cascradius) { - continue; - } - if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < v0cospa) { - continue; - } - if (casc.dcaV0daughters() > dcav0dau) { - continue; - } - if (casc.dcacascdaughters() > dcacascdau) { - continue; - } - if (TMath::Abs(casc.mLambda() - constants::physics::MassLambda) > masslambdalimit) { - continue; - } - if (TMath::Abs(casc.eta()) > eta) { - continue; - } - - 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) < ximasswindow) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > omegarej) && - (xiproperlifetime < properlifetimefactor * ctauxi) && - (TMath::Abs(casc.yXi()) < rapidity); // add PID on bachelor - isXiYN = (TMath::Abs(bachelor.tpcNSigmaPi()) < nsigmatpcpi) && - (casc.cascradius() > lowerradiusXiYN) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) < ximasswindow) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) > omegarej) && - (xiproperlifetime < properlifetimefactor * ctauxi) && - (TMath::Abs(casc.yXi()) < rapidity); // add PID on bachelor - isOmega = (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() < upperradiusOmega) && - (TMath::Abs(casc.mOmega() - o2::constants::physics::MassOmegaMinus) < omegamasswindow) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) > xirej) && - (omegaproperlifetime < properlifetimefactor * ctauomega) && - (TMath::Abs(casc.yOmega()) < rapidity); // add PID on bachelor - 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) < omegamasswindow) && - (TMath::Abs(casc.mXi() - o2::constants::physics::MassXiMinus) > xirej) && - (omegaproperlifetime < properlifetimefactor * ctauomega) && - (TMath::Abs(casc.yOmega()) < rapidity); // add PID on bachelor - - if (isXi) { - // Count number of Xi candidates - xicounter++; - - // Plot for estimates - if (tracks.size() > 0) - triggcounterForEstimates = 1; - 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 - } - if (isXiYN) { - // Xis for YN interactions - xicounterYN++; - } - if (isOmega) { - // Count number of Omega candidates - omegacounter++; - } - if (isOmegalargeR) { - // Count number of Omega candidates with high radius - omegalargeRcounter++; - } - } // end loop over cascades - - // Omega trigger definition - if (omegacounter > 0) { - keepEvent[0] = true; - } - - // High-pT hadron + Xi trigger definition - if (xicounter > 0) { - for (auto track : tracks) { // start loop over tracks - if (isTrackFilter && !mTrackSelector.IsSelected(track)) { - continue; - } - // triggcounter++; - keepEvent[1] = true; - } // end loop over tracks - } - - // 2Xi trigger definition - if (xicounter > 1) { - keepEvent[2] = true; - } - - // 3Xi trigger definition - if (xicounter > 2) { - keepEvent[3] = true; - } - - // 4Xi trigger definition - if (xicounter > 3) { - keepEvent[4] = true; - } - - // Single-Xi (YN) trigger definition - if (xicounterYN > 0) { - keepEvent[5] = true; - } - - // Omega with high radius trigger definition - if (omegalargeRcounter > 0) { - keepEvent[6] = true; - } - - // Fill centrality dependent histos - if (keepEvent[0]) { - hProcessedEvents->Fill(2.5); - } - if (keepEvent[1]) { - hProcessedEvents->Fill(3.5); - } - if (keepEvent[2]) { - hProcessedEvents->Fill(4.5); - } - if (keepEvent[3]) { - hProcessedEvents->Fill(5.5); - } - if (keepEvent[4]) { - hProcessedEvents->Fill(6.5); - } - if (keepEvent[5]) { - hProcessedEvents->Fill(7.5); - } - if (keepEvent[6]) { - hProcessedEvents->Fill(8.5); - } - - // Filling the table - fillTriggerTable(keepEvent); - } - // - PROCESS_SWITCH(strangenessFilter, processRun2, "Process data Run2", true); - - ////////////////////////////////////////////////////// - ////////// Strangeness Filter - Run 3 MC ///////////// - ////////////////////////////////////////////////////// - - void processRun3(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(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&) { // 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[10]{}; // explicitly zero-initialised + bool keepEvent[12]{}; // explicitly zero-initialised + std::vector> v0sFromOmegaID; + std::vector> v0sFromXiID; if (sel8 && !collision.sel8()) { fillTriggerTable(keepEvent); @@ -910,6 +659,7 @@ struct strangenessFilter { // Count number of Xi candidates xicounter++; + v0sFromXiID.push_back({casc.posTrackId(), casc.negTrackId()}); // Plot for estimates for (auto track : tracks) { // start loop over tracks @@ -968,6 +718,7 @@ struct strangenessFilter { // Count number of Omega candidates omegacounter++; + v0sFromOmegaID.push_back({casc.posTrackId(), casc.negTrackId()}); } if (isOmegalargeR) { omegalargeRcounter++; @@ -1044,19 +795,43 @@ struct strangenessFilter { hEvtvshMinPt->Fill(i + 0.5); } - // 2Xi trigger definition - if (xicounter > 1) { - keepEvent[2] = true; + // Double/triple/quad Xi trigger definition + if (v0sFromXiID.size() > 0) { + std::set> uniqueXis = {v0sFromXiID.begin(), v0sFromXiID.end()}; + if (uniqueXis.size() > 1) { + keepEvent[2] = true; + } + if (uniqueXis.size() > 2) { + keepEvent[3] = true; + } + if (uniqueXis.size() > 3) { + keepEvent[4] = true; + } } - // 3Xi trigger definition - if (xicounter > 2) { - keepEvent[3] = true; + // Double Omega trigger definition + if (v0sFromOmegaID.size() > 0) { + std::set> uniqueOmegas = {v0sFromOmegaID.begin(), v0sFromOmegaID.end()}; + if (uniqueOmegas.size() > 1) { + keepEvent[10] = true; + } } - // 4Xi trigger definition - if (xicounter > 3) { - keepEvent[4] = true; + // 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()}; + if (uniqueOmegas.size() > 1 || uniqueXis.size() > 1) { + keepEvent[11] = true; + } else { + // keep only if there is at least one non-overlapping v0 + for (auto v0Omega : uniqueOmegas) { + if (uniqueXis.find(v0Omega) == uniqueXis.end()) { + keepEvent[11] = true; + break; + } + } + } } // Single-Xi (YN) trigger definition @@ -1292,12 +1067,16 @@ struct strangenessFilter { if (keepEvent[9]) { hProcessedEvents->Fill(12.5); } + if (keepEvent[10]) { + hProcessedEvents->Fill(13.5); + } + if (keepEvent[11]) { + hProcessedEvents->Fill(14.5); + } // Filling the table fillTriggerTable(keepEvent); } - // - PROCESS_SWITCH(strangenessFilter, processRun3, "Process Run3", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/EventFiltering/PWGUD/diffractionFilter.cxx b/EventFiltering/PWGUD/diffractionFilter.cxx index 4ea29ab18a0..c5adfcf90c5 100644 --- a/EventFiltering/PWGUD/diffractionFilter.cxx +++ b/EventFiltering/PWGUD/diffractionFilter.cxx @@ -132,11 +132,16 @@ struct DGFilterRun3 { // using MFs = aod::MFTTracks; using FWs = aod::FwdTracks; + // filter for global tracks + Filter globalTrackFilter = requireGlobalTrackInFilter(); + using globalTracks = soa::Filtered; + void process(CC const& collision, BCs const& bcs, TCs& tracks, // MFs& mfttracks, FWs& fwdtracks, + globalTracks& goodTracks, aod::Zdcs& /*zdcs*/, aod::FT0s& /*ft0s*/, aod::FV0As& /*fv0as*/, @@ -162,6 +167,7 @@ struct DGFilterRun3 { // apply DG selection auto isDGEvent = dgSelector.IsSelected(diffCuts, collision, bcRange, tracks, fwdtracks); + LOGF(debug, "isDGEvent %d", isDGEvent); // update after cut histogram registry.fill(HIST("stat/aftercuts"), isDGEvent + 2); @@ -226,8 +232,9 @@ struct DGFilterRun3 { // collisions registry.fill(HIST("collisions/tracksAll"), tracks.size()); registry.fill(HIST("collisions/PVTracksAll"), collision.numContrib()); - Partition goodTracks = requireGlobalTrackInFilter(); - goodTracks.bindTable(tracks); + // Partition goodTracks = requireGlobalTrackInFilter(); + // goodTracks.bindTable(tracks); + // LOGF(info, "# good tracks %d", goodTracks.size()); registry.get(HIST("collisions/globalTracksAll"))->Fill(goodTracks.size()); auto netCharge = udhelpers::netCharge(tracks); registry.fill(HIST("collisions/netChargeAll"), collision.numContrib(), netCharge); diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index bd5f10423b6..ec661548d09 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -12,15 +12,148 @@ #include "Zorro.h" +#include #include -#include "TH1D.h" +#include #include "CCDB/BasicCCDBManager.h" #include "CommonDataFormat/InteractionRecord.h" using o2::InteractionRecord; +namespace +{ +int findBin(TH1* hist, const std::string& label) +{ // Find bin by label, avoiding the axis extention from the native ROOT implementation + for (int iBin{1}; iBin <= hist->GetNbinsX(); ++iBin) { + if (label == hist->GetXaxis()->GetBinLabel(iBin)) { + return iBin; + } + } + return -1; +} +} // namespace + +void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName) +{ + int runId{-1}; + for (size_t i{0}; i < mRunNumberHistos.size(); ++i) { + if (mRunNumberHistos[i] == runNumber) { + runId = i; + break; + } + } + if (runId > -1) { + /// Support jobs running on non-continuous run numbers + mAnalysedTriggers = mAnalysedTriggersList[runId]; + mAnalysedTriggersOfInterest = mAnalysedTriggersOfInterestList[runId]; + return; + } + if (mSelections) { + mAnalysedTriggers = histRegistry.add((folderName + "/" + std::to_string(runNumber) + "/" + "AnalysedTriggers").data(), "", o2::framework::HistType::kTH1D, {{mSelections->GetNbinsX() - 2, -0.5, mSelections->GetNbinsX() - 2.5}}).get(); + 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)); + } + std::shared_ptr selections = histRegistry.add((folderName + "/" + std::to_string(runNumber) + "/" + "Selections").data(), "", o2::framework::HistType::kTH1D, {{mSelections->GetNbinsX(), -0.5, static_cast(mSelections->GetNbinsX() - 0.5)}}); + selections->SetBit(TH1::kIsAverage); + for (int iBin{1}; iBin <= mSelections->GetNbinsX(); ++iBin) { + selections->GetXaxis()->SetBinLabel(iBin, mSelections->GetXaxis()->GetBinLabel(iBin)); + selections->SetBinContent(iBin, mSelections->GetBinContent(iBin)); + selections->SetBinError(iBin, mSelections->GetBinError(iBin)); + } + } + if (mScalers) { + std::shared_ptr scalers = histRegistry.add((folderName + "/" + std::to_string(runNumber) + "/" + "Scalers").data(), "", o2::framework::HistType::kTH1D, {{mScalers->GetNbinsX(), -0.5, static_cast(mScalers->GetNbinsX() - 0.5)}}); + scalers->SetBit(TH1::kIsAverage); + for (int iBin{1}; iBin <= mScalers->GetNbinsX(); ++iBin) { + scalers->GetXaxis()->SetBinLabel(iBin, mScalers->GetXaxis()->GetBinLabel(iBin)); + scalers->SetBinContent(iBin, mScalers->GetBinContent(iBin)); + scalers->SetBinError(iBin, mScalers->GetBinError(iBin)); + } + } + if (mInspectedTVX) { + std::shared_ptr inspectedTVX = histRegistry.add((folderName + "/" + std::to_string(runNumber) + "/" + "InspectedTVX").data(), "", o2::framework::HistType::kTH1D, {{mInspectedTVX->GetNbinsX(), -0.5, static_cast(mInspectedTVX->GetNbinsX() - 0.5)}}); + inspectedTVX->SetBit(TH1::kIsAverage); + for (int iBin{1}; iBin <= mInspectedTVX->GetNbinsX(); ++iBin) { + inspectedTVX->GetXaxis()->SetBinLabel(iBin, mInspectedTVX->GetXaxis()->GetBinLabel(iBin)); + inspectedTVX->SetBinContent(iBin, mInspectedTVX->GetBinContent(iBin)); + inspectedTVX->SetBinError(iBin, mInspectedTVX->GetBinError(iBin)); + } + } + if (mTOIs.size()) { + mAnalysedTriggersOfInterest = histRegistry.add((folderName + "/" + std::to_string(runNumber) + "/" + "AnalysedTriggersOfInterest").data(), "", o2::framework::HistType::kTH1D, {{static_cast(mTOIs.size()), -0.5, static_cast(mTOIs.size() - 0.5)}}).get(); + for (size_t i{0}; i < mTOIs.size(); ++i) { + mAnalysedTriggersOfInterest->GetXaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + } + } + mAnalysedTriggersList.push_back(mAnalysedTriggers); + mAnalysedTriggersOfInterestList.push_back(mAnalysedTriggersOfInterest); + mRunNumberHistos.push_back(runNumber); +} + +void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) +{ + // x-axis is run number, y-axis is same as ZorroSummary + int runId{-1}; + for (size_t i{0}; i < mRunNumberHistos.size(); ++i) { + if (mRunNumberHistos[i] == runNumber) { + runId = i; + break; + } + } + if (runId > -1) { + return; + } + // if the summary histogram is not set, create a new one + if (!ZorroHisto) { + LOGF(info, "Summary histogram not set, creating a new one"); + ZorroHisto = new TH2D("Zorro", "Zorro", 1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + ZorroHisto->SetBit(TH1::kIsAverage); + } + 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); + } + // if it is the first run, initialize the histogram + if (mRunNumberHistos.size() == 0) { + ZorroHisto->SetBins(1, -0.5, 0.5, 1 + mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); + ZorroHisto->SetBit(TH1::kIsAverage); + ZorroHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + ZorroHisto->GetYaxis()->SetBinLabel(1, "inspected TVX"); + for (size_t i{0}; i < mTOIs.size(); ++i) { + ZorroHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s selections", mTOIs[i].data())); + 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->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); + for (size_t i{0}; i < mTOIs.size(); ++i) { + ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + } + } + if (mInspectedTVX) { + ZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); + } + if (mSelections) { + 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)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2, mSelections->GetBinError(bin)); + } + } + if (mScalers) { + for (size_t i{0}; i < mTOIs.size(); ++i) { + int bin = findBin(mScalers, mTOIs[i]); + ZorroHisto->Fill(Form("%d", runNumber), Form("%s scalers", mTOIs[i].data()), mScalers->GetBinContent(bin)); + ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, i + 2 + mTOIs.size(), mScalers->GetBinError(bin)); + } + } + + mRunNumberHistos.push_back(runNumber); +} + std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange) { if (mRunNumber == runNumber) { @@ -31,70 +164,140 @@ std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber mBCtolerance = bcRange; std::map metadata; metadata["runNumber"] = std::to_string(runNumber); - mScalers = mCCDB->getSpecific(mBaseCCDBPath + "FilterCounters", timestamp, metadata); - mSelections = mCCDB->getSpecific(mBaseCCDBPath + "SelectionCounters", timestamp, metadata); - mInspectedTVX = mCCDB->getSpecific(mBaseCCDBPath + "InspectedTVX", timestamp, metadata); - auto selectedBCs = mCCDB->getSpecific>>(mBaseCCDBPath + "SelectedBCs", timestamp, metadata); - mBCranges.clear(); - for (auto bc : *selectedBCs) { - mBCranges.emplace_back(InteractionRecord::long2IR(std::min(bc[0], bc[1])), InteractionRecord::long2IR(std::max(bc[0], bc[1]))); - } - std::sort(mBCranges.begin(), mBCranges.end(), [](const auto& a, const auto& b) { return a.getMin() < b.getMin(); }); - - mSelectionBitMask = mCCDB->getSpecific>>(mBaseCCDBPath + "SelectionBitMask", timestamp, metadata); - mFilterBitMask = mCCDB->getSpecific>>(mBaseCCDBPath + "FilterBitMask", timestamp, metadata); - + mRunDuration = mCCDB->getRunDuration(runNumber, true); + int64_t runTs = (mRunDuration.first / 2 + mRunDuration.second / 2); + auto ctp = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", runTs); + mOrbitResetTimestamp = (*ctp)[0]; + mScalers = mCCDB->getSpecific(mBaseCCDBPath + "FilterCounters", runTs, metadata); + mSelections = mCCDB->getSpecific(mBaseCCDBPath + "SelectionCounters", runTs, metadata); + mInspectedTVX = mCCDB->getSpecific(mBaseCCDBPath + "InspectedTVX", runTs, metadata); + setupHelpers(timestamp); mLastBCglobalId = 0; mLastSelectedIdx = 0; mTOIs.clear(); mTOIidx.clear(); - size_t pos = 0; - while ((pos = tois.find(",")) != std::string::npos) { + 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); - int bin = mScalers->GetXaxis()->FindBin(token.c_str()) - 2; + int bin = findBin(mSelections, token) - 2; mTOIs.push_back(token); mTOIidx.push_back(bin); - tois.erase(0, pos + 1); + 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); + std::vector toiCounters(mTOIs.size(), 0.); + for (size_t i{0}; i < mTOIs.size(); ++i) { + toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2); + } + mZorroSummary.setupRun(runNumber, mInspectedTVX->GetBinContent(1), toiCounters); + return mTOIidx; } std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) { - std::bitset<128> result; + 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); + } + o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance}; - if (bcGlobalId < mLastBCglobalId) { + if (bcGlobalId < mLastBCglobalId) { /// Handle the possible discontinuity in the BC processed by the analyses mLastSelectedIdx = 0; } + uint64_t lastSelectedIdx = mLastSelectedIdx; + mLastBCglobalId = bcGlobalId; for (size_t i = mLastSelectedIdx; i < mBCranges.size(); i++) { - if (!bcFrame.getOverlap(mBCranges[i]).isZeroLength()) { + if (!mBCranges[i].isOutside(bcFrame)) { for (int iMask{0}; iMask < 2; ++iMask) { for (int iTOI{0}; iTOI < 64; ++iTOI) { - result.set(iMask * 64 + iTOI, mFilterBitMask->at(i)[iMask] & (1ull << iTOI)); + if (mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI)) { + mLastResult.set(iMask * 64 + iTOI, 1); + if (mAnalysedTriggers && !mAccountedBCranges[i]) { + mAnalysedTriggers->Fill(iMask * 64 + iTOI); + } + } } } + mAccountedBCranges[i] = true; + mLastSelectedIdx = mLastSelectedIdx == lastSelectedIdx-- ? i : mLastSelectedIdx; /// Decrease lastSelectedIdx to make sure this check is valid only in its first instance + } else if (mBCranges[i].getMax() < bcFrame.getMin()) { mLastSelectedIdx = i; - return result; + } else if (mBCranges[i].getMin() > bcFrame.getMax()) { + break; } } - return result; + return mLastResult; } -bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance) +bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance, TH2* ToiHisto) { - int lastSelectedIdx = mLastSelectedIdx; - std::bitset<128> result = fetch(bcGlobalId, tolerance); + uint64_t lastSelectedIdx = mLastSelectedIdx; + fetch(bcGlobalId, tolerance); + bool retVal{false}; for (size_t i{0}; i < mTOIidx.size(); ++i) { if (mTOIidx[i] < 0) { continue; - } else if (result.test(mTOIidx[i])) { + } else if (mLastResult.test(mTOIidx[i])) { mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting - return true; + if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) { + mAnalysedTriggersOfInterest->Fill(i); + mZorroSummary.increaseTOIcounter(mRunNumber, i); + } + if (ToiHisto && lastSelectedIdx != mLastSelectedIdx) { + ToiHisto->Fill(Form("%d", mRunNumber), Form("%s", mTOIs[i].data()), 1); + } + retVal = true; + } + } + return retVal; +} + +std::vector Zorro::getTriggerOfInterestResults(uint64_t bcGlobalId, uint64_t tolerance) +{ + fetch(bcGlobalId, tolerance); + return getTriggerOfInterestResults(); +} + +std::vector Zorro::getTriggerOfInterestResults() const +{ + std::vector results(mTOIidx.size(), false); + for (size_t i{0}; i < mTOIidx.size(); ++i) { + if (mTOIidx[i] < 0) { + continue; + } else if (mLastResult.test(mTOIidx[i])) { + results[i] = true; } } - return false; -} \ No newline at end of file + return results; +} + +bool Zorro::isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance) +{ + fetch(bcGlobalId, tolerance); + return mLastResult.none(); +} + +void Zorro::setupHelpers(int64_t timestamp) +{ + if (mCCDB->isCachedObjectValid(mBaseCCDBPath + "ZorroHelpers", timestamp)) { + return; + } + mZorroHelpers = mCCDB->getSpecific>(mBaseCCDBPath + "ZorroHelpers", timestamp, {{"runNumber", std::to_string(mRunNumber)}}); + 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) { + 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 6cde3d44aa3..c818e45ce48 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -15,12 +15,18 @@ #define EVENTFILTERING_ZORRO_H_ #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" -class TH1D; namespace o2 { namespace ccdb @@ -35,30 +41,56 @@ class Zorro Zorro() = default; std::vector initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcTolerance = 500); std::bitset<128> fetch(uint64_t bcGlobalId, uint64_t tolerance = 100); - bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100); + bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100, TH2* toiHisto = nullptr); + bool isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance = 100); + void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, int runNumber, std::string folderName = "Zorro"); + void populateExternalHists(int runNumber, TH2* zorroHisto = nullptr, TH2* toiHisto = nullptr); + + TH1D* getScalers() const { return mScalers; } + TH1D* getSelections() const { return mSelections; } + TH1D* getInspectedTVX() const { return mInspectedTVX; } + std::bitset<128> getLastResult() const { return mLastResult; } std::vector getTOIcounters() const { return mTOIcounts; } + std::vector getTriggerOfInterestResults(uint64_t bcGlobalId, uint64_t tolerance = 100); + std::vector getTriggerOfInterestResults() const; void setCCDBpath(std::string path) { mBaseCCDBPath = path; } void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; } void setBCtolerance(int tolerance) { mBCtolerance = tolerance; } + ZorroSummary* getZorroSummary() { return &mZorroSummary; } + private: - std::string mBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/"; + void setupHelpers(int64_t timestamp); + + ZorroSummary mZorroSummary{"ZorroSummary", "ZorroSummary"}; + + std::string mBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/"; 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 + + std::vector mRunNumberHistos; + std::vector mAnalysedTriggersList; /// Per run histograms + std::vector mAnalysedTriggersOfInterestList; /// Per run histograms + int mBCtolerance = 100; uint64_t mLastBCglobalId = 0; uint64_t mLastSelectedIdx = 0; TH1D* mScalers = nullptr; TH1D* mSelections = nullptr; TH1D* mInspectedTVX = nullptr; + std::bitset<128> mLastResult; + std::vector mAccountedBCranges; /// Avoid double accounting of inspected BC ranges std::vector mBCranges; - std::vector>* mFilterBitMask = nullptr; - std::vector>* mSelectionBitMask = nullptr; + std::vector* mZorroHelpers = nullptr; std::vector mTOIs; std::vector mTOIidx; std::vector mTOIcounts; o2::ccdb::BasicCCDBManager* mCCDB = nullptr; }; -#endif // EVENTFILTERING_ZORRO_H_ \ No newline at end of file +#endif // EVENTFILTERING_ZORRO_H_ diff --git a/EventFiltering/ZorroHelper.h b/EventFiltering/ZorroHelper.h new file mode 100644 index 00000000000..8bcc6240bc0 --- /dev/null +++ b/EventFiltering/ZorroHelper.h @@ -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. +// + +#ifndef EVENTFILTERING_ZORROHELPER_H_ +#define EVENTFILTERING_ZORROHELPER_H_ + +#include "Rtypes.h" + +struct ZorroHelper { + ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; + ClassDefNV(ZorroHelper, 1); +}; + +#endif // EVENTFILTERING_ZORROHELPER_H_ diff --git a/EventFiltering/ZorroSummary.cxx b/EventFiltering/ZorroSummary.cxx new file mode 100644 index 00000000000..ee241f49108 --- /dev/null +++ b/EventFiltering/ZorroSummary.cxx @@ -0,0 +1,69 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "ZorroSummary.h" + +#include "TCollection.h" + +void ZorroSummary::Copy(TObject& c) const +{ + static_cast(c) = *this; +} + +Long64_t ZorroSummary::Merge(TCollection* list) +{ + if (!list) { + return 0; + } + int n = 1; + if (list->IsEmpty()) { + return n; + } + + for (auto* obj : *list) { + auto* entry = dynamic_cast(obj); + if (!entry || entry->getTOInames() != mTOInames) { + continue; + } + n++; + auto& analysedToiCounters = entry->getAnalysedTOIcounters(); + for (const auto& [runNumber, currentAnalysedToiCounters] : analysedToiCounters) { + if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) { + mAnalysedTOIcounters[runNumber] = currentAnalysedToiCounters; + mTVXcounters[runNumber] = entry->getTVXcounters().at(runNumber); + mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber); + } else { + auto& thisCounters = mAnalysedTOIcounters[runNumber]; + for (size_t i = 0; i < thisCounters.size(); ++i) { + thisCounters[i] += currentAnalysedToiCounters[i]; + } + } + } + } + return n; +} + +double ZorroSummary::getNormalisationFactor(int toiId) const +{ + double totalTOI{0.}, totalTVX{0.}; + ULong64_t totalAnalysedTOI{0}; + for (const auto& [runNumber, toiCounters] : mTOIcounters) { + totalTOI += toiCounters.at(toiId); + } + for (const auto& [runNumber, tvxCounters] : mTVXcounters) { + totalTVX += tvxCounters; + } + for (const auto& [runNumber, analysedTOIcounters] : mAnalysedTOIcounters) { + totalAnalysedTOI += analysedTOIcounters.at(toiId); + } + + return totalTVX * totalAnalysedTOI / totalTOI; +} \ No newline at end of file diff --git a/EventFiltering/ZorroSummary.h b/EventFiltering/ZorroSummary.h new file mode 100644 index 00000000000..b4d401adba4 --- /dev/null +++ b/EventFiltering/ZorroSummary.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. +// + +#ifndef EVENTFILTERING_ZORROSUMMARY_H_ +#define EVENTFILTERING_ZORROSUMMARY_H_ + +#include + +#include +#include +#include + +class ZorroSummary : public TNamed +{ + public: + ZorroSummary() = default; + ZorroSummary(const char* name, const char* objTitle) : TNamed(name, objTitle) {} + virtual ~ZorroSummary() = default; // NOLINT: Making this override breaks compilation for unknown reason + 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) + { + mNtois = ntois; + mTOInames = toinames; + } + void setupRun(int runNumber, double tvxCountes, const std::vector& toiCounters) + { + if (mRunNumber == runNumber) { + return; + } + mRunNumber = runNumber; + mTVXcounters[runNumber] = tvxCountes; + mTOIcounters[runNumber] = toiCounters; + if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) { + mAnalysedTOIcounters[runNumber] = std::vector(mNtois, 0ull); + } + mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber]; + } + double getNormalisationFactor(int toiId) const; + void increaseTOIcounter(int runNumber, int toiId) + { + if (runNumber != mRunNumber) { + return; + } + mCurrentAnalysedTOIcounters->at(toiId)++; + } + + std::string getTOInames() const { return mTOInames; } + const auto& getTOIcounters() const { return mTOIcounters; } + const auto& getTVXcounters() const { return mTVXcounters; } + const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; } + + private: + int mRunNumber = 0; //! Run currently being analysed + std::vector* mCurrentAnalysedTOIcounters = nullptr; //! Analysed TOI counters for the current run + + int mNtois = 0; + std::string mTOInames; + std::unordered_map> mAnalysedTOIcounters; + std::unordered_map> mTOIcounters; + std::unordered_map mTVXcounters; + + ClassDef(ZorroSummary, 1); +}; + +#endif // EVENTFILTERING_ZORROSUMMARY_H_ \ No newline at end of file diff --git a/EventFiltering/cefpTask.cxx b/EventFiltering/cefpTask.cxx index 833634740a4..6b998a1d37f 100644 --- a/EventFiltering/cefpTask.cxx +++ b/EventFiltering/cefpTask.cxx @@ -200,12 +200,11 @@ static const float defaultDownscaling[128][1]{ {1.f}, {1.f}}; /// Max number of columns for triggers is 128 (extendible) -#define FILTER_CONFIGURABLE(_TYPE_) \ - Configurable> cfg##_TYPE_ \ - { \ -#_TYPE_, {defaultDownscaling[0], NumberOfColumns(typename _TYPE_::table_t::columns{}), 1, ColumnsNames(typename _TYPE_::table_t::columns{}), downscalingName }, #_TYPE_ " downscalings" \ +#define FILTER_CONFIGURABLE(_TYPE_) \ + Configurable> cfg##_TYPE_ \ + { \ + #_TYPE_, {defaultDownscaling[0], NumberOfColumns(typename _TYPE_::table_t::persistent_columns_t{}), 1, ColumnsNames(typename _TYPE_::table_t::persistent_columns_t{}), downscalingName}, #_TYPE_ " downscalings" \ } - } // namespace struct centralEventFilterTask { @@ -213,6 +212,8 @@ struct centralEventFilterTask { HistogramRegistry scalers{"scalers", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; Produces tags; + Configurable cfgDisableDownscalings{"cfgDisableDownscalings", false, "Disable downscalings"}; + FILTER_CONFIGURABLE(F1ProtonFilters); FILTER_CONFIGURABLE(NucleiFilters); FILTER_CONFIGURABLE(DiffractionFilters); @@ -261,17 +262,20 @@ struct centralEventFilterTask { col.second = filterOpt.get(col.first.data(), 0u); } } + if (cfgDisableDownscalings.value) { + LOG(info) << "Downscalings are disabled for all channels."; + } } void run(ProcessingContext& pc) { // Filling output table - auto bcTabConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto bcTabConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto bcTabPtr{bcTabConsumer->asArrowTable()}; - auto collTabConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto collTabConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto collTabPtr{collTabConsumer->asArrowTable()}; - auto evSelConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto evSelConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto evSelTabPtr{evSelConsumer->asArrowTable()}; auto columnGloBCId{bcTabPtr->GetColumnByName(aod::BC::GlobalBC::mLabel)}; @@ -327,7 +331,7 @@ struct centralEventFilterTask { uint64_t decisionBin{(bin - 2) / 64}; uint64_t triggerBit{BIT((bin - 2) % 64)}; auto column{tablePtr->GetColumnByName(colName.first)}; - double downscaling{colName.second}; + double downscaling{cfgDisableDownscalings.value ? 1. : colName.second}; if (column) { int entry = 0; for (int64_t iC{0}; iC < column->num_chunks(); ++iC) { @@ -358,7 +362,7 @@ struct centralEventFilterTask { if (!(outTrigger[iE][iD] & BIT(iB))) { continue; } - for (int jD{0}; jD < outTrigger[0].size(); ++jD) { + 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); diff --git a/EventFiltering/filterTables.h b/EventFiltering/filterTables.h index bfdf9b1dd3d..7283dec82de 100644 --- a/EventFiltering/filterTables.h +++ b/EventFiltering/filterTables.h @@ -15,14 +15,42 @@ #include #include #include -#include "Framework/AnalysisDataModel.h" +#include + +namespace o2::aod +{ +template +struct Hash; +} + +#include "Framework/ASoA.h" + +namespace o2::soa +{ +template + requires(!std::same_as>::metadata, void>) +const char* getTableLabel() +{ + return o2::aod::MetadataTrait>::metadata::tableLabel(); +} + +template + requires requires { T::ref.label_hash; } +const char* getTableLabel() +{ + return o2::aod::Hash::str; +} +} // namespace o2::soa namespace o2::aod { namespace filtering { -DECLARE_SOA_COLUMN(He, hasHe, bool); //! +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(ITSextremeIonisation, hasITSextremeIonisation, bool); //! ITS extreme ionisation +DECLARE_SOA_COLUMN(ITSmildIonisation, hasITSmildIonisation, bool); //! ITS mild ionisation (normalisation of the extreme ionisation), to be downscaled // diffraction DECLARE_SOA_COLUMN(UDdiffSmall, hasDiffSmall, bool); //! Double Gap events, <= 3 prongs @@ -57,16 +85,21 @@ DECLARE_SOA_COLUMN(HfSigmaCPPK, hasHfSigmaCPPK, bool); //! SigmaC( 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) // CF two body triggers DECLARE_SOA_COLUMN(PD, hasPD, bool); //! has d-p pair DECLARE_SOA_COLUMN(LD, hasLD, bool); //! has l-d pair // 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(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 // jets DECLARE_SOA_COLUMN(JetChLowPt, hasJetChLowPt, bool); //! low-pT charged jet @@ -101,6 +134,8 @@ DECLARE_SOA_COLUMN(hadronOmega, hashadronOmega, bool); //! at least 1 DECLARE_SOA_COLUMN(DoubleXi, hasDoubleXi, bool); //! at least 2 Xi DECLARE_SOA_COLUMN(TripleXi, hasTripleXi, bool); //! at least 3 Xi DECLARE_SOA_COLUMN(QuadrupleXi, hasQuadrupleXi, bool); //! at least 4 Xi +DECLARE_SOA_COLUMN(DoubleOmega, hasDoubleOmega, bool); //! at least 2 Omega +DECLARE_SOA_COLUMN(OmegaXi, hasOmegaXi, bool); //! at least 1 Omega + 1 Xi DECLARE_SOA_COLUMN(SingleXiYN, hasSingleXiYN, bool); //! at least 1 Xi with high radius (YN interactions) DECLARE_SOA_COLUMN(OmegaLargeRadius, hasOmegaLargeRadius, bool); //! at least 1 Omega with high radius DECLARE_SOA_COLUMN(TrackedCascade, hasTrackedCascade, bool); //! at least 1 tracked cascade @@ -157,7 +192,8 @@ DECLARE_SOA_COLUMN(BCend, hasBCend, uint64_t); //! CEFP bcrange // nuclei DECLARE_SOA_TABLE(NucleiFilters, "AOD", "NucleiFilters", //! - filtering::He, filtering::H3L3Body); + filtering::H2, filtering::He, filtering::H3L3Body, filtering::ITSmildIonisation, + filtering::ITSextremeIonisation); using NucleiFilter = NucleiFilters::iterator; // diffraction @@ -176,12 +212,31 @@ using DqFilter = DqFilters::iterator; // heavy flavours DECLARE_SOA_TABLE(HfFilters, "AOD", "HfFilters", //! - filtering::HfHighPt2P, filtering::HfHighPt3P, filtering::HfBeauty3P, filtering::HfBeauty4P, filtering::HfFemto2P, filtering::HfFemto3P, filtering::HfDoubleCharm2P, filtering::HfDoubleCharm3P, filtering::HfDoubleCharmMix, filtering::HfV0Charm2P, filtering::HfV0Charm3P, filtering::HfCharmBarToXiBach, filtering::HfSigmaCPPK, filtering::HfSigmaC0K0, filtering::HfPhotonCharm2P, filtering::HfPhotonCharm3P); + filtering::HfHighPt2P, + filtering::HfHighPt3P, + filtering::HfBeauty3P, + filtering::HfBeauty4P, + filtering::HfFemto2P, + filtering::HfFemto3P, + filtering::HfDoubleCharm2P, + filtering::HfDoubleCharm3P, + filtering::HfDoubleCharmMix, + filtering::HfV0Charm2P, + filtering::HfV0Charm3P, + filtering::HfCharmBarToXiBach, + filtering::HfSigmaCPPK, + filtering::HfSigmaC0K0, + filtering::HfPhotonCharm2P, + filtering::HfPhotonCharm3P, + filtering::HfSingleCharm2P, + filtering::HfSingleCharm3P, + filtering::HfSingleNonPromptCharm2P, + filtering::HfSingleNonPromptCharm3P); using HfFilter = HfFilters::iterator; DECLARE_SOA_TABLE(CFFilters, "AOD", "CFFilters", //! - filtering::PPP, filtering::PPL, filtering::PLL, filtering::LLL, filtering::PD, filtering::LD); + filtering::PPP, filtering::PPL, filtering::PLL, filtering::LLL, filtering::PPPHI, filtering::PD, filtering::LD); using CfFilter = CFFilters::iterator; // jets @@ -208,7 +263,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::Omega, filtering::hadronOmega, filtering::DoubleXi, filtering::TripleXi, filtering::QuadrupleXi, filtering::SingleXiYN, filtering::OmegaLargeRadius, filtering::TrackedXi, filtering::TrackedOmega, filtering::OmegaHighMult, filtering::DoubleOmega, filtering::OmegaXi); using StrangenessFilter = StrangenessFilters::iterator; @@ -250,7 +305,7 @@ static_assert(o2::framework::pack_size(FiltersPack) == NumberOfFilters); template void addColumnToMap(std::unordered_map>& map) { - map[MetadataTrait::metadata::tableLabel()][C::columnLabel()] = 1.f; + map[o2::soa::getTableLabel()][C::columnLabel()] = 1.f; } template @@ -267,7 +322,7 @@ void addColumnsToMap(o2::framework::pack, std::unordered_map void FillFiltersMap(o2::framework::pack, std::unordered_map>& map) { - (addColumnsToMap(typename T::table_t::columns{}, map), ...); + (addColumnsToMap(typename T::table_t::persistent_columns_t{}, map), ...); } template diff --git a/EventFiltering/macros/checkBCrangesSkimming.C b/EventFiltering/macros/checkBCrangesSkimming.C index eeda2ca39bc..f71212238c3 100644 --- a/EventFiltering/macros/checkBCrangesSkimming.C +++ b/EventFiltering/macros/checkBCrangesSkimming.C @@ -10,13 +10,14 @@ // or submit itself to any jurisdiction. // O2 includes -#include -#include -#include #include #include -#include #include +#include +#include +#include +#include +#include #include "CommonDataFormat/InteractionRecord.h" #include "CommonDataFormat/IRFrame.h" @@ -24,11 +25,8 @@ using o2::InteractionRecord; using o2::dataformats::IRFrame; // Set the bit of trigger which need to be checked -const ULong64_t trigger0Bit = BIT(54); -const ULong64_t trigger1Bit = 0; -const int bcDiffTolerance = 0; +const ULong64_t bcDiffTolerance = 0; const char outputFileName[15] = "output.root"; -bool skipNoneDuplicate = false; struct bcTuple { bcTuple(ULong64_t bcAO2D, ULong64_t bcEvSel) : bcAO2D(bcAO2D), bcEvSel(bcEvSel) {} @@ -41,16 +39,51 @@ struct bcTuple { }; struct selectedFrames : public IRFrame { + selectedFrames(ULong64_t bcAO2D, ULong64_t bcEvSel, const IRFrame& frame) : IRFrame(frame), bcAO2D(bcAO2D), bcEvSel(bcEvSel), triMask{0, 0}, selMask{0, 0} {} selectedFrames(ULong64_t bcAO2D, ULong64_t bcEvSel, ULong64_t triMask[2], ULong64_t selMask[2], const IRFrame& frame) : IRFrame(frame), bcAO2D(bcAO2D), bcEvSel(bcEvSel), triMask{triMask[0], triMask[1]}, selMask{selMask[0], selMask[1]} {} ULong64_t triMask[2]{0ull}, selMask[2]{0ull}, bcAO2D, bcEvSel; + int numSameTriggerInNearbyBCs = 0; // related to bcDiffTolerance + bool isSingle() { return numSameTriggerInNearbyBCs == 0; } + void SetNInNearbyBC(int n) { numSameTriggerInNearbyBCs = n; } + int GetNInNearbyBC() { return numSameTriggerInNearbyBCs; } }; -std::vector getSelectedFrames(TFile& file, ULong64_t trigger0Bit, ULong64_t trigger1Bit) +int DoBCSubraction(ULong64_t bc1, ULong64_t bc2) +{ + if (bc1 > bc2) { + return bc1 - bc2; + } else { + ULong64_t bcsub = bc2 - bc1; + return -static_cast(bcsub); + } +} + +int DoBCSubraction(selectedFrames bc1, selectedFrames bc2) +{ + if (bc1.getMin() > bc2.getMax()) { + return DoBCSubraction(bc1.getMin().toLong(), bc2.getMax().toLong()); + } else if (bc1.getMax() < bc2.getMin()) { + return DoBCSubraction(bc1.getMax().toLong(), bc2.getMin().toLong()); + } else { + return 0; + } +} + +bool isClose(selectedFrames a, selectedFrames b, ULong64_t bcDiffTolerance) +{ + if (a.getMin() > b.getMax() + bcDiffTolerance || a.getMax() + bcDiffTolerance < b.getMin()) + return false; + else + return true; +} + +std::vector> getFrames(std::unique_ptr& file, int trgIDStart, int N) { - std::vector selectedFrames; ULong64_t bcAO2D{0ull}, bcEvSel{0ull}, triMask[2]{0ull}, selMask[2]{0ull}; - for (auto key : *file.GetListOfKeys()) { - auto dir = dynamic_cast(file.Get(key->GetName())); + std::vector> frames; + frames.resize(N); + for (auto key : *file->GetListOfKeys()) { + auto dir = dynamic_cast(file->Get(key->GetName())); if (!dir) { continue; } @@ -75,315 +108,573 @@ std::vector getSelectedFrames(TFile& file, ULong64_t trigger0Bit if (!selMask[0] && !selMask[1]) { continue; } - if (selMask[0] & trigger0Bit || selMask[1] & trigger1Bit) { - InteractionRecord irstart, irend; - irstart.setFromLong(std::min(bcAO2D, bcEvSel)); - irend.setFromLong(std::max(bcAO2D, bcEvSel)); - IRFrame frame(irstart, irend); - selectedFrames.push_back({bcAO2D, bcEvSel, triMask, selMask, frame}); + for (int trgID = trgIDStart; trgID < trgIDStart + N; trgID++) { + ULong64_t trigger0Bit = 0, trigger1Bit = 0; + if (trgID < 64) { + trigger0Bit = BIT(trgID); + } else { + trigger1Bit = BIT(trgID - 64); + } + if (selMask[0] & trigger0Bit || selMask[1] & trigger1Bit) { + InteractionRecord irstart, irend; + irstart.setFromLong(std::min(bcAO2D, bcEvSel)); + irend.setFromLong(std::max(bcAO2D, bcEvSel)); + IRFrame frame(irstart, irend); + int index = trgID - trgIDStart; + frames[index].push_back({bcAO2D, bcEvSel, triMask, selMask, frame}); + } } } } - return selectedFrames; + + return frames; } -// Calulate the ratio of duplicate triggers -void checkDuplicateTrigger(std::string AnaFileName = "AnalysisResults.root", std::string originalFileName = "bcRanges_fullrun.root", std::string skimmedFileName = "bcRanges_fullrun_skimmed.root") +std::vector getSelectedFrames(std::unique_ptr& file, int trgID) { + auto frames = getFrames(file, trgID, 1); + return frames[0]; +} +// Check how many other triggers are in a compatible BC window with the current one +// Ideally, most of triggers are singles (num = 1) +// which means for most triggered events, none of others is in a nearby time window +void checkNearbyBCs(std::vector& frames, ULong64_t bcDiffTolerance) +{ + std::sort(frames.begin(), frames.end(), [](const selectedFrames& a, const selectedFrames& b) { + if (a.getMin() != b.getMin()) { + return a.getMin() < b.getMin(); + } else { + return a.getMax() < b.getMax(); + } + }); + int firstTrg = 0; + for (auto& currentFrame : frames) { + int num = 0; + bool shouldUpdate = true; // true if the maxBC of event in loop is smaller than the evaluating one -> update firstTrg + for (int i = firstTrg; i < frames.size(); i++) { + auto& frame = frames[i]; + if (frame.getMin() > currentFrame.getMax() + bcDiffTolerance) { + break; + } + if (isClose(currentFrame, frame, bcDiffTolerance)) { + shouldUpdate = false; + bool found = currentFrame.selMask[0] & frame.selMask[0] || currentFrame.selMask[1] & frame.selMask[1]; + if (found) { + num++; + } + } else { + if (shouldUpdate) { + firstTrg = i; + } + } + } + currentFrame.SetNInNearbyBC(num); + } +} + +// Get RunNumber +std::string getRunNumber(std::string fileName) +{ std::string runNumber = ""; std::regex re("/5[0-9]*"); std::smatch match; - if (std::regex_search(originalFileName, match, re)) { + if (std::regex_search(fileName, match, re)) { // Remove the leading '/' runNumber = match.str().substr(1); } + return runNumber; +} - // Readin labels - TFile AnaFile(AnaFileName.c_str(), "READ"); - TH1* hist0 = dynamic_cast(AnaFile.Get("central-event-filter-task/scalers/mFiltered;1")); - std::vector labels; - std::vector binNum; - for (int i = 1; i <= hist0->GetNbinsX(); i++) { - std::string label = hist0->GetXaxis()->GetBinLabel(i); - if (label != "Total number of events" && label != "Filtered events") { - labels.push_back(label); - binNum.push_back(i); - } - } - AnaFile.Close(); +// Detailed checks for specific trigger, not enabled by default +void checkBCForSelectedTrg(std::vector& originalFrames, std::vector& skimmedFrames, string runNumber, string triggerLabel) +{ - TFile originalFile(originalFileName.c_str(), "READ"); - TFile skimmedFile(skimmedFileName.c_str(), "READ"); - std::vector sel_labels; - std::vector numOriginal, numSkimmed, numOriginalDuplicate, numSkimmedDuplicate; - for (int i = 0; i < labels.size(); i++) { - ULong64_t trigger0Bit = 0, trigger1Bit = 0; - int triggerBit = binNum[i] - 2; - if (triggerBit < 64) { - trigger0Bit = BIT(triggerBit); + TH1D hTriggerCounter("hTriggerCounter", (runNumber + " " + triggerLabel + ";;Total number of trigger").data(), 2, -0.5, 1.5); + hTriggerCounter.GetXaxis()->SetBinLabel(1, "Original"); + hTriggerCounter.GetXaxis()->SetBinLabel(2, "Skimmed"); + TH1D hBCDiffAO2D("hBCDiffAO2D", (runNumber + " " + triggerLabel + ";;#DeltaBC_{AO2D} between paired singles").data(), 201, -100.5, 100.5); + TH1D hBCDiffEvSel("hBCDiffEvSel", (runNumber + " " + triggerLabel + ";;#DeltaBC_{EvSel} between paired singles").data(), 201, -100.5, 100.5); + + TH1D hBCOriginal("hBCOriginal", (runNumber + " " + triggerLabel + " Original;;Trigger counts").data(), 4, -0.5, 3.5); + hBCOriginal.GetXaxis()->SetBinLabel(1, "Total"); + hBCOriginal.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); + hBCOriginal.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); + hBCOriginal.GetXaxis()->SetBinLabel(4, "Same Both BC"); + TH1D hBCSkimmed("hBCSkimmed", (runNumber + " " + triggerLabel + " Skimmed;;Trigger counts").data(), 4, -0.5, 3.5); + hBCSkimmed.GetXaxis()->SetBinLabel(1, "Total"); + hBCSkimmed.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); + hBCSkimmed.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); + hBCSkimmed.GetXaxis()->SetBinLabel(4, "Same Both BC"); + + TH1D hMatchedNumCounter("hMatchedNumCounter", (runNumber + " " + triggerLabel + ";;Number of matched triggers in skimmed data").data(), 10, -0.5, 9.5); + + checkNearbyBCs(originalFrames, bcDiffTolerance); + checkNearbyBCs(skimmedFrames, bcDiffTolerance); + + std::vector bcSet; + int firstTrg = 0; + for (int i = 0; i < originalFrames.size(); i++) { + auto& frame = originalFrames[i]; + hTriggerCounter.Fill(0); + hBCOriginal.Fill(0); + //------------------------------ Check if there are triggers which have same BC, time-consuming! ------------------------------------------------------- + auto p1 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcAO2D == frame.bcAO2D; }); + if (p1 != bcSet.end()) { + hBCOriginal.Fill(1); + } + auto p2 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcEvSel == frame.bcEvSel; }); + if (p2 != bcSet.end()) { + hBCOriginal.Fill(2); + } + bcTuple currentBC(frame.bcAO2D, frame.bcEvSel); + auto p3 = std::find(bcSet.begin(), bcSet.end(), currentBC); + if (p3 == bcSet.end()) { + bcSet.push_back(currentBC); } else { - trigger1Bit = BIT(triggerBit - 64); + hBCOriginal.Fill(3); } - // For Original dataset - std::vector bcSet; - double noriginal{0}, nskimmed{0}, noriginalduplicate{0}, nskimmedduplicate{0}; - auto Frames = getSelectedFrames(originalFile, trigger0Bit, trigger1Bit); - for (auto frame : Frames) { - noriginal++; - bcTuple currentBC(frame.bcAO2D, frame.bcEvSel); - auto p = std::find(bcSet.begin(), bcSet.end(), currentBC); - if (p == bcSet.end()) { - bcSet.push_back(currentBC); - } else { - noriginalduplicate++; - } + //------------------------------------------------------------------------------------- + + if (frame.GetNInNearbyBC() != 1) { + continue; // Only check singles } - // For skimmed dataset - bcSet.clear(); - auto skimmedFrames = getSelectedFrames(skimmedFile, trigger0Bit, trigger1Bit); - for (auto& skimmedFrame : skimmedFrames) { - nskimmed++; - bcTuple currentBC(skimmedFrame.bcAO2D, skimmedFrame.bcEvSel); - auto p = std::find(bcSet.begin(), bcSet.end(), currentBC); - if (p == bcSet.end()) { - bcSet.push_back(currentBC); + std::vector skimmedbcs; + int n = 0; + bool shouldUpdate = true; + for (int j = firstTrg; j < skimmedFrames.size(); j++) { + auto& skimmedFrame = skimmedFrames[j]; + if (skimmedFrame.getMin() > frame.getMax()) { + break; + } + if (skimmedFrame.GetNInNearbyBC() != 1) { + continue; // Only check singles + } + if (isClose(frame, skimmedFrame, bcDiffTolerance)) { + shouldUpdate = false; + bool found = frame.selMask[0] & skimmedFrame.selMask[0] || frame.selMask[1] & skimmedFrame.selMask[1]; + if (found) { + // Additional check to avoid match of skimmed singles and original multiplies + if (i != 0 && isClose(originalFrames[i - 1], skimmedFrame, bcDiffTolerance)) { + continue; + } + if (i != originalFrames.size() && isClose(originalFrames[i + 1], skimmedFrame, bcDiffTolerance)) { + continue; + } + skimmedbcs.push_back({skimmedFrame.bcAO2D, skimmedFrame.bcEvSel}); + n++; + } } else { - nskimmedduplicate++; + if (shouldUpdate) { + firstTrg = j; + } } } - if (!skipNoneDuplicate || noriginalduplicate != 0 || nskimmedduplicate != 0) { - sel_labels.push_back(labels[i]); - numOriginal.push_back(noriginal); - numOriginalDuplicate.push_back(noriginalduplicate); - numSkimmed.push_back(nskimmed); - numSkimmedDuplicate.push_back(nskimmedduplicate); + if (n == 0) { + // std::cout << "Trigger not found!!!" << std::endl; + } else if (n == 1) { + hBCDiffAO2D.Fill(DoBCSubraction(frame.bcAO2D, skimmedbcs[0].bcAO2D)); + hBCDiffEvSel.Fill(DoBCSubraction(frame.bcEvSel, skimmedbcs[0].bcEvSel)); } + hMatchedNumCounter.Fill(n); } - originalFile.Close(); - skimmedFile.Close(); - - TH1D hOriginalTotal("hOriginalTotal", "AO2D Original;;Number of events", sel_labels.size(), 0, sel_labels.size()); - TH1D hOriginalDuplicate("hOriginalDuplicate", "Duplicate Trigger Original;;Number of events", sel_labels.size(), 0, sel_labels.size()); - TH1D hOriginalRatio("hOriginalRatio", (runNumber + " Original;;Duplicate / Total").data(), sel_labels.size(), 0, sel_labels.size()); - TH1D hSkimmedTotal("hSkimmedTotal", "AO2D Skimmed;;Number of events", sel_labels.size(), 0, sel_labels.size()); - TH1D hSkimmedDuplicate("hSkimmedDuplicate", "Duplicate Trigger Skimmed;;Number of events", sel_labels.size(), 0, sel_labels.size()); - TH1D hSkimmedRatio("hSkimmedRatio", (runNumber + " Skimmed;;Duplicate / Total").data(), sel_labels.size(), 0, sel_labels.size()); - for (int i = 0; i < sel_labels.size(); i++) { - hOriginalTotal.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hOriginalDuplicate.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hOriginalRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hOriginalTotal.SetBinContent(i + 1, numOriginal[i]); - hOriginalDuplicate.SetBinContent(i + 1, numOriginalDuplicate[i]); - if (hOriginalTotal.GetBinContent(i + 1) > 0) { - hOriginalRatio.SetBinContent(i + 1, hOriginalDuplicate.GetBinContent(i + 1) / hOriginalTotal.GetBinContent(i + 1)); - } else { - hOriginalRatio.SetBinContent(i + 1, 0); + //------------------------------ Check if there are triggers which have same BC, time-consuming! ------------------------------------------------------- + bcSet.clear(); + for (auto& skimmedFrame : skimmedFrames) { + hTriggerCounter.Fill(1); + hBCSkimmed.Fill(0); + auto p1 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcAO2D == skimmedFrame.bcAO2D; }); + if (p1 != bcSet.end()) { + hBCSkimmed.Fill(1); } - - hSkimmedTotal.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hSkimmedDuplicate.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hSkimmedRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); - hSkimmedTotal.SetBinContent(i + 1, numSkimmed[i]); - hSkimmedDuplicate.SetBinContent(i + 1, numSkimmedDuplicate[i]); - if (hSkimmedTotal.GetBinContent(i + 1) > 0) { - hSkimmedRatio.SetBinContent(i + 1, hSkimmedDuplicate.GetBinContent(i + 1) / hSkimmedTotal.GetBinContent(i + 1)); + auto p2 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcEvSel == skimmedFrame.bcEvSel; }); + if (p2 != bcSet.end()) { + hBCSkimmed.Fill(2); + } + bcTuple currentBC(skimmedFrame.bcAO2D, skimmedFrame.bcEvSel); + auto p3 = std::find(bcSet.begin(), bcSet.end(), currentBC); + if (p3 == bcSet.end()) { + bcSet.push_back(currentBC); } else { - hSkimmedRatio.SetBinContent(i + 1, 0); + hBCSkimmed.Fill(3); } } + //------------------------------------------------------------------------------------- TFile fout(outputFileName, "UPDATE"); fout.cd(); - hOriginalTotal.Write(); - hOriginalDuplicate.Write(); - hOriginalRatio.Write(); - hSkimmedTotal.Write(); - hSkimmedDuplicate.Write(); - hSkimmedRatio.Write(); + TDirectory* dir1 = fout.GetDirectory(runNumber.data()); + if (!dir1) { + dir1 = fout.mkdir(runNumber.data()); + } + dir1->cd(); + TDirectory* dir2 = dir1->GetDirectory(triggerLabel.data()); + if (!dir2) { + dir2 = dir1->mkdir(triggerLabel.data()); + } + dir2->cd(); + + hTriggerCounter.Write(); + hBCOriginal.Write(); + hBCSkimmed.Write(); + hBCDiffAO2D.Write(); + hBCDiffEvSel.Write(); + hMatchedNumCounter.Write(); fout.Close(); } -void checkBCrangesSkimming(std::string originalFileName = "bcRanges_fullrun.root", std::string skimmedFileName = "bcRanges_fullrun_skimmed.root") +// Detailed checks for specific trigger +void checkBCForSelectedTrg(std::string AnaFileName = "AnalysisResults.root", std::string originalFileName = "bcRanges_fullrun.root", std::string skimmedFileName = "bcRanges_fullrun_skimmed.root", int triggerID = 1, bool useAlien = true) { - TH1F hTriggerCounter("hTriggerCounter", "hTriggerCounter", 3, 0.5, 3.5); - hTriggerCounter.GetXaxis()->SetBinLabel(1, "Original"); - hTriggerCounter.GetXaxis()->SetBinLabel(2, "Skimmed"); - TH1F hNumCounter("hNumCounter", "hTriggerCounter", 10, -0.5, 9.5); - TH1F hPairedTriggerCounter("hPairedTriggerCounter", "hPairedTriggerCounter", 4, 0.5, 4.5); - hPairedTriggerCounter.GetXaxis()->SetBinLabel(1, "Total"); - hPairedTriggerCounter.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); - hPairedTriggerCounter.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); - hPairedTriggerCounter.GetXaxis()->SetBinLabel(4, "Same Both BC"); - TH1F hSinglePairCheck("hSinglePairCheck", "hSinglePairCheck", 4, 0.5, 4.5); - hSinglePairCheck.GetXaxis()->SetBinLabel(1, "Total"); - hSinglePairCheck.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); - hSinglePairCheck.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); - hSinglePairCheck.GetXaxis()->SetBinLabel(4, "Same Both BC"); - TH1F hMultiPairCheck("hMultiPairCheck", "hMultiPairCheck", 5, 0.5, 5.5); - hMultiPairCheck.GetXaxis()->SetBinLabel(1, "Total"); - hMultiPairCheck.GetXaxis()->SetBinLabel(2, "Total Pair"); - hMultiPairCheck.GetXaxis()->SetBinLabel(3, "Same AO2D BC"); - hMultiPairCheck.GetXaxis()->SetBinLabel(4, "Same EvSel BC"); - hMultiPairCheck.GetXaxis()->SetBinLabel(5, "Same Both BC"); - TH1F hBCDiffAO2D("hBCDiffAO2D", "hBCDiffAO2D", 1000, -5.e3, 5.e3); - TH1F hBCDiffEvSel("hBCDiffEvSel", "hBCDiffEvSel", 1000, -5.e3, 5.e3); - - TH1F hBCOriginal("hBCOriginal", "hBCOriginal", 4, 0.5, 4.5); - hBCOriginal.GetXaxis()->SetBinLabel(1, "Total"); - hBCOriginal.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); - hBCOriginal.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); - hBCOriginal.GetXaxis()->SetBinLabel(4, "Same Both BC"); - TH1F hBCSkimmed("hBCSkimmed", "hBCSkimmed", 4, 0.5, 4.5); - hBCSkimmed.GetXaxis()->SetBinLabel(1, "Total"); - hBCSkimmed.GetXaxis()->SetBinLabel(2, "Same AO2D BC"); - hBCSkimmed.GetXaxis()->SetBinLabel(3, "Same EvSel BC"); - hBCSkimmed.GetXaxis()->SetBinLabel(4, "Same Both BC"); - auto t1 = std::chrono::steady_clock::now(); - TFile originalFile(originalFileName.c_str(), "READ"); - TFile skimmedFile(skimmedFileName.c_str(), "READ"); - auto originalFrames = getSelectedFrames(originalFile, trigger0Bit, trigger1Bit); - auto skimmedFrames = getSelectedFrames(skimmedFile, trigger0Bit, trigger1Bit); - originalFile.Close(); - skimmedFile.Close(); - auto t2 = std::chrono::steady_clock::now(); - int d1 = std::chrono::duration_cast(t2 - t1).count(); - std::cout << "Readin Time: " << d1 << std::endl; - - auto t3 = std::chrono::steady_clock::now(); - std::sort(originalFrames.begin(), originalFrames.end(), [](const selectedFrames& a, const selectedFrames& b) { - return a.getMin() < b.getMin(); - }); - std::sort(skimmedFrames.begin(), skimmedFrames.end(), [](const selectedFrames& a, const selectedFrames& b) { - return a.getMin() < b.getMin(); - }); - auto t4 = std::chrono::steady_clock::now(); - int d2 = std::chrono::duration_cast(t4 - t3).count(); - std::cout << "Sort Time: " << d2 << std::endl; + string runNumber = getRunNumber(originalFileName); + if (useAlien) { + TGrid::Connect("alien://"); + AnaFileName = "alien://" + AnaFileName; + originalFileName = "alien://" + originalFileName; + skimmedFileName = "alien://" + skimmedFileName; + } - auto t5 = std::chrono::steady_clock::now(); - std::vector bcSet; - for (auto frame : originalFrames) { - if (frame.selMask[0] & trigger0Bit) { - bool found = false; - hTriggerCounter.Fill(1); - hBCOriginal.Fill(1); - auto p1 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcAO2D == frame.bcAO2D; }); - if (p1 != bcSet.end()) { - hBCOriginal.Fill(2); - } - auto p2 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcEvSel == frame.bcEvSel; }); - if (p2 != bcSet.end()) { - hBCOriginal.Fill(3); + // Readin labels + std::unique_ptr AnaFile{TFile::Open(AnaFileName.c_str(), "READ")}; + TH1* hist0 = dynamic_cast(AnaFile->Get("central-event-filter-task/scalers/mFiltered;1")); + std::vector labels; + std::vector binNum; + for (int i = 1; i <= hist0->GetNbinsX(); i++) { + std::string label = hist0->GetXaxis()->GetBinLabel(i); + if (label != "Total number of events" && label != "Filtered events") { + labels.push_back(label); + binNum.push_back(i); + } + } + AnaFile->Close(); + std::string triggerLabel = labels[triggerID]; + + std::unique_ptr originalFile{TFile::Open(originalFileName.c_str(), "READ")}; + std::unique_ptr skimmedFile{TFile::Open(skimmedFileName.c_str(), "READ")}; + auto originalFrames = getSelectedFrames(originalFile, triggerID); + auto skimmedFrames = getSelectedFrames(skimmedFile, triggerID); + originalFile->Close(); + skimmedFile->Close(); + + checkBCForSelectedTrg(originalFrames, skimmedFrames, runNumber, triggerLabel); +} + +// Check the BCId compatibility of triggers on original and skimmmed data +void checkBCrangesSkimming(std::string AnaFileName = "AnalysisResults.root", std::string originalFileName = "bcRanges_fullrun.root", std::string skimmedFileName = "bcRanges_fullrun_skimmed.root", bool useAlien = true) +{ + + string runNumber = getRunNumber(originalFileName); + if (useAlien) { + TGrid::Connect("alien://"); + AnaFileName = "alien://" + AnaFileName; + originalFileName = "alien://" + originalFileName; + skimmedFileName = "alien://" + skimmedFileName; + } + + // Readin labels + std::unique_ptr AnaFile{TFile::Open(AnaFileName.c_str(), "READ")}; + TH1* hist0 = dynamic_cast(AnaFile->Get("central-event-filter-task/scalers/mFiltered;1")); + std::vector labels; + std::vector binNum; + for (int i = 1; i <= hist0->GetNbinsX(); i++) { + std::string label = hist0->GetXaxis()->GetBinLabel(i); + if (label != "Total number of events" && label != "Filtered events") { + labels.push_back(label); + binNum.push_back(i); + // std::cout << i - 2 << ": " << label << std::endl; + } + } + AnaFile->Close(); + + // Due to potential selection on triggers, histograms should be created later + // for example: skip triggers which have no enrties + std::vector sel_labels; + std::vector numOriginal, numSkimmed, numOriginalSingle, numSkimmedSingle, numOriginalDouble, numSkimmedDouble, numOriginalMultiple, numSkimmedMultiple, numCloseSkimmed; + std::vector numpair, numpairedBCAO2D, numpairedBCEvSel; + std::vector avgDeltaBCAO2D, avgDeltaBCEvSel, avgDeltaBC, rmsDeltaBCAO2D, rmsDeltaBCEvSel, rmsDeltaBC; + std::vector avgNumPairedTrigger, rmsNumPairedTrigger; + + std::unique_ptr originalFile{TFile::Open(originalFileName.c_str(), "READ")}; + std::unique_ptr skimmedFile{TFile::Open(skimmedFileName.c_str(), "READ")}; + std::vector> originalAllFrames = getFrames(originalFile, 0, labels.size()); + std::vector> skimmedAllFrames = getFrames(skimmedFile, 0, labels.size()); + for (int trgID = 0; trgID < labels.size(); trgID++) { + // Caculate singles, doubles, and multiples + int noriginal{0}, nskimmed{0}, noriginalsingle{0}, nskimmedsingle{0}, noriginaldouble{0}, nskimmeddouble{0}, noriginalmultiple{0}, nskimmedmultiple{0}; + // Caculate mean and rms of diff BC + TH1D hDiffBCAO2DCount("hDiffBCAO2DCount", "hDiffBCAO2DCount", 21, -10.5, 10.5); + TH1D hDiffBCEvSelCount("hDiffBCEvSelCount", "hDiffBCEvSelCount", 21, -10.5, 10.5); + TH1D hDiffBCCount("hDiffBCCount", "hDiffBCCount", 21, -10.5, 10.5); + TH1D hNumPairedTriggerCount("hNumPairedTriggerCount", "hNumPairedTriggerCount", 10, -0.5, 9.5); + // For Original dataset + auto& originalFrames = originalAllFrames[trgID]; + checkNearbyBCs(originalFrames, bcDiffTolerance); // include sorting + noriginal = originalFrames.size(); + for (auto originalFrame : originalFrames) { + if (originalFrame.GetNInNearbyBC() == 0) { + std::cerr << "Unexpected trigger!!! " << std::endl; + } else if (originalFrame.GetNInNearbyBC() == 1) { + noriginalsingle++; + } else if (originalFrame.GetNInNearbyBC() == 2) { + noriginaldouble++; + } else { + noriginalmultiple++; } - bcTuple currentBC(frame.bcAO2D, frame.bcEvSel); - auto p3 = std::find(bcSet.begin(), bcSet.end(), currentBC); - if (p3 == bcSet.end()) { - bcSet.push_back(currentBC); + } + // For skimmed dataset + auto& skimmedFrames = skimmedAllFrames[trgID]; + checkNearbyBCs(skimmedFrames, bcDiffTolerance); // include sorting + nskimmed = skimmedFrames.size(); + for (auto& skimmedFrame : skimmedFrames) { + if (skimmedFrame.GetNInNearbyBC() == 0) { + std::cerr << "Unexpected trigger!!! " << std::endl; + } else if (skimmedFrame.GetNInNearbyBC() == 1) { + nskimmedsingle++; + } else if (skimmedFrame.GetNInNearbyBC() == 2) { + nskimmeddouble++; } else { - hBCOriginal.Fill(4); + nskimmedmultiple++; + } + } + + // Check BC differences + int npair{0}, npairedBCAO2D{0}, npairedBCEvSel{0}, ncloseskimmed{0}, maxdeltaBCAO2D{0}, maxdeltaBCEvSel{0}; + int firstTrg = 0; + for (int i = 0; i < originalFrames.size(); i++) { + auto& frame = originalFrames[i]; + if (frame.GetNInNearbyBC() != 1) { + continue; // Only check singles } - // std::cout << "------------------------------------------------" << std::endl; - frame.getMin() -= bcDiffTolerance; - frame.getMax() += bcDiffTolerance; - std::vector skimmedbcs; + std::vector skimmedbcs; int n = 0; - for (auto& skimmedFrame : skimmedFrames) { + bool shouldUpdate = true; + for (int j = firstTrg; j < skimmedFrames.size(); j++) { + auto& skimmedFrame = skimmedFrames[j]; if (skimmedFrame.getMin() > frame.getMax()) { break; } - if (!frame.isOutside(skimmedFrame)) { - found = frame.selMask[0] & skimmedFrame.selMask[0] || frame.selMask[1] & skimmedFrame.selMask[1]; - found = found && (frame.bcAO2D == skimmedFrame.bcAO2D || frame.bcEvSel == skimmedFrame.bcEvSel); + if (skimmedFrame.GetNInNearbyBC() != 1) { + continue; // Only check singles + } + if (isClose(frame, skimmedFrame, bcDiffTolerance)) { + shouldUpdate = false; + bool found = frame.selMask[0] & skimmedFrame.selMask[0] || frame.selMask[1] & skimmedFrame.selMask[1]; if (found) { - hPairedTriggerCounter.Fill(1); - if (frame.bcAO2D == skimmedFrame.bcAO2D) { - hPairedTriggerCounter.Fill(2); + // Additional check to avoid match of skimmed singles and original multiplies + if (i != 0 && isClose(originalFrames[i - 1], skimmedFrame, bcDiffTolerance)) { + continue; } - if (frame.bcEvSel == skimmedFrame.bcEvSel) { - hPairedTriggerCounter.Fill(3); - if (frame.bcAO2D == skimmedFrame.bcAO2D) { - hPairedTriggerCounter.Fill(4); - } + if (i != originalFrames.size() && isClose(originalFrames[i + 1], skimmedFrame, bcDiffTolerance)) { + continue; } - skimmedbcs.push_back({skimmedFrame.bcAO2D, skimmedFrame.bcEvSel}); + + InteractionRecord irstart, irend; + irstart.setFromLong(std::min(skimmedFrame.bcAO2D, skimmedFrame.bcEvSel)); + irend.setFromLong(std::max(skimmedFrame.bcAO2D, skimmedFrame.bcEvSel)); + IRFrame frame(irstart, irend); + skimmedbcs.push_back({skimmedFrame.bcAO2D, skimmedFrame.bcEvSel, frame}); n++; } + } else { + if (shouldUpdate) { + firstTrg = j; + } } } - if (n == 0) { - // std::cout << "Trigger not found!!! " << n << std::endl; - } else if (n == 1) { - hSinglePairCheck.Fill(1); - hBCDiffAO2D.Fill(frame.bcAO2D - skimmedbcs[0].bcAO2D); - hBCDiffEvSel.Fill(frame.bcEvSel - skimmedbcs[0].bcEvSel); + if (n == 1) { + npair++; + int bcdiffAO2D = DoBCSubraction(frame.bcAO2D, skimmedbcs[0].bcAO2D); + int bcdiffEvSel = DoBCSubraction(frame.bcEvSel, skimmedbcs[0].bcEvSel); + hDiffBCAO2DCount.Fill(std::abs(bcdiffAO2D)); + hDiffBCEvSelCount.Fill(std::abs(bcdiffEvSel)); + hDiffBCCount.Fill(std::abs(DoBCSubraction(frame, skimmedbcs[0]))); if (frame.bcAO2D == skimmedbcs[0].bcAO2D) { - hSinglePairCheck.Fill(2); + npairedBCAO2D++; } if (frame.bcEvSel == skimmedbcs[0].bcEvSel) { - hSinglePairCheck.Fill(3); - if (frame.bcAO2D == skimmedbcs[0].bcAO2D) { - hSinglePairCheck.Fill(4); - } - } - } else { - // std::cout << "Unexpected trigger!!! " << n << std::endl; - hMultiPairCheck.Fill(1); - for (auto skimmedbc : skimmedbcs) { - hMultiPairCheck.Fill(2); - if (frame.bcAO2D == skimmedbc.bcAO2D) { - hMultiPairCheck.Fill(3); - } - if (frame.bcEvSel == skimmedbc.bcEvSel) { - hMultiPairCheck.Fill(4); - if (frame.bcAO2D == skimmedbc.bcAO2D) { - hMultiPairCheck.Fill(5); - } - } + npairedBCEvSel++; } } - hNumCounter.Fill(n); + ncloseskimmed += n; + hNumPairedTriggerCount.Fill(n); } + + // if (static_cast(ncloseskimmed) / noriginal > 0.95 || noriginal == 0) + if (noriginal == 0) { + // continue; + } + sel_labels.push_back(labels[trgID]); + numOriginal.push_back(noriginal); + numOriginalSingle.push_back(noriginalsingle); + numOriginalDouble.push_back(noriginaldouble); + numOriginalMultiple.push_back(noriginalmultiple); + numSkimmed.push_back(nskimmed); + numSkimmedSingle.push_back(nskimmedsingle); + numSkimmedDouble.push_back(nskimmeddouble); + numSkimmedMultiple.push_back(nskimmedmultiple); + + numpair.push_back(npair); + numpairedBCAO2D.push_back(npairedBCAO2D); + numpairedBCEvSel.push_back(npairedBCEvSel); + numCloseSkimmed.push_back(ncloseskimmed); + avgDeltaBCAO2D.push_back(hDiffBCAO2DCount.GetMean()); + avgDeltaBCEvSel.push_back(hDiffBCEvSelCount.GetMean()); + avgDeltaBC.push_back(hDiffBCCount.GetMean()); + rmsDeltaBCAO2D.push_back(hDiffBCAO2DCount.GetRMS()); + rmsDeltaBCEvSel.push_back(hDiffBCEvSelCount.GetRMS()); + rmsDeltaBC.push_back(hDiffBCCount.GetRMS()); + avgNumPairedTrigger.push_back(hNumPairedTriggerCount.GetMean()); + rmsNumPairedTrigger.push_back(hNumPairedTriggerCount.GetRMS()); } - auto t6 = std::chrono::steady_clock::now(); - int d3 = std::chrono::duration_cast(t6 - t5).count(); - std::cout << "Search Time: " << d3 << std::endl; + originalFile->Close(); + skimmedFile->Close(); - bcSet.clear(); - for (auto& skimmedFrame : skimmedFrames) { - if (skimmedFrame.selMask[0] & trigger0Bit || skimmedFrame.selMask[1] & trigger1Bit) { - hTriggerCounter.Fill(2); - hBCSkimmed.Fill(1); - auto p1 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcAO2D == skimmedFrame.bcAO2D; }); - if (p1 != bcSet.end()) { - hBCSkimmed.Fill(2); - } - auto p2 = std::find_if(bcSet.begin(), bcSet.end(), [&](const auto& val) { return val.bcEvSel == skimmedFrame.bcEvSel; }); - if (p2 != bcSet.end()) { - hBCSkimmed.Fill(3); - } - bcTuple currentBC(skimmedFrame.bcAO2D, skimmedFrame.bcEvSel); - auto p3 = std::find(bcSet.begin(), bcSet.end(), currentBC); - if (p3 == bcSet.end()) { - bcSet.push_back(currentBC); - } else { - hBCSkimmed.Fill(4); - } + TH1D hOriginalTotal("hOriginalTotal", (runNumber + " Original;;Number of events").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hOriginalSingles("hOriginalSingles", (runNumber + " Original;;Number of singles").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hOriginalDoubles("hOriginalDoubles", (runNumber + " Original;;Number of doubles").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hOriginalMultiples("hOriginalMultiples", (runNumber + " Original;;Number of multiples").data(), sel_labels.size(), 0, sel_labels.size()); + + TH1D hSkimmedTotal("hSkimmedTotal", (runNumber + " Skimmed;;Number of events").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hSkimmedSingles("hSkimmedSingles", (runNumber + " Skimmed;;Number of singles").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hSkimmedDoubles("hSkimmedDoubles", (runNumber + " Skimmed;;Number of doubles").data(), sel_labels.size(), 0, sel_labels.size()); + TH1D hSkimmedMultiples("hSkimmedMultiples", (runNumber + " Skimmed;;Number of multiples").data(), sel_labels.size(), 0, sel_labels.size()); + + TH1D hTriggerMatchesRatio("hTriggerMatchesRatio", (runNumber + " Skimmed Efficiency;; Matched skimmed triggers / Original singles").data(), sel_labels.size(), 0, sel_labels.size()); // the ratio of triggers in skimmed dataset whose BC is compatible with original triggers to the number of original triggers, might be duplicate since we check it based on every trigger in unskimmed data + TH1D hTriggerSingleMatchesRatio("hTriggerSingleMatchesRatio", (runNumber + " Skimmed Efficiency;; One-to-one matches / Original singles").data(), sel_labels.size(), 0, sel_labels.size()); // the ratio of 1-1 paired triggers to the number of original triggers + TH1D hMatchesSameBCAO2DRatio("hMatchesSameBCAO2DRatio", (runNumber + " One-to-one matches;; Matchess with same BC_{AO2D} / Total").data(), sel_labels.size(), 0, sel_labels.size()); // In 1-1 matches, the ratio of matches who have same BCAO2D + TH1D hMatchesSameBCEvSelRatio("hMatchesSameBCEvSelRatio", (runNumber + " One-to-one matches;; Matches with same BC_{EvSel} / Total").data(), sel_labels.size(), 0, sel_labels.size()); // In 1-1 matches, the ratio of matches who have same BCEvSel + TH1D hDiffBCAO2D("hDiffBCAO2D", (runNumber + " One-to-one matches;;|#DeltaBC_{AO2D}|").data(), sel_labels.size(), 0, sel_labels.size()); // difference in BCAO2D of 1-1 matches + TH1D hDiffBCEvSel("hDiffBCEvSel", (runNumber + " One-to-one matches;;|#DeltaBC_{EvSel}|").data(), sel_labels.size(), 0, sel_labels.size()); // difference in BCEvSel of 1-1 matches + TH1D hDiffBC("hDiffBC", (runNumber + " One-to-one matches;;|#DeltaBC|").data(), sel_labels.size(), 0, sel_labels.size()); // difference between the BC tuple, expected to be 0 if bcDiffTolerance = 0 + TH1D hNumMatchesInSkimmed("hNumMatchesInSkimmed", (runNumber + " number of matched triggers in skimmed data;;Matched trigger count").data(), sel_labels.size(), 0, sel_labels.size()); // number of triggers in skimmed data which are compatible in the BC ranges of singles in original selection + + for (int i = 0; i < sel_labels.size(); i++) { + // Original data + hOriginalTotal.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hOriginalSingles.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hOriginalDoubles.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hOriginalMultiples.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + + hOriginalTotal.SetBinContent(i + 1, numOriginal[i]); + hOriginalTotal.SetBinError(i + 1, std::sqrt(numOriginal[i])); + hOriginalSingles.SetBinContent(i + 1, numOriginalSingle[i]); + hOriginalSingles.SetBinError(i + 1, std::sqrt(numOriginalSingle[i])); + hOriginalDoubles.SetBinContent(i + 1, numOriginalDouble[i]); + hOriginalDoubles.SetBinError(i + 1, std::sqrt(numOriginalDouble[i])); + hOriginalMultiples.SetBinContent(i + 1, numOriginalMultiple[i]); + hOriginalMultiples.SetBinError(i + 1, std::sqrt(numOriginalMultiple[i])); + + // Skimmed data + hSkimmedTotal.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hSkimmedSingles.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hSkimmedDoubles.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hSkimmedMultiples.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + + hSkimmedTotal.SetBinContent(i + 1, numSkimmed[i]); + hSkimmedTotal.SetBinError(i + 1, std::sqrt(numSkimmed[i])); + hSkimmedSingles.SetBinContent(i + 1, numSkimmedSingle[i]); + hSkimmedSingles.SetBinError(i + 1, std::sqrt(numSkimmedSingle[i])); + hSkimmedDoubles.SetBinContent(i + 1, numSkimmedDouble[i]); + hSkimmedDoubles.SetBinError(i + 1, std::sqrt(numSkimmedDouble[i])); + hSkimmedMultiples.SetBinContent(i + 1, numSkimmedMultiple[i]); + hSkimmedMultiples.SetBinError(i + 1, std::sqrt(numSkimmedMultiple[i])); + + // Matches QA + hTriggerMatchesRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hTriggerSingleMatchesRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hMatchesSameBCAO2DRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hMatchesSameBCEvSelRatio.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hDiffBCAO2D.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hDiffBCEvSel.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hDiffBC.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + hNumMatchesInSkimmed.GetXaxis()->SetBinLabel(i + 1, sel_labels[i].c_str()); + + if (numpair[i] > 0) { + hMatchesSameBCAO2DRatio.SetBinContent(i + 1, static_cast(numpairedBCAO2D[i]) / numpair[i]); + hMatchesSameBCEvSelRatio.SetBinContent(i + 1, static_cast(numpairedBCEvSel[i]) / numpair[i]); } + hTriggerMatchesRatio.SetBinContent(i + 1, numCloseSkimmed[i]); + hTriggerMatchesRatio.SetBinError(i + 1, std::sqrt(numCloseSkimmed[i])); + hTriggerSingleMatchesRatio.SetBinContent(i + 1, numpair[i]); + hTriggerSingleMatchesRatio.SetBinError(i + 1, std::sqrt(numpair[i])); + hDiffBCAO2D.SetBinContent(i + 1, avgDeltaBCAO2D[i]); + hDiffBCAO2D.SetBinError(i + 1, rmsDeltaBCAO2D[i]); + hDiffBCEvSel.SetBinContent(i + 1, avgDeltaBCEvSel[i]); + hDiffBCEvSel.SetBinError(i + 1, rmsDeltaBCEvSel[i]); + hDiffBC.SetBinContent(i + 1, avgDeltaBC[i]); + hDiffBC.SetBinError(i + 1, rmsDeltaBC[i]); + hNumMatchesInSkimmed.SetBinContent(i + 1, avgNumPairedTrigger[i]); + hNumMatchesInSkimmed.SetBinError(i + 1, rmsNumPairedTrigger[i]); } - TFile fout(outputFileName, "RECREATE"); + TH1D* hTriggerEff; // Ratio of the total number of triggers in skimmed data to that in original data (not the real efficiency since the downscalings are removed in skimmed for this QA) + TH1D *hOriginalSinglesRatio, *hOriginalDoublesRatio, *hOriginalMultiplesRatio; + TH1D *hSkimmedSinglesRatio, *hSkimmedDoublesRatio, *hSkimmedMultiplesRatio; + + hTriggerEff = reinterpret_cast(hSkimmedTotal.Clone("hTriggerEff")); + hTriggerEff->SetTitle((runNumber + " skimmed efficiency;; Skimmed / Original").data()); + hTriggerEff->Divide(&hOriginalTotal); + hTriggerMatchesRatio.Divide(&hOriginalSingles); + hTriggerSingleMatchesRatio.Divide(&hOriginalSingles); + hOriginalSinglesRatio = reinterpret_cast(hOriginalSingles.Clone("hOriginalSinglesRatio")); + hOriginalSinglesRatio->SetTitle((runNumber + " Original;;Singles / Total").data()); + hOriginalSinglesRatio->Divide(&hOriginalTotal); + hOriginalDoublesRatio = reinterpret_cast(hOriginalDoubles.Clone("hOriginalDoublesRatio")); + hOriginalDoublesRatio->SetTitle((runNumber + " Original;;Doubles / Total").data()); + hOriginalDoublesRatio->Divide(&hOriginalTotal); + hOriginalMultiplesRatio = reinterpret_cast(hOriginalMultiples.Clone("hOriginalMultiplesRatio")); + hOriginalMultiplesRatio->SetTitle((runNumber + " Original;;Multiples / Total").data()); + hOriginalMultiplesRatio->Divide(&hOriginalTotal); + + hSkimmedSinglesRatio = reinterpret_cast(hSkimmedSingles.Clone("hSkimmedSinglesRatio")); + hSkimmedSinglesRatio->SetTitle((runNumber + " Skimmed;;Singles / Total").data()); + hSkimmedSinglesRatio->Divide(&hSkimmedTotal); + hSkimmedDoublesRatio = reinterpret_cast(hSkimmedDoubles.Clone("hSkimmedDoublesRatio")); + hSkimmedDoublesRatio->SetTitle((runNumber + " Skimmed;;Doubles / Total").data()); + hSkimmedDoublesRatio->Divide(&hSkimmedTotal); + hSkimmedMultiplesRatio = reinterpret_cast(hSkimmedMultiples.Clone("hSkimmedMultiplesRatio")); + hSkimmedMultiplesRatio->SetTitle((runNumber + " Skimmed;;Multiples / Total").data()); + hSkimmedMultiplesRatio->Divide(&hSkimmedTotal); + + TFile fout(outputFileName, "UPDATE"); fout.cd(); - hTriggerCounter.Write(); - hBCOriginal.Write(); - hBCSkimmed.Write(); - hNumCounter.Write(); - hPairedTriggerCounter.Write(); - hSinglePairCheck.Write(); - hBCDiffAO2D.Write(); - hBCDiffEvSel.Write(); - hMultiPairCheck.Write(); + TDirectory* dir = fout.mkdir(runNumber.data()); + dir->cd(); + hTriggerEff->Write(); + hTriggerMatchesRatio.Write(); + hTriggerSingleMatchesRatio.Write(); + hDiffBCAO2D.Write(); + hDiffBCEvSel.Write(); + hNumMatchesInSkimmed.Write(); + if (bcDiffTolerance > 0) { + hDiffBC.Write(); + } + TDirectory* dirextra = dir->mkdir("ExtraQA"); + dirextra->cd(); + hOriginalTotal.Write(); + hOriginalSingles.Write(); + hOriginalDoubles.Write(); + hOriginalMultiples.Write(); + hOriginalSinglesRatio->Write(); + hOriginalDoublesRatio->Write(); + hOriginalMultiplesRatio->Write(); + hSkimmedTotal.Write(); + hSkimmedSingles.Write(); + hSkimmedDoubles.Write(); + hSkimmedMultiples.Write(); + hSkimmedSinglesRatio->Write(); + hSkimmedDoublesRatio->Write(); + hSkimmedMultiplesRatio->Write(); + hMatchesSameBCAO2DRatio.Write(); + hMatchesSameBCEvSelRatio.Write(); fout.Close(); + + // Do checks for trigger + for (int trgID = 0; trgID < labels.size(); trgID++) { + // if (trgID == 77 || trgID == 78 || trgID == 79) { + // checkBCForSelectedTrg(originalAllFrames[trgID], skimmedAllFrames[trgID], runNumber, labels[trgID]); + //} + } } diff --git a/EventFiltering/macros/selectivityPlot.C b/EventFiltering/macros/selectivityPlot.C new file mode 100644 index 00000000000..56215bcd3e6 --- /dev/null +++ b/EventFiltering/macros/selectivityPlot.C @@ -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. + +void selectivityPlot(int runNumber = 550781, TString inputfile = "AnalysisResults_550781.root", TString outputfolder = "") +{ + TCanvas* Canvas_1 = new TCanvas("Canvas_1", "Canvas_1", 928, 592); + gStyle->SetOptFit(0); + gStyle->SetOptStat(0); + Canvas_1->Range(-6.079755, -8.734506, 67.09509, -2.808365); + Canvas_1->SetFillColor(0); + Canvas_1->SetBorderMode(0); + Canvas_1->SetBorderSize(2); + Canvas_1->SetLogy(); + Canvas_1->SetGridx(); + Canvas_1->SetGridy(); + Canvas_1->SetTickx(1); + Canvas_1->SetTicky(1); + Canvas_1->SetLeftMargin(0.08991826); + Canvas_1->SetRightMargin(0.02179836); + Canvas_1->SetTopMargin(0.05); + Canvas_1->SetBottomMargin(0.2711864); + Canvas_1->SetFrameBorderMode(0); + Canvas_1->SetFrameBorderMode(0); + + TFile* file = new TFile(inputfile.Data()); + TH1D* mFiltered = (TH1D*)file->Get("central-event-filter-task/scalers/mFiltered"); + double nEvents = mFiltered->GetBinContent(1); + mFiltered->Scale(1. / nEvents); + mFiltered->SetLineColor(2); + mFiltered->SetLineWidth(2); + mFiltered->SetMarkerColor(2); + mFiltered->SetMarkerStyle(4); + mFiltered->SetMarkerSize(0.6); + mFiltered->GetXaxis()->SetRange(2, mFiltered->GetXaxis()->GetNbins()); + for (int i = 1; i <= mFiltered->GetNbinsX(); i++) { + std::string label = mFiltered->GetXaxis()->GetBinLabel(i); + if (label[0] == 'f') { + mFiltered->GetXaxis()->SetBinLabel(i, label.substr(1).c_str()); + } + mFiltered->SetBinContent(i, mFiltered->GetBinContent(i) / mFiltered->GetBinContent(1)); + mFiltered->SetBinError(i, mFiltered->GetBinError(i) / mFiltered->GetBinContent(1)); + } + mFiltered->GetXaxis()->SetBinLabel(mFiltered->GetNbinsX(), "Total"); + mFiltered->GetXaxis()->SetLabelFont(42); + mFiltered->GetXaxis()->SetTitleOffset(1); + mFiltered->GetXaxis()->SetTitleFont(42); + mFiltered->GetYaxis()->SetTitle("Async. trigger selectivity"); + mFiltered->GetYaxis()->SetLabelFont(42); + mFiltered->GetYaxis()->SetTitleFont(42); + mFiltered->GetZaxis()->SetLabelFont(42); + mFiltered->GetZaxis()->SetTitleOffset(1); + mFiltered->GetZaxis()->SetTitleFont(42); + mFiltered->DrawClone(""); + TLine* line = new TLine(mFiltered->GetXaxis()->GetBinLowEdge(2), 5.e-05, mFiltered->GetXaxis()->GetBinLowEdge(mFiltered->GetNbinsX()), 5.e-05); + line->SetLineStyle(2); + line->Draw(); + TArrow* arrow = new TArrow(mFiltered->GetXaxis()->GetXmax(), 0.0005, mFiltered->GetXaxis()->GetXmax() + 1, 0.0005, 0.01, "<|"); + + Int_t ci; // for color index setting + TColor* color; // for color definition with alpha + ci = TColor::GetColor("#0000ff"); + arrow->SetFillColor(ci); + arrow->SetFillStyle(1001); + TLatex* tex = new TLatex(); + tex->SetTextSize(0.035); + tex->SetTextFont(42); + tex->DrawLatexNDC(0.09, 0.96, Form("ALICE Internal, pp #sqrt{s} = 13.6 TeV, Run %d, #it{L}_{int} #approx %.1f nb^{-1}", runNumber, nEvents / 78.e6)); + ci = TColor::GetColor("#0000ff"); + arrow->SetLineColor(ci); + arrow->Draw(); + Canvas_1->Modified(); + Canvas_1->SetSelected(Canvas_1); + + if (outputfolder.IsNull()) { + return; + } + gROOT->SetBatch(true); + TCanvas Canvas_2("Canvas_2", "Canvas_2", Canvas_1->GetWw() * 2, Canvas_1->GetWh() * 2); + Canvas_1->DrawClonePad(); + Canvas_2.SaveAs(Form("%s/asyncTriggerSelectivity_%d.png", outputfolder.Data(), runNumber)); + gROOT->SetBatch(false); +} diff --git a/EventFiltering/macros/uploadOTSobjects.C b/EventFiltering/macros/uploadOTSobjects.C index 5f3f076c90c..77b6ac97f34 100644 --- a/EventFiltering/macros/uploadOTSobjects.C +++ b/EventFiltering/macros/uploadOTSobjects.C @@ -16,26 +16,34 @@ #include #include #include +#include -#include #include "TFile.h" -#include "TKey.h" +#include "TGrid.h" #include "TH1.h" +#include "TKey.h" +#include "TSystem.h" +#include "TTree.h" #include "CCDB/BasicCCDBManager.h" +#include "EventFiltering/ZorroHelper.h" +#include "CommonConstants/LHCConstants.h" -const std::string kBaseCCDBPath = "Users/r/rlietava/EventFiltering/OTS/"; +constexpr uint32_t chunkSize = 1000000; -#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ; -struct bcInfo { - bcInfo() = default; - ULong64_t bcAOD, bcEvSel, trigMask, selMask; - void print() const; -}; -void uploadOTSobjects(std::string inputList) +void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien, bool chunkedProcessing) { + const std::string kBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/"; + std::string baseCCDBpath = passName.empty() ? kBaseCCDBPath : kBaseCCDBPath + passName + "/"; + if (chunkedProcessing) { + baseCCDBpath += "Chunked/"; + } + if (useAlien) { + TGrid::Connect("alien://"); + } o2::ccdb::CcdbApi api; api.init("http://alice-ccdb.cern.ch"); + auto& ccdb = o2::ccdb::BasicCCDBManager::instance(); std::ifstream file(inputList.data()); std::string path; @@ -47,44 +55,88 @@ void uploadOTSobjects(std::string inputList) const int runNumber = std::stoi(runString); metadata["runNumber"] = runString; std::pair duration = o2::ccdb::BasicCCDBManager::getRunDuration(api, runNumber); - duration.first -= 10000; // subtract 3 minutes from the run start - duration.second += 180000; // add 3 minutes to the run duration - TFile scalersFile((path + "/AnalysisResults_fullrun.root").data(), "READ"); - TH1* scalers = (TH1*)scalersFile.Get("central-event-filter-task/scalers/mScalers"); - TH1* filters = (TH1*)scalersFile.Get("central-event-filter-task/scalers/mFiltered"); - api.storeAsTFile(scalers, kBaseCCDBPath + "FilterCounters", metadata, duration.first, duration.second); - api.storeAsTFile(filters, kBaseCCDBPath + "SelectionCounters", metadata, duration.first, duration.second); - TH1* hCounterTVX = (TH1*)scalersFile.Get("bc-selection-task/hCounterTVX"); - api.storeAsTFile(hCounterTVX, kBaseCCDBPath + "InspectedTVX", metadata, duration.first, duration.second); + duration.first -= 60000; // subtract 1 minutes from the run start + duration.second += 60000; // add 1 minutes to the run duration + std::cout << ">>> Begin - end timestamps for the upload: " << duration.first << " - " << duration.second << std::endl; + auto ctp = ccdb.getForTimeStamp>("CTP/Calib/OrbitReset", duration.first / 2 + duration.second / 2); + auto orbitResetTimestamp = (*ctp)[0]; + path = useAlien ? "alien://" + path : path; + 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); + TH1* hCounterTVX = static_cast(scalersFile->Get("bc-selection-task/hCounterTVX")); + api.storeAsTFile(hCounterTVX, baseCCDBpath + "InspectedTVX", metadata, duration.first, duration.second); - std::vector> bcRanges, filterBitMask, selectionBitMask; - TFile bcRangesFile((path + "/bcRanges_fullrun.root").data(), "READ"); + std::vector zorroHelpers; + std::unique_ptr bcRangesFile{TFile::Open((path + "/bcRanges_fullrun.root").data(), "READ")}; int Nmax = 0; - for (auto key : *(bcRangesFile.GetListOfKeys())) { - TTree* cefpTree = (TTree*)bcRangesFile.Get(Form("%s/selectedBC", key->GetName())); + for (auto key : *(bcRangesFile->GetListOfKeys())) { + TTree* cefpTree = static_cast(bcRangesFile->Get(Form("%s/selectedBC", key->GetName()))); if (!cefpTree) continue; - bcInfo bci; + ZorroHelper bci; cefpTree->SetBranchAddress("bcAO2D", &bci.bcAOD); cefpTree->SetBranchAddress("bcEvSel", &bci.bcEvSel); - cefpTree->SetBranchAddress("selMask", &bci.selMask); - cefpTree->SetBranchAddress("triMask", &bci.trigMask); + if (cefpTree->GetBranch("selMask") && cefpTree->GetBranch("triMask")) { + cefpTree->SetBranchAddress("selMask", &bci.selMask[0]); + cefpTree->SetBranchAddress("triMask", &bci.trigMask[0]); + } else { + cefpTree->SetBranchAddress("selMask0", &bci.selMask[0]); + cefpTree->SetBranchAddress("triMask0", &bci.trigMask[0]); + cefpTree->SetBranchAddress("selMask1", &bci.selMask[1]); + cefpTree->SetBranchAddress("triMask1", &bci.trigMask[1]); + } for (int i = 0; i < cefpTree->GetEntries(); i++) { if ((i < Nmax) || (Nmax == 0)) { cefpTree->GetEntry(i); - // Check consistency - if (~bci.trigMask & bci.selMask) { - std::cout << "ERROR selMask is not subset of trigMask:"; - // bcAO2D.print(); + zorroHelpers.push_back(bci); + } + } + } + std::sort(zorroHelpers.begin(), zorroHelpers.end(), [](const ZorroHelper& a, const ZorroHelper& b) { + return a.bcAOD < b.bcAOD; + }); + if (!chunkedProcessing) { + api.storeAsTFileAny(&zorroHelpers, baseCCDBpath + "ZorroHelpers", metadata, duration.first, duration.second); + std::cout << std::endl; + } else { + uint32_t helperIndex{0}; + auto startTS = duration.first; + int64_t endTS = 0; + while (helperIndex < zorroHelpers.size()) { + std::vector chunk; + uint32_t endIndex = helperIndex + chunkSize; + while (true) { + if (endIndex >= zorroHelpers.size() - 2) { + endTS = duration.second; + chunk.insert(chunk.begin(), zorroHelpers.begin() + helperIndex, zorroHelpers.end()); + break; + } + auto bcEnd{zorroHelpers[endIndex].bcAOD > zorroHelpers[endIndex].bcEvSel ? zorroHelpers[endIndex].bcAOD : zorroHelpers[endIndex].bcEvSel}; + const auto& nextHelper = zorroHelpers[endIndex + 1]; + auto bcNext{nextHelper.bcAOD < nextHelper.bcEvSel ? nextHelper.bcAOD : nextHelper.bcEvSel}; + if (bcNext - bcEnd > 2001 / o2::constants::lhc::LHCBunchSpacingMUS) { /// ensure a gap of 2ms between chunks + chunk.insert(chunk.begin(), zorroHelpers.begin() + helperIndex, zorroHelpers.begin() + endIndex + 1); + endTS = (orbitResetTimestamp + int64_t(bcEnd * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000 + 1; + break; } - bcRanges.push_back({bci.bcAOD, bci.bcEvSel}); - filterBitMask.push_back({bci.trigMask, 0ull}); - selectionBitMask.push_back({bci.selMask, 0ull}); + bcEnd = nextHelper.bcAOD > nextHelper.bcEvSel ? nextHelper.bcAOD : nextHelper.bcEvSel; + 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); + startTS = endTS + 1; + helperIndex += chunk.size(); } } - api.storeAsTFileAny(&bcRanges, kBaseCCDBPath + "SelectedBCs", metadata, duration.first, duration.second); - api.storeAsTFileAny(&filterBitMask, kBaseCCDBPath + "FilterBitMasks", metadata, duration.first, duration.second); - api.storeAsTFileAny(&selectionBitMask, kBaseCCDBPath + "SelectionBitMasks", metadata, duration.first, duration.second); } } + +void uploadOTSobjects(std::string periodName, bool chunkedProcessing) +{ + int year = 2000 + std::stoi(periodName.substr(3, 2)); + gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root | sed 's:/AnalysisResults_fullrun\\.root::' > list_%s.txt", year, periodName.data(), periodName.data())); + uploadOTSobjects(Form("list_%s.txt", periodName.data()), "", true, chunkedProcessing); +} diff --git a/EventFiltering/selectBCRange.cxx b/EventFiltering/selectBCRange.cxx index eabdb3db004..8a2d200e8e6 100644 --- a/EventFiltering/selectBCRange.cxx +++ b/EventFiltering/selectBCRange.cxx @@ -49,13 +49,13 @@ struct BCRangeSelector { void run(ProcessingContext& pc) { - auto bcConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto bcConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto bcTable{bcConsumer->asArrowTable()}; - auto collConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto collConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto collTable{collConsumer->asArrowTable()}; - auto evSelConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto evSelConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto evSelTable{evSelConsumer->asArrowTable()}; - auto cefpConsumer = pc.inputs().get(aod::MetadataTrait>::metadata::tableLabel()); + auto cefpConsumer = pc.inputs().get(o2::soa::getTableLabel()); auto cefpTable{cefpConsumer->asArrowTable()}; auto bcs = aod::BCs({bcTable}); diff --git a/PWGCF/DataModel/FemtoDerived.h b/PWGCF/DataModel/FemtoDerived.h index 082527cb5ef..ab9708cbaae 100644 --- a/PWGCF/DataModel/FemtoDerived.h +++ b/PWGCF/DataModel/FemtoDerived.h @@ -166,11 +166,15 @@ DECLARE_SOA_COLUMN(TPCNSigmaPi, tpcNSigmaPi, float); //! Nsigma separation with 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(TOFNSigmaEl, tofNSigmaEl, float); //! Nsigma separation with the TPC detector for electron -DECLARE_SOA_COLUMN(TOFNSigmaPi, tofNSigmaPi, float); //! Nsigma separation with the TPC detector for pion -DECLARE_SOA_COLUMN(TOFNSigmaKa, tofNSigmaKa, float); //! Nsigma separation with the TPC detector for kaon -DECLARE_SOA_COLUMN(TOFNSigmaPr, tofNSigmaPr, float); //! Nsigma separation with the TPC detector for proton -DECLARE_SOA_COLUMN(TOFNSigmaDe, tofNSigmaDe, 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(TOFNSigmaEl, tofNSigmaEl, float); //! Nsigma separation with the TOF detector for electron +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(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 @@ -206,7 +210,7 @@ DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int8_t); //! Selectio DECLARE_SOA_COLUMN(BDTBkg, bdtBkg, float); //! Background score using Boosted Decision Tree for charm hadron DECLARE_SOA_COLUMN(BDTPrompt, bdtPrompt, float); //! Prompt signal score using Boosted Decision Tree for charm hadron DECLARE_SOA_COLUMN(BDTFD, bdtFD, float); //! Feed-down score using Boosted Decision Tree for charm hadron -DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); //! To select MC particle among charm hadrons, { DplusToPiKPi = 0, LcToPKPi = 2, DsToKKPi = 4, XicToPKP = 8, N3ProngD = 2ecays }; +DECLARE_SOA_COLUMN(FlagMc, flagMc, int8_t); //! To select MC particle among charm hadrons, { DplusToPiKPi = 1, LcToPKPi = 2, DsToKKPi = 4, XicToPKP = 8, N3ProngD = 2ecays }; 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) @@ -218,7 +222,7 @@ DECLARE_SOA_COLUMN(CharmM, charmM, float); //! Charm ha DECLARE_SOA_COLUMN(CharmPt, charmPt, float); //! Transverse momentum 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(PartPairSign, partPairSign, int8_t); //! Selection between ++ (1), and -- pair (2) +DECLARE_SOA_COLUMN(PairSign, pairSign, int8_t); //! Selection between like sign (1) and unlike sign pair (2) DECLARE_SOA_COLUMN(ProcessType, processType, int64_t); //! Selection between same-event (1), and mixed-event (2) DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! [](float pt0, float phi0, float eta0, float pt1, float phi1, float eta1, float pt2, float phi2, float eta2, const std::array& m) -> float { return RecoDecay::m(std::array{ @@ -294,8 +298,11 @@ DECLARE_SOA_TABLE(FDResultsHF, "AOD", "FDRESULTSHF", //! table to store results fdhf::MT, fdhf::Mult, fdhf::MultPercentile, - fdhf::PartPairSign, - fdhf::ProcessType); + fdhf::Charge, + fdhf::PairSign, + fdhf::ProcessType, + fdhf::FlagMc, + fdhf::OriginMcRec); DECLARE_SOA_TABLE(FDHfCandMC, "AOD", "FDHFCANDMC", //! Table for reconstructed MC charm hadron candidates o2::soa::Index<>, @@ -343,11 +350,15 @@ DECLARE_SOA_TABLE(FDExtParticles, "AOD", "FDEXTPARTICLE", femtodreamparticle::TPCNSigmaKa, femtodreamparticle::TPCNSigmaPr, femtodreamparticle::TPCNSigmaDe, + femtodreamparticle::TPCNSigmaTr, + femtodreamparticle::TPCNSigmaHe, femtodreamparticle::TOFNSigmaEl, femtodreamparticle::TOFNSigmaPi, femtodreamparticle::TOFNSigmaKa, femtodreamparticle::TOFNSigmaPr, femtodreamparticle::TOFNSigmaDe, + femtodreamparticle::TOFNSigmaTr, + femtodreamparticle::TOFNSigmaHe, femtodreamparticle::DaughDCA, femtodreamparticle::TransRadius, femtodreamparticle::DecayVtxX, @@ -440,8 +451,8 @@ namespace hash { DECLARE_SOA_COLUMN(Bin, bin, int); //! Hash for the event mixing } // namespace hash -DECLARE_SOA_TABLE(Hashes, "AOD", "HASH", hash::Bin); -using Hash = Hashes::iterator; +DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin); +using MixingHash = MixingHashes::iterator; } // namespace o2::aod diff --git a/PWGCF/DataModel/SPTableZDC.h b/PWGCF/DataModel/SPTableZDC.h new file mode 100644 index 00000000000..fcafff23c90 --- /dev/null +++ b/PWGCF/DataModel/SPTableZDC.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 SPTableZDC.h + +#ifndef PWGCF_DATAMODEL_SPTABLEZDC_H_ +#define PWGCF_DATAMODEL_SPTABLEZDC_H_ + +#include + +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace sptablezdc +{ +DECLARE_SOA_COLUMN(Runnumber, runnumber, int); +DECLARE_SOA_COLUMN(Cent, cent, float); +DECLARE_SOA_COLUMN(Vx, vx, float); +DECLARE_SOA_COLUMN(Vy, vy, float); +DECLARE_SOA_COLUMN(Vz, vz, float); +DECLARE_SOA_COLUMN(QXA, qxA, float); +DECLARE_SOA_COLUMN(QYA, qyA, float); +DECLARE_SOA_COLUMN(QXC, qxC, float); +DECLARE_SOA_COLUMN(QYC, qyC, float); +DECLARE_SOA_COLUMN(IsSelected, isSelected, bool); +DECLARE_SOA_COLUMN(Iteration, iteration, int); +DECLARE_SOA_COLUMN(Step, step, int); + +} // namespace sptablezdc + +DECLARE_SOA_TABLE(SPTableZDC, "AOD", "SPZDC", + sptablezdc::Runnumber, + sptablezdc::Cent, + sptablezdc::Vx, + sptablezdc::Vy, + sptablezdc::Vz, + sptablezdc::QXA, + sptablezdc::QYA, + sptablezdc::QXC, + sptablezdc::QYC, + sptablezdc::IsSelected, + sptablezdc::Iteration, + sptablezdc::Step); +} // namespace o2::aod +#endif // PWGCF_DATAMODEL_SPTABLEZDC_H_ diff --git a/PWGCF/EbyEFluctuations/Tasks/FactorialMomentsTask.cxx b/PWGCF/EbyEFluctuations/Tasks/FactorialMomentsTask.cxx index 1818380b853..c76556ec26f 100644 --- a/PWGCF/EbyEFluctuations/Tasks/FactorialMomentsTask.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/FactorialMomentsTask.cxx @@ -16,6 +16,7 @@ #include #include #include +#include "TRandom.h" // O2 includes #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" @@ -28,24 +29,30 @@ #include "ReconstructionDataFormats/GlobalTrackID.h" #include "ReconstructionDataFormats/Track.h" #include "Framework/ASoAHelpers.h" - using std::array; using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; - struct FactorialMoments { - - Configurable confEta{"centralEta", 0.8, "eta limit for tracks"}; + Configurable confEta{"centralEta", 0.9, "eta limit for tracks"}; Configurable confNumPt{"numPt", 1, "number of pT bins"}; Configurable confPtMin{"ptMin", 0.2f, "lower pT cut"}; Configurable confDCAxy{"dcaXY", 2.4f, "DCA xy cut"}; - Configurable confDCAz{"dcaZ", 3.2f, "DCA z cut"}; + Configurable confDCAz{"dcaZ", 2.0f, "DCA z cut"}; Configurable confMinTPCCls{"minTPCCls", 70.0f, "minimum number of TPC clusters"}; Configurable> confCentCut{"centLimits", {0, 5}, "centrality min and max"}; Configurable> confVertex{"vertexXYZ", {0.3f, 0.4f, 10.0f}, "vertex cuts"}; Configurable> confPtBins{"ptCuts", {0.2f, 2.0f}, "pT cuts"}; - + Configurable IsApplySameBunchPileup{"IsApplySameBunchPileup", true, "Enable SameBunchPileup cut"}; + Configurable IsApplyGoodZvtxFT0vsPV{"IsApplyGoodZvtxFT0vsPV", true, "Enable GoodZvtxFT0vsPV cut"}; + Configurable IsApplyVertexITSTPC{"IsApplyVertexITSTPC", true, "Enable VertexITSTPC cut"}; + Configurable IsApplyVertexTOFmatched{"IsApplyVertexTOFmatched", true, "Enable VertexTOFmatched cut"}; + Configurable IsApplyVertexTRDmatched{"IsApplyVertexTRDmatched", true, "Enable VertexTRDmatched cut"}; + Configurable IsApplyExtraCorrCut{"IsApplyExtraCorrCut", false, "Enable extra NPVtracks vs FTOC correlation cut"}; + Configurable IsApplyExtraPhiCut{"IsApplyExtraPhiCut", false, "Enable extra phi cut"}; + Configurable includeGlobalTracks{"includeGlobalTracks", false, "Enable Global Tracks"}; + Configurable includeTPCTracks{"includeTPCTracks", false, "TPC Tracks"}; + Configurable includeITSTracks{"includeITSTracks", false, "ITS Tracks"}; Filter filterTracks = (nabs(aod::track::eta) < confEta) && (aod::track::pt >= confPtMin) && (nabs(aod::track::dcaXY) < confDCAxy) && (nabs(aod::track::dcaZ) < confDCAz); Filter filterCollisions = (nabs(aod::collision::posZ) < confVertex.value[2]) && (nabs(aod::collision::posX) < confVertex.value[0]) && (nabs(aod::collision::posY) < confVertex.value[1]); @@ -71,9 +78,11 @@ struct FactorialMoments { {"mChi2TPC", "chi2 TPC", {HistType::kTH1F, {{100, 0, 10}}}}, {"mChi2ITS", "chi2 ITS", {HistType::kTH1F, {{100, 0, 10}}}}, {"mChi2TRD", "chi2 TRD", {HistType::kTH1F, {{100, 0, 100}}}}, - {"mDCAxy", "DCA xy", {HistType::kTH1F, {{100, -0.8, 0.8}}}}, - {"mDCAx", "DCA z", {HistType::kTH1F, {{100, -2.0, 2.0}}}}, - {"mDCAxyPt", "DCA xy vs #pt;#pt;DCAxy", {HistType::kTH2F, {{100, 0, 20}, {100, -0.5, 0.5}}}}, + {"mDCAxy", "DCA xy", {HistType::kTH1F, {{500, -0.8, 0.8}}}}, + {"mDCAx", "DCA z", {HistType::kTH1F, {{500, -2.0, 2.0}}}}, + {"mDCAxyPt", "DCA xy vs #pt;#pt;DCAxy", {HistType::kTH2F, {{100, 0, 20}, {500, -0.5, 0.5}}}}, + {"mDCAxyPtbcut", "DCA xy vs #pt;#pt;DCAxycut", {HistType::kTH2F, {{100, 0, 20}, {500, -0.5, 0.5}}}}, + {"mDCAzPtbcut", "DCA z vs #pt;#pt;DCAzcut", {HistType::kTH2F, {{100, 0, 20}, {100, -2.0, 2.0}}}}, {"mDCAzPt", "DCA z vs #pt;#pt;DCAz", {HistType::kTH2F, {{100, 0, 20}, {100, -2.0, 2.0}}}}, {"mNSharedClsTPC", "shared clusters in TPC", {HistType::kTH1F, {{100, 0, 10}}}}, {"mCrossedRowsTPC", "crossedrows in TPC", {HistType::kTH1F, {{100, 0, 200}}}}, @@ -95,7 +104,6 @@ struct FactorialMoments { std::vector> mBinConFinal; // max number of bins restricted to 5 static constexpr array mbinNames{"bin1/", "bin2/", "bin3/", "bin4/", "bin5/"}; - void init(o2::framework::InitContext&) { // NOTE: check to make number of pt and the vector consistent @@ -127,15 +135,21 @@ struct FactorialMoments { } } } - template void checkpT(const T& track) { for (auto iPt = 0; iPt < confNumPt; ++iPt) { if (track.pt() > confPtBins.value[2 * iPt] && track.pt() < confPtBins.value[2 * iPt + 1]) { + float iphi = track.phi(); + iphi = gRandom->Gaus(iphi, TMath::TwoPi()); + if (iphi < 0) { + iphi += TMath::TwoPi(); + } else if (iphi > TMath::TwoPi()) { + iphi -= TMath::TwoPi(); + } mHistArrQA[iPt * 4]->Fill(track.eta()); mHistArrQA[iPt * 4 + 1]->Fill(track.pt()); - mHistArrQA[iPt * 4 + 2]->Fill(track.phi()); + mHistArrQA[iPt * 4 + 2]->Fill(iphi); countTracks[iPt]++; for (auto iM = 0; iM < nBins; ++iM) { mHistArrReset[iPt * nBins + iM]->Fill(track.eta(), track.phi()); @@ -143,7 +157,6 @@ struct FactorialMoments { } } } - void calculateMoments(std::vector> hist) { Double_t binContent = 0; @@ -179,7 +192,7 @@ struct FactorialMoments { mBinConFinal[iPt * 6 + iOrder]->Fill(iM, binConEvent[iPt][iM]); } } // end of loop over M bins - } // end of loop over pT bins + } // end of loop over pT bins } using TracksFMs = soa::Filtered>; @@ -189,6 +202,15 @@ struct FactorialMoments { if (!coll.sel8()) { return; } + if (IsApplySameBunchPileup && !coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return; + } + if (IsApplyGoodZvtxFT0vsPV && !coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return; + } + if (IsApplyVertexITSTPC && !coll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return; + } if (coll.centFT0C() < confCentCut.value[0] || coll.centFT0C() > confCentCut.value[1]) { return; } @@ -199,42 +221,39 @@ struct FactorialMoments { histos.fill(HIST("mCentFV0A"), coll.centFV0A()); histos.fill(HIST("mCentFT0A"), coll.centFT0A()); histos.fill(HIST("mCentFT0C"), coll.centFT0C()); - for (auto const& h : mHistArrReset) { h->Reset(); } - countTracks = {0, 0, 0, 0, 0}; fqEvent = {{{{{0, 0, 0, 0, 0, 0}}}}}; binConEvent = {{{0, 0, 0, 0, 0}}}; - for (auto const& track : tracks) { - if ((track.pt() < confPtMin) || (!track.isGlobalTrack()) || (track.tpcNClsFindable() < confMinTPCCls)) { - continue; + if (track.hasTPC()) { + histos.fill(HIST("mCollID"), track.collisionId()); + histos.fill(HIST("mEta"), track.eta()); + histos.fill(HIST("mPt"), track.pt()); + histos.fill(HIST("mPhi"), track.phi()); + histos.fill(HIST("mNFindableClsTPC"), track.tpcNClsFindable()); + histos.fill(HIST("mNClsTPC"), track.tpcNClsFound()); + histos.fill(HIST("mNClsITS"), track.itsNCls()); + histos.fill(HIST("mChi2TPC"), track.tpcChi2NCl()); + histos.fill(HIST("mChi2ITS"), track.itsChi2NCl()); + histos.fill(HIST("mChi2TRD"), track.trdChi2()); + histos.fill(HIST("mDCAxy"), track.dcaXY()); + histos.fill(HIST("mDCAx"), track.dcaZ()); + histos.fill(HIST("mDCAxyPt"), track.pt(), track.dcaXY()); + histos.fill(HIST("mDCAzPt"), track.pt(), track.dcaZ()); + histos.fill(HIST("mNSharedClsTPC"), track.tpcNClsShared()); + histos.fill(HIST("mCrossedRowsTPC"), track.tpcNClsCrossedRows()); + histos.fill(HIST("mNFinClsminusCRows"), track.tpcNClsFindableMinusCrossedRows()); + histos.fill(HIST("mNFractionShClsTPC"), track.tpcFractionSharedCls()); + histos.fill(HIST("mSharedClsvsPt"), track.pt(), track.tpcNClsShared()); + histos.fill(HIST("mSharedClsProbvsPt"), track.pt(), track.tpcFractionSharedCls() / track.tpcNClsCrossedRows()); + checkpT(track); } - histos.fill(HIST("mCollID"), track.collisionId()); - histos.fill(HIST("mEta"), track.eta()); - histos.fill(HIST("mPt"), track.pt()); - histos.fill(HIST("mPhi"), track.phi()); - histos.fill(HIST("mNFindableClsTPC"), track.tpcNClsFindable()); - histos.fill(HIST("mNClsTPC"), track.tpcNClsFound()); - histos.fill(HIST("mNClsITS"), track.itsNCls()); - histos.fill(HIST("mChi2TPC"), track.tpcChi2NCl()); - histos.fill(HIST("mChi2ITS"), track.itsChi2NCl()); - histos.fill(HIST("mChi2TRD"), track.trdChi2()); - histos.fill(HIST("mDCAxy"), track.dcaXY()); - histos.fill(HIST("mDCAx"), track.dcaZ()); - histos.fill(HIST("mDCAxyPt"), track.pt(), track.dcaXY()); - histos.fill(HIST("mDCAzPt"), track.pt(), track.dcaZ()); - histos.fill(HIST("mNSharedClsTPC"), track.tpcNClsShared()); - histos.fill(HIST("mCrossedRowsTPC"), track.tpcNClsCrossedRows()); - histos.fill(HIST("mNFinClsminusCRows"), track.tpcNClsFindableMinusCrossedRows()); - histos.fill(HIST("mNFractionShClsTPC"), track.tpcFractionSharedCls()); - histos.fill(HIST("mSharedClsvsPt"), track.pt(), track.tpcNClsShared()); - histos.fill(HIST("mSharedClsProbvsPt"), track.pt(), track.tpcFractionSharedCls() / track.tpcNClsCrossedRows()); - checkpT(track); } for (auto iPt = 0; iPt < confNumPt; ++iPt) { + // if (countTracks[iPt] > 0) if (countTracks[iPt] > 0) { mHistArrQA[iPt * 4 + 3]->Fill(countTracks[iPt]); } @@ -242,7 +261,7 @@ struct FactorialMoments { // Calculate the normalized factorial moments calculateMoments(mHistArrReset); } - PROCESS_SWITCH(FactorialMoments, processRun3, "main process function", false); + PROCESS_SWITCH(FactorialMoments, processRun3, "main process function", true); void processRun2(soa::Filtered>::iterator const& coll, TracksFMs const& tracks) { diff --git a/PWGCF/EbyEFluctuations/Tasks/MeanPtFlucIdentified.cxx b/PWGCF/EbyEFluctuations/Tasks/MeanPtFlucIdentified.cxx index b61c8de928d..cda9e3ebd83 100644 --- a/PWGCF/EbyEFluctuations/Tasks/MeanPtFlucIdentified.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/MeanPtFlucIdentified.cxx @@ -29,59 +29,69 @@ #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" +#include "Common/Core/RecoDecay.h" -#include "TDatabasePDG.h" -#include "TLorentzVector.h" +#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; using namespace std; -double massPi = TDatabasePDG::Instance()->GetParticle(211)->Mass(); -double massKa = TDatabasePDG::Instance()->GetParticle(321)->Mass(); -double massPr = TDatabasePDG::Instance()->GetParticle(2212)->Mass(); - struct meanPtFlucId { Configurable nPtBins{"nPtBins", 300, ""}; Configurable nPartBins{"nPartBins", 250, ""}; Configurable nCentBins{"nCentBins", 101, ""}; Configurable nEtaBins{"nEtaBins", 100, ""}; - Configurable nTpNBins{"nTpNBins", 200, ""}; - Configurable nTpDBins{"nTpDBins", 100, ""}; - Configurable cfgCutPtMax{"cfgCutPtMax", 2.0, "maximum pT"}; + Configurable nPhiBins{"nPhiBins", 100, ""}; + Configurable cfgCutPtMax{"cfgCutPtMax", 3.0, "maximum pT"}; Configurable cfgCutPtMin{"cfgCutPtMin", 0.15, "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 cfgCutNSigTpcEl{"cfgCutNSigTpcEl", 1.5, "TPC nSigma Electron veto cut"}; - Configurable cfgCutNSigTofEl{"cfgCutNSigTofEl", 1.5, "TOF nSigma Electron veto cut"}; + 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 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 cfgCutPiP1{"cfgCutPiP1", 0.65, "pion p cut-1"}; - Configurable cfgCutPiP2{"cfgCutPiP2", 0.75, "pion p cut-2"}; - Configurable cfgCutKaP1{"cfgCutKaP1", 0.50, "kaon p cut-1"}; - Configurable cfgCutKaP2{"cfgCutKaP2", 0.60, "kaon p cut-2"}; - Configurable cfgCutKaP3{"cfgCutKaP3", 1.60, "kaon p cut-3"}; - Configurable cfgCutPrP1{"cfgCutPrP1", 0.90, "proton p cut-1"}; - Configurable cfgCutPrP2{"cfgCutPrP2", 1.00, "proton p cut-2"}; - Configurable cfgSelPi{"cfgSelPi", true, "PID selection cut for Pions"}; - Configurable cfgSelKa{"cfgSelKa", true, "PID selection cut for Kaons"}; - Configurable cfgSelPr{"cfgSelPr", true, "PID selection cut for Protons"}; - Configurable cfgSelPiInnerParam{"cfgSelPiInnerParam", false, "PID selection cut for Pions by using Momentum at inner wall of the TPC"}; - Configurable cfgSelKaInnerParam{"cfgSelKaInnerParam", false, "PID selection cut for Kaons by using Momentum at inner wall of the TPC"}; - Configurable cfgSelPrInnerParam{"cfgSelPrInnerParam", false, "PID selection cut for Protons by using Momentum at inner wall of the TPC"}; + 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 cfgPosZ{"cfgPosZ", true, "Position Z"}; + Configurable cfgSel8{"cfgSel8", true, "Sel8 trigger"}; + Configurable cfgEvSel1{"cfgEvSel1", true, "kNoSameBunchPileup"}; + Configurable cfgEvSel2{"cfgEvSel2", true, "kIsGoodZvtxFT0vsPV"}; + 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"}; ConfigurableAxis multTPCBins{"multTPCBins", {150, 0, 150}, "TPC Multiplicity bins"}; - ConfigurableAxis multFT0CBins{"multFT0CBins", {200, 0, 2000}, "Forward Multiplicity bins"}; - ConfigurableAxis multFT0CMCBins{"multFT0CMCBins", {250, 0, 250}, "Forward Multiplicity bins"}; // made change fore Gen + ConfigurableAxis multFT0CBins{"multFT0CBins", {400, 0, 4000}, "Forward Multiplicity bins"}; + ConfigurableAxis multFT0CMCBins{"multFT0CMCBins", {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 QnBins{"QnBins", {100, 0., 100.}, "nth moments bins"}; + ConfigurableAxis QnBins{"QnBins", {1000, 0., 100.}, "nth moments bins"}; + ConfigurableAxis TpNBins{"TpNBins", {300, 0., 3000.}, ""}; + ConfigurableAxis TpDBins{"TpDBins", {100, 0., 2000.}, ""}; using MyAllTracks = soa::Join ", kTH1D, {axisMeanPt}); @@ -318,20 +340,23 @@ struct meanPtFlucId { template bool selRun3Col(T const& col) { - if (std::abs(col.posZ()) > cfgCutPosZ) - return false; + hist.fill(HIST("QA/after/counts_evSelCuts"), 0); - if (!col.sel8()) + if (cfgPosZ && std::abs(col.posZ()) > cfgCutPosZ) return false; + hist.fill(HIST("QA/after/counts_evSelCuts"), 1); - if (!col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + if (cfgSel8 && !col.sel8()) return false; + hist.fill(HIST("QA/after/counts_evSelCuts"), 2); - if (!col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + if (cfgEvSel1 && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) return false; + hist.fill(HIST("QA/after/counts_evSelCuts"), 3); - if (!col.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + if (cfgEvSel2 && !col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) return false; + hist.fill(HIST("QA/after/counts_evSelCuts"), 4); return true; } @@ -352,63 +377,149 @@ struct meanPtFlucId { if (track.sign() == 0) return false; - if (std::abs(track.dcaZ()) > cfgCutDcaZ) + if (std::fabs(track.dcaZ()) > cfgCutDcaZ) return false; - if (std::abs(track.dcaXY()) > cfgCutDcaXY) + if (std::fabs(track.dcaXY()) > cfgCutDcaXY) return false; return true; } - // Cuts to rejects the tracks + // Cuts to reject the tracks template bool rejectTracks(T const& track) { - if (track.tpcNSigmaEl() > -3. && track.tpcNSigmaEl() < 5. && std::abs(track.tpcNSigmaPi()) > 3 && std::abs(track.tpcNSigmaKa()) > 3 && std::abs(track.tpcNSigmaPr()) > 3) { + 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)) { return true; } + + return false; + } + + template + bool selElectrons(T const& track) + { + 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; + } + } return false; } - // PID selection tpc (!tof) or (tof + tpc) - // PID selction cuts for Pions + // PID selction cuts for Low momentum Kaons template - bool selPions(T const& track, double innerParam) + bool selLowKa(T const& track, double p) { - if (track.pt() >= cfgCutPiPtMin && ((!track.hasTOF() && std::abs(track.tpcNSigmaEl()) > cfgCutNSigTpcEl && - ((std::abs(track.tpcNSigmaPi()) < cfgCutNSig3 && innerParam <= cfgCutPiP1) || (std::abs(track.tpcNSigmaPi()) < cfgCutNSig2 && innerParam > cfgCutPiP1 && innerParam <= cfgCutPiP2))) || - (track.hasTOF() && std::abs(track.tpcNSigmaPi()) < cfgCutNSig3 && std::abs(track.tofNSigmaEl()) > cfgCutNSigTofEl && (std::abs(track.tofNSigmaPi()) < cfgCutNSig3)))) { - if (abs(track.rapidity(massPi)) < cfgCutRap) + 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; + } } + return false; } - // PID selction cuts for Kaons + // PID selction cuts for Low momentum Protons template - bool selKaons(T const& track, double innerParam) + bool selLowPr(T const& track, double p) { - if (track.pt() >= cfgCutKaPtMin && (((!track.hasTOF()) && std::abs(track.tpcNSigmaEl()) > cfgCutNSigTpcEl && - ((std::abs(track.tpcNSigmaKa()) < cfgCutNSig3 && innerParam <= cfgCutKaP1) || (std::abs(track.tpcNSigmaKa()) < cfgCutNSig2 && innerParam > cfgCutKaP1 && innerParam <= cfgCutKaP2))) || - (track.hasTOF() && std::abs(track.tpcNSigmaKa()) < cfgCutNSig3 && std::abs(track.tofNSigmaEl()) > cfgCutNSigTofEl && - ((std::abs(track.tofNSigmaKa()) < cfgCutNSig3 && track.p() <= cfgCutKaP3) || (std::abs(track.tofNSigmaKa()) < cfgCutNSig2 && track.p() > cfgCutKaP3))))) { - if (abs(track.rapidity(massKa)) < cfgCutRap) + 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; + } } return false; } - // PID selction cuts for Protons + // PID selction cuts for High momentum Protons template - bool selProtons(T const& track, double innerParam) + bool selHighPi(T const& track) { - if (track.pt() >= cfgCutPrPtMin && (((!track.hasTOF()) && std::abs(track.tpcNSigmaEl()) > cfgCutNSigTpcEl && - ((std::abs(track.tpcNSigmaPr()) < cfgCutNSig3 && innerParam <= cfgCutPrP1) || (std::abs(track.tpcNSigmaPr()) < cfgCutNSig2 && innerParam > cfgCutPrP1 && innerParam <= cfgCutPrP2))) || - (track.hasTOF() && std::abs(track.tpcNSigmaPr()) < cfgCutNSig3 && std::abs(track.tofNSigmaEl()) > cfgCutNSigTofEl && std::abs(track.tofNSigmaPr()) < cfgCutNSig3))) { - if (abs(track.rapidity(massPr)) < cfgCutRap) + 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; + } + } + + 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; + } + } + + return false; + } + + // PID selction cuts for High momentum Protons + template + bool selHighPr(T const& track) + { + if (track.hasTOF() && + track.p() > cfgCutPrThrsldP && + std::fabs(track.tpcNSigmaPr() - cfgMcTpcShiftPr) < cfgCutNSig3 && + std::fabs(track.tofNSigmaPr() - cfgMcTofShiftPr) < cfgCutNSig3) { + + if (std::abs(track.rapidity(MassProton)) < cfgCutRap) { + return true; + } } return false; @@ -418,18 +529,22 @@ struct meanPtFlucId { template void FillBeforeQAHistos(T const& col, U const& tracks) { - for (auto& myTrack : tracks) { - hist.fill(HIST("QA/before/h_Eta"), myTrack.eta()); - hist.fill(HIST("QA/before/h_Pt"), myTrack.pt()); - hist.fill(HIST("QA/before/h2_PvsPinner"), myTrack.p(), myTrack.tpcInnerParam()); - hist.fill(HIST("QA/before/h2_Pt_Eta"), myTrack.eta(), myTrack.pt()); - hist.fill(HIST("QA/before/h_TPCChi2perCluster"), myTrack.tpcChi2NCl()); - hist.fill(HIST("QA/before/h_ITSChi2perCluster"), myTrack.itsChi2NCl()); - hist.fill(HIST("QA/before/h_crossedTPC"), myTrack.tpcNClsCrossedRows()); - hist.fill(HIST("QA/before/h_DcaXY"), myTrack.dcaXY()); - hist.fill(HIST("QA/before/h_DcaZ"), myTrack.dcaZ()); - hist.fill(HIST("QA/before/h2_DcaXY"), myTrack.pt(), myTrack.dcaXY()); - hist.fill(HIST("QA/before/h2_DcaZ"), myTrack.pt(), myTrack.dcaZ()); + for (auto& track : tracks) { + 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); @@ -473,6 +588,7 @@ struct meanPtFlucId { void FillChargedQAHistos(T const& track) { 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()); @@ -484,6 +600,9 @@ struct meanPtFlucId { 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: @@ -519,19 +638,21 @@ struct meanPtFlucId { hist.fill(HIST("QA/Kaon/innerParam/before/h2_TpcTofNsigma"), track.tpcNSigmaKa(), track.tofNSigmaKa()); } - // Fill Proton QA hist: + // Fill after PID cut QA hist: template void FillIdParticleQAHistos(T const& track, double rap, double nSigmaTPC, double nSigmaTOF) { - hist.fill(HIST(dire[mode]) + HIST("h_Pt"), track.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()); 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_TPCNsigma_El"), track.p(), track.tpcNSigmaEl()); hist.fill(HIST(dire[mode]) + HIST("h2_TOFNsigma_El"), track.p(), track.tofNSigmaEl()); @@ -558,13 +679,28 @@ struct meanPtFlucId { hist.fill(HIST("QA/after/innerParam/h2_pvsm2"), track.mass() * track.mass(), track.tpcInnerParam()); } + template + void FillMCPIDHist(T const& track, int PID, int pdgCodePos, int pdgCodeNeg, int& N, double& Q1, double& Q2, double& Q3, double& Q4) + { + N++; + double pt = track.pt(); + moments(pt, Q1, Q2, Q3, Q4); + hist.fill(HIST(dire[mode]) + HIST("h_Pt"), track.pt()); + if (PID == pdgCodePos) { + hist.fill(HIST(dire[mode]) + HIST("h_PtPos"), track.pt()); + } + if (PID == pdgCodeNeg) { + hist.fill(HIST(dire[mode]) + HIST("h_PtNeg"), track.pt()); + } + } + // Moments Calculation: - void moments(double pt, double* Q1, double* Q2, double* Q3, double* Q4) + void moments(double pt, double& Q1, double& Q2, double& Q3, double& Q4) { - *Q1 += pt; - *Q2 += pt * pt; - *Q3 += pt * pt * pt; - *Q4 += pt * pt * pt * pt; + Q1 += pt; + Q2 += pt * pt; + Q3 += pt * pt * pt; + Q4 += pt * pt * pt * pt; } template @@ -628,6 +764,26 @@ struct meanPtFlucId { double pt_Pr = 0, Q1_Pr = 0, Q2_Pr = 0, Q3_Pr = 0, Q4_Pr = 0; double pt_Ka = 0, Q1_Ka = 0, Q2_Ka = 0, Q3_Ka = 0, Q4_Ka = 0; + array p1, p2; + double invMassGamma = 0.0; + + for (auto const& [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; + + p1 = array{trkEl.px(), trkEl.py(), trkEl.pz()}; + p2 = array{trkPos.px(), trkPos.py(), trkPos.pz()}; + + invMassGamma = RecoDecay::m(array{p1, p2}, array{MassElectron, MassElectron}); + hist.fill(HIST("QA/after/h_invMass_gamma"), invMassGamma); + } + for (auto& track : tracks) { if (!selTrack(track)) { continue; @@ -639,16 +795,16 @@ struct meanPtFlucId { double nSigmaTOFPi = track.tofNSigmaPi(); double nSigmaTOFKa = track.tofNSigmaKa(); double nSigmaTOFPr = track.tofNSigmaPr(); - double rapPi = track.rapidity(massPi); - double rapKa = track.rapidity(massKa); - double rapPr = track.rapidity(massPr); + double rapPi = track.rapidity(MassPiPlus); + double rapKa = track.rapidity(MassKPlus); + double rapPr = track.rapidity(MassProton); double innerParam = track.tpcInnerParam(); if constexpr (DataFlag) { - if (std::abs(track.eta()) < 0.8) { + if (std::fabs(track.eta()) < 0.8) { Nch++; pt_ch = track.pt(); - moments(pt_ch, &Q1_ch, &Q2_ch, &Q3_ch, &Q4_ch); + moments(pt_ch, Q1_ch, Q2_ch, Q3_ch, Q4_ch); FillChargedQAHistos(track); } @@ -658,70 +814,172 @@ struct meanPtFlucId { return; } - // For Pions: - if (selPions(track, innerParam) == cfgSelPi) { - N_Pi++; - pt_Pi = track.pt(); - moments(pt_Pi, &Q1_Pi, &Q2_Pi, &Q3_Pi, &Q4_Pi); - FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + if (cfgInvMass == true && invMassGamma < cfgGammaCut) { + continue; } - // For Kaons: - if (selKaons(track, innerParam) == cfgSelKa) { - N_Ka++; - pt_Ka = track.pt(); - moments(pt_Ka, &Q1_Ka, &Q2_Ka, &Q3_Ka, &Q4_Ka); - FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowPi(track, innerParam) == cfgSelLow || selHighPi(track) == cfgSelHigh) { + N_Pi++; + pt_Pi = track.pt(); + hist.fill(HIST("QA/Pion/h_Pt"), track.pt()); + moments(pt_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowPi(track, innerParam) == cfgSelLow && selHighPi(track) == cfgSelHigh) { + N_Pi++; + pt_Pi = track.pt(); + hist.fill(HIST("QA/Pion/h_Pt"), track.pt()); + moments(pt_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + } } - // For Protons: - if (selProtons(track, innerParam) == cfgSelPr) { - N_Pr++; - pt_Pr = track.pt(); - moments(pt_Pr, &Q1_Pr, &Q2_Pr, &Q3_Pr, &Q4_Pr); - FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowKa(track, innerParam) == cfgSelLow || selHighKa(track) == cfgSelHigh) { + N_Ka++; + pt_Ka = track.pt(); + hist.fill(HIST("QA/Kaon/h_Pt"), track.pt()); + moments(pt_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowKa(track, innerParam) == cfgSelLow && selHighKa(track) == cfgSelHigh) { + N_Ka++; + pt_Ka = track.pt(); + hist.fill(HIST("QA/Kaon/h_Pt"), track.pt()); + moments(pt_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + } + } + + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowPr(track, innerParam) == cfgSelLow || selHighPr(track) == cfgSelHigh) { + N_Pr++; + pt_Pr = track.pt(); + hist.fill(HIST("QA/Proton/h_Pt"), track.pt()); + moments(pt_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowPr(track, innerParam) == cfgSelLow && selHighPr(track) == cfgSelHigh) { + N_Pr++; + pt_Pr = track.pt(); + hist.fill(HIST("QA/Proton/h_Pt"), track.pt()); + moments(pt_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + } } } else if constexpr (RecoFlag) { if (track.has_mcParticle() && track.mcParticle().isPhysicalPrimary()) { - if (std::abs(track.eta()) < 0.8) { + if (std::fabs(track.eta()) < 0.8) { Nch++; pt_ch = track.pt(); - moments(pt_ch, &Q1_ch, &Q2_ch, &Q3_ch, &Q4_ch); + moments(pt_ch, Q1_ch, Q2_ch, Q3_ch, Q4_ch); FillChargedQAHistos(track); } FillBeforePIDQAHistos(track); - if (rejectTracks(track)) + if (rejectTracks(track)) { return; + } + + if (cfgInvMass == true && invMassGamma < cfgGammaCut) { + continue; + } + + int PID = track.mcParticle().pdgCode(); - if (selPions(track, innerParam) == cfgSelPi) { - hist.fill(HIST("QA/Reco/Pion/h_allPt"), track.pt()); - if (std::abs(track.mcParticle().pdgCode()) == 211) { - N_Pi++; - pt_Pi = track.pt(); - moments(pt_Pi, &Q1_Pi, &Q2_Pi, &Q3_Pi, &Q4_Pi); - FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowPi(track, innerParam) == cfgSelLow || selHighPi(track) == cfgSelHigh) { + hist.fill(HIST("QA/Pion/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Pion/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Pion/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kPiPlus) { + FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + FillMCPIDHist(track, PID, kPiPlus, kPiMinus, N_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + } + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowPi(track, innerParam) == cfgSelLow && selHighPi(track) == cfgSelHigh) { + hist.fill(HIST("QA/Pion/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Pion/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Pion/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kPiPlus) { + + FillIdParticleQAHistos(track, rapPi, nSigmaTPCPi, nSigmaTOFPi); + FillMCPIDHist(track, PID, kPiPlus, kPiMinus, N_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + } } } - if (selKaons(track, innerParam) == cfgSelKa) { - hist.fill(HIST("QA/Reco/Kaon/h_allPt"), track.pt()); - if (std::abs(track.mcParticle().pdgCode()) == 321) { - N_Ka++; - pt_Ka = track.pt(); - moments(pt_Ka, &Q1_Ka, &Q2_Ka, &Q3_Ka, &Q4_Ka); - FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowKa(track, innerParam) == cfgSelLow || selHighKa(track) == cfgSelHigh) { + hist.fill(HIST("QA/Kaon/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Kaon/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Kaon/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kKPlus) { + FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + FillMCPIDHist(track, PID, kKPlus, kKMinus, N_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + } + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowKa(track, innerParam) == cfgSelLow && selHighKa(track) == cfgSelHigh) { + hist.fill(HIST("QA/Kaon/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Kaon/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Kaon/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kKPlus) { + FillIdParticleQAHistos(track, rapKa, nSigmaTPCKa, nSigmaTOFKa); + FillMCPIDHist(track, PID, kKPlus, kKMinus, N_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + } } } - if (selProtons(track, innerParam) == cfgSelPr) { - hist.fill(HIST("QA/Reco/Proton/h_allPt"), track.pt()); - if (std::abs(track.mcParticle().pdgCode()) == 2212) { - N_Pr++; - pt_Pr = track.pt(); - moments(pt_Pr, &Q1_Pr, &Q2_Pr, &Q3_Pr, &Q4_Pr); - FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + if (cfgSelOR == true && cfgSelAND == false) { + if (selLowPr(track, innerParam) == cfgSelLow || selHighPr(track) == cfgSelHigh) { + hist.fill(HIST("QA/Proton/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Proton/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Proton/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kProton) { + FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + FillMCPIDHist(track, PID, kProton, kProtonBar, N_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + } + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if (selLowPr(track, innerParam) == cfgSelLow && selHighPr(track) == cfgSelHigh) { + hist.fill(HIST("QA/Proton/h_allPt"), track.pt()); + if (track.sign() > 0) + hist.fill(HIST("QA/Proton/h_allPtPos"), track.pt()); + + if (track.sign() < 0) + hist.fill(HIST("QA/Proton/h_allPtNeg"), track.pt()); + + if (std::abs(PID) == kProton) { + FillIdParticleQAHistos(track, rapPr, nSigmaTPCPr, nSigmaTOFPr); + FillMCPIDHist(track, PID, kProton, kProtonBar, N_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + } } } } @@ -751,7 +1009,7 @@ struct meanPtFlucId { FillHistos(col, tracks); } } - PROCESS_SWITCH(meanPtFlucId, process_Run3, "Process for Run3", false); + PROCESS_SWITCH(meanPtFlucId, process_Run3, "Process for Run3", true); void process_MCRecoRun3(MyMCCollisions::iterator const& col, aod::McCollisions const&, MyMCTracks const& tracks, aod::McParticles const&) { @@ -766,18 +1024,18 @@ struct meanPtFlucId { FillHistos(col, tracks); } } - PROCESS_SWITCH(meanPtFlucId, process_MCRecoRun3, "process MC Reconstructed Run-3", true); + PROCESS_SWITCH(meanPtFlucId, process_MCRecoRun3, "process MC Reconstructed Run-3", false); void process_MCGen(soa::Join::iterator const& mccol, aod::McParticles const& McParticles) { int N_Pi = 0, N_Ka = 0, N_Pr = 0; int Nch = 0, NTPC = 0, N_FT0C = 0; double pt_ch = 0, Q1_ch = 0, Q2_ch = 0, Q3_ch = 0, Q4_ch = 0; - double pt_Pi = 0, Q1_Pi = 0, Q2_Pi = 0, Q3_Pi = 0, Q4_Pi = 0; - double pt_Pr = 0, Q1_Pr = 0, Q2_Pr = 0, Q3_Pr = 0, Q4_Pr = 0; - double pt_Ka = 0, Q1_Ka = 0, Q2_Ka = 0, Q3_Ka = 0, Q4_Ka = 0; + double Q1_Pi = 0, Q2_Pi = 0, Q3_Pi = 0, Q4_Pi = 0; + double Q1_Pr = 0, Q2_Pr = 0, Q3_Pr = 0, Q4_Pr = 0; + double Q1_Ka = 0, Q2_Ka = 0, Q3_Ka = 0, Q4_Ka = 0; - if (abs(mccol.posZ()) > cfgCutPosZ) + if (std::abs(mccol.posZ()) > cfgCutPosZ) return; for (auto& mcParticle : McParticles) { @@ -785,39 +1043,55 @@ struct meanPtFlucId { continue; auto charge = 0.; - auto* p = pdg->GetParticle(mcParticle.pdgCode()); - if (p != nullptr) { - charge = p->Charge(); + int PID = mcParticle.pdgCode(); + auto* pd = pdg->GetParticle(PID); + if (pd != nullptr) { + charge = pd->Charge(); } - if (std::abs(charge) < 1e-3) { - continue; // reject neutral particles in counters + if (std::fabs(charge) < 1e-3) { + continue; } - if (mcParticle.pt() > cfgCutPtMin && mcParticle.pt() < cfgCutPtMax && abs(mcParticle.y()) < cfgCutRap) { + if (mcParticle.pt() > cfgCutPtMin && mcParticle.pt() < cfgCutPtMax && std::abs(mcParticle.y()) < cfgCutRap) { Nch++; pt_ch = mcParticle.pt(); - moments(pt_ch, &Q1_ch, &Q2_ch, &Q3_ch, &Q4_ch); + moments(pt_ch, Q1_ch, Q2_ch, Q3_ch, Q4_ch); hist.fill(HIST("Gen/Charged/h_Pt"), mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == 211 && mcParticle.pt() >= cfgCutPiPtMin) { - N_Pi++; - pt_Pi = mcParticle.pt(); - moments(pt_Pi, &Q1_Pi, &Q2_Pi, &Q3_Pi, &Q4_Pi); - hist.fill(HIST("Gen/Pion/h_Pt"), mcParticle.pt()); + if (std::abs(PID) == kPiPlus && mcParticle.pt() >= cfgCutPiPtMin) { + if (cfgSelOR == true && cfgSelAND == false) { + if (mcParticle.p() <= cfgCutPiThrsldP || mcParticle.p() > cfgCutPiThrsldP) { + FillMCPIDHist(mcParticle, PID, kPiPlus, kPiMinus, N_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if ((cfgSelLow == true && mcParticle.p() <= cfgCutPiThrsldP) && (cfgSelHigh == true && mcParticle.p() > cfgCutPiThrsldP)) { + FillMCPIDHist(mcParticle, PID, kPiPlus, kPiMinus, N_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); + } + } } - if (std::abs(mcParticle.pdgCode()) == 321 && mcParticle.pt() >= cfgCutKaPtMin) { - N_Ka++; - pt_Ka = mcParticle.pt(); - moments(pt_Ka, &Q1_Ka, &Q2_Ka, &Q3_Ka, &Q4_Ka); - hist.fill(HIST("Gen/Kaon/h_Pt"), mcParticle.pt()); + if (std::abs(PID) == kKPlus && mcParticle.pt() >= cfgCutKaPtMin) { + if (cfgSelOR == true && cfgSelAND == false) { + if ((cfgSelLow == true && mcParticle.p() <= cfgCutPiThrsldP) || (cfgSelHigh == true && mcParticle.p() > cfgCutPiThrsldP)) { + FillMCPIDHist(mcParticle, PID, kKPlus, kKMinus, N_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if ((cfgSelLow == true && mcParticle.p() <= cfgCutKaThrsldP) && (cfgSelHigh == true && mcParticle.p() > cfgCutKaThrsldP)) { + FillMCPIDHist(mcParticle, PID, kKPlus, kKMinus, N_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); + } + } } - if (std::abs(mcParticle.pdgCode()) == 2212 && mcParticle.pt() >= cfgCutPrPtMin) { - N_Pr++; - pt_Pr = mcParticle.pt(); - moments(pt_Pr, &Q1_Pr, &Q2_Pr, &Q3_Pr, &Q4_Pr); - hist.fill(HIST("Gen/Proton/h_Pt"), mcParticle.pt()); + if (std::abs(PID) == kProton && mcParticle.pt() >= cfgCutPrPtMin) { + if (cfgSelOR == true && cfgSelAND == false) { + if ((cfgSelLow == true && mcParticle.p() <= cfgCutPrThrsldP) || (cfgSelHigh == true && mcParticle.p() > cfgCutPrThrsldP)) { + FillMCPIDHist(mcParticle, PID, kProton, kProtonBar, N_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + } + } else if (cfgSelOR == false && cfgSelAND == true) { + if ((cfgSelLow == true && mcParticle.p() <= cfgCutPrThrsldP) && (cfgSelHigh == true && mcParticle.p() > cfgCutPrThrsldP)) { + FillMCPIDHist(mcParticle, PID, kProton, kProtonBar, N_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); + } + } } } } @@ -825,16 +1099,19 @@ struct meanPtFlucId { N_FT0C = mccol.multMCFT0C(); hist.fill(HIST("Gen/Counts"), 2); hist.fill(HIST("Gen/vtxZ"), mccol.posZ()); - hist.fill(HIST("Gen/NTPC"), NTPC); - hist.fill(HIST("Gen/NFT0C"), N_FT0C); - hist.fill(HIST("Gen/h2_NTPC_NFT0C"), N_FT0C, NTPC); + if (NTPC != 0) + hist.fill(HIST("Gen/NTPC"), NTPC); + if (N_FT0C != 0) + hist.fill(HIST("Gen/NFT0C"), N_FT0C); + if (NTPC != 0 && N_FT0C != 0) + hist.fill(HIST("Gen/h2_NTPC_NFT0C"), N_FT0C, NTPC); FillAnalysisHistos(NTPC, N_FT0C, Nch, Q1_ch, Q2_ch, Q3_ch, Q4_ch); FillAnalysisHistos(NTPC, N_FT0C, N_Pi, Q1_Pi, Q2_Pi, Q3_Pi, Q4_Pi); FillAnalysisHistos(NTPC, N_FT0C, N_Ka, Q1_Ka, Q2_Ka, Q3_Ka, Q4_Ka); FillAnalysisHistos(NTPC, N_FT0C, N_Pr, Q1_Pr, Q2_Pr, Q3_Pr, Q4_Pr); } - PROCESS_SWITCH(meanPtFlucId, process_MCGen, "process MC Generated", true); + PROCESS_SWITCH(meanPtFlucId, process_MCGen, "process MC Generated", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx b/PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx index 191158c7ba0..f4d50ac9c7a 100644 --- a/PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx @@ -14,6 +14,9 @@ #include #include +#include +#include +#include #include "TF1.h" #include "TGraphErrors.h" @@ -82,7 +85,7 @@ struct RobustFluctuationObservables { // for vertex vs time: bool flagShowInfo = false; int lastRunNumber = -1; - int nBCsPerOrbit = 3564; + uint64_t nBCsPerOrbit = 3564; // bc position correlations int64_t prevOrbit = -1; @@ -101,7 +104,7 @@ struct RobustFluctuationObservables { int64_t orbitSOR = -1; // int64_t bcSORbis = -1; // global bc of the start of the first orbit - try alternative int64_t nBCsPerTF = 1; // 128*3564; // duration of TF in bcs - int64_t TFid = -1; // count time frames in a given run + uint64_t TFid = 0; // count time frames in a given run bool flagWaitForNewTF = false; uint32_t nOrbitsPerTF = 0; @@ -154,7 +157,7 @@ struct RobustFluctuationObservables { // hand-made ITS ROF cut Configurable nITSROF{"nITSROF", 6, "nITSROF"}; Configurable nITSROF_BC_offset{"nITSROF_BC_offset", 65, "nITSROF_BC_offset"}; - Configurable nITSROF_BC_cutWidth{"nITSROF_BC_cutWidth", 40, "nITSROF_BC_cutWidth"}; + Configurable nITSROF_BC_cutWidth{"nITSROF_BC_cutWidth", 40, "nITSROF_BC_cutWidth"}; // Configurable nITSROF_middle_cut_forITSonlyVert{"nITSROF_middle_cut_forITSonlyVert", 198/2 /*ROF=198 in pp*/, "nITSROF_middle_cut_forITSonlyVert"}; // Configurable nNoITSonlyVertices{"nNoITSonlyVertices", false, "nITSROF_middle_cut_forITSonlyVert"}; @@ -163,7 +166,7 @@ struct RobustFluctuationObservables { Configurable cutVzTrackT0diffUpper{"cutVzTrackT0diffUpper", 1., "cutVzTrackT0diffUpper, cm"}; // splitting of the orbit into several BC ranges - Configurable> vSplitBCpointsOfTheOrbit{"SplitBCpointsOfTheOrbit", {1200, 2000, 3000}, "BC split points of the orbit"}; + Configurable> vSplitBCpointsOfTheOrbit{"SplitBCpointsOfTheOrbit", {1200, 2000, 3000}, "BC split points of the orbit"}; // orbit QA uint32_t orbitAtCollIndexZero = 0; @@ -968,7 +971,7 @@ struct RobustFluctuationObservables { } if (myDF_ID >= 0 && myDF_ID < nHistQAplotsDF) { - int diffOrbits = (int32_t)orbit - (int32_t)orbitAtCollIndexZero; + int diffOrbits = static_cast(orbit) - static_cast(orbitAtCollIndexZero); TString strDF = Form("DF_%d", static_cast(DF_ID_raw)); fV_h1D_Orbit_vs_CollIndex[myDF_ID]->Fill(collision.index(), diffOrbits); fV_h1D_Orbit_vs_CollIndex[myDF_ID]->SetTitle(strDF); @@ -1474,23 +1477,23 @@ struct RobustFluctuationObservables { // ##### check how often we analyze collision in the same BC (and also the vZ difference) if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { if (prevBC != 9999) { - int32_t diff = (int32_t)collBC - (int32_t)prevBC; + int32_t diff = static_cast(collBC) - static_cast(prevBC); histosEvent.fill(HIST("hBC_DIFF_to_previous"), diff); if (diff == 0) histosEvent.fill(HIST("hBC_DIFF_to_previous_vZvZ_2D"), vZ, prev_vZ); } if (prevBcInTF >= 0) { - int32_t diffBcInTF = (int32_t)bcInTF - (int32_t)prevBcInTF; + int32_t diffBcInTF = static_cast(bcInTF) - static_cast(prevBcInTF); histosEvent.fill(HIST("hBCinTF_DIFF_to_previous"), diffBcInTF); } if (prevFoundBcInTF >= 0) { - int32_t diffGlobalBcInTF = (int32_t)foundBcInTF - (int32_t)prevFoundBcInTF; + int32_t diffGlobalBcInTF = static_cast(foundBcInTF) - static_cast(prevFoundBcInTF); histosEvent.fill(HIST("hBCinTF_DIFF_to_previous_FOUND_BC"), diffGlobalBcInTF); } // global found BC: if (prevGlobalFoundBC != 9999) { - int32_t diff = (int32_t)globalFoundBC - (int32_t)prevGlobalFoundBC; + int32_t diff = static_cast(globalFoundBC) - static_cast(prevGlobalFoundBC); histosEvent.fill(HIST("hBC_DIFF_to_previous_FOUND_BC"), diff); if (counterPVcontributorsAfterTPCcuts > 0) { @@ -1620,8 +1623,8 @@ struct RobustFluctuationObservables { histosEventBcInTF.fill(HIST("hGlobalTracks_vs_bcInTF"), bcInTF, nTracksGlobalAccepted); } - histosEvent.fill(HIST("hOrbitStartFromCollIndexZeroAft"), (int32_t)orbit - (int32_t)orbitAtCollIndexZero); - histosEvent.fill(HIST("h2D_Orbit_vs_CollIndex_Aft"), collision.index(), (int32_t)orbit - (int32_t)orbitAtCollIndexZero); + histosEvent.fill(HIST("hOrbitStartFromCollIndexZeroAft"), static_cast(orbit) - static_cast(orbitAtCollIndexZero)); + histosEvent.fill(HIST("h2D_Orbit_vs_CollIndex_Aft"), collision.index(), static_cast(orbit) - static_cast(orbitAtCollIndexZero)); histosEvent.fill(HIST("hMF"), magneticField); int MFsign = magneticField > 0 ? +1 : -1; @@ -1680,11 +1683,11 @@ struct RobustFluctuationObservables { histosEvent.fill(HIST("hBCFound_Aft"), globalFoundBC); histosEvent.fill(HIST("h2D_numContrib_vs_BC"), collBC, collision.numContrib()); - int64_t diffFoundBC_vs_BC = (int64_t)globalFoundBC - (int64_t)collBC; + int64_t diffFoundBC_vs_BC = static_cast(globalFoundBC) - static_cast(collBC); histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC"), collBC, diffFoundBC_vs_BC); if (collision.has_foundBC()) - histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC_inTF"), collBC, (int64_t)foundBcInTF - (int64_t)bcInTF); + histosEvent.fill(HIST("h2D_diffFoundBC_vs_BC_inTF"), collBC, static_cast(foundBcInTF) - static_cast(bcInTF)); // with FT0 conditions if (isFT0) { diff --git a/PWGCF/Femto3D/Core/femto3dPairTask.h b/PWGCF/Femto3D/Core/femto3dPairTask.h index 8480cbcbadd..a3b74c36cd0 100755 --- a/PWGCF/Femto3D/Core/femto3dPairTask.h +++ b/PWGCF/Femto3D/Core/femto3dPairTask.h @@ -109,14 +109,14 @@ float GetKstarFrom4vectors(TLorentzVector& first4momentum, TLorentzVector& secon { if (isIdentical) { TLorentzVector fourmomentadiff = first4momentum - second4momentum; - return 0.5 * abs(fourmomentadiff.Mag()); + return 0.5 * std::fabs(fourmomentadiff.Mag()); } else { TLorentzVector fourmomentasum = first4momentum + second4momentum; TLorentzVector fourmomentadif = first4momentum - second4momentum; fourmomentadif.Boost((-1) * fourmomentasum.BoostVector()); - return 0.5 * abs(fourmomentadif.Vect().Mag()); + return 0.5 * std::fabs(fourmomentadif.Vect().Mag()); } } @@ -215,7 +215,8 @@ class FemtoPair float GetKstar() const; TVector3 GetQLCMS() const; float GetKt() const; - float GetMt() const; // test + float GetMt() const; // test + float GetGammaOut() const; // test private: TrackType _first = NULL; @@ -252,9 +253,9 @@ bool FemtoPair::IsClosePair(const float& deta, const float& dphi, con return true; if (_magfield1 * _magfield2 == 0) return true; - if (std::pow(abs(GetEtaDiff()) / deta, 2) + std::pow(abs(GetPhiStarDiff(radius)) / dphi, 2) < 1.0f) + if (std::pow(std::fabs(GetEtaDiff()) / deta, 2) + std::pow(std::fabs(GetPhiStarDiff(radius)) / dphi, 2) < 1.0f) return true; - // if (abs(GetEtaDiff()) < deta && abs(GetPhiStarDiff(radius)) < dphi) + // if (std::fabs(GetEtaDiff()) < deta && std::fabs(GetPhiStarDiff(radius)) < dphi) // return true; return false; @@ -346,6 +347,34 @@ float FemtoPair::GetMt() const return 0.5 * fourmomentasum.Mt(); } + +template +float FemtoPair::GetGammaOut() const +{ + if (_first == NULL || _second == NULL) + return -1000; + if (_magfield1 * _magfield2 == 0) + return -1000; + if (_PDG1 * _PDG2 == 0) + return -1000; + + // double Qinv = 2.0 * GetKstar(); + // TVector3 QLCMS = GetQLCMS(); + // double Qout_PRF = sqrt(Qinv * Qinv - QLCMS.Y() * QLCMS.Y() - QLCMS.Z() * QLCMS.Z()); + // return std::fabs(QLCMS.X() / Qout_PRF); + + TLorentzVector first4momentum; + first4momentum.SetPtEtaPhiM(_first->pt(), _first->eta(), _first->phi(), particle_mass(_PDG1)); + TLorentzVector second4momentum; + second4momentum.SetPtEtaPhiM(_second->pt(), _second->eta(), _second->phi(), particle_mass(_PDG2)); + + TLorentzVector fourmomentasum = first4momentum + second4momentum; + + fourmomentasum.Boost(0.0, 0.0, (-1) * fourmomentasum.BoostVector().Z()); // boost to LCMS + fourmomentasum.RotateZ((-1) * fourmomentasum.Phi()); // rotate so the X axis is along pair's kT + + return fourmomentasum.Gamma(); +} } // namespace o2::aod::singletrackselector #endif // PWGCF_FEMTO3D_CORE_FEMTO3DPAIRTASK_H_ diff --git a/PWGCF/Femto3D/DataModel/singletrackselector.h b/PWGCF/Femto3D/DataModel/singletrackselector.h index 5c78911a3e1..afb4fc3f615 100644 --- a/PWGCF/Femto3D/DataModel/singletrackselector.h +++ b/PWGCF/Femto3D/DataModel/singletrackselector.h @@ -55,6 +55,32 @@ inline o2::framework::expressions::Node unPack(const T& b) return binningType::bin_width * b + binningType::binned_center; } +template +inline typename binningType::binned_t packSymmetric(const float& valueToBin) +{ + if (valueToBin <= binningType::binned_min) { + return (binningType::underflowBin); + } else if (valueToBin >= binningType::binned_max) { + return (binningType::overflowBin); + } else if (valueToBin >= 0) { + return (static_cast((valueToBin * binningType::inv_bin_width) + 0.5f)); + } else { + return (static_cast((valueToBin * binningType::inv_bin_width) - 0.5f)); + } +} + +template +inline float unPackSymmetric(const typename binningType::binned_t& b) +{ + return binningType::bin_width * static_cast(b); +} + +template +inline o2::framework::expressions::Node unPackSymmetric(const T& b) +{ + return binningType::bin_width * static_cast(b); +} + namespace binning { @@ -70,6 +96,7 @@ struct binningParent { static constexpr float binned_max = lim.second; static constexpr float binned_center = 0.5 * (binned_min + binned_max); static constexpr float bin_width = (binned_max - binned_min) / nbins; + static constexpr float inv_bin_width = 1. / bin_width; static_assert(binned_min < binned_max, "Invalid binning range"); static void print() { @@ -78,10 +105,15 @@ struct binningParent { } }; -using nsigma = 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 = dca_v1; +using dca_v2 = binningParent(-3.2767f, 3.2767f), int16_t>; // Width 0.0001 symmetric around 0 +using dca = dca_v2; + using chi2 = binningParent(0.f, 10.f)>; using rowsOverFindable = binningParent(0.f, 3.f)>; @@ -157,20 +189,33 @@ DECLARE_SOA_COLUMN(StoredDcaXY, storedDcaXY, binning::dca_v0::binned_t); 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(StoredTPCCrossedRowsOverFindableCls, storedTpcCrossedRowsOverFindableCls, binning::rowsOverFindable::binned_t); // Ratio of found over findable clusters -DECLARE_SOA_COLUMN(StoredTOFNSigmaPi, storedTofNSigmaPi, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTPCNSigmaPi, storedTpcNSigmaPi, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTOFNSigmaKa, storedTofNSigmaKa, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTPCNSigmaKa, storedTpcNSigmaKa, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTOFNSigmaPr, storedTofNSigmaPr, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTPCNSigmaPr, storedTpcNSigmaPr, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTOFNSigmaDe, storedTofNSigmaDe, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTPCNSigmaDe, storedTpcNSigmaDe, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTOFNSigmaHe, storedTofNSigmaHe, binning::nsigma::binned_t); -DECLARE_SOA_COLUMN(StoredTPCNSigmaHe, storedTpcNSigmaHe, binning::nsigma::binned_t); +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_DYNAMIC_COLUMN(Energy, energy, [](float p, float mass) -> float { return sqrt(p * p + mass * mass); }); DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float p, float eta) -> float { return p / std::cosh(eta); }); @@ -194,6 +239,12 @@ 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, @@ -205,32 +256,56 @@ DECLARE_SOA_DYNAMIC_COLUMN(TPCCrossedRowsOverFindableCls, tpcCrossedRowsOverFind 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, tofNSigmaPi, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPi, tpcNSigmaPi, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaKa, tofNSigmaKa, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaKa, tpcNSigmaKa, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); - -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaPr, tofNSigmaPr, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaPr, tpcNSigmaPr, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaDe, tofNSigmaDe, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaDe, tpcNSigmaDe, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TOFNSigmaHe, tofNSigmaHe, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); -DECLARE_SOA_DYNAMIC_COLUMN(TPCNSigmaHe, tpcNSigmaHe, - [](binning::nsigma::binned_t nsigma_binned) -> float { return singletrackselector::unPack(nsigma_binned); }); +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); }); 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); @@ -240,118 +315,178 @@ DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! Track rapidity, computed unde } // namespace singletrackselector -DECLARE_SOA_TABLE_FULL(SingleTrackSels_v0, "SelTracks", "AOD", "SINGLETRACKSEL", // 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::ITSNCls, - 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::TPCChi2NCl, - singletrackselector::ITSChi2NCl, - singletrackselector::TPCCrossedRowsOverFindableCls, - singletrackselector::TPCFractionSharedCls, - - singletrackselector::TOFNSigmaPi, - singletrackselector::TPCNSigmaPi, - singletrackselector::TOFNSigmaKa, - singletrackselector::TPCNSigmaKa, - singletrackselector::TOFNSigmaPr, - singletrackselector::TPCNSigmaPr, - singletrackselector::TOFNSigmaDe, - singletrackselector::TPCNSigmaDe, - - singletrackselector::Rapidity, - singletrackselector::Energy, - singletrackselector::Pt, - singletrackselector::Px, - singletrackselector::Py, - singletrackselector::Pz, - singletrackselector::PhiStar); - -DECLARE_SOA_TABLE_FULL(SingleTrackSels_v1, "SelTracks", "AOD", "SINGLETRACKSEL1", // 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::TOFNSigmaPi, - singletrackselector::TPCNSigmaPi, - singletrackselector::TOFNSigmaKa, - singletrackselector::TPCNSigmaKa, - singletrackselector::TOFNSigmaPr, - singletrackselector::TPCNSigmaPr, - singletrackselector::TOFNSigmaDe, - singletrackselector::TPCNSigmaDe, - singletrackselector::TOFNSigmaHe, - singletrackselector::TPCNSigmaHe, - - singletrackselector::Rapidity, - singletrackselector::Energy, - singletrackselector::Pt, - singletrackselector::Px, - singletrackselector::Py, - singletrackselector::Pz, - singletrackselector::PhiStar); - -using SingleTrackSels = SingleTrackSels_v1; +DECLARE_SOA_TABLE(SingleTrackSels_v0, "AOD", "SINGLETRACKSEL", // 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::ITSNCls, + 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::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::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::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); + +DECLARE_SOA_TABLE_VERSIONED(SingleTrackSels_v2, "AOD", "SINGLETRACKSEL2", 2, // 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_v2, + singletrackselector::StoredDcaZ_v2, + singletrackselector::StoredTPCChi2NCl, + singletrackselector::StoredITSChi2NCl, + singletrackselector::StoredTPCCrossedRowsOverFindableCls, + + singletrackselector::StoredTOFNSigmaPi_v1, + singletrackselector::StoredTPCNSigmaPi_v1, + singletrackselector::StoredTOFNSigmaKa_v1, + singletrackselector::StoredTPCNSigmaKa_v1, + singletrackselector::StoredTOFNSigmaPr_v1, + singletrackselector::StoredTPCNSigmaPr_v1, + singletrackselector::StoredTOFNSigmaDe_v1, + singletrackselector::StoredTPCNSigmaDe_v1, + singletrackselector::StoredTOFNSigmaHe_v1, + singletrackselector::StoredTPCNSigmaHe_v1, + + singletrackselector::ITSNClsDyn, + track::v001::ITSClsSizeInLayer, + singletrackselector::DcaXY_v2, + singletrackselector::DcaZ_v2, + 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::Rapidity, + singletrackselector::Energy, + singletrackselector::Pt, + singletrackselector::Px, + singletrackselector::Py, + singletrackselector::Pz, + singletrackselector::PhiStar); + +using SingleTrackSels = SingleTrackSels_v2; DECLARE_SOA_TABLE(SingleTrkExtras, "AOD", "SINGLETRKEXTRA", singletrackselector::TPCInnerParam, singletrackselector::TPCSignal, singletrackselector::Beta); +DECLARE_SOA_TABLE(SinglePIDEls, "AOD", "SINGLEPIDEL", + singletrackselector::StoredTPCNSigmaEl, + singletrackselector::TPCNSigmaEl); + namespace singletrackselector { DECLARE_SOA_COLUMN(PdgCode, pdgCode, int); diff --git a/PWGCF/Femto3D/TableProducer/CMakeLists.txt b/PWGCF/Femto3D/TableProducer/CMakeLists.txt index aba3d3c728f..a31ce326c9f 100644 --- a/PWGCF/Femto3D/TableProducer/CMakeLists.txt +++ b/PWGCF/Femto3D/TableProducer/CMakeLists.txt @@ -9,14 +9,11 @@ # 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(single-track-selector SOURCES singleTrackSelector.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(single-track-selector-converter - SOURCES singleTrackSelectorConverter.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(single-track-selector-extra diff --git a/PWGCF/Femto3D/TableProducer/Converters/CMakeLists.txt b/PWGCF/Femto3D/TableProducer/Converters/CMakeLists.txt new file mode 100644 index 00000000000..9014f8fbe4e --- /dev/null +++ b/PWGCF/Femto3D/TableProducer/Converters/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(single-track-selector-converter + SOURCES singleTrackSelectorConverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(single-track-selector-converter-v1 + SOURCES singleTrackSelectorConverterV1.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGCF/Femto3D/TableProducer/singleTrackSelectorConverter.cxx b/PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverter.cxx similarity index 98% rename from PWGCF/Femto3D/TableProducer/singleTrackSelectorConverter.cxx rename to PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverter.cxx index 2fe7126ff95..4a44e331e9b 100644 --- a/PWGCF/Femto3D/TableProducer/singleTrackSelectorConverter.cxx +++ b/PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverter.cxx @@ -26,7 +26,7 @@ using namespace o2::aod; //::singletrackselector; // the namespace defined in .h struct singleTrackSelectorConverter { - Produces tableRow; + Produces tableRow; void init(InitContext&) {} diff --git a/PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverterV1.cxx b/PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverterV1.cxx new file mode 100644 index 00000000000..584760ce74a --- /dev/null +++ b/PWGCF/Femto3D/TableProducer/Converters/singleTrackSelectorConverterV1.cxx @@ -0,0 +1,68 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Converter for the different versions of the singletrackselector tables +/// \author Sofia Tomassini, Gleb Romanenko, Nicolò Jacazio +/// \since 03 May 2024 + +#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 singleTrackSelectorConverter { + Produces tableRow; + + void init(InitContext&) {} + + void process(o2::aod::SingleTrackSels_v1 const& tracks) + { + tableRow.reserve(tracks.size()); + for (auto const& track : tracks) { + tableRow(track.singleCollSelId(), + track.p(), + track.eta(), + track.phi(), + track.sign(), + track.tpcNClsFound(), + track.tpcNClsShared(), + track.itsClsMap(), + track.itsClusterSizes(), + singletrackselector::packSymmetric(track.dcaXY()), + 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())); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx b/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx index 8172d07bbf0..0bec4d3cf40 100644 --- a/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx +++ b/PWGCF/Femto3D/TableProducer/singleTrackSelector.cxx @@ -18,6 +18,9 @@ #include +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + #include "PWGCF/Femto3D/DataModel/singletrackselector.h" #include "Framework/AnalysisTask.h" @@ -44,9 +47,14 @@ using namespace o2::aod; struct singleTrackSelector { Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + 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 applySkimming{"applySkimming", false, "Skimmed dataset processing"}; + Configurable cfgSkimming{"cfgSkimming", "fPD", "Configurable for skimming"}; 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"}; @@ -89,6 +97,7 @@ struct singleTrackSelector { Produces tableRowCollExtra; Produces tableRow; Produces tableRowExtra; + Produces tableRowPIDEl; Produces tableRowMC; Filter eventFilter = (applyEvSel.node() == 0) || @@ -110,7 +119,7 @@ struct singleTrackSelector { std::vector particlesToKeep; std::vector particlesToReject; - HistogramRegistry registry{"registry"}; + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; SliceCache cache; void init(InitContext&) @@ -119,11 +128,20 @@ struct singleTrackSelector { particlesToKeep = _particlesToKeep; particlesToReject = _particlesToReject; + if (applySkimming) { + zorroSummary.setObject(zorro.getZorroSummary()); + } ccdb->setURL(ccdburl); ccdb->setCaching(true); 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"); + } + 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"}}}); @@ -142,6 +160,11 @@ struct singleTrackSelector { } d_bz = 0.f; + if (applySkimming) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), cfgSkimming.value); + zorro.populateHistRegistry(registry, bc.runNumber()); + } + auto run3grp_timestamp = bc.timestamp(); o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); o2::parameters::GRPMagField* grpmag = 0x0; @@ -204,27 +227,28 @@ struct singleTrackSelector { track.tpcNClsShared(), track.itsClusterMap(), track.itsClusterSizes(), - - singletrackselector::packInTable(track.dcaXY()), - singletrackselector::packInTable(track.dcaZ()), + singletrackselector::packSymmetric(track.dcaXY()), + singletrackselector::packSymmetric(track.dcaZ()), singletrackselector::packInTable(track.tpcChi2NCl()), singletrackselector::packInTable(track.itsChi2NCl()), singletrackselector::packInTable(track.tpcCrossedRowsOverFindableCls()), - singletrackselector::packInTable(track.tofNSigmaPi()), - singletrackselector::packInTable(track.tpcNSigmaPi()), - singletrackselector::packInTable(track.tofNSigmaKa()), - singletrackselector::packInTable(track.tpcNSigmaKa()), - singletrackselector::packInTable(track.tofNSigmaPr()), - singletrackselector::packInTable(track.tpcNSigmaPr()), - singletrackselector::packInTable(track.tofNSigmaDe()), - singletrackselector::packInTable(track.tpcNSigmaDe()), - singletrackselector::packInTable(track.tofNSigmaHe()), - singletrackselector::packInTable(track.tpcNSigmaHe())); + 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())); tableRowExtra(track.tpcInnerParam(), track.tpcSignal(), track.beta()); + tableRowPIDEl(singletrackselector::packSymmetric(track.tpcNSigmaEl())); + if constexpr (isMC) { int origin = -1; if (track.mcParticle().isPhysicalPrimary()) { @@ -289,6 +313,16 @@ struct singleTrackSelector { { auto bc = collision.bc_as(); initCCDB(bc); + + if (applySkimming) { + registry.fill(HIST("hNEvents"), 0.5); + bool zorroSelected = zorro.isSelected(bc.globalBC()); + if (!zorroSelected) { + return; + } + registry.fill(HIST("hNEvents"), 1.5); + } + double hadronicRate = 0.; if (fetchRate) { hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), mRunNumber, "ZNC hadronic") * 1.e-3; // fetch IR @@ -492,7 +526,7 @@ struct singleTrackSelector { return; } - if (abs(mcCollision.posZ()) > _vertexZ) { + if (std::fabs(mcCollision.posZ()) > _vertexZ) { return; } diff --git a/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx b/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx index e3f5fa8f0c3..045dc9ad2d8 100644 --- a/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dPairTask.cxx @@ -97,6 +97,7 @@ struct FemtoCorrelations { ConfigurableAxis CFkStarBinning{"CFkStarBinning", {500, 0.005, 5.005}, "k* binning of the CF (Nbins, lowlimit, uplimit)"}; Configurable _fill3dCF{"fill3dCF", false, "flag for filling 3D LCMS histos: true -- fill; false -- not"}; + Configurable _fill3dAddHistos{"fill3dAddHistos", 1, "flag for filling additional 3D histos: 0 -- nothing; 1 -- Q_LCMS vs. k*; 2 -- Q_LCMS vs. Gamma_out (currently testing)"}; Configurable _fillDetaDphi{"fillDetaDphi", -1, "flag for filling dEta(dPhi*) histos: '-1' -- don't fill; '0' -- fill before the cut; '1' -- fill after the cut; '2' -- fill before & after the cut"}; ConfigurableAxis CF3DqLCMSBinning{"CF3DqLCMSBinning", {60, -0.3, 0.3}, "q_out/side/long binning of the CF 3D in LCMS (Nbins, lowlimit, uplimit)"}; // the next configarable is responsible for skipping (pseudo)randomly chosen ($value -1) pairs of events in the mixing process @@ -147,7 +148,7 @@ struct FemtoCorrelations { std::vector>> SEhistos_3D; std::vector>> MEhistos_3D; - std::vector>> qLCMSvskStar; + std::vector>> Add3dHistos; std::vector>> DoubleTrack_SE_histos_BC; // BC -- before cutting std::vector>> DoubleTrack_ME_histos_BC; // BC -- before cutting @@ -204,19 +205,26 @@ struct FemtoCorrelations { if (_fill3dCF) { std::vector> SEperMult_3D; std::vector> MEperMult_3D; - std::vector> qLCMSvskStarperMult; + std::vector> Add3dHistosperMult; for (unsigned int j = 0; j < _kTbins.value.size() - 1; j++) { auto hSE_3D = registry.add(Form("Cent%i/SE_3D_cent%i_kT%i", i, i, j), Form("SE_3D_cent%i_kT%i", i, j), kTH3F, {{CF3DqLCMSBinning, "q_out (GeV/c)"}, {CF3DqLCMSBinning, "q_side (GeV/c)"}, {CF3DqLCMSBinning, "q_long (GeV/c)"}}); auto hME_3D = registry.add(Form("Cent%i/ME_3D_cent%i_kT%i", i, i, j), Form("ME_3D_cent%i_kT%i", i, j), kTH3F, {{CF3DqLCMSBinning, "q_out (GeV/c)"}, {CF3DqLCMSBinning, "q_side (GeV/c)"}, {CF3DqLCMSBinning, "q_long (GeV/c)"}}); - auto hqLCMSvskStar = registry.add(Form("Cent%i/qLCMSvskStar_cent%i_kT%i", i, i, j), Form("qLCMSvskStar_cent%i_kT%i", i, j), kTH3F, {{CF3DqLCMSBinning, "q_out (GeV/c)"}, {CF3DqLCMSBinning, "q_side (GeV/c)"}, {CF3DqLCMSBinning, "q_long (GeV/c)"}}); SEperMult_3D.push_back(std::move(hSE_3D)); MEperMult_3D.push_back(std::move(hME_3D)); - qLCMSvskStarperMult.push_back(std::move(hqLCMSvskStar)); + + if (_fill3dAddHistos == 1) { + auto hAdd3dHistos = registry.add(Form("Cent%i/qLCMSvskStar_cent%i_kT%i", i, i, j), Form("qLCMSvskStar_cent%i_kT%i", i, j), kTH3F, {{CF3DqLCMSBinning, "q_out (GeV/c)"}, {CF3DqLCMSBinning, "q_side (GeV/c)"}, {CF3DqLCMSBinning, "q_long (GeV/c)"}}); + Add3dHistosperMult.push_back(std::move(hAdd3dHistos)); + } else if (_fill3dAddHistos == 2) { + auto hAdd3dHistos = registry.add(Form("Cent%i/qLCMSvsGout_cent%i_kT%i", i, i, j), Form("qLCMSvsGout_cent%i_kT%i", i, j), kTH3F, {{CF3DqLCMSBinning, "q_out (GeV/c)"}, {CF3DqLCMSBinning, "q_side (GeV/c)"}, {CF3DqLCMSBinning, "q_long (GeV/c)"}}); + Add3dHistosperMult.push_back(std::move(hAdd3dHistos)); + } } SEhistos_3D.push_back(std::move(SEperMult_3D)); MEhistos_3D.push_back(std::move(MEperMult_3D)); - qLCMSvskStar.push_back(std::move(qLCMSvskStarperMult)); + if (_fill3dAddHistos != 0) + Add3dHistos.push_back(std::move(Add3dHistosperMult)); } if (_fillDetaDphi > -1) { @@ -366,7 +374,10 @@ struct FemtoCorrelations { std::mt19937 mt(std::chrono::steady_clock::now().time_since_epoch().count()); TVector3 qLCMS = std::pow(-1, (mt() % 2)) * Pair->GetQLCMS(); // introducing randomness to the pair order ([first, second]); important only for 3D because if there are any sudden order/correlation in the tables, it could couse unwanted asymmetries in the final 3d rel. momentum distributions; irrelevant in 1D case because the absolute value of the rel.momentum is taken MEhistos_3D[multBin][kTbin]->Fill(qLCMS.X(), qLCMS.Y(), qLCMS.Z()); - qLCMSvskStar[multBin][kTbin]->Fill(qLCMS.X(), qLCMS.Y(), qLCMS.Z(), Pair->GetKstar()); + if (_fill3dAddHistos == 1) + Add3dHistos[multBin][kTbin]->Fill(qLCMS.X(), qLCMS.Y(), qLCMS.Z(), Pair->GetKstar()); + else if (_fill3dAddHistos == 2) + Add3dHistos[multBin][kTbin]->Fill(qLCMS.X(), qLCMS.Y(), qLCMS.Z(), Pair->GetGammaOut()); } } Pair->ResetPair(); @@ -380,7 +391,7 @@ struct FemtoCorrelations { LOGF(fatal, "One of passed PDG is 0!!!"); for (auto track : tracks) { - if (abs(track.template singleCollSel_as>().posZ()) > _vertexZ) + if (std::fabs(track.template singleCollSel_as>().posZ()) > _vertexZ) continue; if (_removeSameBunchPileup && !track.template singleCollSel_as>().isNoSameBunchPileup()) continue; @@ -400,7 +411,7 @@ struct FemtoCorrelations { continue; if (track.template singleCollSel_as>().occupancy() < _OccupancyCut.value.first || track.template singleCollSel_as>().occupancy() >= _OccupancyCut.value.second) continue; - if (abs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || abs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) + 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 diff --git a/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx b/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx index c9da488f56d..4c095f134df 100644 --- a/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dPairTaskMC.cxx @@ -321,7 +321,7 @@ struct FemtoCorrelationsMC { int trackPDG, trackOrigin; for (auto track : tracks) { - if (abs(track.template singleCollSel_as>().posZ()) > _vertexZ) + if (std::fabs(track.template singleCollSel_as>().posZ()) > _vertexZ) continue; if (track.tpcFractionSharedCls() > _tpcFractionSharedCls || track.itsNCls() < _itsNCls) continue; @@ -351,7 +351,7 @@ struct FemtoCorrelationsMC { if (trackOrigin > -1 && trackOrigin < 3) DCA_histos_1[centBin][track.origin()]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); - if (abs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || abs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) + 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; trackPDG = abs(track.pdgCode()); @@ -372,7 +372,7 @@ struct FemtoCorrelationsMC { if (trackOrigin > -1 && trackOrigin < 3) DCA_histos_2[centBin][track.origin()]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); - if (abs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || abs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) + 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; trackPDG = abs(track.pdgCode()); diff --git a/PWGCF/Femto3D/Tasks/femto3dQA.cxx b/PWGCF/Femto3D/Tasks/femto3dQA.cxx index ba04c6c61a0..e544b1bdacb 100644 --- a/PWGCF/Femto3D/Tasks/femto3dQA.cxx +++ b/PWGCF/Femto3D/Tasks/femto3dQA.cxx @@ -186,7 +186,7 @@ struct QAHistograms { if (_requestNoCollInTimeRangeStandard && !track.template singleCollSel_as().noCollInTimeRangeStandard()) continue; - if (abs(track.template singleCollSel_as().posZ()) > _vertexZ) + if (std::fabs(track.template singleCollSel_as().posZ()) > _vertexZ) continue; if (track.template singleCollSel_as().multPerc() < _centCut.value.first || track.template singleCollSel_as().multPerc() >= _centCut.value.second) continue; @@ -196,7 +196,7 @@ struct QAHistograms { continue; if ((track.tpcFractionSharedCls()) > _tpcFractionSharedCls || (track.itsNCls()) < _itsNCls) continue; - if (abs(track.dcaXY()) > _dcaXY.value[0] + _dcaXY.value[1] * std::pow(track.pt(), _dcaXY.value[2]) || abs(track.dcaZ()) > _dcaZ.value[0] + _dcaZ.value[1] * std::pow(track.pt(), _dcaZ.value[2])) + 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 constexpr (FillExtra) { diff --git a/PWGCF/Femto3D/Tools/checkPacking.cxx b/PWGCF/Femto3D/Tools/checkPacking.cxx index baa4322e553..51d26443200 100644 --- a/PWGCF/Femto3D/Tools/checkPacking.cxx +++ b/PWGCF/Femto3D/Tools/checkPacking.cxx @@ -24,22 +24,45 @@ using namespace o2; template -bool process(std::string outputName, int nevents = 100000) +bool process(const TString outputName, const int nevents = 100000) { class Container { public: Container() {} - void operator()(const float toPack) { mPacked = aod::singletrackselector::packInTable(toPack); } + void operator()(const float toPack) { mPacked = aod::singletrackselector::packSymmetric(toPack); } + void test(const float toPack) + { + auto bin = aod::singletrackselector::packSymmetric(toPack); + LOG(info) << toPack << " goes to " << aod::singletrackselector::unPackSymmetric(bin) << " bin " << static_cast(bin); + } T::binned_t mPacked = 0; - float unpack() { return aod::singletrackselector::unPack(mPacked); } + float unpack() { return aod::singletrackselector::unPackSymmetric(mPacked); } } container; - const float min = T::binned_min - 2; - const float max = T::binned_max + 2; + T::print(); + const float min = T::binned_min; + const float max = T::binned_max; + container.test(0); + container.test(0 + T::bin_width); + container.test(0 - T::bin_width); + container.test(0 - T::bin_width * 0.5); + const int nbins = (max - min) / T::bin_width; + std::vector xbins; + for (int i = 0; i <= nbins; i++) { + const float x = min + i * T::bin_width; + const auto ix = aod::singletrackselector::packSymmetric(x); + const float u = aod::singletrackselector::unPackSymmetric(ix); + LOG(info) << "Bin " << i << "/" << xbins.size() << " " << x << " => " << static_cast(ix) << " " << u; + if (i > 1) { + if (ix == aod::singletrackselector::packSymmetric(xbins.back())) { + continue; + } + } + xbins.push_back(u); + } LOG(info) << "Min = " << min << " Max = " << max; - TH1F* hgaus = new TH1F("hgaus", "", (max - min) / T::bin_width, - min, max); + TH1F* hgaus = new TH1F("hgaus", "", nbins, min + T::bin_width * 0.5, max + 0.5 * T::bin_width); hgaus->Print(); LOG(info) << "Bin width = " << T::bin_width << " vs histo " << hgaus->GetXaxis()->GetBinWidth(1); hgaus->SetLineColor(2); @@ -56,31 +79,47 @@ bool process(std::string outputName, int nevents = 100000) huniformPacked->SetLineStyle(2); for (int i = 0; i < nevents; i++) { - float nsigma = gRandom->Gaus(0, 1); - hgaus->Fill(nsigma); - aod::pidutils::packInTable(nsigma, container); + float randomValue = gRandom->Gaus(0, 1); + hgaus->Fill(randomValue); + container(randomValue); hgausPacked->Fill(container.unpack()); - nsigma = gRandom->Uniform(-10, 10); - huniform->Fill(nsigma); - aod::pidutils::packInTable(nsigma, container); + randomValue = gRandom->Uniform(-10, 10); + huniform->Fill(randomValue); + container(randomValue); huniformPacked->Fill(container.unpack()); } TCanvas* can = new TCanvas("can"); hgaus->Draw(); hgausPacked->Draw("same"); - outputName = "/tmp/" + outputName + ".pdf"; - can->SaveAs(Form("%s[", outputName.c_str())); - can->SaveAs(outputName.c_str()); + TString imgoutputName = "/tmp/" + outputName + ".pdf"; + can->SaveAs("/tmp/" + outputName + "_Gaus.root"); + can->SaveAs(Form("%s[", imgoutputName.Data())); + can->SaveAs(imgoutputName.Data()); huniform->Draw(); huniformPacked->Draw("same"); - can->SaveAs(outputName.c_str()); - can->SaveAs(Form("%s]", outputName.c_str())); + can->SaveAs(imgoutputName.Data()); + can->SaveAs(Form("%s]", imgoutputName.Data())); const bool gausOk = (hgaus->GetBinContent(hgaus->FindBin(0)) == hgausPacked->GetBinContent(hgausPacked->FindBin(0))); + if (!gausOk) { + LOG(info) << "Gaus packing/unpacking failed"; + } + const bool gausMeanOk = (hgaus->GetMean() == hgausPacked->GetMean()); + if (!gausMeanOk) { + LOG(info) << "Gaus packing/unpacking mean failed"; + } + const bool uniformOk = (huniform->GetBinContent(huniform->FindBin(0)) == huniformPacked->GetBinContent(huniformPacked->FindBin(0))); - return gausOk && uniformOk; + if (!uniformOk) { + LOG(info) << "Uniform packing/unpacking failed"; + } + const bool uniformMeanOk = (huniform->GetMean() == huniformPacked->GetMean()); + if (!uniformMeanOk) { + LOG(info) << "Uniform packing/unpacking mean failed"; + } + return gausOk && uniformOk && gausMeanOk && uniformMeanOk; } int main(int /*argc*/, char* /*argv*/[]) @@ -93,4 +132,11 @@ int main(int /*argc*/, char* /*argv*/[]) LOG(fatal) << "Packing and unpacking of PID signals (nsigmas) in the Femto PID response is incorrect."; } + LOG(info) << "Checking the packing and unpacking of PID signals (dca) in the Femto DCA."; + if (process("Dca", 100000)) { + LOG(info) << "Packing and unpacking of DCA signals (dca) in the Femto is correct."; + } else { + LOG(fatal) << "Packing and unpacking of DCA signals (dca) in the Femto is incorrect."; + } + } // main diff --git a/PWGCF/FemtoDream/Core/femtoDreamContainer.h b/PWGCF/FemtoDream/Core/femtoDreamContainer.h index dace1424255..8a9038e6198 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamContainer.h +++ b/PWGCF/FemtoDream/Core/femtoDreamContainer.h @@ -280,7 +280,21 @@ class FemtoDreamContainer setPair_base(femtoObs, mT, part1, part2, mult, multPercentile, use4dplots, extendedplots); if constexpr (isMC) { - if (part1.has_fdMCParticle() && part2.has_fdMCParticle()) { + if constexpr (isHF) { + // calculate the femto observable and the mT with MC truth information + if constexpr (mFemtoObs == femtoDreamContainer::Observable::kstar) { + femtoObsMC = FemtoDreamMath::getkstar(part1.fdMCParticle(), mMassOne, part2, mMassTwo); + } + const float mTMC = FemtoDreamMath::getmT(part1.fdMCParticle(), mMassOne, part2, mMassTwo); + + if (abs(part1.fdMCParticle().pdgMCTruth()) == mPDGOne) { // Note: all pair-histogramms are filled with MC truth information ONLY in case of non-fake candidates + setPair_base(femtoObsMC, mTMC, part1.fdMCParticle(), part2, mult, multPercentile, use4dplots, extendedplots); + setPair_MC(femtoObsMC, femtoObs, mT, mult, part1.fdMCParticle().partOriginMCTruth(), part2.flagMc(), smearingByOrigin); + } else { + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[o2::aod::femtodreamMCparticle::MCType::kTruth]) + HIST("/hFakePairsCounter"), 0); + } + + } else if (part1.has_fdMCParticle() && part2.has_fdMCParticle()) { // calculate the femto observable and the mT with MC truth information if constexpr (mFemtoObs == femtoDreamContainer::Observable::kstar) { femtoObsMC = FemtoDreamMath::getkstar(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); diff --git a/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h b/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h index 65bc644ea24..30686bcad09 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h +++ b/PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h @@ -22,6 +22,7 @@ #include #include "PWGCF/DataModel/FemtoDerived.h" #include "Framework/HistogramRegistry.h" +#include "CommonConstants/PhysicsConstants.h" using namespace o2::framework; @@ -100,16 +101,22 @@ class FemtoDreamParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_K").c_str(), "n#sigma_{TPC}^{K}", kTH2F, {pTAxis, NsigmaTPCAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_p").c_str(), "n#sigma_{TPC}^{p}", kTH2F, {pTAxis, NsigmaTPCAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_d").c_str(), "n#sigma_{TPC}^{d}", kTH2F, {pTAxis, NsigmaTPCAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_tr").c_str(), "n#sigma_{TPC}^{tr}", kTH2F, {pTAxis, NsigmaTPCAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_he3").c_str(), "n#sigma_{TPC}^{he3}", kTH2F, {pTAxis, NsigmaTPCAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_el").c_str(), "n#sigma_{TOF}^{e}", kTH2F, {pTAxis, NsigmaTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_pi").c_str(), "n#sigma_{TOF}^{#pi}", kTH2F, {pTAxis, NsigmaTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_K").c_str(), "n#sigma_{TOF}^{K}", kTH2F, {pTAxis, NsigmaTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_p").c_str(), "n#sigma_{TOF}^{p}", kTH2F, {pTAxis, NsigmaTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_d").c_str(), "n#sigma_{TOF}^{d}", kTH2F, {pTAxis, NsigmaTOFAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_tr").c_str(), "n#sigma_{TOF}^{tr}", kTH2F, {pTAxis, NsigmaTOFAxis}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_he3").c_str(), "n#sigma_{TOF}^{he3}", kTH2F, {pTAxis, NsigmaTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_el").c_str(), "n#sigma_{comb}^{e}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_pi").c_str(), "n#sigma_{comb}^{#pi}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_K").c_str(), "n#sigma_{comb}^{K}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_p").c_str(), "n#sigma_{comb}^{p}", kTH2F, {pTAxis, NsigmaTPCTOFAxis}); 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}); if (correlatedPlots) { mHistogramRegistry->add((folderName + folderSuffix + "/HighDcorrelator").c_str(), "", kTHnSparseF, {multAxis, multPercentileAxis, pTAxis, etaAxis, phiAxis, tempFitVarAxis, dcazAxis, NsigmaTPCAxis, NsigmaTOFAxis}); } @@ -327,16 +334,22 @@ class FemtoDreamParticleHisto mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTPC_K"), momentum, part.tpcNSigmaKa()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTPC_p"), momentum, part.tpcNSigmaPr()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTPC_d"), momentum, part.tpcNSigmaDe()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTPC_tr"), momentum, part.tpcNSigmaTr()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTPC_he3"), momentum, part.tpcNSigmaHe()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_el"), momentum, part.tofNSigmaEl()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_pi"), momentum, part.tofNSigmaPi()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_K"), momentum, part.tofNSigmaKa()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_p"), momentum, part.tofNSigmaPr()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_d"), momentum, part.tofNSigmaDe()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_tr"), momentum, part.tofNSigmaTr()); + mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaTOF_he3"), momentum, part.tofNSigmaHe()); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_el"), momentum, std::sqrt(part.tpcNSigmaEl() * part.tpcNSigmaEl() + part.tofNSigmaEl() * part.tofNSigmaEl())); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_pi"), momentum, std::sqrt(part.tpcNSigmaPi() * part.tpcNSigmaPi() + part.tofNSigmaPi() * part.tofNSigmaPi())); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_K"), momentum, std::sqrt(part.tpcNSigmaKa() * part.tpcNSigmaKa() + part.tofNSigmaKa() * part.tofNSigmaKa())); mHistogramRegistry->fill(HIST(o2::aod::femtodreamparticle::ParticleTypeName[mParticleType]) + HIST(mFolderSuffix[mFolderSuffixType]) + HIST(o2::aod::femtodreamMCparticle::MCTypeName[mc]) + HIST("/nSigmaComb_p"), momentum, std::sqrt(part.tpcNSigmaPr() * part.tpcNSigmaPr() + part.tofNSigmaPr() * part.tofNSigmaPr())); 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())); if (correlatedPlots) { @@ -344,26 +357,34 @@ class FemtoDreamParticleHisto float pidTOF = 0.; switch (abs(mPDG)) { - case 11: + case kElectron: pidTPC = part.tpcNSigmaEl(); pidTOF = part.tofNSigmaEl(); break; - case 211: + case kPiPlus: pidTPC = part.tpcNSigmaPi(); pidTOF = part.tofNSigmaPi(); break; - case 321: + case kKPlus: pidTPC = part.tpcNSigmaKa(); pidTOF = part.tofNSigmaKa(); break; - case 2212: + case kProton: pidTPC = part.tpcNSigmaPr(); pidTOF = part.tofNSigmaPr(); break; - case 1000010020: + case constants::physics::kDeuteron: pidTPC = part.tpcNSigmaDe(); pidTOF = part.tofNSigmaDe(); break; + case constants::physics::kTriton: + pidTPC = part.tpcNSigmaTr(); + pidTOF = part.tofNSigmaTr(); + break; + case constants::physics::kHelium3: + pidTPC = part.tpcNSigmaHe(); + pidTOF = part.tofNSigmaHe(); + break; default: LOG(warn) << "PDG code " << mPDG << " not supported. No PID information will be used."; } diff --git a/PWGCF/FemtoDream/Core/femtoDreamUtils.h b/PWGCF/FemtoDream/Core/femtoDreamUtils.h index 1d6cb84b78c..cf3ba2b1585 100644 --- a/PWGCF/FemtoDream/Core/femtoDreamUtils.h +++ b/PWGCF/FemtoDream/Core/femtoDreamUtils.h @@ -18,87 +18,12 @@ #include #include -#include -#include -#include "Framework/ASoAHelpers.h" #include "CommonConstants/PhysicsConstants.h" #include "PWGCF/DataModel/FemtoDerived.h" namespace o2::analysis::femtoDream { -// TODO: remove all these functions pertaining to PID selection for the next tutorial session they have been removed from femtodream tasks but are still present in tutorial files - -enum kDetector { kTPC, - kTPCTOF, - kNdetectors }; - -/// internal function that returns the kPIDselection element corresponding to a -/// specifica n-sigma value \param nSigma number of sigmas for PID -/// \param vNsigma vector with the number of sigmas of interest -/// \return kPIDselection corresponding to n-sigma -int getPIDselection(float nSigma, std::vector vNsigma) -{ - std::sort(vNsigma.begin(), vNsigma.end(), std::greater<>()); - auto it = std::find(vNsigma.begin(), vNsigma.end(), nSigma); - if (it == vNsigma.end()) { - it = vNsigma.begin() + 1; - LOG(warn) << "Invalid value of nSigma: " << nSigma << ". Return the first value of the vector: " << *(it); - } - return std::distance(vNsigma.begin(), it); -} - -/// function that checks whether the PID selection specified in the vectors is -/// fulfilled -/// \param pidcut Bit-wise container for the PID -/// \param vSpecies vector with ID corresponding to the selected species (output from cutculator) -/// \param nSpecies number of available selected species (output from cutculator) -/// \param nSigma number of sigma selection fo PID -/// \param vNsigma vector with available n-sigma selections for PID -/// \param kDetector enum corresponding to the PID technique -/// \return Whether the PID selection specified in the vectors is fulfilled -bool isPIDSelected(aod::femtodreamparticle::cutContainerType pidcut, - int vSpecies, - int nSpecies, - float nSigma, - std::vector vNsigma, - kDetector iDet) -{ - int iNsigma = getPIDselection(nSigma, vNsigma); - int nDet = static_cast(kDetector::kNdetectors); - int bit_to_check = 1 + (vNsigma.size() - (iNsigma + 1)) * nDet * nSpecies + (nSpecies - (vSpecies + 1)) * nSpecies + (nDet - 1 - iDet); - return ((pidcut >> (bit_to_check)) & 1) == 1; -}; - -/// function that checks whether the PID selection specified in the vectors is fulfilled, depending on the momentum TPC or TPC+TOF PID is conducted -/// \param pidcut Bit-wise container for the PID -/// \param momentum Momentum of the track -/// \param pidThresh Momentum threshold that separates between TPC and TPC+TOF PID -/// \param vSpecies Vector with the species of interest (number returned by the CutCulator) -/// \param nSpecies number of available selected species (output from cutculator) -/// \param nSigmaTPC Number of TPC sigmas for selection -/// \param nSigmaTPCTOF Number of TPC+TOF sigmas for selection (circular selection) -/// \return Whether the PID selection is fulfilled -bool isFullPIDSelected(aod::femtodreamparticle::cutContainerType const& pidCut, - float momentum, - float pidThresh, - int vSpecies, - int nSpecies, - std::vector vNsigma, - float nSigmaTPC, - float nSigmaTPCTOF) -{ - bool pidSelection = true; - if (momentum < pidThresh) { - /// TPC PID only - pidSelection = isPIDSelected(pidCut, vSpecies, nSpecies, nSigmaTPC, vNsigma, kDetector::kTPC); - } else { - /// TPC + TOF PID - pidSelection = isPIDSelected(pidCut, vSpecies, nSpecies, nSigmaTPCTOF, vNsigma, kDetector::kTPCTOF); - } - return pidSelection; -}; - /// function for getting the mass of a particle depending on the pdg code /// \param pdgCode pdg code of the particle /// \return mass of the particle @@ -109,24 +34,33 @@ inline float getMass(int pdgCode) float mass = 0; // add new particles if necessary here switch (std::abs(pdgCode)) { - case kPiPlus: // charged pions, changed magic number as per their pdg name + case kPiPlus: mass = o2::constants::physics::MassPiPlus; break; - case kKPlus: // charged kaon + case kKPlus: mass = o2::constants::physics::MassKPlus; break; - case kProton: // proton + case kProton: mass = o2::constants::physics::MassProton; break; - case kLambda0: // Lambda + case kLambda0: mass = o2::constants::physics::MassLambda; break; - case o2::constants::physics::Pdg::kLambdaCPlus: // Charm Lambda + case o2::constants::physics::Pdg::kPhi: + mass = o2::constants::physics::MassPhi; + break; + case o2::constants::physics::Pdg::kLambdaCPlus: mass = o2::constants::physics::MassLambdaCPlus; break; - case o2::constants::physics::Pdg::kDeuteron: // Deuteron + case o2::constants::physics::Pdg::kDeuteron: mass = o2::constants::physics::MassDeuteron; break; + case o2::constants::physics::Pdg::kTriton: + mass = o2::constants::physics::MassTriton; + break; + case o2::constants::physics::Pdg::kHelium3: + mass = o2::constants::physics::MassHelium3; + break; default: LOG(fatal) << "PDG code is not suppored"; } @@ -138,10 +72,10 @@ inline int checkDaughterType(o2::aod::femtodreamparticle::ParticleType partType, int partOrigin = 0; if (partType == o2::aod::femtodreamparticle::ParticleType::kTrack) { switch (abs(motherPDG)) { - case 3122: + case kLambda0: partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterLambda; break; - case 3222: + case kSigmaPlus: partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterSigmaplus; break; default: @@ -153,10 +87,10 @@ inline int checkDaughterType(o2::aod::femtodreamparticle::ParticleType partType, } else if (partType == o2::aod::femtodreamparticle::ParticleType::kV0Child) { switch (abs(motherPDG)) { - case 3122: + case kLambda0: partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterLambda; break; - case 3222: + case kSigmaPlus: partOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kSecondaryDaughterSigmaplus; break; default: diff --git a/PWGCF/FemtoDream/TableProducer/CMakeLists.txt b/PWGCF/FemtoDream/TableProducer/CMakeLists.txt index 0f8d87d9570..569a6de54cc 100644 --- a/PWGCF/FemtoDream/TableProducer/CMakeLists.txt +++ b/PWGCF/FemtoDream/TableProducer/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(femtodream-producer SOURCES femtoDreamProducerTask.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(femtodream-producer-reduced diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx index 0739c7890e7..f5e72eeda89 100644 --- a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerReducedTask.cxx @@ -50,10 +50,10 @@ using FemtoFullCollisionMC = soa::Join::iterator; using FemtoFullTracks = soa::Join; + aod::pidTPCFullEl, aod::pidTPCFullMu, aod::pidTPCFullPi, aod::pidTPCFullKa, + aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullTr, aod::pidTPCFullHe, + aod::pidTOFFullEl, aod::pidTOFFullMu, aod::pidTOFFullPi, aod::pidTOFFullKa, + aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullTr, aod::pidTOFFullHe>; } // namespace o2::aod struct femtoDreamProducerReducedTask { @@ -298,11 +298,15 @@ struct femtoDreamProducerReducedTask { track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tpcNSigmaDe(), + track.tpcNSigmaTr(), + track.tpcNSigmaHe(), track.tofNSigmaEl(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), track.tofNSigmaDe(), + track.tofNSigmaTr(), + track.tofNSigmaHe(), -999., -999., -999., -999., -999., -999.); } } diff --git a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx index dc2cfbc407f..fa215542a6c 100644 --- a/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx +++ b/PWGCF/FemtoDream/TableProducer/femtoDreamProducerTask.cxx @@ -32,11 +32,12 @@ #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" -#include "Math/Vector4D.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; @@ -47,6 +48,7 @@ namespace o2::aod { using FemtoFullCollision = soa::Join::iterator; +using FemtoFullCollision_noCent = soa::Join::iterator; using FemtoFullCollisionMC = soa::Join::iterator; using FemtoFullCollision_noCent_MC = soa::Join::iterator; using FemtoFullMCgenCollisions = soa::Join; @@ -54,10 +56,20 @@ using FemtoFullMCgenCollision = FemtoFullMCgenCollisions::iterator; using FemtoFullTracks = soa::Join; + aod::pidTPCFullEl, aod::pidTPCFullPi, aod::pidTPCFullKa, + aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullTr, aod::pidTPCFullHe, + aod::pidTOFFullEl, aod::pidTOFFullPi, aod::pidTOFFullKa, + aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullTr, aod::pidTOFFullHe>; } // 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) { @@ -73,6 +85,8 @@ int getRowDaughters(int daughID, T const& vecID) struct femtoDreamProducerTask { + Zorro zorro; + Produces outputCollision; Produces outputMCCollision; Produces outputCollsMCLabels; @@ -89,12 +103,21 @@ struct femtoDreamProducerTask { /// 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"}; + + // 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 ConfTrkRejectNotPropagated{"ConfTrkRejectNotPropagated", false, "True: reject not propagated tracks"}; // Configurable ConfRejectITSHitandTOFMissing{ "ConfRejectITSHitandTOFMissing", false, "True: reject if neither ITS hit nor TOF timing satisfied"}; @@ -141,6 +164,22 @@ 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"}; + 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) && @@ -151,17 +190,19 @@ struct femtoDreamProducerTask { HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry TrackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry V0Registry{"V0", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry ResoRegistry{"Reso", {}, OutputObjHandlingPolicy::AnalysisObject}; int mRunNumber; float mMagField; + std::string zorroTriggerNames = ""; Service ccdb; /// Accessing the CCDB void init(InitContext&) { - if (doprocessData == false && doprocessMC == false && doprocessMC_noCentrality == false) { + if (doprocessData == false && doprocessData_noCentrality == false && doprocessMC == false && doprocessMC_noCentrality == 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)) { + 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)) { LOGF(fatal, "Cannot enable more than one process switch at the same time. " "Please choose one."); @@ -170,6 +211,25 @@ struct femtoDreamProducerTask { int CutBits = 8 * sizeof(o2::aod::femtodreamparticle::cutContainerType); TrackRegistry.add("AnalysisQA/CutCounter", "; Bit; Counter", kTH1F, {{CutBits + 1, -0.5, CutBits + 0.5}}); 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}}); + 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); @@ -244,7 +304,7 @@ struct femtoDreamProducerTask { } /// Function to retrieve the nominal magnetic field in kG (0.1T) and convert it directly to T - void getMagneticFieldTesla(aod::BCsWithTimestamps::iterator bc) + 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 @@ -278,6 +338,11 @@ struct femtoDreamProducerTask { } mMagField = output; mRunNumber = bc.runNumber(); + + // Init for zorro to get trigger flags + if (ConfEnableTriggerSelection) { + zorro.initCCDB(ccdb.service, mRunNumber, timestamp, zorroTriggerNames); + } } template @@ -300,16 +365,21 @@ struct femtoDreamProducerTask { 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.); } else { - outputDebugParts(-999., -999., -999., -999., -999., -999., -999., -999., - -999., -999., -999., -999., -999., -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., particle.dcaV0daughters(), particle.v0radius(), particle.x(), @@ -391,6 +461,14 @@ struct femtoDreamProducerTask { template void fillCollisionsAndTracksAndV0(CollisionType const& col, TrackType const& tracks, V0Type const& fullV0s) { + // 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; @@ -431,6 +509,7 @@ 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; for (auto& track : tracks) { /// if the most open selection criteria are not fulfilled there is no @@ -459,6 +538,32 @@ struct femtoDreamProducerTask { 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) { @@ -537,7 +642,7 @@ struct femtoDreamProducerTask { indexChildID, v0.mLambda(), v0.mAntiLambda()); - if (ConfIsDebug) { + if (ConfIsDebug.value) { fillDebugParticle(postrack); // QA for positive daughter fillDebugParticle(negtrack); // QA for negative daughter fillDebugParticle(v0); // QA for v0 @@ -547,6 +652,70 @@ struct femtoDreamProducerTask { } } } + + 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., -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 + } + } + } + } + } } void @@ -556,13 +725,27 @@ struct femtoDreamProducerTask { o2::aod::V0Datas const& fullV0s) { // get magnetic field for run - getMagneticFieldTesla(col.bc_as()); + initCCDB_Mag_Trig(col.bc_as()); // fill the tables fillCollisionsAndTracksAndV0(col, tracks, fullV0s); } PROCESS_SWITCH(femtoDreamProducerTask, 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) + { + // get magnetic field for run + initCCDB_Mag_Trig(col.bc_as()); + // fill the tables + fillCollisionsAndTracksAndV0(col, tracks, fullV0s); + } + PROCESS_SWITCH(femtoDreamProducerTask, processData_noCentrality, + "Provide experimental data without centrality information", false); + void processMC(aod::FemtoFullCollisionMC const& col, aod::BCsWithTimestamps const&, soa::Join const& tracks, @@ -571,7 +754,7 @@ struct femtoDreamProducerTask { soa::Join const& fullV0s) /// \todo with FilteredFullV0s { // get magnetic field for run - getMagneticFieldTesla(col.bc_as()); + initCCDB_Mag_Trig(col.bc_as()); // fill the tables fillCollisionsAndTracksAndV0(col, tracks, fullV0s); } @@ -585,7 +768,7 @@ struct femtoDreamProducerTask { soa::Join const& fullV0s) /// \todo with FilteredFullV0s { // get magnetic field for run - getMagneticFieldTesla(col.bc_as()); + initCCDB_Mag_Trig(col.bc_as()); // fill the tables fillCollisionsAndTracksAndV0(col, tracks, fullV0s); } diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx index cc449887df1..78fe8c1cce4 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamHashTask.cxx @@ -31,7 +31,7 @@ struct femtoDreamPairHashTask { std::vector CastCfgVtxBins, CastCfgMultBins; - Produces hashes; + Produces hashes; void init(InitContext&) { diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx index 24836fda097..371324a96e8 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackTrack.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include "TRandom3.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -49,30 +50,32 @@ struct femtoDreamPairTaskTrackTrack { /// General options struct : ConfigurableGroup { - Configurable IsMC{"Option.IsMC", false, "Enable additional Histogramms in the case of runninger over Monte Carlo"}; - Configurable Use4D{"Option.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{"Option.ExtendedPlots", false, "Enable additional three dimensional histogramms. High memory consumption. Use for debugging"}; - Configurable HighkstarCut{"Option.HighkstarCut", -1., "Set a cut for high k*, above which the pairs are rejected. Set it to -1 to deactivate it"}; - Configurable SameSpecies{"Option.SameSpecies", false, "Set to true if particle 1 and particle 2 are the same species"}; - Configurable MixEventWithPairs{"Option.MixEventWithPairs", false, "Only use events that contain particle 1 and partile 2 for the event mixing"}; - Configurable RandomizePair{"Option.RandomizePair", true, "Randomly mix particle 1 and particle 2 in case both are identical"}; - Configurable CPROn{"Option.CPROn", true, "Close Pair Rejection"}; - Configurable CPROld{"Option.CPROld", false, "Set to FALSE to use fixed version of CPR (for testing now, will be default soon)"}; - Configurable CPRSepMeSe{"Option.CPRSepMESE", true, "Use seperated plots for same and mixed event for CPR plots"}; - Configurable CPRPlotPerRadii{"Option.CPRPlotPerRadii", false, "Plot CPR per radii"}; - Configurable CPRdeltaPhiMax{"Option.CPRdeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; - Configurable CPRdeltaEtaMax{"Option.CPRdeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; - Configurable DCACutPtDep{"Option.DCACutPtDep", false, "Use pt dependent dca cut"}; - ConfigurableAxis Dummy{"Option.Dummy", {1, 0, 1}, "Dummy axis"}; - Configurable SmearingByOrigin{"Option.SmearingByOrigin", false, "Obtain the smearing matrix differential in the MC origin of particle 1 and particle 2. High memory consumption"}; + std::string prefix = std::string("Option"); + Configurable IsMC{"IsMC", false, "Enable additional Histogramms in the case of runninger over Monte Carlo"}; + 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 SameSpecies{"SameSpecies", false, "Set to true if particle 1 and particle 2 are the same species"}; + Configurable MixEventWithPairs{"MixEventWithPairs", false, "Only use events that contain particle 1 and partile 2 for the event mixing"}; + Configurable RandomizePair{"RandomizePair", true, "Randomly mix particle 1 and particle 2 in case both are identical"}; + 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 CPRSepMeSe{"CPRSepMESE", true, "Use seperated plots for same and mixed event for CPR plots"}; + 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 SmearingByOrigin{"SmearingByOrigin", false, "Obtain the smearing matrix differential in the MC origin of particle 1 and particle 2. High memory consumption"}; + ConfigurableAxis Dummy{"Dummy", {1, 0, 1}, "Dummy axis"}; } Option; /// Event selection struct : ConfigurableGroup { - Configurable MultMin{"EventSel.MultMin", 0, "Minimum Multiplicity (MultNtr)"}; - Configurable MultMax{"EventSel.MultMax", 99999, "Maximum Multiplicity (MultNtr)"}; - Configurable MultPercentileMin{"EventSel.MultPercentileMin", 0, "Maximum Multiplicity Percentile"}; - Configurable MultPercentileMax{"EventSel.MultPercentileMax", 100, "Minimum Multiplicity Percentile"}; + std::string prefix = std::string("EventSel"); + Configurable MultMin{"MultMin", 0, "Minimum Multiplicity (MultNtr)"}; + Configurable MultMax{"MultMax", 99999, "Maximum Multiplicity (MultNtr)"}; + Configurable MultPercentileMin{"MultPercentileMin", 0, "Maximum Multiplicity Percentile"}; + Configurable MultPercentileMax{"MultPercentileMax", 100, "Minimum Multiplicity Percentile"}; } EventSel; Filter EventMultiplicity = aod::femtodreamcollision::multNtr >= EventSel.MultMin && aod::femtodreamcollision::multNtr <= EventSel.MultMax; @@ -92,18 +95,19 @@ struct femtoDreamPairTaskTrackTrack { /// Track 1 struct : ConfigurableGroup { - Configurable PDGCode{"Track1.PDGCode", 2212, "PDG code of particle 1 (Track)"}; - Configurable CutBit{"Track1.CutBit", 3191978, "Selection bit from cutCulator for particle 1 (Track)"}; - Configurable TPCBit{"Track1.TPCBit", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; - Configurable TPCBit_Reject{"Track1.TPCBit_Reject", 0, "PID TPC bit from cutCulator to reject a particle hypothesis for particle 1 (set to 0 to ignore)"}; - Configurable TPCTOFBit{"Track1.TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 1 (Track)"}; - Configurable PIDThres{"Track1.PIDThres", 0.75, "Momentum threshold for PID selection for particle 1 (Track)"}; - Configurable PtMin{"Track1.PtMin", 0., "Minimum pT of partricle 1 (Track)"}; - Configurable PtMax{"Track1.PtMax", 999., "Maximum pT of partricle 1 (Track)"}; - Configurable EtaMin{"Track1.EtaMin", -10., "Minimum eta of partricle 1 (Track)"}; - Configurable EtaMax{"Track1.EtaMax", 10., "Maximum eta of partricle 1 (Track)"}; - Configurable TempFitVarMin{"Track1.TempFitVarMin", -10., "Minimum DCAxy of partricle 1 (Track)"}; - Configurable TempFitVarMax{"Track1.TempFitVarMax", 10., "Maximum DCAxy of partricle 1 (Track)"}; + std::string prefix = std::string("Track1"); + Configurable PDGCode{"PDGCode", 2212, "PDG code of particle 1 (Track)"}; + Configurable CutBit{"CutBit", 3191978, "Selection bit from cutCulator for particle 1 (Track)"}; + Configurable TPCBit{"TPCBit", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; + Configurable TPCBit_Reject{"TPCBit_Reject", 0, "PID TPC bit from cutCulator to reject a particle hypothesis for particle 1 (set to 0 to ignore)"}; + 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 @@ -136,18 +140,19 @@ struct femtoDreamPairTaskTrackTrack { /// Track 2 struct : ConfigurableGroup { - Configurable PDGCode{"Track2.PDGCode", 2212, "PDG code of particle 2 (Track)"}; - Configurable CutBit{"Track2.CutBit", 3191978, "Selection bit from cutCulator for particle 2 (Track)"}; - Configurable TPCBit{"Track2.TPCBit", 4, "PID TPC bit from cutCulator for particle 2 (Track)"}; - Configurable TPCBit_Reject{"Track2.TPCBit_Reject", 0, "PID TPC bit from cutCulator to reject a particle hypothesis for particle 2 (set to 0 to ignore)"}; - Configurable TPCTOFBit{"Track2.TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 2 (Track)"}; - Configurable PIDThres{"Track2.PIDThres", 0.75, "Momentum threshold for PID selection for particle 2 (Track)"}; - Configurable PtMin{"Track2.PtMin", 0., "Minimum pT of particle 2 (Track)"}; - Configurable PtMax{"Track2.PtMax", 999., "Maximum pT of particle 2 (Track)"}; - Configurable EtaMin{"Track2.EtaMin", -10., "Minimum eta of particle 2 (Track)"}; - Configurable EtaMax{"Track2.EtaMax", 10., "Maximum eta of particle 2 (Track)"}; - Configurable TempFitVarMin{"Track2.TempFitVarMin", -10., "Minimum DCAxy of partricle 1 (Track)"}; - Configurable TempFitVarMax{"Track2.TempFitVarMax", 10., "Maximum DCAxy of partricle 1 (Track)"}; + std::string prefix = std::string("Track2"); + Configurable PDGCode{"PDGCode", 2212, "PDG code of particle 2 (Track)"}; + Configurable CutBit{"CutBit", 3191978, "Selection bit from cutCulator for particle 2 (Track)"}; + Configurable TPCBit{"TPCBit", 4, "PID TPC bit from cutCulator for particle 2 (Track)"}; + Configurable TPCBit_Reject{"TPCBit_Reject", 0, "PID TPC bit from cutCulator to reject a particle hypothesis for particle 2 (set to 0 to ignore)"}; + Configurable TPCTOFBit{"TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 2 (Track)"}; + Configurable PIDThres{"PIDThres", 0.75, "Momentum threshold for PID selection for particle 2 (Track)"}; + Configurable PtMin{"PtMin", 0., "Minimum pT of particle 2 (Track)"}; + Configurable PtMax{"PtMax", 999., "Maximum pT of particle 2 (Track)"}; + Configurable EtaMin{"EtaMin", -10., "Minimum eta of particle 2 (Track)"}; + Configurable EtaMax{"EtaMax", 10., "Maximum eta of particle 2 (Track)"}; + Configurable TempFitVarMin{"TempFitVarMin", -10., "Minimum DCAxy of partricle 1 (Track)"}; + Configurable TempFitVarMax{"TempFitVarMax", 10., "Maximum DCAxy of partricle 1 (Track)"}; } Track2; /// Partition for track 2 @@ -221,29 +226,34 @@ struct femtoDreamPairTaskTrackTrack { FemtoDreamDetaDphiStar pairCloseRejectionSE; FemtoDreamDetaDphiStar pairCloseRejectionME; /// Histogram output - HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry Registry{"Output", {}, OutputObjHandlingPolicy::AnalysisObject}; TRandom3* random; void init(InitContext& context) { + + // setup columnpolicy for binning + colBinningMult = {{Mixing.VztxMixBins, Mixing.MultMixBins}, true}; + colBinningMultPercentile = {{Mixing.VztxMixBins, Mixing.MultPercentileMixBins}, true}; + colBinningMultMultPercentile = {{Mixing.VztxMixBins, Mixing.MultMixBins, Mixing.MultPercentileMixBins}, true}; + if (Option.RandomizePair.value) { random = new TRandom3(0); } - eventHisto.init(&qaRegistry, Option.IsMC); - trackHistoPartOne.init(&qaRegistry, 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); + 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); if (!Option.SameSpecies) { - trackHistoPartTwo.init(&qaRegistry, 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.IsMC, Track2.PDGCode); } - sameEventCont.init(&resultRegistry, + sameEventCont.init(&Registry, Binning.kstar, Binning.pT, Binning.kT, Binning.mT, Mixing.MultMixBins, Mixing.MultPercentileMixBins, Binning4D.kstar, Binning4D.mT, Binning4D.mult, Binning4D.multPercentile, Option.IsMC, Option.Use4D, Option.ExtendedPlots, Option.HighkstarCut, Option.SmearingByOrigin); - mixedEventCont.init(&resultRegistry, + mixedEventCont.init(&Registry, Binning.kstar, Binning.pT, Binning.kT, Binning.mT, Mixing.MultMixBins, Mixing.MultPercentileMixBins, Binning4D.kstar, Binning4D.mT, Binning4D.mult, Binning4D.multPercentile, Option.IsMC, Option.Use4D, Option.ExtendedPlots, @@ -251,10 +261,10 @@ struct femtoDreamPairTaskTrackTrack { Option.SmearingByOrigin); sameEventCont.setPDGCodes(Track1.PDGCode, Track2.PDGCode); mixedEventCont.setPDGCodes(Track1.PDGCode, Track2.PDGCode); - pairCleaner.init(&qaRegistry); + pairCleaner.init(&Registry); if (Option.CPROn.value) { - pairCloseRejectionSE.init(&resultRegistry, &qaRegistry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 1, Option.CPROld.value); - pairCloseRejectionME.init(&resultRegistry, &qaRegistry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 2, Option.CPROld.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); } // get bit for the collision mask diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx index 3c58faddfb4..dbaaacedfe8 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamPairTaskTrackV0.cxx @@ -16,13 +16,13 @@ #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 "Framework/StepTHn.h" #include "PWGCF/DataModel/FemtoDerived.h" #include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h" @@ -45,152 +45,172 @@ struct femtoDreamPairTaskTrackV0 { /// General options struct : ConfigurableGroup { - Configurable IsMC{"Option.IsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; - Configurable Use4D{"Option.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{"Option.ExtendedPlots", false, "Enable additional three dimensional histogramms. High memory consumption. Use for debugging"}; - Configurable HighkstarCut{"Option.HighkstarCut", -1., "Set a cut for high k*, above which the pairs are rejected. Set it to -1 to deactivate it"}; - Configurable CPROn{"Option.CPROn", true, "Close Pair Rejection"}; - Configurable CPROld{"Option.CPROld", false, "Set to FALSE to use fixed version of CPR (for testing now, will be default soon)"}; - Configurable CPRPlotPerRadii{"Option.CPRPlotPerRadii", false, "Plot CPR per radii"}; - Configurable CPRdeltaPhiMax{"Option.CPRdeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; - Configurable CPRdeltaEtaMax{"Option.CPRdeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; - Configurable DCACutPtDep{"Option.DCACutPtDep", false, "Use pt dependent dca cut"}; - Configurable MixEventWithPairs{"Option.MixEventWithPairs", false, "Only use events that contain particle 1 and partile 2 for the event mixing"}; - Configurable smearingByOrigin{"Option.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{"Option.Dummy", {1, 0, 1}, "Dummy axis"}; + 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 { - Configurable MultMin{"EventSel.MultMin", 0, "Minimum Multiplicity (MultNtr)"}; - Configurable MultMax{"EventSel.MultMax", 99999, "Maximum Multiplicity (MultNtr)"}; - Configurable MultPercentileMin{"EventSel.MultPercentileMin", 0, "Minimum Multiplicity Percentile"}; - Configurable MultPercentileMax{"EventSel.MultPercentileMax", 100, "Maximum Multiplicity Percentile"}; + 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 FilteredMaskedCollisions = soa::Filtered>; using FilteredMaskedCollision = FilteredMaskedCollisions::iterator; using FilteredMaskedMCCollisions = soa::Filtered>; using FilteredMaskedMCCollision = FilteredMaskedMCCollisions::iterator; + using FDMCParts = soa::Join; + using FDMCPart = FDMCParts::iterator; + femtodreamcollision::BitMaskType BitMask = 1; /// Particle 1 (track) struct : ConfigurableGroup { - Configurable PDGCode{"Track1.PDGCode", 2212, "PDG code of Particle 1 (Track)"}; - Configurable CutBit{"Track1.CutBit", 5542474, "Particle 1 (Track) - Selection bit from cutCulator"}; - Configurable TPCBit{"Track1.TPCBit", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; - Configurable TPCBit_Reject{"Track1.TPCBit_Reject", 0, "Reject PID TPC bit from cutCulator for particle 1 (Track). Set to 0 to turn off"}; - Configurable TPCTOFBit{"Track1.TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 1 (Track)"}; - Configurable PIDThres{"Track1.PIDThres", 0.75, "Momentum threshold for PID selection for particle 1 (Track)"}; - Configurable PtMin{"Track1.PtMin", 0., "Minimum pT of partricle 1 (Track)"}; - Configurable PtMax{"Track1.PtMax", 999., "Maximum pT of partricle 1 (Track)"}; - Configurable EtaMin{"Track1.EtaMin", -10., "Minimum eta of partricle 1 (Track)"}; - Configurable EtaMax{"Track1.EtaMax", 10., "Maximum eta of partricle 1 (Track)"}; - Configurable TempFitVarMin{"Track1.TempFitVarMin", -10., "Minimum DCAxy of partricle 1 (Track)"}; - Configurable TempFitVarMax{"Track1.TempFitVarMax", 10., "Maximum DCAxy of partricle 1 (Track)"}; + 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; - Filter trackPtFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt > Track1.PtMin, true); - Filter trackPtFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt < Track1.PtMax, true); - Filter trackEtaFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta > Track1.EtaMin, true); - Filter trackEtaFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta < Track1.EtaMax, true); - Filter trackTempFitVarFilterUp = !Option.DCACutPtDep && ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::tempFitVar > Track1.TempFitVarMin, true); - Filter trackTempFitVarFilterLow = !Option.DCACutPtDep && ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::tempFitVar < Track1.TempFitVarMax, true); - Filter trackTempFitVarFilterPtDep = Option.DCACutPtDep && ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), nabs(aod::femtodreamparticle::tempFitVar) <= 0.0105f + (0.035f / npow(aod::femtodreamparticle::pt, 1.1f)), true); + /// 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))); + + Partition PartitionMCTrk1 = (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 (V0) struct : ConfigurableGroup { - Configurable PDGCode{"V02.PDGCode", 3122, "PDG code of particle 2 (V0)"}; - Configurable CutBit{"V02.CutBit", 338, "Selection bit for particle 2 (V0)"}; - Configurable ChildPos_CutBit{"V02.ChildPos_CutBit", 149, "Selection bit for positive child of V0"}; - Configurable ChildPos_TPCBit{"V02.ChildPos_TPCBit", 2, "PID TPC bit for positive child of V0"}; - Configurable ChildNeg_CutBit{"V02.ChildNeg_CutBit", 149, "Selection bit for negative child of V0"}; - Configurable ChildNeg_TPCBit{"V02.ChildNeg_TPCBit", 2, "PID TPC bit for negative child of V0"}; - - Configurable InvMassMin{"V02.InvMassMin", 1.08, "Minimum invariant mass of Partricle 2 (particle) (V0)"}; - Configurable InvMassMax{"V02.InvMassMax", 1.15, "Maximum invariant mass of Partricle 2 (particle) (V0)"}; - Configurable InvMassAntiMin{"V02.InvMassAntiMin", 0., "Minimum invariant mass of Partricle 2 (antiparticle) (V0)"}; - Configurable InvMassAntiMax{"V02.InvMassAntiMax", 999., "Maximum invariant mass of Partricle 2 (antiparticle) (V0)"}; - - Configurable PtMin{"V02.PtMin", 0., "Minimum pT of Partricle 2 (V0)"}; - Configurable PtMax{"V02.PtMax", 999., "Maximum pT of Partricle 2 (V0)"}; - Configurable EtaMin{"V02.EtaMin", -10., "Minimum eta of Partricle 2 (V0)"}; - Configurable EtaMax{"V02.EtaMax", 10., "Maximum eta of Partricle 2 (V0)"}; + std::string prefix = std::string("V02"); + Configurable PDGCode{"PDGCode", 3122, "PDG code of particle 2 (V0)"}; + Configurable CutBit{"CutBit", 338, "Selection bit for particle 2 (V0)"}; + Configurable ChildPos_CutBit{"ChildPos_CutBit", 149, "Selection bit for positive child of V0"}; + Configurable ChildPos_TPCBit{"ChildPos_TPCBit", 2, "PID TPC bit for positive child of V0"}; + Configurable ChildNeg_CutBit{"ChildNeg_CutBit", 149, "Selection bit for negative child of V0"}; + Configurable ChildNeg_TPCBit{"ChildNeg_TPCBit", 2, "PID TPC bit for negative child of V0"}; + + Configurable InvMassMin{"InvMassMin", 1.08, "Minimum invariant mass of Partricle 2 (particle) (V0)"}; + Configurable InvMassMax{"InvMassMax", 1.15, "Maximum invariant mass of Partricle 2 (particle) (V0)"}; + Configurable InvMassAntiMin{"InvMassAntiMin", 0., "Minimum invariant mass of Partricle 2 (antiparticle) (V0)"}; + Configurable InvMassAntiMax{"InvMassAntiMax", 999., "Maximum invariant mass of Partricle 2 (antiparticle) (V0)"}; + + 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)"}; } V02; - Filter v0MassFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::mLambda > V02.InvMassMin, true); - Filter v0MassFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::mLambda < V02.InvMassMax, true); - Filter antiv0MassFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::mAntiLambda > V02.InvMassAntiMin, true); - Filter antiv0MassFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::mAntiLambda < V02.InvMassAntiMax, true); - - Filter v0PtFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::pt > V02.PtMin, true); - Filter v0PtFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::pt < V02.PtMax, true); - Filter v0EtaFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::eta > V02.EtaMin, true); - Filter v0EtaFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0), aod::femtodreamparticle::eta < V02.EtaMax, true); + /// Partition for particle 2 + Partition PartitionV02 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)) && + ((aod::femtodreamparticle::cut & V02.CutBit) == V02.CutBit) && + (aod::femtodreamparticle::pt > V02.PtMin) && + (aod::femtodreamparticle::pt < V02.PtMax) && + (aod::femtodreamparticle::eta > V02.EtaMin) && + (aod::femtodreamparticle::eta < V02.EtaMax) && + (aod::femtodreamparticle::mLambda > V02.InvMassMin) && + (aod::femtodreamparticle::mLambda < V02.InvMassMax) && + (aod::femtodreamparticle::mAntiLambda > V02.InvMassAntiMin) && + (aod::femtodreamparticle::mAntiLambda < V02.InvMassAntiMax); + + Partition PartitionMCV02 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)) && + ((aod::femtodreamparticle::cut & V02.CutBit) == V02.CutBit) && + (aod::femtodreamparticle::pt > V02.PtMin) && + (aod::femtodreamparticle::pt < V02.PtMax) && + (aod::femtodreamparticle::eta > V02.EtaMax) && + (aod::femtodreamparticle::eta < V02.EtaMin) && + (aod::femtodreamparticle::mLambda > V02.InvMassMin) && + (aod::femtodreamparticle::mLambda < V02.InvMassMax) && + (aod::femtodreamparticle::mAntiLambda > V02.InvMassAntiMin) && + (aod::femtodreamparticle::mAntiLambda < V02.InvMassAntiMax); /// Histogramming for particle 2 FemtoDreamParticleHisto trackHistoPartTwo; FemtoDreamParticleHisto posChildHistos; FemtoDreamParticleHisto negChildHistos; - using FilteredFDParticles = soa::Filtered; - using FilteredFDParticle = FilteredFDParticles::iterator; - - using FilteredFDMCParts = soa::Filtered>; - using FilteredFDMCPart = FilteredFDMCParts::iterator; - - /// 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)); - Partition PartitionMCTrk1 = (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)); - - /// Partition for particle 2 - Partition PartitionV02 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)) && ((aod::femtodreamparticle::cut & V02.CutBit) == V02.CutBit); - Partition PartitionMCV02 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0)) && ((aod::femtodreamparticle::cut & V02.CutBit) == V02.CutBit); - - /// Histogramming for Event - FemtoDreamEventHisto eventHisto; - /// Binning configurables struct : ConfigurableGroup { - ConfigurableAxis TempFitVarTrack{"Binning.TempFitVarTrack", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Track)"}; - ConfigurableAxis TempFitVarV0{"Binning.TempFitVarV0", {300, 0.9, 1}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis TempFitVarV0Child{"Binning.TempFitVarV0Child", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0 child)"}; - ConfigurableAxis InvMass{"Binning.InvMass", {200, 1, 1.2}, "InvMass binning"}; - ConfigurableAxis pTTrack{"Binning.pTTrack", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (Track)"}; - ConfigurableAxis pTV0{"Binning.pTV0", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis pTV0Child{"Binning.pTV0Child", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis pT{"Binning.pT", {20, 0.5, 4.05}, "pT binning"}; - ConfigurableAxis kstar{"Binning.kstar", {1500, 0., 6.}, "binning kstar"}; - ConfigurableAxis kT{"Binning.kT", {150, 0., 9.}, "binning kT"}; - ConfigurableAxis mT{"Binning.mT", {225, 0., 7.5}, "binning mT"}; - ConfigurableAxis multTempFit{"Binning.multTempFit", {1, 0, 1}, "multiplicity Binning for the TempFitVar plot"}; + 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 TempFitVarV0{"TempFitVarV0", {300, 0.9, 1}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0)"}; + ConfigurableAxis TempFitVarV0Child{"TempFitVarV0Child", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0 child)"}; + ConfigurableAxis InvMass{"InvMass", {200, 1, 1.2}, "InvMass binning"}; + ConfigurableAxis pTTrack{"pTTrack", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (Track)"}; + ConfigurableAxis pTV0{"pTV0", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; + ConfigurableAxis pTV0Child{"pTV0Child", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; + 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 { - ConfigurableAxis kstar{"Binning4D.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{"Binning4D.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{"Binning4D.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{"Binning4D.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)"}; + 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 { - ConfigurableAxis BinMult{"Mixing.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}, "Mixing bins - multiplicity"}; - ConfigurableAxis BinMultPercentile{"Mixing.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}, "Mixing bins - multiplicity percentile"}; - ConfigurableAxis BinVztx{"Mixing.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}, "Mixing bins - z-vertex"}; - Configurable Depth{"Mixing.Depth", 5, "Number of events for mixing"}; - Configurable Policy{"Mixing.BinPolicy", 0, "Binning policy for mixing - 0: multiplicity, 1: multipliciy percentile, 2: both"}; + 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}; @@ -204,21 +224,22 @@ struct femtoDreamPairTaskTrackV0 { FemtoDreamDetaDphiStar pairCloseRejectionME; /// Histogram output - HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry Registry{"Output", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext& context) { - eventHisto.init(&qaRegistry, Option.IsMC); - // void init(HistogramRegistry* registry, - // T& MomentumBins, T& tempFitVarBins, T& NsigmaTPCBins, T& NsigmaTOFBins, T& NsigmaTPCTOFBins, T& InvMassBins, - // bool isMC, int pdgCode, bool isDebug = false) - trackHistoPartOne.init(&qaRegistry, 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(&qaRegistry, 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(&qaRegistry, 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(&qaRegistry, Binning.multTempFit, Option.Dummy, Binning.pTV0Child, Option.Dummy, Option.Dummy, Binning.TempFitVarV0Child, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, Option.Dummy, false, 0); - - sameEventCont.init(&resultRegistry, + // 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.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); + + 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, @@ -226,7 +247,7 @@ struct femtoDreamPairTaskTrackV0 { Option.smearingByOrigin); sameEventCont.setPDGCodes(Track1.PDGCode, V02.PDGCode); - mixedEventCont.init(&resultRegistry, + 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, @@ -234,10 +255,10 @@ struct femtoDreamPairTaskTrackV0 { Option.smearingByOrigin); mixedEventCont.setPDGCodes(Track1.PDGCode, V02.PDGCode); - pairCleaner.init(&qaRegistry); + pairCleaner.init(&Registry); if (Option.CPROn.value) { - pairCloseRejectionSE.init(&resultRegistry, &qaRegistry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 1, Option.CPROld.value); - pairCloseRejectionME.init(&resultRegistry, &qaRegistry, Option.CPRdeltaPhiMax.value, Option.CPRdeltaEtaMax.value, Option.CPRPlotPerRadii.value, 2, Option.CPROld.value, 8, true); + 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); } // get bit for the collision mask @@ -331,7 +352,7 @@ struct femtoDreamPairTaskTrackV0 { } } - void processSameEventMasked(FilteredMaskedCollision const& col, FilteredFDParticles const& parts) + void processSameEventMasked(FilteredMaskedCollision const& col, FDParticles const& parts) { if ((col.bitmaskTrackOne() & BitMask) != BitMask || (col.bitmaskTrackTwo() & BitMask) != BitMask) { return; @@ -343,7 +364,7 @@ struct femtoDreamPairTaskTrackV0 { } PROCESS_SWITCH(femtoDreamPairTaskTrackV0, processSameEventMasked, "Enable processing same event with masks", true); - void processSameEventMCMasked(FilteredMaskedMCCollision const& col, o2::aod::FDMCCollisions&, FilteredFDMCParts const& parts, o2::aod::FDMCParticles const&) + void processSameEventMCMasked(FilteredMaskedMCCollision const& col, o2::aod::FDMCCollisions&, FDMCParts const& parts, o2::aod::FDMCParticles const&) { if ((col.bitmaskTrackOne() & BitMask) != BitMask && (col.bitmaskTrackTwo() & BitMask) != BitMask) { return; @@ -433,7 +454,7 @@ struct femtoDreamPairTaskTrackV0 { } } - void processMixedEventMasked(FilteredMaskedCollisions const& cols, FilteredFDParticles const& parts) + void processMixedEventMasked(FilteredMaskedCollisions const& cols, FDParticles const& parts) { switch (Mixing.Policy.value) { case femtodreamcollision::kMult: @@ -451,7 +472,7 @@ struct femtoDreamPairTaskTrackV0 { } PROCESS_SWITCH(femtoDreamPairTaskTrackV0, processMixedEventMasked, "Enable processing mixed events with masks", true); - void processMixedEventMCMasked(FilteredMaskedMCCollisions const& cols, o2::aod::FDMCCollisions&, FilteredFDMCParts const& parts, o2::aod::FDMCParticles const&) + void processMixedEventMCMasked(FilteredMaskedMCCollisions const& cols, o2::aod::FDMCCollisions&, FDMCParts const& parts, o2::aod::FDMCParticles const&) { switch (Mixing.Policy.value) { case femtodreamcollision::kMult: diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx index 4667ed15972..0dea45463f6 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackTrack.cxx @@ -14,6 +14,7 @@ /// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -128,6 +129,9 @@ struct femtoDreamTripletTaskTrackTrackTrack { { eventHisto.init(&qaRegistry, false); + + 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); @@ -141,7 +145,6 @@ struct femtoDreamTripletTaskTrackTrackTrack { if (ConfIsMC) { ThreeBodyQARegistry.add("TrackMC_QA/hMazzachi", ";gen;(reco-gen)/gen", kTH2F, {{100, ConfMinpT, ConfMaxpT}, {300, -1, 1}}); } - sameEventCont.init(&resultRegistry, ConfQ3Bins, ConfMultBins, ConfIsMC); mixedEventCont.init(&resultRegistry, ConfQ3Bins, ConfMultBins, ConfIsMC); sameEventCont.setPDGCodes(ConfPDGCodePart, ConfPDGCodePart, ConfPDGCodePart); @@ -337,6 +340,7 @@ struct femtoDreamTripletTaskTrackTrackTrack { 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)) { @@ -377,7 +381,6 @@ struct femtoDreamTripletTaskTrackTrackTrack { if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { continue; } - // CONSIDER testing different strategies to which events to use doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); } @@ -410,6 +413,7 @@ struct femtoDreamTripletTaskTrackTrackTrack { if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { continue; } + doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); } } diff --git a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx index afeeaa36c9d..aecca490b80 100644 --- a/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx +++ b/PWGCF/FemtoDream/Tasks/femtoDreamTripletTaskTrackTrackV0.cxx @@ -15,6 +15,7 @@ #include #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -179,6 +180,9 @@ struct femtoDreamTripletTaskTrackTrackV0 { { eventHisto.init(&qaRegistry, false); + + 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); @@ -548,7 +552,6 @@ struct femtoDreamTripletTaskTrackTrackV0 { if ((magFieldTesla1 != magFieldTesla2) || (magFieldTesla2 != magFieldTesla3) || (magFieldTesla1 != magFieldTesla3)) { continue; } - // CONSIDER testing different strategies to which events to use doMixedEvent(groupPartsOne, groupPartsTwo, groupPartsThree, parts, magFieldTesla1, multiplicityCol); } diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h index 6d48650c2ba..c08c131ab99 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverse3DContainer.h @@ -74,7 +74,6 @@ class FemtoUniverse3DContainer /// \param mTAxis axis object for the mT axis /// \param use3dplots Flag to fill 3D plots /// \param isiden Identical or non-identical particle pair - /// \param islcms LCMS or PRF template void init_base(std::string folderName, std::string femtoObs1D, std::string femtoObsKout, std::string femtoObsKside, std::string femtoObsKlong, T femtoObsAxis1D, T femtoObsAxisOut, T femtoObsAxisSide, T femtoObsAxisLong, T multAxis, T kTAxis, T mTAxis, T multAxis3D, T mTAxis3D, bool use3dplots, bool isiden) { @@ -214,13 +213,13 @@ class FemtoUniverse3DContainer /// \param isiden Choosing identical or non-identical pairs /// \param islcm Choosing LCMS or PRF template - void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, bool isiden, bool islcms) + void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, bool isiden) { std::vector f3d; const float kT = FemtoUniverseMath::getkT(part1, mMassOne, part2, mMassTwo); const float mT = FemtoUniverseMath::getmT(part1, mMassOne, part2, mMassTwo); - f3d = FemtoUniverseMath::getpairmom3d(part1, mMassOne, part2, mMassTwo, isiden, islcms); + f3d = FemtoUniverseMath::newpairfunc(part1, mMassOne, part2, mMassTwo, isiden); const float femtoObs1D = f3d[0]; const float femtoObsKout = f3d[1]; diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h index e0429bd73e8..2f29f3df474 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseAngularContainer.h @@ -153,7 +153,7 @@ class FemtoUniverseAngularContainer /// \param part2 Particle two /// \param mult Multiplicity of the event template - void setPair_base(const float /*femtoObs*/, const float /*mT*/, T const& part1, T const& part2, const int /*mult*/, bool use3dplots) + void setPair_base(const float /*femtoObs*/, const float /*mT*/, T const& part1, T const& part2, const int /*mult*/, bool use3dplots, float weight = 1.0f) { delta_eta = part1.eta() - part2.eta(); delta_phi = part1.phi() - part2.phi(); @@ -165,7 +165,7 @@ class FemtoUniverseAngularContainer delta_phi -= o2::constants::math::TwoPI; } - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/DeltaEtaDeltaPhi"), delta_phi, delta_eta); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/DeltaEtaDeltaPhi"), delta_phi, delta_eta, weight); if (use3dplots) { // use 3d plots } @@ -194,7 +194,7 @@ class FemtoUniverseAngularContainer /// \param part2 Particle two /// \param mult Multiplicity of the event template - void setPair(T const& part1, T const& part2, const int mult, bool use3dplots) + void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, float weight = 1.0f) { float femtoObs, femtoObsMC; // Calculate femto observable and the mT with reconstructed information @@ -215,7 +215,7 @@ class FemtoUniverseAngularContainer const float mTMC = FemtoUniverseMath::getmT(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); if (abs(part1.fdMCParticle().pdgMCTruth()) == abs(mPDGOne) && abs(part2.fdMCParticle().pdgMCTruth()) == abs(mPDGTwo)) { // Note: all pair-histogramms are filled with MC truth information ONLY in case of non-fake candidates - setPair_base(femtoObsMC, mTMC, part1.fdMCParticle(), part2.fdMCParticle(), mult, use3dplots); + setPair_base(femtoObsMC, mTMC, part1.fdMCParticle(), part2.fdMCParticle(), mult, use3dplots, weight); setPair_MC(femtoObsMC, femtoObs, mT, mult); } else { } diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h new file mode 100644 index 00000000000..83e9a59d9c1 --- /dev/null +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseCascadeSelection.h @@ -0,0 +1,591 @@ +// 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 femtoUniverseCascadeSelection.h +/// \brief Definition of the femtoUniverseCascadeSelection +/// \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 + +#ifndef PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSECASCADESELECTION_H_ +#define PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSECASCADESELECTION_H_ + +#include +#include +#include + +#include // FIXME + +#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" + +using namespace o2::framework; + +namespace o2::analysis::femtoUniverse +{ +namespace femtoUniverseCascadeSelection +{ +/// The different selections this task is capable of doing +enum CascadeSel { + kCascadeSign, ///< +1 particle, -1 antiparticle + kCascadepTMin, + kCascadepTMax, + kCascadeetaMax, + kCascadeV0DCADaughMax, + kCascadeV0CPAMin, + kCascadeV0TranRadMin, + kCascadeV0TranRadMax, + kCascadeV0DecVtxMax, + kCascadeDCADaughMax, + kCascadeCPAMin, + kCascadeTranRadMin, + kCascadeTranRadMax, + kCascadeDecVtxMax, + kCascadeDCAPosToPV, + kCascadeDCANegToPV, + kCascadeDCABachToPV, + kCascadeDCAV0ToPV, + kCascadeV0MassMin, + kCascadeV0MassMax +}; + +enum ChildTrackType { kPosTrack, + kNegTrack, + kBachTrack }; + +/*enum CascadeContainerPosition { + kCascade, + kPosCuts, + kPosPID, + kNegCuts, + kNegPID, +}; /// Position in the full VO cut container (for cutculator) +*/ +} // namespace femtoUniverseCascadeSelection + +/// \class FemtoUniverseCascadeSelection +/// \brief Cut class to contain and execute all cuts applied to Cascades +class FemtoUniverseCascadeSelection + : public FemtoUniverseObjectSelection +{ + // do cutculatora + + 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.), DCAV0DaughMax(-9999999.), CPAV0Min(9999999.), TranRadV0Min(9999999.), TranRadV0Max(-9999999.), V0DecVtxMax(-9999999.), DCACascadeDaughMax(-9999999.), CPACascadeMin(9999999.), TranRadCascadeMin(9999999.), TranRadCascadeMax(-9999999.), DecVtxMax(-9999999.), DCAPosToPV(9999999.), DCANegToPV(9999999.), DCABachToPV(9999999.), DCAV0ToPV(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.)*/ + { + } + + /// Initializes histograms for the task + template + 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); + + template + void fillCascadeQA(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack); + + template + void fillQA(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack, Track const& bachTrack); + + template + void setChildCuts(femtoUniverseCascadeSelection::ChildTrackType child, T1 selVal, + T2 selVar, femtoUniverseSelection::SelectionType selType) + { + if (child == femtoUniverseCascadeSelection::kPosTrack) { + PosDaughTrack.setSelection(selVal, selVar, selType); + } else if (child == femtoUniverseCascadeSelection::kNegTrack) { + NegDaughTrack.setSelection(selVal, selVar, selType); + } else if (child == femtoUniverseCascadeSelection::kBachTrack) { + BachTrack.setSelection(selVal, selVar, selType); + } + } + + template + void setChildPIDSpecies(femtoUniverseCascadeSelection::ChildTrackType child, + T& pids) + { + if (child == femtoUniverseCascadeSelection::kPosTrack) { + PosDaughTrack.setPIDSpecies(pids); + } else if (child == femtoUniverseCascadeSelection::kNegTrack) { + NegDaughTrack.setPIDSpecies(pids); + } else if (child == femtoUniverseCascadeSelection::kBachTrack) { + BachTrack.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(femtoUniverseCascadeSelection::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 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(femtoUniverseCascadeSelection::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; + } + + /// 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 nPtCascadeMinSel; + int nPtCascadeMaxSel; + int nEtaCascadeMaxSel; + int nDCAV0DaughMax; + int nCPAV0Min; + int nTranRadV0Min; + int nTranRadV0Max; + int nV0DecVtxMax; + int nDCACascadeDaughMax; + int nCPACascadeMin; + int nTranRadCascadeMin; + int nTranRadCascadeMax; + int nDecVtxMax; + int nDCAPosToPV; + int nDCANegToPV; + int nDCABachToPV; + int nDCAV0ToPV; + float pTCascadeMin; + float pTCascadeMax; + float etaCascadeMax; + float DCAV0DaughMax; + float CPAV0Min; + float TranRadV0Min; + float TranRadV0Max; + float V0DecVtxMax; + float DCACascadeDaughMax; + float CPACascadeMin; + float TranRadCascadeMin; + float TranRadCascadeMax; + float DecVtxMax; + float DCAPosToPV; + float DCANegToPV; + float DCABachToPV; + float DCAV0ToPV; + + float fV0InvMassLowLimit; + float fV0InvMassUpLimit; + + float fInvMassLowLimit; + float fInvMassUpLimit; + + float fRejectCompetingMass; + float fInvMassCompetingLowLimit; + float fInvMassCompetingUpLimit; + + bool isCascOmega; + + // float nSigmaPIDOffsetTPC; + + FemtoUniverseTrackSelection PosDaughTrack; + FemtoUniverseTrackSelection NegDaughTrack; + FemtoUniverseTrackSelection BachTrack; + + static constexpr int kNcascadeSelection = 20; // can I do less ? + + static constexpr std::string_view mSelectionNames[kNcascadeSelection] = { + "Sign", "PtMin", "PtMax", "EtaMax", "DCAv0daughMax", "v0CPAMin", + "v0TranRadMin", "v0TranRadMax", "v0DecVecMax", "DCAcascDaugh", + "CPAMin", "TranRadMin", "TranRadMax", "DecVtxMax", + "DCAPosToPV", "DCANegToPV", "DCABachToPV", "DCAV0ToPV", + "kV0MassMin", "V0MassMax"}; ///< Name of the different + ///< selections + + static constexpr femtoUniverseSelection::SelectionType + mSelectionTypes[kNcascadeSelection]{ + femtoUniverseSelection::kEqual, // sign + femtoUniverseSelection::kLowerLimit, // pt min + femtoUniverseSelection::kUpperLimit, // pt max + femtoUniverseSelection::kUpperLimit, // eta max + femtoUniverseSelection::kUpperLimit, // DCA v0 daughters max + femtoUniverseSelection::kLowerLimit, // v0 cos PA min + femtoUniverseSelection::kLowerLimit, // v0 tran rad min + femtoUniverseSelection::kUpperLimit, // v0 tran rad max + femtoUniverseSelection::kUpperLimit, // v0 maximum distance of decay vertex to PV + femtoUniverseSelection::kUpperLimit, // DCA cascade daughters max + femtoUniverseSelection::kLowerLimit, // cascade cos PA min + femtoUniverseSelection::kLowerLimit, // cascade tran rad min + femtoUniverseSelection::kUpperLimit, // cascade tran rad max + femtoUniverseSelection::kUpperLimit, // cascade maximum distance of decay vertex to PV + femtoUniverseSelection::kLowerLimit, // DCA pos to PV max + femtoUniverseSelection::kLowerLimit, // DCA neg to PV max + femtoUniverseSelection::kLowerLimit, // DCA bach to PV max + femtoUniverseSelection::kLowerLimit, // DCA v0 to PV max + femtoUniverseSelection::kLowerLimit, // v0 mass min + femtoUniverseSelection::kUpperLimit, // v0 mass max + }; ///< 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 v0 daughters (cm)", + "Minimum Cosine of Pointing Angle for v0", + "Minimum v0 transverse radius (cm)", + "Maximum v0 transverse radius (cm)", + "Maximum distance of v0 from primary vertex", + "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 of positive track form primary vertex", + "Maximum DCA of negative track form primary vertex", + "Maximum DCA of bachelor track form primary vertex", + "Maximum DCA of v0 form primary vertex", + "Minimum V0 mass", + "Maximum V0 mass"}; ///< Helper information for the + ///< different selections + +}; // namespace femtoUniverse + +template +void FemtoUniverseCascadeSelection::init(HistogramRegistry* registry, bool isSelectCascOmega) +{ + + if (registry) { + mHistogramRegistry = registry; + fillSelectionHistogram(); // cascade + fillSelectionHistogram(); // pos, neg + fillSelectionHistogram(); // bach + + AxisSpec massAxisCascade = {2200, 1.25f, 1.8f, "m_{#Cascade} (GeV/#it{c}^{2})"}; + AxisSpec massAxisV0 = {600, 0.0f, 3.0f, "m_{#V0} (GeV/#it{c}^{2})"}; + AxisSpec DCADaughAxis = {1000, 0.0f, 2.0f, "DCA (cm)"}; + AxisSpec DCAToPVAxis = {1000, -10.0f, 10.0f, "DCA to PV (cm)"}; + 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 CPAAxis = {1000, 0.95f, 1.0f, "#it{cos #theta_{p}}"}; + AxisSpec tranRadAxis = {1000, 0.0f, 100.0f, "#it{r}_{xy} (cm)"}; + + /// \todo this should be an automatic check in the parent class, and the + /// return type should be templated + size_t nSelections = getNSelections(); + if (nSelections > 17 * sizeof(cutContainerType)) { + LOG(fatal) << "FemtoUniverseCascadeCuts: Number of selections to large for your " + "container - quitting!"; + } + + PosDaughTrack.init( + mHistogramRegistry); + NegDaughTrack.init( + mHistogramRegistry); + BachTrack.init( + mHistogramRegistry); + + // V0 (Lambda) + // mHistogramRegistry->add("CascadeQA/hInvMassV0NoCuts", "No cuts", kTH1F, {massAxisV0}); + mHistogramRegistry->add("CascadeQA/hInvMassV0Cut", "Invariant mass cut", kTH1F, {massAxisV0}); + mHistogramRegistry->add("CascadeQA/hDCAV0Daugh", "V0-daughters DCA", kTH1F, {DCADaughAxis}); + mHistogramRegistry->add("CascadeQA/hV0CPA", "V0 cos PA", kTH1F, {CPAAxis}); + mHistogramRegistry->add("CascadeQA/hV0TranRad", "V0 transverse radius", kTH1F, {tranRadAxis}); + // mHistogramRegistry->add("CascadeQA/hV0DecVtxMax", "V0 maximum distance on decay vertex", kTH1F, {massAxisV0}); + + // Cascade (Xi, Omega) + // mHistogramRegistry->add("CascadeQA/hInvMassCascadeNoCuts", "No cuts", kTH1F, {massAxisCascade}); + mHistogramRegistry->add("CascadeQA/hInvMassCascadeCut", "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}); + mHistogramRegistry->add("CascadeQA/hDCACascadeDaugh", "Cascade-daughters DCA", kTH1F, {DCADaughAxis}); + mHistogramRegistry->add("CascadeQA/hCascadeCPA", "Cos PA", kTH1F, {CPAAxis}); + mHistogramRegistry->add("CascadeQA/hCascadeTranRad", "Transverse radius", kTH1F, {tranRadAxis}); + mHistogramRegistry->add("CascadeQA/hDCAPosToPV", "Pos V0 daughter DCA to primary vertex", kTH1F, {DCAToPVAxis}); + mHistogramRegistry->add("CascadeQA/hDCANegToPV", "Neg V0 daughter DCA to primary vertex", kTH1F, {DCAToPVAxis}); + mHistogramRegistry->add("CascadeQA/hDCABachToPV", "Bachelor DCA to primary vertex", kTH1F, {DCAToPVAxis}); + mHistogramRegistry->add("CascadeQA/hDCAV0ToPV", "V0 DCA to primary vertex", kTH1F, {DCAToPVAxis}); + } + + /// check whether the most open cuts are fulfilled - most of this should have + /// already be done by the filters + nPtCascadeMinSel = getNSelections(femtoUniverseCascadeSelection::kCascadepTMin); + nPtCascadeMaxSel = getNSelections(femtoUniverseCascadeSelection::kCascadepTMax); + nEtaCascadeMaxSel = getNSelections(femtoUniverseCascadeSelection::kCascadeetaMax); + nDCAV0DaughMax = getNSelections(femtoUniverseCascadeSelection::kCascadeV0DCADaughMax); + nCPAV0Min = getNSelections(femtoUniverseCascadeSelection::kCascadeV0CPAMin); + nTranRadV0Min = getNSelections(femtoUniverseCascadeSelection::kCascadeV0TranRadMin); + nTranRadV0Max = getNSelections(femtoUniverseCascadeSelection::kCascadeV0TranRadMax); + nV0DecVtxMax = getNSelections(femtoUniverseCascadeSelection::kCascadeV0DecVtxMax); + nDCACascadeDaughMax = getNSelections(femtoUniverseCascadeSelection::kCascadeDCADaughMax); + nCPACascadeMin = getNSelections(femtoUniverseCascadeSelection::kCascadeCPAMin); + nTranRadCascadeMin = getNSelections(femtoUniverseCascadeSelection::kCascadeTranRadMin); + nTranRadCascadeMax = getNSelections(femtoUniverseCascadeSelection::kCascadeTranRadMax); + nDecVtxMax = getNSelections(femtoUniverseCascadeSelection::kCascadeDecVtxMax); + nDCAPosToPV = getNSelections(femtoUniverseCascadeSelection::kCascadeDCAPosToPV); + nDCANegToPV = getNSelections(femtoUniverseCascadeSelection::kCascadeDCANegToPV); + nDCABachToPV = getNSelections(femtoUniverseCascadeSelection::kCascadeDCABachToPV); + nDCAV0ToPV = getNSelections(femtoUniverseCascadeSelection::kCascadeDCAV0ToPV); + // dodac V0 mass min i max + + pTCascadeMin = getMinimalSelection(femtoUniverseCascadeSelection::kCascadepTMin, + femtoUniverseSelection::kLowerLimit); + pTCascadeMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadepTMax, + femtoUniverseSelection::kUpperLimit); + etaCascadeMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeetaMax, + femtoUniverseSelection::kAbsUpperLimit); + DCAV0DaughMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0DCADaughMax, + femtoUniverseSelection::kUpperLimit); + CPAV0Min = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0CPAMin, + femtoUniverseSelection::kLowerLimit); + TranRadV0Min = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0TranRadMin, + femtoUniverseSelection::kLowerLimit); + TranRadV0Max = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0TranRadMax, + femtoUniverseSelection::kUpperLimit); + V0DecVtxMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0DecVtxMax, + femtoUniverseSelection::kAbsUpperLimit); + DCACascadeDaughMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDCADaughMax, + femtoUniverseSelection::kUpperLimit); + CPACascadeMin = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeCPAMin, + femtoUniverseSelection::kLowerLimit); + TranRadCascadeMin = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeTranRadMin, + femtoUniverseSelection::kLowerLimit); + TranRadCascadeMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeTranRadMax, + femtoUniverseSelection::kUpperLimit); + DecVtxMax = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDecVtxMax, + femtoUniverseSelection::kAbsUpperLimit); + DCAPosToPV = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDCAPosToPV, + femtoUniverseSelection::kLowerLimit); + DCANegToPV = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDCANegToPV, + femtoUniverseSelection::kLowerLimit); + DCABachToPV = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDCABachToPV, + femtoUniverseSelection::kLowerLimit); + DCAV0ToPV = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeDCAV0ToPV, + femtoUniverseSelection::kLowerLimit); + fV0InvMassLowLimit = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0MassMin, + femtoUniverseSelection::kLowerLimit); + fV0InvMassUpLimit = getMinimalSelection(femtoUniverseCascadeSelection::kCascadeV0MassMax, + femtoUniverseSelection::kUpperLimit); + + isCascOmega = isSelectCascOmega; +} + +template +bool FemtoUniverseCascadeSelection::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 dcav0topv = cascade.dcav0topv(col.posX(), col.posY(), col.posZ()); + const float invMassLambda = cascade.mLambda(); + const float invMass = isCascOmega ? cascade.mOmega() : 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 (nPtCascadeMinSel > 0 && cascade.pt() < pTCascadeMin) { + return false; + } + if (nPtCascadeMaxSel > 0 && cascade.pt() > pTCascadeMax) { + return false; + } + if (nEtaCascadeMaxSel > 0 && std::abs(cascade.eta()) > etaCascadeMax) { + return false; + } + if (nDCAV0DaughMax > 0 && cascade.dcaV0daughters() > DCAV0DaughMax) { + return false; + } + if (nCPAV0Min > 0 && cpav0 < CPAV0Min) { + return false; + } + if (nTranRadV0Min > 0 && cascade.v0radius() < TranRadV0Min) { + return false; + } + if (nTranRadV0Max > 0 && cascade.v0radius() > TranRadV0Max) { + return false; + } + if (nDCACascadeDaughMax > 0 && cascade.dcacascdaughters() > DCACascadeDaughMax) { + return false; + } + if (nCPACascadeMin > 0 && cpaCasc < CPACascadeMin) { + return false; + } + if (nTranRadCascadeMin > 0 && cascade.cascradius() < TranRadCascadeMin) { + return false; + } + if (nTranRadCascadeMax > 0 && cascade.cascradius() > TranRadCascadeMax) { + return false; + } + for (size_t i = 0; i < decVtx.size(); i++) { + if (nDecVtxMax > 0 && decVtx.at(i) > DecVtxMax) { + return false; + } + } + if (nDCAPosToPV > 0 && abs(cascade.dcapostopv()) < DCAPosToPV) { + return false; + } + if (nDCANegToPV > 0 && abs(cascade.dcanegtopv()) < DCANegToPV) { + return false; + } + if (nDCABachToPV > 0 && abs(cascade.dcabachtopv()) < DCABachToPV) { + return false; + } + if (nDCAV0ToPV > 0 && abs(dcav0topv) < DCAV0ToPV) { + return false; + } + + if (!PosDaughTrack.isSelectedMinimal(posTrack)) { + return false; + } + if (!NegDaughTrack.isSelectedMinimal(negTrack)) { + return false; + } + if (!BachTrack.isSelectedMinimal(bachTrack)) { + return false; + } + /* + // check that track combinations for V0 or antiV0 would be fulfilling PID + float nSigmaPIDMax = PosDaughTrack.getSigmaPIDMax(); + // antiV0 + auto nSigmaPrNeg = negTrack.tpcNSigmaPr(); + auto nSigmaPiPos = posTrack.tpcNSigmaPi(); + // 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)) { + return false; + } + */ + return true; +} + +template +void FemtoUniverseCascadeSelection::fillCascadeQA(Col const& col, Casc const& cascade, Track const& posTrack, Track const& negTrack) +{ + 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 dcav0topv = cascade.dcav0topv(col.posX(), col.posY(), col.posZ()); + + const float invMassLambda = cascade.mLambda(); + const float invMass = isCascOmega ? cascade.mOmega() : cascade.mXi(); + + mHistogramRegistry->fill(HIST("CascadeQA/hInvMassV0Cut"), invMassLambda); + mHistogramRegistry->fill(HIST("CascadeQA/hInvMassCascadeCut"), invMass); + mHistogramRegistry->fill(HIST("CascadeQA/hCascadePt"), cascade.pt()); + mHistogramRegistry->fill(HIST("CascadeQA/hCascadeEta"), cascade.eta()); + mHistogramRegistry->fill(HIST("CascadeQA/hCascadePhi"), cascade.phi()); + mHistogramRegistry->fill(HIST("CascadeQA/hDCAV0Daugh"), cascade.dcaV0daughters()); + mHistogramRegistry->fill(HIST("CascadeQA/hV0CPA"), cpav0); + mHistogramRegistry->fill(HIST("CascadeQA/hV0TranRad"), cascade.v0radius()); + mHistogramRegistry->fill(HIST("CascadeQA/hCascadeCPA"), cpaCasc); + mHistogramRegistry->fill(HIST("CascadeQA/hDCACascadeDaugh"), cascade.dcacascdaughters()); + mHistogramRegistry->fill(HIST("CascadeQA/hCascadeTranRad"), cascade.cascradius()); + mHistogramRegistry->fill(HIST("CascadeQA/hDCAPosToPV"), cascade.dcapostopv()); + mHistogramRegistry->fill(HIST("CascadeQA/hDCANegToPV"), cascade.dcanegtopv()); + mHistogramRegistry->fill(HIST("CascadeQA/hDCABachToPV"), cascade.dcabachtopv()); + mHistogramRegistry->fill(HIST("CascadeQA/hDCAV0ToPV"), dcav0topv); + + // is this necessary + /* + bool write = true; + for (size_t i = 0; i < decVtx.size(); i++) { + write = write && (decVtx.at(i) < DecVtxMax); + } + if (write) { + mHistogramRegistry->fill(HIST("CAscadeQA/hInvMassCascadeDecVtxMax"), + cascade.mXi()); + } + */ +} + +template +void FemtoUniverseCascadeSelection::fillQA(Col const& /*col*/, Casc const& /*cascade*/, Track const& posTrack, Track const& negTrack, Track const& bachTrack) +{ + PosDaughTrack.fillQA(posTrack); + NegDaughTrack.fillQA(negTrack); + BachTrack.fillQA(bachTrack); +} + +} // namespace o2::analysis::femtoUniverse + +#endif // PWGCF_FEMTOUNIVERSE_CORE_FEMTOUNIVERSECASCADESELECTION_H_ diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h index 285dabc0b4d..e3f9c0feee6 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h @@ -168,7 +168,7 @@ class FemtoUniverseContainer /// \param part2 Particle two /// \param mult Multiplicity of the event template - void setPair_base(const float femtoObs, const float mT, T const& part1, T const& part2, const int mult, bool use3dplots) + void setPair_base(const float femtoObs, const float mT, T const& part1, T const& part2, const int mult, bool use3dplots, float weight = 1.0f) { const float kT = FemtoUniverseMath::getkT(part1, mMassOne, part2, mMassTwo); delta_eta = part1.eta() - part2.eta(); @@ -181,19 +181,19 @@ class FemtoUniverseContainer delta_phi -= o2::constants::math::TwoPI; } - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairDist"), femtoObs); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkT"), kT); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarkT"), femtoObs, kT); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarmT"), femtoObs, mT); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarMult"), femtoObs, mult); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/kstarPtPart1"), femtoObs, part1.pt()); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/kstarPtPart2"), femtoObs, part2.pt()); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/MultPtPart1"), part1.pt(), mult); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/MultPtPart2"), part2.pt(), mult); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/PtPart1PtPart2"), part1.pt(), part2.pt()); - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/DeltaEtaDeltaPhi"), delta_phi, delta_eta); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairDist"), femtoObs, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkT"), kT, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarkT"), femtoObs, kT, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarmT"), femtoObs, mT, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarMult"), femtoObs, mult, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/kstarPtPart1"), femtoObs, part1.pt(), weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/kstarPtPart2"), femtoObs, part2.pt(), weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/MultPtPart1"), part1.pt(), mult, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/MultPtPart2"), part2.pt(), mult, weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/PtPart1PtPart2"), part1.pt(), part2.pt(), weight); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/DeltaEtaDeltaPhi"), delta_phi, delta_eta, weight); if (use3dplots) { - mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarmTMult"), femtoObs, mT, mult); + mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/relPairkstarmTMult"), femtoObs, mT, mult, weight); } } @@ -225,7 +225,7 @@ 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) + void setPair(T const& part1, T const& part2, const int mult, bool use3dplots, float weight = 1.0f) { float femtoObs, femtoObsMC; // Calculate femto observable and the mT with reconstructed information @@ -235,7 +235,7 @@ class FemtoUniverseContainer const float mT = FemtoUniverseMath::getmT(part1, mMassOne, part2, mMassTwo); if (mHistogramRegistry) { - setPair_base(femtoObs, mT, part1, part2, mult, use3dplots); + setPair_base(femtoObs, mT, part1, part2, mult, use3dplots, weight); if constexpr (isMC) { if (part1.has_fdMCParticle() && part2.has_fdMCParticle()) { @@ -246,7 +246,7 @@ class FemtoUniverseContainer const float mTMC = FemtoUniverseMath::getmT(part1.fdMCParticle(), mMassOne, part2.fdMCParticle(), mMassTwo); if (abs(part1.fdMCParticle().pdgMCTruth()) == abs(mPDGOne) && abs(part2.fdMCParticle().pdgMCTruth()) == abs(mPDGTwo)) { // Note: all pair-histogramms are filled with MC truth information ONLY in case of non-fake candidates - setPair_base(femtoObsMC, mTMC, part1.fdMCParticle(), part2.fdMCParticle(), mult, use3dplots); + setPair_base(femtoObsMC, mTMC, part1.fdMCParticle(), part2.fdMCParticle(), mult, use3dplots, weight); setPair_MC(femtoObsMC, femtoObs, mT, mult); } else { mHistogramRegistry->fill(HIST(mFolderSuffix[mEventType]) + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[o2::aod::femtouniverseMCparticle::MCType::kTruth]) + HIST("/hFakePairsCounter"), 0); diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h index d7069e357a9..d89aeef295f 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h @@ -225,8 +225,6 @@ class FemtoUniverseDetaDphiStar for (int i = 0; i < 2; i++) { auto indexOfDaughterpart1 = (ChosenEventType == femtoUniverseContainer::EventType::mixed ? part1.globalIndex() : part1.index()) - 2 + i; auto indexOfDaughterpart2 = (ChosenEventType == femtoUniverseContainer::EventType::mixed ? part2.globalIndex() : part2.index()) - 2 + i; - // auto indexOfDaughterpart1 = part1.globalIndex() - 2 + i; - // auto indexOfDaughterpart2 = part2.globalIndex() - 2 + i; auto daughterpart1 = particles.begin() + indexOfDaughterpart1; auto daughterpart2 = particles.begin() + indexOfDaughterpart2; auto deta = daughterpart1.eta() - daughterpart2.eta(); @@ -239,7 +237,8 @@ class FemtoUniverseDetaDphiStar LOG(fatal) << "FemtoUniverseDetaDphiStar: passed arguments don't agree with FemtoUniverseDetaDphiStar's type of events! Please provide same or mixed."; } - if (pow(dphiAvg, 2) / pow(CutDeltaPhiStarMax, 2) + pow(deta, 2) / pow(CutDeltaEtaMax, 2) < 1.) { + // if (pow(dphiAvg, 2) / pow(CutDeltaPhiStarMax, 2) + pow(deta, 2) / pow(CutDeltaEtaMax, 2) < 1.) { + if ((dphiAvg > CutDeltaPhiStarMin) && (dphiAvg < CutDeltaPhiStarMax) && (deta > CutDeltaEtaMin) && (deta < CutDeltaEtaMax)) { pass = true; } else { if (ChosenEventType == femtoUniverseContainer::EventType::same) { diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h index 216cecb1148..b49c2480710 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h @@ -35,9 +35,11 @@ class FemtoUniverseEventHisto void init(HistogramRegistry* registry) { mHistogramRegistry = registry; - mHistogramRegistry->add("Event/zvtxhist", "; vtx_{z} (cm); Entries", kTH1F, {{300, -12.5, 12.5}}); - mHistogramRegistry->add("Event/MultV0M", "; vMultV0M; Entries", kTH1F, {{16384, 0, 32768}}); - mHistogramRegistry->add("Event/MultNTr", "; vMultNTr; Entries", kTH1F, {{200, 0, 200}}); + mHistogramRegistry->add("Event/zvtxhist", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); + mHistogramRegistry->add("Event/MultV0M", "; vMultV0M; Entries", kTH1F, {{1500, 0, 30000}}); + mHistogramRegistry->add("Event/MultNTr", "; vMultNTr; Entries", kTH1F, {{20, 0, 200}}); + mHistogramRegistry->add("Event/MultNTrVSMultV0M", "; vMultNTr; MultV0M", kTH2F, {{200, 0, 4000}, {1500, 0, 30000}}); + mHistogramRegistry->add("Event/zvtxhist_MultNTr", "; zvtxhist; MultNTr", kTH2F, {{250, -12.5, 12.5}, {20, 0, 200}}); } /// Some basic QA of the event @@ -50,6 +52,8 @@ class FemtoUniverseEventHisto mHistogramRegistry->fill(HIST("Event/zvtxhist"), col.posZ()); mHistogramRegistry->fill(HIST("Event/MultV0M"), col.multV0M()); mHistogramRegistry->fill(HIST("Event/MultNTr"), col.multNtr()); + mHistogramRegistry->fill(HIST("Event/MultNTrVSMultV0M"), col.multNtr(), col.multV0M()); + mHistogramRegistry->fill(HIST("Event/zvtxhist_MultNTr"), col.posZ(), col.multNtr()); } } diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h index cd992906c89..957fe316eb7 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseMath.h @@ -65,6 +65,36 @@ class FemtoUniverseMath return 0.5 * trackRelK.P(); } + /// \tparam T type of tracks + /// \param part1 Particle 1 + /// \param mass1 Mass of particle 1 + /// \param part2 Particle 2 + /// \param mass2 Mass of particle 2 + template + static float getthetastar(const T& part1, const float mass1, const T& part2, const float mass2) + { + const ROOT::Math::PtEtaPhiMVector vecpart1(part1.pt(), part1.eta(), part1.phi(), mass1); + const ROOT::Math::PtEtaPhiMVector vecpart2(part2.pt(), part2.eta(), part2.phi(), mass2); + const ROOT::Math::PtEtaPhiMVector trackSum = vecpart1 + vecpart2; + + 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(vecpart1); + ROOT::Math::PxPyPzMVector PartTwoCMS(vecpart2); + + const ROOT::Math::Boost boostPRF = ROOT::Math::Boost(-betax, -betay, -betaz); + PartOneCMS = boostPRF(PartOneCMS); + PartTwoCMS = boostPRF(PartTwoCMS); + + const ROOT::Math::PtEtaPhiMVector PartOneCMSGeo(PartOneCMS); + const ROOT::Math::PtEtaPhiMVector PartTwoCMSGeo(PartTwoCMS); + + return (PartOneCMSGeo.Theta() - PartTwoCMSGeo.Theta()); + } + /// Compute the qij of a pair of particles /// \tparam T type of tracks /// \param vecparti Particle i PxPyPzMVector @@ -149,9 +179,8 @@ class FemtoUniverseMath /// \param part2 Particle 2 /// \param mass2 Mass of particle 2 /// \param isiden Identical or non-identical particle pair - /// \param islcms LCMS or PRF template - static std::vector getpairmom3d(const T& part1, const float mass1, const T& part2, const float mass2, bool isiden, bool islcms) + static std::vector newpairfunc(const T& part1, const float mass1, const T& part2, const float mass2, bool isiden) { const double E1 = sqrt(pow(part1.px(), 2) + pow(part1.py(), 2) + pow(part1.pz(), 2) + pow(mass1, 2)); const double E2 = sqrt(pow(part2.px(), 2) + pow(part2.py(), 2) + pow(part2.pz(), 2) + pow(mass2, 2)); @@ -165,80 +194,63 @@ class FemtoUniverseMath const double tPx = trackSum.px(); const double tPy = trackSum.py(); const double tPz = trackSum.pz(); - const double tPE = trackSum.E(); - - const double tPt = trackSum.pt(); - const double tMt = trackSum.mt(); - const double tPinv = std::sqrt((tMt * tMt) - (tPt * tPt)); - - float nullmass = 0.0; - const double m1 = std::max(nullmass, mass1); - const double m2 = std::max(nullmass, mass2); + const double tE = trackSum.E(); - const double tQinvL = std::pow((E1 - E2), 2) - std::pow((part1.px() - part2.px()), 2) - - std::pow((part1.py() - part2.py()), 2) - std::pow((part1.pz() - part2.pz()), 2); - - double tQ = (m1 - m2) / tPinv; - tQ = ::sqrt(tQ * tQ - tQinvL); - - const double fKStarCalc = tQ / 2.0; - vect.push_back(fKStarCalc); + const double tPtSq = (tPx * tPx + tPy * tPy); + const double tMtSq = (tE * tE - tPz * tPz); + const double tM = sqrt(tMtSq - tPtSq); + const double tMt = sqrt(tMtSq); + const double tPt = sqrt(tPtSq); // Boost to LCMS - const double beta = tPz / tPE; - const double gamma = tPE / tMt; - - const double px1L = (part1.px() * tPx + part1.py() * tPy) / tPt; - const double py1L = (-part1.px() * tPy + part1.py() * tPx) / tPt; - const double pz1L = gamma * (part1.pz() - beta * E1); - const double pE1L = gamma * (E1 - beta * part1.pz()); + const double beta = tPz / tE; + const double gamma = tE / tMt; - const double px2L = (part2.px() * tPx + part2.py() * tPy) / tPt; - const double py2L = (-part2.px() * tPy + part2.py() * tPx) / tPt; - const double pz2L = gamma * (part2.pz() - beta * E2); - const double pE2L = gamma * (E2 - beta * part2.pz()); + const double fDKOut = (part1.px() * tPx + part1.py() * tPy) / tPt; + const double fDKSide = (-part1.px() * tPy + part1.py() * tPx) / tPt; + const double fDKLong = gamma * (part1.pz() - beta * E1); + const double fDE = gamma * (E1 - beta * part1.pz()); - double fDKOutLCMS; - double fDKSideLCMS; - double fDKLongLCMS; + const double px1LCMS = fDKOut; + const double py1LCMS = fDKSide; + const double pz1LCMS = fDKLong; + const double pE1LCMS = fDE; - double fDKOutPRF; - double fDKSidePRF; - double fDKLongPRF; + const double px2LCMS = (part2.px() * tPx + part2.py() * tPy) / tPt; + const double py2LCMS = (part2.py() * tPx - part2.px() * tPy) / tPt; + const double pz2LCMS = gamma * (part2.pz() - beta * E2); + const double pE2LCMS = gamma * (E2 - beta * part2.pz()); - if (!isiden) { - fDKOutLCMS = px1L; - fDKSideLCMS = py1L; - fDKLongLCMS = pz1L; - } else { - fDKOutLCMS = px1L - px2L; - fDKSideLCMS = py1L - py2L; - fDKLongLCMS = pz1L - pz2L; - } + const double fDKOutLCMS = px1LCMS - px2LCMS; + const double fDKSideLCMS = py1LCMS - py2LCMS; + const double fDKLongLCMS = pz1LCMS - pz2LCMS; // Boost to PRF + const double betaOut = tPt / tMt; - const double gammaOut = tMt / tPinv; + const double gammaOut = tMt / tM; - if (!isiden) { - fDKOutPRF = gammaOut * (fDKOutLCMS - betaOut * pE1L); - fDKSidePRF = fDKSideLCMS; - fDKLongPRF = fDKLongLCMS; - } else { - fDKOutPRF = gammaOut * (fDKOutLCMS - betaOut * (pE1L - pE2L)); - fDKSidePRF = fDKSideLCMS; - fDKLongPRF = fDKLongLCMS; - } + const double fDKOutPRF = gammaOut * (fDKOutLCMS - betaOut * (pE1LCMS - pE2LCMS)); + const double fDKSidePRF = fDKSideLCMS; + const double fDKLongPRF = fDKLongLCMS; + const double fKOut = gammaOut * (fDKOut - betaOut * fDE); + + const double qlcms = sqrt(fDKOutLCMS * fDKOutLCMS + fDKSideLCMS * fDKSideLCMS + fDKLongLCMS * fDKLongLCMS); + const double qinv = sqrt(fDKOutPRF * fDKOutPRF + fDKSidePRF * fDKSidePRF + fDKLongPRF * fDKLongPRF); + const double kstar = sqrt(fKOut * fKOut + fDKSide * fDKSide + fDKLong * fDKLong); - if (islcms) { + if (isiden) { + vect.push_back(qinv); vect.push_back(fDKOutLCMS); vect.push_back(fDKSideLCMS); vect.push_back(fDKLongLCMS); + vect.push_back(qlcms); } else { - vect.push_back(fDKOutPRF); - vect.push_back(fDKSidePRF); - vect.push_back(fDKLongPRF); + vect.push_back(kstar); + vect.push_back(fDKOut); + vect.push_back(fDKSide); + vect.push_back(fDKLong); } return vect; } diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h b/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h index a99d569fd65..bbddf41aefd 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h @@ -100,6 +100,19 @@ class FemtoUniversePairCleaner return false; } return part1.globalIndex() != part2.globalIndex(); + } else if constexpr (mPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && mPartTwoType == o2::aod::femtouniverseparticle::ParticleType::kCascade) { + /// Track-Cascade combination part1 is hadron and part2 is cascade + if (part1.partType() != o2::aod::femtouniverseparticle::ParticleType::kTrack || part2.partType() != o2::aod::femtouniverseparticle::ParticleType::kCascade) { + LOG(fatal) << "FemtoUniversePairCleaner: passed arguments don't agree with FemtoUniversePairCleaner instantiation! Please provide first argument kTrack candidate and second argument kCascade candidate."; + return false; + } + // Getting cascade children for part2 + const auto& posChild = particles.iteratorAt(part2.index() - 3); + const auto& negChild = particles.iteratorAt(part2.index() - 2); + const auto& bachelor = particles.iteratorAt(part2.index() - 1); + if (part1.globalIndex() == posChild.globalIndex() || part1.globalIndex() == negChild.globalIndex() || part1.globalIndex() == bachelor.globalIndex()) { + return false; + } } else if constexpr (mPartOneType == o2::aod::femtouniverseparticle::ParticleType::kTrack && mPartTwoType == 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 9d3c60bea79..771b1aed1ab 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h @@ -184,24 +184,24 @@ class PairSHCentMultKt /// \param ktval kT value template void fill_mult_NumDen(T const& part1, T const& part2, uint8_t ChosenEventType, - int maxl, int multval, float ktval) + int maxl, int multval, float ktval, bool isiden) { int multbinval; int absmultval = multval; - if ((absmultval > CentMultBins[0]) && (absmultval <= CentMultBins[1])) { + if ((absmultval >= CentMultBins[0]) && (absmultval < CentMultBins[1])) { multbinval = 0; - } else if (absmultval <= CentMultBins[2]) { + } else if (absmultval < CentMultBins[2]) { multbinval = 1; - } else if (absmultval <= CentMultBins[3]) { + } else if (absmultval < CentMultBins[3]) { multbinval = 2; - } else if (ktval <= CentMultBins[4]) { + } else if (absmultval < CentMultBins[4]) { multbinval = 3; } else { return; } // std::cout<<"multbinval "< void fill_kT_NumDen(T const& part1, T const& part2, uint8_t ChosenEventType, - int maxl, int multval, float ktval) + int maxl, int multval, float ktval, bool isiden) { int ktbinval = -1; - if ((ktval > KtBins[0]) && (ktval <= KtBins[1])) { + if ((ktval >= KtBins[0]) && (ktval < KtBins[1])) { ktbinval = 0; - } else if (ktval <= KtBins[2]) { + } else if (ktval < KtBins[2]) { ktbinval = 1; - } else if (ktval <= KtBins[3]) { + } else if (ktval < KtBins[3]) { ktbinval = 2; - } else if (ktval <= KtBins[4]) { + } else if (ktval < KtBins[4]) { ktbinval = 3; } else { return; } - AddEventPair(part1, part2, ChosenEventType, maxl, multval, ktbinval); + AddEventPair(part1, part2, ChosenEventType, maxl, multval, ktbinval, isiden); } /// Set the PDG codes of the two particles involved @@ -262,14 +262,14 @@ class PairSHCentMultKt /// \param ktval kT value template void AddEventPair(T const& part1, T const& part2, uint8_t ChosenEventType, - int /*maxl*/, int multval, int ktval) + int /*maxl*/, int multval, int ktval, bool isiden) { int fMultBin = multval; int fKtBin = ktval; std::vector> fYlmBuffer(fMaxJM); std::vector f3d; - f3d = FemtoUniverseMath::getpairmom3d(part1, mMassOne, part2, mMassTwo, - true, true); + f3d = FemtoUniverseMath::newpairfunc(part1, mMassOne, part2, mMassTwo, + isiden); const float qout = f3d[1]; const float qside = f3d[2]; @@ -374,13 +374,13 @@ class PairSHCentMultKt } private: - std::array, 15>, 10>, 10> + std::array, 10>, 4>, 4> fnumsreal{}; - std::array, 15>, 10>, 10> + std::array, 10>, 4>, 4> fnumsimag{}; - std::array, 15>, 10>, 10> + std::array, 10>, 4>, 4> fdensreal{}; - std::array, 15>, 10>, 10> + std::array, 10>, 4>, 4> fdensimag{}; TH1D* fbinctn[10][10]; @@ -389,13 +389,13 @@ class PairSHCentMultKt static constexpr int fMaxL = 2; static constexpr int fMaxJM = (fMaxL + 1) * (fMaxL + 1); - std::array, 10>, 10> + std::array, 4>, 4> fcovmnum{}; ///< Covariance matrix for the numerator - std::array, 10>, 10> + std::array, 4>, 4> fcovmden{}; ///< Covariance matrix for the numerator - std::array, 10>, 10> fcovnum{}; - std::array, 10>, 10> fcovden{}; + std::array, 4>, 4> fcovnum{}; + std::array, 4>, 4> fcovden{}; protected: HistogramRegistry* PairSHCentMultKtRegistry = nullptr; diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniversePairWithCentMultKt.h b/PWGCF/FemtoUniverse/Core/FemtoUniversePairWithCentMultKt.h index 01b82ae3b3b..6b52d810d43 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniversePairWithCentMultKt.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniversePairWithCentMultKt.h @@ -105,57 +105,57 @@ class PairWithCentMultKt void fill(t1 kstar_value, t1 cent_mult_value, t1 kt_value) { - if (cent_mult_value > CentMultBins[CentMultBins.size() - 1] || cent_mult_value < CentMultBins[0]) { + if (cent_mult_value >= CentMultBins[CentMultBins.size() - 1] || cent_mult_value < CentMultBins[0]) { PairWithCentMultKtRegistry->fill(HIST("Beyond_Max"), kstar_value); - } else if (cent_mult_value <= CentMultBins[1]) { + } else if (cent_mult_value < CentMultBins[1]) { PairWithCentMultKtRegistry->fill(HIST("mult_0_1/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_0_1/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[2]) { + } else if (cent_mult_value < CentMultBins[2]) { PairWithCentMultKtRegistry->fill(HIST("mult_1_2/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_1_2/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[3]) { + } else if (cent_mult_value < CentMultBins[3]) { PairWithCentMultKtRegistry->fill(HIST("mult_2_3/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_2_3/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[4]) { + } else if (cent_mult_value < CentMultBins[4]) { PairWithCentMultKtRegistry->fill(HIST("mult_3_4/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_3_4/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[5]) { + } else if (cent_mult_value < CentMultBins[5]) { PairWithCentMultKtRegistry->fill(HIST("mult_4_5/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_4_5/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[6]) { + } else if (cent_mult_value < CentMultBins[6]) { PairWithCentMultKtRegistry->fill(HIST("mult_5_6/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_5_6/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[7]) { + } else if (cent_mult_value < CentMultBins[7]) { PairWithCentMultKtRegistry->fill(HIST("mult_6_7/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_6_7/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[8]) { + } else if (cent_mult_value < CentMultBins[8]) { PairWithCentMultKtRegistry->fill(HIST("mult_7_8/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_7_8/"); fill_kT(kstar_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[9]) { + } else if (cent_mult_value < CentMultBins[9]) { PairWithCentMultKtRegistry->fill(HIST("mult_8_9/kstar"), kstar_value); if (UseKt) { auto histMultFolder = HIST("mult_8_9/"); @@ -173,23 +173,23 @@ class PairWithCentMultKt template void fill_kT(t1 kstar_value, t1 kt_value, t2 folder) { - if (kt_value <= KtBins[1]) { + if (kt_value < KtBins[1]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_0_1"), kstar_value); - } else if (kt_value <= KtBins[2]) { + } else if (kt_value < KtBins[2]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_1_2"), kstar_value); - } else if (kt_value <= KtBins[3]) { + } else if (kt_value < KtBins[3]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_2_3"), kstar_value); - } else if (kt_value <= KtBins[4]) { + } else if (kt_value < KtBins[4]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_3_4"), kstar_value); - } else if (kt_value <= KtBins[5]) { + } else if (kt_value < KtBins[5]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_4_5"), kstar_value); - } else if (kt_value <= KtBins[6]) { + } else if (kt_value < KtBins[6]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_5_6"), kstar_value); - } else if (kt_value <= KtBins[7]) { + } else if (kt_value < KtBins[7]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_6_7"), kstar_value); - } else if (kt_value <= KtBins[8]) { + } else if (kt_value < KtBins[8]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_7_8"), kstar_value); - } else if (kt_value <= KtBins[9]) { + } else if (kt_value < KtBins[9]) { PairWithCentMultKtRegistry->fill(folder + HIST("kstar_kt_8_9"), kstar_value); } } @@ -204,57 +204,57 @@ class PairWithCentMultKt void fill_3D(t1 qout_value, t1 qside_value, t1 qlong_value, t1 cent_mult_value, t1 kt_value) { - if (cent_mult_value > CentMultBins[CentMultBins.size() - 1] || cent_mult_value < CentMultBins[0]) { + if (cent_mult_value >= CentMultBins[CentMultBins.size() - 1] || cent_mult_value < CentMultBins[0]) { PairWithCentMultKtRegistry->fill(HIST("Beyond_Max_3D"), qout_value, qside_value, qlong_value); - } else if (cent_mult_value <= CentMultBins[1]) { + } else if (cent_mult_value < CentMultBins[1]) { PairWithCentMultKtRegistry->fill(HIST("mult_0_1/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_0_1/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[2]) { + } else if (cent_mult_value < CentMultBins[2]) { // PairWithCentMultKtRegistry->fill(HIST("mult_1_2/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_1_2/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[3]) { + } else if (cent_mult_value < CentMultBins[3]) { // PairWithCentMultKtRegistry->fill(HIST("mult_2_3/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_2_3/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[4]) { + } else if (cent_mult_value < CentMultBins[4]) { // PairWithCentMultKtRegistry->fill(HIST("mult_3_4/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_3_4/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[5]) { + } else if (cent_mult_value < CentMultBins[5]) { // PairWithCentMultKtRegistry->fill(HIST("mult_4_5/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_4_5/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[6]) { + } else if (cent_mult_value < CentMultBins[6]) { // PairWithCentMultKtRegistry->fill(HIST("mult_5_6/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_5_6/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[7]) { + } else if (cent_mult_value < CentMultBins[7]) { // PairWithCentMultKtRegistry->fill(HIST("mult_6_7/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_6_7/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[8]) { + } else if (cent_mult_value < CentMultBins[8]) { // PairWithCentMultKtRegistry->fill(HIST("mult_7_8/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_7_8/"); fill_kT_3d(qout_value, qside_value, qlong_value, kt_value, histMultFolder); } - } else if (cent_mult_value <= CentMultBins[9]) { + } else if (cent_mult_value < CentMultBins[9]) { // PairWithCentMultKtRegistry->fill(HIST("mult_8_9/q3D"), qout_value, qside_value, qlong_value); if (Use3D) { auto histMultFolder = HIST("mult_8_9/"); @@ -273,11 +273,11 @@ class PairWithCentMultKt template void fill_kT_3d(t1 qout_value, t1 qside_value, t1 qlong_value, t1 kt_value, t2 folder) { - if (kt_value <= KtBins[1]) { + if (kt_value < KtBins[1]) { PairWithCentMultKtRegistry->fill(folder + HIST("q3D_kt_0_1"), qout_value, qside_value, qlong_value); - } else if (kt_value <= KtBins[2]) { + } else if (kt_value < KtBins[2]) { PairWithCentMultKtRegistry->fill(folder + HIST("q3D_kt_1_2"), qout_value, qside_value, qlong_value); - } else if (kt_value <= KtBins[3]) { + } else if (kt_value < KtBins[3]) { PairWithCentMultKtRegistry->fill(folder + HIST("q3D_kt_2_3"), qout_value, qside_value, qlong_value); } } diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h index 9a5070a22e6..50827d8b243 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h @@ -70,7 +70,7 @@ class FemtoUniverseParticleHisto void init_debug(std::string folderName) { std::string folderSuffix = static_cast(o2::aod::femtouniverseMCparticle::MCTypeName[mc]).c_str(); - if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { + 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) { 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}}); @@ -83,16 +83,16 @@ class FemtoUniverseParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hDCAz").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA_{z} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hDCA").c_str(), "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", kTH2F, {{100, 0, 10}, {301, 0., 1.5}}); mHistogramRegistry->add((folderName + folderSuffix + "/hTPCdEdX").c_str(), "; #it{p} (GeV/#it{c}); TPC Signal", kTH2F, {{100, 0, 10}, {1000, 0, 1000}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{e}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{#pi}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{K}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{p}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{d}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{e}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{#pi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{K}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{p}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTPC_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TPC}^{d}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{e}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{#pi}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{K}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_p").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{p}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaTOF_d").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{TOF}^{d}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_el").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{e}", kTH2F, {{100, 0, 10}, {100, 0, 5}}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_pi").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{#pi}", kTH2F, {{100, 0, 10}, {100, 0, 5}}); mHistogramRegistry->add((folderName + folderSuffix + "/nSigmaComb_K").c_str(), "; #it{p} (GeV/#it{c}); n#sigma_{comb}^{K}", kTH2F, {{100, 0, 10}, {100, 0, 5}}); @@ -125,7 +125,7 @@ class FemtoUniverseParticleHisto mHistogramRegistry->add((folderName + folderSuffix + "/hPt_ReconNoFake").c_str(), "; #it{p}_{T} (GeV/#it{c}); Entries", kTH1F, {{240, 0, 6}}); - if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { + 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}}); @@ -168,7 +168,7 @@ class FemtoUniverseParticleHisto 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::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child) { + if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kCascadeBachelor) { /// Track histograms tempFitVarAxisTitle = "DCA_{xy} (cm)"; } else if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { @@ -231,7 +231,7 @@ class FemtoUniverseParticleHisto void fillQA_debug(T const& part, H const& histFolder) { // Histograms holding further debug information - if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { + 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) { mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/hCharge"), part.sign()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/hTPCfindable"), part.tpcNClsFindable()); mHistogramRegistry->fill(histFolder + HIST(o2::aod::femtouniverseMCparticle::MCTypeName[mc]) + HIST("/hTPCfound"), part.tpcNClsFound()); @@ -289,7 +289,7 @@ class FemtoUniverseParticleHisto mHistogramRegistry->fill(histFolder + HIST("_MC/hPt_ReconNoFake"), part.pt()); } - if constexpr (mParticleType == o2::aod::femtouniverseparticle::ParticleType::kTrack || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kV0Child || mParticleType == o2::aod::femtouniverseparticle::ParticleType::kMCTruthTrack) { + 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::femtouniverseMCparticle::kPrimary): @@ -348,7 +348,6 @@ class FemtoUniverseParticleHisto template void fillQABase(T const& part, H const& histFolder) { - fillQA_base(part, histFolder); std::string tempFitVarName; if (mHistogramRegistry) { fillQA_base(part, histFolder); diff --git a/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h b/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h index 0838ce5e5b3..4bc96996408 100644 --- a/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h +++ b/PWGCF/FemtoUniverse/Core/FemtoUniverseSHContainer.h @@ -159,20 +159,17 @@ class FemtoUniverseSHContainer /// \param ChosenEventType same or mixed event /// \param maxl Maximum valie of L component of the spherical harmonics template - void AddEventPair(T const& part1, T const& part2, uint8_t ChosenEventType, int /*maxl*/) + void AddEventPair(T const& part1, T const& part2, uint8_t ChosenEventType, int /*maxl*/, bool isiden) { - // int fMaxL = 2; - // int fMaxJM = (2+1)*(2+1); std::vector> fYlmBuffer(fMaxJM); std::vector f3d; - f3d = FemtoUniverseMath::getpairmom3d(part1, mMassOne, part2, mMassTwo, true, true); + f3d = FemtoUniverseMath::newpairfunc(part1, mMassOne, part2, mMassTwo, isiden); - // const float qstar = f3d[0]; + const float kv = f3d[0]; const float qout = f3d[1]; const float qside = f3d[2]; const float qlong = f3d[3]; - double kv = sqrt(qout * qout + qside * qside + qlong * qlong); int nqbin = fbinctn->GetXaxis()->FindFixBin(kv) - 1; FemtoUniverseSpherHarMath Ylm; diff --git a/PWGCF/FemtoUniverse/DataModel/FemtoDerived.h b/PWGCF/FemtoUniverse/DataModel/FemtoDerived.h index b7fd3e34524..7f43c675053 100644 --- a/PWGCF/FemtoUniverse/DataModel/FemtoDerived.h +++ b/PWGCF/FemtoUniverse/DataModel/FemtoDerived.h @@ -31,6 +31,8 @@ DECLARE_SOA_COLUMN(MultV0M, multV0M, float); //! V0M multiplicity DECLARE_SOA_COLUMN(MultNtr, multNtr, int); //! multiplicity of charged tracks as defined in the producer DECLARE_SOA_COLUMN(Sphericity, sphericity, float); //! Sphericity of the event DECLARE_SOA_COLUMN(MagField, magField, float); //! Magnetic field of the event +DECLARE_SOA_COLUMN(IRrate, irrate, float); //! Interaction rate +DECLARE_SOA_COLUMN(Occupancy, occupancy, int); //! TPC occupancy } // namespace femtouniversecollision @@ -43,6 +45,11 @@ DECLARE_SOA_TABLE(FDCollisions, "AOD", "FDCOLLISION", femtouniversecollision::MagField); using FDCollision = FDCollisions::iterator; +DECLARE_SOA_TABLE(FDExtCollisions, "AOD", "FDEXTCOLLISION", + femtouniversecollision::IRrate, + femtouniversecollision::Occupancy); +using FDExtCollision = FDExtCollisions::iterator; + /// FemtoUniverseTrack namespace femtouniverseparticle { @@ -70,10 +77,11 @@ enum TrackType { kNoChild, //! Not a V0 child kPosChild, //! Positive V0 child kNegChild, //! Negative V0 child + kBachelor, //! Cascade bachelor 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) @@ -125,6 +133,24 @@ DECLARE_SOA_COLUMN(DecayVtxZ, decayVtxZ, float); //! Z position of the decay DECLARE_SOA_COLUMN(MKaon, mKaon, float); //! The invariant mass of V0 candidate, assuming kaon } // 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, @@ -186,6 +212,36 @@ DECLARE_SOA_TABLE(FDExtParticles, "AOD", "FDEXTPARTICLE", pidtof_tiny::TOFNSigmaDe); 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, + femtouniverseparticle::Theta, + femtouniverseparticle::Px, + femtouniverseparticle::Py, + femtouniverseparticle::Pz, + femtouniverseparticle::P, + femtouniversecascparticle::DcaV0daughters, + femtouniversecascparticle::Cpav0, + femtouniversecascparticle::V0radius, + femtouniversecascparticle::CpaCasc, + femtouniversecascparticle::Dcacascdaughters, + femtouniversecascparticle::Cascradius, + femtouniversecascparticle::Dcapostopv, + femtouniversecascparticle::Dcanegtopv, + femtouniversecascparticle::Dcabachtopv, + femtouniversecascparticle::Dcav0topv); +using FDCascParticle = FDCascParticles::iterator; + /// FemtoUniverseTrackMC namespace femtouniverseMCparticle { @@ -252,8 +308,8 @@ namespace hash { DECLARE_SOA_COLUMN(Bin, bin, int); //! Hash for the event mixing } // namespace hash -DECLARE_SOA_TABLE(Hashes, "AOD", "HASH", hash::Bin); -using Hash = Hashes::iterator; +DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin); +using MixingHash = MixingHashes::iterator; } // namespace o2::aod diff --git a/PWGCF/FemtoUniverse/TableProducer/CMakeLists.txt b/PWGCF/FemtoUniverse/TableProducer/CMakeLists.txt index ecbb6e46873..b82a2e6d6f1 100644 --- a/PWGCF/FemtoUniverse/TableProducer/CMakeLists.txt +++ b/PWGCF/FemtoUniverse/TableProducer/CMakeLists.txt @@ -11,7 +11,7 @@ o2physics_add_dpl_workflow(femtouniverse-producer SOURCES femtoUniverseProducerTask.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(femtouniverse-mctruth-producer diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx index f80d7dafcd6..117b5c57624 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerMCTruthTask.cxx @@ -170,6 +170,8 @@ struct femtoUniverseProducerMCTruthTask { for (uint32_t pdg : tmpPDGCodes) { if (pdgCode == 333) { pass = true; + } else if (pdgCode == 421) { + pass = true; } else if (static_cast(pdg) == static_cast(pdgCode)) { if (particle.isPhysicalPrimary()) pass = true; diff --git a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx index 48037f07edf..2482c592275 100644 --- a/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx +++ b/PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx @@ -14,10 +14,14 @@ /// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de /// \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 +#include #include // FIXME +#include +#include +#include -#include #include "Common/Core/trackUtilities.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -29,6 +33,7 @@ #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" @@ -45,6 +50,7 @@ #include "ReconstructionDataFormats/Track.h" #include "TMath.h" #include "TLorentzVector.h" +#include "Framework/O2DatabasePDGPlugin.h" using namespace o2; using namespace o2::analysis::femtoUniverse; @@ -57,9 +63,9 @@ namespace o2::aod using FemtoFullCollision = soa::Join::iterator; using FemtoFullCollisionCentRun2 = - soa::Join::iterator; + soa::Join::iterator; using FemtoFullCollisionCentRun3 = - soa::Join::iterator; + soa::Join::iterator; using FemtoFullCollisionMC = soa::Join::iterator; using FemtoFullTracks = @@ -100,12 +106,13 @@ struct femtoUniverseProducerTask { Produces outputDebugParts; Produces outputPartsMCLabels; Produces outputDebugPartsMC; + Produces outputCascParts; Configurable ConfIsDebug{"ConfIsDebug", true, "Enable Debug tables"}; // Choose if filtering or skimming version is run Configurable ConfIsTrigger{"ConfIsTrigger", false, "Store all collisions"}; // Choose if running on converted data or Run3 / Pilot - Configurable ConfIsRun3{"ConfIsRun3", false, "Running on Run3 or pilot"}; + Configurable ConfIsRun3{"ConfIsRun3", true, "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)"}; @@ -119,12 +126,21 @@ struct femtoUniverseProducerTask { 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", true, "Activate filling of V0 into femtouniverse tables"}; + 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); @@ -136,17 +152,7 @@ struct femtoUniverseProducerTask { // "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"}; // only for checking the particle origin (particles for which PDG does not match are marked as "Fake") FemtoUniverseTrackSelection trackCuts; - - struct : o2::framework::ConfigurableGroup { - Configurable ConfPtLowFilterCut{"ConfPtLowFilterCut", 0.14, "Lower limit for Pt for the global track"}; // pT low - Configurable ConfPtHighFilterCut{"ConfPtHighFilterCut", 5.0, "Higher limit for Pt for the global track"}; // pT high - Configurable ConfEtaFilterCut{"ConfEtaFilterCut", 0.8, "Eta cut for the global track"}; // eta - Configurable ConfDcaXYFilterCut{"ConfDcaXYFilterCut", 2.4, "Value for DCA_XY for the global track"}; // max dca to vertex XY - Configurable ConfDcaZFilterCut{"ConfDcaZFilterCut", 3.2, "Value for DCA_Z for the global track"}; // max dca to vertex Z - } ConfFilterCuts; - Configurable> ConfTrkCharge{FemtoUniverseTrackSelection::getSelectionName(femtoUniverseTrackSelection::kSign, "ConfTrk"), std::vector{-1, 1}, FemtoUniverseTrackSelection::getSelectionHelper(femtoUniverseTrackSelection::kSign, "Track selection: ")}; Configurable> ConfTrkPtmin{FemtoUniverseTrackSelection::getSelectionName(femtoUniverseTrackSelection::kpTMin, "ConfTrk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoUniverseTrackSelection::getSelectionHelper(femtoUniverseTrackSelection::kpTMin, "Track selection: ")}; Configurable> ConfTrkPtmax{FemtoUniverseTrackSelection::getSelectionName(femtoUniverseTrackSelection::kpTMax, "ConfTrk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoUniverseTrackSelection::getSelectionHelper(femtoUniverseTrackSelection::kpTMax, "Track selection: ")}; @@ -171,76 +177,109 @@ struct femtoUniverseProducerTask { // V0 FemtoUniverseV0Selection v0Cuts; - Configurable> ConfV0Sign{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0Sign, "ConfV0"), std::vector{-1, 1}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0Sign, "V0 selection: ")}; - Configurable> ConfV0PtMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0pTMin, "ConfV0"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0pTMin, "V0 selection: ")}; - Configurable> ConfV0PtMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0pTMax, "ConfV0"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0pTMax, "V0 selection: ")}; - Configurable> ConfV0EtaMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0etaMax, "ConfV0"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0etaMax, "V0 selection: ")}; - Configurable> ConfV0DCADaughMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0DCADaughMax, "ConfV0"), std::vector{1.2f, 1.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0DCADaughMax, "V0 selection: ")}; - Configurable> ConfV0CPAMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0CPAMin, "ConfV0"), std::vector{0.99f, 0.995f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0CPAMin, "V0 selection: ")}; - Configurable> ConfV0TranRadMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0TranRadMin, "ConfV0"), std::vector{0.2f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0TranRadMin, "V0 selection: ")}; - Configurable> ConfV0TranRadMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0TranRadMax, "ConfV0"), std::vector{100.f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0TranRadMax, "V0 selection: ")}; - Configurable> ConfV0DecVtxMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0DecVtxMax, "ConfV0"), std::vector{100.f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0DecVtxMax, "V0 selection: ")}; - - 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"}; - - 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"}; + struct : o2::framework::ConfigurableGroup { + Configurable> ConfV0Sign{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0Sign, "ConfV0"), std::vector{-1, 1}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0Sign, "V0 selection: ")}; + Configurable> ConfV0PtMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0pTMin, "ConfV0"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0pTMin, "V0 selection: ")}; + Configurable> ConfV0PtMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0pTMax, "ConfV0"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0pTMax, "V0 selection: ")}; + Configurable> ConfV0EtaMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0etaMax, "ConfV0"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0etaMax, "V0 selection: ")}; + Configurable> ConfV0DCADaughMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0DCADaughMax, "ConfV0"), std::vector{1.2f, 1.5f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0DCADaughMax, "V0 selection: ")}; + Configurable> ConfV0CPAMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0CPAMin, "ConfV0"), std::vector{0.99f, 0.995f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0CPAMin, "V0 selection: ")}; + Configurable> ConfV0TranRadMin{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0TranRadMin, "ConfV0"), std::vector{0.2f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0TranRadMin, "V0 selection: ")}; + Configurable> ConfV0TranRadMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0TranRadMax, "ConfV0"), std::vector{100.f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0TranRadMax, "V0 selection: ")}; + Configurable> ConfV0DecVtxMax{FemtoUniverseV0Selection::getSelectionName(femtoUniverseV0Selection::kV0DecVtxMax, "ConfV0"), std::vector{100.f}, FemtoUniverseV0Selection::getSelectionHelper(femtoUniverseV0Selection::kV0DecVtxMax, "V0 selection: ")}; + + 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"}; + + 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"}; + } ConfV0Selection; - Filter GlobalCutFilter = requireGlobalTrackInFilter(); + struct : o2::framework::ConfigurableGroup { + Configurable ConfPtLowFilterCut{"ConfPtLowFilterCut", 0.14, "Lower limit for Pt for the global track"}; // pT low + Configurable ConfPtHighFilterCut{"ConfPtHighFilterCut", 5.0, "Higher limit for Pt for the global track"}; // pT high + Configurable ConfEtaFilterCut{"ConfEtaFilterCut", 0.8, "Eta cut for the global track"}; // eta + Configurable ConfDxaXYCustom0Cut{"ConfDxaXYCustom0Cut", false, "Enable Custom Dcaxy < [0] cut."}; + Configurable ConfDcaXYFilterCut{"ConfDcaXYFilterCut", 2.4, "Value for DCA_XY for the global track"}; // max dca to vertex XY + Configurable ConfDcaZFilterCut{"ConfDcaZFilterCut", 3.2, "Value for DCA_Z for the global track"}; // max dca to vertex Z + Configurable ConfDcaXYCustom1Cut{"ConfDcaXYCustom1Cut", true, "Enable Custom |DCAxy| < [1] + [2]/pt cut."}; + Configurable ConfDcaXYCustom11FilterCut{"ConfDcaXY1FilterCut", 0.004, "Value for [1] custom DCAxy cut -> |DCAxy| < [1] + [2]/pT"}; + Configurable ConfDcaXYCustom12FilterCut{"ConfDcaXY2FilterCut", 0.013, "Value for [2] custom DCAxy cut -> |DCAxy| < [1] + [2]/pT"}; + } ConfFilterCuts; + Filter GlobalCutFilter = requireGlobalTrackInFilter(); Filter CustomTrackFilter = (aod::track::pt > ConfFilterCuts.ConfPtLowFilterCut) && (aod::track::pt < ConfFilterCuts.ConfPtHighFilterCut) && (nabs(aod::track::eta) < ConfFilterCuts.ConfEtaFilterCut) && - (aod::track::dcaXY < ConfFilterCuts.ConfDcaXYFilterCut) && - (aod::track::dcaZ < ConfFilterCuts.ConfDcaZFilterCut); - - // PHI - FemtoUniversePhiSelection phiCuts; - struct : o2::framework::ConfigurableGroup { - Configurable> ConfPhiSign{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiSign, "ConfPhi"), std::vector{-1, 1}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiSign, "Phi selection: ")}; - Configurable> ConfPhiPtMin{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhipTMin, "ConfPhi"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhipTMin, "Phi selection: ")}; - Configurable> ConfPhiPtMax{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhipTMax, "ConfPhi"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhipTMax, "Phi selection: ")}; - Configurable> ConfPhiEtaMax{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhietaMax, "ConfPhi"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhietaMax, "Phi selection: ")}; - Configurable> ConfPhiDCADaughMax{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiDCADaughMax, "ConfPhi"), std::vector{1.2f, 1.5f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiDCADaughMax, "Phi selection: ")}; - Configurable> ConfPhiCPAMin{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiCPAMin, "ConfPhi"), std::vector{0.99f, 0.995f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiCPAMin, "Phi selection: ")}; - Configurable> ConfPhiTranRadMin{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiTranRadMin, "ConfPhi"), std::vector{0.2f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiTranRadMin, "Phi selection: ")}; - Configurable> ConfPhiTranRadMax{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiTranRadMax, "ConfPhi"), std::vector{100.f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiTranRadMax, "Phi selection: ")}; - Configurable> ConfPhiDecVtxMax{FemtoUniversePhiSelection::getSelectionName(femtoUniversePhiSelection::kPhiDecVtxMax, "ConfPhi"), std::vector{100.f}, FemtoUniversePhiSelection::getSelectionHelper(femtoUniversePhiSelection::kPhiDecVtxMax, "Phi selection: ")}; - } ConfPhiSelection; + (!ConfFilterCuts.ConfDxaXYCustom0Cut || (aod::track::dcaXY < ConfFilterCuts.ConfDcaXYFilterCut)) && // true if configurable set to false or if configurable is true and it passes the selection + (aod::track::dcaZ < ConfFilterCuts.ConfDcaZFilterCut) && + (!ConfFilterCuts.ConfDcaXYCustom1Cut || (nabs(aod::track::dcaXY) < ConfFilterCuts.ConfDcaXYCustom11FilterCut + ConfFilterCuts.ConfDcaXYCustom12FilterCut / aod::track::pt)); // same logic here + // CASCADE + FemtoUniverseCascadeSelection cascadeCuts; struct : o2::framework::ConfigurableGroup { - Configurable> ConfPhiChildCharge{"ConfPhiChildSign", std::vector{-1, 1}, "Phi Child sel: Charge"}; - Configurable> ConfPhiChildEtaMax{"ConfPhiChildEtaMax", std::vector{0.8f}, "Phi Child sel: max eta"}; - Configurable> ConfPhiChildTPCnClsMin{"ConfPhiChildTPCnClsMin", std::vector{80.f, 70.f, 60.f}, "Phi Child sel: Min. nCls TPC"}; - Configurable> ConfPhiChildDCAMin{"ConfPhiChildDCAMin", std::vector{0.05f, 0.06f}, "Phi Child sel: Max. DCA Daugh to PV (cm)"}; - Configurable> ConfPhiChildPIDnSigmaMax{"ConfPhiChildPIDnSigmaMax", std::vector{5.f, 4.f}, "Phi Child sel: Max. PID nSigma TPC"}; - Configurable> ConfPhiChildPIDspecies{"ConfPhiChildPIDspecies", std::vector{o2::track::PID::Kaon, o2::track::PID::Kaon}, "Phi Child sel: Particles species for PID"}; - } ConfPhiChildSelection; + Configurable> ConfCascSign{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeSign, "ConfCasc"), std::vector{-1, 1}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeSign, "Cascade selection: ")}; + Configurable> ConfCascPtMin{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadepTMin, "ConfCasc"), std::vector{0.3f, 0.4f, 0.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadepTMin, "Cascade selection: ")}; + Configurable> ConfCascPtMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadepTMax, "ConfCasc"), std::vector{3.3f, 3.4f, 3.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadepTMax, "Cascade selection: ")}; + Configurable> ConfCascEtaMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeetaMax, "ConfCasc"), std::vector{0.8f, 0.7f, 0.9f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeetaMax, "Cascade selection: ")}; + Configurable> ConfCascV0DCADaughMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0DCADaughMax, "ConfCasc"), std::vector{1.f, 1.2f, 1.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0DCADaughMax, "Cascade selection: ")}; + Configurable> ConfCascV0CPAMin{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0CPAMin, "ConfCasc"), std::vector{0.99f, 0.95f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0CPAMin, "Cascade selection: ")}; + Configurable> ConfCascV0TranRadMin{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0TranRadMin, "ConfCasc"), std::vector{0.2f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0TranRadMin, "Cascade selection: ")}; + Configurable> ConfCascV0TranRadMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0TranRadMax, "ConfCasc"), std::vector{100.f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0TranRadMax, "Cascade selection: ")}; + Configurable> ConfCascV0DecVtxMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0DecVtxMax, "ConfCasc"), std::vector{100.f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0DecVtxMax, "Cascade selection: ")}; + Configurable> ConfCascDCADaughMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDCADaughMax, "ConfCasc"), std::vector{1.f, 1.2f, 1.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDCADaughMax, "Cascade selection: ")}; + Configurable> ConfCascCPAMin{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeCPAMin, "ConfCasc"), std::vector{0.99f, 0.95f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeCPAMin, "Cascade selection: ")}; + Configurable> ConfCascTranRadMin{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeTranRadMin, "ConfCasc"), std::vector{0.2f, 0.5f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeTranRadMin, "Cascade selection: ")}; + Configurable> ConfCascTranRadMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeTranRadMax, "ConfCasc"), std::vector{100.f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeTranRadMax, "Cascade selection: ")}; + Configurable> ConfCascDecVtxMax{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDecVtxMax, "ConfCasc"), std::vector{100.f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDecVtxMax, "Cascade selection: ")}; + + Configurable> ConfCascDCAPosToPV{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDCAPosToPV, "ConfCasc"), std::vector{0.1f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDCAPosToPV, "Cascade selection: ")}; + Configurable> ConfCascDCANegToPV{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDCANegToPV, "ConfCasc"), std::vector{0.1f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDCANegToPV, "Cascade selection: ")}; + Configurable> ConfCascDCABachToPV{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDCABachToPV, "ConfCasc"), std::vector{0.1f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDCABachToPV, "Cascade selection: ")}; + Configurable> ConfCascDCAV0ToPV{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeDCAV0ToPV, "ConfCasc"), std::vector{0.01f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeDCAV0ToPV, "Cascade selection: ")}; + Configurable> ConfCascV0MassLowLimit{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0MassMin, "ConfCasc"), std::vector{1.05f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0MassMin, "Cascade selection: ")}; + Configurable> ConfCascV0MassUpLimit{FemtoUniverseCascadeSelection::getSelectionName(femtoUniverseCascadeSelection::kCascadeV0MassMax, "ConfCasc"), std::vector{1.30f}, FemtoUniverseCascadeSelection::getSelectionHelper(femtoUniverseCascadeSelection::kCascadeV0MassMax, "Cascade selection: ")}; + + Configurable> ConfCascChildCharge{"ConfCascChildSign", std::vector{-1, 1}, "Cascade Child sel: Charge"}; + Configurable> ConfCascChildEtaMax{"ConfCascChildEtaMax", std::vector{0.8f}, "Cascade Child sel: max eta"}; + Configurable> ConfCascChildTPCnClsMin{"ConfCascChildTPCnClsMin", std::vector{80.f, 70.f, 60.f}, "Cascade Child sel: Min. nCls TPC"}; + // Configurable> ConfCascChildDCAMin{"ConfCascChildDCAMin", std::vector{0.05f, 0.06f}, "Cascade Child sel: Max. DCA Daugh to PV (cm)"}; + 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"}; + } ConfCascadeSelection; + // PHI + FemtoUniversePhiSelection phiCuts; struct : o2::framework::ConfigurableGroup { - Configurable ConfNsigmaCombinedKaon{"ConfNsigmaCombinedKaon", 3.0, "TPC and TOF Kaon Sigma (combined) for momentum > 0.4"}; - Configurable ConfNsigmaTPCKaon{"ConfNsigmaTPCKaon", 3.0, "TPC Kaon Sigma for momentum < 0.4"}; - Configurable ConfNsigmaTPCTOFKaon{"ConfNsigmaTPCTOFKaon", true, "Use TPC and TOF for PID of Kaons"}; + 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 ConfLooseTOFNSigmaValue{"ConfLooseTOFNSigmaValue", 10, "Value for the loose TOF N Sigma for Kaon PID."}; 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"}; - } ConfPhiCommon; - // PHI child one - struct : o2::framework::ConfigurableGroup { - Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 321, "Particle 1 - PDG code"}; - } ConfPhiChildOne; - // PHI child two - struct : o2::framework::ConfigurableGroup { - Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 321, "Particle 2 - PDG code"}; - } ConfPhiChildTwo; + Configurable ConfPtLowLimitPhi{"ConfPtLowLimitPhi", 0.8, "Lower limit of the Phi pT."}; + Configurable ConfPtHighLimitPhi{"ConfPtHighLimitPhi", 4.0, "Higher limit of the Phi pT."}; + 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."}; + } ConfPhiSelection; + + Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 321, "Particle 1 - PDG code"}; + Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 321, "Particle 2 - PDG code"}; // D0/D0bar mesons struct : o2::framework::ConfigurableGroup { @@ -252,13 +291,6 @@ struct femtoUniverseProducerTask { bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { - //|nsigma_TPC| < 5 for p < 0.4 GeV/c - //|nsigma_combined| < 5 for p > 0.4 - - // using configurables: - // ConfNsigmaTPCTOFKaon -> are we doing TPC TOF PID for Kaons? (boolean) - // ConfNsigmaTPCKaon -> TPC Kaon Sigma for momentum < 0.4 - // ConfNsigmaCombinedKaon -> TPC and TOF Kaon Sigma (combined) for momentum > 0.4 if (mom < 0.3) { // 0.0-0.3 if (TMath::Abs(nsigmaTPCK) < 3.0) { @@ -297,6 +329,105 @@ struct femtoUniverseProducerTask { } } + bool IsKaonNSigmaTPCLoose(float mom, float nsigmaTPCK, float nsigmaTOFK) + { + + if (mom < 0.3) { // 0.0-0.3 + if (TMath::Abs(nsigmaTPCK) < ConfPhiSelection.ConfLooseTPCNSigmaValue.value) { + return true; + } else { + return false; + } + } else if (mom < 0.45) { // 0.30 - 0.45 + if (TMath::Abs(nsigmaTPCK) < ConfPhiSelection.ConfLooseTPCNSigmaValue.value) { + return true; + } else { + return false; + } + } else if (mom < 0.55) { // 0.45-0.55 + if (TMath::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 ((TMath::Abs(nsigmaTOFK) < 3.0) && (TMath::Abs(nsigmaTPCK) < ConfPhiSelection.ConfLooseTPCNSigmaValue.value)) { + return true; + } else { + return false; + } + } else if (mom > 1.5) { // 1.5 - + if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < ConfPhiSelection.ConfLooseTPCNSigmaValue.value)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + bool IsKaonNSigmaTOFLoose(float mom, float nsigmaTPCK, float nsigmaTOFK) + { + if (mom < 0.3) { // 0.0-0.3 + if (TMath::Abs(nsigmaTPCK) < 3.0) { + return true; + } else { + return false; + } + } else if (mom < 0.45) { // 0.30 - 0.45 + if (TMath::Abs(nsigmaTPCK) < 2.0) { + return true; + } else { + return false; + } + } else if (mom < 0.55) { // 0.45-0.55 + if (TMath::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) < ConfPhiSelection.ConfLooseTOFNSigmaValue.value) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + { + return true; + } + } else { + return false; + } + } else if (mom > 1.5) { // 1.5 - + if ((TMath::Abs(nsigmaTOFK) < ConfPhiSelection.ConfLooseTOFNSigmaValue.value) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + bool IsKaonRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi) + { + if (mom < 0.5) { + if (TMath::Abs(nsigmaTPCPi) < ConfPhiSelection.ConfNsigmaRejectPion.value) { + return true; + } else if (TMath::Abs(nsigmaTPCPr) < ConfPhiSelection.ConfNsigmaRejectProton.value) { + return true; + } + } + if (mom > 0.5) { + if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfPhiSelection.ConfNsigmaRejectPion.value) { + return true; + } else if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfPhiSelection.ConfNsigmaRejectProton.value) { + return true; + } else { + return false; + } + } else { + return false; + } + } + /// \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) && @@ -305,6 +436,7 @@ struct femtoUniverseProducerTask { // for now do not know why HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; + HistogramRegistry cascadeQaRegistry{"CascadeQAHistos", {}, OutputObjHandlingPolicy::QAObject}; int mRunNumber; float mMagField; @@ -312,10 +444,10 @@ struct femtoUniverseProducerTask { void init(InitContext&) { - if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data) == false && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth) == false) { + if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data || doprocessTrackV0CentRun3) == false && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMC || doprocessFullMCCent) == false) { LOGF(fatal, "Neither processFullData nor processFullMC enabled. Please choose one."); } - if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data) == true && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth) == true) { + if ((doprocessFullData || doprocessTrackPhiData || doprocessTrackData || doprocessTrackV0 || doprocessTrackCascadeData || doprocessTrackD0mesonData || doprocessTrackCentRun2Data || doprocessTrackCentRun3Data || doprocessTrackV0CentRun3) == true && (doprocessFullMC || doprocessTrackMC || doprocessTrackMCTruth || doprocessTrackMCGen || doprocessTruthAndFullMC || doprocessFullMCCent) == true) { LOGF(fatal, "Cannot enable process Data and process MC at the same time. " "Please choose one."); @@ -347,29 +479,29 @@ struct femtoUniverseProducerTask { // femtoUniverseV0Selection::kDecVtxMax, femtoUniverseSelection::kAbsUpperLimit); if (ConfIsActivateV0) { // initializing for V0 - v0Cuts.setSelection(ConfV0Sign, femtoUniverseV0Selection::kV0Sign, femtoUniverseSelection::kEqual); - v0Cuts.setSelection(ConfV0PtMin, femtoUniverseV0Selection::kV0pTMin, femtoUniverseSelection::kLowerLimit); - v0Cuts.setSelection(ConfV0PtMax, femtoUniverseV0Selection::kV0pTMax, femtoUniverseSelection::kUpperLimit); - v0Cuts.setSelection(ConfV0EtaMax, femtoUniverseV0Selection::kV0etaMax, femtoUniverseSelection::kAbsUpperLimit); - v0Cuts.setSelection(ConfV0DCADaughMax, femtoUniverseV0Selection::kV0DCADaughMax, femtoUniverseSelection::kUpperLimit); - v0Cuts.setSelection(ConfV0CPAMin, femtoUniverseV0Selection::kV0CPAMin, femtoUniverseSelection::kLowerLimit); - v0Cuts.setSelection(ConfV0TranRadMin, femtoUniverseV0Selection::kV0TranRadMin, femtoUniverseSelection::kLowerLimit); - v0Cuts.setSelection(ConfV0TranRadMax, femtoUniverseV0Selection::kV0TranRadMax, femtoUniverseSelection::kUpperLimit); - v0Cuts.setSelection(ConfV0DecVtxMax, femtoUniverseV0Selection::kV0DecVtxMax, femtoUniverseSelection::kUpperLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfChildDCAMin, femtoUniverseTrackSelection::kDCAMin, femtoUniverseSelection::kAbsLowerLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfChildDCAMin, femtoUniverseTrackSelection::kDCAMin, femtoUniverseSelection::kAbsLowerLimit); - v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); - v0Cuts.setChildPIDSpecies(femtoUniverseV0Selection::kPosTrack, ConfChildPIDspecies); - v0Cuts.setChildPIDSpecies(femtoUniverseV0Selection::kNegTrack, ConfChildPIDspecies); + v0Cuts.setSelection(ConfV0Selection.ConfV0Sign, femtoUniverseV0Selection::kV0Sign, femtoUniverseSelection::kEqual); + v0Cuts.setSelection(ConfV0Selection.ConfV0PtMin, femtoUniverseV0Selection::kV0pTMin, femtoUniverseSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0PtMax, femtoUniverseV0Selection::kV0pTMax, femtoUniverseSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0EtaMax, femtoUniverseV0Selection::kV0etaMax, femtoUniverseSelection::kAbsUpperLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0DCADaughMax, femtoUniverseV0Selection::kV0DCADaughMax, femtoUniverseSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0CPAMin, femtoUniverseV0Selection::kV0CPAMin, femtoUniverseSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0TranRadMin, femtoUniverseV0Selection::kV0TranRadMin, femtoUniverseSelection::kLowerLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0TranRadMax, femtoUniverseV0Selection::kV0TranRadMax, femtoUniverseSelection::kUpperLimit); + v0Cuts.setSelection(ConfV0Selection.ConfV0DecVtxMax, femtoUniverseV0Selection::kV0DecVtxMax, femtoUniverseSelection::kUpperLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildDCAMin, femtoUniverseTrackSelection::kDCAMin, femtoUniverseSelection::kAbsLowerLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildDCAMin, femtoUniverseTrackSelection::kDCAMin, femtoUniverseSelection::kAbsLowerLimit); + v0Cuts.setChildCuts(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); + v0Cuts.setChildPIDSpecies(femtoUniverseV0Selection::kPosTrack, ConfV0Selection.ConfChildPIDspecies); + v0Cuts.setChildPIDSpecies(femtoUniverseV0Selection::kNegTrack, ConfV0Selection.ConfChildPIDspecies); v0Cuts.init(&qaRegistry); - v0Cuts.setInvMassLimits(ConfV0InvMassLowLimit, ConfV0InvMassUpLimit); + v0Cuts.setInvMassLimits(ConfV0Selection.ConfV0InvMassLowLimit, ConfV0Selection.ConfV0InvMassUpLimit); v0Cuts.setChildRejectNotPropagatedTracks(femtoUniverseV0Selection::kPosTrack, ConfTrkRejectNotPropagated); v0Cuts.setChildRejectNotPropagatedTracks(femtoUniverseV0Selection::kNegTrack, ConfTrkRejectNotPropagated); @@ -378,8 +510,8 @@ struct femtoUniverseProducerTask { v0Cuts.setChildnSigmaPIDOffset(femtoUniverseV0Selection::kPosTrack, ConfTrkPIDnSigmaOffsetTPC, ConfTrkPIDnSigmaOffsetTOF); v0Cuts.setChildnSigmaPIDOffset(femtoUniverseV0Selection::kNegTrack, ConfTrkPIDnSigmaOffsetTPC, ConfTrkPIDnSigmaOffsetTOF); - if (ConfV0RejectKaons) { - v0Cuts.setKaonInvMassLimits(ConfV0InvKaonMassLowLimit, ConfV0InvKaonMassUpLimit); + if (ConfV0Selection.ConfV0RejectKaons) { + v0Cuts.setKaonInvMassLimits(ConfV0Selection.ConfV0InvKaonMassLowLimit, ConfV0Selection.ConfV0InvKaonMassUpLimit); } // if (ConfRejectITSHitandTOFMissing) { // o2PhysicsTrackSelection = new @@ -388,6 +520,59 @@ struct femtoUniverseProducerTask { // } } + if (ConfIsActivateCascade) { + // initializing for cascades + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascSign, femtoUniverseCascadeSelection::kCascadeSign, femtoUniverseSelection::kEqual); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascPtMin, femtoUniverseCascadeSelection::kCascadepTMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascPtMax, femtoUniverseCascadeSelection::kCascadepTMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascEtaMax, femtoUniverseCascadeSelection::kCascadeetaMax, femtoUniverseSelection::kAbsUpperLimit); + // v0 child cuts + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0DCADaughMax, femtoUniverseCascadeSelection::kCascadeV0DCADaughMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0CPAMin, femtoUniverseCascadeSelection::kCascadeV0CPAMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0TranRadMin, femtoUniverseCascadeSelection::kCascadeV0TranRadMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0TranRadMax, femtoUniverseCascadeSelection::kCascadeV0TranRadMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0DecVtxMax, femtoUniverseCascadeSelection::kCascadeV0DecVtxMax, femtoUniverseSelection::kUpperLimit); + // cascade cuts + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDCADaughMax, femtoUniverseCascadeSelection::kCascadeDCADaughMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascCPAMin, femtoUniverseCascadeSelection::kCascadeCPAMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascTranRadMin, femtoUniverseCascadeSelection::kCascadeTranRadMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascTranRadMax, femtoUniverseCascadeSelection::kCascadeTranRadMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDecVtxMax, femtoUniverseCascadeSelection::kCascadeDecVtxMax, femtoUniverseSelection::kUpperLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDCAPosToPV, femtoUniverseCascadeSelection::kCascadeDCAPosToPV, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDCANegToPV, femtoUniverseCascadeSelection::kCascadeDCANegToPV, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDCABachToPV, femtoUniverseCascadeSelection::kCascadeDCABachToPV, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascDCAV0ToPV, femtoUniverseCascadeSelection::kCascadeDCAV0ToPV, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0MassLowLimit, femtoUniverseCascadeSelection::kCascadeV0MassMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setSelection(ConfCascadeSelection.ConfCascV0MassUpLimit, femtoUniverseCascadeSelection::kCascadeV0MassMax, femtoUniverseSelection::kUpperLimit); + // children cuts + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kPosTrack, ConfCascadeSelection.ConfCascChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kPosTrack, ConfCascadeSelection.ConfCascChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kPosTrack, ConfCascadeSelection.ConfCascChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kPosTrack, ConfCascadeSelection.ConfCascChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kNegTrack, ConfCascadeSelection.ConfCascChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kNegTrack, ConfCascadeSelection.ConfCascChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kNegTrack, ConfCascadeSelection.ConfCascChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kNegTrack, ConfCascadeSelection.ConfCascChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kBachTrack, ConfCascadeSelection.ConfCascChildCharge, femtoUniverseTrackSelection::kSign, femtoUniverseSelection::kEqual); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kBachTrack, ConfCascadeSelection.ConfCascChildEtaMax, femtoUniverseTrackSelection::kEtaMax, femtoUniverseSelection::kAbsUpperLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kBachTrack, ConfCascadeSelection.ConfCascChildTPCnClsMin, femtoUniverseTrackSelection::kTPCnClsMin, femtoUniverseSelection::kLowerLimit); + cascadeCuts.setChildCuts(femtoUniverseCascadeSelection::kBachTrack, ConfCascadeSelection.ConfCascChildPIDnSigmaMax, femtoUniverseTrackSelection::kPIDnSigmaMax, femtoUniverseSelection::kAbsUpperLimit); + + // TODO + cascadeCuts.setChildPIDSpecies(femtoUniverseCascadeSelection::kPosTrack, ConfV0Selection.ConfChildPIDspecies); + cascadeCuts.setChildPIDSpecies(femtoUniverseCascadeSelection::kNegTrack, ConfV0Selection.ConfChildPIDspecies); + cascadeCuts.setChildPIDSpecies(femtoUniverseCascadeSelection::kBachTrack, ConfCascadeSelection.ConfCascChildPIDspecies); + + // check if works correctly for bachelor track + cascadeCuts.init(&cascadeQaRegistry, ConfIsSelectCascOmega); + // invmass cuts + cascadeCuts.setInvMassLimits(ConfCascadeSelection.ConfCascInvMassLowLimit, ConfCascadeSelection.ConfCascInvMassUpLimit); + + if (ConfCascadeSelection.ConfCascRejectCompetingMass) { + cascadeCuts.setCompetingInvMassLimits(ConfCascadeSelection.ConfCascInvCompetingMassLowLimit, ConfCascadeSelection.ConfCascInvCompetingMassUpLimit); + } + } + if (ConfIsActivatePhi) { // initializing for Phi meson phiCuts.init(&qaRegistry); @@ -441,7 +626,7 @@ struct femtoUniverseProducerTask { mRunNumber = bc.runNumber(); } - template + template void fillDebugParticle(ParticleType const& particle) { if constexpr (isTrackOrV0) { @@ -464,10 +649,17 @@ struct femtoUniverseProducerTask { -999., -999., -999., -999., -999., -999.); // QA for phi or D0/D0bar + } else if constexpr (isXi) { + outputDebugParts(-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(), + particle.x(), particle.y(), particle.z(), + 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., - -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(), particle.x(), particle.y(), particle.z(), @@ -483,13 +675,15 @@ struct femtoUniverseProducerTask { auto particleMC = particle.mcParticle(); auto pdgCode = particleMC.pdgCode(); int particleOrigin = 99; - auto motherparticleMC = particleMC.template mothers_as().front(); + auto motherparticlesMC = particleMC.template mothers_as(); - if (abs(pdgCode) == abs(ConfTrkPDGCode.value)) { + if (abs(pdgCode) == abs(ConfPDGCodePartOne.value) || abs(pdgCode) == abs(ConfPDGCodePartTwo.value)) { if (particleMC.isPhysicalPrimary()) { particleOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kPrimary; - } else if (motherparticleMC.producedByGenerator()) { - particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); + } else if (!motherparticlesMC.empty()) { + auto motherparticleMC = motherparticlesMC.front(); + if (motherparticleMC.producedByGenerator()) + particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); } else { particleOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kMaterial; } @@ -503,6 +697,62 @@ struct femtoUniverseProducerTask { outputPartsMCLabels(-1); } } + + template + void fillMCParticlePhi(ParticleType const& kaon1, ParticleType const& kaon2) + { + if (kaon1.has_mcParticle() && kaon2.has_mcParticle()) { + // get corresponding MC particle and its info + auto kaon1MC = kaon1.mcParticle(); + auto kaon2MC = kaon2.mcParticle(); + auto pdgCode1 = kaon1MC.pdgCode(); + auto pdgCode2 = kaon2MC.pdgCode(); + + int phiOrigin = 99; + auto motherskaon1MC = kaon1MC.template mothers_as(); + auto motherskaon2MC = kaon2MC.template mothers_as(); + + if (abs(pdgCode1) == abs(321) || abs(pdgCode2) == abs(-321)) { + if ((kaon1MC.isPhysicalPrimary() && kaon2MC.isPhysicalPrimary()) && (!motherskaon1MC.empty() && !motherskaon2MC.empty())) { + for (auto& particleMotherOfNeg : motherskaon1MC) { + for (auto& particleMotherOfPos : motherskaon2MC) { + if (particleMotherOfNeg == particleMotherOfPos && particleMotherOfNeg.pdgCode() == 333) { + phiOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kPrimary; + } else { + phiOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kFake; + } + } + } + } else { + phiOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kFake; + } + } else { + phiOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kFake; + } + + TLorentzVector part1Vec; + TLorentzVector part2Vec; + + float mMassOne = TDatabasePDG::Instance()->GetParticle(321)->Mass(); // FIXME: Get from the PDG service of the common header + float mMassTwo = TDatabasePDG::Instance()->GetParticle(-321)->Mass(); // FIXME: Get from the PDG service of the common header + + part1Vec.SetPtEtaPhiM(kaon1MC.pt(), kaon1MC.eta(), kaon1MC.phi(), mMassOne); + part2Vec.SetPtEtaPhiM(kaon2MC.pt(), kaon2MC.eta(), kaon2MC.phi(), mMassTwo); + + TLorentzVector sumVec(part1Vec); + sumVec += part2Vec; + + float phiEta = sumVec.Eta(); + float phiPt = sumVec.Pt(); + float phiPhi = sumVec.Phi(); + + outputPartsMC(phiOrigin, 333, phiPt, phiEta, phiPhi); + outputPartsMCLabels(outputPartsMC.lastIndex()); + } else { + outputPartsMCLabels(-1); + } + } + template void fillCollisions(CollisionType const& col, TrackType const& tracks) { @@ -527,35 +777,42 @@ struct femtoUniverseProducerTask { // in case of trigger run - store such collisions but don't store any // particle candidates for such collisions if (!colCuts.isSelected(col)) { - if (ConfIsTrigger) { - if (ConfDoSpher) { - outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, mult, multNtr, 2, mMagField); - } - } return; } - colCuts.fillQA(col); - if (ConfDoSpher) { - outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); + if (!ConfIsUsePileUp) { + if (ConfDoSpher) { + outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); + } else { + outputCollision(vtxZ, mult, multNtr, 2, mMagField); + } } else { - outputCollision(vtxZ, mult, multNtr, 2, mMagField); + 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); + } } + colCuts.fillQA(col); } template - void fillMCTruthCollisions(CollisionType const& col, TrackType const&) + void fillMCTruthCollisions(CollisionType const& col, TrackType const& tracks) { for (auto& c : col) { const auto vtxZ = c.posZ(); - const auto spher = 0; // colCuts.computeSphericity(col, tracks); int mult = 0; int multNtr = 0; - // 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 (std::abs(vtxZ) > ConfEvtZvtx) { + continue; + } + + if (ConfDoSpher) { + outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField); + } else { + outputCollision(vtxZ, mult, multNtr, 2, mMagField); + } } } @@ -567,7 +824,7 @@ struct femtoUniverseProducerTask { int multNtr = 0; if (!ConfIsRun3) { cent = col.centRun2V0M(); - multNtr = col.centRun2V0M(); + multNtr = col.multNTracksPV(); } // check whether the basic event selection criteria are fulfilled @@ -576,14 +833,6 @@ struct femtoUniverseProducerTask { // in case of trigger run - store such collisions but don't store any // particle candidates for such collisions if (!colCuts.isSelected(col)) { - if (ConfIsTrigger) { - if (ConfDoSpher) { - outputCollision(vtxZ, cent, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, cent, multNtr, 2, mMagField); - } - } - return; } @@ -602,32 +851,27 @@ struct femtoUniverseProducerTask { int cent = 0; int multNtr = 0; if (ConfIsRun3) { - multNtr = col.centFT0C(); + multNtr = col.multNTracksPV(); cent = col.centFT0C(); } + int occupancy = col.trackOccupancyInTimeRange(); // 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.isSelectedRun3(col)) { - if (ConfIsTrigger) { - if (ConfDoSpher) { - outputCollision(vtxZ, cent, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, cent, multNtr, 2, mMagField); - } - } ////// - return; } // colCuts.fillQA(col); //for now, TODO: create a configurable so in the FemroUniverseCollisionSelection.h there is an option to plot QA just for the posZ - if (ConfDoSpher) { - outputCollision(vtxZ, cent, multNtr, colCuts.computeSphericity(col, tracks), mMagField); - } else { - outputCollision(vtxZ, cent, multNtr, 2, mMagField); + if ((col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (occupancy > ConfTPCOccupancyMin && occupancy <= ConfTPCOccupancyMax)) { + if (ConfDoSpher) { + outputCollision(vtxZ, cent, multNtr, colCuts.computeSphericity(col, tracks), mMagField); + } else { + outputCollision(vtxZ, cent, multNtr, 2, mMagField); + } } } @@ -656,16 +900,26 @@ struct femtoUniverseProducerTask { auto cutContainer = trackCuts.getCutContainer(track); // now the table is filled - outputParts(outputCollision.lastIndex(), track.pt(), track.eta(), - track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, - cutContainer.at( - femtoUniverseTrackSelection::TrackContainerPosition::kCuts), - cutContainer.at( - femtoUniverseTrackSelection::TrackContainerPosition::kPID), - track.dcaXY(), childIDs, 0, 0); + if (!ConfIsActivateCascade) { + outputParts(outputCollision.lastIndex(), track.pt(), track.eta(), + track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, + cutContainer.at( + femtoUniverseTrackSelection::TrackContainerPosition::kCuts), + cutContainer.at( + femtoUniverseTrackSelection::TrackContainerPosition::kPID), + track.dcaXY(), childIDs, 0, 0); + } else { + outputCascParts(outputCollision.lastIndex(), track.pt(), track.eta(), + track.phi(), aod::femtouniverseparticle::ParticleType::kTrack, + cutContainer.at( + femtoUniverseTrackSelection::TrackContainerPosition::kCuts), + cutContainer.at( + femtoUniverseTrackSelection::TrackContainerPosition::kPID), + track.dcaXY(), childIDs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } tmpIDtrack.push_back(track.globalIndex()); if (ConfIsDebug) { - fillDebugParticle(track); + fillDebugParticle(track); } if constexpr (isMC) { @@ -755,9 +1009,9 @@ struct femtoUniverseProducerTask { v0.mLambda(), v0.mAntiLambda()); if (ConfIsDebug) { - 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(v0, o2::aod::femtouniverseparticle::ParticleType::kV0); @@ -765,6 +1019,147 @@ struct femtoUniverseProducerTask { } } + template + void fillCascade(CollisionType const& col, CascadeType const& fullCascades, TrackType const&) + { + std::vector childIDs = {0, 0, 0}; // child1, child2, bachelor; 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 + + for (const auto& casc : fullCascades) { + const auto& posTrackCasc = casc.template posTrack_as(); + const auto& negTrackCasc = casc.template negTrack_as(); + const auto& bachTrackCasc = casc.template bachelor_as(); + + if (!cascadeCuts.isSelectedMinimal(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc)) { + continue; + } + + cascadeCuts.fillCascadeQA(col, casc, posTrackCasc, negTrackCasc); + cascadeCuts.fillQA(col, casc, posTrackCasc, negTrackCasc, bachTrackCasc); // fill QA for daughters + + int postrackID = casc.posTrackId(); + int rowInPrimaryTrackTablePos = -1; + rowInPrimaryTrackTablePos = getRowDaughters(postrackID, tmpIDtrack); + 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(femtoUniverseV0Selection::V0ContainerPosition::kPosCuts), + 0, // cutContainerV0.at(femtoUniverseV0Selection::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); + // } + 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(femtoUniverseV0Selection::V0ContainerPosition::kNegCuts), + 0, // cutContainerV0.at(femtoUniverseV0Selection::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); + // } + // bachelor + int bachtrackID = casc.bachelorId(); + int rowInPrimaryTrackTableBach = -1; + rowInPrimaryTrackTableBach = getRowDaughters(bachtrackID, tmpIDtrack); + 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(femtoUniverseV0Selection::V0ContainerPosition::kNegCuts), + 0, // cutContainerV0.at(femtoUniverseV0Selection::V0ContainerPosition::kNegPID), + 0., + childIDs, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0); + const int rowOfBachTrack = outputCascParts.lastIndex(); + // cascade + std::vector indexCascChildID = {rowOfPosTrack, rowOfNegTrack, rowOfBachTrack}; + outputCascParts(outputCollision.lastIndex(), + casc.pt(), + casc.eta(), + casc.phi(), + aod::femtouniverseparticle::ParticleType::kCascade, + 0, // cutContainerV0.at(femtoUniverseV0Selection::V0ContainerPosition::kV0), + 0, + 0, + indexCascChildID, + ConfIsSelectCascOmega ? casc.mOmega() : casc.mXi(), + ConfIsSelectCascOmega ? casc.mOmega() : casc.mXi(), + casc.dcaV0daughters(), + casc.v0cosPA(col.posX(), col.posY(), col.posZ()), + casc.v0radius(), + casc.casccosPA(col.posX(), col.posY(), col.posZ()), + casc.dcacascdaughters(), + casc.cascradius(), + casc.dcapostopv(), + casc.dcanegtopv(), + casc.dcabachtopv(), + casc.dcav0topv(col.posX(), col.posY(), col.posZ())); + if (ConfIsDebug) { + fillDebugParticle(posTrackCasc); // QA for positive daughter + fillDebugParticle(negTrackCasc); // QA for negative daughter + fillDebugParticle(bachTrackCasc); // QA for negative daughter + fillDebugParticle(casc); // QA for cascade + } + } + } + template void fillD0mesons(CollisionType const&, TrackType const&, HfCandidate const& hfCands) { @@ -773,6 +1168,7 @@ struct femtoUniverseProducerTask { double invMassD0 = 0.0; double invMassD0bar = 0.0; bool isD0D0bar = false; + uint8_t daughFlag = 0; // flag = 0 (daugh of D0 or D0bar), 1 (daug of D0), -1 (daugh of D0bar) for (auto const& hfCand : hfCands) { @@ -801,14 +1197,17 @@ struct femtoUniverseProducerTask { invMassD0 = hfHelper.invMassD0ToPiK(hfCand); invMassD0bar = -hfHelper.invMassD0barToKPi(hfCand); isD0D0bar = true; + daughFlag = 1; } else if (hfCand.isSelD0() == 0 && hfCand.isSelD0bar() == 1) { invMassD0 = -hfHelper.invMassD0ToPiK(hfCand); invMassD0bar = hfHelper.invMassD0barToKPi(hfCand); isD0D0bar = true; + daughFlag = -1; } else if (hfCand.isSelD0() == 1 && hfCand.isSelD0bar() == 1) { invMassD0 = hfHelper.invMassD0ToPiK(hfCand); invMassD0bar = hfHelper.invMassD0barToKPi(hfCand); isD0D0bar = true; + daughFlag = 0; } else { invMassD0 = 0.0; invMassD0bar = 0.0; @@ -825,12 +1224,12 @@ struct femtoUniverseProducerTask { -999, // cutContainerV0.at(femtoUniverseV0Selection::V0ContainerPosition::kPosPID), -999, childIDs, - 0, // D0 mass - 0); // D0bar mass + 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(tracks, o2::aod::femtouniverseparticle::ParticleType::kDmesonChild); - }*/ + if constexpr (isMC) { + fillMCParticle(postrack, o2::aod::femtouniverseparticle::ParticleType::kD0Child); + } // int negtrackID = hfCand.prong1().globalIndex(); int negtrackID = hfCand.prong1Id(); int rowInPrimaryTrackTableNeg = -1; @@ -847,12 +1246,12 @@ struct femtoUniverseProducerTask { -999, // cutContainerV0.at(femtoUniverseV0Selection::V0ContainerPosition::kNegPID), -999, childIDs, - 0, - 0); + 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(p2, o2::aod::femtouniverseparticle::ParticleType::kDmesonChild); - }*/ + if constexpr (isMC) { + fillMCParticle(negtrack, o2::aod::femtouniverseparticle::ParticleType::kD0Child); + } std::vector indexChildID = {rowOfPosTrack, rowOfNegTrack}; outputParts(outputCollision.lastIndex(), @@ -868,9 +1267,9 @@ struct femtoUniverseProducerTask { invMassD0bar); // D0bar mass (mAntiLambda) if (ConfIsDebug) { - fillDebugParticle(postrack); // QA for positive daughter - fillDebugParticle(negtrack); // QA for negative daughter - fillDebugParticle(hfCand); // QA for D0/D0bar + fillDebugParticle(postrack); // QA for positive daughter + fillDebugParticle(negtrack); // QA for negative daughter + fillDebugParticle(hfCand); // QA for D0/D0bar } if constexpr (isMC) { fillMCParticle(hfCand, o2::aod::femtouniverseparticle::ParticleType::kD0); @@ -885,22 +1284,50 @@ struct femtoUniverseProducerTask { 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 // lorentz vectors and filling the tables - for (auto& [p1, p2] : combinations(soa::CombinationsStrictlyUpperIndexPolicy(tracks, tracks))) { + for (auto& [p1, p2] : combinations(soa::CombinationsFullIndexPolicy(tracks, tracks))) { + if (!trackCuts.isSelectedMinimal(p1) || !trackCuts.isSelectedMinimal(p1)) { + continue; + } // implementing PID cuts for phi children - if (!(IsKaonNSigma(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon)))) { + if (ConfPhiSelection.ConfLooseTPCNSigma.value) { + if (!(IsKaonNSigmaTPCLoose(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon)))) { + continue; + } + if (!(IsKaonNSigmaTPCLoose(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon)))) { + 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)))) { + continue; + } + } else { + if (!(IsKaonNSigma(p1.pt(), trackCuts.getNsigmaTPC(p1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p1, o2::track::PID::Kaon)))) { + continue; + } + if (!(IsKaonNSigma(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon)))) { + continue; + } + } + if (IsKaonRejected(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))) { continue; } - if (!(IsKaonNSigma(p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon)))) { + if (IsKaonRejected(p2.p(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion))) { continue; - } else if ((!(p1.sign() == 1)) || (!(p2.sign() == -1))) { + } + + if ((!(p1.sign() == 1)) || (!(p2.sign() == -1))) { continue; } TLorentzVector part1Vec; TLorentzVector part2Vec; - float mMassOne = TDatabasePDG::Instance()->GetParticle(ConfPhiChildOne.ConfPDGCodePartOne)->Mass(); // FIXME: Get from the PDG service of the common header - float mMassTwo = TDatabasePDG::Instance()->GetParticle(ConfPhiChildTwo.ConfPDGCodePartTwo)->Mass(); // FIXME: Get from the PDG service of the common header + float mMassOne = TDatabasePDG::Instance()->GetParticle(321)->Mass(); // FIXME: Get from the PDG service of the common header + float mMassTwo = TDatabasePDG::Instance()->GetParticle(-321)->Mass(); // FIXME: Get from the PDG service of the common header part1Vec.SetPtEtaPhiM(p1.pt(), p1.eta(), p1.phi(), mMassOne); part2Vec.SetPtEtaPhiM(p2.pt(), p2.eta(), p2.phi(), mMassTwo); @@ -914,7 +1341,7 @@ struct femtoUniverseProducerTask { } float phiPt = sumVec.Pt(); - if ((phiPt < 0.14) || (phiPt > 10.0)) { + if ((phiPt < ConfPhiSelection.ConfPtLowLimitPhi.value) || (phiPt > ConfPhiSelection.ConfPtHighLimitPhi.value)) { continue; } @@ -926,11 +1353,11 @@ struct femtoUniverseProducerTask { } float phiM = sumVec.M(); - if (((phiM < ConfPhiCommon.ConfInvMassLowLimitPhi) || (phiM > ConfPhiCommon.ConfInvMassUpLimitPhi))) { + if (((phiM < ConfPhiSelection.ConfInvMassLowLimitPhi.value) || (phiM > ConfPhiSelection.ConfInvMassUpLimitPhi.value))) { continue; } - phiCuts.fillQA(col, p1, p1, p2, ConfPhiChildOne.ConfPDGCodePartOne, ConfPhiChildTwo.ConfPDGCodePartTwo); ///\todo fill QA also for daughters + phiCuts.fillQA(col, p1, p1, p2, 321, -321); ///\todo fill QA also for daughters int postrackID = p1.globalIndex(); int rowInPrimaryTrackTablePos = -1; // does it do anything? @@ -986,20 +1413,21 @@ struct femtoUniverseProducerTask { -999); // v0.mAntiLambda() if (ConfIsDebug) { - fillDebugParticle(p1); // QA for positive daughter - fillDebugParticle(p2); // QA for negative daughter - fillDebugParticle(p1); // QA for phi + fillDebugParticle(p1); // QA for positive daughter + fillDebugParticle(p2); // QA for negative daughter + fillDebugParticle(p1); // QA for phi + } + if constexpr (isMC) { + fillMCParticlePhi(p1, p2); } - // if constexpr (isMC) { - // fillMCParticle(v0, o2::aod::femtouniverseparticle::ParticleType::kV0); - // } } } - template - void fillParticles(TrackType const& tracks) + template + void fillParticles(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 (auto& particle : tracks) { /// if the most open selection criteria are not fulfilled there is no @@ -1010,17 +1438,17 @@ struct femtoUniverseProducerTask { if (particle.pt() < ConfFilterCuts.ConfPtLowFilterCut || particle.pt() > ConfFilterCuts.ConfPtHighFilterCut) continue; - uint32_t pdgCode = (uint32_t)particle.pdgCode(); + uint32_t pdgCode = static_cast(particle.pdgCode()); if (ConfMCTruthAnalysisWithPID) { bool pass = false; std::vector tmpPDGCodes = ConfMCTruthPDGCodes; // necessary due to some features of the Configurable for (uint32_t pdg : tmpPDGCodes) { if (static_cast(pdg) == static_cast(pdgCode)) { - if (pdgCode == 333 || pdgCode == 3122) { // ATTENTION: workaround for now, because all Phi mesons and lambda baryons are NOT primary particles for now. + if (pdgCode == 333) { // && (recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) { // ATTENTION: all Phi mesons are NOT primary particles pass = true; } else { - if (particle.isPhysicalPrimary()) + if (particle.isPhysicalPrimary() || (ConfActivateSecondaries && recoMcIds && recoMcIds->get().contains(particle.globalIndex()))) pass = true; } } @@ -1041,6 +1469,10 @@ struct femtoUniverseProducerTask { // instead of the bitmask, the PDG of the particle is stored as uint32_t // now the table is filled + if constexpr (resolveDaughs) { + tmpIDtrack.push_back(particle.globalIndex()); + continue; + } outputParts(outputCollision.lastIndex(), particle.pt(), particle.eta(), @@ -1052,6 +1484,51 @@ struct femtoUniverseProducerTask { 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); + } + } + if constexpr (resolveDaughs) { + childIDs[0] = 0; + childIDs[1] = 0; + 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(2ul, 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; + } + } + } + outputParts(outputCollision.lastIndex(), + particle.pt(), + particle.eta(), + particle.phi(), + aod::femtouniverseparticle::ParticleType::kMCTruthTrack, + 0, + static_cast(particle.pdgCode()), + particle.pdgCode(), + 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); + } + } } } @@ -1067,6 +1544,9 @@ struct femtoUniverseProducerTask { if (ConfIsActivatePhi) { fillPhi(col, tracks); } + // if (ConfIsActivateCascade) { + // fillCascade(col, fullCascades, tracks); + // } } void processFullData(aod::FemtoFullCollision const& col, @@ -1093,6 +1573,34 @@ struct femtoUniverseProducerTask { } PROCESS_SWITCH(femtoUniverseProducerTask, processTrackV0, "Provide experimental data for track v0", false); + void processTrackCascadeData(aod::FemtoFullCollision const& col, + aod::BCsWithTimestamps const&, + soa::Filtered const& tracks, + o2::aod::CascDatas const& fullCascades) + { + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + fillCollisions(col, tracks); + fillTracks(tracks); + fillCascade(col, fullCascades, tracks); + } + PROCESS_SWITCH(femtoUniverseProducerTask, processTrackCascadeData, "Provide experimental data for track cascades", false); + + void processTrackV0CentRun3(aod::FemtoFullCollisionCentRun3 const& col, + aod::BCsWithTimestamps const&, + soa::Filtered const& tracks, + o2::aod::V0Datas const& fullV0s) + { + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + fillCollisionsCentRun3(col, tracks); + fillTracks(tracks); + fillV0(col, fullV0s, tracks); + } + PROCESS_SWITCH(femtoUniverseProducerTask, processTrackV0CentRun3, "Provide experimental data for track v0", false); + void processFullMC(aod::FemtoFullCollisionMC const& col, aod::BCsWithTimestamps const&, soa::Join const& tracks, @@ -1136,6 +1644,21 @@ struct femtoUniverseProducerTask { } PROCESS_SWITCH(femtoUniverseProducerTask, processTrackPhiMC, "Provide MC data for track Phi analysis", false); + void processTrackD0MC(aod::FemtoFullCollisionMC const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::McCollisions const&, + aod::McParticles const&) + { + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + fillCollisions(col, tracks); + fillTracks(tracks); + // fillD0mesons(col, tracks, candidates); + } + PROCESS_SWITCH(femtoUniverseProducerTask, processTrackD0MC, "Provide MC data for track D0 analysis", false); + void processTrackData(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks) @@ -1191,6 +1714,65 @@ struct femtoUniverseProducerTask { } PROCESS_SWITCH(femtoUniverseProducerTask, processTrackMCTruth, "Provide MC data for MC truth track analysis", false); + void processTrackMCGen(aod::McCollision const& col, + aod::McParticles const& mcParticles) + { + outputCollision(col.posZ(), 0, 0, 2, 0); + fillParticles(mcParticles); + } + PROCESS_SWITCH(femtoUniverseProducerTask, processTrackMCGen, "Provide MC Generated for model comparisons", false); + + Preslice perMCCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted> recoCollsPerMCColl = aod::mcparticle::mcCollisionId; + Preslice> perCollisionTracks = aod::track::collisionId; + Preslice> perCollisionV0s = aod::track::collisionId; + 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&) + { + // recos + std::set recoMcIds; + for (auto& col : collisions) { + auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex()); + auto groupedV0s = fullV0s.sliceBy(perCollisionV0s, col.globalIndex()); + getMagneticFieldTesla(col.bc_as()); + fillCollisionsAndTracksAndV0AndPhi(col, groupedTracks, groupedV0s); + for (auto& track : groupedTracks) { + if (trackCuts.isSelectedMinimal(track)) + recoMcIds.insert(track.mcParticleId()); + } + } + + // truth + for (auto& mccol : mccols) { + auto groupedMCParticles = mcParticles.sliceBy(perMCCollision, mccol.globalIndex()); + auto groupedCollisions = collisions.sliceBy(recoCollsPerMCColl, mccol.globalIndex()); + fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision + fillParticles(groupedMCParticles, recoMcIds); // fills mc particles + } + } + PROCESS_SWITCH(femtoUniverseProducerTask, processTruthAndFullMC, "Provide both MC truth and reco for tracks and V0s", false); + + void processFullMCCent(aod::FemtoFullCollisionCentRun3 const& col, + aod::BCsWithTimestamps const&, + soa::Join const& tracks, + aod::McCollisions const&, + aod::McParticles const&, + soa::Join const& fullV0s) + { + // get magnetic field for run + getMagneticFieldTesla(col.bc_as()); + // fill the tables + fillCollisionsCentRun3(col, tracks); + fillTracks(tracks); + fillV0(col, fullV0s, tracks); + } + PROCESS_SWITCH(femtoUniverseProducerTask, processFullMCCent, "Provide MC data with centrality bins", false); + void processTrackCentRun2Data(aod::FemtoFullCollisionCentRun2 const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks) @@ -1205,7 +1787,7 @@ struct femtoUniverseProducerTask { void processTrackCentRun3Data(aod::FemtoFullCollisionCentRun3 const& col, aod::BCsWithTimestamps const&, - aod::FemtoFullTracks const& tracks) + soa::Filtered const& tracks) { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); diff --git a/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt b/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt index c1e487e8908..7e82d3c4525 100644 --- a/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt +++ b/PWGCF/FemtoUniverse/Tasks/CMakeLists.txt @@ -49,6 +49,11 @@ o2physics_add_dpl_workflow(femtouniverse-pair-track-v0-extended PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtouniverse-pair-track-cascade-extended + SOURCES femtoUniversePairTaskTrackCascadeExtended.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 @@ -79,6 +84,11 @@ o2physics_add_dpl_workflow(femtouniverse-efficiency-task PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(femtouniverse-efficiency-base + SOURCES femtoUniverseEfficiencyBase.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_executable(femtouniverse-cutculator SOURCES femtoUniverseCutCulator.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx index 04bc95eb5c9..94a0d58a646 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseDebugTrack.cxx @@ -53,7 +53,7 @@ struct femtoUniverseDebugTrack { Configurable ConfIsTrackIdentified{"ConfIsTrackIdentified", true, "Enable PID for the track"}; Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; Configurable ConfTrackChoicePartOne{"ConfTrackChoicePartOne", 1, "Type of particle (track1): {0:Proton, 1:Pion, 2:Kaon}"}; - Configurable ConfTrackSign{"ConfTrackSign", 1, "Track sign"}; + Configurable ConfTrackSign{"ConfTrackSign", 1, "Track sign"}; } trackonefilter; struct : o2::framework::ConfigurableGroup { diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx new file mode 100644 index 00000000000..04b6424455b --- /dev/null +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseEfficiencyBase.cxx @@ -0,0 +1,627 @@ +// 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 femtoUniverseEfficiencyBase.cxx +/// \brief Tasks that reads the track tables used for the pairing and builds pairs of two tracks +/// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch +/// \author Alicja Płachta, WUT Warsaw, alicja.plachta@cern.ch + +#include +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/RunningWorkflowInfo.h" + +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" +#include "PWGCF/FemtoUniverse/Core/FemtoUniverseTrackSelection.h" + +using namespace o2; +using namespace o2::analysis::femtoUniverse; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct femtoUniverseEfficiencyBase { + SliceCache cache; + using FemtoFullParticles = soa::Join; + Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + + Configurable ConfIsDebug{"ConfIsDebug", true, "Enable debug histograms"}; + + // Collisions + Configurable ConfZVertex{"ConfZVertex", 10.f, "Event sel: Maximum z-Vertex (cm)"}; + + 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"}; + + 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"}; + } 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"}; + + // Kaon configurables + Configurable IsKaonRun2{"IsKaonRun2", false, "Enable kaon selection used in Run2"}; // to check consistency with Run2 results + + /// 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"}; + + /// 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 partsTrackOneMCReco = aod::femtouniverseparticle::pt < ConfPtHighPart1 && aod::femtouniverseparticle::pt > ConfPtLowPart1&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + + /// Histogramming for particle 1 + FemtoUniverseParticleHisto trackHistoPartOneGen; + FemtoUniverseParticleHisto trackHistoPartOneRec; + FemtoUniverseParticleHisto trackHistoV0OneRec; + FemtoUniverseParticleHisto trackHistoV0OneChildPosRec; + 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"}; + + /// 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 partsTrackTwoMCReco = aod::femtouniverseparticle::pt < ConfPtHighPart2 && aod::femtouniverseparticle::pt > ConfPtLowPart2&& nabs(aod::femtouniverseparticle::eta) < ConfBothTracks.ConfEtaMax; + + /// Histogramming for particle 2 + FemtoUniverseParticleHisto trackHistoPartTwoGen; + FemtoUniverseParticleHisto trackHistoPartTwoRec; + FemtoUniverseParticleHisto trackHistoV0TwoRec; + FemtoUniverseParticleHisto trackHistoV0TwoChildPosRec; + FemtoUniverseParticleHisto trackHistoV0TwoChildNegRec; + + /// Histogramming for Event + FemtoUniverseEventHisto eventHisto; + + FemtoUniverseTrackSelection trackCuts; + + /// Histogram output + HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryPDG{"PDGHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryMCOrigin{"MCOriginHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + void init(InitContext&) + { + + eventHisto.init(&qaRegistry); + trackHistoPartOneGen.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarPDGBins, 0, ConfPDGCodePartOne, false); + trackHistoPartOneRec.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarDCABins, 0, 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/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); + 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"); + 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 + { + if (mom < ConfBothTracks.ConfMomProton) { + if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfNsigmaTPCProton) { + return true; + } else { + return false; + } + } else { + if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfNsigmaCombinedProton) { + return true; + } else { + return false; + } + } + return false; + } + + 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); + } else { + return false; + } + } else { + if (mom < 0.3) { // 0.0-0.3 + if (TMath::Abs(nsigmaTPCK) < 3.0) { + return true; + } else { + return false; + } + } else if (mom < 0.45) { // 0.30 - 0.45 + if (TMath::Abs(nsigmaTPCK) < 2.0) { + return true; + } else { + return false; + } + } else if (mom < 0.55) { // 0.45-0.55 + if (TMath::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)) { + { + return true; + } + } else { + return false; + } + } else if (mom > 1.5) { // 1.5 - + if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + } + + bool IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) + { + if (mom < ConfBothTracks.ConfMomPion) { + if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfNsigmaTPCPion) { + return true; + } else { + return false; + } + } else { + if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfNsigmaCombinedPion) { + return true; + } else { + return false; + } + } + return false; + } + + bool IsParticleNSigma(int pdgCode, float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) + { + switch (pdgCode) { + case 2212: // Proton + case -2212: // anty Proton + return IsProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); + break; + case 211: // Pion + case -211: // Pion- + return IsPionNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); + break; + case 321: // Kaon+ + case -321: // Kaon- + return IsKaonNSigma(mom, nsigmaTPCK, nsigmaTOFK); + break; + default: + return false; + } + } + + bool invMLambda(float invMassLambda, float invMassAntiLambda) + { + if ((invMassLambda < ConfV0InvMassLowLimit || invMassLambda > ConfV0InvMassUpLimit) && (invMassAntiLambda < ConfV0InvMassLowLimit || invMassAntiLambda > ConfV0InvMassUpLimit)) { + return false; + } + return true; + } + + template + void fillCollision(CollisionType col) + { + eventHisto.fillQA(col); + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @param grouppartsOneMCGen partition for the first particle passed by the process function + /// @param grouppartsTwoMCGen partition for the second particle passed by the process function + template + void doMCGen(PartitionType grouppartsOneMCGen, PartitionType grouppartsTwoMCGen) + { + /// Histogramming same event + for (auto& part : grouppartsOneMCGen) { + if (!ConfNoPDGPartOne && part.tempFitVar() != ConfPDGCodePartOne) { + continue; + } + trackHistoPartOneGen.fillQA(part); + } + + if (!ConfIsSame) { + for (auto& part : grouppartsTwoMCGen) { + if (!ConfNoPDGPartTwo && part.tempFitVar() != ConfPDGCodePartTwo) { + continue; + } + trackHistoPartTwoGen.fillQA(part); + } + } + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @tparam isDebug: enables debug histograms + /// @param grouppartsOneMCRec partition for the first particle passed by the process function + /// @param grouppartsTwoMCRec partition for the second particle passed by the process function + template + 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))) { + continue; + } + trackHistoPartOneRec.fillQA(part); + + if (!part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + + 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))) { + continue; + } + + trackHistoPartTwoRec.fillQA(part); + + if (!part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + + registryPDG.fill(HIST("part2/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); + registryMCOrigin.fill(HIST("part2/hPt"), mcParticle.pt()); + } + } + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @tparam isDebug: enables debug histograms + /// @param grouppartsOneMCRec partition for the first particle passed by the process function + /// @param grouppartsTwoMCRec partition for the second particle passed by the process function + template + 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))) { + continue; + } + trackHistoPartOneRec.fillQA(part); + + if (!part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + + 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) { + continue; + } + + trackHistoPartTwoRec.fillQA(part); + + if (!part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + + registryPDG.fill(HIST("part2/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); + registryMCOrigin.fill(HIST("part2/hPt"), mcParticle.pt()); + } + } + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam ParticlesType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @tparam isDebug: enables debug histograms + /// @param grouppartsOneMCRec partition for the first particle passed by the process function + /// @param grouppartsTwoMCRec partition for the second particle passed by the process function + /// @param parts all tracks + template + void doMCRecV0V0(PartitionType grouppartsOneMCRec, PartitionType grouppartsTwoMCRec, ParticlesType parts) + { + /// Histogramming same event + for (auto& part : grouppartsOneMCRec) { + + 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 + 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 + continue; + } + + trackHistoV0OneRec.fillQA(part); + trackHistoV0OneChildPosRec.fillQABase(posChild, HIST("posChildV0_1")); + trackHistoV0OneChildNegRec.fillQABase(negChild, HIST("negChildV0_1")); + + if (!posChild.has_fdMCParticle() || !negChild.has_fdMCParticle() || !part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + const auto mcPosChild = posChild.fdMCParticle(); + const auto mcNegChild = negChild.fdMCParticle(); + + registryPDG.fill(HIST("part1/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); + registryPDG.fill(HIST("part1/dpositive/PDGvspT"), part.pt(), mcPosChild.pdgMCTruth()); + registryPDG.fill(HIST("part1/dnegative/PDGvspT"), part.pt(), mcNegChild.pdgMCTruth()); + registryMCOrigin.fill(HIST("part1/hPt"), mcParticle.pt()); + } + + if (!ConfIsSame) { + for (auto& part : grouppartsTwoMCRec) { + + 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 + 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 + continue; + } + + trackHistoV0TwoRec.fillQA(part); + trackHistoV0TwoChildPosRec.fillQABase(posChild, HIST("posChildV0_2")); + trackHistoV0TwoChildNegRec.fillQABase(negChild, HIST("negChildV0_2")); + + if (!posChild.has_fdMCParticle() || !negChild.has_fdMCParticle() || !part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + const auto mcPosChild = posChild.fdMCParticle(); + const auto mcNegChild = negChild.fdMCParticle(); + + registryPDG.fill(HIST("part2/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); + registryPDG.fill(HIST("part2/dpositive/PDGvspT"), part.pt(), mcPosChild.pdgMCTruth()); + registryPDG.fill(HIST("part2/dnegative/PDGvspT"), part.pt(), mcNegChild.pdgMCTruth()); + registryMCOrigin.fill(HIST("part2/hPt"), mcParticle.pt()); + } + } + } + + /// This function processes the same event and takes care of all the histogramming + /// @tparam PartitionType + /// @tparam ParticlesType + /// @tparam isMC: enables Monte Carlo truth specific histograms + /// @tparam isDebug: enables debug histograms + /// @param grouppartsOneMCRec partition for the first particle passed by the process function + /// @param grouppartsTwoMCRec partition for the second particle passed by the process function + /// @param parts all tracks + template + void doMCRecTrackV0(PartitionType grouppartsOneMCRec, PartitionType grouppartsTwoMCRec, ParticlesType const& parts) + { // 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))) { + continue; + } + + trackHistoPartOneRec.fillQA(part); + if (!part.has_fdMCParticle()) + continue; + + const auto mcParticle = part.fdMCParticle(); + 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 || !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 + 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 + continue; + } + + trackHistoV0TwoRec.fillQA(part); + trackHistoV0TwoChildPosRec.fillQABase(posChild, HIST("posChildV0_2")); + trackHistoV0TwoChildNegRec.fillQABase(negChild, HIST("negChildV0_2")); + + if (!posChild.has_fdMCParticle() || !negChild.has_fdMCParticle() || !part.has_fdMCParticle()) { + continue; + } + const auto mcParticle = part.fdMCParticle(); + const auto mcPosChild = posChild.fdMCParticle(); + const auto mcNegChild = negChild.fdMCParticle(); + + registryPDG.fill(HIST("part2/PDGvspT"), part.pt(), mcParticle.pdgMCTruth()); + registryPDG.fill(HIST("part2/dpositive/PDGvspT"), part.pt(), mcPosChild.pdgMCTruth()); + registryPDG.fill(HIST("part2/dnegative/PDGvspT"), part.pt(), mcNegChild.pdgMCTruth()); + registryMCOrigin.fill(HIST("part2/hPt"), mcParticle.pt()); + } + } + } + + /// process function for to call doMCRecTrackTrack with Data + /// \param col subscribe to the collision table (Data) + void processTrackTrack(FilteredFDCollision& col, + FemtoFullParticles&, 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); + // 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); + } else { + doMCRecTrackTrack(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + } + } + 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&) + { + 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); + // MCRec + auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + if (ConfIsDebug) { + doMCRecTrackPhi(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + } else { + doMCRecTrackPhi(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec); + } + } + 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&) + { + 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); + + // MCRec + auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + if (ConfIsDebug) { + doMCRecV0V0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); + } else { + doMCRecV0V0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); + } + } + 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&) + { + 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); + // MCRec + auto thegroupPartsTrackOneRec = partsTrackOneMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto thegroupPartsTrackTwoRec = partsTrackTwoMCReco->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + if (ConfIsDebug) { + doMCRecTrackV0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); + } else { + doMCRecTrackV0(thegroupPartsTrackOneRec, thegroupPartsTrackTwoRec, parts); + } + } + PROCESS_SWITCH(femtoUniverseEfficiencyBase, processTrackV0, "Enable processing track-V0 efficiency task", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx index 1fef7a97ac2..f33657f0dca 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniverseHashTask.cxx @@ -32,7 +32,7 @@ struct femtoUniversePairHashTask { std::vector CastCfgVtxBins, CastCfgMultBins; - Produces hashes; + Produces hashes; void init(InitContext&) { diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx new file mode 100644 index 00000000000..914017c9b7d --- /dev/null +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackCascadeExtended.cxx @@ -0,0 +1,365 @@ +// 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. + +/// \brief Task for cascade QA; in the future: for cascade correlations +/// \author Barbara Chytla, WUT Warsaw, barbara.chytla@cern.ch +/// \author Shirajum Monira, WUT Warsaw, shirajum.monira@cern.ch + +#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" + +using namespace o2; +using namespace o2::soa; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::analysis::femtoUniverse; +using namespace o2::aod::pidutils; + +struct femtoUniversePairTaskTrackCascadeExtended { + + SliceCache cache; + using FemtoFullParticles = soa::Join; + Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + + 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; + + 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 NSigmaTPCPion{"NSigmaTPCPion", 4, "NSigmaTPCPion"}; + Configurable NSigmaTPCProton{"NSigmaTPCProton", 4, "NSigmaTPCProton"}; + + // configs 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 V0s (Omega = 0, Xi = 1, anti-Omega = 2, anti-Xi = 3) for track-cascade combination"}; + Configurable ConfChargePart1{"ConfChargePart1", 0, "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 momentum < Confmom"}; + Configurable ConfNsigmaCombinedParticle{"ConfNsigmaCombinedParticle", 3.0, "TPC and TOF Sigma (combined) for particle 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"}; + 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{"ConfTrkDTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + + /// 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 2 (cascade) + Partition partsTwo = (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)); + + /// Histogramming for track particle + FemtoUniverseParticleHisto trackHistoPartOnePos; + FemtoUniverseParticleHisto trackHistoPartOneNeg; + + /// Histogramming for cascade + FemtoUniverseParticleHisto posChildHistos; + FemtoUniverseParticleHisto negChildHistos; + FemtoUniverseParticleHisto bachHistos; + + FemtoUniverseContainer sameEventCont; + FemtoUniverseContainer mixedEventCont; + + HistogramRegistry rXiQA{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Table to select cascade daughters + // Charges: = +--, +--, +-+, +-+ + static constexpr UInt_t CascChildTable[][3] = {{0, 1, 2}, {0, 1, 1}, {1, 0, 2}, {1, 0, 1}}; + + bool invMCascade(float invMassCascade, float invMassAntiCascade) + { + if ((invMassCascade < ConfCascInvMassLowLimit || invMassCascade > ConfCascInvMassUpLimit) && (invMassAntiCascade < ConfCascInvMassLowLimit || invMassAntiCascade > ConfCascInvMassUpLimit)) { + return false; + } + return true; + } + + bool IsNSigmaTPC(float nsigmaTPCParticle) + { + if (TMath::Abs(nsigmaTPCParticle) < ConfNsigmaTPCParticle) { + return true; + } else { + return false; + } + } + + bool IsNSigmaCombined(float mom, float nsigmaTPCParticle, float nsigmaTOFParticle) + { + if (mom <= Confmom) { + return (TMath::Abs(nsigmaTPCParticle) < ConfNsigmaTPCParticle); + } else { + return (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < ConfNsigmaCombinedParticle); + } + } + + 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 IsParticleCombined(const T& part, int id) + { + 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())}; + + return IsNSigmaCombined(part.p(), tpcNSigmas[id], tofNSigmas[id]); + } + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {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})"}; + 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 DCAToPVAxis = {1000, -10.0f, 10.0f, "DCA to PV (cm)"}; + + // Histograms + rXiQA.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + rXiQA.add("hMassXiSelected", "hMassXiSelected", {HistType::kTH1F, {XiMassAxis}}); + rXiQA.add("hPtXi", "hPtXi", {HistType::kTH1F, {{ptAxis}}}); + rXiQA.add("hEtaXi", "hEtaXi", {HistType::kTH1F, {{etaAxis}}}); + rXiQA.add("hPhiXi", "hPhiXi", {HistType::kTH1F, {{phiAxis}}}); + rXiQA.add("hDCAV0Daughters", "hDCAV0Daughters", {HistType::kTH1F, {DCADaughAxis}}); + rXiQA.add("hV0CosPA", "hV0CosPA", {HistType::kTH1F, {CPAAxis}}); + rXiQA.add("hV0TranRad", "hV0TranRad", {HistType::kTH1F, {tranRadAxis}}); + rXiQA.add("hDCACascDaughters", "hDCACascDaughters", {HistType::kTH1F, {DCADaughAxis}}); + rXiQA.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {CPAAxis}}); + rXiQA.add("hCascTranRad", "hCascTranRad", {HistType::kTH1F, {tranRadAxis}}); + rXiQA.add("hDcaPostoPV", "hDcaPostoPV", {HistType::kTH1F, {DCAToPVAxis}}); + rXiQA.add("hDcaNegtoPV", "hDcaNegtoPV", {HistType::kTH1F, {DCAToPVAxis}}); + rXiQA.add("hDcaBachtoPV", "hDcaBachtoPV", {HistType::kTH1F, {DCAToPVAxis}}); + rXiQA.add("hDcaV0toPV", "hDcaV0toPV", {HistType::kTH1F, {DCAToPVAxis}}); + + 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}}); + + trackHistoPartOnePos.init(&qaRegistry, ConfTrkTempFitVarpTBins, ConfTrkTempFitVarBins, ConfIsMC, ConfTrkPDGCodePartOne); + trackHistoPartOneNeg.init(&qaRegistry, ConfTrkTempFitVarpTBins, ConfTrkTempFitVarBins, ConfIsMC, ConfTrkPDGCodePartOne); + posChildHistos.init(&qaRegistry, ConfChildTempFitVarpTBins, ConfChildTempFitVarBins, false, 0, true); + negChildHistos.init(&qaRegistry, ConfChildTempFitVarpTBins, ConfChildTempFitVarBins, false, 0, true); + bachHistos.init(&qaRegistry, ConfChildTempFitVarpTBins, ConfChildTempFitVarBins, false, 0, true, "hBachelor"); + + 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); + } + + void processCascades(FilteredFDCollision& col, FemtoFullParticles& parts) + { + auto groupCascs = cascs->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + // const int multCol = col.multNtr(); + + for (auto& casc : groupCascs) { + rXiQA.fill(HIST("hMassXi"), casc.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); + + // if (casc.transRadius() < ConfCascTranRad) + // continue; + // std::cout< NSigmaTPCProton) { + continue; + } + if (TMath::Abs(negChild.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } else { + if (TMath::Abs(negChild.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(posChild.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } + if (TMath::Abs(bachelor.tpcNSigmaPi()) > NSigmaTPCPion) { + 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("hDCAV0Daughters"), casc.dcaV0daughters()); + rXiQA.fill(HIST("hV0CosPA"), casc.cpav0()); + rXiQA.fill(HIST("hV0TranRad"), casc.v0radius()); + rXiQA.fill(HIST("hCascCosPA"), casc.cpaCasc()); + rXiQA.fill(HIST("hDCACascDaughters"), casc.dcacascdaughters()); + rXiQA.fill(HIST("hCascTranRad"), casc.cascradius()); + rXiQA.fill(HIST("hDcaPostoPV"), casc.dcapostopv()); + rXiQA.fill(HIST("hDcaNegtoPV"), casc.dcanegtopv()); + rXiQA.fill(HIST("hDcaBachtoPV"), casc.dcabachtopv()); + rXiQA.fill(HIST("hDcaV0toPV"), casc.dcav0topv()); + + posChildHistos.fillQA(posChild); + negChildHistos.fillQA(negChild); + bachHistos.fillQABase(bachelor, HIST("hBachelor")); + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processCascades, "Enable processing cascades", true); + + void processSameEvent(FilteredFDCollision& col, FemtoFullParticles& parts) + { + // const auto& magFieldTesla = col.magField(); + + auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + + for (auto& part : groupPartsTwo) { + if (!invMCascade(part.mLambda(), part.mAntiLambda())) + continue; + const auto& posChild = parts.iteratorAt(part.index() - 3); + const auto& negChild = parts.iteratorAt(part.index() - 2); + const auto& bachelor = parts.iteratorAt(part.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;*/ + + posChildHistos.fillQA(posChild); + negChildHistos.fillQA(negChild); + bachHistos.fillQABase(bachelor, HIST("hBachelor")); + } + + for (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.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); + } + } + + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + continue; + if (!IsParticleCombined(p1, ConfTrackChoicePartOne)) + 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;*/ + + sameEventCont.setPair(p1, p2, col.multNtr(), ConfUse3D, 1.0f); + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processSameEvent, "Enable processing same event for track - cascade", true); + + void processMixedEvent(FilteredFDCollisions& cols, FemtoFullParticles& /*parts*/) + { + ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + + for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + + 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 (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (!invMCascade(p2.mLambda(), p2.mAntiLambda())) + continue; + if (!IsParticleCombined(p1, ConfTrackChoicePartOne)) + 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;*/ + + mixedEventCont.setPair(p1, p2, collision1.multNtr(), ConfUse3D, 1.0f); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackCascadeExtended, processMixedEvent, "Enable processing mixed event for track - cascade", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc), + }; + return workflow; +} diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx index d9496c47212..f377c2aaa90 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackD0.cxx @@ -18,6 +18,7 @@ /// \author Katarzyna Gwiździel, WUT Warsaw, katarzyna.gwizdziel@cern.ch #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -56,9 +57,7 @@ static constexpr int nPart = 2; static constexpr int nCuts = 5; static const std::vector partNames{"D0", "Track"}; static const std::vector cutNames{"MaxPt", "PIDthr", "nSigmaTPC", "nSigmaTPCTOF", "MaxP"}; -static const float cutsTable[nPart][nCuts]{ - {4.05f, 1.f, 3.f, 3.f, 100.f}, - {4.05f, 1.f, 3.f, 3.f, 100.f}}; +static const float cutsTable[nPart][nCuts]{{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] @@ -110,7 +109,7 @@ struct femtoUniversePairTaskTrackD0 { Configurable ConfIsSame{"ConfIsSame", false, "Pairs of the same particle"}; Configurable ConfPDGCodeTrack{"ConfPDGCodeTrack", 2212, "Particle 2 - PDG code"}; Configurable ConfPIDTrack{"ConfPIDTrack", 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 ConfTrackSign{"ConfTrackSign", 1, "Track sign"}; Configurable ConfIsTrackIdentified{"ConfIsTrackIdentified", true, "Enable PID for the track"}; } ConfTrack; @@ -134,7 +133,7 @@ struct femtoUniversePairTaskTrackD0 { } ConfD0D0barSideBand; Configurable> binsPt{"binsPt", std::vector{hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits"}; - Configurable ConfUseAllD0mesons{"ConfUseAllD0mesons", false, "Include cand. which are both D0 and D0bar cand."}; + Configurable ConfChooseD0trackCorr{"ConfChooseD0trackCorr", 3, "If 0 - only D0s, 1 - only D0bars, 2 - D0/D0bar (one mass hypo.), 3 - all D0/D0bar cand."}; Configurable ConfUsePtCutForD0D0bar{"ConfUsePtCutForD0D0bar", false, "Include pT cut for D0/D0bar in same and mixed processes."}; Configurable ConfUseMassCutForD0D0bar{"ConfUseMassCutForD0D0bar", false, "Switch to save D0/D0bar within declared inv. mass range"}; @@ -143,8 +142,15 @@ struct femtoUniversePairTaskTrackD0 { Partition> partsTrackMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); /// Partitions for particle 2 + /// Partition with all D0/D0bar mesons (which pass double and one mass hypothesis) Partition partsAllDmesons = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)); + /// 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 with D0 mesons only (one mass hypothesis) + Partition partsD0s = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)) && (aod::femtouniverseparticle::mLambda > 0.0f) && (aod::femtouniverseparticle::mAntiLambda < 0.0f); + /// 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 > 0.0f); + /// Partition for D0/D0bar mesons from MC Partition> partsD0D0barMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kD0)); /// Partition for D0/D0bar daughters @@ -230,13 +236,6 @@ struct femtoUniversePairTaskTrackD0 { // 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 { - //|nsigma_TPC| < 3 for p < 0.5 GeV/c - //|nsigma_combined| < 3 for p > 0.5 - - // using configurables: - // ConfNsigmaTPCProton -> TPC Kaon Sigma for momentum < 0.5 - // ConfNsigmaCombinedProton -> TPC and TOF Kaon Sigma (combined) for momentum > 0.5 - if (mom < 0.5) { if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfNsigmaTPCProton) { return true; @@ -245,7 +244,6 @@ struct femtoUniversePairTaskTrackD0 { } } else if (mom > 0.4) { if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfNsigmaCombinedProton) { - // if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfNsigmaCombinedProton) { return true; } else { return false; @@ -282,7 +280,7 @@ struct femtoUniversePairTaskTrackD0 { } else { return false; } - } else if (mom > 1.5) { // 1.5 - + } else if (mom > 1.5) { if ((TMath::Abs(nsigmaTOFK) < 2.0) && (TMath::Abs(nsigmaTPCK) < 3.0)) { return true; } else { @@ -310,7 +308,6 @@ struct femtoUniversePairTaskTrackD0 { } } else if (mom > 0.5) { if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfNsigmaCombinedPion) { - // if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfNsigmaCombinedPion) { return true; } else { return false; @@ -343,6 +340,41 @@ struct femtoUniversePairTaskTrackD0 { void init(InitContext&) { eventHisto.init(&qaRegistry); + 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}}); + qaRegistry.add("D0_pos_daugh/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); + qaRegistry.add("D0_pos_daugh/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); + qaRegistry.add("D0_pos_daugh/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + + qaRegistry.add("D0_neg_daugh/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0_neg_daugh/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0_neg_daugh/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + qaRegistry.add("D0_neg_daugh/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); + qaRegistry.add("D0_neg_daugh/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); + qaRegistry.add("D0_neg_daugh/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + + qaRegistry.add("D0bar_pos_daugh/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0bar_pos_daugh/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0bar_pos_daugh/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + qaRegistry.add("D0bar_pos_daugh/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); + qaRegistry.add("D0bar_pos_daugh/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); + qaRegistry.add("D0bar_pos_daugh/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + + qaRegistry.add("D0bar_neg_daugh/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0bar_neg_daugh/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("D0bar_neg_daugh/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); + qaRegistry.add("D0bar_neg_daugh/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); + qaRegistry.add("D0bar_neg_daugh/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); + qaRegistry.add("D0bar_neg_daugh/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); + + 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}}); + trackHistoPartD0D0bar.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarInvMassBins, ConfBothTracks.ConfIsMC, ConfDmesons.ConfPDGCodeD0); if (!ConfTrack.ConfIsSame) { trackHistoPartTrack.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarBins, ConfBothTracks.ConfIsMC, ConfTrack.ConfPDGCodeTrack); @@ -441,6 +473,31 @@ struct femtoUniversePairTaskTrackD0 { // 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) { + 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) { + 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) { + 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) { + 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, processD0mesons, "Enable processing D0 mesons", true); @@ -498,7 +555,7 @@ struct femtoUniversePairTaskTrackD0 { } } } // It is the end of the for loop over D0bar mesons - } // It is the end of the for loop over all candidates + } // It is the end of the for loop over all candidates } PROCESS_SWITCH(femtoUniversePairTaskTrackD0, processSideBand, "Enable processing side-band methode", false); @@ -521,6 +578,8 @@ struct femtoUniversePairTaskTrackD0 { trackHistoPartD0D0bar.fillQA(d0candidate); } + float tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa; + if (!ConfTrack.ConfIsSame) { for (auto& track : groupPartsTrack) { if (ConfTrack.ConfIsTrackIdentified) { @@ -529,6 +588,20 @@ struct femtoUniversePairTaskTrackD0 { } } trackHistoPartTrack.fillQA(track); + + 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); + + 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); } } /// Now build the combinations @@ -577,11 +650,23 @@ struct femtoUniversePairTaskTrackD0 { 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); - if (ConfUseAllD0mesons) { - doSameEvent(thegroupPartsTrack, thegroupPartsAllD0D0bar, parts, col.magField(), col.multNtr()); - } else { - doSameEvent(thegroupPartsTrack, thegroupPartsOnlyD0D0bar, parts, col.magField(), col.multNtr()); + switch (ConfChooseD0trackCorr) { + case 0: + doSameEvent(thegroupPartsTrack, theGroupPartsD0s, parts, col.magField(), col.multNtr()); + break; + case 1: + doSameEvent(thegroupPartsTrack, theGroupPartsD0bars, parts, col.magField(), col.multNtr()); + break; + case 2: + doSameEvent(thegroupPartsTrack, thegroupPartsOnlyD0D0bar, parts, col.magField(), col.multNtr()); + break; + case 3: + doSameEvent(thegroupPartsTrack, thegroupPartsAllD0D0bar, parts, col.magField(), col.multNtr()); + default: + break; } } PROCESS_SWITCH(femtoUniversePairTaskTrackD0, processSameEvent, "Enable processing same event", true); @@ -661,6 +746,8 @@ struct femtoUniversePairTaskTrackD0 { 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); const auto& magFieldTesla1 = collision1.magField(); const auto& magFieldTesla2 = collision2.magField(); @@ -671,10 +758,20 @@ struct femtoUniversePairTaskTrackD0 { /// \todo before mixing we should check whether both collisions contain a pair of particles! // if (partsD0.size() == 0 || nPart2Evt1 == 0 || nPart1Evt2 == 0 || partsTrack.size() == 0 ) continue; - if (ConfUseAllD0mesons) { - doMixedEvent(groupPartsTrack, groupPartsAllD0D0bar, parts, magFieldTesla1, multiplicityCol); - } else { - doMixedEvent(groupPartsTrack, groupPartsOnlyD0D0bar, parts, magFieldTesla1, multiplicityCol); + switch (ConfChooseD0trackCorr) { + case 0: + doMixedEvent(groupPartsTrack, theGroupPartsD0s, parts, magFieldTesla1, multiplicityCol); + break; + case 1: + doMixedEvent(groupPartsTrack, theGroupPartsD0bars, parts, magFieldTesla1, multiplicityCol); + break; + case 2: + doMixedEvent(groupPartsTrack, groupPartsOnlyD0D0bar, parts, magFieldTesla1, multiplicityCol); + break; + case 3: + doMixedEvent(groupPartsTrack, groupPartsAllD0D0bar, parts, magFieldTesla1, multiplicityCol); + default: + break; } } } diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx index b74fb942a59..15aea7eee19 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackPhi.cxx @@ -17,6 +17,7 @@ /// \author Zuzanna Chochulska, WUT Warsaw & CTU Prague, zchochul@cern.ch #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -32,11 +33,13 @@ #include "PWGCF/FemtoUniverse/Core/FemtoUniverseParticleHisto.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseEventHisto.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniversePairCleaner.h" -#include "PWGCF/FemtoUniverse/Core/FemtoUniverseFemtoContainer.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" using namespace o2; using namespace o2::analysis::femtoUniverse; @@ -57,54 +60,75 @@ static const float cutsTable[nPart][nCuts]{ struct femtoUniversePairTaskTrackPhi { + Service pdgMC; + using FemtoFullParticles = soa::Join; SliceCache cache; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; - Configurable ConfIsCPR{"ConfIsCPR", true, "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"}; + 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", true, "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; /// Table for both particles struct : o2::framework::ConfigurableGroup { - Configurable ConfNsigmaCombinedProton{"ConfNsigmaCombinedProton", 3.0, "TPC and TOF Proton Sigma (combined) for momentum > 0.5"}; - Configurable ConfNsigmaTPCProton{"ConfNsigmaTPCProton", 3.0, "TPC Proton Sigma for momentum < 0.5"}; - 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 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"}; 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 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 ConfPhiBins{"ConfPhiBins", 29, "Number of phi bins in deta dphi"}; - Configurable ConfEtaBins{"ConfEtaBins", 29, "Number of eta bins in deta dphi"}; + Configurable ConfBinsPhi{"ConfBinsPhi", 29, "Number of phi bins in deta dphi"}; + Configurable ConfBinsEta{"ConfBinsEta", 29, "Number of eta bins in deta dphi"}; } ConfBothTracks; /// Particle 1 --- IDENTIFIED TRACK struct : o2::framework::ConfigurableGroup { - Configurable ConfIsSame{"ConfIsSame", false, "Pairs of the same particle"}; - Configurable ConfPDGCodeTrack{"ConfPDGCodeTrack", 2212, "Particle 2 - PDG code"}; - Configurable ConfPIDTrack{"ConfPIDTrack", 2, "Particle 2 - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector> + 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 ConfIsTrackIdentified{"ConfIsTrackIdentified", true, "Enable PID for the track"}; + 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; /// Particle 2 --- PHI struct : o2::framework::ConfigurableGroup { - Configurable ConfPDGCodePhi{"ConfPDGCodePhi", 333, "Phi meson - PDG code"}; - Configurable ConfPIDPhi{"ConfPIDPhi", 2, "Phi meson - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector>int>> + Configurable ConfPhiPDGCode{"ConfPhiPDGCode", 333, "Phi meson - PDG code"}; + Configurable ConfPhiPID{"ConfPhiPID", 2, "Phi meson - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector>int>> } ConfPhi; /// Partitions for particle 1 - Partition partsTrack = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == ConfTrack.ConfTrackSign); - Partition> partsTrackMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)); + 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)); @@ -114,6 +138,10 @@ struct femtoUniversePairTaskTrackPhi { 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)); + /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartTrack; @@ -128,24 +156,22 @@ struct femtoUniversePairTaskTrackPhi { std::vector kNsigma; /// particle part - ConfigurableAxis ConfTempFitVarBins{"ConfDTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; - ConfigurableAxis ConfTempFitVarInvMassBins{"ConfDTempFitVarInvMassBins", {6000, 0.9, 4.0}, "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 ConfBinsTempFitVar{"ConfDTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; + ConfigurableAxis ConfBinsTempFitVarInvMass{"ConfDTempFitVarInvMassBins", {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"}; /// 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 - 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 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)"}; + 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{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinning{{ConfBinsVtx, ConfBinsMult}, true}; - ConfigurableAxis ConfkstarBins{"ConfkstarBins", {1500, 0., 6.}, "binning kstar"}; - ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; - ConfigurableAxis ConfmTBins{"ConfmTBins", {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"}; - FemtoUniverseFemtoContainer sameEventFemtoCont; - FemtoUniverseFemtoContainer mixedEventFemtoCont; FemtoUniverseAngularContainer sameEventAngularCont; FemtoUniverseAngularContainer mixedEventAngularCont; FemtoUniversePairCleaner pairCleaner; @@ -156,18 +182,25 @@ struct femtoUniversePairTaskTrackPhi { HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry MixQaRegistry{"MixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryMCtruth{"MCtruthHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryMCreco{"MCrecoHistos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry registryPhiMinvBackground{"registryPhiMinvBackground", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + + Service ccdb; + TH2F* protoneff; + TH2F* phieff; // 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 (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfNsigmaTPCProton) { + if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaTPC.value) { return true; } else { return false; } } else if (mom > 0.4) { - if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfNsigmaCombinedProton) { + if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaCombined.value) { return true; } else { return false; @@ -176,6 +209,24 @@ struct femtoUniversePairTaskTrackPhi { return false; } + bool IsProtonRejected(float mom, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) + { + if (mom < 0.5) { + return true; + } + if (mom > 0.5) { + if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfPIDPionNsigmaReject.value) { + return true; + } else if (TMath::Hypot(nsigmaTOFK, nsigmaTPCK) < ConfBothTracks.ConfPIDKaonNsigmaReject.value) { + return true; + } else { + return false; + } + } else { + return false; + } + } + bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) { if (mom < 0.3) { // 0.0-0.3 @@ -215,17 +266,39 @@ struct femtoUniversePairTaskTrackPhi { } } + bool IsKaonRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi) + { + if (mom < 0.5) { + if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfPIDPionNsigmaReject.value) { + return true; + } else if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaReject.value) { + return true; + } + } + if (mom > 0.5) { + if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfPIDPionNsigmaReject.value) { + return true; + } else if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaReject.value) { + return true; + } else { + return false; + } + } else { + return false; + } + } + bool IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) { if (true) { if (mom < 0.5) { - if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfNsigmaTPCPion) { + if (TMath::Abs(nsigmaTPCPi) < ConfBothTracks.ConfPIDPionNsigmaTPC.value) { return true; } else { return false; } } else if (mom > 0.5) { - if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfNsigmaCombinedPion) { + if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < ConfBothTracks.ConfPIDPionNsigmaCombined.value) { return true; } else { return false; @@ -235,9 +308,31 @@ struct femtoUniversePairTaskTrackPhi { return false; } - bool IsParticleNSigma(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) + bool IsPionRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCK, float nsigmaTOFK) + { + if (mom < 0.5) { + if (TMath::Abs(nsigmaTPCK) < ConfBothTracks.ConfPIDKaonNsigmaReject.value) { + return true; + } else if (TMath::Abs(nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaReject.value) { + return true; + } + } + if (mom > 0.5) { + if (TMath::Hypot(nsigmaTOFK, nsigmaTPCK) < ConfBothTracks.ConfPIDKaonNsigmaReject.value) { + return true; + } else if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < ConfBothTracks.ConfPIDProtonNsigmaReject.value) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + bool IsParticleNSigmaAccepted(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) { - switch (ConfTrack.ConfPDGCodeTrack) { + switch (ConfTrack.ConfTrackPDGCode) { case 2212: // Proton case -2212: // anty Proton return IsProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); @@ -255,48 +350,113 @@ struct femtoUniversePairTaskTrackPhi { } } + bool IsParticleNSigmaRejected(float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) + { + switch (ConfTrack.ConfTrackPDGCode) { + case 2212: // Proton + case -2212: // anty Proton + return IsProtonRejected(mom, nsigmaTPCPi, nsigmaTOFPi, nsigmaTPCK, nsigmaTOFK); + break; + case 211: // Pion + case -211: // Pion- + return IsPionRejected(mom, nsigmaTPCPr, nsigmaTOFPr, nsigmaTPCK, nsigmaTOFK); + break; + case 321: // Kaon+ + case -321: // Kaon- + return IsKaonRejected(mom, nsigmaTPCPr, nsigmaTOFPr, nsigmaTPCPi, nsigmaTOFPi); + break; + default: + return false; + } + } + void init(InitContext&) { eventHisto.init(&qaRegistry); - qaRegistry.add("PhiDaugh_pos/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - qaRegistry.add("PhiDaugh_pos/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + 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}}); qaRegistry.add("PhiDaugh_pos/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); qaRegistry.add("PhiDaugh_pos/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); qaRegistry.add("PhiDaugh_pos/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); qaRegistry.add("PhiDaugh_pos/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); - qaRegistry.add("PhiDaugh_neg/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - qaRegistry.add("PhiDaugh_neg/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + qaRegistry.add("PhiDaugh_neg/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); + qaRegistry.add("PhiDaugh_neg/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {200, -4.975, 5.025}}); qaRegistry.add("PhiDaugh_neg/pt", "; #it{p_T} (GeV/#it{c}); Counts", kTH1F, {{100, 0, 10}}); qaRegistry.add("PhiDaugh_neg/eta", "; #it{eta}; Counts", kTH1F, {{200, -1.5, 1.5}}); qaRegistry.add("PhiDaugh_neg/phi", "; #it{varphi}; Counts", kTH1F, {{200, 0, 2. * M_PI}}); qaRegistry.add("PhiDaugh_neg/hDCAxy", "; #it{p}_{T} (GeV/#it{c}); DCA_{xy} (cm)", kTH2F, {{100, 0, 10}, {500, -5, 5}}); - trackHistoPartPhi.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarInvMassBins, ConfBothTracks.ConfIsMC, ConfPhi.ConfPDGCodePhi); - if (!ConfTrack.ConfIsSame) { - trackHistoPartTrack.init(&qaRegistry, ConfTempFitVarpTBins, ConfTempFitVarBins, ConfBothTracks.ConfIsMC, ConfTrack.ConfPDGCodeTrack); + 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}}); + + // 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}}}); + 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}}}); + 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}}}); + + // 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}}}); + registryMCreco.add("MCrecoPpos", "MC reco proton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("MCrecoPneg", "MC reco antiproton;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + trackHistoPartPhi.init(&qaRegistry, ConfBinsTempFitVarpT, ConfBinsTempFitVarInvMass, ConfBothTracks.ConfIsMC, ConfPhi.ConfPhiPDGCode); + if (!ConfTrack.ConfTrackIsSame) { + trackHistoPartTrack.init(&qaRegistry, ConfBinsTempFitVarpT, ConfBinsTempFitVar, ConfBothTracks.ConfIsMC, ConfTrack.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}}); - 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); + 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); - sameEventFemtoCont.setPDGCodes(ConfPhi.ConfPDGCodePhi, ConfTrack.ConfPDGCodeTrack); - mixedEventFemtoCont.setPDGCodes(ConfPhi.ConfPDGCodePhi, ConfTrack.ConfPDGCodeTrack); - sameEventAngularCont.setPDGCodes(ConfPhi.ConfPDGCodePhi, ConfTrack.ConfPDGCodeTrack); - mixedEventAngularCont.setPDGCodes(ConfPhi.ConfPDGCodePhi, ConfTrack.ConfPDGCodeTrack); + sameEventAngularCont.setPDGCodes(ConfPhi.ConfPhiPDGCode, ConfTrack.ConfTrackPDGCode); + mixedEventAngularCont.setPDGCodes(ConfPhi.ConfPhiPDGCode, ConfTrack.ConfTrackPDGCode); pairCleaner.init(&qaRegistry); - if (ConfIsCPR.value) { - pairCloseRejection.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiCutMin.value, ConfCPRdeltaPhiCutMax.value, ConfCPRdeltaEtaCutMin.value, ConfCPRdeltaEtaCutMax.value, ConfCPRChosenRadii.value, ConfCPRPlotPerRadii.value, ConfCPRInvMassCutMin.value, ConfCPRInvMassCutMax.value); + 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); } - vPIDPhiCandidate = ConfPhi.ConfPIDPhi.value; - vPIDTrack = ConfTrack.ConfPIDTrack.value; + /// 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()); + } + } + + vPIDPhiCandidate = ConfPhi.ConfPhiPID.value; + vPIDTrack = ConfTrack.ConfTrackPID.value; kNsigma = ConfBothTracks.ConfTrkPIDnSigmaMax.value; } @@ -318,7 +478,7 @@ struct femtoUniversePairTaskTrackPhi { /// @param magFieldTesla magnetic field of the collision /// @param multCol multiplicity of the collision template - void doSameEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartitionType groupPartsPhiDaugh, PartType parts, float magFieldTesla, int multCol) + void doSameEvent(PartitionType groupPartsTrack, PartitionType groupPartsPhi, PartitionType groupPartsPhiDaugh, PartitionType groupPartsKaons, PartType parts, float magFieldTesla, int multCol) { /// Histogramming same event @@ -351,60 +511,54 @@ struct femtoUniversePairTaskTrackPhi { qaRegistry.fill(HIST("PhiDaugh_neg/hDCAxy"), phidaugh.p(), phidaugh.tempFitVar()); } } - - if (!ConfTrack.ConfIsSame) { + float tpcNSigmaPr, tofNSigmaPr, tpcNSigmaPi, tofNSigmaPi, tpcNSigmaKa, tofNSigmaKa; + if (!ConfTrack.ConfTrackIsSame) { for (auto& track : groupPartsTrack) { - // if (track.p() > ConfBothTracks.ConfCutTable->get("Track", "MaxP") || track.pt() > ConfBothTracks.ConfCutTable->get("Track", "MaxPt")) { - // continue; - // } - // if (!isFullPIDSelected(track.pidcut(), - // track.p(), - // ConfBothTracks.ConfCutTable->get("Track", "PIDthr"), - // vPIDTrack, - // ConfBothTracks.ConfNspecies, - // kNsigma, - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPC"), - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPCTOF"))) { - // continue; - // } - if (ConfTrack.ConfIsTrackIdentified) { - if (!IsParticleNSigma(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))) { + 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) { + 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); } } /// Now build the combinations for (auto& [track, phicandidate] : combinations(CombinationsFullIndexPolicy(groupPartsTrack, groupPartsPhi))) { - // if (track.p() > ConfBothTracks.ConfCutTable->get("PhiCandidate", "MaxP") || track.pt() > ConfBothTracks.ConfCutTable->get("PhiCandidate", "MaxPt") || phicandidate.p() > ConfBothTracks.ConfCutTable->get("Track", "MaxP") || phicandidate.pt() > ConfBothTracks.ConfCutTable->get("Track", "MaxPt")) { - // continue; - // } - // if (!isFullPIDSelected(track.pidcut(), - // track.p(), - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "PIDthr"), - // vPIDPhiCandidate, - // ConfBothTracks.ConfNspecies, - // kNsigma, - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "nSigmaTPC"), - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "nSigmaTPCTOF")) || - // !isFullPIDSelected(phicandidate.pidcut(), - // phicandidate.p(), - // ConfBothTracks.ConfCutTable->get("Track", "PIDthr"), - // vPIDTrack, - // ConfBothTracks.ConfNspecies, - // kNsigma, - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPC"), - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPCTOF"))) { - // continue; - // } - if (ConfTrack.ConfIsTrackIdentified) { - if (!IsParticleNSigma(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))) { + if (ConfTrack.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; + } + } + // // Close Pair Rejection - if (ConfIsCPR.value) { + if (ConfCPR.ConfCPRIsEnabled.value) { if (pairCloseRejection.isClosePair(track, phicandidate, parts, magFieldTesla, femtoUniverseContainer::EventType::same)) { continue; } @@ -414,8 +568,43 @@ struct femtoUniversePairTaskTrackPhi { if (!pairCleaner.isCleanPair(track, phicandidate, parts)) { continue; } - sameEventFemtoCont.setPair(track, phicandidate, multCol, ConfBothTracks.ConfUse3D); - sameEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.ConfUse3D); + + 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); + } + } + + TLorentzVector part1Vec; + TLorentzVector part2Vec; + + float mMassOne = TDatabasePDG::Instance()->GetParticle(321)->Mass(); // FIXME: Get from the PDG service of the common header + float mMassTwo = TDatabasePDG::Instance()->GetParticle(-321)->Mass(); // FIXME: Get from the PDG service of the common header + + for (auto& [kaon1, kaon2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsKaons, groupPartsKaons))) { + // empty if statements commented out on 20241114 to get rid of MegaLinter errors + // if (!IsKaonNSigma(kaon1.p(), trackCuts.getNsigmaTPC(kaon1, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(kaon1, o2::track::PID::Kaon))) { + // } + // if (!IsKaonNSigma(kaon2.p(), trackCuts.getNsigmaTPC(kaon2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(kaon2, o2::track::PID::Kaon))) { + // } + 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()); + } } } @@ -430,8 +619,9 @@ struct femtoUniversePairTaskTrackPhi { 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, parts, col.magField(), col.multNtr()); + doSameEvent(thegroupPartsTrack, thegroupPartsPhi, thegroupPartsPhiDaugh, thegroupPartsKaons, parts, col.magField(), col.multNtr()); } PROCESS_SWITCH(femtoUniversePairTaskTrackPhi, processSameEvent, "Enable processing same event", true); @@ -448,8 +638,9 @@ struct femtoUniversePairTaskTrackPhi { 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, parts, col.magField(), col.multNtr()); + doSameEvent(thegroupPartsTrack, thegroupPartsPhi, thegroupPartsPhiDaugh, thegroupPartsKaons, parts, col.magField(), col.multNtr()); } PROCESS_SWITCH(femtoUniversePairTaskTrackPhi, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -468,40 +659,31 @@ struct femtoUniversePairTaskTrackPhi { { for (auto& [track, phicandidate] : combinations(CombinationsFullIndexPolicy(groupPartsTrack, groupPartsPhi))) { - // if (track.p() > ConfBothTracks.ConfCutTable->get("PhiCandidate", "MaxP") || track.pt() > ConfBothTracks.ConfCutTable->get("PhiCandidate", "MaxPt") || phicandidate.p() > ConfBothTracks.ConfCutTable->get("Track", "MaxP") || phicandidate.pt() > ConfBothTracks.ConfCutTable->get("Track", "MaxPt")) { - // continue; - // } - // if (!isFullPIDSelected(track.pidcut(), - // track.p(), - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "PIDthr"), - // vPIDPhiCandidate, - // ConfBothTracks.ConfNspecies, - // kNsigma, - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "nSigmaTPC"), - // ConfBothTracks.ConfCutTable->get("PhiCandidate", "nSigmaTPCTOF")) || - // !isFullPIDSelected(phicandidate.pidcut(), - // phicandidate.p(), - // ConfBothTracks.ConfCutTable->get("Track", "PIDthr"), - // vPIDTrack, - // ConfBothTracks.ConfNspecies, - // kNsigma, - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPC"), - // ConfBothTracks.ConfCutTable->get("Track", "nSigmaTPCTOF"))) { - // continue; - // } - if (ConfTrack.ConfIsTrackIdentified) { - if (!IsParticleNSigma(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))) { + if (ConfTrack.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 (ConfIsCPR.value) { + + 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 (ConfCPR.ConfCPRIsEnabled.value) { if (pairCloseRejection.isClosePair(track, phicandidate, parts, magFieldTesla, femtoUniverseContainer::EventType::mixed)) { continue; } } - mixedEventFemtoCont.setPair(track, phicandidate, multCol, ConfBothTracks.ConfUse3D); - mixedEventAngularCont.setPair(track, phicandidate, multCol, ConfBothTracks.ConfUse3D); + 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); + } } } @@ -562,6 +744,81 @@ struct femtoUniversePairTaskTrackPhi { } } PROCESS_SWITCH(femtoUniversePairTaskTrackPhi, processMixedEventMC, "Enable processing mixed events MC", false); + + ///--------------------------------------------MC-------------------------------------------------/// + + /// This function fills MC truth particles from derived MC table + void processMCTruth(aod::FDParticles const& parts) + { + for (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 (pdgParticle->Charge() > 0.0) { + registryMCtruth.fill(HIST("MCtruthAllPositivePt"), part.pt()); + } + if (pdgCode == 321) { + registryMCtruth.fill(HIST("MCtruthKp"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("MCtruthKpPt"), part.pt()); + } + if (pdgCode == 333) { + registryMCtruth.fill(HIST("MCtruthPhi"), part.pt(), part.eta()); + continue; + } + if (pdgCode == 2212) { + registryMCtruth.fill(HIST("MCtruthPpos"), part.pt(), part.eta()); + } + + 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()); + } + } + } + PROCESS_SWITCH(femtoUniversePairTaskTrackPhi, processMCTruth, "Process MC truth data", false); + + void processMCReco(FemtoRecoParticles const& parts, aod::FDMCParticles const& mcparts) + { + for (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::kPhi) { + if ((mcpart.pdgMCTruth() == 333) && (mcpart.partOriginMCTruth() == aod::femtouniverseMCparticle::ParticleOriginMCTruth::kPrimary)) { + registryMCreco.fill(HIST("MCrecoPhi"), mcpart.pt(), mcpart.eta()); // phi + } + } 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()); + } + } + + 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()); + } + } + } // partType + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackPhi, processMCReco, "Process MC reco data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx index ed5ff3c56f1..deb2e4b8d80 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrack3DMultKtExtended.cxx @@ -15,6 +15,7 @@ /// \author Pritam Chakraborty, WUT Warsaw, pritam.chakraborty@pw.edu.pl #include +#include #include "TRandom2.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -134,7 +135,8 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { Configurable ConfV0MHigh{"ConfV0MHigh", 25000.0, "Upper limit for V0M multiplicity"}; Filter collV0Mfilter = ((o2::aod::femtouniversecollision::multV0M > ConfV0MLow) && (o2::aod::femtouniversecollision::multV0M < ConfV0MHigh)); - // Filter trackAdditionalfilter = (nabs(aod::femtouniverseparticle::eta) < twotracksconfigs.ConfEtaMax); // example filtering on configurable + using FilteredFDCollisions = soa::Filtered; + using FilteredFDCollision = soa::Filtered::iterator; /// Particle part ConfigurableAxis ConfTempFitVarBins{"ConfDTempFitVarBins", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot"}; @@ -149,7 +151,7 @@ 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 colBinning{{ConfVtxBins, ConfMultBins}, true}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {300, -1.5, 1.5}, "binning kstar"}; ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; @@ -213,6 +215,8 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { HistogramRegistry SameMultRegistryMM{"SameMultRegistryMM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry MixedMultRegistryMM{"MixedMultRegistryMM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + TRandom2* randgen; + // 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 { @@ -412,7 +416,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { template void fillCollision(CollisionType col) { - MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multNtr()})); + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); eventHisto.fillQA(col); } @@ -476,15 +480,14 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); if (!cfgProcessMultBins) { - sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + sameEventCont.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { - std::vector k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); + std::vector k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); sameEventMultCont.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); } } } else { /// Now build the combinations for identical particles pairs - TRandom2* randgen = new TRandom2(0); double rand; for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { @@ -515,16 +518,16 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { if (rand > 0.5) { if (!cfgProcessMultBins) { - sameEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + sameEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { - k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); + k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); sameEventMultContPP.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); } } else { if (!cfgProcessMultBins) { - sameEventContPP.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + sameEventContPP.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { - k3d = FemtoUniverseMath::getpairmom3d(p2, mass2, p1, mass1, ConfIsIden, ConfIsLCMS); + k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); sameEventMultContPP.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); } } @@ -538,16 +541,16 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { if (rand > 0.5) { if (!cfgProcessMultBins) { - sameEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + sameEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { - k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); + k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); sameEventMultContMM.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); } } else { if (!cfgProcessMultBins) { - sameEventContMM.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + sameEventContMM.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); } else { - k3d = FemtoUniverseMath::getpairmom3d(p2, mass2, p1, mass1, ConfIsIden, ConfIsLCMS); + k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); sameEventMultContMM.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); } } @@ -563,7 +566,7 @@ 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(soa::Filtered::iterator& col, + void processSameEvent(FilteredFDCollision& col, FilteredFemtoFullParticles& parts) { fillCollision(col); @@ -572,18 +575,20 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { auto thegroupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); bool fillQA = true; + randgen = new TRandom2(0); if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); } if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); } if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); } + delete randgen; } PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processSameEvent, "Enable processing same event", true); @@ -603,15 +608,15 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { bool fillQA = true; if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); } if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); } if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); } } PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -646,38 +651,72 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { } } + double rand; + rand = randgen->Rndm(); + switch (ContType) { case 1: { float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); - if (!cfgProcessMultBins) { - mixedEventCont.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + + if (rand > 0.5) { + if (!cfgProcessMultBins) { + mixedEventCont.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); + mixedEventMultCont.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } else { - std::vector k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); - mixedEventMultCont.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + if (!cfgProcessMultBins) { + mixedEventCont.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + mixedEventMultCont.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } break; } case 2: { float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass1); - if (!cfgProcessMultBins) { - mixedEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + + if (rand > 0.5) { + if (!cfgProcessMultBins) { + mixedEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); + mixedEventMultContPP.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } else { - std::vector k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); - mixedEventMultContPP.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + if (!cfgProcessMultBins) { + mixedEventContPP.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + mixedEventMultContPP.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } break; } case 3: { float kT = FemtoUniverseMath::getkT(p1, mass2, p2, mass2); - if (!cfgProcessMultBins) { - mixedEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden, ConfIsLCMS); + + if (rand > 0.5) { + if (!cfgProcessMultBins) { + mixedEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p1, mass1, p2, mass2, ConfIsIden); + mixedEventMultContMM.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } else { - std::vector k3d = FemtoUniverseMath::getpairmom3d(p1, mass1, p2, mass2, ConfIsIden, ConfIsLCMS); - mixedEventMultContMM.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + if (!cfgProcessMultBins) { + mixedEventContMM.setPair(p2, p1, multCol, twotracksconfigs.ConfUse3D, ConfIsIden); + } else { + std::vector k3d = FemtoUniverseMath::newpairfunc(p2, mass2, p1, mass1, ConfIsIden); + mixedEventMultContMM.fill_3D(k3d[1], k3d[2], k3d[3], multCol, kT); + } } break; } + default: break; } @@ -687,12 +726,14 @@ 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(soa::Filtered& cols, + void processMixedEvent(FilteredFDCollisions& cols, FilteredFemtoFullParticles& parts) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + randgen = new TRandom2(0); + + for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); @@ -718,6 +759,7 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); } } + delete randgen; } PROCESS_SWITCH(femtoUniversePairTaskTrackTrack3DMultKtExtended, processMixedEvent, "Enable processing mixed events", true); @@ -729,9 +771,9 @@ struct femtoUniversePairTaskTrackTrack3DMultKtExtended { soa::Join& parts, o2::aod::FDMCParticles&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx index af8bccfc785..0ae10b8c65a 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMcTruth.cxx @@ -56,8 +56,8 @@ struct femtoUniversePairTaskTrackTrackMcTruth { Configurable ConfPtHighPart1{"ConfPtHighPart1", 2.5, "Higher limit for Pt for the first particle"}; /// Partition for particle 1 - Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (ConfNoPDGPartOne || aod::femtouniverseparticle::pidcut == uint32_t(ConfPDGCodePartOne)) && - aod::femtouniverseparticle::pt < ConfPtHighPart1 && aod::femtouniverseparticle::pt > ConfPtLowPart1&& nabs(aod::femtouniverseparticle::eta) < ConfEtaMax; + Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && + (aod::femtouniverseparticle::pt < ConfPtHighPart1) && (aod::femtouniverseparticle::pt > ConfPtLowPart1) && (nabs(aod::femtouniverseparticle::eta) < ConfEtaMax); /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartOne; @@ -70,8 +70,8 @@ struct femtoUniversePairTaskTrackTrackMcTruth { Configurable ConfPtHighPart2{"ConfPtHighPart2", 2.5, "Higher limit for Pt for the second particle"}; /// Partition for particle 2 - Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (ConfNoPDGPartTwo || aod::femtouniverseparticle::pidcut == uint32_t(ConfPDGCodePartTwo)) && - aod::femtouniverseparticle::pt < ConfPtHighPart2 && aod::femtouniverseparticle::pt > ConfPtLowPart2&& nabs(aod::femtouniverseparticle::eta) < ConfEtaMax; + Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && + (aod::femtouniverseparticle::pt < ConfPtHighPart2) && (aod::femtouniverseparticle::pt > ConfPtLowPart2) && (nabs(aod::femtouniverseparticle::eta) < ConfEtaMax); /// Histogramming for particle 2 FemtoUniverseParticleHisto trackHistoPartTwo; @@ -161,31 +161,57 @@ struct femtoUniversePairTaskTrackTrackMcTruth { /// Histogramming same event for (auto& part : groupPartsOne) { - + if (!ConfNoPDGPartOne && part.tempFitVar() != ConfPDGCodePartOne) { + continue; + } trackHistoPartOne.fillQA(part); } if (!ConfIsSame) { for (auto& part : groupPartsTwo) { - + if (!ConfNoPDGPartTwo && part.tempFitVar() != ConfPDGCodePartTwo) { + continue; + } trackHistoPartTwo.fillQA(part); } } /// Now build the combinations - for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsTwo))) { - // track cleaning - if (!pairCleaner.isCleanPair(p1, p2, parts)) { - continue; + if (!ConfIsSame) { + // Build the combinations for pairs of non-identical particles + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + if ((!ConfNoPDGPartOne && p2.tempFitVar() != ConfPDGCodePartOne) || (!ConfNoPDGPartTwo && p1.tempFitVar() != ConfPDGCodePartTwo)) { + continue; + } + if (swpart) + sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + else + sameEventCont.setPair(p2, p1, multCol, ConfUse3D); + + swpart = !swpart; + } + } else { + // Build the combinations for pairs of identical pairs + for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsTwo))) { + // track cleaning + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + if ((!ConfNoPDGPartOne && p2.tempFitVar() != ConfPDGCodePartOne) || (!ConfNoPDGPartTwo && p1.tempFitVar() != ConfPDGCodePartTwo)) { + continue; + } + if (swpart) + sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + else + sameEventCont.setPair(p2, p1, multCol, ConfUse3D); + + swpart = !swpart; } - if (swpart) - sameEventCont.setPair(p1, p2, multCol, ConfUse3D); - else - sameEventCont.setPair(p2, p1, multCol, ConfUse3D); - - swpart = !swpart; } } - /// process function for to call doSameEvent with Data /// \param col subscribe to the collision table (Data) /// \param parts subscribe to the femtoUniverseParticleTable @@ -218,6 +244,9 @@ struct femtoUniversePairTaskTrackTrackMcTruth { fNeventsProcessed++; for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if ((!ConfNoPDGPartOne && p2.tempFitVar() != ConfPDGCodePartOne) || (!ConfNoPDGPartTwo && p1.tempFitVar() != ConfPDGCodePartTwo)) { + continue; + } if (swpart) mixedEventCont.setPair(p1, p2, multCol, ConfUse3D); else diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx index ff1761f8fb4..f7f9baa6d87 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackMultKtExtended.cxx @@ -18,6 +18,7 @@ /// \author Alicja Płachta, WUT Warsaw, alicja.plachta.stud@pw.edu.pl #include +#include #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/HistogramRegistry.h" @@ -52,9 +53,7 @@ static constexpr int nPart = 2; static constexpr int nCuts = 5; static const std::vector partNames{"PartOne", "PartTwo"}; static const std::vector cutNames{"MaxPt", "PIDthr", "nSigmaTPC", "nSigmaTPCTOF", "MaxP"}; -static const float cutsTable[nPart][nCuts]{ - {4.05f, 1.f, 3.f, 3.f, 100.f}, - {4.05f, 1.f, 3.f, 3.f, 100.f}}; +static const float cutsTable[nPart][nCuts]{{4.05f, 1.f, 3.f, 3.f, 100.f}, {4.05f, 1.f, 3.f, 3.f, 100.f}}; } // namespace struct femtoUniversePairTaskTrackTrackMultKtExtended { @@ -65,9 +64,10 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { /// Table for both particles struct : o2::framework::ConfigurableGroup { - Configurable ConfNsigmaCombined{"ConfNsigmaCombined", 3.0f, "TPC and TOF Pion Sigma (combined) for momentum > ConfTOFPtMin"}; - Configurable ConfNsigmaTPC{"ConfNsigmaTPC", 3.0f, "TPC Pion Sigma for momentum < ConfTOFPtMin"}; - Configurable ConfTOFPtMin{"ConfTOFPtMin", 0.5f, "Min. Pt for which TOF is required for PID."}; + Configurable IsKaonNsigma{"IsKaonNsigma", false, "Enable a strict cut selection for K+ and K-"}; + Configurable ConfNsigmaCombined{"ConfNsigmaCombined", 3.0f, "TPC and TOF Pion Sigma (combined) for momentum > ConfTOFpMin"}; + Configurable ConfNsigmaTPC{"ConfNsigmaTPC", 3.0f, "TPC Pion Sigma for momentum < ConfTOFpMin"}; + Configurable ConfTOFpMin{"ConfTOFpMin", 0.5f, "Min. momentum for which TOF is required for PID."}; Configurable ConfEtaMax{"ConfEtaMax", 0.8f, "Higher limit for |Eta| (the same for both particles)"}; Configurable> ConfCutTable{"ConfCutTable", {cutsTable[0], nPart, nCuts, partNames, cutNames}, "Particle selections"}; @@ -75,9 +75,35 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { 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"}; - } twotracksconfigs; + /// Table for separate 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"}; + } deuteronconfigs; + + /// Table for linear cut for TPC Deuteron Sigma + struct : o2::framework::ConfigurableGroup { + Configurable ConfIsLine{"ConfIsLine", false, "Enable a separation line for clearer TPC Deuteron Sigma"}; + Configurable pLow{"pLow", 0.0f, "Lower limit of momentum for linear cut of TPC Deuteron Sigma"}; + Configurable pHigh{"pHigh", 1.4f, "Higher limit of momentum for linear cut of TPC Deuteron Sigma"}; + Configurable a{"a", -167.0f, "Parameter 'a' of a linear function 'y = a * x + b'"}; + Configurable b{"b", 300.0f, "Parameter 'b' of a linear function 'y = a * x + b'"}; + } lincut; + + /// Table for polynomial 3 cut for TPC Deuteron Sigma + struct : o2::framework::ConfigurableGroup { + Configurable ConfIsPol{"ConfIsPol", false, "Enable a separation polynomial 3 curve for clearer TPC Deuteron Sigma"}; + Configurable A{"A", -52.2f, "Parameter 'A' of a polynomial function 'y = A * x^3 + B * x^2 + C * x + D'"}; + Configurable B{"B", 357.7f, "Parameter 'B' of a polynomial function 'y = A * x^3 + B * x^2 + C * x + D'"}; + Configurable C{"C", -834.7f, "Parameter 'C' of a polynomial function 'y = A * x^3 + B * x^2 + C * x + D'"}; + Configurable D{"D", 705.8f, "Parameter 'D' of a polynomial function 'y = A * x^3 + B * x^2 + C * x + D'"}; + } polcut; + using FemtoFullParticles = soa::Join; // Filters for selecting particles (both p1 and p2) Filter trackAdditionalfilter = (nabs(aod::femtouniverseparticle::eta) < twotracksconfigs.ConfEtaMax); // example filtering on configurable @@ -89,9 +115,9 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { /// Particle 1 struct : o2::framework::ConfigurableGroup { - Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 211, "Particle 1 - PDG code"}; - // Configurable ConfCutPartOne{"ConfCutPartOne", 5542474, "Particle 1 - Selection bit from cutCulator"}; - Configurable ConfPIDPartOne{"ConfPIDPartOne", 2, "Particle 1 - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector>int>> + Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 211, "Particle 1 -- PDG code"}; + // Configurable ConfCutPartOne{"ConfCutPartOne", 5542474, "Particle 1 -- Selection bit from cutCulator"}; + Configurable ConfPIDPartOne{"ConfPIDPartOne", 2, "Particle 1 -- Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector>int>> Configurable ConfPtLowPart1{"ConfPtLowPart1", 0.14, "Lower limit for Pt for the first particle"}; Configurable ConfPtHighPart1{"ConfPtHighPart1", 1.5, "Higher limit for Pt for the first particle"}; Configurable ConfChargePart1{"ConfChargePart1", 1, "Particle 1 sign"}; @@ -101,17 +127,15 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { 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; - // /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartOne; /// Particle 2 struct : o2::framework::ConfigurableGroup { - Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 211, "Particle 2 - PDG code"}; - // Configurable ConfCutPartTwo{"ConfCutPartTwo", 5542474, "Particle 2 - Selection bit"}; - Configurable ConfPIDPartTwo{"ConfPIDPartTwo", 2, "Particle 2 - Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector> - + Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 211, "Particle 2 -- PDG code"}; + // Configurable ConfCutPartTwo{"ConfCutPartTwo", 5542474, "Particle 2 -- Selection bit"}; + Configurable ConfPIDPartTwo{"ConfPIDPartTwo", 2, "Particle 2 -- Read from cutCulator"}; // we also need the possibility to specify whether the bit is true/false ->std>>vector> Configurable ConfPtLowPart2{"ConfPtLowPart2", 0.14, "Lower limit for Pt for the second particle"}; Configurable ConfPtHighPart2{"ConfPtHighPart2", 1.5, "Higher limit for Pt for the second particle"}; Configurable ConfChargePart2{"ConfChargePart2", -1, "Particle 2 sign"}; @@ -155,7 +179,7 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { 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 colBinning{{ConfVtxBins, ConfMultBins}, true}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {1500, 0., 6.}, "binning kstar"}; ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; @@ -169,12 +193,13 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { 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 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"}; - 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 IsPairIdentical{"IsPairIdentical", true, "'true' for identical particles, 'false' for non-identical particles"}; + Configurable cfgProcessPM{"cfgProcessPM", true, "Process differently charged particles (plus-minus)"}; + Configurable cfgProcessPP{"cfgProcessPP", true, "Process positively charged particles (plus-plus)"}; + Configurable cfgProcessMM{"cfgProcessMM", true, "Process negatively charged particles (minus-minus)"}; + Configurable cfgProcessMultBins{"cfgProcessMultBins", true, "Process kstar histograms (in multiplicity bins)"}; + Configurable cfgProcessKtBins{"cfgProcessKtBins", true, "Process kstar histograms in kT bins (if 'cfgProcessMultBins' is false, it will not be processed regardless of 'cfgProcessKtBins' state)"}; + Configurable cfgProcessKtMt3DCF{"cfgProcessKtMt3DCF", false, "Process 3D histograms in kT and MultBins"}; FemtoUniverseFemtoContainer sameEventCont; FemtoUniverseFemtoContainer mixedEventCont; @@ -220,122 +245,142 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { HistogramRegistry sphericityRegistry{"SphericityHisto", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - // 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 + /// TPC Pion/Kaon/Proton Sigma selection (general) + bool IsNSigma(float mom, float nsigmaTPC, float nsigmaTOF) { - //|nsigma_TPC| < 3 for p < 0.5 GeV/c - //|nsigma_combined| < 3 for p > 0.5 + // |nsigma_TPC| < 3 for p < 0.5 GeV/c + // |nsigma_combined| < 3 for p > 0.5 // using configurables: - // ConfTOFPtMin - momentum value when we start using TOF; set to 1000 if TOF not needed - // ConfNsigmaTPC -> TPC Sigma for momentum < 0.5 - // ConfNsigmaCombined -> TPC and TOF Sigma (combined) for momentum > 0.5 + // ConfTOFpMin -- momentum value when we start using TOF; set to 1000 if TOF not needed + // ConfNsigmaTPC -> TPC Sigma for momentum < ConfTOFpMin + // ConfNsigmaCombined -> TPC and TOF Sigma (combined) for momentum > ConfTOFpMin + + if (mom < twotracksconfigs.ConfTOFpMin) { + return TMath::Abs(nsigmaTPC) < twotracksconfigs.ConfNsigmaTPC; + } else { + return TMath::Hypot(nsigmaTOF, nsigmaTPC) < twotracksconfigs.ConfNsigmaCombined; + } + } - if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPr) < twotracksconfigs.ConfNsigmaTPC) { - return true; + /// TPC Kaon Sigma selection (stricter cuts for K+ and K-) -- based on Run2 results + bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) + { + if (twotracksconfigs.IsKaonNsigma == 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); } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFPr, nsigmaTPCPr) < twotracksconfigs.ConfNsigmaCombined) { - return true; + return IsNSigma(mom, nsigmaTPCK, nsigmaTOFK); + } + } + + /// TPC Deuteron Sigma selection + 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; } else { - return false; + return (TMath::Abs(nsigmaTOFDe) < deuteronconfigs.ConfNsigmaTOFDe && (TMath::Abs(nsigmaTPCDe) < deuteronconfigs.ConfNsigmaTPCDe)); } + } else { + return false; } - return false; } - bool IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK) + /// Linear cut for clearer TPC Deuteron Sigma + bool IsDeuteronNSigmaLinearCut(float mom, float nsigmaTPCDe, float nsigmaTOFDe, float tpcSignal) { - //|nsigma_TPC| < 3 for p < 0.5 GeV/c - //|nsigma_combined| < 3 for p > 0.5 - - // using configurables: - // ConfTOFPtMin - momentum value when we start using TOF; set to 1000 if TOF not needed - // ConfNsigmaTPCTOFKaon -> are we doing TPC TOF PID for Kaons? (boolean) - // ConfNsigmaTPC -> TPC Kaon Sigma for momentum < 0.5 - // ConfNsigmaCombined -> TPC and TOF Sigma (combined) for momentum > 0.5 - if (true) { - if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCK) < twotracksconfigs.ConfNsigmaTPC) { - return true; + if (lincut.ConfIsLine == true) { + if (mom > lincut.pLow && mom < lincut.pHigh) { + if (tpcSignal > lincut.a * mom + lincut.b) { + return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); } else { return false; } } else { - if (TMath::Hypot(nsigmaTOFK, nsigmaTPCK) < twotracksconfigs.ConfNsigmaCombined) { - return true; - } else { - return false; - } + return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); } + } else { + return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); } - return false; } - bool IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi) + /// Polynomial 3 cut for clearer TPC Deuteron Sigma + bool IsDeuteronNSigmaPolCut(float mom, float nsigmaTPCDe, float nsigmaTOFDe, float tpcSignal) { - //|nsigma_TPC| < 3 for p < 0.5 GeV/c - //|nsigma_combined| < 3 for p > 0.5 - - // using configurables: - // ConfTOFPtMin - momentum value when we start using TOF; set to 1000 if TOF not needed - // ConfNsigmaTPC -> TPC Sigma for momentum < 0.5 - // ConfNsigmaCombined -> TPC and TOF Pion Sigma (combined) for momentum > 0.5 - if (true) { - if (mom < twotracksconfigs.ConfTOFPtMin) { - if (TMath::Abs(nsigmaTPCPi) < twotracksconfigs.ConfNsigmaTPC) { - return true; - } else { - return false; - } + if (polcut.ConfIsPol == true) { + if (tpcSignal > polcut.A * TMath::Power(mom, 3) + polcut.B * TMath::Power(mom, 2) + polcut.C * mom + polcut.D) { + return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); } else { - if (TMath::Hypot(nsigmaTOFPi, nsigmaTPCPi) < twotracksconfigs.ConfNsigmaCombined) { - return true; - } else { - return false; - } + return false; } + } else { + return IsDeuteronNSigma(mom, nsigmaTPCDe, nsigmaTOFDe); } - return false; } - bool IsParticleNSigma(int8_t particle_number, float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK) + bool IsParticleNSigma(int8_t particle_number, float mom, float nsigmaTPCPr, float nsigmaTOFPr, float nsigmaTPCPi, float nsigmaTOFPi, float nsigmaTPCK, float nsigmaTOFK, float nsigmaTPCDe, float nsigmaTOFDe, float tpcSignal) { if (particle_number == 1) { switch (trackonefilter.ConfPDGCodePartOne) { - case 2212: // Proton - case -2212: // Antiproton - return IsProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); + case 2212: // Proton+ + case -2212: // Proton- + return IsNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); break; case 211: // Pion+ case -211: // Pion- - return IsPionNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); + case 111: // Pion 0 + return IsNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); break; case 321: // Kaon+ case -321: // Kaon- return IsKaonNSigma(mom, nsigmaTPCK, nsigmaTOFK); break; + case 130: // Kaon 0 LONG + case 310: // Kaon 0 SHORT + return IsNSigma(mom, nsigmaTPCK, nsigmaTOFK); + break; + case 1000010020: // Deuteron+ + case -1000010020: // Deuteron- + return IsDeuteronNSigmaPolCut(mom, nsigmaTPCDe, nsigmaTOFDe, tpcSignal); + break; default: return false; } return false; } else if (particle_number == 2) { switch (tracktwofilter.ConfPDGCodePartTwo) { - case 2212: // Proton - case -2212: // Antiproton - return IsProtonNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); + case 2212: // Proton+ + case -2212: // Proton- + return IsNSigma(mom, nsigmaTPCPr, nsigmaTOFPr); break; case 211: // Pion+ case -211: // Pion- - return IsPionNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); + case 111: // Pion 0 + return IsNSigma(mom, nsigmaTPCPi, nsigmaTOFPi); break; case 321: // Kaon+ case -321: // Kaon- return IsKaonNSigma(mom, nsigmaTPCK, nsigmaTOFK); break; + case 130: // Kaon 0 LONG + case 310: // Kaon 0 SHORT + return IsNSigma(mom, nsigmaTPCK, nsigmaTOFK); + break; + case 1000010020: // Deuteron+ + case -1000010020: // Deuteron- + return IsDeuteronNSigmaPolCut(mom, nsigmaTPCDe, nsigmaTOFDe, tpcSignal); + break; default: return false; } @@ -411,53 +456,55 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { template void fillCollision(CollisionType col) { - MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multNtr()})); + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); 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 groupPartsOne partition for the first particle passed by the process function - /// @param groupPartsTwo 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 + /// \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 parts femtoUniverseParticles table (in case of Monte Carlo joined with FemtoUniverseMCLabels) + /// \param magFieldTesla magnetic field of the collision + /// \param multCol multiplicity of the collision + /// \param pairType describes charge of correlation pair (plus-minus (1), plus-plus (2), minus-minus (3)) + /// \param fillQA enables filling of QA histograms template - void doSameEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType, bool fillQA) + void doSameEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int pairType, bool fillQA) { /// Histogramming same event - if ((ContType == 1 || ContType == 2) && fillQA) { + if ((pairType == 1 || pairType == 2) && fillQA) { for (auto& part : groupPartsOne) { - if (!IsParticleNSigma((int8_t)1, part.pt(), 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))) { + 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), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron), part.tpcSignal())) { continue; } trackHistoPartOne.fillQA(part); } } - if ((ContType == 1 || ContType == 3) && fillQA) { + if ((pairType == 1 || pairType == 3) && fillQA) { for (auto& part : groupPartsTwo) { - if (!IsParticleNSigma((int8_t)2, part.pt(), 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))) { + 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), trackCuts.getNsigmaTPC(part, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(part, o2::track::PID::Deuteron), part.tpcSignal())) { continue; } trackHistoPartTwo.fillQA(part); } } - if (ContType == 1) { + if (pairType == 1) { /// Now build the combinations for non-identical particle pairs for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { - if (!IsParticleNSigma((int8_t)1, p1.pt(), 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))) { + 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), trackCuts.getNsigmaTPC(p1, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p1, o2::track::PID::Deuteron), p1.tpcSignal())) { continue; } - if (!IsParticleNSigma((int8_t)2, p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon))) { + if (!IsParticleNSigma((int8_t)2, p2.p(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(p2, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p2, o2::track::PID::Deuteron), p2.tpcSignal())) { continue; } @@ -483,11 +530,11 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { /// Now build the combinations for identical particles pairs for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { - if (!IsParticleNSigma((int8_t)2, p1.pt(), 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))) { + 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), trackCuts.getNsigmaTPC(p1, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p1, o2::track::PID::Deuteron), p1.tpcSignal())) { continue; } - if (!IsParticleNSigma((int8_t)2, p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon))) { + if (!IsParticleNSigma((int8_t)2, p2.p(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(p2, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p2, o2::track::PID::Deuteron), p2.tpcSignal())) { continue; } @@ -502,24 +549,44 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { continue; } - switch (ContType) { + switch (pairType) { case 2: { - float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass1); - float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass1); + if (IsPairIdentical == true) { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass1); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass1); + + sameEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + sameEventMultContPP.fill(kstar, multCol, kT); + } else { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + + sameEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + sameEventMultContPP.fill(kstar, multCol, kT); + } - sameEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); - if (cfgProcessMultBins) - sameEventMultContPP.fill(kstar, multCol, kT); break; } case 3: { - float kstar = FemtoUniverseMath::getkstar(p1, mass2, p2, mass2); - float kT = FemtoUniverseMath::getkT(p1, mass2, p2, mass2); + if (IsPairIdentical == true) { + float kstar = FemtoUniverseMath::getkstar(p1, mass2, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass2, p2, mass2); + + sameEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + sameEventMultContMM.fill(kstar, multCol, kT); + } else { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + + sameEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + sameEventMultContMM.fill(kstar, multCol, kT); + } - sameEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); - if (cfgProcessMultBins) - sameEventMultContMM.fill(kstar, multCol, kT); break; } default: @@ -544,13 +611,13 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { bool fillQA = true; if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); fillQA = false; } if (cfgProcessPP) - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); if (cfgProcessMM) - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); } PROCESS_SWITCH(femtoUniversePairTaskTrackTrackMultKtExtended, processSameEvent, "Enable processing same event", true); @@ -569,13 +636,13 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { bool fillQA = true; if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); fillQA = false; } if (cfgProcessPP) - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); if (cfgProcessMM) - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); } PROCESS_SWITCH(femtoUniversePairTaskTrackTrackMultKtExtended, processSameEventMC, "Enable processing same event for Monte Carlo", false); @@ -589,17 +656,18 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { /// \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 + /// \param pairType describes charge of correlation pair (plus-minus (1), plus-plus (2), minus-minus (3)) template - void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int ContType) + void doMixedEvent(PartitionType groupPartsOne, PartitionType groupPartsTwo, PartType parts, float magFieldTesla, int multCol, int pairType) { for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { - if (!IsParticleNSigma((int8_t)2, p1.pt(), 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))) { + 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), trackCuts.getNsigmaTPC(p1, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p1, o2::track::PID::Deuteron), p1.tpcSignal())) { continue; } - if (!IsParticleNSigma((int8_t)2, p2.pt(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon))) { + if (!IsParticleNSigma((int8_t)2, p2.p(), trackCuts.getNsigmaTPC(p2, o2::track::PID::Proton), trackCuts.getNsigmaTOF(p2, o2::track::PID::Proton), trackCuts.getNsigmaTPC(p2, o2::track::PID::Pion), trackCuts.getNsigmaTOF(p2, o2::track::PID::Pion), trackCuts.getNsigmaTPC(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTOF(p2, o2::track::PID::Kaon), trackCuts.getNsigmaTPC(p2, o2::track::PID::Deuteron), trackCuts.getNsigmaTOF(p2, o2::track::PID::Deuteron), p2.tpcSignal())) { continue; } @@ -609,30 +677,54 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { } } - switch (ContType) { + switch (pairType) { case 1: { float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass2); float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + mixedEventCont.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); if (cfgProcessMultBins) mixedEventMultCont.fill(kstar, multCol, kT); + break; } case 2: { - float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass1); - float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass1); - mixedEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); - if (cfgProcessMultBins) - mixedEventMultContPP.fill(kstar, multCol, kT); + if (IsPairIdentical == true) { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass1); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass1); + + mixedEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + mixedEventMultContPP.fill(kstar, multCol, kT); + } else { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + + mixedEventContPP.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + mixedEventMultContPP.fill(kstar, multCol, kT); + } + break; } case 3: { - float kstar = FemtoUniverseMath::getkstar(p1, mass2, p2, mass2); - float kT = FemtoUniverseMath::getkT(p1, mass2, p2, mass2); - mixedEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); - if (cfgProcessMultBins) - mixedEventMultContMM.fill(kstar, multCol, kT); + if (IsPairIdentical == true) { + float kstar = FemtoUniverseMath::getkstar(p1, mass2, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass2, p2, mass2); + + mixedEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + mixedEventMultContMM.fill(kstar, multCol, kT); + } else { + float kstar = FemtoUniverseMath::getkstar(p1, mass1, p2, mass2); + float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + + mixedEventContMM.setPair(p1, p2, multCol, twotracksconfigs.ConfUse3D); + if (cfgProcessMultBins) + mixedEventMultContMM.fill(kstar, multCol, kT); + } + break; } default: @@ -642,14 +734,14 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { } /// process function for to call doMixedEvent with Data - /// @param cols subscribe to the collisions table (Data) - /// @param parts subscribe to the femtoUniverseParticleTable + /// \param cols subscribe to the collisions table (Data) + /// \param parts subscribe to the femtoUniverseParticleTable void processMixedEvent(soa::Filtered& cols, FilteredFemtoFullParticles& parts) { for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); @@ -679,16 +771,16 @@ struct femtoUniversePairTaskTrackTrackMultKtExtended { PROCESS_SWITCH(femtoUniversePairTaskTrackTrackMultKtExtended, 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 + /// \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&) { for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx index f2d9093976e..9ada1b9b973 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackTrackSpherHarMultKtExtended.cxx @@ -15,6 +15,7 @@ /// \author Pritam Chakraborty, WUT Warsaw, pritam.chakraborty@pw.edu.pl #include +#include #include "TRandom2.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -132,8 +133,9 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { /// Event part Configurable ConfV0MLow{"ConfV0MLow", 0.0, "Lower limit for V0M multiplicity"}; Configurable ConfV0MHigh{"ConfV0MHigh", 25000.0, "Upper limit for V0M multiplicity"}; - Filter collV0Mfilter = ((o2::aod::femtouniversecollision::multV0M > ConfV0MLow) && (o2::aod::femtouniversecollision::multV0M < ConfV0MHigh)); + using FilteredFDCollisions = soa::Filtered; + using FilteredFDCollision = soa::Filtered::iterator; // Filter trackAdditionalfilter = (nabs(aod::femtouniverseparticle::eta) < twotracksconfigs.ConfEtaMax); // example filtering on configurable /// Particle part @@ -149,7 +151,7 @@ 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 colBinning{{ConfVtxBins, ConfMultBins}, true}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {60, 0.0, 0.3}, "binning kstar"}; ConfigurableAxis ConfkTBins{"ConfkTBins", {150, 0., 9.}, "binning kT"}; @@ -214,6 +216,8 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { HistogramRegistry SameMultRegistryMM{"SameMultRegistryMM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry MixedMultRegistryMM{"MixedMultRegistryMM", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + TRandom2* randgen; + // 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 { @@ -413,7 +417,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { template void fillCollision(CollisionType col) { - MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multNtr()})); + MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); eventHisto.fillQA(col); } @@ -474,7 +478,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { continue; } float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); - sameEventMultCont.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT); + sameEventMultCont.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT, ConfIsIden); } } else { for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsOne, groupPartsOne))) { @@ -499,33 +503,30 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); - TRandom2* randgen = new TRandom2(0); double rand; + rand = randgen->Rndm(); switch (ContType) { case 2: { - rand = randgen->Rndm(); if (rand > 0.5) { - sameEventMultContPP.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT); + sameEventMultContPP.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT, ConfIsIden); } else if (rand <= 0.5) { - sameEventMultContPP.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::same, 2, multCol, kT); + sameEventMultContPP.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::same, 2, multCol, kT, ConfIsIden); } break; } case 3: { - rand = randgen->Rndm(); if (rand > 0.5) { - sameEventMultContMM.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT); + sameEventMultContMM.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::same, 2, multCol, kT, ConfIsIden); } else if (rand <= 0.5) { - sameEventMultContMM.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::same, 2, multCol, kT); + sameEventMultContMM.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::same, 2, multCol, kT, ConfIsIden); } break; } default: break; } - delete randgen; } } } @@ -533,7 +534,7 @@ 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(soa::Filtered::iterator& col, + void processSameEvent(FilteredFDCollision& col, FilteredFemtoFullParticles& parts) { fillCollision(col); @@ -542,18 +543,20 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { auto thegroupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); bool fillQA = true; + randgen = new TRandom2(0); if (cfgProcessPM) { - doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 1, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 1, fillQA); } if (cfgProcessPP) { - doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multNtr(), 2, fillQA); + doSameEvent(thegroupPartsOne, thegroupPartsOne, parts, col.magField(), col.multV0M(), 2, fillQA); } if (cfgProcessMM) { - doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multNtr(), 3, fillQA); + doSameEvent(thegroupPartsTwo, thegroupPartsTwo, parts, col.magField(), col.multV0M(), 3, fillQA); } + delete randgen; } PROCESS_SWITCH(femtoUniversePairTaskTrackTrackSpherHarMultKtExtended, processSameEvent, "Enable processing same event", true); @@ -603,19 +606,37 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { } float kT = FemtoUniverseMath::getkT(p1, mass1, p2, mass2); + double rand; + rand = randgen->Rndm(); + switch (ContType) { case 1: { - mixedEventMultCont.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT); + if (rand > 0.5) { + mixedEventMultCont.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } else { + mixedEventMultCont.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } break; } + case 2: { - mixedEventMultContPP.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT); + if (rand > 0.5) { + mixedEventMultContPP.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } else { + mixedEventMultContPP.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } break; } + case 3: { - mixedEventMultContMM.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT); + if (rand > 0.5) { + mixedEventMultContMM.fill_mult_NumDen(p1, p2, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } else { + mixedEventMultContMM.fill_mult_NumDen(p2, p1, femtoUniverseSHContainer::EventType::mixed, 2, multCol, kT, ConfIsIden); + } break; } + default: break; } @@ -625,12 +646,14 @@ 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(soa::Filtered& cols, + void processMixedEvent(FilteredFDCollisions& cols, FilteredFemtoFullParticles& parts) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + randgen = new TRandom2(0); + + for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); @@ -656,6 +679,7 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { doMixedEvent(groupPartsOne, groupPartsTwo, parts, magFieldTesla1, multiplicityCol, 3); } } + delete randgen; } /// process function for to fill covariance histograms @@ -688,9 +712,9 @@ struct femtoUniversePairTaskTrackTrackSpherHarMultKtExtended { soa::Join& /*parts*/, o2::aod::FDMCParticles&) { - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, ConfNEventsMix, -1, cols, cols)) { - const int multiplicityCol = collision1.multNtr(); + const int multiplicityCol = collision1.multV0M(); MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinning.getBin({collision1.posZ(), multiplicityCol})); const auto& magFieldTesla1 = collision1.magField(); diff --git a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx index cc000bfeb45..4810c79298d 100644 --- a/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx +++ b/PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackV0Extended.cxx @@ -15,6 +15,8 @@ /// \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" @@ -28,6 +30,9 @@ #include "PWGCF/FemtoUniverse/Core/FemtoUniverseContainer.h" #include "PWGCF/FemtoUniverse/Core/FemtoUniverseDetaDphiStar.h" #include "PWGCF/FemtoUniverse/Core/FemtoUtils.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include +#include using namespace o2; using namespace o2::soa; @@ -35,13 +40,19 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::analysis::femtoUniverse; using namespace o2::aod::pidutils; +using namespace o2::track; struct femtoUniversePairTaskTrackV0Extended { + Service pdgMC; + SliceCache cache; using FemtoFullParticles = soa::Join; Preslice perCol = aod::femtouniverseparticle::fdCollisionId; + using FemtoRecoParticles = soa::Join; + Preslice perColMC = aod::femtouniverseparticle::fdCollisionId; + /// To apply narrow cut Configurable ConfZVertexCut{"ConfZVertexCut", 10.f, "Event sel: Maximum z-Vertex (cm)"}; Configurable ConfEta{"ConfEta", 0.8, "Eta cut for the global track"}; @@ -64,6 +75,8 @@ struct femtoUniversePairTaskTrackV0Extended { /// Partition for particle 1 Partition partsOne = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == ConfChargePart1) && (nabs(aod::femtouniverseparticle::eta) < ConfEta) && (aod::femtouniverseparticle::pt < ConfHPtPart1) && (aod::femtouniverseparticle::pt > ConfLPtPart1); + Partition partsOneMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (nabs(aod::femtouniverseparticle::eta) < ConfEta) && (aod::femtouniverseparticle::pt < ConfHPtPart1) && (aod::femtouniverseparticle::pt > ConfLPtPart1); + Partition partsOneMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kTrack)) && (aod::femtouniverseparticle::sign == ConfChargePart1) && (nabs(aod::femtouniverseparticle::eta) < ConfEta) && (aod::femtouniverseparticle::pt < ConfHPtPart1) && (aod::femtouniverseparticle::pt > ConfLPtPart1); /// Histogramming for particle 1 FemtoUniverseParticleHisto trackHistoPartOnePos; @@ -84,6 +97,8 @@ struct femtoUniversePairTaskTrackV0Extended { /// Partition for particle 2 Partition partsTwo = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) && (aod::femtouniverseparticle::pt < ConfHPtPart2) && (aod::femtouniverseparticle::pt > ConfLPtPart2); + Partition partsTwoMC = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kMCTruthTrack)) && (aod::femtouniverseparticle::pt < ConfHPtPart2) && (aod::femtouniverseparticle::pt > ConfLPtPart2); + Partition partsTwoMCReco = (aod::femtouniverseparticle::partType == uint8_t(aod::femtouniverseparticle::ParticleType::kV0)) && (aod::femtouniverseparticle::pt < ConfHPtPart2) && (aod::femtouniverseparticle::pt > ConfLPtPart2); /// Histogramming for particle 2 FemtoUniverseParticleHisto trackHistoPartTwo; @@ -102,8 +117,9 @@ struct femtoUniversePairTaskTrackV0Extended { /// Correlation part // Configurable ConfTrackChoicePartTwo{"ConfTrackChoicePartTwo", 1, "0:Proton, 1:Pion, 2:Kaon"}; //not used - Configurable ConfIsMC{"ConfIsMC", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; + 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 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"}; ConfigurableAxis ConfkstarBins{"ConfkstarBins", {1500, 0., 6.}, "binning kstar"}; @@ -121,6 +137,9 @@ struct femtoUniversePairTaskTrackV0Extended { 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)"}; + // Efficiency + Configurable ConfLocalEfficiency{"ConfLocalEfficiency", "", "Local path to efficiency .root file"}; + static constexpr UInt_t V0ChildTable[][2] = {{0, 1}, {1, 0}, {1, 1}}; // Table to select the V0 children FemtoUniverseContainer sameEventCont; @@ -132,21 +151,21 @@ struct femtoUniversePairTaskTrackV0Extended { /// Histogram output HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; + 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; bool IsNSigmaCombined(float mom, float nsigmaTPCParticle, float nsigmaTOFParticle) { if (mom <= Confmom) { - if (TMath::Abs(nsigmaTPCParticle) < ConfNsigmaTPCParticle) { - return true; - } else { - return false; - } + return (TMath::Abs(nsigmaTPCParticle) < ConfNsigmaTPCParticle); } else { - if (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < ConfNsigmaCombinedParticle) { - return true; - } else { - return false; - } + return (TMath::Hypot(nsigmaTOFParticle, nsigmaTPCParticle) < ConfNsigmaCombinedParticle); } } @@ -188,10 +207,10 @@ struct femtoUniversePairTaskTrackV0Extended { void init(InitContext&) { eventHisto.init(&qaRegistry); - qaRegistry.add("Tracks_pos/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - qaRegistry.add("Tracks_pos/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - qaRegistry.add("Tracks_neg/nSigmaTPC", "; #it{p} (GeV/#it{c}); n#sigma_{TPC}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); - qaRegistry.add("Tracks_neg/nSigmaTOF", "; #it{p} (GeV/#it{c}); n#sigma_{TOF}", kTH2F, {{100, 0, 10}, {100, -5, 5}}); + 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}}); trackHistoPartOnePos.init(&qaRegistry, ConfTrkTempFitVarpTBins, ConfTrkTempFitVarBins, ConfIsMC, ConfTrkPDGCodePartOne); trackHistoPartOneNeg.init(&qaRegistry, ConfTrkTempFitVarpTBins, ConfTrkTempFitVarBins, ConfIsMC, ConfTrkPDGCodePartOne); trackHistoPartTwo.init(&qaRegistry, ConfV0TempFitVarpTBins, ConfV0TempFitVarBins, ConfIsMC, ConfV0PDGCodePartTwo, true); @@ -205,6 +224,48 @@ 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}}); + + // 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}}}); + registryMCtruth.add("minus/MCtruthLambda", "MC truth Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCtruth.add("plus/MCtruthAllPt", "MC truth all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCtruth.add("minus/MCtruthAllPt", "MC truth all;#it{p}_{T} (GeV/c); #eta", {HistType::kTH1F, {{500, 0, 5}}}); + + registryMCtruth.add("plus/MCtruthPi", "MC truth pions;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCtruth.add("plus/MCtruthPr", "MC truth protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCtruth.add("minus/MCtruthPi", "MC truth pions;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCtruth.add("minus/MCtruthPr", "MC truth protons;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + + registryMCtruth.add("plus/MCtruthPiPt", "MC truth pions;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCtruth.add("plus/MCtruthPrPt", "MC truth protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + 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}}}); + + // 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}}}); + registryMCreco.add("plus/MCrecoLambdaChildPi", "MC reco Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("minus/MCrecoLambda", "MC reco Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("minus/MCrecoLambdaChildPr", "MC reco Lambdas;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + registryMCreco.add("minus/MCrecoLambdaChildPi", "MC reco Lambdas;#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/MCrecoPi", "MC reco pions;#it{p}_{T} (GeV/c); #eta", {HistType::kTH2F, {{500, 0, 5}, {400, -1.0, 1.0}}}); + 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/MCrecoPi", "MC reco pions;#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/MCrecoPiPt", "MC reco pions;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + registryMCreco.add("plus/MCrecoPrPt", "MC reco protons;#it{p}_{T} (GeV/c)", {HistType::kTH1F, {{500, 0, 5}}}); + 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}}}); + 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); @@ -216,15 +277,29 @@ struct femtoUniversePairTaskTrackV0Extended { pairCloseRejection.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiCutMin.value, ConfCPRdeltaPhiCutMax.value, ConfCPRdeltaEtaCutMin.value, ConfCPRdeltaEtaCutMax.value, ConfCPRChosenRadii.value, ConfCPRPlotPerRadii.value); pairCloseRejectionV0.init(&resultRegistry, &qaRegistry, ConfCPRdeltaPhiCutMin.value, ConfCPRdeltaPhiCutMax.value, ConfCPRdeltaEtaCutMin.value, ConfCPRdeltaEtaCutMax.value, ConfCPRChosenRadii.value, ConfCPRPlotPerRadii.value); } + + if (!ConfLocalEfficiency.value.empty()) { + plocalEffFile = std::unique_ptr(TFile::Open(ConfLocalEfficiency.value.c_str(), "read")); + if (!plocalEffFile || plocalEffFile.get()->IsZombie()) + LOGF(fatal, "Could not load efficiency histogram from %s", ConfLocalEfficiency.value.c_str()); + if (doprocessSameEvent || doprocessMixedEvent) { + plocalEffp1 = (ConfChargePart1 > 0) ? std::unique_ptr(plocalEffFile.get()->Get("PrPlus")) : std::unique_ptr(plocalEffFile.get()->Get("PrMinus")); // note: works only for protons for now + plocalEffp2 = (ConfV0Type1 == 0) ? std::unique_ptr(plocalEffFile.get()->Get("Lambda")) : std::unique_ptr(plocalEffFile.get()->Get("AntiLambda")); + LOGF(info, "Loaded efficiency histograms for track-V0."); + } else if (doprocessSameEventV0 || doprocessMixedEventV0) { + plocalEffp1 = (ConfV0Type1 == 0) ? std::unique_ptr(plocalEffFile.get()->Get("Lambda")) : std::unique_ptr(plocalEffFile.get()->Get("AntiLambda")); + plocalEffp2 = (ConfV0Type2 == 0) ? std::unique_ptr(plocalEffFile.get()->Get("Lambda")) : std::unique_ptr(plocalEffFile.get()->Get("AntiLambda")); + LOGF(info, "Loaded efficiency histograms for V0-V0."); + } + } } /// This function processes the same event for track - V0 - void processSameEvent(FilteredFDCollision& col, FemtoFullParticles& parts) + template + void doSameEvent(FilteredFDCollision& col, PartType& parts, PartitionType& groupPartsOne, PartitionType& groupPartsTwo, [[maybe_unused]] MCParticles mcParts = nullptr) { const auto& magFieldTesla = col.magField(); - auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - const int multCol = col.multNtr(); + const int multCol = ConfUseCent ? col.multV0M() : col.multNtr(); eventHisto.fillQA(col); @@ -266,6 +341,9 @@ struct femtoUniversePairTaskTrackV0Extended { // Lambda invariant mass cut if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) continue; + /// PID using stored binned nsigma + if (!IsParticleCombined(p1, ConfTrackChoicePartOne)) + continue; // track cleaning if (!pairCleaner.isCleanPair(p1, p2, parts)) { continue; @@ -275,9 +353,6 @@ struct femtoUniversePairTaskTrackV0Extended { continue; } } - /// PID using stored binned nsigma - if (!IsParticleCombined(p1, ConfTrackChoicePartOne)) - continue; const auto& posChild = parts.iteratorAt(p2.index() - 2); const auto& negChild = parts.iteratorAt(p2.index() - 1); @@ -285,19 +360,39 @@ struct femtoUniversePairTaskTrackV0Extended { if (!IsParticleTPC(posChild, V0ChildTable[ConfV0Type1][0]) || !IsParticleTPC(negChild, V0ChildTable[ConfV0Type1][1])) continue; - sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + float weight = 1.0f; + if (plocalEffp1) + weight = plocalEffp1.get()->GetBinContent(plocalEffp1->FindBin(p1.pt(), p1.eta())) * plocalEffp2.get()->GetBinContent(plocalEffp2->FindBin(p2.pt(), p2.eta())); + if constexpr (std::is_same::value) + sameEventCont.setPair(p1, p2, multCol, ConfUse3D, weight); + else + sameEventCont.setPair(p1, p2, multCol, ConfUse3D, weight); } } + void processSameEvent(FilteredFDCollision& col, FemtoFullParticles& 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& col, FemtoRecoParticles& 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& col, FemtoFullParticles& parts) { const auto& magFieldTesla = col.magField(); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); - const int multCol = col.multNtr(); + const int multCol = ConfUseCent ? col.multV0M() : col.multNtr(); eventHisto.fillQA(col); @@ -322,64 +417,180 @@ struct femtoUniversePairTaskTrackV0Extended { } } - /// Now build the combinations - for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { + auto pairProcessFunc = [&](auto& p1, auto& p2) -> void { // Lambda invariant mass cut for p1 if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) - continue; + return; // Lambda invariant mass cut for p2 if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) - continue; + return; // track cleaning if (!pairCleanerV0.isCleanPair(p1, p2, parts)) { - continue; + return; } if (ConfIsCPR.value) { if (pairCloseRejectionV0.isClosePair(p1, p2, parts, magFieldTesla, femtoUniverseContainer::EventType::same)) { - continue; + return; } } const auto& posChild1 = parts.iteratorAt(p1.index() - 2); const auto& negChild1 = parts.iteratorAt(p1.index() - 1); /// Daughters that do not pass this condition are not selected if (!IsParticleTPC(posChild1, V0ChildTable[ConfV0Type1][0]) || !IsParticleTPC(negChild1, V0ChildTable[ConfV0Type1][1])) - continue; + return; const auto& posChild2 = parts.iteratorAt(p2.index() - 2); const auto& negChild2 = parts.iteratorAt(p2.index() - 1); /// Daughters that do not pass this condition are not selected if (!IsParticleTPC(posChild2, V0ChildTable[ConfV0Type2][0]) || !IsParticleTPC(negChild2, V0ChildTable[ConfV0Type2][1])) - continue; + return; sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + }; + if (ConfV0Type1 == ConfV0Type2) { + /// Now build the combinations for identical V0s + for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairProcessFunc(p1, p2); + } + } else { + /// Now build the combinations for not identical identical V0s + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairProcessFunc(p1, p2); + } } } PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processSameEventV0, "Enable processing same event for V0 - V0", false); - /// This function processes the mixed event for track - V0 - void processMixedEvent(FilteredFDCollisions& cols, FemtoFullParticles& parts) + /// This function processes MC same events for Track - V0 + void processMCSameEvent(FilteredFDCollision& col, FemtoFullParticles& parts) { - ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + const auto& magFieldTesla = col.magField(); - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { + auto groupPartsOne = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + const int multCol = ConfUseCent ? col.multV0M() : col.multNtr(); - const int multCol = collision1.multNtr(); + eventHisto.fillQA(col); - auto groupPartsOne = partsOne->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); - auto groupPartsTwo = partsTwo->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + /// Histogramming same event + for (auto& part : groupPartsTwo) { + int pdgCode = static_cast(part.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode != 3122) || (ConfV0Type1 == 1 && pdgCode != -3122)) + continue; + trackHistoPartTwo.fillQA(part); + } + + for (auto& part : groupPartsOne) { + int pdgCode = static_cast(part.pidcut()); + if (pdgCode != ConfTrkPDGCodePartOne) + continue; + const auto& pdgParticle = pdgMC->GetParticle(pdgCode); + if (!pdgParticle) { + continue; + } + /// PID plot for particle 1 + if (pdgParticle->Charge() > 0.0) { + trackHistoPartOnePos.fillQA(part); + } else if (pdgParticle->Charge() < 0.0) { + trackHistoPartOneNeg.fillQA(part); + } + } + + /// Now build the combinations + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (static_cast(p1.pidcut()) != ConfTrkPDGCodePartOne) + continue; + int pdgCode2 = static_cast(p2.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode2 != 3122) || (ConfV0Type1 == 1 && pdgCode2 != -3122)) + continue; + // track cleaning + if (ConfIsCPR.value) { + if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla, femtoUniverseContainer::EventType::same)) { + continue; + } + } + sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + } + } + + 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& col, FemtoFullParticles& /*parts*/) + { + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, col.globalIndex(), cache); + const int multCol = ConfUseCent ? col.multV0M() : col.multNtr(); + + eventHisto.fillQA(col); + + /// Histogramming same event + for (auto& part : groupPartsTwo) { + int pdgCode = static_cast(part.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode != 3122) || (ConfV0Type1 == 1 && pdgCode != -3122)) + continue; + trackHistoPartTwo.fillQA(part); + } + + auto pairProcessFunc = [&](auto& p1, auto& p2) -> void { + int pdgCode1 = static_cast(p1.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode1 != 3122) || (ConfV0Type1 == 1 && pdgCode1 != -3122)) + return; + int pdgCode2 = static_cast(p2.pidcut()); + if ((ConfV0Type2 == 0 && pdgCode2 != 3122) || (ConfV0Type2 == 1 && pdgCode2 != -3122)) + return; + sameEventCont.setPair(p1, p2, multCol, ConfUse3D); + }; + /// Now build the combinations + if (ConfV0Type1 == ConfV0Type2) { + /// Now build the combinations for identical V0s + for (auto& [p1, p2] : combinations(CombinationsStrictlyUpperIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairProcessFunc(p1, p2); + } + } else { + /// Now build the combinations for not identical identical V0s + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsTwo, groupPartsTwo))) { + pairProcessFunc(p1, p2); + } + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMCSameEventV0, "Enable processing same event for MC truth V0 - V0", false); + + /// This function processes the mixed event for track - V0 + template + void doMixedEvent(FilteredFDCollisions& cols, PartType& parts, PartitionType& partitionOne, PartitionType& partitionTwo, [[maybe_unused]] MCParticles mcParts = nullptr) + { + 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 = partitionOne->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(); if (magFieldTesla1 != magFieldTesla2) { - continue; + return; } for (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; @@ -389,30 +600,50 @@ struct femtoUniversePairTaskTrackV0Extended { 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; + float weight = 1.0f; + if (plocalEffp1) + weight = plocalEffp1.get()->GetBinContent(plocalEffp1->FindBin(p1.pt(), p1.eta())) * plocalEffp2.get()->GetBinContent(plocalEffp2->FindBin(p2.pt(), p2.eta())); + + if constexpr (std::is_same::value) + mixedEventCont.setPair(p1, p2, multCol, ConfUse3D, weight); + else + mixedEventCont.setPair(p1, p2, multCol, ConfUse3D, weight); + } + }; - mixedEventCont.setPair(p1, p2, multCol, ConfUse3D); + if (ConfUseCent) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + } + } else { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); } } } - PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMixedEvent, "Enable processing mixed events for track - V0", false); + void processMixedEvent(FilteredFDCollisions& cols, FemtoFullParticles& parts) + { + doMixedEvent(cols, parts, partsOne, partsTwo); + } + PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMixedEvent, "Enable processing mixed event for track - V0", false); + + void processMixedEventMCReco(FilteredFDCollisions& cols, FemtoRecoParticles& 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& cols, FemtoFullParticles& parts) { - ColumnBinningPolicy colBinning{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinningMult{{ConfVtxBins, ConfMultBins}, true}; + ColumnBinningPolicy colBinningCent{{ConfVtxBins, ConfMultBins}, true}; - for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, 5, -1, cols, cols)) { - - const int multCol = collision1.multNtr(); + 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); @@ -421,25 +652,19 @@ struct femtoUniversePairTaskTrackV0Extended { const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { - continue; + return; } for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { // Lambda invariant mass cut for p1 - if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) + if (!invMLambda(p1.mLambda(), p1.mAntiLambda())) { continue; + } // Lambda invariant mass cut for p2 - if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) - continue; - // track cleaning - if (!pairCleanerV0.isCleanPair(p1, p2, parts)) { + if (!invMLambda(p2.mLambda(), p2.mAntiLambda())) { continue; } - if (ConfIsCPR.value) { - if (pairCloseRejectionV0.isClosePair(p1, p2, parts, magFieldTesla1, femtoUniverseContainer::EventType::mixed)) { - 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 @@ -452,12 +677,236 @@ struct femtoUniversePairTaskTrackV0Extended { 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, femtoUniverseContainer::EventType::mixed)) { + continue; + } + } mixedEventCont.setPair(p1, p2, multCol, ConfUse3D); } + }; + + if (ConfUseCent) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + } + } else { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + } } } - PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMixedEventV0, "Enable processing mixed events for V0 - V0", false); + + /// This function processes MC mixed events for Track - V0 + void processMCMixedEvent(FilteredFDCollisions& cols, FemtoFullParticles& parts) + { + 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 = partsOneMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); + + if (magFieldTesla1 != magFieldTesla2) { + return; + } + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + if (static_cast(p1.pidcut()) != ConfTrkPDGCodePartOne) + continue; + int pdgCode2 = static_cast(p2.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode2 != 3122) || (ConfV0Type1 == 1 && pdgCode2 != -3122)) + continue; + if (ConfIsCPR.value) { + if (pairCloseRejection.isClosePair(p1, p2, parts, magFieldTesla1, femtoUniverseContainer::EventType::mixed)) { + continue; + } + } + mixedEventCont.setPair(p1, p2, multCol, ConfUse3D); + } + }; + + if (ConfUseCent) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + } + } else { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), collision1.multNtr()})); + } + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMCMixedEvent, "Enable processing mixed events for MC truth track - V0", false); + + /// This function processes MC mixed events for V0 - V0 + void processMCMixedEventV0(FilteredFDCollisions& cols, FemtoFullParticles& /*parts*/) + { + 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 = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision1.globalIndex(), cache); + auto groupPartsTwo = partsTwoMC->sliceByCached(aod::femtouniverseparticle::fdCollisionId, collision2.globalIndex(), cache); + + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(groupPartsOne, groupPartsTwo))) { + int pdgCode1 = static_cast(p1.pidcut()); + if ((ConfV0Type1 == 0 && pdgCode1 != 3122) || (ConfV0Type1 == 1 && pdgCode1 != -3122)) + continue; + int pdgCode2 = static_cast(p2.pidcut()); + if ((ConfV0Type2 == 0 && pdgCode2 != 3122) || (ConfV0Type2 == 1 && pdgCode2 != -3122)) + continue; + mixedEventCont.setPair(p1, p2, multCol, ConfUse3D); + } + }; + + if (ConfUseCent) { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningCent, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.fill(HIST("MixingQA/hMECollisionBins"), colBinningCent.getBin({collision1.posZ(), collision1.multV0M()})); + } + } else { + for (auto& [collision1, collision2] : soa::selfCombinations(colBinningMult, 5, -1, cols, cols)) { + mixedCollProcessFunc(collision1, collision2); + MixQaRegistry.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 + void processMCTruth(aod::FDParticles const& parts) + { + for (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 (pdgCode == 3122) { + registryMCtruth.fill(HIST("plus/MCtruthLambda"), part.pt(), part.eta()); + continue; + } else if (pdgCode == -3122) { + registryMCtruth.fill(HIST("minus/MCtruthLambda"), part.pt(), part.eta()); + continue; + } + + if (pdgParticle->Charge() > 0.0) { + registryMCtruth.fill(HIST("plus/MCtruthAllPt"), part.pt()); + } + if (pdgCode == 211) { + registryMCtruth.fill(HIST("plus/MCtruthPi"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("plus/MCtruthPiPt"), part.pt()); + } + if (pdgCode == 2212) { + registryMCtruth.fill(HIST("plus/MCtruthPr"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("plus/MCtruthPrPt"), part.pt()); + } + + if (pdgParticle->Charge() < 0.0) { + registryMCtruth.fill(HIST("minus/MCtruthAllPt"), part.pt()); + } + if (pdgCode == -211) { + registryMCtruth.fill(HIST("minus/MCtruthPi"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("minus/MCtruthPiPt"), part.pt()); + } + if (pdgCode == -2212) { + registryMCtruth.fill(HIST("minus/MCtruthPr"), part.pt(), part.eta()); + registryMCtruth.fill(HIST("minus/MCtruthPrPt"), part.pt()); + } + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMCTruth, "Process MC truth data", false); + + void processMCReco(FemtoRecoParticles const& parts, aod::FDMCParticles const& mcparts) + { + for (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::kV0) { + if (mcpart.pdgMCTruth() == 3122) { + 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 + if (IsParticleTPC(posChild, 0) && IsParticleTPC(negChild, 1)) { + registryMCreco.fill(HIST("plus/MCrecoLambda"), mcpart.pt(), mcpart.eta()); // lambda + if (auto mcpartIdChild = posChild.fdMCParticleId(); mcpartIdChild != -1) { + const auto& mcpartChild = mcparts.iteratorAt(mcpartIdChild); + registryMCreco.fill(HIST("plus/MCrecoLambdaChildPr"), mcpartChild.pt(), mcpartChild.eta()); // lambda proton child + } + if (auto mcpartIdChild = negChild.fdMCParticleId(); mcpartIdChild != -1) { + const auto& mcpartChild = mcparts.iteratorAt(mcpartIdChild); + registryMCreco.fill(HIST("plus/MCrecoLambdaChildPi"), mcpartChild.pt(), mcpartChild.eta()); // lambda pion child + } + } + } else if (mcpart.pdgMCTruth() == -3122) { + 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 + if (IsParticleTPC(posChild, 1) && IsParticleTPC(negChild, 0)) { + registryMCreco.fill(HIST("minus/MCrecoLambda"), mcpart.pt(), mcpart.eta()); // anti-lambda + if (auto mcpartIdChild = posChild.fdMCParticleId(); mcpartIdChild != -1) { + const auto& mcpartChild = mcparts.iteratorAt(mcpartIdChild); + registryMCreco.fill(HIST("minus/MCrecoLambdaChildPi"), mcpartChild.pt(), mcpartChild.eta()); // anti-lambda pion child + } + if (auto mcpartIdChild = negChild.fdMCParticleId(); mcpartIdChild != -1) { + const auto& mcpartChild = mcparts.iteratorAt(mcpartIdChild); + registryMCreco.fill(HIST("minus/MCrecoLambdaChildPr"), mcpartChild.pt(), mcpartChild.eta()); // anti-lambda proton child + } + } + } + } 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()))) { + 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()))) { + registryMCreco.fill(HIST("plus/MCrecoPr"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("plus/MCrecoPrPt"), mcpart.pt()); + } + } + + if (part.sign() < 0) { + registryMCreco.fill(HIST("minus/MCrecoAllPt"), mcpart.pt()); + if (mcpart.pdgMCTruth() == -211 && 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()))) { + registryMCreco.fill(HIST("minus/MCrecoPr"), mcpart.pt(), mcpart.eta()); + registryMCreco.fill(HIST("minus/MCrecoPrPt"), mcpart.pt()); + } + } + } // partType + } + } + + PROCESS_SWITCH(femtoUniversePairTaskTrackV0Extended, processMCReco, "Process MC reco data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/FemtoWorld/Tasks/femtoWorldHashTask.cxx b/PWGCF/FemtoWorld/Tasks/femtoWorldHashTask.cxx index a9c678bc2e5..4a6bdac3a2b 100644 --- a/PWGCF/FemtoWorld/Tasks/femtoWorldHashTask.cxx +++ b/PWGCF/FemtoWorld/Tasks/femtoWorldHashTask.cxx @@ -33,7 +33,7 @@ struct femtoWorldPairHashTask { std::vector CastCfgVtxBins, CastCfgMultBins; - Produces hashes; + Produces hashes; void init(InitContext&) { diff --git a/PWGCF/Flow/TableProducer/CMakeLists.txt b/PWGCF/Flow/TableProducer/CMakeLists.txt index bbfd7adac2b..667fcde6866 100644 --- a/PWGCF/Flow/TableProducer/CMakeLists.txt +++ b/PWGCF/Flow/TableProducer/CMakeLists.txt @@ -8,3 +8,9 @@ # In applying this license CERN does 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(flow-zdc-qvectors + SOURCES ZDCQvectors.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore + COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGCF/Flow/TableProducer/ZDCQvectors.cxx b/PWGCF/Flow/TableProducer/ZDCQvectors.cxx new file mode 100644 index 00000000000..f8cfb02a8a4 --- /dev/null +++ b/PWGCF/Flow/TableProducer/ZDCQvectors.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. + +// In this task the energy calibration and recentring of Q-vectors constructed in the ZDCs will be done + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CCDB/BasicCCDBManager.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/TrackSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/EventSelection.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" + +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "ReconstructionDataFormats/GlobalTrackID.h" +#include "ReconstructionDataFormats/Track.h" +#include "PWGCF/DataModel/SPTableZDC.h" + +#include "TH1F.h" +#include "TH2F.h" +#include "TProfile.h" +#include "TObjArray.h" +#include "TF1.h" +#include "TFitResult.h" +#include "TCanvas.h" +#include "TSystem.h" +#include "TROOT.h" + +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::track; +using namespace o2::aod::evsel; + +// define my..... +using myCollisions = soa::Join; +using BCsRun3 = soa::Join; + +namespace o2::analysis::qvectortask +{ + +int counter = 0; + +// step0 -> Energy calib +std::shared_ptr ZN_Energy[10] = {{nullptr}}; +std::shared_ptr hQx_vs_Qy[6] = {{nullptr}}; + +// and +std::shared_ptr COORD_correlations[6][4] = {{nullptr}}; +std::vector hZN_mean(10, nullptr); // Get from calibration file + +// step1: 4D large bins +std::vector mean_10perCent_v(4, nullptr); // hQXA, hQYA, hQXC, hQYC + +// step2: Small bins 1D +std::vector mean_cent_Run(4, nullptr); // hQXA, hQYA, hQXC, hQYC +std::vector mean_vx_Run(4, nullptr); // hQXA, hQYA, hQXC, hQYC +std::vector mean_vy_Run(4, nullptr); // hQXA, hQYA, hQXC, hQYC +std::vector mean_vz_Run(4, nullptr); // hQXA, hQYA, hQXC, hQYC + +// Define histogrm names here to use same names for creating and later uploading and retrieving data from ccdb +// Energy calibration: +std::vector names_Ecal(10, ""); +std::vector> names(5, std::vector()); //(1x 4d 4x 1d) +std::vector vnames = {"hvertex_vx", "hvertex_vy"}; + +// https://alice-notes.web.cern.ch/system/files/notes/analysis/620/017-May-31-analysis_note-ALICE_analysis_note_v2.pdf +std::vector ZDC_px = {-1.75, 1.75, -1.75, 1.75}; +std::vector ZDC_py = {-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 + +// for energy calibration +std::vector EZN(8); // uncalibrated energy for the 2x4 towers (a1, a2, a3, a4, c1, c2, c3, c4) +std::vector meanEZN(10); // mean energies from calibration histos (common A, t1-4 A,common C, t1-4C) +std::vector e(8, 0.); // calibrated energies (a1, a2, a3, a4, c1, c2, c3, c4)) + +// 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 = false; + +} // namespace o2::analysis::qvectortask + +using namespace o2::analysis::qvectortask; + +struct ZDCqvectors { + + Produces SPtableZDC; + + ConfigurableAxis axisCent{"axisCent", {90, 0, 90}, "Centrality axis in 1% bins"}; + ConfigurableAxis axisCent10{"axisCent10", {9, 0, 90}, "Centrality axis in 10% bins"}; + ConfigurableAxis axisQ{"axisQ", {100, -2, 2}, "Q vector (xy) in ZDC"}; + ConfigurableAxis axisVx_big{"axisVx_big", {3, -0.01, 0.01}, "for Pos X of collision"}; + ConfigurableAxis axisVy_big{"axisVy_big", {3, -0.01, 0.01}, "for Pos Y of collision"}; + ConfigurableAxis axisVz_big{"axisVz_big", {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") + O2_DEFINE_CONFIGURABLE(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried") + O2_DEFINE_CONFIGURABLE(cfgEnergyCal, std::string, "", "ccdb path for energy calibration histos") + O2_DEFINE_CONFIGURABLE(cfgMeanv, std::string, "", "ccdb path for mean v histos") + + Configurable> cfgRec1{"cfgRec1", {"", "", "", "", ""}, "ccdb paths for recentering calibration histos iteration 1"}; + Configurable> cfgRec2{"cfgRec2", {"", "", "", "", ""}, "ccdb paths for recentering calibration histos iteration 2"}; + Configurable> cfgRec3{"cfgRec3", {"", "", "", "", ""}, "ccdb paths for recentering calibration histos iteration 3"}; + Configurable> cfgRec4{"cfgRec4", {"", "", "", "", ""}, "ccdb paths for recentering calibration histos iteration 4"}; + Configurable> cfgRec5{"cfgRec5", {"", "", "", "", ""}, "ccdb paths for recentering calibration histos iteration 5"}; + + // Define output + HistogramRegistry registry{"Registry"}; + + Service ccdb; + + // 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)); + int atStep = 0; + int atIteration = 0; + } cal; + + void init(InitContext const&) + { + 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); + + std::vector sides = {"A", "C"}; + std::vector coords = {"x", "y", "z"}; + std::vector COORDS = {"X", "Y"}; + + // Tower mean energies vs. centrality used for tower gain equalisation + for (int tower = 0; tower < 10; tower++) { + names_Ecal[tower] = TString::Format("hZN%s_mean_t%i_cent", sides[(tower < 5) ? 0 : 1], tower % 5); + ZN_Energy[tower] = registry.add(Form("Energy/%s", names_Ecal[tower].Data()), Form("%s", names_Ecal[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}); + for (const char* side : sides) { + hQx_vs_Qy[step] = registry.add(Form("step%i/hZN%s_Qx_vs_Qy", step, side), Form("hZN%s_Qx_vs_Qy", side), kTH2F, {axisQ, axisQ}); + } + int i = 0; + for (const char* COORD1 : COORDS) { + for (const char* COORD2 : COORDS) { + // Now we get: & vs. Centrality + COORD_correlations[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++; + } + } + + // Add histograms for each step in the calibration process. + // Sides is {A,C} and coords is {X,Y} + for (const char* side : sides) { + for (const char* coord : COORDS) { + 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, axisVx_big, axisVy_big, axisVz_big, 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); + } + } // end of COORDS + } // 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("vmean/hvertex_vx", "hvertex_vx", kTProfile, {{1, 0., 1.}}); + registry.add("vmean/hvertex_vy", "hvertex_vy", 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}}); + } + + inline void fillRegistry(int iteration, int step) + { + 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 (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 (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 (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 (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 (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); + } + } + + inline void fillCommonRegistry(int iteration) + { + // 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 subdir[] = {"step1/", "step2/", "step3/", "step4/", "step5/"}; + static_for<0, 4>([&](auto ind) { + constexpr int index = ind.value; + int index_rt = index + 1; + + registry.fill(HIST(subdir[index]) + HIST("hZNA_Qx_vs_Qy"), q[iteration][index_rt][0], q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("hZNC_Qx_vs_Qy"), q[iteration][index_rt][2], q[iteration][index_rt][3]); + + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_QXC_vs_cent"), centrality, q[iteration][index_rt][0] * q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_QYC_vs_cent"), centrality, q[iteration][index_rt][1] * q[iteration][index_rt][3]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_QXC_vs_cent"), centrality, q[iteration][index_rt][1] * q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_QYC_vs_cent"), centrality, q[iteration][index_rt][0] * q[iteration][index_rt][3]); + + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_vs_cent"), centrality, q[iteration][index_rt][0]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_vs_cent"), centrality, q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQXC_vs_cent"), centrality, q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYC_vs_cent"), centrality, q[iteration][index_rt][3]); + + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_vs_vx"), v[0], q[iteration][index_rt][0]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_vs_vx"), v[0], q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQXC_vs_vx"), v[0], q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYC_vs_vx"), v[0], q[iteration][index_rt][3]); + + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_vs_vy"), v[1], q[iteration][index_rt][0]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_vs_vy"), v[1], q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQXC_vs_vy"), v[1], q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYC_vs_vy"), v[1], q[iteration][index_rt][3]); + + registry.fill(HIST(subdir[index]) + HIST("QA/hQXA_vs_vz"), v[2], q[iteration][index_rt][0]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYA_vs_vz"), v[2], q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQXC_vs_vz"), v[2], q[iteration][index_rt][2]); + registry.fill(HIST(subdir[index]) + HIST("QA/hQYC_vs_vz"), v[2], q[iteration][index_rt][3]); + + // add psi!! + double Psi_A = 1.0 * TMath::ATan2(q[iteration][index_rt][2], q[iteration][index_rt][0]); + registry.fill(HIST(subdir[index]) + HIST("QA/hSPplaneA"), Psi_A, centrality, 1); + double Psi_C = 1.0 * TMath::ATan2(q[iteration][index_rt][3], q[iteration][index_rt][1]); + registry.fill(HIST(subdir[index]) + HIST("QA/hSPplaneC"), Psi_C, centrality, 1); + + }); + } + + void loadCalibrations(int iteration, int step, uint64_t timestamp, std::string ccdb_dir, std::vector names) + { + // 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 iteration %i and step %i", iteration, step + 1); + cal.calibfilesLoaded[iteration][step] = true; + cal.atIteration = iteration; + cal.atStep = step; + return; + } else { + if (counter < 1) + LOGF(info, "<--------X-----------> Calibrations not loaded for iteration %i and step %i cfg = empty!", iteration, step + 1); + } + } + + template + double getCorrection(int iteration, int step, const char* objName) + { + T* hist = nullptr; + double calibConstant{0}; + + hist = reinterpret_cast(cal.calibList[iteration][step]->FindObject(Form("%s", objName))); + if (!hist) { + LOGF(fatal, "%s not available.. Abort..", objName); + } + + if (hist->InheritsFrom("TProfile2D")) { + // needed for energy calibration! + TProfile2D* h = reinterpret_cast(hist); + TString name = h->GetName(); + int binrunnumber = h->GetXaxis()->FindBin(TString::Format("%i", runnumber)); + int bin = h->GetYaxis()->FindBin(centrality); + calibConstant = h->GetBinContent(binrunnumber, bin); + + } else if (hist->InheritsFrom("TProfile")) { + TProfile* h = reinterpret_cast(hist); + TString name = h->GetName(); + int bin; + if (name.Contains("mean_vx")) + bin = h->GetXaxis()->FindBin(v[0]); + if (name.Contains("mean_vy")) + bin = h->GetXaxis()->FindBin(v[1]); + if (name.Contains("mean_vz")) + bin = h->GetXaxis()->FindBin(v[2]); + if (name.Contains("mean_cent")) + bin = h->GetXaxis()->FindBin(centrality); + if (name.Contains("vertex")) + bin = h->GetXaxis()->FindBin(TString::Format("%i", runnumber)); + calibConstant = h->GetBinContent(bin); + } else if (hist->InheritsFrom("THnSparse")) { + std::vector sparsePars; + THnSparseD* h = reinterpret_cast(hist); + if (step == 0 && iteration > 0) { + sparsePars.push_back(h->GetAxis(1)->FindBin(centrality)); + sparsePars.push_back(h->GetAxis(2)->FindBin(v[0])); + sparsePars.push_back(h->GetAxis(3)->FindBin(v[1])); + sparsePars.push_back(h->GetAxis(4)->FindBin(v[2])); + } + for (std::size_t i = 0; i < sparsePars.size(); i++) { + h->GetAxis(i)->SetRange(sparsePars[i], sparsePars[i]); + } + calibConstant = h->Projection(sparsePars.size())->GetMean(); + + if (h->Projection(sparsePars.size())->GetEntries() < 2) { + LOGF(debug, "1 entry in sparse bin! Not used... (increase binsize)"); + calibConstant = 0; + } + } + return calibConstant; + } + + void fillAllRegistries(int iteration, int step) + { + for (int s = 0; s <= step; s++) + fillRegistry(iteration, s); + fillCommonRegistry(iteration); + } + + void process(myCollisions::iterator const& collision, + BCsRun3 const& /*bcs*/, + aod::Zdcs const& /*zdcs*/) + { + // for Q-vector calculation + // A[0] & C[1] + std::vector sumZN(2, 0.); + std::vector xEnZN(2, 0.); + std::vector yEnZN(2, 0.); + + auto cent = collision.centFT0C(); + + if (cent < 0 || cent > 90) { + SPtableZDC(runnumber, cent, v[0], v[1], v[2], 0, 0, 0, 0, false, 0, 0); + lastRunnumber = runnumber; + return; + } + + registry.fill(HIST("QA/centrality_before"), cent); + + const auto& foundBC = collision.foundBC_as(); + + if (!foundBC.has_zdc()) { + SPtableZDC(runnumber, cent, v[0], v[1], v[2], 0, 0, 0, 0, false, 0, 0); + lastRunnumber = runnumber; + return; + } + + v[0] = collision.posX(); + v[1] = collision.posY(); + v[2] = collision.posZ(); + centrality = cent; + runnumber = foundBC.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]; + } + + // load the calibration histos for iteration 0 step 0 (Energy Calibration) + if (runnumber != lastRunnumber) + loadCalibrations(0, 0, foundBC.timestamp(), cfgEnergyCal, names_Ecal); + if (!cal.calibfilesLoaded[0][0]) { + if (counter < 1) { + LOGF(info, " --> No Energy calibration files found.. -> Only Energy calibration will be done. "); + } + } + // load the calibrations for the mean v + if (runnumber != lastRunnumber) + loadCalibrations(0, 1, foundBC.timestamp(), cfgMeanv, 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]); + } + + if (counter < 1) + LOGF(info, "=====================> .....Start Energy Calibration..... <====================="); + + bool isZNAhit = true; + bool isZNChit = true; + + for (int i = 0; i < 8; ++i) { + if (i < 4 && EZN[i] <= 0) + isZNAhit = false; + if (i > 3 && EZN[i] <= 0) + isZNChit = false; + } + + if (zdcCol.energyCommonZNA() <= 0) + isZNAhit = false; + if (zdcCol.energyCommonZNC() <= 0) + 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) + ZN_Energy[tower]->Fill(Form("%d", runnumber), cent, zdcCol.energyCommonZNA(), 1); + if (isZNChit) + ZN_Energy[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) + ZN_Energy[tower]->Fill(Form("%d", runnumber), cent, EZN[tower - 1], 1); + if (isZNChit) + ZN_Energy[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 ZNA or ZNC not hit correctly.. do not use event in q-vector calculation + if (!isZNAhit || !isZNChit) { + counter++; + SPtableZDC(runnumber, centrality, v[0], v[1], v[2], 0, 0, 0, 0, false, 0, 0); + lastRunnumber = runnumber; + return; + } + + if (!cal.calibfilesLoaded[0][0]) { + counter++; + SPtableZDC(runnumber, centrality, v[0], v[1], v[2], 0, 0, 0, 0, false, 0, 0); + lastRunnumber = runnumber; + 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, names_Ecal[tower].Data()); + } + + // Use the calibration constants but now only loop over towers 1-4 + int calibtower = 0; + std::vector towers_nocom = {1, 2, 3, 4, 6, 7, 8, 9}; + + for (int tower : towers_nocom) { + if (meanEZN[tower] > 0) { + double ecommon = (tower > 4) ? meanEZN[5] : meanEZN[0]; + e[calibtower] = EZN[calibtower] * (0.25 * ecommon) / meanEZN[tower]; + } + calibtower++; + } + + for (int i = 0; i < 4; 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]); + } + + // Now calculate Q-vector + for (int tower = 0; tower < 8; tower++) { + int side = (tower > 3) ? 1 : 0; + int sector = tower % 4; + double energy = std::pow(e[tower], alphaZDC); + sumZN[side] += energy; + xEnZN[side] += (side == 0) ? ZDC_px[sector] * energy : -1.0 * ZDC_px[sector] * energy; + yEnZN[side] += ZDC_py[sector] * energy; + } + + // "QXA", "QYA", "QXC", "QYC" + for (int i = 0; i < 2; ++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] + } + } + + 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 (runnumber != lastRunnumber) { + for (int iteration = 1; iteration < 6; iteration++) { + std::vector ccdb_dirs; + if (iteration == 1) + ccdb_dirs = cfgRec1.value; + if (iteration == 2) + ccdb_dirs = cfgRec2.value; + if (iteration == 3) + ccdb_dirs = cfgRec3.value; + if (iteration == 4) + ccdb_dirs = cfgRec4.value; + if (iteration == 5) + ccdb_dirs = cfgRec5.value; + + for (int step = 0; step < 5; step++) { + loadCalibrations(iteration, step, foundBC.timestamp(), (ccdb_dirs)[step], names[step]); + } + } + } + + if (cal.atIteration == 0) { + if (counter < 1) + LOGF(warning, "Calibation files missing!!! Output created with q-vectors right after energy gain eq. !!"); + 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], true, 0, 0); + lastRunnumber = runnumber; + 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); + fillAllRegistries(cal.atIteration, cal.atStep + 1); + registry.fill(HIST("QA/centrality_after"), centrality); + 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], true, cal.atIteration, cal.atStep); + lastRunnumber = runnumber; + counter++; + return; + } + LOGF(warning, "We return without saving table... -> THis is a problem"); + } // end of process +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/CMakeLists.txt b/PWGCF/Flow/Tasks/CMakeLists.txt index bb658dc7398..bb7fd7d4ac4 100644 --- a/PWGCF/Flow/Tasks/CMakeLists.txt +++ b/PWGCF/Flow/Tasks/CMakeLists.txt @@ -14,8 +14,13 @@ o2physics_add_dpl_workflow(flow-pt-efficiency PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(flow-pbpb-task - SOURCES FlowPbPbTask.cxx +o2physics_add_dpl_workflow(flow-task + SOURCES FlowTask.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-runbyrun + SOURCES FlowRunbyRun.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::GFWCore COMPONENT_NAME Analysis) @@ -38,3 +43,8 @@ o2physics_add_dpl_workflow(flow-pbpb-pikp-task SOURCES FlowPbPbpikp.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::GFWCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(flow-gfw-omegaxi + SOURCES flowGFWOmegaXi.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 index 48868e86934..39cddafbd2a 100644 --- a/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx +++ b/PWGCF/Flow/Tasks/FlowGFWPbPb.cxx @@ -13,11 +13,14 @@ #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" @@ -38,6 +41,8 @@ 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}; @@ -57,6 +62,20 @@ struct FlowGFWPbPb { 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"}; @@ -70,11 +89,8 @@ struct FlowGFWPbPb { 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)"}; - - using Colls = soa::Join; // collisions filter - using aodTracks = soa::Filtered>; // tracks filter - 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); + ConfigurableAxis axisDCAz{"axisDCAz", {200, -2, 2}, "DCA_{z} (cm)"}; + ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; // Corrections TH1D* mEfficiency = nullptr; @@ -106,11 +122,28 @@ struct FlowGFWPbPb { 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; @@ -129,12 +162,20 @@ struct FlowGFWPbPb { ccdb->setCreatedNotAfter(nolaterthan.value); // Add some output objects to the histogram registry - registry.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{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, "after additional event cut"); - registry.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(4, "after correction loads"); - registry.add("hPhi", "", {HistType::kTH1D, {axisPhi}}); + 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}}}); @@ -149,10 +190,6 @@ struct FlowGFWPbPb { 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("multITSnoTPC_vs_MultITSTPC_Bef", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multITSonly_vs_MultITSTPC_Bef", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multNTracksITSonly_vs_MultNTracksITSTPC_Bef", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multNTracksTPConly_vs_MultNtracksITSTPC_Bef", " multiplicity TPC only vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); // After cuts registry.add("globalTracks_centT0C_Aft", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); @@ -162,10 +199,13 @@ struct FlowGFWPbPb { 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("multITSnoTPC_vs_MultITSTPC_Aft", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multITSonly_vs_MultITSTPC_Aft", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multNTracksITSonly_vs_MultNTracksITSTPC_Aft", " multiplicity ITS vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); - registry.add("multNTracksTPConly_vs_MultNtracksITSTPC_Aft", " multiplicity TPC only vs multiplicity ITS+TPC", kTH2F, {axisNch, axisNch}); + + // 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}}); @@ -175,6 +215,8 @@ struct FlowGFWPbPb { 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}}); @@ -182,6 +224,8 @@ struct FlowGFWPbPb { 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); @@ -195,6 +239,8 @@ struct FlowGFWPbPb { 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; @@ -223,6 +269,8 @@ struct FlowGFWPbPb { 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) { @@ -345,30 +393,53 @@ struct FlowGFWPbPb { template bool eventSelected(o2::aod::mult::MultNTracksPV, TCollision collision, const int multTrk, const float centrality) { - if (collision.alias_bit(kTVXinTRD)) { - // TRD triggered - return false; + if (cfgTVXinTRD) { + if (collision.alias_bit(kTVXinTRD)) { + // TRD triggered + return false; + } + registry.fill(HIST("hEventCount"), kTVXINTRD); } - 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 (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 (!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 (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 (!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 (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 (!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 (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(); @@ -379,18 +450,20 @@ struct FlowGFWPbPb { auto multNTracksPV = collision.multNTracksPV(); - if (centrality >= 70. || centrality < 0) - return false; if (abs(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 (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())) @@ -433,9 +506,16 @@ struct FlowGFWPbPb { 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"), 0.5); + registry.fill(HIST("hEventCount"), kFILTERED); if (!collision.sel8()) return; @@ -443,6 +523,7 @@ struct FlowGFWPbPb { 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()); @@ -450,47 +531,37 @@ struct FlowGFWPbPb { 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"), 1.5); - - Int_t multITSnoTPC = 0, multITSonly = 0, multITSTPC = 0; - - for (auto& track : tracks) { - - if (track.hasITS() && !track.hasTPC()) - multITSnoTPC++; + registry.fill(HIST("hEventCount"), kSEL8); - if (track.hasITS()) - multITSonly++; + const auto centrality = collision.centFT0C(); - if (track.hasITS() && track.hasTPC()) - multITSTPC++; + if (cfgOccupancy) { + int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) + return; + registry.fill(HIST("hEventCount"), kOCCUPANCY); } - registry.fill(HIST("multITSnoTPC_vs_MultITSTPC_Bef"), multITSTPC, multITSnoTPC); - registry.fill(HIST("multITSonly_vs_MultITSTPC_Bef"), multITSTPC, multITSonly); - registry.fill(HIST("multNTracksITSonly_vs_MultNTracksITSTPC_Bef"), collision.multNTracksITSTPC(), collision.multNTracksITSOnly()); - registry.fill(HIST("multNTracksTPConly_vs_MultNtracksITSTPC_Bef"), collision.multNTracksITSTPC(), collision.multNTracksTPCOnly()); - - const auto cent = collision.centFT0C(); - - if (cfgUseAdditionalEventCut && !eventSelected(o2::aod::mult::MultNTracksPV(), collision, tracks.size(), cent)) + if (cfgUseAdditionalEventCut && !eventSelected(o2::aod::mult::MultNTracksPV(), collision, tracks.size(), centrality)) { return; + } - registry.fill(HIST("hEventCount"), 2.5); + 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"), collision.centFT0C()); - registry.fill(HIST("cent_vs_Nch"), cent, 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"), 3.5); + registry.fill(HIST("hEventCount"), kCENTRALITY); - // fill event QA + // 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()); @@ -499,11 +570,6 @@ struct FlowGFWPbPb { registry.fill(HIST("multV0A_multT0A_Aft"), collision.multFT0A(), collision.multFV0A()); registry.fill(HIST("multT0C_centT0C_Aft"), collision.centFT0C(), collision.multFT0C()); - registry.fill(HIST("multITSnoTPC_vs_MultITSTPC_Aft"), multITSTPC, multITSnoTPC); - registry.fill(HIST("multITSonly_vs_MultITSTPC_Aft"), multITSTPC, multITSonly); - registry.fill(HIST("multNTracksITSonly_vs_MultNTracksITSTPC_Aft"), collision.multAllTracksITSTPC(), collision.multNTracksITSOnly()); - registry.fill(HIST("multNTracksTPConly_vs_MultNtracksITSTPC_Aft"), collision.multAllTracksITSTPC(), collision.multNTracksTPCOnly()); - // track weights float weff = 1, wacc = 1; int Magnetfield = 0; @@ -513,6 +579,10 @@ struct FlowGFWPbPb { Magnetfield = getMagneticField(bc.timestamp()); } + // track loop + int globaltracks_nch{0}; + int itstracks_nch{0}; + for (auto& track : tracks) { if (track.tpcNClsFound() < cfgCutTPCclu) @@ -520,7 +590,7 @@ struct FlowGFWPbPb { if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) continue; if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), centrality, 0); if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) continue; @@ -529,40 +599,62 @@ struct FlowGFWPbPb { 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 (WithinPtRef) - fGFW->Fill(track.eta(), fPtAxis->FindBin(track.pt()) - 1, track.phi(), wacc * weff, 1); + 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"), cent); - FillProfile(corrconfigs.at(1), HIST("c24"), cent); - FillProfile(corrconfigs.at(2), HIST("c26"), cent); - FillProfile(corrconfigs.at(3), HIST("c28"), cent); - FillProfile(corrconfigs.at(4), HIST("c22etagap"), cent); + 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], cent); - FillProfile(corrconfigs.at(1), BootstrapArray[SampleIndex][kc24], cent); - FillProfile(corrconfigs.at(2), BootstrapArray[SampleIndex][kc26], cent); - FillProfile(corrconfigs.at(3), BootstrapArray[SampleIndex][kc28], cent); - FillProfile(corrconfigs.at(4), BootstrapArray[SampleIndex][kc22etagap], cent); + 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), cent, l_Random); + FillFC(corrconfigs.at(l_ind), centrality, l_Random); } } // End of process -}; // End of struct +}; // End of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGCF/Flow/Tasks/FlowPbPbpikp.cxx b/PWGCF/Flow/Tasks/FlowPbPbpikp.cxx index 1483a74fb09..9ad0696091a 100644 --- a/PWGCF/Flow/Tasks/FlowPbPbpikp.cxx +++ b/PWGCF/Flow/Tasks/FlowPbPbpikp.cxx @@ -69,7 +69,7 @@ struct v2ellip { // Confugrable for QA histograms 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"}; + bool onlyTPC = true; // Configurables for track selections Configurable cfgCutPT{"cfgCutPT", 0.2f, "PT cut on daughter track"}; @@ -91,7 +91,6 @@ struct v2ellip { Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; Configurable TVXEvsel{"TVXEvsel", false, "Triggger selection"}; Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable MID{"MID", false, "Misidentification of tracks"}; // Configurable for histograms Configurable nBins{"nBins", 100, "N bins in all histos"}; @@ -101,8 +100,9 @@ struct v2ellip { { // Axes AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm] for plots"}; - AxisSpec axisv2ref = {5, 0, 5, "v2_{ref}"}; + AxisSpec axisv2ref = {10, 0, 10, "v2_{ref}"}; AxisSpec axisv2diff = {14, 0, 14, "v2_{def}"}; + AxisSpec axisphi = {700, 0, 7, "#phi"}; // Histograms // Event selection @@ -111,9 +111,24 @@ struct v2ellip { // v2 tprofiles for reference and differential flow histos.add("profv2ref", "profv2ref", kTProfile, {axisv2ref}); - histos.add("profv2diff_pr", "profv2diff_pr", kTProfile, {axisv2diff}); - histos.add("profv2diff_pi", "profv2diff_pi", kTProfile, {axisv2diff}); - histos.add("profv2diff_k", "profv2diff_k", kTProfile, {axisv2diff}); + histos.add("profv2diff_pr_10_20", "profv2diff_pr_10_20", kTProfile, {axisv2diff}); + histos.add("profv2diff_pi_10_20", "profv2diff_pi_10_20", kTProfile, {axisv2diff}); + histos.add("profv2diff_k_10_20", "profv2diff_k_10_20", kTProfile, {axisv2diff}); + + histos.add("profv2diff_pr_20_30", "profv2diff_pr_20_30", kTProfile, {axisv2diff}); + histos.add("profv2diff_pi_20_30", "profv2diff_pi_20_30", kTProfile, {axisv2diff}); + histos.add("profv2diff_k_20_30", "profv2diff_k_20_30", kTProfile, {axisv2diff}); + + histos.add("profv2diff_pr_30_40", "profv2diff_pr_30_40", kTProfile, {axisv2diff}); + histos.add("profv2diff_pi_30_40", "profv2diff_pi_30_40", kTProfile, {axisv2diff}); + histos.add("profv2diff_k_30_40", "profv2diff_k_30_40", kTProfile, {axisv2diff}); + + histos.add("profv2diff_pr_40_50", "profv2diff_pr_40_50", kTProfile, {axisv2diff}); + histos.add("profv2diff_pi_40_50", "profv2diff_pi_40_50", kTProfile, {axisv2diff}); + histos.add("profv2diff_k_40_50", "profv2diff_k_40_50", kTProfile, {axisv2diff}); + + // histogram for phi distribution + histos.add("hphi", "hphi", kTH1F, {axisphi}); } template @@ -129,6 +144,10 @@ struct v2ellip { template bool selectionPID(const T& candidate, int PID) { + if (candidate.pt() > 0.4) { + onlyTPC = false; + } + if (PID == 0) { if (onlyTOF) { if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOFPi) { @@ -206,86 +225,6 @@ struct v2ellip { return false; } - template - bool MIDselectionPID(const T& candidate, int PID) - { - if (PID == 0) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < 3.0) { - return true; - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < 3.0) { - return true; - } - if (!candidate.hasTOF() && - std::abs(candidate.tpcNSigmaPi()) < 3.0) { - return true; - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaPi()) < 3.0) { - return true; - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < (3.0 * 3.0)) { - return true; - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < 3.0) { - return true; - } - } - } else if (PID == 1) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < 3.0) { - return true; - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < 3.0) { - return true; - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0) { - return true; - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaKa()) < 3.0) { - return true; - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (3.0 * 3.0)) { - return true; - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < 3.0) { - return true; - } - } - } else if (PID == 2) { - if (onlyTOF) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < 3.0) { - return true; - } - } else if (onlyTOFHIT) { - if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < 3.0) { - return true; - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; - } - } else if (onlyTPC) { - if (std::abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; - } - } else { - if (candidate.hasTOF() && (candidate.tofNSigmaPr() * candidate.tofNSigmaPr() + candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr()) < (3.0 * 3.0)) { - return true; - } - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; - } - } - } - return false; - } - // Defining filters for events (event selection) // Processed events will be already fulfilling the event selection // requirements @@ -303,7 +242,7 @@ struct v2ellip { array ptbins = {0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0, 3.5, 4.0, 4.5, 5.0}; - void processSE(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { float sum_sinA = 0.0, sum_cosA = 0.0, sum_sinB = 0.0, sum_cosB = 0.0; @@ -367,113 +306,189 @@ struct v2ellip { auto atrack = Atracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto btrack = Btracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - for (auto track1 : atrack) { - if (!selectionTrack(track1)) { + for (auto track : tracks) { + if (!selectionTrack(track)) { + continue; + } + if (selectionPID(track, 0) || selectionPID(track, 1) || selectionPID(track, 2)) { // If track pion, kaon or proton + histos.fill(HIST("hphi"), track.phi()); + } else { continue; } + } // end of track loop - if (!selectionPID(track1, 0) && !selectionPID(track1, 1) && !selectionPID(track1, 2)) { + for (auto track1 : atrack) { + if (!selectionTrack(track1)) { continue; - } // If track not pion, kaon and proton then discard the track - - if (MID) { - if (MIDselectionPID(track1, 0)) { - continue; - } // misidentified as pion - if (MIDselectionPID(track1, 2)) { - continue; - } // misidentified as proton } sum_sinA += TMath::Sin(2.0 * track1.phi()); // sum of sin components of Q vector sum_cosA += TMath::Cos(2.0 * track1.phi()); // sum of cos components of Q vector multA++; // charged particle multiplicity - // pt loop for component sums of p vector, POI multiplicities pt wise - for (auto pt = 0; pt < 14; pt++) { - sum_sindsA[pt] += TMath::Sin(2 * track1.phi()); - sum_cosdsA[pt] += TMath::Cos(2 * track1.phi()); - - if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 2)) { - pn_sumsinA_pr[pt] += TMath::Sin(2 * track1.phi()); - pn_sumcosA_pr[pt] += TMath::Cos(2 * track1.phi()); - mpA_pr[pt]++; - } else if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 0)) { - pn_sumsinA_pi[pt] += TMath::Sin(2 * track1.phi()); - pn_sumcosA_pi[pt] += TMath::Cos(2 * track1.phi()); - mpA_pi[pt]++; - } else if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 1)) { - pn_sumsinA_k[pt] += TMath::Sin(2 * track1.phi()); - pn_sumcosA_k[pt] += TMath::Cos(2 * track1.phi()); - mpA_k[pt]++; - } else { - continue; - } - } // end of pt loop - } // track loop ends + if (selectionPID(track1, 0) || selectionPID(track1, 1) || selectionPID(track1, 2)) { // If track pion, kaon or proton + // pt loop for component sums of p vector, POI multiplicities pt wise + for (auto pt = 0; pt < 14; pt++) { + sum_sindsA[pt] += TMath::Sin(2 * track1.phi()); + sum_cosdsA[pt] += TMath::Cos(2 * track1.phi()); + + if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 0)) { // for pion + pn_sumsinA_pi[pt] += TMath::Sin(2 * track1.phi()); + pn_sumcosA_pi[pt] += TMath::Cos(2 * track1.phi()); + mpA_pi[pt]++; + } else if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 1)) { // for kaon + pn_sumsinA_k[pt] += TMath::Sin(2 * track1.phi()); + pn_sumcosA_k[pt] += TMath::Cos(2 * track1.phi()); + mpA_k[pt]++; + } else if (track1.pt() > ptbins[pt] && track1.pt() <= ptbins[pt + 1] && selectionPID(track1, 2)) { // for proton + pn_sumsinA_pr[pt] += TMath::Sin(2 * track1.phi()); + pn_sumcosA_pr[pt] += TMath::Cos(2 * track1.phi()); + mpA_pr[pt]++; + } else { + continue; + } + } // end of pt loop + } else { + continue; + } + } // track loop ends for (auto track2 : btrack) { if (!selectionTrack(track2)) { continue; } - if (!selectionPID(track2, 0) && !selectionPID(track2, 1) && !selectionPID(track2, 2)) { + sum_sinB += TMath::Sin(2.0 * track2.phi()); // sum of sin components of Q vector + sum_cosB += TMath::Cos(2.0 * track2.phi()); // sum of cos components of Q vector + multB++; // charged particle multiplicity + + if (selectionPID(track2, 0) || selectionPID(track2, 1) || selectionPID(track2, 2)) { // If track pion, kaon or proton + // pt loop for component sums of p vector, POI multiplicities pt wise + for (auto pt = 0; pt < 14; pt++) { + sum_sindsB[pt] += TMath::Sin(2 * track2.phi()); + sum_cosdsB[pt] += TMath::Cos(2 * track2.phi()); + + if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 0)) { // for pion + pn_sumsinB_pi[pt] += TMath::Sin(2 * track2.phi()); + pn_sumcosB_pi[pt] += TMath::Cos(2 * track2.phi()); + mpB_pi[pt]++; + } else if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 1)) { // for kaon + pn_sumsinB_k[pt] += TMath::Sin(2 * track2.phi()); + pn_sumcosB_k[pt] += TMath::Cos(2 * track2.phi()); + mpB_k[pt]++; + } else if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 2)) { // for proton + pn_sumsinB_pr[pt] += TMath::Sin(2 * track2.phi()); + pn_sumcosB_pr[pt] += TMath::Cos(2 * track2.phi()); + mpB_pr[pt]++; + } else { + continue; + } + } // end of pt loop + } else { continue; - } // If track not pion, kaon and proton then discard the track + } + } // track loop ends - if (MID) { - if (MIDselectionPID(track2, 1)) { - continue; - } // misidentified as kaon + if (10.0 < multiplicity && multiplicity <= 20.0) { + // reference flow + if ((multA * multB) != 0) { + histos.fill(HIST("profv2ref"), 1, ((sum_cosA * sum_cosB + sum_sinA * sum_sinB) / (multA * multB)), multA * multB); } - sum_sinB += TMath::Sin(2.0 * track2.phi()); // sum of sin components of Q vector - sum_cosB += TMath::Cos(2.0 * track2.phi()); // sum of cos components of Q vector - multB++; // charged particle multiplicity + // pt wise differential flow + for (auto pt = 0; pt < 14; pt++) { + if ((mpA_pr[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_pr_10_20"), pt + 1, ((pn_sumcosA_pr[pt] * sum_cosB + pn_sumsinA_pr[pt] * sum_sinB) / (mpA_pr[pt] * multB)), mpA_pr[pt] * multB); + } // for proton + if ((mpA_pi[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_pi_10_20"), pt + 1, ((pn_sumcosA_pi[pt] * sum_cosB + pn_sumsinA_pi[pt] * sum_sinB) / (mpA_pi[pt] * multB)), mpA_pi[pt] * multB); + } // for pion + if ((mpA_k[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_k_10_20"), pt + 1, ((pn_sumcosA_k[pt] * sum_cosB + pn_sumsinA_k[pt] * sum_sinB) / (mpA_k[pt] * multB)), mpA_k[pt] * multB); + } // for kaon + } + } // 10 to 20 percent centrality + + if (20.0 < multiplicity && multiplicity <= 30.0) { + // reference flow + if ((multA * multB) != 0) { + histos.fill(HIST("profv2ref"), 2, ((sum_cosA * sum_cosB + sum_sinA * sum_sinB) / (multA * multB)), multA * multB); + } - // pt loop for component sums of p vector, POI multiplicities pt wise + // pt wise differential flow for (auto pt = 0; pt < 14; pt++) { - sum_sindsB[pt] += TMath::Sin(2 * track2.phi()); - sum_cosdsB[pt] += TMath::Cos(2 * track2.phi()); - - if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 2)) { - pn_sumsinB_pr[pt] += TMath::Sin(2 * track2.phi()); - pn_sumcosB_pr[pt] += TMath::Cos(2 * track2.phi()); - mpB_pr[pt]++; - } else if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 0)) { - pn_sumsinB_pi[pt] += TMath::Sin(2 * track2.phi()); - pn_sumcosB_pi[pt] += TMath::Cos(2 * track2.phi()); - mpB_pi[pt]++; - } else if (track2.pt() > ptbins[pt] && track2.pt() <= ptbins[pt + 1] && selectionPID(track2, 1)) { - pn_sumsinB_k[pt] += TMath::Sin(2 * track2.phi()); - pn_sumcosB_k[pt] += TMath::Cos(2 * track2.phi()); - mpB_k[pt]++; - } else { - continue; - } - } // end of pt loop + if ((mpA_pr[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_pr_20_30"), pt + 1, ((pn_sumcosA_pr[pt] * sum_cosB + pn_sumsinA_pr[pt] * sum_sinB) / (mpA_pr[pt] * multB)), mpA_pr[pt] * multB); + } // for proton + if ((mpA_pi[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_pi_20_30"), pt + 1, ((pn_sumcosA_pi[pt] * sum_cosB + pn_sumsinA_pi[pt] * sum_sinB) / (mpA_pi[pt] * multB)), mpA_pi[pt] * multB); + } // for pion + if ((mpA_k[pt] * multB) != 0) { + histos.fill(HIST("profv2diff_k_20_30"), pt + 1, ((pn_sumcosA_k[pt] * sum_cosB + pn_sumsinA_k[pt] * sum_sinB) / (mpA_k[pt] * multB)), mpA_k[pt] * multB); + } // for kaon + } + } // 20 to 30 percent centrality - } // track loop ends + if (30.0 < multiplicity && multiplicity <= 40.0) { + // reference flow + if ((multA * multB) != 0) { + histos.fill(HIST("profv2ref"), 3, ((sum_cosA * sum_cosB + sum_sinA * sum_sinB) / (multA * multB)), multA * multB); + } - // std::cout<<"MultA: "< +#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/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 + +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 FlowRunbyRun { + + 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(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.5, "Chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "max DCA to vertex z") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, false, "Use Nch for flow observables") + 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"}; + + 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.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"}; + + 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); + + // 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")}; + HistogramRegistry registry{"registry"}; + + // define global variables + GFW* fGFW = new GFW(); + std::vector corrconfigs; + std::vector corrconfigsFC; + TAxis* fPtAxis; + TRandom3* fRndm = new TRandom3(0); + std::vector RunNumbers; // vector of run numbers + std::map>> TH1sList; // map of 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, + hEta, + hVtxZ, + hMult, + hCent, + kCount_TH1Names + }; + enum OutputTProfileNames { + c22 = 0, + c22_gap10, + kCount_TProfileNames + }; + + using aodCollisions = soa::Filtered>; + using aodTracks = soa::Filtered>; + + void init(InitContext const&) + { + ccdb->setURL(url.value); + ccdb->setCaching(true); + ccdb->setCreatedNotAfter(nolaterthan.value); + + // Add output histograms to the registry + RunNumbers = cfgRunNumbers; + for (auto& runNumber : RunNumbers) { + CreateOutputObjectsForRun(runNumber); + } + + o2::framework::AxisSpec axis = axisPt; + int nPtBins = axis.binEdges.size() - 1; + double* PtBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, PtBins); + + // Create FlowContainer + TObjArray* oba = new TObjArray(); + 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, 1); + delete oba; + + fGFW->AddRegion("full", -0.8, 0.8, 1, 1); + fGFW->AddRegion("refN10", -0.8, -0.5, 1, 1); + fGFW->AddRegion("refP10", 0.5, 0.8, 1, 1); + corrconfigs.resize(kCount_TProfileNames); + corrconfigs[c22] = fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE); + corrconfigs[c22_gap10] = fGFW->GetCorrelatorConfig("refN10 {2} refP10 {-2}", "Ch10Gap22", kFALSE); + 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()); + corrconfigsFC.push_back(fGFW->GetCorrelatorConfig(UserDefineGFWCorr.at(i).c_str(), UserDefineGFWName.at(i).c_str(), kFALSE)); + } + } + fGFW->CreateRegions(); + } + + template + void FillProfile(const GFW::CorrConfig& corrconf, std::shared_ptr profile, 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) + profile->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 CreateOutputObjectsForRun(int runNumber) + { + std::vector> histos(kCount_TH1Names); + histos[hPhi] = registry.add(Form("%d/hPhi", 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}}}); + TH1sList.insert(std::make_pair(runNumber, histos)); + + 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}}); + ProfilesList.insert(std::make_pair(runNumber, profiles)); + } + + void process(aodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, aodTracks const& tracks) + { + if (!collision.sel8()) + return; + if (tracks.size() < 1) + return; + // detect run number + auto bc = collision.bc_as(); + int runNumber = bc.runNumber(); + float l_Random = fRndm->Rndm(); + 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 + CreateOutputObjectsForRun(runNumber); + RunNumbers.push_back(runNumber); + } + + if (TH1sList.find(runNumber) == TH1sList.end()) { + LOGF(fatal, "RunNumber %d not found in TH1sList", runNumber); + return; + } + + TH1sList[runNumber][hVtxZ]->Fill(collision.posZ()); + TH1sList[runNumber][hMult]->Fill(tracks.size()); + TH1sList[runNumber][hCent]->Fill(collision.centFT0C()); + + fGFW->Clear(); + const auto cent = collision.centFT0C(); + float weff = 1, wacc = 1; + for (auto& track : tracks) { + TH1sList[runNumber][hPhi]->Fill(track.phi()); + TH1sList[runNumber][hEta]->Fill(track.eta()); + bool WithinPtRef = (cfgCutPtRefMin < track.pt()) && (track.pt() < cfgCutPtRefMax); // within RF pT range + if (WithinPtRef) { + fGFW->Fill(track.eta(), 1, track.phi(), wacc * weff, 1); + } + } + + // Filling TProfile + for (uint i = 0; i < kCount_TProfileNames; ++i) { + FillProfile(corrconfigs[i], ProfilesList[runNumber][i], cent); + } + // Filling Flow Container + for (uint l_ind = 0; l_ind < corrconfigsFC.size(); l_ind++) { + FillFC(corrconfigsFC.at(l_ind), cent, l_Random); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/FlowPbPbTask.cxx b/PWGCF/Flow/Tasks/FlowTask.cxx similarity index 60% rename from PWGCF/Flow/Tasks/FlowPbPbTask.cxx rename to PWGCF/Flow/Tasks/FlowTask.cxx index 9a24b1c243c..0f4d6977855 100644 --- a/PWGCF/Flow/Tasks/FlowPbPbTask.cxx +++ b/PWGCF/Flow/Tasks/FlowTask.cxx @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/ASoAHelpers.h" @@ -24,6 +27,7 @@ #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" @@ -45,28 +49,48 @@ using namespace o2::framework::expressions; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; -struct FlowPbPbTask { +struct FlowTask { 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(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.5, "Chi2 per TPC clusters") + 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(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(cfgRejectionTPCsectorOverlap, bool, true, "rejection for TPC sector overlap") 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(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(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(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(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(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") + 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 axisVertex{"axisVertex", {40, -20, 20}, "vertex axis for histograms"}; ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; @@ -74,7 +98,7 @@ struct FlowPbPbTask { 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 axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality 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)"}; @@ -84,7 +108,7 @@ struct FlowPbPbTask { ConfigurableAxis axisDCAxy{"axisDCAxy", {200, -1, 1}, "DCA_{xy} (cm)"}; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); + 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; @@ -127,9 +151,11 @@ struct FlowPbPbTask { using aodCollisions = soa::Filtered>; using aodTracks = soa::Filtered>; - // Additional Event selection cuts - Copy from flowGenericFramework.cxx + // 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; @@ -149,26 +175,28 @@ struct FlowPbPbTask { 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 strict Pile-up cut"); + 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("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("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("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("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}}); + if (!cfgUseSmallMemory) { + 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("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("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}}); + } // Track QA registry.add("hPhi", "#phi distribution", {HistType::kTH1D, {axisPhi}}); registry.add("hPhiWeighted", "corrected #phi distribution", {HistType::kTH1D, {axisPhi}}); @@ -178,30 +206,33 @@ struct FlowPbPbTask { 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("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("hTrackCorrection2d", "Correlation table for number of tracks table; uncorrected track; corrected track", {HistType::kTH2D, {axisNch, axisNch}}); - // additional Output histograms - registry.add("hMeanPt", "", {HistType::kTProfile, {axisCentrality}}); - registry.add("hMeanPtWithinGap08", "", {HistType::kTProfile, {axisCentrality}}); - registry.add("c22_gap08_Weff", "", {HistType::kTProfile, {axisCentrality}}); - registry.add("c22_gap08_trackMeanPt", "", {HistType::kTProfile, {axisCentrality}}); - registry.add("PtVariance_partA_WithinGap08", "", {HistType::kTProfile, {axisCentrality}}); - registry.add("PtVariance_partB_WithinGap08", "", {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][kMeanPt_InGap08] = registry.add(Form("BootstrapContainer_%d/hMeanPtWithinGap08", i), "", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kC22_Gap08_Weff] = registry.add(Form("BootstrapContainer_%d/c22_gap08_Weff", i), "", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kC22_Gap08_MeanPt] = registry.add(Form("BootstrapContainer_%d/c22_gap08_trackMeanPt", i), "", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kPtVarParA_InGap08] = registry.add(Form("BootstrapContainer_%d/PtVariance_partA_WithinGap08", i), "", {HistType::kTProfile, {axisCentrality}}); - BootstrapArray[i][kPtVarParB_InGap08] = registry.add(Form("BootstrapContainer_%d/PtVariance_partB_WithinGap08", i), "", {HistType::kTProfile, {axisCentrality}}); + 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}}); + } } o2::framework::AxisSpec axis = axisPt; @@ -217,25 +248,36 @@ struct FlowPbPbTask { // add in FlowContainer to Get boostrap sample automatically TObjArray* oba = new TObjArray(); oba->Add(new TNamed("ChGap22", "ChGap22")); - for (Int_t i = 0; i < fPtAxis->GetNbins(); i++) - oba->Add(new TNamed(Form("ChGap22_pt_%i", i + 1), "ChGap22_pTDiff")); 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 (Int_t i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull22_pt_%i", i + 1), "ChFull22_pTDiff")); + for (Int_t i = 0; i < fPtAxis->GetNbins(); i++) + oba->Add(new TNamed(Form("ChFull24_pt_%i", i + 1), "ChFull24_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 (Int_t 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 (Int_t 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 (Int_t 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")); @@ -249,13 +291,24 @@ struct FlowPbPbTask { oba->Add(new TNamed("Ch10Gap3232", "Ch10Gap3232")); oba->Add(new TNamed("Ch10Gap4242", "Ch10Gap4242")); oba->Add(new TNamed("Ch10Gap24", "Ch10Gap24")); + 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, axisCentrality, cfgNbootstrap); + 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 @@ -264,10 +317,19 @@ struct FlowPbPbTask { 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("refP", 0.4, 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, 4); + fGFW->AddRegion("olN10", -0.8, -0.5, 1, 4); + fGFW->AddRegion("olfull", -0.8, 0.8, 1, 4); corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {2 -2}", "ChFull22", kFALSE)); corrconfigs.push_back(fGFW->GetCorrelatorConfig("full {3 -3}", "ChFull32", kFALSE)); @@ -278,16 +340,23 @@ struct FlowPbPbTask { 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("poiN refN | olN {2} refP {-2}", "ChGap22", kTRUE)); + 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("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)); @@ -301,6 +370,18 @@ struct FlowPbPbTask { 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)); + 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) { @@ -320,10 +401,19 @@ struct FlowPbPbTask { fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); } - if (cfgUseAdditionalTrackCut) { + if (cfgRejectionTPCsectorOverlap) { 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 (cfgTrkSelRun3ITSMatch) { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSall7Layers, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } else { + myTrackSel = getGlobalTrackSelectionRun3ITSMatch(TrackSelection::GlobalTrackRun3ITSMatching::Run3ITSibAny, TrackSelection::GlobalTrackRun3DCAxyCut::Default); + } + 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 @@ -443,59 +533,42 @@ struct FlowPbPbTask { template bool eventSelected(TCollision collision, const int multTrk, const float centrality) { - if (collision.alias_bit(kTVXinTRD)) { + if (cfgTriggerkTVXinTRD && collision.alias_bit(kTVXinTRD)) { // TRD triggered return 0; } - if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - // reject collisions close to Time Frame borders - // https://its.cern.ch/jira/browse/O2-4623 - return 0; - } - 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 0; - } - if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + 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 (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + 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 (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + if (cfgEvSelkNoCollInTimeRangeStandard && !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 (abs(vtxz) > cfgCutVertex) - 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; - if (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh) + if (cfgEvSelOccupancy && (occupancy < cfgCutOccupancyLow || occupancy > cfgCutOccupancyHigh)) return 0; + 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; + } + // V0A T0A 5 sigma cut - if (abs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A())) + if (cfgEvSelV0AT0ACut && (fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > 5 * fT0AV0ASigma->Eval(collision.multFT0A()))) return 0; return 1; @@ -516,7 +589,20 @@ struct FlowPbPbTask { } template - bool trackSelected(TTrack track, const int field) + bool trackSelected(TTrack track) + { + if (cfgCutDCAzPtDepEnabled && (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 @@ -559,16 +645,24 @@ struct FlowPbPbTask { return; if (tracks.size() < 1) return; - 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"), 1.5); - // place holder for pile-up rejection + auto bc = collision.bc_as(); + int currentRunNumber = bc.runNumber(); + for (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()); + } const auto cent = collision.centFT0C(); if (cfgUseAdditionalEventCut && !eventSelected(collision, tracks.size(), cent)) return; @@ -579,24 +673,27 @@ struct FlowPbPbTask { registry.fill(HIST("hMult"), tracks.size()); registry.fill(HIST("hCent"), collision.centFT0C()); fGFW->Clear(); - auto bc = collision.bc_as(); - 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 - return; - gCurrentHadronicRate->Fill(seconds, hadronicRate); + 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 + return; + gCurrentHadronicRate->Fill(seconds, hadronicRate); + } loadCorrections(bc.timestamp()); registry.fill(HIST("hEventCount"), 4.5); // fill event QA - 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()); + 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()); + } // track weights float weff = 1, wacc = 1; @@ -606,23 +703,32 @@ struct FlowPbPbTask { double sum_ptSquare_wSquare_WithinGap08 = 0., sum_pt_wSquare_WithinGap08 = 0.; int Magnetfield = 0; double NTracksCorrected = 0; - if (cfgUseAdditionalTrackCut) { + if (cfgRejectionTPCsectorOverlap) { // magnet field dependence cut Magnetfield = getMagneticField(bc.timestamp()); } + float independent = cent; + if (cfgUseNch) + independent = static_cast(tracks.size()); for (auto& track : tracks) { - if (track.tpcNClsFound() < cfgCutTPCclu) + if (!trackSelected(track)) continue; - if (cfgUseAdditionalTrackCut && !trackSelected(track, Magnetfield)) - continue; - if (cfgOutputNUAWeights) - fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); - if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + if (cfgRejectionTPCsectorOverlap && !RejectionTPCoverlap(track, Magnetfield)) continue; bool WithinPtPOI = (cfgCutPtPOIMin < track.pt()) && (track.pt() < cfgCutPtPOIMax); // within POI pT range - bool WithinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF 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); + } else { + fWeights->Fill(track.phi(), track.eta(), vtxz, track.pt(), cent, 0); + } + } + if (!setCurrentParticleWeights(weff, wacc, track.phi(), track.eta(), track.pt(), vtxz)) + continue; registry.fill(HIST("hPt"), track.pt()); if (WithinPtRef) { registry.fill(HIST("hPhi"), track.phi()); @@ -630,6 +736,7 @@ struct FlowPbPbTask { 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("hnTPCCrossedRow"), track.tpcNClsCrossedRows()); registry.fill(HIST("hDCAz"), track.dcaZ()); @@ -654,45 +761,47 @@ struct FlowPbPbTask { } registry.fill(HIST("hTrackCorrection2d"), tracks.size(), NTracksCorrected); - double WeffEvent_diff_WithGap08 = weffEvent_WithinGap08 * weffEvent_WithinGap08 - weffEventSquare_WithinGap08; - // Filling TProfile - // MeanPt - if (weffEvent > 1e-6) - registry.fill(HIST("hMeanPt"), cent, ptSum / weffEvent, weffEvent); - if (weffEvent_WithinGap08 > 1e-6) - registry.fill(HIST("hMeanPtWithinGap08"), cent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08); - // v22-Pt - // c22_gap8 * pt_withGap8 - if (weffEvent_WithinGap08 > 1e-6) - FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, HIST("c22_gap08_Weff"), HIST("c22_gap08_trackMeanPt"), cent); - // PtVariance - if (WeffEvent_diff_WithGap08 > 1e-6) { - registry.fill(HIST("PtVariance_partA_WithinGap08"), cent, - (ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, - WeffEvent_diff_WithGap08); - registry.fill(HIST("PtVariance_partB_WithinGap08"), cent, - (weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, - WeffEvent_diff_WithGap08); - } - - // Filling Bootstrap Samples - int SampleIndex = static_cast(cfgNbootstrap * l_Random); - if (weffEvent_WithinGap08 > 1e-6) - BootstrapArray[SampleIndex][kMeanPt_InGap08]->Fill(cent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08); - if (weffEvent_WithinGap08 > 1e-6) - FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, BootstrapArray[SampleIndex][kC22_Gap08_Weff], BootstrapArray[SampleIndex][kC22_Gap08_MeanPt], cent); - if (WeffEvent_diff_WithGap08 > 1e-6) { - BootstrapArray[SampleIndex][kPtVarParA_InGap08]->Fill(cent, - (ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, - WeffEvent_diff_WithGap08); - BootstrapArray[SampleIndex][kPtVarParB_InGap08]->Fill(cent, - (weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, - WeffEvent_diff_WithGap08); + if (!cfgUseSmallMemory) { + double WeffEvent_diff_WithGap08 = weffEvent_WithinGap08 * weffEvent_WithinGap08 - weffEventSquare_WithinGap08; + // Filling TProfile + // MeanPt + if (weffEvent > 1e-6) + registry.fill(HIST("hMeanPt"), independent, ptSum / weffEvent, weffEvent); + if (weffEvent_WithinGap08 > 1e-6) + registry.fill(HIST("hMeanPtWithinGap08"), independent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08); + // v22-Pt + // c22_gap8 * pt_withGap8 + if (weffEvent_WithinGap08 > 1e-6) + FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, HIST("c22_gap08_Weff"), HIST("c22_gap08_trackMeanPt"), independent); + // PtVariance + if (WeffEvent_diff_WithGap08 > 1e-6) { + registry.fill(HIST("PtVariance_partA_WithinGap08"), independent, + (ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, + WeffEvent_diff_WithGap08); + registry.fill(HIST("PtVariance_partB_WithinGap08"), independent, + (weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, + WeffEvent_diff_WithGap08); + } + + // Filling Bootstrap Samples + int SampleIndex = static_cast(cfgNbootstrap * l_Random); + if (weffEvent_WithinGap08 > 1e-6) + BootstrapArray[SampleIndex][kMeanPt_InGap08]->Fill(independent, ptSum_Gap08 / weffEvent_WithinGap08, weffEvent_WithinGap08); + if (weffEvent_WithinGap08 > 1e-6) + FillpTvnProfile(corrconfigs.at(7), ptSum_Gap08, weffEvent_WithinGap08, BootstrapArray[SampleIndex][kC22_Gap08_Weff], BootstrapArray[SampleIndex][kC22_Gap08_MeanPt], independent); + if (WeffEvent_diff_WithGap08 > 1e-6) { + BootstrapArray[SampleIndex][kPtVarParA_InGap08]->Fill(independent, + (ptSum_Gap08 * ptSum_Gap08 - sum_ptSquare_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, + WeffEvent_diff_WithGap08); + BootstrapArray[SampleIndex][kPtVarParB_InGap08]->Fill(independent, + (weffEvent_WithinGap08 * ptSum_Gap08 - sum_pt_wSquare_WithinGap08) / WeffEvent_diff_WithGap08, + WeffEvent_diff_WithGap08); + } } // Filling Flow Container for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - FillFC(corrconfigs.at(l_ind), cent, l_Random); + FillFC(corrconfigs.at(l_ind), independent, l_Random); } } }; @@ -700,5 +809,5 @@ struct FlowPbPbTask { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc)}; } diff --git a/PWGCF/Flow/Tasks/FlowZDCtask.cxx b/PWGCF/Flow/Tasks/FlowZDCtask.cxx index 641ef3cb1e5..7efdeff3d05 100644 --- a/PWGCF/Flow/Tasks/FlowZDCtask.cxx +++ b/PWGCF/Flow/Tasks/FlowZDCtask.cxx @@ -36,7 +36,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod::mult; -using ColEvSels = soa::Join; +using ColEvSels = soa::Join; using aodCollisions = soa::Filtered>; using aodTracks = soa::Filtered>; using BCsRun3 = soa::Join; @@ -70,16 +70,19 @@ struct FlowZDCtask { 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", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "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 @@ -102,6 +105,12 @@ struct FlowZDCtask { 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 @@ -120,11 +129,10 @@ struct FlowZDCtask { const AxisSpec axisQZNA{100, -1, 1, "Q"}; const AxisSpec axisREQ{100, -1, 1, "real Q"}; const AxisSpec axisIMQ{100, -1, 1, "imag Q"}; - const AxisSpec axisEnergy{100, 0, 50, "energy"}; 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, 100.f, "centrality"}; + AxisSpec axisCent{8, 0.f, 105.f, "centrality"}; AxisSpec axisMult{1000, -0.5f, 1500.5f, "multiplicity"}; AxisSpec axisMultTPC{1000, -0.5f, 1999.5f, "TPCmultiplicity"}; AxisSpec axisCentBins{{0, 5., 10., 20., 30., 40., 50., 60., 70., 80.}, "centrality percentile"}; @@ -152,6 +160,16 @@ struct FlowZDCtask { 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}); @@ -179,6 +197,19 @@ struct FlowZDCtask { 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}}); } } @@ -228,18 +259,47 @@ struct FlowZDCtask { void processZdcCollAssoc( ColEvSels const& cols, BCsRun3 const& /*bcs*/, - aod::Zdcs const& /*zdcs*/) + 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()); @@ -254,23 +314,48 @@ struct FlowZDCtask { 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; // Initialize qZNA_real - double qZNA_im = 0.0; // Initialize - double qZNC_real = 0.0; // Initialize qZNC_real - double qZNC_im = 0.0; // Initialize + 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) { - // energy for current sector for ZNA and ZNC float energyZNA = zdcread.energySectorZNA()[sector]; float energyZNC = zdcread.energySectorZNC()[sector]; - // Calculate q-vector from current sector and add it to the total q-vector 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); } @@ -313,6 +398,7 @@ struct FlowZDCtask { } } } + PROCESS_SWITCH(FlowZDCtask, processZdcCollAssoc, "Processing ZDC w. collision association", true); PROCESS_SWITCH(FlowZDCtask, processQVector, "Process before recentering", true); diff --git a/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx new file mode 100644 index 00000000000..fba1baa6069 --- /dev/null +++ b/PWGCF/Flow/Tasks/flowGFWOmegaXi.cxx @@ -0,0 +1,727 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "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; + +#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(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_dcav0topv, 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(cfgcheckDauTPC, bool, false, "check if daughter tracks have TPC match") + O2_DEFINE_CONFIGURABLE(cfgCasc_rapidity, float, 0.5, "rapidity") + O2_DEFINE_CONFIGURABLE(cfgNSigmaCascPion, float, 3, "NSigmaCascPion") + O2_DEFINE_CONFIGURABLE(cfgNSigmaCascProton, float, 3, "NSigmaCascProton") + O2_DEFINE_CONFIGURABLE(cfgNSigmaCascKaon, 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"); + + // 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}}); + // 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 + // with (-0.5, 0.5) eta gap + fGFW->AddRegion("refN10", -0.8, -0.4, 1, 1); + fGFW->AddRegion("refP10", 0.4, 0.8, 1, 1); + fGFW->AddRegion("refN10dpt", -0.8, -0.4, nPtBins, 1); + fGFW->AddRegion("refP10dpt", 0.4, 0.8, nPtBins, 1); + fGFW->AddRegion("reffulldpt", -0.8, 0.8, nPtBins, 1); + fGFW->AddRegion("refoldpt", -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("refP10dpt {2} refN10dpt {-2}", "Ref10Gap22dpt", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("reffulldpt reffulldpt {2 2 -2 -2}", "Ref10Gap24dpt", 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("poiOmegaPdpt 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("poiK0sPdpt 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("poiLambdaPdpt reffull {2 2 -2 -2}", "Xi10Gap24a", kTRUE)); + corrconfigs.push_back(fGFW->GetCorrelatorConfig("refP10 {2} refN10 {-2}", "Ref10Gap22", 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); + } + } + + 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; + } + + 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 (TMath::Abs(val) < 1) { + registry.fill(tarName, fPtAxis->GetBinCenter(ptbin), cent, val, dnx); + } + return; + } + + 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 (TMath::Abs(val) < 1) { + registry.fill(tarName, 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; + } + 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 (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; + + // V0A T0A 5 sigma cut + if (abs(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 (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; + if (v0.qtarm() / TMath::Abs(v0.alpha()) > cfgv0_ArmPodocut && TMath::Abs(v0posdau.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(v0negdau.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(v0posdau.tofNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(v0negdau.tofNSigmaPi()) < cfgNSigmaCascPion) { + 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; + } else if (TMath::Abs(v0posdau.tpcNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(v0negdau.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(v0posdau.tofNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(v0negdau.tofNSigmaPi()) < cfgNSigmaCascPion) { + 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; + } + // track quality check + if (v0posdau.tpcNClsFound() < cfgtpcclusters) + continue; + if (v0negdau.tpcNClsFound() < cfgtpcclusters) + 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 (PDGCode == kK0Short) { + if (TMath::Abs(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 (TMath::Abs(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 && TMath::Abs(casc.yOmega()) < cfgCasc_rapidity && TMath::Abs(bachelor.tpcNSigmaKa()) < cfgNSigmaCascKaon && TMath::Abs(posdau.tpcNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(negdau.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(bachelor.tofNSigmaKa()) < cfgNSigmaCascKaon && TMath::Abs(posdau.tofNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(negdau.tofNSigmaPi()) < cfgNSigmaCascPion) { + 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 && TMath::Abs(casc.yXi()) < cfgCasc_rapidity && TMath::Abs(bachelor.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(posdau.tpcNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(negdau.tpcNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(bachelor.tofNSigmaPi()) < cfgNSigmaCascPion && TMath::Abs(posdau.tofNSigmaPr()) < cfgNSigmaCascProton && TMath::Abs(negdau.tofNSigmaPi()) < cfgNSigmaCascPion) { + 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 (TMath::Abs(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(14), HIST("c22"), cent); + FillProfile(corrconfigs.at(15), HIST("c24"), cent); + FillProfile(corrconfigs.at(16), HIST("K0sc22"), cent); + FillProfile(corrconfigs.at(17), HIST("K0sc22"), cent); + FillProfile(corrconfigs.at(18), HIST("Lambdac22"), cent); + FillProfile(corrconfigs.at(19), HIST("Lambdac22"), cent); + for (int i = 1; i <= nPtBins; i++) { + FillProfilepT(corrconfigs.at(0), HIST("c22dpt"), i, cent); + FillProfilepT(corrconfigs.at(1), HIST("c24dpt"), i, cent); + } + for (int i = 1; i <= nV0PtBins; i++) { + FillProfilepTMass(corrconfigs.at(8), HIST("K0sc22dpt"), i, kK0Short, cent); + FillProfilepTMass(corrconfigs.at(9), HIST("K0sc22dpt"), i, kK0Short, cent); + FillProfilepTMass(corrconfigs.at(10), HIST("K0sc24dpt"), i, kK0Short, cent); + FillProfilepTMass(corrconfigs.at(11), HIST("Lambdac22dpt"), i, kLambda0, cent); + FillProfilepTMass(corrconfigs.at(12), HIST("Lambdac22dpt"), i, kLambda0, cent); + FillProfilepTMass(corrconfigs.at(13), HIST("Lambdac24dpt"), i, kLambda0, cent); + } + for (int i = 1; i <= nXiPtBins; i++) { + FillProfilepTMass(corrconfigs.at(2), HIST("Xic22dpt"), i, kXiMinus, cent); + FillProfilepTMass(corrconfigs.at(3), HIST("Xic22dpt"), i, kXiMinus, cent); + FillProfilepTMass(corrconfigs.at(4), HIST("Xic24dpt"), i, kXiMinus, cent); + FillProfilepTMass(corrconfigs.at(5), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + FillProfilepTMass(corrconfigs.at(6), HIST("Omegac22dpt"), i, kOmegaMinus, cent); + FillProfilepTMass(corrconfigs.at(7), HIST("Omegac24dpt"), i, kOmegaMinus, cent); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/Flow/Tasks/flowPtEfficiency.cxx b/PWGCF/Flow/Tasks/flowPtEfficiency.cxx index 43a6eff399d..874f0c3d2df 100644 --- a/PWGCF/Flow/Tasks/flowPtEfficiency.cxx +++ b/PWGCF/Flow/Tasks/flowPtEfficiency.cxx @@ -14,11 +14,15 @@ /// \author everyone #include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/EventSelection.h" #include "Framework/ASoAHelpers.h" #include "Framework/HistogramRegistry.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" using namespace o2; using namespace o2::framework; @@ -32,18 +36,38 @@ struct flowPtEfficiency { 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(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(cfgCutTPCcrossedrows, float, 70.0f, "minimum TPC crossed rows") O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 0.2f, "DCAxy cut for tracks") + 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(cfgSelRunNumberEnabled, bool, false, "switch of run number selection") + 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"}; // Filter the tracks - Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (nabs(aod::track::dcaXY) < cfgCutDCAxy); + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtMin) && (aod::track::pt < cfgCutPtMax) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); using myTracks = soa::Filtered>; + // Filter for collisions + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; + 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; + // Filter for MCcollisions + Filter mccollisionFilter = nabs(aod::mccollision::posZ) < cfgCutVertex; + using myMcCollisions = soa::Filtered; + + // Additional filters for tracks + TrackSelection myTrackSel; + // Define the output HistogramRegistry registry{"registry"}; @@ -71,13 +95,46 @@ struct flowPtEfficiency { registry.add("mcEventCounter", "Monte Carlo Truth EventCounter", kTH1F, {axisCounter}); registry.add("hPtMCGen", "Monte Carlo Truth", {HistType::kTH1D, {axisPt}}); + + 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); + } + myTrackSel.SetMinNClustersTPC(cfgCutTPCclu); + myTrackSel.SetMinNCrossedRowsTPC(cfgCutTPCcrossedrows); + if (!cfgCutDCAzPtDepEnabled) + myTrackSel.SetMaxDcaZ(cfgCutDCAz); } - void processReco(o2::aod::Collision const&, myTracks const& tracks, aod::McParticles const&) + template + bool trackSelected(TTrack track) + { + 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&) { registry.fill(HIST("eventCounter"), 0.5); + if (!collision.sel8()) + return; + if (tracks.size() < 1) + return; + if (cfgSelRunNumberEnabled) { + auto bc = collision.bc_as(); + int RunNumber = bc.runNumber(); + if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), RunNumber)) + return; + } for (const auto& track : tracks) { - if (track.tpcNClsCrossedRows() < 70) + if (!trackSelected(track)) continue; if (track.has_mcParticle()) { auto mcParticle = track.mcParticle(); @@ -89,8 +146,14 @@ struct flowPtEfficiency { } PROCESS_SWITCH(flowPtEfficiency, processReco, "process reconstructed information", true); - void processSim(aod::McCollision const&, soa::SmallGroups> const& collisions, myMcParticles const& mcParticles) + void processSim(myMcCollisions::iterator const& collision, aod::BCsWithTimestamps const&, soa::SmallGroups> const& collisions, myMcParticles const& mcParticles) { + if (cfgSelRunNumberEnabled) { + auto bc = collision.bc_as(); + int RunNumber = bc.runNumber(); + if (!std::count(cfgRunNumberList.value.begin(), cfgRunNumberList.value.end(), RunNumber)) + return; + } if (collisions.size() > -1) { registry.fill(HIST("mcEventCounter"), 0.5); for (const auto& mcParticle : mcParticles) { diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx index d7b6b8dd114..239107ce0ad 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.cxx +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.cxx @@ -20,8 +20,13 @@ FlowPtContainer::FlowPtContainer() : TNamed("name", "name"), mpar(0), fillCounter(0), fEventWeight(kEventWeight::kUnity), + fUseCentralMoments(true), + fUseGap(false), + sumP(), corrNum(), - corrDen() {} + corrDen(), + cmVal(), + cmDen() {} FlowPtContainer::~FlowPtContainer() { delete fCMTermList; @@ -36,36 +41,29 @@ FlowPtContainer::FlowPtContainer(const char* name) : TNamed(name, name), mpar(0), fillCounter(0), fEventWeight(kEventWeight::kUnity), + fUseCentralMoments(true), + fUseGap(false), + sumP(), corrNum(), - corrDen() {} -FlowPtContainer::FlowPtContainer(const char* name, const char* title, int nbinsx, double* xbins, const int& m, const GFWCorrConfigs& configs) : TNamed(name, title), - fCMTermList(0), - fCorrList(0), - fCovList(0), - fCumulantList(0), - fCentralMomentList(0), - mpar(m), - fillCounter(0), - fEventWeight(kEventWeight::kUnity), - corrNum(), - corrDen() -{ - Initialise(nbinsx, xbins, m, configs); -}; -FlowPtContainer::FlowPtContainer(const char* name, const char* title, int nbinsx, double xlow, double xhigh, const int& m, const GFWCorrConfigs& configs) : TNamed(name, title), - fCMTermList(0), - fCorrList(0), - fCovList(0), - fCumulantList(0), - fCentralMomentList(0), - mpar(m), - fillCounter(0), - fEventWeight(kEventWeight::kUnity), - corrNum(), - corrDen() -{ - Initialise(nbinsx, xlow, xhigh, m, configs); -}; + corrDen(), + cmVal(), + cmDen() {} +FlowPtContainer::FlowPtContainer(const char* name, const char* title) : TNamed(name, title), + fCMTermList(0), + fCorrList(0), + fCovList(0), + fCumulantList(0), + fCentralMomentList(0), + mpar(0), + fillCounter(0), + fEventWeight(kEventWeight::kUnity), + fUseCentralMoments(true), + fUseGap(false), + sumP(), + corrNum(), + corrDen(), + cmVal(), + cmDen() {} void FlowPtContainer::Initialise(const o2::framework::AxisSpec axis, const int& m, const GFWCorrConfigs& configs, const int& nsub) { if (!mpar) @@ -90,19 +88,51 @@ void FlowPtContainer::Initialise(const o2::framework::AxisSpec axis, const int& delete fCovList; fCovList = new TList(); fCovList->SetOwner(kTRUE); - for (int m = 0; m < mpar; ++m) - fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("corr_%ipar", m + 1), nMultiBins, &multiBins[0])); + for (int m = 0; m < mpar; ++m) { + fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nMultiBins, &multiBins[0])); + } for (int m = 0; m < 4; ++m) { - for (int i = 0; i <= m; ++i) + for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nMultiBins, &multiBins[0])); + } } - for (int i = 0; i < configs.GetSize(); ++i) { - for (auto m(1); m <= mpar; ++m) { - if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) - continue; - fCovList->Add(new BootstrapProfile(Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m), Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m), nMultiBins, &multiBins[0])); + if (fUseGap) { + for (int i = 0; i < configs.GetSize(); ++i) { + for (auto m(1); m <= mpar; ++m) { + if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) + continue; + if (fUseCentralMoments) { + for (auto j = 0; j <= m; ++j) { + fCovList->Add(new BootstrapProfile(Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), nMultiBins, &multiBins[0])); + } + } else { + fCovList->Add(new BootstrapProfile(Form("%spt%i", configs.GetHeads()[i].c_str(), m), Form("%spt%i", configs.GetHeads()[i].c_str(), m), nMultiBins, &multiBins[0])); + } + } + } + } else { + if (fUseCentralMoments) { + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt0", "ChFull24pt2_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt1", "ChFull24pt2_Mpt1", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt2", "ChFull24pt2_Mpt2", nMultiBins, &multiBins[0])); + + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt0", "ChFull24pt1_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt1", "ChFull24pt1_Mpt1", nMultiBins, &multiBins[0])); + + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt0", "ChFull22pt2_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt1", "ChFull22pt2_Mpt1", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt2", "ChFull22pt2_Mpt2", nMultiBins, &multiBins[0])); + + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nMultiBins, &multiBins[0])); + } else { + fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt2", "ChFull22pt2", nMultiBins, &multiBins[0])); + fCovList->Add(new BootstrapProfile("ChFull22pt1", "ChFull22pt1", nMultiBins, &multiBins[0])); } } + if (nsub) { for (int i = 0; i < fCorrList->GetEntries(); ++i) dynamic_cast(fCorrList->At(i))->InitializeSubsamples(nsub); @@ -126,17 +156,48 @@ void FlowPtContainer::Initialise(int nbinsx, double* xbins, const int& m, const delete fCorrList; fCorrList = new TList(); fCorrList->SetOwner(kTRUE); - for (int m = 0; m < mpar; ++m) + for (int m = 0; m < mpar; ++m) { fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xbins)); + } for (int m = 0; m < 4; ++m) { - for (int i = 0; i <= m; ++i) + for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xbins)); + } } - for (int i = 0; i < configs.GetSize(); ++i) { - for (auto m(1); m <= mpar; ++m) { - if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) - continue; - fCovList->Add(new BootstrapProfile(Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m + 1), Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m + 1), nbinsx, xbins)); + if (fUseGap) { + for (int i = 0; i < configs.GetSize(); ++i) { + for (auto m(1); m <= mpar; ++m) { + if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) + continue; + if (fUseCentralMoments) { + for (auto j = 0; j <= m; ++j) { + fCovList->Add(new BootstrapProfile(Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), nbinsx, xbins)); + } + } else { + fCovList->Add(new BootstrapProfile(Form("%spt%i", configs.GetHeads()[i].c_str(), m), Form("%spt%i", configs.GetHeads()[i].c_str(), m), nbinsx, xbins)); + } + } + } + } else { + if (fUseCentralMoments) { + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt0", "ChFull24pt2_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt1", "ChFull24pt2_Mpt1", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt2", "ChFull24pt2_Mpt2", nbinsx, xbins)); + + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt0", "ChFull24pt1_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt1", "ChFull24pt1_Mpt1", nbinsx, xbins)); + + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt0", "ChFull22pt2_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt1", "ChFull22pt2_Mpt1", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt2", "ChFull22pt2_Mpt2", nbinsx, xbins)); + + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nbinsx, xbins)); + } else { + fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt2", "ChFull22pt2", nbinsx, xbins)); + fCovList->Add(new BootstrapProfile("ChFull22pt1", "ChFull22pt1", nbinsx, xbins)); } } if (nsub) { @@ -161,17 +222,48 @@ void FlowPtContainer::Initialise(int nbinsx, double xlow, double xhigh, const in delete fCorrList; fCorrList = new TList(); fCorrList->SetOwner(kTRUE); - for (int m = 0; m < mpar; ++m) + for (int m = 0; m < mpar; ++m) { fCorrList->Add(new BootstrapProfile(Form("mpt%i", m + 1), Form("mpt%i", m + 1), nbinsx, xlow, xhigh)); + } for (int m = 0; m < 4; ++m) { - for (int i = 0; i <= m; ++i) + for (int i = 0; i <= m; ++i) { fCMTermList->Add(new BootstrapProfile(Form("cm%i_Mpt%i", m + 1, i), Form("cm%i_Mpt%i", m + 1, i), nbinsx, xlow, xhigh)); + } } - for (int i = 0; i < configs.GetSize(); ++i) { - for (auto m(1); m <= mpar; ++m) { - if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) - continue; - fCovList->Add(new BootstrapProfile(Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m + 1), Form("%s_mpt%i", configs.GetHeads()[i].c_str(), m + 1), nbinsx, xlow, xhigh)); + if (fUseGap) { + for (int i = 0; i < configs.GetSize(); ++i) { + for (auto m(1); m <= mpar; ++m) { + if (!(configs.GetpTCorrMasks()[i] & (1 << (m - 1)))) + continue; + if (fUseCentralMoments) { + for (auto j = 0; j <= m; ++j) { + fCovList->Add(new BootstrapProfile(Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), Form("%spt%i_Mpt%i", configs.GetHeads()[i].c_str(), m, j), nbinsx, xlow, xhigh)); + } + } else { + fCovList->Add(new BootstrapProfile(Form("%spt%i", configs.GetHeads()[i].c_str(), m), Form("%spt%i", configs.GetHeads()[i].c_str(), m), nbinsx, xlow, xhigh)); + } + } + } + } else { + if (fUseCentralMoments) { + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt0", "ChFull24pt2_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt1", "ChFull24pt2_Mpt1", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull24pt2_Mpt2", "ChFull24pt2_Mpt2", nbinsx, xlow, xhigh)); + + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt0", "ChFull24pt1_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull24pt1_Mpt1", "ChFull24pt1_Mpt1", nbinsx, xlow, xhigh)); + + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt0", "ChFull22pt2_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt1", "ChFull22pt2_Mpt1", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt2_Mpt2", "ChFull22pt2_Mpt2", nbinsx, xlow, xhigh)); + + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt0", "ChFull22pt1_Mpt0", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt1_Mpt1", "ChFull22pt1_Mpt1", nbinsx, xlow, xhigh)); + } else { + fCovList->Add(new BootstrapProfile("ChFull24pt2", "ChFull24pt2", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull24pt1", "ChFull24pt1", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt2", "ChFull22pt2", nbinsx, xlow, xhigh)); + fCovList->Add(new BootstrapProfile("ChFull22pt1", "ChFull22pt1", nbinsx, xlow, xhigh)); } } if (nsub) { @@ -186,7 +278,7 @@ void FlowPtContainer::Initialise(int nbinsx, double xlow, double xhigh, const in }; void FlowPtContainer::Fill(const double& w, const double& pt) { - for (auto i = 0; i < sumP.size(); ++i) { + for (size_t i = 0; i < sumP.size(); ++i) { sumP[i] += pow(w, i % (mpar + 1)) * pow(pt, i / (mpar + 1)); } return; @@ -221,61 +313,451 @@ void FlowPtContainer::CalculateCorrelations() void FlowPtContainer::FillPtProfiles(const double& centmult, const double& rn) { for (int m = 1; m <= mpar; ++m) { - if (corrDen[m] != 0) + if (corrDen[m] != 0) { dynamic_cast(fCorrList->At(m - 1))->FillProfile(centmult, corrNum[m] / corrDen[m], (fEventWeight == kEventWeight::kUnity) ? 1.0 : corrDen[m], rn); + } } return; } -void FlowPtContainer::FillVnPtProfiles(const double& centmult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask) +void FlowPtContainer::FillVnPtCorrProfiles(const double& centmult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask) { - if (!mask) + if (!mask) { return; + } for (auto m(1); m <= mpar; ++m) { - if (!(mask & (1 << (m - 1)))) + if (!(mask & (1 << (m - 1)))) { continue; - if (corrDen[m] != 0) + } + if (corrDen[m] != 0) { dynamic_cast(fCovList->At(fillCounter))->FillProfile(centmult, flowval * corrNum[m] / corrDen[m], (fEventWeight == kUnity) ? 1.0 : flowtuples * corrDen[m], rn); + } ++fillCounter; } return; } +void FlowPtContainer::FillVnDeltaPtProfiles(const double& centmult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask) +{ + if (!mask) { + return; + } + for (auto m(1); m <= mpar; ++m) { + if (!(mask & (1 << (m - 1)))) + 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 == kUnity) ? 1.0 : flowtuples * cmDen[m], rn); + } + ++fillCounter; + } + } + return; +} +void FlowPtContainer::FillVnPtCorrStdProfiles(const double& centmult, const double& rn) +{ + double wAABBCC = getStdAABBCC(warr); + if (wAABBCC != 0) + dynamic_cast(fCovList->At(0))->FillProfile(centmult, getStdAABBCC(arr) / wAABBCC, (fEventWeight == kUnity) ? 1.0 : wAABBCC, rn); + double wAABBC = getStdAABBC(warr); + if (wAABBC != 0) + dynamic_cast(fCovList->At(1))->FillProfile(centmult, getStdAABBCC(arr) / wAABBC, (fEventWeight == kUnity) ? 1.0 : wAABBC, rn); + double wABCC = getStdAABBC(warr); + if (wABCC != 0) + dynamic_cast(fCovList->At(2))->FillProfile(centmult, getStdABCC(arr) / wABCC, (fEventWeight == kUnity) ? 1.0 : wABCC, rn); + double wABC = getStdABC(warr); + if (wABC != 0) + dynamic_cast(fCovList->At(3))->FillProfile(centmult, getStdABC(arr) / wABC, (fEventWeight == kUnity) ? 1.0 : wABC, rn); + return; +} +void FlowPtContainer::FillVnDeltaPtStdProfiles(const double& centmult, const double& rn) +{ + double wAABBCC = getStdAABBCC(warr); + if (wAABBCC != 0) + dynamic_cast(fCovList->At(0))->FillProfile(centmult, getStdAABBCC(arr) / wAABBCC, (fEventWeight == kUnity) ? 1.0 : wAABBCC, rn); + double wAABBCD = getStdAABBCD(warr); + if (wAABBCD != 0) + dynamic_cast(fCovList->At(1))->FillProfile(centmult, getStdAABBCD(arr) / wAABBCD, (fEventWeight == kUnity) ? 1.0 : wAABBCD, rn); + double wAABBDD = getStdAABBDD(warr); + if (wAABBDD != 0) + dynamic_cast(fCovList->At(2))->FillProfile(centmult, getStdAABBDD(arr) / wAABBDD, (fEventWeight == kUnity) ? 1.0 : wAABBDD, rn); + + double wAABBC = getStdAABBC(warr); + if (wAABBC != 0) + dynamic_cast(fCovList->At(3))->FillProfile(centmult, getStdAABBC(arr) / wAABBC, (fEventWeight == kUnity) ? 1.0 : wAABBC, rn); + double wAABBD = getStdAABBD(warr); + if (wAABBD != 0) + dynamic_cast(fCovList->At(4))->FillProfile(centmult, getStdAABBD(arr) / wAABBD, (fEventWeight == kUnity) ? 1.0 : wAABBD, rn); + + double wABCC = getStdABCC(warr); + if (wABCC != 0) + dynamic_cast(fCovList->At(5))->FillProfile(centmult, getStdABCC(arr) / wABCC, (fEventWeight == kUnity) ? 1.0 : wABCC, rn); + double wABCD = getStdABCD(warr); + if (wABCD != 0) + dynamic_cast(fCovList->At(6))->FillProfile(centmult, getStdABCD(arr) / wABCD, (fEventWeight == kUnity) ? 1.0 : wABCD, rn); + double wABDD = getStdABDD(warr); + if (wABDD != 0) + dynamic_cast(fCovList->At(7))->FillProfile(centmult, getStdABDD(arr) / wABDD, (fEventWeight == kUnity) ? 1.0 : wABDD, rn); + + double wABC = getStdABC(warr); + if (wABC != 0) + dynamic_cast(fCovList->At(8))->FillProfile(centmult, getStdABC(arr) / wABC, (fEventWeight == kUnity) ? 1.0 : wABC, rn); + double wABD = getStdABD(warr); + if (wABD != 0) + dynamic_cast(fCovList->At(9))->FillProfile(centmult, getStdABD(arr) / wABD, (fEventWeight == kUnity) ? 1.0 : wABD, rn); + return; +} void FlowPtContainer::FillCMProfiles(const double& centmult, const double& rn) { if (sumP[GetVectorIndex(0, 0)] == 0) return; - double tau1 = sumP[GetVectorIndex(2, 0)] / pow(sumP[GetVectorIndex(1, 0)], 2); - double tau2 = sumP[GetVectorIndex(3, 0)] / pow(sumP[GetVectorIndex(1, 0)], 3); - double tau3 = sumP[GetVectorIndex(4, 0)] / pow(sumP[GetVectorIndex(1, 0)], 4); - // double tau4 = sumP[GetVectorIndex(5,0)]/pow(sumP[GetVectorIndex(1,0)],5); - double weight1 = 1 - tau1; - double weight2 = 1 - 3 * tau1 + 2 * tau2; - double weight3 = 1 - 6 * tau1 + 3 * tau1 * tau1 + 8 * tau2 - 6 * tau3; - // double weight4 = 1 - 10*tau1 + 15*tau1*tau1 + 20*tau2 - 20*tau1*tau2 - 30*tau3 + 24*tau4; - if (mpar < 1 || sumP[GetVectorIndex(1, 0)] == 0) + // 0th order correlation + cmDen.push_back(1.); + cmVal.push_back(1.); + + cmDen.push_back(sumP[GetVectorIndex(1, 0)]); + cmDen.push_back(sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] - sumP[GetVectorIndex(2, 0)]); + cmDen.push_back(sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] - 3 * sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 0)] + 2 * sumP[GetVectorIndex(3, 0)]); + cmDen.push_back(sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] - 6 * sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 0)] + 8 * sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(3, 0)] + 3 * sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(2, 0)] - 6 * sumP[GetVectorIndex(4, 0)]); + if (mpar < 1 || cmDen[1] == 0) return; - dynamic_cast(fCMTermList->At(0))->FillProfile(centmult, sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)], (fEventWeight == kEventWeight::kUnity) ? 1.0 : sumP[GetVectorIndex(1, 0)], rn); - if (mpar < 2 || sumP[GetVectorIndex(2, 0)] == 0 || weight1 == 0) + cmVal.push_back(sumP[GetVectorIndex(1, 1)] / cmDen[1]); + dynamic_cast(fCMTermList->At(0))->FillProfile(centmult, cmVal[1], (fEventWeight == kEventWeight::kUnity) ? 1.0 : cmDen[0], rn); + if (mpar < 2 || sumP[GetVectorIndex(2, 0)] == 0 || cmDen[2] == 0) return; - dynamic_cast(fCMTermList->At(1))->FillProfile(centmult, 1 / weight1 * (sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight1, rn); - dynamic_cast(fCMTermList->At(2))->FillProfile(centmult, 1 / weight1 * (-2 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 2 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight1, rn); - if (mpar < 3 || sumP[GetVectorIndex(3, 0)] == 0 || weight2 == 0) + 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 == kEventWeight::kUnity) ? 1.0 : cmDen[1], 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 == kEventWeight::kUnity) ? 1.0 : cmDen[1], rn); + if (mpar < 3 || sumP[GetVectorIndex(3, 0)] == 0 || cmDen[3] == 0) return; - dynamic_cast(fCMTermList->At(3))->FillProfile(centmult, 1 / weight2 * (sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 3 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 2 * tau2 * sumP[GetVectorIndex(3, 3)] / sumP[GetVectorIndex(3, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight2, rn); - dynamic_cast(fCMTermList->At(4))->FillProfile(centmult, 1 / weight2 * (-3 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 3 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] + 6 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau2 * sumP[GetVectorIndex(3, 2)] / sumP[GetVectorIndex(3, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight2, rn); - dynamic_cast(fCMTermList->At(5))->FillProfile(centmult, 1 / weight2 * (3 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] - 3 * tau1 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 6 * tau2 * sumP[GetVectorIndex(3, 1)] / sumP[GetVectorIndex(3, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight2, rn); - if (mpar < 4 || sumP[GetVectorIndex(4, 0)] == 0 || weight3 == 0) + 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 == kEventWeight::kUnity) ? 1.0 : cmDen[2], 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 == kEventWeight::kUnity) ? 1.0 : cmDen[2], 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 == kEventWeight::kUnity) ? 1.0 : cmDen[2], rn); + if (mpar < 4 || sumP[GetVectorIndex(4, 0)] == 0 || cmDen[4] == 0) return; - dynamic_cast(fCMTermList->At(6))->FillProfile(centmult, 1 / weight3 * (sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 3 * tau1 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] + 8 * tau2 * sumP[GetVectorIndex(3, 3)] / sumP[GetVectorIndex(3, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau3 * sumP[GetVectorIndex(4, 4)] / sumP[GetVectorIndex(4, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight3, rn); - dynamic_cast(fCMTermList->At(7))->FillProfile(centmult, 1 / weight3 * (-4 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 12 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 12 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 12 * tau1 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] - 8 * tau2 * sumP[GetVectorIndex(3, 3)] / sumP[GetVectorIndex(3, 0)] - 24 * tau2 * sumP[GetVectorIndex(3, 2)] / sumP[GetVectorIndex(3, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 24 * tau3 * sumP[GetVectorIndex(4, 3)] / sumP[GetVectorIndex(4, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight3, rn); - dynamic_cast(fCMTermList->At(8))->FillProfile(centmult, 1 / weight3 * (6 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] - 24 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 6 * tau1 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 6 * tau1 * tau1 * sumP[GetVectorIndex(2, 2)] / sumP[GetVectorIndex(2, 0)] + 12 * tau1 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] + 24 * tau2 * sumP[GetVectorIndex(3, 2)] / sumP[GetVectorIndex(3, 0)] + 24 * tau2 * sumP[GetVectorIndex(3, 1)] / sumP[GetVectorIndex(3, 0)] * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 36 * tau3 * sumP[GetVectorIndex(4, 2)] / sumP[GetVectorIndex(4, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight3, rn); - dynamic_cast(fCMTermList->At(9))->FillProfile(centmult, 1 / weight3 * (-4 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 12 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] + 12 * tau1 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] - 12 * tau1 * tau1 * sumP[GetVectorIndex(2, 1)] / sumP[GetVectorIndex(2, 0)] - 24 * tau2 * sumP[GetVectorIndex(3, 1)] / sumP[GetVectorIndex(3, 0)] - 8 * tau2 * sumP[GetVectorIndex(1, 1)] / sumP[GetVectorIndex(1, 0)] + 24 * tau3 * sumP[GetVectorIndex(4, 1)] / sumP[GetVectorIndex(4, 0)]), (fEventWeight == kEventWeight::kUnity) ? 1.0 : weight3, rn); + 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 == kEventWeight::kUnity) ? 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 == kEventWeight::kUnity) ? 1.0 : cmDen[3], 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 == kEventWeight::kUnity) ? 1.0 : cmDen[3], 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 == kEventWeight::kUnity) ? 1.0 : cmDen[3], rn); + return; +} +void FlowPtContainer::FillArray(FillType a, FillType b, double c, double d) +{ + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + for (int k = 0; k < 3; ++k) { + for (int l = 0; l < 3; ++l) { + if (std::holds_alternative>(a) && std::holds_alternative>(b)) { + arr[i][j][k][l] += pow(std::get<0>(a), i) * pow(std::get<0>(b), j) * pow(c, k) * pow(d, l); + } else if (std::holds_alternative(a) && std::holds_alternative(b)) { + warr[i][j][k][l] += pow(std::get<1>(a), i) * pow(std::get<1>(b), j) * pow(c, k) * pow(d, l); + } else { + LOGF(error, "FillType variant should hold same type for a and b during single function c"); + } + } + } + } + } return; } +void FlowPtContainer::ClearArray() +{ + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + for (int k = 0; k < 3; ++k) { + for (int l = 0; l < 3; ++l) { + arr[i][j][k][l] = {0.0, 0.0}; + warr[i][j][k][l] = 0.0; + } + } + } + } + + return; +} +template +double FlowPtContainer::getStdAABBCC(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex aa = inarr[2][0][0][0]; + std::complex bb = inarr[0][2][0][0]; + std::complex cc = inarr[0][0][2][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex bc = inarr[0][1][1][0]; + std::complex aab = inarr[2][1][0][0]; + std::complex aac = inarr[2][0][1][0]; + std::complex abb = inarr[1][2][0][0]; + std::complex acc = inarr[1][0][2][0]; + std::complex abc = inarr[1][1][1][0]; + std::complex bbc = inarr[0][2][1][0]; + std::complex bcc = inarr[0][1][2][0]; + std::complex aabb = inarr[2][2][0][0]; + std::complex aacc = inarr[2][0][2][0]; + std::complex aabc = inarr[2][1][1][0]; + std::complex abbc = inarr[1][2][1][0]; + std::complex abcc = inarr[1][1][2][0]; + std::complex bbcc = inarr[0][2][2][0]; + std::complex aabbc = inarr[2][2][1][0]; + std::complex aabcc = inarr[2][1][2][0]; + std::complex abbcc = inarr[0][0][0][0]; + std::complex aabbcc = inarr[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 + + 4. * a * abb * c * c + 4. * a * acc * b * b + 4. * a * a * bbc * c + 4. * a * a * b * bcc + + 16. * a * abc * b * c + aa * bb * c * c + aa * b * b * cc + a * a * bb * cc + 2. * ab * ab * c * c + + 2. * ac * ac * b * b + 2. * a * a * bc * bc + 4. * aa * b * bc * c + 4. * a * ac * bb * c + + 4. * a * ab * b * cc + 8. * ab * ac * b * c + 8. * a * ab * bc * c + 8. * a * ac * b * bc - 6. * aabb * c * c - + 24. * aabc * b * c - 6. * aacc * b * b - 24. * abbc * a * c - 24. * abcc * a * b - 6. * bbcc * a * a - + 8. * aab * bc * c - 8. * aac * b * bc - 4. * aac * bb * c - 4. * aab * b * cc - 8. * abb * ac * c - + 4. * abb * a * cc - 8. * acc * ab * b - 4. * acc * a * bb - 8. * bbc * a * ac - 4. * bbc * aa * c - + 8. * bcc * a * ab - 4. * bcc * aa * b - 16. * abc * ab * c - 16. * abc * ac * b - 16. * abc * a * bc - + aa * bb * cc - 2. * ab * ab * cc - 2. * ac * ac * bb - 2. * bc * bc * aa - 8. * ab * ac * bc + + 48. * aabbc * c + 48. * aabcc * b + 48. * abbcc * a + 6. * aabb * cc + 6. * aacc * bb + + 6. * bbcc * aa + 24. * aabc * bc + 24. * abbc * ac + 24. * abcc * ab + 8. * aab * bcc + + 8. * aac * bbc + 8. * abb * acc + 16. * abc * abc - 120. * aabbcc) + .real(); +} +template +double FlowPtContainer::getStdAABBCD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex d = inarr[0][0][0][1]; + std::complex aa = inarr[2][0][0][0]; + std::complex bb = inarr[0][2][0][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex ad = inarr[1][0][0][1]; + std::complex bc = inarr[0][1][1][0]; + std::complex bd = inarr[0][1][0][1]; + std::complex cd = inarr[0][0][1][1]; + std::complex aab = inarr[2][1][0][0]; + std::complex aac = inarr[2][0][1][0]; + std::complex aad = inarr[2][0][0][1]; + std::complex abb = inarr[1][2][0][0]; + std::complex abc = inarr[1][1][1][0]; + std::complex abd = inarr[1][1][0][1]; + std::complex acd = inarr[1][0][1][1]; + std::complex bbc = inarr[0][2][1][0]; + std::complex bbd = inarr[0][2][0][1]; + std::complex bcd = inarr[0][1][1][1]; + std::complex aabb = inarr[2][2][0][0]; + std::complex aabc = inarr[2][1][1][0]; + std::complex aabd = inarr[2][1][0][1]; + std::complex aacd = inarr[2][0][1][1]; + std::complex abbc = inarr[1][2][1][0]; + std::complex abbd = inarr[1][2][0][1]; + std::complex abcd = inarr[0][1][1][1]; + std::complex bbcd = inarr[0][2][1][1]; + std::complex aabbc = inarr[2][2][1][0]; + std::complex aabbd = inarr[2][2][0][1]; + std::complex aabcd = inarr[2][1][1][1]; + std::complex abbcd = inarr[1][2][1][1]; + std::complex aabbcd = inarr[2][2][1][1]; + return (-120. * aabbcd + 48. * a * abbcd + 24. * ab * abcd + 16. * abc * abd + 12. * abbd * ac + + 8. * abb * acd + 12. * abbc * ad + 48. * aabcd * b - 24. * a * abcd * b - 8. * abd * ac * b - + 8. * ab * acd * b - 8. * abc * ad * b - 6. * aacd * b * b + 4. * a * acd * b * b + 2. * ac * ad * b * b + + 6. * aacd * bb - 4. * a * acd * bb - 2. * ac * ad * bb + 4. * aad * bbc - 4. * a * ad * bbc - + 6. * a * a * bbcd + 6. * aa * bbcd + 4. * aac * bbd - 4. * a * ac * bbd + 12. * aabd * bc - + 8. * a * abd * bc - 4. * ab * ad * bc - 4. * aad * b * bc + 4. * a * ad * b * bc + 8. * aab * bcd - + 8. * a * ab * bcd + 4. * a * a * b * bcd - 4. * aa * b * bcd + 12. * aabc * bd - 8. * a * abc * bd - + 4. * ab * ac * bd - 4. * aac * b * bd + 4. * a * ac * b * bd + 2. * a * a * bc * bd - 2. * aa * bc * bd + + 24. * aabbd * c - 12. * a * abbd * c - 8. * ab * abd * c - 4. * abb * ad * c - 12. * aabd * b * c + + 8. * a * abd * b * c + 4. * ab * ad * b * c + 2. * aad * b * b * c - 2. * a * ad * b * b * c - + 2. * aad * bb * c + 2. * a * ad * bb * c + 2. * a * a * bbd * c - 2. * aa * bbd * c - 4. * aab * bd * c + + 4. * a * ab * bd * c - 2. * a * a * b * bd * c + 2. * aa * b * bd * c + 6. * aabb * cd - 2. * ab * ab * cd - + 4. * a * abb * cd - 4. * aab * b * cd + 4. * a * ab * b * cd - a * a * b * b * cd + aa * b * b * cd + + a * a * bb * cd - aa * bb * cd + 24. * aabbc * d - 12. * a * abbc * d - 8. * ab * abc * d - + 4. * abb * ac * d - 12. * aabc * b * d + 8. * a * abc * b * d + 4. * ab * ac * b * d + 2. * aac * b * b * d - + 2. * a * ac * b * b * d - 2. * aac * bb * d + 2. * a * ac * bb * d + 2. * a * a * bbc * d - 2. * aa * bbc * d - + 4. * aab * bc * d + 4. * a * ab * bc * d - 2. * a * a * b * bc * d + 2. * aa * b * bc * d - 6. * aabb * c * d + + 2. * ab * ab * c * d + 4. * a * abb * c * d + 4. * aab * b * c * d - 4. * a * ab * b * c * d + + a * a * b * b * c * d - aa * b * b * c * d - a * a * bb * c * d + aa * bb * c * d) + .real(); +} +template +double FlowPtContainer::getStdAABBDD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex d = inarr[0][0][1][1]; + std::complex aa = inarr[2][0][0][0]; + std::complex bb = inarr[0][2][0][0]; + std::complex dd = inarr[0][0][0][2]; + std::complex ab = inarr[1][1][0][0]; + std::complex ad = inarr[1][0][0][1]; + std::complex bd = inarr[0][1][0][1]; + std::complex aab = inarr[2][1][0][0]; + std::complex aad = inarr[2][0][0][1]; + std::complex abb = inarr[1][2][0][0]; + std::complex add = inarr[1][0][0][2]; + std::complex abd = inarr[1][1][0][1]; + std::complex bbd = inarr[0][2][0][1]; + std::complex bdd = inarr[0][1][0][2]; + std::complex aabb = inarr[2][2][0][0]; + std::complex aadd = inarr[2][0][0][2]; + std::complex aabd = inarr[2][1][0][1]; + std::complex abbd = inarr[1][2][0][1]; + std::complex abdd = inarr[1][1][0][2]; + std::complex bbdd = inarr[0][2][0][2]; + std::complex aabbd = inarr[2][2][0][1]; + std::complex aabdd = inarr[2][1][0][2]; + std::complex abbdd = inarr[0][0][0][2]; + std::complex aabbdd = inarr[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 - + 6. * aadd * b * b + 2. * ad * ad * b * b + 4. * a * add * b * b + 6. * aadd * bb - 2. * ad * ad * bb - + 4. * a * add * bb + 8. * aad * bbd - 8. * a * ad * bbd - 6. * a * a * bbdd + 6. * aa * bbdd + + 24. * aabd * bd - 16. * a * abd * bd - 8. * ab * ad * bd - 8. * aad * b * bd + 8. * a * ad * b * bd + + 2. * a * a * bd * bd - 2. * aa * bd * bd + 8. * aab * bdd - 8. * a * ab * bdd + 4. * a * a * b * bdd - + 4. * aa * b * bdd + 48. * aabbd * d - 24. * a * abbd * d - 16. * ab * abd * d - 8. * abb * ad * d - + 24. * aabd * b * d + 16. * a * abd * b * d + 8. * ab * ad * b * d + 4. * aad * b * b * d - + 4. * a * ad * b * b * d - 4. * aad * bb * d + 4. * a * ad * bb * d + 4. * a * a * bbd * d - 4. * aa * bbd * d - + 8. * aab * bd * d + 8. * a * ab * bd * d - 4. * a * a * b * bd * d + 4. * aa * b * bd * d - 6. * aabb * d * d + + 2. * ab * ab * d * d + 4. * a * abb * d * d + 4. * aab * b * d * d - 4. * a * ab * b * d * d + + a * a * b * b * d * d - aa * b * b * d * d - a * a * bb * d * d + aa * bb * d * d + 6. * aabb * dd - + 2. * ab * ab * dd - 4. * a * abb * dd - 4. * aab * b * dd + 4. * a * ab * b * dd - a * a * b * b * dd + + aa * b * b * dd + a * a * bb * dd - aa * bb * dd) + .real(); +} +template +double FlowPtContainer::getStdAABBC(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex aa = inarr[2][0][0][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex bb = inarr[0][2][0][0]; + std::complex bc = inarr[0][1][1][0]; + std::complex aab = inarr[2][1][0][0]; + std::complex aac = arr[2][0][1][0]; + std::complex abb = inarr[1][2][0][0]; + std::complex abc = inarr[1][1][1][0]; + std::complex bbc = inarr[0][2][1][0]; + std::complex aabb = inarr[2][2][0][0]; + std::complex aabc = inarr[2][1][1][0]; + std::complex abbc = inarr[1][2][1][0]; + std::complex aabbc = inarr[2][2][1][0]; + return (a * a * b * b * c - aa * b * b * c - a * a * bb * c - 4. * ab * a * b * c - 2. * a * ac * b * b - 2. * a * a * bc * b + 2. * ab * ab * c + 4. * ab * ac * b + 4. * ab * bc * a + 8. * abc * a * b + 4. * aab * b * c + 2. * aac * b * b + 4. * abb * a * c + 2. * bbc * a * a + aa * bb * c + 2. * aa * b * bc + 2. * bb * a * ac - 12. * aabc * b - 12. * abbc * a - 6. * aabb * c - 8. * abc * ab - 2. * bbc * aa - 2. * aac * bb - 4. * aab * bc - 4. * abb * ac + 24. * aabbc).real(); +} +template +double FlowPtContainer::getStdAABBD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex d = inarr[0][0][1][0]; + std::complex aa = inarr[2][0][0][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ad = inarr[1][0][1][0]; + std::complex bb = inarr[0][2][0][0]; + std::complex bd = inarr[0][1][1][0]; + std::complex aab = inarr[2][1][0][0]; + std::complex aad = arr[2][0][1][0]; + std::complex abb = inarr[1][2][0][0]; + std::complex abd = inarr[1][1][1][0]; + std::complex bbd = inarr[0][2][1][0]; + std::complex aabb = inarr[2][2][0][0]; + std::complex aabd = inarr[2][1][1][0]; + std::complex abbd = inarr[1][2][1][0]; + std::complex aabbd = inarr[2][2][1][0]; + 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 +double FlowPtContainer::getStdABCC(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex bc = inarr[0][1][1][0]; + std::complex cc = inarr[0][0][2][0]; + std::complex abc = inarr[1][1][1][0]; + std::complex acc = inarr[1][0][2][0]; + std::complex bcc = inarr[0][1][2][0]; + std::complex abcc = inarr[1][1][2][0]; + return (a * b * c * c - a * b * cc - 2. * a * bc * c - 2. * ac * b * c - ab * c * c + 2. * acc * b + 2. * a * bcc + 4. * abc * c + ab * cc + 2. * ac * bc - 6. * abcc).real(); +} +template +double FlowPtContainer::getStdABCD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex d = inarr[0][0][0][1]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex ad = inarr[1][0][0][1]; + std::complex bc = inarr[0][1][1][0]; + std::complex bd = inarr[0][1][0][1]; + std::complex cd = inarr[0][0][1][1]; + std::complex abc = inarr[1][1][1][0]; + std::complex abd = inarr[1][1][0][1]; + std::complex acd = inarr[1][0][1][1]; + std::complex bcd = inarr[0][1][1][1]; + std::complex abcd = inarr[1][1][0][1]; + return (-6. * abcd + 2. * acd * b + ad * bc + 2. * a * bcd + ac * bd + 2. * abd * c - ad * b * c - + a * bd * c + ab * cd - a * b * cd + 2. * abc * d - ac * b * d - a * bc * d - ab * c * d + + a * b * c * d) + .real(); +} +template +double FlowPtContainer::getStdABDD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex d = inarr[0][0][0][1]; + std::complex ab = inarr[1][1][0][0]; + std::complex ad = inarr[1][0][0][1]; + std::complex bd = inarr[0][1][0][1]; + std::complex dd = inarr[0][0][0][2]; + std::complex abd = inarr[1][1][0][1]; + std::complex add = inarr[1][0][0][2]; + std::complex bdd = inarr[0][1][0][2]; + std::complex abdd = inarr[1][1][0][2]; + return (a * b * d * d - a * b * dd - 2. * a * bd * d - 2. * ad * b * d - ab * d * d + 2. * add * b + 2. * a * bdd + 4. * abd * d + ab * dd + 2. * ad * bd - 6. * abdd).real(); +} +template +double FlowPtContainer::getStdABC(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex c = inarr[0][0][1][0]; + std::complex ab = inarr[1][1][0][0]; + std::complex ac = inarr[1][0][1][0]; + std::complex bc = inarr[0][1][1][0]; + std::complex abc = inarr[1][1][1][0]; + return (a * b * c - ab * c - ac * b - a * bc + 2. * abc).real(); +} +template +double FlowPtContainer::getStdABD(T& inarr) +{ + std::complex a = inarr[1][0][0][0]; + std::complex b = inarr[0][1][0][0]; + std::complex d = inarr[0][0][0][1]; + std::complex ab = inarr[1][1][0][0]; + std::complex ad = inarr[1][0][0][1]; + std::complex bd = inarr[0][1][0][1]; + std::complex abd = inarr[1][1][0][1]; + return (a * b * d - ab * d - ad * b - a * bd + 2. * abd).real(); +} double FlowPtContainer::OrderedAddition(std::vector vec) { double sum = 0; std::sort(vec.begin(), vec.end()); - for (int i = 0; i < vec.size(); i++) { + for (size_t i = 0; i < vec.size(); i++) { sum += vec[i]; } return sum; @@ -314,7 +796,7 @@ void FlowPtContainer::RebinMulti(Int_t nbins, Double_t* binedges) } TH1* FlowPtContainer::getCorrHist(int ind, int m) { - return dynamic_cast(fCorrList->FindObject(Form("corr_%ipar", m)))->getHist(ind); + return dynamic_cast(fCorrList->FindObject(Form("mpt%i", m + 1)))->getHist(ind); } TH1* FlowPtContainer::getCentralMomentHist(int ind, int m) { @@ -323,7 +805,7 @@ TH1* FlowPtContainer::getCentralMomentHist(int ind, int m) if (!fCentralMomentList) return 0; if (ind + 1 < fCentralMomentList->GetEntries()) - return dynamic_cast(fCentralMomentList->FindObject(Form("cm%i_%i", m + 1, ind))); + return dynamic_cast(fCentralMomentList->FindObject(Form("cm%i_%i", m, ind))); return 0; } void FlowPtContainer::CreateCentralMomentList() @@ -378,8 +860,8 @@ void FlowPtContainer::CreateCumulantList() for (int i = -1; i < reinterpret_cast(fCorrList->At(0))->getNSubs(); ++i) { std::vector hTs; for (int j = 0; j < mpar; ++j) { - dynamic_cast(fCorrList->FindObject(Form("corr_%ipar", j + 1)))->SetErrorOption("g"); - hTs.push_back(reinterpret_cast(fCorrList->FindObject(Form("corr_%ipar", j + 1)))->getHist(i)); + dynamic_cast(fCorrList->FindObject(Form("mpt%i", j + 1)))->SetErrorOption("g"); + hTs.push_back(reinterpret_cast(fCorrList->FindObject(Form("mpt%i", j + 1)))->getHist(i)); } CalculateCumulantHists(hTs, i); } diff --git a/PWGCF/GenericFramework/Core/FlowPtContainer.h b/PWGCF/GenericFramework/Core/FlowPtContainer.h index 981c1d0540c..5455859cf05 100644 --- a/PWGCF/GenericFramework/Core/FlowPtContainer.h +++ b/PWGCF/GenericFramework/Core/FlowPtContainer.h @@ -14,6 +14,8 @@ #include #include +#include +#include #include "BootstrapProfile.h" #include "TNamed.h" #include "TList.h" @@ -36,24 +38,46 @@ using namespace o2::analysis::genericframework::eventweight; class FlowPtContainer : public TNamed { public: + using FillType = std::variant, double>; FlowPtContainer(); explicit FlowPtContainer(const char* name); ~FlowPtContainer(); - FlowPtContainer(const char* name, const char* title, int nbinsx, double* xbins, const int& m, const GFWCorrConfigs& configs); - FlowPtContainer(const char* name, const char* title, int nbinsx, double xlow, double xhigh, const int& m, const GFWCorrConfigs& configs); + FlowPtContainer(const char* name, const char* title); void Initialise(const o2::framework::AxisSpec axis, const int& m, const GFWCorrConfigs& configs, const int& nsub = 10); void Initialise(int nbinsx, double* xbins, const int& m, const GFWCorrConfigs& configs, const int& nsub = 10); void Initialise(int nbinsx, double xlow, double xhigh, const int& m, const GFWCorrConfigs& configs, const int& nsub = 10); 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; } void CalculateCorrelations(); void CalculateCMTerms(); void FillPtProfiles(const Double_t& lMult, const Double_t& rn); - void FillVnPtProfiles(const double& lMult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask); + void FillVnPtCorrProfiles(const double& lMult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask); + void FillVnDeltaPtProfiles(const double& centmult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask); + void FillVnDeltaPtStdProfiles(const double& centmult, const double& rn); + void FillVnPtCorrStdProfiles(const double& centmult, const double& rn); + void FillVnPtProfiles(const double& centmult, const double& flowval, const double& flowtuples, const double& rn, uint8_t mask) + { + if (fUseCentralMoments) + FillVnDeltaPtProfiles(centmult, flowval, flowtuples, rn, mask); + else + FillVnPtCorrProfiles(centmult, flowval, flowtuples, rn, mask); + } + void FillVnPtStdProfiles(const double& centmult, const double& rn) + { + if (fUseCentralMoments) + FillVnDeltaPtStdProfiles(centmult, rn); + else + FillVnPtCorrStdProfiles(centmult, rn); + } void FillCMProfiles(const double& lMult, const double& rn); TList* GetCorrList() { return fCorrList; } TList* GetCMTermList() { return fCMTermList; } + TList* GetCovList() { return fCovList; } void SetEventWeight(const unsigned int& lWeight) { fEventWeight = lWeight; } + void SetUseCentralMoments(bool newval) { fUseCentralMoments = newval; } + void SetUseGapMethod(bool newval) { fUseGap = newval; } + bool usesCentralMoments() { return fUseCentralMoments; } void RebinMulti(Int_t nbins); void RebinMulti(Int_t nbins, double* binedges); TH1* getCentralMomentHist(int ind, int m); @@ -66,10 +90,13 @@ class FlowPtContainer : public TNamed void CalculateCentralMomentHists(std::vector inh, int ind, int m, TH1* hMpt); void CreateCumulantList(); void CalculateCumulantHists(std::vector inh, Int_t ind); + void ClearArray(); void ClearVector() { sumP.clear(); sumP.resize((mpar + 1) * (mpar + 1)); + cmVal.clear(); + cmDen.clear(); fillCounter = 0; }; @@ -82,12 +109,37 @@ class FlowPtContainer : public TNamed int mpar; int fillCounter; unsigned int fEventWeight; + 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 sumP; //! + std::vector corrNum; //! + std::vector corrDen; //! + std::vector cmVal; //! + std::vector cmDen; //! + std::complex arr[3][3][3][3]; //! + double warr[3][3][3][3]; //! + template + double getStdAABBCC(T& inarr); + template + double getStdAABBCD(T& inarr); + template + double getStdAABBDD(T& inarr); + template + double getStdAABBC(T& inarr); + template + double getStdAABBD(T& inarr); + template + double getStdABCC(T& inarr); + template + double getStdABCD(T& inarr); + template + double getStdABDD(T& inarr); + template + double getStdABC(T& inarr); + template + double getStdABD(T& inarr); static constexpr float fFactorial[9] = {1., 1., 2., 6., 24., 120., 720., 5040., 40320.}; static constexpr int fSign[9] = {1, -1, 1, -1, 1, -1, 1, -1, 1}; ClassDef(FlowPtContainer, 1); diff --git a/PWGCF/GenericFramework/Core/GFWConfig.h b/PWGCF/GenericFramework/Core/GFWConfig.h index 9c086acbef1..779d06b604e 100644 --- a/PWGCF/GenericFramework/Core/GFWConfig.h +++ b/PWGCF/GenericFramework/Core/GFWConfig.h @@ -35,7 +35,7 @@ int CheckSameSize(const std::vector& first) template int CheckSameSize(const std::vector& first, const std::vector&... rest) { - int size = first.size(); + size_t size = first.size(); bool allSameSize = ((size == rest.size()) && ...); return allSameSize ? size : -1; @@ -145,7 +145,7 @@ class GFWRegions auto Print() const { - for (auto i = 0; i < names.size(); ++i) { + for (size_t i = 0; i < names.size(); ++i) { LOGF(info, "{%s, %.1f, %.1f, %d, %d}", names[i].c_str(), etaminvals[i], etamaxvals[i], pTDifs[i], bitmasks[i]); } return; @@ -190,7 +190,7 @@ class GFWCorrConfigs auto Print() const { - for (auto i = 0; i < corrs.size(); ++i) { + for (size_t i = 0; i < corrs.size(); ++i) { LOGF(info, "{%s,%s,%d,%d}", heads[i].c_str(), corrs[i].c_str(), pTDifs[i], pTCorrMasks[i]); } return; diff --git a/PWGCF/GenericFramework/Core/GFWPowerArray.cxx b/PWGCF/GenericFramework/Core/GFWPowerArray.cxx index 82291e507a2..609b235ec6f 100644 --- a/PWGCF/GenericFramework/Core/GFWPowerArray.cxx +++ b/PWGCF/GenericFramework/Core/GFWPowerArray.cxx @@ -52,7 +52,7 @@ void GFWPowerArray::RecursiveFunction(HarSet& masterVector, HarSet hars, int off { HarSet compVec = AddConstant(hars, offset); FlushVectorToMaster(masterVector, compVec, MaxPower); - for (int i = 0; i < hars.size(); i++) + for (size_t i = 0; i < hars.size(); i++) RecursiveFunction(masterVector, TrimVec(hars, i), offset + hars.at(i), MaxPower); ; }; diff --git a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx index d18d08309bf..d9b969ffbf6 100644 --- a/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx +++ b/PWGCF/GenericFramework/Tasks/flowGenericFramework.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -83,6 +84,8 @@ struct GenericFramework { 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(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)"); @@ -91,6 +94,7 @@ struct GenericFramework { 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(cfgMagField, float, 99999, "Configurable magnetic field; default CCDB will be queried"); @@ -239,6 +243,8 @@ struct GenericFramework { fFC_gen->Initialize(oba, multAxis, cfgNbootstrap); } delete oba; + fFCpt->SetUseCentralMoments(cfgUseCentralMoments); + fFCpt->SetUseGapMethod(cfgUseGapMethod); fFCpt->Initialise(multAxis, cfgMpar, configs, cfgNbootstrap); // Event selection - Alex if (cfgUseAdditionalEventCut) { @@ -419,6 +425,8 @@ struct GenericFramework { fFCpt->CalculateCorrelations(); fFCpt->FillPtProfiles(centmult, rndm); fFCpt->FillCMProfiles(centmult, rndm); + if (!cfgUseGapMethod) + fFCpt->FillVnPtStdProfiles(centmult, rndm); for (uint l_ind = 0; l_ind < corrconfigs.size(); ++l_ind) { auto dnx = fGFW->Calculate(corrconfigs.at(l_ind), 0, kTRUE).real(); if (dnx == 0) @@ -427,7 +435,8 @@ struct GenericFramework { auto val = fGFW->Calculate(corrconfigs.at(l_ind), 0, kFALSE).real() / dnx; if (TMath::Abs(val) < 1) { (dt == kGen) ? fFC_gen->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); - fFCpt->FillVnPtProfiles(centmult, val, dnx, rndm, configs.GetpTCorrMasks()[l_ind]); + if (cfgUseGapMethod) + fFCpt->FillVnPtProfiles(centmult, val, dnx, rndm, configs.GetpTCorrMasks()[l_ind]); } continue; } @@ -453,6 +462,7 @@ struct GenericFramework { float vtxz = collision.posZ(); fGFW->Clear(); fFCpt->ClearVector(); + fFCpt->ClearArray(); float l_Random = fRndm->Rndm(); for (auto& track : tracks) { ProcessTrack(track, centrality, vtxz, field); @@ -518,7 +528,14 @@ struct GenericFramework { template inline void FillGFW(TrackObject track, float weff, float wacc) { - fFCpt->Fill(weff, track.pt()); + if (fabs(track.eta()) < cfgEtaPtPt) + fFCpt->Fill(weff, track.pt()); + std::complex q2p = {weff * wacc * cos(2 * track.phi()), weff * wacc * sin(2 * track.phi())}; + std::complex q2n = {weff * wacc * cos(-2 * track.phi()), weff * wacc * sin(-2 * track.phi())}; + if (!cfgUseGapMethod) { + fFCpt->FillArray(q2p, q2n, weff * track.pt(), weff); + fFCpt->FillArray(weff * wacc, weff * wacc, weff, weff); + } bool WithinPtPOI = (ptpoilow < track.pt()) && (track.pt() < ptpoiup); // within POI pT range bool WithinPtRef = (ptreflow < track.pt()) && (track.pt() < ptrefup); // within RF pT range if (WithinPtRef) diff --git a/PWGCF/JCorran/Core/CMakeLists.txt b/PWGCF/JCorran/Core/CMakeLists.txt index 9f6f99e9e74..6c4e10529bb 100644 --- a/PWGCF/JCorran/Core/CMakeLists.txt +++ b/PWGCF/JCorran/Core/CMakeLists.txt @@ -14,6 +14,7 @@ o2physics_add_library(JCorran JFFlucAnalysisO2Hist.cxx FlowJSPCAnalysis.cxx FlowJHistManager.cxx + JEPFlowAnalysis.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore) o2physics_target_root_dictionary(JCorran @@ -22,4 +23,5 @@ o2physics_target_root_dictionary(JCorran FlowJHistManager.h FlowJSPCAnalysis.h FlowJSPCObservables.h + JEPFlowAnalysis.h LINKDEF JCORRANLinkDef.h) diff --git a/PWGCF/JCorran/Core/JCORRANLinkDef.h b/PWGCF/JCorran/Core/JCORRANLinkDef.h index 7cadfacca79..d0e9bef308d 100755 --- a/PWGCF/JCorran/Core/JCORRANLinkDef.h +++ b/PWGCF/JCorran/Core/JCORRANLinkDef.h @@ -21,5 +21,6 @@ #pragma link C++ class FlowJHistManager + ; #pragma link C++ class FlowJSPCAnalysis + ; #pragma link C++ class FlowJSPCObservables + ; +#pragma link C++ class JEPFlowAnalysis + ; #endif // PWGCF_JCORRAN_CORE_JCORRANLINKDEF_H_ diff --git a/PWGCF/JCorran/Core/JEPFlowAnalysis.cxx b/PWGCF/JCorran/Core/JEPFlowAnalysis.cxx new file mode 100644 index 00000000000..6d027002e8c --- /dev/null +++ b/PWGCF/JCorran/Core/JEPFlowAnalysis.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 "JEPFlowAnalysis.h" + +using namespace o2; +using namespace o2::framework; +using namespace std; + +void JEPFlowAnalysis::FillVnHistograms(const Int_t harmN, Float_t cent, Float_t det, Float_t pT, Float_t vn, Float_t vn_sin) +{ + switch (harmN) { + case 2: { + mHistRegistry->fill(HIST("fV2EP"), vn, det, pT, cent, 1.); + mHistRegistry->fill(HIST("fV2EP_sin"), vn_sin, det, pT, cent, 1.); + } break; + case 3: { + mHistRegistry->fill(HIST("fV3EP"), vn, det, pT, cent, 1.); + mHistRegistry->fill(HIST("fV3EP_sin"), vn_sin, det, pT, cent, 1.); + } break; + case 4: { + mHistRegistry->fill(HIST("fV4EP"), vn, det, pT, cent, 1.); + mHistRegistry->fill(HIST("fV4EP_sin"), vn_sin, det, pT, cent, 1.); + } break; + default: + break; + } +} + +void JEPFlowAnalysis::FillResolutionHistograms(Float_t cent, Float_t harmN, Float_t ResNumA, Float_t ResNumB, Float_t ResDenom) +{ + mHistRegistry->fill(HIST("fResNumA"), ResNumA, harmN, cent, 1.); + mHistRegistry->fill(HIST("fResNumB"), ResNumB, harmN, cent, 1.); + mHistRegistry->fill(HIST("fResDenom"), ResDenom, harmN, cent, 1.); +} diff --git a/PWGCF/JCorran/Core/JEPFlowAnalysis.h b/PWGCF/JCorran/Core/JEPFlowAnalysis.h new file mode 100644 index 00000000000..f1bc994099c --- /dev/null +++ b/PWGCF/JCorran/Core/JEPFlowAnalysis.h @@ -0,0 +1,63 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Maxim Virta (maxim.virta@cern.ch) + +#ifndef PWGCF_JCORRAN_CORE_JEPFLOWANALYSIS_H_ +#define PWGCF_JCORRAN_CORE_JEPFLOWANALYSIS_H_ + +#include + +// O2 headers. // +#include "Framework/HistogramRegistry.h" + +using namespace o2; +using namespace o2::framework; +using namespace std; + +class JEPFlowAnalysis +{ + public: + JEPFlowAnalysis() = default; + void SetHistRegistry(HistogramRegistry* histReg) { mHistRegistry = histReg; } + + void FillHistograms(const Int_t fCentBin, Float_t det, Float_t v2, Float_t v3, Float_t v4); + void FillVnHistograms(const Int_t harmN, Float_t fCent, Float_t det, Float_t pT, Float_t vn, Float_t vn_sin); + void FillResolutionHistograms(Float_t fCent, Float_t harmN, Float_t ResNumA, Float_t ResNumB, Float_t ResDenom); + TComplex Q(const Int_t harmN, const Int_t p); + + void CreateHistograms() + { + if (!mHistRegistry) { + LOGF(error, "Histogram registry missing. Quitting..."); + return; + } + + mHistRegistry->add("FullCentrality", "FullCentrality", HistType::kTH1D, {{100, 0., 100.}}, true); + mHistRegistry->add("fV2EP", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_cos, y: detector, z: pT, t: centrality + mHistRegistry->add("fV3EP", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_cos, y: detector, z: pT, t: centrality + mHistRegistry->add("fV4EP", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_cos, y: detector, z: pT, t: centrality + mHistRegistry->add("fV2EP_sin", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_sin, y: detector, z: pT, t: centrality + mHistRegistry->add("fV3EP_sin", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_sin, y: detector, z: pT, t: centrality + mHistRegistry->add("fV4EP_sin", "", {HistType::kTHnD, {{200, -1.05, 1.05}, {3, 0.5, 3.5}, {100, 0.2, 12.}, {20, 0., 100.}}}, true); // x: v2_sin, y: detector, z: pT, t: centrality + mHistRegistry->add("fResNumA", "", {HistType::kTH3D, {{100, -1.05, 1.05}, {3, 1.5, 4.5}, {20, 0., 100.}}}, true); // x: resolution, y: harmonic, t: centrality + mHistRegistry->add("fResNumB", "", {HistType::kTH3D, {{100, -1.05, 1.05}, {3, 1.5, 4.5}, {20, 0., 100.}}}, true); // x: resolution, y: harmonic, t: centrality + mHistRegistry->add("fResDenom", "", {HistType::kTH3D, {{100, -1.05, 1.05}, {3, 1.5, 4.5}, {20, 0., 100.}}}, true); // x: resolution, y: harmonic, t: centrality + mHistRegistry->add("phi", "Phi", {HistType::kTH1D, {{100, 0., TMath::TwoPi()}}}, true); + } + + private: + HistogramRegistry* mHistRegistry; + + ClassDefNV(JEPFlowAnalysis, 1); +}; + +#endif // PWGCF_JCORRAN_CORE_JEPFLOWANALYSIS_H_ diff --git a/PWGCF/JCorran/Tasks/CMakeLists.txt b/PWGCF/JCorran/Tasks/CMakeLists.txt index bb123a2d5a6..18284bd2f4c 100644 --- a/PWGCF/JCorran/Tasks/CMakeLists.txt +++ b/PWGCF/JCorran/Tasks/CMakeLists.txt @@ -28,3 +28,8 @@ o2physics_add_dpl_workflow(flow-nuacreation SOURCES flowJNUACreation.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::JCorran COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(epflow-analysis + SOURCES jEPFlowAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::JCorran + COMPONENT_NAME Analysis) diff --git a/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx b/PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx new file mode 100644 index 00000000000..f3f43744f19 --- /dev/null +++ b/PWGCF/JCorran/Tasks/jEPFlowAnalysis.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. +/// \author Maxim Virta (maxim.virta@cern.ch) +/// \since Jul 2024 + +#include "Framework/AnalysisTask.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/HistogramRegistry.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/Core/TrackSelection.h" +#include "Framework/runDataProcessing.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Common/DataModel/Qvectors.h" +#include "Common/Core/EventPlaneHelper.h" + +#include "FlowJHistManager.h" +#include "JEPFlowAnalysis.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; + +using MyCollisions = soa::Join; + +using MyTracks = aod::Tracks; + +struct jEPFlowAnalysis { + + HistogramRegistry EPFlowHistograms{"EPFlow", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + JEPFlowAnalysis epAnalysis; + EventPlaneHelper helperEP; + FlowJHistManager histManager; + Bool_t debug = kFALSE; + + // Set Configurables here + struct : ConfigurableGroup { + Configurable cfgPtMin{"cfgPtMin", 0.2f, "Minimum pT used for track selection."}; + Configurable cfgPtMax{"cfgPtMax", 5.0f, "Maximum pT used for track selection."}; + Configurable cfgEtaMax{"cfgEtaMax", 1.f, "Maximum eta used for track selection."}; + } cfgTrackCuts; + + Configurable cfgAddEvtSel{"cfgAddEvtSel", true, "Use event selection"}; + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "Total number of detectors in qVectorsTable"}; + + 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"}; + + Filter trackFilter = (aod::track::pt > cfgTrackCuts.cfgPtMin) && (aod::track::pt < cfgTrackCuts.cfgPtMax) && (nabs(aod::track::eta) < cfgTrackCuts.cfgEtaMax); + + int DetId; + int RefAId; + int RefBId; + int harmInd; + + template + int GetDetId(const T& name) + { + 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 if (name.value == "TPCTot") { + return 6; + } else { + return 0; + } + } + + void init(InitContext const&) + { + DetId = GetDetId(cfgDetName); + RefAId = GetDetId(cfgRefAName); + RefBId = GetDetId(cfgRefBName); + + epAnalysis.SetHistRegistry(&EPFlowHistograms); + epAnalysis.CreateHistograms(); + } + + void process(MyCollisions::iterator const& coll, soa::Filtered const& tracks) + { + if (cfgAddEvtSel && (!coll.sel8() || !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))) + return; + + Float_t cent = coll.cent(); + EPFlowHistograms.fill(HIST("FullCentrality"), cent); + Float_t EPs[3] = {0.}; + for (int i = 2; i < 5; i++) { // loop over different harmonic orders + harmInd = cfgnTotalSystem * 4 * (i - 2) + 3; // harmonic index to access corresponding Q-vector as all Q-vectors are in same vector + EPs[0] = helperEP.GetEventPlane(coll.qvecRe()[DetId + harmInd], coll.qvecIm()[DetId + harmInd], i); + EPs[1] = helperEP.GetEventPlane(coll.qvecRe()[RefAId + harmInd], coll.qvecIm()[RefAId + harmInd], i); + EPs[2] = helperEP.GetEventPlane(coll.qvecRe()[RefBId + harmInd], coll.qvecIm()[RefBId + harmInd], i); + + Float_t resNumA = helperEP.GetResolution(EPs[0], EPs[1], i); + Float_t resNumB = helperEP.GetResolution(EPs[0], EPs[2], i); + Float_t resDenom = helperEP.GetResolution(EPs[1], EPs[2], i); + epAnalysis.FillResolutionHistograms(cent, static_cast(i), resNumA, resNumB, resDenom); + for (uint j = 0; j < 3; j++) { // loop over detectors used + for (auto& track : tracks) { + Float_t vn = TMath::Cos((i) * (track.phi() - EPs[j])); + Float_t vn_sin = TMath::Sin((i) * (track.phi() - EPs[j])); + epAnalysis.FillVnHistograms(i, cent, static_cast(j + 1), track.pt(), vn, vn_sin); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h index 770ed87472f..201115e2241 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-Configurables.h @@ -21,35 +21,38 @@ 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 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 function calls per particle)"}; + 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)"}; Configurable cfVerboseForEachParticle{"cfVerboseForEachParticle", false, "run or not in verbose mode (also for function calls per particle)"}; Configurable cfDoAdditionalInsanityChecks{"cfDoAdditionalInsanityChecks", false, "do additional insanity checks at run time (this leads to small loss of performance)"}; Configurable cfInsanityCheckForEachParticle{"cfInsanityCheckForEachParticle", false, "do insanity checks at run time for each particle, at the expense of losing a lot of performance. Use only during debugging."}; - Configurable cfUseCCDB{"cfUseCCDB", true, "if requested, access personal files from CCDB (true) or from home dir in AliEn (false)"}; Configurable cfRandomSeed{"cfRandomSeed", 0, "0 = random seed is guaranteed to be unique in space and time"}; 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 cfSequentialBailout{"cfSequentialBailout", 0, "if fSequentialBailout > 0, then each fSequentialBailout events the function BailOut() is called. Can be used for real analysis and for IV"}; + } 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 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", {"MultTPC_vs_NContributors-1", "Vertex_z_vs_MultTPC-1", "Vertex_z_vs_NContributors-1", "CentFT0M_vs_CentNTPV-1", "CentRun2V0M_vs_CentRun2SPDTracklets-1", "CentRun2V0M_vs_NContributors-1"}, "book (1) or do not book (0) this QA 2D event histogram"}; + Configurable> cfBookQAEventHistograms2D{"cfBookQAEventHistograms2D", {"MultTPC_vs_NContributors-1", "MultTPC_vs_Centrality-1", "Vertex_z_vs_MultTPC-1", "Vertex_z_vs_NContributors-1", "CentFT0C_vs_CentNTPV-1", "CentFT0M_vs_CentNTPV-1", "CentRun2V0M_vs_CentRun2SPDTracklets-1", "CentRun2V0M_vs_NContributors-1", "TrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange-1", "TrackOccupancyInTimeRange_vs_MultTPC-1", "TrackOccupancyInTimeRange_vs_Vertex_z-1", "TrackOccupancyInTimeRange_vs_Centrality-1"}, "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", {"dcaXY_vs_Pt-1"}, "book (1) or do not book (0) this QA 2D particle histogram"}; + Configurable> cfBookQAParticleHistograms2D{"cfBookQAParticleHistograms2D", {"Pt_vs_dcaXY-1"}, "book (1) or do not book (0) this QA 2D particle histogram"}; } 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", {"NumberOfEvents-1", "TotalMultiplicity-1", "SelectedTracks-1", "MultFV0M-1", "MultFT0M-1", "MultTPC-1", "MultNTracksPV-1", "MultTracklets-1", "Centrality-1", "Vertex_x-1", "Vertex_y-1", "Vertex_z-1", "NContributors-1", "ImpactParameter-1"}, "Book (1) or do not book (0) event histogram"}; + Configurable> cfBookEventHistograms{"cfBookEventHistograms", {"NumberOfEvents-1", "TotalMultiplicity-1", "SelectedTracks-1", "MultFV0M-1", "MultFT0M-1", "MultTPC-1", "MultNTracksPV-1", "MultTracklets-1", "Centrality-1", "Vertex_x-1", "Vertex_y-1", "Vertex_z-1", "NContributors-1", "ImpactParameter-1", "Occupancy-1"}, "Book (1) or do not book (0) event histogram"}; } cf_eh; // *) Event cuts: struct : ConfigurableGroup { - Configurable> cfUseEventCuts{"cfUseEventCuts", {"NumberOfEvents-1", "TotalMultiplicity-1", "SelectedTracks-1", "MultFV0M-1", "MultFT0M-1", "MultTPC-1", "MultNTracksPV-1", "MultTracklets-1", "Centrality-1", "Vertex_x-1", "Vertex_y-1", "Vertex_z-1", "NContributors-1", "ImpactParameter-1", "Trigger-1", "Sel7-1", "Sel8-1", "CentralityEstimator-1", "SelectedEvents-1", "NoSameBunchPileup-1", "IsGoodZvtxFT0vsPV-1", "IsVertexITSTPC-1", "IsVertexTOFmatched-1", "IsVertexTRDmatched-1"}, "use (1) or do not use (0) event cuts"}; + Configurable> cfUseEventCuts{"cfUseEventCuts", {"NumberOfEvents-1", "TotalMultiplicity-1", "SelectedTracks-1", "MultFV0M-1", "MultFT0M-1", "MultTPC-1", "MultNTracksPV-1", "MultTracklets-1", "Centrality-1", "Vertex_x-1", "Vertex_y-1", "Vertex_z-1", "NContributors-1", "ImpactParameter-1", "Occupancy-1", "Trigger-0", "Sel7-1", "Sel8-1", "CentralityEstimator-1", "SelectedEvents-1", "NoSameBunchPileup-1", "IsGoodZvtxFT0vsPV-1", "IsVertexITSTPC-1", "IsVertexTOFmatched-1", "IsVertexTRDmatched-1", "OccupancyEstimator-1"}, "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)"}; @@ -68,16 +71,18 @@ struct : ConfigurableGroup { Configurable> cfVertex_z{"cfVertex_z", {-10., 10.}, "vertex z position range: {min, max}[cm], with convention: min <= Vz < max"}; Configurable> cfNContributors{"cfNContributors", {-1, 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> cfOccupancy{"cfOccupancy", {-2, 1000000000}, "Range for occupancy (use cfOccupancyEstimator to set specific estimator): {min, max}, with convention: min <= X < max"}; Configurable cfTrigger{"cfTrigger", "some supported trigger", "set here some supported trigger (kINT7, ...) "}; 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 cfCentralityEstimator{"cfCentralityEstimator", "some supported centrality estimator", "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"}; Configurable cfUseIsVertexTOFmatched{"cfUseIsVertexTOFmatched", false, "TBI 20240521 explanation"}; Configurable cfUseIsVertexTRDmatched{"cfUseIsVertexTRDmatched", false, "TBI 20240521 explanation"}; - Configurable cfCentralityEstimator{"cfCentralityEstimator", "some supported centrality estimator", "set here some supported centrality estimator (CentFT0M, CentFV0A, CentNTPV, ... for Run 3, and CentRun2V0M, CentRun2SPDTracklets, ..., for Run 2 and 1) "}; + Configurable cfOccupancyEstimator{"cfOccupancyEstimator", "some supported occupancy estimator", "set here some supported occupancy estimator (TrackOccupancyInTimeRange, FT0COccupancyInTimeRange, ..."}; } cf_ec; // *) Particle histograms: @@ -85,7 +90,7 @@ 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", {"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-1"}, "Book (1) or do not book (0) particle histogram"}; Configurable cfFillParticleHistograms2D{"cfFillParticleHistograms2D", true, "if false, all 2D particle histograms are not filled. if kTRUE, the ones for which fBookParticleHistograms2D[...] is kTRUE, are filled"}; - Configurable> cfBookParticleHistograms2D{"cfBookParticleHistograms2D", {"Phi_vs_Pt-1", "Phi_vs_Eta-1"}, "Book (1) or do not book (0) this 2D particle histogram"}; + Configurable> cfBookParticleHistograms2D{"cfBookParticleHistograms2D", {"Phi_vs_Pt-1", "Phi_vs_Eta-1"}, "Book (1) or do not book (0) 2D particle histograms"}; } cf_ph; // *) Particle cuts: @@ -106,8 +111,8 @@ struct : ConfigurableGroup { Configurable> cftpcCrossedRowsOverFindableCls{"cftpcCrossedRowsOverFindableCls", {-1000., 1000.}, "tpcCrossedRowsOverFindableCls range: {min, max}, with convention: min <= eta < max"}; Configurable> cftpcFoundOverFindableCls{"cftpcFoundOverFindableCls", {-1000., 1000.}, "tpcFoundOverFindableCls range: {min, max}, with convention: min <= eta < max"}; Configurable> cftpcFractionSharedCls{"cftpcFractionSharedCls", {-1000., 1000.}, "tpcFractionSharedCls range: {min, max}, with convention: min <= eta < max"}; - Configurable> cfdcaXY{"cfdcaXY", {-1000., 1000.}, "dcaXY range: {min, max}, with convention: min <= eta < max"}; - Configurable> cfdcaZ{"cfdcaZ", {-1000., 1000.}, "dcaZ range: {min, max}, with convention: min <= eta < max"}; + Configurable> cfdcaXY{"cfdcaXY", {-1000., 1000.}, "dcaXY range: {min, max}, with convention: min <= dcaXY < max (yes, DCA can be negative!)"}; + Configurable> cfdcaZ{"cfdcaZ", {-1000., 1000.}, "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"}; @@ -127,6 +132,12 @@ struct : ConfigurableGroup { // *) Multiparticle correlations: struct : ConfigurableGroup { Configurable cfCalculateCorrelations{"cfCalculateCorrelations", false, "calculate or not multiparticle correlations"}; + Configurable cfCalculateCorrelationsAsFunctionOfIntegrated{"cfCalculateCorrelationsAsFunctionOfIntegrated", false, "calculate or not correlations as a function of integrated"}; + Configurable cfCalculateCorrelationsAsFunctionOfMultiplicity{"cfCalculateCorrelationsAsFunctionOfMultiplicity", false, "calculate or not correlations as a function of multiplicity"}; + Configurable cfCalculateCorrelationsAsFunctionOfCentrality{"cfCalculateCorrelationsAsFunctionOfCentrality", false, "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", false, "calculate or not correlations as a function of occupancy"}; } cf_mupa; // *) Test0: @@ -137,7 +148,9 @@ struct : ConfigurableGroup { 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 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"}; } cf_t0; // *) Particle weights: @@ -150,6 +163,12 @@ struct : ConfigurableGroup { 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" +} cf_cw; + // *) Nested loops: struct : ConfigurableGroup { Configurable cfCalculateNestedLoops{"cfCalculateNestedLoops", false, "cross-check for all events all correlations with nested loops"}; @@ -171,30 +190,36 @@ 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 \"correlared\""}; + Configurable cfHarmonicsOptionInternalValidation{"cfHarmonicsOptionInternalValidation", "constant", "for internal validation, set whether flow amplitudes are \"constant\" or \"correlated\""}; 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}, "{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}, "{Psi1, Psi2, Psi3, Psi4, ...} + has an effect only in combination with cfHarmonicsOptionInternalValidation = \"constant\". Max number of Psin's is gMaxHarmonic."}; + 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: +// *) Results histograms: 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"}; Configurable> cfFixedLength_cent_bins{"cfFixedLength_cent_bins", {110, 0., 110.}, "nCentBins, centMin, centMax"}; Configurable> cfFixedLength_pt_bins{"cfFixedLength_pt_bins", {1000, 0., 100.}, "nPtBins, ptMin, ptMax"}; Configurable> cfFixedLength_eta_bins{"cfFixedLength_eta_bins", {1000, -2., 2.}, "nEtaBins, etaMin, etaMax"}; - // Variable-length binning: TBI 20240113 I do it via string + tokenize + Atof(), use arrays eventually as for FixedLength case above. + Configurable> cfFixedLength_occu_bins{"cfFixedLength_occu_bins", {400, 0., 4000.}, "nOccuBins, occuMin, occuMax"}; + + // 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.,100.,250.,1000.", "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> cfVariableLength_cent_bins{"cfVariableLength_cent_bins", {0., 10., 50., 100.}, "variable-length centrality bins"}; Configurable cfUseVariableLength_pt_bins{"cfUseVariableLength_pt_bins", false, "use or not variable-length pt bins"}; - Configurable cfVariableLength_pt_bins{"cfVariableLength_pt_bins", "1.0,2.0,5.0", "variable-length pt bins"}; + Configurable> cfVariableLength_pt_bins{"cfVariableLength_pt_bins", {0.20, 0.30, 0.40, 0.65, 1.00, 2.00, 5.00}, "variable-length pt bins"}; Configurable cfUseVariableLength_eta_bins{"cfUseVariableLength_eta_bins", false, "use or not variable-length eta bins"}; - Configurable cfVariableLength_eta_bins{"cfVariableLength_eta_bins", "-0.8,-0.4,0.0,0.4,0.8", "variable-length eta bins"}; + Configurable> cfVariableLength_eta_bins{"cfVariableLength_eta_bins", {-0.8, 0.0, 0.3, 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"}; + } cf_res; #endif // PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_CONFIGURABLES_H_ diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h index 2d4d7536cc6..bb020581fc7 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-DataMembers.h @@ -42,14 +42,13 @@ struct TaskConfiguration { TString fRunNumber = ""; // over which run number this task is executed Bool_t fRunNumberIsDetermined = kFALSE; // ensures that run number is determined in process() and propagated to already booked objects only once Bool_t fDryRun = kFALSE; // book all histos and run without storing and calculating anything - Bool_t fVerbose = kFALSE; // print additional info during debugging, but not for function calls per particle (see next) + Bool_t fVerbose = kFALSE; // print additional info during debugging, but not for simply utility function or function calls per particle (see next) + Bool_t fVerboseUtility = kFALSE; // print additional info during debugging also for simply utility function, but not for function calls per particle (see next) Bool_t fVerboseForEachParticle = kFALSE; // print additional info during debugging, also for function calls per particle Bool_t fDoAdditionalInsanityChecks = kFALSE; // 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_t fInsanityCheckForEachParticle = kFALSE; // do additional insanity checks at run time for each particle, at the expense of losing a lot of performance. Use only during debugging. - Bool_t fUseCCDB = kFALSE; // access personal files from CCDB (kTRUE, this is set as default in Configurables), - // or from home dir in AliEn (kFALSE, use with care, as this is discouraged) - Bool_t fProcess[eProcess_N] = {kFALSE}; // Set what to process. See enum eProcess for full description. Set via implicit variables within a PROCESS_SWITCH clause. + Bool_t fProcess[eProcess_N] = {kFALSE}; // 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 UInt_t fRandomSeed = 0; // argument for TRandom3 constructor. By default it is 0 (seed is guaranteed to be unique in time and space) Bool_t fUseFisherYates = kFALSE; // algorithm used to randomize particle indices, set via configurable @@ -57,47 +56,57 @@ struct TaskConfiguration { Int_t fFixedNumberOfRandomlySelectedTracks = -1; // use a fixed number of randomly selected particles in each event. It is set and applied, if > 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 - // Bool_t fRescaleWithTheoreticalInput; // if kTRUE, all measured correlators are - // rescaled with theoretical input, so that in profiles everything is at 1. Used - // both in OTF and internal val. -} tc; // "tc" labels an instance of this group of variables. + 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. +} 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 - Double_t fCentrality = 0.; // event-by-event centrality. Value of the default centrality estimator, set via configurable cfCentralityEstimator + 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 } ebye; // "ebye" is a common label for objects in this struct // *) QA: -// Remark: 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 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; //! 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 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) @@ -228,15 +256,16 @@ struct InternalValidation { // *) 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] = {true, true, true, false, false}; //! [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pT,4=eta] - TString fFileWithLabels = ""; // path to external ROOT file which specifies all labels of interest - 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_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] = {true, true, true, false, false, 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() + TH1I* fTest0LabelsPlaceholder = NULL; // store all Test0 labels in this histogram +} t0; // "t0" labels an instance of this group of histograms // *) Results: struct Results { // This is in addition also sort of "abstract" interface, which defines common binning, etc., for other groups of histograms. @@ -246,12 +275,12 @@ struct Results { // This is in addition also s TProfile* fResultsPro[eAsFunctionOf_N] = {NULL}; //! use only in Run 2 and Run 1. TBI 20240522 I stil need to validate this one over MC - eSel8, // 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 def. of sel8 in Ref. a) + 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 + // *) As of 20240410, kNoITSROFrameBorder (only in MC) and kNoTimeFrameBorder event selection cuts are part of Sel8 // See also email from EK from 20240410 - eCentralityEstimator, // the default centrality estimator, set via configurable. All supported centrality estimatos, for QA, etc, are in enum eCentralityEstimators + eCentralityEstimator, // the default centrality estimator, set via configurable. All supported centrality estimators, for QA, etc, are in enum eCentralityEstimators 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) 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 + eOccupancyEstimator, // the default Occupancy estimator, set via configurable. All supported centrality estimators, for QA, etc, are in enum eOccupancyEstimators eEventCuts_N }; enum eParticleHistograms { - // from o2::aod::Tracks: (Track parameters at collision vertex) + // from o2::aod::Tracks (Track parameters at their point closest to the collision vertex) ePhi = 0, ePt, eEta, @@ -179,6 +183,7 @@ enum eAsFunctionOf { AFO_CENTRALITY = 2, // vs. default centrality estimator, see how it's calculated in DetermineCentrality(...) AFO_PT = 3, AFO_ETA = 4, + AFO_OCCUPANCY = 5, // vs. default "occupancy" variable which is (at the moment) "TrackOccupancyInTimeRange" (alternative is "FT0COccupancyInTimeRange") eAsFunctionOf_N }; // prefix is needed, to avoid conflict with enum eKinematics @@ -201,7 +206,7 @@ enum eTimer { eTimer_N }; -enum eEventCounter { +enum eEventCounterForDryRun { eFill = 0, ePrint }; @@ -220,26 +225,30 @@ enum eCutCounter { }; enum eQAEventHistograms2D { - // Common: eMultTPC_vs_NContributors = 0, + eMultTPC_vs_Centrality, // only vs. chosen centrality estimator eVertex_z_vs_MultTPC, eVertex_z_vs_NContributors, - // Run 3: - eCentFT0M_vs_CentNTPV, - // Run 2 (do not use in Run 1 converted, because there is no centrality information): - eCentRun2V0M_vs_CentRun2SPDTracklets, - eCentRun2V0M_vs_NContributors, + eCentFT0C_vs_CentNTPV, // 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) + eCentRun2V0M_vs_NContributors, // Run 2 centrality (do not use in Run 1 converted, because there is no centrality information) + eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange, + eTrackOccupancyInTimeRange_vs_MultTPC, + eTrackOccupancyInTimeRange_vs_Vertex_z, + eTrackOccupancyInTimeRange_vs_Centrality, // only vs. chosen centrality estimator eQAEventHistograms2D_N }; enum eQAParticleHistograms2D { - edcaXY_vs_Pt, + ePt_vs_dcaXY, eQAParticleHistograms2D_N }; enum eCentralityEstimators { // Run 3: - eCentFT0M = 0, + eCentFT0C = 0, + eCentFT0M, eCentFV0A, eCentNTPV, // Run 2: @@ -248,4 +257,16 @@ enum eCentralityEstimators { eCentralityEstimators_N }; +enum eOccupancyEstimators { + eTrackOccupancyInTimeRange, // from helper task o2-analysis-event-selection, see also IA's presentation in https://indico.cern.ch/event/1464946, slide 38 + eFT0COccupancyInTimeRange, // from helper task o2-analysis-event-selection + eOccupancyEstimators_N +}; + +enum eEventCounter { + eTotal, // total number of events, before any cuts are applied + eProcessed, // number of processed events, i.e. number of events which survived cuts and on which analysis have been performed + eEventCounter_N +}; + #endif // PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_ENUMS_H_ diff --git a/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h b/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h index 48ad656cba9..417690caeb4 100644 --- a/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h +++ b/PWGCF/MultiparticleCorrelations/Core/MuPa-MemberFunctions.h @@ -20,18 +20,23 @@ void BookBaseList() { - // ... + // Book base TList and store task configuration. + + // a) Book base TList; + // b) Store task configuration. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } + // a) Book base TList: TList* temp = new TList(); temp->SetOwner(kTRUE); fBaseList.setObject(temp); - // fBaseList.object->SetName("4444"); - fBasePro = new TProfile("fBasePro", "flags for the whole analysis", eConfiguration_N, 0.5, 0.5 + static_cast(eConfiguration_N)); + // b) Store 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->SetLineColor(eColor); fBasePro->SetFillColor(eFillColor); @@ -45,39 +50,46 @@ void BookBaseList() // Then, I replace placeholder with run number in DetermineAndPropagateRunNumber(T const& collision) fBasePro->GetXaxis()->SetBinLabel(eDryRun, "fDryRun"); - fBasePro->Fill(eDryRun, static_cast(tc.fDryRun)); + fBasePro->Fill(eDryRun, static_cast(tc.fDryRun)); fBasePro->GetXaxis()->SetBinLabel(eVerbose, "fVerbose"); - fBasePro->Fill(eVerbose, static_cast(tc.fVerbose)); + fBasePro->Fill(eVerbose, static_cast(tc.fVerbose)); fBasePro->GetXaxis()->SetBinLabel(eVerboseForEachParticle, "fVerboseForEachParticle"); - fBasePro->Fill(eVerboseForEachParticle, static_cast(tc.fVerboseForEachParticle)); + fBasePro->Fill(eVerboseForEachParticle, static_cast(tc.fVerboseForEachParticle)); fBasePro->GetXaxis()->SetBinLabel(eDoAdditionalInsanityChecks, "fDoAdditionalInsanityChecks"); - fBasePro->Fill(eDoAdditionalInsanityChecks, static_cast(tc.fDoAdditionalInsanityChecks)); + fBasePro->Fill(eDoAdditionalInsanityChecks, static_cast(tc.fDoAdditionalInsanityChecks)); fBasePro->GetXaxis()->SetBinLabel(eInsanityCheckForEachParticle, "fInsanityCheckForEachParticle"); - fBasePro->Fill(eInsanityCheckForEachParticle, static_cast(tc.fInsanityCheckForEachParticle)); - - fBasePro->GetXaxis()->SetBinLabel(eUseCCDB, "fUseCCDB"); - fBasePro->Fill(eUseCCDB, static_cast(tc.fUseCCDB)); + 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->Fill(eRandomSeed, static_cast(tc.fRandomSeed)); fBasePro->GetXaxis()->SetBinLabel(eUseFisherYates, "fUseFisherYates"); - fBasePro->Fill(eUseFisherYates, static_cast(tc.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->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)); fBaseList->Add(fBasePro); + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookBaseList() //============================================================ @@ -85,8 +97,7 @@ void BookBaseList() void DefaultConfiguration() { // Default task configuration. - // a) Default values are hardcoded as Configurables in the file - // MuPa-Configurables.h + // a) Default values are hardcoded as Configurables in the file MuPa-Configurables.h // b) If corresponding fields are available in an external json file at run time, the default values hardcoded here are // overwritten with values set in json file. @@ -117,11 +128,11 @@ void DefaultConfiguration() tc.fDryRun = cf_tc.cfDryRun; tc.fVerbose = cf_tc.cfVerbose; if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // yes, here + StartFunction(__FUNCTION__); // yes, here } + tc.fVerboseUtility = cf_tc.cfVerboseUtility; tc.fVerboseForEachParticle = cf_tc.cfVerboseForEachParticle; tc.fDoAdditionalInsanityChecks = cf_tc.cfDoAdditionalInsanityChecks; - tc.fUseCCDB = cf_tc.cfUseCCDB; // Set automatically what to process, from an implicit variable "doprocessSomeProcessName" within a PROCESS_SWITCH clause: tc.fProcess[eProcessRec] = doprocessRec; tc.fProcess[eProcessRecSim] = doprocessRecSim; @@ -187,8 +198,10 @@ void DefaultConfiguration() tc.fUseFisherYates = cf_tc.cfUseFisherYates; tc.fFixedNumberOfRandomlySelectedTracks = cf_tc.cfFixedNumberOfRandomlySelectedTracks; tc.fUseStopwatch = cf_tc.cfUseStopwatch; + tc.fFloatingPointPrecision = cf_tc.cfFloatingPointPrecision; + tc.fSequentialBailout = cf_tc.cfSequentialBailout; - // *) Event histograms: + // *) Event histograms (for QA see below): eh.fEventHistogramsName[eNumberOfEvents] = "NumberOfEvents"; eh.fEventHistogramsName[eTotalMultiplicity] = "TotalMultiplicity"; eh.fEventHistogramsName[eSelectedTracks] = "SelectedTracks"; @@ -203,6 +216,7 @@ void DefaultConfiguration() eh.fEventHistogramsName[eVertex_z] = "Vertex_z"; eh.fEventHistogramsName[eNContributors] = "NContributors"; eh.fEventHistogramsName[eImpactParameter] = "ImpactParameter"; + eh.fEventHistogramsName[eOccupancy] = "Occupancy"; for (Int_t 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)); @@ -229,6 +243,7 @@ void DefaultConfiguration() ec.fEventCutName[eVertex_z] = "Vertex_z"; ec.fEventCutName[eNContributors] = "NContributors"; ec.fEventCutName[eImpactParameter] = "ImpactParameter"; + ec.fEventCutName[eOccupancy] = "Occupancy"; ec.fEventCutName[eTrigger] = "Trigger"; ec.fEventCutName[eSel7] = "Sel7"; ec.fEventCutName[eSel8] = "Sel8"; @@ -239,13 +254,14 @@ void DefaultConfiguration() ec.fEventCutName[eIsVertexITSTPC] = "IsVertexITSTPC"; ec.fEventCutName[eIsVertexTOFmatched] = "IsVertexTOFmatched"; ec.fEventCutName[eIsVertexTRDmatched] = "IsVertexTRDmatched"; + ec.fEventCutName[eOccupancyEstimator] = "OccupancyEstimator"; for (Int_t 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()); } } - // *) Particle histograms 1D: + // *) Particle histograms 1D (for QA see below): ph.fParticleHistogramsName[ePhi] = "Phi"; ph.fParticleHistogramsName[ePt] = "Pt"; ph.fParticleHistogramsName[eEta] = "Eta"; @@ -268,7 +284,7 @@ void DefaultConfiguration() } } - // *) Particle histograms 2D: + // *) 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++) { @@ -316,23 +332,23 @@ void DefaultConfiguration() // *) Multiparticle correlations: mupa.fCalculateCorrelations = cf_mupa.cfCalculateCorrelations; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_INTEGRATED] = cf_mupa.cfCalculateCorrelationsAsFunctionOfIntegrated; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_MULTIPLICITY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfMultiplicity; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_CENTRALITY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfCentrality; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] = cf_mupa.cfCalculateCorrelationsAsFunctionOfPt; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] = cf_mupa.cfCalculateCorrelationsAsFunctionOfEta; + mupa.fCalculateCorrelationsAsFunctionOf[AFO_OCCUPANCY] = cf_mupa.cfCalculateCorrelationsAsFunctionOfOccupancy; // *) Test0: - // TBI 20250506 Implemented this way, I miss possibility to switch off all Test0 flags in one go. Re-think if i really need that. - t0.fCalculateTest0 = cf_t0.cfCalculateTest0; // + see below, how it's automatically set via other Test0 flags + t0.fCalculateTest0 = cf_t0.cfCalculateTest0; t0.fCalculateTest0AsFunctionOf[AFO_INTEGRATED] = cf_t0.cfCalculateTest0AsFunctionOfIntegrated; t0.fCalculateTest0AsFunctionOf[AFO_MULTIPLICITY] = cf_t0.cfCalculateTest0AsFunctionOfMultiplicity; t0.fCalculateTest0AsFunctionOf[AFO_CENTRALITY] = cf_t0.cfCalculateTest0AsFunctionOfCentrality; t0.fCalculateTest0AsFunctionOf[AFO_PT] = cf_t0.cfCalculateTest0AsFunctionOfPt; t0.fCalculateTest0AsFunctionOf[AFO_ETA] = cf_t0.cfCalculateTest0AsFunctionOfEta; - // Use above Test0 flags to automatically set the main Test0 flag: TBI 20240521 do I really want to do it this way? - for (Int_t v = 0; v < eAsFunctionOf_N; v++) { - if (t0.fCalculateTest0AsFunctionOf[v]) { - t0.fCalculateTest0 = true; - break; // yes, it suffices one diff. flag to be true, for the main Test0 flag to be true - } - } + t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY] = cf_t0.cfCalculateTest0AsFunctionOfOccupancy; t0.fFileWithLabels = TString(cf_t0.cfFileWithLabels); + t0.fUseDefaultLabels = cf_t0.cfUseDefaultLabels; // *) Particle weights: pw.fUseWeights[wPHI] = cf_pw.cfUsePhiWeights; @@ -342,6 +358,10 @@ void DefaultConfiguration() pw.fUseDiffWeights[wPHIETA] = cf_pw.cfUseDiffPhiEtaWeights; pw.fFileWithWeights = cf_pw.cfFileWithWeights; + // *) Centrality weights: + cw.fUseCentralityWeights = cf_cw.cfUseCentralityWeights; + cw.fFileWithCentralityWeights = cf_cw.cfFileWithCentralityWeights; + // ... // *) Nested loops: @@ -388,6 +408,7 @@ void DefaultConfiguration() // *) histogram names with custom NUA distributions in that file + get those histograms immediately here: auto lCustomNUAPDFHistNames = (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()); LOGF(info, "\033[1;31m eNUAPDF_N = %d\033[0m", static_cast(eNUAPDF_N)); @@ -434,19 +455,31 @@ void DefaultConfiguration() qa.fCheckUnderflowAndOverflow = cf_qa.cfCheckUnderflowAndOverflow; // **) Centrality estimators: + qa.fCentralityEstimatorName[eCentFT0C] = "CentFT0C"; qa.fCentralityEstimatorName[eCentFT0M] = "CentFT0M"; qa.fCentralityEstimatorName[eCentFV0A] = "CentFV0A"; qa.fCentralityEstimatorName[eCentNTPV] = "CentNTPV"; qa.fCentralityEstimatorName[eCentRun2V0M] = "CentRun2V0M"; qa.fCentralityEstimatorName[eCentRun2SPDTracklets] = "CentRun2SPDTracklets"; - // **) Names of 2D event histograms: + // **) Occupancy estimators: + qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange] = "TrackOccupancyInTimeRange"; + qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange] = "FT0COccupancyInTimeRange"; + + // **) Names of QA 2D event histograms: + // Remark: Do NOT use FancyFormatting here, only later in BookQAHistograms() for axis titles! qa.fEventHistogramsName2D[eMultTPC_vs_NContributors] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultTPC].Data(), eh.fEventHistogramsName[eNContributors].Data()); + qa.fEventHistogramsName2D[eMultTPC_vs_Centrality] = Form("%s_vs_%s", eh.fEventHistogramsName[eMultTPC].Data(), eh.fEventHistogramsName[eCentrality].Data()); qa.fEventHistogramsName2D[eVertex_z_vs_MultTPC] = Form("%s_vs_%s", eh.fEventHistogramsName[eVertex_z].Data(), eh.fEventHistogramsName[eMultTPC].Data()); qa.fEventHistogramsName2D[eVertex_z_vs_NContributors] = Form("%s_vs_%s", eh.fEventHistogramsName[eVertex_z].Data(), eh.fEventHistogramsName[eNContributors].Data()); + qa.fEventHistogramsName2D[eCentFT0C_vs_CentNTPV] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentFT0C].Data(), qa.fCentralityEstimatorName[eCentNTPV].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[eCentRun2V0M_vs_NContributors] = Form("%s_vs_%s", qa.fCentralityEstimatorName[eCentRun2V0M].Data(), eh.fEventHistogramsName[eNContributors].Data()); + qa.fEventHistogramsName2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = Form("%s_vs_%s", qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data(), qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange].Data()); + qa.fEventHistogramsName2D[eTrackOccupancyInTimeRange_vs_MultTPC] = Form("%s_vs_%s", qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data(), eh.fEventHistogramsName[eMultTPC].Data()); + qa.fEventHistogramsName2D[eTrackOccupancyInTimeRange_vs_Vertex_z] = Form("%s_vs_%s", qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data(), eh.fEventHistogramsName[eVertex_z].Data()); + qa.fEventHistogramsName2D[eTrackOccupancyInTimeRange_vs_Centrality] = Form("%s_vs_%s", qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data(), eh.fEventHistogramsName[eCentrality].Data()); // ***) Quick insanity check that all names are set: for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) { @@ -455,8 +488,8 @@ void DefaultConfiguration() } } - // **) Names of 2D particle histograms: - qa.fParticleHistogramsName2D[edcaXY_vs_Pt] = Form("%s_vs_%s", ph.fParticleHistogramsName[edcaXY].Data(), ph.fParticleHistogramsName[ePt].Data()); + // **) Names of QA 2D particle histograms: + 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++) { @@ -465,6 +498,10 @@ void DefaultConfiguration() } } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void DefaultConfiguration() //============================================================ @@ -476,10 +513,13 @@ Bool_t Alright(TString s) // a) Insanity check on the format; // b) Do the thing. - if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + if (tc.fVerboseUtility) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m TString s = %s\033[0m", s.Data()); } + Bool_t returnValue = kFALSE; + // a) Insanity check on the format: TObjArray* oa = s.Tokenize("-"); if (!oa) { @@ -494,14 +534,19 @@ Bool_t Alright(TString s) // Algorithm: I split "someName-0" with respect to "-" as a field separator, and check what is in the 2nd field. if (TString(oa->At(1)->GetName()).EqualTo("0")) { delete oa; - return kFALSE; + returnValue = kFALSE; } else if (TString(oa->At(1)->GetName()).EqualTo("1")) { delete oa; - return kTRUE; + returnValue = kTRUE; } else { 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()); } - return kFALSE; // obsolete, but suppresses the warning + + if (tc.fVerboseUtility) { + ExitFunction(__FUNCTION__); + } + + return returnValue; } // Bool_t Alright(const char* name) @@ -518,7 +563,7 @@ void DefaultBooking() // e) QA; if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Event histograms 1D: @@ -529,7 +574,7 @@ void DefaultBooking() // 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. // Ordering of the flags in that array is interpreted through ordering of enums in enum eEventHistograms. - auto lBookEventHistograms = (vector)cf_eh.cfBookEventHistograms; // this is now the local version of that int array from configurable. + auto lBookEventHistograms = cf_eh.cfBookEventHistograms.value; // this is now the local version of that string array from configurable. if (lBookEventHistograms.size() != eEventHistograms_N) { LOGF(info, "\033[1;31m lBookEventHistograms.size() = %d\033[0m", lBookEventHistograms.size()); LOGF(info, "\033[1;31m eEventHistograms_N) = %d\033[0m", static_cast(eEventHistograms_N)); @@ -560,6 +605,7 @@ void DefaultBooking() eh.fBookEventHistograms[eVertex_z] = Alright(lBookEventHistograms[eVertex_z]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eNContributors] = Alright(lBookEventHistograms[eNContributors]) && eh.fFillEventHistograms; eh.fBookEventHistograms[eImpactParameter] = Alright(lBookEventHistograms[eImpactParameter]) && eh.fFillEventHistograms; + eh.fBookEventHistograms[eOccupancy] = Alright(lBookEventHistograms[eOccupancy]) && eh.fFillEventHistograms; // b) Event histograms 2D: // TBI 20240515 Ideally, all 2D shall go to QA group, see below @@ -570,7 +616,7 @@ void DefaultBooking() // *) 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). // Ordering of the flags in that array is interpreted through ordering of enums in enum eParticleHistograms. // TBI 20240124 is this safe enough? - auto lBookParticleHistograms = (vector)cf_ph.cfBookParticleHistograms; // this is now the local version of that int array from configurable. TBI 20240124 why is this casting mandatory? + auto lBookParticleHistograms = cf_ph.cfBookParticleHistograms.value; // this is now the local version of that string array from configurable. if (lBookParticleHistograms.size() != eParticleHistograms_N) { LOGF(info, "\033[1;31m lBookParticleHistograms.size() = %d\033[0m", lBookParticleHistograms.size()); LOGF(info, "\033[1;31m eParticleHistograms_N) = %d\033[0m", static_cast(eParticleHistograms_N)); @@ -611,14 +657,24 @@ void DefaultBooking() 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). - // Ordering of the flags in that array is interpreted through ordering of enums in enum eParticleHistograms2D. // TBI 20240124 is this safe enough? - auto lBookParticleHistograms2D = (vector)cf_ph.cfBookParticleHistograms2D; // this is now the local version of that int array from configurable. TBI 20240124 why is this casting mandatory? + // *) Ordering of the flags in that array is interpreted through ordering of enums in enum eParticleHistograms2D. + auto lBookParticleHistograms2D = cf_ph.cfBookParticleHistograms2D.value; // this is now the local version of that string array from configurable + // TBI 20241113 For some reason, the default values of configurable "cfBookParticleHistograms2D" are not correctly propagated in the local variables, but I can circumvent that with JSON settings for the time being if (lBookParticleHistograms2D.size() != eParticleHistograms2D_N) { LOGF(info, "\033[1;31m lBookParticleHistograms2D.size() = %d\033[0m", lBookParticleHistograms2D.size()); LOGF(info, "\033[1;31m eParticleHistograms2D_N) = %d\033[0m", static_cast(eParticleHistograms2D_N)); LOGF(fatal, "in function \033[1;31m%s at line %d Mismatch in the number of flags in configurable cfBookParticleHistograms2D, and number of entries in enum eParticleHistograms2D \n \033[0m", __FUNCTION__, __LINE__); } + // *) 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++) { + // TBI 20241109 I could implement even a strickter EqualTo instead of BeginsWith, but then I need to tokenize, etc., etc. This shall be safe enough. + if (!TString(lBookParticleHistograms2D[name]).BeginsWith(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\" \033[0m", __FUNCTION__, __LINE__, name, TString(lBookParticleHistograms2D[name]).Data(), ph.fParticleHistogramsName2D[name].Data()); + } + } + // I append "&& ph.fFillParticleHistograms2D" below, to switch off booking of all 2D particle histograms with one common flag: ph.fBookParticleHistograms2D[ePhiPt] = Alright(lBookParticleHistograms2D[ePhiPt]) && ph.fFillParticleHistograms2D; ph.fBookParticleHistograms2D[ePhiEta] = Alright(lBookParticleHistograms2D[ePhiEta]) && ph.fFillParticleHistograms2D; @@ -630,7 +686,8 @@ void DefaultBooking() // *) If you do not want particular 2D event histogram to be booked, use configurable array cfBookQAEventHistograms2D, 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 eQAEventHistograms2D - auto lBookQAEventHistograms2D = (vector)cf_qa.cfBookQAEventHistograms2D; // this is now the local version of that int array from configurable + auto lBookQAEventHistograms2D = cf_qa.cfBookQAEventHistograms2D.value; // this is now the local version of that string array from configurable + // TBI 20241115 For some reason, the default values of configurable "cfBookQAEventHistograms2D" are not correctly propagated in the local variables, but I can circumvent that with JSON settings for the time being if (lBookQAEventHistograms2D.size() != eQAEventHistograms2D_N) { LOGF(info, "\033[1;31m lBookQAEventHistograms2D.size() = %d\033[0m", lBookQAEventHistograms2D.size()); LOGF(info, "\033[1;31m eQAEventHistograms2D_N = %d\033[0m", static_cast(eQAEventHistograms2D_N)); @@ -648,11 +705,17 @@ void DefaultBooking() // I append "&& qa.fFillQAEventHistograms2D" below, to switch off booking of all 2D event histograms with one common flag: qa.fBookQAEventHistograms2D[eMultTPC_vs_NContributors] = Alright(lBookQAEventHistograms2D[eMultTPC_vs_NContributors]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eMultTPC_vs_Centrality] = Alright(lBookQAEventHistograms2D[eMultTPC_vs_Centrality]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eVertex_z_vs_MultTPC] = Alright(lBookQAEventHistograms2D[eVertex_z_vs_MultTPC]) && qa.fFillQAEventHistograms2D; qa.fBookQAEventHistograms2D[eVertex_z_vs_NContributors] = Alright(lBookQAEventHistograms2D[eVertex_z_vs_NContributors]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eCentFT0C_vs_CentNTPV] = Alright(lBookQAEventHistograms2D[eCentFT0C_vs_CentNTPV]) && 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[eCentRun2V0M_vs_NContributors] = Alright(lBookQAEventHistograms2D[eCentRun2V0M_vs_NContributors]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = Alright(lBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_MultTPC] = Alright(lBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_MultTPC]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Vertex_z] = Alright(lBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Vertex_z]) && qa.fFillQAEventHistograms2D; + qa.fBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Centrality] = Alright(lBookQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Centrality]) && qa.fFillQAEventHistograms2D; // **) QA 2D particle histograms: qa.fFillQAParticleHistograms2D = cf_qa.cfFillQAParticleHistograms2D; @@ -676,10 +739,14 @@ void DefaultBooking() } // I append "&& qa.fFillQAParticleHistograms2D" below, to switch off booking of all 2D particle histograms with one common flag: - qa.fBookQAParticleHistograms2D[edcaXY_vs_Pt] = Alright(lBookQAParticleHistograms2D[edcaXY_vs_Pt]) && qa.fFillQAParticleHistograms2D; + qa.fBookQAParticleHistograms2D[ePt_vs_dcaXY] = Alright(lBookQAParticleHistograms2D[ePt_vs_dcaXY]) && qa.fFillQAParticleHistograms2D; // ... + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void DefaultBooking() //============================================================ @@ -698,7 +765,7 @@ void DefaultBinning() // e) Variable-length binning set via MuPa-Configurables.h. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Default binning for event histograms: @@ -706,32 +773,32 @@ void DefaultBinning() eh.fEventHistogramsBins[eNumberOfEvents][1] = 0.; eh.fEventHistogramsBins[eNumberOfEvents][2] = 1.; - eh.fEventHistogramsBins[eTotalMultiplicity][0] = 20000; - eh.fEventHistogramsBins[eTotalMultiplicity][1] = -1.e5; + eh.fEventHistogramsBins[eTotalMultiplicity][0] = 10000; + eh.fEventHistogramsBins[eTotalMultiplicity][1] = 0.; eh.fEventHistogramsBins[eTotalMultiplicity][2] = 1.e5; - eh.fEventHistogramsBins[eSelectedTracks][0] = 20000; - eh.fEventHistogramsBins[eSelectedTracks][1] = -1.e5; + eh.fEventHistogramsBins[eSelectedTracks][0] = 10000; + eh.fEventHistogramsBins[eSelectedTracks][1] = 0.; eh.fEventHistogramsBins[eSelectedTracks][2] = 1.e5; - eh.fEventHistogramsBins[eMultFV0M][0] = 20000; - eh.fEventHistogramsBins[eMultFV0M][1] = -1.e5; + eh.fEventHistogramsBins[eMultFV0M][0] = 10000; + eh.fEventHistogramsBins[eMultFV0M][1] = 0.; eh.fEventHistogramsBins[eMultFV0M][2] = 1.e5; - eh.fEventHistogramsBins[eMultFT0M][0] = 20000; - eh.fEventHistogramsBins[eMultFT0M][1] = -1.e5; + eh.fEventHistogramsBins[eMultFT0M][0] = 10000; + eh.fEventHistogramsBins[eMultFT0M][1] = 0.; eh.fEventHistogramsBins[eMultFT0M][2] = 1.e5; - eh.fEventHistogramsBins[eMultTPC][0] = 20000; - eh.fEventHistogramsBins[eMultTPC][1] = -1.e5; + eh.fEventHistogramsBins[eMultTPC][0] = 10000; + eh.fEventHistogramsBins[eMultTPC][1] = 0.; eh.fEventHistogramsBins[eMultTPC][2] = 1.e5; - eh.fEventHistogramsBins[eMultNTracksPV][0] = 20000; - eh.fEventHistogramsBins[eMultNTracksPV][1] = -1.e5; + eh.fEventHistogramsBins[eMultNTracksPV][0] = 10000; + eh.fEventHistogramsBins[eMultNTracksPV][1] = 0.; eh.fEventHistogramsBins[eMultNTracksPV][2] = 1.e5; - eh.fEventHistogramsBins[eMultTracklets][0] = 20000; - eh.fEventHistogramsBins[eMultTracklets][1] = -1.e5; + eh.fEventHistogramsBins[eMultTracklets][0] = 10000; + eh.fEventHistogramsBins[eMultTracklets][1] = 0.; eh.fEventHistogramsBins[eMultTracklets][2] = 1.e5; eh.fEventHistogramsBins[eCentrality][0] = 120; // intentionally, because if centrality is not determined, it's set to 105.0 at the moment @@ -755,8 +822,12 @@ void DefaultBinning() eh.fEventHistogramsBins[eNContributors][2] = 10000.; eh.fEventHistogramsBins[eImpactParameter][0] = 2000; - eh.fEventHistogramsBins[eImpactParameter][1] = -1000.; - eh.fEventHistogramsBins[eImpactParameter][2] = 1000.; // It's set to -999 is not meaningful + eh.fEventHistogramsBins[eImpactParameter][1] = -1000.; // It's set to -999 if not meaningful + eh.fEventHistogramsBins[eImpactParameter][2] = 1000.; + + eh.fEventHistogramsBins[eOccupancy][0] = 151; + eh.fEventHistogramsBins[eOccupancy][1] = -100.; // It's set to -1 if not meaningful TBI 20241109 check this further + eh.fEventHistogramsBins[eOccupancy][2] = 15000.; // b) Default binning for particle histograms 1D: ph.fParticleHistogramsBins[ePhi][0] = 360; @@ -846,77 +917,161 @@ void DefaultBinning() res.fResultsProFixedLengthBins[AFO_INTEGRATED][0] = 1; res.fResultsProFixedLengthBins[AFO_INTEGRATED][1] = 0.; res.fResultsProFixedLengthBins[AFO_INTEGRATED][2] = 1.; - // *) Fixed-length binning vs. multiplicity: - auto lFixedLength_mult_bins = (vector)cf_res.cfFixedLength_mult_bins; // this is now the local version of that float array from configurable. - if (lFixedLength_mult_bins.size() != 3) { - LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfFixedLength_mult_bins must have 3 entries: {nBins, min, max} \n \033[0m", __FUNCTION__, __LINE__); - } - res.fResultsProFixedLengthBins[AFO_MULTIPLICITY][0] = lFixedLength_mult_bins[0]; - res.fResultsProFixedLengthBins[AFO_MULTIPLICITY][1] = lFixedLength_mult_bins[1]; - res.fResultsProFixedLengthBins[AFO_MULTIPLICITY][2] = lFixedLength_mult_bins[2]; - + this->InitializeFixedLengthBins(AFO_MULTIPLICITY); // *) Fixed-length binning vs. centrality: - auto lFixedLength_cent_bins = (vector)cf_res.cfFixedLength_cent_bins; // this is now the local version of that float array from configurable. - if (lFixedLength_cent_bins.size() != 3) { - LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfFixedLength_cent_bins must have 3 entries: {nBins, min, max} \n \033[0m", __FUNCTION__, __LINE__); - } - res.fResultsProFixedLengthBins[AFO_CENTRALITY][0] = lFixedLength_cent_bins[0]; - res.fResultsProFixedLengthBins[AFO_CENTRALITY][1] = lFixedLength_cent_bins[1]; - res.fResultsProFixedLengthBins[AFO_CENTRALITY][2] = lFixedLength_cent_bins[2]; - + this->InitializeFixedLengthBins(AFO_CENTRALITY); // *) Fixed-length binning vs. pt: - auto lFixedLength_pt_bins = (vector)cf_res.cfFixedLength_pt_bins; // this is now the local version of that float array from configurable. - if (lFixedLength_pt_bins.size() != 3) { - LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfFixedLength_pt_bins must have 3 entries: {nBins, min, max} \n \033[0m", __FUNCTION__, __LINE__); - } - res.fResultsProFixedLengthBins[AFO_PT][0] = lFixedLength_pt_bins[0]; - res.fResultsProFixedLengthBins[AFO_PT][1] = lFixedLength_pt_bins[1]; - res.fResultsProFixedLengthBins[AFO_PT][2] = lFixedLength_pt_bins[2]; - + this->InitializeFixedLengthBins(AFO_PT); // *) Fixed-length binning vs. eta: - auto lFixedLength_eta_bins = (vector)cf_res.cfFixedLength_eta_bins; // this is now the local version of that float array from configurable. - if (lFixedLength_eta_bins.size() != 3) { - LOGF(fatal, "in function \033[1;31m%s at line %d => The array cfFixedLength_eta_bins must have 3 entries: {nBins, min, max} \n \033[0m", __FUNCTION__, __LINE__); - } - res.fResultsProFixedLengthBins[AFO_ETA][0] = lFixedLength_eta_bins[0]; - res.fResultsProFixedLengthBins[AFO_ETA][1] = lFixedLength_eta_bins[1]; - res.fResultsProFixedLengthBins[AFO_ETA][2] = lFixedLength_eta_bins[2]; + this->InitializeFixedLengthBins(AFO_ETA); + // *) Fixed-length binning vs. occupancy: + this->InitializeFixedLengthBins(AFO_OCCUPANCY); // e) Variable-length binning set via MuPa-Configurables.h: // *) Variable-length binning vs. multiplicity: if (cf_res.cfUseVariableLength_mult_bins) { - res.fUseResultsProVariableLengthBins[AFO_MULTIPLICITY] = kTRUE; - res.fResultsProVariableLengthBinsString[AFO_MULTIPLICITY] = cf_res.cfVariableLength_mult_bins; - this->CastStringIntoArray(AFO_MULTIPLICITY); + this->InitializeVariableLengthBins(AFO_MULTIPLICITY); } // *) Variable-length binning vs. centrality: if (cf_res.cfUseVariableLength_cent_bins) { - res.fUseResultsProVariableLengthBins[AFO_CENTRALITY] = kTRUE; - res.fResultsProVariableLengthBinsString[AFO_CENTRALITY] = cf_res.cfVariableLength_cent_bins; - this->CastStringIntoArray(AFO_CENTRALITY); + this->InitializeVariableLengthBins(AFO_CENTRALITY); } // *) Variable-length binning vs. pt: if (cf_res.cfUseVariableLength_pt_bins) { - res.fUseResultsProVariableLengthBins[AFO_PT] = kTRUE; - res.fResultsProVariableLengthBinsString[AFO_PT] = cf_res.cfVariableLength_pt_bins; - this->CastStringIntoArray(AFO_PT); + this->InitializeVariableLengthBins(AFO_PT); } // *) Variable-length binning vs. eta: if (cf_res.cfUseVariableLength_eta_bins) { - res.fUseResultsProVariableLengthBins[AFO_ETA] = kTRUE; - res.fResultsProVariableLengthBinsString[AFO_ETA] = cf_res.cfVariableLength_eta_bins; - this->CastStringIntoArray(AFO_ETA); + this->InitializeVariableLengthBins(AFO_ETA); + } + // *) Variable-length binning vs. occupancy: + if (cf_res.cfUseVariableLength_occu_bins) { + this->InitializeVariableLengthBins(AFO_OCCUPANCY); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); } } // void DefaultBinning() //============================================================ +void InitializeFixedLengthBins(eAsFunctionOf AFO) +{ + // This is a helper function to suppress code bloat in DefaultBinning(). + // It merely initalizes res.fResultsProFixedLengthBins[...] from corresponding configurables + a few other minor thingies. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // Common local vector for all fixed-length bins: + vector lFixedLength_bins; + + switch (AFO) { + case AFO_MULTIPLICITY: + lFixedLength_bins = cf_res.cfFixedLength_mult_bins.value; + break; + case AFO_CENTRALITY: + lFixedLength_bins = cf_res.cfFixedLength_cent_bins.value; + break; + case AFO_PT: + lFixedLength_bins = cf_res.cfFixedLength_pt_bins.value; + break; + case AFO_ETA: + lFixedLength_bins = cf_res.cfFixedLength_eta_bins.value; + break; + case AFO_OCCUPANCY: + lFixedLength_bins = cf_res.cfFixedLength_occu_bins.value; + break; + // ... + 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]; + + 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__); + } + +} // void InitializeFixedLengthBins(eAsFunctionOf AFO) + +//============================================================ + +void InitializeVariableLengthBins(eAsFunctionOf AFO) +{ + // 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) { + StartFunction(__FUNCTION__); + } + + // Common local vector for all variable-length bins: + vector lVariableLength_bins; + + switch (AFO) { + case AFO_MULTIPLICITY: + lVariableLength_bins = cf_res.cfVariableLength_mult_bins.value; + break; + case AFO_CENTRALITY: + lVariableLength_bins = cf_res.cfVariableLength_cent_bins.value; + break; + case AFO_PT: + lVariableLength_bins = cf_res.cfVariableLength_pt_bins.value; + break; + case AFO_ETA: + lVariableLength_bins = cf_res.cfVariableLength_eta_bins.value; + break; + case AFO_OCCUPANCY: + lVariableLength_bins = cf_res.cfVariableLength_occu_bins.value; + break; + // ... + 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()); + 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)); + } + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void InitializeVariableLengthBins(eAsFunctionOf AFO) + +//============================================================ + void CastStringIntoArray(Int_t 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. - // TBI 20240114 This function is used until I figure out how to pass array directly via configurable. + + // TBI 20241019 This function is not needed any longer, remove eventually. if (tc.fVerbose) { LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); @@ -931,9 +1086,8 @@ void CastStringIntoArray(Int_t AFO) 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(); - res.fResultsProVariableLengthBins[AFO] = new TArrayD(nEntries); + res.fResultsProVariableLengthBins[AFO] = new TArrayF(nEntries); for (Int_t i = 0; i < nEntries; i++) { - // cout<< TString(oa->At(i)->GetName()).Atof() <AddAt(TString(oa->At(i)->GetName()).Atof(), i); } delete oa; // yes, otherwise it's a memory leak @@ -960,7 +1114,7 @@ void DefaultCuts() // b) Default particle cuts. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Default event cuts: @@ -998,6 +1152,7 @@ void DefaultCuts() ec.fUseEventCuts[eVertex_z] = Alright(lUseEventCuts[eVertex_z]); ec.fUseEventCuts[eNContributors] = Alright(lUseEventCuts[eNContributors]); ec.fUseEventCuts[eImpactParameter] = Alright(lUseEventCuts[eImpactParameter]); + ec.fUseEventCuts[eOccupancy] = Alright(lUseEventCuts[eOccupancy]); // *) from enum eEventCuts: ec.fUseEventCuts[eTrigger] = Alright(lUseEventCuts[eTrigger]); ec.fUseEventCuts[eSel7] = Alright(lUseEventCuts[eSel7]); @@ -1009,6 +1164,7 @@ void DefaultCuts() ec.fUseEventCuts[eIsVertexITSTPC] = Alright(lUseEventCuts[eIsVertexITSTPC]); ec.fUseEventCuts[eIsVertexTOFmatched] = Alright(lUseEventCuts[eIsVertexTOFmatched]); ec.fUseEventCuts[eIsVertexTRDmatched] = Alright(lUseEventCuts[eIsVertexTRDmatched]); + ec.fUseEventCuts[eOccupancyEstimator] = Alright(lUseEventCuts[eOccupancyEstimator]); // **) event cuts defined via booleans: ec.fUseEventCuts[eSel7] = ec.fUseEventCuts[eSel7] && cf_ec.cfUseSel7; @@ -1076,6 +1232,10 @@ void DefaultCuts() ec.fdEventCuts[eImpactParameter][eMin] = lImpactParameter[eMin]; ec.fdEventCuts[eImpactParameter][eMax] = lImpactParameter[eMax]; + auto lOccupancy = (vector)cf_ec.cfOccupancy; + ec.fdEventCuts[eOccupancy][eMin] = lOccupancy[eMin]; + ec.fdEventCuts[eOccupancy][eMax] = lOccupancy[eMax]; + auto lSelectedEvents = (vector)cf_ec.cfSelectedEvents; ec.fdEventCuts[eSelectedEvents][eMin] = lSelectedEvents[eMin]; ec.fdEventCuts[eSelectedEvents][eMax] = lSelectedEvents[eMax]; @@ -1083,6 +1243,7 @@ void DefaultCuts() // **) event cuts defined via string: ec.fsEventCuts[eCentralityEstimator] = cf_ec.cfCentralityEstimator; ec.fsEventCuts[eTrigger] = cf_ec.cfTrigger; + ec.fsEventCuts[eOccupancyEstimator] = cf_ec.cfOccupancyEstimator; // ---------------------------------------------------------------------- @@ -1207,75 +1368,154 @@ void DefaultCuts() // **) particles cuts defined via string: pc.fsParticleCuts[ePtDependentDCAxyParameterization] = cf_pc.cfPtDependentDCAxyParameterization; + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void DefaultCuts() //============================================================ -void InsanityChecks() +void InsanityChecksBeforeBooking() { - // Do insanity checks on configuration, booking, binning and cuts. + // Do insanity checks on configuration, binning and cuts. Values to be checked are either hardwired locally, or obtained from configurables. + // Remember that here I cannot do insanity checks on local hostograms, etc., because they are not vbooked yet. + // For those additional checks, use InsanityChecksAfterBooking(). // a) Insanity checks on configuration; - // b) Insanity checks on event cuts; - // c) Insanity checks on booking; + // b) Ensure that Run 1/2 specific cuts and flags are used only in Run 1/2 (both data and sim); + // c) Ensure that Run 3 specific cuts and flags are used only in Run 3 (both data and sim); // d) Insanity checks on binning; - // e) Insanity checks on cuts; + // e) Insanity checks on events cuts; // f) Insanity checks on Toy NUA; - // g) Insanity checks on internal validation. + // g) Insanity checks on internal validation; + // h) Insanity checks on results histograms. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Insanity checks on configuration: - // Remark: Here I also classify all cases which couple 2 or more categories: - // *) Cannot calculate multiparticle correlations, in case Q-vectors are not filled: + // **) Cannot calculate multiparticle correlations, in case Q-vectors are not filled: if (mupa.fCalculateCorrelations && !qv.fCalculateQvectors) { LOGF(fatal, "\033[1;31m%s at line %d : Cannot calculate multiparticle correlations, in case Q-vectors are not filled \033[0m", __FUNCTION__, __LINE__); } - // *) Cannot calculate Test0, in case Q-vectors are not filled: + // **) 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++) { + 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); + } + } + + // **) Cannot calculate Test0, in case Q-vectors are not filled: if (t0.fCalculateTest0 && !qv.fCalculateQvectors) { LOGF(fatal, "\033[1;31m%s at line %d : Cannot calculate Test0, in case Q-vectors are not filled \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. - // Re-think this if it's possible to run different process(...)'s concurently over the same data. + // **) 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++) { + 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: + if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && !tc.fUseFisherYates) { + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + } + + // **) When it comes to DCAxy cut, ensure that either flat or pt-dependent cut is used, but not both: + if (pc.fUseParticleCuts[edcaXY] && pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { + 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. + // 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(fatal, "in function \033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - // *) Insanity checks on event cuts: + // **) Insanity checks on event cuts: if (ec.fUseEventCuts[eTrigger] && !(tc.fProcess[eProcessRec_Run2])) { LOGF(fatal, "\033[1;31m%s at line %d : trigger \"%s\" => From documentation: Bypass this check if you analyse MC or continuous Run3 data. By now, it's validated only for \"Rec_Run2\", for other cases, simply switch off this event cut eTrigger. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eTrigger].Data()); } + // **) This check is meant to prevent the case when I want to bailout for max number of events, but I do not fill event histograms: + if (ec.fdEventCuts[eNumberOfEvents][eMax] < 1e6) { // TBI 20241011 Do I need to tune 1000000000 + // If I do not want to bail out when max number of events is reached, then in the configurable I have e.g. cfNumberOfEvents{"cfNumberOfEvents", {-1, 1000000000} + // 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__); + } + } + + // **) Check if the trigger makes sense 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 and Run 1 converted real data if (!(ec.fUseEventCuts[eTrigger] && ec.fsEventCuts[eTrigger].EqualTo("kINT7"))) { // TBI 20240223 expand this list with other supported triggers eventually in this category (see if(...) above) 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 programmattic access to "event-selection-task" flags "isMC and "isRunMC" . Then I can directly bail out. + // 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] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { // From documentation: Bypass this check if you analyse MC or continuous Run3 data. + // **) Do NOT use eTrigger for Run 3. From documentation: Bypass this check if you analyse MC or continuous Run3 data: + // TBI 20241023 this needs further scrutiny + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { if (ec.fUseEventCuts[eTrigger]) { LOGF(fatal, "\033[1;31m%s at line %d : offline trigger eTrigger (e.g. kINT7) cannot be used in Run 3\033[0m", __FUNCTION__, __LINE__); } } - if (ec.fUseEventCuts[eSel7]) { // from doc: for Run 2 data and MC + // **) Ensure that fFloatingPointPrecision makes sense: + if (!(tc.fFloatingPointPrecision > 0.)) { + LOGF(fatal, "\033[1;31m%s at line %d : set fFloatingPointPrecision = %f to some small positive value, which will determine if two floats are the same \033[0m", __FUNCTION__, __LINE__, tc.fFloatingPointPrecision); + } + + // **) Ensure that fSequentialBailout makes sense: + if (!(tc.fSequentialBailout >= 0)) { + 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); + } + + // 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]) { 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])) { LOGF(fatal, "\033[1;31m%s at line %d : use fSel7 for Run 2 data and MC\033[0m", __FUNCTION__, __LINE__); } } - if (ec.fUseEventCuts[eSel8]) { // from doc: for Run 3 data and MC + // **) 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()); + } + } + + // **) 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[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__); + } + 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__); + } + } + + // ... + + // 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])) { LOGF(fatal, "\033[1;31m%s at line %d : use eSel8 only for Run 3 data and MC\033[0m", __FUNCTION__, __LINE__); } @@ -1311,29 +1551,25 @@ void InsanityChecks() } } - if (tc.fFixedNumberOfRandomlySelectedTracks > 0 && !tc.fUseFisherYates) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); - } - + // **) Supported centrality estimators for Run 3 are enlisted here: if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim] || tc.fProcess[eProcessSim]) { - // Supported centrality estimators for Run 3 are enlisted here: - if (!(ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0M", TString::kIgnoreCase) || + if (!(ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0C", 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. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); + 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()); } } - 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]) { - // Supported centrality estimators for Run 3 are enlisted here: - 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 yet for converted Run 2 and Run 1 analysis. \033[0m", __FUNCTION__, __LINE__, ec.fsEventCuts[eCentralityEstimator].Data()); + // **) Supported occupancy estimators for Run 3 are enlisted here: + if (tc.fProcess[eProcessRec] || tc.fProcess[eProcessRecSim]) { + 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()); } } - // *) Insanity checks on particle cuts: - // **) Protection against particle cuts which are available, but not yet validated, or are meaningless, in Run 3: + // **) 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 (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__); @@ -1343,32 +1579,20 @@ void InsanityChecks() } } - // **) 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[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__); - } - 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__); - } - } - - // **) When it comes to DCAxy cut, ensure that either flat or pt-dependent cut is used, but not both: - if (pc.fUseParticleCuts[edcaXY] && pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { - 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 checks on booking: + // d) Insanity checks on binning: // ... - // *) Insanity checks on binning: + // e) Insanity checks on events cuts: // ... - // *) Insanity checks on cuts: + // f) Insanity checks on Toy NUA: // ... - // *) 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() + // 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() 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__); @@ -1388,7 +1612,114 @@ void InsanityChecks() } // if (iv.fUseInternalValidation) { -} // void InsanityChecks() + // h) Insanity checks on results histograms: + // **) Check if all arrays are initialized until the end: + for (Int_t 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); + } + + 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++) { + + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void InsanityChecksBeforeBooking() + +//============================================================ + +void InsanityChecksAfterBooking() +{ + // Do insanity checks on all booked histograms, etc., + // Configuration, binning and cuts are checked already before booking in InsanityChecksBeforeBooking(). + + // a) Insanity checks on booking; + // b) Insanity checks on internal validation; + // ... + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // 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.) { + 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.) { + 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__); + } + + // **) Print a warning if this histogram is not booked: + if (!eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { + LOGF(warning, "\033[1;31m%s at line %d : eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] is not booked => no info on the total number of events in internal validation can be provided \033[0m", __FUNCTION__, __LINE__); + } + + } // end of if (iv.fUseInternalValidation) { + + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void InsanityChecksAfterBooking() + +//============================================================ + +Bool_t Skip(Int_t recOrSim) +{ + // Decide here whether a certain histogram, etc., will be booked and used both for eRec and eSim. + // Same for cuts. + + if (tc.fVerboseUtility) { + StartFunction(__FUNCTION__); + } + + // *) Insanity check: + if (!(recOrSim == eRec || recOrSim == eSim)) { + LOGF(fatal, "\033[1;31m%s at line %d : recOrSim = %d \033[0m", __FUNCTION__, __LINE__, recOrSim); + } + + // *) If I am doing internal validation, I book and fill only eSim: + if (iv.fUseInternalValidation) { + if (recOrSim == eRec) { + return kTRUE; // yes, skip + } else { + return kFALSE; // 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 kFALSE; // by default, I do not skip anything + +} // Bool_t Skip(Int_t recOrSim) //============================================================ @@ -1400,6 +1731,7 @@ void BookAndNestAllLists() // *) Correlations; // *) Q-vectors; // *) Particle weights; + // *) Centrality weights; // *) Nested loops; // *) Toy NUA; // *) Internal validation; @@ -1407,7 +1739,7 @@ void BookAndNestAllLists() // *) Results. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // *) QA: @@ -1458,6 +1790,12 @@ void BookAndNestAllLists() pw.fWeightsList->SetOwner(kTRUE); fBaseList->Add(pw.fWeightsList); + // *) Centrality weights: + cw.fCentralityWeightsList = new TList(); + cw.fCentralityWeightsList->SetName("CentralityWeights"); + cw.fCentralityWeightsList->SetOwner(kTRUE); + fBaseList->Add(cw.fCentralityWeightsList); + // *) Nested loops: nl.fNestedLoopsList = new TList(); nl.fNestedLoopsList->SetName("NestedLoops"); @@ -1488,6 +1826,10 @@ void BookAndNestAllLists() res.fResultsList->SetOwner(kTRUE); fBaseList->Add(res.fResultsList); + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookAndNestAllLists() //============================================================ @@ -1504,11 +1846,21 @@ void BookQAHistograms() // d) Book specific QA 2D particle histograms. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + 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: + */ + 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", 2, 0., 2.); // TBI 20240515 re-think how to organize the binning here + qa.fQAHistogramsPro = new TProfile("fQAHistogramsPro", "flags for QA histograms", 3, 0., 3.); qa.fQAHistogramsPro->SetStats(kFALSE); qa.fQAHistogramsPro->SetLineColor(eColor); qa.fQAHistogramsPro->SetFillColor(eFillColor); @@ -1516,6 +1868,8 @@ void BookQAHistograms() 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)); // ... @@ -1539,35 +1893,55 @@ void BookQAHistograms() TString title_y_Event[eQAEventHistograms2D_N] = {""}; // *) "MultTPC_vs_NContributors": - nBins_x_Event[eMultTPC_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]) / 10; // TBI 20240504 hardcoded number + nBins_x_Event[eMultTPC_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]); // TBI 20240702 add support for rebinning min_x_Event[eMultTPC_vs_NContributors] = eh.fEventHistogramsBins[eMultTPC][1]; max_x_Event[eMultTPC_vs_NContributors] = eh.fEventHistogramsBins[eMultTPC][2]; title_x_Event[eMultTPC_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eMultTPC].Data()); - nBins_y_Event[eMultTPC_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0]) / 10; // TBI 20240504 hardcoded number + nBins_y_Event[eMultTPC_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0]); // TBI 20240702 add support for rebinning min_y_Event[eMultTPC_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][1]; max_y_Event[eMultTPC_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][2]; title_y_Event[eMultTPC_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); + // *) "MultTPC_vs_Centrality": + nBins_x_Event[eMultTPC_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]); // TBI 20240702 add support for rebinning + min_x_Event[eMultTPC_vs_Centrality] = eh.fEventHistogramsBins[eMultTPC][1]; + max_x_Event[eMultTPC_vs_Centrality] = eh.fEventHistogramsBins[eMultTPC][2]; + title_x_Event[eMultTPC_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eMultTPC].Data()); + nBins_y_Event[eMultTPC_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); // TBI 20240702 add support for rebinning + min_y_Event[eMultTPC_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eMultTPC_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eMultTPC_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + // *) "Vertex_z_vs_MultTPC": - nBins_x_Event[eVertex_z_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]) / 10; // TBI 20240504 hardcoded number + nBins_x_Event[eVertex_z_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); // TBI 20240702 add support for rebinning min_x_Event[eVertex_z_vs_MultTPC] = eh.fEventHistogramsBins[eVertex_z][1]; max_x_Event[eVertex_z_vs_MultTPC] = eh.fEventHistogramsBins[eVertex_z][2]; title_x_Event[eVertex_z_vs_MultTPC] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); - nBins_y_Event[eVertex_z_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]) / 100; // TBI 20240504 hardcoded number + nBins_y_Event[eVertex_z_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]); // TBI 20240702 add support for rebinning min_y_Event[eVertex_z_vs_MultTPC] = eh.fEventHistogramsBins[eMultTPC][1]; max_y_Event[eVertex_z_vs_MultTPC] = eh.fEventHistogramsBins[eMultTPC][2]; title_y_Event[eVertex_z_vs_MultTPC] = FancyFormatting(eh.fEventHistogramsName[eMultTPC].Data()); // *) "Vertex_z_vs_NContributors": - nBins_x_Event[eVertex_z_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]) / 10; // TBI 20240504 hardcoded number + nBins_x_Event[eVertex_z_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); // TBI 20240702 add support for rebinning min_x_Event[eVertex_z_vs_NContributors] = eh.fEventHistogramsBins[eVertex_z][1]; max_x_Event[eVertex_z_vs_NContributors] = eh.fEventHistogramsBins[eVertex_z][2]; title_x_Event[eVertex_z_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); - nBins_y_Event[eVertex_z_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0]) / 10; // TBI 20240504 hardcoded number + nBins_y_Event[eVertex_z_vs_NContributors] = static_cast(eh.fEventHistogramsBins[eNContributors][0]); // TBI 20240702 add support for rebinning min_y_Event[eVertex_z_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][1]; max_y_Event[eVertex_z_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][2]; title_y_Event[eVertex_z_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); + // *) "eCentFT0C_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]; + title_x_Event[eCentFT0C_vs_CentNTPV] = FancyFormatting(qa.fCentralityEstimatorName[eCentFT0C].Data()); + nBins_y_Event[eCentFT0C_vs_CentNTPV] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eCentFT0C_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eCentFT0C_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eCentFT0C_vs_CentNTPV] = FancyFormatting(qa.fCentralityEstimatorName[eCentNTPV].Data()); + // *) "eCentFT0M_vs_CentNTPV": nBins_x_Event[eCentFT0M_vs_CentNTPV] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); min_x_Event[eCentFT0M_vs_CentNTPV] = eh.fEventHistogramsBins[eCentrality][1]; @@ -1598,17 +1972,68 @@ void BookQAHistograms() max_y_Event[eCentRun2V0M_vs_NContributors] = eh.fEventHistogramsBins[eNContributors][2]; title_y_Event[eCentRun2V0M_vs_NContributors] = FancyFormatting(eh.fEventHistogramsName[eNContributors].Data()); + // *) "eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange": + nBins_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = static_cast(eh.fEventHistogramsBins[eOccupancy][0]); + min_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][1]; + max_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][2]; + title_x_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = FancyFormatting(qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data()); + nBins_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = static_cast(eh.fEventHistogramsBins[eOccupancy][0]); + min_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][1]; + max_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = eh.fEventHistogramsBins[eOccupancy][2] * 10; // TBI 20241112 I extend here manually this axis temporarily + title_y_Event[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange] = FancyFormatting(qa.fOccupancyEstimatorName[eFT0COccupancyInTimeRange].Data()); + + // *) "eTrackOccupancyInTimeRange_vs_MultTPC": + nBins_x_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eOccupancy][0]); + min_x_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = eh.fEventHistogramsBins[eOccupancy][1]; + max_x_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = eh.fEventHistogramsBins[eOccupancy][2]; + title_x_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = FancyFormatting(qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data()); + nBins_y_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = static_cast(eh.fEventHistogramsBins[eMultTPC][0]); + min_y_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = eh.fEventHistogramsBins[eMultTPC][1]; + max_y_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = eh.fEventHistogramsBins[eMultTPC][2]; + title_y_Event[eTrackOccupancyInTimeRange_vs_MultTPC] = FancyFormatting(eh.fEventHistogramsName[eMultTPC].Data()); + + // *) "eTrackOccupancyInTimeRange_vs_Vertex_z": + nBins_x_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eOccupancy][0]); + min_x_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = eh.fEventHistogramsBins[eOccupancy][1]; + max_x_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = eh.fEventHistogramsBins[eOccupancy][2]; + title_x_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = FancyFormatting(qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data()); + nBins_y_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = static_cast(eh.fEventHistogramsBins[eVertex_z][0]); + min_y_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][1]; + max_y_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = eh.fEventHistogramsBins[eVertex_z][2]; + title_y_Event[eTrackOccupancyInTimeRange_vs_Vertex_z] = FancyFormatting(eh.fEventHistogramsName[eVertex_z].Data()); + + // *) "eTrackOccupancyInTimeRange_vs_Centrality": + nBins_x_Event[eTrackOccupancyInTimeRange_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eOccupancy][0]); + min_x_Event[eTrackOccupancyInTimeRange_vs_Centrality] = eh.fEventHistogramsBins[eOccupancy][1]; + max_x_Event[eTrackOccupancyInTimeRange_vs_Centrality] = eh.fEventHistogramsBins[eOccupancy][2]; + title_x_Event[eTrackOccupancyInTimeRange_vs_Centrality] = FancyFormatting(qa.fOccupancyEstimatorName[eTrackOccupancyInTimeRange].Data()); + nBins_y_Event[eTrackOccupancyInTimeRange_vs_Centrality] = static_cast(eh.fEventHistogramsBins[eCentrality][0]); + min_y_Event[eTrackOccupancyInTimeRange_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][1]; + max_y_Event[eTrackOccupancyInTimeRange_vs_Centrality] = eh.fEventHistogramsBins[eCentrality][2]; + title_y_Event[eTrackOccupancyInTimeRange_vs_Centrality] = FancyFormatting(eh.fEventHistogramsName[eCentrality].Data()); + // ... // *) Quick insanity check on title_x_Event and title_y_Event: for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) { + + // **) title_x_Event: + if (tc.fVerbose) { + LOGF(info, "\033[1;32m title_x_Event[%d] = %s \033[0m", t, title_x_Event[t].Data()); + } if (title_x_Event[t].EqualTo("")) { LOGF(fatal, "\033[1;31m%s at line %d : title_x_Event[%d] is not set, check corresponding enum \033[0m", __FUNCTION__, __LINE__, t); } + + // **) title_y_Event: + if (tc.fVerbose) { + LOGF(info, "\033[1;32m title_y_Event[%d] = %s \033[0m", t, title_y_Event[t].Data()); + } if (title_y_Event[t].EqualTo("")) { 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++) { // Okay, let's book 'em all: for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D @@ -1618,24 +2043,17 @@ void BookQAHistograms() } for (Int_t rs = 0; rs < 2; rs++) // reco/sim { - // 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] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { - continue; - } - // If I am doing internal validation, I need only sim: - if (iv.fUseInternalValidation && rs == eRec) { + if (Skip(rs)) { continue; } for (Int_t ba = 0; ba < 2; ba++) // before/after cuts { - qa.fQAEventHistograms2D[t][rs][ba] = new TH2D( + qa.fQAEventHistograms2D[t][rs][ba] = new TH2F( Form("fQAEventHistograms2D[%s][%s][%s]", qa.fEventHistogramsName2D[t].Data(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[ba].Data()), // __RUN_NUMBER__ is handled in DetermineAndPropagateRunNumber(T const& collision) 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()); qa.fQAEventHistograms2D[t][rs][ba]->SetLineColor(ec.fBeforeAfterColor[ba]); @@ -1643,8 +2061,8 @@ void BookQAHistograms() qa.fQAEventHistograms2D[t][rs][ba]->SetOption("col"); qa.fQAList->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(ph.fParticleHistogramsBins[edcaXY][0]) / 10; // TBI 20240504 hardcoded number - min_x_Particle[edcaXY_vs_Pt] = ph.fParticleHistogramsBins[edcaXY][1]; - max_x_Particle[edcaXY_vs_Pt] = ph.fParticleHistogramsBins[edcaXY][2]; - title_x_Particle[edcaXY_vs_Pt] = FancyFormatting(ph.fParticleHistogramsName[edcaXY].Data()); - nBins_y_Particle[edcaXY_vs_Pt] = static_cast(ph.fParticleHistogramsBins[ePt][0]) / 10; // TBI 20240504 hardcoded number - min_y_Particle[edcaXY_vs_Pt] = ph.fParticleHistogramsBins[ePt][1]; - max_y_Particle[edcaXY_vs_Pt] = ph.fParticleHistogramsBins[ePt][2]; - title_y_Particle[edcaXY_vs_Pt] = FancyFormatting(ph.fParticleHistogramsName[ePt].Data()); + // *) "pt_vs_dcaXY": + nBins_x_Particle[ePt_vs_dcaXY] = static_cast(ph.fParticleHistogramsBins[ePt][0]); // TBI 20240702 add support for rebinning + min_x_Particle[ePt_vs_dcaXY] = ph.fParticleHistogramsBins[ePt][1]; + max_x_Particle[ePt_vs_dcaXY] = ph.fParticleHistogramsBins[ePt][2]; + title_x_Particle[ePt_vs_dcaXY] = FancyFormatting(ph.fParticleHistogramsName[ePt].Data()); + nBins_y_Particle[ePt_vs_dcaXY] = static_cast(ph.fParticleHistogramsBins[edcaXY][0]); // TBI 20240702 add support for rebinning + min_y_Particle[ePt_vs_dcaXY] = ph.fParticleHistogramsBins[edcaXY][1]; + max_y_Particle[ePt_vs_dcaXY] = ph.fParticleHistogramsBins[edcaXY][2]; + title_y_Particle[ePt_vs_dcaXY] = FancyFormatting(ph.fParticleHistogramsName[edcaXY].Data()); // ... @@ -1689,20 +2107,14 @@ void BookQAHistograms() } for (Int_t rs = 0; rs < 2; rs++) // reco/sim { - // 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] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { - continue; - } - // If I am doing internal validation, I need only sim: - if (iv.fUseInternalValidation && rs == eRec) { + if (Skip(rs)) { continue; } for (Int_t ba = 0; ba < 2; ba++) // before/after cuts { - qa.fQAParticleHistograms2D[t][rs][ba] = new TH2D( + qa.fQAParticleHistograms2D[t][rs][ba] = new TH2F( Form("fQAParticleHistograms2D[%s][%s][%s]", qa.fParticleHistogramsName2D[t].Data(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[ba].Data()), // __RUN_NUMBER__ is handled in DetermineAndPropagateRunNumber(T const& collision) nBins_x_Particle[t], min_x_Particle[t], max_x_Particle[t], nBins_y_Particle[t], min_y_Particle[t], max_y_Particle[t]); @@ -1714,8 +2126,12 @@ void BookQAHistograms() qa.fQAParticleHistograms2D[t][rs][ba]->SetOption("col"); qa.fQAList->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;tSetStats(kFALSE); 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); @@ -1752,16 +2170,10 @@ void BookEventHistograms() if (!eh.fBookEventHistograms[t]) { continue; } + for (Int_t rs = 0; rs < 2; rs++) // reco/sim { - // 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] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { - continue; - } - - // If I am doing internal validation, I need only sim: - if (iv.fUseInternalValidation && rs == eRec) { + if (Skip(rs)) { continue; } @@ -1772,20 +2184,22 @@ void BookEventHistograms() if (ba == eBefore && eh.fEventHistogramsName[t].EqualTo("SelectedTracks")) { continue; } - - eh.fEventHistograms[t][rs][ba] = new TH1D( + eh.fEventHistograms[t][rs][ba] = new TH1F( Form("fEventHistograms[%s][%s][%s]", eh.fEventHistogramsName[t].Data(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[ba].Data()), // __RUN_NUMBER__ is handled in DetermineAndPropagateRunNumber(T const& collision) 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;t(eEventCuts_N) + 0.5); + ec.fEventCutCounterHist[rs][cc] = new TH1I(Form("fEventCutCounterHist[%s][%s]", srs[rs].Data(), scc[cc].Data()), Form("%s, %s, event cut counter (%s)", "__RUN_NUMBER__", srs_long[rs].Data(), 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]->SetLineColor(eColor); ec.fEventCutCounterHist[rs][cc]->SetFillColor(eFillColor); @@ -1861,6 +2270,10 @@ void BookEventCutsHistograms() } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookEventCutsHistograms() //============================================================ @@ -1874,7 +2287,7 @@ void BookParticleHistograms() // c) Book specific particle histograms 2D. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -1883,7 +2296,9 @@ void BookParticleHistograms() ph.fParticleHistogramsPro->SetStats(kFALSE); ph.fParticleHistogramsPro->SetLineColor(eColor); ph.fParticleHistogramsPro->SetFillColor(eFillColor); - // ... TBI 20240418 I shall fill something in this config profile... + ph.fParticleHistogramsPro->GetXaxis()->SetBinLabel(1, "fFillParticleHistograms"); + ph.fParticleHistogramsPro->Fill(0.5, static_cast(ph.fFillParticleHistograms)); + // ... ph.fParticleHistogramsList->Add(ph.fParticleHistogramsPro); // b) Book specific particle histograms 1D: @@ -1900,8 +2315,7 @@ void BookParticleHistograms() for (Int_t rs = 0; rs < 2; rs++) // reco/sim { - // **) If I am analyzing only reconstructed data, do not book histos for simulated, and vice versa. - if ((tc.fProcess[eGenericRec] && rs == eSim) || (tc.fProcess[eGenericSim] && rs == eRec)) { + if (Skip(rs)) { continue; } @@ -1912,14 +2326,9 @@ void BookParticleHistograms() } } - // **) If I am doing internal validation, I need only sim: - if (iv.fUseInternalValidation && rs == eRec) { - continue; - } - for (Int_t ba = 0; ba < 2; ba++) // before/after cuts { - ph.fParticleHistograms[t][rs][ba] = new TH1D(Form("fParticleHistograms[%s][%s][%s]", ph.fParticleHistogramsName[t].Data(), srs[rs].Data(), sba[ba].Data()), + ph.fParticleHistograms[t][rs][ba] = new TH1F(Form("fParticleHistograms[%s][%s][%s]", ph.fParticleHistogramsName[t].Data(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[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]); @@ -1932,8 +2341,8 @@ void BookParticleHistograms() 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], // TBI 20240418 this is not safe, eX doesn't have to be phi axis in general, but it's ok for the time being => re-thing and fix later - 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("PhiEta") && res.fUseResultsProVariableLengthBins[AFO_ETA]) { + static_cast(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(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[ba].Data()), - static_cast(ph.fParticleHistogramsBins2D[t][eX][0]), ph.fParticleHistogramsBins2D[t][eX][1], ph.fParticleHistogramsBins2D[t][eX][2], // TBI 20240418 this is not safe, eX doesn't have to be phi axis in general, but it's ok for the time being => re-thing and fix later - 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 + 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-langth binnging: + // default fixed-length binning: ph.fParticleHistograms2D[t][rs][ba] = new TH2D(Form("fParticleHistograms2D[%s][%s][%s]", ph.fParticleHistogramsName2D[t].Data(), srs[rs].Data(), sba[ba].Data()), Form("%s, %s, %s", "__RUN_NUMBER__", srs_long[rs].Data(), sba_long[ba].Data()), static_cast(ph.fParticleHistogramsBins2D[t][eX][0]), ph.fParticleHistogramsBins2D[t][eX][1], ph.fParticleHistogramsBins2D[t][eX][2], @@ -1996,9 +2407,13 @@ void BookParticleHistograms() 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(eParticleCuts_N) + 0.5); + pc.fParticleCutCounterHist[rs][cc] = new TH1I(Form("fParticleCutCounterHist[%s][%s]", srs[rs].Data(), scc[cc].Data()), Form("%s, %s, particle cut counter (%s)", "__RUN_NUMBER__", srs_long[rs].Data(), scc_long[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]->SetLineColor(eColor); pc.fParticleCutCounterHist[rs][cc]->SetFillColor(eFillColor); @@ -2080,11 +2491,15 @@ void BookParticleCutsHistograms() if (pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { pc.fPtDependentDCAxyFormula = new TFormula("fPtDependentDCAxyFormula", pc.fsParticleCuts[ePtDependentDCAxyParameterization].Data()); // As a quick insanity check, try immediately to evaluate something from this formula: - if (isnan(pc.fPtDependentDCAxyFormula->Eval(1.44))) { + if (std::isnan(pc.fPtDependentDCAxyFormula->Eval(1.44))) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } } // if(pc.fUseParticleCuts[ePtDependentDCAxyParameterization]) { + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookParticleCutsHistograms() //============================================================ @@ -2097,7 +2512,7 @@ void BookQvectorHistograms() // b) ... if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2117,6 +2532,10 @@ void BookQvectorHistograms() // b) ... + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookQvectorHistograms() //============================================================ @@ -2131,7 +2550,7 @@ void BookCorrelationsHistograms() // d) Few quick insanity checks on booking. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2163,9 +2582,28 @@ void BookCorrelationsHistograms() { for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic { - for (Int_t v = 0; v < eAsFunctionOf_N; - v++) // variable [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pt,4=eta] - { + 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 && !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 (!res.fResultsPro[v]) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } @@ -2177,7 +2615,7 @@ void BookCorrelationsHistograms() 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_t 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")) { @@ -2187,6 +2625,10 @@ void BookCorrelationsHistograms() 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 (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // BookCorrelationsHistograms() //============================================================ @@ -2196,11 +2638,11 @@ void BookWeightsHistograms() // Book all objects for particle weights. // a) Book the profile holding flags; - // b) Histograms; + // b) Histograms for integrated weights; // c) Histograms for differential weights. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2213,8 +2655,8 @@ void BookWeightsHistograms() 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})"); - pw.fWeightsFlagsPro->GetXaxis()->SetBinLabel(5, "w_{#varphi}(#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] { @@ -2230,13 +2672,54 @@ void BookWeightsHistograms() } pw.fWeightsList->Add(pw.fWeightsFlagsPro); - // b) Histograms: + // b) Histograms for integrated weights: // As of 20240216, I have abandoned the idea to generate integrated weights internally, weights // are always fetched and cloned from external files, in any case (local, AliEn, CCDB). // Therefore, add histos with weights to this list only after they are cloned from external files. // c) Histograms for differential weights: - // Same comment applies as for c) => add histograms to the list, only after they are cloned from external files. + // Same comment applies as for b) => add histograms to the list, only after they are cloned from external files. + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void BookWeightsHistograms() + +//============================================================ + +void BookCentralityWeightsHistograms() +{ + // Book all objects for particle centrality weights. + + // a) Book the profile holding flags; + // b) Histograms for centrality weights. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // a) Book the profile holding flags: + cw.fCentralityWeightsFlagsPro = + new TProfile("fWeightsFlagsPro", "flags for centrality weights", 1, 0., 1.); + cw.fCentralityWeightsFlagsPro->SetStats(kFALSE); + 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 (cw.fUseCentralityWeights) { + cw.fCentralityWeightsFlagsPro->Fill(0.5, 1.); // TBI 20241118 shall I automate this? + } + cw.fCentralityWeightsList->Add(cw.fCentralityWeightsFlagsPro); + + // b) Histograms for centrality weights: + // As of 20240216, I have abandoned the idea to generate centrality weights internally, centrality weights + // are always fetched and cloned from external files, in any case (local, AliEn, CCDB). + // Therefore, add histos with centrality weights to this list only after they are cloned from external files. + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } // void BookWeightsHistograms() @@ -2252,7 +2735,7 @@ void BookNestedLoopsHistograms() // d) Few quick insanity checks on booking. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2315,9 +2798,7 @@ void BookNestedLoopsHistograms() for (Int_t n = 0; n < gMaxHarmonic; n++) // harmonic { - for (Int_t v = 0; v < eAsFunctionOf_N; - v++) // variable [0=integrated,1=vs. multiplicity,2=vs. centrality,3=pt,4=eta] - { + for (Int_t v = 0; v < eAsFunctionOf_N; v++) { // if(PTKINE == v && !fCalculatePtCorrelations){continue;} // if(ETAKINE == v && !fCalculateEtaCorrelations){continue;} @@ -2329,8 +2810,7 @@ void BookNestedLoopsHistograms() 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]->Sumw2(); - nl.fNestedLoopsPro[k][n][v]->GetXaxis()->SetTitle( - res.fResultsProXaxisTitle[v].Data()); + nl.fNestedLoopsPro[k][n][v]->GetXaxis()->SetTitle(res.fResultsProXaxisTitle[v].Data()); /* if(fUseFixedNumberOfRandomlySelectedTracks && 1==v) // just a warning @@ -2345,8 +2825,8 @@ void BookNestedLoopsHistograms() nl.fNestedLoopsList->Add(nl.fNestedLoopsPro[k][n][v]); } // for(Int_t 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_t n = 0; n < gMaxHarmonic; n++) // harmonic + } // for (Int_t 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")) { @@ -2356,6 +2836,10 @@ void BookNestedLoopsHistograms() 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 (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookNestedLoopsHistograms() //============================================================ @@ -2369,7 +2853,7 @@ void BookNUAHistograms() // c) Histograms. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2494,6 +2978,10 @@ void BookNUAHistograms() } // for(Int_t pdf=0;pdfSetStats(kFALSE); iv.fInternalValidationFlagsPro->SetLineColor(eColor); iv.fInternalValidationFlagsPro->SetFillColor(eFillColor); @@ -2581,6 +3069,10 @@ void BookInternalValidationHistograms() LOGF(fatal, "\033[1;31m%s at line %d : iv.fMultRangeInternalValidation[eMin] >= iv.fMultRangeInternalValidation[eMax] \n \033[0m", __FUNCTION__, __LINE__); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // BookInternalValidationHistograms() //============================================================ @@ -2595,7 +3087,7 @@ TComplex TheoreticalValue(TArrayI* harmonics, TArrayD* amplitudes, TArrayD* plan // c) Return value. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Insanity checks: @@ -2620,6 +3112,9 @@ TComplex TheoreticalValue(TArrayI* harmonics, TArrayD* amplitudes, TArrayD* plan } // for(Int_t h=0;hGetSize();h++) // c) Return value: + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } return value; } // TComplex TheoreticalValue(TArrayI *harmonics, TArrayD *amplitudes, TArrayD *planes) @@ -2630,21 +3125,23 @@ void InternalValidation() { // Internal validation against theoretical values in on-the-fly study for all implemented correlators. + // Last update: 20241111 + // To do: // 20231114 Do I need to add support for diff. weights also here? // a) Fourier like p.d.f. for azimuthal angles and flow amplitudes; // b) Loop over on-the-fly events. - // b0) Reset ebe quantities; + // b0) Reset ebye quantities; // b1) Determine multiplicity, centrality, reaction plane and configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e; - // b2) Fill event histograms; + // b2) Fill event histograms before cuts; // b3) Loop over particles; - // b4) Calculate correlations; - // b5) Optionally, cross-check with nested loops; + // b4) Fill event histograms after cuts; + // b5) Calculate everything for selected events and particles; // c) Delete persistent objects. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Fourier like p.d.f. for azimuthal angles and flow amplitudes: @@ -2679,8 +3176,8 @@ void InternalValidation() for (Int_t 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) { + 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 @@ -2702,53 +3199,51 @@ void InternalValidation() } // else if(fHarmonicsOptionInternalValidation->EqualTo("correlated")) // b) Loop over on-the-fly events: - // Double_t step = 10.; // in percentage. Used only for the printout of progress - // TStopwatch watch; - // watch.Start(); Double_t v1 = 0., v2 = 0., v3 = 0.; for (Int_t e = 0; e < static_cast(iv.fnEventsInternalValidation); e++) { - // b0) Reset ebe quantities: + // 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 = gRandom->Uniform(iv.fMultRangeInternalValidation[eMin], iv.fMultRangeInternalValidation[eMax]); + Int_t nMult = static_cast(gRandom->Uniform(iv.fMultRangeInternalValidation[eMin], iv.fMultRangeInternalValidation[eMax])); - Double_t fReactionPlane = gRandom->Uniform(0., TMath::TwoPi()); + Double_t fReactionPlane = gRandom->Uniform(0., TMath::TwoPi()); // no cast is needed, since Uniform(...) returns double if (iv.fHarmonicsOptionInternalValidation->EqualTo("constant")) { fPhiPDF->SetParameter(18, fReactionPlane); } else if (iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { fPhiPDF->SetParameter(3, fReactionPlane); } - ebye.fCentrality = gRandom->Uniform(0., 100.); // 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 - // b2) Fill event histograms: + // b2) Fill event histograms before cuts: if (eh.fFillEventHistograms) { - !eh.fEventHistograms[eNumberOfEvents][eSim][eAfter] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->Fill(0.5); - !eh.fEventHistograms[eTotalMultiplicity][eSim][eAfter] ? true : eh.fEventHistograms[eTotalMultiplicity][eSim][eAfter]->Fill(nMult); - !eh.fEventHistograms[eSelectedTracks][eSim][eAfter] ? true : eh.fEventHistograms[eSelectedTracks][eSim][eAfter]->Fill(ebye.fSelectedTracks); - !eh.fEventHistograms[eCentrality][eSim][eAfter] ? true : eh.fEventHistograms[eCentrality][eSim][eAfter]->Fill(ebye.fCentrality); + !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); + !eh.fEventHistograms[eCentrality][eSim][eBefore] ? true : eh.fEventHistograms[eCentrality][eSim][eBefore]->Fill(ebye.fCentrality); + !eh.fEventHistograms[eOccupancy][eSim][eBefore] ? true : eh.fEventHistograms[eCentrality][eSim][eBefore]->Fill(ebye.fOccupancy); } + // ... here I could implement some event cuts, if necessary ... + // configure p.d.f. for azimuthal angles if harmonics are not constant e-by-e: if (iv.fHarmonicsOptionInternalValidation->EqualTo("correlated")) { // Sample 3 correlated vn's from TF3 fvnPDF, and with them initialize fPhiPDF: fvnPDF->GetRandom3(v1, v2, v3); - // cout<SetParameter(0, v1); fPhiPDF->SetParameter(1, v2); fPhiPDF->SetParameter(2, v3); // reaction plane is set above } // if(fHarmonicsOptionInternalValidation->EqualTo("correlated")) - // b2) Loop over particles: + // b3) Loop over particles: Double_t dPhi = 0.; Double_t dPt = 0.; Double_t dEta = 0.; - // ..) Define min and max ranges for sampling: + // *) 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 @@ -2759,15 +3254,15 @@ void InternalValidation() dPhi = fPhiPDF->GetRandom(); // *) To increase performance, sample pt or eta only if requested: - if (mupa.fCalculateCorrelations || t0.fCalculateTest0AsFunctionOf[AFO_PT]) { // TBI 20240423 The first switch I need to replace with differentual switch, like I have it for Test0 now + if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT]) { dPt = gRandom->Uniform(dPt_min, dPt_max); } - if (mupa.fCalculateCorrelations || t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { // TBI 20240423 The first switch I need to replace with differentual switch, like I have it for Test0 now + if (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { dEta = gRandom->Uniform(dEta_min, dEta_max); } - // *) Fill few selected particle histograms before cuts here directly here: + // *) 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) { // 1D: @@ -2809,11 +3304,11 @@ void InternalValidation() } // *) Differential q-vectors: - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_PT]) { // TBI 20240423 I need to extend this condition to mupa.fCalculateCorrelations or some differential version of it - this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT])) { + this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum } - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { // TBI 20240423 I need to extend this condition to mupa.fCalculateCorrelations or some differential version of it - this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA])) { + this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum } // *) Fill nested loops containers: @@ -2822,6 +3317,7 @@ void InternalValidation() } // *) Counter of selected tracks in the current event: + // Remark: This has to go after FillNestedLoopsContainers(...), because ebye.fSelectedTracks is used as a particle index there. ebye.fSelectedTracks++; if (ebye.fSelectedTracks >= ec.fdEventCuts[eSelectedTracks][eMax]) { break; @@ -2829,28 +3325,44 @@ void InternalValidation() } // for(Int_t p=0;pFill(0.5); + !eh.fEventHistograms[eTotalMultiplicity][eSim][eAfter] ? true : eh.fEventHistograms[eTotalMultiplicity][eSim][eAfter]->Fill(nMult); + !eh.fEventHistograms[eSelectedTracks][eSim][eAfter] ? true : eh.fEventHistograms[eSelectedTracks][eSim][eAfter]->Fill(ebye.fSelectedTracks); + !eh.fEventHistograms[eCentrality][eSim][eAfter] ? true : eh.fEventHistograms[eCentrality][eSim][eAfter]->Fill(ebye.fCentrality); + !eh.fEventHistograms[eOccupancy][eSim][eAfter] ? true : eh.fEventHistograms[eCentrality][eSim][eAfter]->Fill(ebye.fOccupancy); + } + + // b5) Calculate everything for selected events and particles: CalculateEverything(); // *) Reset event-by-event quantities: ResetEventByEventQuantities(); - // *) Print info on the current event number after cuts: - if (tc.fVerbose) { - if (eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]) { - LOGF(info, "\033[1;32m%s : event number %d/%d\033[0m", __FUNCTION__, static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1)), static_cast(iv.fnEventsInternalValidation)); - } + // *) 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)); + + // *) Determine all event counters: + DetermineEventCounters(); + + // *) Sequential bailout: After each tc.fSequentialBailout events, I bail out: + if (iv.fInternalValidationForceBailout && tc.fSequentialBailout > 0 && eh.fEventCounter[eProcessed] > 0 && 0 == eh.fEventCounter[eProcessed] % tc.fSequentialBailout) { + BailOut(); } // *) If I reached max number of events, ignore the remaining collisions: if (MaxNumberOfEvents(eAfter)) { if (iv.fInternalValidationForceBailout) { - BailOut(); + BailOut(kTRUE); } } } // for(Int_t e=0;e(iv.fnEventsInternalValidation);e++) + // *) Print info on the current event number (total): + PrintEventCounter(eAfter); + // c) Delete persistent objects: if (fPhiPDF) { delete fPhiPDF; @@ -2859,6 +3371,10 @@ void InternalValidation() delete fvnPDF; } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void InternalValidation() //============================================================ @@ -2917,7 +3433,7 @@ void BookTest0Histograms() // e) Few quick insanity checks on booking. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -2967,6 +3483,9 @@ void BookTest0Histograms() if (AFO_ETA == v && !t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { continue; } + if (AFO_OCCUPANCY == v && !t0.fCalculateTest0AsFunctionOf[AFO_OCCUPANCY]) { + continue; + } if (!res.fResultsPro[v]) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); @@ -2984,10 +3503,10 @@ void BookTest0Histograms() } */ t0.fTest0List->Add(t0.fTest0Pro[mo][mi][v]); // yes, this has to be here - } // for(Int_t v=0;vGetXaxis()->GetTitle()).EqualTo("integrated")) { @@ -2997,6 +3516,10 @@ void BookTest0Histograms() 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 (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookTest0Histograms() //============================================================ @@ -3009,7 +3532,7 @@ void BookResultsHistograms() // b) Book results histograms, which in addition act as a sort of "abstract" interface, which defines common binning, etc., for other groups of histograms. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the profile holding flags: @@ -3039,6 +3562,10 @@ void BookResultsHistograms() } } // for (Int_t v = 0; v < eAsFunctionOf_N; v++) { + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookResultsHistograms() //============================================================ @@ -3051,7 +3578,7 @@ void BookTheRest() // *) ... if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Book the timer: @@ -3061,6 +3588,10 @@ void BookTheRest() tc.fTimer[eLocal] = new TStopwatch(); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void BookTheRest() //============================================================ @@ -3071,13 +3602,20 @@ void Preprocess(T const& collision) // Do all thingies before starting to process data (e.g. count number of events, fetch the run number, get the weights for this run number, etc.). if (tc.fVerbose) { - // LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // full function signature (including arguments, etc.), too verbose here... - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); + } + + // *) Determine all event counters: + DetermineEventCounters(); + + // *) Sequential bailout: After each tc.fSequentialBailout events, I bail out: + if (tc.fSequentialBailout > 0 && eh.fEventCounter[eProcessed] > 0 && 0 == eh.fEventCounter[eProcessed] % tc.fSequentialBailout) { + BailOut(); } // *) 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(); + BailOut(kTRUE); } // *) Determine and propagate run number info to already booked objects: @@ -3097,6 +3635,19 @@ void Preprocess(T const& collision) } } + // *) 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; + } + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void Preprocess(T const& collision) //============================================================ @@ -3114,8 +3665,7 @@ void DetermineAndPropagateRunNumber(T const& collision) // b) Propagate run number to all booked objects, wherever that info is relevant. if (tc.fVerbose) { - // LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // full function signature (including arguments, etc.), too verbose here... - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // a) Determine run number for reconstructed data: @@ -3128,7 +3678,7 @@ void DetermineAndPropagateRunNumber(T const& collision) // b) Propagate run number to all booked objects, wherever that info is relevant: // *) base: - fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("tc.fRunNumber = %s", tc.fRunNumber.Data())); + fBasePro->GetXaxis()->SetBinLabel(eRunNumber, Form("fRunNumber = %s", tc.fRunNumber.Data())); // *) common title var: TString histTitle = ""; @@ -3165,8 +3715,8 @@ void DetermineAndPropagateRunNumber(T const& collision) 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_t rs=0;rs<2;rs++) // reco/sim + } // for (Int_t 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 @@ -3203,8 +3753,8 @@ void DetermineAndPropagateRunNumber(T const& collision) 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_t rs=0;rs<2;rs++) // reco/sim + } // for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eParticleHistograms2D // *) particle cuts: for (Int_t rs = 0; rs < 2; rs++) // reco/sim @@ -3239,8 +3789,8 @@ void DetermineAndPropagateRunNumber(T const& collision) 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 void DetermineAndPropagateRunNumber(T const& collision) @@ -3270,11 +3824,19 @@ void CheckCurrentRunNumber(T const& collision) { // Insanity check for the current run number. + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + if (!tc.fRunNumber.EqualTo(Form("%d", collision.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__); LOGF(fatal, "tc.fRunNumber = %s, collision.bc().runNumber() = %d", tc.fRunNumber.Data(), collision.bc().runNumber()); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void CheckCurrentRunNumber(T const& collision) //============================================================ @@ -3289,12 +3851,13 @@ void ResetEventByEventQuantities() // d) Fisher-Yates algorithm. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Event-by-event quantities: ebye.fSelectedTracks = 0; - ebye.fCentrality = 0; + ebye.fCentrality = 0.; + ebye.fOccupancy = 0.; // b) Q-vectors: if (qv.fCalculateQvectors) { @@ -3316,9 +3879,9 @@ void ResetEventByEventQuantities() 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) + } // for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { + } // for (Int_t b = 0; b < gMaxNoBinsKine; b++ ) { + } // if(qv.fCalculateQvectors) // c) Reset ebe containers for nested loops: if (nl.fCalculateNestedLoops || nl.fCalculateCustomNestedLoops) { @@ -3350,6 +3913,10 @@ void ResetEventByEventQuantities() // ... TBI 20240117 port the rest ... + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void ResetEventByEventQuantities() //============================================================ @@ -3360,7 +3927,7 @@ void EventCutsCounters(T1 const& collision, T2 const& tracks) // Use this function to fill absolute and sequential event cut counters. Use only during QA, as this is computationally heavy. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // *) Establish ordering of binning in event cut counters histograms, which resembles ordering of event cuts implementation: @@ -3436,6 +4003,10 @@ void EventCutsCounters(T1 const& collision, T2 const& tracks) // Add same treatment for other special cases, but do not forget above to expand **) Special treatment for event cuts ... } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void EventCutsCounters(T1 const& collision, T2 const& tracks, eCutModus cutModus) //============================================================ @@ -3445,6 +4016,8 @@ Bool_t 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 , + // 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); // b) Event cuts only on simulated (common to Run 3, Run 2 and Run 1); @@ -3455,7 +4028,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) // *) Event cuts on Test case. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // a) Event cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) ... @@ -3533,7 +4106,7 @@ 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]) { + } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || TMath::Abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eTotalMultiplicity, cutModus)) { return kFALSE; } @@ -3548,7 +4121,7 @@ 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]) { + } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || TMath::Abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eCentrality, cutModus)) { return kFALSE; } @@ -3559,7 +4132,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_x]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eVertex_x, eCutCounterBinning); - } else if (collision.posX() < ec.fdEventCuts[eVertex_x][eMin] || collision.posX() > ec.fdEventCuts[eVertex_x][eMax]) { + } 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; } @@ -3570,7 +4143,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_y]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eVertex_y, eCutCounterBinning); - } else if (collision.posY() < ec.fdEventCuts[eVertex_y][eMin] || collision.posY() > ec.fdEventCuts[eVertex_y][eMax]) { + } 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; } @@ -3581,7 +4154,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_z]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax]) { + } 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; } @@ -3592,7 +4165,7 @@ 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]) { + } else if (collision.numContrib() < ec.fdEventCuts[eNContributors][eMin] || collision.numContrib() > ec.fdEventCuts[eNContributors][eMax] || TMath::Abs(collision.numContrib() - ec.fdEventCuts[eNContributors][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eNContributors, cutModus)) { return kFALSE; } @@ -3634,7 +4207,7 @@ 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]) { + } else if (collision.impactParameter() < ec.fdEventCuts[eImpactParameter][eMin] || collision.impactParameter() > ec.fdEventCuts[eImpactParameter][eMax] || TMath::Abs(collision.impactParameter() - ec.fdEventCuts[eImpactParameter][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eSim, eImpactParameter, cutModus)) { return kFALSE; } @@ -3653,7 +4226,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_x]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eVertex_x, eCutCounterBinning); - } else if (collision.posX() < ec.fdEventCuts[eVertex_x][eMin] || collision.posX() > ec.fdEventCuts[eVertex_x][eMax]) { + } 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; } @@ -3664,7 +4237,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_y]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eVertex_y, eCutCounterBinning); - } else if (collision.posY() < ec.fdEventCuts[eVertex_y][eMin] || collision.posY() > ec.fdEventCuts[eVertex_y][eMax]) { + } 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; } @@ -3675,7 +4248,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_z]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax]) { + } 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; } @@ -3705,7 +4278,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMultFV0M]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMultFV0M, eCutCounterBinning); - } else if (collision.multFV0M() < ec.fdEventCuts[eMultFV0M][eMin] || collision.multFV0M() > ec.fdEventCuts[eMultFV0M][eMax]) { + } else if (collision.multFV0M() < ec.fdEventCuts[eMultFV0M][eMin] || collision.multFV0M() > ec.fdEventCuts[eMultFV0M][eMax] || TMath::Abs(collision.multFV0M() - ec.fdEventCuts[eMultFV0M][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eVertex_z, cutModus)) { return kFALSE; } @@ -3716,7 +4289,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMultFT0M]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMultFT0M, eCutCounterBinning); - } else if (collision.multFT0M() < ec.fdEventCuts[eMultFT0M][eMin] || collision.multFT0M() > ec.fdEventCuts[eMultFT0M][eMax]) { + } else if (collision.multFT0M() < ec.fdEventCuts[eMultFT0M][eMin] || collision.multFT0M() > ec.fdEventCuts[eMultFT0M][eMax] || TMath::Abs(collision.multFT0M() - ec.fdEventCuts[eMultFT0M][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eVertex_z, cutModus)) { return kFALSE; } @@ -3727,7 +4300,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMultTPC]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMultTPC, eCutCounterBinning); - } else if (collision.multTPC() < ec.fdEventCuts[eMultTPC][eMin] || collision.multTPC() > ec.fdEventCuts[eMultTPC][eMax]) { + } else if (collision.multTPC() < ec.fdEventCuts[eMultTPC][eMin] || collision.multTPC() > ec.fdEventCuts[eMultTPC][eMax] || TMath::Abs(collision.multTPC() - ec.fdEventCuts[eMultTPC][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eVertex_z, cutModus)) { return kFALSE; } @@ -3738,13 +4311,24 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMultNTracksPV]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMultNTracksPV, eCutCounterBinning); - } else if (collision.multNTracksPV() < ec.fdEventCuts[eMultNTracksPV][eMin] || collision.multNTracksPV() > ec.fdEventCuts[eMultNTracksPV][eMax]) { + } else if (collision.multNTracksPV() < ec.fdEventCuts[eMultNTracksPV][eMin] || collision.multNTracksPV() > ec.fdEventCuts[eMultNTracksPV][eMax] || TMath::Abs(collision.multNTracksPV() - ec.fdEventCuts[eMultNTracksPV][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eMultNTracksPV, cutModus)) { return kFALSE; } } } + // *) Occupancy: + 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) { + if (!EventCut(eRec, eOccupancy, cutModus)) { + return kFALSE; + } + } + } + // ... // ... and corresponding MC truth simulated (Run 3 specific): @@ -3816,7 +4400,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eMultTracklets]) { if (cutModus == eCutCounterBinning) { EventCut(eRec, eMultTracklets, eCutCounterBinning); - } else if (collision.multTracklets() < ec.fdEventCuts[eMultTracklets][eMin] || collision.multTracklets() > ec.fdEventCuts[eMultTracklets][eMax]) { + } 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; } @@ -3867,7 +4451,7 @@ 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]) { + } else if (tracks.size() < ec.fdEventCuts[eTotalMultiplicity][eMin] || tracks.size() > ec.fdEventCuts[eTotalMultiplicity][eMax] || TMath::Abs(tracks.size() - ec.fdEventCuts[eTotalMultiplicity][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eTotalMultiplicity, cutModus)) { return kFALSE; } @@ -3878,7 +4462,7 @@ Bool_t EventCuts(T1 const& collision, T2 const& tracks, eCutModus cutModus) if (ec.fUseEventCuts[eVertex_z]) { if (cutModus == eCutCounterBinning) { EventCut(eSim, eVertex_z, eCutCounterBinning); - } else if (collision.posZ() < ec.fdEventCuts[eVertex_z][eMin] || collision.posZ() > ec.fdEventCuts[eVertex_z][eMax]) { + } 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; } @@ -3889,7 +4473,7 @@ 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]) { + } else if (ebye.fCentrality < ec.fdEventCuts[eCentrality][eMin] || ebye.fCentrality > ec.fdEventCuts[eCentrality][eMax] || TMath::Abs(ebye.fCentrality - ec.fdEventCuts[eCentrality][eMax]) < tc.fFloatingPointPrecision) { if (!EventCut(eRec, eCentrality, cutModus)) { return kFALSE; } @@ -3957,7 +4541,7 @@ Bool_t EventCut(Int_t rs, Int_t eventCut, eCutModus cutModus) template void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) { - // Fill all event histograms for reconstructed or simulated data. + // Fill all event histograms for reconstructed or simulated data. QA event histograms are also filled here. // a) Fill reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1); // b) Fill only simulated (common to Run 3, Run 2 and Run 1); @@ -3968,27 +4552,30 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // g) Test case. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // 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) { - // 1D: - !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[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[eSelectedTracks][eRec][ba] ? true : eh.fEventHistograms[eSelectedTracks][eRec][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter - !eh.fEventHistograms[eMultTPC][eRec][ba] ? true : eh.fEventHistograms[eMultTPC][eRec][ba]->Fill(collision.multTPC()); - !eh.fEventHistograms[eMultNTracksPV][eRec][ba] ? true : eh.fEventHistograms[eMultNTracksPV][eRec][ba]->Fill(collision.multNTracksPV()); - !eh.fEventHistograms[eCentrality][eRec][ba] ? true : eh.fEventHistograms[eCentrality][eRec][ba]->Fill(ebye.fCentrality); + 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[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[eSelectedTracks][eRec][ba] ? true : eh.fEventHistograms[eSelectedTracks][eRec][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter + !eh.fEventHistograms[eMultTPC][eRec][ba] ? true : eh.fEventHistograms[eMultTPC][eRec][ba]->Fill(collision.multTPC()); + !eh.fEventHistograms[eMultNTracksPV][eRec][ba] ? true : eh.fEventHistograms[eMultNTracksPV][eRec][ba]->Fill(collision.multNTracksPV()); + !eh.fEventHistograms[eCentrality][eRec][ba] ? true : eh.fEventHistograms[eCentrality][eRec][ba]->Fill(ebye.fCentrality); + } // QA: if (qa.fFillQAEventHistograms2D) { !qa.fQAEventHistograms2D[eMultTPC_vs_NContributors][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultTPC_vs_NContributors][eRec][ba]->Fill(collision.multTPC(), collision.numContrib()); + !qa.fQAEventHistograms2D[eMultTPC_vs_Centrality][eRec][ba] ? true : qa.fQAEventHistograms2D[eMultTPC_vs_Centrality][eRec][ba]->Fill(collision.multTPC(), ebye.fCentrality); !qa.fQAEventHistograms2D[eVertex_z_vs_MultTPC][eRec][ba] ? true : qa.fQAEventHistograms2D[eVertex_z_vs_MultTPC][eRec][ba]->Fill(collision.posZ(), collision.multTPC()); !qa.fQAEventHistograms2D[eVertex_z_vs_NContributors][eRec][ba] ? true : qa.fQAEventHistograms2D[eVertex_z_vs_NContributors][eRec][ba]->Fill(collision.posZ(), collision.numContrib()); + !qa.fQAEventHistograms2D[eCentFT0C_vs_CentNTPV][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0C_vs_CentNTPV][eRec][ba]->Fill(qa.fCentrality[eCentFT0C], qa.fCentrality[eCentNTPV]); !qa.fQAEventHistograms2D[eCentFT0M_vs_CentNTPV][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentFT0M_vs_CentNTPV][eRec][ba]->Fill(qa.fCentrality[eCentFT0M], qa.fCentrality[eCentNTPV]); } @@ -3998,34 +4585,48 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) LOGF(warning, "No MC collision for this collision, skip..."); return; } - !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[eImpactParameter][eSim][ba] ? true : eh.fEventHistograms[eImpactParameter][eSim][ba]->Fill(collision.mcCollision().impactParameter()); - // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231106 check how to get corresponding MC truth info, and validate further - // eh.fEventHistograms[eSelectedTracks][eSim][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter + re-think if I really need it here - // TBI 20240120 eMultFT0M, ..., eMultNTracksPV are not needed here - // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() + 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[eImpactParameter][eSim][ba] ? true : eh.fEventHistograms[eImpactParameter][eSim][ba]->Fill(collision.mcCollision().impactParameter()); + // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231106 check how to get corresponding MC truth info, and validate further + // eh.fEventHistograms[eSelectedTracks][eSim][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter + re-think if I really need it here + // TBI 20240120 eMultFT0M, ..., eMultNTracksPV are not needed here + // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() + } } // if constexpr (rs == eRecAndSim) { - } // if constexpr (rs == eRec || rs == eRecAndSim) { + } // if constexpr (rs == eRec || rs == eRecAndSim) { // ----------------------------------------------------------------------------- // b) Fill only simulated (common to Run 3, Run 2 and Run 1): if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { - !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[eSelectedTracks][eSim][ba] ? true : eh.fEventHistograms[eSelectedTracks][eSim][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter - // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() - // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231030 check further how to use the same thing for 'sim' - } // if constexpr (rs == eSim) { + if (eh.fFillEventHistograms) { + !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[eSelectedTracks][eSim][ba] ? true : eh.fEventHistograms[eSelectedTracks][eSim][ba]->Fill(ebye.fSelectedTracks); // TBI 20240108 this one makes sense only for eAfter + // eh.fEventHistograms[eCentrality][eSim][ba]->Fill(ebye.fCentrality); // TBI 20240120 this case is still not supported in DetermineCentrality() + // eh.fEventHistograms[eTotalMultiplicity][eSim][ba]->Fill(tracks.size()); // TBI 20231030 check further how to use the same thing for 'sim' + } + } // ----------------------------------------------------------------------------- // c) Fill reconstructed (Run 3 specific): if constexpr (rs == eRec || rs == eRecAndSim) { - !eh.fEventHistograms[eMultFT0M][eRec][ba] ? true : eh.fEventHistograms[eMultFT0M][eRec][ba]->Fill(collision.multFT0M()); - !eh.fEventHistograms[eMultFV0M][eRec][ba] ? true : eh.fEventHistograms[eMultFV0M][eRec][ba]->Fill(collision.multFV0M()); + if (eh.fFillEventHistograms) { + !eh.fEventHistograms[eMultFT0M][eRec][ba] ? true : eh.fEventHistograms[eMultFT0M][eRec][ba]->Fill(collision.multFT0M()); + !eh.fEventHistograms[eMultFV0M][eRec][ba] ? true : eh.fEventHistograms[eMultFV0M][eRec][ba]->Fill(collision.multFV0M()); + !eh.fEventHistograms[eOccupancy][eRec][ba] ? true : eh.fEventHistograms[eOccupancy][eRec][ba]->Fill(ebye.fOccupancy); + } + // QA: + if (qa.fFillQAEventHistograms2D) { + !qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange][eRec][ba] ? true : qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_FT0COccupancyInTimeRange][eRec][ba]->Fill(collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + !qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_MultTPC][eRec][ba] ? true : qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_MultTPC][eRec][ba]->Fill(collision.trackOccupancyInTimeRange(), collision.multTPC()); + !qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Vertex_z][eRec][ba] ? true : qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Vertex_z][eRec][ba]->Fill(collision.trackOccupancyInTimeRange(), collision.posZ()); + !qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Centrality][eRec][ba] ? true : qa.fQAEventHistograms2D[eTrackOccupancyInTimeRange_vs_Centrality][eRec][ba]->Fill(collision.trackOccupancyInTimeRange(), ebye.fCentrality); + } // ... and corresponding MC truth simulated (Run 3 specific) // See https://github.com/AliceO2Group/O2Physics/blob/master/Tutorials/src/mcHistograms.cxx @@ -4036,7 +4637,7 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) } // !eh.fEventHistograms[eNumberOfEvents][eSim][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][ba]->Fill(0.5); } // if constexpr (rs == eRecAndSim) { - } // if constexpr (rs == eRec || rs == eRecAndSim) { + } // if constexpr (rs == eRec || rs == eRecAndSim) { // ----------------------------------------------------------------------------- @@ -4049,7 +4650,9 @@ 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) { - !eh.fEventHistograms[eMultTracklets][eRec][ba] ? true : eh.fEventHistograms[eMultTracklets][eRec][ba]->Fill(collision.multTracklets()); + if (eh.fFillEventHistograms) { + !eh.fEventHistograms[eMultTracklets][eRec][ba] ? true : eh.fEventHistograms[eMultTracklets][eRec][ba]->Fill(collision.multTracklets()); + } // QA: if (qa.fFillQAEventHistograms2D) { !qa.fQAEventHistograms2D[eCentRun2V0M_vs_CentRun2SPDTracklets][eRec][ba] ? true : qa.fQAEventHistograms2D[eCentRun2V0M_vs_CentRun2SPDTracklets][eRec][ba]->Fill(qa.fCentrality[eCentRun2V0M], qa.fCentrality[eCentRun2SPDTracklets]); @@ -4066,7 +4669,7 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) // !eh.fEventHistograms[eNumberOfEvents][eSim][ba] ? true : eh.fEventHistograms[eNumberOfEvents][eSim][ba]->Fill(0.5); } // if constexpr (rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { - } // if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + } // if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { // ----------------------------------------------------------------------------- @@ -4081,11 +4684,17 @@ void FillEventHistograms(T1 const& collision, T2 const& tracks, eBeforeAfter ba) if constexpr (rs == eTest) { // TBI 20240223 for the time being, eTest fills only eRec histos: // A few example histograms, just to check if I access corresponding tables: - !eh.fEventHistograms[eVertex_z][eRec][ba] ? true : eh.fEventHistograms[eVertex_z][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); + if (eh.fFillEventHistograms) { + !eh.fEventHistograms[eVertex_z][eRec][ba] ? true : eh.fEventHistograms[eVertex_z][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); + } } // if constexpr (rs == eTest) { + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void FillEventHistograms(...) //============================================================ @@ -4102,7 +4711,7 @@ void CheckUnderflowAndOverflow() // f) QA Particle histograms 2D. if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Event histograms 1D: @@ -4175,9 +4784,9 @@ void CheckUnderflowAndOverflow() 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_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 // e) QA Event histograms 2D: for (Int_t t = 0; t < eQAEventHistograms2D_N; t++) // type, see enum eQAEventHistograms2D @@ -4210,9 +4819,9 @@ void CheckUnderflowAndOverflow() 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_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 // f) QA Particle histograms 2D: for (Int_t t = 0; t < eQAParticleHistograms2D_N; t++) // type, see enum eQAParticleHistograms2D @@ -4245,9 +4854,13 @@ void CheckUnderflowAndOverflow() 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_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 + + if (tc.fVerboseForEachParticle) { + ExitFunction(__FUNCTION__); + } } // void CheckUnderflowAndOverflow() @@ -4266,7 +4879,7 @@ bool ValidTrack(T const& track) // c) Additional validity checks for all tracks (in Run 3, 2 and 1), use only during debugging. if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); LOGF(info, " track.phi() = %f", track.phi()); LOGF(info, " track.pt() = %f", track.pt()); LOGF(info, " track.eta() = %f", track.eta()); @@ -4303,10 +4916,10 @@ bool ValidTrack(T const& track) // c) Additional validity checks for all tracks (in Run 3, 2 and 1), use only during debugging: if (tc.fInsanityCheckForEachParticle) { - // *) isnan() check (remember that 'nan' is 0./0., inf-inf, etc. However 'inf' itself is NOT a 'nan', therefore isnan(1./0.) is false, isnan(0./0.) is true, etc.): - if (isnan(track.phi()) || isnan(track.pt()) || isnan(track.eta())) { + // *) std::isnan() check (remember that 'nan' is 0./0., inf-inf, etc. However 'inf' itself is NOT a 'nan', therefore std::isnan(1./0.) is false, std::isnan(0./0.) is true, etc.): + if (std::isnan(track.phi()) || std::isnan(track.pt()) || std::isnan(track.eta())) { if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;31m%s isnan(track.phi()) || isnan(track.pt()) || isnan(track.eta())\033[0m", __FUNCTION__); + 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; @@ -4330,7 +4943,7 @@ void ParticleCutsCounters(T const& track) // Use this function to fill absolute and sequential particle cut counters. Use only during QA, as this is computationally heavy (I mean really). if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // *) Establish ordering of binning in particle cut counters histograms, which resembles ordering of particle cuts implementation: @@ -4391,6 +5004,8 @@ Bool_t 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 , + // 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); // b) Particle cuts only on simulated (common to Run 3, Run 2 and Run 1); @@ -4402,7 +5017,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) // *) Toy NUA. if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Particle cuts on reconstructed, and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) ... @@ -4412,7 +5027,7 @@ 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]) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePhi, cutModus)) { return kFALSE; } @@ -4423,7 +5038,7 @@ 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]) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePt, cutModus)) { return kFALSE; } @@ -4434,7 +5049,7 @@ 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]) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, eEta, cutModus)) { return kFALSE; } @@ -4446,7 +5061,8 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) if (cutModus == eCutCounterBinning) { ParticleCut(eRec, 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 + // 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; } @@ -4523,7 +5139,7 @@ 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]) { + } else if (track.tpcCrossedRowsOverFindableCls() < pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMin] || track.tpcCrossedRowsOverFindableCls() > pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax] || TMath::Abs(track.tpcCrossedRowsOverFindableCls() - pc.fdParticleCuts[etpcCrossedRowsOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcCrossedRowsOverFindableCls, cutModus)) { return kFALSE; } @@ -4534,7 +5150,7 @@ 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]) { + } else if (track.tpcFoundOverFindableCls() < pc.fdParticleCuts[etpcFoundOverFindableCls][eMin] || track.tpcFoundOverFindableCls() > pc.fdParticleCuts[etpcFoundOverFindableCls][eMax] || TMath::Abs(track.tpcFoundOverFindableCls() - pc.fdParticleCuts[etpcFoundOverFindableCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcFoundOverFindableCls, cutModus)) { return kFALSE; } @@ -4545,7 +5161,7 @@ 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]) { + } else if (track.tpcFractionSharedCls() < pc.fdParticleCuts[etpcFractionSharedCls][eMin] || track.tpcFractionSharedCls() > pc.fdParticleCuts[etpcFractionSharedCls][eMax] || TMath::Abs(track.tpcFractionSharedCls() - pc.fdParticleCuts[etpcFractionSharedCls][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, etpcFractionSharedCls, cutModus)) { return kFALSE; } @@ -4556,7 +5172,7 @@ 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]) { + } else if (track.dcaXY() < pc.fdParticleCuts[edcaXY][eMin] || track.dcaXY() > pc.fdParticleCuts[edcaXY][eMax] || TMath::Abs(track.dcaXY() - pc.fdParticleCuts[edcaXY][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, edcaXY, cutModus)) { return kFALSE; } @@ -4567,7 +5183,7 @@ 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]) { + } else if (track.dcaZ() < pc.fdParticleCuts[edcaZ][eMin] || track.dcaZ() > pc.fdParticleCuts[edcaZ][eMax] || TMath::Abs(track.dcaZ() - pc.fdParticleCuts[edcaZ][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, edcaZ, cutModus)) { return kFALSE; } @@ -4711,7 +5327,7 @@ 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]) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, ePhi, cutModus)) { return kFALSE; } @@ -4722,7 +5338,7 @@ 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]) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, ePt, cutModus)) { return kFALSE; } @@ -4733,7 +5349,7 @@ 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]) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eSim, eEta, cutModus)) { return kFALSE; } @@ -4842,7 +5458,7 @@ 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]) { + } else if (track.phi() < pc.fdParticleCuts[ePhi][eMin] || track.phi() > pc.fdParticleCuts[ePhi][eMax] || TMath::Abs(track.phi() - pc.fdParticleCuts[ePhi][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePhi, cutModus)) { return kFALSE; } @@ -4853,7 +5469,7 @@ 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]) { + } else if (track.pt() < pc.fdParticleCuts[ePt][eMin] || track.pt() > pc.fdParticleCuts[ePt][eMax] || TMath::Abs(track.pt() - pc.fdParticleCuts[ePt][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, ePt, cutModus)) { return kFALSE; } @@ -4864,7 +5480,7 @@ 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]) { + } else if (track.eta() < pc.fdParticleCuts[eEta][eMin] || track.eta() > pc.fdParticleCuts[eEta][eMax] || TMath::Abs(track.eta() - pc.fdParticleCuts[eEta][eMax]) < tc.fFloatingPointPrecision) { if (!ParticleCut(eRec, eEta, cutModus)) { return kFALSE; } @@ -4927,7 +5543,7 @@ Bool_t ParticleCuts(T const& track, eCutModus cutModus) } } // 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) { + } // if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { // *) Apply Toy NUA on info available only in simulated data: if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { @@ -5017,7 +5633,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // I use BanishmentLoopOverParticles . Alternatively, I would need new set of histograms, fill them separately, etc. if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } if (tc.fInsanityCheckForEachParticle) { @@ -5033,34 +5649,39 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // But I have already tc.fProcess[eGenericRec] and tc.fProcess[eGenericRecSim], available, shall I simply re-use them? // 1D: - // From o2::aod::Tracks - !ph.fParticleHistograms[ePhi][eRec][ba] ? true : ph.fParticleHistograms[ePhi][eRec][ba]->Fill(track.phi(), weight); // 3 2 - !ph.fParticleHistograms[ePt][eRec][ba] ? true : ph.fParticleHistograms[ePt][eRec][ba]->Fill(track.pt(), weight); // 3 2 - !ph.fParticleHistograms[eEta][eRec][ba] ? true : ph.fParticleHistograms[eEta][eRec][ba]->Fill(track.eta(), weight); // 3 2 - !ph.fParticleHistograms[eCharge][eRec][ba] ? true : ph.fParticleHistograms[eCharge][eRec][ba]->Fill(track.sign(), weight); // 3 2 - - // From o2::aod::TracksExtra_001 - !ph.fParticleHistograms[etpcNClsFindable][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFindable][eRec][ba]->Fill(track.tpcNClsFindable(), weight); // 3 2 - !ph.fParticleHistograms[etpcNClsShared][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsShared][eRec][ba]->Fill(track.tpcNClsShared(), weight); // 3 2 - !ph.fParticleHistograms[etpcNClsFound][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFound][eRec][ba]->Fill(track.tpcNClsFound(), weight); // 3 2 - !ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba]->Fill(track.tpcNClsCrossedRows(), weight); // 3 2 - !ph.fParticleHistograms[eitsNCls][eRec][ba] ? true : ph.fParticleHistograms[eitsNCls][eRec][ba]->Fill(track.itsNCls(), weight); // 3 2 - !ph.fParticleHistograms[eitsNClsInnerBarrel][eRec][ba] ? true : ph.fParticleHistograms[eitsNClsInnerBarrel][eRec][ba]->Fill(track.itsNClsInnerBarrel(), weight); // 3 2 - !ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba]->Fill(track.tpcCrossedRowsOverFindableCls(), weight); // 3 2 - !ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba]->Fill(track.tpcFoundOverFindableCls(), weight); // 3 2 - !ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba]->Fill(track.tpcFractionSharedCls(), weight); // 3 2 - - // 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 . - !ph.fParticleHistograms[edcaXY][eRec][ba] ? true : ph.fParticleHistograms[edcaXY][eRec][ba]->Fill(track.dcaXY(), weight); // 3 2 - !ph.fParticleHistograms[edcaZ][eRec][ba] ? true : ph.fParticleHistograms[edcaZ][eRec][ba]->Fill(track.dcaZ(), weight); // 3 2 + if (ph.fFillParticleHistograms) { + // From o2::aod::Tracks + !ph.fParticleHistograms[ePhi][eRec][ba] ? true : ph.fParticleHistograms[ePhi][eRec][ba]->Fill(track.phi(), weight); // 3 2 + !ph.fParticleHistograms[ePt][eRec][ba] ? true : ph.fParticleHistograms[ePt][eRec][ba]->Fill(track.pt(), weight); // 3 2 + !ph.fParticleHistograms[eEta][eRec][ba] ? true : ph.fParticleHistograms[eEta][eRec][ba]->Fill(track.eta(), weight); // 3 2 + !ph.fParticleHistograms[eCharge][eRec][ba] ? true : ph.fParticleHistograms[eCharge][eRec][ba]->Fill(track.sign(), weight); // 3 2 + + // From o2::aod::TracksExtra_001 + !ph.fParticleHistograms[etpcNClsFindable][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFindable][eRec][ba]->Fill(track.tpcNClsFindable(), weight); // 3 2 + !ph.fParticleHistograms[etpcNClsShared][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsShared][eRec][ba]->Fill(track.tpcNClsShared(), weight); // 3 2 + !ph.fParticleHistograms[etpcNClsFound][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsFound][eRec][ba]->Fill(track.tpcNClsFound(), weight); // 3 2 + !ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba] ? true : ph.fParticleHistograms[etpcNClsCrossedRows][eRec][ba]->Fill(track.tpcNClsCrossedRows(), weight); // 3 2 + !ph.fParticleHistograms[eitsNCls][eRec][ba] ? true : ph.fParticleHistograms[eitsNCls][eRec][ba]->Fill(track.itsNCls(), weight); // 3 2 + !ph.fParticleHistograms[eitsNClsInnerBarrel][eRec][ba] ? true : ph.fParticleHistograms[eitsNClsInnerBarrel][eRec][ba]->Fill(track.itsNClsInnerBarrel(), weight); // 3 2 + !ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcCrossedRowsOverFindableCls][eRec][ba]->Fill(track.tpcCrossedRowsOverFindableCls(), weight); // 3 2 + !ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFoundOverFindableCls][eRec][ba]->Fill(track.tpcFoundOverFindableCls(), weight); // 3 2 + !ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba] ? true : ph.fParticleHistograms[etpcFractionSharedCls][eRec][ba]->Fill(track.tpcFractionSharedCls(), weight); // 3 2 + + // 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 . + !ph.fParticleHistograms[edcaXY][eRec][ba] ? true : ph.fParticleHistograms[edcaXY][eRec][ba]->Fill(track.dcaXY(), weight); // 3 2 + !ph.fParticleHistograms[edcaZ][eRec][ba] ? true : ph.fParticleHistograms[edcaZ][eRec][ba]->Fill(track.dcaZ(), weight); // 3 2 + } // 2D: - !ph.fParticleHistograms2D[ePhiPt][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eRec][ba]->Fill(track.phi(), track.pt(), weight); // 3 2 - !ph.fParticleHistograms2D[ePhiEta][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eRec][ba]->Fill(track.phi(), track.eta(), weight); + if (ph.fFillParticleHistograms2D) { + !ph.fParticleHistograms2D[ePhiPt][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eRec][ba]->Fill(track.phi(), track.pt(), weight); // 3 2 + !ph.fParticleHistograms2D[ePhiEta][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eRec][ba]->Fill(track.phi(), track.eta(), weight); + } // if (ph.fFillParticleHistograms2D) { + // QA: if (qa.fFillQAParticleHistograms2D) { - !qa.fQAParticleHistograms2D[edcaXY_vs_Pt][eRec][ba] ? true : qa.fQAParticleHistograms2D[edcaXY_vs_Pt][eRec][ba]->Fill(track.dcaXY(), track.pt()); + !qa.fQAParticleHistograms2D[ePt_vs_dcaXY][eRec][ba] ? true : qa.fQAParticleHistograms2D[ePt_vs_dcaXY][eRec][ba]->Fill(track.pt(), track.dcaXY()); } // ... and corresponding MC truth simulated (common to Run 3, Run 2 and Run 1) @@ -5073,18 +5694,24 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) return; } auto mcparticle = track.mcParticle(); // corresponding MC truth simulated particle + // 1D: - !ph.fParticleHistograms[ePhi][eSim][ba] ? true : ph.fParticleHistograms[ePhi][eSim][ba]->Fill(mcparticle.phi(), weight); // 3 - !ph.fParticleHistograms[ePt][eSim][ba] ? true : ph.fParticleHistograms[ePt][eSim][ba]->Fill(mcparticle.pt(), weight); // 3 - !ph.fParticleHistograms[eEta][eSim][ba] ? true : ph.fParticleHistograms[eEta][eSim][ba]->Fill(mcparticle.eta(), weight); // 3 - // !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 + if (ph.fFillParticleHistograms) { + !ph.fParticleHistograms[ePhi][eSim][ba] ? true : ph.fParticleHistograms[ePhi][eSim][ba]->Fill(mcparticle.phi(), weight); // 3 + !ph.fParticleHistograms[ePt][eSim][ba] ? true : ph.fParticleHistograms[ePt][eSim][ba]->Fill(mcparticle.pt(), weight); // 3 + !ph.fParticleHistograms[eEta][eSim][ba] ? true : ph.fParticleHistograms[eEta][eSim][ba]->Fill(mcparticle.eta(), weight); // 3 + // !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 + } + // 2D: - !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) { + !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) { } // 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) { + } // if constexpr (rs == eRec || rs == eRecAndSim || rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { // ----------------------------------------------------------------------------- @@ -5093,14 +5720,19 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // Remark #2: In this branch, 'track' is always TracksSim = aod::McParticles, see https://aliceo2group.github.io/analysis-framework/docs/datamodel/ao2dTables.html#montecarlo if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { // 1D: - !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()) - !ph.fParticleHistograms[ePDG][eSim][ba] ? true : ph.fParticleHistograms[ePDG][eSim][ba]->Fill(track.pdgCode(), weight); + if (ph.fFillParticleHistograms) { + !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()) + !ph.fParticleHistograms[ePDG][eSim][ba] ? true : ph.fParticleHistograms[ePDG][eSim][ba]->Fill(track.pdgCode(), weight); + } // if(ph.fFillParticleHistograms) { + // 2D: - !ph.fParticleHistograms2D[ePhiPt][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][ba]->Fill(track.phi(), track.pt(), weight); - !ph.fParticleHistograms2D[ePhiEta][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][ba]->Fill(track.phi(), track.eta(), weight); + if (ph.fFillParticleHistograms2D) { + !ph.fParticleHistograms2D[ePhiPt][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eSim][ba]->Fill(track.phi(), track.pt(), weight); + !ph.fParticleHistograms2D[ePhiEta][eSim][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eSim][ba]->Fill(track.phi(), track.eta(), weight); + } // if(ph.fFillParticleHistograms2D) { } // if constexpr (rs == eSim || rs == eSim_Run2 || rs == eSim_Run1) { // ----------------------------------------------------------------------------- @@ -5125,7 +5757,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // ... } // if constexpr (rs == eRecAndSim) { - } // if constexpr (rs == eRec || rs == eRecAndSim) { + } // if constexpr (rs == eRec || rs == eRecAndSim) { // ----------------------------------------------------------------------------- @@ -5160,7 +5792,7 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // ... } // if constexpr (rs == eRecAndSim_Run2 || rs == eRecAndSim_Run1) { - } // if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { + } // if constexpr (rs == eRec_Run2 || rs == eRecAndSim_Run2 || rs == eRec_Run1 || rs == eRecAndSim_Run1) { // ----------------------------------------------------------------------------- @@ -5181,12 +5813,16 @@ void FillParticleHistograms(T const& track, eBeforeAfter ba, Int_t weight = 1) // This branch corresponds to process with minimal subscription - I implement just a few example cuts, just for testing purposes. // Only eRec is support in Test for the time being. // 1D: - !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); - !ph.fParticleHistograms[eEta][eRec][ba] ? true : ph.fParticleHistograms[eEta][eRec][ba]->Fill(track.eta(), weight); + if (ph.fFillParticleHistograms) { + !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); + !ph.fParticleHistograms[eEta][eRec][ba] ? true : ph.fParticleHistograms[eEta][eRec][ba]->Fill(track.eta(), weight); + } // 2D: - !ph.fParticleHistograms2D[ePhiPt][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eRec][ba]->Fill(track.phi(), track.pt(), weight); - !ph.fParticleHistograms2D[ePhiEta][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eRec][ba]->Fill(track.phi(), track.eta(), weight); + if (ph.fFillParticleHistograms2D) { + !ph.fParticleHistograms2D[ePhiPt][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiPt][eRec][ba]->Fill(track.phi(), track.pt(), weight); + !ph.fParticleHistograms2D[ePhiEta][eRec][ba] ? true : ph.fParticleHistograms2D[ePhiEta][eRec][ba]->Fill(track.phi(), track.eta(), weight); + } } // if constexpr (rs == eTest) { } // template void FillParticleHistograms(...) @@ -5204,7 +5840,7 @@ void CalculateCorrelations() // c) Flush the generic Q-vectors. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Flush 'n' fill the generic Q-vectors: @@ -5243,10 +5879,10 @@ void CalculateCorrelations() harmonics->SetAt(h, 0); harmonics->SetAt(-h, 1); Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(twoC - nestedLoopValue) > 1.e-5) { + if (TMath::Abs(nestedLoopValue) > 0. && TMath::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, " e-b-e check with CustomNestedLoops is OK for isotropic 2-p, harmonic %d", 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; @@ -5269,6 +5905,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[0][h - 1][AFO_CENTRALITY]) { mupa.fCorrelationsPro[0][h - 1][AFO_CENTRALITY]->Fill(ebye.fCentrality, twoC, wTwo); } + // vs. occupancy: + if (mupa.fCorrelationsPro[0][h - 1][AFO_OCCUPANCY]) { + mupa.fCorrelationsPro[0][h - 1][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, twoC, wTwo); + } // 4p: if (ebye.fSelectedTracks < 4) { @@ -5296,10 +5936,10 @@ void CalculateCorrelations() harmonics->SetAt(-h, 2); harmonics->SetAt(-h, 3); Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(fourC - nestedLoopValue) > 1.e-5) { + if (TMath::Abs(nestedLoopValue) > 0. && TMath::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, " e-b-e check with CustomNestedLoops is OK for isotropic 4-p, harmonic %d", 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; @@ -5322,6 +5962,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[1][h - 1][AFO_CENTRALITY]) { mupa.fCorrelationsPro[1][h - 1][AFO_CENTRALITY]->Fill(ebye.fCentrality, fourC, wFour); } + // vs. occupancy: + if (mupa.fCorrelationsPro[1][h - 1][AFO_OCCUPANCY]) { + mupa.fCorrelationsPro[1][h - 1][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, fourC, wFour); + } // 6p: if (ebye.fSelectedTracks < 6) { @@ -5351,10 +5995,10 @@ void CalculateCorrelations() harmonics->SetAt(-h, 4); harmonics->SetAt(-h, 5); Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(sixC - nestedLoopValue) > 1.e-5) { + if (TMath::Abs(nestedLoopValue) > 0. && TMath::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, " e-b-e check with CustomNestedLoops is OK for isotropic 6-p, harmonic %d", 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; @@ -5377,6 +6021,10 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[2][h - 1][AFO_CENTRALITY]) { mupa.fCorrelationsPro[2][h - 1][AFO_CENTRALITY]->Fill(ebye.fCentrality, sixC, wSix); } + // vs. occupancy: + if (mupa.fCorrelationsPro[2][h - 1][AFO_OCCUPANCY]) { + mupa.fCorrelationsPro[2][h - 1][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, sixC, wSix); + } // 8p: if (ebye.fSelectedTracks < 8) { @@ -5408,10 +6056,10 @@ void CalculateCorrelations() harmonics->SetAt(-h, 6); harmonics->SetAt(-h, 7); Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); - if (TMath::Abs(nestedLoopValue) > 0. && TMath::Abs(eightC - nestedLoopValue) > 1.e-5) { + if (TMath::Abs(nestedLoopValue) > 0. && TMath::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, " e-b-e check with CustomNestedLoops is OK for isotropic 8-p, harmonic %d", 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; @@ -5434,15 +6082,69 @@ void CalculateCorrelations() if (mupa.fCorrelationsPro[3][h - 1][AFO_CENTRALITY]) { mupa.fCorrelationsPro[3][h - 1][AFO_CENTRALITY]->Fill(ebye.fCentrality, eightC, wEight); } + // vs. occupancy: + if (mupa.fCorrelationsPro[3][h - 1][AFO_OCCUPANCY]) { + mupa.fCorrelationsPro[3][h - 1][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, eightC, wEight); + } + } // for(Int_t h=1;h<=gMaxHarmonic;h++) // harmonic // c) Flush the generic Q-vectors: ResetQ(); + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void CalculateCorrelations() //============================================================ +void CalculateKineCorrelations(eAsFunctionOf AFO_variable) +{ + // Calculate analytically differential multiparticle correlations from Q-vectors. + + if (tc.fVerbose) { + StartFunction(__FUNCTION__); + } + + // *) ... + eqvectorKine qvKine = eqvectorKine_N; // which eqvectorKine enum + // Int_t nBins = -1; // TBI 20241111 temporarily commented out just to suppress warnings + + switch (AFO_variable) { + case AFO_PT: + qvKine = PTq; + // nBins = res.fResultsPro[AFO_PT]->GetNbinsX(); // TBI 20241111 temporarily commented out just to suppress warnings + break; + case AFO_ETA: + qvKine = ETAq; + // 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: + 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__); + } + + // ... + + LOGF(warning, "\033[1;33m%s at line %d : Not implemented yet, this is just a placeholder for future implementation.\033[0m", __FUNCTION__, __LINE__); + + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void CalculateKineCorrelations(eAsFunctionOf AFO_variable) + +//============================================================ + void CalculateTest0() { // Calculate Test0. @@ -5452,7 +6154,7 @@ void CalculateTest0() // c) Flush the generic Q-vectors. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Flush 'n' fill the generic Q-vectors: @@ -5610,11 +6312,11 @@ void CalculateTest0() } Double_t nestedLoopValue = this->CalculateCustomNestedLoops(harmonics); if (!(TMath::Abs(nestedLoopValue) > 0.)) { - LOGF(info, " e-b-e check 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) > 1.e-5) { + 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) { 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, " e-b-e check with CustomNestedLoops is OK for %d-p Test0 corr. %s", 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; @@ -5648,13 +6350,21 @@ void CalculateTest0() if (t0.fTest0Pro[mo][mi][AFO_CENTRALITY]) { t0.fTest0Pro[mo][mi][AFO_CENTRALITY]->Fill(ebye.fCentrality, correlation / weight, weight); } + // vs. occupancy: + if (t0.fTest0Pro[mo][mi][AFO_OCCUPANCY]) { + t0.fTest0Pro[mo][mi][AFO_OCCUPANCY]->Fill(ebye.fOccupancy, correlation / weight, weight); + } } // if(t0.fTest0Labels[mo][mi]) - } // for(Int_t mi=0;mi add some more entries to the case stamenent \033[0m", __FUNCTION__, __LINE__); + 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: @@ -5722,8 +6432,7 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) // cout<At(h)->GetName()).Atoi(); delete oa; // yes, otherwise it's a memory leak @@ -5811,10 +6520,10 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) Double_t nestedLoopValue = this->CalculateKineCustomNestedLoops(harmonics, AFO_variable, b); if (!(TMath::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) > 1.e-5) { + } else if (TMath::Abs(nestedLoopValue) > 0. && TMath::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, " e-b-e check with CalculateKineCustomNestedLoops is OK for %d-p Test0 corr. %s, bin = %d", mo + 1, t0.fTest0Labels[mo][mi]->Data(), b + 1); + 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); } delete harmonics; harmonics = NULL; @@ -5857,11 +6566,15 @@ void CalculateKineTest0(eAsFunctionOf AFO_variable) } // fill in the bin center } // if(fTest0Labels[mo][mi]) - } // for(Int_t mi=0;miAddAt(wPhi * wPt * wEta, particleIndex); // remember that the 2nd argument here must start from 0 } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void FillNestedLoopsContainers(const Int_t& particleIndex, const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta) //============================================================ @@ -5924,7 +6641,7 @@ void CalculateNestedLoops() // d) 8-particle nested loops. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } LOGF(info, " ebye.fSelectedTracks = %d", ebye.fSelectedTracks); @@ -5977,9 +6694,14 @@ void CalculateNestedLoops() 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); + } } // for(int h=1; h<=6; h++) - } // for(int i2=0; i2Fill(ebye.fCentrality, TMath::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); + } } // for(int h=0; hFill(ebye.fSelectedTracks + 0.5, TMath::Cos((h + 1.) * (dPhi1 + dPhi2 + dPhi3 - dPhi4 - dPhi5 - dPhi6)), dW1 * dW2 * dW3 * dW4 * dW5 * dW6); } - // fill cos, 6p, all harmonics, vs. M: + // 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); } + // 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); + } } // for(int h=0; hFill(ebye.fSelectedTracks + 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: + // 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); + } } // for(int h=0; hGetNbinsX(); nBinsNL = nl.fNestedLoopsPro[0][0][v]->GetNbinsX(); if (nBinsQV != nBinsNL) { @@ -6211,16 +6950,20 @@ void ComparisonNestedLoopsVsCorrelations() 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) > 1.e-5) { + 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<6;h++) + } // if(TMath::Abs(valueQV)>0. && TMath::Abs(valueNL)>0.) + } // for(Int_t b=1;b<=nBinsQV;b++) + } // for(Int_t h=0;h<6;h++) LOGF(info, ""); // new line - } // for(Int_t o=0;o<4;o++) - } // for (Int_t v = 0; v < 3; v++) + } // for(Int_t o=0;o<4;o++) + } // for (Int_t v = 0; v < 3; v++) + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } // void ComparisonNestedLoopsVsCorrelations() @@ -6455,7 +7198,7 @@ void ResetQ() // standard functions for correlations, for some custom Q-vectors. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } for (Int_t h = 0; h < gMaxHarmonic * gMaxCorrelator + 1; h++) { @@ -6465,6 +7208,10 @@ void ResetQ() } } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void ResetQ() //============================================================ @@ -6474,7 +7221,7 @@ void SetWeightsHist(TH1D* const hist, eWeights whichWeight) // Copy histogram holding weights from an external file to the corresponding data member. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // Finally: @@ -6494,12 +7241,20 @@ void SetWeightsHist(TH1D* const hist, eWeights whichWeight) pw.fWeightsHist[whichWeight]->GetYaxis()->SetTitle(sWeights[whichWeight].Data()); pw.fWeightsHist[whichWeight]->SetFillColor(eFillColor); pw.fWeightsHist[whichWeight]->SetLineColor(eColor); - pw.fWeightsList->Add(pw.fWeightsHist[whichWeight]); + 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] = kTRUE; -} // void SetWeightsHist(TH1D* const hist, , eWeights whichWeight) + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void SetWeightsHist(TH1D* const hist, eWeights whichWeight) //============================================================ @@ -6507,8 +7262,11 @@ void SetDiffWeightsHist(TH1D* const hist, eDiffWeights whichDiffWeight, Int_t bi { // 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) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // Finally: @@ -6521,14 +7279,15 @@ void SetDiffWeightsHist(TH1D* const hist, eDiffWeights whichDiffWeight, Int_t bi // 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}"}; + 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]); + 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 kTRUE, for all bins @@ -6536,16 +7295,66 @@ void SetDiffWeightsHist(TH1D* const hist, eDiffWeights whichDiffWeight, Int_t bi pw.fUseDiffWeights[whichDiffWeight] = kTRUE; } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // SetDiffWeightsHist(TH1D* const hist, const char *variable, Int_t bin) //============================================================ +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->Clone()); + + 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(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__); + } + 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) + +//============================================================ + TH1D* GetWeightsHist(eWeights whichWeight) { // The standard getter. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); + } + + // ... + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); } // Finally: @@ -6567,6 +7376,10 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const // 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; @@ -6576,7 +7389,7 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const // g) The final touch on histogram with weights. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + 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); @@ -6610,7 +7423,7 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { bFileIsInCCDB = kTRUE; } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { if (bFileIsInAliEn) { // d) Handle the AliEn case: @@ -6634,7 +7447,12 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + 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) { @@ -6653,23 +7471,23 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const 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()); + 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())); + 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)); + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + 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 { @@ -6691,19 +7509,22 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - weightsFile->GetObject( - "ccdb_object", baseList); // TBI 20231008 for simplicity, harwired name - // of base TList is "ccdb_object" also for - // local case, see if I need to change this + weightsFile->GetObject("ccdb_object", baseList); // TBI 20231008 for simplicity, harwired 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)); + listWithRuns = reinterpret_cast(GetObjectFromList(baseList, runNumber)); if (!listWithRuns) { - LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); + 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 { @@ -6729,7 +7550,7 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } hist->SetDirectory(0); - hist->SetTitle(Form("%s, %s", filePath, runNumber)); + hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" av } else { // Differential weights: @@ -6746,35 +7567,281 @@ TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const hist = reinterpret_cast(GetObjectFromList(listWithRuns, Form("%s[%d]", variable, bin))); // yes, for some simple tests I can have only histogram named e.g. 'phipt[0]' } if (!hist) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + LOGF(info, "\033[1;31m Form(\"%%s[%%d]\", variable, bin) = %s\033[0m", Form("%s[%d]", variable, bin)); listWithRuns->ls(); LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } - hist->SetDirectory(0); + // *) 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(); + + // 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")) { - hist->SetTitle(Form("%s, %.2f < p_{T} < %.2f", filePath, res.fResultsProVariableLengthBins[AFO_PT]->At(bin), res.fResultsProVariableLengthBins[AFO_PT]->At(bin + 1))); + 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_t min = res.fResultsPro[AFO]->GetBinLowEdge(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()); + } + + // Compare with min and max value store 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); + } + 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); + } + 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)); + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + + return hist; + +} // TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, Int_t bin = -1) + +//============================================================ + +TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) +{ + // 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? + + // 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. + + // 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. + + 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 + + // 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. 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* 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, harwired 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__); + } + + 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* centralityWeightsFile = TFile::Open(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, harwired name + // of base TList is "ccdb_object" also for + // local 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__); } - if (TString(variable).EqualTo("phieta")) { - hist->SetTitle(Form("%s, %.2f < #eta < %.2f", filePath, res.fResultsProVariableLengthBins[AFO_ETA]->At(bin), res.fResultsProVariableLengthBins[AFO_ETA]->At(bin + 1))); + + 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 + } // else { + + // g) The final touch on histogram with centrality weights: + // 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__); + } + hist->SetDirectory(0); + hist->SetTitle(Form("%s, %s", filePath, runNumber)); // I have to do it here, because only here I have "filePath" available + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } return hist; -} // TH1D* GetHistogramWithWeights(const char* filePath, const char* runNumber, const char* variable, Int_t bin = -1) +} // TH1D* GetHistogramWithCentralityWeights(const char* filePath, const char* runNumber) + +//============================================================ + +TObjArray* GetDefaultObjArrayWithLabels() +{ + // To speed up testing, I hardwire here some labels and use them directly as they are. + + // Define TObjArray: + TObjArray* arr = new TObjArray(); + arr->SetOwner(); + + // Define some labels: + const Int_t nLabels = 4; + TString labels[nLabels] = {"1 -1", "2 -2", "1 2 -3", "2 3 -3 -2"}; + + // Make a transfer: + for (Int_t l = 0; l < nLabels; l++) { + TObjString* objstr = new TObjString(labels[l].Data()); + arr->Add(objstr); + } + + return arr; + +} // TObjArray* GetDefaultObjArrayWithLabels() //============================================================ TObjArray* GetObjArrayWithLabels(const char* filePath) { // 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" + // 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" // a) Return value; // b) Determine from filePath if the file in on a local machine, or in AliEn; @@ -6783,7 +7850,7 @@ TObjArray* GetObjArrayWithLabels(const char* filePath) // e) Handle the local case. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Return value: @@ -6805,7 +7872,7 @@ TObjArray* GetObjArrayWithLabels(const char* filePath) if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { bFileIsInCCDB = kTRUE; } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { TFile* oaFile = NULL; // file holding TObjArray with all labels if (bFileIsInAliEn) { @@ -6897,6 +7964,7 @@ TObjArray* GetObjArrayWithLabels(const char* filePath) 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 oa; @@ -6926,7 +7994,7 @@ void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) // g) The final touch. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + 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()); @@ -6960,7 +8028,7 @@ void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) if (TString(filePath).BeginsWith("/alice-ccdb.cern.ch/")) { bFileIsInCCDB = kTRUE; } // else { - } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { + } // if (TString(filePath).BeginsWith("/alice/cern.ch/")) { if (bFileIsInAliEn) { // d) Handle the AliEn case: @@ -7039,6 +8107,10 @@ void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) // TBI 20240501 if additional cosmetics is needed, it can be implemented here + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void GetHistogramWithCustomNUA(const char* filePath, eNUAPDF variable) //============================================================ @@ -7054,7 +8126,7 @@ void StoreLabelsInPlaceholder() // e) Insantity check on labels. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Initialize all counters; @@ -7064,7 +8136,12 @@ void StoreLabelsInPlaceholder() } // now it's safe :-) // b) Fetch TObjArray with labels from an external file: - TObjArray* oa = GetObjArrayWithLabels(t0.fFileWithLabels.Data()); + TObjArray* oa = NULL; + if (t0.fUseDefaultLabels) { + oa = GetDefaultObjArrayWithLabels(); + } else { + oa = GetObjArrayWithLabels(t0.fFileWithLabels.Data()); + } if (!oa) { LOGF(info, "\033[1;33m fFileWithLabels = %s \033[0m", t0.fFileWithLabels.Data()); @@ -7112,10 +8189,14 @@ void StoreLabelsInPlaceholder() 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++) { + } // 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_t b = 1; b <= t0.fTest0LabelsPlaceholder->GetXaxis()->GetNbins(); b++) { + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } // void StoreLabelsInPlaceholder() @@ -7127,7 +8208,7 @@ Bool_t RetrieveCorrelationsLabels() // from TH1I *t0.fTest0LabelsPlaceholder if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } Int_t counter[gMaxCorrelator] = {0}; // is this safe? @@ -7150,21 +8231,21 @@ Bool_t RetrieveCorrelationsLabels() 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... - // cout<<__LINE__<<": - // "<Data()<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 +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 @@ -7184,6 +8265,10 @@ TObject* GetObjectFromList(TList* list, // 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__); + } + // Insanity checks: if (!list) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); @@ -7214,6 +8299,10 @@ TObject* GetObjectFromList(TList* list, } } // while(objectIter = next()) + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + return NULL; } // TObject* GetObjectFromList(TList *list, Char_t *objectName) @@ -7225,7 +8314,7 @@ Double_t Weight(const Double_t& value, eWeights whichWeight) // value, integrate // Determine particle weight. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); LOGF(info, "\033[1;32m value = %f\033[0m", value); LOGF(info, "\033[1;32m variable = %d\033[0m", static_cast(whichWeight)); } @@ -7243,6 +8332,10 @@ Double_t Weight(const Double_t& value, eWeights whichWeight) // value, integrate weight = pw.fWeightsHist[whichWeight]->GetBinContent(bin); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + return weight; } // Weight(const Double_t &value, eWeights whichWeight) // value, integrated [phi,pt,eta] weight @@ -7253,6 +8346,10 @@ Double_t DiffWeight(const Double_t& valueY, const Double_t& valueX, eqvectorKine { // Determine differential particle weight y(x). For the time being, "y = phi" always, but this can be generalized. + 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 @@ -7269,10 +8366,10 @@ Double_t DiffWeight(const Double_t& valueY, const Double_t& valueX, eqvectorKine // *) 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 stamenent \033[0m", __FUNCTION__, __LINE__); + 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 stamenent \033[0m", __FUNCTION__, __LINE__); + 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__); } // *) Determine first to which bin the 'valueX' corresponds to. @@ -7321,6 +8418,10 @@ Double_t DiffWeight(const Double_t& valueY, const Double_t& valueX, eqvectorKine } } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + return diffWeight; } // DiffWeight(const Double_t &valueY, const Double_t &valueX, eqvectorKine variableX) @@ -7340,7 +8441,7 @@ void GetParticleWeights() // b) Differential weights. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Integrated weights: @@ -7377,10 +8478,26 @@ void GetParticleWeights() TH1D* phiptWeights = NULL; Int_t nPtBins = res.fResultsPro[AFO_PT]->GetXaxis()->GetNbins(); for (Int_t 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; + } + + // *) 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()); } + + // *) okay, just use this histogram with weights: SetDiffWeightsHist(phiptWeights, wPHIPT, b); } } // if (pw.fUseDiffWeights[wPHIPT]) { @@ -7390,24 +8507,77 @@ void GetParticleWeights() TH1D* phietaWeights = NULL; Int_t nEtaBins = res.fResultsPro[AFO_ETA]->GetXaxis()->GetNbins(); for (Int_t b = 0; b < nEtaBins; b++) { + + // *) 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()); } + + // *) okay, just use this histogram with weights: SetDiffWeightsHist(phietaWeights, wPHIETA, b); } // for(Int_t b=0; bGetBinContent(1) == static_cast(iv.fnEventsInternalValidation)) { + 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; } else { return kFALSE; @@ -7450,6 +8620,9 @@ Bool_t MaxNumberOfEvents(eBeforeAfter ba) } // *) Hasta la vista: + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } return reachedMaxNumberOfEvents; } // void MaxNumberOfEvents(eBeforeAfter ba) @@ -7459,50 +8632,45 @@ Bool_t MaxNumberOfEvents(eBeforeAfter ba) void PrintEventCounter(eBeforeAfter ba) { // Print how many events were processed by now. + // Remark: If I am processing RecSim, the counter is corresponding to Rec. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // *) Print or die: switch (ba) { case eBefore: - if (eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]) { - LOGF(info, "\033[1;32m%s : processing event %d\033[0m", __FUNCTION__, static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]->GetBinContent(1))); - } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]) { - LOGF(info, "\033[1;32m%s : processing event %d\033[0m", __FUNCTION__, static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1))); - } + LOGF(info, "\033[1;32m%s : processing event %d ....\033[0m", __FUNCTION__, eh.fEventCounter[eTotal]); break; case eAfter: - if (tc.fVerbose) { - if (eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]) { - LOGF(info, "\033[1;32m%s : this event passed all cuts %d/%d\033[0m", __FUNCTION__, static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)), static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]->GetBinContent(1))); - } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]) { - LOGF(info, "\033[1;32m%s : this event passed all cuts %d/%d\033[0m", __FUNCTION__, static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1)), static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1))); - } - } + LOGF(info, "\033[1;32m%s : event passed all cuts %d/%d\033[0m", __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; } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void PrintEventCounter(eBeforeAfter ba) //============================================================ -void EventCounter(eEventCounter eVar) +void EventCounterForDryRun(eEventCounterForDryRun eVar) { // 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. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } if (!tc.fDryRun) { - LOGF(fatal, "\033[1;31m%s at line %d : for the time being, function EventCounter(...) can be safely used only for tc.fDryRun = kTRUE \033[0m", __FUNCTION__, __LINE__); + 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) { @@ -7513,10 +8681,10 @@ void EventCounter(eEventCounter eVar) break; case ePrint: // Print current status of event counter: - // Remark: if I am processign RecSim, the counter is corresponding to Rec. + // 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][eRec][eBefore] && eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { + } else if (eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]) { LOGF(info, "Processing event %d (dry run) ....", static_cast(eh.fEventHistograms[eNumberOfEvents][eSim][eAfter]->GetBinContent(1))); } break; @@ -7525,7 +8693,11 @@ void EventCounter(eEventCounter eVar) break; } // switch(eVar) -} // void EventCounter() + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void EventCounterForDryRun() //============================================================ @@ -7538,8 +8710,9 @@ const char* FancyFormatting(const char* name) // 2. add additional information to defalt name (e.g. "Centrality" => "Centrality (V0M)" // 3. ... - if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + if (tc.fVerboseUtility) { + StartFunction(__FUNCTION__); + LOGF(info, "\033[1;32m const char* name = %s\033[0m", name); } // By default, do nothing and return the same thing: @@ -7561,12 +8734,28 @@ const char* FancyFormatting(const char* name) } else if (TString(name).EqualTo("Centrality")) { 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()); + fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("CentRun2", "").Data()); // "CentRun2V0M" => "Centrality (V0M)" } else if (tmp.BeginsWith("Cent")) { - fancyFormatting = Form("Centrality (%s)", tmp.ReplaceAll("Cent", "").Data()); + 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")) { + if (ec.fsEventCuts[eOccupancyEstimator].BeginsWith("Track")) { + fancyFormatting = "Occupancy (getter trackOccupancyInTimeRange())"; + } else if (ec.fsEventCuts[eOccupancyEstimator].BeginsWith("FT0C")) { + fancyFormatting = "Occupancy (getter ft0cOccupancyInTimeRange())"; + } + } + + if (tc.fVerboseUtility) { + ExitFunction(__FUNCTION__); } return fancyFormatting; @@ -7585,7 +8774,7 @@ Double_t CalculateCustomNestedLoops(TArrayI* harmonics) // c) Return value. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } if (!harmonics) { @@ -7764,22 +8953,25 @@ Double_t CalculateCustomNestedLoops(TArrayI* harmonics) // ... 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; } // Double_t CalculateCustomNestedLoops(TArrayI *harmonics) @@ -7796,37 +8988,53 @@ Double_t CalculateKineCustomNestedLoops(TArrayI* harmonics, eAsFunctionOf AFO_va // c) Return value. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } + Trace(__FUNCTION__, __LINE__); + if (!harmonics) { LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } + Trace(__FUNCTION__, __LINE__); + // *) ... eqvectorKine qvKine = eqvectorKine_N; // which component of q-vector + TString kineVarName = ""; switch (AFO_variable) { case AFO_PT: + Trace(__FUNCTION__, __LINE__); qvKine = PTq; + kineVarName = "pt"; break; case AFO_ETA: + Trace(__FUNCTION__, __LINE__); qvKine = ETAq; + kineVarName = "eta"; break; default: + Trace(__FUNCTION__, __LINE__); 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) + Trace(__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 stamenent \033[0m", __FUNCTION__, __LINE__); + LOGF(fatal, "\033[1;31m%s at line %d : qvKine == eqvectorKine_N => add some more entries to the case statement \033[0m", __FUNCTION__, __LINE__); } + Trace(__FUNCTION__, __LINE__); + 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); } + Trace(__FUNCTION__, __LINE__); + // 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++) { @@ -7835,25 +9043,41 @@ Double_t CalculateKineCustomNestedLoops(TArrayI* harmonics, eAsFunctionOf AFO_va } } + Trace(__FUNCTION__, __LINE__); + // 'qvKine' is enum eqvectorKine: - LOGF(info, " %s: nParticles = %d, bin range = [%f,%f)", static_cast(qvKine), nParticles, res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 1), res.fResultsPro[AFO_variable]->GetBinLowEdge(bin + 2)); + 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); + } + + Trace(__FUNCTION__, __LINE__); + + 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)); + + Trace(__FUNCTION__, __LINE__); // a) Determine the order of correlator; Int_t order = harmonics->GetSize(); if (0 == order || order > gMaxCorrelator) { - cout << __LINE__ << endl; - exit(1); + LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__); } + Trace(__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... } + + Trace(__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... } + Trace(__FUNCTION__, __LINE__); + // b) Custom nested loop: TProfile* profile = new TProfile("profile", "", 1, 0., 1.); // helper profile to get all averages automatically // profile->Sumw2(); @@ -8004,22 +9228,33 @@ Double_t CalculateKineCustomNestedLoops(TArrayI* harmonics, eAsFunctionOf AFO_va // ... it's easy to continue the above pattern here } // for(int i12=0; i12GetBinContent(1); + + Trace(__FUNCTION__, __LINE__); + delete profile; profile = NULL; + + Trace(__FUNCTION__, __LINE__); + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } return finalValue; } // Double_t CalculateKineCustomNestedLoops(TArrayI *harmonics, eAsFunctionOf AFO_variable, Int_t bin) @@ -8037,25 +9272,29 @@ void DetermineCentrality(T const& collision) // 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. + // g) Test case; + // h) Print centrality for the audience... if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // a) For real data, determine centrality from default centrality estimator: if constexpr (rs == eRec || rs == eRecAndSim) { - if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFT0M", TString::kIgnoreCase)) { + 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)) { + } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("centFV0A", TString::kIgnoreCase)) { ebye.fCentrality = collision.centFV0A(); - } else if (ec.fsEventCuts[eCentralityEstimator].EqualTo("CentNTPV", TString::kIgnoreCase)) { + } 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(); @@ -8112,24 +9351,99 @@ void DetermineCentrality(T const& collision) // g) Test case: if constexpr (rs == eTest) { - ebye.fCentrality = gRandom->Uniform(0., 100.); + ebye.fCentrality = static_cast(gRandom->Uniform(0., 100.)); } - // *) Print centrality for the audience...: + // h) Print centrality for the audience...: if (tc.fVerbose) { LOGF(info, "\033[1;32m ebye.fCentrality = %f\033[0m", ebye.fCentrality); + ExitFunction(__FUNCTION__); } } // template void DetermineCentrality(T const& collision) //============================================================ +template +void DetermineOccupancy(T const& collision) +{ + // 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__); + } + + // 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()); + } + // 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(); + } + } 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.; + } + } + } + + // c) Print occupancy for the audience...: + if (tc.fVerbose) { + LOGF(info, "\033[1;32m ebye.fOccupancy = %f\033[0m", ebye.fOccupancy); + ExitFunction(__FUNCTION__); + } + +} // template void DetermineOccupancy(T const& collision) + +//============================================================ + +void DetermineEventCounters() +{ + // Determine all event counters. + + if (tc.fVerbose) { + 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 on [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)); + } + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + +} // void DetermineEventCounters() + +//============================================================ + void RandomIndices(Int_t nTracks) { // Randomize indices using Fisher-Yates algorithm. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } if (nTracks < 1) { @@ -8149,6 +9463,10 @@ void RandomIndices(Int_t nTracks) tc.fRandomIndices->AddAt(temp, i); } // end of for(Int_t i=nTracks-1;i>=1;i--) + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void RandomIndices(Int_t nTracks) //============================================================ @@ -8168,7 +9486,7 @@ void BanishmentLoopOverParticles(T const& tracks) // at the end with central data member ebye.fSelectedTracks if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // *) If random access of tracks from collection is requested, use Fisher-Yates algorithm to generate random indices: @@ -8191,7 +9509,7 @@ void BanishmentLoopOverParticles(T const& tracks) if (!tc.fUseFisherYates) { track = tracks.iteratorAt(i); } else { - track = tracks.iteratorAt((int64_t)tc.fRandomIndices->GetAt(i)); + 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.): @@ -8216,13 +9534,13 @@ void BanishmentLoopOverParticles(T const& tracks) lSelectedTracks++; // *) Banish particle histograms after particle cuts: - if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { + if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { FillParticleHistograms(track, eAfter, -1); // with negative weight -1, I effectively remove the previous fill for this track } // *) 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); + LOGF(info, "%s : Breaking the loop over particles, since requested fixed number of %d particles was reached", __FUNCTION__, tc.fFixedNumberOfRandomlySelectedTracks); break; } @@ -8233,6 +9551,10 @@ void BanishmentLoopOverParticles(T const& tracks) LOGF(fatal, "\033[1;31m%s at line %d : lSelectedTracks != ebye.fSelectedTracks , lSelectedTracks = %d, ebye.fSelectedTracks = %d \033[0m", __FUNCTION__, __LINE__, lSelectedTracks, ebye.fSelectedTracks); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void BanishmentLoopOverParticles(T const& tracks) { //============================================================ @@ -8245,7 +9567,7 @@ void PrintCutCounterContent() // b) Print or die. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // a) Insanity checks: @@ -8269,7 +9591,11 @@ void PrintCutCounterContent() 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 + } // for (Int_t rs = 0; rs < 2; rs++) // reco/sim + + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } // void PrintCutCounterContent() @@ -8286,18 +9612,67 @@ void Trace(const char* functionName, Int_t lineNumber) //============================================================ -void BailOut() +void Exit() +{ + // A simple utility wrapper. Used only during debugging. + // Use directly as: Exit(); + // Line number, function name, formatting, etc, are determinad automatically. + + LOGF(info, "\n\n\n\n\n\n\n\n\n\n"); + exit(1); + +} // void Exit() + +//============================================================ + +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. + + LOGF(info, "\033[1;32mStart %s\033[0m", functionName); // prints in green + +} // void StartFunction(const char* functionName) + +//============================================================ + +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. + + LOGF(info, "\033[1;32mExit %s\033[0m", functionName); // prints in green + +} // void ExitFunction(const char* functionName) + +//============================================================ + +void BailOut(Bool_t finalBailout = kFALSE) { // 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. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + 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"; + // *) 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 event to pass selection criteria... \033[0m", sBailOutFile.Data()); + return; + } + } + // *) 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()); @@ -8310,7 +9685,7 @@ void BailOut() // 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(kTRUE); + 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); @@ -8334,10 +9709,21 @@ void BailOut() dirFile = NULL; f->Close(); + if (tc.fVerbose && !(tc.fSequentialBailout > 0)) { // then it will be called only once, for the only and permanent bailout + ExitFunction(__FUNCTION__); + } + // *) Hasta la vista: - LOGF(fatal, "\n\nHasta la vista - bailed out intentionally in function \033[1;31m%s at line %d\n The output file is: %s\n\n\033[0m", __FUNCTION__, __LINE__, sBailOutFile.Data()); + 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__); + } + } -} // void BailOut() +} // void BailOut(Bool_t finalBailout = kFALSE) //============================================================ @@ -8350,7 +9736,7 @@ void FillQvector(const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta // But since usage of weights amounts to checking a few simple booleans here, I do not anticipate any big gain in efficiency... if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + 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); @@ -8396,8 +9782,12 @@ void FillQvector(const Double_t& dPhi, const Double_t& dPt, const Double_t& dEta qv.fQvector[h][wp] += TComplex(TMath::Cos(h * dPhi), TMath::Sin(h * dPhi)); // bare Q-vector without weights } } // for(Int_t wp=0;wpFillqvector(dPhi, dPt, PTq); if (tc.fVerboseForEachParticle) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); + StartFunction(__FUNCTION__); } // *) Mapping between enum's "eqvectorKine" on one side, and "eAsFunctionOf", "eWeights" and "eDiffWeights" on the other: @@ -8435,13 +9825,13 @@ void Fillqvector(const Double_t& dPhi, const Double_t& kineVarValue, eqvectorKin // *) 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 stamenent \033[0m", __FUNCTION__, __LINE__); + 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 stamenent \033[0m", __FUNCTION__, __LINE__); + 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 stamenent \033[0m", __FUNCTION__, __LINE__); + 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: @@ -8487,7 +9877,7 @@ void Fillqvector(const Double_t& dPhi, const Double_t& kineVarValue, eqvectorKin qv.fqvector[kineVarChoice][bin - 1][h][wp] += TComplex(TMath::Cos(h * dPhi), TMath::Sin(h * dPhi)); // bare q-vector without weights } } // for(Int_t wp=0;wp(eh.fEventHistograms[eNumberOfEvents][eSim][eBefore]->GetBinContent(1))); - } else if (eh.fEventHistograms[eNumberOfEvents][eRec][eBefore] && eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]) { - LOGF(info, " Processing event %d/%d (selected/total) .... ", static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eAfter]->GetBinContent(1)), static_cast(eh.fEventHistograms[eNumberOfEvents][eRec][eBefore]->GetBinContent(1))); + StartFunction(__FUNCTION__); } - // TBI 20240423 I need to re-organize here if-else statements + add support for the case when I process only sim, etc. // *) Calculate multiparticle correlations (standard, isotropic, same harmonic): if (qv.fCalculateQvectors && mupa.fCalculateCorrelations) { this->CalculateCorrelations(); } + // *) Calculate differential ("kine") multiparticle correlations: + // Remark: vs. pt, vs. eta, etc., are all calculated here + if (qv.fCalculateQvectors && mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT]) { + this->CalculateKineCorrelations(AFO_PT); + } + if (qv.fCalculateQvectors && mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA]) { + this->CalculateKineCorrelations(AFO_ETA); + } + // *) Calculate Test0: TBI 20240110 name convention // Remark: integrated, vs. M and vs. centrality are all calculated here if (qv.fCalculateQvectors && t0.fCalculateTest0) { @@ -8544,10 +9938,16 @@ void CalculateEverything() 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 this->ComparisonNestedLoopsVsCorrelations(); // I call it here, so comparison is performed cumulatively after each event. The final printout corresponds to all events. } } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // void CalculateEverything() //============================================================ @@ -8560,13 +9960,14 @@ void Steer(T1 const& collision, T2 const& tracks) // The order of function calls obviously matters. if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s starting ...\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // *) Dry run: if (tc.fDryRun) { - EventCounter(eFill); - EventCounter(ePrint); + EventCounterForDryRun(eFill); + EventCounterForDryRun(ePrint); + Preprocess(collision); // yes, so that e.g. I can only test if the weights were correctly fetched from external file and initialized locally into data members return; } @@ -8581,18 +9982,21 @@ void Steer(T1 const& collision, T2 const& tracks) // *) Global timestamp: if (tc.fUseStopwatch) { - LOGF(info, "\033[1;32m\n\n=> Global timer: Steer begins ... %.6f\n\033[0m", tc.fTimer[eGlobal]->RealTime()); + LOGF(info, "\033[1;32m=> Global timer: Steer begins ... %.6f\033[0m", tc.fTimer[eGlobal]->RealTime()); tc.fTimer[eGlobal]->Continue(); // yes } - // *) Do all thingies before starting to process data from this collision (e.g. cut on number of events (bot total and selected), fetch the run number, etc.): + // *) 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); // *) Determine collision centrality: DetermineCentrality(collision); + // *) Determine collision occupancy: + DetermineOccupancy(collision); + // *) Fill event histograms before event cuts: - if (eh.fFillEventHistograms) { + if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D) { FillEventHistograms(collision, tracks, eBefore); } @@ -8634,7 +10038,7 @@ void Steer(T1 const& collision, T2 const& tracks) } // *) Fill event histograms after event AND particle cuts: // TBI 20240110 not sure still if this one is called here, or it has to be moved above - if (eh.fFillEventHistograms) { + if (eh.fFillEventHistograms || qa.fFillQAEventHistograms2D) { FillEventHistograms(collision, tracks, eAfter); } @@ -8659,10 +10063,14 @@ void Steer(T1 const& collision, T2 const& tracks) // *) Global timestamp: if (tc.fUseStopwatch) { - LOGF(info, "\033[1;32m\n\n=> Global timer: Steer ends ... %.6f\n\n\033[0m", tc.fTimer[eGlobal]->RealTime()); + LOGF(info, "\033[1;32m=> Global timer: Steer ends ... %.6f\033[0m\n", tc.fTimer[eGlobal]->RealTime()); tc.fTimer[eGlobal]->Continue(); // yes } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } + } // template void Steer(T1 const* collision, T2 const* tracks) //============================================================ @@ -8684,7 +10092,7 @@ void MainLoopOverParticles(T const& tracks) // *) There is also processTest(...), to process data with minimum subscription to the tables. To use it, set field "processTest": "true" in json config if (tc.fVerbose) { - LOGF(info, "\033[1;32m%s\033[0m", __FUNCTION__); // just a bare function name + StartFunction(__FUNCTION__); } // *) Declare local kinematic variables: @@ -8704,7 +10112,7 @@ void MainLoopOverParticles(T const& tracks) } // *) Local timestamp: - if (tc.fUseStopwatch) { + if (tc.fUseStopwatch && tc.fVerboseUtility) { LOGF(info, " Local timer starts at line %d", __LINE__); tc.fTimer[eLocal]->Reset(); tc.fTimer[eLocal]->Start(); @@ -8719,7 +10127,7 @@ void MainLoopOverParticles(T const& tracks) if (!tc.fUseFisherYates) { track = tracks.iteratorAt(i); } else { - track = tracks.iteratorAt((int64_t)tc.fRandomIndices->GetAt(i)); + 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.): @@ -8728,7 +10136,7 @@ void MainLoopOverParticles(T const& tracks) } // *) Fill particle histograms before particle cuts: - if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { + if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { FillParticleHistograms(track, eBefore); } @@ -8743,7 +10151,7 @@ void MainLoopOverParticles(T const& tracks) } // *) Fill particle histograms after particle cuts: - if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D) { + if (ph.fFillParticleHistograms || ph.fFillParticleHistograms2D || qa.fFillQAParticleHistograms2D) { FillParticleHistograms(track, eAfter); } @@ -8759,11 +10167,11 @@ void MainLoopOverParticles(T const& tracks) } // *) Differential q-vectors: - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_PT]) { // TBI 20240423 I need to extend this condition to mupa.fCalculateCorrelations or some differential version of it - this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_PT] || t0.fCalculateTest0AsFunctionOf[AFO_PT])) { + this->Fillqvector(dPhi, dPt, PTq); // first 2 arguments are passed by reference, 3rd argument is enum } - if (qv.fCalculateQvectors && t0.fCalculateTest0AsFunctionOf[AFO_ETA]) { // TBI 20240423 I need to extend this condition to mupa.fCalculateCorrelations or some differential version of it - this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum + if (qv.fCalculateQvectors && (mupa.fCalculateCorrelationsAsFunctionOf[AFO_ETA] || t0.fCalculateTest0AsFunctionOf[AFO_ETA])) { + this->Fillqvector(dPhi, dEta, ETAq); // first 2 arguments are passed by reference, 3rd argument is enum } // *) Fill nested loops containers: @@ -8779,14 +10187,14 @@ void MainLoopOverParticles(T const& tracks) // *) 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 == ebye.fSelectedTracks) { - LOGF(info, " Breaking the loop over particles, since requested fixed number of %d particles was reached", tc.fFixedNumberOfRandomlySelectedTracks); + 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) // *) Local timestamp: - if (tc.fUseStopwatch) { + if (tc.fUseStopwatch && tc.fVerboseUtility) { LOGF(info, " Local timer ends at line %d, time elapsed ... %.6f", __LINE__, tc.fTimer[eLocal]->RealTime()); tc.fTimer[eLocal]->Continue(); } @@ -8796,6 +10204,9 @@ void MainLoopOverParticles(T const& tracks) LOGF(fatal, "\033[1;31mIn this event there are too few particles (ebye.fSelectedTracks = %d), and requested number of fixed number randomly selected tracks %d couldn't be reached\033[0m", ebye.fSelectedTracks, tc.fFixedNumberOfRandomlySelectedTracks); } + if (tc.fVerbose) { + ExitFunction(__FUNCTION__); + } } // template void MainLoopOverParticles(T const& tracks) { #endif // PWGCF_MULTIPARTICLECORRELATIONS_CORE_MUPA_MEMBERFUNCTIONS_H_ diff --git a/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt b/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt index 397e25796c1..4240aaf37e0 100644 --- a/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt +++ b/PWGCF/MultiparticleCorrelations/Tasks/CMakeLists.txt @@ -18,3 +18,8 @@ o2physics_add_dpl_workflow(multiparticle-correlations-ar SOURCES multiparticle-correlations-ar.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(threeparticle-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 new file mode 100644 index 00000000000..fdb4ff9dcca --- /dev/null +++ b/PWGCF/MultiparticleCorrelations/Tasks/ThreeParticleCorrelations.cxx @@ -0,0 +1,588 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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("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) { + A_PID = TrackPID(track); + if (A_PID[1] < 4.0) { + QARegistry.fill(HIST("hTrackPt"), track.pt()); + QARegistry.fill(HIST("hTrackEta"), track.eta()); + QARegistry.fill(HIST("hTrackPhi"), track.phi()); + QARegistry.fill(HIST("hdEdx"), track.p(), track.tpcSignal()); + QARegistry.fill(HIST("hBeta"), track.p(), track.beta()); + if (A_PID[0] == 0.0) { // Pions + QARegistry.fill(HIST("hdEdxPion"), track.p(), track.tpcSignal()); + QARegistry.fill(HIST("hBetaPion"), track.p(), track.beta()); + QARegistry.fill(HIST("hNSigmaPion"), track.tpcNSigmaPi(), track.tofNSigmaPi()); + } else if (A_PID[0] == 1.0) { // Kaons + QARegistry.fill(HIST("hdEdxKaon"), track.p(), track.tpcSignal()); + QARegistry.fill(HIST("hBetaKaon"), track.p(), track.beta()); + QARegistry.fill(HIST("hNSigmaKaon"), track.tpcNSigmaKa(), track.tofNSigmaKa()); + } else if (A_PID[0] == 2.0) { // Protons + QARegistry.fill(HIST("hdEdxProton"), track.p(), track.tpcSignal()); + QARegistry.fill(HIST("hBetaProton"), track.p(), 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(trigger, associate)) { + if (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(trigger, associate)) { + if (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; + } + + 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 + A_PID = TrackPID(track); + if (A_PID[1] < 4.0) { + + 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 NSigmaTPC[3], NSigma[3]; + Double_t NSigmaTOF[3] = {0.0, 0.0, 0.0}; + NSigmaTPC[0] = Track.tpcNSigmaPi(); + NSigmaTPC[1] = Track.tpcNSigmaKa(); + NSigmaTPC[2] = Track.tpcNSigmaPr(); + if (Track.hasTOF()) { + NSigmaTOF[0] = Track.tofNSigmaPi(); + NSigmaTOF[1] = Track.tofNSigmaKa(); + NSigmaTOF[2] = Track.tofNSigmaPr(); + } + + NSigma[0] = TMath::Sqrt(pow(NSigmaTPC[0], 2) + pow(NSigmaTOF[0], 2)); + NSigma[1] = TMath::Sqrt(pow(NSigmaTPC[1], 2) + pow(NSigmaTOF[1], 2)); + NSigma[2] = TMath::Sqrt(pow(NSigmaTPC[2], 2) + pow(NSigmaTOF[2], 2)); + + if (NSigma[0] <= std::min(NSigma[1], NSigma[2])) { // Pions + ID[0] = 0.0; + ID[1] = NSigma[0]; + } else if (NSigma[1] <= std::min(NSigma[0], NSigma[2])) { // Kaons + ID[0] = 1.0; + ID[1] = NSigma[1]; + } else if (NSigma[2] <= std::min(NSigma[0], NSigma[1])) { // Protons + ID[0] = 2.0; + ID[1] = NSigma[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 V0Cand& V0, const TrackCand& Track) + { + + if (Track.globalIndex() == V0.posTrackId() || Track.globalIndex() == V0.negTrackId()) { + return kFALSE; + } + if (TrackPID(Track)[1] > 4.0) { + 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 aac8b255ef4..fd0b3942024 100644 --- a/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx +++ b/PWGCF/MultiparticleCorrelations/Tasks/multiparticle-correlations-ab.cxx @@ -24,7 +24,7 @@ using namespace o2; using namespace o2::framework; // *) Run 3: -using EventSelection = soa::Join; +using EventSelection = soa::Join; using CollisionRec = soa::Join::iterator; // use in json "isMC": "true" for "event-selection-task" using CollisionRecSim = soa::Join::iterator; using CollisionSim = aod::McCollision; @@ -62,6 +62,7 @@ using CollisionRecSim_Run1 = soa::Join #include #include +#include using namespace std; // *) Enums: @@ -93,11 +94,11 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to { // *) Trick to avoid name clashes, part 1; // *) Default configuration, booking, binning and cuts; - // *) Insanity checks; + // *) Insanity checks before booking; // *) Book random generator; // *) Book base list; // *) Book all remaining objects; - // ... + // *) Insanity checks after booking; // *) Trick to avoid name clashes, part 2; // *) Trick to avoid name clashes, part 1: @@ -105,16 +106,15 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to TH1::AddDirectory(kFALSE); // *) Default configuration, booking, binning and cuts: - DefaultConfiguration(); - DefaultBooking(); // here I decide only which histograms are booked, not details like binning, etc. That's done later in Book* member functions. - DefaultBinning(); - DefaultCuts(); // Remark: has to be called after DefaultBinning(), since some default cuts are defined through default binning, to ease bookeeping + 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() - // *) Set what to process - only rec, both rec and sim, only sim: - // WhatToProcess(); // yes, this can be called here, after calling all Default* member functions above, because this has an effect only on Book* members functions, and the ones called afterward - - // *) Insanity checks: - InsanityChecks(); + // *) Insanity checks before booking: + InsanityChecksBeforeBooking(); // check only harwired values and the ones obtained from configurables // *) Book random generator: delete gRandom; @@ -134,12 +134,16 @@ struct MultiparticleCorrelationsAB // this name is used in lower-case format to BookQvectorHistograms(); BookCorrelationsHistograms(); BookWeightsHistograms(); + BookCentralityWeightsHistograms(); BookNestedLoopsHistograms(); BookNUAHistograms(); BookInternalValidationHistograms(); BookTest0Histograms(); BookTheRest(); // here I book everything that was not sorted (yet) in the specific functions above + // *) Insanity checks after booking: + 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); diff --git a/PWGCF/TableProducer/dptdptfilter.cxx b/PWGCF/TableProducer/dptdptfilter.cxx index ff5930aa9cc..986370739b4 100644 --- a/PWGCF/TableProducer/dptdptfilter.cxx +++ b/PWGCF/TableProducer/dptdptfilter.cxx @@ -11,10 +11,13 @@ #include #include +#include +#include #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" +#include "CommonConstants/PhysicsConstants.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Centrality.h" #include "Common/Core/TableHelper.h" @@ -29,6 +32,7 @@ #include "Framework/RunningWorkflowInfo.h" #include #include +#include #include #include #include @@ -163,6 +167,169 @@ std::vector partMultNeg; // multiplicity of negative particles using namespace dptdptfilter; +////////////////////////////////////////////////////////////////////////////// +// Multiplicity in principle for on the fly generated events +////////////////////////////////////////////////////////////////////////////// + +struct Multiplicity { + enum multest { + kV0M, + kCL1, + kCL1GAP + }; + + float getMultiplicityClass() { return multiplicityclass; } + float getMultiplicity() { return multiplicity; } + + multest classestimator = kV0M; + + float multiplicityclass = -1.0; + float multiplicity = 0.0; + bool inelgth0 = false; + int V0AM = 0; + int V0CM = 0; + int CL1M = 0; + int CL1EtaGapM = 0; + int dNchdEta = 0; + int nPart = 0; + TH1F* fhNPartTot = nullptr; ///< total number of particles analyzed + TH1F* fhMultiplicity; ///< the multiplicity distribution + TH2F* fhV0Multiplicity; ///< the V0M multiplicity histogram + TH2F* fhCL1Multiplicity; ///< the CL1 multiplicity histogram + TH2F* fhCL1EtaGapMultiplicity; ///< the CL1 with an eta gap multiplicity histogram + const TH1* fhV0MMultPercentile; ///< the V0M Centrality / Multiplicity percentile estimation histogram + const TH1* fhCL1MultPercentile; ///< the CL1 Centrality / Multiplicity percentile estimation histogram + const TH1* fhCL1EtaGapMultPercentile; ///< the CL1 with an eta gap Centrality / Multiplicity percentile estimation histogram + + void init(TList* hlist) + { + fhNPartTot = new TH1F("CollisionNpart", "Collision analyzed particles;number of particles;counts", 8000, -0.5, 8000 - 0.5); + fhMultiplicity = new TH1F("CollisionMultiplicity", "Event multiplicity;multiplicity (%);counts", 101, -0.5, 101 - 0.5); + fhV0Multiplicity = new TH2F("V0Multiplicity", "V0M;V0M;d#it{N}/d#eta;counts", 3000, -9.5, 3000 - 9.5, 2500, -9.5, 2500 - 9.5); + fhCL1Multiplicity = new TH2F("CL1Multiplicity", "CL1M;CL1M;d#it{N}/d#eta;counts", 3000, -9.5, 3000 - 9.5, 2500, -9.5, 2500 - 9.5); + fhCL1EtaGapMultiplicity = new TH2F("CL1EtaGapMultiplicity", "CL1M (excl |#eta|<0.8);CL1M;d#it{N}/d#eta;counts", 3000, -9.5, 3000 - 9.5, 2500, -9.5, 2500 - 9.5); + + hlist->Add(fhNPartTot); + hlist->Add(fhMultiplicity); + hlist->Add(fhV0Multiplicity); + hlist->Add(fhCL1Multiplicity); + hlist->Add(fhCL1EtaGapMultiplicity); + } + + void setMultiplicityPercentiles(TList* list) + { + LOGF(info, "setMultiplicityPercentiles()", "From list %s", list->GetName()); + fhV0MMultPercentile = reinterpret_cast(list->FindObject("V0MCentMult")); + fhCL1MultPercentile = reinterpret_cast(list->FindObject("CL1MCentMult")); + fhCL1EtaGapMultPercentile = reinterpret_cast(list->FindObject("CL1EtaGapMCentMult")); + + if (fhV0MMultPercentile == nullptr || fhCL1MultPercentile == nullptr || fhCL1EtaGapMultPercentile == nullptr) { + LOGF(fatal, "setMultiplicityPercentiles()", "Percentiles histograms not correctly loaded. ABORTING!!!"); + return; + } + } + + template + bool addParticleToMultiplicity(const Particle& p) + { + /* on the fly MC production */ + /* get event multiplicity according to the passed eta range */ + /* event multiplicity as number of primary charged particles */ + /* based on AliAnalysisTaskPhiCorrelations implementation */ + int pdgcode = std::abs(p.pdgCode()); + auto addTo = [](const Particle& p, int& est, float etamin, float etamax) { + if (p.eta() < etamax && etamin < p.eta()) { + est = est + 1; + } + }; + + /* pdg checks */ + switch (pdgcode) { + case kPiPlus: + case kKPlus: + 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()) { + 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); + nPart++; + } + break; + default: + break; + } + return true; + } + + template + void extractMultiplicity(const CollisionParticles& particles) + { + multiplicityclass = 105; + multiplicity = 0; + inelgth0 = false; + nPart = 0; + V0AM = 0; + V0CM = 0; + CL1M = 0; + CL1EtaGapM = 0; + dNchdEta = 0; + + for (auto particle : particles) { + addParticleToMultiplicity(particle); + } + + if (inelgth0) { + if (fhNPartTot != nullptr) { + fhNPartTot->Fill(nPart); + } + if (fhV0Multiplicity != nullptr) { + fhV0Multiplicity->Fill(V0AM + V0CM, dNchdEta); + } + if (fhCL1Multiplicity != nullptr) { + fhCL1Multiplicity->Fill(CL1M, dNchdEta); + } + if (fhCL1EtaGapMultiplicity != nullptr) { + fhCL1EtaGapMultiplicity->Fill(CL1EtaGapM, dNchdEta); + } + switch (classestimator) { + case kV0M: + if (fhV0MMultPercentile != nullptr) { + multiplicityclass = fhV0MMultPercentile->GetBinContent(fhV0MMultPercentile->FindFixBin(V0AM + V0CM)); + multiplicity = V0AM + V0CM; + } + break; + case kCL1: + if (fhCL1MultPercentile != nullptr) { + multiplicityclass = fhCL1MultPercentile->GetBinContent(fhCL1MultPercentile->FindFixBin(CL1M)); + multiplicity = CL1M; + } + break; + case kCL1GAP: + if (fhCL1EtaGapMultPercentile != nullptr) { + multiplicityclass = fhCL1EtaGapMultPercentile->GetBinContent(fhCL1EtaGapMultPercentile->FindFixBin(CL1EtaGapM)); + multiplicity = CL1EtaGapM; + } + break; + default: + break; + } + fhMultiplicity->Fill(multiplicityclass); + } + } +}; + +////////////////////////////////////////////////////////////////////////////// +// The filter class +////////////////////////////////////////////////////////////////////////////// + struct DptDptFilter { struct : ConfigurableGroup { Configurable cfgCCDBUrl{"input_ccdburl", "http://ccdb-test.cern.ch:8080", "The CCDB url for the input file"}; @@ -189,6 +356,8 @@ struct DptDptFilter { Produces acceptedtrueevents; Produces gencollisionsinfo; + Multiplicity multiplicity; + void init(InitContext const&) { using namespace dptdptfilter; @@ -212,6 +381,8 @@ struct DptDptFilter { /* the centrality/multiplicity estimation */ if (doprocessWithoutCent || doprocessWithoutCentDetectorLevel || doprocessWithoutCentGeneratorLevel) { fCentMultEstimator = kNOCM; + } else if (doprocessOnTheFlyGeneratorLevel) { + fCentMultEstimator = kFV0A; } else { fCentMultEstimator = getCentMultEstimator(cfgCentMultEstimator); } @@ -271,14 +442,20 @@ struct DptDptFilter { fhTrueVertexZB = new TH1F("TrueVertexZB", "Vertex Z before (truth); z_{vtx}", 60, -15, 15); fhTrueVertexZA = new TH1F("TrueVertexZA", "Vertex Z (truth); z_{vtx}", zvtxbins, zvtxlow, zvtxup); - fhTrueVertexZAA = new TH1F("TrueVertexZAA", "Vertex Z (truth rec associated); z_{vtx}", zvtxbins, zvtxlow, zvtxup); + if (!doprocessOnTheFlyGeneratorLevel) { + fhTrueVertexZAA = new TH1F("TrueVertexZAA", "Vertex Z (truth rec associated); z_{vtx}", zvtxbins, zvtxlow, zvtxup); + } /* add the hstograms to the output list */ fOutputList->Add(fhTrueCentMultB); fOutputList->Add(fhTrueCentMultA); fOutputList->Add(fhTrueVertexZB); fOutputList->Add(fhTrueVertexZA); - fOutputList->Add(fhTrueVertexZAA); + if (doprocessOnTheFlyGeneratorLevel) { + multiplicity.init(fOutputList); + } else { + fOutputList->Add(fhTrueVertexZAA); + } } } @@ -304,7 +481,7 @@ struct DptDptFilter { PROCESS_SWITCH(DptDptFilter, processWithoutCentDetectorLevel, "Process MC detector level without centrality", false); template - void processGenerated(CollisionObject const& mccollision, ParticlesList const& mcparticles, float centormult); + bool processGenerated(CollisionObject const& mccollision, ParticlesList const& mcparticles, float centormult); template void processGeneratorLevel(aod::McCollision const& mccollision, @@ -331,6 +508,10 @@ struct DptDptFilter { aod::CollisionsEvSel const& allcollisions); PROCESS_SWITCH(DptDptFilter, processWithoutCentGeneratorLevel, "Process generated without centrality", false); + void processOnTheFlyGeneratorLevel(aod::McCollision const& mccollision, + aod::McParticles const& mcparticles); + PROCESS_SWITCH(DptDptFilter, processOnTheFlyGeneratorLevel, "Process on the fly generated events", false); + void processVertexGenerated(aod::McCollisions const&); PROCESS_SWITCH(DptDptFilter, processVertexGenerated, "Process vertex generator level", false); }; @@ -398,7 +579,7 @@ void DptDptFilter::processWithoutCentDetectorLevel(aod::CollisionEvSel const& co } template -void DptDptFilter::processGenerated(CollisionObject const& mccollision, ParticlesList const&, float centormult) +bool DptDptFilter::processGenerated(CollisionObject const& mccollision, ParticlesList const&, float centormult) { using namespace dptdptfilter; @@ -411,6 +592,7 @@ void DptDptFilter::processGenerated(CollisionObject const& mccollision, Particle } else { gencollisionsinfo(acceptedevent, centormult); } + return static_cast(acceptedevent); } template @@ -471,6 +653,26 @@ void DptDptFilter::processWithoutCentGeneratorLevel(aod::McCollision const& mcco processGeneratorLevel(mccollision, collisions, mcparticles, allcollisions, 50.0); } +void DptDptFilter::processOnTheFlyGeneratorLevel(aod::McCollision const& mccollision, + aod::McParticles const& mcparticles) +{ + uint8_t acceptedEvent = uint8_t(false); + fhTrueVertexZB->Fill(mccollision.posZ()); + /* we assign a default value for the time being */ + float centormult = 50.0f; + if (IsEvtSelected(mccollision, centormult)) { + acceptedEvent = true; + multiplicity.extractMultiplicity(mcparticles); + fhTrueVertexZA->Fill((mccollision.posZ())); + centormult = multiplicity.getMultiplicityClass(); + } + if (fullDerivedData) { + acceptedtrueevents(mccollision.bcId(), mccollision.posZ(), acceptedEvent, centormult); + } else { + gencollisionsinfo(acceptedEvent, centormult); + } +} + void DptDptFilter::processVertexGenerated(aod::McCollisions const& mccollisions) { for (aod::McCollision const& mccollision : mccollisions) { @@ -517,6 +719,7 @@ struct DptDptFilterTracks { 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"}; @@ -572,6 +775,7 @@ struct DptDptFilterTracks { traceDCAOutliers = cfgTraceDCAOutliers; traceOutOfSpeciesParticles = cfgTraceOutOfSpeciesParticles; recoIdMethod = cfgRecoIdMethod; + onlyInOneSide = cfgOnlyInOneSide.value; /* 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 */ @@ -583,7 +787,8 @@ struct DptDptFilterTracks { fPDG = TDatabasePDG::Instance(); /* required ambiguous tracks checks? */ - if (dofilterDetectorLevelWithoutPIDAmbiguous || dofilterDetectorLevelWithPIDAmbiguous || dofilterRecoWithoutPIDAmbiguous || dofilterRecoWithPIDAmbiguous) { + if (dofilterDetectorLevelWithoutPIDAmbiguous || dofilterDetectorLevelWithPIDAmbiguous || dofilterDetectorLevelWithFullPIDAmbiguous || + dofilterRecoWithoutPIDAmbiguous || dofilterRecoWithPIDAmbiguous || dofilterRecoWithFullPIDAmbiguous) { checkAmbiguousTracks = true; } @@ -837,7 +1042,7 @@ struct DptDptFilterTracks { template int8_t trackIdentification(TrackObject const& track); - template + template int8_t selectTrack(TrackObject const& track); template int8_t selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track); @@ -1101,7 +1306,7 @@ int8_t DptDptFilterTracks::trackIdentification(TrackObject const& track) return sp; } -template +template int8_t DptDptFilterTracks::selectTrack(TrackObject const& track) { using namespace dptdptfilter; @@ -1111,7 +1316,7 @@ int8_t DptDptFilterTracks::selectTrack(TrackObject const& track) /* track selection */ int8_t sp = -127; - if (AcceptTrack(track)) { + if (AcceptTrack(track)) { /* the track has been accepted */ /* let's identify it */ sp = trackIdentification(track); @@ -1166,7 +1371,7 @@ int8_t DptDptFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& col } } - float multiplicityclass = (track.template collision_as>()).centmult(); + float multiplicityclass = (track.template collision_as()).centmult(); if (ambiguoustrack) { /* keep track of ambiguous tracks */ fhAmbiguousTrackType->Fill(ambtracktype, multiplicityclass); @@ -1183,7 +1388,7 @@ int8_t DptDptFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& col /* feedback of no ambiguous tracks only if checks required */ fhAmbiguousTrackType->Fill(ambtracktype, multiplicityclass); } - return selectTrack(track); + return selectTrack(track); } } diff --git a/PWGCF/TableProducer/dptdptfilter.h b/PWGCF/TableProducer/dptdptfilter.h index bae7b9934d0..b4a6f2859b8 100644 --- a/PWGCF/TableProducer/dptdptfilter.h +++ b/PWGCF/TableProducer/dptdptfilter.h @@ -94,12 +94,16 @@ enum CentMultEstimatorType { /// \enum TriggerSelectionType /// \brief The type of trigger to apply for event selection enum TriggerSelectionType { - kNONE = 0, ///< do not use trigger selection - kMB, ///< Minimum bias trigger - kVTXTOFMATCHED, ///< at least one vertex contributor is matched to TOF - kVTXTRDMATCHED, ///< at least one vertex contributor is matched to TRD - kVTXTRDTOFMATCHED, ///< at least one vertex contributor is matched to TRD and TOF - knEventSelection ///< number of triggers for event selection + kNONE = 0, ///< do not use trigger selection + kMB, ///< Minimum bias trigger + kMBEXTRA, ///< Additional Run3 event quality + kVTXTOFMATCHED, ///< at least one vertex contributor is matched to TOF + kVTXTRDMATCHED, ///< at least one vertex contributor is matched to TRD + kVTXTRDTOFMATCHED, ///< at least one vertex contributor is matched to TRD and TOF + kEXTRAVTXTOFMATCHED, ///< Additional Run3 event quality and at least one vertex contributor is matched to TOF + kEXTRAVTXTRDMATCHED, ///< Additional Run3 event quality and at least one vertex contributor is matched to TRD + kEXTRAVTXTRDTOFMATCHED, ///< Additional Run3 event quality and at least one vertex contributor is matched to TRD and TOF + knEventSelection ///< number of triggers for event selection }; /// \enum StrongDebugging @@ -131,6 +135,7 @@ float zvtxlow = -10.0, zvtxup = 10.0; int phibins = 72; float philow = 0.0; float phiup = constants::math::TwoPI; +bool onlyInOneSide = false; /* select only tracks that don't cross the TPC central membrane */ /* selection criteria from PWGMM */ // default quality criteria for tracks with ITS contribution @@ -312,12 +317,20 @@ inline TriggerSelectionType getTriggerSelection(std::string const& triggstr) { if (triggstr.empty() || triggstr == "MB") { return kMB; + } else if (triggstr == "MBEXTRA") { + return kMBEXTRA; } else if (triggstr == "VTXTOFMATCHED") { return kVTXTOFMATCHED; } else if (triggstr == "VTXTRDMATCHED") { return kVTXTRDMATCHED; } else if (triggstr == "VTXTRDTOFMATCHED") { return kVTXTRDTOFMATCHED; + } else if (triggstr == "EXTRAVTXTOFMATCHED") { + return kEXTRAVTXTOFMATCHED; + } else if (triggstr == "EXTRAVTXTRDMATCHED") { + return kEXTRAVTXTRDMATCHED; + } else if (triggstr == "EXTRAVTXTRDTOFMATCHED") { + return kEXTRAVTXTRDTOFMATCHED; } else if (triggstr == "None") { return kNONE; } else { @@ -481,9 +494,10 @@ inline bool triggerSelectionReco(CollisionObject const& collision) case kppRun3: case kPbPbRun3: { auto run3Accepted = [](auto const& coll) { + return coll.sel8(); + }; + auto run3ExtraAccepted = [](auto const& coll) { return coll.sel8() && - coll.selection_bit(aod::evsel::kNoITSROFrameBorder) && - coll.selection_bit(aod::evsel::kNoTimeFrameBorder) && coll.selection_bit(aod::evsel::kNoSameBunchPileup) && coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && coll.selection_bit(aod::evsel::kIsVertexITSTPC); @@ -494,6 +508,11 @@ inline bool triggerSelectionReco(CollisionObject const& collision) trigsel = true; } break; + case kMBEXTRA: + if (run3ExtraAccepted(collision)) { + trigsel = true; + } + break; case kVTXTOFMATCHED: if (run3Accepted(collision) && collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { trigsel = true; @@ -509,6 +528,21 @@ inline bool triggerSelectionReco(CollisionObject const& collision) trigsel = true; } break; + case kEXTRAVTXTOFMATCHED: + if (run3ExtraAccepted(collision) && collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + trigsel = true; + } + break; + case kEXTRAVTXTRDMATCHED: + if (run3ExtraAccepted(collision) && collision.selection_bit(aod::evsel::kIsVertexTRDmatched)) { + trigsel = true; + } + break; + case kEXTRAVTXTRDTOFMATCHED: + if (run3ExtraAccepted(collision) && collision.selection_bit(aod::evsel::kIsVertexTRDmatched) && collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + trigsel = true; + } + break; case kNONE: trigsel = true; break; @@ -628,51 +662,38 @@ inline float extractMultiplicity(CollisionObject const& collision, CentMultEstim /// \brief Centrality/multiplicity percentile template + requires(o2::aod::HasRun2Centrality) float getCentMultPercentile(CollisionObject collision) { - if constexpr (framework::has_type_v || - framework::has_type_v || - framework::has_type_v) { - switch (fCentMultEstimator) { - case kV0M: - return collision.centRun2V0M(); - break; - case kCL0: - return collision.centRun2CL0(); - break; - case kCL1: - return collision.centRun2CL1(); - break; - default: - return 105.0; - break; - } + switch (fCentMultEstimator) { + case kV0M: + return collision.centRun2V0M(); + case kCL0: + return collision.centRun2CL0(); + case kCL1: + return collision.centRun2CL1(); + default: + return 105.0; } - if constexpr (framework::has_type_v || - framework::has_type_v || - framework::has_type_v || - framework::has_type_v || - framework::has_type_v) { - switch (fCentMultEstimator) { - case kFV0A: - return collision.centFV0A(); - break; - case kFT0M: - return collision.centFT0M(); - break; - case kFT0A: - return collision.centFT0A(); - break; - case kFT0C: - return collision.centFT0C(); - break; - case kNTPV: - return collision.centNTPV(); - break; - default: - return 105.0; - break; - } +} + +template + requires(o2::aod::HasCentrality) +float getCentMultPercentile(CollisionObject collision) +{ + switch (fCentMultEstimator) { + case kFV0A: + return collision.centFV0A(); + case kFT0M: + return collision.centFT0M(); + case kFT0A: + return collision.centFT0A(); + case kFT0C: + return collision.centFT0C(); + case kNTPV: + return collision.centNTPV(); + default: + return 105.0; } } @@ -777,7 +798,14 @@ inline bool IsEvtSelected(CollisionObject const& collision, float& centormult) bool zvtxsel = false; /* TODO: vertex quality checks */ if (zvtxlow < collision.posZ() && collision.posZ() < zvtxup) { - zvtxsel = true; + if (onlyInOneSide) { + if (collision.posZ() != 0.0) { + /* if only one side, we accept collisions which have zvtx different than zero */ + zvtxsel = true; + } + } else { + zvtxsel = true; + } } bool centmultsel = centralitySelection(collision, centormult); @@ -820,7 +848,7 @@ inline bool matchTrackType(TrackObject const& track) } }; auto checkDcaZcut = [&](auto const& track) { - return ((maxDcaZPtDep) ? abs(track.dcaZ()) <= maxDcaZPtDep(track.pt()) : true); + return ((maxDcaZPtDep) ? std::fabs(track.dcaZ()) <= maxDcaZPtDep(track.pt()) : true); }; /* tight pT dependent DCAz cut */ @@ -841,9 +869,12 @@ inline bool matchTrackType(TrackObject const& track) /// \brief Checks if the passed track is within the acceptance conditions of the analysis /// \param track the track of interest /// \return true if the track is in the acceptance, otherwise false -template +template inline bool InTheAcceptance(TrackObject const& track) { + /* the side on which the collision happened */ + float side = track.template collision_as().posZ(); + /* overall minimum momentum cut for the analysis */ if (!(overallminp < track.p())) { return false; @@ -855,6 +886,22 @@ inline bool InTheAcceptance(TrackObject const& track) } } + /* check the side of the collision and decide if one side */ + if (onlyInOneSide) { + if (side < 0) { + if (track.eta() >= 0.0) { + return false; + } + } else if (side > 0) { + if (track.eta() <= 0.0) { + return false; + } + } else { + /* if only one side we should not have collisions with zvtx = 0 */ + LOGF(fatal, "Selecting one side tracks with a zvtx zero collision"); + } + } + if (ptlow < track.pt() && track.pt() < ptup && etalow < track.eta() && track.eta() < etaup) { return true; } @@ -864,10 +911,10 @@ inline bool InTheAcceptance(TrackObject const& track) /// \brief Accepts or not the passed track /// \param track the track of interest /// \return true if the track is accepted, otherwise false -template +template inline bool AcceptTrack(TrackObject const& track) { - if (InTheAcceptance(track)) { + if (InTheAcceptance(track)) { if (matchTrackType(track)) { return true; } @@ -939,6 +986,7 @@ struct PIDSpeciesSelection { const std::vector sptitles = {"e", "#mu", "#pi", "K", "p"}; const std::vector spfnames = {"E", "Mu", "Pi", "Ka", "Pr"}; const std::vector spadjnames = {"Electron", "Muon", "Pion", "Kaon", "Proton"}; + const std::vector spmasses = {o2::constants::physics::MassElectron, o2::constants::physics::MassMuon, o2::constants::physics::MassPionCharged, o2::constants::physics::MassKaonCharged, o2::constants::physics::MassProton}; const std::vector chadjnames = {"P", "M"}; const char* hadname = "h"; const char* hadtitle = "h"; @@ -947,6 +995,7 @@ struct PIDSpeciesSelection { const char* getSpeciesName(uint8_t ix) { return spnames[species[ix]].data(); } const char* getSpeciesTitle(uint8_t ix) { return sptitles[species[ix]].data(); } const char* getSpeciesFName(uint8_t ix) { return spfnames[species[ix]].data(); } + double getSpeciesMass(uint8_t ix) { return spmasses[species[ix]]; } const char* getHadName() { return hadname; } const char* getHadTitle() { return hadtitle; } const char* getHadFName() { return hadfname; } diff --git a/PWGCF/TableProducer/filterCorrelations.cxx b/PWGCF/TableProducer/filterCorrelations.cxx index 9bb042dff51..9cbde25a20c 100644 --- a/PWGCF/TableProducer/filterCorrelations.cxx +++ b/PWGCF/TableProducer/filterCorrelations.cxx @@ -277,6 +277,25 @@ struct FilterCF { delete[] mcParticleLabels; } PROCESS_SWITCH(FilterCF, processMC, "Process MC", false); + + void processMCGen(aod::McCollisions::iterator const& mcCollision, aod::McParticles const& particles) + { + float multiplicity = 0.0f; + for (auto& particle : particles) { + if (!particle.isPhysicalPrimary() || std::abs(particle.eta()) > cfgCutMCEta || particle.pt() < cfgCutMCPt) + continue; + int8_t sign = 0; + if (TParticlePDG* pdgparticle = pdg->GetParticle(particle.pdgCode())) + if ((sign = pdgparticle->Charge()) != 0) + multiplicity += 1.0f; + outputMcParticles(outputMcCollisions.lastIndex() + 1, truncateFloatFraction(particle.pt(), FLOAT_PRECISION), + truncateFloatFraction(particle.eta(), FLOAT_PRECISION), + truncateFloatFraction(particle.phi(), FLOAT_PRECISION), + sign, particle.pdgCode(), particle.flags()); + } + outputMcCollisions(mcCollision.posZ(), multiplicity); + } + PROCESS_SWITCH(FilterCF, processMCGen, "Process MCGen", false); }; struct MultiplicitySelector { @@ -306,6 +325,9 @@ struct MultiplicitySelector { if (doprocessFT0A) { enabledFunctions++; } + if (doprocessMCGen) { + enabledFunctions++; + } if (enabledFunctions != 1) { LOGP(fatal, "{} multiplicity selectors enabled but we need exactly 1.", enabledFunctions); @@ -349,6 +371,12 @@ struct MultiplicitySelector { } } PROCESS_SWITCH(MultiplicitySelector, processRun2V0M, "Select V0M centrality as multiplicity", true); + + void processMCGen(aod::McCollision const&, aod::McParticles const& particles) + { + output(particles.size()); + } + PROCESS_SWITCH(MultiplicitySelector, processMCGen, "Select MC particle count as multiplicity", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/Tasks/CMakeLists.txt b/PWGCF/Tasks/CMakeLists.txt index fdc35cf2ef6..ab3d5edd9e2 100644 --- a/PWGCF/Tasks/CMakeLists.txt +++ b/PWGCF/Tasks/CMakeLists.txt @@ -28,3 +28,8 @@ o2physics_add_dpl_workflow(correlations SOURCES correlations.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(pid-cme + SOURCES pidcme.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 a83558740e2..5ad33872ccb 100644 --- a/PWGCF/Tasks/correlations.cxx +++ b/PWGCF/Tasks/correlations.cxx @@ -85,6 +85,7 @@ struct CorrelationTask { O2_DEFINE_CONFIGURABLE(cfgDecayParticleMask, int, 0, "Selection bitmask 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.") ConfigurableAxis axisVertex{"axisVertex", {7, -7, 7}, "vertex axis for histograms"}; ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {72, -PIHalf, PIHalf * 3}, "delta phi axis for histograms"}; @@ -149,6 +150,7 @@ struct CorrelationTask { registry.add("etaphiTrigger", "multiplicity/centrality vs eta vs phi (triggers)", {HistType::kTH3F, {{100, 0, 100, "multiplicity/centrality"}, {100, -2, 2, "#eta"}, {200, 0, 2 * M_PI, "#varphi"}}}); registry.add("invMass", "2-prong invariant mass (GeV/c^2)", {HistType::kTH3F, {axisInvMassHistogram, axisPtTrigger, axisMultiplicity}}); } + registry.add("multiplicity", "event multiplicity", {HistType::kTH1F, {{1000, 0, 100, "/multiplicity/centrality"}}}); const int maxMixBin = AxisSpec(axisMultiplicity).getNbins() * AxisSpec(axisVertex).getNbins(); registry.add("eventcount_same", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); @@ -221,6 +223,7 @@ struct CorrelationTask { template void fillQA(const TCollision& /*collision*/, float multiplicity, const TTracks& tracks) { + registry.fill(HIST("multiplicity"), multiplicity); for (auto& track1 : tracks) { registry.fill(HIST("yields"), multiplicity, track1.pt(), track1.eta()); registry.fill(HIST("etaphi"), multiplicity, track1.eta(), track1.phi()); @@ -229,6 +232,8 @@ struct CorrelationTask { template using hasInvMass = decltype(std::declval().invMass()); + template + using hasPDGCode = decltype(std::declval().pdgCode()); template void fillQA(const TCollision& collision, float multiplicity, const TTracks1& tracks1, const TTracks2& tracks2) @@ -241,6 +246,10 @@ struct CorrelationTask { } registry.fill(HIST("invMass"), track1.invMass(), track1.pt(), multiplicity); } + if constexpr (std::experimental::is_detected::value) { + if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1->pdgCode()) == cfgMcTriggerPDGs->end()) + continue; + } registry.fill(HIST("yieldsTrigger"), multiplicity, track1.pt(), track1.eta()); registry.fill(HIST("etaphiTrigger"), multiplicity, track1.eta(), track1.phi()); } @@ -312,6 +321,11 @@ struct CorrelationTask { continue; } + if constexpr (std::experimental::is_detected::value) { + if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track1.pdgCode()) == cfgMcTriggerPDGs->end()) + continue; + } + if constexpr (std::experimental::is_detected::value) { if (cfgTriggerCharge != 0 && cfgTriggerCharge * track1.sign() < 0) { continue; @@ -341,6 +355,11 @@ struct CorrelationTask { continue; } } + if constexpr (std::experimental::is_detected::value) { + if (!cfgMcTriggerPDGs->empty() && std::find(cfgMcTriggerPDGs->begin(), cfgMcTriggerPDGs->end(), track2.pdgCode()) != cfgMcTriggerPDGs->end()) + continue; + } + if constexpr (std::experimental::is_detected::value) { if (track2.globalIndex() == track1.cfTrackProng0Id()) // do not correlate daughter tracks of the same event continue; @@ -722,8 +741,11 @@ struct CorrelationTask { case 2212: // proton case -2212: return 2; - default: + case 421: // D0 + case -421: return 3; + default: + return 4; } } @@ -794,6 +816,8 @@ struct CorrelationTask { } } + fillQA(mcCollision, multiplicity, mcParticles); + same->fillEvent(multiplicity, CorrelationContainer::kCFStepAll); fillCorrelations(same, mcParticles, mcParticles, multiplicity, mcCollision.posZ(), 0, 1.0f); diff --git a/PWGCF/Tasks/dptdptcorrelations.cxx b/PWGCF/Tasks/dptdptcorrelations.cxx index 8ccdc1f93a0..ad227a09e7d 100644 --- a/PWGCF/Tasks/dptdptcorrelations.cxx +++ b/PWGCF/Tasks/dptdptcorrelations.cxx @@ -62,9 +62,11 @@ float deltaphibinwidth = constants::math::TwoPI / deltaphibins; float deltaphilow = 0.0 - deltaphibinwidth / 2.0; float deltaphiup = constants::math::TwoPI - deltaphibinwidth / 2.0; -bool processpairs = false; -bool processmixedevents = false; -bool ptorder = false; +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 @@ -72,6 +74,7 @@ bool fUseTwoTrackCut = false; // suppress too close tracks std::vector poinames; ///< the species of interest names std::vector tnames; ///< the track names +std::vector poimass; ///< the species of interest mass std::vector> trackPairsNames; ///< the track pairs names } // namespace correlationstask @@ -102,6 +105,8 @@ struct DptDptCorrelationsTask { std::vector> 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}}; //!> fhInvMassDEta{nch, {nch, nullptr}}; //!> fhInvMassDPhi{nch, {nch, nullptr}}; //! fhN1_vsC{nch, nullptr}; //! fhSum1Pt_vsC{nch, nullptr}; //! + float GetDEtaValue(TrackObject const& t1, TrackObject const& t2) + { + using namespace correlationstask; + using namespace o2::analysis::dptdptfilter; + + /* rule: ix are always zero based while bins are always one based */ + int etaix_1 = static_cast((t1.eta() - etalow) / etabinwidth); + int etaix_2 = static_cast((t2.eta() - etalow) / etabinwidth); + + int deltaeta_ix = etaix_1 - etaix_2 + etabins - 1; + + return deltaetalow + (deltaeta_ix + 0.5) * deltaetabinwidth; + } + + /// \brief Returns the delta phi value for the differential phi + /// \param t1 the intended track one + /// \param t2 the intended track two + /// \return the delta phi value within [-pi,pi] for delta phi + /// + /// WARNING: for performance reasons no checks are done about the consistency + /// of tracks' eta and phi within the corresponding ranges so, it is suppossed + /// the tracks have been accepted and they are within that ranges + /// IF THAT IS NOT THE CASE THE ROUTINE WILL PRODUCE NONSENSE RESULTS + template + float GetDPhiValue(TrackObject const& t1, TrackObject const& t2) + { + using namespace correlationstask; + using namespace o2::analysis::dptdptfilter; + + /* rule: ix are always zero based while bins are always one based */ + /* consider a potential phi origin shift */ + float phi = GetShiftedPhi(t1.phi()); + int phiix_1 = static_cast((phi - philow) / phibinwidth); + /* consider a potential phi origin shift */ + phi = GetShiftedPhi(t2.phi()); + int phiix_2 = static_cast((phi - philow) / phibinwidth); + + int deltaphi_ix = phiix_1 - phiix_2; + if (deltaphi_ix < 0) { + deltaphi_ix += phibins; + } + + float value = deltaphilow + (deltaphi_ix + 0.5) * deltaphibinwidth; + + return (value < (deltaphiup - constants::math::PI)) ? value : value - constants::math::TwoPI; + } + + /// \brief Returns the TH2 global bin for the differential histograms /// \param t1 the intended track one /// \param t2 the intended track two /// \return the globl TH2 bin for delta eta delta phi @@ -170,7 +232,7 @@ struct DptDptCorrelationsTask { /// 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 GetDEtaDPhiGlobalBin(TrackObject const& t1, TrackObject const& t2) { using namespace correlationstask; using namespace o2::analysis::dptdptfilter; @@ -194,6 +256,39 @@ struct DptDptCorrelationsTask { return fhN2_vsDEtaDPhi[0][0]->GetBin(deltaeta_ix + 1, deltaphi_ix + 1); } + /* taken from PWGCF/Core/PairCuts.h implemented by JFGO */ + template + double getInvMassSquared(TrackObject const& track1, double m0_1, TrackObject 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 (track1.eta() < -1e-10 || track1.eta() > 1e-10) { + float expTmp = std::exp(-track1.eta()); + tantheta1 = 2.0 * expTmp / (1.0 - expTmp * expTmp); + } + + float tantheta2 = 1e10; + if (track2.eta() < -1e-10 || track2.eta() > 1e-10) { + float expTmp = std::exp(-track2.eta()); + 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(track1.phi() - track2.phi()) + 1.0 / tantheta1 / tantheta2))); + + return mass2; + } + void storeTrackCorrections(std::vector corrs) { LOGF(info, "Stored NUA&NUE corrections for %d track ids", corrs.size()); @@ -315,7 +410,7 @@ struct DptDptCorrelationsTask { /// \param trks2 filtered table with the tracks associated to the second track in the pair /// \param cmul centrality - multiplicity for the collision being analyzed /// Be aware that in most of the cases traks1 and trks2 will have the same content (exception: mixed events) - template + template void processTrackPairs(TrackOneListObject const& trks1, TrackTwoListObject const& trks2, std::vector* corrs1, std::vector* corrs2, std::vector* ptavgs1, std::vector* ptavgs2, float cmul, int bfield) { using namespace correlationstask; @@ -329,6 +424,8 @@ struct DptDptCorrelationsTask { std::vector> sum2PtPtnw(nch, std::vector(nch, 0.0)); ///< accumulated sum of not weighted track 1 track 2 \f${p_T}_1 {p_T}_2\f$ for current collision 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; + int globalbin = 0; + LOGF(debug, "Initializing globalbin to ", globalbin); for (auto& track1 : trks1) { double ptavg_1 = (*ptavgs1)[index1]; @@ -356,7 +453,9 @@ struct DptDptCorrelationsTask { double dptdptw = (corr1 * track1.pt() - ptavg_1) * (corr2 * track2.pt() - ptavg_2); /* get the global bin for filling the differential histograms */ - int globalbin = GetDEtaDPhiGlobalIndex(track1, track2); + if constexpr (docorrelations) { + globalbin = GetDEtaDPhiGlobalBin(track1, track2); + } float deltaeta = track1.eta() - track2.eta(); float deltaphi = track1.phi() - track2.phi(); while (deltaphi >= deltaphiup) { @@ -367,8 +466,10 @@ struct DptDptCorrelationsTask { } 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); + if constexpr (docorrelations) { + fhSupN1N1_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, corr); + fhSupPt1Pt1_vsDEtaDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->AddBinContent(globalbin, track1.pt() * track2.pt() * corr); + } n2sup[track1.trackacceptedid()][track2.trackacceptedid()] += corr; } else { /* count the pair */ @@ -379,12 +480,22 @@ struct DptDptCorrelationsTask { 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); + if constexpr (docorrelations) { + 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); + fhN2_vsPtPt[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.pt(), track2.pt(), corr); + } + if constexpr (doinvmass) { + if (!(track2.trackacceptedid() < track1.trackacceptedid())) { + /* only 12 combinations, 21 are exactly the same */ + double invariantMass = std::sqrt(getInvMassSquared(track1, poimass[static_cast(track1.trackacceptedid() / 2)], track2, poimass[static_cast(track2.trackacceptedid() / 2)])) * 1000.0f; + fhInvMassDEta[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(GetDEtaValue(track1, track2), invariantMass); + fhInvMassDPhi[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(GetDPhiValue(track1, track2), invariantMass); + } + } } - fhN2_vsPtPt[track1.trackacceptedid()][track2.trackacceptedid()]->Fill(track1.pt(), track2.pt(), corr); index2++; } index1++; @@ -398,11 +509,13 @@ struct DptDptCorrelationsTask { fhSum2PtPtnw_vsC[pid1][pid2]->Fill(cmul, sum2PtPtnw[pid1][pid2]); fhSum2DptDptnw_vsC[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]); + if constexpr (docorrelations) { + 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]); + } } } } @@ -442,15 +555,40 @@ struct DptDptCorrelationsTask { /* process pair magnitudes */ if constexpr (mixed) { if (ptorder) { - processTrackPairs(Tracks1, Tracks2, corrs1, corrs2, ptavgs1, ptavgs2, centmult, bfield); + /* no invariant mass analysis on a mixed event data collection */ + processTrackPairs(Tracks1, Tracks2, corrs1, corrs2, ptavgs1, ptavgs2, centmult, bfield); } else { - processTrackPairs(Tracks1, Tracks2, corrs1, corrs2, ptavgs1, ptavgs2, centmult, bfield); + processTrackPairs(Tracks1, Tracks2, corrs1, corrs2, ptavgs1, ptavgs2, centmult, bfield); } } else { if (ptorder) { - processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + if (invmass) { + if (corrana) { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } else { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } + } else { + if (corrana) { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } else { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } + } } else { - processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + if (invmass) { + if (corrana) { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } else { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } + } else { + if (corrana) { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } else { + processTrackPairs(Tracks1, Tracks1, corrs1, corrs1, ptavgs1, ptavgs1, centmult, bfield); + } + } } } @@ -465,11 +603,14 @@ struct DptDptCorrelationsTask { } } + template void init(TList* fOutputList) { using namespace correlationstask; using namespace o2::analysis::dptdptfilter; + LOGF(info, "Do invariant mass: %s; do correlation histograms: %s", doinvmass ? "yes" : "no", docorrelations ? "yes" : "no"); + /* create the histograms */ Bool_t oldstatus = TH1::AddDirectoryStatus(); TH1::AddDirectory(kFALSE); @@ -596,24 +737,34 @@ struct DptDptCorrelationsTask { bool defSumw2 = TH1::GetDefaultSumw2(); TH1::SetDefaultSumw2(false); const char* pname = trackPairsNames[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), + if constexpr (docorrelations) { + 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); - 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), + 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); - 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), - 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), + 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), 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), + deltaetabins, deltaetalow, deltaetaup, deltaphibins, deltaphilow, deltaphiup); + 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); + } + if constexpr (doinvmass) { + if (!(j < i)) { + /* only 12 combinations, 21 are exactly the same */ + fhInvMassDEta[i][j] = new TH2D(TString::Format("n2_invMassDeta_%s", pname), TString::Format("%s invariant mass;#Delta#eta;Mass (MeV/#it{c}^{2})", pname), + deltaetabins, deltaetalow, deltaetaup, 5000, 0, 5000); + fhInvMassDPhi[i][j] = new TH2D(TString::Format("n2_invMassDphi_%s", pname), TString::Format("%s invariant mass;#Delta#varphi;Mass (MeV/#it{c}^{2})", pname), + deltaphibins, deltaphilow - constants::math::PI, deltaphiup - constants::math::PI, 5000, 0, 5000); + } + } /* 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); - 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); @@ -622,26 +773,46 @@ struct DptDptCorrelationsTask { 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); /* 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]); + if constexpr (docorrelations) { + 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); + } + if constexpr (doinvmass) { + if (!(j < i)) { + /* only 12 combinations, 21 are exactly the same */ + fhInvMassDEta[i][j]->SetBit(TH1::kIsNotW); + fhInvMassDEta[i][j]->Sumw2(false); + fhInvMassDPhi[i][j]->SetBit(TH1::kIsNotW); + fhInvMassDPhi[i][j]->Sumw2(false); + } + } + + if constexpr (docorrelations) { + 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]); + } + if constexpr (doinvmass) { + if (!(j < i)) { + /* only 12 combinations, 21 are exactly the same */ + fOutputList->Add(fhInvMassDEta[i][j]); + fOutputList->Add(fhInvMassDPhi[i][j]); + } + } fOutputList->Add(fhN2_vsC[i][j]); fOutputList->Add(fhSum2PtPt_vsC[i][j]); fOutputList->Add(fhSum2DptDpt_vsC[i][j]); @@ -684,6 +855,8 @@ struct DptDptCorrelationsTask { 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"}; @@ -727,6 +900,8 @@ struct DptDptCorrelationsTask { processpairs = cfgProcessPairs.value; processmixedevents = cfgProcessME.value; ptorder = cfgPtOrder.value; + invmass = cfgDoInvMass.value; + corrana = cfgDoCorrelations.value; /* self configure the CCDB access to the input file */ getTaskOptionValue(initContext, "dpt-dpt-filter", "input_ccdburl", cfgCCDBUrl, false); @@ -803,7 +978,8 @@ struct DptDptCorrelationsTask { poinames.push_back(std::string(pidselector.getSpeciesFName(ix))); tnames.push_back(std::string(TString::Format("%sP", pidselector.getSpeciesFName(ix)).Data())); tnames.push_back(std::string(TString::Format("%sM", pidselector.getSpeciesFName(ix)).Data())); - LOGF(info, "Incorporated species name %s to the analysis", poinames[ix].c_str()); + poimass.push_back(pidselector.getSpeciesMass(ix)); + LOGF(info, "Incorporated species name %s with mass %f to the analysis", poinames[ix].c_str(), poimass[ix]); } } uint ntracknames = tnames.size(); @@ -839,7 +1015,6 @@ struct DptDptCorrelationsTask { fCentMultMin[0] = 0.0f; fCentMultMax[0] = 100.0f; } - dataCE = new DataCollectingEngine*[ncmranges]; if (cfgSmallDCE) { dataCE_small = new DataCollectingEngine*[ncmranges]; } else { @@ -850,23 +1025,36 @@ struct DptDptCorrelationsTask { } for (int i = 0; i < ncmranges; ++i) { - auto initializeCEInstance = [&fGlobalOutputList](auto dce, auto name) { + auto initializeCEInstance = [&fGlobalOutputList](auto dce, auto name, bool im, bool corr) { /* crete the output list for the passed centrality/multiplicity range */ TList* fOutputList = new TList(); fOutputList->SetName(name); fOutputList->SetOwner(true); /* init the data collection instance */ - dce->init(fOutputList); + if (im) { + if (corr) { + dce->template init(fOutputList); + } else { + dce->template init(fOutputList); + } + } else { + if (corr) { + dce->template init(fOutputList); + } else { + dce->template init(fOutputList); + } + } fGlobalOutputList->Add(fOutputList); }; auto builSmallDCEInstance = [&initializeCEInstance](auto rg, bool me = false) { + /* only for singles analysis, no sense of inv mass nor no correlations */ DataCollectingEngine* dce = new DataCollectingEngine(); - initializeCEInstance(dce, TString::Format("DptDptCorrelationsData%s-%s", me ? "ME" : "", rg)); + initializeCEInstance(dce, TString::Format("DptDptCorrelationsData%s-%s", me ? "ME" : "", rg), false, false); return dce; }; - auto buildCEInstance = [&initializeCEInstance](auto rg, bool me = false) { + auto buildCEInstance = [&initializeCEInstance](auto rg, bool im, bool corr, bool me = false) { DataCollectingEngine* dce = new DataCollectingEngine(); - initializeCEInstance(dce, TString::Format("DptDptCorrelationsData%s-%s", me ? "ME" : "", rg)); + initializeCEInstance(dce, TString::Format("DptDptCorrelationsData%s-%s", me ? "ME" : "", rg), im, corr); return dce; }; TString range = TString::Format("%d-%d", static_cast(fCentMultMin[i]), static_cast(fCentMultMax[i])); @@ -874,16 +1062,30 @@ struct DptDptCorrelationsTask { if (processpairs) { LOGF(fatal, "Processing pairs cannot be used with the small DCE, please configure properly!!"); } + if (invmass) { + LOGF(fatal, "Invariant mass cannot be used with singles in the small DCE mode, please configure properly!!"); + } dataCE_small[i] = builSmallDCEInstance(range.Data()); } else { - dataCE[i] = buildCEInstance(range.Data()); + if (invmass) { + if (!processpairs) { + LOGF(fatal, "Invariant mass cannot be used in processing singles, please configure properly!!"); + } + } + dataCE[i] = buildCEInstance(range.Data(), invmass, corrana); } if (processmixedevents) { /* consistency check */ if (cfgSmallDCE.value) { LOGF(fatal, "Mixed events cannot be used with the small DCE, please configure properly!!"); } - dataCEME[i] = buildCEInstance(range.Data(), true); + if (invmass) { + LOGF(warning, "Invariant mass will not be used with Mixed events!!"); + } + if (!corrana) { + LOGF(fatal, "Mixed events makes not sense to run it without correlations, please configure properly!!"); + } + dataCEME[i] = buildCEInstance(range.Data(), false, false, true); } } for (int i = 0; i < ncmranges; ++i) { diff --git a/PWGCF/Tasks/match-reco-gen.cxx b/PWGCF/Tasks/match-reco-gen.cxx index 3cba78997b2..adf0b363e6b 100644 --- a/PWGCF/Tasks/match-reco-gen.cxx +++ b/PWGCF/Tasks/match-reco-gen.cxx @@ -409,7 +409,7 @@ struct CheckGeneratorLevelVsDetectorLevel { float centormult = -100.0f; if (IsEvtSelected(coll, centormult)) { /* TODO: AcceptTrack does not consider PID */ - if (AcceptTrack(track)) { + if (AcceptTrack(track)) { /* the track has been accepted */ nreco++; LOGF(MATCHRECGENLOGTRACKS, "Accepted track with global Id %d and collision Id %d has label %d associated to MC collision %d", recix, track.collisionId(), label, track.template mcParticle_as().mcCollisionId()); diff --git a/PWGCF/Tasks/pidcme.cxx b/PWGCF/Tasks/pidcme.cxx new file mode 100644 index 00000000000..a776e584f7d --- /dev/null +++ b/PWGCF/Tasks/pidcme.cxx @@ -0,0 +1,498 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// C++/ROOT includes. +#include +#include +#include +#include +#include +#include +#include +#include + +// o2Physics includes. +#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 "CommonConstants/PhysicsConstants.h" + +// o2 includes. + +using namespace o2; +using namespace o2::framework; + +using MyCollisions = soa::Join; +using MyTracks = soa::Join; + +struct pidcme { + HistogramRegistry histosQA{"histosQA", {}, 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"}; + + 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"}; + + 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 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 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 onlyTOF{"onlyTOF", false, "only TOF tracks"}; + Configurable onlyTOFHIT{"onlyTOFHIT", false, "accept only TOF hit tracks at high pt"}; + Configurable OpenCME = {"cfgkOpeanCME", false, "open PID CME"}; + bool onlyTPC = true; + + EventPlaneHelper helperEP; + + 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; + } + } + + 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 axisRigidity{cfgrigidityBins, "#it{p}^{TPC}/#it{z}"}; + AxisSpec axisdEdx{cfgdedxBins, "d#it{E}/d#it{x}"}; + AxisSpec axisnSigma{cfgnSigmaBins, "n_{#sigma}({}^{3}He)"}; + + 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("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, {axisnSigma}}); + histosQA.add(Form("QA/PID/histdEdxTPC_Ka"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histnSigma_Ka"), "", {HistType::kTH1F, {axisnSigma}}); + histosQA.add(Form("QA/PID/histdEdxTPC_Pr"), "", {HistType::kTH2F, {axisRigidity, axisdEdx}}); + histosQA.add(Form("QA/PID/histnSigma_Pr"), "", {HistType::kTH1F, {axisnSigma}}); + + 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 (OpenCME) { + histosQA.add(Form("PIDCME/histgamama_PiKa_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histgamama_PiKa_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histgamama_PiPr_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histgamama_PiPr_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histgamama_KaPr_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histgamama_KaPr_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + + histosQA.add(Form("PIDCME/histdelta_PiKa_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histdelta_PiKa_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histdelta_PiPr_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_ss"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + histosQA.add(Form("PIDCME/histdelta_KaPr_os"), "", {HistType::kTProfile3D, {axisCentMerged, axissumpt, axisdeltaeta}}); + } + } + + template + bool SelEvent(const CollType& collision) + { + if (!collision.sel8()) { + return 0; + } + 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; + } + if (std::abs(collision.posZ()) > 10.) { + return 0; + } + + return 1; + } + + template + bool SelTrack(const TrackType 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 + bool selectionPID(const T& candidate, int PID) + { + if (candidate.pt() > 0.4) { + onlyTPC = false; + } + + if (PID == 0) { + if (onlyTOF) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOFPi) { + return true; + } + } else if (onlyTOFHIT) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOFPi) { + return true; + } + if (!candidate.hasTOF() && + std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { + return true; + } + } else if (onlyTPC) { + if (std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { + return true; + } + } else { + if (candidate.hasTOF() && (candidate.tofNSigmaPi() * candidate.tofNSigmaPi() + candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPCPi) { + return true; + } + } + } else if (PID == 1) { + if (onlyTOF) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOFKa) { + return true; + } + } else if (onlyTOFHIT) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOFKa) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { + return true; + } + } else if (onlyTPC) { + if (std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { + return true; + } + } else { + if (candidate.hasTOF() && (candidate.tofNSigmaKa() * candidate.tofNSigmaKa() + candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPCPi) { + return true; + } + } + } else if (PID == 2) { + if (onlyTOF) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOFPr) { + return true; + } + } else if (onlyTOFHIT) { + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOFPr) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { + return true; + } + } else if (onlyTPC) { + if (std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { + return true; + } + } else { + if (candidate.hasTOF() && (candidate.tofNSigmaPr() * candidate.tofNSigmaPr() + candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr()) < (cfgnSigmaCutCombine * cfgnSigmaCutCombine)) { + return true; + } + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPCPr) { + return true; + } + } + } + return false; + } + + 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 fillHistosFlow_gamma_delta(const CollType& collision, const TrackType& track, int nmode) + { + if (collision.qvecAmp()[DetId] < 1e-8) { + return; + } + int DetInd = DetId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + bool kisPi = false, kisKa = false, kisPr = false; + bool kisPi_2 = false, kisKa_2 = false, kisPr_2 = false; + float Psi_n = helperEP.GetEventPlane(collision.qvecRe()[DetInd + 3], collision.qvecIm()[DetInd + 3], nmode); + for (auto& trk : track) { + histosQA.fill(HIST("QA/PID/histdEdxTPC_All"), trk.sign() * trk.tpcInnerParam(), trk.tpcSignal()); + if (!SelTrack(trk)) { + continue; + } + kisPi = selectionPID(trk, 0); + kisKa = selectionPID(trk, 1); + kisPr = selectionPID(trk, 2); + if (kisPi) { + histosQA.fill(HIST("QA/PID/histdEdxTPC_Pi"), trk.sign() * trk.tpcInnerParam(), trk.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_Pi"), trk.tpcNSigmaPi()); + } + if (kisKa) { + histosQA.fill(HIST("QA/PID/histdEdxTPC_Ka"), trk.sign() * trk.tpcInnerParam(), trk.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_Ka"), trk.tpcNSigmaKa()); + } + if (kisPr) { + histosQA.fill(HIST("QA/PID/histdEdxTPC_Pr"), trk.sign() * trk.tpcInnerParam(), trk.tpcSignal()); + histosQA.fill(HIST("QA/PID/histnSigma_Pr"), trk.tpcNSigmaPr()); + } + if (nmode == 2) { + histosQA.fill(HIST("V2/histSinDetV2"), collision.centFT0C(), trk.pt(), + std::sin(static_cast(nmode) * (trk.phi() - Psi_n))); + histosQA.fill(HIST("V2/histCosDetV2"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + if (kisPi) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pi"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pi_Neg"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } + } + if (kisKa) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Ka"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Ka_Neg"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } + } + if (kisPr) { + if (trk.sign() > 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pr"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } else if (trk.sign() < 0) { + histosQA.fill(HIST("V2/PID/histCosDetV2_Pr_Neg"), collision.centFT0C(), trk.pt(), + std::cos(static_cast(nmode) * (trk.phi() - Psi_n))); + } + } + } + if (OpenCME) { + for (auto& trk_2 : track) { + if (trk_2.globalIndex() == trk.globalIndex()) + continue; + if (nmode == 2) { + kisPi_2 = selectionPID(trk_2, 0); + kisKa_2 = selectionPID(trk_2, 1); + kisPr_2 = selectionPID(trk_2, 2); + if (kisPi && kisKa_2) { + if (trk.sign() == trk_2.sign()) { + histosQA.fill(HIST("PIDCME/histgamama_PiKa_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamama_PiKa_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_PiKa_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } + } + if (kisPi && kisPr_2) { + if (trk.sign() == trk_2.sign()) { + histosQA.fill(HIST("PIDCME/histgamama_PiPr_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamama_PiPr_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_PiPr_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } + } + if (kisKa && kisPr_2) { + if (trk.sign() == trk_2.sign()) { + histosQA.fill(HIST("PIDCME/histgamama_KaPr_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_ss"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } else { + histosQA.fill(HIST("PIDCME/histgamama_KaPr_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() + trk_2.phi() - static_cast(nmode) * Psi_n))); + histosQA.fill(HIST("PIDCME/histdelta_KaPr_os"), collision.centFT0C(), trk.pt() + trk_2.pt(), std::abs(trk.eta() - trk_2.eta()), + std::cos((trk.phi() - trk_2.phi()))); + } + } + } + } + } + } + } + + void process(MyCollisions::iterator const& collision, MyTracks 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()); + for (auto i = 0; i < static_cast(cfgnMods->size()); i++) { + fillHistosQvec(collision, cfgnMods->at(i)); + fillHistosFlow_gamma_delta(collision, tracks, cfgnMods->at(i)); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx index 7bcdf88ff4c..fee15c95f97 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.cxx @@ -12,6 +12,8 @@ #include #include +#include +#include #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -65,6 +67,9 @@ using IdBfFullTracksFullPIDDetLevelAmbiguous = soa::Join& 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"}; + } cfgcentersinputfile; + Service ccdb; + + TList* getCCDBInput(const char* ccdbpath, const char* ccdbdate) + { + + std::tm cfgtm = {}; + std::stringstream ss(ccdbdate); + ss >> std::get_time(&cfgtm, "%Y%m%d"); + cfgtm.tm_hour = 12; + int64_t timestamp = std::mktime(&cfgtm) * 1000; + + TList* lst = ccdb->getForTimeStamp(ccdbpath, timestamp); + if (lst != nullptr) { + LOGF(info, "Correctly loaded CCDB input object"); + } else { + LOGF(error, "CCDB input object could not be loaded"); + } + return lst; + } + Produces scannedtracks; Produces tracksinfo; Produces scannedgentracks; @@ -606,6 +644,8 @@ struct IdentifiedBfFilterTracks { 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 tofCut{"TOFCutoff", 0.8, "Momentum under which we don't use TOF PID data"}; + OutputObj fOutput{"IdentifiedBfFilterTracksInfo", OutputObjHandlingPolicy::AnalysisObject}; bool checkAmbiguousTracks = false; @@ -613,6 +653,26 @@ struct IdentifiedBfFilterTracks { { LOGF(info, "IdentifiedBfFilterTracks::init()"); + // ccdb info + ccdb->setURL(cfgcentersinputfile.cfgCCDBUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + LOGF(info, "Initizalized CCDB"); + + loadfromccdb = cfgcentersinputfile.cfgCCDBPathName->length() > 0; + + if (ccdblst == nullptr) { + if (loadfromccdb) { + LOGF(info, "Loading CCDB Objects"); + + ccdblst = getCCDBInput(cfgcentersinputfile.cfgCCDBPathName->c_str(), cfgcentersinputfile.cfgCCDBDate->c_str()); + for (int i = 0; i < kIdBfNoOfSpecies; i++) { + fhNSigmaCorrection[i] = reinterpret_cast(ccdblst->FindObject(Form("centerBin_%s", speciesName[i]))); + } + } + } + LOGF(info, "Loaded CCDB Objects"); + fullDerivedData = cfgFullDerivedData; /* update with the configurable values */ @@ -739,6 +799,14 @@ struct IdentifiedBfFilterTracks { 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); @@ -787,6 +855,8 @@ struct IdentifiedBfFilterTracks { 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]); } @@ -861,14 +931,15 @@ struct IdentifiedBfFilterTracks { fOutputList->Add(fhTrueDeltaNA[sp]); } } + /* initialize access to the CCDB */ } template inline MatchRecoGenSpecies IdentifyTrack(TrackObject const& track); template - MatchRecoGenSpecies trackIdentification(TrackObject const& track); - template int8_t AcceptTrack(TrackObject const& track); + template + int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const& mccollision); template int8_t selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track); template @@ -949,7 +1020,6 @@ struct IdentifiedBfFilterTracks { void filterParticles(soa::Join const& gencollisions, aod::McParticles const& particles) { using namespace identifiedbffilter; - int acceptedparticles = 0; int acceptedcollisions = 0; if (!fullDerivedData) { @@ -978,38 +1048,9 @@ struct IdentifiedBfFilterTracks { fillParticleHistosBeforeSelection(particle, mccollision, charge); /* track selection */ - /* TODO: at some point the pid has to be substituted by the identified species */ pid = AcceptParticle(particle, mccollision); - if (!(pid < 0)) { - /* the particle has been accepted */ - /* let's identify the particle */ - /* TODO: probably this needs to go to AcceptParticle */ - MatchRecoGenSpecies sp = IdentifyParticle(particle); - if (sp != kWrongSpecies) { - if (sp != kIdBfCharged) { - /* fill the charged particle histograms */ - fillParticleHistosAfterSelection(particle, mccollision, charge, kIdBfCharged); - /* update charged multiplicities */ - if (pid % 2 == 0) { - partMultPos[kIdBfCharged]++; - } - if (pid % 2 == 1) { - partMultNeg[kIdBfCharged]++; - } - } - /* fill the species histograms */ - fillParticleHistosAfterSelection(particle, mccollision, charge, sp); - /* update species multiplicities */ - if (pid % 2 == 0) { - partMultPos[sp]++; - } - if (pid % 2 == 1) { - partMultNeg[sp]++; - } - acceptedparticles++; - } else { - pid = -1; - } + if (!(pid < 0)) { // if PID isn't negative + acceptedparticles++; } } } else { @@ -1090,7 +1131,7 @@ struct IdentifiedBfFilterTracks { } PROCESS_SWITCH(IdentifiedBfFilterTracks, filterRecoWithoutPIDAmbiguous, "Track filtering without PID information with ambiguous tracks check", false) - void filterDetectorLevelWithoutPID(soa::Join const& collisions, IdBfFullTracksDetLevel const& tracks) + void filterDetectorLevelWithoutPID(soa::Join const& collisions, IdBfFullTracksDetLevel const& tracks, aod::McParticles const&) { filterTracks(collisions, tracks); } @@ -1113,7 +1154,6 @@ template inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleObject const& particle) { using namespace identifiedbffilter; - constexpr int pdgcodeEl = 11; constexpr int pdgcodePi = 211; constexpr int pdgcodeKa = 321; @@ -1146,41 +1186,78 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyParticle(ParticleOb } template -inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject const& track) +void fillNSigmaHistos(TrackObject const& track) { - using namespace o2::analysis::identifiedbffilter; - if (!onlyTOF) { - fhNSigmaTPC[kIdBfElectron]->Fill(track.tpcNSigmaEl(), track.tpcInnerParam()); - fhNSigmaTPC[kIdBfPion]->Fill(track.tpcNSigmaPi(), track.tpcInnerParam()); - fhNSigmaTPC[kIdBfKaon]->Fill(track.tpcNSigmaKa(), track.tpcInnerParam()); - fhNSigmaTPC[kIdBfProton]->Fill(track.tpcNSigmaPr(), track.tpcInnerParam()); + float actualTPCNSigmaEl = track.tpcNSigmaEl(); + float actualTPCNSigmaPi = track.tpcNSigmaPi(); + float actualTPCNSigmaKa = track.tpcNSigmaKa(); + float actualTPCNSigmaPr = track.tpcNSigmaPr(); + + 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())); } + + fhNSigmaTPC[kIdBfElectron]->Fill(actualTPCNSigmaEl, track.tpcInnerParam()); + fhNSigmaTPC[kIdBfPion]->Fill(actualTPCNSigmaPi, track.tpcInnerParam()); + fhNSigmaTPC[kIdBfKaon]->Fill(actualTPCNSigmaKa, track.tpcInnerParam()); + fhNSigmaTPC[kIdBfProton]->Fill(actualTPCNSigmaPr, 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()); + 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()); +} + +template +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(); + float nsigmas[kIdBfNoOfSpecies]; - if (track.p() < 0.8 && !reqTOF && !onlyTOF) { - nsigmas[kIdBfElectron] = track.tpcNSigmaEl(); - nsigmas[kIdBfPion] = track.tpcNSigmaPi(); - nsigmas[kIdBfKaon] = track.tpcNSigmaKa(); - nsigmas[kIdBfProton] = track.tpcNSigmaPr(); + + 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 (track.tpcInnerParam() < tofCut && !reqTOF && !onlyTOF) { + + nsigmas[kIdBfElectron] = actualTPCNSigmaEl; + nsigmas[kIdBfPion] = actualTPCNSigmaPi; + nsigmas[kIdBfKaon] = actualTPCNSigmaKa; + nsigmas[kIdBfProton] = actualTPCNSigmaPr; } else { /* introduce require TOF flag */ if (track.hasTOF() && !onlyTOF) { - nsigmas[kIdBfElectron] = sqrtf(track.tpcNSigmaEl() * track.tpcNSigmaEl() + track.tofNSigmaEl() * track.tofNSigmaEl()); - nsigmas[kIdBfPion] = sqrtf(track.tpcNSigmaPi() * track.tpcNSigmaPi() + track.tofNSigmaPi() * track.tofNSigmaPi()); - nsigmas[kIdBfKaon] = sqrtf(track.tpcNSigmaKa() * track.tpcNSigmaKa() + track.tofNSigmaKa() * track.tofNSigmaKa()); - nsigmas[kIdBfProton] = sqrtf(track.tpcNSigmaPr() * track.tpcNSigmaPr() + track.tofNSigmaPr() * track.tofNSigmaPr()); + 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] = track.tpcNSigmaEl(); - nsigmas[kIdBfPion] = track.tpcNSigmaPi(); - nsigmas[kIdBfKaon] = track.tpcNSigmaKa(); - nsigmas[kIdBfProton] = track.tpcNSigmaPr(); + nsigmas[kIdBfElectron] = actualTPCNSigmaEl; + nsigmas[kIdBfPion] = actualTPCNSigmaPi; + nsigmas[kIdBfKaon] = actualTPCNSigmaKa; + nsigmas[kIdBfProton] = actualTPCNSigmaPr; } else if (track.hasTOF() && onlyTOF) { nsigmas[kIdBfElectron] = track.tofNSigmaEl(); @@ -1218,7 +1295,7 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject c if (min_nsigma < maxPIDSigma && min_nsigma > minPIDSigma) { // Check that current nsigma is in accpetance 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 && min_nsigma > minRejectSigma) { // If secondary species is in rejection range + if (nsigmas[sp] < maxRejectSigma && nsigmas[sp] > minRejectSigma) { // If secondary species is in rejection range doublematch = true; // Set double match true spDouble = MatchRecoGenSpecies(sp); } @@ -1231,20 +1308,19 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject c fhDoublePID->Fill(sp_min_nsigma, spDouble); return kWrongSpecies; // Return wrong species value } else { - if (track.hasTOF() && onlyTOF) { - if (sp_min_nsigma == 0) { - fhNSigmaTPC[sp_min_nsigma]->Fill(track.tpcNSigmaEl(), track.tpcInnerParam()); - } - if (sp_min_nsigma == 1) { - fhNSigmaTPC[sp_min_nsigma]->Fill(track.tpcNSigmaPi(), track.tpcInnerParam()); - } - if (sp_min_nsigma == 2) { - fhNSigmaTPC[sp_min_nsigma]->Fill(track.tpcNSigmaKa(), track.tpcInnerParam()); - } - if (sp_min_nsigma == 3) { - fhNSigmaTPC[sp_min_nsigma]->Fill(track.tpcNSigmaPr(), track.tpcInnerParam()); - } + 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()); + } + return sp_min_nsigma; } } else { @@ -1252,31 +1328,6 @@ inline MatchRecoGenSpecies IdentifiedBfFilterTracks::IdentifyTrack(TrackObject c } } -template -MatchRecoGenSpecies IdentifiedBfFilterTracks::trackIdentification(TrackObject const& track) -{ - using namespace identifiedbffilter; - - MatchRecoGenSpecies sp = kWrongSpecies; - if (recoIdMethod == 0) { - sp = kIdBfCharged; - } else if (recoIdMethod == 1) { - - if constexpr (framework::has_type_v || framework::has_type_v) { - sp = IdentifyTrack(track); - } else { - LOGF(fatal, "Track identification required but PID information not present"); - } - } else if (recoIdMethod == 2) { - if constexpr (framework::has_type_v) { - sp = IdentifyParticle(track.template mcParticle_as()); - } else { - LOGF(fatal, "Track identification required from MC particle but MC information not present"); - } - } - return sp; -} - /// \brief Accepts or not the passed track /// \param track the track of interest /// \return the internal track id, -1 if not accepted @@ -1299,17 +1350,33 @@ inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track) if (matchTrackType(track)) { if (ptlow < track.pt() && track.pt() < ptup && etalow < track.eta() && track.eta() < etaup) { fillTrackHistosAfterSelection(track, kIdBfCharged); - MatchRecoGenSpecies sp = trackIdentification(track); + MatchRecoGenSpecies sp = kWrongSpecies; + if (recoIdMethod == 0) { + sp = kIdBfCharged; + } else if (recoIdMethod == 1) { + + if constexpr (framework::has_type_v || framework::has_type_v) { + sp = IdentifyTrack(track); + } else { + LOGF(fatal, "Track identification required but PID information not present"); + } + } else if (recoIdMethod == 2) { + if constexpr (framework::has_type_v) { + sp = IdentifyParticle(track.template mcParticle_as()); + } else { + LOGF(fatal, "Track identification required from MC particle but MC information not present"); + } + } if (sp == kWrongSpecies) { return -1; } if (!(sp < 0)) { fillTrackHistosAfterSelection(track, sp); // 0) { + if (track.sign() > 0) { // if positive trkMultPos[sp]++; //<< Update Particle Multiplicity return speciesChargeValue1[sp]; } - if (track.sign() < 0) { + if (track.sign() < 0) { // if negative trkMultNeg[sp]++; //<< Update Particle Multiplicity return speciesChargeValue1[sp] + 1; } @@ -1319,6 +1386,61 @@ inline int8_t IdentifiedBfFilterTracks::AcceptTrack(TrackObject const& track) return -1; } +/// \brief Accepts or not the passed generated particle +/// \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) +{ + /* overall momentum cut */ + if (!(overallminp < particle.p())) { + return kWrongSpecies; + } + + 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 = IdentifyParticle(particle); + 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[sp]++; + } else if (charge == -1) { + partMultNeg[sp]++; + } + } + 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()); + } + } + return kWrongSpecies; +} + template int8_t IdentifiedBfFilterTracks::selectTrackAmbiguousCheck(CollisionObjects const& collisions, TrackObject const& track) { diff --git a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h index 55036a6ae38..6897cac98b4 100644 --- a/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h +++ b/PWGCF/TwoParticleCorrelations/TableProducer/identifiedBfFilter.h @@ -12,6 +12,8 @@ #ifndef PWGCF_TWOPARTICLECORRELATIONS_TABLEPRODUCER_IDENTIFIEDBFFILTER_H_ #define PWGCF_TWOPARTICLECORRELATIONS_TABLEPRODUCER_IDENTIFIEDBFFILTER_H_ +#include + #include #include @@ -32,8 +34,8 @@ namespace aod { using CollisionsEvSelCent = soa::Join; using CollisionEvSelCent = soa::Join::iterator; -using CollisionsEvSelRun2Cent = soa::Join; -using CollisionEvSelRun2Cent = soa::Join::iterator; +using CollisionsEvSelRun2Cent = soa::Join; +using CollisionEvSelRun2Cent = soa::Join::iterator; using CollisionsEvSel = soa::Join; using CollisionEvSel = soa::Join::iterator; using TrackData = soa::Join::iterator; @@ -43,6 +45,8 @@ namespace analysis namespace identifiedbffilter { +const std::vector pdgcodes = {11, 211, 321, 2212}; + /// \enum MatchRecoGenSpecies /// \brief The species considered by the matching test enum MatchRecoGenSpecies { @@ -126,6 +130,8 @@ enum CentMultEstimatorType { knCentMultEstimators ///< number of centrality/mutiplicity estimator }; +float overallminp = 0.0f; + /// \enum TriggerSelectionType /// \brief The type of trigger to apply for event selection enum TriggerSelectionType { @@ -515,7 +521,6 @@ inline float extractMultiplicity(CollisionObject const& collision, CentMultEstim ////////////////////////////////////////////////////////////////////////////////// /// Centrality selection ////////////////////////////////////////////////////////////////////////////////// - /// \brief Centrality/multiplicity percentile template float getCentMultPercentile(CollisionObject collision) @@ -528,10 +533,19 @@ float getCentMultPercentile(CollisionObject collision) return collision.centRun2V0M(); break; case kCL0: - return collision.centRun2CL0(); + if constexpr (framework::has_type_v) { + return collision.centRun2CL0(); + } else { + return 105.0; + } break; + case kCL1: - return collision.centRun2CL1(); + if constexpr (framework::has_type_v) { + return collision.centRun2CL1(); + } else { + return 105.0; + } break; default: return 105.0; @@ -728,54 +742,15 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision) } } -/// \brief Accepts or not the passed generated particle -/// \param track the particle of interest -/// \return the internal particle id, -1 if not accepted -/// TODO: the PID implementation -/// For the time being we keep the convention -/// - positive particle pid even -/// - negative particle pid odd -/// - charged hadron 0/1 -template -inline int8_t AcceptParticle(ParticleObject& particle, MCCollisionObject const& collision) +template +inline float getCharge(ParticleObject& particle) { - float charge = (fPDG->GetParticle(particle.pdgCode())->Charge() / 3 >= 1) ? 1.0 : ((fPDG->GetParticle(particle.pdgCode())->Charge() / 3 <= -1) ? -1.0 : 0.0); - - if (particle.isPhysicalPrimary()) { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex()); - } - if (useOwnParticleSelection) { - float dcaxy = TMath::Sqrt((particle.vx() - collision.posX()) * (particle.vx() - collision.posX()) + - (particle.vy() - collision.posY()) * (particle.vy() - collision.posY())); - float dcaz = TMath::Abs(particle.vz() - collision.posZ()); - if (!((dcaxy < particleMaxDCAxy) && (dcaz < particleMaxDCAZ))) { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Rejecting particle with dcaxy: %.2f and dcaz: %.2f", dcaxy, dcaz); - LOGF(info, " assigned collision Id: %d, looping on collision Id: %d", particle.mcCollisionId(), collision.globalIndex()); - LOGF(info, " Collision x: %.5f, y: %.5f, z: %.5f", collision.posX(), collision.posY(), collision.posZ()); - LOGF(info, " Particle x: %.5f, y: %.5f, z: %.5f", particle.vx(), particle.vy(), particle.vz()); - LOGF(info, " index: %d, pdg code: %d", particle.globalIndex(), particle.pdgCode()); - - exploreMothers(particle, collision); - } - return -1; - } - } - if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) { - if (charge > 0) { - return 0; - } - if (charge < 0) { - return 1; - } - } - } else { - if ((particle.mcCollisionId() == 0) && traceCollId0) { - LOGF(info, "Particle %d NOT passed isPhysicalPrimary", particle.globalIndex()); - } + 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); } - return -1; + return charge; } } // namespace identifiedbffilter diff --git a/PWGCF/TwoParticleCorrelations/Tasks/efficiencyAndQc.cxx b/PWGCF/TwoParticleCorrelations/Tasks/efficiencyAndQc.cxx index 5b76d50d1a2..216f273fde3 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/efficiencyAndQc.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/efficiencyAndQc.cxx @@ -286,7 +286,7 @@ struct QADataCollectingEngine { } } - template + template void processTrack(float zvtx, TrackObject const& track) { using namespace efficiencyandqatask; @@ -320,7 +320,7 @@ struct QADataCollectingEngine { fhTPC_CrossedRows_vs_PtB->Fill(track.pt(), track.tpcNClsCrossedRows()); fhTPC_CrossedRowsOverFindableCls_vs_PtB->Fill(track.pt(), track.tpcCrossedRowsOverFindableCls()); fhTPC_Chi2NCls_vs_PtB->Fill(track.pt(), track.tpcChi2NCl()); - if (InTheAcceptance(track)) { + if (InTheAcceptance(track)) { /* efficiency histograms */ fillhisto(fhPt_vs_EtaItsAcc, hasits); fillhisto(fhPt_vs_EtaTpcAcc, hastpc); @@ -800,8 +800,8 @@ struct DptDptEfficiencyAndQc { } } - template - void processTracks(FilterdCollision const& collision, PassedTracks const& tracks) + template + void processTracks(FilteredCollisions::iterator const& collision, PassedTracks const& tracks) { using namespace efficiencyandqatask; @@ -814,7 +814,7 @@ struct DptDptEfficiencyAndQc { mom = track.tpcInnerParam(); } } - qaDataCE[ixDCE]->processTrack(collision.posZ(), track); + qaDataCE[ixDCE]->processTrack(collision.posZ(), track); if constexpr (dopid) { pidDataCE[ixDCE]->processTrack(track, mom); } @@ -838,7 +838,7 @@ struct DptDptEfficiencyAndQc { { using namespace efficiencyandqatask; - processTracks(collision, tracks); + processTracks>, true, kReco>(collision, tracks); } PROCESS_SWITCH(DptDptEfficiencyAndQc, processReconstructedNotStored, "Process reconstructed efficiency and QA for not stored derived data", false); @@ -848,7 +848,7 @@ struct DptDptEfficiencyAndQc { { using namespace efficiencyandqatask; - processTracks(collision, tracks); + processTracks>, true, kReco>(collision, tracks); } PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStored, "Process MC detector level efficiency and QA for not stored derived data", false); @@ -857,7 +857,7 @@ struct DptDptEfficiencyAndQc { { using namespace efficiencyandqatask; - processTracks(collision, particles); + processTracks>, false, kGen>(collision, particles); } PROCESS_SWITCH(DptDptEfficiencyAndQc, processGeneratorLevelNotStored, "Process MC generator level efficiency and QA for not stored derived data", true); @@ -866,7 +866,7 @@ struct DptDptEfficiencyAndQc { { using namespace efficiencyandqatask; - processTracks(collision, tracks); + processTracks>, false, kReco>(collision, tracks); } PROCESS_SWITCH(DptDptEfficiencyAndQc, processReconstructedNotStoredNoPID, "Process reconstructed efficiency and QA for not stored derived data", false); @@ -876,7 +876,7 @@ struct DptDptEfficiencyAndQc { { using namespace efficiencyandqatask; - processTracks(collision, tracks); + processTracks>, false, kReco>(collision, tracks); } PROCESS_SWITCH(DptDptEfficiencyAndQc, processDetectorLevelNotStoredNoPID, "Process MC detector level efficiency and QA for not stored derived data", true); }; diff --git a/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx b/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx index e0d331ba140..55222b26eb4 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx @@ -13,8 +13,8 @@ /// \brief R2 correlation of Lambda baryons. /// \author Yash Patley -#include -#include +#include +#include #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Centrality.h" @@ -26,6 +26,8 @@ #include "PWGLF/DataModel/LFStrangenessTables.h" #include "CommonConstants/PhysicsConstants.h" #include "Common/Core/RecoDecay.h" +#include "CCDB/BasicCCDBManager.h" +#include "TPDGCode.h" using namespace o2; using namespace o2::framework; @@ -45,35 +47,71 @@ DECLARE_SOA_TABLE(LambdaCollisions, "AOD", "LAMBDACOLS", o2::soa::Index<>, aod::collision::PosZ); using LambdaCollision = LambdaCollisions::iterator; +namespace lambdamcgencollision +{ +} +DECLARE_SOA_TABLE(LambdaMCGenCollisions, "AOD", "LMCGENCOLS", o2::soa::Index<>, + o2::aod::mccollision::PosX, + o2::aod::mccollision::PosY, + o2::aod::mccollision::PosZ); +using LambdaMCGenCollision = LambdaMCGenCollisions::iterator; + namespace lambdatrack { DECLARE_SOA_INDEX_COLUMN(LambdaCollision, lambdaCollision); +DECLARE_SOA_COLUMN(Px, px, float); +DECLARE_SOA_COLUMN(Py, py, float); +DECLARE_SOA_COLUMN(Pz, pz, float); DECLARE_SOA_COLUMN(Pt, pt, float); -DECLARE_SOA_COLUMN(Rap, rap, float); +DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); +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(MassWindow, masswindow, int8_t); +DECLARE_SOA_COLUMN(Cospa, cospa, float); +DECLARE_SOA_COLUMN(DcaDau, dcadau, float); } // namespace lambdatrack DECLARE_SOA_TABLE(LambdaTracks, "AOD", "LAMBDATRACKS", o2::soa::Index<>, lambdatrack::LambdaCollisionId, + lambdatrack::Px, + lambdatrack::Py, + lambdatrack::Pz, lambdatrack::Pt, - lambdatrack::Rap, + lambdatrack::Eta, lambdatrack::Phi, + lambdatrack::Rap, lambdatrack::Mass, lambdatrack::PosTrackId, lambdatrack::NegTrackId, lambdatrack::V0Type, - lambdatrack::MassWindow); + lambdatrack::Cospa, + lambdatrack::DcaDau); using LambdaTrack = LambdaTracks::iterator; -} // namespace o2::aod -enum PidType { - kPion = 0, - kProton -}; +namespace lambdamcgentrack +{ +DECLARE_SOA_INDEX_COLUMN(LambdaMCGenCollision, lambdaMcGenCollision); +} +DECLARE_SOA_TABLE(LambdaMCGenTracks, "AOD", "LMCGENTRACKS", o2::soa::Index<>, + lambdamcgentrack::LambdaMCGenCollisionId, + o2::aod::mcparticle::Px, + o2::aod::mcparticle::Py, + o2::aod::mcparticle::Pz, + lambdatrack::Pt, + lambdatrack::Eta, + lambdatrack::Phi, + lambdatrack::Rap, + lambdatrack::Mass, + lambdatrack::PosTrackId, + lambdatrack::NegTrackId, + lambdatrack::V0Type, + lambdatrack::Cospa, + lambdatrack::DcaDau); +using LambdaMCGenTrack = LambdaMCGenTracks::iterator; + +} // namespace o2::aod enum ParticleType { kLambda = 0, @@ -86,32 +124,36 @@ enum ParticlePairType { kAntiLambdaAntiLambda }; -enum MassWindowType { - kCentralWindow = 0, - kLeftWindow, - kRightWindow +enum RecGenType { + kRec = 0, + kGen }; struct lambdaCorrTableProducer { Produces lambdaCollisionTable; Produces lambdaTrackTable; + Produces lambdaMCGenCollisionTable; + Produces lambdaMCGenTrackTable; // Collisions - Configurable cfg_z_vtx{"cfg_z_vtx", 10.0, "z vertex cut"}; + Configurable cfg_min_z_vtx{"cfg_min_z_vtx", -10.0, "z vertex cut"}; + Configurable cfg_max_z_vtx{"cfg_max_z_vtx", 10.0, "z vertex cut"}; + Configurable cfg_sel8_sel{"cfg_sel8_sel", true, "Sel8 (T0A + T0C) Selection"}; Configurable cfg_trigger_tvx_sel{"cfg_trigger_tvx_sel", false, "Trigger Time and Vertex Selection"}; Configurable cfg_tf_border{"cfg_tf_border", false, "Timeframe Border Selection"}; Configurable cfg_noitsro_border{"cfg_noitsro_border", false, "No ITSRO Border Cut"}; - Configurable cfg_sel8_sel{"cfg_sel8_sel", true, "Sel8 (T0A + T0C) Selection"}; Configurable cfg_itstpc_vtx{"cfg_itstpc_vtx", false, "ITS+TPC Vertex Selection"}; Configurable cfg_pileup_reject{"cfg_pileup_reject", false, "Pileup rejection"}; Configurable cfg_zvtx_time_diff{"cfg_zvtx_time_diff", false, "z-vtx time diff selection"}; // Tracks + Configurable cfg_pt_min{"cfg_pt_min", 0.2, "p_{T} minimum"}; + Configurable cfg_pt_max{"cfg_pt_max", 4.0, "p_{T} minimum"}; Configurable cfg_eta_cut{"cfg_eta_cut", 0.8, "Pseudorapidity cut"}; Configurable cfg_min_crossed_rows{"cfg_min_crossed_rows", 70, "min crossed rows"}; - Configurable cfg_tpc_nsigma{"cfg_tpc_nsigma", 3.0, "TPC NSigma Selection Cut"}; - Configurable cfg_tof_nsigma{"cfg_tof_nsigma", 3.0, "TOF NSigma Selection Cut"}; + Configurable cfg_tpc_nsigma{"cfg_tpc_nsigma", 2.0, "TPC NSigma Selection Cut"}; + Configurable cfg_track_dcaXY_min{"cfg_track_dcaXY_min", 0.05, "Minimum DcaXY of Daughter Tracks"}; // V0s Configurable cfg_min_dca_V0_daughters{"cfg_min_dca_V0_daughters", 1.0, "min DCA between V0 daughters"}; @@ -122,68 +164,87 @@ struct lambdaCorrTableProducer { Configurable cfg_max_V0_radius{"cfg_max_V0_radius", 50.0, "Maximum V0 radius from PV"}; Configurable cfg_min_ctau{"cfg_min_ctau", 0.0, "Minimum ctau"}; Configurable cfg_max_ctau{"cfg_max_ctau", 50.0, "Maximum ctau"}; - Configurable cfg_min_V0_cosPA{"cfg_min_V0_cosPA", 0.995, "Minimum V0 CosPA to PV"}; - Configurable cfg_lambda_mass_window{"cfg_lambda_mass_window", 0.01, "Mass Window to select Lambda"}; + Configurable cfg_min_V0_cosPA{"cfg_min_V0_cosPA", 0.998, "Minimum V0 CosPA to PV"}; + Configurable cfg_lambda_mass_window{"cfg_lambda_mass_window", 0.007, "Mass Window to select Lambda"}; Configurable cfg_kshort_rej{"cfg_kshort_rej", 0.005, "Reject K0Short Candidates"}; + Configurable cfg_kshort_rej_flag{"cfg_kshort_rej_flag", false, "K0short Mass Rej Flag"}; + Configurable cfg_armpod_flag{"cfg_armpod_flag", true, "Armentros-Podolanski Cut Flag"}; + Configurable cfg_armpod_val{"cfg_armpod_val", 0.5, "Armentros-Podolanski Slope Parameter"}; // V0s kinmatic acceptance - Configurable cfg_v0_pt_min{"cfg_v0_pt_min", 0.5, "Minimum V0 pT"}; - Configurable cfg_v0_pt_max{"cfg_v0_pt_max", 2.5, "Minimum V0 pT"}; + Configurable cfg_v0_pt_min{"cfg_v0_pt_min", 0.3, "Minimum V0 pT"}; + Configurable cfg_v0_pt_max{"cfg_v0_pt_max", 3.0, "Minimum V0 pT"}; Configurable cfg_v0_rap_max{"cfg_v0_rap_max", 0.8, "|rap| cut"}; // bool eta/rapidity Configurable cfg_do_eta_analysis{"cfg_do_eta_analysis", false, "Eta Analysis"}; - // lambda mass windows - Configurable cfg_lambda_mass_min{"cfg_lambda_mass_min", 1.11, "Minimum Central Window"}; - Configurable cfg_lambda_mass_max{"cfg_lambda_mass_max", 1.12, "Maximum Central Window"}; - Configurable cfg_lambda_left_min{"cfg_lambda_left_min", 1.08, "Minimum Left Window"}; - Configurable cfg_lambda_left_max{"cfg_lambda_left_max", 1.10, "Maximum Left Window"}; - Configurable cfg_lambda_right_min{"cfg_lambda_right_min", 1.13, "Minimum Right Window"}; - Configurable cfg_lambda_right_max{"cfg_lambda_right_max", 1.15, "Maximum Right Window"}; - - // global variable declaration - std::map mass_map_min; - std::map mass_map_max; + // V0s MC + Configurable cfg_has_mc_flag{"cfg_has_mc_flag", true, "Has Mc Tag"}; + Configurable cfg_rec_primary_lambda{"cfg_rec_primary_lambda", false, "Primary Lambda"}; + Configurable cfg_rec_secondary_lambda{"cfg_rec_secondary_lambda", false, "Secondary Lambda"}; + Configurable cfg_rec_pid_flag{"cfg_rec_pid_flag", false, "PID Flag"}; + Configurable cfg_gen_primary_lambda{"cfg_gen_primary_lambda", true, "Primary Lambda"}; // Histogram Registry. HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext const&) { - // global variable - mass_map_min = {{kCentralWindow, cfg_lambda_mass_min}, {kLeftWindow, cfg_lambda_left_min}, {kRightWindow, cfg_lambda_right_min}}; - mass_map_max = {{kCentralWindow, cfg_lambda_mass_max}, {kLeftWindow, cfg_lambda_left_max}, {kRightWindow, cfg_lambda_right_max}}; - + const AxisSpec axisCol(10, 0, 10, ""); const AxisSpec axisCent(105, 0, 105, "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(100, 1.06, 1.16, "Inv Mass (GeV/#it{c}^{2})"); - const AxisSpec axisV0Pt(200, 0., 5., "p_{T} (GeV/#it{c})"); - const AxisSpec axisV0Rap(16, -1., 1., "rap"); + const AxisSpec axisV0Mass(200, 1.09, 1.14, "M_{p#pi} (GeV/#it{c}^{2})"); + const AxisSpec axisV0Pt(32, 0.3, 3.5, "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 axisV0Phi(36, 0., 2. * TMath::Pi(), "#phi (rad)"); - const AxisSpec axisRadius(500, 0, 100, "r(cm)"); - const AxisSpec axisCosPA(120, 0.97, 1.0, "cos(#theta_{PA})"); - const AxisSpec axisDcaV0PV(200, 0, 2., "dca (cm)"); - const AxisSpec axisDcaProngPV(200, 0, 20., "dca (cm)"); - const AxisSpec axisDcaDau(75, 0., 1.5, "Daug DCA (cm^{2})"); - const AxisSpec axisCTau(500, 0, 100, "c#tau (cm/#it{c})"); - + const AxisSpec axisRadius(400, 0, 200, "r(cm)"); + const AxisSpec axisCosPA(100, 0.99, 1.0, "cos(#theta_{PA})"); + const AxisSpec axisDcaV0PV(1000, -5., 5., "dca (cm)"); + const AxisSpec axisDcaProngPV(1000, -50., 50., "dca (cm)"); + const AxisSpec axisDcaDau(75, 0., 1.5, "Daug DCA (#sigma)"); + const AxisSpec axisCTau(400, 0, 200, "c#tau (cm)"); + const AxisSpec axisGCTau(400, 0, 200, "#gammac#tau (cm)"); + const AxisSpec axisAlpha(40, -1, 1, "#alpha"); + const AxisSpec axisQtarm(40, 0, 0.4, "q_{T}"); + + const AxisSpec axisTrackPt(80, 0, 4, "p_{T} (GeV/#it{c})"); + const AxisSpec axisTrackDCA(200, -1, 1, "dca_{XY} (cm)"); const AxisSpec axisMomPID(80, 0, 4, "p (GeV/#it{c})"); const AxisSpec axisNsigma(401, -10.025, 10.025, {"n#sigma"}); const AxisSpec axisdEdx(360, 20, 200, "#frac{dE}{dx}"); // Create Histograms. + // Event histograms + histos.add("Event/h1d_collision_posZ", "V_{z}-distribution", kTH1F, {axisVz}); + histos.add("Event/h1d_collisions_info", "# of Collisions", kTH1F, {axisCol}); + // QA + histos.add("QA_Checks/h1d_tracks_info", "# of tracks", kTH1F, {axisCol}); histos.add("QA_Checks/h1d_lambda_mass", "M_{#Lambda}", kTH1F, {axisV0Mass}); + histos.add("QA_Checks/h1d_antilambda_mass", "M_{#Lambda}", kTH1F, {axisV0Mass}); + histos.add("QA_Checks/h2d_lambda_pt_vs_mass", "p_{T} vs M_{#Lambda}", kTH2F, {axisV0Mass, axisV0Pt}); + histos.add("QA_Checks/h2d_antilambda_pt_vs_mass", "p_{T} vs M_{#Lambda}", kTH2F, {axisV0Mass, axisV0Pt}); + histos.add("QA_Checks/h2d_before_topo_cuts_pt_vs_alpha", "Armentros-Podolanski Plot", kTH2F, {axisAlpha, axisQtarm}); + histos.add("QA_Checks/h2d_after_topo_cuts_pt_vs_alpha", "Armentros-Podolanski Plot", kTH2F, {axisAlpha, axisQtarm}); + histos.add("QA_Checks/h2d_before_masswincut_pt_vs_alpha", "Armentros-Podolanski Plot", kTH2F, {axisAlpha, axisQtarm}); + histos.add("QA_Checks/h2d_after_masswincut_pt_vs_alpha", "Armentros-Podolanski Plot", kTH2F, {axisAlpha, axisQtarm}); // QA Lambda histos.add("QA_Sel_Lambda/h1d_V0_inv_mass", "V_{0} mass", kTH1F, {axisV0Mass}); histos.add("QA_Sel_Lambda/h1d_V0_pt", "V_{0} p_{T}", kTH1F, {axisV0Pt}); - histos.add("QA_Sel_Lambda/h1d_V0_eta", "#eta-distribution", kTH1F, {axisV0Rap}); + histos.add("QA_Sel_Lambda/h1d_V0_eta", "#eta-distribution", kTH1F, {axisV0Eta}); histos.add("QA_Sel_Lambda/h1d_V0_rap", "y-distribution", kTH1F, {axisV0Rap}); histos.add("QA_Sel_Lambda/h1d_V0_phi", "#phi-distribution", kTH1F, {axisV0Phi}); + histos.add("QA_Sel_Lambda/h2d_V0_pt_vs_eta", "p_{T} vs #eta", kTH2F, {axisV0Eta, axisV0Pt}); + histos.add("QA_Sel_Lambda/h2d_V0_pt_vs_rap", "p_{T} vs y", kTH2F, {axisV0Rap, axisV0Pt}); + histos.add("QA_Sel_Lambda/h2d_V0_pt_vs_phi", "p_{T} vs #phi", kTH2F, {axisV0Phi, axisV0Pt}); + histos.add("QA_Sel_Lambda/h2d_V0_pt_vs_mass", "p_{T} vs M_{p#pi}", kTH2F, {axisV0Mass, axisV0Pt}); histos.add("QA_Sel_Lambda/h1d_dca_V0_daughters", "DCA between V0 daughters", kTH1F, {axisDcaDau}); histos.add("QA_Sel_Lambda/h1d_dca_pos_to_PV", "DCA positive prong to PV", kTH1F, {axisDcaProngPV}); @@ -192,39 +253,81 @@ struct lambdaCorrTableProducer { histos.add("QA_Sel_Lambda/h1d_V0_cospa", "cos(#theta_{PA})", kTH1F, {axisCosPA}); histos.add("QA_Sel_Lambda/h1d_V0_radius", "V_{0} Decay Radius in XY plane", kTH1F, {axisRadius}); histos.add("QA_Sel_Lambda/h1d_V0_ctau", "V_{0} c#tau", kTH1F, {axisCTau}); - - histos.add("QA_Sel_Lambda/h2d_pr_dEdx_vs_p", "TPC Signal Proton", kTH2F, {axisMomPID, axisdEdx}); - histos.add("QA_Sel_Lambda/h2d_pi_dEdx_vs_p", "TPC Signal Pion", kTH2F, {axisMomPID, axisdEdx}); - histos.add("QA_Sel_Lambda/h2d_pr_nsigma_tpc", "TPC Proton", kTH2F, {axisMomPID, axisNsigma}); - histos.add("QA_Sel_Lambda/h2d_pi_nsigma_tpc", "TPC Pion", kTH2F, {axisMomPID, axisNsigma}); - histos.add("QA_Sel_Lambda/h2d_pr_nsigma_tof", "TOF Proton", kTH2F, {axisMomPID, axisNsigma}); - histos.add("QA_Sel_Lambda/h2d_pi_nsigma_tof", "TOF Pion", kTH2F, {axisMomPID, axisNsigma}); + histos.add("QA_Sel_Lambda/h1d_V0_gctau", "V_{0} #gammac#tau", kTH1F, {axisGCTau}); + histos.add("QA_Sel_Lambda/h2d_qt_vs_alpha", "Armentros-Podolanski Plot", kTH2F, {axisAlpha, axisQtarm}); + + histos.add("QA_Sel_Lambda/h1d_pos_prong_pt", "Pos-Prong p_{T}", kTH1F, {axisTrackPt}); + histos.add("QA_Sel_Lambda/h1d_neg_prong_pt", "Neg-Prong p_{T}", kTH1F, {axisTrackPt}); + histos.add("QA_Sel_Lambda/h1d_pos_prong_eta", "Pos-Prong #eta-distribution", kTH1F, {axisV0Eta}); + histos.add("QA_Sel_Lambda/h1d_neg_prong_eta", "Neg-Prong #eta-distribution", kTH1F, {axisV0Eta}); + histos.add("QA_Sel_Lambda/h1d_pos_prong_phi", "Pos-Prong #phi-distribution", kTH1F, {axisV0Phi}); + histos.add("QA_Sel_Lambda/h1d_neg_prong_phi", "Neg-Prong #phi-distribution", kTH1F, {axisV0Phi}); + + histos.add("QA_Sel_Lambda/h2d_pos_prong_dcaXY_vs_pt", "DCA vs p_{T}", kTH2F, {axisTrackPt, axisTrackDCA}); + histos.add("QA_Sel_Lambda/h2d_neg_prong_dcaXY_vs_pt", "DCA vs p_{T}", kTH2F, {axisTrackPt, axisTrackDCA}); + histos.add("QA_Sel_Lambda/h2d_pos_prong_dEdx_vs_p", "TPC Signal Pos-Prong", kTH2F, {axisMomPID, axisdEdx}); + histos.add("QA_Sel_Lambda/h2d_neg_prong_dEdx_vs_p", "TPC Signal Neg-Prong", kTH2F, {axisMomPID, axisdEdx}); + histos.add("QA_Sel_Lambda/h2d_pos_prong_tpc_nsigma_pr_vs_p", "TPC n#sigma Pos Prong", kTH2F, {axisMomPID, axisNsigma}); + histos.add("QA_Sel_Lambda/h2d_neg_prong_tpc_nsigma_pr_vs_p", "TPC n#sigma Neg Prong", kTH2F, {axisMomPID, axisNsigma}); + histos.add("QA_Sel_Lambda/h2d_pos_prong_tpc_nsigma_pi_vs_p", "TPC n#sigma Pos Prong", kTH2F, {axisMomPID, axisNsigma}); + histos.add("QA_Sel_Lambda/h2d_neg_prong_tpc_nsigma_pi_vs_p", "TPC n#sigma Neg Prong", kTH2F, {axisMomPID, axisNsigma}); // QA Anti-Lambda histos.addClone("QA_Sel_Lambda/", "QA_Sel_AntiLambda/"); + + // MC Generated Histograms + if (doprocessMCGen) { + // McReco Histos + histos.add("QA_Checks/h2d_tracks_pid_before_sel", "PIDs", kTH2F, {axisPID, axisV0Pt}); + histos.add("QA_Checks/h2d_tracks_pid_after_sel", "PIDs", kTH2F, {axisPID, axisV0Pt}); + histos.add("QA_Checks/h2d_lambda_from_sigma", "PIDs", kTH2F, {axisPID, axisV0Pt}); + histos.add("QA_Checks/h2d_lambda_from_cascade", "PIDs", kTH2F, {axisPID, axisV0Pt}); + + // McGen Histos + histos.add("McGen/h1d_collisions_info", "# of collisions", kTH1F, {axisCol}); + histos.add("McGen/h1d_collision_posZ", "V_{z}-distribution", kTH1F, {axisVz}); + histos.add("McGen/h1d_lambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID}); + histos.add("McGen/h1d_antilambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID}); + histos.add("McGen/h1d_mass_lambda", "M_{#Lambda}", kTH1F, {axisV0Mass}); + histos.add("McGen/h1d_pt_lambda", "#Lambda p_{T}", kTH1F, {axisV0Pt}); + histos.add("McGen/h1d_eta_lambda", "#Lambda #eta-distribution", kTH1F, {axisV0Eta}); + histos.add("McGen/h1d_y_lambda", "#Lambda y-distribution", kTH1F, {axisV0Rap}); + histos.add("McGen/h1d_phi_lambda", "#Lambda #phi-distribution", kTH1F, {axisV0Phi}); + histos.add("McGen/h2d_pteta_lambda", "#Lambda p_{T} vs #eta", kTH2F, {axisV0Eta, axisV0Pt}); + histos.add("McGen/h2d_ptrap_lambda", "#Lambda p_{T} vs y", kTH2F, {axisV0Rap, axisV0Pt}); + histos.add("McGen/h2d_ptphi_lambda", "#Lambda p_{T} vs #phi", kTH2F, {axisV0Phi, axisV0Pt}); + histos.add("McGen/h1d_mass_antilambda", "M_{#bar{#Lambda}}", kTH1F, {axisV0Mass}); + histos.add("McGen/h1d_pt_antilambda", "#bar{#Lambda} p_{T}", kTH1F, {axisV0Pt}); + histos.add("McGen/h1d_eta_antilambda", "#bar{#Lambda} #eta-distribution", kTH1F, {axisV0Eta}); + histos.add("McGen/h1d_y_antilambda", "#bar{#Lambda} y-distribution", kTH1F, {axisV0Rap}); + histos.add("McGen/h1d_phi_antilambda", "#bar{#Lambda} #phi-distribution", kTH1F, {axisV0Phi}); + histos.add("McGen/h2d_pteta_antilambda", "#bar{#Lambda} p_{T} vs #eta", kTH2F, {axisV0Eta, axisV0Pt}); + histos.add("McGen/h2d_ptrap_antilambda", "#bar{#Lambda} p_{T} vs y", kTH2F, {axisV0Rap, axisV0Pt}); + histos.add("McGen/h2d_ptphi_antilambda", "#bar{#Lambda} p_{T} vs #phi", kTH2F, {axisV0Phi, axisV0Pt}); + } } template bool selCol(C const& col) { - if (fabs(col.posZ()) > cfg_z_vtx) { + if (col.posZ() < cfg_min_z_vtx || col.posZ() >= cfg_max_z_vtx) { return false; } - if (!col.selection_bit(aod::evsel::kIsTriggerTVX) && cfg_trigger_tvx_sel) { + if (!col.sel8() && cfg_sel8_sel) { return false; } - if (!col.selection_bit(aod::evsel::kNoTimeFrameBorder) && cfg_tf_border) { + if (!col.selection_bit(aod::evsel::kIsTriggerTVX) && cfg_trigger_tvx_sel) { return false; } - if (!col.selection_bit(aod::evsel::kNoITSROFrameBorder) && cfg_noitsro_border) { + if (!col.selection_bit(aod::evsel::kNoTimeFrameBorder) && cfg_tf_border) { return false; } - if (!col.sel8() && cfg_sel8_sel) { + if (!col.selection_bit(aod::evsel::kNoITSROFrameBorder) && cfg_noitsro_border) { return false; } @@ -243,26 +346,37 @@ struct lambdaCorrTableProducer { return true; } - template - bool topologicalCutsV0(V const& v0, T const&) + template + bool dauTrackSelection(T const& track) { - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); + if (track.pt() < cfg_pt_min || track.pt() > cfg_pt_max) { + return false; + } - if (fabs(postrack.eta()) > cfg_eta_cut) { + if (fabs(track.eta()) >= cfg_eta_cut) { return false; } - if (fabs(negtrack.eta()) > cfg_eta_cut) { + if (track.tpcNClsCrossedRows() < cfg_min_crossed_rows) { return false; } - if (postrack.tpcNClsCrossedRows() < cfg_min_crossed_rows) { + if (fabs(track.dcaXY()) < cfg_track_dcaXY_min) { return false; } - if (negtrack.tpcNClsCrossedRows() < cfg_min_crossed_rows) { + return true; + } + + template + bool topologicalCutsV0(C const& col, V const& v0, T const&) + { + + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + + if (!dauTrackSelection(postrack) || !dauTrackSelection(negtrack)) { return false; } @@ -286,6 +400,12 @@ struct lambdaCorrTableProducer { return false; } + // ctau + float ctau = v0.distovertotmom(col.posX(), col.posY(), col.posZ()) * MassLambda0; + if (ctau < cfg_min_ctau || ctau > cfg_max_ctau) { + return false; + } + if (v0.v0cosPA() < cfg_min_V0_cosPA) { return false; } @@ -293,45 +413,75 @@ struct lambdaCorrTableProducer { return true; } - template - bool selPIDTrack(T const& track) + template + bool selPIDTrack(T const& postrack, T const& negtrack) { + bool return_flag = false; + float tpcNSigmaPr = 0., tpcNSigmaPi = 0.; + + switch (part) { + // postrack = Proton, negtrack = Pion + case kLambda: + tpcNSigmaPr = postrack.tpcNSigmaPr(); + tpcNSigmaPi = negtrack.tpcNSigmaPi(); + break; - bool selTPCv0type = false, selTOFv0type = false; - float tpcNSigma = 0., tofNSigma = 0.; + // negtrack = Proton, postrack = Pion + case kAntiLambda: + tpcNSigmaPr = negtrack.tpcNSigmaPr(); + tpcNSigmaPi = postrack.tpcNSigmaPi(); + break; + } - switch (pid) { + if (fabs(tpcNSigmaPr) < cfg_tpc_nsigma && fabs(tpcNSigmaPi) < cfg_tpc_nsigma) { + return_flag = true; + } - case kPion: - tpcNSigma = track.tpcNSigmaPi(); - tofNSigma = track.tofNSigmaPi(); - break; + return return_flag; + } - case kProton: - tpcNSigma = track.tpcNSigmaPr(); - tofNSigma = track.tofNSigmaPr(); - break; + template + bool checkKinCuts(T const& v0track) + { + + // pT cut + if (v0track.pt() <= cfg_v0_pt_min || v0track.pt() >= cfg_v0_pt_max) { + return false; } - if (track.hasTOF()) { - if (fabs(tofNSigma) < cfg_tof_nsigma) { - selTOFv0type = true; - } - if (fabs(tpcNSigma) < cfg_tpc_nsigma) { - selTPCv0type = true; - } + // apply rapidity/pseudorapidity acceptance + float rap = 0.; + if (cfg_do_eta_analysis) { + rap = v0track.eta(); } else { - selTOFv0type = true; - if (fabs(tpcNSigma) < cfg_tpc_nsigma) { - selTPCv0type = true; + rap = v0track.yLambda(); + } + + if (fabs(rap) >= cfg_v0_rap_max) { + return false; + } + + return true; + } + + template + void getPDGsIDs(T const& mcparts, std::vector& PDGs, std::vector& IDs) + { + + for (auto mcpart : mcparts) { + if (mcpart.globalIndex() != 0) { + IDs.push_back(mcpart.globalIndex()); + PDGs.push_back(mcpart.pdgCode()); } } - if (selTPCv0type && selTOFv0type) { - return true; + while (IDs.size() > 2) { + IDs.pop_back(); } - return false; + while (PDGs.size() > 2) { + PDGs.pop_back(); + } } template @@ -340,151 +490,406 @@ struct lambdaCorrTableProducer { static constexpr std::string_view sub_dir[] = {"QA_Sel_Lambda/", "QA_Sel_AntiLambda/"}; - // ctau - float ctau = v0.distovertotmom(col.posX(), col.posY(), col.posZ()) * MassLambda0; - // daugthers auto postrack = v0.template posTrack_as(); auto negtrack = v0.template negTrack_as(); + float mass = 0.; - histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_V0_daughters"), v0.dcaV0daughters()); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_pos_to_PV"), fabs(v0.dcapostopv())); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_neg_to_PV"), fabs(v0.dcanegtopv())); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_V0_to_PV"), fabs(v0.dcav0topv())); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_cospa"), v0.v0cosPA()); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_radius"), v0.v0radius()); - histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_ctau"), ctau); + if constexpr (part == kLambda) { + mass = v0.mLambda(); + } else { + mass = v0.mAntiLambda(); + } + + // ctau + float e = RecoDecay::e(v0.px(), v0.py(), v0.pz(), mass); + float gamma = e / mass; + float ctau = v0.distovertotmom(col.posX(), col.posY(), col.posZ()) * MassLambda0; + float gctau = ctau * gamma; + + histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_inv_mass"), mass); histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_pt"), v0.pt()); histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_eta"), v0.eta()); histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_rap"), v0.yLambda()); histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_phi"), v0.phi()); - if constexpr (part == kLambda) { - histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_inv_mass"), v0.mLambda()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_dEdx_vs_p"), postrack.tpcInnerParam(), postrack.tpcSignal()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_dEdx_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcSignal()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_nsigma_tpc"), postrack.tpcInnerParam(), postrack.tpcNSigmaPr()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_nsigma_tpc"), negtrack.tpcInnerParam(), negtrack.tpcNSigmaPi()); - if (postrack.hasTOF()) { - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_nsigma_tof"), postrack.tofExpMom(), postrack.tofNSigmaPr()); - } - if (negtrack.hasTOF()) { - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_nsigma_tof"), negtrack.tofExpMom(), negtrack.tofNSigmaPi()); - } - } else { - histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_inv_mass"), v0.mAntiLambda()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_dEdx_vs_p"), postrack.tpcInnerParam(), postrack.tpcSignal()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_dEdx_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcSignal()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_nsigma_tpc"), postrack.tpcInnerParam(), postrack.tpcNSigmaPi()); - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_nsigma_tpc"), negtrack.tpcInnerParam(), negtrack.tpcNSigmaPr()); - if (postrack.hasTOF()) { - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pi_nsigma_tof"), postrack.tofExpMom(), postrack.tofNSigmaPi()); - } - if (negtrack.hasTOF()) { - histos.fill(HIST(sub_dir[part]) + HIST("h2d_pr_nsigma_tof"), negtrack.tofExpMom(), negtrack.tofNSigmaPr()); - } - } + histos.fill(HIST(sub_dir[part]) + HIST("h2d_V0_pt_vs_eta"), v0.eta(), v0.pt()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_V0_pt_vs_rap"), v0.yLambda(), v0.pt()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_V0_pt_vs_phi"), v0.phi(), v0.pt()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_V0_pt_vs_mass"), mass, v0.pt()); + + histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_V0_daughters"), v0.dcaV0daughters()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_pos_to_PV"), v0.dcapostopv()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_neg_to_PV"), v0.dcanegtopv()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_dca_V0_to_PV"), v0.dcav0topv()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_cospa"), v0.v0cosPA()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_radius"), v0.v0radius()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_ctau"), ctau); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_V0_gctau"), gctau); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_qt_vs_alpha"), v0.alpha(), v0.qtarm()); + + histos.fill(HIST(sub_dir[part]) + HIST("h1d_pos_prong_pt"), postrack.pt()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_pos_prong_eta"), postrack.eta()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_pos_prong_phi"), postrack.phi()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_neg_prong_pt"), negtrack.pt()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_neg_prong_eta"), negtrack.eta()); + histos.fill(HIST(sub_dir[part]) + HIST("h1d_neg_prong_phi"), negtrack.phi()); + + histos.fill(HIST(sub_dir[part]) + HIST("h2d_pos_prong_dcaXY_vs_pt"), postrack.pt(), postrack.dcaXY()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_neg_prong_dcaXY_vs_pt"), negtrack.pt(), negtrack.dcaXY()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_pos_prong_dEdx_vs_p"), postrack.tpcInnerParam(), postrack.tpcSignal()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_neg_prong_dEdx_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcSignal()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_pos_prong_tpc_nsigma_pr_vs_p"), postrack.tpcInnerParam(), postrack.tpcNSigmaPr()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_neg_prong_tpc_nsigma_pr_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcNSigmaPr()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_pos_prong_tpc_nsigma_pi_vs_p"), postrack.tpcInnerParam(), postrack.tpcNSigmaPi()); + histos.fill(HIST(sub_dir[part]) + HIST("h2d_neg_prong_tpc_nsigma_pi_vs_p"), negtrack.tpcInnerParam(), negtrack.tpcNSigmaPi()); } - template + template void selV0Particle(C const& collision, V const& v0track, T const& tracks) { - // initialize variables + // apply kinematic cuts + if (!checkKinCuts(v0track)) { + return; + } + + // initialize daughter tracks auto postrack = v0track.template posTrack_as(); auto negtrack = v0track.template negTrack_as(); - float mass = 0., rap = 0.; - if (v0part == kLambda) { + // initialize mass and v0lambda/v0antilambda + float mass = 0.; + ParticleType v0part; + + // apply daughter particle id + // check for Lambda / Anti-Lambda + if (selPIDTrack(postrack, negtrack)) { mass = v0track.mLambda(); - } - if (v0part == kAntiLambda) { + v0part = kLambda; + } else if (selPIDTrack(postrack, negtrack)) { mass = v0track.mAntiLambda(); - } - - if (cfg_do_eta_analysis) { - rap = v0track.eta(); + v0part = kAntiLambda; } else { - rap = v0track.yLambda(); - } - - // apply mass window selection [global] - if ((fabs(mass - MassLambda0) >= cfg_lambda_mass_window) || (fabs(v0track.mK0Short() - MassK0Short) <= cfg_kshort_rej)) { return; } - // apply daughter particle id - if (!selPIDTrack(postrack) || !selPIDTrack(negtrack)) { - return; - } + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 3.5); + histos.fill(HIST("QA_Checks/h2d_before_masswincut_pt_vs_alpha"), v0track.alpha(), v0track.qtarm()); - // apply kinematic acceptance - if (v0track.pt() <= cfg_v0_pt_min || v0track.pt() >= cfg_v0_pt_max) { + // apply Armentros-Podolanski Selection + if (cfg_armpod_flag && (fabs(v0track.alpha()) < v0track.qtarm() / cfg_armpod_val)) { return; } - if (cfg_do_eta_analysis && (fabs(v0track.eta()) >= cfg_v0_rap_max)) { - return; - } else if (fabs(v0track.yLambda()) >= cfg_v0_rap_max) { + // apply kshort rejection hypothesis + if (cfg_kshort_rej_flag && (fabs(v0track.mK0Short() - MassK0Short) <= cfg_kshort_rej)) { return; } + // fill mass histograms before applying mass window cut to get % purity if (v0part == kLambda) { - histos.fill(HIST("QA_Checks/h1d_lambda_mass"), v0track.mLambda()); + histos.fill(HIST("QA_Checks/h1d_lambda_mass"), mass); + histos.fill(HIST("QA_Checks/h2d_lambda_pt_vs_mass"), mass, v0track.pt()); + } else if (v0part == kAntiLambda) { + histos.fill(HIST("QA_Checks/h1d_antilambda_mass"), mass); + histos.fill(HIST("QA_Checks/h2d_antilambda_pt_vs_mass"), mass, v0track.pt()); } - if (v0part == kAntiLambda) { - histos.fill(HIST("QA_Checks/h1d_lambda_mass"), v0track.mAntiLambda()); + // apply mass window cut (Selection of Lambda/AntiLambda) + if (fabs(mass - MassLambda0) >= cfg_lambda_mass_window) { + return; } - // apply further mass window selection [central, left, right] - if (mass > mass_map_min[masswin] && mass < mass_map_max[masswin]) { - if (masswin == kCentralWindow) { - fillQALambda(collision, v0track, tracks); + histos.fill(HIST("QA_Checks/h2d_after_masswincut_pt_vs_alpha"), v0track.alpha(), v0track.qtarm()); + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 4.5); + + // MC Reco Analysis + if constexpr (reco) { + auto v0mcpart = v0track.mcParticle(); + + // Get information of all the reconstructed V0s + histos.fill(HIST("QA_Checks/h2d_tracks_pid_before_sel"), v0mcpart.pdgCode(), v0mcpart.pt()); + + // Get Daughters and Mothers + bool decay_channel_flag = false; + std::vector daughterPDGs{}, daughterIDs{}, motherPDGs{}, motherIDs{}; + auto mcpart_daughters = v0mcpart.template daughters_as(); + auto mcpart_mothers = v0mcpart.template mothers_as(); + + if (cfg_rec_pid_flag) { + + if (v0part == kLambda && v0mcpart.pdgCode() != kLambda0) { + return; + } else if (v0part == kAntiLambda && v0mcpart.pdgCode() != kLambda0Bar) { + return; + } + + getPDGsIDs(mcpart_daughters, daughterPDGs, daughterIDs); + getPDGsIDs(mcpart_mothers, motherPDGs, motherIDs); + + // Decay to Proton-Pion + if (abs(daughterPDGs[0]) == kProton && abs(daughterPDGs[1]) == kPiPlus) { + decay_channel_flag = true; + } + + // check for correct decay channel + if (!decay_channel_flag) { + return; + } + + // check whether the selected lambda is a Physical Primary / Secondary + if (cfg_rec_primary_lambda && !v0mcpart.isPhysicalPrimary()) { + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 7.5); + return; + } else if (cfg_rec_secondary_lambda && v0mcpart.isPhysicalPrimary()) { + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 8.5); + return; + } + + // check the secondary lambdas coming from Sigma, Cascades and Omegas + if (abs(motherPDGs[0]) == kSigma0 || abs(motherPDGs[1]) == kSigma0Bar) { + histos.fill(HIST("QA_Checks/h2d_lambda_from_sigma"), v0mcpart.pdgCode(), v0mcpart.pt()); + } + + if (abs(motherPDGs[0]) == kXiMinus || abs(motherPDGs[1]) == kXiMinus) { + histos.fill(HIST("QA_Checks/h2d_lambda_from_cascade"), v0mcpart.pdgCode(), v0mcpart.pt()); + } } - lambdaTrackTable(lambdaCollisionTable.lastIndex(), v0track.pt(), rap, v0track.phi(), mass, postrack.index(), negtrack.index(), v0part, masswin); + + // Fill the counter for selected primary/secondary Lambda/AntiLambda + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 5.5); + histos.fill(HIST("QA_Checks/h2d_tracks_pid_after_sel"), v0mcpart.pdgCode(), v0mcpart.pt()); } + + if (v0part == kLambda) { + fillQALambda(collision, v0track, tracks); + } else { + fillQALambda(collision, v0track, tracks); + } + + // Fill Lambda/AntiLambda Table + lambdaTrackTable(lambdaCollisionTable.lastIndex(), v0track.px(), v0track.py(), v0track.pz(), v0track.pt(), v0track.eta(), v0track.phi(), v0track.yLambda(), mass, postrack.index(), negtrack.index(), (int8_t)v0part, v0track.v0cosPA(), v0track.dcaV0daughters()); } using Collisions = soa::Join; using Tracks = soa::Join; - void process(Collisions::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) + void processData(Collisions::iterator const& collision, aod::V0Datas const& V0s, Tracks const& tracks) { + histos.fill(HIST("Event/h1d_collisions_info"), 1.5); + // select collision if (!selCol(collision)) { return; } + histos.fill(HIST("Event/h1d_collisions_info"), 2.5); + histos.fill(HIST("Event/h1d_collision_posZ"), collision.posZ()); + lambdaCollisionTable(collision.centFT0M(), collision.posX(), collision.posY(), collision.posZ()); for (auto const& v0 : V0s) { + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 1.5); + histos.fill(HIST("QA_Checks/h2d_before_topo_cuts_pt_vs_alpha"), v0.alpha(), v0.qtarm()); + // apply topological cuts on v0 candidates - if (!topologicalCutsV0(v0, tracks)) { + if (!topologicalCutsV0(collision, v0, tracks)) { + continue; + } + + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 2.5); + histos.fill(HIST("QA_Checks/h2d_after_topo_cuts_pt_vs_alpha"), v0.alpha(), v0.qtarm()); + + selV0Particle(collision, v0, tracks); + } + } + + PROCESS_SWITCH(lambdaCorrTableProducer, processData, "Process for DATA", true); + + Preslice> perCol = aod::track::collisionId; + Preslice perMCCol = aod::mcparticle::mcCollisionId; + + SliceCache cache1; + + // Service pdgDB; + + using CollisionsWithMcLabels = soa::Join; + // using McCollisions = soa::Join; + using McCollisions = aod::McCollisions; + using McV0Tracks = soa::Join; + using TracksMC = soa::Join; + + void processMCReco(CollisionsWithMcLabels const& collisions, McCollisions const&, McV0Tracks const& V0s, aod::McParticles const& /*mcParticles*/, TracksMC const& tracks) + { + + for (auto const& collision : collisions) { + + histos.fill(HIST("Event/h1d_collisions_info"), 1.5); + + // select collision + if (!selCol(collision)) { + continue; + } + + histos.fill(HIST("Event/h1d_collisions_info"), 2.5); + + // check for corresponding MCGen Collision + if (cfg_has_mc_flag && !collision.has_mcCollision()) { + continue; + } + + histos.fill(HIST("Event/h1d_collisions_info"), 3.5); + histos.fill(HIST("Event/h1d_collision_posZ"), collision.posZ()); + + lambdaCollisionTable(collision.centFT0M(), collision.posX(), collision.posY(), collision.posZ()); + + // auto const& mcCollision = collision.mcCollision_as(); + + // v0-track loop + auto v0sThisCollision = V0s.sliceBy(perCol, collision.globalIndex()); + for (auto const& v0 : v0sThisCollision) { + + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 0.5); + + // check for corresponding MCGen Particle + if (cfg_has_mc_flag && !v0.has_mcParticle()) { + continue; + } + + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 1.5); + histos.fill(HIST("QA_Checks/h2d_before_topo_cuts_pt_vs_alpha"), v0.alpha(), v0.qtarm()); + + // apply topological cuts on v0 candidates + if (!topologicalCutsV0(collision, v0, tracks)) { + continue; + } + + histos.fill(HIST("QA_Checks/h1d_tracks_info"), 2.5); + histos.fill(HIST("QA_Checks/h2d_after_topo_cuts_pt_vs_alpha"), v0.alpha(), v0.qtarm()); + + selV0Particle(collision, v0, tracks); + } + } + } + + PROCESS_SWITCH(lambdaCorrTableProducer, processMCReco, "Process for MC Reconstructed", false); + + void processMCGen(McCollisions::iterator const& mcCollision, aod::McParticles const& mcParticles) + { + + histos.fill(HIST("McGen/h1d_collisions_info"), 1.5); + + // apply collision cuts + if (mcCollision.posZ() < cfg_min_z_vtx || mcCollision.posZ() > cfg_max_z_vtx) { + return; + } + + histos.fill(HIST("McGen/h1d_collisions_info"), 2.5); + histos.fill(HIST("McGen/h1d_collision_posZ"), mcCollision.posZ()); + lambdaMCGenCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); + float mass = 0.; + + for (auto const& mcpart : mcParticles) { + + // check for Lambda first + if (abs(mcpart.pdgCode()) != kLambda0) { + continue; + } + + // check for Primary Lambdas/AntiLambdas + if (cfg_gen_primary_lambda && !mcpart.isPhysicalPrimary()) { + continue; + } + + // apply kinematic acceptance + if (mcpart.pt() <= cfg_v0_pt_min || mcpart.pt() >= cfg_v0_pt_max) { + continue; + } + + float rap = 0.; + if (cfg_do_eta_analysis) { + rap = mcpart.eta(); + } else { + rap = mcpart.y(); + } + + if (fabs(rap) >= cfg_v0_rap_max) { + continue; + } + + // Get Daughters and Mothers + bool decay_channel_flag = false; + std::vector daughterPDGs{}, daughterIDs{}, motherPDGs{}, motherIDs{}; + auto mcpart_daughters = mcpart.template daughters_as(); + auto mcpart_mothers = mcpart.template mothers_as(); + getPDGsIDs(mcpart_daughters, daughterPDGs, daughterIDs); + getPDGsIDs(mcpart_mothers, motherPDGs, motherIDs); + + // Decay to Proton-Pion + if (abs(daughterPDGs[0]) == kProton && abs(daughterPDGs[1]) == kPiPlus) { + decay_channel_flag = true; + } + + if (!decay_channel_flag) { continue; } - selV0Particle(collision, v0, tracks); - selV0Particle(collision, v0, tracks); - selV0Particle(collision, v0, tracks); - selV0Particle(collision, v0, tracks); - selV0Particle(collision, v0, tracks); - selV0Particle(collision, v0, tracks); + mass = RecoDecay::m(mcpart.p(), mcpart.e()); + + // Fill histograms + if (mcpart.pdgCode() == kLambda0) { + histos.fill(HIST("McGen/h1d_lambda_daughter_PDG"), daughterPDGs[0]); + histos.fill(HIST("McGen/h1d_lambda_daughter_PDG"), daughterPDGs[1]); + histos.fill(HIST("McGen/h1d_mass_lambda"), mass); + histos.fill(HIST("McGen/h1d_pt_lambda"), mcpart.pt()); + histos.fill(HIST("McGen/h1d_eta_lambda"), mcpart.eta()); + histos.fill(HIST("McGen/h1d_y_lambda"), mcpart.y()); + histos.fill(HIST("McGen/h1d_phi_lambda"), mcpart.phi()); + histos.fill(HIST("McGen/h2d_pteta_lambda"), mcpart.eta(), mcpart.pt()); + histos.fill(HIST("McGen/h2d_ptrap_lambda"), mcpart.y(), mcpart.pt()); + histos.fill(HIST("McGen/h2d_ptphi_lambda"), mcpart.phi(), mcpart.pt()); + lambdaMCGenTrackTable(lambdaMCGenCollisionTable.lastIndex(), mcpart.px(), mcpart.py(), mcpart.pz(), mcpart.pt(), mcpart.eta(), mcpart.phi(), mcpart.y(), mass, daughterIDs[0], daughterIDs[1], (int8_t)kLambda, -999., -999.); + } else if (mcpart.pdgCode() == kLambda0Bar) { + histos.fill(HIST("McGen/h1d_antilambda_daughter_PDG"), daughterPDGs[0]); + histos.fill(HIST("McGen/h1d_antilambda_daughter_PDG"), daughterPDGs[1]); + histos.fill(HIST("McGen/h1d_mass_antilambda"), mass); + histos.fill(HIST("McGen/h1d_pt_antilambda"), mcpart.pt()); + histos.fill(HIST("McGen/h1d_eta_antilambda"), mcpart.eta()); + histos.fill(HIST("McGen/h1d_y_antilambda"), mcpart.y()); + histos.fill(HIST("McGen/h1d_phi_antilambda"), mcpart.phi()); + histos.fill(HIST("McGen/h2d_pteta_antilambda"), mcpart.eta(), mcpart.pt()); + histos.fill(HIST("McGen/h2d_ptrap_antilambda"), mcpart.y(), mcpart.pt()); + histos.fill(HIST("McGen/h2d_ptphi_antilambda"), mcpart.phi(), mcpart.pt()); + lambdaMCGenTrackTable(lambdaMCGenCollisionTable.lastIndex(), mcpart.px(), mcpart.py(), mcpart.pz(), mcpart.pt(), mcpart.eta(), mcpart.phi(), mcpart.y(), mass, daughterIDs[1], daughterIDs[0], (int8_t)kAntiLambda, -999., -999.); + } } } + + PROCESS_SWITCH(lambdaCorrTableProducer, processMCGen, "Process for MC Generated", false); }; struct lambdaCorrelationAnalysis { // Global Configurables - Configurable cfg_nRapBins{"cfg_nRapBins", 16, "N Rapidity Bins"}; - Configurable cfg_Rap_Min{"cfg_Rap_Min", -0.8, "Minimum Rapidity"}; - Configurable cfg_Rap_Max{"cfg_Rap_Max", 0.8, "Maximum Rapidity"}; + Configurable cfg_nRapBins{"cfg_nRapBins", 12, "N Rapidity Bins"}; + Configurable cfg_Rap_Min{"cfg_Rap_Min", -0.6, "Minimum Rapidity"}; + Configurable cfg_Rap_Max{"cfg_Rap_Max", 0.6, "Maximum Rapidity"}; Configurable cfg_nPhiBins{"cfg_nPhiBins", 64, "N Phi Bins"}; Configurable cfg_Phi_Min{"cfg_Phi_Min", 0, "Minimum Phi"}; Configurable cfg_Phi_Max{"cfg_Phi_Max", 2 * TMath::Pi(), "Maximum Phi"}; + // remove lambda with shared daughters + Configurable cfg_remove_lambda{"cfg_remove_lambda", true, "Flag to remove lambda"}; + + // Efficiency Correction + Configurable cfg_eff_corr_flag{"cfg_eff_corr_flag", true, "Efficiency Correction Flag"}; + + // CCDB + Configurable cfg_ccdb_url{"cfg_ccdb_url", "http://ccdb-test.cern.ch:8080", "url of ccdb"}; + Configurable cfg_ccdb_path{"cfg_ccdb_path", "Users/y/ypatley/lambda_corr_fact", "Path for ccdb-object"}; + // Histogram Registry. HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -497,9 +902,19 @@ struct lambdaCorrelationAnalysis { float kmaxphi = 0.; float rapbinwidth = 0.; float phibinwidth = 0.; + float q = 0., e = 0., qinv = 0.; + + // Initialize CCDB Service + Service ccdb; void init(InitContext const&) { + + // Set CCDB url + ccdb->setURL(cfg_ccdb_url.value); + ccdb->setCaching(true); + + // Set Density Histogram Attributes nrapbins = static_cast(cfg_nRapBins); kminrap = static_cast(cfg_Rap_Min); kmaxrap = static_cast(cfg_Rap_Max); @@ -514,45 +929,171 @@ struct lambdaCorrelationAnalysis { float kminrapphi = 0.; float kmaxrapphi = knrapphibins; + const AxisSpec axisCheck(1, 0, 1, ""); const AxisSpec axisPosZ(220, -11, 11, "V_{z} (cm)"); const AxisSpec axisCent(105, 0, 105, "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 axisRap(cfg_nRapBins, cfg_Rap_Min, cfg_Rap_Max, "rap"); + const AxisSpec axisPt(64, 0.3, 3.5, "p_{T} (GeV/#it{c})"); + const AxisSpec axisEta(24, -1.2, 1.2, "#eta"); + const AxisSpec axisCPA(100, 0.99, 1.0, "cos(#theta_{PA})"); + const AxisSpec axisDcaDau(75, 0., 1.5, "Daug DCA (#sigma)"); + const AxisSpec axisRap(cfg_nRapBins, cfg_Rap_Min, cfg_Rap_Max, "y"); const AxisSpec axisPhi(cfg_nPhiBins, cfg_Phi_Min, cfg_Phi_Max, "#phi (rad)"); - const AxisSpec axisRapPhi(knrapphibins, kminrapphi, kmaxrapphi, "rap #phi"); + const AxisSpec axisRapPhi(knrapphibins, kminrapphi, kmaxrapphi, "y #phi"); + const AxisSpec axisQinv(100, 0, 10, "q_{inv} (GeV/#it{c})"); + + const AxisSpec axisEfPt(16, 0.3, 3.5, "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/h1d_posz", "V_{Z} Distribution", kTH1F, {axisPosZ}); - histos.add("Event/h1d_ft0m_mult_percentile", "FT0M (%)", kTH1F, {axisCent}); - histos.add("Event/h1d_lambda_tot_mult", "#Lambda/#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); - histos.add("Event/h1d_lambda_multiplicity", "#Lambda - Multiplicity", kTH1I, {axisMult}); - histos.add("Event/h1d_antilambda_multiplicity", "#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_collision_posz", "V_{Z} Distribution", kTH1F, {axisPosZ}); + histos.add("Event/Reco/h1d_ft0m_mult_percentile", "FT0M (%)", kTH1F, {axisCent}); + histos.add("Event/Reco/h1d_lambda_multiplicity", "#Lambda - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_antilambda_multiplicity", "#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_lambda_sdau", "#Lambda - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_antilambda_sdau", "#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_lambda_totmult", "#Lambda - Multiplicity", kTH1I, {axisMult}); + histos.add("Event/Reco/h1d_antilambda_totmult", "#bar{#Lambda} - Multiplicity", kTH1I, {axisMult}); + + // InvMass, DcaDau and CosPA + histos.add("Reco/QA_Lambda/h1d_V0_mass", "M_{p#pi}", kTH1F, {axisMass}); + histos.add("Reco/QA_Lambda/h1d_V0_cpa", "cos(#theta_{PA})", kTH1F, {axisCPA}); + histos.add("Reco/QA_Lambda/h1d_V0_dcadau", "DCA_{p#pi} at V0 Decay Vertex", kTH1F, {axisDcaDau}); + + histos.addClone("Reco/QA_Lambda/", "Reco/QA_AntiLambda/"); + + // Efficiency Histograms + 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}); - // Lambda - histos.add("Lambda/h1d_inv_mass", "M_{p#pi}", kTH1F, {axisMass}); + // single and two particle densities + // 1D Histograms + 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, {axisEta}); + histos.add("Reco/h1d_n1_rap_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH1D, {axisEta}); + 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}); + 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}); + + // 2D Histograms + histos.add("Reco/h2d_n1_LaP", "#rho_{1}^{#Lambda}", kTH2D, {axisRap, axisPhi}); + histos.add("Reco/h2d_n1_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2D, {axisRap, axisPhi}); + histos.add("Reco/h2d_n2_LaP_LaM", "#rho_{2}^{#Lambda - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); + histos.add("Reco/h2d_n2_LaP_LaP", "#rho_{2}^{#Lambda - #Lambda}", kTH2D, {axisRapPhi, axisRapPhi}); + histos.add("Reco/h2d_n2_LaM_LaM", "#rho_{2}^{#bar{#Lambda} - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); + histos.add("Reco/h2d_n2_pt1pt2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisPt, axisPt}); + histos.add("Reco/h2d_n2_pt1pt2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisPt, axisPt}); + histos.add("Reco/h2d_n2_pt1pt2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisPt, axisPt}); + histos.add("Reco/h2d_n2_eta1eta2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisEta, axisEta}); + histos.add("Reco/h2d_n2_eta1eta2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisEta, axisEta}); + histos.add("Reco/h2d_n2_eta1eta2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisEta, axisEta}); + histos.add("Reco/h2d_n2_phi1phi2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisPhi, axisPhi}); + histos.add("Reco/h2d_n2_phi1phi2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisPhi, axisPhi}); + histos.add("Reco/h2d_n2_phi1phi2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisPhi, axisPhi}); + histos.add("Reco/h2d_n2_rap1rap2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisRap, axisRap}); + histos.add("Reco/h2d_n2_rap1rap2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisRap, axisRap}); + histos.add("Reco/h2d_n2_rap1rap2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisRap, axisRap}); + histos.add("Reco/h2d_n2_pt1eta2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisPt, axisEta}); + histos.add("Reco/h2d_n2_pt1eta2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisPt, axisEta}); + histos.add("Reco/h2d_n2_pt1eta2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisPt, axisEta}); + histos.add("Reco/h2d_n2_pt1phi2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisPt, axisPhi}); + histos.add("Reco/h2d_n2_pt1phi2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisPt, axisPhi}); + histos.add("Reco/h2d_n2_pt1phi2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisPt, axisPhi}); + histos.add("Reco/h2d_n2_pt1rap2_LaP_LaM", "#rho_{2}^{#Lambda#bar{#Lambda}}", kTH2D, {axisPt, axisRap}); + histos.add("Reco/h2d_n2_pt1rap2_LaP_LaP", "#rho_{2}^{#Lambda#Lambda}", kTH2D, {axisPt, axisRap}); + histos.add("Reco/h2d_n2_pt1rap2_LaM_LaM", "#rho_{2}^{#bar{#Lambda}#bar{#Lambda}}", kTH2D, {axisPt, axisRap}); + + // MCGen + if (doprocessMCGen) { + histos.addClone("Event/Reco/", "Event/McGen/"); + histos.addClone("Reco/", "McGen/"); + } + } - // Anti-Lambda - histos.addClone("Lambda/", "AntiLambda/"); + template + bool removeLambdaSharingDau(T const& v, V const& vs) + { + // check whether to remove lambda or not + if (!cfg_remove_lambda) { + return true; + } - // single and two particle densities - histos.add("Lambda_Mass/h2d_n1_LaP", "#rho_{1}^{#Lambda}", kTH2D, {axisRap, axisPhi}); - histos.add("Lambda_Mass/h2d_n1_LaM", "#rho_{1}^{#bar{#Lambda}}", kTH2D, {axisRap, axisPhi}); - histos.add("Lambda_Mass/h2d_n2_LaP_LaM", "#rho_{2}^{#Lambda - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); - histos.add("Lambda_Mass/h2d_n2_LaP_LaP", "#rho_{2}^{#Lambda - #Lambda}", kTH2D, {axisRapPhi, axisRapPhi}); - histos.add("Lambda_Mass/h2d_n2_LaM_LaM", "#rho_{2}^{#bar{#Lambda} - #bar{#Lambda}}", kTH2D, {axisRapPhi, axisRapPhi}); - - histos.addClone("Lambda_Mass/", "Lambda_Right/"); - histos.addClone("Lambda_Mass/", "Lambda_Left/"); + static constexpr std::string_view sub_dir_recgen[] = {"Reco/", "McGen/"}; + static constexpr std::string_view sub_dir[] = {"QA_Lambda/", "QA_AntiLambda/"}; + + bool ret_flag = true; + + for (auto const& x : vs) { + if ((v.index() != x.index()) && (v.postrackid() == x.postrackid() || v.negtrackid() == x.negtrackid())) { + if (fillHist) { + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST(sub_dir[part]) + HIST("h1d_V0_mass"), x.mass()); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST(sub_dir[part]) + HIST("h1d_V0_cpa"), x.cospa()); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST(sub_dir[part]) + HIST("h1d_V0_dcadau"), x.dcadau()); + } + if (std::abs(v.mass() - MassLambda0) > std::abs(x.mass() - MassLambda0)) { + ret_flag = false; + break; + } + } + } + + return ret_flag; } - template - void fillPairHistos(U& p1, U& p2) + template + void get_corr_factor(float& corfact, C const& col, T const& track) { - static constexpr std::string_view sub_dir_type[] = {"Lambda_Mass/", "Lambda_Left/", "Lambda_Right/"}; - static constexpr std::string_view sub_dir_hist[] = {"h2d_n2_LaP_LaM", "h2d_n2_LaP_LaP", "h2d_n2_LaM_LaM"}; + // Check for efficiency correction flag and Rec/Gen Data + if (!cfg_eff_corr_flag || rec_gen == kGen) { + return; + } + + // Get from CCDB + auto ccdb_obj = ccdb->getForTimeStamp(cfg_ccdb_path.value, -1); + + // Check CCDB Object + if (!ccdb_obj) { + LOGF(warning, "CCDB OBJECT NOT FOUND"); + return; + } + + std::string str; + + if (track.v0type() == kLambda) { + str = "h3f_lambda_corr_fact"; + } else { + str = "h3f_antilambda_corr_fact"; + } + + TH3F* hist = reinterpret_cast(ccdb_obj->FindObject(Form("%s", str.c_str()))); + + int pt_bin = hist->GetXaxis()->FindBin(track.pt()); + int eta_bin = hist->GetYaxis()->FindBin(track.eta()); + int vz_bin = hist->GetZaxis()->FindBin(col.posZ()); + + corfact = hist->GetBinContent(pt_bin + 0.00001, eta_bin + 0.00001, vz_bin + 0.01); + + return; + } + + template + void fillPairHistos(C const& col, U& p1, U& p2) + { + + static constexpr std::string_view sub_dir_recgen[] = {"Reco/", "McGen/"}; + static constexpr std::string_view sub_dir_hist[] = {"LaP_LaM", "LaP_LaP", "LaM_LaM"}; int rapbin1 = static_cast((p1.rap() - kminrap) / rapbinwidth); int rapbin2 = static_cast((p2.rap() - kminrap) / rapbinwidth); @@ -560,39 +1101,112 @@ struct lambdaCorrelationAnalysis { int phibin1 = static_cast(p1.phi() / phibinwidth); int phibin2 = static_cast(p2.phi() / phibinwidth); + float corfac1 = 1., corfac2 = 1.; + + get_corr_factor(corfac1, col, p1); + get_corr_factor(corfac2, col, p2); + + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_pt1pt2_") + HIST(sub_dir_hist[part_pair]), p1.pt(), p2.pt(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_eta1eta2_") + HIST(sub_dir_hist[part_pair]), p1.eta(), p2.eta(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_phi1phi2_") + HIST(sub_dir_hist[part_pair]), p1.phi(), p2.phi(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_rap1rap2_") + HIST(sub_dir_hist[part_pair]), p1.rap(), p2.rap(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_pt1eta2_") + HIST(sub_dir_hist[part_pair]), p1.pt(), p2.eta(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_pt1phi2_") + HIST(sub_dir_hist[part_pair]), p1.pt(), p2.phi(), corfac1 * corfac2); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_pt1rap2_") + HIST(sub_dir_hist[part_pair]), p1.pt(), p2.rap(), corfac1 * corfac2); + 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(sub_dir_type[mass_win]) + HIST(sub_dir_hist[part_pair]), rapphix + 0.5, rapphiy + 0.5); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n2_") + HIST(sub_dir_hist[part_pair]), rapphix + 0.5, rapphiy + 0.5, corfac1 * corfac2); } + + // qinv histos + 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(sub_dir_recgen[rec_gen]) + HIST("h1d_n2_qinv_") + HIST(sub_dir_hist[part_pair]), qinv, corfac1 * corfac2); } - template - void analyzeSingles(T const& tracks) + template + void analyzeSingles(C const& col, T const& tracks) { - static constexpr std::string_view sub_dir_part[] = {"Lambda/", "AntiLambda/"}; - static constexpr std::string_view sub_dir_mass_win[] = {"Lambda_Mass/", "Lambda_Left/", "Lambda_Right/"}; - static constexpr std::string_view sub_dir_hist[] = {"h2d_n1_LaP", "h2d_n1_LaM"}; + static constexpr std::string_view sub_dir_recgen[] = {"Reco/", "McGen/"}; + static constexpr std::string_view sub_dir_hist[] = {"LaP", "LaM"}; + + int ntrk1 = 0, ntrk2 = 0, ntrk3 = 0; + float corfac = 1.; for (auto const& track : tracks) { - histos.fill(HIST(sub_dir_part[part]) + HIST("h1d_inv_mass"), track.mass()); - histos.fill(HIST(sub_dir_mass_win[masswin]) + HIST(sub_dir_hist[part]), track.rap(), track.phi()); + ++ntrk1; + if (!removeLambdaSharingDau(track, tracks)) { + ++ntrk2; + continue; + } + ++ntrk3; + + // Get Correction Factor + get_corr_factor(corfac, col, track); + + // QA Plots + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_n1_pt_") + HIST(sub_dir_hist[part]), track.pt(), corfac); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_n1_eta_") + HIST(sub_dir_hist[part]), track.eta(), corfac); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_n1_phi_") + HIST(sub_dir_hist[part]), track.phi(), corfac); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_n1_rap_") + HIST(sub_dir_hist[part]), track.rap(), corfac); + + // Efficiency Calculation Plots + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("Efficiency/h3f_n1_ptetaposz_") + HIST(sub_dir_hist[part]), track.pt(), track.eta(), col.posZ()); + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("Efficiency/h3f_n1_ptrapposz_") + HIST(sub_dir_hist[part]), track.pt(), track.rap(), col.posZ()); + + // Rho1 for R2 Calculation + histos.fill(HIST(sub_dir_recgen[rec_gen]) + HIST("h2d_n1_") + HIST(sub_dir_hist[part]), track.rap(), track.phi(), corfac); + } + + // fill multiplicity histograms + if (ntrk1 != 0) { + if (part == kLambda) { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_lambda_totmult"), ntrk1); + } else { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_antilambda_totmult"), ntrk1); + } + } + + if (ntrk2 != 0) { + if (part == kLambda) { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_lambda_sdau"), ntrk2); + } else { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_antilambda_sdau"), ntrk2); + } + } + + if (ntrk3 != 0) { + if (part == kLambda) { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_lambda_multiplicity"), ntrk3); + } else { + histos.fill(HIST("Event/") + HIST(sub_dir_recgen[rec_gen]) + HIST("h1d_antilambda_multiplicity"), ntrk3); + } } } - template - void analyzePairs(T const& trks_1, T const& trks_2) + template + void analyzePairs(C const& col, T const& trks_1, T const& trks_2) { - for (auto const& trk_1 : trks_1) { + if (!removeLambdaSharingDau(trk_1, trks_1)) { + continue; + } for (auto const& trk_2 : trks_2) { - if (samelambda && (trk_1.index() == trk_2.index()) && (trk_1.postrackid() == trk_2.postrackid()) && (trk_1.negtrackid() == trk_2.negtrackid())) { + // check for same index for Lambda-Lambda / AntiLambda-AntiLambda + if (samelambda && ((trk_1.index() == trk_2.index()))) { continue; } - fillPairHistos(trk_1, trk_2); + // check if Lambda shares a daughter and select the one closest to PDG Mass + if (!removeLambdaSharingDau(trk_2, trks_2)) { + continue; + } + fillPairHistos(col, trk_1, trk_2); } } } @@ -602,50 +1216,49 @@ struct lambdaCorrelationAnalysis { SliceCache cache; - Partition part_lambda_tracks = (aod::lambdatrack::v0type == (int8_t)kLambda && aod::lambdatrack::masswindow == (int8_t)kCentralWindow); - Partition part_anti_lambda_tracks = (aod::lambdatrack::v0type == (int8_t)kAntiLambda && aod::lambdatrack::masswindow == (int8_t)kCentralWindow); - - Partition part_lambda_tracks_left_masswin = (aod::lambdatrack::v0type == (int8_t)kLambda && aod::lambdatrack::masswindow == (int8_t)kLeftWindow); - Partition part_anti_lambda_tracks_left_masswin = (aod::lambdatrack::v0type == (int8_t)kAntiLambda && aod::lambdatrack::masswindow == (int8_t)kLeftWindow); + Partition part_lambda_tracks = (aod::lambdatrack::v0type == (int8_t)kLambda); + Partition part_anti_lambda_tracks = (aod::lambdatrack::v0type == (int8_t)kAntiLambda); - Partition part_lambda_tracks_right_masswin = (aod::lambdatrack::v0type == (int8_t)kLambda && aod::lambdatrack::masswindow == (int8_t)kRightWindow); - Partition part_anti_lambda_tracks_right_masswin = (aod::lambdatrack::v0type == (int8_t)kAntiLambda && aod::lambdatrack::masswindow == (int8_t)kRightWindow); - - void process(Lambda_Collisions::iterator const& collision, Lambda_Tracks const&) + void processDataReco(Lambda_Collisions::iterator const& collision, Lambda_Tracks const&) { - - histos.fill(HIST("Event/h1d_posz"), collision.posZ()); - histos.fill(HIST("Event/h1d_ft0m_mult_percentile"), collision.cent()); + histos.fill(HIST("Event/Reco/h1d_collision_posz"), collision.posZ()); + histos.fill(HIST("Event/Reco/h1d_ft0m_mult_percentile"), collision.cent()); auto lambda_tracks = part_lambda_tracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); auto anti_lambda_tracks = part_anti_lambda_tracks->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); - auto lambda_tracks_left = part_lambda_tracks_left_masswin->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); - auto anti_lambda_tracks_left = part_anti_lambda_tracks_left_masswin->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + analyzeSingles(collision, lambda_tracks); + analyzeSingles(collision, anti_lambda_tracks); + analyzePairs(collision, lambda_tracks, anti_lambda_tracks); + analyzePairs(collision, lambda_tracks, lambda_tracks); + analyzePairs(collision, anti_lambda_tracks, anti_lambda_tracks); + } + + PROCESS_SWITCH(lambdaCorrelationAnalysis, processDataReco, "Process for Data and MCReco", true); - auto lambda_tracks_right = part_lambda_tracks_right_masswin->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); - auto anti_lambda_tracks_right = part_anti_lambda_tracks_right_masswin->sliceByCached(aod::lambdatrack::lambdaCollisionId, collision.globalIndex(), cache); + using LambdaMCGenCollisions = aod::LambdaMCGenCollisions; + using LambdaMCGenTracks = aod::LambdaMCGenTracks; - analyzeSingles(lambda_tracks); - analyzeSingles(lambda_tracks_left); - analyzeSingles(lambda_tracks_right); + SliceCache cachemc; + Partition part_lambda_mcgen_tracks = aod::lambdatrack::v0type == (int8_t)kLambda; + Partition part_antilambda_mcgen_tracks = aod::lambdatrack::v0type == (int8_t)kAntiLambda; - analyzeSingles(anti_lambda_tracks); - analyzeSingles(anti_lambda_tracks_left); - analyzeSingles(anti_lambda_tracks_right); + void processMCGen(LambdaMCGenCollisions::iterator const& mcgencol, LambdaMCGenTracks const&) + { - analyzePairs(lambda_tracks, anti_lambda_tracks); - analyzePairs(lambda_tracks_left, anti_lambda_tracks_left); - analyzePairs(lambda_tracks_right, anti_lambda_tracks_right); + histos.fill(HIST("Event/McGen/h1d_collision_posz"), mcgencol.posZ()); - analyzePairs(lambda_tracks, lambda_tracks); - analyzePairs(lambda_tracks_left, lambda_tracks_left); - analyzePairs(lambda_tracks_right, lambda_tracks_right); + auto lambda_mcgen_tracks = part_lambda_mcgen_tracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); + auto antilambda_mcgen_tracks = part_antilambda_mcgen_tracks->sliceByCached(aod::lambdamcgentrack::lambdaMcGenCollisionId, mcgencol.globalIndex(), cachemc); - analyzePairs(anti_lambda_tracks, anti_lambda_tracks); - analyzePairs(anti_lambda_tracks_left, anti_lambda_tracks_left); - analyzePairs(anti_lambda_tracks_right, anti_lambda_tracks_right); + analyzeSingles(mcgencol, lambda_mcgen_tracks); + analyzeSingles(mcgencol, antilambda_mcgen_tracks); + analyzePairs(mcgencol, lambda_mcgen_tracks, antilambda_mcgen_tracks); + analyzePairs(mcgencol, lambda_mcgen_tracks, lambda_mcgen_tracks); + analyzePairs(mcgencol, antilambda_mcgen_tracks, antilambda_mcgen_tracks); } + + PROCESS_SWITCH(lambdaCorrelationAnalysis, processMCGen, "Process for MC Generated", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGCF/TwoParticleCorrelations/Tasks/r2p2-4-id.cxx b/PWGCF/TwoParticleCorrelations/Tasks/r2p2-4-id.cxx index d7187c49f0c..e6c13fe1318 100644 --- a/PWGCF/TwoParticleCorrelations/Tasks/r2p2-4-id.cxx +++ b/PWGCF/TwoParticleCorrelations/Tasks/r2p2-4-id.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 "Common/DataModel/EventSelection.h" @@ -49,12 +51,12 @@ struct FillFlagsTable { auto tpcnsigma = (std::vector>){TPCnsigmacutsPi, TPCnsigmacutsKa, TPCnsigmacutsPr}; auto tofpt = (std::vector>){TOFpTrangesPi, TOFpTrangesKa, TOFpTrangesPr}; auto tofnsigma = (std::vector>){TOFnsigmacutsPi, TOFnsigmacutsKa, TOFnsigmacutsPr}; - for (int8_t i = 0; i < tpcpt[species].size(); i++) + for (std::size_t i = 0; i < tpcpt[species].size(); i++) if (trackpt < tpcpt[species][i]) { tpcindex = i; break; } - for (int8_t i = 0; i < tofpt[species].size(); i++) + for (std::size_t i = 0; i < tofpt[species].size(); i++) if (trackpt >= tofpt[species][i]) { tofindex = i; break; @@ -258,8 +260,8 @@ struct r2p24id { Configurable maxpT{"maxpT", 2.0, "Maximum pT"}; Configurable trackpartition{"trackpartition", 1.0, "where(in pT) to partition"}; - Configurable pid_particle1{"pid_particle1", 1, "Define particle1 type"}; // 1->Pion, 2->Kaon, 3->Proton - Configurable pid_particle2{"pid_particle2", 1, "Define particle2 type"}; + Configurable pid_particle1{"pid_particle1", 1, "Define particle1 type"}; // 1->Pion, 2->Kaon, 3->Proton + Configurable pid_particle2{"pid_particle2", 1, "Define particle2 type"}; Configurable iftrackpartition{"iftrackpartition", false, "If track partition is needed"}; Configurable ifpid{"ifpid", false, "If PID is needed"}; diff --git a/PWGDQ/Core/CutsLibrary.cxx b/PWGDQ/Core/CutsLibrary.cxx index 4bcbbdf502f..8fc8f9fccd5 100644 --- a/PWGDQ/Core/CutsLibrary.cxx +++ b/PWGDQ/Core/CutsLibrary.cxx @@ -14,6 +14,7 @@ #include "PWGDQ/Core/CutsLibrary.h" #include #include +#include #include "AnalysisCompositeCut.h" #include "VarManager.h" @@ -144,6 +145,15 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) cut->AddCut(GetAnalysisCut("electronPIDnsigmaMedium")); return cut; } + + if (!nameStr.compare("electronSelection1_idstoreh")) { // same as electronSelection1_ionut, but with kIsSPDAny -> kIsITSibAny + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaMedium")); + return cut; + } + if (!nameStr.compare("electronSelection1pos_ionut")) { cut->AddCut(GetAnalysisCut("posTrack")); cut->AddCut(GetAnalysisCut("jpsiStandardKine")); @@ -369,6 +379,18 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("pidElectron_ionut")) { + cut->AddCut(GetAnalysisCut("pidcalib_ele")); + cut->AddCut(GetAnalysisCut("jpsiStandardKine3")); + return cut; + } + + if (!nameStr.compare("pidPion_ionut")) { + cut->AddCut(GetAnalysisCut("pidcalib_pion")); + cut->AddCut(GetAnalysisCut("jpsiStandardKine3")); + return cut; + } + if (!nameStr.compare("jpsiO2MCdebugCuts13_Corr")) { cut->AddCut(GetAnalysisCut("jpsiStandardKine")); cut->AddCut(GetAnalysisCut("electronStandardQualityTPCOnly")); // no cut on ITS clusters @@ -392,6 +414,36 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("emu_electronCuts")) { + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaSkewed")); + return cut; + } + + if (!nameStr.compare("emu_electronCuts_tof")) { + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaSkewed")); + cut->AddCut(GetAnalysisCut("tof_electron_sigma_2")); + return cut; + } + + if (!nameStr.compare("emu_electronCuts_tightTPC")) { + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaSkewed_2")); + return cut; + } + + if (!nameStr.compare("emu_electronCuts_tof_tightTPC")) { + cut->AddCut(GetAnalysisCut("jpsiStandardKine")); + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("electronPIDnsigmaSkewed_2")); + cut->AddCut(GetAnalysisCut("tof_electron_sigma_2")); + return cut; + } + if (!nameStr.compare("jpsiKineAndQuality")) { cut->AddCut(GetAnalysisCut("jpsiStandardKine")); cut->AddCut(GetAnalysisCut("electronStandardQuality")); @@ -582,6 +634,14 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("kaonPID3_withDCA")) { // same as kaonPID3 but with cut on DCA and SPDAny->ITSAny + cut->AddCut(GetAnalysisCut("AssocKine")); // standard kine cuts usually are applied via Filter in the task + cut->AddCut(GetAnalysisCut("electronStandardQualityForO2MCdebug4")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("kaonPID_TPCnTOF")); + return cut; + } + if (!nameStr.compare("kaonPID4")) { cut->AddCut(GetAnalysisCut("kaonPID_TPCnTOF")); return cut; @@ -612,16 +672,10 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare("kaonPosPID4DCAz")) { + if (!nameStr.compare("kaonPosPID4Pt05")) { cut->AddCut(GetAnalysisCut("kaonPID_TPCnTOF")); cut->AddCut(GetAnalysisCut("posTrack")); - cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); - return cut; - } - - if (!nameStr.compare("kaonPosPID5")) { - cut->AddCut(GetAnalysisCut("kaonPIDnsigma")); - cut->AddCut(GetAnalysisCut("posTrack")); + cut->AddCut(GetAnalysisCut("muonLowPt")); return cut; } @@ -631,22 +685,10 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare("kaonNegPID4DCAz")) { + if (!nameStr.compare("kaonNegPID4Pt05")) { cut->AddCut(GetAnalysisCut("kaonPID_TPCnTOF")); cut->AddCut(GetAnalysisCut("negTrack")); - cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); - return cut; - } - - if (!nameStr.compare("kaonNegPID5")) { - cut->AddCut(GetAnalysisCut("kaonPIDnsigma")); - cut->AddCut(GetAnalysisCut("negTrack")); - return cut; - } - - if (!nameStr.compare("kaonPID4_PVC")) { - cut->AddCut(GetAnalysisCut("kaonPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("primaryVertexContributor")); + cut->AddCut(GetAnalysisCut("muonLowPt")); return cut; } @@ -680,13 +722,6 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare("pionPosPIDDCAz")) { - cut->AddCut(GetAnalysisCut("pionPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("posTrack")); - cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); - return cut; - } - if (!nameStr.compare("pionPosPID2")) { cut->AddCut(GetAnalysisCut("pionPIDnsigma")); cut->AddCut(GetAnalysisCut("posTrack")); @@ -699,70 +734,62 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare("pionNegPIDDCAz")) { - cut->AddCut(GetAnalysisCut("pionPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("negTrack")); - cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); - return cut; - } - if (!nameStr.compare("pionNegPID2")) { cut->AddCut(GetAnalysisCut("pionPIDnsigma")); cut->AddCut(GetAnalysisCut("negTrack")); return cut; } - if (!nameStr.compare("pionPID_PVC")) { - cut->AddCut(GetAnalysisCut("pionPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("primaryVertexContributor")); + if (!nameStr.compare("protonPosPID")) { + cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); + cut->AddCut(GetAnalysisCut("posTrack")); return cut; } - if (!nameStr.compare("pionPosPID2_PVC")) { - cut->AddCut(GetAnalysisCut("pionPIDnsigma")); - cut->AddCut(GetAnalysisCut("primaryVertexContributor")); + if (!nameStr.compare("protonPosPIDPt05")) { + cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); cut->AddCut(GetAnalysisCut("posTrack")); + cut->AddCut(GetAnalysisCut("muonLowPt")); return cut; } - if (!nameStr.compare("pionNegPID2_PVC")) { - cut->AddCut(GetAnalysisCut("pionPIDnsigma")); - cut->AddCut(GetAnalysisCut("primaryVertexContributor")); + if (!nameStr.compare("protonNegPID")) { + cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); cut->AddCut(GetAnalysisCut("negTrack")); return cut; } - if (!nameStr.compare("protonPosPID")) { + if (!nameStr.compare("protonNegPIDPt05")) { cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("posTrack")); + cut->AddCut(GetAnalysisCut("negTrack")); + cut->AddCut(GetAnalysisCut("muonLowPt")); return cut; } - if (!nameStr.compare("protonPosPIDDCAz")) { - cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("posTrack")); + if (!nameStr.compare("PrimaryTrack_DCAz")) { cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); return cut; } - if (!nameStr.compare("protonNegPID")) { - cut->AddCut(GetAnalysisCut("protonPID_TPCnTOF")); - cut->AddCut(GetAnalysisCut("negTrack")); + if (!nameStr.compare("posPrimaryTrack_DCAz")) { + cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); + cut->AddCut(GetAnalysisCut("posTrack")); return cut; } - if (!nameStr.compare("PrimaryTrack_DCAz")) { + if (!nameStr.compare("negPrimaryTrack_DCAz")) { cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); + cut->AddCut(GetAnalysisCut("negTrack")); return cut; } - if (!nameStr.compare("pionPosPrimaryNoPID")) { + if (!nameStr.compare("posStandardPrimaryTrackDCA")) { cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCA")); cut->AddCut(GetAnalysisCut("posTrack")); return cut; } - if (!nameStr.compare("pionNegPrimaryNoPID")) { + if (!nameStr.compare("negStandardPrimaryTrackDCA")) { cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCA")); cut->AddCut(GetAnalysisCut("negTrack")); return cut; @@ -778,6 +805,51 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("posTrackKaonRej")) { + cut->AddCut(GetAnalysisCut("posTrack")); + cut->AddCut(GetAnalysisCut("kaonRejNsigma")); + return cut; + } + + if (!nameStr.compare("negTrackKaonRej")) { + cut->AddCut(GetAnalysisCut("negTrack")); + cut->AddCut(GetAnalysisCut("kaonRejNsigma")); + return cut; + } + + if (!nameStr.compare("pTLow04")) { + cut->AddCut(GetAnalysisCut("pTLow04")); + return cut; + } + + if (!nameStr.compare("pTLow03")) { + cut->AddCut(GetAnalysisCut("pTLow03")); + return cut; + } + + if (!nameStr.compare("pTLow02")) { + cut->AddCut(GetAnalysisCut("pTLow02")); + return cut; + } + + if (!nameStr.compare("pTLow05DCAzHigh03")) { + cut->AddCut(GetAnalysisCut("muonLowPt")); + cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); + return cut; + } + + if (!nameStr.compare("pTLow04DCAzHigh03")) { + cut->AddCut(GetAnalysisCut("pTLow04")); + cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); + return cut; + } + + if (!nameStr.compare("pTLow03DCAzHigh03")) { + cut->AddCut(GetAnalysisCut("pTLow03")); + cut->AddCut(GetAnalysisCut("PrimaryTrack_DCAz")); + return cut; + } + // NOTE Below there are several TPC pid cuts used for studies of the Run3 TPC post PID calib. if (!nameStr.compare("Jpsi_TPCPost_calib_debug1")) { cut->AddCut(GetAnalysisCut("jpsi_trackCut_debug")); @@ -828,6 +900,12 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("Jpsi_TPCPost_calib_debug9")) { + cut->AddCut(GetAnalysisCut("jpsi_trackCut_debug4")); + cut->AddCut(GetAnalysisCut("electronPIDLooseSkimmed3")); + return cut; + } + if (!nameStr.compare("LMee_TPCPost_calib_debug1")) { cut->AddCut(GetAnalysisCut("lmee_trackCut_debug")); cut->AddCut(GetAnalysisCut("lmee_TPCPID_debug1")); @@ -863,6 +941,24 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + for (int iCut = 0; iCut < 10; iCut++) { + if (!nameStr.compare(Form("jpsiEleSel%d_ionut", iCut))) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQuality_ionut")); + cut->AddCut(GetAnalysisCut(Form("pidJpsiEle%d_ionut", iCut))); + return cut; + } + + if (!nameStr.compare(Form("jpsiEleSelTight%d_ionut", iCut))) { + cut->AddCut(GetAnalysisCut("kineJpsiEle_ionut")); + cut->AddCut(GetAnalysisCut("dcaCut1_ionut")); + cut->AddCut(GetAnalysisCut("trackQualityTight_ionut")); + cut->AddCut(GetAnalysisCut(Form("pidJpsiEle%d_ionut", iCut))); + return cut; + } + } + //--------------------------------------------------------------- // Cuts for the selection of legs from dalitz decay // @@ -1279,6 +1375,13 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare(Form("lmee%s_TrackCuts_Resol", vecTypetrack.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("openEtaSel")); // No pt cut and wider eta cut to produce resolution maps + cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrack.at(icase).Data()))); + cut->AddCut(GetAnalysisCut("PrimaryTrack_looseDCA")); + return cut; + } + // 4 cuts to separate pos & neg tracks in pos & neg eta range if (!nameStr.compare(Form("lmee_posTrack_posEta_selection%s", vecTypetrack.at(icase).Data()))) { cut->AddCut(GetAnalysisCut("posTrack")); @@ -1493,6 +1596,26 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + for (unsigned int i = 0; i < 30; i++) { + if (!nameStr.compare(Form("ElSelCutVar%s%i", vecPIDcase.at(icase).Data(), i))) { + cut->AddCut(GetAnalysisCut("lmeeStandardKine")); + cut->AddCut(GetAnalysisCut(Form("lmeeCutVarTrackCuts%i", i))); + cut->AddCut(GetAnalysisCut("PrimaryTrack_looseDCA")); + + AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); + cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TPCnsigma_cutVar%s%i", vecPIDcase.at(icase).Data(), i))); + + AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); + cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TOFnsigma_cutVar%s%i", vecPIDcase.at(icase).Data(), i))); + + AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); + cut_pid_OR->AddCut(cut_tpc_nSigma); + cut_pid_OR->AddCut(cut_tof_nSigma); + cut->AddCut(cut_pid_OR); + return cut; + } + } + for (size_t jcase = 0; jcase < vecTypetrackWithPID.size(); jcase++) { // All previous cut with TightGlobalTrackRun3 if (!nameStr.compare(Form("ITSTPC%s_TPCPIDalone%s_PbPb", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { @@ -1575,16 +1698,16 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare(Form("lmee%s_lowB_eNSigmaRun3%s_strongNSigE", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { - cut->AddCut(GetAnalysisCut("lmeeLowBKine")); + if (!nameStr.compare(Form("lmee%s_eNSigmaRun3%s_strongNSigE_rejBadTOF", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("lmeeStandardKine")); cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); - cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCAz")); // to reject looper using DCAz + cut->AddCut(GetAnalysisCut("PrimaryTrack_looseDCA")); AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); - cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TPCnsigma%s_strongNSigE", vecPIDcase.at(icase).Data()))); + cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TPCnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); - cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TOFnsigma%s_strongNSigE", vecPIDcase.at(icase).Data()))); + cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TOFnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); cut_pid_OR->AddCut(cut_tpc_nSigma); @@ -1593,34 +1716,24 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } - if (!nameStr.compare(Form("lmee%s_lowB_eNSigmaRun3%s_strongNSigE_rejBadTOF", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { - cut->AddCut(GetAnalysisCut("lmeeLowBKine")); + if (!nameStr.compare(Form("lmee%s_eNSigmaRun3%s_TOFreq", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("lmeeStandardKine")); cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); - cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCAz")); // to reject looper using DCAz - - AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); - cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TPCnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); - - AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); - cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TOFnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); - - AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); - cut_pid_OR->AddCut(cut_tpc_nSigma); - cut_pid_OR->AddCut(cut_tof_nSigma); - cut->AddCut(cut_pid_OR); + cut->AddCut(GetAnalysisCut("PrimaryTrack_looseDCA")); + cut->AddCut(GetAnalysisCut(Form("electronPID_TPC_TOFnsigma%s", vecPIDcase.at(icase).Data()))); return cut; } - if (!nameStr.compare(Form("lmee%s_eNSigmaRun3%s_strongNSigE_rejBadTOF", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { - cut->AddCut(GetAnalysisCut("lmeeStandardKine")); + if (!nameStr.compare(Form("lmee%s_eNSigmaRun3%s_Resol", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("openEtaSel")); // No pt cut and wider eta cut to produce resolution maps cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); cut->AddCut(GetAnalysisCut("PrimaryTrack_looseDCA")); AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); - cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TPCnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); + cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TPCnsigma%s", vecPIDcase.at(icase).Data()))); AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); - cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TOFnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); + cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_TOFnsigma%s", vecPIDcase.at(icase).Data()))); AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); cut_pid_OR->AddCut(cut_tpc_nSigma); @@ -1701,6 +1814,42 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare(Form("lmee%s_lowB_eNSigmaRun3%s_strongNSigE", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("lmeeLowBKine")); + cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); + cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCAz")); // to reject looper using DCAz + + AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); + cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TPCnsigma%s_strongNSigE", vecPIDcase.at(icase).Data()))); + + AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); + cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TOFnsigma%s_strongNSigE", vecPIDcase.at(icase).Data()))); + + AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); + cut_pid_OR->AddCut(cut_tpc_nSigma); + cut_pid_OR->AddCut(cut_tof_nSigma); + cut->AddCut(cut_pid_OR); + return cut; + } + + if (!nameStr.compare(Form("lmee%s_lowB_eNSigmaRun3%s_strongNSigE_rejBadTOF", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { + cut->AddCut(GetAnalysisCut("lmeeLowBKine")); + cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); + cut->AddCut(GetAnalysisCut("standardPrimaryTrackDCAz")); // to reject looper using DCAz + + AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); + cut_tpc_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TPCnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); + + AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); + cut_tof_nSigma->AddCut(GetAnalysisCut(Form("electronPID_lowB_TOFnsigma%s_strongNSigE_rejBadTOF", vecPIDcase.at(icase).Data()))); + + AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); + cut_pid_OR->AddCut(cut_tpc_nSigma); + cut_pid_OR->AddCut(cut_tof_nSigma); + cut->AddCut(cut_pid_OR); + return cut; + } + if (!nameStr.compare(Form("lmee%s_TOFreqRun3%s_strongNSigEPbPb_rejBadTOF_pt04", vecTypetrackWithPID.at(jcase).Data(), vecPIDcase.at(icase).Data()))) { cut->AddCut(GetAnalysisCut("lmeeStandardKine_pt04")); cut->AddCut(GetAnalysisCut(Form("lmeeQCTrackCuts%s", vecTypetrackWithPID.at(jcase).Data()))); @@ -2403,6 +2552,22 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("trackCut_compareDQEMframework")) { // cut setting to check least common factor between reduced data sets of PWGEM and PWGDQ + cut->AddCut(GetAnalysisCut("lmeeStandardKine")); + cut->AddCut(GetAnalysisCut("trackQuality_compareDQEMframework")); + cut->AddCut(GetAnalysisCut("trackDCA1cm")); + AnalysisCompositeCut* cut_tpc_nSigma = new AnalysisCompositeCut("pid_TPCnSigma", "pid_TPCnSigma", kTRUE); + cut_tpc_nSigma->AddCut(GetAnalysisCut("lmee_commonDQEM_PID_TPC")); + + AnalysisCompositeCut* cut_tof_nSigma = new AnalysisCompositeCut("pid_TOFnSigma", "pid_TOFnSigma", kTRUE); + cut_tof_nSigma->AddCut(GetAnalysisCut("lmee_commonDQEM_PID_TOF")); + + AnalysisCompositeCut* cut_pid_OR = new AnalysisCompositeCut("e_NSigma", "e_NSigma", kFALSE); + cut_pid_OR->AddCut(cut_tpc_nSigma); + cut_pid_OR->AddCut(cut_tof_nSigma); + return cut; + } + // ------------------------------------------------------------------------------------------------- // lmee pair cuts @@ -2440,6 +2605,23 @@ AnalysisCompositeCut* o2::aod::dqcuts::GetCompositeCut(const char* cutName) return cut; } + if (!nameStr.compare("matchedQualityCutsMFTeta")) { + cut->AddCut(GetAnalysisCut("matchedQualityCutsMFTeta")); + return cut; + } + + if (!nameStr.compare("muonQualityCuts5SigmaPDCA_Run3")) { + cut->AddCut(GetAnalysisCut("muonQualityCuts5SigmaPDCA_Run3")); + return cut; + } + + if (!nameStr.compare("muonLowPt5SigmaPDCA_Run3")) { + cut->AddCut(GetAnalysisCut("muonLowPt")); + cut->AddCut(GetAnalysisCut("muonQualityCuts5SigmaPDCA_Run3")); + cut->AddCut(GetAnalysisCut("MCHMID")); + return cut; + } + if (!nameStr.compare("muonLowPt10SigmaPDCA")) { cut->AddCut(GetAnalysisCut("muonLowPt")); cut->AddCut(GetAnalysisCut("muonQualityCuts10SigmaPDCA")); @@ -3111,6 +3293,10 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) std::string nameStr = cutName; // --------------------------------------------------------------- // Event cuts + if (!nameStr.compare("noEventCut")) { + return cut; + } + if (!nameStr.compare("eventNoTFBorder")) { cut->AddCut(VarManager::kIsNoTFBorder, 0.5, 1.5); return cut; @@ -3140,6 +3326,7 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) if (!nameStr.compare("eventStandardSel8WithITSROFRecomputedCut")) { 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::kIsNoITSROFBorderRecomputed, 0.5, 1.5); return cut; } @@ -3151,6 +3338,22 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("eventStandardSel8NoTFBNoITSROFB")) { + 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); + return cut; + } + + if (!nameStr.compare("eventStandardSel8NoTFBNoITSROFBrecomp")) { + 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::kIsNoITSROFBorderRecomputed, 0.5, 1.5); + return cut; + } + if (!nameStr.compare("eventStandardSel8PbPbQuality")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); cut->AddCut(VarManager::kIsSel8, 0.5, 1.5); @@ -3173,6 +3376,18 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("eventStandardSel8PbPbQualityFirmTrackOccupancy")) { + 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., 2000); + + return cut; + } if (!nameStr.compare("eventStandardSel8PbPbQualityLooseTrackOccupancy")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); @@ -3187,6 +3402,34 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("eventStandardSel8PbPbQualityTightTrackOccupancyCollInTime")) { + 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., 500); + cut->AddCut(VarManager::kNoCollInTimeRangeStandard, 0.5, 1.5); + + return cut; + } + + if (!nameStr.compare("eventStandardSel8PbPbQualityTightTrackOccupancyCollInTime")) { + 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., 1000); + cut->AddCut(VarManager::kNoCollInTimeRangeStandard, 0.5, 1.5); + + return cut; + } + std::vector vecOccupancies = {0., 250., 500., @@ -3311,6 +3554,26 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cutAorC; } + if (!nameStr.compare("eventUPCMode")) { + cut->AddCut(VarManager::kIsITSUPCMode, 0.5, 1.5); + return cut; + } + + if (!nameStr.compare("eventSingleGapACZDC_UPCMode")) { + AnalysisCompositeCut* cutA = new AnalysisCompositeCut("singleGapAZDC", "singleGapAZDC", kTRUE); + cutA->AddCut(GetAnalysisCut("eventSingleGapAZDC")); + cutA->AddCut(GetAnalysisCut("eventUPCMode")); + + AnalysisCompositeCut* cutC = new AnalysisCompositeCut("singleGapCZDC", "singleGapCZDC", kTRUE); + cutC->AddCut(GetAnalysisCut("eventSingleGapCZDC")); + cutC->AddCut(GetAnalysisCut("eventUPCMode")); + + AnalysisCompositeCut* cutAorC = new AnalysisCompositeCut("singleGapACZDC", "singleGapACZDC", kFALSE); + cutAorC->AddCut(cutA); + cutAorC->AddCut(cutC); + return cutAorC; + } + // Event cuts based on centrality if (!nameStr.compare("eventStandardNoINT7Cent090")) { cut->AddCut(VarManager::kVtxZ, -10.0, 10.0); @@ -3495,6 +3758,21 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("pTLow04")) { + cut->AddCut(VarManager::kPt, 0.4, 1000.0); + return cut; + } + + if (!nameStr.compare("pTLow03")) { + cut->AddCut(VarManager::kPt, 0.3, 1000.0); + return cut; + } + + if (!nameStr.compare("pTLow02")) { + cut->AddCut(VarManager::kPt, 0.2, 1000.0); + return cut; + } + // ----------------------------------------------- // Barrel track quality cuts @@ -3584,6 +3862,17 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("jpsi_trackCut_debug4")) { + cut->AddCut(VarManager::kEta, -0.9, 0.9); + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCncls, 90., 159); + cut->AddCut(VarManager::kITSncls, 2.5, 7.5); + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTrackDCAxy, -1, 1); + cut->AddCut(VarManager::kTrackDCAz, -3.0, 3.0); + return cut; + } + if (!nameStr.compare("lmee_trackCut_debug")) { cut->AddCut(VarManager::kEta, -0.9, 0.9); cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); @@ -3601,6 +3890,17 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("trackQuality_compareDQEMframework")) { // cut setting to check least common factor between reduced data sets of PWGEM and PWGDQ + cut->AddCut(VarManager::kIsSPDfirst, 0.5, 1.5); + cut->AddCut(VarManager::kITSchi2, 0.0, 5.0); + cut->AddCut(VarManager::kITSncls, 4.5, 7.5); + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCnclsCR, 80.0, 161.); + cut->AddCut(VarManager::kTPCnCRoverFindCls, 0.8, 1e+10); + cut->AddCut(VarManager::kTPCncls, 90.0, 170.); + return cut; + } + if ((!nameStr.compare("TightGlobalTrackRun3")) || (!nameStr.compare("lmeeQCTrackCuts"))) { cut->AddCut(VarManager::kIsSPDfirst, 0.5, 1.5); cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); @@ -3734,6 +4034,25 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + // List of 30 variations in ITS and TPC parameters + std::vector cutVar_ITSchi2 = {6., 6., 5., 4., 4., 6., 6., 5., 4., 5., 4., 5., 6., 5., 6., 5., 6., 5., 5., 4., 6., 4., 6., 5., 6., 4., 4., 6., 4., 5.}; + std::vector cutVar_TPCchi2 = {5., 5., 4., 3., 5., 4., 5., 3., 5., 4., 5., 3., 3., 5., 4., 5., 3., 5., 5., 5., 3., 5., 5., 4., 3., 4., 5., 5., 5., 3.}; + std::vector cutVar_ITSnCl = {4.5, 5.5, 5.5, 4.5, 6.5, 4.5, 4.5, 4.5, 4.5, 5.5, 4.5, 5.5, 5.5, 5.5, 5.5, 4.5, 5.5, 6.5, 5.5, 4.5, 4.5, 5.5, 5.5, 5.5, 6.5, 5.5, 4.5, 4.5, 6.5, 6.5}; + std::vector cutVar_TPCnClsCR = {90., 80., 80., 80., 90., 80., 70., 90., 70., 80., 70., 90., 90., 70., 90., 90., 70., 80., 90., 80., 80., 90., 70., 70., 70., 80., 90., 70., 70., 80.}; + std::vector cutVar_TPCnCls = {80., 100., 80., 90., 90., 80., 80., 80., 80., 90., 100., 100., 80., 80., 80., 80., 100., 90., 100., 90., 90., 100., 100., 80., 100., 90., 90., 100., 90., 90.}; + + for (unsigned int i = 0; i < cutVar_ITSchi2.size(); i++) { + if (!nameStr.compare(Form("lmeeCutVarTrackCuts%i", i))) { + cut->AddCut(VarManager::kIsSPDfirst, 0.5, 1.5); + cut->AddCut(VarManager::kITSchi2, 0.0, cutVar_ITSchi2.at(i)); + cut->AddCut(VarManager::kTPCchi2, 0.0, cutVar_TPCchi2.at(i)); + cut->AddCut(VarManager::kITSncls, cutVar_ITSnCl.at(i), 7.5); + cut->AddCut(VarManager::kTPCnclsCR, cutVar_TPCnClsCR.at(i), 161.); + cut->AddCut(VarManager::kTPCncls, cutVar_TPCnCls.at(i), 170.); + return cut; + } + } + if (!nameStr.compare("electronStandardQualityForO2MCdebug")) { cut->AddCut(VarManager::kIsSPDany, 0.5, 1.5); cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); @@ -3755,6 +4074,13 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("electronStandardQualityForO2MCdebug4")) { + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTPCchi2, 0.0, 4.0); + cut->AddCut(VarManager::kTPCncls, 70, 161.); + return cut; + } + if (!nameStr.compare("electronStandardQualityITSOnly")) { cut->AddCut(VarManager::kIsSPDany, 0.5, 1.5); cut->AddCut(VarManager::kITSchi2, 0.0, 5.0); @@ -3823,12 +4149,106 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("trackDCA1cm")) { // cut setting to check least common factor between reduced data sets of PWGEM and PWGDQ + cut->AddCut(VarManager::kTrackDCAxy, -1.0, 1.0); + cut->AddCut(VarManager::kTrackDCAz, -1.0, 1.0); + return cut; + } + if (!nameStr.compare("dcaCut1_ionut")) { cut->AddCut(VarManager::kTrackDCAxy, -0.5, 0.5); cut->AddCut(VarManager::kTrackDCAz, -0.5, 0.5); return cut; } + if (!nameStr.compare("trackQuality_ionut")) { + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTPCncls, 70, 161); + cut->AddCut(VarManager::kITSchi2, 0.0, 5.0); + cut->AddCut(VarManager::kTPCchi2, 0.0, 2.0); + return cut; + } + + if (!nameStr.compare("trackQualityTight_ionut")) { + cut->AddCut(VarManager::kIsITSibAny, 0.5, 1.5); + cut->AddCut(VarManager::kTPCncls, 100, 161); + cut->AddCut(VarManager::kITSchi2, 0.0, 3.0); + cut->AddCut(VarManager::kTPCchi2, 0.0, 2.0); + cut->AddCut(VarManager::kITSncls, 5.0, 8.0); + return cut; + } + + if (!nameStr.compare("kineJpsiEle_ionut")) { + cut->AddCut(VarManager::kP, 1.0, 15.0); + cut->AddCut(VarManager::kEta, -0.9, 0.9); + return cut; + } + + if (!nameStr.compare("pidJpsiEle0_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -2.0, 4.0, false, VarManager::kPin, 1.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0, false, VarManager::kPin, 4.0, 150.0); + cut->AddCut(VarManager::kTPCnSigmaEl, 98.1, 98.11, false, VarManager::kPin, 0.0, 1.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle1_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.5, 4.0, false, VarManager::kPin, 1.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0, false, VarManager::kPin, 4.0, 150.0); + cut->AddCut(VarManager::kTPCnSigmaEl, 98.1, 98.11, false, VarManager::kPin, 0.0, 1.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle2_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle3_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -0.5, 4.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle4_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, 0.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle5_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, 0.5, 4.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle6_ionut")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0); + cut->AddCut(VarManager::kTOFnSigmaEl, -1.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaPr, -4.0, 4.0, true); + return cut; + } + + if (!nameStr.compare("pidJpsiEle7_ionut")) { + cut->AddCut(VarManager::kTOFnSigmaEl, -3.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaEl, -1.0, 4.0); + return cut; + } + + if (!nameStr.compare("pidJpsiEle8_ionut")) { + cut->AddCut(VarManager::kTOFnSigmaEl, -3.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaEl, -1.5, 4.0); + return cut; + } + + if (!nameStr.compare("pidJpsiEle9_ionut")) { + cut->AddCut(VarManager::kTOFnSigmaEl, -3.0, 4.0); + cut->AddCut(VarManager::kTPCnSigmaEl, -2.0, 4.0); + return cut; + } + if (!nameStr.compare("standardPrimaryTrackDCAz")) { cut->AddCut(VarManager::kTrackDCAxy, -3.0, 3.0); cut->AddCut(VarManager::kTrackDCAz, -1.0, 1.0); @@ -3964,6 +4384,14 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) cut->AddCut(VarManager::kTPCnSigmaPr, 1.5, 999, false, VarManager::kPin, 3.0, 999); return cut; } + + if (!nameStr.compare("electronPIDLooseSkimmed3")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 3.0); + cut->AddCut(VarManager::kTPCnSigmaPi, 3.0, 999, false, VarManager::kPin, 0, 3.0); + cut->AddCut(VarManager::kTPCnSigmaPr, 3.0, 999, false, VarManager::kPin, 0, 3.0); + return cut; + } + if (!nameStr.compare("jpsi_TPCPID_debug6")) { cut->AddCut(VarManager::kTPCnSigmaEl, -2.0, 3.0); cut->AddCut(VarManager::kTPCnSigmaPi, 3.0, 999); @@ -4087,6 +4515,21 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("lmee_commonDQEM_PID_TPC")) { // cut setting to check least common factor between reduced data sets of PWGEM and PWGDQ + cut->AddCut(VarManager::kTPCnSigmaEl, -2.5, 3., false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi, -1e12, 3.5, true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa, -3., 3., true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr, -3., 3., true, VarManager::kPin, 0.0, 1e+10, false); + return cut; + } + + if (!nameStr.compare("lmee_commonDQEM_PID_TOF")) { // cut setting to check least common factor between reduced data sets of PWGEM and PWGDQ + cut->AddCut(VarManager::kTPCnSigmaEl, -2.5, 3., false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi, -3., 3.5, true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTOFnSigmaEl, -3., 3., false, VarManager::kPin, 0.3, 1e+10, false); + return cut; + } + std::vector vecPIDcase; vecPIDcase.emplace_back(""); // without post calibration vecPIDcase.emplace_back("_Corr"); // case of using post calibrated PID spectra @@ -4297,6 +4740,38 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + // List of nSigma values for lower and upper edge of El, Pi, Ka, Pr, TPC PID selections/rejection + std::vector cutVar_TPCnSigmaEl_low = {-4., -4., -4., -2., -3., -2., -3., -4., -2., -4., -3., -3., -3., -4., -3., -3., -4., -3., -4., -4., -3., -4., -3., -3., -2., -4., -4., -3., -4., -2}; + std::vector cutVar_TPCnSigmaEl_up = {2., 3., 2., 2., 2., 2., 2., 4., 2., 2., 4., 3., 3., 2., 4., 2., 2., 4., 3., 4., 2., 4., 2., 3., 2., 3., 4., 2., 3., 2}; + std::vector cutVar_TPCnSigmaPi_low = {-3., -2., -3., -4., -4., -3., -4., -2., -2., -2., -3., -3., -2., -2., -4., -3., -3., -2., -3., -2., -4., -2., -4., -4., -3., -3., -3., -2., -4., -4}; + std::vector cutVar_TPCnSigmaPi_up = {3., 3., 4., 4., 3., 2., 4., 4., 3., 4., 4., 3., 4., 4., 3., 2., 4., 2., 4., 2., 3., 4., 2., 2., 3., 2., 3., 4., 2., 4}; + std::vector cutVar_TPCnSigmaKa_low = {-4., -2., -2., -2., -4., -3., -2., -4., -3., -3., -4., -2., -3., -3., -4., -2., -4., -2., -3., -4., -4., -2., -2., -3., -2., -2., -3., -3., -2., -4}; + std::vector cutVar_TPCnSigmaKa_up = {4., 3., 2., 3., 4., 3., 4., 4., 4., 4., 4., 4., 4., 4., 2., 4., 4., 2., 2., 4., 3., 3., 2., 4., 2., 4., 3., 3., 3., 3}; + std::vector cutVar_TPCnSigmaPr_low = {-4., -2., -2., -3., -4., -4., -3., -2., -2., -4., -4., -2., -3., -4., -2., -3., -3., -2., -3., -3., -2., -2., -2., -2., -2., -3., -2., -3., -3., -3}; + std::vector cutVar_TPCnSigmaPr_up = {2., 2., 3., 2., 3., 3., 3., 2., 4., 3., 3., 4., 4., 3., 4., 4., 3., 4., 2., 3., 4., 4., 3., 4., 3., 2., 3., 3., 2., 3}; + + for (unsigned int i = 0; i < cutVar_TPCnSigmaEl_low.size(); i++) { + if (!nameStr.compare(Form("electronPID_TPCnsigma_cutVar%s%i", vecPIDcase.at(icase).Data(), i))) { + if (icase == 0) { + cut->AddCut(VarManager::kTPCnSigmaEl, cutVar_TPCnSigmaEl_low.at(i), cutVar_TPCnSigmaEl_up.at(i), false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi, cutVar_TPCnSigmaPi_low.at(i), cutVar_TPCnSigmaPi_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa, cutVar_TPCnSigmaKa_low.at(i), cutVar_TPCnSigmaKa_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr, cutVar_TPCnSigmaPr_low.at(i), cutVar_TPCnSigmaPr_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + } else if (icase == 1) { + cut->AddCut(VarManager::kTPCnSigmaEl_Corr, cutVar_TPCnSigmaEl_low.at(i), cutVar_TPCnSigmaEl_up.at(i), false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi_Corr, cutVar_TPCnSigmaPi_low.at(i), cutVar_TPCnSigmaPi_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa, cutVar_TPCnSigmaKa_low.at(i), cutVar_TPCnSigmaKa_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr_Corr, cutVar_TPCnSigmaPr_low.at(i), cutVar_TPCnSigmaPr_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + } else if (icase == 2) { + cut->AddCut(VarManager::kTPCnSigmaEl_Corr, cutVar_TPCnSigmaEl_low.at(i), cutVar_TPCnSigmaEl_up.at(i), false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi_Corr, cutVar_TPCnSigmaPi_low.at(i), cutVar_TPCnSigmaPi_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa_Corr, cutVar_TPCnSigmaKa_low.at(i), cutVar_TPCnSigmaKa_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr_Corr, cutVar_TPCnSigmaPr_low.at(i), cutVar_TPCnSigmaPr_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + } + return cut; + } + } + if (!nameStr.compare(Form("lmee_pp_502TeV_TPC%s", vecPIDcase.at(icase).Data()))) { if (icase == 0) { cut->AddCut(VarManager::kTPCnSigmaEl, -3., 3., false, VarManager::kPin, 0.0, 1e+10, false); @@ -4426,6 +4901,13 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("electronPIDnsigmaSkewed_2")) { + cut->AddCut(VarManager::kTPCnSigmaEl, -0.0, 3.0); + cut->AddCut(VarManager::kTPCnSigmaPr, 3.5, 3000.0); + cut->AddCut(VarManager::kTPCnSigmaPi, 3.5, 3000.0); + return cut; + } + if (!nameStr.compare("electronPIDPrKaPiRej")) { cut->AddCut(VarManager::kTPCnSigmaEl, -3.0, 3.0); cut->AddCut(VarManager::kTPCnSigmaPr, -3.0, 3.0, true); @@ -4465,6 +4947,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("kaonRejNsigma")) { + cut->AddCut(VarManager::kTPCnSigmaKa, -3.0, 3.0, true); + return cut; + } + if (!nameStr.compare("kaonPIDnsigma2")) { cut->AddCut(VarManager::kTPCnSigmaKa, -2.0, 2.0); return cut; @@ -4585,6 +5072,11 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("tof_electron_sigma_2")) { + cut->AddCut(VarManager::kTOFnSigmaEl, -3., 3.); + return cut; + } + if (!nameStr.compare("tof_electron_loose")) { cut->AddCut(VarManager::kTOFbeta, 0.95, 1.05, false, VarManager::kPin, 0.0, 1e+10, false); return cut; @@ -4644,6 +5136,46 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + // List of nSigma values for lower and upper edge of TPC: El, Pi and TOF: El PID selections/rejection + std::vector cutVar_TPCnSigmaEl_low = {-4., -4., -4., -2., -3., -2., -3., -4., -2., -4., -3., -3., -3., -4., -3., -3., -4., -3., -4., -4., -3., -4., -3., -3., -2., -4., -4., -3., -4., -2}; + std::vector cutVar_TPCnSigmaEl_up = {2., 3., 2., 2., 2., 2., 2., 4., 2., 2., 4., 3., 3., 2., 4., 2., 2., 4., 3., 4., 2., 4., 2., 3., 2., 3., 4., 2., 3., 2}; + std::vector cutVar_TPCnSigmaPi_low = {-3., -2., -3., -4., -4., -3., -4., -2., -2., -2., -3., -3., -2., -2., -4., -3., -3., -2., -3., -2., -4., -2., -4., -4., -3., -3., -3., -2., -4., -4}; + std::vector cutVar_TPCnSigmaPi_up = {3., 3., 4., 4., 3., 2., 4., 4., 3., 4., 4., 3., 4., 4., 3., 2., 4., 2., 4., 2., 3., 4., 2., 2., 3., 2., 3., 4., 2., 4}; + std::vector cutVar_TOFnSigmaEl_low = {-4., -2., -4., -4., -3., -2., -4., -4., -4., -2., -2., -4., -3., -3., -4., -4., -4., -2., -4., -4., -2., -2., -3., -4., -4., -2., -4., -2., -3., -3}; + std::vector cutVar_TOFnSigmaEl_up = {4., 2., 4., 2., 4., 3., 2., 3., 3., 3., 4., 3., 2., 3., 4., 3., 3., 3., 4., 4., 2., 2., 2., 3., 3., 3., 2., 3., 2., 4}; + + for (unsigned int i = 0; i < cutVar_TOFnSigmaEl_low.size(); i++) { + if (!nameStr.compare(Form("electronPID_TOFnsigma_cutVar%s%i", vecPIDcase.at(icase).Data(), i))) { + if (icase == 0) { + cut->AddCut(VarManager::kTPCnSigmaEl, cutVar_TPCnSigmaEl_low.at(i), cutVar_TPCnSigmaEl_up.at(i), false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi, cutVar_TPCnSigmaPi_low.at(i), cutVar_TPCnSigmaPi_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTOFnSigmaEl, cutVar_TOFnSigmaEl_low.at(i), cutVar_TOFnSigmaEl_up.at(i), false, VarManager::kPin, 0.3, 1e+10, false); + } else if (icase == 1 || icase == 2) { + cut->AddCut(VarManager::kTPCnSigmaEl_Corr, cutVar_TPCnSigmaEl_low.at(i), cutVar_TPCnSigmaEl_up.at(i), false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi_Corr, cutVar_TPCnSigmaPi_low.at(i), cutVar_TPCnSigmaPi_up.at(i), true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTOFnSigmaEl, cutVar_TOFnSigmaEl_low.at(i), cutVar_TOFnSigmaEl_up.at(i), false, VarManager::kPin, 0.3, 1e+10, false); + } + return cut; + } + } + + if (!nameStr.compare(Form("electronPID_TPC_TOFnsigma%s", vecPIDcase.at(icase).Data()))) { + if (icase == 0) { // previously known as electronPID_TOFnsigma_tight + cut->AddCut(VarManager::kTPCnSigmaEl, -3., 2., false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi, -3., 3.5, true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa, -3., 4., true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr, -3., 4., true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTOFnSigmaEl, -3., 3., false, VarManager::kPin, 0.0, 1e+10, false); + } else if (icase == 1 || icase == 2) { + cut->AddCut(VarManager::kTPCnSigmaEl_Corr, -3., 2., false, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPi_Corr, -3., 3.5, true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaKa, -3., 4., true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTPCnSigmaPr_Corr, -3., 4., true, VarManager::kPin, 0.0, 1e+10, false); + cut->AddCut(VarManager::kTOFnSigmaEl, -3., 3., false, VarManager::kPin, 0.0, 1e+10, false); + } + return cut; + } + if (!nameStr.compare(Form("electronPID_lowB_TOFnsigma%s_strongNSigE", vecPIDcase.at(icase).Data()))) { if (icase == 0) { cut->AddCut(VarManager::kTPCnSigmaEl, -2., 2., false, VarManager::kPin, 0.0, 1e+10, false); @@ -4838,6 +5370,16 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("muonQualityCuts5SigmaPDCA_Run3")) { + cut->AddCut(VarManager::kEta, -4.0, -2.5); + cut->AddCut(VarManager::kMuonRAtAbsorberEnd, 17.6, 89.5); + cut->AddCut(VarManager::kMuonPDca, 0.0, 500.0, false, VarManager::kMuonRAtAbsorberEnd, 17.6, 26.5); + cut->AddCut(VarManager::kMuonPDca, 0.0, 335.0, false, VarManager::kMuonRAtAbsorberEnd, 26.5, 89.5); + cut->AddCut(VarManager::kMuonChi2, 0.0, 1e6); + cut->AddCut(VarManager::kMuonChi2MatchMCHMID, 0.0, 1e6); // matching MCH-MID + return cut; + } + if (!nameStr.compare("muonQualityCuts10SigmaPDCA")) { cut->AddCut(VarManager::kEta, -4.0, -2.5); cut->AddCut(VarManager::kMuonRAtAbsorberEnd, 17.6, 89.5); @@ -4859,6 +5401,17 @@ AnalysisCut* o2::aod::dqcuts::GetAnalysisCut(const char* cutName) return cut; } + if (!nameStr.compare("matchedQualityCutsMFTeta")) { + cut->AddCut(VarManager::kEta, -3.6, -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); + cut->AddCut(VarManager::kMuonChi2, 0.0, 1e6); + cut->AddCut(VarManager::kMuonChi2MatchMCHMID, 0.0, 1e6); // matching MCH-MID + cut->AddCut(VarManager::kMuonChi2MatchMCHMFT, 0.0, 1e6); // matching MFT-MCH + return cut; + } + if (!nameStr.compare("muonQualityCutsMatchingOnly")) { cut->AddCut(VarManager::kEta, -4.0, -2.5); cut->AddCut(VarManager::kMuonChi2, 0.0, 1e6); diff --git a/PWGDQ/Core/HistogramManager.cxx b/PWGDQ/Core/HistogramManager.cxx index 146baeb939a..19956da4496 100644 --- a/PWGDQ/Core/HistogramManager.cxx +++ b/PWGDQ/Core/HistogramManager.cxx @@ -121,7 +121,7 @@ void HistogramManager::AddHistogram(const char* histClass, const char* hname, co int nYbins, double ymin, double ymax, int varY, int nZbins, double zmin, double zmax, int varZ, const char* xLabels, const char* yLabels, const char* zLabels, - int varT, int varW, bool isdouble) + int varT, int varW, bool isdouble, bool isFillLabelx) { // // add a histogram (this function can define TH1F,TH2F,TH3F,TProfile,TProfile2D, and TProfile3D) @@ -179,7 +179,8 @@ void HistogramManager::AddHistogram(const char* histClass, const char* hname, co varVector.push_back(varX); // variables on each axis varVector.push_back(varY); varVector.push_back(varZ); - varVector.push_back(varT); // variable used for profiling in case of TProfile3D + varVector.push_back(varT); // variable used for profiling in case of TProfile3D + varVector.push_back(isFillLabelx ? 1 : 0); // whether to fill with the x-axis labels std::list varList = fVariablesMap[histClass]; varList.push_back(varVector); fVariablesMap[histClass] = varList; @@ -330,7 +331,7 @@ void HistogramManager::AddHistogram(const char* histClass, const char* hname, co int nYbins, double* ybins, int varY, int nZbins, double* zbins, int varZ, const char* xLabels, const char* yLabels, const char* zLabels, - int varT, int varW, bool isdouble) + int varT, int varW, bool isdouble, bool isFillLabelx) { // // add a histogram @@ -388,7 +389,8 @@ void HistogramManager::AddHistogram(const char* histClass, const char* hname, co varVector.push_back(varX); // variables on each axis varVector.push_back(varY); varVector.push_back(varZ); - varVector.push_back(varT); // variable used for profiling in case of TProfile3D + varVector.push_back(varT); // variable used for profiling in case of TProfile3D + varVector.push_back(isFillLabelx ? 1 : 0); // whether to fill with the x-axis labels std::list varList = fVariablesMap[histClass]; varList.push_back(varVector); fVariablesMap[histClass] = varList; @@ -754,6 +756,7 @@ void HistogramManager::FillHistClass(const char* className, Float_t* values) bool isTHn; int dimension = 0; bool isSparse = kFALSE; + bool isFillLabelx = kFALSE; // TODO: At the moment, maximum 20 dimensions are foreseen for the THn histograms. We should make this more dynamic // But maybe its better to have it like to avoid dynamically allocating this array in the histogram loop double fillValues[20] = {0.0}; @@ -783,6 +786,7 @@ void HistogramManager::FillHistClass(const char* className, Float_t* values) varY = varIter->at(4); varZ = varIter->at(5); varT = varIter->at(6); + isFillLabelx = (varIter->at(7) == 1 ? true : false); } if (!isTHn) { @@ -790,15 +794,31 @@ void HistogramManager::FillHistClass(const char* className, Float_t* values) case 1: if (isProfile) { if (varW > kNothing) { - (reinterpret_cast(h))->Fill(values[varX], values[varY], values[varW]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), values[varY], values[varW]); + } else { + (reinterpret_cast(h))->Fill(values[varX], values[varY], values[varW]); + } } else { - (reinterpret_cast(h))->Fill(values[varX], values[varY]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), values[varY]); + } else { + (reinterpret_cast(h))->Fill(values[varX], values[varY]); + } } } else { if (varW > kNothing) { - (reinterpret_cast(h))->Fill(values[varX], values[varW]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), values[varW]); + } else { + (reinterpret_cast(h))->Fill(values[varX], values[varW]); + } } else { - (reinterpret_cast(h))->Fill(values[varX]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), 1.); + } else { + (reinterpret_cast(h))->Fill(values[varX]); + } } } break; @@ -811,9 +831,17 @@ void HistogramManager::FillHistClass(const char* className, Float_t* values) } } else { if (varW > kNothing) { - (reinterpret_cast(h))->Fill(values[varX], values[varY], values[varW]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), values[varY], values[varW]); + } else { + (reinterpret_cast(h))->Fill(values[varX], values[varY], values[varW]); + } } else { - (reinterpret_cast(h))->Fill(values[varX], values[varY]); + if (isFillLabelx) { + (reinterpret_cast(h))->Fill(Form("%d", static_cast(values[varX])), values[varY], 1.); + } else { + (reinterpret_cast(h))->Fill(values[varX], values[varY]); + } } } break; @@ -852,7 +880,7 @@ void HistogramManager::FillHistClass(const char* className, Float_t* values) } } } // end else - } // end loop over histograms + } // end loop over histograms } //____________________________________________________________________________________ diff --git a/PWGDQ/Core/HistogramManager.h b/PWGDQ/Core/HistogramManager.h index 273cbfd0bd6..4b1393b2eb7 100644 --- a/PWGDQ/Core/HistogramManager.h +++ b/PWGDQ/Core/HistogramManager.h @@ -67,14 +67,14 @@ class HistogramManager : public TNamed int nYbins = 0, double ymin = 0, double ymax = 0, int varY = -1, int nZbins = 0, double zmin = 0, double zmax = 0, int varZ = -1, const char* xLabels = "", const char* yLabels = "", const char* zLabels = "", - int varT = -1, int varW = -1, bool isdouble = false); + int varT = -1, int varW = -1, bool isdouble = false, bool isFillLabelx = false); // Similar to the above function, with the difference that the user can specify non-equidistant binning void AddHistogram(const char* histClass, const char* name, const char* title, bool isProfile, int nXbins, double* xbins, int varX, int nYbins = 0, double* ybins = nullptr, int varY = -1, int nZbins = 0, double* zbins = nullptr, int varZ = -1, const char* xLabels = "", const char* yLabels = "", const char* zLabels = "", - int varT = -1, int varW = -1, bool isdouble = false); + int varT = -1, int varW = -1, bool isdouble = false, bool isFillLabelx = false); // Create a THn histogram (either THnF or THnSparse) with equidistant binning void AddHistogram(const char* histClass, const char* name, const char* title, int nDimensions, int* vars, int* nBins, double* xmin, double* xmax, diff --git a/PWGDQ/Core/HistogramsLibrary.cxx b/PWGDQ/Core/HistogramsLibrary.cxx index 0dc742c0d8e..bad53e0fd1b 100644 --- a/PWGDQ/Core/HistogramsLibrary.cxx +++ b/PWGDQ/Core/HistogramsLibrary.cxx @@ -30,7 +30,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h if (!groupStr.CompareTo("event")) { if (!subGroupStr.Contains("generator")) { hm->AddHistogram(histClass, "VtxZ", "Vtx Z", false, 60, -15.0, 15.0, VarManager::kVtxZ); - hm->AddHistogram(histClass, "VtxZ_Run", "Vtx Z", true, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, 60, -15.0, 15.0, VarManager::kVtxZ, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); + hm->AddHistogram(histClass, "VtxZ_Run", "Vtx Z", true, 1, -0.5, 0.5, VarManager::kRunNo, 60, -15.0, 15.0, VarManager::kVtxZ, 1, 0, 1, VarManager::kNothing, "", "", "", VarManager::kNothing, VarManager::kNothing, false, true); hm->AddHistogram(histClass, "BC", "Event per BC", false, 3564, 0.0, 3564.0, VarManager::kBCOrbit); } if (subGroupStr.Contains("trigger")) { @@ -54,16 +54,17 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } if (subGroupStr.Contains("time")) { hm->AddHistogram(histClass, "CollTime", "Coll. time wrt BC", false, 100, 0.0, 100.0, VarManager::kCollisionTime); - hm->AddHistogram(histClass, "CollTimeRes", "Coll. time resolution", false, 100, 0.0, 100.0, VarManager::kCollisionTimeRes); + hm->AddHistogram(histClass, "CollTimeRes", "Coll. time resolution", false, 100, 0.0, 200.0, VarManager::kCollisionTimeRes); hm->AddHistogram(histClass, "CollTime_VtxZ", "Coll. time wrt BC vs vtx-z", false, 50, -15.0, 15., VarManager::kVtxZ, 100, 0.0, 100.0, VarManager::kCollisionTime); hm->AddHistogram(histClass, "CollTimeRes_VtxZ", "Coll. time resolution ", false, 50, -15.0, 15., VarManager::kVtxZ, 100, 0.0, 100.0, VarManager::kCollisionTimeRes); - hm->AddHistogram(histClass, "CollTimeRes_MultTPC", "Coll. time resolution ", false, 50, 0.0, 500., VarManager::kMultTPC, 100, 0.0, 100.0, VarManager::kCollisionTimeRes); - hm->AddHistogram(histClass, "CollTimeRes_MultPV", "Coll. time resolution ", false, 50, 0.0, 500., VarManager::kVtxNcontribReal, 100, 0.0, 100.0, VarManager::kCollisionTimeRes); + hm->AddHistogram(histClass, "CollTimeRes_MultTPC", "Coll. time resolution ", false, 50, 0.0, 50000., VarManager::kMultTPC, 100, 0.0, 200.0, VarManager::kCollisionTimeRes); + hm->AddHistogram(histClass, "CollTimeRes_MultPV", "Coll. time resolution ", false, 100, 0.0, 4000., VarManager::kVtxNcontribReal, 100, 0.0, 200.0, VarManager::kCollisionTimeRes); + hm->AddHistogram(histClass, "TimeFromSOR", "Time since SOR", false, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR); } if (subGroupStr.Contains("vtx")) { hm->AddHistogram(histClass, "VtxX", "Vtx X", false, 200, -0.1, 0.1, VarManager::kVtxX); hm->AddHistogram(histClass, "VtxY", "Vtx Y", false, 200, -0.1, 0.1, VarManager::kVtxY); - hm->AddHistogram(histClass, "VtxYVtxX", "Vtx Y vs Vtx X", false, 100, -0.1, 0.1, VarManager::kVtxX, 100, -0.1, 0.1, VarManager::kVtxY); + hm->AddHistogram(histClass, "VtxYVtxX", "Vtx Y vs Vtx X", false, 200, -0.06, 0.0, VarManager::kVtxX, 200, -0.03, 0.03, VarManager::kVtxY); } if (subGroupStr.Contains("vtxpp")) { hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 100.0, VarManager::kVtxNcontrib); @@ -72,44 +73,64 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 20000.0, VarManager::kVtxNcontrib); } if (subGroupStr.Contains("cent")) { - hm->AddHistogram(histClass, "CentV0M", "CentV0M", false, 100, 0., 100., VarManager::kCentVZERO); - hm->AddHistogram(histClass, "CentV0M_vtxZ", "CentV0M vs Vtx Z", false, 60, -15.0, 15.0, VarManager::kVtxZ, 20, 0., 100., VarManager::kCentVZERO); hm->AddHistogram(histClass, "CentFT0C", "CentFT0C", false, 100, 0., 100., VarManager::kCentFT0C); hm->AddHistogram(histClass, "CentFT0C_vtxZ", "CentFT0C vs Vtx Z", false, 60, -15.0, 15.0, VarManager::kVtxZ, 20, 0., 100., VarManager::kCentFT0C); - hm->AddHistogram(histClass, "CentFT0C_MultTPC", "CentFT0C vs MultTPC", false, 100, 0., 100., VarManager::kCentFT0C, 50, 0., 50., VarManager::kMultTPC); - hm->AddHistogram(histClass, "CentFT0C_Run", "Cent FT0C", true, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, 100, 0., 100., VarManager::kCentFT0C, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); + hm->AddHistogram(histClass, "CentFT0C_MultTPC", "CentFT0C vs MultTPC", false, 100, 0., 100., VarManager::kCentFT0C, 100, 0., 50000., VarManager::kMultTPC); + hm->AddHistogram(histClass, "CentFT0C_Run", "Cent FT0C", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, 0., 100., VarManager::kCentFT0C, 1, 0, 1, VarManager::kNothing, "", "", "", VarManager::kNothing, VarManager::kNothing, false, true); } if (subGroupStr.Contains("mult")) { if (subGroupStr.Contains("pp")) { - hm->AddHistogram(histClass, "MultTPC", "MultTPC", false, 300, 0.0, 500.0, VarManager::kMultTPC); - hm->AddHistogram(histClass, "MultFV0A", "MultFV0A", false, 300, 0.0, 500.0, VarManager::kMultFV0A); - hm->AddHistogram(histClass, "MultFT0A", "MultFT0A", false, 300, 0.0, 200.0, VarManager::kMultFT0A); + 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, 300, 0.0, 50.0, VarManager::kMultFDDC); - hm->AddHistogram(histClass, "MultTracklets", "MultTracklets", false, 100, 0.0, 250.0, VarManager::kMultTracklets); - hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 100.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "MultFDDC", "MultFDDC", false, 50, 0.0, 50.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, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 100.0, VarManager::kVtxNcontrib); 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); hm->AddHistogram(histClass, "MultFT0A_MultFT0C", "MultFT0A vs MultFT0C", false, 100, 0, 200.0, VarManager::kMultFT0A, 100, 0, 300.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "MultITSWithPV", "MultITSWithPV", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasITS); + hm->AddHistogram(histClass, "MultTPCWithPV", "MultTPCWithPV", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasTPC); + hm->AddHistogram(histClass, "MultITSTPCWithPV", "MultITSTPCWithPV", false, 150, 0.0, 150.0, VarManager::kMultNTracksITSTPC); + hm->AddHistogram(histClass, "MultITSOnly", "MultITSOnly", false, 150, 0.0, 150.0, VarManager::kMultNTracksITSOnly); + hm->AddHistogram(histClass, "MultITSWithPV_MultTPCWithPV", "MultITSWithPV_MultTPCWithPV", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasITS, 150, 0.0, 150.0, VarManager::kMultNTracksHasTPC); + hm->AddHistogram(histClass, "MultITSWithPV_MultITSTPCWithPV", "MultITSWithPV_MultTPCWithPV", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasITS, 150, 0.0, 150.0, VarManager::kMultNTracksITSTPC); + hm->AddHistogram(histClass, "MultITSWithPV_MultFT0C", "MultITSWithPV_MultFT0C", false, 150, 0.0, 150.0, VarManager::kMultNTracksHasITS, 250, 0.0, 2500.0, VarManager::kMultFT0C); + 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); } else { - hm->AddHistogram(histClass, "MultTPC", "MultTPC", false, 100, 0.0, 25000.0, VarManager::kMultTPC); - hm->AddHistogram(histClass, "MultFV0A", "MultFV0A", false, 100, 0.0, 25000.0, VarManager::kMultFV0A); - hm->AddHistogram(histClass, "MultFT0A", "MultFT0A", false, 100, 0.0, 25000.0, VarManager::kMultFT0A); - hm->AddHistogram(histClass, "MultFT0C", "MultFT0C", false, 100, 0.0, 25000.0, VarManager::kMultFT0C); - hm->AddHistogram(histClass, "MultFDDA", "MultFDDA", false, 100, 0.0, 25000.0, VarManager::kMultFDDA); - hm->AddHistogram(histClass, "MultFDDC", "MultFDDC", false, 100, 0.0, 25000.0, VarManager::kMultFDDC); - hm->AddHistogram(histClass, "MultZNA", "MultZNA", false, 100, 0.0, 25000.0, VarManager::kMultZNA); - hm->AddHistogram(histClass, "MultZNC", "MultZNC", false, 100, 0.0, 25000.0, VarManager::kMultZNC); + 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); + hm->AddHistogram(histClass, "MultFV0A", "MultFV0A", false, 200, 0.0, 300000.0, VarManager::kMultFV0A); + hm->AddHistogram(histClass, "MultFT0A", "MultFT0A", false, 200, 0.0, 300000.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "MultFT0C", "MultFT0C", false, 200, 0.0, 100000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "MultFDDA", "MultFDDA", false, 100, 0.0, 100000.0, VarManager::kMultFDDA); + hm->AddHistogram(histClass, "MultFDDC", "MultFDDC", false, 100, 0.0, 100000.0, VarManager::kMultFDDC); + hm->AddHistogram(histClass, "MultZNA", "MultZNA", false, 400, 0.0, 400.0, VarManager::kMultZNA); + hm->AddHistogram(histClass, "MultZNC", "MultZNC", false, 400, 0.0, 400.0, VarManager::kMultZNC); + hm->AddHistogram(histClass, "MultZNA_ZNC", "MultZNA vs ZNC", false, 400, 0.0, 400.0, VarManager::kMultZNA, 400, 0.0, 400.0, VarManager::kMultZNC); hm->AddHistogram(histClass, "MultTracklets", "MultTracklets", false, 100, 0.0, 25000.0, VarManager::kMultTracklets); - hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 10000.0, VarManager::kVtxNcontribReal); - hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 10000.0, VarManager::kVtxNcontrib); - hm->AddHistogram(histClass, "MultTPC_MultFV0A", "MultTPC vs MultFV0A", false, 100, 0, 25000.0, VarManager::kMultTPC, 100, 0, 25000.0, VarManager::kMultFV0A); - hm->AddHistogram(histClass, "MultTPC_MultFT0A", "MultTPC vs MultFT0A", false, 100, 0, 25000.0, VarManager::kMultTPC, 100, 0, 25000.0, VarManager::kMultFT0A); - hm->AddHistogram(histClass, "MultTPC_MultFT0C", "MultTPC vs MultFT0C", false, 100, 0, 25000.0, VarManager::kMultTPC, 100, 0, 25000.0, VarManager::kMultFT0C); - hm->AddHistogram(histClass, "MultFT0A_MultFT0C", "MultFT0A vs MultFT0C", false, 100, 0, 25000.0, VarManager::kMultFT0A, 100, 0, 25000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "VtxNContribReal", "Vtx n contributors (real)", false, 100, 0.0, 5000.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "VtxNContribReal_vsTimeSOR", "VtxNContribReal vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, 0.0, 5000.0, VarManager::kVtxNcontribReal); + hm->AddHistogram(histClass, "VtxNContrib", "Vtx n contributors", false, 100, 0.0, 20000.0, VarManager::kVtxNcontrib); + hm->AddHistogram(histClass, "MultTPC_MultFV0A", "MultTPC vs MultFV0A", false, 100, 0, 50000.0, VarManager::kMultTPC, 100, 0, 300000.0, VarManager::kMultFV0A); + hm->AddHistogram(histClass, "MultTPC_MultFT0A", "MultTPC vs MultFT0A", false, 100, 0, 50000.0, VarManager::kMultTPC, 100, 0, 300000.0, VarManager::kMultFT0A); + hm->AddHistogram(histClass, "MultTPC_MultFT0C", "MultTPC vs MultFT0C", false, 100, 0, 50000.0, VarManager::kMultTPC, 100, 0, 100000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "MultFT0A_MultFT0C", "MultFT0A vs MultFT0C", false, 100, 0, 100000.0, VarManager::kMultFT0A, 100, 0, 300000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "VtxNContribReal_MultTPC", "Vtx n contributors (real) vs mult TPC", false, 100, 0.0, 5000.0, VarManager::kVtxNcontribReal, 200, 0.0, 50000.0, VarManager::kMultTPC); + hm->AddHistogram(histClass, "VtxNContribReal_ZNA", "Vtx n contributors (real) vs ZNA", false, 100, 0.0, 5000.0, VarManager::kVtxNcontribReal, 200, 0.0, 400.0, VarManager::kMultZNA); + hm->AddHistogram(histClass, "VtxNContribReal_ZNC", "Vtx n contributors (real) vs ZNC", false, 100, 0.0, 5000.0, VarManager::kVtxNcontribReal, 200, 0.0, 400.0, VarManager::kMultZNC); + hm->AddHistogram(histClass, "MultZNA_FT0C", "MultZNA vs FT0C", false, 400, 0.0, 400.0, VarManager::kMultZNA, 200, 0.0, 100000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "MultZNC_FT0C", "MultZNC vs FT0C", false, 400, 0.0, 400.0, VarManager::kMultZNC, 200, 0.0, 100000.0, VarManager::kMultFT0C); + hm->AddHistogram(histClass, "TPCpileupZA", "TPC pileup Z, A-side", false, 200, -50.0, 50.0, VarManager::kNTPCpileupZA); + hm->AddHistogram(histClass, "TPCpileupZC", "TPC pileup Z, C-side", false, 200, -50.0, 50.0, VarManager::kNTPCpileupZC); + hm->AddHistogram(histClass, "TPCpileupNcontribA", "TPC pileup n-contributors, A-side", false, 300, 0.0, 3000.0, VarManager::kNTPCpileupContribA); + hm->AddHistogram(histClass, "TPCpileupNcontribC", "TPC pileup n-contributors, C-side", false, 300, 0.0, 3000.0, VarManager::kNTPCpileupContribC); } } if (subGroupStr.Contains("ftmulpbpb")) { @@ -123,7 +144,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MultFT0A_VtxNContrib", "MultFT0A vs VtxNContrib", false, 100, 0, 180000.0, VarManager::kMultFT0A, 100, 0, 10000.0, VarManager::kVtxNcontrib); } if (subGroupStr.Contains("occupancy")) { - hm->AddHistogram(histClass, "ITStrackOccupancy", "ITStrackOccupancy", false, 300, 0.0, 30000.0, VarManager::kTrackOccupancyInTimeRange); + hm->AddHistogram(histClass, "ITStrackOccupancy", "ITStrackOccupancy", false, 200, 0.0, 20000.0, VarManager::kTrackOccupancyInTimeRange); } 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); @@ -141,6 +162,9 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MCVtxX_VtxY", "Vtx X vs Vtx Y", false, 200, 15.0, 15.0, VarManager::kMCVtxZ, 200, -0.2, 0.2, VarManager::kMCVtxY); hm->AddHistogram(histClass, "MCImpPar", "MC impact param", false, 20, 0.0, 20.0, VarManager::kMCEventImpParam); } + if (subGroupStr.Contains("subgen")) { + hm->AddHistogram(histClass, "SubGenID", "SubGenerator ID", false, 11, -0.5, 10.5, VarManager::kMCEventSubGeneratorId); + } if (subGroupStr.Contains("qvector")) { int varZNA[3] = {VarManager::kQ1ZNAX, VarManager::kQ1ZNAY, VarManager::kCentFT0C}; int varZNC[3] = {VarManager::kQ1ZNCX, VarManager::kQ1ZNCY, VarManager::kCentFT0C}; @@ -154,6 +178,19 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "IntercalibZNA_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -50.0, 50.0, VarManager::KIntercalibZNA); hm->AddHistogram(histClass, "IntercalibZNC_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 500, -50.0, 50.0, VarManager::KIntercalibZNC); + hm->AddHistogram(histClass, "EnergyCommonZNA", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyCommonZNA); + hm->AddHistogram(histClass, "EnergyCommonZNC", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyCommonZNC); + + hm->AddHistogram(histClass, "EnergyZNA1", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNA1); + hm->AddHistogram(histClass, "EnergyZNA2", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNA2); + hm->AddHistogram(histClass, "EnergyZNA3", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNA3); + hm->AddHistogram(histClass, "EnergyZNA4", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNA4); + + hm->AddHistogram(histClass, "EnergyZNC1", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNC1); + hm->AddHistogram(histClass, "EnergyZNC2", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNC2); + hm->AddHistogram(histClass, "EnergyZNC3", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNC3); + hm->AddHistogram(histClass, "EnergyZNC4", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 2000, 0, 2000, VarManager::kEnergyZNC4); + 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, "Q2X0B", "", false, 500, -10.0, 10.0, VarManager::kQ2X0B); @@ -201,9 +238,18 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Psi2A", "", false, 100, -2.0, 2.0, VarManager::kPsi2A); 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, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -2.0, 2.0, VarManager::kPsi2A); - hm->AddHistogram(histClass, "Psi2B_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -2.0, 2.0, VarManager::kPsi2B); - hm->AddHistogram(histClass, "Psi2C_CentFT0C", "", false, 18, 0.0, 90.0, VarManager::kCentFT0C, 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); + hm->AddHistogram(histClass, "Psi2B_CentFT0C", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 100, -2.0, 2.0, VarManager::kPsi2B); + hm->AddHistogram(histClass, "Psi2C_CentFT0C", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 100, -2.0, 2.0, VarManager::kPsi2C); + hm->AddHistogram(histClass, "centrFT0C_Corr2REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR2REF, VarManager::kM11REF); + hm->AddHistogram(histClass, "centrFT0C_Corr2REFetagap_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR2REFetagap, VarManager::kM11REFetagap); + hm->AddHistogram(histClass, "centrFT0C_Corr4REF_ev", "", true, 100, 0.0, 100.0, VarManager::kCentFT0C, 250, -1.0, 1.0, VarManager::kCORR4REF, VarManager::kM1111REF); + hm->AddHistogram(histClass, "Run2_centrFT0C_Corr2REF_ev", "", true, 9, std::array{0.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0}.data(), VarManager::kCentFT0C, 250, std::array{-1.0, 1.0}.data(), VarManager::kCORR2REF, 0, nullptr, -1, "", "", "", VarManager::kCORR2REF, VarManager::kM11REF); + hm->AddHistogram(histClass, "Run2_centrFT0C_Corr2REFetagap_ev", "", true, 9, std::array{0.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0}.data(), VarManager::kCentFT0C, 250, std::array{-1.0, 1.0}.data(), VarManager::kCORR2REFetagap, 0, nullptr, -1, "", "", "", VarManager::kCORR2REFetagap, VarManager::kM11REFetagap); + hm->AddHistogram(histClass, "Run2_centrFT0C_Corr4REF_ev", "", true, 9, std::array{0.0, 5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0}.data(), VarManager::kCentFT0C, 250, std::array{-1.0, 1.0}.data(), VarManager::kCORR4REF, 0, nullptr, -1, "", "", "", VarManager::kCORR4REF, VarManager::kM1111REF); + hm->AddHistogram(histClass, "Corr2REFerrorsetagap", "", 4, std::array{VarManager::kCentFT0C, VarManager::kCORR2REFetagapw, VarManager::kCORR2REFetagapsquaredw, VarManager::kM11REFetagap}.data(), std::array{100, 5000, 5000, 5000}.data(), std::array{0.0, -5000.0, 0.0, 0.0}.data(), std::array{100.0, 5000.0, 100.0, 300000.0}.data(), nullptr, -1, true, true); + hm->AddHistogram(histClass, "Corr2REFerrors", "", 4, std::array{VarManager::kCentFT0C, VarManager::kCORR2REFw, VarManager::kCORR2REFsquaredw, VarManager::kM11REF}.data(), std::array{100, 10000, 10000, 10000}.data(), std::array{0.0, -40000.0, 0.0, 0.0}.data(), std::array{100.0, 40000.0, 100.0, 6000000.0}.data(), nullptr, -1, true, true); + hm->AddHistogram(histClass, "Corr4REFerrors", "", 4, std::array{VarManager::kCentFT0C, VarManager::kCORR4REFw, VarManager::kCORR4REFsquaredw, VarManager::kM1111REF}.data(), std::array{100, 100000, 100000, 100000}.data(), std::array{0.0, -30000000.0, 0.0, 0.0}.data(), std::array{100.0, 90000000.0, 40000.0, 9000000000000.0}.data(), nullptr, -1, true, true); if (subGroupStr.Contains("cross")) { hm->AddHistogram(histClass, "Q1ZNACXX_CentFT0C", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 4000, -2, 2, VarManager::kQ1ZNACXX); hm->AddHistogram(histClass, "Q1ZNACYY_CentFT0C", "", false, 90, 0.0, 90.0, VarManager::kCentFT0C, 4000, -2, 2, VarManager::kQ1ZNACYY); @@ -272,6 +318,8 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "IsDoubleGap", "Is double gap", false, 2, -0.5, 1.5, VarManager::kIsDoubleGap); hm->AddHistogram(histClass, "IsSingleGapA", "Is single gap on side A", false, 2, -0.5, 1.5, VarManager::kIsSingleGapA); hm->AddHistogram(histClass, "IsSingleGapC", "Is single gap on side C", false, 2, -0.5, 1.5, VarManager::kIsSingleGapC); + hm->AddHistogram(histClass, "IsITSUPCMode", "UPC settings used", false, 2, -0.5, 1.5, VarManager::kIsITSUPCMode); + hm->AddHistogram(histClass, "IsITSUPCMode_IsSingleGap", "UPC settings used vs Is single gap", false, 2, -0.5, 1.5, VarManager::kIsITSUPCMode, 2, -0.5, 1.5, VarManager::kIsSingleGap); } if (subGroupStr.Contains("zdc")) { hm->AddHistogram(histClass, "energyCommonZNA_energyCommonZNC", "Common ZNA energy vs common ZNC energy", false, 1050, -10.0, 200.0, VarManager::kEnergyCommonZNA, 1050, -10.0, 200.0, VarManager::kEnergyCommonZNC); @@ -336,6 +384,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "IsITSrefit", "", false, 2, -0.5, 1.5, VarManager::kIsITSrefit); hm->AddHistogram(histClass, "IsSPDany", "", false, 2, -0.5, 1.5, VarManager::kIsSPDany); hm->AddHistogram(histClass, "IsSPDfirst", "", false, 2, -0.5, 1.5, VarManager::kIsSPDfirst); + hm->AddHistogram(histClass, "ITSncls_vsTimeFromSOR", "Number of cluster in ITS vs time from SOR", true, 10000, 0.0, 1000, VarManager::kTimeFromSOR, 8, -0.5, 7.5, VarManager::kITSncls); if (subGroupStr.Contains("cluster")) { hm->AddHistogram(histClass, "ITSClusterMap", "", false, 128, -0.5, 127.5, VarManager::kITSClusterMap); hm->AddHistogram(histClass, "ITSClustermap_vs_pin", "ITSClustermap vs pin", false, 200, 0.0, 20.0, VarManager::kPin, 128, -0.5, 127.5, VarManager::kITSClusterMap); @@ -366,10 +415,9 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } if (subGroupStr.Contains("tpc")) { hm->AddHistogram(histClass, "TPCncls", "Number of cluster in TPC", false, 160, -0.5, 159.5, VarManager::kTPCncls); + hm->AddHistogram(histClass, "TPCncls_vsTimeFromSOR", "Number of cluster in TPC vs time from SOR", true, 10000, 0.0, 1000., VarManager::kTimeFromSOR, 160, -0.5, 159.5, VarManager::kTPCncls); hm->AddHistogram(histClass, "TPCncls_Phi", "Number of cluster in TPC vs #varphi", true, 720, 0.0, TMath::TwoPi(), VarManager::kPhi, 10, 0.0, 200.0, VarManager::kTPCncls); hm->AddHistogram(histClass, "TPCncls_PhiPt", "Number of cluster in TPC vs p_{T} and #varphi", true, 20, 0.0, 10.0, VarManager::kPt, 720, 0.0, TMath::TwoPi(), VarManager::kPhi, 10, 0.0, 200.0, VarManager::kTPCncls); - hm->AddHistogram(histClass, "TPCncls_Run", "Number of cluster in TPC", true, (VarManager::GetNRuns() > 0 ? VarManager::GetNRuns() : 1), 0.5, 0.5 + VarManager::GetNRuns(), VarManager::kRunId, - 10, -0.5, 159.5, VarManager::kTPCncls, 10, 0., 1., VarManager::kNothing, VarManager::GetRunStr().Data()); hm->AddHistogram(histClass, "TPCnclsCR", "Number of crossed rows in TPC", false, 160, -0.5, 159.5, VarManager::kTPCnclsCR); hm->AddHistogram(histClass, "TPCncls_TPCnclsCR", "Number of TPC cluster vs Number of crossed rows in TPC", false, 160, -0.5, 159.5, VarManager::kTPCncls, 160, -0.5, 159.5, VarManager::kTPCnclsCR); hm->AddHistogram(histClass, "IsTPCrefit", "", false, 2, -0.5, 1.5, VarManager::kIsTPCrefit); @@ -417,24 +465,42 @@ 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); - 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); + 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, "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, "TPCnSigPi_pIN", "TPC n-#sigma(#pi) vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_timeFromSOR", "TPC n-#sigma(#pi) vs time from SOR", true, 1000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_eta", "TPC n-#sigma(#pi) vs #eta", false, 20, -1.0, 1.0, VarManager::kEta, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_etaPin_prof", " vs (#eta,p_{IN}), --s--", true, 20, -1.0, 1.0, VarManager::kEta, 20, 0.0, 10.0, VarManager::kPin, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_etaCent_prof", " vs (#eta,cent), --s--", true, 20, -1.0, 1.0, VarManager::kEta, 20, 0.0, 100.0, VarManager::kCentFT0C, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_etaContrib_prof", " vs (#eta,n-contrib real), --s--", true, 20, -1.0, 1.0, VarManager::kEta, 20, 0.0, 4000.0, VarManager::kVtxNcontribReal, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_etaZA_prof", " vs (#eta,ZA), --s--", true, 20, -1.0, 1.0, VarManager::kEta, 30, -15.0, 15.0, VarManager::kNTPCpileupZA, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_etaNZA_prof", " vs (#eta,NZA), --s--", true, 20, -1.0, 1.0, VarManager::kEta, 30, 0.0, 1500.0, VarManager::kNTPCpileupContribA, 10, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_centFT0C", "TPC n-#sigma(#pi) vs centrality", false, 20, 0.0, 100.0, VarManager::kCentFT0C, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_vtxContrib", "TPC n-#sigma(#pi) vs vtx. contrib real", false, 50, 0.0, 4000.0, VarManager::kVtxNcontribReal, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_occupancy", "TPC n-#sigma(#pi) vs occupancy", false, 200, 0., 20000., VarManager::kTrackOccupancyInTimeRange, 100, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_pileupZA", "TPC n-#sigma(#pi) vs pileup ZA", false, 60, -15.0, 15.0, VarManager::kNTPCpileupZA, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_pileupZC", "TPC n-#sigma(#pi) vs pileup ZC", false, 60, -15.0, 15.0, VarManager::kNTPCpileupZC, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_pileupNA", "TPC n-#sigma(#pi) vs n.pileup contrib A", false, 60, 0.0, 1500.0, VarManager::kNTPCpileupContribA, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); + hm->AddHistogram(histClass, "TPCnSigPi_pileupNC", "TPC n-#sigma(#pi) vs n.pileup contrib C", false, 60, 0.0, 1500.0, VarManager::kNTPCpileupContribC, 200, -5.0, 5.0, VarManager::kTPCnSigmaPi); hm->AddHistogram(histClass, "TPCnSigKa_pIN", "TPC n-#sigma(K) vs pIN", false, 100, 0.0, 10.0, VarManager::kPin, 100, -5.0, 5.0, VarManager::kTPCnSigmaKa); 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, "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); - } - hm->AddHistogram(histClass, "TPCnSigEl_Corr_Eta", "TPC n-#sigma(e) Corr. vs Eta", false, 20, -1.0, 1.0, VarManager::kEta, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl_Corr); - hm->AddHistogram(histClass, "TPCnSigPi_Corr_Eta", "TPC n-#sigma(#pi) Corr. vs Eta", false, 20, -1.0, 1.0, VarManager::kEta, 100, -5.0, 5.0, VarManager::kTPCnSigmaPi_Corr); - hm->AddHistogram(histClass, "TPCnSigKa_Corr_Eta", "TPC n-#sigma(K) Corr. vs Eta", false, 20, -1.0, 1.0, VarManager::kEta, 100, -5.0, 5.0, VarManager::kTPCnSigmaKa_Corr); - hm->AddHistogram(histClass, "TPCnSigPr_Corr_Eta", "TPC n-#sigma(p) Corr. vs Eta", false, 20, -1.0, 1.0, VarManager::kEta, 100, -5.0, 5.0, VarManager::kTPCnSigmaPr_Corr); + 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")) { + 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("postcalib")) { const int kNvarsPID = 4; @@ -443,8 +509,8 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h for (int i = 0; i <= kTPCnsigmaNbins; ++i) tpcNsigmaBinLims[i] = -7.0 + 0.2 * i; - const int kPinEleNbins = 18; - double pinEleBinLims[kPinEleNbins + 1] = {0.1, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 15.0}; + const int kPinEleNbins = 20; + double pinEleBinLims[kPinEleNbins + 1] = {0.1, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0, 12.0, 16.0, 20.0}; const int kEtaNbins = 9; double etaBinLimsI[kEtaNbins + 1] = {-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9}; @@ -603,41 +669,30 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } } if (subGroupStr.Contains("runbyrun")) { - hm->AddHistogram(histClass, "TPCncls_run", "Number of cluster in TPC vs RunNumber", false, (VarManager::GetNRuns() > 0 ? VarManager::GetNRuns() : 1), -0.5, -0.5 + VarManager::GetNRuns(), VarManager::kRunIndex, - 160, -0.5, 159.5, VarManager::kTPCncls, 10, 0., 1., VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCdEdx_run", "TPCdEdx vs RunNumber", false, (VarManager::GetNRuns() > 0 ? VarManager::GetNRuns() : 1), -0.5, -0.5 + VarManager::GetNRuns(), VarManager::kRunIndex, - 300, 0., 300., VarManager::kTPCsignal, 10, 0., 1., VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCchi2_run", "TPCchi2 vs RunNumber", false, (VarManager::GetNRuns() > 0 ? VarManager::GetNRuns() : 1), -0.5, -0.5 + VarManager::GetNRuns(), VarManager::kRunIndex, - 100, 0., 10., VarManager::kTPCchi2, 10, 0., 1., VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "Pt_Run", "p_{T} distribution", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 2000, 0.0, 20.0, VarManager::kPt, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "ITSncls_Run", "Number of cluster in ITS", false, 100, -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 8, -0.5, 7.5, VarManager::kITSncls, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "ITSchi2_Run", "ITS chi2", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 100, 0.0, 50.0, VarManager::kITSchi2, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCncls_Run", "Number of cluster in TPC", false, 100, -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 160, -0.5, 159.5, VarManager::kTPCncls, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCchi2_Run", "TPC chi2", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 100, 0.0, 10.0, VarManager::kTPCchi2, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCdedx_Run", "TPC dE/dx", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 200, 0.0, 200., VarManager::kTPCsignal, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "TPCnSigEle_Run", "TPC n-#sigma(e)", false, 100, -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 100, -5.0, 5.0, VarManager::kTPCnSigmaEl, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "DCAxy_Run", "DCA_{xy}", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 400, -2.0, 2.0, VarManager::kTrackDCAxy, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); - hm->AddHistogram(histClass, "DCAz_Run", "DCA_{z}", false, VarManager::GetDummyNRuns(), -0.5 + VarManager::GetDummyFirst(), 0.5 + VarManager::GetDummyLast(), VarManager::kRunNo, - 800, -4.0, 4.0, VarManager::kTrackDCAz, 1, 0, 1, VarManager::kNothing, VarManager::GetRunStr().Data()); + hm->AddHistogram(histClass, "TPCncls_Run", "Number of cluster in TPC vs RunNumber", true, 1, -0.5, 0.5, VarManager::kRunNo, 160, -0.5, 159.5, VarManager::kTPCncls, 1, 0., 1., VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "TPCdEdx_Run", "TPCdEdx vs RunNumber", true, 1, -0.5, 0.5, VarManager::kRunNo, 300, 0., 300., VarManager::kTPCsignal, 1, 0., 1., VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "TPCchi2_Run", "TPCchi2 vs RunNumber", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, 0., 10., VarManager::kTPCchi2, 1, 0., 1., VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "Pt_Run", "p_{T} distribution", true, 1, -0.5, 0.5, VarManager::kRunNo, 2000, 0.0, 20.0, VarManager::kPt, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "ITSncls_Run", "Number of cluster in ITS", true, 1, -0.5, 0.5, VarManager::kRunNo, 8, -0.5, 7.5, VarManager::kITSncls, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "ITSchi2_Run", "ITS chi2", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, 0.0, 50.0, VarManager::kITSchi2, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "TPCnSigEle_Run", "TPC n-#sigma(e)", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, -5.0, 5.0, VarManager::kTPCnSigmaEl, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "DCAxy_Run", "DCA_{xy}", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, -1.0, 1.0, VarManager::kTrackDCAxy, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); + hm->AddHistogram(histClass, "DCAz_Run", "DCA_{z}", true, 1, -0.5, 0.5, VarManager::kRunNo, 100, -1.0, 1.0, VarManager::kTrackDCAz, 1, 0, 1, VarManager::kNothing, "", "", "", -1, -1, false, true); } if (subGroupStr.Contains("dca")) { hm->AddHistogram(histClass, "DCAxy", "DCA_{xy}", false, 400, -2.0, 2.0, VarManager::kTrackDCAxy); + hm->AddHistogram(histClass, "DCAxy_vsTimeFromSOR", "DCA_{xy} vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, -2.0, 2.0, VarManager::kTrackDCAxy); hm->AddHistogram(histClass, "DCAz", "DCA_{z}", false, 800, -4.0, 4.0, VarManager::kTrackDCAz); + hm->AddHistogram(histClass, "DCAz_vsTimeFromSOR", "DCA_{z} vs time from SOR", true, 10000, 0.0, 1000.0, VarManager::kTimeFromSOR, 10, -2.0, 2.0, VarManager::kTrackDCAz); hm->AddHistogram(histClass, "DCAsigXY", "DCA_{XY} [#sigma]", false, 200, -20.0, 20.0, VarManager::kTrackDCAsigXY); hm->AddHistogram(histClass, "DCAsigZ", "DCA_{Z} [#sigma]", false, 200, -20.0, 20.0, VarManager::kTrackDCAsigZ); + hm->AddHistogram(histClass, "DCAxy_DCAz", "DCA_{xy} vs DCA_{z}", false, 200, -4.0, 4.0, VarManager::kTrackDCAxy, 200, -4.0, 4.0, VarManager::kTrackDCAz); + hm->AddHistogram(histClass, "DCAsigXY_DCAsigZ", "DCA_{XY} [#sigma] vs DCA_{Z} [#sigma]", false, 200, -20.0, 20.0, VarManager::kTrackDCAsigXY, 200, -20.0, 20.0, VarManager::kTrackDCAsigZ); if (subGroupStr.Contains("pt")) { hm->AddHistogram(histClass, "Pt_DCAxy", "p_{T} vs DCA_{xy}", false, 200, 0.0, 20.0, VarManager::kPt, 400, -2.0, 2.0, VarManager::kTrackDCAxy); hm->AddHistogram(histClass, "Pt_DCAz", "p_{T} vs DCA_{z}", false, 200, 0.0, 20.0, VarManager::kPt, 800, -4.0, 4.0, VarManager::kTrackDCAz); - hm->AddHistogram(histClass, "Pt_DCAsigXY", "p_{T} vs DCA_{XY} [#sigma]", false, 200, 0.0, 20.0, VarManager::kPt, 100, -10.0, 10.0, VarManager::kTrackDCAsigXY); // JJ:edit - hm->AddHistogram(histClass, "Pt_DCAsigZ", "p_{T} vs DCA_{Z} [#sigma]", false, 200, 0.0, 20.0, VarManager::kPt, 100, -10.0, 10.0, VarManager::kTrackDCAsigZ); + hm->AddHistogram(histClass, "Pt_DCAsigXY", "p_{T} vs DCA_{XY} [#sigma]", false, 200, 0.0, 20.0, VarManager::kPt, 200, -20.0, 20.0, VarManager::kTrackDCAsigXY); // JJ:edit + hm->AddHistogram(histClass, "Pt_DCAsigZ", "p_{T} vs DCA_{Z} [#sigma]", false, 200, 0.0, 20.0, VarManager::kPt, 200, -20.0, 20.0, VarManager::kTrackDCAsigZ); hm->AddHistogram(histClass, "Pt_DCAresXY", "p_{T} vs #DeltaDCA_{XY}", false, 200, 0.0, 10.0, VarManager::kPt, 100, -0.03, 0.03, VarManager::kTrackDCAresXY); hm->AddHistogram(histClass, "Pt_DCAresZ", "p_{T} vs #DeltaDCA_{Z}", false, 200, 0.0, 10.0, VarManager::kPt, 100, -0.03, 0.03, VarManager::kTrackDCAresZ); } @@ -680,8 +735,13 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MuonDcaX_vs_eta", "", false, 2000, -20.0, 20.0, VarManager::kMuonDCAx, 500, -5.0, 5.0, VarManager::kEta); hm->AddHistogram(histClass, "MuonDcaY_vs_eta", "", false, 2000, -20.0, 20.0, VarManager::kMuonDCAy, 500, -5.0, 5.0, VarManager::kEta); } else { + hm->AddHistogram(histClass, "Pt", "p_{T} distribution", false, 2000, 0.0, 20.0, VarManager::kPt); + hm->AddHistogram(histClass, "Eta", "#eta distribution", false, 500, -5.0, 5.0, VarManager::kEta); + hm->AddHistogram(histClass, "Phi", "#varphi distribution", false, 500, -2. * TMath::Pi(), 2. * TMath::Pi(), VarManager::kPhi); hm->AddHistogram(histClass, "AmbiguityInBunch", "", false, 10, 0.0, 10., VarManager::kMuonNAssocsInBunch); hm->AddHistogram(histClass, "AmbiguityOutOfBunch", "", false, 10, 0.0, 10., VarManager::kMuonNAssocsOutOfBunch); + hm->AddHistogram(histClass, "AmbiguityInBunch_pt", "in bunch collision ambiguity vs p_{T}", false, 50, 0.0, 10.0, VarManager::kPt, 10, 0., 10., VarManager::kMuonNAssocsInBunch); + hm->AddHistogram(histClass, "AmbiguityOutOfBunch_pt", "out of bunch collision ambiguity vs p_{T}", false, 50, 0.0, 10.0, VarManager::kPt, 10, 0., 10., VarManager::kMuonNAssocsOutOfBunch); } } @@ -690,8 +750,6 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "pdca_vs_p", "pDCA vs p", false, 2000, 0.0, 20.0, VarManager::kP, 200, 0.0, 1000., VarManager::kMuonPDca); hm->AddHistogram(histClass, "pdca_vs_pt", "pDCA vs pt", false, 2000, 0.0, 20.0, VarManager::kPt, 200, 0.0, 1000., VarManager::kMuonPDca); hm->AddHistogram(histClass, "pdca_vs_Rabs", "pDCA vs R_{abs}", false, 100, 0., 200., VarManager::kMuonRAtAbsorberEnd, 200, 0.0, 1000., VarManager::kMuonPDca); - hm->AddHistogram(histClass, "pdca_vs_Rabs_vs_p", "pDCA vs R_{abs} vs p", false, 2000, 0.0, 20.0, VarManager::kP, 100, 0., 200., VarManager::kMuonRAtAbsorberEnd, 200, 0.0, 1000., VarManager::kMuonPDca); - hm->AddHistogram(histClass, "pdca_vs_Rabs_vs_pt", "pDCA vs R_{abs} vs pt", false, 2000, 0.0, 20.0, VarManager::kPt, 100, 0., 200., VarManager::kMuonRAtAbsorberEnd, 200, 0.0, 1000., VarManager::kMuonPDca); } if (subGroupStr.Contains("mft-pid")) { hm->AddHistogram(histClass, "hMftTrackEtaVsPt", "", false, 100, -5.f, -2.f, VarManager::kEta, 100, 0.f, 20.f, VarManager::kPt); @@ -764,15 +822,28 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Mass_HighRange", "", false, 375, 0.0, 15.0, VarManager::kMass); hm->AddHistogram(histClass, "Pt", "", false, 2000, 0.0, 20., VarManager::kPt); hm->AddHistogram(histClass, "Mass_Pt", "", false, 125, 0.0, 5.0, VarManager::kMass, 40, 0.0, 20.0, VarManager::kPt); + double massBins[76]; + for (int i = 0; i < 76; i++) { + massBins[i] = 1.5 + i * 0.04; + } + double ptBins[70]; + for (int i = 0; i <= 50; i++) { + ptBins[i] = i * 0.01; + } + for (int i = 1; i <= 19; i++) { + ptBins[50 + i] = 0.5 + i * 0.5; + } + 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, "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, 500, 0.0, 5.0, VarManager::kMass, 20, 0.0, 100.0, VarManager::kCentFT0C); - hm->AddHistogram(histClass, "Pt_CentFT0C", "", false, 500, 0.0, 1.5, VarManager::kPt, 20, 0.0, 100.0, VarManager::kCentFT0C); - hm->AddHistogram(histClass, "Mass_Pt_CentFT0C", "", false, 500, 0.0, 5.0, VarManager::kMass, 400, 0.0, 40.0, VarManager::kPt, 20, 0.0, 100.0, VarManager::kCentFT0C); + hm->AddHistogram(histClass, "Mass_CentFT0C", "", false, 125, 0.0, 5.0, VarManager::kMass, 20, 0.0, 100.0, VarManager::kCentFT0C); + hm->AddHistogram(histClass, "Pt_CentFT0C", "", false, 100, 0.0, 10.0, VarManager::kPt, 20, 0.0, 100.0, VarManager::kCentFT0C); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C", "", false, 75, 1.5, 4.5, VarManager::kMass, 20, 0.0, 10.0, VarManager::kPt, 10, 0.0, 100.0, VarManager::kCentFT0C); } 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); } if (subGroupStr.Contains("polarization")) { hm->AddHistogram(histClass, "cosThetaHE", "", false, 100, -1., 1., VarManager::kCosThetaHE); @@ -918,47 +989,135 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "U2Q2_CentFT0C_ev1", "mass vs. centrality vs. U2Q2_event1", false, 125, 0.0, 5.0, VarManager::kMass, 9, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kU2Q2Ev1); 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")) { + int var1[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kU2Q2Ev1, VarManager::kCos2DeltaPhiMu1}; + int var2[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kU2Q2Ev2, VarManager::kCos2DeltaPhiMu2}; + int bins[5] = {250, 60, 18, 100, 100}; + double minBins[5] = {0.0, 0.0, 0.0, -10., -1.0}; + double maxBins[5] = {5.0, 30.0, 90.0, 10., 1.0}; + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_U2Q2ev1_cos2DeltaPhiMu1", "", 5, var1, bins, minBins, maxBins, 0, -1, kTRUE); + hm->AddHistogram(histClass, "Mass_Pt_CentFT0C_U2Q2ev2_cos2DeltaPhiMu2", "", 5, var2, bins, minBins, maxBins, 0, -1, kTRUE); + hm->AddHistogram(histClass, "R2SPAB1_CentFT0C", "mass vs centrality vs. R2SPAB_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_AB1); + hm->AddHistogram(histClass, "R2SPAB2_CentFT0C", "mass vs centrality vs. R2SPAB_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_AB2); + hm->AddHistogram(histClass, "R2SPAC1_CentFT0C", "mass vs centrality vs. R2SPAC_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_AC1); + hm->AddHistogram(histClass, "R2SPAC2_CentFT0C", "mass vs centrality vs. R2SPAC_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_AC2); + hm->AddHistogram(histClass, "R2SPBC1_CentFT0C", "mass vs centrality vs. R2SPBC_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_BC1); + hm->AddHistogram(histClass, "R2SPBC2_CentFT0C", "mass vs centrality vs. R2SPBC_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2SP_BC2); + hm->AddHistogram(histClass, "R2EPAB1_CentFT0C", "mass vs centrality vs. R2EPAB_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_AB1); + hm->AddHistogram(histClass, "R2EPAB2_CentFT0C", "mass vs centrality vs. R2EPAB_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_AB2); + hm->AddHistogram(histClass, "R2EPAC1_CentFT0C", "mass vs centrality vs. R2EPAC_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_AC1); + hm->AddHistogram(histClass, "R2EPAC2_CentFT0C", "mass vs centrality vs. R2EPAC_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_AC2); + hm->AddHistogram(histClass, "R2EPBC1_CentFT0C", "mass vs centrality vs. R2EPBC_event1", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_BC1); + hm->AddHistogram(histClass, "R2EPBC2_CentFT0C", "mass vs centrality vs. R2EPBC_event2", false, 250, 0.0, 5.0, VarManager::kMass, 18, 0.0, 90.0, VarManager::kCentFT0C, 100, -10.0, 10.0, VarManager::kTwoR2EP_BC2); + } if (subGroupStr.Contains("dimuon-polarization-he")) { int varspTHE[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaHE, VarManager::kPhiHE}; - int varsFT0CCentHE[4] = {VarManager::kMass, VarManager::kCentFT0C, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int varsrapHE[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosThetaHE, VarManager::kPhiHE}; int binspT[4] = {100, 20, 20, 20}; - int binsCent[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 xminCent[4] = {1., 0., -1., -3.14}; - double xmaxCent[4] = {5., 100., 1., +3.14}; + double xminy[4] = {1., 2.5, -1., -3.14}; + double xmaxy[4] = {5., 4.0, 1., +3.14}; hm->AddHistogram(histClass, "Mass_Pt_cosThetaHE_phiHE", "", 4, varspTHE, binspT, xminpT, xmaxpT, 0, -1, kFALSE); - hm->AddHistogram(histClass, "Mass_CentFT0C_cosThetaHE_phiHE", "", 4, varsFT0CCentHE, binsCent, xminCent, xmaxCent, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_y_cosThetaHE_phiHE", "", 4, varsrapHE, binsy, xminy, xmaxy, 0, -1, kFALSE); } if (subGroupStr.Contains("dimuon-polarization-cs")) { int varspTCS[4] = {VarManager::kMass, VarManager::kPt, VarManager::kCosThetaCS, VarManager::kPhiCS}; - int varsFT0CCentCS[4] = {VarManager::kMass, VarManager::kCentFT0C, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int varsrapCS[4] = {VarManager::kMass, VarManager::kRap, VarManager::kCosThetaCS, VarManager::kPhiCS}; int binspT[4] = {100, 20, 20, 20}; - int binsCent[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 xminCent[4] = {1., 0., -1., -3.14}; - double xmaxCent[4] = {5., 100., 1., +3.14}; + double xminy[4] = {1., 2.5, -1., -3.14}; + double xmaxy[4] = {5., 4.0, 1., +3.14}; hm->AddHistogram(histClass, "Mass_Pt_cosThetaCS_phiCS", "", 4, varspTCS, binspT, xminpT, xmaxpT, 0, -1, kFALSE); - hm->AddHistogram(histClass, "Mass_CentFT0C_cosThetaCS_phiCS", "", 4, varsFT0CCentCS, binsCent, xminCent, xmaxCent, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_y_cosThetaCS_phiCS", "", 4, varsrapCS, 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}; + double xminpT[4] = {2., 0., 0, 2.5}; + double xmaxpT[4] = {5., 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")) { + int varsHEpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int binspT[5] = {150, 30, 10, 10, 10}; + double xminpT[5] = {2., 0., 0, -1., -3.14}; + double xmaxpT[5] = {5., 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaHE", "", 5, varsHEpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-lowmass-he-pbpb")) { + int varsHEpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int binspT[5] = {200, 30, 10, 10, 10}; + double xminpT[5] = {0.2, 0., 0, -1., -3.14}; + double xmaxpT[5] = {1.2, 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaHE_lowmass", "", 5, varsHEpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-cs-pbpb")) { + int varsCSpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int binspT[5] = {150, 30, 10, 10, 10}; + double xminpT[5] = {2., 0., 0, -1., -3.14}; + double xmaxpT[5] = {5., 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaCS", "", 5, varsCSpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-polarization-lowmass-cs-pbpb")) { + int varsCSpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int binspT[5] = {200, 30, 10, 10, 10}; + double xminpT[5] = {0.2, 0., 0, -1., -3.14}; + double xmaxpT[5] = {1.2, 3., 100, 1., 3.14}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaCS_lowmass", "", 5, varsCSpbpb, 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}; + int binspT[5] = {150, 30, 10, 10, 6}; + double xminpT[5] = {2., 0., 0, -1., 2.5}; + double xmaxpT[5] = {5., 3., 100, 1., 4.0}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaHE_Rap", "", 5, varsHEpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-rap-polarization-cs-pbpb")) { + int varsCSpbpb[5] = {VarManager::kMass, VarManager::kPt, VarManager::kCentFT0C, VarManager::kCosThetaCS, VarManager::kRap}; + int binspT[5] = {150, 30, 10, 10, 6}; + double xminpT[5] = {2., 0., 0, -1., 2.5}; + double xmaxpT[5] = {5., 3., 100, 1., 4.0}; + hm->AddHistogram(histClass, "Mass_Pt_Cent_cosThetaCS_Rap", "", 5, varsCSpbpb, binspT, xminpT, xmaxpT, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-midmult-polarization-he")) { + int varsITSTPCMulHE[4] = {VarManager::kMass, VarManager::kMultNTracksITSTPC, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int varsITSMulHE[4] = {VarManager::kMass, VarManager::kMultNTracksHasITS, VarManager::kCosThetaHE, VarManager::kPhiHE}; + int binsMul[4] = {100, 20, 20, 20}; + double xminMul[4] = {1., 0., -1., -3.14}; + double xmaxMul[4] = {5., 120., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_ITSTPCMult_cosThetaHE_phiHE", "", 4, varsITSTPCMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_ITSMult_cosThetaHE_phiHE", "", 4, varsITSMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + } + if (subGroupStr.Contains("dimuon-midmult-polarization-cs")) { + int varsITSTPCMulCS[4] = {VarManager::kMass, VarManager::kMultNTracksITSTPC, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int varsITSMulCS[4] = {VarManager::kMass, VarManager::kMultNTracksHasITS, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int binsMul[4] = {100, 20, 20, 20}; + double xminMul[4] = {1., 0., -1., -3.14}; + double xmaxMul[4] = {5., 120., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_ITSTPCMult_cosThetaCS_phiCS", "", 4, varsITSTPCMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_ITSMult_cosThetaCS_phiCS", "", 4, varsITSMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); } - if (subGroupStr.Contains("multiplicity-fvoa")) { + if (subGroupStr.Contains("dimuon-fwdmult-polarization-he")) { + int varsFT0AMulHE[4] = {VarManager::kMass, VarManager::kMultFT0A, VarManager::kCosThetaHE, VarManager::kPhiHE}; int varsFV0AMulHE[4] = {VarManager::kMass, VarManager::kMultFV0A, VarManager::kCosThetaHE, VarManager::kPhiHE}; - int varsFV0AMulCS[4] = {VarManager::kMass, VarManager::kMultFV0A, VarManager::kCosThetaCS, VarManager::kPhiCS}; int binsMul[4] = {100, 20, 20, 20}; double xminMul[4] = {1., 0., -1., -3.14}; - double xmaxMul[4] = {5., 5000., 1., +3.14}; - hm->AddHistogram(histClass, "Mass_MultFV0A_cosThetaHE_phiHE", "", 4, varsFV0AMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); - hm->AddHistogram(histClass, "Mass_MultFV0A_cosThetaCS_phiCS", "", 4, varsFV0AMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + double xmaxMul[4] = {5., 3000., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_FT0AMult_cosThetaHE_phiHE", "", 4, varsFT0AMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_FV0AMult_cosThetaHE_phiHE", "", 4, varsFV0AMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); } - if (subGroupStr.Contains("multiplicity-tpc")) { - int varsTPCMulHE[4] = {VarManager::kMass, VarManager::kMultTPC, VarManager::kCosThetaHE, VarManager::kPhiHE}; - int varsTPCMulCS[4] = {VarManager::kMass, VarManager::kMultTPC, VarManager::kCosThetaCS, VarManager::kPhiCS}; + if (subGroupStr.Contains("dimuon-fwdmult-polarization-cs")) { + int varsFT0AMulCS[4] = {VarManager::kMass, VarManager::kMultFT0A, VarManager::kCosThetaCS, VarManager::kPhiCS}; + int varsFV0AMulCS[4] = {VarManager::kMass, VarManager::kMultFV0A, VarManager::kCosThetaCS, VarManager::kPhiCS}; int binsMul[4] = {100, 20, 20, 20}; double xminMul[4] = {1., 0., -1., -3.14}; - double xmaxMul[4] = {5., 2000., 1., +3.14}; - hm->AddHistogram(histClass, "Mass_MultTPC_cosThetaCS_phiCS", "", 4, varsTPCMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); - hm->AddHistogram(histClass, "Mass_MultTPC_cosThetaHE_phiHE", "", 4, varsTPCMulHE, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + double xmaxMul[4] = {5., 3000., 1., +3.14}; + hm->AddHistogram(histClass, "Mass_FT0AMult_cosThetaCS_phiCS", "", 4, varsFT0AMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); + hm->AddHistogram(histClass, "Mass_FV0AMult_cosThetaCS_phiCS", "", 4, varsFV0AMulCS, binsMul, xminMul, xmaxMul, 0, -1, kFALSE); } if (subGroupStr.Contains("vertexing-forward")) { hm->AddHistogram(histClass, "Lxyz", "", false, 100, 0.0, 10.0, VarManager::kVertexingLxyz); @@ -985,7 +1144,9 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "MassLow", "", false, 400, 0.0, 2.0, VarManager::kMass); } if (subGroupStr.Contains("lmmumu")) { - hm->AddHistogram(histClass, "Mass_QuadDCAabsXY", "", false, 250, 0.0, 5.0, VarManager::kMass, 500, 0.0, 1, VarManager::kQuadDCAabsXY); + hm->AddHistogram(histClass, "Mass_QuadDCAabsXY", "", false, 250, 0.0, 5.0, VarManager::kMass, 900, 0.0, 3, VarManager::kQuadDCAabsXY); + 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")) { int varV2[6] = {VarManager::kMass, VarManager::kPt, VarManager::kRap, VarManager::kCentFT0C, VarManager::kU2Q2, VarManager::kCos2DeltaPhi}; @@ -997,6 +1158,17 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h 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); } + if (subGroupStr.Contains("cumulant")) { + 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::kCORR2REF, 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::kCORR4REF, 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::kCORR2POIMp, 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::kCORR4POIMp, VarManager::kM0111POIoverMp); + } 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}; @@ -1023,6 +1195,11 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h 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); } + if (subGroupStr.Contains("correlation-emu")) { + hm->AddHistogram(histClass, "DeltaPhiPair2", "", false, 600, -0.5 * TMath::Pi(), 1.5 * TMath::Pi(), VarManager::kDeltaPhiPair2); + hm->AddHistogram(histClass, "DeltaEtaPair2", "", false, 350, 1.5, 5.0, VarManager::kDeltaEtaPair2); + hm->AddHistogram(histClass, "DeltaPhiPair2_DeltaEtaPair2", "", false, 600, -0.5 * TMath::Pi(), 1.5 * TMath::Pi(), VarManager::kDeltaPhiPair2, 350, 1.5, 5.0, VarManager::kDeltaEtaPair2); + } if (subGroupStr.Contains("dielectrons")) { if (subGroupStr.Contains("prefilter")) { hm->AddHistogram(histClass, "MassLow_OpeningAngle", "", false, 150, 0., 0.15, VarManager::kMass, 80, 0., 0.8, VarManager::kOpeningAngle); @@ -1123,26 +1300,13 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h } if (subGroupStr.Contains("opencharm")) { if (subGroupStr.Contains("dmeson")) { - double mD0_bins[51]; - for (int i = 0; i <= 50; i++) { - mD0_bins[i] = 1.7 + i * 0.006; - } - int nbins_mD0 = sizeof(mD0_bins) / sizeof(*mD0_bins) - 1; - - double ptD0_bins[31]; - for (int i = 0; i <= 16; i++) - ptD0_bins[i] = 0.125 * i; - for (int i = 1; i <= 8; i++) - ptD0_bins[16 + i] = 2 + 0.25 * i; - for (int i = 1; i <= 4; i++) - ptD0_bins[24 + i] = 4 + 1 * i; - ptD0_bins[29] = 8; - ptD0_bins[30] = 20; - int nbins_ptD0 = sizeof(ptD0_bins) / sizeof(*ptD0_bins) - 1; - hm->AddHistogram(histClass, "MassD0region", "", false, nbins_mD0, mD0_bins, VarManager::kMass); - hm->AddHistogram(histClass, "MassD0region_Pt", "", false, nbins_mD0, mD0_bins, VarManager::kMass, nbins_ptD0, ptD0_bins, VarManager::kPt); - hm->AddHistogram(histClass, "MassD0region_eta", "", false, 50, 1.7, 2.0, VarManager::kMass, 40, -2., 2., VarManager::kEta); - hm->AddHistogram(histClass, "MassD0region_TauxyzProj", "", false, 50, 1.7, 2.0, VarManager::kMass, 1000, -0.03, 0.03, VarManager::kVertexingTauxyzProjected); + hm->AddHistogram(histClass, "MassD0region", "", false, 140, 1.5, 2.2, VarManager::kMass); + hm->AddHistogram(histClass, "MassD0region_Pt", "", false, 70, 1.5, 2.2, VarManager::kMass, 160, 0., 20., VarManager::kPt); + hm->AddHistogram(histClass, "MassD0region_Rapidity", "", false, 140, 1.5, 2.2, VarManager::kMass, 10, -0.8, 0.8, VarManager::kRap); + hm->AddHistogram(histClass, "MassD0region_eta", "", false, 140, 1.5, 2.2, VarManager::kMass, 40, -2., 2., VarManager::kEta); + hm->AddHistogram(histClass, "MassD0region_TauxyzProj", "", false, 140, 1.5, 2.2, VarManager::kMass, 200, -0.03, 0.03, VarManager::kVertexingTauxyzProjected); + hm->AddHistogram(histClass, "MassD0region_VtxNContribReal", "", false, 140, 1.5, 2.2, VarManager::kMass, 50, 0, 50, VarManager::kVtxNcontribReal); + 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); } if (subGroupStr.Contains("lambdac")) { hm->AddHistogram(histClass, "MassLambdacRegion", "", false, 50, 2.15, 2.4, VarManager::kMass); @@ -1168,7 +1332,7 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "Pt_Track", "", false, 120, 0.0, 30.0, VarManager::kPt); hm->AddHistogram(histClass, "Mass", "", false, 750, 0.0, 30.0, VarManager::kPairMass); hm->AddHistogram(histClass, "Pt", "", false, 750, 0.0, 30.0, VarManager::kPairPt); - hm->AddHistogram(histClass, "Mass_Pt", "", false, 40, 0.0, 20.0, VarManager::kPairMass, 40, 0.0, 20.0, VarManager::kPairPt); + hm->AddHistogram(histClass, "Mass_Pt", "", false, 100, 0.0, 20.0, VarManager::kPairMass, 40, 0.0, 20.0, VarManager::kPairPt); hm->AddHistogram(histClass, "Pt_Dilepton__Pt", "", false, 40, 0.0, 20.0, VarManager::kPairPtDau, 40, 0.0, 20.0, VarManager::kPairPt); hm->AddHistogram(histClass, "Pt_Track__Pt", "", false, 40, 0.0, 20.0, VarManager::kPt, 40, 0.0, 20.0, VarManager::kPairPt); } @@ -1192,11 +1356,38 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h hm->AddHistogram(histClass, "TauxyProj", "", false, 4000, -0.5, 0.5, VarManager::kVertexingTauxyProjected); hm->AddHistogram(histClass, "CosPointingAngle", "", false, 100, 0.0, 1.0, VarManager::kCosPointingAngle); } + if (subGroupStr.Contains("multidimentional-vertexing-histograms")) { + hm->AddHistogram(histClass, "Mass_Tauxy", "", false, 75, 4.0, 7.0, VarManager::kPairMass, 40, -0.0, 0.02, VarManager::kVertexingTauxy); + hm->AddHistogram(histClass, "Mass_cosPointing", "", false, 75, 4.0, 7.0, VarManager::kPairMass, 40, 0.0, 1.0, VarManager::kCosPointingAngle); + + const int kNvarsTripletCuts = 4; + const int kInvMassNbins = 100; + double InvMassBinLims[kInvMassNbins + 1]; + for (int i = 0; i <= kInvMassNbins; ++i) + InvMassBinLims[i] = 4.0 + 0.02 * i; + + const int kPtNbins = 6; + double PtBinLims[kPtNbins + 1] = {0., 2., 4., 6., 8., 10., 20.}; + const int kCosPointingAngleNbins = 5; + double CosPointingAngleBinLims[kCosPointingAngleNbins + 1] = {0., 0.86, 0.90, 0.94, 0.98, 1.0}; + + const int kTauNBins = 6; + double TauBinLims[kTauNBins + 1] = {0., 0.005, 0.01, 0.015, 0.02, 0.025, 0.3}; + + TArrayD nCutsBinLimits[kNvarsTripletCuts]; + nCutsBinLimits[0] = TArrayD(kInvMassNbins + 1, InvMassBinLims); + nCutsBinLimits[1] = TArrayD(kPtNbins + 1, PtBinLims); + nCutsBinLimits[2] = TArrayD(kCosPointingAngleNbins + 1, CosPointingAngleBinLims); + nCutsBinLimits[3] = TArrayD(kTauNBins + 1, TauBinLims); + + int varsTripletCuts[kNvarsTripletCuts] = {VarManager::kPairMass, VarManager::kPairPt, VarManager::kCosPointingAngle, VarManager::kVertexingTauxyProjected}; + hm->AddHistogram(histClass, "multidimentional-vertexing", "Invariant mass vs. pT vs. cosine of pointing angle vs. tau", kNvarsTripletCuts, varsTripletCuts, nCutsBinLimits); + } if (subGroupStr.Contains("correlation")) { hm->AddHistogram(histClass, "DeltaEta_DeltaPhi", "", false, 20, -2.0, 2.0, VarManager::kDeltaEta, 50, -8.0, 8.0, VarManager::kDeltaPhi); hm->AddHistogram(histClass, "DeltaEta_DeltaPhiSym", "", false, 20, -2.0, 2.0, VarManager::kDeltaEta, 50, -8.0, 8.0, VarManager::kDeltaPhiSym); } - if (!groupStr.Contains("dilepton-hadron-array-correlation")) { + if (subGroupStr.Contains("dilepton-hadron-array-correlation")) { const int kInvMassBins = 500; double InvMassBinLims[kInvMassBins + 1]; for (int i = 0; i <= kInvMassBins; i++) @@ -1260,11 +1451,36 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h if (!groupStr.CompareTo("dilepton-dihadron")) { if (subGroupStr.EqualTo("xtojpsipipi")) { hm->AddHistogram(histClass, "hMass_X3872", "", false, 1000, 3.0, 5.0, VarManager::kQuadMass); - hm->AddHistogram(histClass, "hPt_X3872", "", false, 200, 0.0, 20.0, VarManager::kQuadPt); - hm->AddHistogram(histClass, "hMass_Pt_X3872", "", false, 1000, 3.0, 5.0, VarManager::kQuadMass, 150, 0.0, 15.0, VarManager::kQuadPt); + 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); + hm->AddHistogram(histClass, "hMass_Pt_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 150, 0.0, 15.0, VarManager::kQuadPt); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_Pt_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 150, 0.0, 15.0, VarManager::kQuadPt); hm->AddHistogram(histClass, "hCostheta_Jpsi_Dihadron", "", false, 100, -1.0, 1.0, VarManager::kCosthetaDileptonDitrack); - hm->AddHistogram(histClass, "hPtDilepton_PtDihadron", "", false, 200, 0, 20, VarManager::kPairPt, 100, 0, 10, VarManager::kDitrackPt); - hm->AddHistogram(histClass, "hPtDilepton_MassDihadron", "", false, 200, 0, 20, VarManager::kPairPt, 100, 3.0, 5.0, VarManager::kDitrackMass); + 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, "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, "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); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_DeltaR2_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 100, 0.0, 10.0, VarManager::kDeltaR2); + hm->AddHistogram(histClass, "hMass_X3872_MassDihadron", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 150, 0.0, 3.0, VarManager::kDitrackMass); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_X3872_MassDihadron", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 150, 0.0, 3.0, VarManager::kDitrackMass); + hm->AddHistogram(histClass, "hRap_X3872", "", false, 1000, 0.0, 5.0, VarManager::kRap); + hm->AddHistogram(histClass, "hMass_Rap_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 1000, 0.0, 5.0, VarManager::kRap); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_Rap_X3872", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 1000, 0.0, 5.0, VarManager::kRap); + hm->AddHistogram(histClass, "hDCAxyTrack1", "", false, 100, -0.1, 0.1, VarManager::kTrackDCAxy); + hm->AddHistogram(histClass, "hDCAzTrack1", "", false, 100, -0.1, 0.1, VarManager::kTrackDCAz); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_DCAxyTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 100, -0.1, 0.1, VarManager::kTrackDCAxy); + hm->AddHistogram(histClass, "hMass_defaultDileptonMass_DCAzTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadDefaultDileptonMass, 100, -0.1, 0.1, VarManager::kTrackDCAz); + hm->AddHistogram(histClass, "hMass_DCAxyTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 100, -0.1, 0.1, VarManager::kTrackDCAxy); + hm->AddHistogram(histClass, "hMass_DCAzTrack1", "", false, 100, 3.0, 5.0, VarManager::kQuadMass, 100, -0.1, 0.1, VarManager::kTrackDCAz); + hm->AddHistogram(histClass, "hPtTrack1", "", false, 100, 0.0, 10.0, VarManager::kPt); + 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 (!groupStr.CompareTo("dilepton-photon-mass")) { diff --git a/PWGDQ/Core/MCProng.cxx b/PWGDQ/Core/MCProng.cxx index 14fa645eb77..975fee96681 100644 --- a/PWGDQ/Core/MCProng.cxx +++ b/PWGDQ/Core/MCProng.cxx @@ -146,7 +146,11 @@ void MCProng::Print() const for (int i = 0; i < fNGenerations; i++) { std::cout << "Generation #" << i << " PDGcode(" << fPDGcodes[i] << ") CheckBothCharges(" << fCheckBothCharges[i] << ") ExcludePDG(" << fExcludePDG[i] << ") SourceBits(" << fSourceBits[i] << ") ExcludeSource(" << fExcludeSource[i] - << ") UseANDonSource(" << fUseANDonSourceBitMap[i] << ") CheckGenerationsInTime(" << fCheckGenerationsInTime << ") PDGInHistory(" << fPDGInHistory[i] << ") ExcludePDGInHistory(" << fExcludePDGInHistory[i] << ")" << std::endl; + << ") UseANDonSource(" << fUseANDonSourceBitMap[i] << ") CheckGenerationsInTime(" << fCheckGenerationsInTime << ")"; + for (std::size_t j = 0; j < fPDGInHistory.size(); j++) { + std::cout << " #" << j << " PDGInHistory(" << fPDGInHistory[j] << ") ExcludePDGInHistory(" << fExcludePDGInHistory[j] << ")"; + } + std::cout << std::endl; } } diff --git a/PWGDQ/Core/MCSignal.cxx b/PWGDQ/Core/MCSignal.cxx index a86b0f8aa8d..e66ebea3687 100644 --- a/PWGDQ/Core/MCSignal.cxx +++ b/PWGDQ/Core/MCSignal.cxx @@ -21,6 +21,7 @@ MCSignal::MCSignal() : TNamed("", ""), fProngs({}), fNProngs(0), fCommonAncestorIdxs({}), + fExcludeCommonAncestor(false), fTempAncestorLabel(-1) { } @@ -30,17 +31,19 @@ MCSignal::MCSignal(int nProngs, const char* name /*= ""*/, const char* title /*= fProngs({}), fNProngs(nProngs), fCommonAncestorIdxs({}), + fExcludeCommonAncestor(false), fTempAncestorLabel(-1) { fProngs.reserve(nProngs); } //________________________________________________________________________________________________ -MCSignal::MCSignal(const char* name, const char* title, std::vector prongs, std::vector commonAncestors) : TNamed(name, title), - fProngs(prongs), - fNProngs(prongs.size()), - fCommonAncestorIdxs(commonAncestors), - fTempAncestorLabel(-1) +MCSignal::MCSignal(const char* name, const char* title, std::vector prongs, std::vector commonAncestors, bool excludeCommonAncestor) : TNamed(name, title), + fProngs(prongs), + fNProngs(prongs.size()), + fCommonAncestorIdxs(commonAncestors), + fExcludeCommonAncestor(excludeCommonAncestor), + fTempAncestorLabel(-1) { } @@ -67,10 +70,11 @@ void MCSignal::AddProng(MCProng prong, short commonAncestor) void MCSignal::PrintConfig() { cout << "Name/Title: " << fName << " / " << fTitle << endl; + cout << "Exclude common ancestor combinations: " << fExcludeCommonAncestor << endl; cout << "Printing " << fNProngs << "/" << fProngs.size() << " prongs:" << endl; int i = 0; for (auto& pr : fProngs) { - cout << "Prong #" << i << " commonAncestor" << fCommonAncestorIdxs[i] << " ================ " << endl; + cout << "Prong #" << i << " commonAncestor: " << fCommonAncestorIdxs[i] << " ================ " << endl; i++; pr.Print(); } diff --git a/PWGDQ/Core/MCSignal.h b/PWGDQ/Core/MCSignal.h index 787aa443b22..c2fa8227de2 100644 --- a/PWGDQ/Core/MCSignal.h +++ b/PWGDQ/Core/MCSignal.h @@ -67,7 +67,7 @@ class MCSignal : public TNamed public: MCSignal(); MCSignal(int nProngs, const char* name = "", const char* title = ""); - MCSignal(const char* name, const char* title, std::vector prongs, std::vector commonAncestors); + MCSignal(const char* name, const char* title, std::vector prongs, std::vector commonAncestors, bool excludeCommonAncestor = false); MCSignal(const MCSignal& c) = default; ~MCSignal() override = default; @@ -100,6 +100,7 @@ class MCSignal : public TNamed std::vector fProngs; unsigned int fNProngs; std::vector fCommonAncestorIdxs; + bool fExcludeCommonAncestor; int fTempAncestorLabel; template @@ -139,14 +140,15 @@ bool MCSignal::CheckProng(int i, bool checkSources, const T& track) if (i == 0) { fTempAncestorLabel = currentMCParticle.globalIndex(); } else { - if (currentMCParticle.globalIndex() != fTempAncestorLabel) { + if (currentMCParticle.globalIndex() != fTempAncestorLabel && !fExcludeCommonAncestor) + return false; + else if (currentMCParticle.globalIndex() == fTempAncestorLabel && fExcludeCommonAncestor) return false; - } } } // Update the currentMCParticle by moving either back in time (towards mothers, grandmothers, etc) - // or in time (towards daughters) depending on how this was configured in the MSignal + // or in time (towards daughters) depending on how this was configured in the MC Signal if (!fProngs[i].fCheckGenerationsInTime) { // make sure that a mother exists in the stack before moving one generation further in history if (!currentMCParticle.has_mothers() && j < fProngs[i].fNGenerations - 1) { diff --git a/PWGDQ/Core/MCSignalLibrary.cxx b/PWGDQ/Core/MCSignalLibrary.cxx index b157ff0897b..b4061743a7d 100644 --- a/PWGDQ/Core/MCSignalLibrary.cxx +++ b/PWGDQ/Core/MCSignalLibrary.cxx @@ -119,6 +119,11 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Inclusive jpsi", {prong}, {-1}); return signal; } + if (!nameStr.compare("Helium3")) { + MCProng prong(1, {1000020030}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Helium3", {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}); @@ -174,6 +179,21 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Inclusive Chic0, Chic1 and Chic2", {prong}, {-1}); return signal; } + if (!nameStr.compare("Upsilon1S")) { + MCProng prong(1, {553}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Inclusive Upsilon1S", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("Upsilon2S")) { + MCProng prong(1, {100553}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Inclusive Upsilon2S", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("Upsilon3S")) { + MCProng prong(1, {200553}, {true}, {false}, {0}, {0}, {false}); + signal = new MCSignal(name, "Inclusive Upsilon3S", {prong}, {-1}); + return signal; + } if (!nameStr.compare("allBeautyHadrons")) { MCProng prong(1, {503}, {true}, {false}, {0}, {0}, {false}); signal = new MCSignal(name, "All beauty hadrons", {prong}, {-1}); @@ -456,6 +476,24 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) signal = new MCSignal(name, "Electrons from Lambda_c decays", {prong}, {-1}); return signal; } + if (!nameStr.compare("eFromXiC0")) { + MCProng prong(2, {11, Pdg::kXiC0}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {true}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "Electrons from Xi_c_0 decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromXiCPlus")) { + MCProng prong(2, {11, Pdg::kXiCPlus}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {true}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "Electrons from Xi_c_+ decays", {prong}, {-1}); + return signal; + } + if (!nameStr.compare("eFromXiCPlusPlus")) { + MCProng prong(2, {11, Pdg::kXiCCPlusPlus}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {true}); + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "Electrons from Xi_c_++ decays", {prong}, {-1}); + return signal; + } if (!nameStr.compare("eFromHb")) { MCProng prong(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); prong.SetSourceBit(0, MCProng::kPhysicalPrimary); @@ -691,6 +729,21 @@ 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("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 + return signal; + } + if (!nameStr.compare("mumuFromUpsilon2S")) { + MCProng prong(2, {13, 100553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "mumu pairs from upsilon2s decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } + if (!nameStr.compare("mumuFromUpsilon3S")) { + MCProng prong(2, {13, 200553}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + signal = new MCSignal(name, "mumu pairs from upsilon3s decays", {prong, prong}, {1, 1}); // signal at pair level + return signal; + } if (!nameStr.compare("eeFromLMeeLFQ")) { MCProng prong(2, {11, 900}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); prong.SetSourceBit(0, MCProng::kPhysicalPrimary); @@ -886,33 +939,108 @@ MCSignal* o2::aod::dqmcsignals::GetMCSignal(const char* name) } // Any b to any c in history b -> c -> e - if (!nameStr.compare("eeFromBtoCandBtoC")) { + if (!nameStr.compare("eeFromAnyBtoCandAnyBtoC")) { MCProng prong(2, {11, 402}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {false}); // check if mother pdg code is in history prong.SetSourceBit(0, MCProng::kPhysicalPrimary); signal = new MCSignal(name, "ee pairs with any beauty to charm in decay chain", {prong, prong}, {-1, -1}); // signal at pair level return signal; } - // Any b->e and Any b->c->e - if (!nameStr.compare("eeFromBandBtoC")) { - MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); // check if mother pdg code is in history + // b->c->e, b->c->e + if (!nameStr.compare("eeFromBtoCandBtoC")) { + MCProng prong(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prong.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs with any beauty to charm in decay chain", {prong, prong}, {-1, -1}); // signal at pair level + return signal; + } + + // Any b->e and Any b->X->c->e + // Looking at such decays: B -> (e) D -> (e)e and bar{B} -> e + // Signal allows combinations of ee from the same B meson + // + the combination of e fom B and e from bar{B} + if (!nameStr.compare("eeFromBandAnyBtoC")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); MCProng prongBtoC(2, {11, 402}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {false}); // check if mother pdg code is in history prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); - signal = new MCSignal(name, "ee pairs from b->e and b->c->e", {prongB, prongBtoC}, {-1, -1}); // signal at pair level + signal = new MCSignal(name, "ee pairs from b->e and b->X->c->e", {prongB, prongBtoC}, {-1, -1}); // signal at pair level return signal; } - // Any b->e and Any b->c->e - if (!nameStr.compare("eeFromBandBtoCBis")) { - MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); // check if mother pdg code is in history + // Any b->e and Any b->X->c->e + if (!nameStr.compare("eeFromBandAnyBtoCBis")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); MCProng prongBtoC(2, {11, 402}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}, false, {502}, {false}); // check if mother pdg code is in history prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs from b->X->c->e and b->e", {prongBtoC, prongB}, {-1, -1}); // signal at pair level + return signal; + } + + // b->e and b->c->e + if (!nameStr.compare("eeFromBandBtoC")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "direkt ee pairs from b->e and b->c->e", {prongB, prongBtoC}, {-1, -1}); // signal at pair level + return signal; + } + + // b->e and b->c->e + if (!nameStr.compare("eeFromBandBtoCBis")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); signal = new MCSignal(name, "ee pairs from b->c->e and b->e", {prongBtoC, prongB}, {-1, -1}); // signal at pair level return signal; } + // b->e and b->c->e (same mother/grandmother) + // require that the mother is the grandmother of the other electron + if (!nameStr.compare("eeFromBandBtoCsameGM")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs from b->e and b->c->e, mother = grandmother", {prongB, prongBtoC}, {1, 2}, false); // signal at pair level, accept commonAncestor Pairs + return signal; + } + + // b->e and b->c->e (same mother/grandmother) + // require that the mother is the grandmother of the other electron + if (!nameStr.compare("eeFromBandBtoCsameGMBis")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs from b->c->e and b->e, mother = grandmother", {prongBtoC, prongB}, {2, 1}, false); // signal at pair level, accept commonAncestor Pairs + return signal; + } + + // b->e and b->c->e (different mother/grandmother) + // require that the mother is not the grandmother of the other electron + if (!nameStr.compare("eeFromBandBtoCdiffGM")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs from b->e and b->c->e, mother != grandmother", {prongB, prongBtoC}, {1, 2}, true); // signal at pair level, exclude commonAncestor Pairs + return signal; + } + + // b->e and b->c->e (different mother/grandmother) + // require that the mother is not the grandmother of the other electron + if (!nameStr.compare("eeFromBandBtoCdiffGMBis")) { + MCProng prongB(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); + prongB.SetSourceBit(0, MCProng::kPhysicalPrimary); + MCProng prongBtoC(3, {11, 402, 502}, {true, true, true}, {false, false, false}, {0, 0, 0}, {0, 0, 0}, {false, false, false}, false); // check if mother pdg code is in history + prongBtoC.SetSourceBit(0, MCProng::kPhysicalPrimary); + signal = new MCSignal(name, "ee pairs from b->c->e and b->e, mother != grandmother", {prongBtoC, prongB}, {2, 1}, true); // signal at pair level, exclude commonAncestor Pairs + return signal; + } + // b->e and b->e if (!nameStr.compare("eeFromBB")) { MCProng prong(2, {11, 502}, {true, true}, {false, false}, {0, 0}, {0, 0}, {false, false}); diff --git a/PWGDQ/Core/VarManager.cxx b/PWGDQ/Core/VarManager.cxx index b0f613ce068..0f9892c6c2f 100644 --- a/PWGDQ/Core/VarManager.cxx +++ b/PWGDQ/Core/VarManager.cxx @@ -34,6 +34,8 @@ int VarManager::fgITSROFbias = 0; int VarManager::fgITSROFlength = 100; int VarManager::fgITSROFBorderMarginLow = 0; int VarManager::fgITSROFBorderMarginHigh = 0; +uint64_t VarManager::fgSOR = 0; +uint64_t VarManager::fgEOR = 0; o2::vertexing::DCAFitterN<2> VarManager::fgFitterTwoProngBarrel; o2::vertexing::DCAFitterN<3> VarManager::fgFitterThreeProngBarrel; o2::vertexing::FwdDCAFitterN<2> VarManager::fgFitterTwoProngFwd; @@ -228,6 +230,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kRunId] = ""; fgVariableNames[kBC] = "Bunch crossing"; fgVariableUnits[kBC] = ""; + fgVariableNames[kTimeFromSOR] = "time since SOR"; + fgVariableUnits[kTimeFromSOR] = "min."; + fgVariableNames[kBCOrbit] = "Bunch crossing"; + fgVariableUnits[kBCOrbit] = ""; fgVariableNames[kIsPhysicsSelection] = "Physics selection"; fgVariableUnits[kIsPhysicsSelection] = ""; fgVariableNames[kVtxX] = "Vtx X "; @@ -236,6 +242,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kVtxY] = "cm"; fgVariableNames[kVtxZ] = "Vtx Z "; fgVariableUnits[kVtxZ] = "cm"; + fgVariableNames[kCollisionTime] = "collision time wrt BC"; + fgVariableUnits[kCollisionTime] = "ns"; + fgVariableNames[kCollisionTimeRes] = "collision time resolution"; + fgVariableUnits[kCollisionTimeRes] = "ns"; fgVariableNames[kVtxNcontrib] = "Vtx contrib."; fgVariableUnits[kVtxNcontrib] = ""; fgVariableNames[kVtxNcontribReal] = "Real Vtx contrib."; @@ -283,6 +293,7 @@ void VarManager::SetDefaultVarNames() fgVariableNames[kCentFT0C] = "Centrality FT0C"; fgVariableUnits[kCentFT0C] = "%"; fgVariableNames[kMCEventGeneratorId] = "MC Generator ID"; + fgVariableNames[kMCEventSubGeneratorId] = "MC SubGenerator ID"; fgVariableNames[kMCVtxX] = "MC Vtx X"; fgVariableNames[kMCVtxY] = "MC Vtx Y"; fgVariableNames[kMCVtxZ] = "MC Vtx Z"; @@ -290,6 +301,7 @@ void VarManager::SetDefaultVarNames() fgVariableNames[kMCEventWeight] = "MC event weight"; fgVariableNames[kMCEventImpParam] = "MC impact parameter"; fgVariableUnits[kMCEventGeneratorId] = ""; + fgVariableUnits[kMCEventSubGeneratorId] = ""; fgVariableUnits[kMCVtxX] = "cm"; fgVariableUnits[kMCVtxY] = "cm"; fgVariableUnits[kMCVtxZ] = "cm"; @@ -348,6 +360,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kMultNTracksITSTPC] = ""; fgVariableNames[kTrackOccupancyInTimeRange] = "track occupancy in TPC drift time (PV tracks)"; fgVariableUnits[kTrackOccupancyInTimeRange] = ""; + fgVariableNames[kNoCollInTimeRangeStandard] = "track occupancy in TPC drift standart time"; + fgVariableUnits[kNoCollInTimeRangeStandard] = ""; fgVariableNames[kMultAllTracksITSTPC] = "# ITS-TPC tracks"; fgVariableUnits[kMultAllTracksITSTPC] = ""; fgVariableNames[kMultAllTracksTPCOnly] = "# TPC only tracks"; @@ -423,6 +437,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kTPCncls] = ""; fgVariableNames[kTPCnclsCR] = "TPC #cls crossed rows"; fgVariableUnits[kTPCnclsCR] = ""; + fgVariableNames[kTPCnCRoverFindCls] = "TPC crossed rows over findable cls"; + fgVariableUnits[kTPCnCRoverFindCls] = ""; fgVariableNames[kTPCchi2] = "TPC chi2"; fgVariableUnits[kTPCchi2] = ""; fgVariableNames[kTPCsignal] = "TPC dE/dx"; @@ -581,6 +597,8 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kVertexingTauxyProjected] = "ns"; fgVariableNames[kVertexingTauxyzProjected] = "Pair pseudo-proper Tauxyz"; fgVariableUnits[kVertexingTauxyzProjected] = "ns"; + fgVariableNames[kCosPointingAngle] = "cos(#theta_{pointing})"; + fgVariableUnits[kCosPointingAngle] = ""; fgVariableNames[kVertexingPz] = "Pz Pair"; fgVariableUnits[kVertexingPz] = "GeV/c"; fgVariableNames[kVertexingSV] = "Secondary Vertexing z"; @@ -739,26 +757,68 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kS31A] = ""; fgVariableNames[kM11REF] = "M_{11}^{REF} "; fgVariableUnits[kM11REF] = ""; - fgVariableNames[kM01POI] = "M_{01}^{POI} "; + fgVariableNames[kM11REFetagap] = "M_{11}^{REF}-etagap "; + fgVariableUnits[kM11REFetagap] = ""; + fgVariableNames[kM01POI] = "M^{'}_{01}^{POI} "; fgVariableUnits[kM01POI] = ""; fgVariableNames[kM1111REF] = "M_{1111}^{REF} "; fgVariableUnits[kM1111REF] = ""; - fgVariableNames[kM0111POI] = "M_{0111}^{POI} "; + fgVariableNames[kM1111REFsmall] = "M_{1111}^{REF}small "; + fgVariableUnits[kM1111REFsmall] = ""; + fgVariableNames[kM0111POI] = "M^{'}_{0111}^{POI} "; fgVariableUnits[kM0111POI] = ""; fgVariableNames[kCORR2REF] = "<2> "; fgVariableUnits[kCORR2REF] = ""; - fgVariableNames[kCORR2POI] = " <2'> "; + fgVariableNames[kCORR2REFw] = "<2w> "; + fgVariableUnits[kCORR2REFw] = ""; + fgVariableNames[kCORR2REFsquared] = " "; + fgVariableUnits[kCORR2REFsquared] = ""; + fgVariableNames[kCORR2REFsquaredw] = " "; + fgVariableUnits[kCORR2REFsquaredw] = ""; + fgVariableNames[kCORR2REFetagap] = "<2-etagap> "; + fgVariableUnits[kCORR2REFetagap] = ""; + fgVariableNames[kCORR2REFetagapw] = "<2w-etagap> "; + fgVariableUnits[kCORR2REFetagapw] = ""; + fgVariableNames[kCORR2REFetagapsquaredw] = " "; + fgVariableUnits[kCORR2REFetagapsquaredw] = ""; + fgVariableNames[kCORR2POI] = "<2'> "; fgVariableUnits[kCORR2POI] = ""; - fgVariableNames[kCORR4REF] = " <4>"; + fgVariableNames[kCORR2POIw] = "<2'w> "; + fgVariableUnits[kCORR2POIw] = ""; + fgVariableNames[kCORR2POIsquaredw] = " "; + fgVariableUnits[kCORR2POIsquaredw] = ""; + fgVariableNames[kCORR4REF] = "<4> "; fgVariableUnits[kCORR4REF] = ""; + fgVariableNames[kCORR4REFw] = "<4w> "; + fgVariableUnits[kCORR4REFw] = ""; + fgVariableNames[kCORR4REFsquaredw] = " "; + fgVariableUnits[kCORR4REFsquaredw] = ""; fgVariableNames[kCORR4POI] = "<4'> "; fgVariableUnits[kCORR4POI] = ""; - fgVariableNames[kC4REF] = "c_{2}(4)"; - fgVariableUnits[kC4REF] = ""; - fgVariableNames[kC4POI] = "d_{2}(4)"; - fgVariableUnits[kC4POI] = ""; - fgVariableNames[kV4] = "v_{2}(4)"; - fgVariableUnits[kV4] = ""; + fgVariableNames[kCORR4POIw] = "<4'w> "; + fgVariableUnits[kCORR4POIw] = ""; + fgVariableNames[kCORR4POIsquaredw] = " "; + fgVariableUnits[kCORR4POIsquaredw] = ""; + fgVariableNames[kM11REFoverMp] = "M_{11}^{REF}/M_{p} "; + fgVariableUnits[kM11REFoverMp] = ""; + fgVariableNames[kM01POIoverMp] = "M^{'}_{01}^{POI}/M_{p} "; + fgVariableUnits[kM01POIoverMp] = ""; + fgVariableNames[kM1111REFoverMp] = "M_{1111}^{REF}/M_{p} "; + fgVariableUnits[kM1111REFoverMp] = ""; + fgVariableNames[kM0111POIoverMp] = "M^{'}_{0111}^{POI}/M_{p} "; + fgVariableUnits[kM0111POIoverMp] = ""; + fgVariableNames[kCORR2POIMp] = "<2'> M_{p} "; + fgVariableUnits[kCORR2POIMp] = ""; + fgVariableNames[kCORR2POIMpw] = "<2'w> M_{p} "; + fgVariableUnits[kCORR2POIMpw] = ""; + fgVariableNames[kCORR2POIsquaredMpw] = "<2'w>^{2} M_{p} "; + fgVariableUnits[kCORR2POIsquaredMpw] = ""; + fgVariableNames[kCORR4POIMp] = "<4'> M_{p} "; + fgVariableUnits[kCORR4POIMp] = ""; + fgVariableNames[kCORR4POIMpw] = "<4'w> M_{p} "; + fgVariableUnits[kCORR4POIMpw] = ""; + fgVariableNames[kCORR4POIsquaredMpw] = "<4'w>^{2} M_{p} "; + fgVariableUnits[kCORR4POIsquaredMpw] = ""; fgVariableNames[kCos2DeltaPhi] = "cos 2(#varphi-#Psi_{2}^{A}) "; fgVariableUnits[kCos2DeltaPhi] = ""; fgVariableNames[kCos3DeltaPhi] = "cos 3(#varphi-#Psi_{3}^{A}) "; @@ -831,6 +891,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kCosThetaCS] = ""; fgVariableNames[kPhiCS] = "#varphi_{CS}"; fgVariableUnits[kPhiCS] = "rad."; + fgVariableNames[kDeltaPhiPair2] = "#Delta#phi"; + fgVariableUnits[kDeltaPhiPair2] = "rad."; + fgVariableNames[kDeltaEtaPair2] = "#Delta#eta"; + fgVariableUnits[kDeltaEtaPair2] = ""; fgVariableNames[kPsiPair] = "#Psi_{pair}"; fgVariableUnits[kPsiPair] = "rad."; fgVariableNames[kDeltaPhiPair] = "#Delta#phi"; @@ -875,6 +939,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kIsSingleGapA] = ""; fgVariableNames[kIsSingleGapC] = "is single gap event side C"; fgVariableUnits[kIsSingleGapC] = ""; + fgVariableNames[kIsSingleGap] = "is single gap event"; + fgVariableUnits[kIsSingleGap] = ""; + fgVariableNames[kIsITSUPCMode] = "UPC settings used"; + fgVariableUnits[kIsITSUPCMode] = ""; fgVariableNames[kQuadMass] = "mass quadruplet"; fgVariableUnits[kQuadMass] = "GeV/c2"; fgVariableNames[kQuadPt] = "p_{T}"; @@ -889,4 +957,10 @@ void VarManager::SetDefaultVarNames() fgVariableUnits[kDitrackMass] = "GeV/c2"; fgVariableNames[kDitrackPt] = "p_{T}"; fgVariableUnits[kDitrackPt] = "GeV/c"; + fgVariableNames[kQ] = "mass difference"; + fgVariableUnits[kQ] = "GeV/c2"; + fgVariableNames[kDeltaR1] = "angular distance prong 1"; + fgVariableUnits[kDeltaR1] = ""; + fgVariableNames[kDeltaR2] = "angular distance prong 2"; + fgVariableUnits[kDeltaR2] = ""; } diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index b0ad6857479..0c5b49f5a7e 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -101,6 +102,7 @@ class VarManager : public TObject ReducedZdc = BIT(17), CollisionMultExtra = BIT(18), ReducedEventMultExtra = BIT(19), + CollisionQvectCentr = BIT(20), Track = BIT(0), TrackCov = BIT(1), TrackExtra = BIT(2), @@ -144,6 +146,7 @@ class VarManager : public TObject kDecayToKPi, // e.g. D0 -> K+ pi- or cc. kTripleCandidateToKPiPi, // e.g. D+ -> K- pi+ pi+ kTripleCandidateToPKPi, // e.g. Lambda_c -> p K- pi+ + kTripleCandidateToKKPi, // e.g. D_s -> K+ K- pi+ kNMaxCandidateTypes }; @@ -174,6 +177,7 @@ class VarManager : public TObject // Event wise variables kTimestamp, + kTimeFromSOR, // Time since Start of Run (SOR) in minutes kCollisionTime, kCollisionTimeRes, kBC, @@ -231,6 +235,7 @@ class VarManager : public TObject kMultNTracksTPCOnly, kMultNTracksITSTPC, kTrackOccupancyInTimeRange, + kNoCollInTimeRangeStandard, kMultAllTracksTPCOnly, kMultAllTracksITSTPC, kNTPCpileupContribA, @@ -240,6 +245,7 @@ class VarManager : public TObject kNTPCtracksInPast, kNTPCtracksInFuture, kMCEventGeneratorId, + kMCEventSubGeneratorId, kMCVtxX, kMCVtxY, kMCVtxZ, @@ -329,6 +335,7 @@ class VarManager : public TObject kIsSingleGapA, // Rapidity gap on side A kIsSingleGapC, // Rapidity gap on side C kIsSingleGap, // Rapidity gap on either side + kIsITSUPCMode, // UPC mode used for event kTwoEvPosZ1, // vtx-z for collision 1 in two events correlations kTwoEvPosZ2, // vtx-z for collision 2 in two events correlations kTwoEvPosR1, // vtx-R for collision 1 in two events correlations @@ -343,6 +350,14 @@ class VarManager : public TObject kEnergyCommonZNC, kEnergyCommonZPA, kEnergyCommonZPC, + kEnergyZNA1, + kEnergyZNA2, + kEnergyZNA3, + kEnergyZNA4, + kEnergyZNC1, + kEnergyZNC2, + kEnergyZNC3, + kEnergyZNC4, kTimeZNA, kTimeZNC, kTimeZPA, @@ -354,10 +369,22 @@ class VarManager : public TObject kQ2Y0A2, kU2Q2Ev1, kU2Q2Ev2, - kTwoR2SP1, // Scalar product resolution of event1 for ME technique - 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 + kTwoR2SP1, // Scalar product resolution of event1 for ME technique + 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 + kTwoR2SP_AB1, // Scalar product resolution of event1 for ME technique + kTwoR2SP_AB2, // Scalar product resolution of event2 for ME technique + kTwoR2SP_AC1, // Scalar product resolution of event1 for ME technique + kTwoR2SP_AC2, // Scalar product resolution of event2 for ME technique + kTwoR2SP_BC1, // Scalar product resolution of event1 for ME technique + kTwoR2SP_BC2, // Scalar product resolution of event2 for ME technique + kTwoR2EP_AB1, // Event plane resolution of event2 for ME technique + kTwoR2EP_AB2, // Event plane resolution of event2 for ME technique + kTwoR2EP_AC1, // Event plane resolution of event2 for ME technique + kTwoR2EP_AC2, // Event plane resolution of event2 for ME technique + kTwoR2EP_BC1, // Event plane resolution of event2 for ME technique + kTwoR2EP_BC2, // Event plane resolution of event2 for ME technique // Basic track/muon/pair wise variables kX, @@ -419,6 +446,7 @@ class VarManager : public TObject kTPCncls, kITSClusterMap, kTPCnclsCR, + kTPCnCRoverFindCls, kTPCchi2, kTPCsignal, kTPCsignalRandomized, @@ -430,7 +458,11 @@ class VarManager : public TObject kTOFbeta, kTrackLength, kTrackDCAxy, + kTrackDCAxyProng1, + kTrackDCAxyProng2, kTrackDCAz, + kTrackDCAzProng1, + kTrackDCAzProng2, kTrackDCAsigXY, kTrackDCAsigZ, kTrackDCAresXY, @@ -561,6 +593,8 @@ class VarManager : public TObject kCosThetaCS, kPhiHE, kPhiCS, + kDeltaPhiPair2, + kDeltaEtaPair2, kPsiPair, kDeltaPhiPair, kOpeningAngle, @@ -586,16 +620,37 @@ class VarManager : public TObject kS13A, kS31A, kM11REF, + kM11REFetagap, kM01POI, kM1111REF, + kM1111REFsmall, kM0111POI, kCORR2REF, + kCORR2REFw, + kCORR2REFsquared, + kCORR2REFsquaredw, + kCORR2REFetagap, + kCORR2REFetagapw, + kCORR2REFetagapsquaredw, kCORR2POI, + kCORR2POIw, + kCORR2POIsquaredw, + kCORR2POIsquaredMpw, kCORR4REF, + kCORR4REFw, + kCORR4REFsquaredw, kCORR4POI, - kC4REF, - kC4POI, - kV4, + kCORR4POIw, + kCORR4POIsquaredw, + kCORR4POIsquaredMpw, + kM11REFoverMp, + kM01POIoverMp, + kM1111REFoverMp, + kM0111POIoverMp, + kCORR2POIMp, + kCORR4POIMp, + kCORR2POIMpw, + kCORR4POIMpw, kPsi2A, kPsi2APOS, kPsi2ANEG, @@ -647,12 +702,16 @@ class VarManager : public TObject // Dilepton-track-track variables kQuadMass, + kQuadDefaultDileptonMass, kQuadPt, kQuadEta, kQuadPhi, kCosthetaDileptonDitrack, kDitrackMass, kDitrackPt, + kQ, + kDeltaR1, + kDeltaR2, // DQ-HF correlation variables kMassCharmHadron, @@ -693,7 +752,8 @@ class VarManager : public TObject enum EventFilters { kDoubleGap = 0, kSingleGapA, - kSingleGapC + kSingleGapC, + kITSUPCMode }; enum MuonExtrapolation { @@ -836,7 +896,6 @@ class VarManager : public TObject fgFitterThreeProngBarrel.setMinParamChange(minParamChange); fgFitterThreeProngBarrel.setMinRelChi2Change(minRelChi2Change); fgFitterThreeProngBarrel.setUseAbsDCA(useAbsDCA); - cout << "!!! fgFitterThreeProngBarrel bz = " << fgFitterThreeProngBarrel.getBz() << endl; fgUsedKF = false; } @@ -869,6 +928,8 @@ class VarManager : public TObject static void FillBC(T const& bc, float* values = nullptr); template static void FillEvent(T const& event, float* values = nullptr); + template + static void FillEventTrackEstimators(TEvent const& collision, TAssoc const& groupedTrackIndices, TTracks const& tracks, float* values = nullptr); template static void FillTwoEvents(T const& event1, T const& event2, float* values = nullptr); template @@ -889,6 +950,10 @@ class VarManager : public TObject static void FillGlobalMuonRefit(T1 const& muontrack, T2 const& mfttrack, const C& collision, float* values = nullptr); template static void FillPair(T1 const& t1, T2 const& t2, float* values = nullptr); + template + static void FillPairCollision(C const& collision, T1 const& t1, T2 const& t2, float* values = nullptr); + template + static void FillPairCollisionMatCorr(C const& collision, T1 const& t1, T2 const& t2, M const& materialCorr, P const& propagator, float* values = nullptr); template static void FillTriple(T1 const& t1, T2 const& t2, T3 const& t3, float* values = nullptr, PairCandidateType pairType = kTripleCandidateToEEPhoton); template @@ -918,6 +983,8 @@ class VarManager : public TObject template static void FillQVectorFromCentralFW(C const& collision, float* values = nullptr); template + static void FillNewQVectorFromCentralFW(C const& collision, float* values = nullptr); + template static void FillSpectatorPlane(C const& collision, float* values = nullptr); template static void FillPairVn(T1 const& t1, T2 const& t2, float* values = nullptr); @@ -964,6 +1031,12 @@ class VarManager : public TObject fgITSROFBorderMarginHigh = marginHigh; } + static void SetSORandEOR(uint64_t sor, uint64_t eor) + { + fgSOR = sor; + fgEOR = eor; + } + public: VarManager(); ~VarManager() override; @@ -987,6 +1060,8 @@ class VarManager : public TObject static int fgITSROFlength; // ITS ROF length (from ALPIDE parameters) static int fgITSROFBorderMarginLow; // ITS ROF border low margin 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 void FillEventDerived(float* values = nullptr); static void FillTrackDerived(float* values = nullptr); @@ -1253,11 +1328,12 @@ void VarManager::FillBC(T const& bc, float* values) if (!values) { values = fgValues; } - values[VarManager::kRunNo] = bc.runNumber(); - values[VarManager::kBC] = bc.globalBC(); + values[kRunNo] = bc.runNumber(); + values[kBC] = bc.globalBC(); values[kBCOrbit] = bc.globalBC() % o2::constants::lhc::LHCMaxBunches; - values[VarManager::kTimestamp] = bc.timestamp(); - values[VarManager::kRunIndex] = GetRunIndex(bc.runNumber()); + values[kTimestamp] = bc.timestamp(); + values[kTimeFromSOR] = (fgSOR > 0 ? (bc.timestamp() - fgSOR) / 60000. : -1.0); + values[kRunIndex] = GetRunIndex(bc.runNumber()); } template @@ -1278,6 +1354,12 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kIsNoITSROFBorder]) { values[kIsNoITSROFBorder] = event.selection_bit(o2::aod::evsel::kNoITSROFrameBorder); } + if (fgUsedVars[kTrackOccupancyInTimeRange]) { + values[kTrackOccupancyInTimeRange] = event.trackOccupancyInTimeRange(); + } + if (fgUsedVars[kNoCollInTimeRangeStandard]) { + values[kNoCollInTimeRangeStandard] = event.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); + } if (fgUsedVars[kIsNoTFBorder]) { values[kIsNoTFBorder] = event.selection_bit(o2::aod::evsel::kNoTimeFrameBorder); } @@ -1294,7 +1376,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kIsVertexTOFmatched] = event.selection_bit(o2::aod::evsel::kIsVertexTOFmatched); } if (fgUsedVars[kIsSel8]) { - values[kIsSel8] = event.selection_bit(o2::aod::evsel::kIsTriggerTVX); + 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[kIsINT7]) { values[kIsINT7] = (event.alias_bit(kINT7) > 0); @@ -1374,7 +1456,6 @@ void VarManager::FillEvent(T const& event, float* values) values[kMultNTracksITSOnly] = event.multNTracksITSOnly(); values[kMultNTracksTPCOnly] = event.multNTracksTPCOnly(); values[kMultNTracksITSTPC] = event.multNTracksITSTPC(); - values[kTrackOccupancyInTimeRange] = event.trackOccupancyInTimeRange(); values[kMultAllTracksTPCOnly] = event.multAllTracksTPCOnly(); values[kMultAllTracksITSTPC] = event.multAllTracksITSTPC(); if constexpr ((fillMap & ReducedEventMultExtra) > 0) { @@ -1401,6 +1482,9 @@ void VarManager::FillEvent(T const& event, float* values) if (fgUsedVars[kIsNoTFBorder]) { values[kIsNoTFBorder] = (event.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) > 0); } + if (fgUsedVars[kNoCollInTimeRangeStandard]) { + values[kNoCollInTimeRangeStandard] = (event.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) > 0); + } if (fgUsedVars[kIsNoSameBunch]) { values[kIsNoSameBunch] = (event.selection_bit(o2::aod::evsel::kNoSameBunchPileup) > 0); } @@ -1414,7 +1498,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kIsVertexTOFmatched] = (event.selection_bit(o2::aod::evsel::kIsVertexTOFmatched) > 0); } if (fgUsedVars[kIsSel8]) { - values[kIsSel8] = (event.selection_bit(o2::aod::evsel::kIsTriggerTVX) > 0); + 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[kIsDoubleGap]) { values[kIsDoubleGap] = (event.tag_bit(56 + kDoubleGap) > 0); @@ -1424,6 +1508,9 @@ void VarManager::FillEvent(T const& event, float* values) values[kIsSingleGapC] = (event.tag_bit(56 + kSingleGapC) > 0); values[kIsSingleGap] = values[kIsSingleGapA] || values[kIsSingleGapC]; } + if (fgUsedVars[kIsITSUPCMode]) { + values[kIsITSUPCMode] = (event.tag_bit(56 + kITSUPCMode) > 0); + } values[kCollisionTime] = event.collisionTime(); values[kCollisionTimeRes] = event.collisionTimeRes(); } @@ -1432,6 +1519,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kBC] = event.globalBC(); values[kBCOrbit] = event.globalBC() % o2::constants::lhc::LHCMaxBunches; values[kTimestamp] = event.timestamp(); + values[kTimeFromSOR] = (fgSOR > 0 ? (event.timestamp() - fgSOR) / 60000. : -1.0); values[kCentVZERO] = event.centRun2V0M(); values[kCentFT0C] = event.centFT0C(); if (fgUsedVars[kIsNoITSROFBorderRecomputed]) { @@ -1534,9 +1622,19 @@ void VarManager::FillEvent(T const& event, float* values) if constexpr ((fillMap & ReducedEventRefFlow) > 0) { values[kM1111REF] = event.m1111ref(); + values[kM1111REFsmall] = event.m1111ref(); values[kM11REF] = event.m11ref(); - values[kCORR4REF] = event.corr4ref(); + values[kM11REFetagap] = event.m11ref(); values[kCORR2REF] = event.corr2ref(); + values[kCORR2REFsquared] = event.corr2ref(); + values[kCORR2REFw] = event.corr2ref(); + values[kCORR2REFsquaredw] = event.corr2ref(); + values[kCORR2REFetagap] = event.corr2ref(); + values[kCORR2REFetagapw] = event.corr2ref(); + values[kCORR2REFetagapsquaredw] = event.corr2ref(); + values[kCORR4REF] = event.corr4ref(); + values[kCORR4REFw] = event.corr4ref(); + values[kCORR4REFsquaredw] = event.corr4ref(); values[kMultA] = event.multa(); } } @@ -1588,10 +1686,19 @@ void VarManager::FillEvent(T const& event, float* values) values[kPsi2ANEG] = Psi2ANEG; values[kPsi2B] = Psi2B; values[kPsi2C] = Psi2C; + + values[kR2SP_AB] = (values[kQ2X0A] * values[kQ2X0B] + values[kQ2Y0A] * values[kQ2Y0B]); + values[kR2SP_AC] = (values[kQ2X0A] * values[kQ2X0C] + values[kQ2Y0A] * values[kQ2Y0C]); + values[kR2SP_BC] = (values[kQ2X0B] * values[kQ2X0C] + values[kQ2Y0B] * values[kQ2Y0C]); + + values[kR2EP_AB] = TMath::Cos(2 * (Psi2A - Psi2B)); + values[kR2EP_AC] = TMath::Cos(2 * (Psi2A - Psi2C)); + values[kR2EP_BC] = TMath::Cos(2 * (Psi2B - Psi2C)); } if constexpr ((fillMap & CollisionMC) > 0) { values[kMCEventGeneratorId] = event.generatorsID(); + values[kMCEventSubGeneratorId] = event.getSubGeneratorId(); values[kMCVtxX] = event.posX(); values[kMCVtxY] = event.posY(); values[kMCVtxZ] = event.posZ(); @@ -1602,6 +1709,7 @@ void VarManager::FillEvent(T const& event, float* values) if constexpr ((fillMap & ReducedEventMC) > 0) { values[kMCEventGeneratorId] = event.generatorsID(); + values[kMCEventGeneratorId] = -999; // to be added in reduced events values[kMCVtxX] = event.mcPosX(); values[kMCVtxY] = event.mcPosY(); values[kMCVtxZ] = event.mcPosZ(); @@ -1615,6 +1723,7 @@ void VarManager::FillEvent(T const& event, float* values) values[kIsSingleGapA] = (event.eventFilter() & (uint64_t(1) << kSingleGapA)) > 0; values[kIsSingleGapC] = (event.eventFilter() & (uint64_t(1) << kSingleGapC)) > 0; values[kIsSingleGap] = values[kIsSingleGapA] || values[kIsSingleGapC]; + values[kIsITSUPCMode] = (event.eventFilter() & (uint64_t(1) << kITSUPCMode)) > 0; } if constexpr ((fillMap & ReducedZdc) > 0) { @@ -1624,6 +1733,56 @@ void VarManager::FillEvent(T const& event, float* values) FillEventDerived(values); } +template +void VarManager::FillEventTrackEstimators(TEvent const& collision, TAssoc const& assocs, TTracks const& /*tracks*/, float* values) +{ + // Compute median Z for the large dcaZ tracks in the TPC + // This is for studies of the pileup impact on the TPC + + if (!values) { + values = fgValues; + } + + if constexpr ((fillMap & Track) > 0 && (fillMap & TrackDCA) > 0) { + + std::vector tracksP; + std::vector tracksM; + + for (const auto& assoc : assocs) { + auto track = assoc.template track_as(); + // compute the dca of this track wrt the collision + auto trackPar = getTrackPar(track); + std::array dca{1e10f, 1e10f}; + trackPar.propagateParamToDCA({collision.posX(), collision.posY(), collision.posZ()}, fgMagField, &dca); + + // if it is a displaced track longitudinally, add it to the track vector + if (abs(dca[0]) < 3.0 && abs(dca[1]) > 4.0) { + if (track.tgl() > 0.1) { + tracksP.push_back(track.z()); + } + if (track.tgl() < -0.1) { + tracksM.push_back(track.z()); + } + } + } // end loop over associations + + // compute the number of pileup contributors and the median z for pileup + if (tracksP.size() > 0) { + std::sort(tracksP.begin(), tracksP.end()); + auto midP = tracksP.size() / 2; + values[kNTPCpileupContribA] = tracksP.size(); + values[kNTPCpileupZA] = (tracksP.size() % 2 ? (tracksP[midP] + tracksP[midP - 1]) / 2 : tracksP[midP]); + } + + if (tracksM.size() > 0) { + std::sort(tracksM.begin(), tracksM.end()); + values[kNTPCpileupContribC] = tracksM.size(); + auto midM = tracksM.size() / 2; + values[kNTPCpileupZC] = (tracksM.size() % 2 ? (tracksM[midM] + tracksM[midM - 1]) / 2 : tracksM[midM]); + } + } +} + template void VarManager::FillTwoEvents(T const& ev1, T const& ev2, float* values) { @@ -1671,21 +1830,78 @@ void VarManager::FillTwoMixEvents(T1 const& ev1, T1 const& ev2, T2 const& /*trac for (auto& track2 : tracks2) { Track2Filter = uint32_t(track2.isMuonSelected());} */ if constexpr ((fillMap & ReducedEventQvector) > 0) { + // Tobe used for the calculation of u1q1 and u2q2 + values[kQ2X0A1] = ev1.q2x0a(); + values[kQ2X0A2] = ev2.q2x0a(); + values[kQ2Y0A1] = ev1.q2y0a(); + values[kQ2Y0A2] = ev2.q2y0a(); + values[kTwoR2SP1] = (ev1.q2x0b() * ev1.q2x0c() + ev1.q2y0b() * ev1.q2y0c()); values[kTwoR2SP2] = (ev2.q2x0b() * ev2.q2x0c() + ev2.q2y0b() * ev2.q2y0c()); + values[kTwoR2SP_AB1] = (ev1.q2x0a() * ev1.q2x0b() + ev1.q2y0a() * ev1.q2y0b()); + values[kTwoR2SP_AB2] = (ev2.q2x0a() * ev2.q2x0b() + ev2.q2y0a() * ev2.q2y0b()); + values[kTwoR2SP_AC1] = (ev1.q2x0a() * ev1.q2x0c() + ev1.q2y0a() * ev1.q2y0c()); + values[kTwoR2SP_AC2] = (ev2.q2x0a() * ev2.q2x0c() + ev2.q2y0a() * ev2.q2y0c()); + values[kTwoR2SP_BC1] = (ev1.q2x0b() * ev1.q2x0c() + ev1.q2y0b() * ev1.q2y0c()); + values[kTwoR2SP_BC2] = (ev2.q2x0b() * ev2.q2x0c() + ev2.q2y0b() * ev2.q2y0c()); + if (ev1.q2y0a() * ev1.q2y0b() != 0.0) { + values[kTwoR2EP_AB1] = TMath::Cos(2 * (getEventPlane(2, ev1.q2x0a(), ev1.q2y0a()) - getEventPlane(2, ev1.q2x0b(), ev1.q2y0b()))); + } + if (ev2.q2y0a() * ev2.q2y0b() != 0.0) { + values[kTwoR2EP_AB2] = TMath::Cos(2 * (getEventPlane(2, ev2.q2x0a(), ev2.q2y0a()) - getEventPlane(2, ev2.q2x0b(), ev2.q2y0b()))); + } + if (ev1.q2y0a() * ev1.q2y0c() != 0.0) { + values[kTwoR2EP_AC1] = TMath::Cos(2 * (getEventPlane(2, ev1.q2x0a(), ev1.q2y0a()) - getEventPlane(2, ev1.q2x0c(), ev1.q2y0c()))); + } + if (ev2.q2y0a() * ev2.q2y0c() != 0.0) { + values[kTwoR2EP_AC2] = TMath::Cos(2 * (getEventPlane(2, ev2.q2x0a(), ev2.q2y0a()) - getEventPlane(2, ev2.q2x0c(), ev2.q2y0c()))); + } if (ev1.q2y0b() * ev1.q2y0c() != 0.0) { values[kTwoR2EP1] = TMath::Cos(2 * (getEventPlane(2, ev1.q2x0b(), ev1.q2y0b()) - getEventPlane(2, ev1.q2x0c(), ev1.q2y0c()))); + values[kTwoR2EP_BC1] = TMath::Cos(2 * (getEventPlane(2, ev1.q2x0b(), ev1.q2y0b()) - getEventPlane(2, ev1.q2x0c(), ev1.q2y0c()))); } - if (ev2.q2y0b() * ev2.q2y0c() != 0.0) { values[kTwoR2EP2] = TMath::Cos(2 * (getEventPlane(2, ev2.q2x0b(), ev2.q2y0b()) - getEventPlane(2, ev2.q2x0c(), ev2.q2y0c()))); + values[kTwoR2EP_BC2] = TMath::Cos(2 * (getEventPlane(2, ev2.q2x0b(), ev2.q2y0b()) - getEventPlane(2, ev2.q2x0c(), ev2.q2y0c()))); } + } + if constexpr ((fillMap & CollisionQvect) > 0) { // Tobe used for the calculation of u1q1 and u2q2 - values[kQ2X0A1] = ev1.q2x0a(); - values[kQ2X0A2] = ev2.q2x0a(); - values[kQ2Y0A1] = ev1.q2y0a(); - values[kQ2Y0A2] = ev2.q2y0a(); + values[kQ2X0A1] = (ev1.qvecBPosRe() * ev1.nTrkBPos() + ev1.qvecBNegRe() * ev1.nTrkBNeg()) / (ev1.nTrkBPos() + ev1.nTrkBNeg()); + values[kQ2X0A2] = (ev2.qvecBPosRe() * ev2.nTrkBPos() + ev2.qvecBNegRe() * ev2.nTrkBNeg()) / (ev2.nTrkBPos() + ev2.nTrkBNeg()); + values[kQ2Y0A1] = (ev1.qvecBPosIm() * ev1.nTrkBPos() + ev1.qvecBNegIm() * ev1.nTrkBNeg()) / (ev1.nTrkBPos() + ev1.nTrkBNeg()); + values[kQ2Y0A2] = (ev2.qvecBPosIm() * ev2.nTrkBPos() + ev2.qvecBNegIm() * ev2.nTrkBNeg()) / (ev2.nTrkBPos() + ev2.nTrkBNeg()); + + values[kTwoR2SP1] = (ev1.qvecFT0ARe() * ev1.qvecFT0CRe() + ev1.qvecFT0AIm() * ev1.qvecFT0CIm()); + values[kTwoR2SP2] = (ev2.qvecFT0ARe() * ev2.qvecFT0CRe() + ev2.qvecFT0AIm() * ev2.qvecFT0CIm()); + values[kTwoR2SP_AB1] = (values[kQ2X0A1] * ev1.qvecFT0ARe() + values[kQ2Y0A1] * ev1.qvecFT0AIm()); + values[kTwoR2SP_AB2] = (values[kQ2X0A2] * ev2.qvecFT0ARe() + values[kQ2Y0A2] * ev2.qvecFT0AIm()); + values[kTwoR2SP_AC1] = (values[kQ2X0A1] * ev1.qvecFT0CRe() + values[kQ2Y0A1] * ev1.qvecFT0CIm()); + values[kTwoR2SP_AC2] = (values[kQ2X0A2] * ev2.qvecFT0CRe() + values[kQ2Y0A2] * ev2.qvecFT0CIm()); + values[kTwoR2SP_BC1] = values[kTwoR2SP1]; + values[kTwoR2SP_BC2] = values[kTwoR2SP2]; + + if (values[kQ2Y0A1] * ev1.qvecFT0AIm() != 0.0) { + values[kTwoR2EP_AB1] = TMath::Cos(2 * (getEventPlane(2, values[kQ2X0A1], values[kQ2Y0A1]) - getEventPlane(2, ev1.qvecFT0ARe(), ev1.qvecFT0AIm()))); + } + if (values[kQ2Y0A2] * ev2.qvecFT0AIm() != 0.0) { + values[kTwoR2EP_AB2] = TMath::Cos(2 * (getEventPlane(2, values[kQ2X0A2], values[kQ2Y0A2]) - getEventPlane(2, ev2.qvecFT0ARe(), ev2.qvecFT0AIm()))); + } + if (values[kQ2Y0A1] * ev1.qvecFT0CIm() != 0.0) { + values[kTwoR2EP_AC1] = TMath::Cos(2 * (getEventPlane(2, values[kQ2X0A1], values[kQ2Y0A1]) - getEventPlane(2, ev1.qvecFT0CRe(), ev1.qvecFT0CIm()))); + } + if (values[kQ2Y0A2] * ev2.qvecFT0CIm() != 0.0) { + values[kTwoR2EP_AC2] = TMath::Cos(2 * (getEventPlane(2, values[kQ2X0A2], values[kQ2Y0A2]) - getEventPlane(2, ev2.qvecFT0CRe(), ev2.qvecFT0CIm()))); + } + if (ev1.qvecFT0AIm() * ev1.qvecFT0CIm() != 0.0) { + values[kTwoR2EP1] = TMath::Cos(2 * (getEventPlane(2, ev1.qvecFT0ARe(), ev1.qvecFT0AIm()) - getEventPlane(2, ev1.qvecFT0CRe(), ev1.qvecFT0CIm()))); + values[kTwoR2EP_BC1] = values[kTwoR2EP1]; + } + if (ev2.qvecFT0AIm() * ev2.qvecFT0CIm() != 0.0) { + values[kTwoR2EP2] = TMath::Cos(2 * (getEventPlane(2, ev2.qvecFT0ARe(), ev2.qvecFT0AIm()) - getEventPlane(2, ev2.qvecFT0CRe(), ev2.qvecFT0CIm()))); + values[kTwoR2EP_BC2] = values[kTwoR2EP2]; + } } if (std::isnan(VarManager::fgValues[VarManager::kTwoR2SP1]) == true || std::isnan(VarManager::fgValues[VarManager::kTwoR2EP1]) == true) { @@ -1694,6 +1910,24 @@ void VarManager::FillTwoMixEvents(T1 const& ev1, T1 const& ev2, T2 const& /*trac values[kTwoR2EP1] = -999.; values[kTwoR2EP2] = -999.; } + if (std::isnan(VarManager::fgValues[VarManager::kTwoR2SP_AB1]) == true || std::isnan(VarManager::fgValues[VarManager::kTwoR2EP_AB1]) == true) { + values[kTwoR2SP_AB1] = -999.; + values[kTwoR2SP_AB2] = -999.; + values[kTwoR2EP_AB1] = -999.; + values[kTwoR2EP_AB2] = -999.; + } + if (std::isnan(VarManager::fgValues[VarManager::kTwoR2SP_AC1]) == true || std::isnan(VarManager::fgValues[VarManager::kTwoR2EP_AC1]) == true) { + values[kTwoR2SP_AC1] = -999.; + values[kTwoR2SP_AC2] = -999.; + values[kTwoR2EP_AC1] = -999.; + values[kTwoR2EP_AC2] = -999.; + } + if (std::isnan(VarManager::fgValues[VarManager::kTwoR2SP_BC1]) == true || std::isnan(VarManager::fgValues[VarManager::kTwoR2EP_BC1]) == true) { + values[kTwoR2SP_BC1] = -999.; + values[kTwoR2SP_BC2] = -999.; + values[kTwoR2EP_BC1] = -999.; + values[kTwoR2EP_BC2] = -999.; + } } template @@ -1850,6 +2084,9 @@ void VarManager::FillTrack(T const& track, float* values) values[kHasTPC] = track.hasTPC(); if constexpr ((fillMap & TrackExtra) > 0) { + if (fgUsedVars[kTPCnCRoverFindCls]) { + values[kTPCnCRoverFindCls] = track.tpcCrossedRowsOverFindableCls(); + } if (fgUsedVars[kITSncls]) { values[kITSncls] = track.itsNCls(); // dynamic column } @@ -2164,15 +2401,12 @@ void VarManager::FillTrackCollision(T const& track, C const& collision, float* v } if constexpr ((fillMap & MuonCov) > 0 || (fillMap & ReducedMuonCov) > 0) { - o2::dataformats::GlobalFwdTrack propmuon = PropagateMuon(track, collision); o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(track, collision, kToDCA); float dcaX = (propmuonAtDCA.getX() - collision.posX()); float dcaY = (propmuonAtDCA.getY() - collision.posY()); float dcaXY = std::sqrt(dcaX * dcaX + dcaY * dcaY); values[kMuonPDca] = track.p() * dcaXY; - values[kMuonDCAx] = dcaX; - values[kMuonDCAy] = dcaY; } } @@ -2335,6 +2569,21 @@ 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; + if (fgUsedVars[kDeltaPhiPair2]) { + double phipair2 = v1.Phi() - v2.Phi(); + if (phipair2 > 3 * TMath::Pi() / 2) { + values[kDeltaPhiPair2] = phipair2 - 2 * TMath::Pi(); + } else if (phipair2 < -TMath::Pi() / 2) { + values[kDeltaPhiPair2] = phipair2 + 2 * TMath::Pi(); + } else { + values[kDeltaPhiPair2] = phipair2; + } + } + + if (fgUsedVars[kDeltaEtaPair2]) { + values[kDeltaEtaPair2] = v1.Eta() - v2.Eta(); + } + if (fgUsedVars[kPsiPair]) { values[kDeltaPhiPair] = (t1.sign() * fgMagField > 0.) ? (v1.Phi() - v2.Phi()) : (v2.Phi() - v1.Phi()); double xipair = TMath::ACos((v1.Px() * v2.Px() + v1.Py() * v2.Py() + v1.Pz() * v2.Pz()) / v1.P() / v2.P()); @@ -2444,6 +2693,116 @@ void VarManager::FillPair(T1 const& t1, T2 const& t2, float* values) } } +template +void VarManager::FillPairCollision(const C& collision, T1 const& t1, T2 const& t2, float* values) +{ + if (!values) { + values = fgValues; + } + + if constexpr ((pairType == kDecayToEE) && ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0)) { + + if (fgUsedVars[kQuadDCAabsXY] || fgUsedVars[kQuadDCAsigXY] || fgUsedVars[kQuadDCAabsZ] || fgUsedVars[kQuadDCAsigZ] || fgUsedVars[kQuadDCAsigXYZ] || fgUsedVars[kSignQuadDCAsigXY]) { + + auto trackPart1 = getTrackPar(t1); + std::array dca1{1e10f, 1e10f}; + trackPart1.propagateParamToDCA({collision.posX(), collision.posY(), collision.posZ()}, fgMagField, &dca1); + + auto trackPart2 = getTrackPar(t2); + std::array dca2{1e10f, 1e10f}; + trackPart2.propagateParamToDCA({collision.posX(), collision.posY(), collision.posZ()}, fgMagField, &dca2); + + // Recalculated quantities + double dca1XY = dca1[0]; + double dca2XY = dca2[0]; + double dca1Z = dca1[1]; + double dca2Z = dca2[1]; + double dca1sigXY = dca1XY / std::sqrt(t1.cYY()); + double dca2sigXY = dca2XY / std::sqrt(t2.cYY()); + double dca1sigZ = dca1Z / std::sqrt(t1.cZZ()); + double dca2sigZ = dca2Z / std::sqrt(t2.cZZ()); + + values[kQuadDCAabsXY] = std::sqrt((dca1XY * dca1XY + dca2XY * dca2XY) / 2); + values[kQuadDCAsigXY] = std::sqrt((dca1sigXY * dca1sigXY + dca2sigXY * dca2sigXY) / 2); + values[kQuadDCAabsZ] = std::sqrt((dca1Z * dca1Z + dca2Z * dca2Z) / 2); + values[kQuadDCAsigZ] = std::sqrt((dca1sigZ * dca1sigZ + dca2sigZ * dca2sigZ) / 2); + values[kSignQuadDCAsigXY] = t1.sign() * t2.sign() * TMath::Sign(1., dca1sigXY) * TMath::Sign(1., dca2sigXY) * std::sqrt((dca1sigXY * dca1sigXY + dca2sigXY * dca2sigXY) / 2); + + double det1 = t1.cYY() * t1.cZZ() - t1.cZY() * t1.cZY(); + double det2 = t2.cYY() * t2.cZZ() - t2.cZY() * t2.cZY(); + if ((det1 < 0) || (det2 < 0)) { + values[kQuadDCAsigXYZ] = -999; + } else { + double chi2t1 = (dca1XY * dca1XY * t1.cZZ() + dca1Z * dca1Z * t1.cYY() - 2. * dca1XY * dca1Z * t1.cZY()) / det1; + double chi2t2 = (dca2XY * dca2XY * t2.cZZ() + dca2Z * dca2Z * t2.cYY() - 2. * dca2XY * dca2Z * t2.cZY()) / det2; + + double dca1sigXYZ = std::sqrt(std::abs(chi2t1) / 2.); + double dca2sigXYZ = std::sqrt(std::abs(chi2t2) / 2.); + + values[kQuadDCAsigXYZ] = std::sqrt((dca1sigXYZ * dca1sigXYZ + dca2sigXYZ * dca2sigXYZ) / 2); + } + } + } +} + +template +void VarManager::FillPairCollisionMatCorr(C const& collision, T1 const& t1, T2 const& t2, M const& materialCorr, P const& propagator, float* values) +{ + if (!values) { + values = fgValues; + } + + if constexpr ((pairType == kDecayToEE) && ((fillMap & TrackCov) > 0 || (fillMap & ReducedTrackBarrelCov) > 0)) { + + if (fgUsedVars[kQuadDCAabsXY] || fgUsedVars[kQuadDCAsigXY] || fgUsedVars[kQuadDCAabsZ] || fgUsedVars[kQuadDCAsigZ] || fgUsedVars[kQuadDCAsigXYZ] || fgUsedVars[kSignQuadDCAsigXY]) { + + auto trackPart1 = getTrackPar(t1); + std::array dca1{1e10f, 1e10f}; + std::array pVect1 = {t1.px(), t1.py(), t1.pz()}; + // trackPar.propagateParamToDCA({collision.posX(), collision.posY(), collision.posZ()}, fgMagField, &dca); + propagator->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPart1, 2.f, materialCorr, &dca1); + getPxPyPz(trackPart1, pVect1); + + auto trackPart2 = getTrackPar(t2); + std::array dca2{1e10f, 1e10f}; + std::array pVect2 = {t2.px(), t2.py(), t2.pz()}; + // trackPar.propagateParamToDCA({collision.posX(), collision.posY(), collision.posZ()}, fgMagField, &dca); + propagator->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPart2, 2.f, materialCorr, &dca2); + getPxPyPz(trackPart2, pVect2); + + // Recalculated quantities + double dca1XY = dca1[0]; + double dca2XY = dca2[0]; + double dca1Z = dca1[1]; + double dca2Z = dca2[1]; + double dca1sigXY = dca1XY / std::sqrt(t1.cYY()); + double dca2sigXY = dca2XY / std::sqrt(t2.cYY()); + double dca1sigZ = dca1Z / std::sqrt(t1.cZZ()); + double dca2sigZ = dca2Z / std::sqrt(t2.cZZ()); + + values[kQuadDCAabsXY] = std::sqrt((dca1XY * dca1XY + dca2XY * dca2XY) / 2); + values[kQuadDCAsigXY] = std::sqrt((dca1sigXY * dca1sigXY + dca2sigXY * dca2sigXY) / 2); + values[kQuadDCAabsZ] = std::sqrt((dca1Z * dca1Z + dca2Z * dca2Z) / 2); + values[kQuadDCAsigZ] = std::sqrt((dca1sigZ * dca1sigZ + dca2sigZ * dca2sigZ) / 2); + values[kSignQuadDCAsigXY] = t1.sign() * t2.sign() * TMath::Sign(1., dca1sigXY) * TMath::Sign(1., dca2sigXY) * std::sqrt((dca1sigXY * dca1sigXY + dca2sigXY * dca2sigXY) / 2); + + double det1 = t1.cYY() * t1.cZZ() - t1.cZY() * t1.cZY(); + double det2 = t2.cYY() * t2.cZZ() - t2.cZY() * t2.cZY(); + if ((det1 < 0) || (det2 < 0)) { + values[kQuadDCAsigXYZ] = -999; + } else { + double chi2t1 = (dca1XY * dca1XY * t1.cZZ() + dca1Z * dca1Z * t1.cYY() - 2. * dca1XY * dca1Z * t1.cZY()) / det1; + double chi2t2 = (dca2XY * dca2XY * t2.cZZ() + dca2Z * dca2Z * t2.cYY() - 2. * dca2XY * dca2Z * t2.cZY()) / det2; + + double dca1sigXYZ = std::sqrt(std::abs(chi2t1) / 2.); + double dca2sigXYZ = std::sqrt(std::abs(chi2t2) / 2.); + + values[kQuadDCAsigXYZ] = std::sqrt((dca1sigXYZ * dca1sigXYZ + dca2sigXYZ * dca2sigXYZ) / 2); + } + } + } +} + template void VarManager::FillTriple(T1 const& t1, T2 const& t2, T3 const& t3, float* values, PairCandidateType pairType) { @@ -2510,6 +2869,21 @@ void VarManager::FillTriple(T1 const& t1, T2 const& t2, T3 const& t3, float* val values[kPhi] = v123.Phi(); values[kRap] = -v123.Rapidity(); } + + if (pairType == kTripleCandidateToKKPi) { + float m1 = o2::constants::physics::MassKaonCharged; + float m2 = o2::constants::physics::MassPionCharged; + + ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), m1); + ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), m1); + ROOT::Math::PtEtaPhiMVector v3(t3.pt(), t3.eta(), t3.phi(), m2); + ROOT::Math::PtEtaPhiMVector v123 = v1 + v2 + v3; + values[kMass] = v123.M(); + values[kPt] = v123.Pt(); + values[kEta] = v123.Eta(); + values[kPhi] = v123.Phi(); + values[kRap] = -v123.Rapidity(); + } } template @@ -2548,6 +2922,21 @@ void VarManager::FillPairME(T1 const& t1, T2 const& t2, float* values) values[kPhi] = v12.Phi() > 0 ? v12.Phi() : v12.Phi() + 2. * M_PI; values[kRap] = -v12.Rapidity(); + if (fgUsedVars[kDeltaPhiPair2]) { + double phipair2ME = v1.Phi() - v2.Phi(); + if (phipair2ME > 3 * TMath::Pi() / 2) { + values[kDeltaPhiPair2] = phipair2ME - 2 * TMath::Pi(); + } else if (phipair2ME < -TMath::Pi() / 2) { + values[kDeltaPhiPair2] = phipair2ME + 2 * TMath::Pi(); + } else { + values[kDeltaPhiPair2] = phipair2ME; + } + } + + if (fgUsedVars[kDeltaEtaPair2]) { + values[kDeltaEtaPair2] = v1.Eta() - v2.Eta(); + } + // TODO: provide different computations for vn // Compute the scalar product UQ for two muon from different event using Q-vector from A, for second and third harmonic values[kU2Q2Ev1] = values[kQ2X0A1] * std::cos(2 * v1.Phi()) + values[kQ2Y0A1] * std::sin(2 * v1.Phi()); @@ -2703,14 +3092,7 @@ void VarManager::FillPairVertexing(C const& collision, T const& t1, T const& t2, t2.c1PtX(), t2.c1PtY(), t2.c1PtPhi(), t2.c1PtTgl(), t2.c1Pt21Pt2()}; SMatrix55 t2covs(v2.begin(), v2.end()); o2::track::TrackParCovFwd pars2{t2.z(), t2pars, t2covs, chi22}; - if (std::abs(t2.cXX()) < 1.0e-6) { - // TODO: Some rare fwd-tracks have very small covariances and the DCAFitter throws a fatal! - // This is a protection, but please check for the reason and eventually change the behaviour. - // At the moment, when these tracks are encountered, the vertexing quantities are initialized to default values (-999) - procCode = 0; - } else { - procCode = fgFitterTwoProngFwd.process(pars1, pars2); - } + procCode = fgFitterTwoProngFwd.process(pars1, pars2); } else { return; } @@ -3528,9 +3910,9 @@ void VarManager::FillDileptonTrackVertexing(C const& collision, T1 const& lepton values[kVertexingTauxyProjectedNs] = values[kVertexingTauxyProjected] / o2::constants::physics::LightSpeedCm2NS; values[kVertexingTauzProjected] = (values[kVertexingLzProjected] * KFGeoThreeProng.GetMass()) / TMath::Abs(KFGeoThreeProng.GetPz()); } // end Run 2 quantities - } // end eventHasVtxCov - } // end (candidateType == kBtoJpsiEEK) && trackHasCov - } // end KF + } // end eventHasVtxCov + } // end (candidateType == kBtoJpsiEEK) && trackHasCov + } // end KF } template @@ -3599,6 +3981,23 @@ void VarManager::FillQVectorFromGFW(C const& /*collision*/, A const& compA11, A 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[kCORR2REF] = std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kCORR2REF]; + values[kCORR4REF] = std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) ? 0 : values[kCORR4REF]; + values[kCORR2REFw] = values[kCORR2REF] * values[kM11REF]; + values[kCORR2REFsquared] = values[kCORR2REF] * values[kCORR2REF]; + values[kCORR2REFsquaredw] = values[kCORR2REF] * values[kCORR2REF] * values[kM11REF]; + values[kCORR4REFw] = values[kCORR4REF] * values[kM1111REF]; + values[kCORR4REFsquaredw] = values[kCORR4REF] * values[kCORR4REF] * values[kM1111REF]; + + // For cumulants: A = Full TPC, B = Negative TPC, C = Positive TPC + complex QA(values[kQ2X0A] * values[kS11A], values[kQ2Y0A] * values[kS11A]); + complex QB(values[kQ2X0B] * S11B, values[kQ2Y0B] * S11B); + complex QC(values[kQ2X0C] * S11C, values[kQ2Y0C] * S11C); + values[kM11REFetagap] = S11B * S11C; + values[kCORR2REFetagap] = ((QB * conj(QC)).real()) / values[kM11REFetagap]; + values[kCORR2REFetagap] = std::isnan(values[kCORR2REFetagap]) || std::isinf(values[kCORR2REFetagap]) ? 0 : values[kCORR2REFetagap]; + values[kCORR2REFetagapw] = values[kCORR2REFetagap] * values[kM11REFetagap]; + values[kCORR2REFetagapsquaredw] = values[kCORR2REFetagap] * values[kCORR2REFetagap] * values[kM11REFetagap]; // TODO: provide different computations for R // Compute the R factor using the 2 sub-events technique for second and third harmonic @@ -3630,21 +4029,21 @@ void VarManager::FillQVectorFromCentralFW(C const& collision, float* values) values = fgValues; } - float xQVecFT0a = collision.qvecFT0ARe(); // already normalised - float yQVecFT0a = collision.qvecFT0AIm(); // already normalised - float xQVecFT0c = collision.qvecFT0CRe(); // already normalised - float yQVecFT0c = collision.qvecFT0CIm(); // already normalised - float xQVecFT0m = collision.qvecFT0MRe(); // already normalised - float yQVecFT0m = collision.qvecFT0MIm(); // already normalised - float xQVecFV0a = collision.qvecFV0ARe(); // already normalised - float yQVecFV0a = collision.qvecFV0AIm(); // already normalised - float xQVecBPos = collision.qvecBPosRe(); // already normalised - float yQVecBPos = collision.qvecBPosIm(); // already normalised - float xQVecBNeg = collision.qvecBNegRe(); // already normalised - float yQVecBNeg = collision.qvecBNegIm(); // already normalised - - values[kQ2X0A] = (collision.nTrkBPos() * xQVecBPos + collision.nTrkBNeg() * xQVecBNeg) / (collision.nTrkBPos() + collision.nTrkBNeg()); - values[kQ2Y0A] = (collision.nTrkBPos() * yQVecBPos + collision.nTrkBNeg() * yQVecBNeg) / (collision.nTrkBPos() + collision.nTrkBNeg()); + float xQVecFT0a = collision.qvecFT0ARe(); // already normalised + float yQVecFT0a = collision.qvecFT0AIm(); // already normalised + float xQVecFT0c = collision.qvecFT0CRe(); // already normalised + float yQVecFT0c = collision.qvecFT0CIm(); // already normalised + float xQVecFT0m = collision.qvecFT0MRe(); // already normalised + float yQVecFT0m = collision.qvecFT0MIm(); // already normalised + float xQVecFV0a = collision.qvecFV0ARe(); // already normalised + float yQVecFV0a = collision.qvecFV0AIm(); // already normalised + float xQVecBPos = collision.qvecTPCposRe(); // already normalised + float yQVecBPos = collision.qvecTPCposIm(); // already normalised + float xQVecBNeg = collision.qvecTPCnegRe(); // already normalised + float yQVecBNeg = collision.qvecTPCnegIm(); // already normalised + + values[kQ2X0A] = collision.qvecTPCallRe(); + values[kQ2Y0A] = collision.qvecTPCallIm(); values[kQ2X0APOS] = xQVecBPos; values[kQ2Y0APOS] = yQVecBPos; values[kQ2X0ANEG] = xQVecBNeg; @@ -3653,9 +4052,9 @@ void VarManager::FillQVectorFromCentralFW(C const& collision, float* values) values[kQ2Y0B] = yQVecFT0a; values[kQ2X0C] = xQVecFT0c; values[kQ2Y0C] = yQVecFT0c; - values[kMultA] = collision.nTrkBPos() + collision.nTrkBNeg(); - values[kMultAPOS] = collision.nTrkBPos(); - values[kMultANEG] = collision.nTrkBNeg(); + values[kMultA] = collision.nTrkTPCpos() + collision.nTrkTPCneg(); + values[kMultAPOS] = collision.nTrkTPCpos(); + values[kMultANEG] = collision.nTrkTPCneg(); values[kMultB] = collision.sumAmplFT0A(); // Be careful, this is weighted sum of multiplicity values[kMultC] = collision.sumAmplFT0C(); // Be careful, this is weighted sum of multiplicity @@ -3738,6 +4137,26 @@ void VarManager::FillSpectatorPlane(C const& collision, float* values) } float znaCommon = collision.energyCommonZNA() < 0 ? -1.f : collision.energyCommonZNA(); float zncCommon = collision.energyCommonZNC() < 0 ? -1.f : collision.energyCommonZNC(); + float zpaCommon = collision.energyCommonZPA() < 0 ? -1.f : collision.energyCommonZPA(); + float zpcCommon = collision.energyCommonZPC() < 0 ? -1.f : collision.energyCommonZPC(); + + // Store ZNA and ZNC energies for calibrations + values[kEnergyCommonZNA] = znaCommon; + values[kEnergyCommonZNC] = zncCommon; + values[kEnergyCommonZPA] = zpaCommon; + values[kEnergyCommonZPC] = zpcCommon; + values[kEnergyZNA1] = znaEnergy[0]; + values[kEnergyZNA2] = znaEnergy[1]; + values[kEnergyZNA3] = znaEnergy[2]; + values[kEnergyZNA4] = znaEnergy[3]; + values[kEnergyZNC1] = zncEnergy[0]; + values[kEnergyZNC2] = zncEnergy[1]; + values[kEnergyZNC3] = zncEnergy[2]; + values[kEnergyZNC4] = zncEnergy[3]; + values[kTimeZNA] = collision.timeZNA(); + values[kTimeZNC] = collision.timeZNC(); + values[kTimeZPA] = collision.timeZPA(); + values[kTimeZPC] = collision.timeZPC(); constexpr float beamEne = 5.36 * 0.5; constexpr float x[4] = {-1.75, 1.75, -1.75, 1.75}; @@ -3892,6 +4311,14 @@ void VarManager::FillPairVn(T1 const& t1, T2 const& t2, float* values) values[kM0111POI] = values[kMultDimuons] * (values[kS31A] - 3. * values[kS11A] * values[kS12A] + 2. * values[kS13A]); values[kCORR2POI] = (P2 * conj(Q21)).real() / values[kM01POI]; values[kCORR4POI] = (P2 * Q21 * conj(Q21) * conj(Q21) - P2 * Q21 * conj(Q42) - 2. * values[kS12A] * P2 * conj(Q21) + 2. * P2 * conj(Q23)).real() / values[kM0111POI]; + values[kM01POIoverMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM01POI]) || std::isinf(values[kM01POI])) ? values[kM01POI] / values[kMultDimuons] : 0; + values[kM0111POIoverMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM0111POI]) || std::isinf(values[kM0111POI])) ? values[kM0111POI] / values[kMultDimuons] : 0; + values[kM11REFoverMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM11REF]) || std::isinf(values[kM11REF])) ? values[kM11REF] / values[kMultDimuons] : 0; + values[kM1111REFoverMp] = values[kMultDimuons] > 0 && !(std::isnan(values[kM1111REF]) || std::isinf(values[kM1111REF])) ? values[kM1111REF] / values[kMultDimuons] : 0; + values[kCORR2POIMp] = std::isnan(values[kCORR2POI]) || std::isinf(values[kCORR2POI]) ? 0 : values[kCORR2POI] * values[kMultDimuons]; + values[kCORR4POIMp] = std::isnan(values[kCORR4POI]) || std::isinf(values[kCORR4POI]) ? 0 : values[kCORR4POI] * values[kMultDimuons]; + values[kCORR2REF] = std::isnan(values[kCORR2REF]) || std::isinf(values[kCORR2REF]) ? 0 : values[kCORR2REF]; + values[kCORR4REF] = std::isnan(values[kCORR4REF]) || std::isinf(values[kCORR4REF]) ? 0 : values[kCORR4REF]; } } @@ -4039,16 +4466,16 @@ void VarManager::FillDileptonTrackTrack(T1 const& dilepton, T2 const& hadron1, T values = fgValues; } - double DefaultdileptonMass = 3.096; + double defaultDileptonMass = 3.096; double hadronMass1 = o2::constants::physics::MassPionCharged; double hadronMass2 = o2::constants::physics::MassPionCharged; if (candidateType == kXtoJpsiPiPi) { - DefaultdileptonMass = 3.096; + defaultDileptonMass = 3.096; hadronMass1 = o2::constants::physics::MassPionCharged; hadronMass2 = o2::constants::physics::MassPionCharged; } if (candidateType == kChictoJpsiEE) { - DefaultdileptonMass = 3.096; + defaultDileptonMass = 3.096; hadronMass1 = o2::constants::physics::MassElectron; hadronMass2 = o2::constants::physics::MassElectron; } @@ -4057,18 +4484,31 @@ void VarManager::FillDileptonTrackTrack(T1 const& dilepton, T2 const& hadron1, T ROOT::Math::PtEtaPhiMVector v2(hadron1.pt(), hadron1.eta(), hadron1.phi(), hadronMass1); ROOT::Math::PtEtaPhiMVector v3(hadron2.pt(), hadron2.eta(), hadron2.phi(), hadronMass2); ROOT::Math::PtEtaPhiMVector v123 = v1 + v2 + v3; - values[kQuadMass] = v123.M() - v1.M() + DefaultdileptonMass; + values[kQuadMass] = v123.M(); + values[kQuadDefaultDileptonMass] = v123.M() - v1.M() + defaultDileptonMass; values[kQuadPt] = v123.Pt(); values[kQuadEta] = v123.Eta(); values[kQuadPhi] = v123.Phi(); - if (fgUsedVars[kCosthetaDileptonDitrack] || fgUsedVars[kPairMass] || fgUsedVars[kPairPt] || fgUsedVars[kDitrackPt] || fgUsedVars[kDitrackMass]) { + values[kTrackDCAxyProng1] = hadron1.dcaXY(); + values[kTrackDCAzProng1] = hadron1.dcaZ(); + values[kPt1] = hadron1.pt(); + + values[kTrackDCAxyProng2] = hadron2.dcaXY(); + values[kTrackDCAzProng2] = hadron2.dcaZ(); + values[kPt2] = hadron2.pt(); + + if (fgUsedVars[kCosthetaDileptonDitrack] || fgUsedVars[kPairMass] || fgUsedVars[kPairPt] || fgUsedVars[kDitrackPt] || fgUsedVars[kDitrackMass] || fgUsedVars[kQ] || fgUsedVars[kDeltaR1] || fgUsedVars[kDeltaR2] || fgUsedVars[kRap]) { ROOT::Math::PtEtaPhiMVector v23 = v2 + v3; values[kPairMass] = v1.M(); values[kPairPt] = v1.Pt(); values[kDitrackMass] = v23.M(); 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[kRap] = v123.Rapidity(); } } diff --git a/PWGDQ/DataModel/ReducedInfoTables.h b/PWGDQ/DataModel/ReducedInfoTables.h index bcb96f28e23..f50c92dc5ec 100644 --- a/PWGDQ/DataModel/ReducedInfoTables.h +++ b/PWGDQ/DataModel/ReducedInfoTables.h @@ -25,6 +25,8 @@ #include "Common/DataModel/PIDResponse.h" #include "MathUtils/Utils.h" +#include "PWGHF/Utils/utilsPid.h" + namespace o2::aod { @@ -52,6 +54,17 @@ DECLARE_SOA_COLUMN(NTPCpileupZC, nTPCpileupZC, float); //! Median Z p DECLARE_SOA_COLUMN(NTPCtracksInPast, nTPCtracksInPast, int); //! Number of TPC tracks in the past events (configurable, but e.g. one drift time) DECLARE_SOA_COLUMN(NTPCtracksInFuture, nTPCtracksInFuture, int); //! Number of TPC tracks in the future events (configurable, but e.g. one drift time) +// Columns declared to guarantee the backward compatibility of the tables +DECLARE_SOA_COLUMN(QvecBPosRe, qvecBPosRe, float); +DECLARE_SOA_COLUMN(QvecBPosIm, qvecBPosIm, float); +DECLARE_SOA_COLUMN(QvecBNegRe, qvecBNegRe, float); +DECLARE_SOA_COLUMN(QvecBNegIm, qvecBNegIm, float); +DECLARE_SOA_COLUMN(QvecBAllRe, qvecBAllRe, float); +DECLARE_SOA_COLUMN(QvecBAllIm, qvecBAllIm, float); +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) @@ -97,18 +110,11 @@ DECLARE_SOA_COLUMN(M11REF, m11ref, float); //! Weighted multiplicity of <<2 DECLARE_SOA_COLUMN(M1111REF, m1111ref, float); //! Weighted multiplicity of <<4>> for reference flow } // namespace reducedevent -DECLARE_SOA_TABLE(ReducedEvents, "AOD", "REDUCEDEVENT", //! Main event information table - o2::soa::Index<>, - reducedevent::Tag, bc::RunNumber, - collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, - collision::CollisionTime, collision::CollisionTimeRes); - -DECLARE_SOA_TABLE(StoredReducedEvents, "AOD1", "REDUCEDEVENT", //! Main event information table - o2::soa::Index<>, - reducedevent::Tag, bc::RunNumber, - collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, - collision::CollisionTime, collision::CollisionTimeRes, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(ReducedEvents, "REDUCEDEVENT", //! Main event information table + o2::soa::Index<>, + reducedevent::Tag, bc::RunNumber, + collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, + collision::CollisionTime, collision::CollisionTimeRes); DECLARE_SOA_TABLE(ReducedEventsExtended, "AOD", "REEXTENDED", //! Extended event information bc::GlobalBC, evsel::Alias, evsel::Selection, timestamp::Timestamp, cent::CentRun2V0M, @@ -142,8 +148,11 @@ DECLARE_SOA_TABLE(ReducedEventsQvectorExtra, "AOD", "REQVECTOREXTRA", //! Eve reducedevent::S11A, reducedevent::S12A, reducedevent::S13A, reducedevent::S31A); DECLARE_SOA_TABLE(ReducedEventsQvectorCentr, "AOD", "REQVECTORCTR", //! Event Q-vector information from central framework - qvec::QvecFT0ARe, qvec::QvecFT0AIm, qvec::QvecFT0CRe, qvec::QvecFT0CIm, qvec::QvecFT0MRe, qvec::QvecFT0MIm, qvec::QvecFV0ARe, qvec::QvecFV0AIm, qvec::QvecBPosRe, qvec::QvecBPosIm, qvec::QvecBNegRe, qvec::QvecBNegIm, - qvec::SumAmplFT0A, qvec::SumAmplFT0C, qvec::SumAmplFT0M, qvec::SumAmplFV0A, qvec::NTrkBPos, qvec::NTrkBNeg); + qvec::QvecFT0ARe, qvec::QvecFT0AIm, qvec::QvecFT0CRe, qvec::QvecFT0CIm, qvec::QvecFT0MRe, qvec::QvecFT0MIm, qvec::QvecFV0ARe, qvec::QvecFV0AIm, reducedevent::QvecBPosRe, reducedevent::QvecBPosIm, reducedevent::QvecBNegRe, reducedevent::QvecBNegIm, + qvec::SumAmplFT0A, qvec::SumAmplFT0C, qvec::SumAmplFT0M, qvec::SumAmplFV0A, reducedevent::NTrkBPos, reducedevent::NTrkBNeg); + +DECLARE_SOA_TABLE(ReducedEventsQvectorCentrExtra, "AOD", "REQVECCTREXTA", //! Event Q-vector information from central framework with TPC all + reducedevent::QvecBAllRe, reducedevent::QvecBAllIm, reducedevent::NTrkBAll); DECLARE_SOA_TABLE(ReducedEventsRefFlow, "AOD", "REREFFLOW", //! Event Ref Flow information reducedevent::M11REF, reducedevent::M1111REF, reducedevent::CORR2REF, reducedevent::CORR4REF, cent::CentFT0C); @@ -172,6 +181,7 @@ using ReducedEventMultAll = ReducedEventsMultAll::iterator; using ReducedEventQvector = ReducedEventsQvector::iterator; using ReducedEventQvectorExtra = ReducedEventsQvectorExtra::iterator; using ReducedEventQvectorCentr = ReducedEventsQvectorCentr::iterator; +using ReducedEventQvectorCentrExtra = ReducedEventsQvectorCentrExtra::iterator; using ReducedEventRefFlow = ReducedEventsRefFlow::iterator; using ReducedEventQvectorZN = ReducedEventsQvectorZN::iterator; using ReducedMCEvent = ReducedMCEvents::iterator; @@ -192,6 +202,14 @@ DECLARE_SOA_COLUMN(EnergyCommonZNA, energyCommonZNA, float); //! DECLARE_SOA_COLUMN(EnergyCommonZNC, energyCommonZNC, float); //! DECLARE_SOA_COLUMN(EnergyCommonZPA, energyCommonZPA, float); //! DECLARE_SOA_COLUMN(EnergyCommonZPC, energyCommonZPC, float); //! +DECLARE_SOA_COLUMN(EnergyZNA1, energyZNA1, float); //! +DECLARE_SOA_COLUMN(EnergyZNA2, energyZNA2, float); //! +DECLARE_SOA_COLUMN(EnergyZNA3, energyZNA3, float); //! +DECLARE_SOA_COLUMN(EnergyZNA4, energyZNA4, float); //! +DECLARE_SOA_COLUMN(EnergyZNC1, energyZNC1, float); //! +DECLARE_SOA_COLUMN(EnergyZNC2, energyZNC2, float); //! +DECLARE_SOA_COLUMN(EnergyZNC3, energyZNC3, float); //! +DECLARE_SOA_COLUMN(EnergyZNC4, energyZNC4, float); //! DECLARE_SOA_COLUMN(TimeZNA, timeZNA, float); //! DECLARE_SOA_COLUMN(TimeZNC, timeZNC, float); //! DECLARE_SOA_COLUMN(TimeZPA, timeZPA, float); //! @@ -204,7 +222,12 @@ DECLARE_SOA_TABLE(ReducedZdcs, "AOD", "REDUCEDZDC", //! Event ZDC information reducedzdc::TimeZNA, reducedzdc::TimeZNC, reducedzdc::TimeZPA, reducedzdc::TimeZPC); +DECLARE_SOA_TABLE(ReducedZdcsExtra, "AOD", "REDUCEDZDCEXTRA", //! Event ZDC extra information + reducedzdc::EnergyZNA1, reducedzdc::EnergyZNA2, reducedzdc::EnergyZNA3, reducedzdc::EnergyZNA4, + reducedzdc::EnergyZNC1, reducedzdc::EnergyZNC2, reducedzdc::EnergyZNC3, reducedzdc::EnergyZNC4); + using ReducedZdc = ReducedZdcs::iterator; +using ReducedZdcExtra = ReducedZdcsExtra::iterator; namespace reducedtrack { @@ -375,6 +398,9 @@ DECLARE_SOA_COLUMN(FwdDcaX, fwdDcaX, float); DECLARE_SOA_COLUMN(FwdDcaY, fwdDcaY, float); //! DECLARE_SOA_COLUMN(MftClusterSizesAndTrackFlags, mftClusterSizesAndTrackFlags, uint64_t); //! DECLARE_SOA_COLUMN(MftNClusters, mftNClusters, int); //! +DECLARE_SOA_INDEX_COLUMN(ReducedMCTrack, reducedMCTrack); //! +DECLARE_SOA_COLUMN(McMask, mcMask, uint16_t); //! +DECLARE_SOA_COLUMN(McReducedFlags, mcReducedFlags, uint16_t); //! } // namespace reducedmft // MFT track kinematics @@ -387,8 +413,13 @@ DECLARE_SOA_TABLE(ReducedMFTsExtra, "AOD", "RMFTEXTRA", //! reducedmft::MftClusterSizesAndTrackFlags, reducedmft::Sign, reducedmft::FwdDcaX, reducedmft::FwdDcaY, reducedmft::MftNClusters); +DECLARE_SOA_TABLE(ReducedMFTLabels, "AOD", "RTMFTLABELS", //! + reducedmft::ReducedMCTrackId, reducedmft::McMask, reducedmft::McReducedFlags); + // iterator using ReducedMFT = ReducedMFTs::iterator; +using ReducedMFTExtra = ReducedMFTsExtra::iterator; +using ReducedMFTLabel = ReducedMFTLabels::iterator; // muon quantities namespace reducedmuon @@ -493,18 +524,6 @@ DECLARE_SOA_TABLE(ReducedMFTAssoc, "AOD", "RMFTASSOC", //! Table for reducemft-t reducedtrack_association::ReducedEventId, reducedtrack_association::ReducedMFTId); -namespace smearedtrack -{ -DECLARE_SOA_COLUMN(PtSmeared, ptSmeared, float); -DECLARE_SOA_COLUMN(EtaSmeared, etaSmeared, float); -DECLARE_SOA_COLUMN(PhiSmeared, phiSmeared, float); -DECLARE_SOA_COLUMN(Efficiency, efficiency, float); -} // namespace smearedtrack - -DECLARE_SOA_TABLE(SmearedTracks, "AOD", "SMEAREDTRACK", // use like this Join - smearedtrack::PtSmeared, smearedtrack::EtaSmeared, smearedtrack::PhiSmeared, smearedtrack::Efficiency); -using SmearedTrack = SmearedTracks::iterator; - namespace dilepton_track_index { DECLARE_SOA_INDEX_COLUMN_FULL(Index0, index0, int, ReducedMuons, "_0"); //! Index to first prong @@ -558,6 +577,8 @@ 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 @@ -572,6 +593,8 @@ 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 @@ -612,6 +635,7 @@ 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) @@ -676,28 +700,16 @@ DECLARE_SOA_DYNAMIC_COLUMN(Y, y, //! [](float pt, float eta, float m) -> float { return std::log((std::sqrt(m * m + pt * pt * std::cosh(eta) * std::cosh(eta)) + pt * std::sinh(eta)) / std::sqrt(m * m + pt * pt)); }); } // namespace reducedpair -DECLARE_SOA_TABLE(Dielectrons, "AOD", "RTDIELECTRON", //! - o2::soa::Index<>, reducedpair::ReducedEventId, - reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::Sign, - reducedpair::FilterMap, reducedpair::McDecision, - reducedpair::Rap, - reducedpair::Y, - reducedpair::Px, - reducedpair::Py, - reducedpair::Pz, - reducedpair::P); - -DECLARE_SOA_TABLE(StoredDielectrons, "AOD1", "RTDIELECTRON", //! - o2::soa::Index<>, reducedpair::ReducedEventId, - reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::Sign, - reducedpair::FilterMap, reducedpair::McDecision, - reducedpair::Rap, - reducedpair::Y, - reducedpair::Px, - reducedpair::Py, - reducedpair::Pz, - reducedpair::P, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(Dielectrons, "RTDIELECTRON", //! + o2::soa::Index<>, reducedpair::ReducedEventId, + reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::Sign, + reducedpair::FilterMap, reducedpair::McDecision, + reducedpair::Rap, + reducedpair::Y, + reducedpair::Px, + reducedpair::Py, + reducedpair::Pz, + reducedpair::P); DECLARE_SOA_TABLE(Dimuons, "AOD", "RTDIMUON", //! o2::soa::Index<>, reducedpair::ReducedEventId, @@ -748,8 +760,8 @@ DECLARE_SOA_TABLE(DielectronsAll, "AOD", "RTDIELECTRONALL", //! reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::Sign, reducedpair::FilterMap, reducedpair::McDecision, - dilepton_track_index::Pt1, dilepton_track_index::Eta1, dilepton_track_index::Phi1, dilepton_track_index::TPCNClsCR1, dilepton_track_index::TPCNClsFound1, dilepton_track_index::TPCChi2NCl1, dilepton_track_index::DcaXY1, dilepton_track_index::DcaZ1, dilepton_track_index::TPCSignal1, dilepton_track_index::TPCNSigmaEl1, dilepton_track_index::TPCNSigmaPi1, dilepton_track_index::TPCNSigmaPr1, dilepton_track_index::TOFBeta1, dilepton_track_index::TOFNSigmaEl1, dilepton_track_index::TOFNSigmaPi1, dilepton_track_index::TOFNSigmaPr1, - dilepton_track_index::Pt2, dilepton_track_index::Eta2, dilepton_track_index::Phi2, dilepton_track_index::TPCNClsCR2, dilepton_track_index::TPCNClsFound2, dilepton_track_index::TPCChi2NCl2, dilepton_track_index::DcaXY2, dilepton_track_index::DcaZ2, dilepton_track_index::TPCSignal2, dilepton_track_index::TPCNSigmaEl2, dilepton_track_index::TPCNSigmaPi2, dilepton_track_index::TPCNSigmaPr2, dilepton_track_index::TOFBeta2, dilepton_track_index::TOFNSigmaEl2, dilepton_track_index::TOFNSigmaPi2, dilepton_track_index::TOFNSigmaPr2, + dilepton_track_index::Pt1, dilepton_track_index::Eta1, dilepton_track_index::Phi1, dilepton_track_index::ITSClusterMap1, dilepton_track_index::ITSChi2NCl1, dilepton_track_index::TPCNClsCR1, dilepton_track_index::TPCNClsFound1, dilepton_track_index::TPCChi2NCl1, dilepton_track_index::DcaXY1, dilepton_track_index::DcaZ1, dilepton_track_index::TPCSignal1, dilepton_track_index::TPCNSigmaEl1, dilepton_track_index::TPCNSigmaPi1, dilepton_track_index::TPCNSigmaPr1, dilepton_track_index::TOFBeta1, dilepton_track_index::TOFNSigmaEl1, dilepton_track_index::TOFNSigmaPi1, dilepton_track_index::TOFNSigmaPr1, + dilepton_track_index::Pt2, dilepton_track_index::Eta2, dilepton_track_index::Phi2, dilepton_track_index::ITSClusterMap2, dilepton_track_index::ITSChi2NCl2, dilepton_track_index::TPCNClsCR2, dilepton_track_index::TPCNClsFound2, dilepton_track_index::TPCChi2NCl2, dilepton_track_index::DcaXY2, dilepton_track_index::DcaZ2, dilepton_track_index::TPCSignal2, dilepton_track_index::TPCNSigmaEl2, dilepton_track_index::TPCNSigmaPi2, dilepton_track_index::TPCNSigmaPr2, dilepton_track_index::TOFBeta2, dilepton_track_index::TOFNSigmaEl2, dilepton_track_index::TOFNSigmaPi2, dilepton_track_index::TOFNSigmaPr2, dilepton_track_index::DCAxyzTrk0KF, dilepton_track_index::DCAxyzTrk1KF, reducedpair::DCAxyzBetweenTrksKF, dilepton_track_index::DCAxyTrk0KF, dilepton_track_index::DCAxyTrk1KF, reducedpair::DCAxyBetweenTrksKF, dilepton_track_index::DeviationTrk0KF, dilepton_track_index::DeviationTrk1KF, dilepton_track_index::DeviationxyTrk0KF, dilepton_track_index::DeviationxyTrk1KF, reducedpair::MassKFGeo, reducedpair::Chi2OverNDFKFGeo, reducedpair::DecayLengthKFGeo, reducedpair::DecayLengthOverErrKFGeo, reducedpair::DecayLengthXYKFGeo, reducedpair::DecayLengthXYOverErrKFGeo, reducedpair::PseudoproperDecayTimeKFGeo, reducedpair::PseudoproperDecayTimeErrKFGeo, reducedpair::CosPAKFGeo, reducedpair::PairDCAxyz, reducedpair::PairDCAxy, @@ -792,6 +804,9 @@ DECLARE_SOA_TABLE(DimuonsAll, "AOD", "RTDIMUONALL", //! reducedpair::VertexPz, reducedpair::SVertex); +DECLARE_SOA_TABLE(DileptonsMiniTree, "AOD", "RTDILEPTMTREE", //! + reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::CentFT0C, reducedpair::Cos2DeltaPhi); + using Dielectron = Dielectrons::iterator; using StoredDielectron = StoredDielectrons::iterator; using Dimuon = Dimuons::iterator; @@ -802,12 +817,13 @@ using DileptonFlow = DileptonsFlow::iterator; using DileptonInfo = DileptonsInfo::iterator; using DielectronAll = DielectronsAll::iterator; using DimuonAll = DimuonsAll::iterator; +using DileptonMiniTree = DileptonsMiniTree::iterator; // Tables for using analysis-dilepton-track with analysis-asymmetric-pairing DECLARE_SOA_TABLE(Ditracks, "AOD", "RTDITRACK", //! o2::soa::Index<>, reducedpair::ReducedEventId, reducedpair::Mass, reducedpair::Pt, reducedpair::Eta, reducedpair::Phi, reducedpair::Sign, - reducedpair::FilterMap, reducedpair::PairFilterMap, + reducedpair::FilterMap, reducedpair::PairFilterMap, reducedpair::CommonFilterMap, reducedpair::Rap, reducedpair::Y, reducedpair::Px, @@ -825,17 +841,18 @@ DECLARE_SOA_TABLE(DitracksExtra, "AOD", "RTDITRKEXTRA", //! // mft PID reduced data model namespace fwdpid { -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_COLUMN(Pt, pt, float); //! +DECLARE_SOA_COLUMN(Eta, eta, float); //! +DECLARE_SOA_COLUMN(Phi, phi, float); //! +DECLARE_SOA_COLUMN(Sign, sign, int); //! +DECLARE_SOA_COLUMN(McDecision, mcDecision, uint32_t); //! } // namespace fwdpid DECLARE_SOA_TABLE(FwdPidsAll, "AOD", "RTFWDPIDALL", //! fwdtrack::TrackType, collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, fwdpid::Pt, fwdpid::Eta, fwdpid::Phi, fwdpid::Sign, reducedmft::MftClusterSizesAndTrackFlags, - reducedmft::FwdDcaX, reducedmft::FwdDcaY, fwdtrack::Chi2MatchMCHMID, fwdtrack::Chi2MatchMCHMFT); + reducedmft::FwdDcaX, reducedmft::FwdDcaY, fwdtrack::Chi2MatchMCHMID, fwdtrack::Chi2MatchMCHMFT, fwdpid::McDecision); using FwdPidAll = FwdPidsAll::iterator; @@ -894,33 +911,62 @@ DECLARE_SOA_TABLE(RedJpDmColls, "AOD", "REDJPDMCOLL", //! namespace jpsidmescorr { -DECLARE_SOA_INDEX_COLUMN(RedJpDmColl, redJpDmColl); //! -DECLARE_SOA_COLUMN(MassD0, massD0, float); //! -DECLARE_SOA_COLUMN(MassD0bar, massD0bar, float); //! -DECLARE_SOA_COLUMN(Px, px, float); //! -DECLARE_SOA_COLUMN(Py, py, float); //! -DECLARE_SOA_COLUMN(Pz, pz, float); //! -DECLARE_SOA_COLUMN(DecVtxX, decVtxX, float); //! -DECLARE_SOA_COLUMN(DecVtxY, decVtxY, float); //! -DECLARE_SOA_COLUMN(DecVtxZ, decVtxZ, float); //! -DECLARE_SOA_COLUMN(BdtBkgMassHypo0, bdtBkgMassHypo0, float); //! -DECLARE_SOA_COLUMN(BdtPromptMassHypo0, bdtPromptMassHypo0, float); //! -DECLARE_SOA_COLUMN(BdtNonpromptMassHypo0, bdtNonpromptMassHypo0, float); //! -DECLARE_SOA_COLUMN(BdtBkg, bdtBkg, float); //! -DECLARE_SOA_COLUMN(BdtPrompt, bdtPrompt, float); //! -DECLARE_SOA_COLUMN(BdtNonprompt, bdtNonprompt, float); //! -DECLARE_SOA_COLUMN(BdtBkgMassHypo1, bdtBkgMassHypo1, float); //! -DECLARE_SOA_COLUMN(BdtPromptMassHypo1, bdtPromptMassHypo1, float); //! -DECLARE_SOA_COLUMN(BdtNonpromptMassHypo1, bdtNonpromptMassHypo1, float); //! -DECLARE_SOA_COLUMN(NumColls, numColls, uint64_t); //! -DECLARE_SOA_COLUMN(PtD0, ptD0, float); //! -DECLARE_SOA_COLUMN(PtJpsi, ptJpsi, float); //! -DECLARE_SOA_COLUMN(RapD0, rapD0, float); //! -DECLARE_SOA_COLUMN(RapJpsi, rapJpsi, float); //! -DECLARE_SOA_COLUMN(PhiD0, phiD0, float); //! -DECLARE_SOA_COLUMN(PhiJpsi, phiJpsi, float); //! -DECLARE_SOA_COLUMN(DeltaY, deltaY, float); //! -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! +DECLARE_SOA_INDEX_COLUMN(RedJpDmColl, redJpDmColl); //! +DECLARE_SOA_COLUMN(MassDmes, massDmes, float); //! +DECLARE_SOA_COLUMN(MassD0, massD0, float); //! +DECLARE_SOA_COLUMN(MassD0bar, massD0bar, float); //! +DECLARE_SOA_COLUMN(Px, px, float); //! +DECLARE_SOA_COLUMN(Py, py, float); //! +DECLARE_SOA_COLUMN(Pz, pz, float); //! +DECLARE_SOA_COLUMN(DecVtxX, decVtxX, float); //! +DECLARE_SOA_COLUMN(DecVtxY, decVtxY, float); //! +DECLARE_SOA_COLUMN(DecVtxZ, decVtxZ, float); //! +DECLARE_SOA_COLUMN(BdtBkgMassHypo0, bdtBkgMassHypo0, float); //! +DECLARE_SOA_COLUMN(BdtPromptMassHypo0, bdtPromptMassHypo0, float); //! +DECLARE_SOA_COLUMN(BdtNonpromptMassHypo0, bdtNonpromptMassHypo0, float); //! +DECLARE_SOA_COLUMN(BdtBkg, bdtBkg, float); //! +DECLARE_SOA_COLUMN(BdtPrompt, bdtPrompt, float); //! +DECLARE_SOA_COLUMN(BdtNonprompt, bdtNonprompt, float); //! +DECLARE_SOA_COLUMN(BdtBkgMassHypo1, bdtBkgMassHypo1, float); //! +DECLARE_SOA_COLUMN(BdtPromptMassHypo1, bdtPromptMassHypo1, float); //! +DECLARE_SOA_COLUMN(BdtNonpromptMassHypo1, bdtNonpromptMassHypo1, float); //! +DECLARE_SOA_COLUMN(NumColls, numColls, uint64_t); //! +DECLARE_SOA_COLUMN(PtDmes, ptDmes, float); //! +DECLARE_SOA_COLUMN(PtJpsi, ptJpsi, float); //! +DECLARE_SOA_COLUMN(RapDmes, rapDmes, float); //! +DECLARE_SOA_COLUMN(RapJpsi, rapJpsi, float); //! +DECLARE_SOA_COLUMN(PhiDmes, phiDmes, float); //! +DECLARE_SOA_COLUMN(PhiJpsi, phiJpsi, float); //! +DECLARE_SOA_COLUMN(DeltaY, deltaY, float); //! +DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! +DECLARE_SOA_COLUMN(NumItsClsDmesProng0, numItsClsDmesProng0, int); //! +DECLARE_SOA_COLUMN(NumItsClsDmesProng1, numItsClsDmesProng1, int); //! +DECLARE_SOA_COLUMN(NumTpcCrossedRowsDmesProng0, numTpcCrossedRowsDmesProng0, int); //! +DECLARE_SOA_COLUMN(NumTpcCrossedRowsDmesProng1, numTpcCrossedRowsDmesProng1, int); //! +DECLARE_SOA_COLUMN(EtaDmesProng0, etaDmesProng0, float); //! +DECLARE_SOA_COLUMN(EtaDmesProng1, etaDmesProng1, float); //! +DECLARE_SOA_COLUMN(PtDmesProng0, ptDmesProng0, float); //! +DECLARE_SOA_COLUMN(PtDmesProng1, ptDmesProng1, float); //! +DECLARE_SOA_COLUMN(MinNumItsClsDmesProng, minNumItsClsDmesProng, int); //! +DECLARE_SOA_COLUMN(MinNumTpcCrossedRowsDmesProng, minNumTpcCrossedRowsDmesProng, int); //! +DECLARE_SOA_COLUMN(MinAbsEtaDmesProng, minAbsEtaDmesProng, float); //! +DECLARE_SOA_COLUMN(MinPtDmesProng, minPtDmesProng, float); //! +DECLARE_SOA_COLUMN(NumSigmaTpcPiProng0, numSigmaTpcPiProng0, float); //! +DECLARE_SOA_COLUMN(NumSigmaTpcPiProng1, numSigmaTpcPiProng1, float); //! +DECLARE_SOA_COLUMN(NumSigmaTofPiProng0, numSigmaTofPiProng0, float); //! +DECLARE_SOA_COLUMN(NumSigmaTofPiProng1, numSigmaTofPiProng1, float); //! +DECLARE_SOA_COLUMN(NumSigmaTpcKaProng0, numSigmaTpcKaProng0, float); //! +DECLARE_SOA_COLUMN(NumSigmaTpcKaProng1, numSigmaTpcKaProng1, float); //! +DECLARE_SOA_COLUMN(NumSigmaTofKaProng0, numSigmaTofKaProng0, float); //! +DECLARE_SOA_COLUMN(NumSigmaTofKaProng1, numSigmaTofKaProng1, float); //! +DECLARE_SOA_DYNAMIC_COLUMN(NumSigmaTpcTofPiProng0, numSigmaTpcTofPiProng0, //! + [](float tpcNSigmaPi0, float tofNSigmaPi0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi0, tofNSigmaPi0); }); +DECLARE_SOA_DYNAMIC_COLUMN(NumSigmaTpcTofPiProng1, numSigmaTpcTofPiProng1, //! + [](float tpcNSigmaPi1, float tofNSigmaPi1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi1, tofNSigmaPi1); }); +DECLARE_SOA_DYNAMIC_COLUMN(NumSigmaTpcTofKaProng0, numSigmaTpcTofKaProng0, //! + [](float tpcNSigmaKa0, float tofNSigmaKa0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa0, tofNSigmaKa0); }); +DECLARE_SOA_DYNAMIC_COLUMN(NumSigmaTpcTofKaProng1, numSigmaTpcTofKaProng1, //! + [](float tpcNSigmaKa1, float tofNSigmaKa1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa1, tofNSigmaKa1); }); } // namespace jpsidmescorr DECLARE_SOA_TABLE(RedJpDmDileptons, "AOD", "REDJPDMDILEPTON", //! @@ -951,6 +997,30 @@ DECLARE_SOA_TABLE(RedJpDmDmesons, "AOD", "REDJPDMDMESON", //! reducedpair::Sign, reducedpair::McDecision); +DECLARE_SOA_TABLE(RedJpDmDmDau0s, "AOD", "REDJPDMDMDAU0", //! + jpsidmescorr::PtDmesProng0, + jpsidmescorr::EtaDmesProng0, + jpsidmescorr::NumItsClsDmesProng0, + jpsidmescorr::NumTpcCrossedRowsDmesProng0, + jpsidmescorr::NumSigmaTpcPiProng0, + jpsidmescorr::NumSigmaTofPiProng0, + jpsidmescorr::NumSigmaTpcKaProng0, + jpsidmescorr::NumSigmaTofKaProng0, + jpsidmescorr::NumSigmaTpcTofPiProng0, + jpsidmescorr::NumSigmaTpcTofKaProng0); + +DECLARE_SOA_TABLE(RedJpDmDmDau1s, "AOD", "REDJPDMDMDAU1", //! + jpsidmescorr::PtDmesProng1, + jpsidmescorr::EtaDmesProng1, + jpsidmescorr::NumItsClsDmesProng1, + jpsidmescorr::NumTpcCrossedRowsDmesProng1, + jpsidmescorr::NumSigmaTpcPiProng1, + jpsidmescorr::NumSigmaTofPiProng1, + jpsidmescorr::NumSigmaTpcKaProng1, + jpsidmescorr::NumSigmaTofKaProng1, + jpsidmescorr::NumSigmaTpcTofPiProng1, + jpsidmescorr::NumSigmaTpcTofKaProng1); + DECLARE_SOA_TABLE(RedJpDmD0Masss, "AOD", "REDJPDMD0MASS", //! jpsidmescorr::MassD0, jpsidmescorr::MassD0bar); @@ -965,18 +1035,73 @@ DECLARE_SOA_TABLE(RedJpDmDmesBdts, "AOD", "REDJPDMDMESBDT", //! DECLARE_SOA_TABLE(RedDleptDmesAll, "AOD", "RTDILPTDMESALL", //! reducedpair::Mass, - jpsidmescorr::MassD0, + jpsidmescorr::MassDmes, jpsidmescorr::PtJpsi, - jpsidmescorr::PtD0, + jpsidmescorr::PtDmes, jpsidmescorr::RapJpsi, - jpsidmescorr::RapD0, + jpsidmescorr::RapDmes, jpsidmescorr::PhiJpsi, - jpsidmescorr::PhiD0, + jpsidmescorr::PhiDmes, jpsidmescorr::DeltaY, jpsidmescorr::DeltaPhi, jpsidmescorr::BdtBkg, jpsidmescorr::BdtPrompt, - jpsidmescorr::BdtNonprompt); + jpsidmescorr::BdtNonprompt, + jpsidmescorr::MinPtDmesProng, + jpsidmescorr::MinAbsEtaDmesProng, + jpsidmescorr::MinNumItsClsDmesProng, + jpsidmescorr::MinNumTpcCrossedRowsDmesProng); + +namespace muondca +{ +DECLARE_SOA_COLUMN(pDCA, pdca, float); //! +DECLARE_SOA_COLUMN(DCA, dca, float); //! +DECLARE_SOA_COLUMN(DCAx, dcax, float); //! +DECLARE_SOA_COLUMN(DCAy, dcay, float); //! +DECLARE_SOA_COLUMN(Rabs, rabs, float); //! +DECLARE_SOA_COLUMN(Px, px, float); //! +DECLARE_SOA_COLUMN(Py, py, float); //! +DECLARE_SOA_COLUMN(Pz, pz, float); //! +} // namespace muondca + +DECLARE_SOA_TABLE(ReducedMuonsDca, "AOD", "RTMUONDCA", + muondca::pDCA, + muondca::DCA, + muondca::DCAx, + muondca::DCAy, + muondca::Rabs, + reducedmuon::Pt, + reducedmuon::Eta, reducedmuon::Phi, + reducedmuon::Sign, reducedmuon::IsAmbiguous, + muondca::Px, + muondca::Py, + muondca::Pz); + +using ReducedMuonDca = ReducedMuonsDca::iterator; + +//______________________________________________________ +namespace generatedquarkoniamc +{ +//______________________________________________________ +// Binned content for generated particles: derived data +DECLARE_SOA_COLUMN(GeneratedEtaC1S, generatedEtaC1S, std::vector); //! Eta(1S) binned generated data +DECLARE_SOA_COLUMN(GeneratedJPsi, generatedJPsi, std::vector); //! J/Psi binned generated data +DECLARE_SOA_COLUMN(GeneratedChiC0, generatedChiC0, std::vector); //! ChiC0(1P) binned generated data +DECLARE_SOA_COLUMN(GeneratedChiC1, generatedChiC1, std::vector); //! ChiC1(1P) binned generated data +DECLARE_SOA_COLUMN(GeneratedHC, generatedHC, std::vector); //! hC binned generated data +DECLARE_SOA_COLUMN(GeneratedChiC2, generatedChiC2, std::vector); //! ChiC2(1P) binned generated data +DECLARE_SOA_COLUMN(GeneratedEtaC2S, generatedEtaC2S, std::vector); //! EtaC(2S) binned generated data +DECLARE_SOA_COLUMN(GeneratedPsi2S, generatedPsi2S, std::vector); //! Psi(2S) binned generated data +} // namespace generatedquarkoniamc + +DECLARE_SOA_TABLE(GeEtaC1S, "AOD", "GEETAC1S", generatedquarkoniamc::GeneratedEtaC1S); +DECLARE_SOA_TABLE(GeJPsi, "AOD", "GEJPSI", generatedquarkoniamc::GeneratedJPsi); +DECLARE_SOA_TABLE(GeChiC0, "AOD", "GECHIC0", generatedquarkoniamc::GeneratedChiC0); +DECLARE_SOA_TABLE(GeChiC1, "AOD", "GECHIC1", generatedquarkoniamc::GeneratedChiC1); +DECLARE_SOA_TABLE(GeHC, "AOD", "GEHC", generatedquarkoniamc::GeneratedHC); +DECLARE_SOA_TABLE(GeChiC2, "AOD", "GECHIC2", generatedquarkoniamc::GeneratedChiC2); +DECLARE_SOA_TABLE(GeEtaC2S, "AOD", "GEETAC2S", generatedquarkoniamc::GeneratedEtaC2S); +DECLARE_SOA_TABLE(GePsi2S, "AOD", "GEPSI2S", generatedquarkoniamc::GeneratedPsi2S); } // namespace o2::aod #endif // PWGDQ_DATAMODEL_REDUCEDINFOTABLES_H_ diff --git a/PWGDQ/TableProducer/CMakeLists.txt b/PWGDQ/TableProducer/CMakeLists.txt index 7663568572f..b8fd20d356d 100644 --- a/PWGDQ/TableProducer/CMakeLists.txt +++ b/PWGDQ/TableProducer/CMakeLists.txt @@ -31,10 +31,15 @@ o2physics_add_dpl_workflow(table-maker-mc-with-assoc o2physics_add_dpl_workflow(table-maker-jpsi-hf SOURCES tableMakerJpsiHf.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore KFParticle::KFParticle + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(table-maker-muon-mch-trk-eff SOURCES tableMakerMuonMchTrkEfficiency.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(generated-quarkonia-mc + SOURCES generatedQuarkoniaMC.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase O2Physics::PWGDQCore + COMPONENT_NAME Analysis) diff --git a/PWGDQ/TableProducer/generatedQuarkoniaMC.cxx b/PWGDQ/TableProducer/generatedQuarkoniaMC.cxx new file mode 100644 index 00000000000..737faaaa6b2 --- /dev/null +++ b/PWGDQ/TableProducer/generatedQuarkoniaMC.cxx @@ -0,0 +1,242 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 provides produces histograms containing +// the number of generated quarkonia per unit of +// percentile and per unit of pT +// It is meant to help with providing auxiliary information +// when dealing with derived data. + +#include +#include +#include +#include +#include +#include + +#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 "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFParticleIdentification.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "Common/Core/TrackSelection.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 "Common/TableProducer/PID/pidTOFBase.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/Qvectors.h" +#include "Framework/StaticFor.h" +#include "Common/DataModel/McCollisionExtra.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +// simple bit checkers +#define bitset(var, nbit) ((var) |= (1 << (nbit))) +#define bitcheck(var, nbit) ((var) & (1 << (nbit))) + +struct generatedQuarkoniaMC { + SliceCache cache; + //__________________________________________________ + // Generated binned data + // this is a hack while the system does not do better + Produces geEtaC1S; + Produces geJPsi; + Produces geChiC0; + Produces geChiC1; + Produces geHC; + Produces geChiC2; + Produces geEtaC2S; + Produces gePsi2S; + + // histogram registry for bookkeeping + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + static constexpr int nSpecies = 8; + static constexpr int nParameters = 1; + static const std::vector particleNames; + static const std::vector particlePDGCodes; + static const std::vector parameterNames; + static const int defaultParameters[nSpecies][nParameters]; + static constexpr std::string_view particleNamesConstExpr[] = {"EtaC1S", "JPsi", "ChiC0", "ChiC1", + "hC", "ChiC2", "EtaC2S", "Psi2S"}; + + uint32_t enabledBits = 0; + + Configurable> enableGeneratedInfo{"enableGeneratedInfo", + {defaultParameters[0], nSpecies, + nParameters, particleNames, parameterNames}, + "Fill generated particle histograms for each species. 0: no, 1: yes"}; + + 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 axisCentrality{"axisCentrality", {100, 0.0f, 100.0f}, "Centrality"}; + + ConfigurableAxis axisNVertices{"axisNVertices", {10, -0.5f, 9.5f}, "N(vertices)"}; + + std::vector genEtaC1S; + std::vector genJPsi; + std::vector genChiC0; + std::vector genChiC1; + std::vector genHC; + std::vector genChiC2; + std::vector genEtaC2S; + std::vector genPsi2S; + + // Preslice + Preslice mcParticlePerMcCollision = o2::aod::mcparticle::mcCollisionId; + + void init(InitContext&) + { + // setup map for fast checking if enabled + static_for<0, nSpecies - 1>([&](auto i) { + constexpr int index = i.value; + int f = enableGeneratedInfo->get(particleNames[index].c_str(), "Enable"); + if (f == 1) { + bitset(enabledBits, index); + } + }); + + // Creation of histograms: MC generated + for (Int_t i = 0; i < nSpecies; i++) { + histos.add(Form("h2dGenerated%s", particleNames[i].data()), Form("h2dGenerated%s", particleNames[i].data()), kTH2D, {axisCentrality, axisPt}); + } + + histos.add("h2dNVerticesVsCentrality", "h2dNVerticesVsCentrality", kTH2D, {axisCentrality, axisNVertices}); + + // reserve space for generated vectors if that process enabled + auto hBinFinder = histos.get(HIST("h2dGeneratedEtaC1S")); + LOGF(info, "Binned generated processing enabled. Initialising with %i elements...", hBinFinder->GetNcells()); + genEtaC1S.resize(hBinFinder->GetNcells(), 0); + genJPsi.resize(hBinFinder->GetNcells(), 0); + genChiC0.resize(hBinFinder->GetNcells(), 0); + genChiC1.resize(hBinFinder->GetNcells(), 0); + genHC.resize(hBinFinder->GetNcells(), 0); + genChiC2.resize(hBinFinder->GetNcells(), 0); + genEtaC2S.resize(hBinFinder->GetNcells(), 0); + genPsi2S.resize(hBinFinder->GetNcells(), 0); + LOGF(info, "Binned generated processing: init done."); + } + + void processReconstructedSimulation(aod::McCollision const& /*mcCollision*/, soa::SmallGroups> const& collisions, aod::McParticles const& mcParticles) + { + // this process function also checks if a given collision was reconstructed and checks explicitly for splitting, etc + // identify best-of collision + int biggestNContribs = -1; + float bestCentrality = 100.5; + for (auto& collision : collisions) { + if (biggestNContribs < collision.numContrib()) { + biggestNContribs = collision.numContrib(); + bestCentrality = collision.centFT0M(); + } + } + histos.fill(HIST("h2dNVerticesVsCentrality"), bestCentrality, collisions.size()); + + for (auto& mcp : mcParticles) { + if (TMath::Abs(mcp.y()) < 0.5 /* && mcp.isPhysicalPrimary()*/) { + static_for<0, nSpecies - 1>([&](auto i) { + constexpr int index = i.value; + if (mcp.pdgCode() == particlePDGCodes[index] && bitcheck(enabledBits, index)) { + histos.fill(HIST("h2dGenerated") + HIST(particleNamesConstExpr[index]), bestCentrality, mcp.pt()); + } + }); + } + } + } + + void processBinnedGenerated(soa::Join const& mcCollisions, aod::McParticles const& mcParticlesEntireTable) + { + // set to zero + std::fill(genEtaC1S.begin(), genEtaC1S.end(), 0); + std::fill(genJPsi.begin(), genJPsi.end(), 0); + std::fill(genChiC0.begin(), genChiC0.end(), 0); + std::fill(genChiC1.begin(), genChiC1.end(), 0); + std::fill(genHC.begin(), genHC.end(), 0); + std::fill(genChiC2.begin(), genChiC2.end(), 0); + std::fill(genEtaC2S.begin(), genEtaC2S.end(), 0); + std::fill(genPsi2S.begin(), genPsi2S.end(), 0); + + // this process function also checks if a given collision was reconstructed and checks explicitly for splitting, etc + for (auto& mcCollision : mcCollisions) { + const uint64_t mcCollIndex = mcCollision.globalIndex(); + + // use one of the generated histograms as the bin finder + auto hBinFinder = histos.get(HIST("h2dGeneratedEtaC1S")); + + auto mcParticles = mcParticlesEntireTable.sliceBy(mcParticlePerMcCollision, mcCollIndex); + for (auto& mcp : mcParticles) { + if (TMath::Abs(mcp.y()) < 0.5 /* && mcp.isPhysicalPrimary()*/) { + auto binNumber = hBinFinder->FindBin(mcCollision.bestCollisionCentFT0C(), mcp.pt()); // caution: pack + if (mcp.pdgCode() == 441) + genEtaC1S[binNumber]++; + if (mcp.pdgCode() == 443) + genJPsi[binNumber]++; + if (mcp.pdgCode() == 10441) + genChiC0[binNumber]++; + if (mcp.pdgCode() == 20443) + genChiC1[binNumber]++; + if (mcp.pdgCode() == 10443) + genHC[binNumber]++; + if (mcp.pdgCode() == 445) + genChiC2[binNumber]++; + if (mcp.pdgCode() == 100441) + genEtaC2S[binNumber]++; + if (mcp.pdgCode() == 100443) + genPsi2S[binNumber]++; + } + } + } + // at end of data frame + // -> pack information from this DF into a generated histogram, once / DF + geEtaC1S(genEtaC1S); + geJPsi(genJPsi); + geChiC0(genChiC0); + geChiC1(genChiC1); + geHC(genHC); + geChiC2(genChiC2); + geEtaC2S(genEtaC2S); + gePsi2S(genPsi2S); + } + + PROCESS_SWITCH(generatedQuarkoniaMC, processReconstructedSimulation, "Produce reco-ed simulated information", true); + PROCESS_SWITCH(generatedQuarkoniaMC, processBinnedGenerated, "Produce binned generated information", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} + +//__________________________________________________ +// do not over-populate general namespace, keep scope generatedQuarkoniaMC:: +const std::vector generatedQuarkoniaMC::particleNames{"EtaC1S", "JPsi", "ChiC0", "ChiC1", + "hC", "ChiC2", "EtaC2S", "Psi2S"}; +const std::vector generatedQuarkoniaMC::particlePDGCodes{441, 443, 10441, 20443, 10443, 445, 100441, 100443}; +const std::vector generatedQuarkoniaMC::parameterNames{"Enable"}; + +const int generatedQuarkoniaMC::defaultParameters[generatedQuarkoniaMC::nSpecies][generatedQuarkoniaMC::nParameters] = {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}}; diff --git a/PWGDQ/TableProducer/tableMaker.cxx b/PWGDQ/TableProducer/tableMaker.cxx index 8e428047973..5a6fc2f09a7 100644 --- a/PWGDQ/TableProducer/tableMaker.cxx +++ b/PWGDQ/TableProducer/tableMaker.cxx @@ -17,7 +17,13 @@ // The skimming can optionally produce just the barrel, muon, or both barrel and muon tracks // The event filtering (filterPP), centrality, and V0Bits (from v0-selector) can be switched on/off by selecting one // of the process functions +// C++ includes #include +#include +#include +#include +#include +// other includes #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" @@ -65,20 +71,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod; -// DQ triggers -enum DQTriggers { - kSingleE = 1 << 0, // 0000001 - kLMeeIMR = 1 << 1, // 0000010 - kLMeeHMR = 1 << 2, // 0000100 - kDiElectron = 1 << 3, // 0001000 - kSingleMuLow = 1 << 4, // 0010000 - kSingleMuHigh = 1 << 5, // 0100000 - kDiMuon = 1 << 6, // 1000000 - kNTriggersDQ -}; - Zorro zorro; -std::string zorroTriggerMask[7] = {"fSingleE", "fLMeeIMR", "fLMeeHMR", "fDiElectron", "fSingleMuLow", "fSingleMuHigh", "fDiMuon"}; using MyBarrelTracks = soa::Join; +using MyBarrelTracksForElectronMuon = soa::Join; using MyEvents = soa::Join; using MyEventsWithMults = soa::Join; using MyEventsWithFilter = soa::Join; @@ -120,14 +115,6 @@ using MyMuonsColl = soa::Join; using ExtBCs = soa::Join; -namespace o2::aod -{ -DECLARE_SOA_TABLE(AmbiguousTracksMid, "AOD", "AMBIGUOUSTRACK", //! Table for tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::TrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -DECLARE_SOA_TABLE(AmbiguousTracksFwd, "AOD", "AMBIGUOUSFWDTR", //! Table for Fwd tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::FwdTrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -} // namespace o2::aod - constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; constexpr static uint32_t gkEventFillMapWithMult = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::CollisionMultExtra; constexpr static uint32_t gkEventFillMapWithMultsAndEventFilter = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::CollisionMultExtra | VarManager::ObjTypes::EventFilter; @@ -140,6 +127,7 @@ constexpr static uint32_t gkTrackFillMapWithV0Bits = gkTrackFillMap | VarManager constexpr static uint32_t gkTrackFillMapWithV0BitsForMaps = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackV0Bits | VarManager::ObjTypes::TrackSelection | VarManager::ObjTypes::TrackTPCPID; constexpr static uint32_t gkTrackFillMapWithDalitzBits = gkTrackFillMap | VarManager::ObjTypes::DalitzBits; constexpr static uint32_t gkTrackFillMapWithV0AndDalitzBits = gkTrackFillMap | VarManager::ObjTypes::TrackV0Bits | VarManager::ObjTypes::DalitzBits; +constexpr static uint32_t gkTrackFillMapForElectronMuon = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackSelection | VarManager::ObjTypes::TrackTPCPID; 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; @@ -173,9 +161,11 @@ struct TableMaker { 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"}; - Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; - Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; - Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + struct : ConfigurableGroup { + Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + } addHistoConfigurations; 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"}; @@ -185,9 +175,19 @@ struct TableMaker { 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"}; - Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; - 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"}; + + struct : ConfigurableGroup { + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; + Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; + Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; + } useZorro; + + struct : ConfigurableGroup { + Configurable fConfigCcdbUrl{"useCCDBConfigurations.ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable fConfigCcdbPathTPC{"useCCDBConfigurations.ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"}; + Configurable fConfigCcdbPathZorro{"useCCDBConfigurations.ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/", "base path to the ccdb object for zorro"}; + } useCCDBConfigurations; + 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(electrons, pions, protons)"}; Configurable fConfigComputeTPCpostCalibKaon{"cfgTPCpostCalibKaon", false, "If true, compute TPC post-calibrated n-sigmas for kaons"}; @@ -198,11 +198,16 @@ struct TableMaker { Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; Configurable grpmagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"}; + struct : ConfigurableGroup { + Configurable useMatCorrType{"useMatConfigurations.useMatCorrType", 1, "materialCorrType: 0: none, 1: TGeo, 2: LUT"}; + Configurable lutPath{"useMatConfigurations.lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + } useMatConfigurations; Service fCCDB; o2::parameters::GRPObject* grpmagrun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP o2::parameters::GRPMagField* grpmag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField + o2::base::MatLayerCylSet* lut = nullptr; AnalysisCompositeCut* fEventCut; //! Event selection cut std::vector fTrackCuts; //! Barrel track cuts @@ -224,11 +229,19 @@ struct TableMaker { void init(o2::framework::InitContext& context) { DefineCuts(); - fCCDB->setURL(fConfigCcdbUrl); + fCCDB->setURL(useCCDBConfigurations.fConfigCcdbUrl); fCCDB->setCaching(true); fCCDB->setLocalObjectValidityChecking(); - if (!o2::base::GeometryManager::isGeometryLoaded()) { - fCCDB->get(geoPath); + if (useMatConfigurations.useMatCorrType == 1) { + LOGF(info, "TGeo correction requested, loading geometry"); + if (!o2::base::GeometryManager::isGeometryLoaded()) { + fCCDB->get(geoPath); + } + } + if (useMatConfigurations.useMatCorrType == 2) { + LOGF(info, "LUT correction requested, loading LUT"); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(fCCDB->get(useMatConfigurations.lutPath)); + LOGF(info, "LUT load done!"); } VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); @@ -257,7 +270,7 @@ struct TableMaker { context.mOptions.get("processBarrelOnlyWithMultsAndEventFilter") || context.mOptions.get("processBarrelOnlyWithCovAndEventFilter") || context.mOptions.get("processBarrelOnlyWithDalitzBits") || context.mOptions.get("processBarrelOnlyWithV0Bits") || context.mOptions.get("processBarrelWithDalitzEvent") || context.mOptions.get("processBarrelOnlyWithV0BitsAndMaps") || context.mOptions.get("processAmbiguousBarrelOnly")) || - context.mOptions.get("processBarrelWithV0AndDalitzEvent"); + 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") || @@ -315,7 +328,7 @@ struct TableMaker { fOutputList.setObject(fHistMan->GetMainHistogramList()); // CCDB configuration if (fConfigComputeTPCpostCalib) { - fCCDB->setURL(fConfigCcdbUrl.value); + fCCDB->setURL(useCCDBConfigurations.fConfigCcdbUrl.value); fCCDB->setCaching(true); fCCDB->setLocalObjectValidityChecking(); // Not later than now objects @@ -358,7 +371,7 @@ struct TableMaker { auto bc = collision.template bc_as(); if (fCurrentRun != bc.runNumber()) { if (fConfigComputeTPCpostCalib) { - auto calibList = fCCDB->getForTimeStamp(fConfigCcdbPathTPC.value, bc.timestamp()); + auto calibList = fCCDB->getForTimeStamp(useCCDBConfigurations.fConfigCcdbPathTPC.value, bc.timestamp()); VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion")); @@ -383,6 +396,11 @@ struct TableMaker { if (fPropMuon) { VarManager::SetupMuonMagField(); } + if (useMatConfigurations.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); + } } fCurrentRun = bc.runNumber(); } @@ -393,11 +411,13 @@ struct TableMaker { // if the BC found by event selection does not coincide with the collision.bc() auto bcEvSel = collision.template foundBC_as(); if (bcEvSel.globalIndex() != bc.globalIndex()) { - tag |= (uint64_t(1) << 0); + 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) { - tag |= (collision.eventFilter() << 56); + if (!useZorro.fConfigRunZorro) { + tag |= (collision.eventFilter() << 56); + } } VarManager::ResetValues(0, VarManager::kNEventWiseVariables); @@ -415,18 +435,22 @@ struct TableMaker { uint32_t triggerAliases = collision.alias_raw(); // fill stats information, before selections for (int i = 0; i < kNaliases; i++) { - if (triggerAliases & (uint32_t(1) << i)) { + if (triggerAliases & (static_cast(1) << i)) { (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(i)); } } (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(kNaliases)); - if (fConfigRunZorro) { - for (int i = 0; i < kNTriggersDQ; ++i) { - zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), zorroTriggerMask[i]); - if (!zorro.isSelected(bc.globalBC())) { - tag |= static_cast(1 << i); - } + if (useZorro.fConfigRunZorro) { + zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); + 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))); + if (zorroSel) { + tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb + } + if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { + return; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { @@ -436,7 +460,7 @@ struct TableMaker { // fill stats information, after selections for (int i = 0; i < kNaliases; i++) { - if (triggerAliases & (uint32_t(1) << i)) { + if (triggerAliases & (static_cast(1) << i)) { (reinterpret_cast(fStatsList->At(0)))->Fill(3.0, static_cast(i)); } } @@ -498,7 +522,7 @@ struct TableMaker { } } - trackFilteringTag = uint64_t(0); + trackFilteringTag = static_cast(0); trackTempFilterMap = uint8_t(0); VarManager::FillTrack(track); if (fDoDetailedQA) { @@ -534,35 +558,35 @@ struct TableMaker { trackFilteringTag |= (uint64_t(1) << 1); // BIT1: global track SSD }*/ if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackV0Bits)) { // BIT0-4: V0Bits - trackFilteringTag = uint64_t(track.pidbit()); + trackFilteringTag = static_cast(track.pidbit()); for (int iv0 = 0; iv0 < 5; iv0++) { if (track.pidbit() & (uint8_t(1) << iv0)) { (reinterpret_cast(fStatsList->At(1)))->Fill(fTrackCuts.size() + static_cast(iv0)); } } if (fConfigIsOnlyforMaps) { - if (trackFilteringTag & (uint64_t(1) << VarManager::kIsConversionLeg)) { // for electron + if (trackFilteringTag & (static_cast(1) << VarManager::kIsConversionLeg)) { // for electron fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues); } - if (trackFilteringTag & (uint64_t(1) << VarManager::kIsK0sLeg)) { // for pion + if (trackFilteringTag & (static_cast(1) << VarManager::kIsK0sLeg)) { // for pion fHistMan->FillHistClass("TrackBarrel_PostCalibPion", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda + if ((static_cast(trackFilteringTag & (static_cast(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda + if ((static_cast(trackFilteringTag & (static_cast(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } } } if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::DalitzBits)) { - trackFilteringTag |= (uint64_t(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz selection bits + trackFilteringTag |= (static_cast(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz selection bits } - trackFilteringTag |= (uint64_t(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-20...: user track filters + trackFilteringTag |= (static_cast(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-20...: user track filters if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackPID)) { if (fConfigComputeTPCpostCalib) { - trackFilteringTag |= (uint64_t(1) << VarManager::kIsTPCPostcalibrated); // store the info on whether TPC pid is skimmed as postcalibrated + trackFilteringTag |= (static_cast(1) << VarManager::kIsTPCPostcalibrated); // store the info on whether TPC pid is skimmed as postcalibrated } } @@ -594,6 +618,10 @@ struct TableMaker { track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), track.trdSignal()); } + if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackTPCPID)) { + trackBarrelPID(track.tpcSignal(), track.tpcNSigmaEl(), -1, track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), + -1, -1, -1, -1, -1, -1, -1); + } } } // end if constexpr (TTrackFillMap) @@ -653,7 +681,7 @@ struct TableMaker { std::map newMFTMatchIndex; for (auto& muon : tracksMuon) { - fwdFilteringTag = uint64_t(0); + fwdFilteringTag = static_cast(0); VarManager::FillTrack(muon); if (fPropMuon) { VarManager::FillPropagateMuon(muon, collision); @@ -796,7 +824,7 @@ struct TableMaker { } } } // end if constexpr (TMuonFillMap) - } // end fullSkimming() + } // end fullSkimming() // Templated function instantianed for all of the process functions template @@ -805,7 +833,7 @@ struct TableMaker { auto bc = collision.template bc_as(); if (fCurrentRun != bc.runNumber()) { if (fConfigComputeTPCpostCalib) { - auto calibList = fCCDB->getForTimeStamp(fConfigCcdbPathTPC.value, bc.timestamp()); + auto calibList = fCCDB->getForTimeStamp(useCCDBConfigurations.fConfigCcdbPathTPC.value, bc.timestamp()); VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion")); @@ -830,6 +858,11 @@ struct TableMaker { if constexpr (static_cast(TMuonFillMap)) { VarManager::SetupMuonMagField(); } + if (useMatConfigurations.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); + } } fCurrentRun = bc.runNumber(); } @@ -842,11 +875,13 @@ struct TableMaker { // if the BC found by event selection does not coincide with the collision.bc() auto bcEvSel = collision.template foundBC_as(); if (bcEvSel.globalIndex() != bc.globalIndex()) { - tag |= (uint64_t(1) << 0); + 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) { - tag |= (collision.eventFilter() << 56); + if (!useZorro.fConfigRunZorro) { + tag |= (collision.eventFilter() << 56); + } } VarManager::ResetValues(0, VarManager::kNEventWiseVariables); @@ -863,18 +898,22 @@ struct TableMaker { // fill stats information, before selections for (int i = 0; i < kNaliases; i++) { - if (triggerAliases & (uint32_t(1) << i)) { + if (triggerAliases & (static_cast(1) << i)) { (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(i)); } } (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(kNaliases)); - if (fConfigRunZorro) { - for (int i = 0; i < kNTriggersDQ; ++i) { - zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), zorroTriggerMask[i]); - if (!zorro.isSelected(bc.globalBC())) { - tag |= static_cast(1 << i); - } + if (useZorro.fConfigRunZorro) { + zorro.setBaseCCDBPath(useCCDBConfigurations.fConfigCcdbPathZorro.value); + 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))); + if (zorroSel) { + tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb + } + if (useZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { + return; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { @@ -884,7 +923,7 @@ struct TableMaker { // fill stats information, after selections for (int i = 0; i < kNaliases; i++) { - if (triggerAliases & (uint32_t(1) << i)) { + if (triggerAliases & (static_cast(1) << i)) { (reinterpret_cast(fStatsList->At(0)))->Fill(3.0, static_cast(i)); } } @@ -932,7 +971,7 @@ struct TableMaker { isAmbiguous = (track.compatibleCollIds().size() != 1); } } - trackFilteringTag = uint64_t(0); + trackFilteringTag = static_cast(0); trackTempFilterMap = uint8_t(0); VarManager::FillTrack(track); if (fDoDetailedQA) { @@ -962,37 +1001,37 @@ struct TableMaker { // store filtering information if (track.isGlobalTrack()) { - trackFilteringTag |= (uint64_t(1) << 0); // BIT0: global track + trackFilteringTag |= (static_cast(1) << 0); // BIT0: global track } if (track.isGlobalTrackSDD()) { - trackFilteringTag |= (uint64_t(1) << 1); // BIT1: global track SSD + trackFilteringTag |= (static_cast(1) << 1); // BIT1: global track SSD } if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackV0Bits)) { // BIT2-6: V0Bits - trackFilteringTag |= (uint64_t(track.pidbit()) << 2); + trackFilteringTag |= (static_cast(track.pidbit()) << 2); for (int iv0 = 0; iv0 < 5; iv0++) { if (track.pidbit() & (uint8_t(1) << iv0)) { (reinterpret_cast(fStatsList->At(1)))->Fill(fTrackCuts.size() + static_cast(iv0)); } } if (fConfigIsOnlyforMaps) { - if (trackFilteringTag & (uint64_t(1) << 2)) { // for electron + if (trackFilteringTag & (static_cast(1) << 2)) { // for electron fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues); } - if (trackFilteringTag & (uint64_t(1) << 3)) { // for pion + if (trackFilteringTag & (static_cast(1) << 3)) { // for pion fHistMan->FillHistClass("TrackBarrel_PostCalibPion", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << 4)) * (track.sign()) > 0)) { // for proton from Lambda + if ((static_cast(trackFilteringTag & (static_cast(1) << 4)) * (track.sign()) > 0)) { // for proton from Lambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << 5)) * (track.sign()) < 0)) { // for proton from AntiLambda + if ((static_cast(trackFilteringTag & (static_cast(1) << 5)) * (track.sign()) < 0)) { // for proton from AntiLambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } } } if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::DalitzBits)) { - trackFilteringTag |= (uint64_t(track.dalitzBits()) << 7); // BIT7-14: Dalitz + trackFilteringTag |= (static_cast(track.dalitzBits()) << 7); // BIT7-14: Dalitz } - trackFilteringTag |= (uint64_t(trackTempFilterMap) << 15); // BIT15-...: user track filters + trackFilteringTag |= (static_cast(trackTempFilterMap) << 15); // BIT15-...: user track filters // create the track tables trackBarrelInfo(track.collisionId(), collision.posX(), collision.posY(), collision.posZ(), track.globalIndex()); @@ -1021,6 +1060,10 @@ struct TableMaker { track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), track.trdSignal()); } + if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackTPCPID)) { + trackBarrelPID(track.tpcSignal(), track.tpcNSigmaEl(), -1, track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), + -1, -1, -1, -1, -1, -1, -1); + } } } // end if constexpr (TTrackFillMap) @@ -1042,7 +1085,7 @@ struct TableMaker { for (const auto& muonId : fwdtrackIndices) { // start loop over tracks auto muon = muonId.template fwdtrack_as(); - trackFilteringTag = uint64_t(0); + trackFilteringTag = static_cast(0); VarManager::FillTrack(muon); if (muon.index() > idxPrev + 1) { // checks if some muons are filtered even before the skimming function @@ -1072,7 +1115,7 @@ struct TableMaker { isAmbiguous = (muon.compatibleCollIds().size() != 1); } } - trackFilteringTag = uint64_t(0); + trackFilteringTag = static_cast(0); trackTempFilterMap = uint8_t(0); VarManager::FillTrack(muon); @@ -1144,22 +1187,22 @@ struct TableMaker { 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(), - muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), - muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), - muon.trackTime(), muon.trackTimeRes()); - } + } else { + muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), + muon.chi2(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT(), + muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), + muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), + muon.trackTime(), muon.trackTimeRes()); + } - 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], - VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); + 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], + VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); } } } // end if constexpr (TMuonFillMap) - } // end fullSkimming() + } // end fullSkimming() void DefineHistograms(TString histClasses) { @@ -1183,28 +1226,28 @@ struct TableMaker { } } - TString histEventName = fConfigAddEventHistogram.value; + TString histEventName = addHistoConfigurations.fConfigAddEventHistogram.value; if (classStr.Contains("Event")) { if (fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "event", histEventName); } } - TString histTrackName = fConfigAddTrackHistogram.value; + TString histTrackName = addHistoConfigurations.fConfigAddTrackHistogram.value; if (classStr.Contains("Track")) { if (fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histTrackName); } } - TString histMuonName = fConfigAddMuonHistogram.value; + TString histMuonName = addHistoConfigurations.fConfigAddMuonHistogram.value; if (classStr.Contains("Muons")) { if (fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histMuonName); } } - TString histMftName = fConfigAddMuonHistogram.value; + TString histMftName = addHistoConfigurations.fConfigAddMuonHistogram.value; if (classStr.Contains("Mft")) { if (fConfigDetailedQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histMftName); @@ -1212,7 +1255,13 @@ struct TableMaker { } } - // create statistics histograms (event, tracks, muons) + // create statistics histograms + // 0: Event statistics + // 1: Track statistics + // 2: Muon statistics + // 3: Zorro information + // 4: Zorro trigger selection + // NOTE: Please keep the order of the histograms in the list fStatsList.setObject(new TList()); fStatsList->SetOwner(kTRUE); std::vector eventLabels{"BCs", "Collisions before filtering", "Before cuts", "After cuts"}; @@ -1225,7 +1274,7 @@ struct TableMaker { histEvents->GetYaxis()->SetBinLabel(ib, aliasLabels[ib - 1].data()); } histEvents->GetYaxis()->SetBinLabel(kNaliases + 1, "Total"); - fStatsList->Add(histEvents); + fStatsList->Add(histEvents); // At index 0 // Track statistics: one bin for each track selection and 5 bins for V0 tags (gamma, K0s, Lambda, anti-Lambda, Omega) TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0); @@ -1237,13 +1286,19 @@ struct TableMaker { for (ib = 0; ib < 5; ib++) { histTracks->GetXaxis()->SetBinLabel(fTrackCuts.size() + 1 + ib, v0TagNames[ib]); } - fStatsList->Add(histTracks); + fStatsList->Add(histTracks); // At index 1 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()); } - fStatsList->Add(histMuons); + fStatsList->Add(histMuons); // At index 2 + + TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); + fStatsList->Add(histZorroInfo); // At index 3 + + TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); + fStatsList->Add(histZorroSel); // At index 4 } // Produce barrel + muon tables ------------------------------------------------------------------------------------------------------------- @@ -1310,6 +1365,13 @@ struct TableMaker { } } + // Produce barrel + muon tables for the eletron-muon analysis, without PIDTOF---------------------------------------------------------------------- + void processFullForElectronMuon(MyEvents::iterator const& collision, aod::BCsWithTimestamps const& bcs, + soa::Filtered const& tracksBarrel, soa::Filtered const& tracksMuon) + { + fullSkimming(collision, bcs, tracksBarrel, tracksMuon, nullptr, nullptr); + } + // Produce barrel only tables, with V0Bits ------------------------------------------------------------------------------------------------ void processBarrelOnlyWithV0Bits(MyEvents::iterator const& collision, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksBarrel) @@ -1317,6 +1379,13 @@ struct TableMaker { fullSkimming(collision, bcs, tracksBarrel, nullptr, nullptr, nullptr); } + // Produce barrel only tables, with V0Bits and Mults + void processBarrelOnlyWithV0BitsAndMults(MyEventsWithMults::iterator const& collision, aod::BCsWithTimestamps const& bcs, + soa::Filtered const& tracksBarrel) + { + fullSkimming(collision, bcs, tracksBarrel, nullptr, nullptr, nullptr); + } + // Produce barrel only tables, with V0Bits and produce maps ------------------------------------------------------------------------------ void processBarrelOnlyWithV0BitsAndMaps(MyEvents::iterator const& collision, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksBarrel) @@ -1509,7 +1578,7 @@ struct TableMaker { } void processAssociatedMuonOnlyWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon, aod::AmbiguousTracksFwd const&, aod::FwdTrackAssoc const& fwdtrackIndices) + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { auto muonIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); @@ -1518,7 +1587,7 @@ struct TableMaker { } void processAssociatedMuonOnlyWithCovAndCent(MyEventsWithCent const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon, aod::AmbiguousTracksFwd const&, aod::FwdTrackAssoc const& fwdtrackIndices) + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { auto muonIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); @@ -1527,7 +1596,7 @@ struct TableMaker { } void processAssociatedMuonOnlyWithCovAndMults(MyEventsWithMults const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon, aod::AmbiguousTracksFwd const&, aod::FwdTrackAssoc const& fwdtrackIndices) + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { auto muonIdsThisCollision = fwdtrackIndices.sliceBy(fwdtrackIndicesPerCollision, collision.globalIndex()); @@ -1536,7 +1605,7 @@ struct TableMaker { } void processAmbiguousMuonOnlyWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksMuon, aod::AmbiguousTracksFwd const& ambiTracksFwd) + soa::Filtered const& tracksMuon, aod::AmbiguousFwdTracks const& ambiTracksFwd) { // Process orphan tracks if (fDoDetailedQA && fIsAmbiguous) { @@ -1560,7 +1629,7 @@ struct TableMaker { // Produce track tables only for ambiguous tracks studies ------------------------------------------------------------------------------------- void processAmbiguousBarrelOnly(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, - soa::Filtered const& tracksBarrel, aod::AmbiguousTracksMid const& ambiTracksMid) + soa::Filtered const& tracksBarrel, aod::AmbiguousTracks const& ambiTracksMid) { // Process orphan tracks if (fDoDetailedQA && fIsAmbiguous) { @@ -1667,7 +1736,9 @@ struct TableMaker { PROCESS_SWITCH(TableMaker, processFullWithCent, "Build full DQ skimmed data model, w/ centrality", false); PROCESS_SWITCH(TableMaker, processFullWithCentAndMults, "Build full DQ skimmed data model, w/ centrality and multiplicities", false); PROCESS_SWITCH(TableMaker, processFullWithCovCentAndMults, "Build full DQ skimmed data model, w/ centrality, multiplicities and track covariances", false); + PROCESS_SWITCH(TableMaker, processFullForElectronMuon, "Build full DQ skimmed data model for electron-muon correlation analysis, w/o centrality", false); PROCESS_SWITCH(TableMaker, processBarrelOnlyWithV0Bits, "Build full DQ skimmed data model, w/o centrality, w/ V0Bits", false); + PROCESS_SWITCH(TableMaker, processBarrelOnlyWithV0BitsAndMults, "Build full DQ skimmed data model, w/ multiplicity, w/ V0Bits", false); PROCESS_SWITCH(TableMaker, processBarrelOnlyWithV0BitsAndMaps, "Build full DQ skimmed data model, w/o multiplicity, w/ V0Bits", false); PROCESS_SWITCH(TableMaker, processBarrelOnlyWithDalitzBits, "Build barrel-only DQ skimmed data model, w/o centrality, w/ DalitzBits", false); PROCESS_SWITCH(TableMaker, processBarrelWithDalitzEvent, "Build barrel-only DQ skimmed data model, w/o centrality, w/ DalitzBits", false); diff --git a/PWGDQ/TableProducer/tableMakerJpsiHf.cxx b/PWGDQ/TableProducer/tableMakerJpsiHf.cxx index 9c18f0b9fc4..7ae949c40d1 100644 --- a/PWGDQ/TableProducer/tableMakerJpsiHf.cxx +++ b/PWGDQ/TableProducer/tableMakerJpsiHf.cxx @@ -22,12 +22,15 @@ #include "Framework/runDataProcessing.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGDQ/Core/AnalysisCut.h" +#include "PWGDQ/Core/AnalysisCompositeCut.h" +#include "PWGDQ/Core/CutsLibrary.h" +#include "PWGDQ/Core/HistogramManager.h" +#include "PWGDQ/Core/HistogramsLibrary.h" +#include "PWGDQ/Core/VarManager.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGDQ/DataModel/ReducedInfoTables.h" -#include "PWGDQ/Core/VarManager.h" -#include "PWGDQ/Core/HistogramManager.h" -#include "PWGDQ/Core/HistogramsLibrary.h" using namespace o2; using namespace o2::analysis; @@ -36,14 +39,48 @@ using namespace o2::framework::expressions; using namespace o2::aod; using namespace o2::aod::hf_cand_2prong; +// bit maps used for the Fill functions of the VarManager +constexpr static uint32_t gkTrackFillMapWithColl = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelPID | VarManager::ObjTypes::ReducedTrackCollInfo; +constexpr static uint32_t gkMuonFillMapWithColl = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra | VarManager::ObjTypes::ReducedMuonCollInfo; + +namespace +{ +struct CandidateDilepton { + float fMass; + float fPt; + float fPhi; + float fEta; + float fTauz; + float fLz; + float fLxy; + int fSign; + uint32_t fMcDecision; + + float pt() const { return fPt; } + float mass() const { return fMass; } + float phi() const { return fPhi; } + float eta() const { return fEta; } + int sign() const { return fSign; } + uint32_t mcDecision() const { return fMcDecision; } + float tauz() const { return fTauz; } + float lz() const { return fLz; } + float lxy() const { return fLxy; } + float px() const { return fPt * std::cos(fPhi); } + float py() const { return fPt * std::sin(fPhi); } + float pz() const { return fPt * std::sinh(fEta); } + float p() const { return fPt * std::cosh(fEta); } + float rap() const { return std::log((std::sqrt(fMass * fMass + fPt * fPt * std::cosh(fEta) * std::cosh(fEta)) + fPt * std::sinh(fEta)) / std::sqrt(fMass * fMass + fPt * fPt)); } +}; +} // namespace + // Declarations of various short names using MyEvents = soa::Join; -using MyDimuonCandidatesSelected = soa::Join; -using MyDimuonCandidatesSelectedWithDca = soa::Join; -using MyDielectronCandidatesSelected = soa::Join; -using MyDielectronCandidatesSelectedWithDca = soa::Join; -using MyD0CandidatesSelected = soa::Join; -using MyD0CandidatesSelectedWithBdt = soa::Join; +using MyD0CandidatesSelected = soa::Join; +using MyD0CandidatesSelectedWithBdt = soa::Join; +using TracksWithExtra = soa::Join; + +using MyBarrelTracksSelectedWithColl = soa::Join; +using MyMuonTracksSelectedWithColl = soa::Join; HfHelper hfHelper; @@ -55,6 +92,8 @@ struct tableMakerJpsiHf { // Produce derived tables Produces redCollisions; Produces redDmesons; + Produces redDmesDau0; + Produces redDmesDau1; Produces redDmesBdts; Produces redD0Masses; Produces redDileptons; @@ -64,32 +103,38 @@ struct tableMakerJpsiHf { // cuts on BDT output scores to be applied only for the histograms Configurable yCandDmesonMax{"yCandDmesonMax", -1., "max. cand. rapidity"}; // DQ configurables - Configurable dileptonDecayChannel{"dileptonDecayChannel", "JPsiToMuMu", "Dilepton decay channel (JPsiToMuMu/JPsiToEE)"}; + Configurable fConfigTrackCuts{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; + // Configurable fConfigPairCuts{"cfgPairCuts", "", "Comma separated list of pair cuts"}; It seems to me that they are not used + Configurable fConfigMuonCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; Configurable massDileptonCandMin{"massDileptonCandMin", 1, "minimum dilepton mass"}; Configurable massDileptonCandMax{"massDileptonCandMax", 5, "maximum dilepton mass"}; // General configurables Configurable configDebug{"configDebug", true, "If true, fill D0 - J/psi histograms separately"}; Configurable storeTableForNorm{"storeTableForNorm", true, "If true, store a table with number of processed collisions for normalisation"}; - SliceCache cache; - Partition selectedDimuonCandidates = aod::reducedpair::mass > 1.0f && aod::reducedpair::mass < 5.0f && aod::reducedpair::sign == 0; - Partition selectedDimuonCandidatesWithDca = aod::reducedpair::mass > 1.0f && aod::reducedpair::mass < 5.0f && aod::reducedpair::sign == 0; - Partition selectedDielectronCandidates = aod::reducedpair::mass > 1.0f && aod::reducedpair::mass < 5.0f && aod::reducedpair::sign == 0; - Partition selectedDielectronCandidatesWithDca = aod::reducedpair::mass > 1.0f && aod::reducedpair::mass < 5.0f && aod::reducedpair::sign == 0; - Partition selectedD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; - Partition selectedD0CandidatesWithBdt = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; - Preslice perCollisionDmeson = aod::hf_cand::collisionId; - Preslice perCollisionDimuon = aod::reducedpair::collisionId; - Preslice perCollisionDielectron = aod::reducedpair::collisionId; + Preslice perCollisionDmesonWithBdt = aod::hf_cand::collisionId; + PresliceUnsorted perCollisionMuons = aod::reducedmuon::collisionId; + PresliceUnsorted perCollisionElectrons = aod::reducedtrack::collisionId; + + SliceCache cache; + Filter filterD0Candidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; // Define histograms manager float* fValuesDileptonCharmHadron{}; HistogramManager* fHistMan{}; OutputObj fOutputList{"output"}; + std::vector fTrackCuts; + std::vector fMuonCuts; + void init(o2::framework::InitContext&) { + std::array doprocess{doprocessJspiToMuMuD0, doprocessJspiToMuMuD0WithBdt, doprocessJspiToEED0, doprocessJspiToEED0WithBdt}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { + LOGP(fatal, "Only one process function should be enabled! Please check your configuration!"); + } + fValuesDileptonCharmHadron = new float[VarManager::kNVars]; VarManager::SetDefaultVarNames(); fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); @@ -99,28 +144,116 @@ struct tableMakerJpsiHf { fHistMan->AddHistClass("JPsi"); fHistMan->AddHistClass("JPsiDmeson"); dqhistograms::DefineHistograms(fHistMan, "Dmeson", "dilepton-charmhadron", "dmeson"); - if (dileptonDecayChannel.value == "JPsiToMuMu") { + if (doprocessJspiToMuMuD0 || doprocessJspiToMuMuD0WithBdt) { dqhistograms::DefineHistograms(fHistMan, "JPsi", "dilepton-charmhadron", "jpsitomumu"); dqhistograms::DefineHistograms(fHistMan, "JPsiDmeson", "dilepton-charmhadron", "jpsitomumudmeson"); } - if (dileptonDecayChannel.value == "JPsiToEE") { + if (doprocessJspiToEED0 || doprocessJspiToEED0WithBdt) { dqhistograms::DefineHistograms(fHistMan, "JPsi", "dilepton-charmhadron", "jpsitoee"); dqhistograms::DefineHistograms(fHistMan, "JPsiDmeson", "dilepton-charmhadron", "jpsitoeedmeson"); } VarManager::SetUseVars(fHistMan->GetUsedVars()); fOutputList.setObject(fHistMan->GetMainHistogramList()); + + // cut strings + if (doprocessJspiToMuMuD0 || doprocessJspiToMuMuD0WithBdt) { + TString cutNamesMuon = fConfigMuonCuts.value; + if (!cutNamesMuon.IsNull()) { + std::unique_ptr objArray(cutNamesMuon.Tokenize(",")); + for (int iCut{0}; iCut < objArray->GetEntries(); ++iCut) { + fMuonCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(iCut)->GetName())); + } + } + } + if (doprocessJspiToEED0 || doprocessJspiToEED0WithBdt) { + TString cutNamesElectron = fConfigTrackCuts.value; + if (!cutNamesElectron.IsNull()) { // if track cuts + std::unique_ptr objArray(cutNamesElectron.Tokenize(",")); + for (int iCut{0}; iCut < objArray->GetEntries(); ++iCut) { + fTrackCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(iCut)->GetName())); + } + } + } + + // It seems they are not applied when filling the table + // TString cutNamesPair = fConfigPairCuts.value; + // if (!cutNamesPair.IsNull()) { + // std::unique_ptr objArray(cutNamesPair.Tokenize(",")); + // for (int iCut{0}; iCut < objArray->GetEntries(); ++iCut) { + // fPairCuts.push_back(*dqcuts::GetCompositeCut(objArray->At(iCut)->GetName())); + // } + // } + } + + // template function for lepton selection + template + bool isLeptonSelected(TTrack const& lepton) + { + + if constexpr (TPairType == VarManager::kDecayToEE) { + VarManager::FillTrack(lepton); + for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++) { + if (!(*cut).IsSelected(VarManager::fgValues)) { + return false; + } + } + } else if constexpr (TPairType == VarManager::kDecayToMuMu) { + VarManager::FillTrack(lepton); + for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++) { + if (!(*cut).IsSelected(VarManager::fgValues)) { + return false; + } + } + } + + return true; + } + + // template function to compute the dilepton combinatorial + template + std::vector computeDileptonCombinatorial(TTracks const& tracks) + { + std::vector dileptons{}; + uint32_t dileptonMcDecision{0u}; // placeholder, copy of the dqEfficiency.cxx one + + for (auto& [trackFirst, trackSecond] : combinations(tracks, tracks)) { + bool isFirstSelected = isLeptonSelected(trackFirst); + bool isSecondSelected = isLeptonSelected(trackSecond); + + if (!isFirstSelected || !isSecondSelected || (trackFirst.sign() + trackSecond.sign()) != 0) { + continue; + } + + // we fill a struct for the dileptons, which has the same signatures of the DQ tables to be used in the VarManager + VarManager::FillPair(trackFirst, trackSecond); + + if (VarManager::fgValues[VarManager::kMass] < massDileptonCandMin || VarManager::fgValues[VarManager::kMass] > massDileptonCandMax) { + continue; + } + + CandidateDilepton dilepton{}; + dilepton.fMass = VarManager::fgValues[VarManager::kMass]; + dilepton.fPt = VarManager::fgValues[VarManager::kPt]; + dilepton.fEta = VarManager::fgValues[VarManager::kEta]; + dilepton.fPhi = VarManager::fgValues[VarManager::kPhi]; + dilepton.fSign = trackFirst.sign() + trackSecond.sign(); + dilepton.fMcDecision = dileptonMcDecision; + dileptons.push_back(dilepton); + } + + return dileptons; } // Template function to run pair - hadron combinations // TODO: generalise to all charm-hadron species - template - void runDileptonDmeson(TDqTrack const& dileptons, THfTrack const& dmesons, MyEvents::iterator const& collision) + template + void runDileptonDmeson(TDqTrack const& leptons, THfTrack const& dmesons, MyEvents::iterator const& collision, TracksWithExtra const&) { VarManager::ResetValues(0, VarManager::kNVars, fValuesDileptonCharmHadron); bool isCollSel{false}; if (configDebug) { - for (auto& dmeson : dmesons) { + for (auto const& dmeson : dmesons) { if (!TESTBIT(dmeson.hfflag(), DecayType::D0ToPiK)) { continue; } @@ -158,7 +291,11 @@ struct tableMakerJpsiHf { } } + // we compute the dileptons on the fly + auto dileptons = computeDileptonCombinatorial(leptons); + // loop over dileptons + std::vector filledDmesonIds{}; // keep track of the D-mesons filled in the table to avoid repetitions for (auto dilepton : dileptons) { auto massJPsi = dilepton.mass(); bool isJPsiFilled{false}; @@ -175,11 +312,17 @@ struct tableMakerJpsiHf { } // loop over D mesons - for (auto& dmeson : dmesons) { + for (auto const& dmeson : dmesons) { if (!TESTBIT(dmeson.hfflag(), DecayType::D0ToPiK)) { continue; } + int dmesonIdx = dmeson.globalIndex(); + bool isDmesonFilled{false}; + if (std::find(filledDmesonIds.begin(), filledDmesonIds.end(), dmesonIdx) != filledDmesonIds.end()) { // we already included this D meson in the table, skip it + isDmesonFilled = true; + } + auto rapD0 = hfHelper.yD0(dmeson); if (yCandDmesonMax >= 0. && std::abs(rapD0) > yCandDmesonMax) { @@ -203,20 +346,30 @@ struct tableMakerJpsiHf { } isJPsiFilled = true; } - redDmesons(indexRed, dmeson.px(), dmeson.py(), dmeson.pz(), dmeson.xSecondaryVertex(), dmeson.ySecondaryVertex(), dmeson.zSecondaryVertex(), 0, 0); + if (!isDmesonFilled) { + redDmesons(indexRed, dmeson.px(), dmeson.py(), dmeson.pz(), dmeson.xSecondaryVertex(), dmeson.ySecondaryVertex(), dmeson.zSecondaryVertex(), 0, 0); + auto trackProng0 = dmeson.template prong0_as(); + auto trackProng1 = dmeson.template prong1_as(); + // one table for each daughter with single track variables + redDmesDau0(trackProng0.pt(), trackProng0.eta(), trackProng0.itsNCls(), trackProng0.tpcNClsCrossedRows(), dmeson.nSigTpcPi0(), dmeson.nSigTofPi0(), dmeson.nSigTpcKa0(), dmeson.nSigTofKa0()); + redDmesDau1(trackProng1.pt(), trackProng1.eta(), trackProng1.itsNCls(), trackProng1.tpcNClsCrossedRows(), dmeson.nSigTpcPi1(), dmeson.nSigTofPi1(), dmeson.nSigTpcKa1(), dmeson.nSigTofKa1()); + filledDmesonIds.push_back(dmesonIdx); + } std::array scores = {999., -999., -999., 999., -999., -999.}; // D0 + D0bar if constexpr (withBdt) { - if (dmeson.mlProbD0().size() == 3) { - for (auto iScore{0u}; iScore < dmeson.mlProbD0().size(); ++iScore) { - scores[iScore] = dmeson.mlProbD0()[iScore]; + if (!isDmesonFilled) { + if (dmeson.mlProbD0().size() == 3) { + for (auto iScore{0u}; iScore < dmeson.mlProbD0().size(); ++iScore) { + scores[iScore] = dmeson.mlProbD0()[iScore]; + } } - } - if (dmeson.mlProbD0bar().size() == 3) { - for (auto iScore{0u}; iScore < dmeson.mlProbD0bar().size(); ++iScore) { - scores[iScore + 3] = dmeson.mlProbD0bar()[iScore]; + if (dmeson.mlProbD0bar().size() == 3) { + for (auto iScore{0u}; iScore < dmeson.mlProbD0bar().size(); ++iScore) { + scores[iScore + 3] = dmeson.mlProbD0bar()[iScore]; + } } + redDmesBdts(scores[0], scores[1], scores[2], scores[3], scores[4], scores[5]); } - redDmesBdts(scores[0], scores[1], scores[2], scores[3], scores[4], scores[5]); } if (dmeson.isSelD0() >= 1) { @@ -231,61 +384,63 @@ struct tableMakerJpsiHf { fHistMan->FillHistClass("JPsiDmeson", fValuesDileptonCharmHadron); VarManager::ResetValues(0, VarManager::kNVars, fValuesDileptonCharmHadron); } - redD0Masses(massD0, massD0bar); + if (!isDmesonFilled) { + redD0Masses(massD0, massD0bar); + } } } } } // process J/psi(->mumu) - D0 - void processJspiToMuMuD0(MyEvents const& collisions, MyDimuonCandidatesSelected const&, MyD0CandidatesSelected const&) + void processJspiToMuMuD0(MyEvents const& collisions, MyMuonTracksSelectedWithColl const& muonCandidates, soa::Filtered const& selectedD0Candidates, TracksWithExtra const& barrelTracks) { if (storeTableForNorm) { redCollCounter(collisions.size()); } - for (auto& collision : collisions) { - auto groupedDmesonCandidates = selectedD0Candidates->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - auto groupedDileptonCandidates = selectedDimuonCandidates->sliceByCached(aod::reducedpair::collisionId, collision.globalIndex(), cache); - runDileptonDmeson(groupedDileptonCandidates, groupedDmesonCandidates, collision); + for (auto const& collision : collisions) { + auto groupedDmesonCandidates = selectedD0Candidates.sliceBy(perCollisionDmeson, collision.globalIndex()); + auto groupedLeptonCandidates = muonCandidates.sliceBy(perCollisionMuons, collision.globalIndex()); + runDileptonDmeson(groupedLeptonCandidates, groupedDmesonCandidates, collision, barrelTracks); } } // process J/psi(->ee) - D0 - void processJspiToEED0(MyEvents const& collisions, MyDielectronCandidatesSelected const&, MyD0CandidatesSelected const&) + void processJspiToEED0(MyEvents const& collisions, MyBarrelTracksSelectedWithColl const& electronCandidates, soa::Filtered const& selectedD0Candidates, TracksWithExtra const& barrelTracks) { if (storeTableForNorm) { redCollCounter(collisions.size()); } - for (auto& collision : collisions) { - auto groupedDmesonCandidates = selectedD0Candidates->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - auto groupedDileptonCandidates = selectedDielectronCandidates->sliceByCached(aod::reducedpair::collisionId, collision.globalIndex(), cache); - runDileptonDmeson(groupedDileptonCandidates, groupedDmesonCandidates, collision); + for (auto const& collision : collisions) { + auto groupedDmesonCandidates = selectedD0Candidates.sliceBy(perCollisionDmeson, collision.globalIndex()); + auto groupedLeptonCandidates = electronCandidates.sliceBy(perCollisionElectrons, collision.globalIndex()); + runDileptonDmeson(groupedLeptonCandidates, groupedDmesonCandidates, collision, barrelTracks); } } // process J/psi(->mumu) - D0 adding the BDT output scores to the D0 table - void processJspiToMuMuD0WithBdt(MyEvents const& collisions, MyDimuonCandidatesSelected const&, MyD0CandidatesSelectedWithBdt const&) + void processJspiToMuMuD0WithBdt(MyEvents const& collisions, MyMuonTracksSelectedWithColl const& muonCandidates, soa::Filtered const& selectedD0CandidatesWithBdt, TracksWithExtra const& barrelTracks) { if (storeTableForNorm) { redCollCounter(collisions.size()); } - for (auto& collision : collisions) { - auto groupedDmesonCandidates = selectedD0CandidatesWithBdt->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - auto groupedDileptonCandidates = selectedDimuonCandidates->sliceByCached(aod::reducedpair::collisionId, collision.globalIndex(), cache); - runDileptonDmeson(groupedDileptonCandidates, groupedDmesonCandidates, collision); + for (auto const& collision : collisions) { + auto groupedDmesonCandidates = selectedD0CandidatesWithBdt.sliceBy(perCollisionDmesonWithBdt, collision.globalIndex()); + auto groupedLeptonCandidates = muonCandidates.sliceBy(perCollisionMuons, collision.globalIndex()); + runDileptonDmeson(groupedLeptonCandidates, groupedDmesonCandidates, collision, barrelTracks); } } // process J/psi(->ee) - D0 adding the BDT output scores to the D0 table - void processJspiToEED0WithBdt(MyEvents const& collisions, MyDielectronCandidatesSelected const&, MyD0CandidatesSelectedWithBdt const&) + void processJspiToEED0WithBdt(MyEvents const& collisions, MyBarrelTracksSelectedWithColl const& electronCandidates, soa::Filtered const& selectedD0CandidatesWithBdt, TracksWithExtra const& barrelTracks) { if (storeTableForNorm) { redCollCounter(collisions.size()); } - for (auto& collision : collisions) { - auto groupedDmesonCandidates = selectedD0CandidatesWithBdt->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); - auto groupedDileptonCandidates = selectedDielectronCandidates->sliceByCached(aod::reducedpair::collisionId, collision.globalIndex(), cache); - runDileptonDmeson(groupedDileptonCandidates, groupedDmesonCandidates, collision); + for (auto const& collision : collisions) { + auto groupedDmesonCandidates = selectedD0CandidatesWithBdt.sliceBy(perCollisionDmesonWithBdt, collision.globalIndex()); + auto groupedLeptonCandidates = electronCandidates.sliceBy(perCollisionElectrons, collision.globalIndex()); + runDileptonDmeson(groupedLeptonCandidates, groupedDmesonCandidates, collision, barrelTracks); } } diff --git a/PWGDQ/TableProducer/tableMakerMC.cxx b/PWGDQ/TableProducer/tableMakerMC.cxx index 40d3c346b58..fde24653c03 100644 --- a/PWGDQ/TableProducer/tableMakerMC.cxx +++ b/PWGDQ/TableProducer/tableMakerMC.cxx @@ -79,19 +79,13 @@ using MyMuonsWithCov = soa::Join; using MyMuonsCollWithCov = soa::Join; +using MyMftTracks = soa::Join; + using MyEvents = soa::Join; using MyEventsWithMults = soa::Join; using MyEventsWithCent = soa::Join; using MyEventsWithCentAndMults = soa::Join; -namespace o2::aod -{ -DECLARE_SOA_TABLE(AmbiguousTracksMid, "AOD", "AMBIGUOUSTRACK", //! Table for tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::TrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -DECLARE_SOA_TABLE(AmbiguousTracksFwd, "AOD", "AMBIGUOUSFWDTR", //! Table for Fwd tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::FwdTrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -} // namespace o2::aod - 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; constexpr static uint32_t gkEventFillMapWithCent = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent; @@ -105,6 +99,7 @@ constexpr static uint32_t gkMuonFillMapWithCov = VarManager::ObjTypes::Muon | Va 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; struct TableMakerMC { @@ -127,6 +122,9 @@ struct TableMakerMC { Produces muonExtra; Produces muonCov; Produces muonLabels; // TODO: enable this once we have fwdtrack labels + Produces trackMFT; + Produces trackMFTExtra; + Produces trackMFTLabels; // list of MCsignal objects std::vector fMCSignals; @@ -316,9 +314,9 @@ struct TableMakerMC { Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; // Templated function instantianed for all of the process functions - template + template void fullSkimming(TEvent const& collisions, aod::BCsWithTimestamps const& /*bcs*/, TTracks const& tracksBarrel, TMuons const& tracksMuon, - aod::McCollisions const& /*mcEvents*/, aod::McParticles_001 const& mcTracks, TAmbiTracks const& ambiTracksMid, TAmbiMuons const& ambiTracksFwd) + aod::McCollisions const& /*mcEvents*/, aod::McParticles_001 const& mcTracks, TAmbiTracks const& ambiTracksMid, TAmbiMuons const& ambiTracksFwd, TMFTTracks const& mftTracks = nullptr) { // Loop over collisions and produce skimmed data tables for: // 1) all selected collisions @@ -652,6 +650,71 @@ struct TableMakerMC { } // end loop over reconstructed tracks } // end if constexpr (static_cast(TTrackFillMap)) + // Maps for the MFT-muon matching index + std::map newMFTTableSize; // key : oldMFTIndex, value: size of the table-1 at step key + std::map mftOffsets; // key: mftoldglobalindex, value: mft.offsets + + if constexpr (static_cast(TMFTFillMap)) { + trackMFT.reserve(mftTracks.size()); + trackMFTExtra.reserve(mftTracks.size()); + // TODO add cuts on the MFT tracks + // int nDel = 0; + for (auto& mft : mftTracks) { + if (false) // for now no cuts + { + // nDel++; + } else { // it passes the cuts and will be saved in the tables + newMFTTableSize[mft.index()] = trackMFT.lastIndex(); + } + + // Check MC matching + if (!mft.has_mcParticle()) { + continue; + } + auto mctrack = mft.template mcParticle_as(); + + 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 |= (uint16_t(1) << i); + } + i++; + } + + // if the MC truth particle corresponding to this reconstructed track is not already written, + // add it to the skimmed 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.globalIndex())->second; + fCounters[0]++; + } + + mftOffsets[mft.globalIndex()] = mft.offsets(); + + double chi2 = mft.chi2(); + SMatrix5 tpars(mft.x(), mft.y(), mft.phi(), mft.tgl(), mft.signed1Pt()); + std::vector v1; + SMatrix55 tcovs(v1.begin(), v1.end()); + o2::track::TrackParCovFwd pars1{mft.z(), tpars, tcovs, chi2}; + pars1.propagateToZlinear(collision.posZ()); + + double dcaX = (pars1.getX() - collision.posX()); + double dcaY = (pars1.getY() - collision.posY()); + + VarManager::FillTrack(mft); + fHistMan->FillHistClass("MftTracks", VarManager::fgValues); + + trackMFT(event.lastIndex(), trackFilteringTag, mft.pt(), mft.eta(), mft.phi()); + trackMFTExtra(mft.mftClusterSizesAndTrackFlags(), mft.sign(), dcaX, dcaY, mft.nClusters()); + trackMFTLabels(fNewLabels.find(mctrack.index())->second, mft.mcMask(), mcflags); + } // end of mft : mftTracks + + } // end if constexpr (TMFTFillMap) + if constexpr (static_cast(TMuonFillMap)) { // build the muon tables muonBasic.reserve(tracksMuon.size()); @@ -669,6 +732,7 @@ struct TableMakerMC { int idxPrev = -1; std::map newEntryNb; std::map newMatchIndex; + std::map newMFTMatchIndex; for (auto& muon : groupedMuons) { trackFilteringTag = uint64_t(0); @@ -792,9 +856,13 @@ struct TableMakerMC { if (static_cast(muon.trackType()) == 0 || static_cast(muon.trackType()) == 2) { // MCH-MFT or GLB track int matchIdx = muon.matchMCHTrackId() - muon.offsets(); + int matchMFTIdx = muon.matchMFTTrackId() - mftOffsets[muon.matchMFTTrackId()]; + + // first for MCH matching index if (newEntryNb.count(matchIdx) > 0) { // if the key exists which means the match will not get deleted newMatchIndex[muon.index()] = newEntryNb[matchIdx]; // update the match for this muon to the updated entry of the match newMatchIndex[muon.index()] += muonBasic.lastIndex() + 1 - newEntryNb[muon.index()]; // adding the offset of muons, muonBasic.lastIndex() start at -1 + if (static_cast(muon.trackType()) == 0) { // for now only do this to global tracks newMatchIndex[matchIdx] = newEntryNb[muon.index()]; // add the updated index of this muon as a match to mch track newMatchIndex[matchIdx] += muonBasic.lastIndex() + 1 - newEntryNb[muon.index()]; // adding the offset, muonBasic.lastIndex() start at -1 @@ -802,6 +870,14 @@ struct TableMakerMC { } else { newMatchIndex[muon.index()] = -1; } + + // then for MFT match index + if (newMFTTableSize.count(matchMFTIdx) > 0) { // if the key exists i.e the match will not get deleted + newMFTMatchIndex[muon.index()] = newMFTTableSize[matchMFTIdx] + 1; // adding the offset of mfts, newMFTTableSize start at -1 + } else { + newMFTMatchIndex[muon.index()] = -1; + } + } else if (static_cast(muon.trackType() == 4)) { // an MCH track // in this case the matches should be filled from the other types but we need to check if (newMatchIndex.count(muon.index()) == 0) { @@ -809,7 +885,7 @@ struct TableMakerMC { } } - 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); + muonBasic(event.lastIndex(), newMatchIndex.find(muon.index())->second, newMFTMatchIndex.find(muon.index())->second, trackFilteringTag, VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], muon.sign(), isAmbiguous); if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { if (fPropMuon) { muonExtra(muon.nClusters(), VarManager::fgValues[VarManager::kMuonPDca], VarManager::fgValues[VarManager::kMuonRAtAbsorberEnd], @@ -1218,6 +1294,7 @@ struct TableMakerMC { int idxPrev = -1; std::map newEntryNb; std::map newMatchIndex; + std::map newMFTMatchIndex; for (auto& muonId : fwdtrackIdsThisCollision) { auto muon = muonId.template fwdtrack_as(); @@ -1529,14 +1606,14 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, soa::Filtered const& tracksMuon, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, tracksMuon, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, nullptr); } void processFullWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksBarrel, soa::Filtered const& tracksMuon, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, tracksMuon, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables ------------------------------------------------------------------------------------ @@ -1544,7 +1621,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with multiplicity ------------------------------------------------------------------------------------ @@ -1552,7 +1629,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with centrality ------------------------------------------------------------------------------------ @@ -1560,7 +1637,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with centrality and multiplicity ------------------------------------------------------------------- @@ -1568,7 +1645,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with cov matrix----------------------------------------------------------------------- @@ -1576,7 +1653,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with centrality, multiplicity and cov matrix ------------------------------------------------------------------- @@ -1584,7 +1661,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce barrel only tables, with cov matrix and dalitz bits----------------------------------------------------------------------- @@ -1592,7 +1669,7 @@ struct TableMakerMC { soa::Filtered const& tracksBarrel, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce muon only tables ------------------------------------------------------------------------------------ @@ -1600,21 +1677,28 @@ struct TableMakerMC { soa::Filtered const& tracksMuon, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce muon only tables, with centrality------------------------------------------------------------------------------- void processMuonOnlyWithCent(MyEventsWithCent const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksMuon, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, nullptr); } // Produce muon only tables, with cov matrix ------------------------------------------------------------------------------------ void processMuonOnlyWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksMuon, aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) { - fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr); + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, nullptr); + } + // Produce MFT tracks tables and muons ------------------------------------------------------------------------------------------------------------------ + void processMuonsAndMFT(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, + MyMftTracks const& tracksMft, MyMuonsWithCov const& tracksMuon, + aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks) + { + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, nullptr, tracksMft); } // Produce muon tables only based on track-collision association tables -------------------------------------------------------------------------------------- void processAssociatedMuonOnly(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, @@ -1647,24 +1731,24 @@ struct TableMakerMC { // Produce muon tables only for ambiguous tracks studies -------------------------------------------------------------------------------------- void processAmbiguousMuonOnly(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksMuon, - aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousTracksFwd const& ambiTracksFwd) + aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousFwdTracks const& ambiTracksFwd) { - fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, ambiTracksFwd); + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, ambiTracksFwd, nullptr); } void processAmbiguousMuonOnlyWithCov(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksMuon, - aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousTracksFwd const& ambiTracksFwd) + aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousFwdTracks const& ambiTracksFwd) { - fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, ambiTracksFwd); + fullSkimming(collisions, bcs, nullptr, tracksMuon, mcEvents, mcTracks, nullptr, ambiTracksFwd, nullptr); } // Produce track tables only for ambiguous tracks studies ------------------------------------------------------------------------------------- void processAmbiguousBarrelOnly(MyEvents const& collisions, aod::BCsWithTimestamps const& bcs, soa::Filtered const& tracksBarrel, - aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousTracksMid const& ambiTracksMid) + aod::McCollisions const& mcEvents, aod::McParticles_001 const& mcTracks, aod::AmbiguousTracks const& ambiTracksMid) { - fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, ambiTracksMid, nullptr); + fullSkimming(collisions, bcs, tracksBarrel, nullptr, mcEvents, mcTracks, ambiTracksMid, nullptr, nullptr); } // Process the BCs and store stats for luminosity retrieval ----------------------------------------------------------------------------------- void processOnlyBCs(soa::Join::iterator const& bc) @@ -1688,6 +1772,7 @@ struct TableMakerMC { PROCESS_SWITCH(TableMakerMC, processBarrelOnlyWithDalitzBits, "Produce barrel skims, and dalitz bits", false); PROCESS_SWITCH(TableMakerMC, processMuonOnly, "Produce muon skims", false); PROCESS_SWITCH(TableMakerMC, processMuonOnlyWithCov, "Produce muon skims, with muon covariance matrix", false); + PROCESS_SWITCH(TableMakerMC, processMuonsAndMFT, "Produce muon and MFT skims", false); PROCESS_SWITCH(TableMakerMC, processMuonOnlyWithCent, "Produce muon skims, w/ centrality", false); PROCESS_SWITCH(TableMakerMC, processOnlyBCs, "Analyze the BCs to store sampled lumi", false); PROCESS_SWITCH(TableMakerMC, processAssociatedMuonOnly, "Produce muon skims using track-collision association tables", false); diff --git a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx index b0e33fb4258..bcb465d13fb 100644 --- a/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx @@ -152,21 +152,28 @@ struct TableMakerMC { Configurable fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"}; Configurable fConfigBarrelTrackMaxAbsEta{"cfgBarrelMaxAbsEta", 0.9f, "Eta absolute value cut for tracks in the barrel"}; Configurable fConfigBarrelTrackMinPt{"cfgBarrelMinPt", 0.5f, "Minimum pt for tracks in the barrel"}; - Configurable fConfigBarrelRequireTPC{"cfgBarrelRequireTPC", true, "Require TPC for tracks in the barrel"}; Configurable fConfigBarrelMinTPCncls{"cfgBarrelMinTPCncls", 50.0f, "Minimum TPC cls for tracks in the barrel"}; Configurable fConfigBarrelMaxTPCchi2{"cfgBarrelMaxTPCchi2", 10.0f, "Maximum TPC chi2/ndf for tracks in the barrel"}; - Configurable fConfigBarrelRequireITS{"cfgBarrelRequireITS", true, "Require ITS for tracks in the barrel"}; Configurable fConfigBarrelMaxITSchi2{"cfgBarrelMaxITSchi2", 36.0f, "Maximum ITS chi2/ndf for tracks in the barrel"}; Configurable fConfigMuonPtLow{"cfgMuonLowPt", 1.0f, "Low pt cut for muons"}; // CCDB connection configurables Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - 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"}; Configurable grpmagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"}; + // Track related options + Configurable fPropTrack{"cfgPropTrack", true, "Propagate tracks to primary vertex"}; + + // 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 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"}; + Service fCCDB; + o2::ccdb::CcdbApi fCCDBApi; o2::parameters::GRPObject* grpmagrun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP o2::parameters::GRPMagField* grpmag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField @@ -280,6 +287,7 @@ struct TableMakerMC { if (!o2::base::GeometryManager::isGeometryLoaded()) { fCCDB->get(geoPath); } + fCCDBApi.init(fConfigCcdbUrl.value); } void DefineCuts() @@ -348,9 +356,9 @@ struct TableMakerMC { bool checked = false; if constexpr (soa::is_soa_filtered_v) { auto mctrack_raw = mcTracks.rawIteratorAt(mctrack.globalIndex()); - checked = sig.CheckSignal(false, mctrack_raw); + checked = sig.CheckSignal(true, mctrack_raw); } else { - checked = sig.CheckSignal(false, mctrack); + checked = sig.CheckSignal(true, mctrack); } if (checked) { mcflags |= (uint16_t(1) << i); @@ -512,6 +520,9 @@ struct TableMakerMC { trackFilteringTag = uint64_t(0); trackTempFilterMap = uint8_t(0); VarManager::FillTrack(track); + if (fPropTrack && (track.collisionId() != collision.globalIndex())) { + VarManager::FillTrackCollision(track, collision); + } if (fDoDetailedQA) { fHistMan->FillHistClass("TrackBarrel_BeforeCuts", VarManager::fgValues); } @@ -647,8 +658,8 @@ struct TableMakerMC { } } - template - void skimMuons(TEvent const& collision, TMuons const& muons, FwdTrackAssoc const& muonAssocs, aod::McParticles const& mcTracks) + template + void skimMuons(TEvent const& collision, TMuons const& muons, FwdTrackAssoc const& muonAssocs, aod::McParticles const& mcTracks, TMFTTracks const& /*mftTracks*/) { // Skim the fwd-tracks (muons) // Loop over the collision-track associations, recompute track properties depending on the collision assigned, and apply track cuts for selection @@ -667,10 +678,25 @@ struct TableMakerMC { auto muon = assoc.template fwdtrack_as(); trackFilteringTag = uint8_t(0); + trackTempFilterMap = uint8_t(0); 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 - VarManager::FillPropagateMuon(muon, collision); + if (fPropMuon) { + VarManager::FillPropagateMuon(muon, collision); + } + // recalculte pDca and global muon kinematics + if (static_cast(muon.trackType()) < 2 && fRefitGlobalMuon) { + auto muontrack = muon.template matchMCHTrack_as(); + if (muontrack.eta() < fMuonMatchEtaMin || muontrack.eta() > fMuonMatchEtaMax) { + continue; + } + auto mfttrack = muon.template matchMFTTrack_as(); + VarManager::FillTrackCollision(muontrack, collision); + VarManager::FillGlobalMuonRefit(muontrack, mfttrack, collision); + } else { + VarManager::FillTrackCollision(muon, collision); + } if (fDoDetailedQA) { fHistMan->FillHistClass("Muons_BeforeCuts", VarManager::fgValues); @@ -770,18 +796,31 @@ struct TableMakerMC { mftIdx = fMftIndexMap[muon.matchMFTTrackId()]; } } - muonBasic(reducedEventIdx, mchIdx, mftIdx, fFwdTrackFilterMap[muon.globalIndex()], muon.pt(), muon.eta(), muon.phi(), muon.sign(), 0); - muonExtra(muon.nClusters(), muon.pDca(), muon.rAtAbsorberEnd(), + VarManager::FillTrack(muon); + if (fPropMuon) { + VarManager::FillPropagateMuon(muon, collision); + } + // recalculte pDca and global muon kinematics + if (static_cast(muon.trackType()) < 2 && fRefitGlobalMuon) { + auto muontrack = muon.template matchMCHTrack_as(); + auto mfttrack = muon.template matchMFTTrack_as(); + 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(), muon.matchScoreMCHMFT(), muon.mchBitMap(), muon.midBitMap(), - muon.midBoards(), muon.trackType(), muon.fwdDcaX(), muon.fwdDcaY(), + muon.midBoards(), muon.trackType(), VarManager::fgValues[VarManager::kMuonDCAx], VarManager::fgValues[VarManager::kMuonDCAy], muon.trackTime(), muon.trackTimeRes()); if constexpr (static_cast(TMuonFillMap & VarManager::ObjTypes::MuonCov)) { - muonCov(muon.x(), muon.y(), muon.z(), muon.phi(), muon.tgl(), muon.sign() / muon.pt(), - 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()); + 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], + VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); } if (muon.has_mcParticle()) { auto mctrack = muon.template mcParticle_as(); @@ -811,6 +850,12 @@ struct TableMakerMC { o2::base::Propagator::initFieldFromGRP(grpmag); } } + std::map metadataRCT, header; + header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", bcs.begin().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); + fCurrentRun = bcs.begin().runNumber(); } @@ -875,8 +920,13 @@ struct TableMakerMC { skimMFT(collision, mftTracks, groupedMFTIndices); } if constexpr (static_cast(TMuonFillMap)) { - auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); - skimMuons(collision, muons, groupedMuonIndices, mcParticles); + if constexpr (static_cast(TMFTFillMap)) { + auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); + skimMuons(collision, muons, groupedMuonIndices, mcParticles, mftTracks); + } else { + auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); + skimMuons(collision, muons, groupedMuonIndices, mcParticles, nullptr); + } } } // end loop over skimmed collisions } diff --git a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx index 7550a15b713..d475c222f61 100644 --- a/PWGDQ/TableProducer/tableMaker_withAssoc.cxx +++ b/PWGDQ/TableProducer/tableMaker_withAssoc.cxx @@ -17,6 +17,12 @@ // The skimming can optionally produce just the barrel, muon, or both barrel and muon tracks // The event filtering, centrality, and V0Bits (from v0-selector) can be switched on/off by selecting one // of the process functions +// C++ includes +#include +#include +#include +#include +// other includes #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" @@ -61,21 +67,9 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod; -// DQ triggers -enum DQTriggers { - kSingleE = 1 << 0, // 0000001 - kLMeeIMR = 1 << 1, // 0000010 - kLMeeHMR = 1 << 2, // 0000100 - kDiElectron = 1 << 3, // 0001000 - kSingleMuLow = 1 << 4, // 0010000 - kSingleMuHigh = 1 << 5, // 0100000 - kDiMuon = 1 << 6, // 1000000 - kNTriggersDQ -}; - Zorro zorro; -std::string zorroTriggerMask[7] = {"fSingleE", "fLMeeIMR", "fLMeeHMR", "fDiElectron", "fSingleMuLow", "fSingleMuHigh", "fDiMuon"}; +// Declaration of various Joins used in the different process functions // TODO: Since DCA depends on which collision the track is associated to, we should remove writing and subscribing to DCA tables, to optimize on CPU / memory using MyBarrelTracks = soa::Join; using MyEventsWithFilter = soa::Join; using MyEventsWithMultsAndFilter = soa::Join; using MyEventsWithCent = soa::Join; -using MyEventsWithCentAndMults = soa::Join; +using MyEventsWithCentAndMults = soa::Join; using MyMuons = soa::Join; using MyMuonsWithCov = soa::Join; using MyMuonsColl = soa::Join; @@ -113,26 +107,20 @@ using MyMuonsCollWithCov = soa::Join; using ExtBCs = soa::Join; -namespace o2::aod -{ -DECLARE_SOA_TABLE(AmbiguousTracksMid, "AOD", "AMBIGUOUSTRACK", //! Table for tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::TrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -DECLARE_SOA_TABLE(AmbiguousTracksFwd, "AOD", "AMBIGUOUSFWDTR", //! Table for Fwd tracks which are not uniquely associated with a collision - o2::soa::Index<>, o2::aod::ambiguous::FwdTrackId, o2::aod::ambiguous::BCIdSlice, o2::soa::Marker<2>); -} // namespace o2::aod - +// Declaration of various bit maps containing information on which tables are included in a Join +// These are used as template arguments and checked at compile time // constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision; // constexpr static uint32_t gkEventFillMapWithFilter = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::EventFilter; - -// constexpr static uint32_t gkEventFillMapWithMult = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult; +constexpr static uint32_t gkEventFillMapWithMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult; +constexpr static uint32_t gkEventFillMapWithMultsZdc = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::Zdc; constexpr static uint32_t gkEventFillMapWithMultsAndEventFilter = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::CollisionMultExtra | VarManager::ObjTypes::EventFilter; constexpr static uint32_t gkEventFillMapWithMultsEventFilterZdc = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionMult | VarManager::ObjTypes::EventFilter | VarManager::ObjTypes::Zdc; // 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; +constexpr static uint32_t gkEventFillMapWithCentAndMults = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent | VarManager::CollisionMult | VarManager::ObjTypes::CollisionMultExtra; // constexpr static uint32_t gkEventFillMapWithCentRun2 = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCentRun2; // Unused variable // constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackPID | VarManager::ObjTypes::TrackPIDExtra; constexpr static uint32_t gkTrackFillMapWithCov = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackCov | VarManager::ObjTypes::TrackPID | VarManager::ObjTypes::TrackPIDExtra; -// constexpr static uint32_t gkTrackFillMapWithV0Bits = gkTrackFillMapWithCov | VarManager::ObjTypes::TrackV0Bits; +constexpr static uint32_t gkTrackFillMapWithV0Bits = gkTrackFillMapWithCov | VarManager::ObjTypes::TrackV0Bits; // constexpr static uint32_t gkTrackFillMapWithV0BitsForMaps = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackV0Bits | VarManager::ObjTypes::TrackTPCPID; // constexpr static uint32_t gkTrackFillMapWithDalitzBits = gkTrackFillMap | VarManager::ObjTypes::DalitzBits; // constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::Muon; @@ -142,6 +130,16 @@ constexpr static uint32_t gkMuonFillMapWithCov = VarManager::ObjTypes::Muon | Va // constexpr static uint32_t gkTrackFillMapWithAmbi = VarManager::ObjTypes::Track | VarManager::ObjTypes::AmbiTrack; constexpr static uint32_t gkMFTFillMap = VarManager::ObjTypes::TrackMFT; +// Enum containing the ordering of statistics histograms to be written in the QA file +enum SkimStatsHists { + kStatsEvent = 0, + kStatsTracks, + kStatsMuons, + kStatsOrphanTracks, + kStatsZorroInfo, + kStatsZorroSel +}; + struct TableMaker { Produces event; @@ -172,61 +170,83 @@ struct TableMaker { HistogramManager* fHistMan; // Event and track AnalysisCut configurables - 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"}; - Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; + 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"}; + } fConfigCuts; + + // Zorro selection + struct : ConfigurableGroup { + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; + Configurable fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"}; + Configurable fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"}; + } fConfigZorro; // Steer QA output - Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; - Configurable fConfigDetailedQA{"cfgDetailedQA", false, "If true, include more QA histograms (BeforeCuts classes)"}; - Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; - Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; - Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + struct : ConfigurableGroup { + Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; + Configurable fConfigDetailedQA{"cfgDetailedQA", false, "If true, include more QA histograms (BeforeCuts classes)"}; + Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddTrackHistogram{"cfgAddTrackHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigAddMuonHistogram{"cfgAddMuonHistogram", "", "Comma separated list of histograms"}; + } fConfigHistOutput; - // Selections to be applied as Filter on the Track and FwdTrack Configurable fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"}; - Configurable fConfigBarrelTrackMaxAbsEta{"cfgBarrelMaxAbsEta", 0.9f, "Eta absolute value cut for tracks in the barrel"}; - Configurable fConfigBarrelTrackMinPt{"cfgBarrelMinPt", 0.5f, "Minimum pt for tracks in the barrel"}; - Configurable fConfigBarrelRequireTPC{"cfgBarrelRequireTPC", true, "Require TPC for tracks in the barrel"}; - Configurable fConfigBarrelMinTPCncls{"cfgBarrelMinTPCncls", 50.0f, "Minimum TPC cls for tracks in the barrel"}; - Configurable fConfigBarrelMaxTPCchi2{"cfgBarrelMaxTPCchi2", 10.0f, "Maximum TPC chi2/ndf for tracks in the barrel"}; - Configurable fConfigBarrelRequireITS{"cfgBarrelRequireITS", true, "Require ITS for tracks in the barrel"}; - Configurable fConfigBarrelMaxITSchi2{"cfgBarrelMaxITSchi2", 36.0f, "Maximum ITS chi2/ndf for tracks in the barrel"}; - Configurable fConfigMuonPtLow{"cfgMuonLowPt", 1.0f, "Low pt cut for muons"}; + + // Selections to be applied as Filter on the Track and FwdTrack + /*struct : ConfigurableGroup { + Configurable fConfigBarrelTrackMaxAbsEta{"cfgBarrelMaxAbsEta", 0.9f, "Eta absolute value cut for tracks in the barrel"}; + Configurable fConfigBarrelTrackMinPt{"cfgBarrelMinPt", 0.5f, "Minimum pt for tracks in the barrel"}; + Configurable fConfigBarrelRequireTPC{"cfgBarrelRequireTPC", true, "Require TPC for tracks in the barrel"}; + Configurable fConfigBarrelMinTPCncls{"cfgBarrelMinTPCncls", 50.0f, "Minimum TPC cls for tracks in the barrel"}; + Configurable fConfigBarrelMaxTPCchi2{"cfgBarrelMaxTPCchi2", 10.0f, "Maximum TPC chi2/ndf for tracks in the barrel"}; + Configurable fConfigBarrelRequireITS{"cfgBarrelRequireITS", true, "Require ITS for tracks in the barrel"}; + Configurable fConfigBarrelMaxITSchi2{"cfgBarrelMaxITSchi2", 36.0f, "Maximum ITS chi2/ndf for tracks in the barrel"}; + Configurable fConfigMuonPtLow{"cfgMuonLowPt", 1.0f, "Low pt cut for muons"}; + } fConfigFilter;*/ // CCDB connection configurables - 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 geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable grpmagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"}; + struct : ConfigurableGroup { + 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 fConfigCcdbPathZorro{"ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/Chunked/", "base path to the ccdb object for zorro"}; + 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"}; + Configurable fConfigGrpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable fConfigGrpMagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"}; + } fConfigCCDB; // TPC postcalibration related options - 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 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"}; - - // Track related options - Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; - - // Muon related options - Configurable fPropMuon{"cfgPropMuon", true, "Propgate muon tracks through absorber (do not use if applying pairing)"}; + struct : ConfigurableGroup { + 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 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 { + // Track related options + Configurable fPropTrack{"cfgPropTrack", true, "Propagate tracks to associated collision to recalculate DCA and momentum vector"}; + // 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 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; Service fCCDB; + o2::ccdb::CcdbApi fCCDBApi; - o2::parameters::GRPObject* grpmagrun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP - o2::parameters::GRPMagField* grpmag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField + 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 - Service ccdb; 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. @@ -242,12 +262,12 @@ struct TableMaker { // our own Filtered tracks. If the filter is very selective, then it may be worth to run the association in this workflow // using the Common/CollisionAssociation class /*Filter barrelSelectedTracks = ifnode(fIsRun2.node() == true, track::trackType == uint8_t(track::Run2Track), track::trackType == uint8_t(track::Track)) - && track::pt > fConfigBarrelTrackMinPt - && nabs(track::eta) <= fConfigBarrelTrackMaxAbsEta - && ifnode(fConfigBarrelRequireITS.node() == true, track::itsChi2NCl < fConfigBarrelMaxITSchi2, true) - && ifnode(fConfigBarrelRequireTPC.node() == true, track::tpcNClsFound > fConfigBarrelMinTPCncls && track::tpcChi2NCl < fConfigBarrelMaxTPCchi2, true); + && track::pt > fConfigFilter.fConfigBarrelTrackMinPt + && nabs(track::eta) <= fConfigFilter.fConfigBarrelTrackMaxAbsEta + && ifnode(fConfigFilter.fConfigBarrelRequireITS.node() == true, track::itsChi2NCl < fConfigFilter.fConfigBarrelMaxITSchi2, true) + && ifnode(fConfigFilter.fConfigBarrelRequireTPC.node() == true, track::tpcNClsFound > fConfigFilter.fConfigBarrelMinTPCncls && track::tpcChi2NCl < fConfigFilter.fConfigBarrelMaxTPCchi2, true); - Filter muonFilter = o2::aod::fwdtrack::pt >= fConfigMuonPtLow;*/ + Filter muonFilter = o2::aod::fwdtrack::pt >= fConfigFilter.fConfigMuonPtLow;*/ Preslice trackIndicesPerCollision = aod::track_association::collisionId; Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; @@ -255,92 +275,105 @@ struct TableMaker { void init(o2::framework::InitContext& context) { - DefineCuts(); - ccdb->setURL(fConfigCcdbUrl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); + // CCDB configuration + if (fConfigPostCalibTPC.fConfigComputeTPCpostCalib) { + fCCDB->setURL(fConfigCCDB.fConfigCcdbUrl.value); + fCCDB->setCaching(true); + fCCDB->setLocalObjectValidityChecking(); + // Not later than now objects + fCCDB->setCreatedNotAfter(fConfigCCDB.fConfigNoLaterThan.value); + } + fCCDBApi.init(fConfigCCDB.fConfigCcdbUrl.value); + if (!o2::base::GeometryManager::isGeometryLoaded()) { - ccdb->get(geoPath); + fCCDB->get(fConfigCCDB.fConfigGeoPath); } + // 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); // Only use detailed QA when QA is set true - if (fConfigQA && fConfigDetailedQA) { + if (fConfigHistOutput.fConfigQA && fConfigHistOutput.fConfigDetailedQA) { fDoDetailedQA = true; } // Create the histogram class names to be added to the histogram manager + // The histogram class names are added into a string and then passed to the DefineHistograms() function which + // actually configures the HistogramManager + // Histograms are defined as histogram classes / groups and filled at specific points in the analysis flow TString histClasses = ""; + // Event-wise histograms, before selection cuts if (fDoDetailedQA) { histClasses += "Event_BeforeCuts;"; } - if (fConfigQA) { + // Event-wise histograms, after selection cuts + if (fConfigHistOutput.fConfigQA) { histClasses += "Event_AfterCuts;"; } - bool enableBarrelHistos = (context.mOptions.get("processPPWithFilter") || context.mOptions.get("processPPWithFilterBarrelOnly") || - context.mOptions.get("processPbPb") || context.mOptions.get("processPbPbBarrelOnly")); - bool enableMuonHistos = (context.mOptions.get("processPPWithFilter") || context.mOptions.get("processPPWithFilterMuonOnly") || context.mOptions.get("processPPWithFilterMuonMFT") || + // 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")); + + 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")); if (enableBarrelHistos) { + // Barrel track histograms, before selections if (fDoDetailedQA) { histClasses += "TrackBarrel_BeforeCuts;"; } - if (fConfigQA) { + 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()); } } - if (fConfigIsOnlyforMaps) { + // Barrel histograms for clean samples of V0 legs used for post-calibration + if (fConfigPostCalibTPC.fConfigIsOnlyforMaps) { histClasses += "TrackBarrel_PostCalibElectron;"; histClasses += "TrackBarrel_PostCalibPion;"; histClasses += "TrackBarrel_PostCalibProton;"; } } if (enableMuonHistos) { + // Muon tracks before cuts and MFT tracks if (fDoDetailedQA) { histClasses += "Muons_BeforeCuts;"; histClasses += "MftTracks;"; } - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { + // Muon tracks after selections; one directory per selection for (auto& muonCut : fMuonCuts) { histClasses += Form("Muons_%s;", muonCut.GetName()); } } } - if (fConfigDummyRunlist) { - VarManager::SetDummyRunlist(fConfigInitRunNumber); + if (fConfigPostCalibTPC.fConfigDummyRunlist) { + VarManager::SetDummyRunlist(fConfigPostCalibTPC.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()); - - // CCDB configuration - if (fConfigComputeTPCpostCalib) { - fCCDB->setURL(fConfigCcdbUrl.value); - fCCDB->setCaching(true); - fCCDB->setLocalObjectValidityChecking(); - // Not later than now objects - fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); - } } void DefineCuts() { // Event cuts fEventCut = new AnalysisCompositeCut(true); - TString eventCutStr = fConfigEventCuts.value; + TString eventCutStr = fConfigCuts.fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); // Barrel track cuts - TString cutNamesStr = fConfigTrackCuts.value; + TString cutNamesStr = fConfigCuts.fConfigTrackCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { @@ -349,7 +382,7 @@ struct TableMaker { } // Muon cuts - cutNamesStr = fConfigMuonCuts.value; + cutNamesStr = fConfigCuts.fConfigMuonCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); for (int icut = 0; icut < objArray->GetEntries(); ++icut) { @@ -362,15 +395,16 @@ struct TableMaker { void DefineHistograms(TString histClasses) { + // Create histograms via HistogramManager std::unique_ptr objArray(histClasses.Tokenize(";")); for (Int_t iclass = 0; iclass < objArray->GetEntries(); ++iclass) { TString classStr = objArray->At(iclass)->GetName(); - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { fHistMan->AddHistClass(classStr.Data()); } // fill the THn histograms - if (fConfigIsOnlyforMaps) { + if (fConfigPostCalibTPC.fConfigIsOnlyforMaps) { if (classStr.Contains("PostCalibElectron")) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", "postcalib_electron"); } @@ -382,36 +416,42 @@ struct TableMaker { } } - TString histEventName = fConfigAddEventHistogram.value; + TString histEventName = fConfigHistOutput.fConfigAddEventHistogram.value; if (classStr.Contains("Event")) { - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "event", histEventName); } } - TString histTrackName = fConfigAddTrackHistogram.value; + TString histTrackName = fConfigHistOutput.fConfigAddTrackHistogram.value; if (classStr.Contains("Track")) { - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histTrackName); } } - TString histMuonName = fConfigAddMuonHistogram.value; + TString histMuonName = fConfigHistOutput.fConfigAddMuonHistogram.value; if (classStr.Contains("Muons")) { - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histMuonName); } } - TString histMftName = fConfigAddMuonHistogram.value; + TString histMftName = fConfigHistOutput.fConfigAddMuonHistogram.value; if (classStr.Contains("Mft")) { - if (fConfigDetailedQA) { + if (fConfigHistOutput.fConfigDetailedQA) { dqhistograms::DefineHistograms(fHistMan, objArray->At(iclass)->GetName(), "track", histMftName); } } } - // create statistics histograms (event, tracks, muons) + // Create statistics histograms which will be stored in the QA output + // Event statistics: kStatsEvent + // Track statistics: kStatsTracks + // Muon statistics: kStatsMuons + // Orphan track statistics: kStatsOrphanTracks + // Zorro information: kStatsZorroInfo + // Zorro trigger selection: kStatsZorroSel fStatsList.setObject(new TList()); fStatsList->SetOwner(kTRUE); std::vector eventLabels{"BCs", "Collisions before filtering", "Before cuts", "After cuts"}; @@ -424,7 +464,7 @@ struct TableMaker { histEvents->GetYaxis()->SetBinLabel(ib, o2::aod::evsel::selectionLabels[ib - 1]); } histEvents->GetYaxis()->SetBinLabel(o2::aod::evsel::kNsel + 1, "Total"); - fStatsList->Add(histEvents); + fStatsList->AddAt(histEvents, kStatsEvent); // Track statistics: one bin for each track selection and 5 bins for V0 tags (gamma, K0s, Lambda, anti-Lambda, Omega) TH1D* histTracks = new TH1D("TrackStats", "Track statistics", fTrackCuts.size() + 5.0, -0.5, fTrackCuts.size() - 0.5 + 5.0); @@ -436,20 +476,33 @@ struct TableMaker { for (ib = 0; ib < 5; ib++) { histTracks->GetXaxis()->SetBinLabel(fTrackCuts.size() + 1 + ib, v0TagNames[ib]); } - fStatsList->Add(histTracks); + fStatsList->AddAt(histTracks, kStatsTracks); + 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()); } - fStatsList->Add(histMuons); + fStatsList->AddAt(histMuons, kStatsMuons); + + TH1D* histOrphanTracks = new TH1D("histOrphanTracks", "Orphan Track statistics", 2, -1, 1); + histOrphanTracks->GetXaxis()->SetBinLabel(1, "Track w/o collision ID"); + histOrphanTracks->GetXaxis()->SetBinLabel(2, "Track with +ve collision ID"); + fStatsList->AddAt(histOrphanTracks, kStatsOrphanTracks); + + TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5); + fStatsList->AddAt(histZorroInfo, kStatsZorroInfo); + + TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5); + fStatsList->AddAt(histZorroSel, kStatsZorroSel); } - template - void skimCollisions(TEvents const& collisions, TBCs const& /*bcs*/, TZdcs const& /*zdcs*/) + template + void skimCollisions(TEvents const& collisions, TBCs const& /*bcs*/, TZdcs const& /*zdcs*/, + TTrackAssoc const& trackAssocs, TTracks const& tracks) { // Skim collisions - // NOTE: So far, collisions are filtered based on the user specified analysis cuts and the filterPP event filter. + // NOTE: So far, collisions are filtered based on the user specified analysis cuts AND the filterPP or Zorro event filter. // The collision-track associations which point to an event that is not selected for writing are discarded! fCollIndexMap.clear(); @@ -470,10 +523,10 @@ struct TableMaker { for (int i = 0; i < o2::aod::evsel::kNsel; i++) { if (collision.selection_bit(i)) { - (reinterpret_cast(fStatsList->At(0)))->Fill(1.0, static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(1.0, static_cast(i)); } } - (reinterpret_cast(fStatsList->At(0)))->Fill(1.0, static_cast(o2::aod::evsel::kNsel)); + (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) { @@ -489,7 +542,7 @@ struct TableMaker { // if the BC found by event selection does not coincide with the collision.bc() auto bcEvSel = collision.template foundBC_as(); if (bcEvSel.globalIndex() != bc.globalIndex()) { - tag |= (uint64_t(1) << 0); + 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) { @@ -505,6 +558,10 @@ struct TableMaker { VarManager::FillZDC(bc_zdc); } } + if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionMultExtra) > 0 && (TTrackFillMap & VarManager::ObjTypes::Track) > 0 && (TTrackFillMap & VarManager::ObjTypes::TrackDCA) > 0) { + auto groupedTrackIndices = trackAssocs.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + VarManager::FillEventTrackEstimators(collision, groupedTrackIndices, tracks); + } if (fDoDetailedQA) { fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); } @@ -512,17 +569,21 @@ struct TableMaker { // fill stats information, before selections for (int i = 0; i < o2::aod::evsel::kNsel; i++) { if (collision.selection_bit(i)) { - (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(2.0, static_cast(i)); } } - (reinterpret_cast(fStatsList->At(0)))->Fill(2.0, static_cast(o2::aod::evsel::kNsel)); - - if (fConfigRunZorro) { - for (int i = 0; i < kNTriggersDQ; ++i) { - zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), zorroTriggerMask[i]); - if (!zorro.isSelected(bc.globalBC())) { - tag |= static_cast(1 << i); - } + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(2.0, static_cast(o2::aod::evsel::kNsel)); + + if (fConfigZorro.fConfigRunZorro) { + zorro.setBaseCCDBPath(fConfigCCDB.fConfigCcdbPathZorro.value); + 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))); + if (zorroSel) { + tag |= (static_cast(true) << 56); // the same bit is used for this zorro selections from ccdb + } + if (fConfigZorro.fConfigRunZorroSel && (!zorroSel || !fEventCut->IsSelected(VarManager::fgValues))) { + continue; } } else { if (!fEventCut->IsSelected(VarManager::fgValues)) { @@ -533,10 +594,10 @@ struct TableMaker { // fill stats information, after selections for (int i = 0; i < o2::aod::evsel::kNsel; i++) { if (collision.selection_bit(i)) { - (reinterpret_cast(fStatsList->At(0)))->Fill(3.0, static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(3.0, static_cast(i)); } } - (reinterpret_cast(fStatsList->At(0)))->Fill(3.0, static_cast(o2::aod::evsel::kNsel)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(3.0, static_cast(o2::aod::evsel::kNsel)); fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); @@ -574,8 +635,10 @@ 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()); + multAll(collision.multAllTracksTPCOnly(), collision.multAllTracksITSTPC(), - 0, 0, 0.0, 0.0, 0, 0); + VarManager::fgValues[VarManager::kNTPCpileupContribA], VarManager::fgValues[VarManager::kNTPCpileupContribC], + VarManager::fgValues[VarManager::kNTPCpileupZA], VarManager::fgValues[VarManager::kNTPCpileupZC], 0, 0); } fCollIndexMap[collision.globalIndex()] = event.lastIndex(); @@ -590,23 +653,24 @@ struct TableMaker { // One can apply here cuts which depend on the association (e.g. DCA), which will discard (hopefully most) wrong associations. // Tracks are written only once, even if they constribute to more than one association - uint64_t trackFilteringTag = uint64_t(0); - uint64_t trackTempFilterMap = uint8_t(0); + uint64_t trackFilteringTag = static_cast(0); + uint32_t trackTempFilterMap = static_cast(0); // material correction for track propagation + // TODO: Do we need a configurable to switch between different material correction options? // o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; for (const auto& assoc : assocs) { - // get track + // get the track auto track = assoc.template track_as(); - trackFilteringTag = uint64_t(0); - trackTempFilterMap = uint8_t(0); + trackFilteringTag = static_cast(0); + trackTempFilterMap = static_cast(0); VarManager::FillTrack(track); // compute quantities which depend on the associated collision, such as DCA - if (fPropTrack && (track.collisionId() != collision.globalIndex())) { + if (fConfigVariousOptions.fPropTrack && (track.collisionId() != collision.globalIndex())) { VarManager::FillTrackCollisionMatCorr(track, collision, noMatCorr, o2::base::Propagator::Instance()); } @@ -618,13 +682,13 @@ struct TableMaker { int i = 0; for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, i++) { if ((*cut).IsSelected(VarManager::fgValues)) { - trackTempFilterMap |= (uint8_t(1) << i); - // NOTE: the QA is filled here for every (collision,track) association since the results of the track cuts can be different depending on which collision is associated (e.g. DCA cuts) - // TODO: create a statistics histograms with unique tracks - if (fConfigQA) { + 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); } - (reinterpret_cast(fStatsList->At(1)))->Fill(static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsTracks)))->Fill(static_cast(i)); } } if (!trackTempFilterMap) { @@ -633,49 +697,64 @@ struct TableMaker { // store selection information in the track tag if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackV0Bits)) { // BIT0-4: V0Bits - trackFilteringTag |= uint64_t(track.pidbit()); + trackFilteringTag |= static_cast(track.pidbit()); for (int iv0 = 0; iv0 < 5; iv0++) { if (track.pidbit() & (uint8_t(1) << iv0)) { - (reinterpret_cast(fStatsList->At(1)))->Fill(fTrackCuts.size() + static_cast(iv0)); + (reinterpret_cast(fStatsList->At(kStatsTracks)))->Fill(fTrackCuts.size() + static_cast(iv0)); } } - if (fConfigIsOnlyforMaps) { - if (trackFilteringTag & (uint64_t(1) << VarManager::kIsConversionLeg)) { // for electron + if (fConfigPostCalibTPC.fConfigIsOnlyforMaps) { + if (trackFilteringTag & (static_cast(1) << VarManager::kIsConversionLeg)) { // for electron fHistMan->FillHistClass("TrackBarrel_PostCalibElectron", VarManager::fgValues); } - if (trackFilteringTag & (uint64_t(1) << VarManager::kIsK0sLeg)) { // for pion + if (trackFilteringTag & (static_cast(1) << VarManager::kIsK0sLeg)) { // for pion fHistMan->FillHistClass("TrackBarrel_PostCalibPion", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda + if ((static_cast(trackFilteringTag & (static_cast(1) << VarManager::kIsLambdaLeg)) * (track.sign()) > 0)) { // for proton from Lambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } - if ((static_cast(trackFilteringTag & (uint64_t(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda + if ((static_cast(trackFilteringTag & (static_cast(1) << VarManager::kIsALambdaLeg)) * (track.sign()) < 0)) { // for proton from AntiLambda fHistMan->FillHistClass("TrackBarrel_PostCalibProton", VarManager::fgValues); } } - if (fConfigSaveElectronSample) { // only save electron sample - if (!(trackFilteringTag & (uint64_t(1) << VarManager::kIsConversionLeg))) { + if (fConfigPostCalibTPC.fConfigSaveElectronSample) { // only save electron sample + if (!(trackFilteringTag & (static_cast(1) << VarManager::kIsConversionLeg))) { continue; } } } // end if V0Bits if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::DalitzBits)) { - trackFilteringTag |= (uint64_t(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz + trackFilteringTag |= (static_cast(track.dalitzBits()) << VarManager::kDalitzBits); // BIT5-12: Dalitz } - trackFilteringTag |= (uint64_t(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-...: user track filters + trackFilteringTag |= (static_cast(trackTempFilterMap) << VarManager::kBarrelUserCutsBits); // BIT13-...: user track filters if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackPID)) { - if (fConfigComputeTPCpostCalib) { - trackFilteringTag |= (uint64_t(1) << VarManager::kIsTPCPostcalibrated); + if (fConfigPostCalibTPC.fConfigComputeTPCpostCalib) { + trackFilteringTag |= (static_cast(1) << VarManager::kIsTPCPostcalibrated); } } - // write the track global index in the map for skimming (to make sure we have it just once) if (fTrackIndexMap.find(track.globalIndex()) == fTrackIndexMap.end()) { - // NOTE: The collision ID that is written in the table is the one found in the first association for this track. - // However, in data analysis one should loop over associations, so this one should not be used. - // In the case of Run2-like analysis, there will be no associations, so this ID will be the one originally assigned in the AO2Ds (updated for the skims) - uint32_t reducedEventIdx = fCollIndexMap[collision.globalIndex()]; + + // Calculating the percentage of orphan tracks i.e., tracks which have no collisions associated to it + if (!track.has_collision()) { + (reinterpret_cast(fStatsList->At(kStatsOrphanTracks)))->Fill(static_cast(-1)); + } else { + (reinterpret_cast(fStatsList->At(kStatsOrphanTracks)))->Fill(0.9); + } + + // NOTE: The collision ID written in the table is the one of the original collision assigned in the AO2D. + // The reason is that the time associated to the track is wrt that collision. + // If new associations are done with the skimmed data, the track time wrt new collision can then be recomputed based on the + // relative difference in time between the original and the new collision. + + // If the original collision of this track was not selected for skimming, then we skip this track. + // Normally, the filter-pp is selecting all collisions which contain the tracks which contributed to the triggering + // of an event, so this is rejecting possibly a few tracks originally associated with collisions distant in time. + if (fCollIndexMap.find(track.collisionId()) == fCollIndexMap.end()) { + continue; + } + uint32_t reducedEventIdx = fCollIndexMap[track.collisionId()]; // This gives the original iD of the track // NOTE: trackBarrelInfo stores the index of the collision as in AO2D (for use in some cases where the analysis on skims is done // in workflows where the original AO2Ds are also present) trackBarrelInfo(collision.globalIndex(), collision.posX(), collision.posY(), collision.posZ(), track.globalIndex()); @@ -694,10 +773,10 @@ struct TableMaker { track.c1PtY(), track.c1PtZ(), track.c1PtSnp(), track.c1PtTgl(), track.c1Pt21Pt2()); } if constexpr (static_cast(TTrackFillMap & VarManager::ObjTypes::TrackPID)) { - float nSigmaEl = (fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaEl_Corr] : track.tpcNSigmaEl()); - float nSigmaPi = (fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaPi_Corr] : track.tpcNSigmaPi()); - float nSigmaKa = ((fConfigComputeTPCpostCalib && fConfigComputeTPCpostCalibKaon) ? VarManager::fgValues[VarManager::kTPCnSigmaKa_Corr] : track.tpcNSigmaKa()); - float nSigmaPr = (fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaPr_Corr] : track.tpcNSigmaPr()); + float nSigmaEl = (fConfigPostCalibTPC.fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaEl_Corr] : track.tpcNSigmaEl()); + float nSigmaPi = (fConfigPostCalibTPC.fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaPi_Corr] : track.tpcNSigmaPi()); + float nSigmaKa = ((fConfigPostCalibTPC.fConfigComputeTPCpostCalib && fConfigPostCalibTPC.fConfigComputeTPCpostCalibKaon) ? VarManager::fgValues[VarManager::kTPCnSigmaKa_Corr] : track.tpcNSigmaKa()); + float nSigmaPr = (fConfigPostCalibTPC.fConfigComputeTPCpostCalib ? VarManager::fgValues[VarManager::kTPCnSigmaPr_Corr] : track.tpcNSigmaPr()); trackBarrelPID(track.tpcSignal(), nSigmaEl, track.tpcNSigmaMu(), nSigmaPi, nSigmaKa, nSigmaPr, track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), @@ -708,7 +787,7 @@ struct TableMaker { // write the skimmed collision - track association trackBarrelAssoc(fCollIndexMap[collision.globalIndex()], fTrackIndexMap[track.globalIndex()]); } // end loop over associations - } // end skimTracks + } // end skimTracks template void skimMFT(TEvent const& collision, TBCs const& /*bcs*/, MFTTracks const& /*mfts*/, MFTTrackAssoc const& mftAssocs) @@ -719,7 +798,7 @@ struct TableMaker { for (const auto& assoc : mftAssocs) { auto track = assoc.template mfttrack_as(); - if (fConfigQA) { + if (fConfigHistOutput.fConfigQA) { VarManager::FillTrack(track); fHistMan->FillHistClass("MftTracks", VarManager::fgValues); } @@ -727,7 +806,7 @@ struct TableMaker { // write the MFT track global index in the map for skimming (to make sure we have it just once) if (fMftIndexMap.find(track.globalIndex()) == fMftIndexMap.end()) { uint32_t reducedEventIdx = fCollIndexMap[collision.globalIndex()]; - mftTrack(reducedEventIdx, uint64_t(0), track.pt(), track.eta(), track.phi()); + mftTrack(reducedEventIdx, static_cast(0), track.pt(), track.eta(), track.phi()); // TODO: We are not writing the DCA at the moment, because this depend on the collision association mftTrackExtra(track.mftClusterSizesAndTrackFlags(), track.sign(), 0.0, 0.0, track.nClusters()); @@ -737,16 +816,18 @@ struct TableMaker { } } - template - void skimMuons(TEvent const& collision, TBCs const& /*bcs*/, TMuons const& muons, FwdTrackAssoc const& muonAssocs, MFTTracks const& /*mftTracks*/) + template + void skimMuons(TEvent const& collision, TBCs const& /*bcs*/, TMuons const& muons, FwdTrackAssoc const& muonAssocs, TMFTTracks const& /*mftTracks*/) { // Skim the fwd-tracks (muons) // Loop over the collision-track associations, recompute track properties depending on the collision assigned, and apply track cuts for selection // Muons are written only once, even if they constribute to more than one association, // which means that in the case of multiple associations, the track parameters are wrong and should be computed again at analysis time. - uint8_t trackFilteringTag = uint8_t(0); - uint8_t trackTempFilterMap = uint8_t(0); + // TODO: Currently, the TMFTFillMap is not used in this function. Is it needed ? + + uint8_t trackFilteringTag = static_cast(0); + uint8_t trackTempFilterMap = static_cast(0); fFwdTrackIndexMapReversed.clear(); uint32_t offset = muonBasic.lastIndex(); @@ -755,18 +836,25 @@ struct TableMaker { // get the muon auto muon = assoc.template fwdtrack_as(); - trackFilteringTag = uint8_t(0); + trackFilteringTag = static_cast(0); + trackTempFilterMap = static_cast(0); VarManager::FillTrack(muon); - // NOTE: If a muon is associated to multiple collisions, depending on the selections, + // NOTE: Muons are propagated to the current associated collisions. + // So if a muon is associated to multiple collisions, depending on the selections, // it may be accepted for some associations and rejected for other - if (fPropMuon) { + if (fConfigVariousOptions.fPropMuon) { VarManager::FillPropagateMuon(muon, collision); } - // recalculte pDca and global muon kinematics - if (static_cast(muon.trackType()) < 2) { + // recalculate 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(); + if (muontrack.eta() < fConfigVariousOptions.fMuonMatchEtaMin || muontrack.eta() > fConfigVariousOptions.fMuonMatchEtaMax) { + continue; + } VarManager::FillTrackCollision(muontrack, collision); + // NOTE: the MFT track originally associated to the MUON track is currently used in the global muon refit + // Should MUON - MFT time ambiguities be taken into account ? + auto mfttrack = muon.template matchMFTTrack_as(); VarManager::FillGlobalMuonRefit(muontrack, mfttrack, collision); } else { VarManager::FillTrackCollision(muon, collision); @@ -779,11 +867,14 @@ struct TableMaker { int i = 0; for (auto cut = fMuonCuts.begin(); cut != fMuonCuts.end(); cut++, i++) { if ((*cut).IsSelected(VarManager::fgValues)) { - trackTempFilterMap |= (uint8_t(1) << i); - if (fConfigQA) { + 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); } - (reinterpret_cast(fStatsList->At(2)))->Fill(static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsMuons)))->Fill(static_cast(i)); } } @@ -818,13 +909,13 @@ struct TableMaker { // get the muon auto muon = muons.rawIteratorAt(origIdx); uint32_t reducedEventIdx = fCollIndexMap[collision.globalIndex()]; - // NOTE: Currently, one writes the original AO2D momentum-vector (pt, eta and phi) in the tables because we write only one instance of the muon track, - // while multiple collision associations (and multiple mom vectors can exist) + // NOTE: Currently, one writes in the tables the momentum-vector (pt, eta and phi) of the first collision association for this muon, + // while multiple collision associations (and multiple mom vectors can exist). // The momentum can be recomputed at the analysis time based on the associations written in the skims // So all the information which pertains to collision association or MFT associations should not be taken from the skimmed data, but recomputed at analysis time. uint32_t mchIdx = -1; uint32_t mftIdx = -1; - if (muon.trackType() == uint8_t(0) || muon.trackType() == uint8_t(2)) { // MCH-MID (2) or global (0) + if (muon.trackType() == static_cast(0) || muon.trackType() == static_cast(2)) { // MCH-MID (2) or global (0) if (fFwdTrackIndexMap.find(muon.matchMCHTrackId()) != fFwdTrackIndexMap.end()) { mchIdx = fFwdTrackIndexMap[muon.matchMCHTrackId()]; } @@ -832,6 +923,19 @@ struct TableMaker { mftIdx = fMftIndexMap[muon.matchMFTTrackId()]; } } + VarManager::FillTrack(muon); + if (fConfigVariousOptions.fPropMuon) { + VarManager::FillPropagateMuon(muon, collision); + } + // 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(); + 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(), @@ -847,7 +951,7 @@ struct TableMaker { VarManager::fgValues[VarManager::kMuonC1Pt2Phi], VarManager::fgValues[VarManager::kMuonC1Pt2Tgl], VarManager::fgValues[VarManager::kMuonC1Pt21Pt2]); } } // end loop over selected muons - } // end skimMuons + } // end skimMuons // Produce standard barrel + muon tables with event filter (typically for pp and p-Pb) ------------------------------------------------------ template getForTimeStamp(fConfigCcdbPathTPC.value, bcs.begin().timestamp()); + if (bcs.size() > 0 && fCurrentRun != bcs.begin().runNumber()) { + if (fConfigPostCalibTPC.fConfigComputeTPCpostCalib) { + auto calibList = fCCDB->getForTimeStamp(fConfigCCDB.fConfigCcdbPathTPC.value, bcs.begin().timestamp()); VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron")); VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion")); VarManager::SetCalibrationObject(VarManager::kTPCPionSigma, calibList->FindObject("sigma_map_pion")); VarManager::SetCalibrationObject(VarManager::kTPCProtonMean, calibList->FindObject("mean_map_proton")); VarManager::SetCalibrationObject(VarManager::kTPCProtonSigma, calibList->FindObject("sigma_map_proton")); - if (fConfigComputeTPCpostCalibKaon) { + if (fConfigPostCalibTPC.fConfigComputeTPCpostCalibKaon) { VarManager::SetCalibrationObject(VarManager::kTPCKaonMean, calibList->FindObject("mean_map_kaon")); VarManager::SetCalibrationObject(VarManager::kTPCKaonSigma, calibList->FindObject("sigma_map_kaon")); } } if (fIsRun2 == true) { - grpmagrun2 = ccdb->getForTimeStamp(grpmagPathRun2, bcs.begin().timestamp()); - if (grpmagrun2 != nullptr) { - o2::base::Propagator::initFieldFromGRP(grpmagrun2); + fGrpMagRun2 = fCCDB->getForTimeStamp(fConfigCCDB.fConfigGrpMagPathRun2, bcs.begin().timestamp()); + if (fGrpMagRun2 != nullptr) { + o2::base::Propagator::initFieldFromGRP(fGrpMagRun2); } } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, bcs.begin().timestamp()); - if (grpmag != nullptr) { - o2::base::Propagator::initFieldFromGRP(grpmag); + fGrpMag = fCCDB->getForTimeStamp(fConfigCCDB.fConfigGrpMagPath, bcs.begin().timestamp()); + if (fGrpMag != nullptr) { + o2::base::Propagator::initFieldFromGRP(fGrpMag); } } + std::map metadataRCT, header; + header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", bcs.begin().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); + fCurrentRun = bcs.begin().runNumber(); - } + } // end updating the CCDB quantities at change of run // skim collisions - skimCollisions(collisions, bcs, zdcs); + event.reserve(collisions.size()); + eventExtended.reserve(collisions.size()); + eventVtxCov.reserve(collisions.size()); + + skimCollisions(collisions, bcs, zdcs, trackAssocs, tracksBarrel); if (fCollIndexMap.size() == 0) { return; } @@ -919,23 +1033,34 @@ struct TableMaker { muonAssoc.reserve(muons.size()); } - // loop over selected collisions and select the tracks and fwd tracks to be skimmed + // loop over selected collisions, group the compatible associations, and run the skimming for (auto const& [origIdx, skimIdx] : fCollIndexMap) { auto collision = collisions.rawIteratorAt(origIdx); - // group the tracks and muons for this collision + // group the barrel track associations for this collision if constexpr (static_cast(TTrackFillMap)) { auto groupedTrackIndices = trackAssocs.sliceBy(trackIndicesPerCollision, origIdx); skimTracks(collision, bcs, tracksBarrel, groupedTrackIndices); } + // group the MFT associations for this collision if constexpr (static_cast(TMFTFillMap)) { auto groupedMFTIndices = mftAssocs.sliceBy(mfttrackIndicesPerCollision, origIdx); skimMFT(collision, bcs, mftTracks, groupedMFTIndices); } - if constexpr (static_cast(TMuonFillMap) && static_cast(TMFTFillMap)) { - auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); - skimMuons(collision, bcs, muons, groupedMuonIndices, mftTracks); + // group the muon associations for this collision + if constexpr (static_cast(TMuonFillMap)) { + if constexpr (static_cast(TMFTFillMap)) { + auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); + skimMuons(collision, bcs, muons, groupedMuonIndices, mftTracks); + } else { + auto groupedMuonIndices = fwdTrackAssocs.sliceBy(fwdtrackIndicesPerCollision, origIdx); + skimMuons(collision, bcs, muons, groupedMuonIndices, nullptr); + } } } // 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"; } // 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) @@ -953,10 +1078,6 @@ struct TableMaker { MyBarrelTracksWithCov const& tracksBarrel, TrackAssoc const& trackAssocs) { - /*const int& a = 0; - MFTTracks const& mftTracks = 0; - FwdTrackAssoc const& fwdTrackAssocs = 0; - MFTTrackAssoc const& mftAssocs = 0;*/ fullSkimming(collisions, bcs, zdcs, tracksBarrel, nullptr, nullptr, trackAssocs, nullptr, nullptr); } @@ -975,6 +1096,29 @@ struct TableMaker { fullSkimming(collisions, bcs, nullptr, nullptr, muons, mftTracks, nullptr, fwdTrackAssocs, mftAssocs); } + // produce the barrel-only DQ skimmed data model typically for pp/p-Pb or UPC Pb-Pb (no centrality), meant to run on skimmed data + void processPPBarrelOnly(MyEventsWithMults 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 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) + { + 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, + 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, @@ -993,6 +1137,14 @@ 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 subscribtion to the DQ event filter + void processPbPbBarrelOnlyWithV0Bits(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, + MyBarrelTracksWithV0Bits 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 Pb-Pb (with centrality), no subscribtion to the DQ event filter void processPbPbMuonOnly(MyEventsWithCentAndMults const& collisions, BCsWithTimestamps const& bcs, MyMuonsWithCov const& muons, FwdTrackAssoc const& fwdTrackAssocs) @@ -1013,18 +1165,22 @@ struct TableMaker { { for (int i = 0; i < o2::aod::evsel::kNsel; i++) { if (bc.selection_bit(i) > 0) { - (reinterpret_cast(fStatsList->At(0)))->Fill(0.0, static_cast(i)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(0.0, static_cast(i)); } } - (reinterpret_cast(fStatsList->At(0)))->Fill(0.0, static_cast(o2::aod::evsel::kNsel)); + (reinterpret_cast(fStatsList->At(kStatsEvent)))->Fill(0.0, static_cast(o2::aod::evsel::kNsel)); } PROCESS_SWITCH(TableMaker, processPPWithFilter, "Build full DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb, w/ event filtering", false); PROCESS_SWITCH(TableMaker, processPPWithFilterBarrelOnly, "Build barrel only DQ skimmed data model typically for pp/p-Pb and UPC Pb-Pb, w/ event filtering", false); 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, processPPMuonOnly, "Build 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, 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, processPbPbBarrelOnlyWithV0Bits, "Build barrel only DQ skimmed data model typically for Pb-Pb, w/ V0 bits, 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, 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 f8fccece684..3d7f53faeba 100644 --- a/PWGDQ/Tasks/CMakeLists.txt +++ b/PWGDQ/Tasks/CMakeLists.txt @@ -69,6 +69,11 @@ o2physics_add_dpl_workflow(task-j-psi-hf PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-muon-dca + SOURCES muonDCA.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(correlation SOURCES dqCorrelation.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore O2Physics::GFWCore @@ -97,4 +102,14 @@ o2physics_add_dpl_workflow(task-mch-align-record o2physics_add_dpl_workflow(task-muon-mid-eff SOURCES MIDefficiency.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::MIDBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(task-fwd-track-pid + SOURCES taskFwdTrackPid.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(quarkonia-to-hyperons + SOURCES quarkoniaToHyperons.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGDQ/Tasks/MIDefficiency.cxx b/PWGDQ/Tasks/MIDefficiency.cxx index efcbe07af85..13377e5cc5c 100644 --- a/PWGDQ/Tasks/MIDefficiency.cxx +++ b/PWGDQ/Tasks/MIDefficiency.cxx @@ -16,14 +16,14 @@ /// Struct for writing the table and convert the data /// to MID tracks needed to compute the efficiency of the MID RPCs /// -/// \author Luca Quaglia -/// +/// \author Luca Quaglia // O2 physics classes #include "PWGDQ/DataModel/ReducedInfoTables.h" @@ -42,6 +42,7 @@ using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; +using MyEvents = soa::Join; using MyMuonTracks = soa::Join; struct midEfficiency { @@ -50,20 +51,33 @@ struct midEfficiency { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // Configurables for histogram axes - Configurable nBinsLocal{"nBinsLocal", 936, "N bins in local board counts histo"}; - Configurable nBinsRPC{"nBinsRPC", 72, "N bins in RPC counts histo"}; - Configurable nBinsPlane{"nBinsPlane", 4, "N bins in plane counts histo"}; - Configurable nBinsTrackType{"nBinsTrackType", 5, "N bins in track type debug histo"}; - Configurable createRootFile{"createRootFile", false, "if true it creates the mid-reco.root file for debug purposes"}; - - // Vector of MID tracks to pass to the efficiency calculator - std::vector dummyTrack; + // Centrality + Configurable nBinsCentrality{"nBinsCentrality", 9, "N bins for centrality histo in PbPb"}; + Configurable minCentrality{"minCentrality", 0., "minimum of axis in centrality histo in PbPb"}; + Configurable maxCentrality{"maxCentrality", 90., "maximum of axis in centrality histo in PbPb"}; + Configurable isPbPb{"isPbPb", false, "If true, the task will be used to run on PbPb data and will enable the filling of THnSparse for centrality studies"}; + + // pt + Configurable nBinsPt{"nBinsPt", 2000, "N bins for pt histo"}; + Configurable minPt{"minPt", 0., "minimum of pt axis"}; // GeV/c + Configurable maxPt{"maxPt", 20., "maximum of pt axis"}; + + // eta + Configurable nBinsEta{"nBinsEta", 500, "N bins for eta histo"}; + Configurable minEta{"minEta", -5., "minimum of eta axis"}; // + Configurable maxEta{"maxEta", 5., "maximum of eta axis"}; + + // phi + Configurable nBinsPhi{"nBinsPhi", 500, "N bins for phi histo"}; + Configurable minPhi{"minPhi", -2. * TMath::Pi(), "minimum of phi axis"}; // + Configurable maxPhi{"maxPhi", 2 * TMath::Pi(), "maximum of phi axis"}; + // MID track placeholder for processing o2::mid::Track trk; // MID mapping for LB calculation o2::mid::Mapping mapping; - // Filter only for MCH-MID tracks + // Filter only for MCH-MID matched tracks Filter muonTrackType = aod::fwdtrack::trackType == uint8_t(3); void init(o2::framework::InitContext const& /*ic*/) @@ -72,14 +86,18 @@ struct midEfficiency { LOGF(debug, "Initialization starting"); // Axes definition - const AxisSpec axisLocalBoards{nBinsLocal, 0.5, 936.5, "Local board"}; - const AxisSpec axisRPCs{nBinsRPC, -0.5, 71.5, "RPC"}; - const AxisSpec axisPlanes{nBinsPlane, -0.5, 3.5, "Plane"}; - const AxisSpec axisTrackType{nBinsTrackType, -0.5, 4.5, "Muon track type"}; + const AxisSpec axisLocalBoards{936, 0.5, 936.5, "Local board"}; // These are not defined as configurable since they are fixed + const AxisSpec axisRPCs{72, -0.5, 71.5, "RPC"}; // These are not defined as configurable since they are fixed + const AxisSpec axisPlanes{4, -0.5, 3.5, "Plane"}; // These are not defined as configurable since they are fixed + const AxisSpec axisTrackType{5, -0.5, 4.5, "Muon track type"}; // These are not defined as configurable since they are fixed + + const AxisSpec axisCent{nBinsCentrality, minCentrality, maxCentrality, "Centrality"}; + const AxisSpec axisPt{nBinsPt, minPt, maxPt, "track p_{t} [GeV/c]"}; + const AxisSpec axisEta{nBinsEta, minEta, maxEta, "track #eta"}; + const AxisSpec axisPhi{nBinsPhi, minPhi, maxPhi, "track #phi"}; LOGF(debug, "Creating histograms"); - // Same names as O2 task // Local boards histos.add("nFiredBPperBoard", "nFiredBPperBoard", kTH1F, {axisLocalBoards}); histos.add("nFiredNBPperBoard", "nFiredNBPperBoard", kTH1F, {axisLocalBoards}); @@ -95,16 +113,62 @@ struct midEfficiency { histos.add("nFiredNBPperPlane", "nFiredNBPperPlane", kTH1F, {axisPlanes}); histos.add("nFiredBothperPlane", "nFiredBothperPlane", kTH1F, {axisPlanes}); histos.add("nTotperPlane", "nTotperPlane", kTH1F, {axisPlanes}); - // Track type for debug only + // Centrality test + histos.add("hCentr", "hCentr", kTH1F, {axisCent}); + + // Track type histos.add("hTrackType", "hTrackType", kTH1F, {axisTrackType}); + // If this is true -> PbPb data, add THnSparse with centrality + if (isPbPb) { + // Local boards + histos.add("hSparseCentFiredBPperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisCent, axisPt, axisEta, axisPhi}); + + // RPCs + histos.add("hSparseCentFiredBPperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisCent, axisPt, axisEta, axisPhi}); + + // Planes + histos.add("hSparseCentFiredBPperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisCent, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisCent, axisPt, axisEta, axisPhi}); + } else { // THnSparse without centrality in pp + // Local boards + histos.add("hSparseCentFiredBPperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperBoard", "THn for centrality studies", HistType::kTHnSparseF, {axisLocalBoards, axisPt, axisEta, axisPhi}); + + // RPCs + histos.add("hSparseCentFiredBPperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperRPC", "THn for centrality studies", HistType::kTHnSparseF, {axisRPCs, axisPt, axisEta, axisPhi}); + + // Planes + histos.add("hSparseCentFiredBPperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredNBPperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredBothperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisPt, axisEta, axisPhi}); + histos.add("hSparseCentFiredTotperPlane", "THn for centrality studies", HistType::kTHnSparseF, {axisPlanes, axisPt, axisEta, axisPhi}); + } } // end of init template - void runMidEffCounters(TEvent const& /*event*/, Muons const& muons) + void runMidEffCounters(TEvent const& event, Muons const& muons) { LOGF(debug, "Calling process function"); + float cent = event.centFT0C(); + + if (isPbPb) + histos.fill(HIST("hCentr"), cent); // Fill centrality histo + // Loop over all forward tracks for (auto& track : muons) { @@ -119,6 +183,10 @@ struct midEfficiency { auto rpcLine = o2::mid::detparams::getRPCLine(deIdMT11); auto effFlag = trk.getEfficiencyFlag(); + float pt = track.pt(); + float eta = track.eta(); + float phi = track.phi(); + if (effFlag < 0) { continue; } @@ -126,17 +194,38 @@ struct midEfficiency { // Loop on the four planes and fill histograms accordingly for (int ich = 0; ich < 4; ++ich) { + // Check if BP/NBP has been fired by the track bool isFiredBP = trk.isFiredChamber(ich, 0); bool isFiredNBP = trk.isFiredChamber(ich, 1); + // Plane - // Fill all counts - plane - histos.fill(HIST("nTotperPlane"), ich); - if (isFiredBP) + histos.fill(HIST("nTotperPlane"), ich); // All counts - plane + if (isPbPb) + histos.fill(HIST("hSparseCentFiredTotperPlane"), ich, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredTotperPlane"), ich, pt, eta, phi); + + if (isFiredBP) { histos.fill(HIST("nFiredBPperPlane"), ich); // BP - Plane - if (isFiredNBP) + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBPperPlane"), ich, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBPperPlane"), ich, pt, eta, phi); + } + if (isFiredNBP) { histos.fill(HIST("nFiredNBPperPlane"), ich); // NBP - Plane - if (isFiredBP && isFiredNBP) + if (isPbPb) + histos.fill(HIST("hSparseCentFiredNBPperPlane"), ich, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredNBPperPlane"), ich, pt, eta, phi); + } + if (isFiredBP && isFiredNBP) { histos.fill(HIST("nFiredBothperPlane"), ich); // Both planes - plane + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBothperPlane"), ich, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBothperPlane"), ich, pt, eta, phi); + } if (effFlag < 2) { continue; @@ -145,39 +234,80 @@ struct midEfficiency { // Get RPC id auto deId = o2::mid::detparams::getDEId(isRight, ich, rpcLine); - // Fill all counts - RPC - histos.fill(HIST("nTotperRPC"), deId); - if (isFiredBP) + // RPC + histos.fill(HIST("nTotperRPC"), deId); // All counts - RPC + if (isPbPb) + histos.fill(HIST("hSparseCentFiredTotperRPC"), deId, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredTotperRPC"), deId, pt, eta, phi); + + if (isFiredBP) { histos.fill(HIST("nFiredBPperRPC"), deId); // BP - RPC - if (isFiredNBP) + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBPperRPC"), deId, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBPperRPC"), deId, pt, eta, phi); + } + if (isFiredNBP) { histos.fill(HIST("nFiredNBPperRPC"), deId); // NBP - RPC - if (isFiredBP && isFiredNBP) + if (isPbPb) + histos.fill(HIST("hSparseCentFiredNBPperRPC"), deId, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredNBPperRPC"), deId, pt, eta, phi); + } + if (isFiredBP && isFiredNBP) { histos.fill(HIST("nFiredBothperRPC"), deId); // Both planes - RPC + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBothperRPC"), deId, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBothperRPC"), deId, pt, eta, phi); + } if (effFlag < 3) { continue; } + // Get fired column and line -> needed for LB calculation + auto firedColumn = trk.getFiredColumnId(); + auto firedLine = trk.getFiredLineId(); // Get LB ID - auto firedColumn = trk.getFiredColumnId(); // Get fired column - needed for LB calculation - auto firedLine = trk.getFiredLineId(); // Get fired line - needed for LB calculation - auto LB = ich * o2::mid::detparams::NLocalBoards + mapping.getBoardId(firedLine, firedColumn, deId); - histos.fill(HIST("nTotperBoard"), LB); - - if (isFiredBP) - histos.fill(HIST("nFiredBPperBoard"), LB); - if (isFiredNBP) - histos.fill(HIST("nFiredNBPperBoard"), LB); - if (isFiredBP && isFiredNBP) - histos.fill(HIST("nFiredBothperBoard"), LB); + // LB + histos.fill(HIST("nTotperBoard"), LB); // All counts - LB + if (isPbPb) + histos.fill(HIST("hSparseCentFiredTotperBoard"), LB, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredTotperBoard"), LB, pt, eta, phi); + + if (isFiredBP) { + histos.fill(HIST("nFiredBPperBoard"), LB); // BP - LB + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBPperBoard"), LB, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBPperBoard"), LB, pt, eta, phi); + } + if (isFiredNBP) { + histos.fill(HIST("nFiredNBPperBoard"), LB); // NBP - LB + if (isPbPb) + histos.fill(HIST("hSparseCentFiredNBPperBoard"), LB, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredNBPperBoard"), LB, pt, eta, phi); + } + if (isFiredBP && isFiredNBP) { + histos.fill(HIST("nFiredBothperBoard"), LB); // Both Planes - LB + if (isPbPb) + histos.fill(HIST("hSparseCentFiredBothperBoard"), LB, cent, pt, eta, phi); + else + histos.fill(HIST("hSparseCentFiredBothperBoard"), LB, pt, eta, phi); + } } } } // end of runMidEffCounters - void processMidEffCounter(aod::ReducedEvents::iterator const& event, soa::Filtered const& muons) + // void processMidEffCounter(aod::ReducedEvents::iterator const& event, soa::Filtered const& muons) + void processMidEffCounter(MyEvents::iterator const& event, soa::Filtered const& muons) { runMidEffCounters(event, muons); // call efficiency calculator function } diff --git a/PWGDQ/Tasks/dqCorrelation.cxx b/PWGDQ/Tasks/dqCorrelation.cxx index 353a7fbf575..d2fa3a0dd4b 100644 --- a/PWGDQ/Tasks/dqCorrelation.cxx +++ b/PWGDQ/Tasks/dqCorrelation.cxx @@ -116,7 +116,7 @@ struct DqCumulantFlow { ConfigurableAxis axisEta{"axisEta", {40, -6.0, 1.5}, "eta axis for histograms"}; ConfigurableAxis axisPt{"axisPt", {100, 0, 20}, "pt axis for histograms"}; ConfigurableAxis axisMass{"axisMass", {40, 2, 4}, "mass axis for histograms"}; - Configurable fConfigNPow{"cfgNPow", 0, "Power of weights for Q vector"}; + Configurable fConfigNPow{"cfgNPow", 0, "Power of weights for Q vector"}; // Configurables for the reference flow Configurable fConfigTrackCuts{"cfgLeptonCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; Configurable fConfigCutPtMin{"cfgCutPtMin", 1.0f, "Minimal pT for tracks"}; diff --git a/PWGDQ/Tasks/dqEfficiency.cxx b/PWGDQ/Tasks/dqEfficiency.cxx index 2704cbc36a1..ee8cd2af5c1 100644 --- a/PWGDQ/Tasks/dqEfficiency.cxx +++ b/PWGDQ/Tasks/dqEfficiency.cxx @@ -97,8 +97,12 @@ struct AnalysisEventSelection { HistogramManager* fHistMan; AnalysisCompositeCut* fEventCut; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); @@ -167,8 +171,12 @@ struct AnalysisTrackSelection { std::vector fHistNamesReco; std::vector> fHistNamesMCMatched; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + // Setting the cut names TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { @@ -327,8 +335,12 @@ struct AnalysisMuonSelection { std::vector fHistNamesReco; std::vector> fHistNamesMCMatched; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + // Setting the cut names TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { @@ -532,6 +544,10 @@ struct AnalysisSameEventPairing { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; ccdb->setURL(ccdburl.value); @@ -797,8 +813,8 @@ struct AnalysisSameEventPairing { if constexpr ((TPairType == VarManager::kDecayToEE) && (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) { if (fConfigFlatTables.value) { dielectronAllList(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), dileptonFilterMap, dileptonMcDecision, - t1.pt(), t1.eta(), t1.phi(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), - t2.pt(), t2.eta(), t2.phi(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), + t1.pt(), t1.eta(), t1.phi(), t1.itsClusterMap(), t1.itsChi2NCl(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), + t2.pt(), t2.eta(), t2.phi(), t2.itsClusterMap(), t2.itsChi2NCl(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), VarManager::fgValues[VarManager::kKFTrack0DCAxyz], VarManager::fgValues[VarManager::kKFTrack1DCAxyz], VarManager::fgValues[VarManager::kKFDCAxyzBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DCAxy], VarManager::fgValues[VarManager::kKFTrack1DCAxy], VarManager::fgValues[VarManager::kKFDCAxyBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack0DeviationxyFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationxyFromPV], VarManager::fgValues[VarManager::kKFMass], VarManager::fgValues[VarManager::kKFChi2OverNDFGeo], VarManager::fgValues[VarManager::kVertexingLxyz], VarManager::fgValues[VarManager::kVertexingLxyzOverErr], VarManager::fgValues[VarManager::kVertexingLxy], VarManager::fgValues[VarManager::kVertexingLxyOverErr], VarManager::fgValues[VarManager::kVertexingTauxy], VarManager::fgValues[VarManager::kVertexingTauxyErr], VarManager::fgValues[VarManager::kKFCosPA], VarManager::fgValues[VarManager::kKFJpsiDCAxyz], VarManager::fgValues[VarManager::kKFJpsiDCAxy], @@ -1046,6 +1062,10 @@ struct AnalysisDileptonTrack { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + TString sigNamesStr = fConfigMCRecSignals.value; std::unique_ptr objRecSigArray(sigNamesStr.Tokenize(",")); TString histNames; diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 69fe2c90b3e..018d72f3c7c 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -63,6 +63,8 @@ DECLARE_SOA_BITMAP_COLUMN(IsBarrelSelected, isBarrelSelected, 32); DECLARE_SOA_COLUMN(BarrelAmbiguityInBunch, barrelAmbiguityInBunch, int8_t); //! Barrel track in-bunch ambiguity DECLARE_SOA_COLUMN(BarrelAmbiguityOutOfBunch, barrelAmbiguityOutOfBunch, int8_t); //! Barrel track out of bunch ambiguity DECLARE_SOA_BITMAP_COLUMN(IsMuonSelected, isMuonSelected, 32); //! Muon track decisions (joinable to ReducedMuonsAssoc) +DECLARE_SOA_COLUMN(MuonAmbiguityInBunch, muonAmbiguityInBunch, int8_t); //! Muon track in-bunch ambiguity +DECLARE_SOA_COLUMN(MuonAmbiguityOutOfBunch, muonAmbiguityOutOfBunch, int8_t); //! Muon track out of bunch ambiguity 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); @@ -74,14 +76,16 @@ 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(McFlag, mcFlag, int8_t); } // namespace dqanalysisflags DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTS", dqanalysisflags::IsEventSelected); //! joinable to ReducedEvents DECLARE_SOA_TABLE(BarrelTrackCuts, "AOD", "DQANATRKCUTS", dqanalysisflags::IsBarrelSelected); //! joinable to ReducedTracksAssoc DECLARE_SOA_TABLE(BarrelAmbiguities, "AOD", "DQBARRELAMB", dqanalysisflags::BarrelAmbiguityInBunch, dqanalysisflags::BarrelAmbiguityOutOfBunch); //! joinable to ReducedBarrelTracks 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::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate); +DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", dqanalysisflags::massBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate, dqanalysisflags::McFlag); } // namespace o2::aod // Declarations of various short names @@ -101,6 +105,7 @@ using MyDielectronCandidates = soa::Join; using MyMuonTracks = soa::Join; using MyMuonTracksWithCov = soa::Join; +using MyMuonTracksWithCovWithAmbiguities = soa::Join; // using MyMuonTracksSelectedWithColl = soa::Join; // bit maps used for the Fill functions of the VarManager @@ -152,8 +157,12 @@ struct AnalysisEventSelection { std::map fMetadataRCT, fHeader; int fCurrentRun; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); @@ -361,8 +370,12 @@ struct AnalysisTrackSelection { std::map> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting) std::map> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup) - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { @@ -505,8 +518,10 @@ struct AnalysisTrackSelection { int isig = 0; if (filterMap > 0) { for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, track.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); + if (track.has_reducedMCTrack()) { + if ((*sig).CheckSignal(true, track.reducedMCTrack())) { + mcDecision |= (uint32_t(1) << isig); + } } } @@ -524,8 +539,8 @@ struct AnalysisTrackSelection { } } } // end loop over cuts - } // end loop over MC signals - } // end if (filterMap > 0) + } // end loop over MC signals + } // end if (filterMap > 0) // count the number of associations per track if (filterMap > 0) { @@ -610,6 +625,7 @@ struct AnalysisTrackSelection { // Here one should add all the track cuts needed through the workflow (e.g. cuts for same-event pairing, track for dilepton-track correlations) struct AnalysisMuonSelection { Produces muonSel; + Produces muonAmbiguities; OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; @@ -635,8 +651,12 @@ struct AnalysisMuonSelection { std::map> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting) std::map> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup) - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { @@ -729,8 +749,6 @@ struct AnalysisMuonSelection { auto track = assoc.template reducedmuon_as(); VarManager::FillTrack(track); - // compute quantities which depend on the associated collision - VarManager::FillPropagateMuon(track, event); bool isCorrectAssoc = false; if (track.has_reducedMCTrack()) { @@ -755,6 +773,7 @@ struct AnalysisMuonSelection { } } // end loop over cuts muonSel(filterMap); + muonAmbiguities.reserve(muons.size()); // if no filter fulfilled, continue if (!filterMap) { @@ -771,8 +790,10 @@ struct AnalysisMuonSelection { int isig = 0; for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { if constexpr ((TMuonFillMap & VarManager::ObjTypes::ReducedMuon) > 0) { - if ((*sig).CheckSignal(false, track.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); + if (track.has_reducedMCTrack()) { + if ((*sig).CheckSignal(true, track.reducedMCTrack())) { + mcDecision |= (uint32_t(1) << isig); + } } } } @@ -791,7 +812,7 @@ struct AnalysisMuonSelection { } } } // end loop over cuts - } // end loop over MC signals + } // end loop over MC signals // count the number of associations per track if (event.isEventSelected_bit(1)) { @@ -837,6 +858,19 @@ struct AnalysisMuonSelection { VarManager::fgValues[VarManager::kMuonNAssocsOutOfBunch] = static_cast(evIndices.size()); fHistMan->FillHistClass("Muon_AmbiguityOutOfBunch", VarManager::fgValues); } // end loop over out-of-bunch ambiguous tracks + + // publish the ambiguity table + for (auto& track : muons) { + int8_t nInBunch = 0; + if (fNAssocsInBunch.find(track.globalIndex()) != fNAssocsInBunch.end()) { + nInBunch = fNAssocsInBunch[track.globalIndex()].size(); + } + int8_t nOutOfBunch = 0; + if (fNAssocsOutOfBunch.find(track.globalIndex()) != fNAssocsOutOfBunch.end()) { + nOutOfBunch = fNAssocsOutOfBunch[track.globalIndex()].size(); + } + muonAmbiguities(nInBunch, nOutOfBunch); + } } void processSkimmed(ReducedMuonsAssoc const& assocs, MyEventsSelected const& events, MyMuonTracks const& muons, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) @@ -870,6 +904,8 @@ struct AnalysisPrefilterSelection { Configurable fConfigPrefilterTrackCut{"cfgPrefilterTrackCut", "", "Prefilter track cut"}; Configurable fConfigPrefilterPairCut{"cfgPrefilterPairCut", "", "Prefilter pair cut"}; Configurable fConfigTrackCuts{"cfgTrackCuts", "", "Track cuts for which to run the prefilter"}; + // Track related options + Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; std::map fPrefilterMap; AnalysisCompositeCut* fPairCut; @@ -878,8 +914,12 @@ struct AnalysisPrefilterSelection { Preslice trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; - void init(o2::framework::InitContext& initContext) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + // get the list of track cuts to be prefiltered TString trackCutsStr = fConfigTrackCuts.value; TObjArray* objArrayTrackCuts = nullptr; @@ -895,7 +935,7 @@ struct AnalysisPrefilterSelection { fPrefilterMask = 0; fPrefilterCutBit = -1; string trackCuts; - getTaskOptionValue(initContext, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); + getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); TString allTrackCutsStr = trackCuts; TString prefilterTrackCutStr = fConfigPrefilterTrackCut.value; if (!trackCutsStr.IsNull()) { @@ -934,8 +974,8 @@ struct AnalysisPrefilterSelection { VarManager::SetupTwoProngFwdDCAFitter(5.0f, true, 200.0f, 1.0e-3f, 0.9f, true); } - template - void runPrefilter(soa::Join const& assocs, TTracks const& /*tracks*/) + template + void runPrefilter(TEvent const& event, soa::Join const& assocs, TTracks const& /*tracks*/) { for (auto& [assoc1, assoc2] : o2::soa::combinations(assocs, assocs)) { @@ -960,6 +1000,9 @@ struct AnalysisPrefilterSelection { // compute pair quantities VarManager::FillPair(track1, track2); + if (fPropTrack) { + VarManager::FillPairCollision(event, track1, track2); + } // if the pair fullfils the criteria, add an entry into the prefilter map for the two tracks if (fPairCut->IsSelected(VarManager::fgValues)) { if (fPrefilterMap.find(track1.globalIndex()) == fPrefilterMap.end() && track1Candidate > 0) { @@ -980,7 +1023,7 @@ struct AnalysisPrefilterSelection { for (auto& event : events) { auto groupedAssocs = assocs.sliceBy(trackAssocsPerCollision, event.globalIndex()); if (groupedAssocs.size() > 1) { - runPrefilter(groupedAssocs, tracks); + runPrefilter(event, groupedAssocs, tracks); } } uint32_t mymap = -1; @@ -1036,6 +1079,7 @@ struct AnalysisSameEventPairing { Configurable fConfigUseRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"}; Configurable fConfigMagField{"cfgMagField", 5.0f, "Manually set magnetic field"}; + Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"}; Configurable fConfigFlatTables{"cfgFlatTables", false, "Produce a single flat tables with all relevant information of the pairs and single tracks"}; Configurable fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"}; @@ -1048,10 +1092,14 @@ struct AnalysisSameEventPairing { Configurable fConfigCollisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable fConfigCenterMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; - Configurable fConfigMCRecSignals{"cfgBarrelMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; + 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 fConfigSkimSignalOnly{"fConfigSkimSignalOnly", false, "Configurable to select only matched candidates"}; + // 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); @@ -1083,6 +1131,10 @@ struct AnalysisSameEventPairing { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fEnableBarrelHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processBarrelOnlySkimmed") || context.mOptions.get("processBarrelOnlyWithCollSkimmed"); fEnableMuonHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processMuonOnlySkimmed"); bool isDummy = context.mOptions.get("processDummy"); @@ -1155,13 +1207,15 @@ struct AnalysisSameEventPairing { Form("PairsBarrelSEPM_%s", objArray->At(icut)->GetName()), Form("PairsBarrelSEPP_%s", objArray->At(icut)->GetName()), Form("PairsBarrelSEMM_%s", objArray->At(icut)->GetName())}; - // assign separate hist directories for ambiguous tracks - 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())); + if (fConfigQA) { + // assign separate hist directories for ambiguous tracks + 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())); + } for (auto& n : names) { histNames += Form("%s;", n.Data()); } @@ -1183,25 +1237,32 @@ struct AnalysisSameEventPairing { // NOTE: In the numbering scheme for the map key, we use the number of barrel cuts in the barrel-track selection task fTrackHistNames[fNCutsBarrel + icut * fNPairCuts + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) // assign hist directories for the MC matched pairs for each (track cut,MCsignal) combination if (!sigNamesStr.IsNull()) { - for (auto& sig : fRecMCSignals) { + 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("PairsBarrelSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPMIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousInBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousInBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousInBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousOutOfBunch_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousOutOfBunchCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsBarrelSEPM_ambiguousOutOfBunchIncorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName())}; - histNames += Form("%s;%s;%s;%s;%s;%s;%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data(), names[3].Data(), names[4].Data(), names[5].Data(), names[6].Data(), names[7].Data(), names[8].Data()); + 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())); + } + for (auto& n : names) { + histNames += Form("%s;", n.Data()); + } + fBarrelHistNamesMCmatched.try_emplace(icut * fRecMCSignals.size() + isig, names); } // end loop over MC signals } - fBarrelHistNamesMCmatched[icut] = names; } // end if enableBarrelHistos } } @@ -1227,7 +1288,18 @@ struct AnalysisSameEventPairing { Form("PairsMuonSEPM_%s", objArray->At(icut)->GetName()), Form("PairsMuonSEPP_%s", objArray->At(icut)->GetName()), Form("PairsMuonSEMM_%s", objArray->At(icut)->GetName())}; - histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); + if (fConfigQA) { + // assign separate hist directories for ambiguous tracks + names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + } + for (auto& n : names) { + histNames += Form("%s;", n.Data()); + } fMuonHistNames[icut] = names; // if there are specified pair cuts, assign hist dirs for each muon cut - pair cut combination @@ -1243,24 +1315,36 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fMuonHistNames[fNCutsMuon + icut * fNCutsMuon + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) // assign hist directories for pairs matched to MC signals for each (muon cut, MCrec signal) combination if (!sigNamesStr.IsNull()) { for (auto& sig : fRecMCSignals) { names = { - Form("PairsMuonsSEPM_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsMuonsSEPMCorrectAssoc_%s_%s", objArray->At(icut)->GetName(), sig.GetName()), - Form("PairsMuonsSEPMIncorrectAssoc_%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()), }; - histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); + 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())); + } + for (auto& n : names) { + histNames += Form("%s;", n.Data()); + } } // end loop over MC signals } fMuonHistNamesMCmatched[icut] = names; } } } // end loop over cuts - } // end if (muonCutsStr) + } // end if (muonCutsStr) // 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 @@ -1397,7 +1481,7 @@ struct AnalysisSameEventPairing { for (auto& [a1, a2] : o2::soa::combinations(groupedAssocs, groupedAssocs)) { - if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi) { + if constexpr (TPairType == VarManager::kDecayToEE) { twoTrackFilter = a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isBarrelSelectedPrefilter_raw() & fTrackFilterMask; if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue @@ -1426,14 +1510,21 @@ struct AnalysisSameEventPairing { int isig = 0; mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, t1.reducedMCTrack(), t2.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); + if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { + if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { + mcDecision |= (uint32_t(1) << isig); + } } } // end loop over MC signals - isCorrectAssoc_leg1 = (t1.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); - isCorrectAssoc_leg2 = (t2.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { + isCorrectAssoc_leg1 = (t1.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + isCorrectAssoc_leg2 = (t2.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + } VarManager::FillPair(t1, t2); + if (fPropTrack) { + VarManager::FillPairCollision(event, t1, t2); + } if constexpr (TTwoProngFitter) { VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); } @@ -1462,21 +1553,46 @@ struct AnalysisSameEventPairing { } auto t1 = a1.template reducedmuon_as(); auto t2 = a2.template reducedmuon_as(); + if (t1.matchMCHTrackId() == t2.matchMCHTrackId()) + continue; + if (t1.matchMFTTrackId() == t2.matchMFTTrackId()) + continue; 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 + if (t1.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 28); + } + if (t2.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 29); + } + if (t1.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 30); + } + if (t2.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 31); + } // run MC matching for this pair int isig = 0; mcDecision = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, t1.reducedMCTrack(), t2.reducedMCTrack())) { - mcDecision |= (uint32_t(1) << isig); + if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { + if ((*sig).CheckSignal(true, t1.reducedMCTrack(), t2.reducedMCTrack())) { + mcDecision |= (uint32_t(1) << isig); + } } } // end loop over MC signals - isCorrectAssoc_leg1 = (t1.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); - isCorrectAssoc_leg2 = (t2.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + + if (t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) { + isCorrectAssoc_leg1 = (t1.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + isCorrectAssoc_leg2 = (t2.reducedMCTrack().reducedMCevent() == event.reducedMCevent()); + } VarManager::FillPair(t1, t2); + if (fPropTrack) { + VarManager::FillPairCollision(event, t1, t2); + } if constexpr (TTwoProngFitter) { VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); } @@ -1497,7 +1613,7 @@ struct AnalysisSameEventPairing { dimuonAllList(event.posX(), event.posY(), event.posZ(), event.numContrib(), -999., -999., -999., VarManager::fgValues[VarManager::kMass], - false, + mcDecision, 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], @@ -1513,7 +1629,7 @@ struct AnalysisSameEventPairing { -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., - t1.isAmbiguous(), t2.isAmbiguous(), + (twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 30)), (twoTrackFilter & (uint32_t(1) << 29)) || (twoTrackFilter & (uint32_t(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], @@ -1541,46 +1657,70 @@ 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 & (uint32_t(1) << isig)) { - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size()].Data(), VarManager::fgValues); // matched signal - if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { // correct track-collision association - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 1].Data(), VarManager::fgValues); - } else { // incorrect track-collision association - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 2].Data(), VarManager::fgValues); - } - if (isAmbiInBunch) { // ambiguous in bunch - fHistMan->FillHistClass(histNames[icut][isig * fRecMCSignals.size() + 3].Data(), VarManager::fgValues); - if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 4].Data(), VarManager::fgValues); - } else { - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 5].Data(), VarManager::fgValues); + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][0].Data(), VarManager::fgValues); // matched signal + if (fConfigQA) { + if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { // correct track-collision association + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][3].Data(), VarManager::fgValues); + } else { // incorrect track-collision association + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][4].Data(), VarManager::fgValues); } - } - if (isAmbiOutOfBunch) { // ambiguous out of bunch - fHistMan->FillHistClass(histNames[icut][isig * fRecMCSignals.size() + 6].Data(), VarManager::fgValues); - if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 7].Data(), VarManager::fgValues); - } else { - fHistMan->FillHistClass(histNamesMC[icut][isig * fRecMCSignals.size() + 8].Data(), VarManager::fgValues); + if (isAmbiInBunch) { // ambiguous in bunch + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][5].Data(), VarManager::fgValues); + if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][6].Data(), VarManager::fgValues); + } else { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][7].Data(), VarManager::fgValues); + } + } + if (isAmbiOutOfBunch) { // ambiguous out of bunch + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][8].Data(), VarManager::fgValues); + if (isCorrectAssoc_leg1 && isCorrectAssoc_leg2) { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][9].Data(), VarManager::fgValues); + } else { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][10].Data(), VarManager::fgValues); + } } } } + if (fConfigQA) { + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][3 + 3].Data(), VarManager::fgValues); + } + } } } else { if (sign1 > 0) { // ++ pairs fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); - if (isAmbiInBunch) { - fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals + if (mcDecision & (uint32_t(1) << isig)) { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][1].Data(), VarManager::fgValues); + } } - if (isAmbiOutOfBunch) { - fHistMan->FillHistClass(histNames[icut][4 + 3].Data(), VarManager::fgValues); + if (fConfigQA) { + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][4 + 3].Data(), VarManager::fgValues); + } } } else { // -- pairs fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); - if (isAmbiInBunch) { - fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); + for (unsigned int isig = 0; isig < fRecMCSignals.size(); isig++) { // loop over MC signals + if (mcDecision & (uint32_t(1) << isig)) { + fHistMan->FillHistClass(histNamesMC[icut * fRecMCSignals.size() + isig][2].Data(), VarManager::fgValues); + } } - if (isAmbiOutOfBunch) { - fHistMan->FillHistClass(histNames[icut][5 + 3].Data(), VarManager::fgValues); + if (fConfigQA) { + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][5 + 3].Data(), VarManager::fgValues); + } } } } @@ -1600,8 +1740,8 @@ struct AnalysisSameEventPairing { } // end loop (pair cuts) } } // end loop (cuts) - } // end loop over pairs of track associations - } // end loop over events + } // end loop over pairs of track associations + } // end loop over events } // Preslice perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; @@ -1624,9 +1764,9 @@ struct AnalysisSameEventPairing { bool checked = false; /*if constexpr (soa::is_soa_filtered_v) { auto mctrack_raw = groupedMCTracks.rawIteratorAt(mctrack.globalIndex()); - checked = sig.CheckSignal(false, mctrack_raw); + checked = sig.CheckSignal(true, mctrack_raw); } else {*/ - checked = sig.CheckSignal(false, mctrack); + checked = sig.CheckSignal(true, mctrack); //} if (checked) { fHistMan->FillHistClass(Form("MCTruthGen_%s", sig.GetName()), VarManager::fgValues); @@ -1645,24 +1785,25 @@ struct AnalysisSameEventPairing { if (sig.GetNProngs() != 2) { // NOTE: 2-prong signals required here continue; } - if (sig.CheckSignal(false, t1_raw, t2_raw)) { + if (sig.CheckSignal(true, t1_raw, t2_raw)) { VarManager::FillPairMC(t1, t2); fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig.GetName()), VarManager::fgValues); } } // end loop over MC signals - } // end loop over pairs - } // end loop over events + } // end loop over pairs + } // end loop over events } } // end runMCGen void processAllSkimmed(MyEventsVtxCovSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, - soa::Join const& muonAssocs, MyMuonTracksWithCov const& muons, + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks); - runMCGen(mcEvents, mcTracks); + if (fConfigRunMCGenPair) + runMCGen(mcEvents, mcTracks); // runSameEventPairing(event, tracks, muons); } @@ -1671,7 +1812,8 @@ struct AnalysisSameEventPairing { MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); - runMCGen(mcEvents, mcTracks); + if (fConfigRunMCGenPair) + runMCGen(mcEvents, mcTracks); } void processBarrelOnlyWithCollSkimmed(MyEventsVtxCovSelected const& events, @@ -1679,14 +1821,16 @@ struct AnalysisSameEventPairing { MyBarrelTracksWithCovWithAmbiguitiesWithColl const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks); - runMCGen(mcEvents, mcTracks); + if (fConfigRunMCGenPair) + runMCGen(mcEvents, mcTracks); } void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events, - soa::Join const& muonAssocs, MyMuonTracksWithCov const& muons, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks) { runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons, mcEvents, mcTracks); - runMCGen(mcEvents, mcTracks); + if (fConfigRunMCGenPair) + runMCGen(mcEvents, mcTracks); } void processDummy(MyEvents&) @@ -1752,6 +1896,10 @@ struct AnalysisDileptonTrack { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + bool isBarrel = context.mOptions.get("processBarrelSkimmed"); bool isMuon = context.mOptions.get("processMuonSkimmed"); bool isAnyProcessEnabled = isBarrel || isMuon; @@ -1807,6 +1955,12 @@ struct AnalysisDileptonTrack { 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!"; } + 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; if (isBarrel) { @@ -1818,8 +1972,8 @@ struct AnalysisDileptonTrack { if (!tempCutsSingleStr.IsNull() && !tempCutsPairStr.IsNull()) { std::unique_ptr objArray(tempCutsPairStr.Tokenize(",")); fNCuts = objArray->GetEntries(); - for (int icut = 0; icut < objArraySingleCuts->GetEntries(); ++icut) { - TString tempStr = objArraySingleCuts->At(icut)->GetName(); + for (int icut = 0; icut < objArray->GetEntries(); ++icut) { + TString tempStr = objArray->At(icut)->GetName(); if (objArray->FindObject(tempStr.Data()) != nullptr) { fHistNamesDileptonTrack[icut] = Form("DileptonTrack_%s_%s", tempStr.Data(), fConfigTrackCut.value.data()); fHistNamesDileptons[icut] = Form("DileptonsSelected_%s", tempStr.Data()); @@ -1828,13 +1982,10 @@ struct AnalysisDileptonTrack { std::vector mcHistNames; for (auto& sig : fRecMCSignals) { mcHistNames.push_back(Form("DileptonTrackMCMatched_%s_%s_%s", tempStr.Data(), fConfigTrackCut.value.data(), sig.GetName())); - DefineHistograms(fHistMan, mcHistNames[mcHistNames.size() - 1], ""); + DefineHistograms(fHistMan, mcHistNames[mcHistNames.size() - 1], fConfigHistogramSubgroups.value.data()); } fHistNamesDileptonTrackMCmatched[icut] = mcHistNames; } - if (tempStr.CompareTo(fConfigTrackCut.value.data()) == 0) { - fTrackCutBit = icut; // the bit corresponding to the track to be combined with dileptons - } } } // Add histogram classes for each specified MCsignal at the generator level @@ -1934,7 +2085,7 @@ struct AnalysisDileptonTrack { mcDecision = 0; isig = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, lepton1MC, lepton2MC, trackMC)) { + if ((*sig).CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { mcDecision |= (uint32_t(1) << isig); } } @@ -1955,7 +2106,7 @@ struct AnalysisDileptonTrack { mcDecision = 0; isig = 0; for (auto sig = fRecMCSignals.begin(); sig != fRecMCSignals.end(); sig++, isig++) { - if ((*sig).CheckSignal(false, lepton1MC, lepton2MC, trackMC)) { + if ((*sig).CheckSignal(true, lepton1MC, lepton2MC, trackMC)) { mcDecision |= (uint32_t(1) << isig); } } @@ -1973,7 +2124,7 @@ struct AnalysisDileptonTrack { } } // table to be written out for ML analysis - BmesonsTable(fValuesHadron[VarManager::kPairMass], fValuesHadron[VarManager::kPairPt], fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kCosPointingAngle], fValuesHadron[VarManager::kVertexingChi2PCA]); + BmesonsTable(fValuesHadron[VarManager::kPairMass], fValuesHadron[VarManager::kPairPt], fValuesHadron[VarManager::kVertexingLxy], fValuesHadron[VarManager::kVertexingLxyz], fValuesHadron[VarManager::kVertexingLz], fValuesHadron[VarManager::kVertexingTauxy], fValuesHadron[VarManager::kVertexingTauz], fValuesHadron[VarManager::kCosPointingAngle], fValuesHadron[VarManager::kVertexingChi2PCA], mcDecision); } } // end loop over dileptons } @@ -2043,7 +2194,7 @@ struct AnalysisDileptonTrack { // TODO: Use the mcReducedFlags to select signals isig = 0; for (auto& sig : fGenMCSignals) { - if (sig.CheckSignal(false, track)) { + if (sig.CheckSignal(true, track)) { fHistMan->FillHistClass(fHistNamesMCgen[isig++], VarManager::fgValues); } } @@ -2111,7 +2262,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses, const char } } } - if (classStr.Contains("Muon")) { + if (classStr.Contains("Muon") && !classStr.Contains("Pairs")) { if (!classStr.Contains("Ambiguity")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "track", histName); } else { diff --git a/PWGDQ/Tasks/dqFlow.cxx b/PWGDQ/Tasks/dqFlow.cxx index 67bce2f8b8c..b29efd014b8 100644 --- a/PWGDQ/Tasks/dqFlow.cxx +++ b/PWGDQ/Tasks/dqFlow.cxx @@ -65,15 +65,16 @@ using MyBcs = soa::Join; using MyEvents = soa::Join; using MyEventsWithCent = soa::Join; using MyEventsWithCentRun3 = soa::Join; -using MyEventsWithCentQvectRun3 = soa::Join; +// using MyEventsWithCentQvectRun3 = soa::Join; +// using MyEventsWithCentQvectRun3 = soa::Join; +using MyEventsWithCentQvectRun3 = soa::Join; -using MyBarrelTracks = soa::Join; -using MyBarrelTracksWithCov = soa::Join; @@ -83,7 +84,7 @@ using MyMuonsWithCov = soa::Join; constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCentRun2; constexpr static uint32_t gkEventFillMapRun3 = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent; -constexpr static uint32_t gkEventFillMapRun3Qvect = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent | VarManager::ObjTypes::CollisionQvect; +constexpr static uint32_t gkEventFillMapRun3Qvect = VarManager::ObjTypes::BC | VarManager::ObjTypes::Collision | VarManager::ObjTypes::CollisionCent | VarManager::ObjTypes::CollisionQvectCentr; constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::Track | VarManager::ObjTypes::TrackExtra | VarManager::ObjTypes::TrackDCA | VarManager::ObjTypes::TrackSelection | VarManager::ObjTypes::TrackPID; void DefineHistograms(HistogramManager* histMan, TString histClasses); @@ -99,8 +100,11 @@ struct DQEventQvector { Produces eventQvector; Produces eventQvectorExtra; Produces eventQvectorCentr; + 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"}; @@ -110,9 +114,10 @@ struct DQEventQvector { Configurable fConfigCutPtMax{"cfgCutPtMax", 12.0f, "Maximal pT for tracks"}; Configurable fConfigCutEtaMin{"cfgCutEtaMin", -0.8f, "Eta min range for tracks"}; Configurable fConfigCutEtaMax{"cfgCutEtaMax", 0.8f, "Eta max range for tracks"}; + Configurable fConfigCutTPCNClMin{"cfgCutTPCNclMin", 0, "Min requirement for number of TPC clusters"}; Configurable fConfigEtaLimitMin{"cfgEtaLimitMin", -0.4f, "Eta gap min separation, only if using subEvents"}; Configurable fConfigEtaLimitMax{"cfgEtaLimitMax", 0.4f, "Eta gap max separation, only if using subEvents"}; - Configurable fConfigNPow{"cfgNPow", 0, "Power of weights for Q vector"}; + // Configurable fConfigNPow{"cfgNPow", 0, "Power of weights for Q vector"}; // 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"}; // Access to the efficiencies and acceptances from CCDB @@ -126,7 +131,7 @@ struct DQEventQvector { ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1}, "multiplicity / centrality axis for histograms"}; // Define the filter for barrel tracks and forward tracks - Filter trackFilter = (nabs(aod::track::eta) <= fConfigCutEtaMax) && (aod::track::pt > fConfigCutPtMin) && (aod::track::pt < fConfigCutPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)); + Filter trackFilter = (requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true); Filter fwdFilter = (aod::fwdtrack::eta < -2.45f) && (aod::fwdtrack::eta > -3.6f); // Histograms used for optionnal efficiency and non-uniform acceptance corrections @@ -214,6 +219,45 @@ struct DQEventQvector { fGFW->CreateRegions(); } + template + bool isTrackSelected(TTrack const& track) + { + constexpr bool isBarrelTrack = ((TTrackFillMap & VarManager::ObjTypes::Track) > 0); + if constexpr (isBarrelTrack) { + if (!(track.pt() > fConfigCutPtMin && track.pt() < fConfigCutPtMax)) { + return false; + } + if (!(track.eta() > fConfigCutEtaMin && track.eta() < fConfigCutEtaMax)) { + return false; + } + if (track.tpcNClsFound() <= fConfigCutTPCNClMin) { + 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; + } + void loadCorrections(uint64_t timestamp) { if (cfg.correctionsLoaded) { @@ -291,8 +335,9 @@ struct DQEventQvector { // Fill the tree for the reduced event table with Q vector quantities if (fEventCut->IsSelected(VarManager::fgValues)) { - eventQvectorCentr(collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.qvecFV0ARe(), collision.qvecFV0AIm(), collision.qvecBPosRe(), collision.qvecBPosIm(), collision.qvecBNegRe(), collision.qvecBNegIm(), - collision.sumAmplFT0A(), collision.sumAmplFT0C(), collision.sumAmplFT0M(), collision.sumAmplFV0A(), collision.nTrkBPos(), collision.nTrkBNeg()); + eventQvectorCentr(collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.qvecFV0ARe(), collision.qvecFV0AIm(), collision.qvecTPCposRe(), collision.qvecTPCposIm(), collision.qvecTPCnegRe(), collision.qvecTPCnegIm(), + collision.sumAmplFT0A(), collision.sumAmplFT0C(), collision.sumAmplFT0M(), collision.sumAmplFV0A(), collision.nTrkTPCpos(), collision.nTrkTPCneg()); + eventQvectorCentrExtra(collision.qvecTPCallRe(), collision.qvecTPCallIm(), collision.nTrkTPCall()); } } @@ -331,6 +376,11 @@ struct DQEventQvector { // Fill the GFW object in the track loop for (auto& track : tracks1) { + // Selections for barrel tracks + if (!isTrackSelected(track)) { + continue; + } + // 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); @@ -460,7 +510,7 @@ struct DQEventQvector { eventRefFlow(VarManager::fgValues[VarManager::kM11REF], VarManager::fgValues[VarManager::kM1111REF], VarManager::fgValues[VarManager::kCORR2REF], VarManager::fgValues[VarManager::kCORR4REF], centrality); } - if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionQvect) > 0) { + if constexpr ((TEventFillMap & VarManager::ObjTypes::CollisionQvectCentr) > 0) { VarManager::FillQVectorFromCentralFW(collision); if (bc.has_zdc()) { @@ -477,12 +527,19 @@ struct DQEventQvector { } } if (fEventCut->IsSelected(VarManager::fgValues)) { - eventQvectorCentr(collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.qvecFV0ARe(), collision.qvecFV0AIm(), collision.qvecBPosRe(), collision.qvecBPosIm(), collision.qvecBNegRe(), collision.qvecBNegIm(), - collision.sumAmplFT0A(), collision.sumAmplFT0C(), collision.sumAmplFT0M(), collision.sumAmplFV0A(), collision.nTrkBPos(), collision.nTrkBNeg()); + eventQvectorCentr(collision.qvecFT0ARe(), collision.qvecFT0AIm(), collision.qvecFT0CRe(), collision.qvecFT0CIm(), collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.qvecFV0ARe(), collision.qvecFV0AIm(), collision.qvecTPCposRe(), collision.qvecTPCposIm(), collision.qvecTPCnegRe(), collision.qvecTPCnegIm(), + collision.sumAmplFT0A(), collision.sumAmplFT0C(), collision.sumAmplFT0M(), collision.sumAmplFV0A(), collision.nTrkTPCpos(), collision.nTrkTPCneg()); + 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/filterPbPb.cxx b/PWGDQ/Tasks/filterPbPb.cxx index a562b34d4df..81dfa35a996 100644 --- a/PWGDQ/Tasks/filterPbPb.cxx +++ b/PWGDQ/Tasks/filterPbPb.cxx @@ -17,6 +17,7 @@ #include "PWGDQ/DataModel/ReducedInfoTables.h" #include "PWGDQ/Core/VarManager.h" #include "CommonConstants/LHCConstants.h" +#include "ReconstructionDataFormats/Vertex.h" using namespace std; @@ -58,7 +59,7 @@ struct DQFilterPbPbTask { fStats->GetXaxis()->SetBinLabel(1, "Events inspected"); fStats->GetXaxis()->SetBinLabel(2, "Events selected"); // setup the FilterOutcome histogram - fFilterOutcome.setObject(new TH1D("Filter outcome", "Filter outcome", 8, 0.5, 8.5)); + fFilterOutcome.setObject(new TH1D("Filter outcome", "Filter outcome", 9, 0.5, 9.5)); fFilterOutcome->GetXaxis()->SetBinLabel(1, "Events inspected"); fFilterOutcome->GetXaxis()->SetBinLabel(2, "Events selected"); fFilterOutcome->GetXaxis()->SetBinLabel(3, "!A && !C"); @@ -67,6 +68,7 @@ struct DQFilterPbPbTask { 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"); TString eventTypesString = fConfigEventTypes.value; for (std::vector::size_type i = 0; i < eventTypeOptions.size(); i++) { @@ -265,6 +267,12 @@ struct DQFilterPbPbTask { 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(9, 1); + } + eventFilter(filter); } diff --git a/PWGDQ/Tasks/mchAlignRecord.cxx b/PWGDQ/Tasks/mchAlignRecord.cxx index 633b4b39709..6dfe8259564 100644 --- a/PWGDQ/Tasks/mchAlignRecord.cxx +++ b/PWGDQ/Tasks/mchAlignRecord.cxx @@ -137,7 +137,7 @@ struct mchAlignRecordTask { // Configuration for chamber fixing auto chambers = fFixChamber.value; - for (int i = 0; i < chambers.length(); ++i) { + for (std::size_t i = 0; i < chambers.length(); ++i) { if (chambers[i] == ',') continue; int chamber = chambers[i] - '0'; diff --git a/PWGDQ/Tasks/muonDCA.cxx b/PWGDQ/Tasks/muonDCA.cxx new file mode 100644 index 00000000000..b2031418d5c --- /dev/null +++ b/PWGDQ/Tasks/muonDCA.cxx @@ -0,0 +1,196 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 muonDCA.cxx +/// \brief Task to compute and evaluate DCA quantities +/// \author Nicolas Bizé , SUBATECH +// +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "GlobalTracking/MatchGlobalFwd.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "PWGDQ/DataModel/ReducedInfoTables.h" +#include "PWGDQ/Core/VarManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::aod; + +using MyMuons = soa::Join; +using MyEvents = soa::Join; +using MyEventsVtxCov = soa::Join; + +// constexpr static uint32_t gkMuonDCAFillMapWithCov = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra | VarManager::ObjTypes::ReducedMuonCov | VarManager::ObjTypes::MuonDCA; + +constexpr static int toVertex = VarManager::kToVertex; +constexpr static int toDCA = VarManager::kToDCA; +constexpr static int toRabs = VarManager::kToRabs; + +static o2::globaltracking::MatchGlobalFwd mExtrap; +template +bool isSelected(const T& muon); + +struct muonExtrap { + Produces dcaTable; + Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + Service fCCDB; + o2::parameters::GRPMagField* grpmag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField + int fCurrentRun; // needed to detect if the run changed and trigger update of magnetic field + + HistogramRegistry registry{ + "registry", + {}}; + + void init(o2::framework::InitContext&) + { + // Load geometry + fCCDB->setURL(fConfigCcdbUrl); + fCCDB->setCaching(true); + fCCDB->setLocalObjectValidityChecking(); + + if (!o2::base::GeometryManager::isGeometryLoaded()) { + LOGF(info, "Load geometry from CCDB"); + fCCDB->get(geoPath); + } + + AxisSpec pdcaAxis = {5000, 0.0, 5000.0, "p #times DCA"}; + AxisSpec dcaAxis = {200, 0.0, 200.0, "DCA"}; + AxisSpec dcaxAxis = {200, -100.0, 100.0, "DCA_x"}; + AxisSpec dcayAxis = {200, -100.0, 100.0, "DCA_y"}; + AxisSpec rabsAxis = {100, 0., 100.0, "R_{abs}"}; + AxisSpec xAxis = {200, -100., 100.0, "x (cm)"}; + AxisSpec yAxis = {200, -100., 100.0, "y (cm)"}; + AxisSpec zAxis = {200, -100., 100.0, "z (cm)"}; + + HistogramConfigSpec pdcaSpec({HistType::kTH1F, {pdcaAxis}}); + HistogramConfigSpec dcaSpec({HistType::kTH1F, {dcaAxis}}); + HistogramConfigSpec dcaxSpec({HistType::kTH1F, {dcaxAxis}}); + HistogramConfigSpec dcaySpec({HistType::kTH1F, {dcayAxis}}); + HistogramConfigSpec rabsSpec({HistType::kTH1F, {rabsAxis}}); + HistogramConfigSpec xSpec({HistType::kTH1F, {xAxis}}); + HistogramConfigSpec ySpec({HistType::kTH1F, {yAxis}}); + HistogramConfigSpec zSpec({HistType::kTH1F, {zAxis}}); + + registry.add("pdca", "pDCA", pdcaSpec); + registry.add("dca", "DCA", dcaSpec); + registry.add("dcax", "DCA_x", dcaxSpec); + registry.add("dcay", "DCA_y", dcaySpec); + registry.add("rabs", "R_{abs}", rabsSpec); + registry.add("xAtVtx", "x at vertex", xSpec); + registry.add("xAtDCA", "x at DCA", xSpec); + registry.add("xAtRabs", "x at end abs", xSpec); + registry.add("yAtVtx", "y at vertex", ySpec); + registry.add("yAtDCA", "y at DCA", ySpec); + registry.add("yAtRabs", "y at end abs", ySpec); + registry.add("zAtVtx", "z at vertex", zSpec); + registry.add("zAtDCA", "z at DCA", zSpec); + registry.add("zAtRabs", "z at end abs", zSpec); + } + + void processExtrapolation(MyEventsVtxCov::iterator const& collision, MyMuons const& muons) + { + if (fCurrentRun != collision.runNumber()) { + grpmag = fCCDB->getForTimeStamp(grpmagPath, collision.timestamp()); + if (grpmag != nullptr) { + LOGF(info, "Init field from GRP"); + o2::base::Propagator::initFieldFromGRP(grpmag); + } + LOGF(info, "Set field for muons"); + VarManager::SetupMuonMagField(); + fCurrentRun = collision.runNumber(); + } + + for (auto& muon : muons) { + if (static_cast(muon.trackType()) < 2) { + continue; // Make sure to remove global muon tracks + } + // propagate muon track to vertex + o2::dataformats::GlobalFwdTrack muonTrackAtVertex = VarManager::PropagateMuon(muon, collision, toVertex); + + // propagate muon track to DCA + o2::dataformats::GlobalFwdTrack muonTrackAtDCA = VarManager::PropagateMuon(muon, collision, toDCA); + + // propagate to Rabs + o2::dataformats::GlobalFwdTrack muonTrackAtRabs = VarManager::PropagateMuon(muon, collision, toRabs); + + // Calculate DCA quantities (preferable to do it with VarManager) + double dcax = muonTrackAtDCA.getX() - collision.posX(); + double dcay = muonTrackAtDCA.getY() - collision.posY(); + double dca = std::sqrt(dcax * dcax + dcay * dcay); + double pdca = muonTrackAtVertex.getP() * dca; + double xAtVtx = muonTrackAtVertex.getX(); + double yAtVtx = muonTrackAtVertex.getY(); + double zAtVtx = muonTrackAtVertex.getZ(); + double xAtDCA = muonTrackAtDCA.getX(); + double yAtDCA = muonTrackAtDCA.getY(); + double zAtDCA = muonTrackAtDCA.getZ(); + double xAbs = muonTrackAtRabs.getX(); + double yAbs = muonTrackAtRabs.getY(); + double zAbs = muonTrackAtRabs.getZ(); + + double rabs = std::sqrt(xAbs * xAbs + yAbs * yAbs); + + // QA histograms + registry.get(HIST("pdca"))->Fill(pdca); + registry.get(HIST("dca"))->Fill(dca); + registry.get(HIST("dcax"))->Fill(dcax); + registry.get(HIST("dcay"))->Fill(dcay); + registry.get(HIST("rabs"))->Fill(rabs); + + registry.get(HIST("xAtDCA"))->Fill(xAtDCA); + registry.get(HIST("xAtRabs"))->Fill(xAbs); + registry.get(HIST("xAtVtx"))->Fill(xAtVtx); + + registry.get(HIST("yAtDCA"))->Fill(yAtDCA); + registry.get(HIST("yAtRabs"))->Fill(yAbs); + registry.get(HIST("yAtVtx"))->Fill(yAtVtx); + + registry.get(HIST("zAtDCA"))->Fill(zAtDCA); + registry.get(HIST("zAtRabs"))->Fill(zAbs); + registry.get(HIST("zAtVtx"))->Fill(zAtVtx); + + // Fill DCA table + dcaTable(pdca, + dca, + dcax, + dcay, + rabs, + muonTrackAtVertex.getPt(), + muonTrackAtVertex.getEta(), + muonTrackAtVertex.getPhi(), + muon.sign(), + muon.isAmbiguous(), + muonTrackAtVertex.getPx(), + muonTrackAtVertex.getPy(), + muonTrackAtVertex.getPz()); + } + } + + PROCESS_SWITCH(muonExtrap, processExtrapolation, "process extrapolation", false); + + void processDummy(MyEventsVtxCov&) + { + // do nothing + } + + PROCESS_SWITCH(muonExtrap, processDummy, "do nothing", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +}; diff --git a/PWGDQ/Tasks/quarkoniaToHyperons.cxx b/PWGDQ/Tasks/quarkoniaToHyperons.cxx new file mode 100644 index 00000000000..62ba3f9c9d8 --- /dev/null +++ b/PWGDQ/Tasks/quarkoniaToHyperons.cxx @@ -0,0 +1,2004 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// 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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "ReconstructionDataFormats/Track.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.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 "Tools/ML/MlResponse.h" +#include "Tools/ML/model.h" + +// constants +const float ctauXiPDG = 4.91; // from PDG +const float ctauOmegaPDG = 2.461; // from PDG + +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 v0MCCandidates = soa::Join; + +using cascadeCandidates = soa::Join; +using cascadeMCCandidates = 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))) + +struct quarkoniaToHyperons { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // master analysis switches + Configurable isPP{"isPP", true, "If running on pp collision, switch it on true"}; + + Configurable requireSel8{"requireSel8", true, "require sel8 event selection"}; + 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", true, "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 buildLaLaBarPairs{"buildLaLaBarPairs", false, "Build Lambda antiLambda from charmonia decay"}; + Configurable buildXiXiBarPairs{"buildXiXiBarPairs", false, "Build Xi antiXi from charmonia decay"}; + Configurable buildOmOmBarPairs{"buildOmOmBarPairs", false, "Build Omega antiOmega from charmonia decay"}; + + // fast check on occupancy + Configurable minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"}; + Configurable maxOccupancy{"maxOccupancy", -1, "maximum occupancy from neighbouring collisions"}; + + // rapidity cut on the hyperon-antiHyperon pair + Configurable rapidityCut{"rapidityCut", 0.5, "rapidity cut on the hyp-antiHyp pair"}; + + 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 skipTPConly{"v0Selections.skipTPConly", false, "skip 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/TOF) + Configurable TpcPidNsigmaCut{"v0Selections.TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; + Configurable TofPidNsigmaCutLaPr{"v0Selections.TofPidNsigmaCutLaPr", 1e+6, "TofPidNsigmaCutLaPr"}; + Configurable TofPidNsigmaCutLaPi{"v0Selections.TofPidNsigmaCutLaPi", 1e+6, "TofPidNsigmaCutLaPi"}; + Configurable TofPidNsigmaCutK0Pi{"v0Selections.TofPidNsigmaCutK0Pi", 1e+6, "TofPidNsigmaCutK0Pi"}; + + // PID (TOF) + Configurable maxDeltaTimeProton{"v0Selections.maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimePion{"v0Selections.maxDeltaTimePion", 1e+9, "check maximum allowed time"}; + } 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/TOF) + Configurable TpcPidNsigmaCut{"cascSelections.TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; + Configurable TofPidNsigmaCutLaPr{"cascSelections.TofPidNsigmaCutLaPr", 1e+6, "TofPidNsigmaCutLaPr"}; + Configurable TofPidNsigmaCutLaPi{"cascSelections.TofPidNsigmaCutLaPi", 1e+6, "TofPidNsigmaCutLaPi"}; + Configurable TofPidNsigmaCutXiPi{"cascSelections.TofPidNsigmaCutXiPi", 1e+6, "TofPidNsigmaCutXiPi"}; + Configurable TofPidNsigmaCutOmKa{"cascSelections.TofPidNsigmaCutOmKa", 1e+6, "TofPidNsigmaCutOmKa"}; + + // PID (TOF) + Configurable maxDeltaTimeProton{"cascSelections.maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimePion{"cascSelections.maxDeltaTimePion", 1e+9, "check maximum allowed time"}; + Configurable maxDeltaTimeKaon{"cascSelections.maxDeltaTimeKaon", 1e+9, "check maximum allowed time"}; + } cascSelections; + + Configurable qaCentrality{"qaCentrality", false, "qa centrality flag: check base raw values"}; + + // 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; + + // Machine learning evaluation for pre-selection and corresponding information generation + o2::ml::OnnxModel mlCustomModelK0Short; + o2::ml::OnnxModel mlCustomModelLambda; + o2::ml::OnnxModel mlCustomModelAntiLambda; + o2::ml::OnnxModel mlCustomModelGamma; + + struct : ConfigurableGroup { + // 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 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"}; + + // 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)"}; + + // 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."}; + + // 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"}; + } 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"}; + } ccdbConfigurations; + + o2::ccdb::CcdbApi ccdbApi; + int mRunNumber; + std::map metadata; + + 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 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 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 + + 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"}; + + // topological variable QA axes + ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {20, 0.0f, 1.0f}, "DCA (cm)"}; + ConfigurableAxis axisDCAdau{"axisDCAdau", {20, 0.0f, 2.0f}, "DCA (cm)"}; + ConfigurableAxis axisDCAV0ToPV{"axisDCAV0ToPV", {20, 0.0f, 2.0f}, "DCA (cm)"}; + ConfigurableAxis axisPointingAngle{"axisPointingAngle", {20, 0.0f, 2.0f}, "pointing angle (rad)"}; + ConfigurableAxis axisRadius{"axisRadius", {20, 0.0f, 60.0f}, "Decay radius (cm)"}; + ConfigurableAxis axisProperLifeTime{"axisV0ProperLifeTime", {100, 0.0f, 50.0f}, "ProperLifeTime 2D radius (cm)"}; + ConfigurableAxis axisMassWindow{"axisMassWindow", {40, -0.020f, 0.020f}, "Inv. mass - PDG mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisK0Mass{"axisK0Mass", {500, 0.400f, 0.600f}, "K0Short mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisLambdaMass{"axisLambdaMass", {500, 1.098f, 1.198f}, "Lambda mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisXiMass{"axisXiMass", {500, 1.318f, 1.370f}, "Xi mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisOmegaMass{"axisOmegaMass", {500, 1.670f, 1.675f}, "Omega mass (GeV/#it{c}^{2})"}; + ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {200, -10.0f, 10.0f}, "N sigma TPC"}; + + // 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"}; + + // UPC axes + ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; + + // PDG database + Service pdgDB; + + // For manual sliceBy + PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + + enum selection : uint64_t { selCosPA = 0, + selRadius, + selRadiusMax, + selDCANegToPV, + selDCAPosToPV, + selDCAV0ToPV, + selDCAV0Dau, + selK0ShortRapidity, + selLambdaRapidity, + selK0ShortMassWindow, + selLambdaMassWindow, + selAntiLambdaMassWindow, + selK0ShortMassRejection, + selLambdaMassRejection, + selTPCPIDPositivePion, + selTPCPIDNegativePion, + selTPCPIDPositiveProton, + selTPCPIDNegativeProton, + selTOFDeltaTPositiveProtonLambda, + selTOFDeltaTPositivePionLambda, + selTOFDeltaTPositivePionK0Short, + selTOFDeltaTNegativeProtonLambda, + selTOFDeltaTNegativePionLambda, + selTOFDeltaTNegativePionK0Short, + selTOFNSigmaPositiveProtonLambda, // Nsigma + selTOFNSigmaPositivePionLambda, // Nsigma + selTOFNSigmaPositivePionK0Short, // Nsigma + selTOFNSigmaNegativeProtonLambda, // Nsigma + selTOFNSigmaNegativePionLambda, // Nsigma + selTOFNSigmaNegativePionK0Short, // Nsigma + selK0ShortCTau, + selLambdaCTau, + selK0ShortArmenteros, + selPosGoodTPCTrack, // at least min # TPC rows + selNegGoodTPCTrack, // at least min # TPC rows + selPosGoodITSTrack, // at least min # ITS clusters + selNegGoodITSTrack, // at least min # ITS clusters + selPosItsOnly, + selNegItsOnly, + selPosNotTPCOnly, + selNegNotTPCOnly, + selConsiderK0Short, // for mc tagging + selConsiderLambda, // for mc tagging + selConsiderAntiLambda, // for mc tagging + selPhysPrimK0Short, // for mc tagging + selPhysPrimLambda, // for mc tagging + selPhysPrimAntiLambda, // for mc tagging + }; + + uint64_t maskTopological; + uint64_t maskTopoNoV0Radius; + uint64_t maskTopoNoDCANegToPV; + uint64_t maskTopoNoDCAPosToPV; + uint64_t maskTopoNoCosPA; + uint64_t maskTopoNoDCAV0Dau; + uint64_t maskTopoNoDCAV0ToPV; + uint64_t maskTrackProperties; + + uint64_t maskK0ShortSpecific; + uint64_t maskLambdaSpecific; + uint64_t maskAntiLambdaSpecific; + + uint64_t maskSelectionK0Short; + uint64_t maskSelectionLambda; + uint64_t maskSelectionAntiLambda; + + uint64_t secondaryMaskSelectionLambda; + uint64_t secondaryMaskSelectionAntiLambda; + + 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) << selDCAV0ToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); + maskTopoNoV0Radius = (uint64_t(1) << selCosPA) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0ToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); + maskTopoNoDCANegToPV = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0ToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); + maskTopoNoDCAPosToPV = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAV0ToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); + maskTopoNoCosPA = (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0ToPV) | (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) << selDCAV0ToPV) | (uint64_t(1) << selRadiusMax); + maskTopoNoDCAV0ToPV = (uint64_t(1) << selCosPA) | (uint64_t(1) << selRadius) | (uint64_t(1) << selDCANegToPV) | (uint64_t(1) << selDCAPosToPV) | (uint64_t(1) << selDCAV0Dau) | (uint64_t(1) << selRadiusMax); + + maskK0ShortSpecific = (uint64_t(1) << selK0ShortRapidity) | (uint64_t(1) << selK0ShortCTau) | (uint64_t(1) << selK0ShortArmenteros) | (uint64_t(1) << selConsiderK0Short) | (uint64_t(1) << selK0ShortMassWindow) | (uint64_t(1) << selLambdaMassRejection); + maskLambdaSpecific = (uint64_t(1) << selLambdaRapidity) | (uint64_t(1) << selLambdaCTau) | (uint64_t(1) << selConsiderLambda) | (uint64_t(1) << selLambdaMassWindow) | (uint64_t(1) << selK0ShortMassRejection); + maskAntiLambdaSpecific = (uint64_t(1) << selLambdaRapidity) | (uint64_t(1) << selLambdaCTau) | (uint64_t(1) << selConsiderAntiLambda) | (uint64_t(1) << selAntiLambdaMassWindow) | (uint64_t(1) << selK0ShortMassRejection); + + // ask for specific TPC/TOF PID selections + maskTrackProperties = 0; + if (v0Selections.requirePosITSonly) { + maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosItsOnly) | (uint64_t(1) << selPosGoodITSTrack); + } else { + maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosGoodTPCTrack) | (uint64_t(1) << 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); + } + // 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.requireNegITSonly) { + maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegItsOnly) | (uint64_t(1) << selNegGoodITSTrack); + } else { + maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegGoodTPCTrack) | (uint64_t(1) << 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); + } + // 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.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); + } + + // Primary particle selection, central to analysis + maskSelectionK0Short = maskTopological | maskTrackProperties | maskK0ShortSpecific; + maskSelectionLambda = maskTopological | maskTrackProperties | maskLambdaSpecific; + maskSelectionAntiLambda = maskTopological | maskTrackProperties | maskAntiLambdaSpecific; + + // No primary requirement for feeddown matrix + secondaryMaskSelectionLambda = maskTopological | maskTrackProperties | maskLambdaSpecific; + secondaryMaskSelectionAntiLambda = maskTopological | maskTrackProperties | maskAntiLambdaSpecific; + + // 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, "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.add("hEventCentrality", "hEventCentrality", kTH1F, {{100, 0.0f, +100.0f}}); + histos.add("hCentralityVsNch", "hCentralityVsNch", kTH2F, {axisCentrality, axisNch}); + + histos.add("hEventOccupancy", "hEventOccupancy", kTH1F, {axisOccupancy}); + histos.add("hCentralityVsOccupancy", "hCentralityVsOccupancy", kTH2F, {axisCentrality, axisOccupancy}); + + if (!isPP) { + 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}); + } + + // for QA and test purposes + auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1F, {axisRawCentrality}); + + for (int ii = 1; ii < 101; ii++) { + float value = 100.5f - static_cast(ii); + hRawCentrality->SetBinContent(ii, value); + } + + // histograms versus mass + if (buildLaLaBarPairs) { + histos.add("LaLaBar/h3dMassLaLabar", "h3dMassLaLabar", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + if (!isPP) { + // Non-UPC info + histos.add("LaLaBar/h3dMassLaLabarHadronic", "h3dMassLaLabarHadronic", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + // UPC info + histos.add("LaLaBar/h3dMassLaLabarSGA", "h3dMassLaLabarSGA", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dMassLaLabarSGC", "h3dMassLaLabarSGC", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dMassLaLabarDG", "h3dMassLaLabarDG", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + histos.add("LaLaBar/h2dNbrOfK0ShortVsCentrality", "h2dNbrOfK0ShortVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("LaLaBar/h2dNbrOfLambdaVsCentrality", "h2dNbrOfLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("LaLaBar/h2dNbrOfAntiLambdaVsCentrality", "h2dNbrOfAntiLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + // QA plot + // Candidates after Lambda selections + histos.add("LaLaBar/Lambda/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("LaLaBar/Lambda/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("LaLaBar/Lambda/hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {axisDCAdau}); + histos.add("LaLaBar/Lambda/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("LaLaBar/Lambda/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("LaLaBar/Lambda/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("LaLaBar/Lambda/hV0DecayLength", "hDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("LaLaBar/Lambda/hV0InvMassWindow", "hInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("LaLaBar/Lambda/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisLambdaMass, axisK0Mass}); + histos.add("LaLaBar/Lambda/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("LaLaBar/Lambda/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("LaLaBar/Lambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("LaLaBar/Lambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + + // Candidates after AntiLambda selections + histos.add("LaLaBar/AntiLambda/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("LaLaBar/AntiLambda/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("LaLaBar/AntiLambda/hDCAV0Daughters", "hDCADaughters", kTH1F, {axisDCAdau}); + histos.add("LaLaBar/AntiLambda/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("LaLaBar/AntiLambda/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("LaLaBar/AntiLambda/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("LaLaBar/AntiLambda/hV0DecayLength", "hDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("LaLaBar/AntiLambda/hV0InvMassWindow", "hInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("LaLaBar/AntiLambda/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisLambdaMass, axisK0Mass}); + histos.add("LaLaBar/AntiLambda/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("LaLaBar/AntiLambda/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("LaLaBar/AntiLambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("LaLaBar/AntiLambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + if (doMCAssociation) { + histos.add("LaLaBar/h3dInvMassTrueEtaC1S", "h3dInvMassTrueEtaC1S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueJPsi", "h3dInvMassTrueJPsi", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueChiC0", "h3dInvMassTrueChiC0", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueChiC1", "h3dInvMassTrueChiC1", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueHC", "h3dInvMassTrueHC", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueChiC2", "h3dInvMassTrueChiC2", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTrueEtaC2S", "h3dInvMassTrueEtaC2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("LaLaBar/h3dInvMassTruePsi2S", "h3dInvMassTruePsi2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + } + if (buildXiXiBarPairs) { + histos.add("XiXiBar/h3dMassXiXibar", "h3dMassXiXibar", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + if (!isPP) { + // Non-UPC info + histos.add("XiXiBar/h3dMassXiXibarHadronic", "h3dMassXiXibarHadronic", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + // UPC info + histos.add("XiXiBar/h3dMassXiXibarSGA", "h3dMassXiXibarSGA", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dMassXiXibarSGC", "h3dMassXiXibarSGC", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dMassXiXibarDG", "h3dMassXiXibarDG", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + histos.add("XiXiBar/h2dNbrOfXiVsCentrality", "h2dNbrOfXiVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("XiXiBar/h2dNbrOfAntiXiVsCentrality", "h2dNbrOfAntiXiVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + // QA plot + // Candidates after Xi selections + histos.add("XiXiBar/Xi/hBachDCAToPV", "hBachDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/Xi/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/Xi/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/Xi/hDCACascDaughters", "hDCACascDaughters", kTH1F, {axisDCAdau}); + histos.add("XiXiBar/Xi/hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {axisDCAdau}); + histos.add("XiXiBar/Xi/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("XiXiBar/Xi/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("XiXiBar/Xi/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("XiXiBar/Xi/hCascPointingAngle", "hCascPointingAngle", kTH1F, {axisPointingAngle}); + histos.add("XiXiBar/Xi/hCascRadius", "hCascRadius", kTH1F, {axisRadius}); + histos.add("XiXiBar/Xi/hCascDecayLength", "hCascDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("XiXiBar/Xi/hV0InvMassWindow", "hV0InvMassWindow", kTH1F, {axisMassWindow}); + histos.add("XiXiBar/Xi/hCascInvMassWindow", "hCascInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("XiXiBar/Xi/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisXiMass, axisOmegaMass}); + histos.add("XiXiBar/Xi/hBachTPCNsigma", "hBachTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/Xi/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/Xi/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/Xi/h2dBachelorITSvsTPCpts", "h2dBachelorITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("XiXiBar/Xi/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("XiXiBar/Xi/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + // Candidates after AntiXi selections + histos.add("XiXiBar/AntiXi/hBachDCAToPV", "hBachDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/AntiXi/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/AntiXi/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("XiXiBar/AntiXi/hDCACascDaughters", "hDCACascDaughters", kTH1F, {axisDCAdau}); + histos.add("XiXiBar/AntiXi/hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {axisDCAdau}); + histos.add("XiXiBar/AntiXi/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("XiXiBar/AntiXi/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("XiXiBar/AntiXi/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("XiXiBar/AntiXi/hCascPointingAngle", "hCascPointingAngle", kTH1F, {axisPointingAngle}); + histos.add("XiXiBar/AntiXi/hCascRadius", "hCascRadius", kTH1F, {axisRadius}); + histos.add("XiXiBar/AntiXi/hCascDecayLength", "hCascDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("XiXiBar/AntiXi/hV0InvMassWindow", "hV0InvMassWindow", kTH1F, {axisMassWindow}); + histos.add("XiXiBar/AntiXi/hCascInvMassWindow", "hCascInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("XiXiBar/AntiXi/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisXiMass, axisOmegaMass}); + histos.add("XiXiBar/AntiXi/hBachTPCNsigma", "hBachTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/AntiXi/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/AntiXi/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("XiXiBar/AntiXi/h2dBachelorITSvsTPCpts", "h2dBachelorITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("XiXiBar/AntiXi/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("XiXiBar/AntiXi/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + if (doMCAssociation) { + histos.add("XiXiBar/h3dInvMassTrueEtaC1S", "h3dInvMassTrueEtaC1S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueJPsi", "h3dInvMassTrueJPsi", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueChiC0", "h3dInvMassTrueChiC0", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueChiC1", "h3dInvMassTrueChiC1", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueHC", "h3dInvMassTrueHC", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueChiC2", "h3dInvMassTrueChiC2", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTrueEtaC2S", "h3dInvMassTrueEtaC2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("XiXiBar/h3dInvMassTruePsi2S", "h3dInvMassTruePsi2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + } + if (buildOmOmBarPairs) { + histos.add("OmOmBar/h3dMassOmOmbar", "h3dMassOmOmbar", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + if (!isPP) { + // Non-UPC info + histos.add("OmOmBar/h3dMassOmOmbarHadronic", "h3dMassOmOmbarHadronic", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + // UPC info + histos.add("OmOmBar/h3dMassOmOmbarSGA", "h3dMassOmOmbarSGA", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("OmOmBar/h3dMassOmOmbarSGC", "h3dMassOmOmbarSGC", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("OmOmBar/h3dMassOmOmbarDG", "h3dMassOmOmbarDG", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + histos.add("OmOmBar/h2dNbrOfOmegaVsCentrality", "h2dNbrOfOmegaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + histos.add("OmOmBar/h2dNbrOfAntiOmegaVsCentrality", "h2dNbrOfAntiOmegaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); + // QA plot + // Candidates after Omega selections + histos.add("OmOmBar/Omega/hBachDCAToPV", "hBachDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/Omega/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/Omega/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/Omega/hDCACascDaughters", "hDCACascDaughters", kTH1F, {axisDCAdau}); + histos.add("OmOmBar/Omega/hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {axisDCAdau}); + histos.add("OmOmBar/Omega/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("OmOmBar/Omega/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("OmOmBar/Omega/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("OmOmBar/Omega/hCascPointingAngle", "hCascPointingAngle", kTH1F, {axisPointingAngle}); + histos.add("OmOmBar/Omega/hCascRadius", "hCascRadius", kTH1F, {axisRadius}); + histos.add("OmOmBar/Omega/hCascDecayLength", "hCascDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("OmOmBar/Omega/hV0InvMassWindow", "hV0InvMassWindow", kTH1F, {axisMassWindow}); + histos.add("OmOmBar/Omega/hCascInvMassWindow", "hCascInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("OmOmBar/Omega/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisXiMass, axisOmegaMass}); + histos.add("OmOmBar/Omega/hBachTPCNsigma", "hBachTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/Omega/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/Omega/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/Omega/h2dBachelorITSvsTPCpts", "h2dBachelorITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("OmOmBar/Omega/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("OmOmBar/Omega/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + // Candidates after AntiOmega selections + histos.add("OmOmBar/AntiOmega/hBachDCAToPV", "hBachDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/AntiOmega/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/AntiOmega/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); + histos.add("OmOmBar/AntiOmega/hDCACascDaughters", "hDCACascDaughters", kTH1F, {axisDCAdau}); + histos.add("OmOmBar/AntiOmega/hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {axisDCAdau}); + histos.add("OmOmBar/AntiOmega/hDCAV0ToPV", "hDCAV0ToPV", kTH1F, {axisDCAV0ToPV}); + histos.add("OmOmBar/AntiOmega/hV0PointingAngle", "hV0PointingAngle", kTH1F, {axisPointingAngle}); + histos.add("OmOmBar/AntiOmega/hV0Radius", "hV0Radius", kTH1F, {axisRadius}); + histos.add("OmOmBar/AntiOmega/hCascPointingAngle", "hCascPointingAngle", kTH1F, {axisPointingAngle}); + histos.add("OmOmBar/AntiOmega/hCascRadius", "hCascRadius", kTH1F, {axisRadius}); + histos.add("OmOmBar/AntiOmega/hCascDecayLength", "hCascDecayLength", kTH1F, {axisProperLifeTime}); + histos.add("OmOmBar/AntiOmega/hV0InvMassWindow", "hV0InvMassWindow", kTH1F, {axisMassWindow}); + histos.add("OmOmBar/AntiOmega/hCascInvMassWindow", "hCascInvMassWindow", kTH1F, {axisMassWindow}); + histos.add("OmOmBar/AntiOmega/h2dCompetingMassRej", "h2dCompetingMassRej", kTH2F, {axisXiMass, axisOmegaMass}); + histos.add("OmOmBar/AntiOmega/hBachTPCNsigma", "hBachTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/AntiOmega/hPosTPCNsigma", "hPosTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/AntiOmega/hNegTPCNsigma", "hNegTPCNsigma", kTH1F, {axisNsigmaTPC}); + histos.add("OmOmBar/AntiOmega/h2dBachelorITSvsTPCpts", "h2dBachelorITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("OmOmBar/AntiOmega/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + histos.add("OmOmBar/AntiOmega/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); + if (doMCAssociation) { + histos.add("OmOmBar/h3dInvMassTrueEtaC2S", "h3dInvMassTrueEtaC2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + histos.add("OmOmBar/h3dInvMassTruePsi2S", "h3dInvMassTruePsi2S", kTH3F, {axisCentrality, axisPt, axisQuarkoniumMass}); + } + } + // 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(); + + // machine learning initialization if requested + if (mlConfigurations.calculateK0ShortScores || + mlConfigurations.calculateLambdaScores || + mlConfigurations.calculateAntiLambdaScores) { + int64_t timeStampML = collision.timestamp(); + 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.loadCustomModelsFromCCDB) { + ccdbApi.init(ccdbConfigurations.ccdburl); + LOG(info) << "Fetching models for timestamp: " << timeStampML; + + if (mlConfigurations.calculateLambdaScores) { + bool retrieveSuccessLambda = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathLambda.value); + if (retrieveSuccessLambda) { + mlCustomModelLambda.initModel(mlConfigurations.localModelPathLambda.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the Lambda model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateAntiLambdaScores) { + bool retrieveSuccessAntiLambda = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathAntiLambda.value); + if (retrieveSuccessAntiLambda) { + mlCustomModelAntiLambda.initModel(mlConfigurations.localModelPathAntiLambda.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the AntiLambda model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateK0ShortScores) { + bool retrieveSuccessKZeroShort = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathK0Short.value); + if (retrieveSuccessKZeroShort) { + mlCustomModelK0Short.initModel(mlConfigurations.localModelPathK0Short.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the K0Short model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + } else { + if (mlConfigurations.calculateLambdaScores) + mlCustomModelLambda.initModel(mlConfigurations.localModelPathLambda.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateAntiLambdaScores) + mlCustomModelAntiLambda.initModel(mlConfigurations.localModelPathAntiLambda.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateK0ShortScores) + mlCustomModelK0Short.initModel(mlConfigurations.localModelPathK0Short.value, mlConfigurations.enableOptimizations.value); + } + LOG(info) << "ML Models loaded."; + } + + 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 (requireSel8 && !collision.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + + if (std::abs(collision.posZ()) > 10.f) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* vertex-Z selected */); + + if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); + + if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + + if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5 /* Contains at least one ITS-TPC track */); + + if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 6 /* PV position consistency check */); + + if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (fillHists) + 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; + } + if (fillHists) + 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; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* Not at same bunch pile-up */); + + if (requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* No other collision within +/- 10 microseconds */); + + if (requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 4 microseconds */); + + if (minOccupancy > 0 && collision.trackOccupancyInTimeRange() < minOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* Below min occupancy */); + if (maxOccupancy > 0 && collision.trackOccupancyInTimeRange() > maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* Above max occupancy */); + + return true; + } + + template + void fillEventHistograms(TCollision collision, float& centrality, int& selGapSide) + { + if (isPP) { // + centrality = collision.centFT0M(); + + if (qaCentrality) { + auto hRawCentrality = histos.get(HIST("hRawCentrality")); + centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0A() + collision.multFT0C())); + } + } else { + centrality = collision.centFT0C(); + + if (qaCentrality) { + auto hRawCentrality = histos.get(HIST("hRawCentrality")); + centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0C())); + } + } + + // in case we want to push the analysis to Pb-Pb UPC + int gapSide = collision.gapSide(); + if (!isPP) { + // -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()); + + histos.fill(HIST("hEventOccupancy"), collision.trackOccupancyInTimeRange()); + histos.fill(HIST("hCentralityVsOccupancy"), centrality, collision.trackOccupancyInTimeRange()); + + return; + } + + template + uint64_t computeReconstructionBitmap(TV0 v0, TCollision collision, float rapidityLambda, float rapidityK0Short, float /*pT*/) + // precalculate this information so that a check is one mask operation, not many + { + uint64_t bitMap = 0; + + // + // Base topological variables + // + + // v0 radius min/max selections + if (v0.v0radius() > v0Selections.v0radius) + bitset(bitMap, selRadius); + if (v0.v0radius() < v0Selections.v0radiusMax) + bitset(bitMap, selRadiusMax); + // DCA proton and pion to PV for Lambda and AntiLambda decay hypotheses + if (TMath::Abs(v0.dcapostopv()) > v0Selections.dcaprotontopv && + TMath::Abs(v0.dcanegtopv()) > v0Selections.dcapiontopv) { + bitset(bitMap, selDCAPosToPV); + bitset(bitMap, selDCANegToPV); + } else if (TMath::Abs(v0.dcapostopv()) > v0Selections.dcapiontopv && + TMath::Abs(v0.dcanegtopv()) > v0Selections.dcaprotontopv) { + bitset(bitMap, selDCAPosToPV); + bitset(bitMap, selDCANegToPV); + } + // V0 cosine of pointing angle + if (v0.v0cosPA() > v0Selections.v0cospa) + bitset(bitMap, selCosPA); + // DCA between v0 daughters + if (v0.dcaV0daughters() < v0Selections.dcav0dau) + bitset(bitMap, selDCAV0Dau); + // DCA V0 to prim vtx + if (v0.dcav0topv() > v0Selections.dcav0topv) + bitset(bitMap, selDCAV0ToPV); + + // + // rapidity + // + if (TMath::Abs(rapidityLambda) < v0Selections.rapidityCut) + bitset(bitMap, selLambdaRapidity); + if (TMath::Abs(rapidityK0Short) < v0Selections.rapidityCut) + bitset(bitMap, selK0ShortRapidity); + + // + // invariant mass window + // + if (TMath::Abs(v0.mK0Short() - pdgDB->Mass(310)) < v0Selections.v0MassWindow) + bitset(bitMap, selK0ShortMassWindow); + if (TMath::Abs(v0.mLambda() - pdgDB->Mass(3122)) < v0Selections.v0MassWindow) + bitset(bitMap, selLambdaMassWindow); + if (TMath::Abs(v0.mAntiLambda() - pdgDB->Mass(3122)) < v0Selections.v0MassWindow) + bitset(bitMap, selAntiLambdaMassWindow); + + // + // competing mass rejection + // + if (TMath::Abs(v0.mK0Short() - pdgDB->Mass(310)) > v0Selections.compMassRejection) + bitset(bitMap, selK0ShortMassRejection); + if (TMath::Abs(v0.mLambda() - pdgDB->Mass(3122)) > v0Selections.compMassRejection) + bitset(bitMap, selLambdaMassRejection); + + auto posTrackExtra = v0.template posTrackExtra_as(); + auto negTrackExtra = v0.template negTrackExtra_as(); + + // + // ITS quality flags + // + if (posTrackExtra.itsNCls() >= v0Selections.minITSclusters) + bitset(bitMap, selPosGoodITSTrack); + if (negTrackExtra.itsNCls() >= v0Selections.minITSclusters) + bitset(bitMap, selNegGoodITSTrack); + + // + // TPC quality flags + // + if (posTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) + bitset(bitMap, selPosGoodTPCTrack); + if (negTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) + 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); + + // + // 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); + // 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); + + // + // 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); + // 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); + + // + // ITS only tag + if (posTrackExtra.tpcCrossedRows() < 1) + bitset(bitMap, selPosItsOnly); + if (negTrackExtra.tpcCrossedRows() < 1) + bitset(bitMap, selNegItsOnly); + + // + // TPC only tag + if (posTrackExtra.detectorMap() != o2::aod::track::TPC) + bitset(bitMap, selPosNotTPCOnly); + if (negTrackExtra.detectorMap() != o2::aod::track::TPC) + bitset(bitMap, selNegNotTPCOnly); + + // + // proper lifetime + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0 < lifetimecut->get("lifetimecutLambda")) + bitset(bitMap, selLambdaCTau); + if (v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassK0Short < lifetimecut->get("lifetimecutK0S")) + bitset(bitMap, selK0ShortCTau); + + // + // armenteros + if (v0.qtarm() * v0Selections.armPodCut > TMath::Abs(v0.alpha()) || v0Selections.armPodCut < 1e-4) + bitset(bitMap, selK0ShortArmenteros); + + return bitMap; + } + + template + bool isCascadeSelected(TCascade casc, TCollision collision, float rapidity, bool isXi) + // 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 (TMath::Abs(casc.dcapostopv()) < cascSelections.dcaprotontopv) + return false; + if (TMath::Abs(casc.dcanegtopv()) < cascSelections.dcapiontopv) + return false; + } else { // Xi+ or Omega+ --> positive/negative daughter = pion/proton + if (TMath::Abs(casc.dcapostopv()) < cascSelections.dcapiontopv) + return false; + if (TMath::Abs(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 (TMath::Abs(casc.dcabachtopv()) < cascSelections.dcabachtopv) + return false; + // Bachelor-baryon cosPA selection + if (casc.bachBaryonCosPA() < cascSelections.bachbaryoncospa) + return false; + // DCA bachelor-baryon selection + if (TMath::Abs(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 (TMath::Abs(rapidity) > cascSelections.rapidityCut) + return false; + + // + // invariant mass window + // + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > cascSelections.v0MassWindow) + return false; + if (isXi && TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascSelections.cascMassWindow) + return false; + if (!isXi && TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) > cascSelections.cascMassWindow) + return false; + + // + // competing mass rejection + // + if (isXi && TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) < cascSelections.compMassRejection) + return false; + if (!isXi && TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) < 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 (isXi && fabs(bachTrackExtra.tpcNSigmaPi()) > cascSelections.TpcPidNsigmaCut) + return false; + if (!isXi && fabs(bachTrackExtra.tpcNSigmaKa()) > cascSelections.TpcPidNsigmaCut) + return false; + if (casc.sign() < 0) { // Xi- or Omega- --> positive/negative daughter = proton/pion + if (fabs(posTrackExtra.tpcNSigmaPr()) > cascSelections.TpcPidNsigmaCut) + return false; + if (fabs(negTrackExtra.tpcNSigmaPi()) > cascSelections.TpcPidNsigmaCut) + return false; + } else { // Xi+ or Omega+ --> positive/negative daughter = pion/proton + if (fabs(posTrackExtra.tpcNSigmaPi()) > cascSelections.TpcPidNsigmaCut) + return false; + if (fabs(negTrackExtra.tpcNSigmaPr()) > cascSelections.TpcPidNsigmaCut) + return false; + } + + // + // TOF PID in DeltaT + // Bachelor track + if (bachTrackExtra.hasTOF()) { + if (isXi && fabs(casc.bachTOFDeltaTXiPi()) > cascSelections.maxDeltaTimePion) + return false; + if (!isXi && fabs(casc.bachTOFDeltaTOmKa()) > cascSelections.maxDeltaTimeKaon) + return false; + } + // Positive track + if (posTrackExtra.hasTOF()) { + if (casc.sign() < 0) { // Xi- or Omega- --> positive daughter = proton + if (isXi && fabs(casc.posTOFDeltaTXiPr()) > cascSelections.maxDeltaTimeProton) + return false; + if (!isXi && fabs(casc.posTOFDeltaTOmPr()) > cascSelections.maxDeltaTimeProton) + return false; + } else { // Xi+ or Omega+ --> positive daughter = pion + if (isXi && fabs(casc.posTOFDeltaTXiPi()) > cascSelections.maxDeltaTimePion) + return false; + if (!isXi && fabs(casc.posTOFDeltaTOmPi()) > cascSelections.maxDeltaTimePion) + return false; + } + } + // Negative track + if (negTrackExtra.hasTOF()) { + if (casc.sign() < 0) { // Xi- or Omega- --> negative daughter = pion + if (isXi && fabs(casc.negTOFDeltaTXiPi()) > cascSelections.maxDeltaTimePion) + return false; + if (!isXi && fabs(casc.negTOFDeltaTOmPi()) > cascSelections.maxDeltaTimePion) + return false; + } else { // Xi+ or Omega+ --> negative daughter = proton + if (isXi && fabs(casc.negTOFDeltaTXiPr()) > cascSelections.maxDeltaTimeProton) + return false; + if (!isXi && fabs(casc.negTOFDeltaTOmPr()) > cascSelections.maxDeltaTimeProton) + return false; + } + } + + // + // TOF PID in NSigma + // Bachelor track + if (bachTrackExtra.hasTOF()) { + if (isXi && fabs(casc.tofNSigmaXiPi()) > cascSelections.TofPidNsigmaCutXiPi) + return false; + if (!isXi && fabs(casc.tofNSigmaOmKa()) > cascSelections.TofPidNsigmaCutOmKa) + return false; + } + // Positive track + if (posTrackExtra.hasTOF()) { + if (casc.sign() < 0) { // Xi- or Omega- --> positive daughter = proton + if (isXi && fabs(casc.tofNSigmaXiLaPr()) > cascSelections.TofPidNsigmaCutLaPr) + return false; + if (!isXi && fabs(casc.tofNSigmaOmLaPr()) > cascSelections.TofPidNsigmaCutLaPr) + return false; + } else { // Xi+ or Omega+ --> positive daughter = pion + if (isXi && fabs(casc.tofNSigmaXiLaPi()) > cascSelections.TofPidNsigmaCutLaPi) + return false; + if (!isXi && fabs(casc.tofNSigmaOmLaPi()) > cascSelections.TofPidNsigmaCutLaPi) + return false; + } + } + // Negative track + if (negTrackExtra.hasTOF()) { + if (casc.sign() < 0) { // Xi- or Omega- --> negative daughter = pion + if (isXi && fabs(casc.tofNSigmaXiLaPr()) > cascSelections.TofPidNsigmaCutLaPi) + return false; + if (!isXi && fabs(casc.tofNSigmaOmLaPr()) > cascSelections.TofPidNsigmaCutLaPi) + return false; + } else { // Xi+ or Omega+ --> negative daughter = proton + if (isXi && fabs(casc.tofNSigmaXiLaPi()) > cascSelections.TofPidNsigmaCutLaPr) + return false; + if (!isXi && fabs(casc.tofNSigmaOmLaPi()) > cascSelections.TofPidNsigmaCutLaPr) + 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 (isXi && distOverTotMom * o2::constants::physics::MassXiMinus / ctauXiPDG > cascSelections.cascProperLifeTime) + return false; + if (!isXi && distOverTotMom * o2::constants::physics::MassOmegaMinus / ctauOmegaPDG > cascSelections.cascProperLifeTime) + return false; + + // + // MC association (if asked) + if (doMCAssociation) { + if constexpr (requires { casc.template cascMCCore_as>(); }) { // check if MC information is available + auto cascMC = casc.template cascMCCore_as>(); + + if (isXi) { + if (casc.sign() < 0) { + if (cascMC.pdgCode() != 3312 || cascMC.pdgCodePositive() != 2212 || cascMC.pdgCodeNegative() != -211 || cascMC.pdgCodeBachelor() != -211) + return false; + } else { + if (cascMC.pdgCode() != -3312 || cascMC.pdgCodePositive() != 211 || cascMC.pdgCodeNegative() != -2212 || cascMC.pdgCodeBachelor() != 211) + return false; + } + } else { + if (casc.sign() < 0) { + if (cascMC.pdgCode() != 3334 || cascMC.pdgCodePositive() != 2212 || cascMC.pdgCodeNegative() != -211 || cascMC.pdgCodeBachelor() != -321) + return false; + } else { + if (cascMC.pdgCode() != -3334 || cascMC.pdgCodePositive() != 211 || cascMC.pdgCodeNegative() != -2212 || cascMC.pdgCodeBachelor() != 321) + return false; + } + } + } + } + + return true; + } + + template + uint64_t computeMCAssociation(TV0 v0) + // precalculate this information so that a check is one mask operation, not many + { + uint64_t bitMap = 0; + // check for specific particle species + + if (v0.pdgCode() == 310 && v0.pdgCodePositive() == 211 && v0.pdgCodeNegative() == -211) { + bitset(bitMap, selConsiderK0Short); + if (v0.isPhysicalPrimary()) + bitset(bitMap, selPhysPrimK0Short); + } + if (v0.pdgCode() == 3122 && v0.pdgCodePositive() == 2212 && v0.pdgCodeNegative() == -211) { + bitset(bitMap, selConsiderLambda); + if (v0.isPhysicalPrimary()) + bitset(bitMap, selPhysPrimLambda); + } + if (v0.pdgCode() == -3122 && v0.pdgCodePositive() == 211 && v0.pdgCodeNegative() == -2212) { + bitset(bitMap, selConsiderAntiLambda); + if (v0.isPhysicalPrimary()) + bitset(bitMap, selPhysPrimAntiLambda); + } + return bitMap; + } + + bool verifyMask(uint64_t bitmap, uint64_t mask) + { + return (bitmap & mask) == mask; + } + + template + void analyseV0Candidate(TV0 v0, float pt, float /*centrality*/, uint64_t selMap, std::vector& selK0ShortIndices, std::vector& selLambdaIndices, std::vector& selAntiLambdaIndices, int v0TableOffset) + // precalculate this information so that a check is one mask operation, not many + { + bool passK0ShortSelections = false; + bool passLambdaSelections = false; + bool passAntiLambdaSelections = false; + + // machine learning is on, go for calculation of thresholds + // FIXME THIS NEEDS ADJUSTING + std::vector inputFeatures{pt, 0.0f, 0.0f, v0.v0radius(), v0.v0cosPA(), v0.dcaV0daughters(), v0.dcapostopv(), v0.dcanegtopv()}; + + if (mlConfigurations.useK0ShortScores) { + float k0shortScore = -1; + if (mlConfigurations.calculateK0ShortScores) { + // evaluate machine-learning scores + float* k0shortProbability = mlCustomModelK0Short.evalModel(inputFeatures); + k0shortScore = k0shortProbability[1]; + } else { + k0shortScore = v0.k0ShortBDTScore(); + } + if (k0shortScore > mlConfigurations.thresholdK0Short.value) { + passK0ShortSelections = true; + } + } else { + passK0ShortSelections = verifyMask(selMap, maskSelectionK0Short); + } + if (mlConfigurations.useLambdaScores) { + float lambdaScore = -1; + if (mlConfigurations.calculateLambdaScores) { + // evaluate machine-learning scores + float* lambdaProbability = mlCustomModelLambda.evalModel(inputFeatures); + lambdaScore = lambdaProbability[1]; + } else { + lambdaScore = v0.lambdaBDTScore(); + } + if (lambdaScore > mlConfigurations.thresholdK0Short.value) { + passLambdaSelections = true; + } + } else { + passLambdaSelections = verifyMask(selMap, maskSelectionLambda); + } + if (mlConfigurations.useLambdaScores) { + float antiLambdaScore = -1; + if (mlConfigurations.calculateAntiLambdaScores) { + // evaluate machine-learning scores + float* antilambdaProbability = mlCustomModelAntiLambda.evalModel(inputFeatures); + antiLambdaScore = antilambdaProbability[1]; + } else { + antiLambdaScore = v0.antiLambdaBDTScore(); + } + if (antiLambdaScore > mlConfigurations.thresholdK0Short.value) { + passAntiLambdaSelections = true; + } + } else { + passAntiLambdaSelections = verifyMask(selMap, maskSelectionAntiLambda); + } + + // need local index because of the grouping of collisions + selK0ShortIndices[v0.globalIndex() - v0TableOffset] = passK0ShortSelections; + selLambdaIndices[v0.globalIndex() - v0TableOffset] = passLambdaSelections; + selAntiLambdaIndices[v0.globalIndex() - v0TableOffset] = passAntiLambdaSelections; + } + + template + void fillQAplot(TCollision collision, THyperon hyperon, THyperon antiHyperon, int type) + { // fill QA information about hyperon - antihyperon pair + if (type == 0) { + if constexpr (requires { hyperon.mK0Short(); antiHyperon.mK0Short(); }) { // check if v0 information is available + auto posTrackExtraHyperon = hyperon.template posTrackExtra_as(); + auto negTrackExtraHyperon = hyperon.template negTrackExtra_as(); + + auto posTrackExtraAntiHyperon = antiHyperon.template posTrackExtra_as(); + auto negTrackExtraAntiHyperon = antiHyperon.template negTrackExtra_as(); + + float hyperonDecayLength = std::sqrt(std::pow(hyperon.x() - collision.posX(), 2) + std::pow(hyperon.y() - collision.posY(), 2) + std::pow(hyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassLambda0 / (hyperon.p() + 1E-10); + float antiHyperonDecayLength = std::sqrt(std::pow(antiHyperon.x() - collision.posX(), 2) + std::pow(antiHyperon.y() - collision.posY(), 2) + std::pow(antiHyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassLambda0 / (antiHyperon.p() + 1E-10); + + // Candidates after Xi selections + histos.fill(HIST("LaLaBar/Lambda/hPosDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("LaLaBar/Lambda/hNegDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("LaLaBar/Lambda/hDCAV0Daughters"), hyperon.dcaV0daughters()); + histos.fill(HIST("LaLaBar/Lambda/hDCAV0ToPV"), hyperon.dcav0topv()); + histos.fill(HIST("LaLaBar/Lambda/hV0PointingAngle"), hyperon.v0cosPA()); + histos.fill(HIST("LaLaBar/Lambda/hV0Radius"), hyperon.v0radius()); + histos.fill(HIST("LaLaBar/Lambda/hV0DecayLength"), hyperonDecayLength); + histos.fill(HIST("LaLaBar/Lambda/hV0InvMassWindow"), hyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("LaLaBar/Lambda/h2dCompetingMassRej"), hyperon.mLambda(), hyperon.mK0Short()); + histos.fill(HIST("LaLaBar/Lambda/hPosTPCNsigma"), posTrackExtraHyperon.tpcNSigmaPr()); + histos.fill(HIST("LaLaBar/Lambda/hNegTPCNsigma"), negTrackExtraHyperon.tpcNSigmaPi()); + histos.fill(HIST("LaLaBar/Lambda/h2dPositiveITSvsTPCpts"), posTrackExtraHyperon.tpcCrossedRows(), posTrackExtraHyperon.itsNCls()); + histos.fill(HIST("LaLaBar/Lambda/h2dNegativeITSvsTPCpts"), negTrackExtraHyperon.tpcCrossedRows(), negTrackExtraHyperon.itsNCls()); + // Candidates after AntiXi selections + histos.fill(HIST("LaLaBar/AntiLambda/hPosDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("LaLaBar/AntiLambda/hNegDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("LaLaBar/AntiLambda/hDCAV0Daughters"), antiHyperon.dcaV0daughters()); + histos.fill(HIST("LaLaBar/AntiLambda/hDCAV0ToPV"), antiHyperon.dcav0topv()); + histos.fill(HIST("LaLaBar/AntiLambda/hV0PointingAngle"), antiHyperon.v0cosPA()); + histos.fill(HIST("LaLaBar/AntiLambda/hV0Radius"), antiHyperon.v0radius()); + histos.fill(HIST("LaLaBar/AntiLambda/hV0DecayLength"), antiHyperonDecayLength); + histos.fill(HIST("LaLaBar/AntiLambda/hV0InvMassWindow"), antiHyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("LaLaBar/AntiLambda/h2dCompetingMassRej"), antiHyperon.mLambda(), antiHyperon.mK0Short()); + histos.fill(HIST("LaLaBar/AntiLambda/hPosTPCNsigma"), posTrackExtraAntiHyperon.tpcNSigmaPi()); + histos.fill(HIST("LaLaBar/AntiLambda/hNegTPCNsigma"), negTrackExtraAntiHyperon.tpcNSigmaPr()); + histos.fill(HIST("LaLaBar/AntiLambda/h2dPositiveITSvsTPCpts"), posTrackExtraAntiHyperon.tpcCrossedRows(), posTrackExtraAntiHyperon.itsNCls()); + histos.fill(HIST("LaLaBar/AntiLambda/h2dNegativeITSvsTPCpts"), negTrackExtraAntiHyperon.tpcCrossedRows(), negTrackExtraAntiHyperon.itsNCls()); + } + } + if (type == 1) { + if constexpr (requires { hyperon.dcabachtopv(); antiHyperon.dcabachtopv(); }) { // check if Cascade information is available + auto bachTrackExtraHyperon = hyperon.template bachTrackExtra_as(); + auto posTrackExtraHyperon = hyperon.template posTrackExtra_as(); + auto negTrackExtraHyperon = hyperon.template negTrackExtra_as(); + + auto bachTrackExtraAntiHyperon = antiHyperon.template bachTrackExtra_as(); + auto posTrackExtraAntiHyperon = antiHyperon.template posTrackExtra_as(); + auto negTrackExtraAntiHyperon = antiHyperon.template negTrackExtra_as(); + + float hyperonDecayLength = std::sqrt(std::pow(hyperon.x() - collision.posX(), 2) + std::pow(hyperon.y() - collision.posY(), 2) + std::pow(hyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassXiMinus / (hyperon.p() + 1E-10); + float antiHyperonDecayLength = std::sqrt(std::pow(antiHyperon.x() - collision.posX(), 2) + std::pow(antiHyperon.y() - collision.posY(), 2) + std::pow(antiHyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassXiMinus / (antiHyperon.p() + 1E-10); + + // Candidates after Xi selections + histos.fill(HIST("XiXiBar/Xi/hBachDCAToPV"), hyperon.dcabachtopv()); + histos.fill(HIST("XiXiBar/Xi/hPosDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("XiXiBar/Xi/hNegDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("XiXiBar/Xi/hDCACascDaughters"), hyperon.dcacascdaughters()); + histos.fill(HIST("XiXiBar/Xi/hDCAV0Daughters"), hyperon.dcaV0daughters()); + histos.fill(HIST("XiXiBar/Xi/hDCAV0ToPV"), hyperon.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/Xi/hV0PointingAngle"), hyperon.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/Xi/hV0Radius"), hyperon.v0radius()); + histos.fill(HIST("XiXiBar/Xi/hCascPointingAngle"), hyperon.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/Xi/hCascRadius"), hyperon.cascradius()); + histos.fill(HIST("XiXiBar/Xi/hCascDecayLength"), hyperonDecayLength); + histos.fill(HIST("XiXiBar/Xi/hV0InvMassWindow"), hyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("XiXiBar/Xi/hCascInvMassWindow"), hyperon.mXi() - pdgDB->Mass(3312)); + histos.fill(HIST("XiXiBar/Xi/h2dCompetingMassRej"), hyperon.mXi(), hyperon.mOmega()); + histos.fill(HIST("XiXiBar/Xi/hBachTPCNsigma"), bachTrackExtraHyperon.tpcNSigmaPi()); + histos.fill(HIST("XiXiBar/Xi/hPosTPCNsigma"), posTrackExtraHyperon.tpcNSigmaPr()); + histos.fill(HIST("XiXiBar/Xi/hNegTPCNsigma"), negTrackExtraHyperon.tpcNSigmaPi()); + histos.fill(HIST("XiXiBar/Xi/h2dBachelorITSvsTPCpts"), bachTrackExtraHyperon.tpcCrossedRows(), bachTrackExtraHyperon.itsNCls()); + histos.fill(HIST("XiXiBar/Xi/h2dPositiveITSvsTPCpts"), posTrackExtraHyperon.tpcCrossedRows(), posTrackExtraHyperon.itsNCls()); + histos.fill(HIST("XiXiBar/Xi/h2dNegativeITSvsTPCpts"), negTrackExtraHyperon.tpcCrossedRows(), negTrackExtraHyperon.itsNCls()); + // Candidates after AntiXi selections + histos.fill(HIST("XiXiBar/AntiXi/hBachDCAToPV"), antiHyperon.dcabachtopv()); + histos.fill(HIST("XiXiBar/AntiXi/hPosDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("XiXiBar/AntiXi/hNegDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("XiXiBar/AntiXi/hDCACascDaughters"), antiHyperon.dcacascdaughters()); + histos.fill(HIST("XiXiBar/AntiXi/hDCAV0Daughters"), antiHyperon.dcaV0daughters()); + histos.fill(HIST("XiXiBar/AntiXi/hDCAV0ToPV"), antiHyperon.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/AntiXi/hV0PointingAngle"), antiHyperon.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/AntiXi/hV0Radius"), antiHyperon.v0radius()); + histos.fill(HIST("XiXiBar/AntiXi/hCascPointingAngle"), antiHyperon.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("XiXiBar/AntiXi/hCascRadius"), antiHyperon.cascradius()); + histos.fill(HIST("XiXiBar/AntiXi/hCascDecayLength"), antiHyperonDecayLength); + histos.fill(HIST("XiXiBar/AntiXi/hV0InvMassWindow"), antiHyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("XiXiBar/AntiXi/hCascInvMassWindow"), antiHyperon.mXi() - pdgDB->Mass(3312)); + histos.fill(HIST("XiXiBar/AntiXi/h2dCompetingMassRej"), antiHyperon.mXi(), antiHyperon.mOmega()); + histos.fill(HIST("XiXiBar/AntiXi/hBachTPCNsigma"), bachTrackExtraAntiHyperon.tpcNSigmaPi()); + histos.fill(HIST("XiXiBar/AntiXi/hPosTPCNsigma"), posTrackExtraAntiHyperon.tpcNSigmaPi()); + histos.fill(HIST("XiXiBar/AntiXi/hNegTPCNsigma"), negTrackExtraAntiHyperon.tpcNSigmaPr()); + histos.fill(HIST("XiXiBar/AntiXi/h2dBachelorITSvsTPCpts"), bachTrackExtraAntiHyperon.tpcCrossedRows(), bachTrackExtraAntiHyperon.itsNCls()); + histos.fill(HIST("XiXiBar/AntiXi/h2dPositiveITSvsTPCpts"), posTrackExtraAntiHyperon.tpcCrossedRows(), posTrackExtraAntiHyperon.itsNCls()); + histos.fill(HIST("XiXiBar/AntiXi/h2dNegativeITSvsTPCpts"), negTrackExtraAntiHyperon.tpcCrossedRows(), negTrackExtraAntiHyperon.itsNCls()); + } + } + if (type == 2) { + if constexpr (requires { hyperon.dcabachtopv(); antiHyperon.dcabachtopv(); }) { // check if Cascade information is available + auto bachTrackExtraHyperon = hyperon.template bachTrackExtra_as(); + auto posTrackExtraHyperon = hyperon.template posTrackExtra_as(); + auto negTrackExtraHyperon = hyperon.template negTrackExtra_as(); + + auto bachTrackExtraAntiHyperon = antiHyperon.template bachTrackExtra_as(); + auto posTrackExtraAntiHyperon = antiHyperon.template posTrackExtra_as(); + auto negTrackExtraAntiHyperon = antiHyperon.template negTrackExtra_as(); + + float hyperonDecayLength = std::sqrt(std::pow(hyperon.x() - collision.posX(), 2) + std::pow(hyperon.y() - collision.posY(), 2) + std::pow(hyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassOmegaMinus / (hyperon.p() + 1E-10); + float antiHyperonDecayLength = std::sqrt(std::pow(antiHyperon.x() - collision.posX(), 2) + std::pow(antiHyperon.y() - collision.posY(), 2) + std::pow(antiHyperon.z() - collision.posZ(), 2)) * o2::constants::physics::MassOmegaMinus / (antiHyperon.p() + 1E-10); + + // Candidates after Omega selections + histos.fill(HIST("OmOmBar/Omega/hBachDCAToPV"), hyperon.dcabachtopv()); + histos.fill(HIST("OmOmBar/Omega/hPosDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("OmOmBar/Omega/hNegDCAToPV"), hyperon.dcapostopv()); + histos.fill(HIST("OmOmBar/Omega/hDCACascDaughters"), hyperon.dcacascdaughters()); + histos.fill(HIST("OmOmBar/Omega/hDCAV0Daughters"), hyperon.dcaV0daughters()); + histos.fill(HIST("OmOmBar/Omega/hDCAV0ToPV"), hyperon.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/Omega/hV0PointingAngle"), hyperon.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/Omega/hV0Radius"), hyperon.v0radius()); + histos.fill(HIST("OmOmBar/Omega/hCascPointingAngle"), hyperon.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/Omega/hCascRadius"), hyperon.cascradius()); + histos.fill(HIST("OmOmBar/Omega/hCascDecayLength"), hyperonDecayLength); + histos.fill(HIST("OmOmBar/Omega/hV0InvMassWindow"), hyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("OmOmBar/Omega/hCascInvMassWindow"), hyperon.mOmega() - pdgDB->Mass(3334)); + histos.fill(HIST("OmOmBar/Omega/h2dCompetingMassRej"), hyperon.mXi(), hyperon.mOmega()); + histos.fill(HIST("OmOmBar/Omega/hBachTPCNsigma"), bachTrackExtraHyperon.tpcNSigmaKa()); + histos.fill(HIST("OmOmBar/Omega/hPosTPCNsigma"), posTrackExtraHyperon.tpcNSigmaPr()); + histos.fill(HIST("OmOmBar/Omega/hNegTPCNsigma"), negTrackExtraHyperon.tpcNSigmaPi()); + histos.fill(HIST("OmOmBar/Omega/h2dBachelorITSvsTPCpts"), bachTrackExtraHyperon.tpcCrossedRows(), bachTrackExtraHyperon.itsNCls()); + histos.fill(HIST("OmOmBar/Omega/h2dPositiveITSvsTPCpts"), posTrackExtraHyperon.tpcCrossedRows(), posTrackExtraHyperon.itsNCls()); + histos.fill(HIST("OmOmBar/Omega/h2dNegativeITSvsTPCpts"), negTrackExtraHyperon.tpcCrossedRows(), negTrackExtraHyperon.itsNCls()); + // Candidates after AntiOmega selections + histos.fill(HIST("OmOmBar/AntiOmega/hBachDCAToPV"), antiHyperon.dcabachtopv()); + histos.fill(HIST("OmOmBar/AntiOmega/hPosDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("OmOmBar/AntiOmega/hNegDCAToPV"), antiHyperon.dcapostopv()); + histos.fill(HIST("OmOmBar/AntiOmega/hDCACascDaughters"), antiHyperon.dcacascdaughters()); + histos.fill(HIST("OmOmBar/AntiOmega/hDCAV0Daughters"), antiHyperon.dcaV0daughters()); + histos.fill(HIST("OmOmBar/AntiOmega/hDCAV0ToPV"), antiHyperon.dcav0topv(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/AntiOmega/hV0PointingAngle"), antiHyperon.v0cosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/AntiOmega/hV0Radius"), antiHyperon.v0radius()); + histos.fill(HIST("OmOmBar/AntiOmega/hCascPointingAngle"), antiHyperon.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + histos.fill(HIST("OmOmBar/AntiOmega/hCascRadius"), antiHyperon.cascradius()); + histos.fill(HIST("OmOmBar/AntiOmega/hCascDecayLength"), antiHyperonDecayLength); + histos.fill(HIST("OmOmBar/AntiOmega/hV0InvMassWindow"), antiHyperon.mLambda() - pdgDB->Mass(3122)); + histos.fill(HIST("OmOmBar/AntiOmega/hCascInvMassWindow"), antiHyperon.mOmega() - pdgDB->Mass(3334)); + histos.fill(HIST("OmOmBar/AntiOmega/h2dCompetingMassRej"), antiHyperon.mXi(), antiHyperon.mOmega()); + histos.fill(HIST("OmOmBar/AntiOmega/hBachTPCNsigma"), bachTrackExtraAntiHyperon.tpcNSigmaKa()); + histos.fill(HIST("OmOmBar/AntiOmega/hPosTPCNsigma"), posTrackExtraAntiHyperon.tpcNSigmaPi()); + histos.fill(HIST("OmOmBar/AntiOmega/hNegTPCNsigma"), negTrackExtraAntiHyperon.tpcNSigmaPr()); + histos.fill(HIST("OmOmBar/AntiOmega/h2dBachelorITSvsTPCpts"), bachTrackExtraAntiHyperon.tpcCrossedRows(), bachTrackExtraAntiHyperon.itsNCls()); + histos.fill(HIST("OmOmBar/AntiOmega/h2dPositiveITSvsTPCpts"), posTrackExtraAntiHyperon.tpcCrossedRows(), posTrackExtraAntiHyperon.itsNCls()); + histos.fill(HIST("OmOmBar/AntiOmega/h2dNegativeITSvsTPCpts"), negTrackExtraAntiHyperon.tpcCrossedRows(), negTrackExtraAntiHyperon.itsNCls()); + } + } + } + + template + void analyseHyperonPairCandidate(TCollision collision, THyperon hyperon, THyperon antiHyperon, float centrality, uint8_t gapSide, int type) + // fill information related to the quarkonium mother + // type = 0 (Lambda), 1 (Xi), 2 (Omega) + { + float pt = RecoDecay::pt(hyperon.px() + antiHyperon.px(), hyperon.py() + antiHyperon.py()); + + float invmass = -1; + if (type == 0) + invmass = RecoDecay::m(std::array{std::array{hyperon.px(), hyperon.py(), hyperon.pz()}, std::array{antiHyperon.px(), antiHyperon.py(), antiHyperon.pz()}}, std::array{o2::constants::physics::MassLambda0, o2::constants::physics::MassLambda0Bar}); + if (type == 1) + invmass = RecoDecay::m(std::array{std::array{hyperon.px(), hyperon.py(), hyperon.pz()}, std::array{antiHyperon.px(), antiHyperon.py(), antiHyperon.pz()}}, std::array{o2::constants::physics::MassXiMinus, o2::constants::physics::MassXiPlusBar}); + if (type == 2) + invmass = RecoDecay::m(std::array{std::array{hyperon.px(), hyperon.py(), hyperon.pz()}, std::array{antiHyperon.px(), antiHyperon.py(), antiHyperon.pz()}}, std::array{o2::constants::physics::MassOmegaMinus, o2::constants::physics::MassOmegaPlusBar}); + + float rapidity = RecoDecay::y(std::array{hyperon.px() + antiHyperon.px(), hyperon.py() + antiHyperon.py(), hyperon.pz() + antiHyperon.pz()}, invmass); + + // rapidity cut on the quarkonium mother + if (!doMCAssociation && TMath::Abs(rapidity) > rapidityCut) + return; + + // fillV0sInfo(lambda, antiLambda, centrality); + + // __________________________________________ + // main analysis + if (type == 0) { + if (doMCAssociation) { + if constexpr (requires { hyperon.template v0MCCore_as>(); }) { // check if MC information is available + auto hyperonMC = hyperon.template v0MCCore_as>(); + auto antiHyperonMC = antiHyperon.template v0MCCore_as>(); + + if (hyperonMC.pdgCodeMother() != antiHyperonMC.pdgCodeMother()) { + return; + } + + float ptmc = RecoDecay::pt(hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC()); + float rapiditymc = RecoDecay::y(std::array{hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC(), hyperonMC.pzMC() + antiHyperonMC.pzMC()}, pdgDB->Mass(hyperonMC.pdgCodeMother())); + + if (TMath::Abs(rapiditymc) > rapidityCut) + return; + + if (hyperonMC.pdgCodeMother() == 441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // EtaC(1S) + histos.fill(HIST("LaLaBar/h3dInvMassTrueEtaC1S"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // J/psi + histos.fill(HIST("LaLaBar/h3dInvMassTrueJPsi"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 10441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC0 + histos.fill(HIST("LaLaBar/h3dInvMassTrueChiC0"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 20443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC1 + histos.fill(HIST("LaLaBar/h3dInvMassTrueChiC1"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 10443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // hC + histos.fill(HIST("LaLaBar/h3dInvMassTrueHC"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 445 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC2 + histos.fill(HIST("LaLaBar/h3dInvMassTrueChiC2"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 100441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // EtaC(2S) + histos.fill(HIST("LaLaBar/h3dInvMassTrueEtaC2S"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 100443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // Psi(2S) + histos.fill(HIST("LaLaBar/h3dInvMassTruePsi2S"), centrality, ptmc, invmass); + } + } + } + + histos.fill(HIST("LaLaBar/h3dMassLaLabar"), centrality, pt, invmass); + if (!isPP) { // in case of PbPb data + if (gapSide == 0) + histos.fill(HIST("LaLaBar/h3dMassLaLabarSGA"), centrality, pt, invmass); + else if (gapSide == 1) + histos.fill(HIST("LaLaBar/h3dMassLaLabarSGC"), centrality, pt, invmass); + else if (gapSide == 2) + histos.fill(HIST("LaLaBar/h3dMassLaLabarDG"), centrality, pt, invmass); + else + histos.fill(HIST("LaLaBar/h3dMassLaLabarHadronic"), centrality, pt, invmass); + } + fillQAplot(collision, hyperon, antiHyperon, 0); + } + if (type == 1) { + if (doMCAssociation) { + if constexpr (requires { hyperon.template cascMCCore_as>(); }) { // check if MC information is available + auto hyperonMC = hyperon.template cascMCCore_as>(); + auto antiHyperonMC = antiHyperon.template cascMCCore_as>(); + + if (hyperonMC.pdgCodeMother() != antiHyperonMC.pdgCodeMother()) { + return; + } + + float ptmc = RecoDecay::pt(hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC()); + float rapiditymc = RecoDecay::y(std::array{hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC(), hyperonMC.pzMC() + antiHyperonMC.pzMC()}, pdgDB->Mass(hyperonMC.pdgCodeMother())); + + if (TMath::Abs(rapiditymc) > rapidityCut) + return; + + if (hyperonMC.pdgCodeMother() == 441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // EtaC(1S) + histos.fill(HIST("XiXiBar/h3dInvMassTrueEtaC1S"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // J/psi + histos.fill(HIST("XiXiBar/h3dInvMassTrueJPsi"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 10441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC0 + histos.fill(HIST("XiXiBar/h3dInvMassTrueChiC0"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 20443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC1 + histos.fill(HIST("XiXiBar/h3dInvMassTrueChiC1"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 10443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // hC + histos.fill(HIST("XiXiBar/h3dInvMassTrueHC"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 445 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // ChiC2 + histos.fill(HIST("XiXiBar/h3dInvMassTrueChiC2"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 100441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // EtaC(2S) + histos.fill(HIST("XiXiBar/h3dInvMassTrueEtaC2S"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 100443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // Psi(2S) + histos.fill(HIST("XiXiBar/h3dInvMassTruePsi2S"), centrality, ptmc, invmass); + } + } + } + + histos.fill(HIST("XiXiBar/h3dMassXiXibar"), centrality, pt, invmass); + if (!isPP) { // in case of PbPb data + if (gapSide == 0) + histos.fill(HIST("XiXiBar/h3dMassXiXibarSGA"), centrality, pt, invmass); + else if (gapSide == 1) + histos.fill(HIST("XiXiBar/h3dMassXiXibarSGC"), centrality, pt, invmass); + else if (gapSide == 2) + histos.fill(HIST("XiXiBar/h3dMassXiXibarDG"), centrality, pt, invmass); + else + histos.fill(HIST("XiXiBar/h3dMassXiXibarHadronic"), centrality, pt, invmass); + } + fillQAplot(collision, hyperon, antiHyperon, 1); + } + if (type == 2) { + if (doMCAssociation) { + if constexpr (requires { hyperon.template cascMCCore_as>(); }) { // check if MC information is available + auto hyperonMC = hyperon.template cascMCCore_as>(); + auto antiHyperonMC = antiHyperon.template cascMCCore_as>(); + + if (hyperonMC.pdgCodeMother() != antiHyperonMC.pdgCodeMother()) { + return; + } + + float ptmc = RecoDecay::pt(hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC()); + float rapiditymc = RecoDecay::y(std::array{hyperonMC.pxMC() + antiHyperonMC.pxMC(), hyperonMC.pyMC() + antiHyperonMC.pyMC(), hyperonMC.pzMC() + antiHyperonMC.pzMC()}, pdgDB->Mass(hyperonMC.pdgCodeMother())); + + if (TMath::Abs(rapiditymc) > rapidityCut) + return; + + if (hyperonMC.pdgCodeMother() == 100441 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // EtaC(2S) + histos.fill(HIST("OmOmBar/h3dInvMassTrueEtaC2S"), centrality, ptmc, invmass); + } + if (hyperonMC.pdgCodeMother() == 100443 && hyperonMC.pdgCodeMother() == antiHyperonMC.pdgCodeMother()) { // Psi(2S) + histos.fill(HIST("OmOmBar/h3dInvMassTruePsi2S"), centrality, ptmc, invmass); + } + } + } + + histos.fill(HIST("OmOmBar/h3dMassOmOmbar"), centrality, pt, invmass); + if (!isPP) { // in case of PbPb data + if (gapSide == 0) + histos.fill(HIST("OmOmBar/h3dMassOmOmbarSGA"), centrality, pt, invmass); + else if (gapSide == 1) + histos.fill(HIST("OmOmBar/h3dMassOmOmbarSGC"), centrality, pt, invmass); + else if (gapSide == 2) + histos.fill(HIST("OmOmBar/h3dMassOmOmbarDG"), centrality, pt, invmass); + else + histos.fill(HIST("OmOmBar/h3dMassOmOmbarHadronic"), centrality, pt, invmass); + } + fillQAplot(collision, hyperon, antiHyperon, 2); + } + } + + // function to check that the hyperon and antihyperon have different daughter tracks + template + bool checkTrackIndices(THyperon hyperon, THyperon antiHyperon) + { + if constexpr (requires { hyperon.template bachTrackExtra_as(); }) { // cascade case: check if bachelor information is available + // check that bachelor track from hyperon is different from daughter tracks of antiHyperon + if (hyperon.bachTrackExtraId() == antiHyperon.bachTrackExtraId() || + hyperon.bachTrackExtraId() == antiHyperon.posTrackExtraId() || + hyperon.bachTrackExtraId() == antiHyperon.negTrackExtraId()) + return false; + // check that positive track from hyperon is different from daughter tracks of antiHyperon + if (hyperon.posTrackExtraId() == antiHyperon.bachTrackExtraId() || + hyperon.posTrackExtraId() == antiHyperon.posTrackExtraId() || + hyperon.posTrackExtraId() == antiHyperon.negTrackExtraId()) + return false; + // check that negative track from hyperon is different from daughter tracks of antiHyperon + if (hyperon.negTrackExtraId() == antiHyperon.bachTrackExtraId() || + hyperon.negTrackExtraId() == antiHyperon.posTrackExtraId() || + hyperon.negTrackExtraId() == antiHyperon.negTrackExtraId()) + return false; + } else { // v0 case + // check that positive track from hyperon is different from daughter tracks of antiHyperon + if (hyperon.posTrackExtraId() == antiHyperon.posTrackExtraId() || + hyperon.posTrackExtraId() == antiHyperon.negTrackExtraId()) + return false; + // check that negative track from hyperon is different from daughter tracks of antiHyperon + if (hyperon.negTrackExtraId() == antiHyperon.posTrackExtraId() || + hyperon.negTrackExtraId() == antiHyperon.negTrackExtraId()) + return false; + } + return true; + } + + template + void buildHyperonAntiHyperonPairs(TCollision const& collision, THyperons const& fullHyperons, std::vector selHypIndices, std::vector selAntiHypIndices, float centrality, uint8_t gapSide, int type) + { + // 1st loop over all v0s/cascades + for (auto& hyperon : fullHyperons) { + // select only v0s matching Lambda selections + if (!selHypIndices[hyperon.globalIndex() - fullHyperons.offset()]) { // local index needed due to collisions grouping + continue; + } + + // 2nd loop over all v0s/cascade + for (auto& antiHyperon : fullHyperons) { + // select only v0s matching Anti-Lambda selections + if (!selAntiHypIndices[antiHyperon.globalIndex() - fullHyperons.offset()]) { // local index needed due to collisions grouping + continue; + } + + // check we don't look at the same v0s/cascades + if (hyperon.globalIndex() == antiHyperon.globalIndex()) { + continue; + } + + // check that the two hyperons have different daughter tracks + if (!checkTrackIndices(hyperon, antiHyperon)) { + continue; + } + + // form V0 pairs and fill histograms + analyseHyperonPairCandidate(collision, hyperon, antiHyperon, centrality, gapSide, type); + } // end antiHyperon loop + } // end hyperon loop + + return; + } + + // ______________________________________________________ + // Real data processing - no MC subscription + void processRealData(soa::Join::iterator const& collision, v0Candidates const& fullV0s, cascadeCandidates const& fullCascades, dauTracks const&) + { + // Fire up CCDB + if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || + (mlConfigurations.useLambdaScores && mlConfigurations.calculateLambdaScores) || + (mlConfigurations.useAntiLambdaScores && mlConfigurations.calculateAntiLambdaScores)) { + initCCDB(collision); + } + + if (!IsEventAccepted(collision, true)) { + return; + } + + float centrality = -1; + int selGapSide = -1; // only useful in case one wants to use this task in Pb-Pb UPC + fillEventHistograms(collision, centrality, selGapSide); + + // __________________________________________ + // perform main analysis + // + if (buildLaLaBarPairs) { // Look at V0s + std::vector selK0ShortIndices(fullV0s.size()); + std::vector selLambdaIndices(fullV0s.size()); + std::vector selAntiLambdaIndices(fullV0s.size()); + for (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 + + 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); + + analyseV0Candidate(v0, v0.pt(), centrality, selMap, selK0ShortIndices, selLambdaIndices, selAntiLambdaIndices, fullV0s.offset()); + } // end v0 loop + + // count the number of K0s, Lambda and AntiLambdas passsing the selections + int nK0Shorts = std::count(selK0ShortIndices.begin(), selK0ShortIndices.end(), true); + int nLambdas = std::count(selLambdaIndices.begin(), selLambdaIndices.end(), true); + int nAntiLambdas = std::count(selAntiLambdaIndices.begin(), selAntiLambdaIndices.end(), true); + + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + histos.fill(HIST("LaLaBar/h2dNbrOfK0ShortVsCentrality"), centrality, nK0Shorts); + histos.fill(HIST("LaLaBar/h2dNbrOfLambdaVsCentrality"), centrality, nLambdas); + histos.fill(HIST("LaLaBar/h2dNbrOfAntiLambdaVsCentrality"), centrality, nAntiLambdas); + + // Check the number of Lambdas and antiLambdas + // needs at least 1 of each + if (nLambdas >= 1 && nAntiLambdas >= 1) { + buildHyperonAntiHyperonPairs(collision, fullV0s, selLambdaIndices, selAntiLambdaIndices, centrality, selGapSide, 0); + } + } + + if (buildXiXiBarPairs || buildOmOmBarPairs) { // Look at Cascades + std::vector selXiIndices(fullCascades.size()); + std::vector selAntiXiIndices(fullCascades.size()); + std::vector selOmIndices(fullCascades.size()); + std::vector selAntiOmIndices(fullCascades.size()); + for (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 (buildXiXiBarPairs) { + if (cascade.sign() < 0) { + selXiIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, cascade.yXi(), true); + } else { + selAntiXiIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, cascade.yXi(), true); + } + } + if (buildOmOmBarPairs) { + if (cascade.sign() < 0) { + selOmIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, cascade.yOmega(), false); + } else { + selAntiOmIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, cascade.yOmega(), false); + } + } + } // end cascade loop + + // count the number of Xi and antiXi passsing the selections + int nXis = std::count(selXiIndices.begin(), selXiIndices.end(), true); + int nAntiXis = std::count(selAntiXiIndices.begin(), selAntiXiIndices.end(), true); + int nOmegas = std::count(selOmIndices.begin(), selOmIndices.end(), true); + int nAntiOmegas = std::count(selAntiOmIndices.begin(), selAntiOmIndices.end(), true); + + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + if (buildXiXiBarPairs) { + histos.fill(HIST("XiXiBar/h2dNbrOfXiVsCentrality"), centrality, nXis); + histos.fill(HIST("XiXiBar/h2dNbrOfAntiXiVsCentrality"), centrality, nAntiXis); + + // Check the number of Lambdas and antiLambdas + // needs at least 1 of each + if (nXis >= 1 && nAntiXis >= 1) { + buildHyperonAntiHyperonPairs(collision, fullCascades, selXiIndices, selAntiXiIndices, centrality, selGapSide, 1); + } + } + if (buildOmOmBarPairs) { + histos.fill(HIST("OmOmBar/h2dNbrOfOmegaVsCentrality"), centrality, nOmegas); + histos.fill(HIST("OmOmBar/h2dNbrOfAntiOmegaVsCentrality"), centrality, nAntiOmegas); + + // Check the number of Lambdas and antiLambdas + // needs at least 1 of each + if (nOmegas >= 1 && nAntiOmegas >= 1) { + buildHyperonAntiHyperonPairs(collision, fullCascades, selOmIndices, selAntiOmIndices, centrality, selGapSide, 2); + } + } + } + } + + // ______________________________________________________ + // Simulated processing (subscribes to MC information too) + void processMonteCarlo(soa::Join::iterator const& collision, v0MCCandidates const& fullV0s, cascadeMCCandidates const& fullCascades, dauTracks const&, aod::MotherMCParts const&, soa::Join const& /*mccollisions*/, soa::Join const&, soa::Join const&) + { + // Fire up CCDB + if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || + (mlConfigurations.useLambdaScores && mlConfigurations.calculateLambdaScores) || + (mlConfigurations.useAntiLambdaScores && mlConfigurations.calculateAntiLambdaScores)) { + initCCDB(collision); + } + + if (!IsEventAccepted(collision, true)) { + return; + } + + float centrality = -1; + int selGapSide = -1; // only useful in case one wants to use this task in Pb-Pb UPC + fillEventHistograms(collision, centrality, selGapSide); + + // __________________________________________ + // perform main analysis + if (buildLaLaBarPairs) { // Look at V0s + std::vector selK0ShortIndices(fullV0s.size()); + std::vector selLambdaIndices(fullV0s.size()); + std::vector selAntiLambdaIndices(fullV0s.size()); + for (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.has_v0MCCore()) + continue; + + auto v0MC = v0.v0MCCore_as>(); + + float ptmc = RecoDecay::sqrtSumOfSquares(v0MC.pxPosMC() + v0MC.pxNegMC(), v0MC.pyPosMC() + v0MC.pyNegMC()); + 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) + 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); + selMap = selMap | computeMCAssociation(v0MC); + + // 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); + } + + analyseV0Candidate(v0, ptmc, centrality, selMap, selK0ShortIndices, selLambdaIndices, selAntiLambdaIndices, fullV0s.offset()); + } // end v0 loop + + /// count the number of K0s, Lambda and AntiLambdas passsing the selections + int nK0Shorts = std::count(selK0ShortIndices.begin(), selK0ShortIndices.end(), true); + int nLambdas = std::count(selLambdaIndices.begin(), selLambdaIndices.end(), true); + int nAntiLambdas = std::count(selAntiLambdaIndices.begin(), selAntiLambdaIndices.end(), true); + + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + histos.fill(HIST("LaLaBar/h2dNbrOfK0ShortVsCentrality"), centrality, nK0Shorts); + histos.fill(HIST("LaLaBar/h2dNbrOfLambdaVsCentrality"), centrality, nLambdas); + histos.fill(HIST("LaLaBar/h2dNbrOfAntiLambdaVsCentrality"), centrality, nAntiLambdas); + + if (nLambdas >= 1 && nAntiLambdas >= 1) { + buildHyperonAntiHyperonPairs(collision, fullV0s, selLambdaIndices, selAntiLambdaIndices, centrality, selGapSide, 0); + } + } + + if (buildXiXiBarPairs || buildOmOmBarPairs) { // Look at Cascades + std::vector selXiIndices(fullCascades.size()); + std::vector selAntiXiIndices(fullCascades.size()); + std::vector selOmIndices(fullCascades.size()); + std::vector selAntiOmIndices(fullCascades.size()); + for (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 (!cascade.has_cascMCCore()) + continue; + + auto cascadeMC = cascade.cascMCCore_as>(); + + // float ptmc = RecoDecay::sqrtSumOfSquares(cascadeMC.pxMC(), cascadeMC.pyMC()); + float ymc = 1e-3; + if (TMath::Abs(cascadeMC.pdgCode()) == 3312) + ymc = RecoDecay::y(std::array{cascadeMC.pxMC(), cascadeMC.pyMC(), cascadeMC.pzMC()}, o2::constants::physics::MassXiMinus); + else if (TMath::Abs(cascadeMC.pdgCode()) == 3334) + ymc = RecoDecay::y(std::array{cascadeMC.pxMC(), cascadeMC.pyMC(), cascadeMC.pzMC()}, o2::constants::physics::MassOmegaMinus); + + if (buildXiXiBarPairs) { + if (cascade.sign() < 0) { + selXiIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, ymc, true); + } else { + selAntiXiIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, ymc, true); + } + } + if (buildOmOmBarPairs) { + if (cascade.sign() < 0) { + selOmIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, ymc, false); + } else { + selAntiOmIndices[cascade.globalIndex() - fullCascades.offset()] = isCascadeSelected(cascade, collision, ymc, false); + } + } + } // end cascade loop + + // count the number of Xi and antiXi passsing the selections + int nXis = std::count(selXiIndices.begin(), selXiIndices.end(), true); + int nAntiXis = std::count(selAntiXiIndices.begin(), selAntiXiIndices.end(), true); + int nOmegas = std::count(selOmIndices.begin(), selOmIndices.end(), true); + int nAntiOmegas = std::count(selAntiOmIndices.begin(), selAntiOmIndices.end(), true); + + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + if (buildXiXiBarPairs) { + histos.fill(HIST("XiXiBar/h2dNbrOfXiVsCentrality"), centrality, nXis); + histos.fill(HIST("XiXiBar/h2dNbrOfAntiXiVsCentrality"), centrality, nAntiXis); + + // Check the number of Lambdas and antiLambdas + // needs at least 1 of each + if (nXis >= 1 && nAntiXis >= 1) { + buildHyperonAntiHyperonPairs(collision, fullCascades, selXiIndices, selAntiXiIndices, centrality, selGapSide, 1); + } + } + if (buildOmOmBarPairs) { + histos.fill(HIST("OmOmBar/h2dNbrOfOmegaVsCentrality"), centrality, nOmegas); + histos.fill(HIST("OmOmBar/h2dNbrOfAntiOmegaVsCentrality"), centrality, nAntiOmegas); + + // Check the number of Lambdas and antiLambdas + // needs at least 1 of each + if (nOmegas >= 1 && nAntiOmegas >= 1) { + buildHyperonAntiHyperonPairs(collision, fullCascades, selOmIndices, selAntiOmIndices, centrality, selGapSide, 2); + } + } + } + } + + PROCESS_SWITCH(quarkoniaToHyperons, processRealData, "process as if real data", true); + PROCESS_SWITCH(quarkoniaToHyperons, processMonteCarlo, "process as if MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGDQ/Tasks/tableReader.cxx b/PWGDQ/Tasks/tableReader.cxx index 1da0f5c6b55..b7bd4639aba 100644 --- a/PWGDQ/Tasks/tableReader.cxx +++ b/PWGDQ/Tasks/tableReader.cxx @@ -76,6 +76,29 @@ DECLARE_SOA_COLUMN(TauxyBcandidate, tauxyBcandidate, float); DECLARE_SOA_COLUMN(TauzBcandidate, tauzBcandidate, float); DECLARE_SOA_COLUMN(CosPBcandidate, cosPBcandidate, float); DECLARE_SOA_COLUMN(Chi2Bcandidate, chi2Bcandidate, float); + +// Xcandidate columns +DECLARE_SOA_COLUMN(massXcandidate, MXcandidate, float); +DECLARE_SOA_COLUMN(pTXcandidate, PtXcandidate, float); +DECLARE_SOA_COLUMN(rapidityXcandidate, YXcandidate, float); +DECLARE_SOA_COLUMN(etaXcandidate, EtaXcandidate, float); +DECLARE_SOA_COLUMN(massJpsicandidate, MJpsicandidate, float); +DECLARE_SOA_COLUMN(massDipioncandidate, MDipioncandidate, float); +DECLARE_SOA_COLUMN(pTJpsicandidate, PtJpsicandidate, float); +DECLARE_SOA_COLUMN(pTDipioncandidate, PtDipioncandidate, float); +DECLARE_SOA_COLUMN(massDiff, Q, float); +DECLARE_SOA_COLUMN(angDistPion1, DeltaR1, float); +DECLARE_SOA_COLUMN(angDistPion2, DeltaR2, float); +DECLARE_SOA_COLUMN(cosDileptonDipion, CosDileptonDipion, float); +DECLARE_SOA_COLUMN(dcaxyPion1, DcaXYPion1, float); +DECLARE_SOA_COLUMN(dcazPion1, DcaZPion1, float); +DECLARE_SOA_COLUMN(dcaxyPion2, DcaXYPion2, float); +DECLARE_SOA_COLUMN(dcazPion2, DcaZPion2, float); +DECLARE_SOA_COLUMN(pTPion1, PtPion1, float); +DECLARE_SOA_COLUMN(pTPion2, PtPion2, float); +DECLARE_SOA_COLUMN(dileptonSign, DileptonSign, int); +DECLARE_SOA_COLUMN(ditrackSign, DitrackSign, int); + } // namespace dqanalysisflags DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTS", dqanalysisflags::IsEventSelected); @@ -84,6 +107,7 @@ DECLARE_SOA_TABLE(BarrelTrackCuts, "AOD", "DQANATRKCUTS", dqanalysisflags::IsBar DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTS", dqanalysisflags::IsMuonSelected); DECLARE_SOA_TABLE(Prefilter, "AOD", "DQPREFILTER", dqanalysisflags::IsPrefilterVetoed); DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", dqanalysisflags::massBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate); +DECLARE_SOA_TABLE(XCandidates, "AOD", "DQX3872", dqanalysisflags::massXcandidate, dqanalysisflags::pTXcandidate, dqanalysisflags::rapidityXcandidate, dqanalysisflags::etaXcandidate, dqanalysisflags::massJpsicandidate, dqanalysisflags::massDipioncandidate, dqanalysisflags::pTJpsicandidate, dqanalysisflags::pTDipioncandidate, dqanalysisflags::massDiff, dqanalysisflags::angDistPion1, dqanalysisflags::angDistPion2, dqanalysisflags::cosDileptonDipion, dqanalysisflags::dcaxyPion1, dqanalysisflags::dcazPion1, dqanalysisflags::dcaxyPion2, dqanalysisflags::dcazPion2, dqanalysisflags::pTPion1, dqanalysisflags::pTPion2, dqanalysisflags::dileptonSign, dqanalysisflags::ditrackSign); } // namespace o2::aod // Declarations of various short names @@ -92,8 +116,8 @@ using MyEventsSelected = soa::Join; using MyEventsVtxCov = soa::Join; using MyEventsVtxCovSelected = soa::Join; +using MyEventsVtxCovSelectedMultExtra = soa::Join; using MyEventsVtxCovSelectedQvector = soa::Join; -using MyEventsVtxCovSelectedQvectorExtra = soa::Join; using MyEventsVtxCovSelectedQvectorExtraWithRefFlow = soa::Join; using MyEventsVtxCovSelectedQvectorCentr = soa::Join; using MyEventsQvector = soa::Join; @@ -123,11 +147,11 @@ using MyMftTracks = soa::Join; constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended; constexpr static uint32_t gkEventFillMapWithCov = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov; constexpr static uint32_t gkEventFillMapWithQvector = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventQvector; +constexpr static uint32_t gkEventFillMapWithMultExtra = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventMultExtra; constexpr static uint32_t gkEventFillMapWithQvectorMultExtra = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventQvector | VarManager::ObjTypes::ReducedEventMultExtra; constexpr static uint32_t gkEventFillMapWithQvectorCentr = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::CollisionQvect; 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 gkEventFillMapWithCovQvectorExtra = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::ReducedEventQvector | VarManager::ObjTypes::ReducedEventQvectorExtra; 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 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; @@ -153,6 +177,7 @@ struct AnalysisEventSelection { Configurable fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"}; Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; Configurable fConfigITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; Configurable fConfigITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; @@ -165,8 +190,12 @@ struct AnalysisEventSelection { Service fCCDB; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); @@ -222,13 +251,25 @@ struct AnalysisEventSelection { if (fConfigQA) { fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); // automatically fill all the histograms in the class Event } - if (fEventCut->IsSelected(VarManager::fgValues)) { - if (fConfigQA) { - fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + + if (!fConfigRunZorro) { + if (fEventCut->IsSelected(VarManager::fgValues)) { + if (fConfigQA) { + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + } + eventSel(1); + } else { + eventSel(0); } - eventSel(1); } else { - eventSel(0); + if (fEventCut->IsSelected(VarManager::fgValues) && event.tag_bit(56)) { // This is the bit used for the software trigger event selections [TO BE DONE: find a more clear way to use it] + if (fConfigQA) { + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + } + eventSel(1); + } else { + eventSel(0); + } } if (fMixHandler != nullptr) { @@ -297,8 +338,12 @@ struct AnalysisTrackSelection { int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; @@ -421,8 +466,12 @@ struct AnalysisMuonSelection { HistogramManager* fHistMan; std::vector fMuonCuts; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); @@ -515,8 +564,12 @@ struct AnalysisPrefilterSelection { std::map fPrefiltermap; AnalysisCompositeCut* fPairCut; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; ccdb->setURL(ccdburl.value); @@ -627,6 +680,10 @@ struct AnalysisEventMixing { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; ccdb->setURL(ccdburl.value); @@ -763,9 +820,9 @@ struct AnalysisEventMixing { } } } // end if (filter bits) - } // end for (cuts) - } // end for (track2) - } // end for (track1) + } // end for (cuts) + } // end for (track2) + } // end for (track1) } // barrel-barrel and muon-muon event mixing @@ -883,6 +940,7 @@ struct AnalysisSameEventPairing { Produces dimuonAllList; Produces dileptonFlowList; Produces dileptonInfoList; + Produces dileptonMiniTree; float mMagField = 0.0; o2::parameters::GRPMagField* grpmag = nullptr; o2::base::MatLayerCylSet* lut = nullptr; @@ -913,6 +971,13 @@ struct AnalysisSameEventPairing { Configurable fCollisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable fCenterMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; + // Configurables to create output tree (flat tables or minitree) + 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; + Service ccdb; Filter filterEventSelected = aod::dqanalysisflags::isEventSelected == 1; // NOTE: the barrel filter map contains decisions for both electrons and hadrons used in the correlation task @@ -934,6 +999,10 @@ struct AnalysisSameEventPairing { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; ccdb->setURL(ccdburl.value); @@ -997,12 +1066,12 @@ struct AnalysisSameEventPairing { } fTrackHistNames.push_back(names); } // end loop (pair cuts) - } // end if (pair cuts) - } // end loop (track cuts) - } // end if (track cuts) + } // end if (pair cuts) + } // end loop (track cuts) + } // end if (track cuts) } - if (context.mOptions.get("processDecayToMuMuSkimmed") || context.mOptions.get("processDecayToMuMuVertexingSkimmed") || context.mOptions.get("processDecayToMuMuSkimmedWithColl") || context.mOptions.get("processVnDecayToMuMuSkimmed") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeights") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeightsAndColl") || context.mOptions.get("processVnCentrDecayToMuMuSkimmed") || context.mOptions.get("processAllSkimmed")) { + if (context.mOptions.get("processDecayToMuMuSkimmed") || context.mOptions.get("processDecayToMuMuSkimmedWithMult") || context.mOptions.get("processDecayToMuMuVertexingSkimmed") || context.mOptions.get("processDecayToMuMuSkimmedWithColl") || context.mOptions.get("processVnDecayToMuMuSkimmed") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeights") || context.mOptions.get("processVnDecayToMuMuSkimmedWithWeightsAndColl") || context.mOptions.get("processVnCentrDecayToMuMuSkimmed") || context.mOptions.get("processAllSkimmed")) { TString cutNames = fConfigMuonCuts.value; if (!cutNames.IsNull()) { std::unique_ptr objArray(cutNames.Tokenize(",")); @@ -1031,9 +1100,9 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fMuonHistNames.push_back(names); } // end loop (pair cuts) - } // end if (pair cuts) - } // end loop (track cuts) - } // end if (track cuts) + } // end if (pair cuts) + } // end loop (track cuts) + } // end if (track cuts) } if (context.mOptions.get("processElectronMuonSkimmed") || context.mOptions.get("processAllSkimmed")) { TString cutNamesBarrel = fConfigTrackCuts.value; @@ -1064,10 +1133,10 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackMuonHistNames.push_back(names); } // end loop (pair cuts) - } // end if (pair cuts) - } // end loop (track cuts) - } // end if (equal number of cuts) - } // end if (track cuts) + } // end if (pair cuts) + } // end loop (track cuts) + } // end if (equal number of cuts) + } // end if (track cuts) } // Usage example of ccdb @@ -1145,6 +1214,9 @@ struct AnalysisSameEventPairing { dielectronAllList.reserve(1); dimuonAllList.reserve(1); } + if (useMiniTree.fConfigMiniTree) { + dileptonMiniTree.reserve(1); + } if (fConfigMultDimuons.value) { @@ -1205,8 +1277,8 @@ struct AnalysisSameEventPairing { if constexpr ((TPairType == pairTypeEE) && (TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) { if (fConfigFlatTables.value) { dielectronAllList(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), dileptonFilterMap, dileptonMcDecision, - t1.pt(), t1.eta(), t1.phi(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), - t2.pt(), t2.eta(), t2.phi(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), + t1.pt(), t1.eta(), t1.phi(), t1.itsClusterMap(), t1.itsChi2NCl(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), + t2.pt(), t2.eta(), t2.phi(), t2.itsClusterMap(), t2.itsChi2NCl(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), VarManager::fgValues[VarManager::kKFTrack0DCAxyz], VarManager::fgValues[VarManager::kKFTrack1DCAxyz], VarManager::fgValues[VarManager::kKFDCAxyzBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DCAxy], VarManager::fgValues[VarManager::kKFTrack1DCAxy], VarManager::fgValues[VarManager::kKFDCAxyBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack0DeviationxyFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationxyFromPV], VarManager::fgValues[VarManager::kKFMass], VarManager::fgValues[VarManager::kKFChi2OverNDFGeo], VarManager::fgValues[VarManager::kVertexingLxyz], VarManager::fgValues[VarManager::kVertexingLxyzOverErr], VarManager::fgValues[VarManager::kVertexingLxy], VarManager::fgValues[VarManager::kVertexingLxyOverErr], VarManager::fgValues[VarManager::kVertexingTauxy], VarManager::fgValues[VarManager::kVertexingTauxyErr], VarManager::fgValues[VarManager::kKFCosPA], VarManager::fgValues[VarManager::kKFJpsiDCAxyz], VarManager::fgValues[VarManager::kKFJpsiDCAxy], @@ -1252,24 +1324,24 @@ struct AnalysisSameEventPairing { 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::kCORR4POI], VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], VarManager::fgValues[VarManager::kMultDimuons], + 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]); } auto collId = 0; if constexpr ((TTrackFillMap & VarManager::ObjTypes::ReducedMuonCollInfo) > 0) { collId = t1.collisionId(); } - if constexpr (eventHasQvector == true || eventHasQvectorCentr == true) { - dileptonFlowList(collId, VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kCentFT0C], - VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), isFirst, - VarManager::fgValues[VarManager::kU2Q2], VarManager::fgValues[VarManager::kR2SP_AB], VarManager::fgValues[VarManager::kR2SP_AC], VarManager::fgValues[VarManager::kR2SP_BC], - VarManager::fgValues[VarManager::kU3Q3], VarManager::fgValues[VarManager::kR3SP], - VarManager::fgValues[VarManager::kCos2DeltaPhi], VarManager::fgValues[VarManager::kR2EP_AB], VarManager::fgValues[VarManager::kR2EP_AC], VarManager::fgValues[VarManager::kR2EP_BC], - VarManager::fgValues[VarManager::kCos3DeltaPhi], VarManager::fgValues[VarManager::kR3EP], - VarManager::fgValues[VarManager::kCORR4POI], VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], - VarManager::fgValues[VarManager::kCORR2REF], VarManager::fgValues[VarManager::kCORR4REF], VarManager::fgValues[VarManager::kM11REF], VarManager::fgValues[VarManager::kM1111REF], - VarManager::fgValues[VarManager::kMultDimuons], VarManager::fgValues[VarManager::kMultA]); - } + if constexpr (eventHasQvector == true || eventHasQvectorCentr == true) { + dileptonFlowList(collId, VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kCentFT0C], + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), isFirst, + VarManager::fgValues[VarManager::kU2Q2], VarManager::fgValues[VarManager::kR2SP_AB], VarManager::fgValues[VarManager::kR2SP_AC], VarManager::fgValues[VarManager::kR2SP_BC], + VarManager::fgValues[VarManager::kU3Q3], VarManager::fgValues[VarManager::kR3SP], + VarManager::fgValues[VarManager::kCos2DeltaPhi], VarManager::fgValues[VarManager::kR2EP_AB], VarManager::fgValues[VarManager::kR2EP_AC], VarManager::fgValues[VarManager::kR2EP_BC], + VarManager::fgValues[VarManager::kCos3DeltaPhi], VarManager::fgValues[VarManager::kR3EP], + VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kCORR4POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], + VarManager::fgValues[VarManager::kCORR2REF], VarManager::fgValues[VarManager::kCORR4REF], VarManager::fgValues[VarManager::kM11REF], VarManager::fgValues[VarManager::kM1111REF], + VarManager::fgValues[VarManager::kMultDimuons], VarManager::fgValues[VarManager::kMultA]); + } if (t1.sign() != t2.sign()) { isFirst = false; } @@ -1283,6 +1355,16 @@ struct AnalysisSameEventPairing { if (fConfigAmbiguousHist && !(t1.isAmbiguous() || t2.isAmbiguous())) { fHistMan->FillHistClass(Form("%s_unambiguous", histNames[iCut][0].Data()), VarManager::fgValues); } + if (useMiniTree.fConfigMiniTree) { + 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]); + } + } } else { if (t1.sign() > 0) { fHistMan->FillHistClass(histNames[iCut][1].Data(), VarManager::fgValues); @@ -1319,12 +1401,12 @@ struct AnalysisSameEventPairing { } } } - } // end loop (pair cuts) + } // end loop (pair cuts) } else { // end if (filter bits) iCut = iCut + 1 + fPairCuts.size(); } } // end loop (cuts) - } // end loop over pairs + } // end loop over pairs } void processDecayToEESkimmed(soa::Filtered::iterator const& event, soa::Filtered const& tracks) @@ -1397,6 +1479,13 @@ struct AnalysisSameEventPairing { VarManager::FillEvent(event, VarManager::fgValues); runSameEventPairing(event, muons, muons); } + void processDecayToMuMuSkimmedWithMult(soa::Filtered::iterator const& event, soa::Filtered const& muons) + { + // Reset the fValues array + VarManager::ResetValues(0, VarManager::kNVars); + VarManager::FillEvent(event, VarManager::fgValues); + runSameEventPairing(event, muons, muons); + } void processDecayToMuMuVertexingSkimmed(soa::Filtered::iterator const& event, soa::Filtered const& muons) { // Reset the fValues array @@ -1425,12 +1514,12 @@ struct AnalysisSameEventPairing { VarManager::FillEvent(event, VarManager::fgValues); runSameEventPairing(event, muons, muons); } - void processVnDecayToMuMuSkimmedWithWeights(soa::Filtered::iterator const& event, soa::Filtered const& muons) + void processVnDecayToMuMuSkimmedWithWeights(soa::Filtered::iterator const& event, soa::Filtered const& muons) { // Reset the fValues array VarManager::ResetValues(0, VarManager::kNVars); - VarManager::FillEvent(event, VarManager::fgValues); - runSameEventPairing(event, muons, muons); + VarManager::FillEvent(event, VarManager::fgValues); + runSameEventPairing(event, muons, muons); } void processVnDecayToMuMuSkimmedWithWeightsAndColl(soa::Filtered::iterator const& event, soa::Filtered const& muons) @@ -1487,6 +1576,7 @@ struct AnalysisSameEventPairing { PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedWithColl, "Run electron-electron pairing, with skimmed tracks and with collision information", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToEESkimmedWithCollNoTwoProngFitter, "Run electron-electron pairing, with skimmed tracks and with collision information but no two prong fitter", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToMuMuSkimmed, "Run muon-muon pairing, with skimmed muons", false); + PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToMuMuSkimmedWithMult, "Run muon-muon pairing, with skimmed muons and multiplicity", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToMuMuVertexingSkimmed, "Run muon-muon pairing and vertexing, with skimmed muons", false); PROCESS_SWITCH(AnalysisSameEventPairing, processDecayToMuMuSkimmedWithColl, "Run muon-muon pairing keeping the info of AO2D collision, with skimmed muons", false); PROCESS_SWITCH(AnalysisSameEventPairing, processVnDecayToEESkimmed, "Run electron-electron pairing, with skimmed tracks for vn", false); @@ -1500,61 +1590,6 @@ struct AnalysisSameEventPairing { PROCESS_SWITCH(AnalysisSameEventPairing, processDummy, "Dummy function, enabled only if none of the others are enabled", false); }; -struct AnalysisFwdTrackPid { - Produces fwdPidAllList; - - Filter filterEventSelected = aod::dqanalysisflags::isEventSelected == 1; - - Configurable fConfigMaxDCA{"cfgMaxDCA", 0.5f, "Manually set maximum DCA of the track"}; - - void init(o2::framework::InitContext&) - { - } - - // Template function to pair mft tracks and muon tracks - template - void runFwdTrackPid(TEvent const& event, Muons const& muons, MftTracks const& mftTracks) - { - 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()); - } - } - if constexpr (TMatchedOnly == false) { - for (const auto& mftTrack : mftTracks) { - 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); - } - } - } - } - - void processFwdPidMatchedSkimmed(soa::Filtered::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) - { - if (muons.size() > 0 && mftTracks.size() > 0) { - runFwdTrackPid(event, muons, mftTracks); - } - } - - void processFwdPidMatchedOnlySkimmed(soa::Filtered::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) - { - if (muons.size() > 0) { - runFwdTrackPid(event, muons, mftTracks); - } - } - - void processDummy(MyEvents&) - { - // do nothing - } - - PROCESS_SWITCH(AnalysisFwdTrackPid, processFwdPidMatchedSkimmed, "Run MFT - muon track pairing filling tree with MFT and global tracks", false); - PROCESS_SWITCH(AnalysisFwdTrackPid, processFwdPidMatchedOnlySkimmed, "Run MFT - muon track pairing filling tree with global tracks only", false); - PROCESS_SWITCH(AnalysisFwdTrackPid, processDummy, "Dummy function", false); -}; - struct AnalysisDileptonHadron { // // This task combines dilepton candidates with a track and could be used for example @@ -1607,6 +1642,10 @@ struct AnalysisDileptonHadron { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; fValuesDilepton = new float[VarManager::kNVars]; fValuesHadron = new float[VarManager::kNVars]; @@ -1765,7 +1804,7 @@ struct AnalysisDileptonHadron { fHistMan->FillHistClass("DileptonHadronInvMassME", VarManager::fgValues); fHistMan->FillHistClass("DileptonHadronCorrelationME", VarManager::fgValues); } // end for (track) - } // end for (dilepton) + } // end for (dilepton) } // end event loop } @@ -1783,13 +1822,15 @@ struct AnalysisDileptonHadron { struct AnalysisDileptonTrackTrack { OutputObj fOutputList{"output"}; - Configurable fConfigTrackCuts{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"}; // used for select the tracks from SelectedTracks - Configurable fConfigDileptonCut{"cfgDiLeptonCut", "pairJpsi", "Dilepton cut"}; - Configurable fConfigDitrackCut{"cfgDiTrackCut", "pairNoCut", "Track-Track cut"}; - Configurable fConfigQuadrupletCut{"cfgQuadrupletCut", "pairNoCut", "Dilepton-Track-Track cut"}; - Configurable fConfigAddDileptonHistogram{"cfgAddDileptonHistogram", "berral", "Comma separated list of histograms"}; - Configurable fConfigAddDitrackHistogram{"cfgAddDitrackHistogram", "berral", "Comma separated list of histograms"}; - Configurable fConfigAddQuadrupletHistogram{"cfgAddQuadrupletHistogram", "XtoJpsipipi", "Comma separated list of histograms"}; + Configurable fConfigTrackCuts{"cfgTrackCuts", "pionPIDCut1", "Comma separated list of barrel track cuts"}; // used for select the tracks from SelectedTracks + Configurable fConfigDileptonCut{"cfgDiLeptonCut", "pairJpsi2", "Dilepton cut"}; + Configurable fConfigDitrackCut{"cfgDiTrackCut", "DipionPairCut1", "Track-Track cut"}; + Configurable fConfigQuadrupletCut{"cfgQuadrupletCut", "pairX3872Cut1", "Dilepton-Track-Track cut"}; + Configurable fConfigAddDileptonHistogram{"cfgAddDileptonHistogram", "barrel", "Comma separated list of histograms"}; + Configurable fConfigAddDitrackHistogram{"cfgAddDitrackHistogram", "barrel", "Comma separated list of histograms"}; + Configurable fConfigAddQuadrupletHistogram{"cfgAddQuadrupletHistogram", "xtojpsipipi", "Comma separated list of histograms"}; + + Produces XTable; Filter eventFilter = aod::dqanalysisflags::isEventSelected == 1; Filter dileptonFilter = aod::reducedpair::mass > 1.0f && aod::reducedpair::mass < 4.0f; @@ -1813,6 +1854,10 @@ struct AnalysisDileptonTrackTrack { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fValuesDitrack = new float[VarManager::kNVars]; fValuesQuadruplet = new float[VarManager::kNVars]; VarManager::SetDefaultVarNames(); @@ -1919,6 +1964,7 @@ struct AnalysisDileptonTrackTrack { if (t1.isBarrelSelected() & (uint32_t(1) << (iTrackCut + 1)) && t2.isBarrelSelected() & (uint32_t(1) << (iTrackCut + 1))) { fHistMan->FillHistClass(Form("DitrackSelected_%s_%s", fDitrackCut.GetName(), (*cutname).Data()), fValuesDitrack); if (fQuadrupletCut.IsSelected(fValuesQuadruplet)) { + XTable(fValuesQuadruplet[VarManager::kQuadMass], fValuesQuadruplet[VarManager::kQuadPt], fValuesQuadruplet[VarManager::kRap], fValuesQuadruplet[VarManager::kQuadEta], fValuesQuadruplet[VarManager::kPairMass], fValuesQuadruplet[VarManager::kDitrackMass], fValuesQuadruplet[VarManager::kPairPt], fValuesQuadruplet[VarManager::kDitrackPt], fValuesQuadruplet[VarManager::kQ], fValuesQuadruplet[VarManager::kDeltaR1], fValuesQuadruplet[VarManager::kDeltaR2], fValuesQuadruplet[VarManager::kCosthetaDileptonDitrack], fValuesQuadruplet[VarManager::kTrackDCAxyProng1], fValuesQuadruplet[VarManager::kTrackDCAzProng1], fValuesQuadruplet[VarManager::kTrackDCAxyProng2], fValuesQuadruplet[VarManager::kTrackDCAzProng2], fValuesQuadruplet[VarManager::kPt1], fValuesQuadruplet[VarManager::kPt2], dilepton.sign(), t1.sign() + t2.sign()); if (fIsUnlikeSignDilepton) { if (fIsUnlikeSignDitrack) { fHistMan->FillHistClass(Form("QuadrupletSEUSUS_%s_%s_%s", fDileptonCut.GetName(), fDitrackCut.GetName(), (*cutname).Data()), fValuesQuadruplet); @@ -1934,8 +1980,8 @@ struct AnalysisDileptonTrackTrack { } } } - } // check if the diTrack cut is selected - } // loop over hadron cuts + } // check if the Ditrack cut is selected + } // loop over hadron cuts } } } @@ -1963,7 +2009,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc), adaptAnalysisTask(cfgc)}; } diff --git a/PWGDQ/Tasks/tableReader_withAssoc.cxx b/PWGDQ/Tasks/tableReader_withAssoc.cxx index d15f58b6161..e38e03d054a 100644 --- a/PWGDQ/Tasks/tableReader_withAssoc.cxx +++ b/PWGDQ/Tasks/tableReader_withAssoc.cxx @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -70,6 +71,8 @@ DECLARE_SOA_BITMAP_COLUMN(IsBarrelSelected, isBarrelSelected, 32); DECLARE_SOA_COLUMN(BarrelAmbiguityInBunch, barrelAmbiguityInBunch, int8_t); //! Barrel track in-bunch ambiguity DECLARE_SOA_COLUMN(BarrelAmbiguityOutOfBunch, barrelAmbiguityOutOfBunch, int8_t); //! Barrel track out of bunch ambiguity DECLARE_SOA_BITMAP_COLUMN(IsMuonSelected, isMuonSelected, 32); //! Muon track decisions (joinable to ReducedMuonsAssoc) +DECLARE_SOA_COLUMN(MuonAmbiguityInBunch, muonAmbiguityInBunch, int8_t); //! Muon track in-bunch ambiguity +DECLARE_SOA_COLUMN(MuonAmbiguityOutOfBunch, muonAmbiguityOutOfBunch, int8_t); //! Muon track out of bunch ambiguity 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); @@ -88,14 +91,17 @@ DECLARE_SOA_TABLE(MixingHashes, "AOD", "DQANAMIXHASH", dqanalysisflags::MixingHa DECLARE_SOA_TABLE(BarrelTrackCuts, "AOD", "DQANATRKCUTS", dqanalysisflags::IsBarrelSelected); //! joinable to ReducedTracksAssoc DECLARE_SOA_TABLE(BarrelAmbiguities, "AOD", "DQBARRELAMB", dqanalysisflags::BarrelAmbiguityInBunch, dqanalysisflags::BarrelAmbiguityOutOfBunch); //! joinable to ReducedBarrelTracks 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::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate); } // namespace o2::aod // Declarations of various short names using MyEvents = soa::Join; +using MyEventsMultExtra = soa::Join; using MyEventsZdc = soa::Join; using MyEventsSelected = soa::Join; +using MyEventsMultExtraSelected = soa::Join; using MyEventsHashSelected = soa::Join; using MyEventsVtxCov = soa::Join; using MyEventsVtxCovSelected = soa::Join; @@ -114,6 +120,7 @@ using MyDitrackCandidates = soa::Join; using MyDimuonCandidates = soa::Join; using MyMuonTracks = soa::Join; using MyMuonTracksWithCov = soa::Join; +using MyMuonTracksWithCovWithAmbiguities = soa::Join; using MyMuonTracksSelectedWithColl = soa::Join; // bit maps used for the Fill functions of the VarManager @@ -121,6 +128,7 @@ constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | constexpr static uint32_t gkEventFillMapWithZdc = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedZdc; constexpr static uint32_t gkEventFillMapWithCov = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov; constexpr static uint32_t gkEventFillMapWithCovZdc = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ReducedZdc; +constexpr static uint32_t gkEventFillMapWithMultExtra = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventMultExtra; // constexpr static uint32_t gkEventFillMapWithQvector = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventQvector; // constexpr static uint32_t gkEventFillMapWithCovQvector = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended | VarManager::ObjTypes::ReducedEventVtxCov | VarManager::ObjTypes::ReducedEventQvector; constexpr static uint32_t gkTrackFillMap = VarManager::ObjTypes::ReducedTrack | VarManager::ObjTypes::ReducedTrackBarrel | VarManager::ObjTypes::ReducedTrackBarrelPID; @@ -157,6 +165,7 @@ struct AnalysisEventSelection { Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; Configurable fConfigITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"}; Configurable fConfigITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"}; + Configurable fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro [WARNING: under debug, do not enable!]"}; 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"}; @@ -169,11 +178,14 @@ struct AnalysisEventSelection { std::map fSelMap; // key: reduced event global index, value: event selection decision std::map> fBCCollMap; // key: global BC, value: vector of reduced event global indices - std::map fMetadataRCT, fHeader; int fCurrentRun; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fEventCut = new AnalysisCompositeCut(true); TString eventCutStr = fConfigEventCuts.value; fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data())); @@ -209,18 +221,20 @@ struct AnalysisEventSelection { void runEventSelection(TEvents const& events) { if (events.size() > 0 && events.begin().runNumber() != fCurrentRun) { - fHeader = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", events.begin().runNumber()), fMetadataRCT, -1); - uint64_t sor = std::atol(fHeader["SOR"].c_str()); - uint64_t eor = std::atol(fHeader["EOR"].c_str()); - LOGP(debug, "=========================== SOR / EOR is {} / {}", sor, eor); - // cout << "=========================== SOR / EOR is " << sor << " / " << eor << endl; + std::map metadataRCT, header; + header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", events.begin().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); + LOG(info) << "============================= SOR / EOR :: " << sor << " / " << eor; + auto alppar = fCCDB->getForTimeStamp>("ITS/Config/AlpideParam", events.begin().timestamp()); EventSelectionParams* par = fCCDB->getForTimeStamp("EventSelection/EventSelectionParams", events.begin().timestamp()); int itsROFrameStartBorderMargin = fConfigITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : fConfigITSROFrameStartBorderMargin; int itsROFrameEndBorderMargin = fConfigITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : fConfigITSROFrameEndBorderMargin; VarManager::SetITSROFBorderselection(alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); LOGP(debug, "==============++++++++++++========== roBias / roLength / start / end :: {} / {} / {} / {}", alppar->roFrameBiasInBC, alppar->roFrameLengthInBC, itsROFrameStartBorderMargin, itsROFrameEndBorderMargin); - // cout << "==============++++++++++++========== roBias / roLength / start / end :: " << alppar->roFrameBiasInBC << " / " << alppar->roFrameLengthInBC << " / " << itsROFrameStartBorderMargin << " / " << itsROFrameEndBorderMargin << endl; + fCurrentRun = events.begin().runNumber(); } @@ -235,8 +249,15 @@ struct AnalysisEventSelection { bool decision = false; fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); // automatically fill all the histograms in the class Event if (fEventCut->IsSelected(VarManager::fgValues)) { - fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); - decision = true; + if (fConfigRunZorro) { + if (event.tag_bit(56)) { // This is the bit used for the software trigger event selections [TO BE DONE: find a more clear way to use it] + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + decision = true; + } + } else { + fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + decision = true; + } } fSelMap[event.globalIndex()] = decision; if (fBCCollMap.find(event.globalBC()) == fBCCollMap.end()) { @@ -315,6 +336,11 @@ struct AnalysisEventSelection { runEventSelection(events); publishSelections(events); } + void processSkimmedWithMultExtra(MyEventsMultExtra const& events) + { + runEventSelection(events); + publishSelections(events); + } void processDummy(MyEvents&) { // do nothing @@ -322,6 +348,7 @@ 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, processDummy, "Dummy function", false); }; @@ -342,21 +369,27 @@ struct AnalysisTrackSelection { 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"}; Service fCCDB; + o2::ccdb::CcdbApi fCCDBApi; HistogramManager* fHistMan; std::vector fTrackCuts; - int fCurrentRun; // current run (needed to detect run changes for loading CCDB parameters) + int fCurrentRun; // current run kept to detect run changes and trigger loading params from CCDB std::map> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting) std::map> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup) - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& context) { - fCurrentRun = 0; + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { std::unique_ptr objArray(cutNamesStr.Tokenize(",")); @@ -393,6 +426,7 @@ struct AnalysisTrackSelection { fCCDB->setLocalObjectValidityChecking(); fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value); } + fCCDBApi.init(fConfigCcdbUrl.value); } template @@ -401,14 +435,16 @@ struct AnalysisTrackSelection { fNAssocsInBunch.clear(); fNAssocsOutOfBunch.clear(); - if (fConfigComputeTPCpostCalib && events.size() > 0 && fCurrentRun != events.begin().runNumber()) { - auto calibList = fCCDB->getForTimeStamp(fConfigCcdbPathTPC.value, events.begin().timestamp()); - VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); - VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron")); - VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion")); - VarManager::SetCalibrationObject(VarManager::kTPCPionSigma, calibList->FindObject("sigma_map_pion")); - VarManager::SetCalibrationObject(VarManager::kTPCProtonMean, calibList->FindObject("mean_map_proton")); - VarManager::SetCalibrationObject(VarManager::kTPCProtonSigma, calibList->FindObject("sigma_map_proton")); + if (events.size() > 0 && fCurrentRun != events.begin().runNumber()) { + if (fConfigComputeTPCpostCalib) { + auto calibList = fCCDB->getForTimeStamp(fConfigCcdbPathTPC.value, events.begin().timestamp()); + VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron")); + VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron")); + VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion")); + VarManager::SetCalibrationObject(VarManager::kTPCPionSigma, calibList->FindObject("sigma_map_pion")); + VarManager::SetCalibrationObject(VarManager::kTPCProtonMean, calibList->FindObject("mean_map_proton")); + VarManager::SetCalibrationObject(VarManager::kTPCProtonSigma, calibList->FindObject("sigma_map_proton")); + } o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp(grpmagPath, events.begin().timestamp()); if (grpmag != nullptr) { @@ -417,6 +453,12 @@ struct AnalysisTrackSelection { LOGF(fatal, "GRP object is not available in CCDB at timestamp=%llu", events.begin().timestamp()); } + std::map metadataRCT, header; + header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", events.begin().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); + fCurrentRun = events.begin().runNumber(); } @@ -439,7 +481,9 @@ struct AnalysisTrackSelection { filterMap = 0; VarManager::FillTrack(track); // compute quantities which depend on the associated collision, such as DCA - VarManager::FillTrackCollision(track, event); + if (fPropTrack) { + VarManager::FillTrackCollision(track, event); + } if (fConfigQA) { fHistMan->FillHistClass("TrackBarrel_BeforeCuts", VarManager::fgValues); } @@ -519,6 +563,10 @@ struct AnalysisTrackSelection { { runTrackSelection(assocs, events, tracks); } + void processSkimmedWithMultExtra(ReducedTracksAssoc const& assocs, MyEventsMultExtraSelected const& events, MyBarrelTracks const& tracks) + { + runTrackSelection(assocs, events, tracks); + } void processSkimmedWithCov(ReducedTracksAssoc const& assocs, MyEventsVtxCovSelected const& events, MyBarrelTracksWithCov const& tracks) { runTrackSelection(assocs, events, tracks); @@ -529,6 +577,7 @@ struct AnalysisTrackSelection { } PROCESS_SWITCH(AnalysisTrackSelection, processSkimmed, "Run barrel track selection on DQ skimmed track associations", false); + PROCESS_SWITCH(AnalysisTrackSelection, processSkimmedWithMultExtra, "Run barrel track selection on DQ skimmed track associations, with extra multiplicity tables", false); PROCESS_SWITCH(AnalysisTrackSelection, processSkimmedWithCov, "Run barrel track selection on DQ skimmed tracks w/ cov matrix associations", false); PROCESS_SWITCH(AnalysisTrackSelection, processDummy, "Dummy function", false); }; @@ -537,6 +586,7 @@ struct AnalysisTrackSelection { // Here one should add all the track cuts needed through the workflow (e.g. cuts for same-event pairing, track for dilepton-track correlations) struct AnalysisMuonSelection { Produces muonSel; + Produces muonAmbiguities; OutputObj fOutputList{"output"}; Configurable fConfigCuts{"cfgMuonCuts", "muonQualityCuts", "Comma separated list of muon cuts"}; @@ -554,8 +604,15 @@ struct AnalysisMuonSelection { int fCurrentRun; // current run kept to detect run changes and trigger loading params from CCDB - void init(o2::framework::InitContext&) + std::map> fNAssocsInBunch; // key: muon global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting) + std::map> fNAssocsOutOfBunch; // key: muon global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup) + + void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + fCurrentRun = 0; TString cutNamesStr = fConfigCuts.value; if (!cutNamesStr.IsNull()) { @@ -577,6 +634,7 @@ struct AnalysisMuonSelection { for (auto& cut : fMuonCuts) { histDirNames += Form("TrackMuon_%s;", cut.GetName()); } + histDirNames += "TrackMuon_AmbiguityInBunch;TrackMuon_AmbiguityOutOfBunch;"; DefineHistograms(fHistMan, histDirNames.Data(), fConfigAddMuonHistogram.value.data()); // define all histograms VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill @@ -593,8 +651,11 @@ struct AnalysisMuonSelection { } template - void runMuonSelection(ReducedMuonsAssoc const& assocs, TEvents const& events, TMuons const& /*muons*/) + void runMuonSelection(ReducedMuonsAssoc const& assocs, TEvents const& events, TMuons const& muons) { + fNAssocsInBunch.clear(); + fNAssocsOutOfBunch.clear(); + if (events.size() > 0 && fCurrentRun != events.begin().runNumber()) { o2::parameters::GRPMagField* grpmag = fCCDB->getForTimeStamp(grpmagPath, events.begin().timestamp()); if (grpmag != nullptr) { @@ -607,6 +668,7 @@ struct AnalysisMuonSelection { } muonSel.reserve(assocs.size()); + muonAmbiguities.reserve(muons.size()); uint32_t filterMap = 0; int iCut = 0; @@ -616,15 +678,13 @@ struct AnalysisMuonSelection { muonSel(0); continue; } - VarManager::ResetValues(0, VarManager::kNBarrelTrackVariables); + VarManager::ResetValues(0, VarManager::kNMuonTrackVariables); // fill event information which might be needed in histograms/cuts that combine track and event properties VarManager::FillEvent(event); auto track = assoc.template reducedmuon_as(); filterMap = 0; VarManager::FillTrack(track); - // compute quantities which depend on the associated collision - VarManager::FillPropagateMuon(track, event); if (fConfigQA) { fHistMan->FillHistClass("TrackMuon_BeforeCuts", VarManager::fgValues); } @@ -638,7 +698,66 @@ struct AnalysisMuonSelection { } } // end loop over cuts muonSel(filterMap); + + // count the number of associations per track + if (filterMap > 0) { + if (event.isEventSelected_bit(1)) { + if (fNAssocsInBunch.find(track.globalIndex()) == fNAssocsInBunch.end()) { + std::vector evVector = {event.globalIndex()}; + fNAssocsInBunch[track.globalIndex()] = evVector; + } else { + auto& evVector = fNAssocsInBunch[track.globalIndex()]; + evVector.push_back(event.globalIndex()); + } + } else { + if (fNAssocsOutOfBunch.find(track.globalIndex()) == fNAssocsOutOfBunch.end()) { + std::vector evVector = {event.globalIndex()}; + fNAssocsOutOfBunch[track.globalIndex()] = evVector; + } else { + auto& evVector = fNAssocsOutOfBunch[track.globalIndex()]; + evVector.push_back(event.globalIndex()); + } + } + } } // end loop over assocs + + // QA the collision-track associations + if (fConfigQA) { + for (auto& [trackIdx, evIndices] : fNAssocsInBunch) { + if (evIndices.size() == 1) { + continue; + } + auto track = muons.rawIteratorAt(trackIdx); + VarManager::ResetValues(0, VarManager::kNMuonTrackVariables); + VarManager::FillTrack(track); + VarManager::fgValues[VarManager::kMuonNAssocsInBunch] = static_cast(evIndices.size()); + fHistMan->FillHistClass("TrackMuon_AmbiguityInBunch", VarManager::fgValues); + } // end loop over in-bunch ambiguous tracks + + for (auto& [trackIdx, evIndices] : fNAssocsOutOfBunch) { + if (evIndices.size() == 1) { + continue; + } + auto track = muons.rawIteratorAt(trackIdx); + VarManager::ResetValues(0, VarManager::kNMuonTrackVariables); + VarManager::FillTrack(track); + VarManager::fgValues[VarManager::kMuonNAssocsOutOfBunch] = static_cast(evIndices.size()); + fHistMan->FillHistClass("TrackMuon_AmbiguityOutOfBunch", VarManager::fgValues); + } // end loop over out-of-bunch ambiguous tracks + } + + // publish the ambiguity table + for (auto& track : muons) { + int8_t nInBunch = 0; + if (fNAssocsInBunch.find(track.globalIndex()) != fNAssocsInBunch.end()) { + nInBunch = fNAssocsInBunch[track.globalIndex()].size(); + } + int8_t nOutOfBunch = 0; + if (fNAssocsOutOfBunch.find(track.globalIndex()) != fNAssocsOutOfBunch.end()) { + nOutOfBunch = fNAssocsOutOfBunch[track.globalIndex()].size(); + } + muonAmbiguities(nInBunch, nOutOfBunch); + } } void processSkimmed(ReducedMuonsAssoc const& assocs, MyEventsVtxCovSelected const& events, MyMuonTracksWithCov const& muons) @@ -673,12 +792,12 @@ struct AnalysisPrefilterSelection { Preslice trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; - void init(o2::framework::InitContext& initContext) + void init(o2::framework::InitContext& context) { - if (initContext.mOptions.get("processDummy")) { - LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl; + if (context.mOptions.get("processDummy")) { return; } + // get the list of track cuts to be prefiltered TString trackCutsStr = fConfigTrackCuts.value; TObjArray* objArrayTrackCuts = nullptr; @@ -694,7 +813,7 @@ struct AnalysisPrefilterSelection { fPrefilterMask = 0; fPrefilterCutBit = -1; string trackCuts; - getTaskOptionValue(initContext, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); + getTaskOptionValue(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false); TString allTrackCutsStr = trackCuts; TString prefilterTrackCutStr = fConfigPrefilterTrackCut.value; if (!trackCutsStr.IsNull()) { @@ -830,7 +949,7 @@ struct AnalysisSameEventPairing { Configurable fConfigPairCuts{"cfgPairCuts", "", "Comma separated list of pair cuts"}; Configurable fConfigMixingDepth{"cfgMixingDepth", 100, "Number of Events stored for event mixing"}; - Configurable fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"}; + // Configurable fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"}; Configurable fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable fConfigCcdbPath{"ccdb-path", "Users/lm", "base path to the ccdb object"}; @@ -850,8 +969,11 @@ struct AnalysisSameEventPairing { Configurable fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable fConfigCollisionSystem{"syst", "pp", "Collision system, pp or PbPb"}; Configurable fConfigCenterMassEnergy{"energy", 13600, "Center of mass energy in GeV"}; + // Track related options + Configurable fPropTrack{"cfgPropTrack", true, "Propgate tracks to associated collision to recalculate DCA and momentum vector"}; Service fCCDB; + o2::ccdb::CcdbApi fCCDBApi; Filter filterEventSelected = aod::dqanalysisflags::isEventSelected == uint32_t(1); @@ -881,19 +1003,14 @@ struct AnalysisSameEventPairing { void init(o2::framework::InitContext& context) { - fEnableBarrelHistos = context.mOptions.get("processAllSkimmed") || context.mOptions.get("processBarrelOnlySkimmed") || context.mOptions.get("processBarrelOnlyWithCollSkimmed"); - fEnableBarrelMixingHistos = context.mOptions.get("processMixingAllSkimmed"); + if (context.mOptions.get("processDummy")) { + 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"); - bool isDummy = context.mOptions.get("processDummy"); - if (isDummy) { - if (fEnableBarrelHistos || fEnableBarrelMixingHistos || fEnableMuonHistos || fEnableMuonMixingHistos) { - LOG(warning) << "The dummy process function is enabled while you have enabled normal process function. Check your configuration file!" << endl; - } else { - LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl; - return; - } - } // Keep track of all the histogram class names to avoid composing strings in the pairing loop TString histNames = ""; @@ -966,8 +1083,8 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackHistNames[fNCutsBarrel + icut * fNPairCuts + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) - } // end if enableBarrelHistos + } // end if (pair cuts) + } // end if enableBarrelHistos } } } @@ -995,6 +1112,32 @@ struct AnalysisSameEventPairing { names.push_back(Form("PairsMuonMEMM_%s", objArray->At(icut)->GetName())); histNames += Form("%s;%s;%s;", names[3].Data(), names[4].Data(), names[5].Data()); } + names.push_back(Form("PairsMuonSEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPM_unambiguous_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEPP_unambiguous_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonSEMM_unambiguous_%s", objArray->At(icut)->GetName())); + histNames += Form("%s;%s;%s;", names[(fEnableMuonMixingHistos ? 6 : 3)].Data(), names[(fEnableMuonMixingHistos ? 7 : 4)].Data(), names[(fEnableMuonMixingHistos ? 8 : 5)].Data()); + histNames += Form("%s;%s;%s;", names[(fEnableMuonMixingHistos ? 9 : 6)].Data(), names[(fEnableMuonMixingHistos ? 10 : 7)].Data(), names[(fEnableMuonMixingHistos ? 11 : 8)].Data()); + histNames += Form("%s;%s;%s;", names[(fEnableMuonMixingHistos ? 12 : 9)].Data(), names[(fEnableMuonMixingHistos ? 13 : 10)].Data(), names[(fEnableMuonMixingHistos ? 14 : 11)].Data()); + if (fEnableMuonMixingHistos) { + names.push_back(Form("PairsMuonMEPM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEPP_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEMM_ambiguousInBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEPM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEPP_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEMM_ambiguousOutOfBunch_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEPM_unambiguous_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEPP_unambiguous_%s", objArray->At(icut)->GetName())); + names.push_back(Form("PairsMuonMEMM_unambiguous_%s", objArray->At(icut)->GetName())); + histNames += Form("%s;%s;%s;", names[15].Data(), names[16].Data(), names[17].Data()); + histNames += Form("%s;%s;%s;", names[18].Data(), names[19].Data(), names[20].Data()); + histNames += Form("%s;%s;%s;", names[21].Data(), names[22].Data(), names[23].Data()); + } fMuonHistNames[icut] = names; TString cutNamesStr = fConfigPairCuts.value; @@ -1009,7 +1152,7 @@ struct AnalysisSameEventPairing { histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fMuonHistNames[fNCutsMuon + icut * fNCutsMuon + iPairCut] = names; } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) } } } @@ -1020,6 +1163,7 @@ struct AnalysisSameEventPairing { fCCDB->setURL(fConfigCcdbUrl.value); fCCDB->setCaching(true); fCCDB->setLocalObjectValidityChecking(); + fCCDBApi.init(fConfigCcdbUrl.value); if (fConfigNoCorr) { VarManager::SetupFwdDCAFitterNoCorr(); @@ -1077,7 +1221,7 @@ struct AnalysisSameEventPairing { fOutputList.setObject(fHistMan->GetMainHistogramList()); } - void initParamsFromCCDB(uint64_t timestamp, bool withTwoProngFitter = true) + void initParamsFromCCDB(uint64_t timestamp, int runNumber, bool withTwoProngFitter = true) { if (fConfigUseRemoteField.value) { @@ -1110,6 +1254,12 @@ struct AnalysisSameEventPairing { VarManager::SetupTwoProngDCAFitter(fConfigMagField.value, true, 200.0f, 4.0f, 1.0e-3f, 0.9f, fConfigUseAbsDCA.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 same event pairing (barrel-barrel, muon-muon, barrel-muon) @@ -1118,7 +1268,7 @@ struct AnalysisSameEventPairing { { if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() if (fCurrentRun != events.begin().runNumber()) { - initParamsFromCCDB(events.begin().timestamp(), TTwoProngFitter); + initParamsFromCCDB(events.begin().timestamp(), events.begin().runNumber(), TTwoProngFitter); fCurrentRun = events.begin().runNumber(); } } @@ -1126,12 +1276,15 @@ struct AnalysisSameEventPairing { TString cutNames = fConfigTrackCuts.value; std::map> histNames = fTrackHistNames; int ncuts = fNCutsBarrel; + int histIdxOffset = 0; if constexpr (TPairType == pairTypeMuMu) { cutNames = fConfigMuonCuts.value; histNames = fMuonHistNames; ncuts = fNCutsMuon; + if (fEnableMuonMixingHistos) { + histIdxOffset = 3; + } } - int histIdxOffset = 0; if constexpr (TPairType == pairTypeEE) { if (fEnableBarrelMixingHistos) { histIdxOffset = 3; @@ -1176,8 +1329,7 @@ struct AnalysisSameEventPairing { bool isFirst = true; for (auto& [a1, a2] : o2::soa::combinations(groupedAssocs, groupedAssocs)) { - - if constexpr (TPairType == VarManager::kDecayToEE || TPairType == VarManager::kDecayToPiPi) { + if constexpr (TPairType == VarManager::kDecayToEE) { twoTrackFilter = a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isBarrelSelectedPrefilter_raw() & fTrackFilterMask; if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue @@ -1203,6 +1355,10 @@ struct AnalysisSameEventPairing { } VarManager::FillPair(t1, t2); + // compute quantities which depend on the associated collision, such as DCA + if (fPropTrack) { + VarManager::FillPairCollision(event, t1, t2); + } if constexpr (TTwoProngFitter) { VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); } @@ -1223,8 +1379,8 @@ struct AnalysisSameEventPairing { if constexpr ((TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelPID) > 0) { if (fConfigFlatTables.value) { dielectronAllList(VarManager::fgValues[VarManager::kMass], VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], t1.sign() + t2.sign(), twoTrackFilter, dileptonMcDecision, - t1.pt(), t1.eta(), t1.phi(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), - t2.pt(), t2.eta(), t2.phi(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), + t1.pt(), t1.eta(), t1.phi(), t1.itsClusterMap(), t1.itsChi2NCl(), t1.tpcNClsCrossedRows(), t1.tpcNClsFound(), t1.tpcChi2NCl(), t1.dcaXY(), t1.dcaZ(), t1.tpcSignal(), t1.tpcNSigmaEl(), t1.tpcNSigmaPi(), t1.tpcNSigmaPr(), t1.beta(), t1.tofNSigmaEl(), t1.tofNSigmaPi(), t1.tofNSigmaPr(), + t2.pt(), t2.eta(), t2.phi(), t2.itsClusterMap(), t2.itsChi2NCl(), t2.tpcNClsCrossedRows(), t2.tpcNClsFound(), t2.tpcChi2NCl(), t2.dcaXY(), t2.dcaZ(), t2.tpcSignal(), t2.tpcNSigmaEl(), t2.tpcNSigmaPi(), t2.tpcNSigmaPr(), t2.beta(), t2.tofNSigmaEl(), t2.tofNSigmaPi(), t2.tofNSigmaPr(), VarManager::fgValues[VarManager::kKFTrack0DCAxyz], VarManager::fgValues[VarManager::kKFTrack1DCAxyz], VarManager::fgValues[VarManager::kKFDCAxyzBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DCAxy], VarManager::fgValues[VarManager::kKFTrack1DCAxy], VarManager::fgValues[VarManager::kKFDCAxyBetweenProngs], VarManager::fgValues[VarManager::kKFTrack0DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationFromPV], VarManager::fgValues[VarManager::kKFTrack0DeviationxyFromPV], VarManager::fgValues[VarManager::kKFTrack1DeviationxyFromPV], VarManager::fgValues[VarManager::kKFMass], VarManager::fgValues[VarManager::kKFChi2OverNDFGeo], VarManager::fgValues[VarManager::kVertexingLxyz], VarManager::fgValues[VarManager::kVertexingLxyzOverErr], VarManager::fgValues[VarManager::kVertexingLxy], VarManager::fgValues[VarManager::kVertexingLxyOverErr], VarManager::fgValues[VarManager::kVertexingTauxy], VarManager::fgValues[VarManager::kVertexingTauxyErr], VarManager::fgValues[VarManager::kKFCosPA], VarManager::fgValues[VarManager::kKFJpsiDCAxyz], VarManager::fgValues[VarManager::kKFJpsiDCAxy], @@ -1243,10 +1399,31 @@ struct AnalysisSameEventPairing { 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(); + // store the ambiguity number of the two dilepton legs in the last 4 digits of the two-track filter + if (t1.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 28); + } + if (t2.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 29); + } + if (t1.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 30); + } + if (t2.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 31); + } VarManager::FillPair(t1, t2); + // compute quantities which depend on the associated collision, such as DCA + if (fPropTrack) { + VarManager::FillPairCollision(event, t1, t2); + } if constexpr (TTwoProngFitter) { VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); } @@ -1283,11 +1460,11 @@ struct AnalysisSameEventPairing { -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., -999., - t1.isAmbiguous(), t2.isAmbiguous(), + (twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 30)), (twoTrackFilter & (uint32_t(1) << 29)) || (twoTrackFilter & (uint32_t(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::kCORR4POI], VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], VarManager::fgValues[VarManager::kMultDimuons], + 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 ((TTrackFillMap & VarManager::ObjTypes::ReducedMuonCollInfo) > 0) { @@ -1298,7 +1475,7 @@ struct AnalysisSameEventPairing { VarManager::fgValues[VarManager::kU3Q3], VarManager::fgValues[VarManager::kR3SP], VarManager::fgValues[VarManager::kCos2DeltaPhi], VarManager::fgValues[VarManager::kR2EP_AB], VarManager::fgValues[VarManager::kR2EP_AC], VarManager::fgValues[VarManager::kR2EP_BC], VarManager::fgValues[VarManager::kCos3DeltaPhi], VarManager::fgValues[VarManager::kR3EP], - VarManager::fgValues[VarManager::kCORR4POI], VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], + VarManager::fgValues[VarManager::kCORR2POI], VarManager::fgValues[VarManager::kCORR4POI], VarManager::fgValues[VarManager::kM01POI], VarManager::fgValues[VarManager::kM0111POI], VarManager::fgValues[VarManager::kCORR2REF], VarManager::fgValues[VarManager::kCORR4REF], VarManager::fgValues[VarManager::kM11REF], VarManager::fgValues[VarManager::kM1111REF], VarManager::fgValues[VarManager::kMultDimuons], VarManager::fgValues[VarManager::kMultA]); } @@ -1316,10 +1493,12 @@ struct AnalysisSameEventPairing { // Fill histograms bool isAmbiInBunch = false; bool isAmbiOutOfBunch = false; + bool isUnambiguous = false; for (int icut = 0; icut < ncuts; icut++) { if (twoTrackFilter & (uint32_t(1) << icut)) { isAmbiInBunch = (twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 29)); isAmbiOutOfBunch = (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31)); + isUnambiguous = !((twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 29)) || (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31))); if (sign1 * sign2 < 0) { fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); if (isAmbiInBunch) { @@ -1328,6 +1507,9 @@ struct AnalysisSameEventPairing { if (isAmbiOutOfBunch) { fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 3].Data(), VarManager::fgValues); } + if (isUnambiguous) { + fHistMan->FillHistClass(histNames[icut][3 + histIdxOffset + 6].Data(), VarManager::fgValues); + } } else { if (sign1 > 0) { fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); @@ -1337,6 +1519,9 @@ struct AnalysisSameEventPairing { 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) { @@ -1345,6 +1530,9 @@ struct AnalysisSameEventPairing { if (isAmbiOutOfBunch) { fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 3].Data(), VarManager::fgValues); } + if (isUnambiguous) { + fHistMan->FillHistClass(histNames[icut][5 + histIdxOffset + 6].Data(), VarManager::fgValues); + } } } for (unsigned int iPairCut = 0; iPairCut < fPairCuts.size(); iPairCut++) { @@ -1363,8 +1551,8 @@ struct AnalysisSameEventPairing { } // end loop (pair cuts) } } // end loop (cuts) - } // end loop over pairs of track associations - } // end loop over events + } // end loop over pairs of track associations + } // end loop over events } template @@ -1382,7 +1570,7 @@ struct AnalysisSameEventPairing { continue; } auto t1 = a1.template reducedtrack_as(); - auto t2 = a1.template reducedtrack_as(); + auto t2 = a2.template reducedtrack_as(); VarManager::FillPairME(t1, t2); if constexpr ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0) { VarManager::FillPairVn(t1, t2); @@ -1396,11 +1584,29 @@ struct AnalysisSameEventPairing { continue; } auto t1 = a1.template reducedmuon_as(); - auto t2 = a1.template reducedmuon_as(); + auto t2 = a2.template reducedmuon_as(); + if (t1.matchMCHTrackId() == t2.matchMCHTrackId()) + continue; + if (t1.matchMFTTrackId() == t2.matchMFTTrackId()) + continue; VarManager::FillPairME(t1, t2); if constexpr ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0) { VarManager::FillPairVn(t1, t2); } + pairSign = t1.sign() + t2.sign(); + // store the ambiguity number of the two dilepton legs in the last 4 digits of the two-track filter + if (t1.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 28); + } + if (t2.muonAmbiguityInBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 29); + } + if (t1.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 30); + } + if (t2.muonAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 31); + } ncuts = fNCutsMuon; histNames = fMuonHistNames; } @@ -1408,22 +1614,55 @@ struct AnalysisSameEventPairing { twoTrackFilter = a1.isBarrelSelected_raw() & a1.isBarrelSelectedPrefilter_raw() & a2.isMuonSelected_raw() & fTrackFilterMask; }*/ + bool isAmbiInBunch = false; + bool isAmbiOutOfBunch = false; + bool isUnambiguous = false; for (int icut = 0; icut < ncuts; icut++) { if (!(twoTrackFilter & (uint32_t(1) << icut))) { continue; // cut not passed } + isAmbiInBunch = (twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 29)); + isAmbiOutOfBunch = (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31)); + isUnambiguous = !((twoTrackFilter & (uint32_t(1) << 28)) || (twoTrackFilter & (uint32_t(1) << 29)) || (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31))); if (pairSign == 0) { fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][15].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][18].Data(), VarManager::fgValues); + } + if (isUnambiguous) { + fHistMan->FillHistClass(histNames[icut][21].Data(), VarManager::fgValues); + } } else { if (pairSign > 0) { fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][16].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][19].Data(), VarManager::fgValues); + } + if (isUnambiguous) { + fHistMan->FillHistClass(histNames[icut][22].Data(), VarManager::fgValues); + } } else { fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); + if (isAmbiInBunch) { + fHistMan->FillHistClass(histNames[icut][17].Data(), VarManager::fgValues); + } + if (isAmbiOutOfBunch) { + fHistMan->FillHistClass(histNames[icut][20].Data(), VarManager::fgValues); + } + if (isUnambiguous) { + fHistMan->FillHistClass(histNames[icut][23].Data(), VarManager::fgValues); + } } } } // end for (cuts) - } // end for (track2) - } // end for (track1) + } // end for (track2) + } // end for (track1) } // barrel-barrel and muon-muon event mixing @@ -1448,7 +1687,7 @@ struct AnalysisSameEventPairing { void processAllSkimmed(MyEventsVtxCovSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks, - soa::Join const& muonAssocs, MyMuonTracksWithCov const& muons) + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); runSameEventPairing(events, muonAssocsPerCollision, muonAssocs, muons); @@ -1462,6 +1701,13 @@ struct AnalysisSameEventPairing { runSameEventPairing(events, trackAssocsPerCollision, barrelAssocs, barrelTracks); } + void processBarrelOnlySkimmedNoCov(MyEventsSelected 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) @@ -1470,19 +1716,25 @@ struct AnalysisSameEventPairing { } void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events, - soa::Join const& muonAssocs, MyMuonTracksWithCov const& muons) + 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, MyMuonTracksWithCov const& muons) + soa::Join const& muonAssocs, MyMuonTracksWithCovWithAmbiguities const& muons) { runSameSideMixing(events, trackAssocs, tracks, trackAssocsPerCollision); runSameSideMixing(events, muonAssocs, muons, muonAssocsPerCollision); } + void processMixingBarrelSkimmed(soa::Filtered& events, + soa::Join const& trackAssocs, MyBarrelTracksWithCov const& tracks) + { + runSameSideMixing(events, trackAssocs, tracks, trackAssocsPerCollision); + } + void processDummy(MyEvents&) { // do nothing @@ -1491,8 +1743,10 @@ struct AnalysisSameEventPairing { PROCESS_SWITCH(AnalysisSameEventPairing, processAllSkimmed, "Run all types of pairing, with skimmed tracks/muons", false); 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, processMuonOnlySkimmed, "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, processDummy, "Dummy function, enabled only if none of the others are enabled", false); }; @@ -1510,8 +1764,12 @@ struct AnalysisAsymmetricPairing { // Configurables Configurable fConfigLegCuts{"cfgLegCuts", "", ":[:],[:[:],...]"}; + Configurable fConfigLegAFilterMask{"cfgLegAFilterMask", 0, "Filter mask corresponding to cuts in event-selection"}; + Configurable fConfigLegBFilterMask{"cfgLegBFilterMask", 0, "Filter mask corresponding to cuts in event-selection"}; + 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 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"}; @@ -1551,17 +1809,24 @@ struct AnalysisAsymmetricPairing { Preslice> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId; + // Partitions for triplets and asymmetric pairs + Partition> legACandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegAFilterMask) > uint32_t(0); + Partition> legBCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegBFilterMask) > uint32_t(0); + Partition> legCCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fConfigLegCFilterMask) > uint32_t(0); + void init(o2::framework::InitContext& context) { - bool isDummy = context.mOptions.get("processDummy"); - if (isDummy) { - LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl; + if (context.mOptions.get("processDummy")) { return; } TString histNames = ""; std::vector names; + // Get the leg cut filter maps + fLegAFilterMask = fConfigLegAFilterMask.value; + fLegBFilterMask = fConfigLegBFilterMask.value; + fLegCFilterMask = fConfigLegCFilterMask.value; // Get the pair cuts TString cutNamesStr = fConfigPairCuts.value; if (!cutNamesStr.IsNull()) { @@ -1591,7 +1856,21 @@ struct AnalysisAsymmetricPairing { } } } + // Check that the leg cut masks make sense + if (static_cast(std::floor(TMath::Log2(fLegAFilterMask))) + 1 > objArray->GetEntries()) { + LOGF(fatal, "fConfigLegAFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast(std::floor(TMath::Log2(fLegAFilterMask))) + 1, objArray->GetEntries()); + } + if (static_cast(std::floor(TMath::Log2(fLegBFilterMask))) + 1 > objArray->GetEntries()) { + LOGF(fatal, "fConfigLegBFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast(std::floor(TMath::Log2(fLegBFilterMask))) + 1, objArray->GetEntries()); + } + if (static_cast(std::floor(TMath::Log2(fLegCFilterMask))) + 1 > objArray->GetEntries()) { + LOGF(fatal, "fConfigLegCFilterMask has highest bit at position %d, but track-selection only has %d cuts!", static_cast(std::floor(TMath::Log2(fLegCFilterMask))) + 1, objArray->GetEntries()); + } + // Get the cuts defining the legs + uint32_t fConstructedLegAFilterMask = 0; + uint32_t fConstructedLegBFilterMask = 0; + uint32_t fConstructedLegCFilterMask = 0; TString legCutsStr = fConfigLegCuts.value; std::unique_ptr objArrayLegs(legCutsStr.Tokenize(",")); if (objArrayLegs->GetEntries() == 0) { @@ -1617,7 +1896,7 @@ struct AnalysisAsymmetricPairing { // Find leg cuts in the track selection cuts legAIdx = objArray->IndexOf(legs->At(0)); if (legAIdx >= 0) { - fLegAFilterMask |= (uint32_t(1) << legAIdx); + fConstructedLegAFilterMask |= (uint32_t(1) << legAIdx); fTrackCutFilterMasks[icut] |= uint32_t(1) << legAIdx; } else { LOGF(fatal, "Leg A cut %s was not calculated upstream. Check the config!", legs->At(0)->GetName()); @@ -1625,7 +1904,7 @@ struct AnalysisAsymmetricPairing { } legBIdx = objArray->IndexOf(legs->At(1)); if (legBIdx >= 0) { - fLegBFilterMask |= (uint32_t(1) << legBIdx); + fConstructedLegBFilterMask |= (uint32_t(1) << legBIdx); fTrackCutFilterMasks[icut] |= uint32_t(1) << legBIdx; } else { LOGF(fatal, "Leg B cut %s was not calculated upstream. Check the config!", legs->At(1)->GetName()); @@ -1634,7 +1913,7 @@ struct AnalysisAsymmetricPairing { if (isThreeProng[icut]) { legCIdx = objArray->IndexOf(legs->At(2)); if (legCIdx >= 0) { - fLegCFilterMask |= (uint32_t(1) << legCIdx); + fConstructedLegCFilterMask |= (uint32_t(1) << legCIdx); fTrackCutFilterMasks[icut] |= uint32_t(1) << legCIdx; } else { LOGF(fatal, "Leg C cut %s was not calculated upstream. Check the config!", legs->At(2)->GetName()); @@ -1675,7 +1954,7 @@ struct AnalysisAsymmetricPairing { fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) - } // end if (pair cuts) + } // end if (pair cuts) } else { names = {}; std::vector pairHistPrefixes = {"PairsBarrelSEPM"}; @@ -1726,9 +2005,19 @@ struct AnalysisAsymmetricPairing { fTrackHistNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut] = names; } // end loop (common cuts) } // end loop (pair cuts) - } // end if (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); + } + if (fLegBFilterMask != fConstructedLegBFilterMask) { + LOGF(fatal, "cfgLegBFilterMask (%d) is not equal to the mask constructed by the cuts specified in cfgLegCuts (%d)!", fLegBFilterMask, fConstructedLegBFilterMask); + } + if (fLegCFilterMask != fConstructedLegCFilterMask) { + LOGF(fatal, "cfgLegCFilterMask (%d) is not equal to the mask constructed by the cuts specified in cfgLegCuts (%d)!", fLegCFilterMask, fConstructedLegCFilterMask); + } // Make sure only pairs or only triplets of leg cuts were given int tripletCheckSum = std::count(isThreeProng.begin(), isThreeProng.end(), true); if (tripletCheckSum != 0 && tripletCheckSum != fNLegCuts) { @@ -1750,7 +2039,7 @@ struct AnalysisAsymmetricPairing { 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 + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); } @@ -1796,7 +2085,7 @@ struct AnalysisAsymmetricPairing { // Template function to run same event pairing with asymmetric pairs (e.g. kaon-pion) template - void runAsymmetricPairing(TEvents const& events, Preslice& preslice, TTrackAssocs const& assocs, TTracks const& /*tracks*/) + void runAsymmetricPairing(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()) { @@ -1822,145 +2111,147 @@ struct AnalysisAsymmetricPairing { VarManager::ResetValues(0, VarManager::kNVars); VarManager::FillEvent(event, VarManager::fgValues); - auto groupedAssocs = assocs.sliceBy(preslice, event.globalIndex()); - if (groupedAssocs.size() == 0) { + auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex()); + if (groupedLegAAssocs.size() == 0) { + continue; + } + auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex()); + if (groupedLegBAssocs.size() == 0) { continue; } // TODO: Think about double counting - for (auto& a1 : groupedAssocs) { - // Check if a1 is a leg A candidate - uint32_t a1AFilter = a1.isBarrelSelected_raw() & fLegAFilterMask; - if (!a1AFilter) { - continue; - } - for (auto& a2 : groupedAssocs) { - // Check if a2 is a leg B candidate - uint32_t a2BFilter = a2.isBarrelSelected_raw() & fLegBFilterMask; - if (!a2BFilter) { - continue; - } - - uint32_t twoTrackFilter = 0; - uint32_t pairFilter = 0; + std::set> globIdxPairs; + for (auto& [a1, a2] : combinations(soa::CombinationsFullIndexPolicy(groupedLegAAssocs, groupedLegBAssocs))) { + + uint32_t twoTrackFilter = 0; + uint32_t twoTrackCommonFilter = 0; + uint32_t pairFilter = 0; + bool isPairIdWrong = false; + for (int icut = 0; icut < fNLegCuts; ++icut) { // Find leg pair definitions both candidates participate in - for (int icut = 0; icut < fNLegCuts; ++icut) { - if (((a1AFilter | a2BFilter) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { - twoTrackFilter |= (uint32_t(1) << icut); + if ((((a1.isBarrelSelected_raw() & fLegAFilterMask) | (a2.isBarrelSelected_raw() & fLegBFilterMask)) & fTrackCutFilterMasks[icut]) == fTrackCutFilterMasks[icut]) { + twoTrackFilter |= (uint32_t(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; + } } } - // Find common track cuts both candidates pass - twoTrackFilter |= a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & fCommonTrackCutMask; + } - if (!twoTrackFilter) { - continue; - } + if (!twoTrackFilter || isPairIdWrong) { + continue; + } - auto t1 = a1.template reducedtrack_as(); - auto t2 = a2.template reducedtrack_as(); + // Find common track cuts both candidates pass + twoTrackCommonFilter |= a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & fCommonTrackCutMask; - // Avoid self-pairs - if (t1.globalIndex() == t2.globalIndex()) { - continue; - } + auto t1 = a1.template reducedtrack_as(); + auto t2 = a2.template reducedtrack_as(); - 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 - if (t1.barrelAmbiguityInBunch() > 1 || t1.barrelAmbiguityOutOfBunch() > 1) { - twoTrackFilter |= (uint32_t(1) << 30); - } - if (t2.barrelAmbiguityInBunch() > 1 || t2.barrelAmbiguityOutOfBunch() > 1) { - twoTrackFilter |= (uint32_t(1) << 31); - } + // Avoid self-pairs + if (t1.globalIndex() == t2.globalIndex()) { + continue; + } - VarManager::FillPair(t1, t2); - if constexpr (TTwoProngFitter) { - VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); - } + 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 + if (t1.barrelAmbiguityInBunch() > 1 || t1.barrelAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 30); + } + if (t2.barrelAmbiguityInBunch() > 1 || t2.barrelAmbiguityOutOfBunch() > 1) { + twoTrackFilter |= (uint32_t(1) << 31); + } - // Fill histograms - bool isAmbi = false; - for (int icut = 0; icut < fNLegCuts; icut++) { - if (twoTrackFilter & (uint32_t(1) << icut)) { - isAmbi = (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31)); - if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + VarManager::FillPair(t1, t2); + if constexpr (TTwoProngFitter) { + VarManager::FillPairVertexing(event, t1, t2, fConfigPropToPCA); + } + + // Fill histograms + bool isAmbi = false; + for (int icut = 0; icut < fNLegCuts; icut++) { + if (twoTrackFilter & (uint32_t(1) << icut)) { + isAmbi = (twoTrackFilter & (uint32_t(1) << 30)) || (twoTrackFilter & (uint32_t(1) << 31)); + if (sign1 * sign2 < 0) { + fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); + if (isAmbi && fConfigAmbiguousHistograms.value) { + fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + } + } else if (fConfigSameSignHistograms.value) { + if (sign1 > 0) { + fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); + if (isAmbi && fConfigAmbiguousHistograms.value) { + fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); + } + } else { + fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][3].Data(), VarManager::fgValues); + fHistMan->FillHistClass(histNames[icut][5].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); + } else if (fConfigSameSignHistograms.value) { + if (sign1 > 0) { + fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][1].Data(), VarManager::fgValues); + } else { + fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][2].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 + continue; + pairFilter |= (uint32_t(1) << iPairCut); + // Histograms with pair cuts + if (sign1 * sign2 < 0) { + fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); - if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][4].Data(), VarManager::fgValues); - } + fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][1].Data(), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[icut][2].Data(), VarManager::fgValues); - if (isAmbi && fConfigAmbiguousHistograms.value) { - fHistMan->FillHistClass(histNames[icut][5].Data(), VarManager::fgValues); - } + fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][2].Data(), VarManager::fgValues); } } - for (unsigned int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (twoTrackFilter & fCommonTrackCutFilterMasks[iCommonCut]) { + // 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 + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); + fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); } else if (fConfigSameSignHistograms.value) { if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][1].Data(), VarManager::fgValues); + fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][1].Data(), VarManager::fgValues); } else { - fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][2].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 - continue; - pairFilter |= (uint32_t(1) << iPairCut); - // Histograms with pair cuts - if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); - } else if (fConfigSameSignHistograms.value) { - if (sign1 > 0) { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][1].Data(), VarManager::fgValues); - } else { - fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][2].Data(), VarManager::fgValues); - } - } - // Histograms with pair cuts and common track cuts - for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - if (twoTrackFilter & fCommonTrackCutFilterMasks[iCommonCut]) { - if (sign1 * sign2 < 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][0].Data(), VarManager::fgValues); - } else if (fConfigSameSignHistograms.value) { - if (sign1 > 0) { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][1].Data(), VarManager::fgValues); - } else { - fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][2].Data(), VarManager::fgValues); - } + fHistMan->FillHistClass(histNames[(fNLegCuts * (fNCommonTrackCuts + 1) + fNLegCuts * fNPairCuts) + icut * (fNPairCuts * fNCommonTrackCuts + 1) + iCommonCut * (1 + fNPairCuts) + iPairCut][2].Data(), VarManager::fgValues); } } } - } // end loop (pair cuts) - } - } // end loop (cuts) - ditrackList(event.globalIndex(), VarManager::fgValues[VarManager::kMass], - VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], - t1.sign() + t2.sign(), twoTrackFilter, pairFilter); - if constexpr (trackHasCov && TTwoProngFitter) { - ditrackExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]); + } + } // end loop (pair cuts) } - } // end inner assoc loop (leg A) - } // end outer assoc loop (leg B) - } // end event loop + } // end loop (cuts) + ditrackList(event.globalIndex(), VarManager::fgValues[VarManager::kMass], + VarManager::fgValues[VarManager::kPt], VarManager::fgValues[VarManager::kEta], VarManager::fgValues[VarManager::kPhi], + t1.sign() + t2.sign(), twoTrackFilter, pairFilter, twoTrackCommonFilter); + if constexpr (trackHasCov && TTwoProngFitter) { + ditrackExtraList(t1.globalIndex(), t2.globalIndex(), VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]); + } + } // end inner assoc loop (leg A) + } // end event loop } // Template function to run same event triplets (e.g. D+->K-pi+pi+) template - void runThreeProng(TEvents const& events, Preslice& preslice, TTrackAssocs const& assocs, TTracks const& tracks, VarManager::PairCandidateType tripletType) + void runThreeProng(TEvents const& events, Preslice& preslice, TTrackAssocs const& /*assocs*/, TTracks const& tracks, VarManager::PairCandidateType tripletType) { if (events.size() > 0) { // Additional protection to avoid crashing of events.begin().runNumber() if (fCurrentRun != events.begin().runNumber()) { @@ -1979,30 +2270,28 @@ struct AnalysisAsymmetricPairing { VarManager::ResetValues(0, VarManager::kNVars); VarManager::FillEvent(event, VarManager::fgValues); - auto groupedAssocs = assocs.sliceBy(preslice, event.globalIndex()); - if (groupedAssocs.size() == 0) { + auto groupedLegAAssocs = legACandidateAssocs.sliceBy(preslice, event.globalIndex()); + if (groupedLegAAssocs.size() == 0) { + continue; + } + auto groupedLegBAssocs = legBCandidateAssocs.sliceBy(preslice, event.globalIndex()); + if (groupedLegBAssocs.size() == 0) { + continue; + } + auto groupedLegCAssocs = legCCandidateAssocs.sliceBy(preslice, event.globalIndex()); + if (groupedLegCAssocs.size() == 0) { continue; } - // Partitions based on leg selections - Partition legACandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fLegAFilterMask) > uint32_t(0); - legACandidateAssocs.bindTable(groupedAssocs); - legACandidateAssocs.bindExternalIndices(&tracks); - Partition legBCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fLegBFilterMask) > uint32_t(0); - legBCandidateAssocs.bindTable(groupedAssocs); - legBCandidateAssocs.bindExternalIndices(&tracks); - Partition legCCandidateAssocs = (o2::aod::dqanalysisflags::isBarrelSelected & fLegCFilterMask) > uint32_t(0); - legCCandidateAssocs.bindTable(groupedAssocs); - legCCandidateAssocs.bindExternalIndices(&tracks); - + std::set> globIdxTriplets; // Based on triplet type, make suitable combinations of the partitions - if (tripletType == VarManager::kTripleCandidateToPKPi) { - for (auto& [a1, a2, a3] : combinations(soa::CombinationsFullIndexPolicy(legACandidateAssocs, legBCandidateAssocs, legCCandidateAssocs))) { + if (tripletType == VarManager::kTripleCandidateToPKPi || tripletType == VarManager::kTripleCandidateToKKPi) { + for (auto& [a1, a2, a3] : combinations(soa::CombinationsFullIndexPolicy(groupedLegAAssocs, groupedLegBAssocs, groupedLegCAssocs))) { readTriplet(a1, a2, a3, tracks, event, tripletType, histNames); } } else if (tripletType == VarManager::kTripleCandidateToKPiPi) { - for (auto& a1 : legACandidateAssocs) { - for (auto& [a2, a3] : combinations(legBCandidateAssocs, legCCandidateAssocs)) { + for (auto& a1 : groupedLegAAssocs) { + for (auto& [a2, a3] : combinations(groupedLegBAssocs, groupedLegCAssocs)) { readTriplet(a1, a2, a3, tracks, event, tripletType, histNames); } } @@ -2017,19 +2306,36 @@ struct AnalysisAsymmetricPairing { void readTriplet(TTrackAssoc const& a1, TTrackAssoc const& a2, TTrackAssoc const& a3, TTracks const& /*tracks*/, TEvent const& event, VarManager::PairCandidateType tripletType, std::map> histNames) { uint32_t threeTrackFilter = 0; - // Find out which leg cut combination the triplet passes + 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]) { threeTrackFilter |= (uint32_t(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)) { + return; + } + // Check if the supposed kaon passes as a proton, if so, skip this triplet. It is ppPi. + if (a2.isBarrelSelected_raw() & fLegAFilterMask) { + 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)) { + return; + } + } } } - // Find common track cuts both candidates pass - threeTrackFilter |= a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a3.isBarrelSelected_raw() & fCommonTrackCutMask; - if (!threeTrackFilter) { return; } + // Find common track cuts all candidates pass + threeTrackCommonFilter |= a1.isBarrelSelected_raw() & a2.isBarrelSelected_raw() & a3.isBarrelSelected_raw() & fCommonTrackCutMask; + auto t1 = a1.template reducedtrack_as(); auto t2 = a2.template reducedtrack_as(); auto t3 = a3.template reducedtrack_as(); @@ -2062,8 +2368,8 @@ struct AnalysisAsymmetricPairing { if (fConfigAmbiguousHistograms.value && ((threeTrackFilter & (uint32_t(1) << 29)) || (threeTrackFilter & (uint32_t(1) << 30)) || (threeTrackFilter & (uint32_t(1) << 31)))) { fHistMan->FillHistClass(histNames[icut][1].Data(), VarManager::fgValues); } - for (unsigned int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { - if (threeTrackFilter & fCommonTrackCutFilterMasks[iCommonCut]) { + for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; iCommonCut++) { + if (threeTrackCommonFilter & fCommonTrackCutFilterMasks[iCommonCut]) { fHistMan->FillHistClass(histNames[fNLegCuts + icut * fNCommonTrackCuts + iCommonCut][0].Data(), VarManager::fgValues); } } // end loop (common cuts) @@ -2076,7 +2382,7 @@ struct AnalysisAsymmetricPairing { fHistMan->FillHistClass(histNames[fNLegCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut][0].Data(), VarManager::fgValues); // Histograms with pair cuts and common track cuts for (int iCommonCut = 0; iCommonCut < fNCommonTrackCuts; ++iCommonCut) { - if (threeTrackFilter & fCommonTrackCutFilterMasks[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); } } @@ -2099,6 +2405,13 @@ struct AnalysisAsymmetricPairing { runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, VarManager::kTripleCandidateToKPiPi); } + void processKaonKaonPionSkimmed(MyEventsVtxCovZdcSelected const& events, + soa::Join const& barrelAssocs, + MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) + { + runThreeProng(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, VarManager::kTripleCandidateToKKPi); + } + void processProtonKaonPionSkimmed(MyEventsVtxCovZdcSelected const& events, soa::Join const& barrelAssocs, MyBarrelTracksWithCovWithAmbiguities const& barrelTracks) @@ -2113,6 +2426,7 @@ 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, processKaonKaonPionSkimmed, "Run kaon kaon 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); }; @@ -2141,6 +2455,8 @@ struct AnalysisDileptonTrack { int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. int fNCuts; int fNPairCuts; + int fNCommonTrackCuts; + std::map fCommonTrackCutMap; int fTrackCutBit; std::map fHistNamesDileptonTrack; std::map fHistNamesDileptons; @@ -2165,21 +2481,15 @@ struct AnalysisDileptonTrack { void init(o2::framework::InitContext& context) { + if (context.mOptions.get("processDummy")) { + return; + } + 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"); - bool isAnyProcessEnabled = isBarrel || isBarrelME || isMuon || isMuonME; - 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; - } else { - LOG(info) << "Dummy function is enabled. Skipping the rest of the init function" << endl; - return; - } - } fCurrentRun = 0; fValuesDilepton = new float[VarManager::kNVars]; @@ -2213,6 +2523,8 @@ struct AnalysisDileptonTrack { // get the cuts employed for same-event pairing string tempCutsSinglePair; string pairCuts; + string pairCommonCuts; + string tempCutsTrack; if (isBarrel) { getTaskOptionValue(context, "analysis-same-event-pairing", "cfgTrackCuts", tempCutsSinglePair, false); getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", pairCuts, false); @@ -2220,8 +2532,27 @@ struct AnalysisDileptonTrack { getTaskOptionValue(context, "analysis-same-event-pairing", "cfgMuonCuts", tempCutsSinglePair, false); getTaskOptionValue(context, "analysis-same-event-pairing", "cfgPairCuts", 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); + } + + // 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(",")); + 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) { + fCommonTrackCutMap[icut] = iicut; + } + } + } } TString tempCutsSinglePairStr = tempCutsSinglePair; @@ -2249,14 +2580,33 @@ struct AnalysisDileptonTrack { 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 + } + } if (!pairCutsStr.IsNull()) { std::unique_ptr objArrayPairCuts(pairCutsStr.Tokenize(",")); fNPairCuts = objArrayPairCuts->GetEntries(); for (int iPairCut = 0; iPairCut < fNPairCuts; ++iPairCut) { - fHistNamesDileptonTrack[fNCuts + icut * fNPairCuts + iPairCut] = Form("DileptonTrack_%s_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName(), fConfigTrackCut.value.data()); - fHistNamesDileptons[fNCuts + icut * fNPairCuts + iPairCut] = Form("DileptonsSelected_%s_%s", tempStr.Data(), objArrayPairCuts->At(iPairCut)->GetName()); - DefineHistograms(fHistMan, fHistNamesDileptonTrack[fNCuts + icut * fNPairCuts + iPairCut], fConfigHistogramSubgroups.value.data()); // define dilepton-track histograms - DefineHistograms(fHistMan, fHistNamesDileptons[fNCuts + icut * fNPairCuts + iPairCut], "barrel,vertexing"); // define dilepton histograms + 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 (isBarrelME || isMuonME) { @@ -2333,9 +2683,19 @@ struct AnalysisDileptonTrack { 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); + } + } for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptons[fNCuts + icut * fNPairCuts + iPairCut].Data(), fValuesDilepton); + 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); + } + } } } } @@ -2372,9 +2732,19 @@ struct AnalysisDileptonTrack { if (dilepton.filterMap_bit(icut)) { fHistMan->FillHistClass(fHistNamesDileptonTrack[icut].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); + } + } for (int iPairCut = 0; iPairCut < fNPairCuts; iPairCut++) { if (dilepton.pairFilterMap_bit(iPairCut)) { - fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts + icut * fNPairCuts + iPairCut].Data(), fValuesHadron); + fHistMan->FillHistClass(fHistNamesDileptonTrack[fNCuts * (fNCommonTrackCuts + 1) + icut * fNPairCuts + iPairCut].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); + } + } } } } @@ -2484,8 +2854,8 @@ struct AnalysisDileptonTrack { } } } // end for (dileptons) - } // end for (assocs) - } // end event loop + } // end for (assocs) + } // end event loop } void processMuonMixedEvent(soa::Filtered& events, @@ -2523,8 +2893,8 @@ struct AnalysisDileptonTrack { } } } // end for (dileptons) - } // end for (assocs) - } // end event loop + } // end for (assocs) + } // end event loop } void processDummy(MyEvents&) diff --git a/PWGDQ/Tasks/taskFwdTrackPid.cxx b/PWGDQ/Tasks/taskFwdTrackPid.cxx new file mode 100644 index 00000000000..7a135596d56 --- /dev/null +++ b/PWGDQ/Tasks/taskFwdTrackPid.cxx @@ -0,0 +1,296 @@ +// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 taskFwdTrackPid.cxx +/// \brief Task for the analysis of forward PID with MFT +/// \author Luca Micheletti , INFN + +#include +#include +#include +#include +#include +#include +#include +#include +#include "CCDB/BasicCCDBManager.h" +#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" +#include "PWGDQ/Core/VarManager.h" +#include "PWGDQ/Core/HistogramManager.h" +#include "PWGDQ/Core/MixingHandler.h" +#include "PWGDQ/Core/MCSignal.h" +#include "PWGDQ/Core/MCSignalLibrary.h" +#include "PWGDQ/Core/AnalysisCut.h" +#include "PWGDQ/Core/AnalysisCompositeCut.h" +#include "PWGDQ/Core/HistogramsLibrary.h" +#include "PWGDQ/Core/CutsLibrary.h" +#include "PWGDQ/Core/MixingLibrary.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "Field/MagneticField.h" +#include "TGeoGlobalMagField.h" +#include "DetectorsBase/Propagator.h" +#include "DetectorsBase/GeometryManager.h" +#include "ITSMFTBase/DPLAlpideParam.h" +#include "Common/CCDB/EventSelectionParams.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod; + +using MyEvents = soa::Join; +using MyEventsMC = soa::Join; + +using MyMuonTracks = soa::Join; +using MyMuonTracksMC = soa::Join; +using MyMftTracks = soa::Join; +using MyMftTracksMC = soa::Join; + +// bit maps used for the Fill functions of the VarManager +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended; +constexpr static uint32_t gkMCEventFillMap = VarManager::ObjTypes::ReducedEventMC; +constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra; + +void DefineHistograms(HistogramManager* histMan, TString histClasses); + +struct taskFwdTrackPid { + Produces fwdPidAllList; + + HistogramManager* fHistMan; + OutputObj fOutputList{"output"}; + + Configurable fConfigMaxDCA{"cfgMaxDCA", 0.5f, "Manually set maximum DCA of the track"}; + Configurable downSampleFactor{"downSampleFactor", 1., "Fraction of candidates to keep for ML"}; + Configurable fConfigMCGenSignals{"cfgMCGenSignals", "", "Comma separated list of MC signals (generated)"}; + Configurable fConfigMCRecSignals{"cfgMCRecSignals", "", "Comma separated list of MC signals (reconstructed)"}; + + std::vector fGenMCSignalsNames; + std::vector fRecMCSignalsNames; + std::vector fGenMCSignals; + std::vector fRecMCSignals; + + void init(o2::framework::InitContext& context) + { + if (context.mOptions.get("processDummy")) { + return; + } + + fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars); + fHistMan->SetUseDefaultVariableNames(kTRUE); + fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); + + TString histNames = ""; + + 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); + histNames += Form("MCTruthGen_%s;", sig->GetName()); // TODO: Add these names to a std::vector to avoid using Form in the process function + } + } + } + + DefineHistograms(fHistMan, histNames.Data()); // define all histograms + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + fOutputList.setObject(fHistMan->GetMainHistogramList()); + + TString sigNamesStr = fConfigMCRecSignals.value; + std::unique_ptr objRecSigArray(sigNamesStr.Tokenize(",")); + if (!sigNamesStr.IsNull()) { + for (int isig = 0; isig < objRecSigArray->GetEntries(); ++isig) { + MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objRecSigArray->At(isig)->GetName()); + if (sig) { + if (sig->GetNProngs() == 1) { + fRecMCSignals.push_back(*sig); + fRecMCSignalsNames.push_back(sig->GetName()); + } + } + } + } + // Setting the MC rec signal names + for (int isig = 0; isig < objRecSigArray->GetEntries(); ++isig) { + MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(objRecSigArray->At(isig)->GetName()); + if (sig) { + if (sig->GetNProngs() != 1) { // NOTE: 2-prong signals required + continue; + } + fRecMCSignals.push_back(*sig); + } + } + } + + // Template function to pair mft tracks and muon tracks + 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); + } + } + if constexpr (TMatchedOnly == false) { + for (const auto& mftTrack : mftTracks) { + if (TMath::Abs(mftTrack.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(mftTrack.fwdDcaY()) < fConfigMaxDCA) { + if (downSampleFactor < 1.) { + float pseudoRndm = mftTrack.pt() * 1000. - (int64_t)(mftTrack.pt() * 1000); + if (pseudoRndm >= downSampleFactor) { + 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); + } + } + } + } + + // Template function to run over reconstructed tracks + template + void runFwdTrackPidMC(TEvent const& event, Muons const& muons, MftTracks const& mftTracks, TEventsMC const& /*eventsMC*/, TTracksMC const& /*tracksMC*/) + { + 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); + } + } + + 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); + } + } + } + } + + // Template function to run over MC tracks + template + void runMCGen(TTracksMC& groupedMCTracks) + { + 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); + } + } + } + } + + PresliceUnsorted perReducedMcEvent = aod::reducedtrackMC::reducedMCeventId; + + void processFwdPidMatched(MyEvents::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) + { + if (muons.size() > 0 && mftTracks.size() > 0) { + runFwdTrackPid(event, muons, mftTracks); + } + } + + void processFwdPidMatchedOnly(MyEvents::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) + { + if (muons.size() > 0) { + runFwdTrackPid(event, muons, mftTracks); + } + } + + void processFwdPidMatchedMC(MyEventsMC::iterator const& event, MyMuonTracksMC const& muons, MyMftTracksMC const& mftTracks, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) + { + if (muons.size() > 0 && mftTracks.size() > 0) { + runFwdTrackPidMC(event, muons, mftTracks, eventsMC, tracksMC); + } + auto groupedMCTracks = tracksMC.sliceBy(perReducedMcEvent, event.reducedMCevent().globalIndex()); + groupedMCTracks.bindInternalIndicesTo(&tracksMC); + runMCGen(groupedMCTracks); + } + void processFwdPidMatchedOnlyMC(MyEventsMC::iterator const& event, MyMuonTracksMC const& muons, MyMftTracksMC const& mftTracks, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) + { + if (muons.size() > 0) { + runFwdTrackPidMC(event, muons, mftTracks, eventsMC, tracksMC); + } + auto groupedMCTracks = tracksMC.sliceBy(perReducedMcEvent, event.reducedMCevent().globalIndex()); + groupedMCTracks.bindInternalIndicesTo(&tracksMC); + runMCGen(groupedMCTracks); + } + + void processDummy(MyEvents&) + { + // do nothing + } + + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatched, "Run MFT - muon track pairing filling tree with MFT and global tracks", false); + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatchedOnly, "Run MFT - muon track pairing filling tree with global tracks only", false); + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatchedMC, "Run MFT - muon track pairing filling tree with MFT and global tracks and MC info", false); + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatchedOnlyMC, "Run MFT - muon track pairing filling tree with global tracks only and MC info", false); + PROCESS_SWITCH(taskFwdTrackPid, processDummy, "Dummy function", false); +}; // End of struct taskFwdTrackPid + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} + +void DefineHistograms(HistogramManager* histMan, TString histClasses) +{ + 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()); + + 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(), "Phi", "MC generator #varphi distribution", false, 50, 0.0, 2. * TMath::Pi(), VarManager::kMCPhi); + } + + } // end loop over histogram classes +} diff --git a/PWGDQ/Tasks/taskJpsiHf.cxx b/PWGDQ/Tasks/taskJpsiHf.cxx index 0b00497c3d8..79d9348940a 100644 --- a/PWGDQ/Tasks/taskJpsiHf.cxx +++ b/PWGDQ/Tasks/taskJpsiHf.cxx @@ -48,7 +48,7 @@ static const std::vector labelsCutsBdt = {"BDT background", "BDT pr // Declarations of various short names using MyRedEvents = aod::RedJpDmColls; using MyRedPairCandidatesSelected = aod::RedJpDmDileptons; -using MyRedD0CandidatesSelected = soa::Join; +using MyRedD0CandidatesSelected = soa::Join; struct taskJPsiHf { // @@ -60,7 +60,7 @@ struct taskJPsiHf { // HF configurables Configurable massHfCandMin{"massHfCandMin", 1.5f, "minimum HF mass"}; - Configurable massHfCandMax{"massHfCandMax", 2.1f, "maximum HF mass"}; + Configurable massHfCandMax{"massHfCandMax", 2.3f, "maximum HF mass"}; Configurable> binsPtDmesForBdt{"binsPtDmesForBdt", std::vector{bdtcuts::binsPt, bdtcuts::binsPt + bdtcuts::nBinsPt + 1}, "pT bin limits for BDT cuts"}; Configurable> cutsDmesBdt{"cutsDmesBdt", {bdtcuts::bdtCuts[0], bdtcuts::nBinsPt, 3, bdtcuts::labelsPt, bdtcuts::labelsCutsBdt}, "D-meson BDT selections per pT bin"}; @@ -68,6 +68,10 @@ struct taskJPsiHf { Configurable massDileptonCandMin{"massDileptonCandMin", 1.f, "minimum dilepton mass"}; Configurable massDileptonCandMax{"massDileptonCandMax", 5.f, "maximum dilepton mass"}; + // Preslices for unsorted indexes + PresliceUnsorted perCollisionDilepton = aod::jpsidmescorr::redJpDmCollId; + PresliceUnsorted perCollisionDmeson = aod::jpsidmescorr::redJpDmCollId; + // histogram for normalisation std::shared_ptr hCollisions; HistogramRegistry registry{"registry"}; @@ -95,7 +99,7 @@ struct taskJPsiHf { for (auto& dilepton : dileptons) { ptDilepton = RecoDecay::pt(dilepton.px(), dilepton.py()); - rapDilepton = RecoDecay::y(std::array{dilepton.px(), dilepton.py(), dilepton.pz()}, dilepton.mass()); + rapDilepton = RecoDecay::y(std::array{dilepton.px(), dilepton.py(), dilepton.pz()}, constants::physics::MassJPsi); phiDilepton = RecoDecay::phi(dilepton.px(), dilepton.py()); for (auto& dmeson : dmesons) { @@ -108,35 +112,44 @@ struct taskJPsiHf { continue; } + auto minItsClsDmesDau = (dmeson.numItsClsDmesProng0() < dmeson.numItsClsDmesProng1()) ? dmeson.numItsClsDmesProng0() : dmeson.numItsClsDmesProng1(); + auto minTpcCrossRowsDmesDau = (dmeson.numTpcCrossedRowsDmesProng0() < dmeson.numTpcCrossedRowsDmesProng1()) ? dmeson.numTpcCrossedRowsDmesProng0() : dmeson.numTpcCrossedRowsDmesProng1(); + auto minPtDmesDau = (dmeson.ptDmesProng0() < dmeson.ptDmesProng1()) ? dmeson.ptDmesProng0() : dmeson.ptDmesProng1(); + auto minAbsEtaDmesDau = (std::abs(dmeson.etaDmesProng0()) < std::abs(dmeson.etaDmesProng1())) ? std::abs(dmeson.etaDmesProng0()) : std::abs(dmeson.etaDmesProng1()); + if (dmeson.massD0() > 0) { - rapDmeson = RecoDecay::y(std::array{dmeson.px(), dmeson.py(), dmeson.pz()}, dmeson.massD0()); + rapDmeson = RecoDecay::y(std::array{dmeson.px(), dmeson.py(), dmeson.pz()}, constants::physics::MassD0); deltaRap = rapDilepton - rapDmeson; auto bdtBkg = dmeson.bdtBkgMassHypo0(); auto bdtPrompt = dmeson.bdtPromptMassHypo0(); auto bdtNonPrompt = dmeson.bdtNonpromptMassHypo0(); if ((dilepton.mass() > massDileptonCandMin && dilepton.mass() < massDileptonCandMax) && (dmeson.massD0() > massHfCandMin && dmeson.massD0() < massHfCandMax && bdtBkg < cutsDmesBdt->get(ptBinDmesForBdt, "BDT background") && bdtPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT prompt") && bdtNonPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT nonprompt"))) { - redDileptDimesAll(dilepton.mass(), dmeson.massD0(), ptDilepton, ptDmeson, rapDilepton, rapDmeson, phiDilepton, phiDmeson, deltaRap, deltaPhi, bdtBkg, bdtPrompt, bdtNonPrompt); + redDileptDimesAll(dilepton.mass(), dmeson.massD0(), ptDilepton, ptDmeson, rapDilepton, rapDmeson, phiDilepton, phiDmeson, deltaRap, deltaPhi, bdtBkg, bdtPrompt, bdtNonPrompt, minItsClsDmesDau, minTpcCrossRowsDmesDau, minPtDmesDau, minAbsEtaDmesDau); } } if (dmeson.massD0bar() > 0) { - rapDmeson = RecoDecay::y(std::array{dmeson.px(), dmeson.py(), dmeson.pz()}, dmeson.massD0bar()); + rapDmeson = RecoDecay::y(std::array{dmeson.px(), dmeson.py(), dmeson.pz()}, constants::physics::MassD0); deltaRap = rapDilepton - rapDmeson; auto bdtBkg = dmeson.bdtBkgMassHypo1(); auto bdtPrompt = dmeson.bdtPromptMassHypo1(); auto bdtNonPrompt = dmeson.bdtNonpromptMassHypo1(); - if ((dilepton.mass() > massDileptonCandMin && dilepton.mass() < massDileptonCandMax) && (dmeson.massD0() > massHfCandMin && dmeson.massD0() < massHfCandMax && bdtBkg < cutsDmesBdt->get(ptBinDmesForBdt, "BDT background") && bdtPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT prompt") && bdtNonPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT nonprompt"))) { - redDileptDimesAll(dilepton.mass(), dmeson.massD0bar(), ptDilepton, ptDmeson, rapDilepton, rapDmeson, phiDilepton, phiDmeson, deltaRap, deltaPhi, bdtBkg, bdtPrompt, bdtNonPrompt); + if ((dilepton.mass() > massDileptonCandMin && dilepton.mass() < massDileptonCandMax) && (dmeson.massD0bar() > massHfCandMin && dmeson.massD0bar() < massHfCandMax && bdtBkg < cutsDmesBdt->get(ptBinDmesForBdt, "BDT background") && bdtPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT prompt") && bdtNonPrompt > cutsDmesBdt->get(ptBinDmesForBdt, "BDT nonprompt"))) { + redDileptDimesAll(dilepton.mass(), dmeson.massD0bar(), ptDilepton, ptDmeson, rapDilepton, rapDmeson, phiDilepton, phiDmeson, deltaRap, deltaPhi, bdtBkg, bdtPrompt, bdtNonPrompt, minItsClsDmesDau, minTpcCrossRowsDmesDau, minPtDmesDau, minAbsEtaDmesDau); } } } } } - void processRedJspiD0(MyRedEvents::iterator const& event, MyRedPairCandidatesSelected const& dileptons, MyRedD0CandidatesSelected const& dmesons) + void processRedJspiD0(MyRedEvents const& events, MyRedPairCandidatesSelected const& dileptons, MyRedD0CandidatesSelected const& dmesons) { // Fill the column of collisions with pairs - hCollisions->Fill(1.f); - runDileptonDmeson(event, dileptons, dmesons); + for (auto& event : events) { + hCollisions->Fill(1.f); + auto groupedDileptonCandidates = dileptons.sliceBy(perCollisionDilepton, event.index()); + auto groupedDmesonCandidates = dmesons.sliceBy(perCollisionDmeson, event.index()); + runDileptonDmeson(event, groupedDileptonCandidates, groupedDmesonCandidates); + } } void processNormCounter(RedJpDmColCounts const& normCounters) diff --git a/PWGDQ/Tasks/v0selector.cxx b/PWGDQ/Tasks/v0selector.cxx index cdb61eee77c..e5489fc33b6 100644 --- a/PWGDQ/Tasks/v0selector.cxx +++ b/PWGDQ/Tasks/v0selector.cxx @@ -19,6 +19,8 @@ // #include #include +#include +#include #include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -301,7 +303,7 @@ struct v0selector { registry.fill(HIST("hMassGamma"), V0radius, mGamma); registry.fill(HIST("hV0Psi"), psipair, mGamma); } - if (mGamma < v0max_mee && TMath::Abs(V0.posTrack_as().tpcNSigmaEl()) < 5 && TMath::Abs(V0.negTrack_as().tpcNSigmaEl()) < 5 && psipair < maxpsipair) { + if (mGamma < v0max_mee && TMath::Abs(V0.posTrack_as().tpcNSigmaEl()) < 5 && TMath::Abs(V0.negTrack_as().tpcNSigmaEl()) < 5 && TMath::Abs(psipair) < maxpsipair) { pidmap[V0.posTrackId()] |= (uint8_t(1) << kGamma); pidmap[V0.negTrackId()] |= (uint8_t(1) << kGamma); if (fillhisto) { diff --git a/PWGEM/Dilepton/Core/DielectronCut.cxx b/PWGEM/Dilepton/Core/DielectronCut.cxx index da10ac6f928..3d1987801cc 100644 --- a/PWGEM/Dilepton/Core/DielectronCut.cxx +++ b/PWGEM/Dilepton/Core/DielectronCut.cxx @@ -13,13 +13,14 @@ // Class for dilepton Cut // +#include +#include + #include "Framework/Logger.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" ClassImp(DielectronCut); -const char* DielectronCut::mCutNames[static_cast(DielectronCut::DielectronCuts::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"}; - const std::pair> DielectronCut::its_ib_any_Requirement = {1, {0, 1, 2}}; // hits on any ITS ib layers. const std::pair> DielectronCut::its_ib_1st_Requirement = {1, {0}}; // hit on 1st ITS ib layers. @@ -47,16 +48,42 @@ void DielectronCut::SetMeeRange(float min, float max) mMaxMee = max; LOG(info) << "Dielectron Cut, set mee range: " << mMinMee << " - " << mMaxMee; } +void DielectronCut::SetPairOpAng(float minOpAng, float maxOpAng) +{ + mMinOpAng = minOpAng; + mMaxOpAng = maxOpAng; + LOG(info) << "Dielectron Cut, set pair opening angle range: " << mMinOpAng << " - " << mMaxOpAng; +} void DielectronCut::SetMaxPhivPairMeeDep(std::function meeDepCut) { mMaxPhivPairMeeDep = meeDepCut; LOG(info) << "Dielectron Cut, set max phiv pair mee dep: " << mMaxPhivPairMeeDep(0.02); } +void DielectronCut::SetPhivPairRange(float min_phiv, float max_phiv, float min_mee, float max_mee) +{ + mMinPhivPair = min_phiv; + mMaxPhivPair = max_phiv; + mMinMeeForPhivPair = min_mee; + mMaxMeeForPhivPair = max_mee; + LOG(info) << "Dielectron Cut, set phiv range: " << mMinPhivPair << " - " << mMaxPhivPair << " and mee range: " << mMinMeeForPhivPair << " - " << mMaxMeeForPhivPair; +} 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) +{ + mApplydEtadPhi = flag; + mMinDeltaEta = min_deta; + mMinDeltaPhi = min_dphi; + LOG(info) << "Dielectron Cut, set apply deta-dphi cut: " << mApplydEtadPhi << " min_deta: " << mMinDeltaEta << " min_dphi: " << mMinDeltaPhi; +} +void DielectronCut::SetRequireDifferentSides(bool flag) +{ + mRequireDiffSides = flag; + LOG(info) << "Dielectron Cut, require 2 tracks to be from different sides: " << mRequireDiffSides; +} void DielectronCut::SetTrackPtRange(float minPt, float maxPt) { mMinTrackPt = minPt; @@ -69,6 +96,12 @@ 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) +{ + mMinTrackPhi = minPhi; + mMaxTrackPhi = maxPhi; + LOG(info) << "Dielectron Cut, set track phi range (rad.): " << mMinTrackPhi << " - " << mMaxTrackPhi; +} void DielectronCut::SetMinNClustersTPC(int minNClustersTPC) { mMinNClustersTPC = minNClustersTPC; @@ -84,6 +117,17 @@ void DielectronCut::SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedR mMinNCrossedRowsOverFindableClustersTPC = minNCrossedRowsOverFindableClustersTPC; LOG(info) << "Dielectron Cut, set min N crossed rows over findable clusters TPC: " << mMinNCrossedRowsOverFindableClustersTPC; } +void DielectronCut::SetMaxFracSharedClustersTPC(float max) +{ + mMaxFracSharedClustersTPC = max; + LOG(info) << "Dielectron Cut, set max fraction of shared clusters in TPC: " << mMaxFracSharedClustersTPC; +} +void DielectronCut::SetRelDiffPin(float min, float max) +{ + mMinRelDiffPin = min; + mMaxRelDiffPin = max; + LOG(info) << "Dielectron Cut, set rel. diff. between Pin and Ppv range: " << mMinRelDiffPin << " - " << mMaxRelDiffPin; +} void DielectronCut::SetChi2PerClusterTPC(float min, float max) { mMinChi2PerClusterTPC = min; @@ -103,30 +147,39 @@ void DielectronCut::SetChi2PerClusterITS(float min, float max) mMaxChi2PerClusterITS = max; LOG(info) << "Dielectron Cut, set chi2 per cluster ITS range: " << mMinChi2PerClusterITS << " - " << mMaxChi2PerClusterITS; } -void DielectronCut::SetMeanClusterSizeITSob(float min, float max) +void DielectronCut::SetMeanClusterSizeITS(float min, float max, float minP, float maxP) { mMinMeanClusterSizeITS = min; mMaxMeanClusterSizeITS = max; + mMinP_ITSClusterSize = minP; + mMaxP_ITSClusterSize = maxP; LOG(info) << "Dielectron Cut, set mean cluster size ITS range: " << mMinMeanClusterSizeITS << " - " << mMaxMeanClusterSizeITS; } -void DielectronCut::SetDca3DRange(float min, float max) +void DielectronCut::SetChi2TOF(float min, float max) +{ + mMinChi2TOF = min; + mMaxChi2TOF = max; + LOG(info) << "Dielectron Cut, set chi2 TOF range: " << mMinChi2TOF << " - " << mMaxChi2TOF; +} + +void DielectronCut::SetTrackDca3DRange(float min, float max) { mMinDca3D = min; mMaxDca3D = max; LOG(info) << "Dielectron Cut, set DCA 3D range in sigma: " << mMinDca3D << " - " << mMaxDca3D; } -void DielectronCut::SetMaxDcaXY(float maxDcaXY) +void DielectronCut::SetTrackMaxDcaXY(float maxDcaXY) { mMaxDcaXY = maxDcaXY; LOG(info) << "Dielectron Cut, set max DCA xy: " << mMaxDcaXY; } -void DielectronCut::SetMaxDcaZ(float maxDcaZ) +void DielectronCut::SetTrackMaxDcaZ(float maxDcaZ) { mMaxDcaZ = maxDcaZ; LOG(info) << "Dielectron Cut, set max DCA z: " << mMaxDcaZ; } -void DielectronCut::SetMaxDcaXYPtDep(std::function ptDepCut) +void DielectronCut::SetTrackMaxDcaXYPtDep(std::function ptDepCut) { mMaxDcaXYPtDep = ptDepCut; LOG(info) << "Dielectron Cut, set max DCA xy pt dep: " << mMaxDcaXYPtDep(1.0); @@ -159,12 +212,11 @@ void DielectronCut::SetMuonExclusionTPC(bool flag) LOG(info) << "Dielectron Cut, set flag for muon exclusion in TPC: " << mMuonExclusionTPC; } -void DielectronCut::SetTOFbetaRange(bool flag, float min, float max) +void DielectronCut::SetTOFbetaRange(float min, float max) { - mApplyTOFbeta = flag; mMinTOFbeta = min; mMaxTOFbeta = max; - LOG(info) << "Dielectron Cut, set TOF beta rejection range: " << mMinTOFbeta << " - " << mMaxTOFbeta; + LOG(info) << "Dielectron Cut, set TOF beta range (TOFif): " << mMinTOFbeta << " - " << mMaxTOFbeta; } void DielectronCut::SetTPCNsigmaElRange(float min, float max) @@ -233,6 +285,11 @@ 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) +{ + mMaxPinForPionRejectionTPC = max; + LOG(info) << "Dielectron Cut, set max pin for pion rejection in TPC: " << mMaxPinForPionRejectionTPC; +} void DielectronCut::RequireITSibAny(bool flag) { mRequireITSibAny = flag; @@ -243,38 +300,3 @@ void DielectronCut::RequireITSib1st(bool flag) mRequireITSib1st = flag; LOG(info) << "Dielectron Cut, require ITS ib 1st: " << mRequireITSib1st; } - -void DielectronCut::print() const -{ - LOG(info) << "Dalitz EE Cut:"; - for (int i = 0; i < static_cast(DielectronCuts::kNCuts); i++) { - switch (static_cast(i)) { - case DielectronCuts::kTrackPtRange: - LOG(info) << mCutNames[i] << " in [" << mMinTrackPt << ", " << mMaxTrackPt << "]"; - break; - case DielectronCuts::kTrackEtaRange: - LOG(info) << mCutNames[i] << " in [" << mMinTrackEta << ", " << mMaxTrackEta << "]"; - break; - case DielectronCuts::kTPCNCls: - LOG(info) << mCutNames[i] << " > " << mMinNClustersTPC; - break; - case DielectronCuts::kTPCCrossedRows: - LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsTPC; - break; - case DielectronCuts::kTPCCrossedRowsOverNCls: - LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsOverFindableClustersTPC; - break; - case DielectronCuts::kTPCChi2NDF: - LOG(info) << mCutNames[i] << " < " << mMaxChi2PerClusterTPC; - break; - case DielectronCuts::kDCAxy: - LOG(info) << mCutNames[i] << " < " << mMaxDcaXY; - break; - case DielectronCuts::kDCAz: - LOG(info) << mCutNames[i] << " < " << mMaxDcaZ; - break; - default: - LOG(fatal) << "Cut unknown!"; - } - } -} diff --git a/PWGEM/Dilepton/Core/DielectronCut.h b/PWGEM/Dilepton/Core/DielectronCut.h index 16f50e79179..ac3b6d2bb5b 100644 --- a/PWGEM/Dilepton/Core/DielectronCut.h +++ b/PWGEM/Dilepton/Core/DielectronCut.h @@ -24,8 +24,7 @@ #include "TNamed.h" #include "Math/Vector4D.h" -#include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" #include "Framework/Logger.h" #include "Framework/DataTypes.h" @@ -34,12 +33,14 @@ #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; +using namespace o2::aod::pwgem::dilepton::utils::pairutil; class DielectronCut : public TNamed { public: DielectronCut() = default; DielectronCut(const char* name, const char* title) : TNamed(name, title) {} + ~DielectronCut() {} enum class DielectronCuts : int { // pair cut @@ -51,9 +52,12 @@ class DielectronCut : public TNamed // track cut kTrackPtRange, kTrackEtaRange, + kTrackPhiRange, kTPCNCls, kTPCCrossedRows, kTPCCrossedRowsOverNCls, + kTPCFracSharedClusters, + kRelDiffPin, kTPCChi2NDF, kTPCNsigmaEl, kTPCNsigmaMu, @@ -70,11 +74,10 @@ class DielectronCut : public TNamed kDCAz, kITSNCls, kITSChi2NDF, - kITSCluserSize, + kITSClusterSize, kPrefilter, kNCuts }; - static const char* mCutNames[static_cast(DielectronCuts::kNCuts)]; enum class PIDSchemes : int { kUnDef = -1, @@ -83,7 +86,8 @@ class DielectronCut : public TNamed kTPChadrejORTOFreq = 2, kTPConly = 3, kTOFif = 4, - kPIDML = 5 + kPIDML = 5, + kTPChadrejORTOFreq_woTOFif = 6 }; template @@ -104,46 +108,76 @@ class DielectronCut : public TNamed return true; } - template + template bool IsSelectedPair(TTrack1 const& t1, TTrack2 const& t2, const float bz) 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); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dca_t1_3d = dca3DinSigma(t1); - float dca_t2_3d = dca3DinSigma(t2); - float dca_ee_3d = std::sqrt((dca_t1_3d * dca_t1_3d + dca_t2_3d * dca_t2_3d) / 2.); - 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(), bz); + float dca_ee_3d = pairDCAQuadSum(dca3DinSigma(t1), dca3DinSigma(t2)); + float phiv = getPhivPair(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz(), t1.sign(), t2.sign(), bz); + float opAng = getOpeningAngle(t1.px(), t1.py(), t1.pz(), t2.px(), t2.py(), t2.pz()); if (v12.M() < mMinMee || mMaxMee < v12.M()) { return false; } - if (v12.Rapidity() < mMinPairY || mMaxPairY < v12.Rapidity()) { + if (!dont_require_rapidity && (v12.Rapidity() < mMinPairY || mMaxPairY < v12.Rapidity())) { return false; } - if (mApplyPhiV && ((phiv < mMinPhivPair || (mMaxPhivPairMeeDep ? mMaxPhivPairMeeDep(v12.M()) : mMaxPhivPair) < phiv) ^ mSelectPC)) { - return false; + if (mApplyPhiV) { + if (mMaxPhivPairMeeDep) { + if ((phiv < mMinPhivPair || mMaxPhivPairMeeDep(v12.M()) < phiv) ^ mSelectPC) { + return false; + } + } else { + if ((!(mMinPhivPair < phiv && phiv < mMaxPhivPair) && !(mMinMeeForPhivPair < v12.M() && v12.M() < mMaxMeeForPhivPair)) ^ mSelectPC) { + return false; + } + } } + if (dca_ee_3d < mMinPairDCA3D || mMaxPairDCA3D < dca_ee_3d) { // in sigma for pair return false; } + + if (opAng < mMinOpAng || mMaxOpAng < opAng) { // in sigma for pair + return false; + } + + if (mRequireDiffSides && t1.eta() * t2.eta() > 0.0) { + return false; + } + + float deta = v1.Eta() - v2.Eta(); + float dphi = v1.Phi() - v2.Phi(); + o2::math_utils::bringToPMPi(dphi); + if (mApplydEtadPhi && std::pow(deta / mMinDeltaEta, 2) + std::pow(dphi / mMinDeltaPhi, 2) < 1.f) { + return false; + } + return true; } - template + template bool IsSelectedTrack(TTrack const& track, TCollision const& collision = 0) const { if (!track.hasITS() || !track.hasTPC()) { // track has to be ITS-TPC matched track return false; } - if (!IsSelectedTrack(track, DielectronCuts::kTrackPtRange)) { - return false; + if (!dont_require_pteta) { + if (!IsSelectedTrack(track, DielectronCuts::kTrackPtRange)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTrackEtaRange)) { + return false; + } } - if (!IsSelectedTrack(track, DielectronCuts::kTrackEtaRange)) { + + if (!IsSelectedTrack(track, DielectronCuts::kTrackPhiRange)) { return false; } if (!IsSelectedTrack(track, DielectronCuts::kDCA3Dsigma)) { @@ -163,7 +197,7 @@ class DielectronCut : public TNamed if (!IsSelectedTrack(track, DielectronCuts::kITSChi2NDF)) { return false; } - if (!IsSelectedTrack(track, DielectronCuts::kITSCluserSize)) { + if (!IsSelectedTrack(track, DielectronCuts::kITSClusterSize)) { return false; } @@ -191,15 +225,17 @@ class DielectronCut : public TNamed if (!IsSelectedTrack(track, DielectronCuts::kTPCCrossedRowsOverNCls)) { return false; } - if (!IsSelectedTrack(track, DielectronCuts::kTPCChi2NDF)) { + if (!IsSelectedTrack(track, DielectronCuts::kTPCFracSharedClusters)) { return false; } - - if (mApplyPF && !IsSelectedTrack(track, DielectronCuts::kPrefilter)) { + if (!IsSelectedTrack(track, DielectronCuts::kRelDiffPin)) { + return false; + } + if (!IsSelectedTrack(track, DielectronCuts::kTPCChi2NDF)) { return false; } - if (mApplyTOFbeta && (mMinTOFbeta < track.beta() && track.beta() < mMaxTOFbeta)) { + if (mApplyPF && !IsSelectedTrack(track, DielectronCuts::kPrefilter)) { return false; } @@ -220,19 +256,12 @@ class DielectronCut : public TNamed template bool PassPIDML(TTrack const& track, TCollision const& collision) const { - std::vector inputFeatures{static_cast(collision.numContrib()), track.p(), track.tgl(), - track.tpcNSigmaEl(), /*track.tpcNSigmaMu(),*/ track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.tofNSigmaEl(), /*track.tofNSigmaMu(),*/ track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl()))}; - - // calculate classifier - float prob_ele = mPIDModel->evalModel(inputFeatures)[0]; - // LOGF(info, "prob_ele = %f", prob_ele); - if (prob_ele < 0.95) { + /*if (!PassTOFif(track)) { // Allows for pre-selection. But potentially dangerous if analyzers are not aware of it return false; - } else { - return true; - } + }*/ + std::vector inputFeatures = mPIDMlResponse->getInputFeatures(track, collision); + float binningFeature = mPIDMlResponse->getBinningFeature(track, collision); + return mPIDMlResponse->isSelectedMl(inputFeatures, binningFeature); } template @@ -257,6 +286,9 @@ class DielectronCut : public TNamed case static_cast(PIDSchemes::kPIDML): return true; // don't use kPIDML here. + case static_cast(PIDSchemes::kTPChadrejORTOFreq_woTOFif): + return PassTPConlyhadrej(track) || PassTOFreq(track); + case static_cast(PIDSchemes::kUnDef): return true; @@ -269,8 +301,8 @@ class DielectronCut : public TNamed bool PassTOFreq(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 = mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl; + 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); return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; } @@ -279,26 +311,37 @@ class DielectronCut : public TNamed { 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_pi_excluded_TPC = track.tpcNSigmaPi() < mMinTPCNsigmaPi || mMaxTPCNsigmaPi < track.tpcNSigmaPi(); + 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(); - return is_el_included_TPC && is_mu_excluded_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_excluded_TPC; + bool is_el_included_TOF = track.hasTOF() ? (mMinTOFNsigmaEl < track.tofNSigmaEl() && track.tofNSigmaEl() < mMaxTOFNsigmaEl && track.tofChi2() < mMaxChi2TOF) : 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; } template bool PassTPConly(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(); - return is_el_included_TPC && is_pi_excluded_TPC; + 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_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(); + return is_el_included_TPC && is_mu_excluded_TPC && is_pi_excluded_TPC && is_ka_excluded_TPC && is_pr_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) : true; + 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; return is_el_included_TPC && is_pi_excluded_TPC && is_el_included_TOF; } @@ -312,6 +355,9 @@ class DielectronCut : public TNamed case DielectronCuts::kTrackEtaRange: return track.eta() >= mMinTrackEta && track.eta() <= mMaxTrackEta; + case DielectronCuts::kTrackPhiRange: + return track.phi() >= mMinTrackPhi && track.phi() <= mMaxTrackPhi; + case DielectronCuts::kTPCNCls: return track.tpcNClsFound() >= mMinNClustersTPC; @@ -321,6 +367,12 @@ class DielectronCut : public TNamed case DielectronCuts::kTPCCrossedRowsOverNCls: return track.tpcCrossedRowsOverFindableCls() >= mMinNCrossedRowsOverFindableClustersTPC; + case DielectronCuts::kTPCFracSharedClusters: + return track.tpcFractionSharedCls() <= mMaxFracSharedClustersTPC; + + case DielectronCuts::kRelDiffPin: + return mMinRelDiffPin < (track.tpcInnerParam() - track.p()) / track.p() && (track.tpcInnerParam() - track.p()) / track.p() < mMaxRelDiffPin; + case DielectronCuts::kTPCChi2NDF: return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; @@ -339,8 +391,8 @@ class DielectronCut : public TNamed case DielectronCuts::kITSChi2NDF: return mMinChi2PerClusterITS < track.itsChi2NCl() && track.itsChi2NCl() < mMaxChi2PerClusterITS; - case DielectronCuts::kITSCluserSize: - return mMinMeanClusterSizeITS < track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl())) && track.meanClusterSizeITSob() * std::cos(std::atan(track.tgl())) < mMaxMeanClusterSizeITS; + 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; @@ -355,23 +407,31 @@ class DielectronCut : public TNamed void SetPairYRange(float minY = -1e10f, float maxY = 1e10f); void SetPairDCARange(float min = 0.f, float max = 1e10f); // 3D DCA in sigma void SetMeeRange(float min = 0.f, float max = 0.5); + void SetPairOpAng(float minOpAng = 0.f, float maxOpAng = 1e10f); void SetMaxPhivPairMeeDep(std::function meeDepCut); + void SetPhivPairRange(float min_phiv, float max_phiv, float min_mee, float max_mee); void SelectPhotonConversion(bool flag); + void SetMindEtadPhi(bool flag, 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 SetMinNClustersTPC(int minNClustersTPC); void SetMinNCrossedRowsTPC(int minNCrossedRowsTPC); void SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRowsOverFindableClustersTPC); + void SetMaxFracSharedClustersTPC(float max); + void SetRelDiffPin(float min, float max); void SetChi2PerClusterTPC(float min, float max); void SetNClustersITS(int min, int max); void SetChi2PerClusterITS(float min, float max); - void SetMeanClusterSizeITSob(float min, float max); + void SetMeanClusterSizeITS(float min, float max, float minP = 0.f, float maxP = 0.f); + void SetChi2TOF(float min, float max); void SetPIDScheme(int scheme); void SetMinPinTOF(float min); void SetMuonExclusionTPC(bool flag); - void SetTOFbetaRange(bool flag, float min, float max); + void SetTOFbetaRange(float min, float max); void SetTPCNsigmaElRange(float min = -1e+10, float max = 1e+10); void SetTPCNsigmaMuRange(float min = -1e+10, float max = 1e+10); void SetTPCNsigmaPiRange(float min = -1e+10, float max = 1e+10); @@ -383,27 +443,25 @@ class DielectronCut : public TNamed void SetTOFNsigmaKaRange(float min = -1e+10, float max = 1e+10); void SetTOFNsigmaPrRange(float min = -1e+10, float max = 1e+10); void SetMaxPinMuonTPConly(float max); + void SetMaxPinForPionRejectionTPC(float max); void RequireITSibAny(bool flag); void RequireITSib1st(bool flag); - void SetDca3DRange(float min, float max); // in sigma - void SetMaxDcaXY(float maxDcaXY); // in cm - void SetMaxDcaZ(float maxDcaZ); // in cm - void SetMaxDcaXYPtDep(std::function ptDepCut); + 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 ApplyPrefilter(bool flag); void ApplyPhiV(bool flag); - void SetPIDModel(o2::ml::OnnxModel* model) + void SetPIDMlResponse(o2::analysis::MlResponseDielectronSingleTrack* mlResponse) { - mPIDModel = model; + mPIDMlResponse = mlResponse; } // 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; @@ -413,23 +471,34 @@ class DielectronCut : public TNamed float mMinPairY{-1e10f}, mMaxPairY{1e10f}; // range in rapidity float mMinPairDCA3D{0.f}, mMaxPairDCA3D{1e10f}; // range in 3D DCA in sigma float mMinPhivPair{0.f}, mMaxPhivPair{+3.2}; + float mMinMeeForPhivPair{0.f}, mMaxMeeForPhivPair{1e10f}; std::function mMaxPhivPairMeeDep{}; // max phiv as a function of mee bool mSelectPC{false}; // flag to select photon conversion used in mMaxPhivPairMeeDep + bool mApplydEtadPhi{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 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 // 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 cut for muon ID with TPConly bool mRequireITSibAny{true}; bool mRequireITSib1st{false}; + float mMinChi2TOF{-1e10f}, mMaxChi2TOF{1e10f}; // max tof chi2 per float mMinDca3D{0.0f}; // min dca in 3D in units of sigma float mMaxDca3D{1e+10}; // max dca in 3D in units of sigma @@ -439,13 +508,13 @@ class DielectronCut : public TNamed bool mApplyPhiV{true}; bool mApplyPF{false}; float mMinMeanClusterSizeITS{-1e10f}, mMaxMeanClusterSizeITS{1e10f}; // max x cos(Lmabda) + float mMinP_ITSClusterSize{0.0}, mMaxP_ITSClusterSize{0.0}; // pid cuts int mPIDScheme{-1}; float mMinPinTOF{0.0f}; // min pin cut for TOF. bool mMuonExclusionTPC{false}; // flag to reject muon in TPC for low B - bool mApplyTOFbeta{false}; // flag to reject hadron contamination with TOF - float mMinTOFbeta{0.0}, mMaxTOFbeta{0.96}; + float mMinTOFbeta{-999}, mMaxTOFbeta{999}; float mMinTPCNsigmaEl{-1e+10}, mMaxTPCNsigmaEl{+1e+10}; float mMinTPCNsigmaMu{-1e+10}, mMaxTPCNsigmaMu{+1e+10}; float mMinTPCNsigmaPi{-1e+10}, mMaxTPCNsigmaPi{+1e+10}; @@ -457,7 +526,7 @@ class DielectronCut : public TNamed float mMinTOFNsigmaPi{-1e+10}, mMaxTOFNsigmaPi{+1e+10}; float mMinTOFNsigmaKa{-1e+10}, mMaxTOFNsigmaKa{+1e+10}; float mMinTOFNsigmaPr{-1e+10}, mMaxTOFNsigmaPr{+1e+10}; - o2::ml::OnnxModel* mPIDModel{nullptr}; + o2::analysis::MlResponseDielectronSingleTrack* mPIDMlResponse{nullptr}; ClassDef(DielectronCut, 1); }; diff --git a/PWGEM/Dilepton/Core/Dilepton.h b/PWGEM/Dilepton/Core/Dilepton.h new file mode 100644 index 00000000000..70580bbdc74 --- /dev/null +++ b/PWGEM/Dilepton/Core/Dilepton.h @@ -0,0 +1,1619 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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_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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "DCAFitter/DCAFitterN.h" +#include "DCAFitter/FwdDCAFitterN.h" +#include "CommonConstants/LHCConstants.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.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 "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" + +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 MyEMH_electron = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrackWithCov>; +using MyEMH_muon = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrackWithCov>; + +template +struct Dilepton { + + // 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 cfgApplySPresolution{"cfgApplySPresolution", false, "flag to apply resolution correction for flow analysis"}; + Configurable spresoPath{"spresoPath", "Users/d/dsekihat/PWGEM/dilepton/Qvector/resolution/LHC23zzh/pass3/test", "Path to SP resolution file"}; + Configurable spresoHistName{"spresoHistName", "h1_R2_FT0M_BPos_BNeg", "histogram name of SP resolution file"}; + + Configurable cfgAnalysisType{"cfgAnalysisType", static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC), "kQC:0, kUPC:1, kFlowV2:2, kFlowV3:3, kPolarization:4, kVM:5, kHFll:6"}; + Configurable cfgEP2Estimator_for_Mix{"cfgEP2Estimator_for_Mix", 3, "FT0M:0, FT0A:1, FT0C:2, BTot:3, BPos:4, BNeg:5"}; + Configurable cfgQvecEstimator{"cfgQvecEstimator", 0, "FT0M:0, FT0A:1, FT0C:2, BTot:3, BPos:4, BNeg:5"}; + 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.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"}; + 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"}; + 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.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 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 ConfSPBins{"ConfSPBins", {200, -5, 5}, "SP bins for flow analysis"}; + + 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 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"}; + } 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_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; + Configurable cfg_apply_phiv_meedep{"cfg_apply_phiv_meedep", true, "flag to apply mee-dependent 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_min_mee_for_phiv{"cfg_min_mee_for_phiv", 0.0, "min mee for phiv (constant)"}; + Configurable cfg_max_mee_for_phiv{"cfg_max_mee_for_phiv", 1e+10, "max mee for phiv (constant)"}; + 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 electrons (elliptic cut)"}; + Configurable cfg_min_dphi{"cfg_min_dphi", 0.2, "min dphi between 2 electrons (elliptic cut)"}; + Configurable cfg_apply_dzrdphi_geom{"cfg_apply_dzrdphi_geom", false, "flag to apply generator dz-rdphi elliptic cut"}; + Configurable cfg_min_dz_geom{"cfg_min_dz_geom", 1.2, "geometrical min dz between 2 electrons (elliptic cut) in cm"}; + Configurable cfg_min_rdphi_geom{"cfg_min_rdphi_geom", 2.4, "geometrical min rdphi between 2 electrons (elliptic cut) in cm"}; + Configurable cfg_min_opang{"cfg_min_opang", 0.0, "min opening angle"}; + Configurable cfg_max_opang{"cfg_max_opang", 6.4, "max opening angle"}; + Configurable cfg_require_diff_sides{"cfg_require_diff_sides", false, "flag to require 2 tracks are from different sides."}; + Configurable cfg_x_to_go{"cfg_x_to_go", -1, "x (cm) to be propagated in local coordinate"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min 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", 0.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "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 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, 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_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 enableTTCA{"enableTTCA", true, "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.1, "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, "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", 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_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"}; + } dimuoncuts; + + 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}; + 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 ep_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; + + float beamM1 = o2::constants::physics::MassProton; // mass of beam + float beamM2 = o2::constants::physics::MassProton; // mass of beam + float beamE1 = 0.f; // beam energy + float beamE2 = 0.f; // beam energy + float beamP1 = 0.f; // beam momentum + float beamP2 = 0.f; // beam momentum + TH2D* h2sp_resolution = nullptr; + + void init(InitContext& /*context*/) + { + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + 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) { + 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 (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]); + } + } + + 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) { + LOGF(info, "VARIABLE_WIDTH: ep_bin_edges = %f", edge); + } + } else { + int nbins = static_cast(ConfEPBins.value[0]); + float xmin = static_cast(ConfEPBins.value[1]); + float xmax = static_cast(ConfEPBins.value[2]); + ep_bin_edges.resize(nbins + 1); + for (int i = 0; i < nbins + 1; i++) { + ep_bin_edges[i] = (xmax - xmin) / (nbins)*i + xmin; + LOGF(info, "FIXED_WIDTH: ep_bin_edges[%d] = %f", i, ep_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 (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); + emh_neg = new TEMH(ndepth); + + DefineEMEventCut(); + addhistograms(); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + 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 (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 (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; + } + + 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(); + // 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); + int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamA); + int beamA1 = grplhcif->getBeamA(o2::constants::lhc::BeamC); + int beamA2 = grplhcif->getBeamA(o2::constants::lhc::BeamA); + beamE1 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamC); + beamE2 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamA); + beamM1 = o2::constants::physics::MassProton * beamA1; + beamM2 = o2::constants::physics::MassProton * beamA2; + beamP1 = std::sqrt(std::pow(beamE1, 2) - std::pow(beamM1, 2)); + beamP2 = std::sqrt(std::pow(beamE2, 2) - std::pow(beamM2, 2)); + LOGF(info, "beamZ1 = %d, beamZ2 = %d, beamA1 = %d, beamA2 = %d, beamE1 = %f (GeV), beamE2 = %f (GeV), beamM1 = %f (GeV), beamM2 = %f (GeV), beamP1 = %f (GeV), beamP2 = %f (GeV)", beamZ1, beamZ2, beamA1, beamA2, beamE1, beamE2, beamM1, beamM2, beamP1, beamP2); + + 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()); + } + + if (cfgApplySPresolution) { + auto list = ccdb->getForTimeStamp(spresoPath, collision.timestamp()); + h2sp_resolution = reinterpret_cast(list->FindObject(spresoHistName.value.data())); + LOGF(info, "h2sp_resolution.GetBinContent(40, 1) = %f", h2sp_resolution->GetBinContent(40, 1)); + } + } + + ~Dilepton() + { + delete emh_pos; + emh_pos = 0x0; + delete emh_neg; + emh_neg = 0x0; + + used_trackIds.clear(); + used_trackIds.shrink_to_fit(); + + delete h2sp_resolution; + } + + void addhistograms() + { + const std::string qvec_det_names[6] = {"FT0M", "FT0A", "FT0C", "BTot", "BPos", "BNeg"}; + + std::string mass_axis_title = "m_{ll} (GeV/c^{2})"; + std::string pair_pt_axis_title = "p_{T,ll} (GeV/c)"; + std::string pair_dca_axis_title = "DCA_{ll} (#sigma)"; + 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_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)"; + } + } 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_dca_axis_title = "DCA_{#mu#mu}^{XY} (#sigma)"; + } + + // pair 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}; + + 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/hsDeltaP", "difference of p between 2 tracks;|p_{T,1} - p_{T,2}|/|p_{T,1} + p_{T,2}|;#Delta#eta;#Delta#varphi (rad.);", kTHnSparseD, {{20, 0, 1}, {100, -0.5, +0.5}, {180, -M_PI, M_PI}}, true); + fRegistry.add("Pair/same/uls/hGeomDeltaZRDeltaPhi", Form("difference in z-r#varphi plane between 2 tracks at r = %2.1f cm;r#Delta#varphi (cm);#Deltaz (cm);", dielectroncuts.cfg_x_to_go.value), kTH2D, {{200, -50, 50}, {40, -10, 10}}, 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/hMvsPhiV_prop", "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, {{100, 0, 2.0}, {20, 0.0f, 3.2}}, true); + } + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kUPC)) { + const AxisSpec axis_aco{10, 0, 1.f, "#alpha = 1 - #frac{|#varphi_{l^{+}} - #varphi_{l^{-}}|}{#pi}"}; + const AxisSpec axis_asym_pt{10, 0, 1.f, "A = #frac{|p_{T,l^{+}} - p_{T,l^{-}}|}{|p_{T,l^{+}} + p_{T,l^{-}}|}"}; + const AxisSpec axis_dphi_e_ee{18, 0, M_PI, "#Delta#varphi = #varphi_{l} - #varphi_{ll} (rad.)"}; + const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_cos_theta_cs}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV2) || cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV3)) { + if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV2)) { + nmod = 2; + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV3)) { + nmod = 3; + } + + const AxisSpec axis_sp{ConfSPBins, Form("#vec{u}_{%d,ll} #upoint #vec{Q}_{%d}^{%s}", nmod, nmod, qvec_det_names[cfgQvecEstimator].data())}; + + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + + fRegistry.add("Pair/mix/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true); + fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lspp/"); + fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lsmm/"); + + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kPolarization)) { + const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; + const AxisSpec axis_phi_cs{18, 0.f, M_PI, "|#varphi_{CS}| (rad.)"}; + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_cos_theta_cs, axis_phi_cs}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kVM)) { + std::string pair_y_axis_title = "y_{ll}"; + 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) { + pair_y_axis_title = "y_{ee}"; + nbin_y = 20; + min_y = -1.0; + max_y = +1.0; + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + pair_y_axis_title = "y_{#mu#mu}"; + nbin_y = 25; + min_y = -4.5; + max_y = -2.0; + } + const AxisSpec axis_y{nbin_y, min_y, max_y, pair_y_axis_title}; + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_y}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kHFll)) { + 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}"}; + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_dphi_ee, axis_deta_ee}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } else { // same as kQC to avoid seg. fault + fRegistry.add("Pair/same/uls/hs", "dilepton", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); + fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); + fRegistry.addClone("Pair/same/", "Pair/mix/"); + } + + // event info + if (nmod == 2) { + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<2>(&fRegistry); + } else if (nmod == 3) { + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<3>(&fRegistry); + } else { + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); + } + fRegistry.add("Event/before/hEP2_CentFT0C_forMix", Form("2nd harmonics event plane for mix;centrality FT0C (%%);#Psi_{2}^{%s} (rad.)", qvec_det_names[cfgEP2Estimator_for_Mix].data()), kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); + fRegistry.add("Event/after/hEP2_CentFT0C_forMix", Form("2nd harmonics event plane for mix;centrality FT0C (%%);#Psi_{2}^{%s} (rad.)", qvec_det_names[cfgEP2Estimator_for_Mix].data()), kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); + } + + 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.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + } + + 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 + if (dielectroncuts.cfg_apply_phiv_meedep) { + fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); + } else { + fDielectronCut.SetPhivPairRange(dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv, dielectroncuts.cfg_min_mee_for_phiv, dielectroncuts.cfg_max_mee_for_phiv); + } + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); + fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, 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, 1e+10f); + 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.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(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.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); + + // 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.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); + + 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 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.; + } + 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, 1e10f); + 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.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); }); + } + + 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) { + is_good = false; + break; + } + } + return is_good; + } + + float getSPresolution(const float centrality, const int occupancy) + { + if (h2sp_resolution == nullptr) { + return 1.f; + } else { + int binId_cen = h2sp_resolution->GetXaxis()->FindBin(centrality); + int binId_occ = h2sp_resolution->GetYaxis()->FindBin(occupancy); + + if (centrality < h2sp_resolution->GetXaxis()->GetXmin()) { + binId_cen = 1; + } + if (h2sp_resolution->GetXaxis()->GetXmax() < centrality) { + binId_cen = h2sp_resolution->GetXaxis()->GetNbins(); + } + + if (occupancy < h2sp_resolution->GetYaxis()->GetXmin()) { + binId_occ = 1; + } + if (h2sp_resolution->GetYaxis()->GetXmax() < occupancy) { + binId_occ = h2sp_resolution->GetYaxis()->GetNbins(); + } + return h2sp_resolution->GetBinContent(binId_cen, binId_occ); + } + } + + std::map, float> map_z_prop; // map -> geometrical z position at propagated point + std::map, float> map_phi_prop; // map -> geometrical phi position at propagated point + std::map, float> map_px_prop; // map -> px at propagated point + std::map, float> map_py_prop; // map -> py at propagated point + std::map, float> map_pz_prop; // map -> pz at propagated point + + template + void propagateElectron(TTracks const& tracks) + { + // this has to be called after initCCDB for bz. + for (auto& track : tracks) { + auto track_par_cov = getTrackParCov(track); + track_par_cov.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToX(track_par_cov, dielectroncuts.cfg_x_to_go, d_bz, o2::base::PropagatorImpl::MAX_SIN_PHI, o2::base::PropagatorImpl::MAX_STEP, matCorr); + auto xyz = track_par_cov.getXYZGlo(); + // float eta = RecoDecay::eta(std::array{xyz.X(), xyz.Y(), xyz.Z()}); + float phi = RecoDecay::phi(std::array{xyz.X(), xyz.Y()}); + o2::math_utils::bringTo02Pi(phi); + map_z_prop[std::make_tuple(ndf, track.emeventId(), track.globalIndex())] = xyz.Z(); + map_phi_prop[std::make_tuple(ndf, track.emeventId(), track.globalIndex())] = phi; + + std::array pxpypz_prop = {0, 0, 0}; // px, py, pz + getPxPyPz(track_par_cov, pxpypz_prop); + map_px_prop[std::make_tuple(ndf, track.emeventId(), track.globalIndex())] = pxpypz_prop[0]; + map_py_prop[std::make_tuple(ndf, track.emeventId(), track.globalIndex())] = pxpypz_prop[1]; + map_pz_prop[std::make_tuple(ndf, track.emeventId(), track.globalIndex())] = pxpypz_prop[2]; + + // float r = sqrt(pow(xyz.X(),2) + pow(xyz.Y(), 2)); + // float theta = 2.f * std::atan(std::exp(-eta)); + // float z = r/std::tan(theta); + // LOGF(info, "r = %f, z = %f , xyz.Z() = %f", r, z, xyz.Z()); + } + } + + template + bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& 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()) { + // 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()); + 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()) { + // 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()); + 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; + } + } + } + + float dphi_geom = 999.f, dz_geom = 999.f, rdphi_geom = 999.f; + float phiv_prop = 999.f, mee_prop = 999.f; + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + return false; + } + + if constexpr (ev_id == 0) { + dz_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_z_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())] - map_z_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] : map_z_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] - map_z_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + dphi_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_phi_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())] - map_phi_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] : map_phi_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] - map_phi_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + o2::math_utils::bringToPMPi(dphi_geom); + rdphi_geom = dielectroncuts.cfg_x_to_go * dphi_geom; + + float px1 = map_px_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + float py1 = map_py_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + float pz1 = map_pz_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + float px2 = map_px_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())]; + float py2 = map_py_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())]; + float pz2 = map_pz_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())]; + + ROOT::Math::PxPyPzMVector v1prop(px1, py1, pz1, leptonM1); + ROOT::Math::PxPyPzMVector v2prop(px2, py2, pz2, leptonM2); + ROOT::Math::PxPyPzMVector v12prop = v1prop + v2prop; + mee_prop = v12prop.M(); + phiv_prop = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(px1, py1, pz1, px2, py2, pz2, t1.sign(), t2.sign(), d_bz); + + } else { // mixed event + dz_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_z_prop[std::make_tuple(t1.dfId(), t1.collisionId(), t1.globalIndex())] - map_z_prop[std::make_tuple(t2.dfId(), t2.collisionId(), t2.globalIndex())] : map_z_prop[std::make_tuple(t2.dfId(), t2.collisionId(), t2.globalIndex())] - map_z_prop[std::make_tuple(t1.dfId(), t1.collisionId(), t1.globalIndex())]; + dphi_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_phi_prop[std::make_tuple(t1.dfId(), t1.collisionId(), t1.globalIndex())] - map_phi_prop[std::make_tuple(t2.dfId(), t2.collisionId(), t2.globalIndex())] : map_phi_prop[std::make_tuple(t2.dfId(), t2.collisionId(), t2.globalIndex())] - map_phi_prop[std::make_tuple(t1.dfId(), t1.collisionId(), t1.globalIndex())]; + o2::math_utils::bringToPMPi(dphi_geom); + rdphi_geom = dielectroncuts.cfg_x_to_go * dphi_geom; + } + if (dielectroncuts.cfg_x_to_go > 0.f && dielectroncuts.cfg_apply_dzrdphi_geom && std::pow(dz_geom / dielectroncuts.cfg_min_dz_geom, 2) + std::pow(rdphi_geom / dielectroncuts.cfg_min_rdphi_geom, 2) < 1.f) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template 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())]; + } + if (ev_id == 1) { + weight = 1.f; + } + + // LOGF(info, "ev_id = %d, t1.sign() = %d, t2.sign() = %d, map_weight[std::make_pair(%d, %d)] = %f", ev_id, t1.sign(), t2.sign(), t1.globalIndex(), t2.globalIndex(), weight); + + 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 (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC)) { + float dpt = fabs(v1.Pt() - v2.Pt()) / fabs(v1.Pt() + v2.Pt()); + float deta = t1.sign() * v1.Pt() > t2.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = t1.sign() * v1.Pt() > t2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + + 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/hsDeltaP"), dpt, deta, dphi, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hGeomDeltaZRDeltaPhi"), rdphi_geom, dz_geom, 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/hMvsPhiV_prop"), phiv_prop, mee_prop, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsOpAng"), opAng, v12.M(), 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/hsDeltaP"), dpt, deta, dphi, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hGeomDeltaZRDeltaPhi"), rdphi_geom, dz_geom, 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/hMvsPhiV_prop"), phiv_prop, mee_prop, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsOpAng"), opAng, v12.M(), 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/hsDeltaP"), dpt, deta, dphi, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hGeomDeltaZRDeltaPhi"), rdphi_geom, dz_geom, 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/hMvsPhiV_prop"), phiv_prop, mee_prop, weight); + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsOpAng"), opAng, v12.M(), 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 dphi_e_ee = v1.Phi() - v12.Phi(); + o2::math_utils::bringToPMPi(dphi_e_ee); + + 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); + + 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); + } 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); + } 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); + } + } 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()}; + std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; + std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; + std::array q2btot = {collision.q2xbtot(), collision.q2ybtot()}; + std::array q2bpos = {collision.q2xbpos(), collision.q2ybpos()}; + std::array q2bneg = {collision.q2xbneg(), collision.q2ybneg()}; + std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; + std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; + std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; + std::array q3btot = {collision.q3xbtot(), collision.q3ybtot()}; + std::array q3bpos = {collision.q3xbpos(), collision.q3ybpos()}; + std::array q3bneg = {collision.q3xbneg(), collision.q3ybneg()}; + + std::vector>> qvectors = { + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 0th harmonics + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 1st harmonics + {q2ft0m, q2ft0a, q2ft0c, q2btot, q2bpos, q2bneg}, // 2nd harmonics + {q3ft0m, q3ft0a, q3ft0c, q3btot, q3bpos, q3bneg}, // 3rd harmonics + }; + + if constexpr (ev_id == 0) { + // LOGF(info, "collision.centFT0C() = %f, collision.trackOccupancyInTimeRange() = %d, getSPresolution = %f", collision.centFT0C(), collision.trackOccupancyInTimeRange(), getSPresolution(collision.centFT0C(), collision.trackOccupancyInTimeRange())); + + float sp = RecoDecay::dotProd(std::array{static_cast(std::cos(nmod * v12.Phi())), static_cast(std::sin(nmod * v12.Phi()))}, qvectors[nmod][cfgQvecEstimator]) / getSPresolution(collision.centFT0C(), collision.trackOccupancyInTimeRange()); + 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, sp, 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, sp, 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, sp, weight); + } + } else if constexpr (ev_id == 1) { + 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); + } 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); + } 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); + } + } + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kPolarization)) { + 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 (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); + } 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); + } 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); + } + + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kVM)) { + 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, v12.Rapidity(), 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, v12.Rapidity(), 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, v12.Rapidity(), weight); + } + } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kHFll)) { + float dphi = v1.Phi() - v2.Phi(); + dphi = RecoDecay::constrainAngle(dphi, -o2::constants::math::PIHalf); + float deta = v1.Eta() - v2.Eta(); + + 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, dphi, deta, 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, dphi, deta, 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, dphi, deta, weight); + } + + } else { // same as kQC to avoid seg. fault + 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); + } 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); + } 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); + } + } + + // 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, 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())); + } 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())); + } + } + } + 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, 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())); + } 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())); + } + } + } + } 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, 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())); + } 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())); + } + } + } + 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, 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())); + } 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())); + } + } + } + } + } + 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 && 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 ttcaFilter_electron = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); + Partition positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0); + 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 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; + std::map, uint64_t> map_mixed_eventId_to_globalBC; + + 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) + { + for (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; + } + } + + std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; + std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; + std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; + std::array q2btot = {collision.q2xbtot(), collision.q2ybtot()}; + std::array q2bpos = {collision.q2xbpos(), collision.q2ybpos()}; + std::array q2bneg = {collision.q2xbneg(), collision.q2ybneg()}; + std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; + std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; + std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; + std::array q3btot = {collision.q3xbtot(), collision.q3ybtot()}; + std::array q3bpos = {collision.q3xbpos(), collision.q3ybpos()}; + std::array q3bneg = {collision.q3xbneg(), collision.q3ybneg()}; + const float eventplanes_2_for_mix[6] = {collision.ep2ft0m(), collision.ep2ft0a(), collision.ep2ft0c(), collision.ep2btot(), collision.ep2bpos(), collision.ep2bneg()}; + float ep2 = eventplanes_2_for_mix[cfgEP2Estimator_for_Mix]; + + std::vector>> qvectors = { + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 0th harmonics + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 1st harmonics + {q2ft0m, q2ft0a, q2ft0c, q2btot, q2bpos, q2bneg}, // 2nd harmonics + {q3ft0m, q3ft0a, q3ft0c, q3btot, q3bpos, q3bneg}, // 3rd harmonics + }; + + if (nmod == 2) { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, 2>(&fRegistry, collision); + } else if (nmod == 3) { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, 3>(&fRegistry, collision); + } else { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); + } + if (nmod < 0 || isGoodQvector(qvectors)) { + fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev - 1); // is qvector calibarated + } + fRegistry.fill(HIST("Event/before/hEP2_CentFT0C_forMix"), collision.centFT0C(), ep2); + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + if (nmod > 0 && !isGoodQvector(qvectors)) { + continue; + } + + if (nmod == 2) { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, 2>(&fRegistry, collision); + } else if (nmod == 3) { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, 3>(&fRegistry, collision); + } else { + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision); + } + fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev - 1); // is qvector calibarated + + 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 + fRegistry.fill(HIST("Event/after/hEP2_CentFT0C_forMix"), collision.centFT0C(), ep2); + + auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + // 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()); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_x_to_go > 0.f) { + propagateElectron(posTracks_per_coll); + propagateElectron(negTracks_per_coll); + } + } + + 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); + 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); + 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); + if (is_pair_ok) { + nlsmm++; + } + } + + 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 = 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()); + + // make a vector of selected photons 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); + // LOGF(info, "N selected tracks in current event (%d, %d), zvtx = %f, centrality = %f , npos = %d , nneg = %d, nuls = %d , nlspp = %d, nlsmm = %d", ndf, collision.globalIndex(), collision.posZ(), centralities[cfgCentEstimator], selected_posTracks_in_this_event.size(), selected_negTracks_in_this_event.size(), nuls, nlspp, nlsmm); + + 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) { + 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("Pair/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); + // 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 (auto& neg : selected_negTracks_in_this_event) { // ULS mix + for (auto& pos : posTracks_from_event_pool) { + fillPairInfo<1>(collision, neg, pos, cut); + } + } + + for (auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix + for (auto& pos2 : posTracks_from_event_pool) { + fillPairInfo<1>(collision, pos1, pos2, cut); + } + } + + for (auto& neg1 : selected_negTracks_in_this_event) { // LS-- mix + for (auto& neg2 : negTracks_from_event_pool) { + fillPairInfo<1>(collision, neg1, neg2, cut); + } + } + } // end of loop over mixed event pool + + 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); + } + + } // end of collision loop + + } // end of DF + + template + bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut) + { + 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 constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + return false; + } + float dz_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_z_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())] - map_z_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] : map_z_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] - map_z_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + float dphi_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? map_phi_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())] - map_phi_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] : map_phi_prop[std::make_tuple(ndf, t2.emeventId(), t2.globalIndex())] - map_phi_prop[std::make_tuple(ndf, t1.emeventId(), t1.globalIndex())]; + o2::math_utils::bringToPMPi(dphi_geom); + float rdphi_geom = dielectroncuts.cfg_x_to_go * dphi_geom; + + if (dielectroncuts.cfg_x_to_go > 0.f && dielectroncuts.cfg_apply_dzrdphi_geom && std::pow(dz_geom / dielectroncuts.cfg_min_dz_geom, 2) + std::pow(rdphi_geom / dielectroncuts.cfg_min_rdphi_geom, 2) < 1.f) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template 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 (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; + } + } + + std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; + std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; + std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; + std::array q2btot = {collision.q2xbtot(), collision.q2ybtot()}; + std::array q2bpos = {collision.q2xbpos(), collision.q2ybpos()}; + std::array q2bneg = {collision.q2xbneg(), collision.q2ybneg()}; + std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; + std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; + std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; + std::array q3btot = {collision.q3xbtot(), collision.q3ybtot()}; + std::array q3bpos = {collision.q3xbpos(), collision.q3ybpos()}; + std::array q3bneg = {collision.q3xbneg(), collision.q3ybneg()}; + + std::vector>> qvectors = { + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 0th harmonics + {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 1st harmonics + {q2ft0m, q2ft0a, q2ft0c, q2btot, q2bpos, q2bneg}, // 2nd harmonics + {q3ft0m, q3ft0a, q3ft0c, q3btot, q3bpos, q3bneg}, // 3rd harmonics + }; + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + if (nmod > 0 && !isGoodQvector(qvectors)) { + continue; + } + + auto posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_x_to_go > 0.f) { + propagateElectron(posTracks_per_coll); + propagateElectron(negTracks_per_coll); + } + } + + for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + if (isPairOK(collision, pos, neg, cut)) { + 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)) { + 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)) { + 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) { + 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()) { + 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 (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()) { + 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, 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); + } + runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut); + } 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); + } + map_weight.clear(); + ndf++; + } + PROCESS_SWITCH(Dilepton, processAnalysis, "run dilepton analysis", true); + + using FilteredMyCollisionsWithSWT = soa::Filtered; + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, 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); + } + runPairing(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut); + } 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); + } + map_weight.clear(); + ndf++; + } + PROCESS_SWITCH(Dilepton, processTriggerAnalysis, "run dilepton analysis on triggered data", false); + + void processNorm(aod::EMEventNormInfos const& collisions) + { + for (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); + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 6.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 7.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 8.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 9.0); + } + if (collision.sel8()) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); + } + if (abs(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 (!fEMEventCut.IsSelected(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 processDummy(MyCollisions const&) {} + PROCESS_SWITCH(Dilepton, processDummy, "Dummy function", false); +}; + +#endif // PWGEM_DILEPTON_CORE_DILEPTON_H_ diff --git a/PWGEM/Dilepton/Core/DileptonMC.h b/PWGEM/Dilepton/Core/DileptonMC.h new file mode 100644 index 00000000000..84af68489da --- /dev/null +++ b/PWGEM/Dilepton/Core/DileptonMC.h @@ -0,0 +1,2294 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 in MC +// Please write to: daiki.sekihata@cern.ch + +#ifndef PWGEM_DILEPTON_CORE_DILEPTONMC_H_ +#define PWGEM_DILEPTON_CORE_DILEPTONMC_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 "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/GRPMagField.h" +#include "CCDB/BasicCCDBManager.h" +#include "Tools/ML/MlResponse.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "DCAFitter/DCAFitterN.h" +#include "DCAFitter/FwdDCAFitterN.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" + +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::mcutil; +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 MyMCElectrons = soa::Join; +using MyMCElectron = MyMCElectrons::iterator; +using FilteredMyMCElectrons = soa::Filtered; +using FilteredMyMCElectron = FilteredMyMCElectrons::iterator; + +using MyMCMuons = soa::Join; +using MyMCMuon = MyMCMuons::iterator; +using FilteredMyMCMuons = soa::Filtered; +using FilteredMyMCMuon = FilteredMyMCMuons::iterator; + +using MySmearedElectrons = soa::Join; +using MySmearedElectron = MySmearedElectrons::iterator; + +using MySmearedMuons = soa::Join; +using MySmearedMuon = MySmearedMuons::iterator; + +// template +template +struct DileptonMC { + + // 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 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 cfgCentMin{"cfgCentMin", 0, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + 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"}; + Configurable cfgFillUnfolding{"cfgFillUnfolding", false, "flag to fill histograms for unfolding"}; + + 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 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. + + 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 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"}; + } 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_apply_pf{"cfg_apply_pf", false, "flag to apply phiv prefilter"}; + Configurable cfg_apply_phiv_meedep{"cfg_apply_phiv_meedep", true, "flag to apply mee-dependent 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_min_mee_for_phiv{"cfg_min_mee_for_phiv", 0.0, "min mee for phiv (constant)"}; + Configurable cfg_max_mee_for_phiv{"cfg_max_mee_for_phiv", 1e+10, "max mee for phiv (constant)"}; + 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 electrons (elliptic cut)"}; + Configurable cfg_min_dphi{"cfg_min_dphi", 0.2, "min dphi between 2 electrons (elliptic cut)"}; + Configurable cfg_apply_dzrdphi_geom{"cfg_apply_dzrdphi_geom", false, "flag to apply generator dz-rdphi elliptic cut"}; + Configurable cfg_min_dz_geom{"cfg_min_dz_geom", 1.2, "geometrical min deta between 2 electrons (elliptic cut)"}; + Configurable cfg_min_rdphi_geom{"cfg_min_rdphi_geom", 2.4, "geometrical min dphi between 2 electrons (elliptic cut)"}; + Configurable cfg_min_opang{"cfg_min_opang", 0.0, "min opening angle"}; + Configurable cfg_max_opang{"cfg_max_opang", 6.4, "max opening angle"}; + Configurable cfg_require_diff_sides{"cfg_require_diff_sides", false, "flag to require 2 tracks are from different sides."}; + Configurable cfg_x_to_go{"cfg_x_to_go", -1, "x (cm) to be propagated in local coordinate"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max 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_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", 0.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "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 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_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 enableTTCA{"enableTTCA", true, "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.1, "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_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"}; + } dimuoncuts; + + 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; + + struct : ConfigurableGroup { + std::string prefix = "mctrackcut_group"; + Configurable min_mcPt{"min_mcPt", 0.1, "min. MC pT"}; + Configurable max_mcPt{"max_mcPt", 1e+10, "max. MC pT"}; + Configurable min_mcEta{"min_mcEta", -0.8, "max. MC eta"}; + Configurable max_mcEta{"max_mcEta", +0.8, "max. MC eta"}; + } mctrackcuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + + ~DileptonMC() {} + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry); + + 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)"; + pair_y_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)"; + } + 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_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_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 + + // 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/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); + + fRegistry.add("Generated/ccbar/c2l_c2l/hadron_hadron/hs", "generated 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/ccbar/c2l_c2l/hadron_hadron/", "Generated/ccbar/c2l_c2l/meson_meson/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", "Generated/ccbar/c2l_c2l/baryon_baryon/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/hadron_hadron/", "Generated/ccbar/c2l_c2l/meson_baryon/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2l_b2l/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2c2l_b2c2l/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2c2l_b2l_sameb/"); + fRegistry.addClone("Generated/ccbar/c2l_c2l/", "Generated/bbbar/b2c2l_b2l_diffb/"); // LS + + // 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/Eta/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/EtaPrime/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Rho/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Omega/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Omega2ll/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Phi/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Phi2ll/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/PromptJPsi/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/NonPromptJPsi/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/PromptPsi2S/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/NonPromptPsi2S/"); + + 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/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/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); + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", "Pair/ccbar/c2l_c2l/meson_meson/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", "Pair/ccbar/c2l_c2l/baryon_baryon/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/hadron_hadron/", "Pair/ccbar/c2l_c2l/meson_baryon/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2l_b2l/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2c2l_b2c2l/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2c2l_b2l_sameb/"); + fRegistry.addClone("Pair/ccbar/c2l_c2l/", "Pair/bbbar/b2c2l_b2l_diffb/"); // LS + + // 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/"); + + if (cfgFillUnfolding) { + // for 2D unfolding + const AxisSpec axis_mass_gen{ConfMllBins, "m_{ll}^{gen} (GeV/c^{2})"}; + const AxisSpec axis_pt_gen{ConfPtllBins, "p_{T,ll}^{gen} (GeV/c)"}; + const AxisSpec axis_mass_rec{ConfMllBins, "m_{ll}^{rec} (GeV/c^{2})"}; + const AxisSpec axis_pt_rec{ConfPtllBins, "p_{T,ll}^{rec} (GeV/c)"}; + fRegistry.add("Unfold/lf/hsRM", "response matrix for unfolding", kTHnSparseD, {axis_mass_gen, axis_pt_gen, axis_mass_rec, axis_pt_rec}, true); + fRegistry.add("Unfold/lf/hMiss", "missing dilepton for unfolding", kTH2D, {axis_mass_gen, axis_pt_gen}, true); // e.g. true eta is in acceptance, but reconstructed eta is out of acceptance. + fRegistry.add("Unfold/lf/hFake", "fake dilepton for unfolding", kTH2D, {axis_mass_rec, axis_pt_rec}, true); // e.g. true eta is out of acceptance, but reconstructed eta is in acceptance. + fRegistry.addClone("Unfold/lf/", "Unfold/PromptJPsi/"); + fRegistry.addClone("Unfold/lf/", "Unfold/NonPromptJPsi/"); + fRegistry.addClone("Unfold/lf/", "Unfold/PromptPsi2S/"); + fRegistry.addClone("Unfold/lf/", "Unfold/NonPromptPsi2S/"); + fRegistry.addClone("Unfold/lf/", "Unfold/ccbar_uls/"); + fRegistry.addClone("Unfold/lf/", "Unfold/bbbar_uls/"); + fRegistry.addClone("Unfold/lf/", "Unfold/bbbar_ls/"); + } + } + + float beamM1 = o2::constants::physics::MassProton; // mass of beam + float beamM2 = o2::constants::physics::MassProton; // mass of beam + float beamE1 = 0.f; // beam energy + float beamE2 = 0.f; // beam energy + float beamP1 = 0.f; // beam momentum + float beamP2 = 0.f; // beam momentum + + float leptonM1 = 0.f; + float leptonM2 = 0.f; + int pdg_lepton = 0; + void init(InitContext&) + { + if (doprocessAnalysis && doprocessAnalysis_Smeared) { + LOGF(fatal, "Cannot enable doprocessAnalysis and doprocessAnalysis_Smeared at the same time. Please choose one."); + } + + mRunNumber = 0; + d_bz = 0; + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + DefineEMEventCut(); + addhistograms(); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + DefineDielectronCut(); + 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"); + } + + 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)); + } + o2::base::Propagator::initFieldFromGRP(&grpmag); + mRunNumber = collision.runNumber(); + // fitter.setBz(d_bz); + // fwdfitter.setBz(d_bz); + 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(); + // fitter.setBz(d_bz); + // fwdfitter.setBz(d_bz); + + //// for muon + // o2::base::Propagator::initFieldFromGRP(grpmag); + // if (!o2::base::GeometryManager::isGeometryLoaded()) { + // ccdb->get(geoPath); + // } + // o2::mch::TrackExtrap::setField(); + + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", collision.timestamp()); + int beamZ1 = grplhcif->getBeamZ(o2::constants::lhc::BeamC); + int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamA); + int beamA1 = grplhcif->getBeamA(o2::constants::lhc::BeamC); + int beamA2 = grplhcif->getBeamA(o2::constants::lhc::BeamA); + beamE1 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamC); + beamE2 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamA); + beamM1 = o2::constants::physics::MassProton * beamA1; + beamM2 = o2::constants::physics::MassProton * beamA2; + beamP1 = std::sqrt(std::pow(beamE1, 2) - std::pow(beamM1, 2)); + beamP2 = std::sqrt(std::pow(beamE2, 2) - std::pow(beamM2, 2)); + LOGF(info, "beamZ1 = %d, beamZ2 = %d, beamA1 = %d, beamA2 = %d, beamE1 = %f (GeV), beamE2 = %f (GeV), beamM1 = %f (GeV), beamM2 = %f (GeV), beamP1 = %f (GeV), beamP2 = %f (GeV)", beamZ1, beamZ2, beamA1, beamA2, beamE1, beamE2, beamM1, beamM2, beamP1, beamP2); + } + + 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.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + } + + 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 + if (dielectroncuts.cfg_apply_phiv_meedep) { + fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); + } else { + fDielectronCut.SetPhivPairRange(dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv, dielectroncuts.cfg_min_mee_for_phiv, dielectroncuts.cfg_max_mee_for_phiv); + } + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); + fDielectronCut.SetMindEtadPhi(dielectroncuts.cfg_apply_detadphi, 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, 1e+10f); + 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.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(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.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); + + // 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.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); + + 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 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.; + } + 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); // DCAxy in cm + 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, 1e10f); + 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); }); + } + + template + int FindLF(TTrack const& posmc, TTrack const& negmc, TMCParticles const& mcparticles) + { + int arr[] = { + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 22, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 111, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 221, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 331, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 113, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 223, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 333, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 443, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 100443, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 553, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 100553, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 200553, mcparticles), + FindCommonMotherFrom2Prongs(posmc, negmc, -pdg_lepton, pdg_lepton, 300553, mcparticles)}; + int size = sizeof(arr) / sizeof(*arr); + int max = *std::max_element(arr, arr + size); + return max; + } + + template + bool isInAcceptance(T const& lepton) + { + float pt = 0.f, eta = 0.f; + if constexpr (isSmeared) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pt = lepton.ptSmeared(); + eta = lepton.etaSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + pt = lepton.ptSmeared_sa_muon(); + eta = lepton.etaSmeared_sa_muon(); + } else if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + pt = lepton.ptSmeared_gl_muon(); + eta = lepton.etaSmeared_gl_muon(); + } else { + pt = lepton.pt(); + eta = lepton.eta(); + } + } + } else { + pt = lepton.pt(); + eta = lepton.eta(); + } + + if ((mctrackcuts.min_mcPt < pt && pt < mctrackcuts.max_mcPt) && (mctrackcuts.min_mcEta < eta && eta < mctrackcuts.max_mcEta)) { + return true; + } else { + return false; + } + } + + template + bool fillTruePairInfo(TCollision const& collision, TMCCollisions const&, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut, TMCParticles const& mcparticles) + { + auto t1mc = mcparticles.iteratorAt(t1.emmcparticleId()); + auto t2mc = mcparticles.iteratorAt(t2.emmcparticleId()); + bool is_from_same_mcevent = t1mc.emmceventId() == t2mc.emmceventId(); + + auto mccollision1 = t1mc.template emmcevent_as(); + auto mccollision2 = t2mc.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision1.getSubGeneratorId() != cfgEventGeneratorType) { + return false; + } + if (cfgEventGeneratorType >= 0 && mccollision2.getSubGeneratorId() != cfgEventGeneratorType) { + return false; + } + if (!isInAcceptance(t1mc) || !isInAcceptance(t2mc)) { + return false; + } + + 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 (!cut.template IsSelectedPair(t1, t2, d_bz)) { + return false; + } + + if (dielectroncuts.cfg_x_to_go > 0.f) { + auto track_par_cov1 = getTrackParCov(t1); + track_par_cov1.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToX(track_par_cov1, dielectroncuts.cfg_x_to_go, d_bz, o2::base::PropagatorImpl::MAX_SIN_PHI, o2::base::PropagatorImpl::MAX_STEP, matCorr); + auto xyz1 = track_par_cov1.getXYZGlo(); + float z1 = xyz1.Z(); + // float eta1 = RecoDecay::eta(std::array{xyz1.X(), xyz1.Y(), xyz1.Z()}); + float phi1 = RecoDecay::phi(std::array{xyz1.X(), xyz1.Y()}); + o2::math_utils::bringTo02Pi(phi1); + + auto track_par_cov2 = getTrackParCov(t2); + track_par_cov2.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToX(track_par_cov2, dielectroncuts.cfg_x_to_go, d_bz, o2::base::PropagatorImpl::MAX_SIN_PHI, o2::base::PropagatorImpl::MAX_STEP, matCorr); + auto xyz2 = track_par_cov2.getXYZGlo(); + float z2 = xyz2.Z(); + // float eta2 = RecoDecay::eta(std::array{xyz2.X(), xyz2.Y(), xyz2.Z()}); + float phi2 = RecoDecay::phi(std::array{xyz2.X(), xyz2.Y()}); + o2::math_utils::bringTo02Pi(phi2); + + float dz_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? z1 - z2 : z2 - z1; + float dphi_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? phi1 - phi2 : phi2 - phi1; + o2::math_utils::bringToPMPi(dphi_geom); + float rdphi_geom = dielectroncuts.cfg_x_to_go * dphi_geom; + if (dielectroncuts.cfg_apply_dzrdphi_geom && std::pow(dz_geom / dielectroncuts.cfg_min_dz_geom, 2) + std::pow(rdphi_geom / dielectroncuts.cfg_min_rdphi_geom, 2) < 1.f) { + 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 (!cut.template 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) { + pt1 = t1mc.ptSmeared(); + eta1 = t1mc.etaSmeared(); + phi1 = t1mc.phiSmeared(); + pt2 = t2mc.ptSmeared(); + eta2 = t2mc.etaSmeared(); + phi2 = t2mc.phiSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + pt1 = t1mc.ptSmeared_sa_muon(); + eta1 = t1mc.etaSmeared_sa_muon(); + phi1 = t1mc.phiSmeared_sa_muon(); + pt2 = t2mc.ptSmeared_sa_muon(); + eta2 = t2mc.etaSmeared_sa_muon(); + phi2 = t2mc.phiSmeared_sa_muon(); + } else if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + pt1 = t1mc.ptSmeared_gl_muon(); + eta1 = t1mc.etaSmeared_gl_muon(); + phi1 = t1mc.phiSmeared_gl_muon(); + pt2 = t2mc.ptSmeared_gl_muon(); + eta2 = t2mc.etaSmeared_gl_muon(); + phi2 = t2mc.phiSmeared_gl_muon(); + } else { + pt1 = t1mc.pt(); + eta1 = t1mc.eta(); + phi1 = t1mc.phi(); + pt2 = t2mc.pt(); + eta2 = t2mc.eta(); + phi2 = t2mc.phi(); + } + } + } else { + pt1 = t1mc.pt(); + eta1 = t1mc.eta(); + phi1 = t1mc.phi(); + pt2 = t2mc.pt(); + eta2 = t2mc.eta(); + phi2 = t2mc.phi(); + } + + ROOT::Math::PtEtaPhiMVector v1mc(pt1, eta1, phi1, leptonM1); + ROOT::Math::PtEtaPhiMVector v2mc(pt2, eta2, phi2, leptonM2); + ROOT::Math::PtEtaPhiMVector v12mc = v1mc + v2mc; + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12mc.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12mc.Rapidity()) { + return false; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12mc.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12mc.Rapidity()) { + return false; + } + } + + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(t1.globalIndex(), t2.globalIndex())]; + } + // LOGF(info, "t1.sign() = %d, t2.sign() = %d, map_weight[std::make_pair(%d, %d)] = %f", t1.sign(), t2.sign(), t1.globalIndex(), t2.globalIndex(), weight); + + 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)); + } + 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 deta = v1.Eta() - v2.Eta(); + 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 dphi_e_ee = v1.Phi() - v12.Phi(); + o2::math_utils::bringToPMPi(dphi_e_ee); + + 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); + } 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); + } 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); + } + } else { // eh 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); + } 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); + } 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); + } + } + } + } 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); + } 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); + } 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); + } + } + + if (abs(t1mc.pdgCode()) != pdg_lepton || abs(t2mc.pdgCode()) != pdg_lepton) { + return false; + } + + if (!is_from_same_mcevent) { + return false; + } + int mother_id = FindLF(t1mc, t2mc, mcparticles); + int hfee_type = IsHF(t1mc, t2mc, mcparticles); + if (mother_id < 0 && hfee_type < 0) { + return false; + } + + if (mother_id > -1 && t1mc.pdgCode() * t2mc.pdgCode() < 0) { + auto mcmother = mcparticles.iteratorAt(mother_id); + if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { + if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { + switch (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()); + } + 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); + 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); + 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); + 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); + 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); + } + 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); + 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); + } + 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); + } 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); + } + 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); + } 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); + } + break; + } + default: + break; + } + } else if (!(t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && !(t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { + switch (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); + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fRegistry.fill(HIST("Pair/sm/Photon/hMvsPhiV"), phiv, v12.M()); + } + break; + default: + break; + } + } // end of primary/secondary selection + } // end of primary selection for same mother + } else if (hfee_type > -1) { + if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { + auto mp1 = mcparticles.iteratorAt(t1mc.mothersIds()[0]); + auto mp2 = mcparticles.iteratorAt(t2mc.mothersIds()[0]); + 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); + 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); + } 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); + } 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); + } + 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); + 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); + } 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); + } 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); + } + 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); + 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); + } 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); + } 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); + } + 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); + 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); + } 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); + } 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); + } + break; + } + case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS + LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); + break; + default: + break; + } + } else { // LS + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): + LOGF(info, "You should not see kCe_Ce in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBe_Be): + LOGF(info, "You should not see kBe_Be in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_BCe): + LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + 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); + 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); + } 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); + } 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); + } + break; + } + default: + break; + } + } + } + } // end of HF evaluation + return true; + } + + 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 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_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; + 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) + { + for (auto& collision : collisions) { + initCCDB(collision); + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); + if (!fEMEventCut.IsSelected(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 posTracks_per_coll = posTracks.sliceByCached(perCollision, collision.globalIndex(), cache); + 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); + } // 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); + } // 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); + } // end of LS-- pair loop + + } // end of collision loop + } + + template + void runGenInfo(TCollisions const& collisions, TMCCollisions const& mccollisions, TMCLeptons const& posTracksMC, TMCLeptons const& negTracksMC, TMCParticles const& mcparticles) + { + for (auto& mccollision : mccollisions) { + if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + auto rec_colls_per_mccoll = collisions.sliceBy(recColperMcCollision, mccollision.globalIndex()); + 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 + } + } + + if (rec_colls_per_mccoll.size() < 1) { + continue; + } + auto collision = collisions.rawIteratorAt(rec_col_globalIndex); + + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + 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 + // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); + + if (!isInAcceptance(t1) || !isInAcceptance(t2)) { + continue; + } + + if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { + continue; + } + if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { + continue; + } + + int mother_id = FindLF(t1, t2, mcparticles); + int hfee_type = IsHF(t1, t2, mcparticles); + if (mother_id < 0 && hfee_type < 0) { + continue; + } + + 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) { + pt1 = t1.ptSmeared(); + eta1 = t1.etaSmeared(); + phi1 = t1.phiSmeared(); + pt2 = t2.ptSmeared(); + eta2 = t2.etaSmeared(); + phi2 = t2.phiSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == 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 (dimuoncuts.cfg_track_type == 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, leptonM1); + ROOT::Math::PtEtaPhiMVector v2(pt2, eta2, phi2, leptonM2); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + float deta = v1.Eta() - v2.Eta(); + float dphi = v1.Phi() - v2.Phi(); + o2::math_utils::bringToPMPi(dphi); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dielectroncuts.cfg_apply_detadphi && std::pow(deta / dielectroncuts.cfg_min_deta, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dimuoncuts.cfg_apply_detadphi && std::pow(deta / dimuoncuts.cfg_min_deta, 2) + std::pow(dphi / dimuoncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } + + float aco = 1.f - abs(dphi) / M_PI; + float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float dphi_e_ee = v1.Phi() - v12.Phi(); + o2::math_utils::bringToPMPi(dphi_e_ee); + + 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 (mother_id > -1) { + auto mcmother = mcparticles.iteratorAt(mother_id); + if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { + + switch (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)); + 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)); + 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)); + 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)); + 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)); + 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)); + } + 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)); + 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)); + } + 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)); + } 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)); + } + 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)); + } 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)); + } + break; + } + default: + break; + } + } + } else if (hfee_type > -1) { + auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); + 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)); + 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)); + } 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)); + } 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)); + } + 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)); + 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)); + } 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)); + } 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)); + } + 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)); + 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)); + } 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)); + } 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)); + } + 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)); + 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)); + } 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)); + } 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)); + } + break; + } + case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS + LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); + break; + default: + break; + } + } // end of HF evaluation + } // end of true ULS pair loop + + for (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)) { + continue; + } + + if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { + continue; + } + if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { + continue; + } + + int hfee_type = IsHF(t1, t2, mcparticles); + if (hfee_type < 0) { + continue; + } + + 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) { + pt1 = t1.ptSmeared(); + eta1 = t1.etaSmeared(); + phi1 = t1.phiSmeared(); + pt2 = t2.ptSmeared(); + eta2 = t2.etaSmeared(); + phi2 = t2.phiSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == 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 (dimuoncuts.cfg_track_type == 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, leptonM1); + ROOT::Math::PtEtaPhiMVector v2(pt2, eta2, phi2, leptonM2); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + float deta = v1.Eta() - v2.Eta(); + float dphi = v1.Phi() - v2.Phi(); + o2::math_utils::bringToPMPi(dphi); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dielectroncuts.cfg_apply_detadphi && std::pow(deta / dielectroncuts.cfg_min_deta, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dimuoncuts.cfg_apply_detadphi && std::pow(deta / dimuoncuts.cfg_min_deta, 2) + std::pow(dphi / dimuoncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + } + + float aco = 1.f - abs(dphi) / M_PI; + float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float dphi_e_ee = v1.Phi() - v12.Phi(); + o2::math_utils::bringToPMPi(dphi_e_ee); + + 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 (hfee_type > -1) { + auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); + auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): + LOGF(info, "You should not see kCe_Ce in LS++. Good luck."); + break; + case static_cast(EM_HFeeType::kBe_Be): + LOGF(info, "You should not see kBe_Be in LS++. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_BCe): + LOGF(info, "You should not see kBCe_BCe in LS++. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + 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)); + 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)); + } 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)); + } 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)); + } + break; + } + default: + break; + } + } + } // end of true LS++ pair loop + + for (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)) { + continue; + } + + if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { + continue; + } + if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { + continue; + } + + int hfee_type = IsHF(t1, t2, mcparticles); + if (hfee_type < 0) { + continue; + } + + 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) { + pt1 = t1.ptSmeared(); + eta1 = t1.etaSmeared(); + phi1 = t1.phiSmeared(); + pt2 = t2.ptSmeared(); + eta2 = t2.etaSmeared(); + phi2 = t2.phiSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == 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 (dimuoncuts.cfg_track_type == 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, leptonM1); + ROOT::Math::PtEtaPhiMVector v2(pt2, eta2, phi2, leptonM2); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + + float deta = v1.Eta() - v2.Eta(); + float dphi = v1.Phi() - v2.Phi(); + o2::math_utils::bringToPMPi(dphi); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dielectroncuts.cfg_apply_detadphi && std::pow(deta / dielectroncuts.cfg_min_deta, 2) + std::pow(dphi / dielectroncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + if (dimuoncuts.cfg_apply_detadphi && std::pow(deta / dimuoncuts.cfg_min_deta, 2) + std::pow(dphi / dimuoncuts.cfg_min_dphi, 2) < 1.f) { + continue; + } + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + continue; + } + } + + float aco = 1.f - abs(dphi) / M_PI; + float asym = abs(v1.Pt() - v2.Pt()) / (v1.Pt() + v2.Pt()); + float dphi_e_ee = v1.Phi() - v12.Phi(); + o2::math_utils::bringToPMPi(dphi_e_ee); + + 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 (hfee_type > -1) { + auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); + auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): + LOGF(info, "You should not see kCe_Ce in LS--. Good luck."); + break; + case static_cast(EM_HFeeType::kBe_Be): + LOGF(info, "You should not see kBe_Be in LS--. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_BCe): + LOGF(info, "You should not see kBCe_BCe in LS--. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + 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)); + 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)); + } 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)); + } 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)); + } + break; + } + default: + break; + } + } + } // end of true LS++ pair loop + } // end of collision loop + } + + template + bool isPairOK(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TCut const& cut) + { + 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 constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (!cut.template IsSelectedPair(t1, t2, d_bz)) { + return false; + } + if (dielectroncuts.cfg_x_to_go > 0.f) { + auto track_par_cov1 = getTrackParCov(t1); + track_par_cov1.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToX(track_par_cov1, dielectroncuts.cfg_x_to_go, d_bz, o2::base::PropagatorImpl::MAX_SIN_PHI, o2::base::PropagatorImpl::MAX_STEP, matCorr); + auto xyz1 = track_par_cov1.getXYZGlo(); + float z1 = xyz1.Z(); + // float eta1 = RecoDecay::eta(std::array{xyz1.X(), xyz1.Y(), xyz1.Z()}); + float phi1 = RecoDecay::phi(std::array{xyz1.X(), xyz1.Y()}); + o2::math_utils::bringTo02Pi(phi1); + + auto track_par_cov2 = getTrackParCov(t2); + track_par_cov2.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToX(track_par_cov2, dielectroncuts.cfg_x_to_go, d_bz, o2::base::PropagatorImpl::MAX_SIN_PHI, o2::base::PropagatorImpl::MAX_STEP, matCorr); + auto xyz2 = track_par_cov2.getXYZGlo(); + float z2 = xyz2.Z(); + // float eta2 = RecoDecay::eta(std::array{xyz2.X(), xyz2.Y(), xyz2.Z()}); + float phi2 = RecoDecay::phi(std::array{xyz2.X(), xyz2.Y()}); + o2::math_utils::bringTo02Pi(phi2); + + float dz_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? z1 - z2 : z2 - z1; + float dphi_geom = t1.sign() * t1.pt() > t2.sign() * t2.pt() ? phi1 - phi2 : phi2 - phi1; + o2::math_utils::bringToPMPi(dphi_geom); + float rdphi_geom = dielectroncuts.cfg_x_to_go * dphi_geom; + if (dielectroncuts.cfg_apply_dzrdphi_geom && std::pow(dz_geom / dielectroncuts.cfg_min_dz_geom, 2) + std::pow(rdphi_geom / dielectroncuts.cfg_min_rdphi_geom, 2) < 1.f) { + return false; + } + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template IsSelectedPair(t1, t2)) { + return false; + } + } + return true; + } + + std::map, float> map_weight; // -> float + template + void fillPairWeightMap(TCollisions const& collisions, TTracks1 const& posTracks, TTracks2 const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks, TMCCollisions const&, TMCParticles const& mcparticles) + { + std::vector> passed_pairIds; + passed_pairIds.reserve(posTracks.size() * negTracks.size()); + + 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 mccollision = collision.template emmcevent_as(); + // if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + // continue; + // } + + 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 + auto mcpos = mcparticles.iteratorAt(pos.emmcparticleId()); + auto mccollision_from_pos = mcpos.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_pos.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + auto mcneg = mcparticles.iteratorAt(neg.emmcparticleId()); + auto mccollision_from_neg = mcneg.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_neg.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + if (isPairOK(collision, pos, neg, cut)) { + passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), neg.globalIndex())); + } + } + for (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) { + continue; + } + auto mcpos2 = mcparticles.iteratorAt(pos2.emmcparticleId()); + auto mccollision_from_pos2 = mcpos2.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_pos2.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + if (isPairOK(collision, pos1, pos2, cut)) { + passed_pairIds.emplace_back(std::make_pair(pos1.globalIndex(), pos2.globalIndex())); + } + } + for (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) { + continue; + } + auto mcneg2 = mcparticles.iteratorAt(neg2.emmcparticleId()); + auto mccollision_from_neg2 = mcneg2.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_neg2.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + if (isPairOK(collision, neg1, neg2, cut)) { + 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) { + 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()) { + 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 (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()) { + 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(); + } + + template + bool isPairInAcc(TTrack const& t1, TTrack const& t2) + { + 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; + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (t1.pt() < dielectroncuts.cfg_min_pt_track || t2.pt() < dielectroncuts.cfg_min_pt_track) { + return false; + } + if ((t1.eta() < dielectroncuts.cfg_min_eta_track || dielectroncuts.cfg_max_eta_track < t1.eta()) || (t2.eta() < dielectroncuts.cfg_min_eta_track || dielectroncuts.cfg_max_eta_track < t2.eta())) { + return false; + } + if (v12.Rapidity() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < v12.Rapidity()) { + return false; + } + return true; + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (t1.pt() < dimuoncuts.cfg_min_pt_track || t2.pt() < dimuoncuts.cfg_min_pt_track) { + return false; + } + if ((t1.eta() < dimuoncuts.cfg_min_eta_track || dimuoncuts.cfg_max_eta_track < t1.eta()) || (t2.eta() < dimuoncuts.cfg_min_eta_track || dimuoncuts.cfg_max_eta_track < t2.eta())) { + return false; + } + if (v12.Rapidity() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < v12.Rapidity()) { + return false; + } + return true; + } else { + return false; + } + 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) + { + 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 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 + auto mcpos = mcparticles.iteratorAt(pos.emmcparticleId()); + auto mccollision_from_pos = mcpos.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_pos.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + auto mcneg = mcparticles.iteratorAt(neg.emmcparticleId()); + auto mccollision_from_neg = mcneg.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_neg.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + if ((abs(mcpos.pdgCode()) != pdg_lepton || abs(mcneg.pdgCode()) != pdg_lepton) || (mcpos.emmceventId() != mcneg.emmceventId())) { + continue; + } + if (mcpos.pdgCode() * mcneg.pdgCode() > 0) { // ULS + continue; + } + if (!((mcpos.isPhysicalPrimary() || mcpos.producedByGenerator()) && (mcneg.isPhysicalPrimary() || mcneg.producedByGenerator()))) { + continue; + } + int mother_id = FindLF(mcpos, mcneg, mcparticles); + int hfee_type = IsHF(mcpos, mcneg, mcparticles); + if (mother_id < 0 && hfee_type < 0) { + continue; + } + + if (!isPairOK(collision, pos, neg, cut)) { // without acceptance + continue; + } + + ROOT::Math::PtEtaPhiMVector v1rec(pos.pt(), pos.eta(), pos.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2rec(neg.pt(), neg.eta(), neg.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12rec = v1rec + v2rec; + + ROOT::Math::PtEtaPhiMVector v1mc(mcpos.pt(), mcpos.eta(), mcpos.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2mc(mcneg.pt(), mcneg.eta(), mcneg.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12mc = v1mc + v2mc; + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(pos.globalIndex(), neg.globalIndex())]; + } + + if (mother_id > -1) { + auto mcmother = mcparticles.iteratorAt(mother_id); + if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { + switch (abs(mcmother.pdgCode())) { + case 111: + case 221: + case 331: + case 113: + case 223: + case 333: { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/lf/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/lf/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/lf/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + break; + } + case 443: { + if (IsFromBeauty(mcmother, mcparticles) > 0) { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/NonPromptJPsi/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/NonPromptJPsi/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/NonPromptJPsi/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + } else { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/PromptJPsi/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/PromptJPsi/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/PromptJPsi/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + } + break; + } + case 100443: { + if (IsFromBeauty(mcmother, mcparticles) > 0) { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/NonPromptPsi2S/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/NonPromptPsi2S/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/NonPromptPsi2S/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + } else { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/PromptPsi2S/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/PromptPsi2S/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/PromptPsi2S/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + } + break; + } + default: + break; + } + } + } else if (hfee_type > -1) { + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): { + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/ccbar_uls/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/ccbar_uls/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/ccbar_uls/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + break; + } + case static_cast(EM_HFeeType::kBe_Be): + case static_cast(EM_HFeeType::kBCe_BCe): + case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS + if (isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/bbbar_uls/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos, neg) && isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/bbbar_uls/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos, neg) && !isPairInAcc(mcpos, mcneg)) { + fRegistry.fill(HIST("Unfold/bbbar_uls/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + break; + } + case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS + LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); + break; + default: + break; + } + } + } // end of ULS pairing + + for (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) { + continue; + } + auto mcpos2 = mcparticles.iteratorAt(pos2.emmcparticleId()); + auto mccollision_from_pos2 = mcpos2.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_pos2.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + if ((abs(mcpos1.pdgCode()) != pdg_lepton || abs(mcpos2.pdgCode()) != pdg_lepton) || (mcpos1.emmceventId() != mcpos2.emmceventId())) { + continue; + } + if (mcpos1.pdgCode() * mcpos2.pdgCode() < 0) { // LS + continue; + } + if (!((mcpos1.isPhysicalPrimary() || mcpos1.producedByGenerator()) && (mcpos2.isPhysicalPrimary() || mcpos2.producedByGenerator()))) { + continue; + } + int hfee_type = IsHF(mcpos1, mcpos2, mcparticles); + if (hfee_type < 0) { + continue; + } + + if (!isPairOK(collision, pos1, pos2, cut)) { // without acceptance + continue; + } + + ROOT::Math::PtEtaPhiMVector v1rec(pos1.pt(), pos1.eta(), pos1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2rec(pos2.pt(), pos2.eta(), pos2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12rec = v1rec + v2rec; + + ROOT::Math::PtEtaPhiMVector v1mc(mcpos1.pt(), mcpos1.eta(), mcpos1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2mc(mcpos2.pt(), mcpos2.eta(), mcpos2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12mc = v1mc + v2mc; + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(pos1.globalIndex(), pos2.globalIndex())]; + } + + if (hfee_type > -1) { + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): + LOGF(info, "You should not see kCe_Ce in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBe_Be): + LOGF(info, "You should not see kBe_Be in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_BCe): + LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + LOGF(info, "You should not see kBCe_Be_SameB in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS + if (isPairInAcc(pos1, pos2) && isPairInAcc(mcpos1, mcpos2)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/bbbar_ls/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(pos1, pos2) && isPairInAcc(mcpos1, mcpos2)) { + fRegistry.fill(HIST("Unfold/bbbar_ls/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(pos1, pos2) && !isPairInAcc(mcpos1, mcpos2)) { + fRegistry.fill(HIST("Unfold/bbbar_ls/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + break; + } + default: + break; + } + } + } // end of LS++ pairing + + for (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) { + continue; + } + auto mcneg2 = mcparticles.iteratorAt(neg2.emmcparticleId()); + auto mccollision_from_neg2 = mcneg2.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_neg2.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + if (!isPairOK(collision, neg1, neg2, cut)) { // without acceptance + continue; + } + if ((abs(mcneg1.pdgCode()) != pdg_lepton || abs(mcneg2.pdgCode()) != pdg_lepton) || (mcneg1.emmceventId() != mcneg2.emmceventId())) { + continue; + } + if (mcneg1.pdgCode() * mcneg2.pdgCode() < 0) { // LS + continue; + } + if (!((mcneg1.isPhysicalPrimary() || mcneg1.producedByGenerator()) && (mcneg2.isPhysicalPrimary() || mcneg2.producedByGenerator()))) { + continue; + } + int hfee_type = IsHF(mcneg1, mcneg2, mcparticles); + if (hfee_type < 0) { + continue; + } + + if (!isPairOK(collision, neg1, neg2, cut)) { // without acceptance + continue; + } + + ROOT::Math::PtEtaPhiMVector v1rec(neg1.pt(), neg1.eta(), neg1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2rec(neg2.pt(), neg2.eta(), neg2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12rec = v1rec + v2rec; + + ROOT::Math::PtEtaPhiMVector v1mc(mcneg1.pt(), mcneg1.eta(), mcneg1.phi(), leptonM1); + ROOT::Math::PtEtaPhiMVector v2mc(mcneg2.pt(), mcneg2.eta(), mcneg2.phi(), leptonM2); + ROOT::Math::PtEtaPhiMVector v12mc = v1mc + v2mc; + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(neg1.globalIndex(), neg2.globalIndex())]; + } + + if (hfee_type > -1) { + switch (hfee_type) { + case static_cast(EM_HFeeType::kCe_Ce): + LOGF(info, "You should not see kCe_Ce in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBe_Be): + LOGF(info, "You should not see kBe_Be in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_BCe): + LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS + LOGF(info, "You should not see kBCe_Be_SameB in LS. Good luck."); + break; + case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS + if (isPairInAcc(neg1, neg2) && isPairInAcc(mcneg1, mcneg2)) { // both rec and mc info are in acceptance. + fRegistry.fill(HIST("Unfold/bbbar_ls/hsRM"), v12mc.M(), v12mc.Pt(), v12rec.M(), v12rec.Pt(), weight); + } else if (!isPairInAcc(neg1, neg2) && isPairInAcc(mcneg1, mcneg2)) { + fRegistry.fill(HIST("Unfold/bbbar_ls/hMiss"), v12mc.M(), v12mc.Pt(), weight); + } else if (isPairInAcc(neg1, neg2) && !isPairInAcc(mcneg1, mcneg2)) { + fRegistry.fill(HIST("Unfold/bbbar_ls/hFake"), v12rec.M(), v12rec.Pt(), weight); + } + break; + } + default: + break; + } + } + } // end of LS-- pairing + } // end of collision loop + } + + Partition positive_electrons = o2::aod::emprimaryelectron::sign > int8_t(0); // reconstructed tracks + Partition negative_electrons = o2::aod::emprimaryelectron::sign < int8_t(0); // reconstructed tracks + Partition positive_muons = o2::aod::emprimarymuon::sign > int8_t(0); // reconstructed tracks + Partition negative_muons = o2::aod::emprimarymuon::sign < int8_t(0); // reconstructed tracks + + Partition positive_electronsMC = o2::aod::mcparticle::pdgCode == -11; // e+ + Partition negative_electronsMC = o2::aod::mcparticle::pdgCode == 11; // e- + Partition positive_muonsMC = o2::aod::mcparticle::pdgCode == -13; // mu+ + Partition negative_muonsMC = o2::aod::mcparticle::pdgCode == 13; // mu- + PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; + PresliceUnsorted perMcCollision_vm = aod::emmcgenvectormeson::emmceventId; + PresliceUnsorted recColperMcCollision = aod::emmceventlabel::emmceventId; + + void processAnalysis(FilteredMyCollisions const& collisions, aod::EMMCEvents const& mccollisions, aod::EMMCParticles const& mcparticles, TLeptons const& leptons) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + 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); + runGenInfo(collisions, mccollisions, positive_electronsMC, negative_electronsMC, mcparticles); + if (cfgFillUnfolding) { + fillUnfolding(collisions, positive_electrons, negative_electrons, o2::aod::emprimaryelectron::emeventId, fDielectronCut, 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); + runGenInfo(collisions, mccollisions, positive_muonsMC, negative_muonsMC, mcparticles); + if (cfgFillUnfolding) { + fillUnfolding(collisions, positive_muons, negative_muons, o2::aod::emprimarymuon::emeventId, fDimuonCut, mccollisions, mcparticles); + } + } + map_weight.clear(); + } + PROCESS_SWITCH(DileptonMC, processAnalysis, "run dilepton mc analysis", true); + + Partition positive_electronsMC_smeared = o2::aod::mcparticle::pdgCode == -11; // e+ + Partition negative_electronsMC_smeared = o2::aod::mcparticle::pdgCode == 11; // e- + Partition positive_muonsMC_smeared = o2::aod::mcparticle::pdgCode == -13; // mu+ + Partition negative_muonsMC_smeared = o2::aod::mcparticle::pdgCode == 13; // mu- + + void processAnalysis_Smeared(FilteredMyCollisions const& collisions, aod::EMMCEvents const& mccollisions, TLeptons const& leptons, TSmeardMCParitlces const& mcparticles_smeared) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + 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); + 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); + } + } 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); + 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); + } + } + map_weight.clear(); + } + PROCESS_SWITCH(DileptonMC, processAnalysis_Smeared, "run dilepton mc analysis with smearing", false); + + void processGen_VM(FilteredMyCollisions const& collisions, aod::EMMCEvents const&, aod::EMMCGenVectorMesons const& mcparticles) + { + // for oemga, phi efficiency + for (auto& collision : collisions) { + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(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) { + + if (!(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + continue; + } + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (mctrack.y() < dielectroncuts.cfg_min_pair_y || dielectroncuts.cfg_max_pair_y < mctrack.y()) { + continue; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (mctrack.y() < dimuoncuts.cfg_min_pair_y || dimuoncuts.cfg_max_pair_y < mctrack.y()) { + continue; + } + } + + switch (abs(mctrack.pdgCode())) { + case 223: + fRegistry.fill(HIST("Generated/sm/Omega2ll/hPtY"), mctrack.y(), mctrack.pt(), 1.f / mctrack.dsf()); + break; + case 333: + fRegistry.fill(HIST("Generated/sm/Phi2ll/hPtY"), mctrack.y(), mctrack.pt(), 1.f / mctrack.dsf()); + break; + default: + break; + } + + } // end of mctracks per mccollision + } // end of collision loop + } + PROCESS_SWITCH(DileptonMC, processGen_VM, "process generated info for vector mesons", false); + + void processNorm(aod::EMEventNormInfos const& collisions) + { + for (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); + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 6.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 7.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 8.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 9.0); + } + if (collision.sel8()) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); + } + if (abs(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 (!fEMEventCut.IsSelected(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 processDummy(MyCollisions const&) {} + PROCESS_SWITCH(DileptonMC, processDummy, "Dummy function", false); +}; + +#endif // PWGEM_DILEPTON_CORE_DILEPTONMC_H_ diff --git a/PWGEM/Dilepton/Core/DimuonCut.cxx b/PWGEM/Dilepton/Core/DimuonCut.cxx index 8f55e811dcb..ec101afa855 100644 --- a/PWGEM/Dilepton/Core/DimuonCut.cxx +++ b/PWGEM/Dilepton/Core/DimuonCut.cxx @@ -42,6 +42,13 @@ void DimuonCut::SetPairDCAxyRange(float min, float max) mMaxPairDCAxy = max; LOG(info) << "Dimuon Cut, set pair 3d dca range: " << mMinPairDCAxy << " - " << mMaxPairDCAxy; } +void DimuonCut::SetMindEtadPhi(bool flag, float min_deta, float min_dphi) +{ + mApplydEtadPhi = flag; + mMinDeltaEta = min_deta; + mMinDeltaPhi = min_dphi; + LOG(info) << "Dimuon Cut, set apply deta-dphi cut: " << mApplydEtadPhi << " min_deta: " << mMinDeltaEta << " min_dphi: " << mMinDeltaPhi; +} void DimuonCut::SetTrackType(int track_type) { mTrackType = track_type; @@ -59,6 +66,12 @@ void DimuonCut::SetTrackEtaRange(float minEta, float maxEta) mMaxTrackEta = maxEta; LOG(info) << "Dimuon Cut, set track eta range: " << mMinTrackEta << " - " << mMaxTrackEta; } +void DimuonCut::SetTrackPhiRange(float minPhi, float maxPhi) +{ + mMinTrackPhi = minPhi; + mMaxTrackPhi = maxPhi; + LOG(info) << "Dimuon Cut, set track phi range (rad.): " << mMinTrackPhi << " - " << mMaxTrackPhi; +} void DimuonCut::SetChi2(float min, float max) { mMinChi2 = min; diff --git a/PWGEM/Dilepton/Core/DimuonCut.h b/PWGEM/Dilepton/Core/DimuonCut.h index 07b9cb5d6f3..b13569387da 100644 --- a/PWGEM/Dilepton/Core/DimuonCut.h +++ b/PWGEM/Dilepton/Core/DimuonCut.h @@ -24,9 +24,13 @@ #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" + +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; class DimuonCut : public TNamed { @@ -34,6 +38,8 @@ class DimuonCut : public TNamed DimuonCut() = default; DimuonCut(const char* name, const char* title) : TNamed(name, title) {} + ~DimuonCut() {} + enum class DimuonCuts : int { // pair cut kMass = 0, @@ -44,6 +50,7 @@ class DimuonCut : public TNamed kTrackType, kTrackPtRange, kTrackEtaRange, + kTrackPhiRange, kDCAxy, kMFTNCls, kMCHMIDNCls, @@ -72,72 +79,92 @@ class DimuonCut : public TNamed return true; } - template + template bool IsSelectedPair(TTrack1 const& t1, TTrack2 const& t2) const { ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dcaX1 = t1.fwdDcaX(); - float dcaY1 = t1.fwdDcaY(); - float cXX1 = t1.cXX(); - float cYY1 = t1.cYY(); - float cXY1 = t1.cXY(); - float dcaX2 = t2.fwdDcaX(); - float dcaY2 = t2.fwdDcaY(); - float cXX2 = t2.cXX(); - float cYY2 = t2.cYY(); - float cXY2 = t2.cXY(); - - float dca_xy1 = 999.f; - float det1 = cXX1 * cYY1 - cXY1 * cXY1; - if (det1 < 0) { - dca_xy1 = 999.f; - } else { - float chi2 = (dcaX1 * dcaX1 * cYY1 + dcaY1 * dcaY1 * cXX1 - 2. * dcaX1 * dcaY1 * cXY1) / det1; - dca_xy1 = std::sqrt(std::abs(chi2) / 2.); // in sigma - } - - float dca_xy2 = 999.f; - float det2 = cXX2 * cYY2 - cXY2 * cXY2; - if (det2 < 0) { - dca_xy2 = 999.f; - } else { - float chi2 = (dcaX2 * dcaX2 * cYY2 + dcaY2 * dcaY2 * cXX2 - 2. * dcaX2 * dcaY2 * cXY2) / det2; - dca_xy2 = std::sqrt(std::abs(chi2) / 2.); // in sigma - } - - float pair_dca_xy = std::sqrt((std::pow(dca_xy1, 2) + std::pow(dca_xy2, 2)) / 2.); + float dca_xy_t1 = fwdDcaXYinSigma(t1); + float dca_xy_t2 = fwdDcaXYinSigma(t2); + float pair_dca_xy = std::sqrt((dca_xy_t1 * dca_xy_t1 + dca_xy_t2 * dca_xy_t2) / 2.); if (v12.M() < mMinMass || mMaxMass < v12.M()) { return false; } - if (v12.Pt() < mMinPairPt || mMaxPairPt < v12.Pt()) { + if (!dont_require_rapidity && (v12.Rapidity() < mMinPairY || mMaxPairY < v12.Rapidity())) { return false; } - if (v12.Rapidity() < mMinPairY || mMaxPairY < v12.Rapidity()) { + if (pair_dca_xy < mMinPairDCAxy || mMaxPairDCAxy < pair_dca_xy) { // in sigma for pair return false; } - if (pair_dca_xy < mMinPairDCAxy || mMaxPairDCAxy < pair_dca_xy) { // in sigma for pair + float deta = v1.Eta() - v2.Eta(); + float dphi = v1.Phi() - v2.Phi(); + o2::math_utils::bringToPMPi(dphi); + if (mApplydEtadPhi && std::pow(deta / mMinDeltaEta, 2) + std::pow(dphi / mMinDeltaPhi, 2) < 1.f) { return false; } + return true; } - template + template bool IsSelectedTrack(TTrack const& track) const { if (!IsSelectedTrack(track, DimuonCuts::kTrackType)) { return false; } - if (!IsSelectedTrack(track, DimuonCuts::kTrackPtRange)) { + + if (!dont_require_pteta) { + if (!IsSelectedTrack(track, DimuonCuts::kTrackPtRange)) { + return false; + } + if (!IsSelectedTrack(track, DimuonCuts::kTrackEtaRange)) { + 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)) { + return false; + } + if (!IsSelectedTrack(track, DimuonCuts::kPDCA)) { + return false; + } + 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::kTrackEtaRange)) { + if (!IsSelectedTrack(track, DimuonCuts::kTrackPhiRange)) { return false; } if (!IsSelectedTrack(track, DimuonCuts::kDCAxy)) { @@ -181,6 +208,9 @@ class DimuonCut : public TNamed case DimuonCuts::kTrackEtaRange: return track.eta() > mMinTrackEta && track.eta() < mMaxTrackEta; + case DimuonCuts::kTrackPhiRange: + return track.phi() > mMinTrackPhi && track.phi() < mMaxTrackPhi; + case DimuonCuts::kDCAxy: return mMinDcaXY < std::sqrt(std::pow(track.fwdDcaX(), 2) + std::pow(track.fwdDcaY(), 2)) && std::sqrt(std::pow(track.fwdDcaX(), 2) + std::pow(track.fwdDcaY(), 2)) < mMaxDcaXY; @@ -215,10 +245,12 @@ class DimuonCut : public TNamed void SetPairPtRange(float minPt = 0.f, float maxPt = 1e10f); void SetPairYRange(float minY = -1e10f, float maxY = 1e10f); void SetPairDCAxyRange(float min = 0.f, float max = 1e10f); // DCAxy in cm + void SetMindEtadPhi(bool flag, float min_deta, float min_dphi); void SetTrackType(int track_type); // 0: MFT-MCH-MID (global muon), 3: MCH-MID (standalone muon) 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 SetNClustersMFT(int min, int max); void SetNClustersMCHMID(int min, int max); void SetChi2(float min, float max); @@ -234,10 +266,14 @@ class DimuonCut : public TNamed float mMinPairPt{0.f}, mMaxPairPt{1e10f}; // range in pT float mMinPairY{-1e10f}, mMaxPairY{1e10f}; // range in rapidity float mMinPairDCAxy{0.f}, mMaxPairDCAxy{1e10f}; // range in 3D DCA in sigma + bool mApplydEtadPhi{false}; // flag to apply deta, dphi cut between 2 tracks + float mMinDeltaEta{0.f}; + float mMinDeltaPhi{0.f}; // kinematic cuts - float mMinTrackPt{0.f}, mMaxTrackPt{1e10f}; // range in pT - float mMinTrackEta{-1e10f}, mMaxTrackEta{1e10f}; // range in eta + 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 // track quality cuts int mTrackType{3}; diff --git a/PWGEM/Dilepton/Core/EMEventCut.cxx b/PWGEM/Dilepton/Core/EMEventCut.cxx index d1d3b45801d..a32edb39a55 100644 --- a/PWGEM/Dilepton/Core/EMEventCut.cxx +++ b/PWGEM/Dilepton/Core/EMEventCut.cxx @@ -18,8 +18,6 @@ ClassImp(EMEventCut); -const char* EMEventCut::mCutNames[static_cast(EMEventCut::EMEventCuts::kNCuts)] = {"Sel8", "FT0AND", "Zvtx", "eNoTFB", "RequireNoITSROFB", "NoSameBunchPileup", "GoodVertexITSTPC", "GoodZvtxFT0vsPV", "EMC MB Readout", "EMC L0 Triggered"}; - void EMEventCut::SetRequireSel8(bool flag) { mRequireSel8 = flag; @@ -39,13 +37,6 @@ void EMEventCut::SetZvtxRange(float min, float max) LOG(info) << "EM Event Cut, set z vtx range: " << mMinZvtx << " - " << mMaxZvtx; } -void EMEventCut::SetOccupancyRange(int min, int max) -{ - mMinOccupancy = min; - mMaxOccupancy = max; - LOG(info) << "EM Event Cut, set occupancy range: " << mMinOccupancy << " - " << mMaxOccupancy; -} - void EMEventCut::SetRequireNoTFB(bool flag) { mRequireNoTFB = flag; @@ -76,38 +67,25 @@ void EMEventCut::SetRequireGoodZvtxFT0vsPV(bool flag) LOG(info) << "EM Event Cut, require good Zvtx between FT0 vs. PV: " << mRequireGoodZvtxFT0vsPV; } -void EMEventCut::SetRequireEMCReadoutInMB(bool flag) +void EMEventCut::SetRequireNoCollInTimeRangeStandard(bool flag) { - mRequireEMCReadoutInMB = flag; - LOG(info) << "EM Event Cut, require the EMC to be read out in an MB collision by checking kTVXinEMC: " << mRequireEMCReadoutInMB; + mRequireNoCollInTimeRangeStandard = flag; + LOG(info) << "EM Event Cut, require No collision in time range standard: " << mRequireNoCollInTimeRangeStandard; } -void EMEventCut::SetRequireEMCHardwareTriggered(bool flag) +void EMEventCut::SetRequireNoCollInTimeRangeStrict(bool flag) { - mRequireEMCHardwareTriggered = flag; - LOG(info) << "EM Event Cut, require the EMC to be triggered by requiring kEMC7 or kDMC7: " << mRequireEMCHardwareTriggered; + mRequireNoCollInTimeRangeStrict = flag; + LOG(info) << "EM Event Cut, require No collision in time range strict: " << mRequireNoCollInTimeRangeStrict; } - -void EMEventCut::print() const +void EMEventCut::SetRequireNoCollInITSROFStandard(bool flag) { - LOG(info) << "EM Event Cut:"; - for (int i = 0; i < static_cast(EMEventCuts::kNCuts); i++) { - switch (static_cast(i)) { - case EMEventCuts::kFT0AND: - LOG(info) << mCutNames[i] << " = " << mRequireFT0AND; - break; - case EMEventCuts::kZvtx: - LOG(info) << mCutNames[i] << " in [" << mMinZvtx << ", " << mMaxZvtx << "]"; - break; - case EMEventCuts::kNoTFB: - LOG(info) << mCutNames[i] << " = " << mRequireNoTFB; - break; - case EMEventCuts::kNoITSROFB: - LOG(info) << mCutNames[i] << " = " << mRequireNoITSROFB; - break; + mRequireNoCollInITSROFStandard = flag; + LOG(info) << "EM Event Cut, require No collision in ITS TOF standard: " << mRequireNoCollInITSROFStandard; +} - default: - LOG(fatal) << "Cut unknown!"; - } - } +void EMEventCut::SetRequireNoCollInITSROFStrict(bool flag) +{ + mRequireNoCollInITSROFStrict = flag; + LOG(info) << "EM Event Cut, require No collision in ITS ROF strict: " << mRequireNoCollInITSROFStrict; } diff --git a/PWGEM/Dilepton/Core/EMEventCut.h b/PWGEM/Dilepton/Core/EMEventCut.h index 35df62f2183..7287871bcc3 100644 --- a/PWGEM/Dilepton/Core/EMEventCut.h +++ b/PWGEM/Dilepton/Core/EMEventCut.h @@ -27,6 +27,7 @@ class EMEventCut : public TNamed public: EMEventCut() = default; EMEventCut(const char* name, const char* title) : TNamed(name, title) {} + ~EMEventCut() {} enum class EMEventCuts : int { kSel8 = 0, @@ -37,14 +38,13 @@ class EMEventCut : public TNamed kNoSameBunchPileup, kIsVertexITSTPC, kIsGoodZvtxFT0vsPV, - kEMCReadoutInMB, - kEMCHardwareTriggered, - kOccupancy, + kNoCollInTimeRangeStandard, + kNoCollInTimeRangeStrict, + kNoCollInITSROFStandard, + kNoCollInITSROFStrict, kNCuts }; - static const char* mCutNames[static_cast(EMEventCuts::kNCuts)]; - template bool IsSelected(T const& collision) const { @@ -72,13 +72,16 @@ class EMEventCut : public TNamed if (mRequireGoodZvtxFT0vsPV && !IsSelected(collision, EMEventCuts::kIsGoodZvtxFT0vsPV)) { return false; } - if (mRequireEMCReadoutInMB && !IsSelected(collision, EMEventCuts::kEMCReadoutInMB)) { + if (mRequireNoCollInTimeRangeStandard && !IsSelected(collision, EMEventCuts::kNoCollInTimeRangeStandard)) { + return false; + } + if (mRequireNoCollInTimeRangeStrict && !IsSelected(collision, EMEventCuts::kNoCollInTimeRangeStrict)) { return false; } - if (mRequireEMCHardwareTriggered && !IsSelected(collision, EMEventCuts::kEMCHardwareTriggered)) { + if (mRequireNoCollInITSROFStandard && !IsSelected(collision, EMEventCuts::kNoCollInITSROFStandard)) { return false; } - if (!IsSelected(collision, EMEventCuts::kOccupancy)) { + if (mRequireNoCollInITSROFStrict && !IsSelected(collision, EMEventCuts::kNoCollInITSROFStrict)) { return false; } return true; @@ -112,19 +115,18 @@ class EMEventCut : public TNamed case EMEventCuts::kIsGoodZvtxFT0vsPV: return collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV); - case EMEventCuts::kEMCReadoutInMB: - return (collision.alias_bit(kTVXinEMC)); + case EMEventCuts::kNoCollInTimeRangeStandard: + return collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); - case EMEventCuts::kEMCHardwareTriggered: - return (collision.alias_bit(kEMC7) || collision.alias_bit(kDMC7)); + case EMEventCuts::kNoCollInTimeRangeStrict: + return collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict); + + case EMEventCuts::kNoCollInITSROFStandard: + return collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard); + + case EMEventCuts::kNoCollInITSROFStrict: + return collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict); - case EMEventCuts::kOccupancy: { - if (mMinOccupancy < 0) { - return true; - } else { - return mMinOccupancy <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < mMaxOccupancy; - } - } default: return true; } @@ -134,30 +136,29 @@ class EMEventCut : public TNamed void SetRequireSel8(bool flag); void SetRequireFT0AND(bool flag); void SetZvtxRange(float min, float max); - void SetOccupancyRange(int min, int max); void SetRequireNoTFB(bool flag); void SetRequireNoITSROFB(bool flag); void SetRequireNoSameBunchPileup(bool flag); void SetRequireVertexITSTPC(bool flag); void SetRequireGoodZvtxFT0vsPV(bool flag); - void SetRequireEMCReadoutInMB(bool flag); - void SetRequireEMCHardwareTriggered(bool flag); - - /// @brief Print the track selection - void print() const; + void SetRequireNoCollInTimeRangeStandard(bool flag); + void SetRequireNoCollInTimeRangeStrict(bool flag); + void SetRequireNoCollInITSROFStandard(bool flag); + void SetRequireNoCollInITSROFStrict(bool flag); private: bool mRequireSel8{true}; bool mRequireFT0AND{true}; float mMinZvtx{-10.f}, mMaxZvtx{+10.f}; - int mMinOccupancy{static_cast(-1e+9)}, mMaxOccupancy{static_cast(+1e+9)}; bool mRequireNoTFB{true}; bool mRequireNoITSROFB{true}; bool mRequireNoSameBunchPileup{false}; bool mRequireVertexITSTPC{false}; bool mRequireGoodZvtxFT0vsPV{false}; - bool mRequireEMCReadoutInMB{false}; - bool mRequireEMCHardwareTriggered{false}; + bool mRequireNoCollInTimeRangeStandard{false}; + bool mRequireNoCollInTimeRangeStrict{false}; + bool mRequireNoCollInITSROFStandard{false}; + bool mRequireNoCollInITSROFStrict{false}; ClassDef(EMEventCut, 1); }; diff --git a/PWGEM/Dilepton/Core/PhotonHBT.h b/PWGEM/Dilepton/Core/PhotonHBT.h index 4a4216b4fed..e522388d969 100644 --- a/PWGEM/Dilepton/Core/PhotonHBT.h +++ b/PWGEM/Dilepton/Core/PhotonHBT.h @@ -17,6 +17,7 @@ #ifndef PWGEM_DILEPTON_CORE_PHOTONHBT_H_ #define PWGEM_DILEPTON_CORE_PHOTONHBT_H_ +#include #include #include #include @@ -24,11 +25,11 @@ #include #include #include +#include #include "TString.h" #include "Math/Vector4D.h" #include "Math/Vector3D.h" -#include "Math/LorentzRotation.h" #include "Math/GenVector/Boost.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -40,38 +41,50 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" #include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.h" #include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/PhotonMeson/Utils/PairUtilities.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/Dilepton/Core/EMEventCut.h" #include "PWGEM/Dilepton/Core/DielectronCut.h" -#include "PWGEM/PhotonMeson/Core/V0PhotonCut.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 +{ +enum class ggHBTPairType : int { + kPCMPCM = 0, + kPCMEE = 1, + kEEEE = 2, +}; +} // namespace o2::aod::pwgem::dilepton::core::photonhbt 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 namespace o2::aod::pwgem::dilepton::core::photonhbt; using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; +using MyCollisionsWithSWT = soa::Join; +using MyCollisionWithSWT = MyCollisionsWithSWT::iterator; + using MyV0Photons = soa::Join; using MyV0Photon = MyV0Photons::iterator; -using MyPrimaryElectrons = soa::Join; -using MyPrimaryElectron = MyPrimaryElectrons::iterator; +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; +using FilteredMyTracks = soa::Filtered; +using FilteredMyTrack = FilteredMyTracks::iterator; -template +template struct PhotonHBT { // Configurables @@ -81,38 +94,49 @@ struct PhotonHBT { 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 cfgDo3D{"cfgDo3D", false, "enable 3D analysis"}; + Configurable cfgEP2Estimator_for_Mix{"cfgEP2Estimator_for_Mix", 3, "FT0M:0, FT0A:1, FT0C:2, BTot:3, BPos:4, BNeg:5"}; 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 cfgDoFlow{"cfgDoFlow", false, "flag to analyze vn"}; + // Configurable cfgSpherocityMin{"cfgSpherocityMin", -999.f, "min. spherocity"}; + // Configurable cfgSpherocityMax{"cfgSpherocityMax", +999.f, "max. spherocity"}; 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"}; 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 ConfEPBins{"ConfEPBins", {16, -M_PI / 2, +M_PI / 2}, "Mixing bins - event plane angle"}; 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", true, "flag to apply weighting by 1/N"}; - ConfigurableAxis ConfM1Bins{"ConfM1Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.0, 2.5}, "mass1 bins for output histograms"}; - ConfigurableAxis ConfM2Bins{"ConfM2Bins", {VARIABLE_WIDTH, 0.0, 0.14, 0.5, 1.1, 2.0, 2.5}, "mass2 bins for output histograms"}; - ConfigurableAxis ConfDCA1Bins{"ConfDCA1Bins", {VARIABLE_WIDTH, 0.0, 0.5, 1.0, 1.5, 2.0, 10.0}, "DCA1 bins for output histograms"}; - ConfigurableAxis ConfDCA2Bins{"ConfDCA2Bins", {VARIABLE_WIDTH, 0.0, 0.5, 1.0, 1.5, 2.0, 10.0}, "DCA2 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}, "kT 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"}; EMEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; - Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; + 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 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + 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 cfgRequireNoCollInITSROFStandard{"cfgRequireNoCollInITSROFStandard", false, "require no collision in time range standard"}; + Configurable cfgRequireNoCollInITSROFStrict{"cfgRequireNoCollInITSROFStrict", false, "require no collision in time range strict"}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -133,43 +157,60 @@ struct PhotonHBT { 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_disable_itsonly_track{"cfg_disable_itsonly_track", false, "flag to disable ITSonly 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"}; 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"}; } pcmcuts; - DielectronCut fDileptonCut; + DielectronCut fDielectronCut; struct : ConfigurableGroup { - std::string prefix = "dileptoncut_group"; + std::string prefix = "dielectroncut_group"; Configurable cfg_min_mass{"cfg_min_mass", 0.0, "min mass"}; - Configurable cfg_max_mass{"cfg_max_mass", 2.5, "max mass"}; // this is valid, because only ULS is used. - Configurable cfg_min_pair_pt{"cfg_min_pair_pt", 0.0, "min mass"}; - Configurable cfg_max_pair_pt{"cfg_max_pair_pt", 1e+10, "max mass"}; - Configurable cfg_min_pair_y{"cfg_min_pair_y", -0.8, "min mass"}; - Configurable cfg_max_pair_y{"cfg_max_pair_y", +0.8, "max mass"}; + Configurable cfg_max_mass{"cfg_max_mass", 0.015, "max mass"}; // this is valid, because only ULS is used. + 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_max_pair_dca3d{"cfg_max_pair_dca3d", 2.0, "max pair dca3d in sigma"}; 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"}; 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_apply_phiv_meedep{"cfg_apply_phiv_meedep", true, "flag to apply mee-dependent phiv cut"}; + 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_min_mee_for_phiv{"cfg_min_mee_for_phiv", 0.0, "min mee for phiv (constant)"}; + Configurable cfg_max_mee_for_phiv{"cfg_max_mee_for_phiv", 1e+10, "max mee for phiv (constant)"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max eta for single track"}; + Configurable cfg_max_eta_track{"cfg_max_eta_track", +0.8, "max eta for single track"}; + Configurable cfg_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1e+10, "max DCA 3D in sigma"}; 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_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_pid_scheme{"cfg_pid_scheme", static_cast(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3]"}; + 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"}; @@ -182,15 +223,30 @@ 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"}; - - // CCDB configuration for PID ML - Configurable BDTLocalPathGamma{"BDTLocalPathGamma", "pid_ml_xgboost.onnx", "Path to the local .onnx file"}; - - Configurable BDTPathCCDB{"BDTPathCCDB", "Users/d/dsekihat/pwgem/pidml/", "Path on CCDB"}; + 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"}; + + // 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)"}; - } dileptoncuts; + } dielectroncuts; + + struct : ConfigurableGroup { + std::string prefix = "ggpaircut_group"; + Configurable applydRdZ{"applydRdZ", false, "apply dr-dz cut to avoid track splitting/merging only for kPCMPCM"}; + Configurable applydEtadPhi{"applydEtadPhi", false, "apply deta-dphi cut to avoid track splitting/merging"}; + Configurable cfgMinDeltaEta{"cfgMinDeltaEta", 0.f, "min. delta-eta between 2 photons"}; + Configurable cfgMinDeltaPhi{"cfgMinDeltaPhi", 0.f, "min. delta-phi between 2 photons"}; + Configurable cfgMinDeltaR{"cfgMinDeltaR", 0.f, "min. delta-r between 2 photons"}; + Configurable cfgMinDeltaZ{"cfgMinDeltaZ", 0.f, "min. delta-z between 2 photons"}; + } ggpaircuts; ~PhotonHBT() { @@ -199,6 +255,8 @@ struct PhotonHBT { delete emh2; emh2 = 0x0; + map_mixed_eventId_to_globalBC.clear(); + used_photonIds.clear(); used_photonIds.shrink_to_fit(); used_dileptonIds.clear(); @@ -209,6 +267,9 @@ struct PhotonHBT { static constexpr std::string_view event_types[2] = {"before", "after"}; static constexpr std::string_view event_pair_types[2] = {"same/", "mix/"}; + std::mt19937 engine; + std::uniform_int_distribution dist01; + o2::ccdb::CcdbApi ccdbApi; Service ccdb; int mRunNumber; @@ -221,17 +282,74 @@ struct PhotonHBT { void init(InitContext& /*context*/) { - zvtx_bin_edges = std::vector(ConfVtxBins.value.begin(), ConfVtxBins.value.end()); - zvtx_bin_edges.erase(zvtx_bin_edges.begin()); + 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) { + 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]); + } + } - cent_bin_edges = std::vector(ConfCentBins.value.begin(), ConfCentBins.value.end()); - cent_bin_edges.erase(cent_bin_edges.begin()); + 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) { + 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]); + } + } - ep_bin_edges = std::vector(ConfEPBins.value.begin(), ConfEPBins.value.end()); - ep_bin_edges.erase(ep_bin_edges.begin()); + 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) { + LOGF(info, "VARIABLE_WIDTH: ep_bin_edges = %f", edge); + } + } else { + int nbins = static_cast(ConfEPBins.value[0]); + float xmin = static_cast(ConfEPBins.value[1]); + float xmax = static_cast(ConfEPBins.value[2]); + ep_bin_edges.resize(nbins + 1); + for (int i = 0; i < nbins + 1; i++) { + ep_bin_edges[i] = (xmax - xmin) / (nbins)*i + xmin; + LOGF(info, "FIXED_WIDTH: ep_bin_edges[%d] = %f", i, ep_bin_edges[i]); + } + } - occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); - occ_bin_edges.erase(occ_bin_edges.begin()); + 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 (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]); + } + } emh1 = new MyEMH(ndepth); emh2 = new MyEMH(ndepth); @@ -245,9 +363,18 @@ struct PhotonHBT { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); + + std::random_device seed_gen; + engine = std::mt19937(seed_gen()); + dist01 = std::uniform_int_distribution(0, 1); + + fRegistry.add("Pair/mix/hDiffBC", "diff. global BC in mixed event;|BC_{current} - BC_{mixed}|", kTH1D, {{1001, -0.5, 1000.5}}, true); + if (doprocessTriggerAnalysis) { + fRegistry.add("Event/hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); + } } - template + template void initCCDB(TCollision const& collision) { if (mRunNumber == collision.runNumber()) { @@ -284,27 +411,45 @@ struct PhotonHBT { 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()); + } } - static constexpr std::string_view pairnames[9] = {"PCMPCM", "PHOSPHOS", "EMCEMC", "PCMPHOS", "PCMEMC", "PCMDalitzEE", "PCMDalitzMuMu", "PHOSEMC", "DalitzEEDalitzEE"}; void addhistograms() { - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, false); + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); + std::string_view qvec_det_names[6] = {"FT0M", "FT0A", "FT0C", "BTot", "BPos", "BNeg"}; + fRegistry.add("Event/before/hEP2_CentFT0C_forMix", Form("2nd harmonics event plane for mix;centrality FT0C (%%);#Psi_{2}^{%s} (rad.)", qvec_det_names[cfgEP2Estimator_for_Mix].data()), kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); + fRegistry.add("Event/after/hEP2_CentFT0C_forMix", Form("2nd harmonics event plane for mix;centrality FT0C (%%);#Psi_{2}^{%s} (rad.)", qvec_det_names[cfgEP2Estimator_for_Mix].data()), kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); // pair info - const AxisSpec axis_mass1{ConfM1Bins, "m1 (GeV/c^{2})"}; - const AxisSpec axis_mass2{ConfM2Bins, "m2 (GeV/c^{2})"}; - const AxisSpec axis_dca1{ConfDCA1Bins, "DCA1 (#sigma)"}; - const AxisSpec axis_dca2{ConfDCA2Bins, "DCA2 (#sigma)"}; const AxisSpec axis_kt{ConfKtBins, "k_{T} (GeV/c)"}; + const AxisSpec axis_qinv{60, 0.0, +0.3, "q_{inv} (GeV/c)"}; + const AxisSpec axis_kstar{60, 0.0, +0.3, "k* (GeV/c)"}; + const AxisSpec axis_qabs_lcms{60, 0.0, +0.3, "|#bf{q}|^{LCMS} (GeV/c)"}; + const AxisSpec axis_qout{60, 0.0, +0.3, "q_{out} (GeV/c)"}; // qout does not change between LAB and LCMS frame + const AxisSpec axis_qside{60, 0.0, +0.3, "q_{side} (GeV/c)"}; // qside does not change between LAB and LCMS frame + const AxisSpec axis_qlong{60, 0.0, +0.3, "q_{long} (GeV/c)"}; + + if (cfgDo3D) { + fRegistry.add("Pair/same/hs_3d", "diphoton correlation 3D LCMS", kTHnSparseD, {axis_qout, axis_qside, axis_qlong, axis_kt}, true); + } else { + if constexpr (pairtype == ggHBTPairType::kPCMPCM) { // identical particle femtoscopy + fRegistry.add("Pair/same/hs_1d", "diphoton correlation 1D", kTHnSparseD, {axis_qinv, axis_qabs_lcms, axis_kt}, true); + } else { // non-identical particle femtoscopy + fRegistry.add("Pair/same/hs_1d", "diphoton correlation 1D", kTHnSparseD, {axis_kstar, axis_qabs_lcms, axis_kt}, true); + } + } - const AxisSpec axis_qinv{40, 0.0, +0.4, "q_{inv} (GeV/c)"}; - const AxisSpec axis_qout_cms{80, -0.4, +0.4, "q_{out}^{CMS} (GeV/c)"}; - const AxisSpec axis_qside_cms{80, -0.4, +0.4, "q_{side}^{CMS} (GeV/c)"}; - const AxisSpec axis_qlong_cms{80, -0.4, +0.4, "q_{long}^{CMS} (GeV/c)"}; - const AxisSpec axis_qlong_lcms{80, -0.4, +0.4, "q_{long}^{LCMS} (GeV/c)"}; + fRegistry.add("Pair/same/hDeltaEtaDeltaPhi", "distance between 2 LS tracks in #eta-#varphi plane;#Delta#varphi (rad.);#Delta#eta", kTH2D, {{80, -0.2, +0.2}, {80, -0.2, 0.2}}, true); // deta, dphi of track momentum + if constexpr (pairtype == ggHBTPairType::kPCMPCM) { // dr, dz of conversion points + fRegistry.add("Pair/same/hDeltaRDeltaZ", "diphoton distance in RZ;#Deltar = #sqrt{(#Deltax)^{2} + (#Deltay)^{2}} (cm);|#Deltaz| (cm)", kTH2D, {{40, 0, 20}, {40, 0, 20}}, true); + } - fRegistry.add("Pair/same/hs", "diphoton correlation", kTHnSparseD, {axis_mass1, axis_mass2, axis_dca1, axis_dca2, axis_kt, axis_qinv, axis_qout_cms, axis_qside_cms, axis_qlong_cms, axis_qlong_lcms}, true); fRegistry.addClone("Pair/same/", "Pair/mix/"); } @@ -313,13 +458,16 @@ struct PhotonHBT { fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); - fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); + fEMEventCut.SetZvtxRange(eventcuts.cfgZvtxMin, eventcuts.cfgZvtxMax); fEMEventCut.SetRequireNoTFB(eventcuts.cfgRequireNoTFB); fEMEventCut.SetRequireNoITSROFB(eventcuts.cfgRequireNoITSROFB); fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); } void DefinePCMCut() @@ -341,9 +489,12 @@ struct PhotonHBT { 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); + if (pcmcuts.cfg_reject_v0_on_itsib) { fV0PhotonCut.SetNClustersITS(2, 4); } else { @@ -375,131 +526,179 @@ struct PhotonHBT { } } + o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; void DefineDileptonCut() { - fDileptonCut = DielectronCut("fDileptonCut", "fDileptonCut"); + fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); // for pair - fDileptonCut.SetMeeRange(dileptoncuts.cfg_min_mass, dileptoncuts.cfg_max_mass); - fDileptonCut.SetPairPtRange(dileptoncuts.cfg_min_pair_pt, dileptoncuts.cfg_max_pair_pt); - fDileptonCut.SetPairYRange(dileptoncuts.cfg_min_pair_y, dileptoncuts.cfg_max_pair_y); - fDileptonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dileptoncuts.cfg_phiv_intercept) / dileptoncuts.cfg_phiv_slope; }); - fDileptonCut.SetPairDCARange(dileptoncuts.cfg_min_pair_dca3d, dileptoncuts.cfg_max_pair_dca3d); // in sigma - fDileptonCut.ApplyPhiV(dileptoncuts.cfg_apply_phiv); - fDileptonCut.ApplyPrefilter(dileptoncuts.cfg_apply_pf); - fDileptonCut.RequireITSibAny(dileptoncuts.cfg_require_itsib_any); - fDileptonCut.RequireITSib1st(dileptoncuts.cfg_require_itsib_1st); + 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); + if (dielectroncuts.cfg_apply_phiv_meedep) { + fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); + } else { + fDielectronCut.SetPhivPairRange(dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv, dielectroncuts.cfg_min_mee_for_phiv, dielectroncuts.cfg_max_mee_for_phiv); + } + fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); + fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); + fDielectronCut.RequireITSib1st(dielectroncuts.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.SetChi2PerClusterTPC(0.0, dileptoncuts.cfg_max_chi2tpc); - fDileptonCut.SetChi2PerClusterITS(0.0, dileptoncuts.cfg_max_chi2its); - fDileptonCut.SetNClustersITS(dileptoncuts.cfg_min_ncluster_its, 7); - fDileptonCut.SetMeanClusterSizeITSob(0, 16); - fDileptonCut.SetMaxDcaXY(dileptoncuts.cfg_max_dcaxy); - fDileptonCut.SetMaxDcaZ(dileptoncuts.cfg_max_dcaz); + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); + fDielectronCut.SetTrackDca3DRange(0.f, dielectroncuts.cfg_max_dca3dsigma_track); // in sigma + 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(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.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); // for eID - fDileptonCut.SetPIDScheme(dileptoncuts.cfg_pid_scheme); - fDileptonCut.SetTPCNsigmaElRange(dileptoncuts.cfg_min_TPCNsigmaEl, dileptoncuts.cfg_max_TPCNsigmaEl); - fDileptonCut.SetTPCNsigmaMuRange(dileptoncuts.cfg_min_TPCNsigmaMu, dileptoncuts.cfg_max_TPCNsigmaMu); - fDileptonCut.SetTPCNsigmaPiRange(dileptoncuts.cfg_min_TPCNsigmaPi, dileptoncuts.cfg_max_TPCNsigmaPi); - fDileptonCut.SetTPCNsigmaKaRange(dileptoncuts.cfg_min_TPCNsigmaKa, dileptoncuts.cfg_max_TPCNsigmaKa); - fDileptonCut.SetTPCNsigmaPrRange(dileptoncuts.cfg_min_TPCNsigmaPr, dileptoncuts.cfg_max_TPCNsigmaPr); - fDileptonCut.SetTOFNsigmaElRange(dileptoncuts.cfg_min_TOFNsigmaEl, dileptoncuts.cfg_max_TOFNsigmaEl); - - if (dileptoncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut - o2::ml::OnnxModel* eid_bdt = new o2::ml::OnnxModel(); - if (dileptoncuts.loadModelsFromCCDB) { + 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.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); + + 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 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.; + } + o2::framework::LabeledArray cutsMl = {cutsMlArr[0], nBinsMl, nClassesMl, labelsBins, labelsClasses}; + + mlResponseSingleTrack.configure(dielectroncuts.binsMl.value, cutsMl, cutDirMl, nClassesMl); + if (dielectroncuts.loadModelsFromCCDB) { ccdbApi.init(ccdburl); - std::map metadata; - bool retrieveSuccessGamma = ccdbApi.retrieveBlob(dileptoncuts.BDTPathCCDB.value, ".", metadata, dileptoncuts.timestampCCDB.value, false, dileptoncuts.BDTLocalPathGamma.value); - if (retrieveSuccessGamma) { - eid_bdt->initModel(dileptoncuts.BDTLocalPathGamma.value, dileptoncuts.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?"; - } + mlResponseSingleTrack.setModelPathsCCDB(dielectroncuts.onnxFileNames.value, ccdbApi, dielectroncuts.onnxPathsCCDB.value, dielectroncuts.timestampCCDB.value); } else { - eid_bdt->initModel(dileptoncuts.BDTLocalPathGamma.value, dileptoncuts.enableOptimizations.value); + mlResponseSingleTrack.setModelPathsLocal(dielectroncuts.onnxFileNames.value); } + mlResponseSingleTrack.cacheInputFeaturesIndices(dielectroncuts.namesInputFeatures); + mlResponseSingleTrack.cacheBinningIndex(dielectroncuts.nameBinningFeature); + mlResponseSingleTrack.init(dielectroncuts.enableOptimizations.value); - fDileptonCut.SetPIDModel(eid_bdt); + fDielectronCut.SetPIDMlResponse(&mlResponseSingleTrack); } // end of PID ML } template - void fillPairHistogram(TCollision const& /*collision*/, const ROOT::Math::PtEtaPhiMVector v1, const ROOT::Math::PtEtaPhiMVector v2, const float dca1, const float dca2) + void fillPairHistogram(TCollision const&, const ROOT::Math::PtEtaPhiMVector v1, const ROOT::Math::PtEtaPhiMVector v2, const float weight = 1.f) { - - // if constexpr (ev_id == 1 && pairtype == PairType::kEEEE) { - // if (t1.has_ambiguousElectrons() && t2.has_ambiguousElectrons()) { - // for (auto& possible_id1 : t1.ambiguousElectronsIds()) { - // for (auto& possible_id2 : t2.ambiguousElectronsIds()) { - // if (possible_id1 == possible_id2) { - // // LOGF(info, "event id = %d: same track is found. t1.trackId() = %d, t1.collisionId() = %d, t1.pt() = %f, t1.eta() = %f, t1.phi() = %f, t2.trackId() = %d, t2.collisionId() = %d, t2.pt() = %f, t2.eta() = %f, t2.phi() = %f", ev_id, t1.trackId(), t1.collisionId(), t1.pt(), t1.eta(), t1.phi(), t2.trackId(), t2.collisionId(), t2.pt(), t2.eta(), t2.phi()); - // 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. - // } - // } - // } - // } - // } - - // center-of-mass system (CMS) - ROOT::Math::PtEtaPhiMVector q12 = v1 - v2; + float rndm = std::pow(-1, dist01(engine) % 2); // +1 or -1 to randomize order between 1 and 2. + // Lab. frame + ROOT::Math::PtEtaPhiMVector q12 = (v1 - v2) * rndm; ROOT::Math::PtEtaPhiMVector k12 = 0.5 * (v1 + v2); - float qinv = -q12.M(); + float qinv = -q12.M(); // for identical particles -> qinv = 2 x kstar float kt = k12.Pt(); - float qlong_cms = q12.Pz(); - ROOT::Math::XYZVector q_3d = q12.Vect(); // 3D q vector ROOT::Math::XYZVector uv_out(k12.Px() / k12.Pt(), k12.Py() / k12.Pt(), 0); // unit vector for out. i.e. parallel to kt ROOT::Math::XYZVector uv_long(0, 0, 1); // unit vector for long, beam axis ROOT::Math::XYZVector uv_side = uv_out.Cross(uv_long); // unit vector for side - float qout_cms = q_3d.Dot(uv_out); - float qside_cms = q_3d.Dot(uv_side); + + ROOT::Math::PxPyPzEVector v1_cartesian(v1); + ROOT::Math::PxPyPzEVector v2_cartesian(v2); + ROOT::Math::PxPyPzEVector q12_cartesian = (v1_cartesian - v2_cartesian) * rndm; + float beta = (v1 + v2).Beta(); + float beta_x = beta * std::cos((v1 + v2).Phi()) * std::sin((v1 + v2).Theta()); + float beta_y = beta * std::sin((v1 + v2).Phi()) * std::sin((v1 + v2).Theta()); + float beta_z = beta * std::cos((v1 + v2).Theta()); // longitudinally co-moving system (LCMS) - ROOT::Math::PxPyPzEVector v1_cartesian(v1.Px(), v1.Py(), v1.Pz(), v1.E()); - ROOT::Math::PxPyPzEVector v2_cartesian(v2.Px(), v2.Py(), v2.Pz(), v2.E()); - ROOT::Math::PxPyPzEVector q12_cartesian = v1_cartesian - v2_cartesian; - float beta_z = (v1 + v2).Pz() / (v1 + v2).E(); ROOT::Math::Boost bst_z(0, 0, -beta_z); // Boost supports only PxPyPzEVector ROOT::Math::PxPyPzEVector q12_lcms = bst_z(q12_cartesian); - float qlong_lcms = q12_lcms.Pz(); + ROOT::Math::XYZVector q_3d_lcms = q12_lcms.Vect(); // 3D q vector in LCMS + float qout_lcms = q_3d_lcms.Dot(uv_out); + float qside_lcms = q_3d_lcms.Dot(uv_side); + float qlong_lcms = q_3d_lcms.Dot(uv_long); + float qabs_lcms = q_3d_lcms.R(); + + // float qabs_lcms_tmp = std::sqrt(std::pow(qout_lcms, 2) + std::pow(qside_lcms, 2) + std::pow(qlong_lcms, 2)); + // LOGF(info, "qabs_lcms = %f, qabs_lcms_tmp = %f", qabs_lcms, qabs_lcms_tmp); + + // pair rest frame (PRF) + ROOT::Math::Boost boostPRF = ROOT::Math::Boost(-beta_x, -beta_y, -beta_z); + ROOT::Math::PxPyPzEVector v1_prf = boostPRF(v1_cartesian); + ROOT::Math::PxPyPzEVector v2_prf = boostPRF(v2_cartesian); + ROOT::Math::PxPyPzEVector rel_k = (v1_prf - v2_prf) * rndm; + float kstar = 0.5 * rel_k.P(); + // LOGF(info, "qabs_lcms = %f, qinv = %f, kstar = %f", qabs_lcms, qinv, kstar); // ROOT::Math::PxPyPzEVector v1_lcms_cartesian = bst_z(v1_cartesian); // ROOT::Math::PxPyPzEVector v2_lcms_cartesian = bst_z(v2_cartesian); // ROOT::Math::PxPyPzEVector q12_lcms_cartesian = bst_z(q12_cartesian); - // LOGF(info, "q12.Pz() = %f, q12_cartesian.Pz() = %f",q12.Pz(), q12_cartesian.Pz()); - // LOGF(info, "v1.Pz() = %f, v2.Pz() = %f",v1.Pz(), v2.Pz()); - // LOGF(info, "v1_lcms_cartesian.Pz() = %f, v2_lcms_cartesian.Pz() = %f",v1_lcms_cartesian.Pz(), v2_lcms_cartesian.Pz()); + // LOGF(info, "q12.Pz() = %f, q12_cartesian.Pz() = %f", q12.Pz(), q12_cartesian.Pz()); + // LOGF(info, "v1.Pz() = %f, v2.Pz() = %f", v1.Pz(), v2.Pz()); + // LOGF(info, "v1_lcms_cartesian.Pz() = %f, v2_lcms_cartesian.Pz() = %f", v1_lcms_cartesian.Pz(), v2_lcms_cartesian.Pz()); // LOGF(info, "q12_lcms_cartesian.Pz() = %f", q12_lcms_cartesian.Pz()); - - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs"), v1.M(), v2.M(), dca1, dca2, kt, qinv, qout_cms, qside_cms, qlong_cms, qlong_lcms); + // LOGF(info, "q_3d_lcms.Dot(uv_out) = %f, q_3d_lcms.Dot(uv_side) = %f, q_3d.Dot(uv_out) = %f, q_3d.Dot(uv_side) = %f", q_3d_lcms.Dot(uv_out), q_3d_lcms.Dot(uv_side), q_3d.Dot(uv_out), q_3d.Dot(uv_side)); + // LOGF(info, "q12_lcms.Pz() = %f, q_3d_lcms.Dot(uv_long) = %f", q12_lcms.Pz(), q_3d_lcms.Dot(uv_long)); + // ROOT::Math::PxPyPzEVector q12_lcms_tmp = bst_z(v1_cartesian) - bst_z(v2_cartesian); + // LOGF(info, "q12_lcms.Px() = %f, q12_lcms.Py() = %f, q12_lcms.Pz() = %f, q12_lcms_tmp.Px() = %f, q12_lcms_tmp.Py() = %f, q12_lcms_tmp.Pz() = %f", q12_lcms.Px(), q12_lcms.Py(), q12_lcms.Pz(), q12_lcms_tmp.Px(), q12_lcms_tmp.Py(), q12_lcms_tmp.Pz()); + // float qabs_lcms_tmp = q12_lcms.P(); + // 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, 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 constexpr (pairtype == ggHBTPairType::kPCMPCM) { // identical particle femtoscopy + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs_1d"), qinv, qabs_lcms, kt, weight); + } else { + fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("hs_1d"), kstar, qabs_lcms, kt, weight); + } + } } - template + 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) { for (auto& collision : collisions) { - initCCDB(collision); + 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; + } + // if (collision.spherocity_ptunweighted() < cfgSpherocityMin || cfgSpherocityMax < collision.spherocity_ptunweighted()) { + // continue; + // } + // fRegistry.fill(HIST("Event/after/hSpherocity"), collision.spherocity_ptunweighted()); + } + const float eventplanes_2_for_mix[6] = {collision.ep2ft0m(), collision.ep2ft0a(), collision.ep2ft0c(), collision.ep2btot(), collision.ep2bpos(), collision.ep2bneg()}; + float ep2 = eventplanes_2_for_mix[cfgEP2Estimator_for_Mix]; + fRegistry.fill(HIST("Event/before/hEP2_CentFT0C_forMix"), collision.centFT0C(), ep2); - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, cfgDoFlow); + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); if (!fEMEventCut.IsSelected(collision)) { continue; } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, cfgDoFlow); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted + 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 + fRegistry.fill(HIST("Event/after/hEP2_CentFT0C_forMix"), collision.centFT0C(), ep2); int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1; if (zbin < 0) { @@ -516,7 +715,6 @@ struct PhotonHBT { 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; @@ -524,7 +722,15 @@ struct PhotonHBT { 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) { @@ -536,7 +742,7 @@ struct PhotonHBT { 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) { + if constexpr (pairtype == ggHBTPairType::kPCMPCM) { auto photons1_coll = photons1.sliceBy(perCollision1, collision.globalIndex()); auto photons2_coll = photons2.sliceBy(perCollision2, collision.globalIndex()); for (auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons1_coll, photons2_coll))) { @@ -554,21 +760,53 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), 0.); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.); - fillPairHistogram<0>(collision, v1, v2, 0.0, 0.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.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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/same/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), pos1.phi() - pos2.phi(), pos1.eta() - pos2.eta(), 1.f); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), ele1.phi() - ele2.phi(), ele1.eta() - ele2.eta(), 1.f); // distance between 2 LS tracks + + fillPairHistogram<0>(collision, v1, v2, 1.f); ndiphoton++; 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(g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0)); + EMTrack g1tmp = EMTrack(ndf, g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0); + g1tmp.setConversionPointXYZ(g1.vx(), g1.vy(), g1.vz()); + g1tmp.setPositiveLegPtEtaPhiM(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); + g1tmp.setNegativeLegPtEtaPhiM(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); + emh1->AddTrackToEventPool(key_df_collision, g1tmp); 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(g2.globalIndex(), collision.globalIndex(), g2.globalIndex(), g2.pt(), g2.eta(), g2.phi(), 0)); + EMTrack g2tmp = EMTrack(ndf, g2.globalIndex(), collision.globalIndex(), g2.globalIndex(), g2.pt(), g2.eta(), g2.phi(), 0); + g2tmp.setConversionPointXYZ(g2.vx(), g2.vy(), g2.vz()); + g2tmp.setPositiveLegPtEtaPhiM(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + g2tmp.setNegativeLegPtEtaPhiM(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + emh1->AddTrackToEventPool(key_df_collision, g2tmp); used_photonIds.emplace_back(pair_tmp_id2); } } // end of pairing loop - } else if constexpr (pairtype == PairType::kEEEE) { + } else if constexpr (pairtype == ggHBTPairType::kEEEE) { 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); std::vector, std::pair>> used_pairs_per_collision; @@ -578,12 +816,12 @@ struct PhotonHBT { if (pos1.trackId() == ele1.trackId()) { // this is protection against pairing identical 2 tracks. // never happens. only for protection. continue; } - if (dileptoncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!cut1.template IsSelectedTrack(pos1, collision) || !cut1.template IsSelectedTrack(ele1, collision)) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut1.template IsSelectedTrack(pos1, collision) || !cut1.template IsSelectedTrack(ele1, collision)) { continue; } } else { // cut-based - if (!cut1.template IsSelectedTrack(pos1, collision) || !cut1.template IsSelectedTrack(ele1, collision)) { + if (!cut1.template IsSelectedTrack(pos1, collision) || !cut1.template IsSelectedTrack(ele1, collision)) { continue; } } @@ -597,17 +835,21 @@ struct PhotonHBT { float dca_pos1_3d = dca3DinSigma(pos1); float dca_ele1_3d = dca3DinSigma(ele1); float dca1_3d = std::sqrt((dca_pos1_3d * dca_pos1_3d + dca_ele1_3d * dca_ele1_3d) / 2.); + float weight1 = 1.f; + if (cfgApplyWeightTTCA) { + weight1 = map_weight[std::make_pair(pos1.globalIndex(), ele1.globalIndex())]; + } for (auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. // never happens. only for protection. continue; } - if (dileptoncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { continue; } } else { // cut-based - if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { continue; } } @@ -619,6 +861,11 @@ struct PhotonHBT { continue; } + float weight2 = 1.f; + if (cfgApplyWeightTTCA) { + weight2 = map_weight[std::make_pair(pos2.globalIndex(), ele2.globalIndex())]; + } + float dca_pos2_3d = dca3DinSigma(pos2); float dca_ele2_3d = dca3DinSigma(ele2); float dca2_3d = std::sqrt((dca_pos2_3d * dca_pos2_3d + dca_ele2_3d * dca_ele2_3d) / 2.); @@ -629,33 +876,68 @@ 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()) { - fillPairHistogram<0>(collision, v1_ee, v2_ee, dca1_3d, dca2_3d); + 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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, weight1 * weight2); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), 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)); used_pairs_per_collision.emplace_back(std::make_pair(pair_tmp.second, pair_tmp.first)); - ndiphoton++; std::tuple tuple_tmp_id1 = std::make_tuple(ndf, collision.globalIndex(), pos1.globalIndex(), ele1.globalIndex()); std::tuple tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.globalIndex(), ele2.globalIndex()); if (std::find(used_dileptonIds.begin(), used_dileptonIds.end(), tuple_tmp_id1) == used_dileptonIds.end()) { - EMTrack g1pair = EMTrack(-1, collision.globalIndex(), -1, v1_ee.Pt(), v1_ee.Eta(), v1_ee.Phi(), v1_ee.M()); + std::vector possibleIds_pos1; + std::vector possibleIds_ele1; + std::copy(pos1.ambiguousElectronsIds().begin(), pos1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds_pos1)); + std::copy(ele1.ambiguousElectronsIds().begin(), ele1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds_ele1)); + + EMTrack g1pair = EMTrack(ndf, -1, collision.globalIndex(), -1, v1_ee.Pt(), v1_ee.Eta(), v1_ee.Phi(), v1_ee.M()); + g1pair.setGlobalPosId(pos1.globalIndex()); + g1pair.setGlobalNegId(ele1.globalIndex()); g1pair.setPairDca3DinSigmaOTF(dca1_3d); + g1pair.setPositiveLegPtEtaPhiM(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); + g1pair.setNegativeLegPtEtaPhiM(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); + g1pair.setAmbPosLegSelfIds(possibleIds_pos1); + g1pair.setAmbNegLegSelfIds(possibleIds_ele1); emh1->AddTrackToEventPool(key_df_collision, g1pair); - // emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, collision.globalIndex(), -1, v1_ee.Pt(), v1_ee.Eta(), v1_ee.Phi(), v1_ee.M())); used_dileptonIds.emplace_back(tuple_tmp_id1); } if (std::find(used_dileptonIds.begin(), used_dileptonIds.end(), tuple_tmp_id2) == used_dileptonIds.end()) { - EMTrack g2pair = EMTrack(-1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M()); + std::vector possibleIds_pos2; + std::vector possibleIds_ele2; + std::copy(pos2.ambiguousElectronsIds().begin(), pos2.ambiguousElectronsIds().end(), std::back_inserter(possibleIds_pos2)); + std::copy(ele2.ambiguousElectronsIds().begin(), ele2.ambiguousElectronsIds().end(), std::back_inserter(possibleIds_ele2)); + + EMTrack g2pair = EMTrack(ndf, -1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M()); + g2pair.setGlobalPosId(pos2.globalIndex()); + g2pair.setGlobalNegId(ele2.globalIndex()); g2pair.setPairDca3DinSigmaOTF(dca2_3d); + g2pair.setPositiveLegPtEtaPhiM(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + g2pair.setNegativeLegPtEtaPhiM(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); + g2pair.setAmbPosLegSelfIds(possibleIds_pos2); + g2pair.setAmbNegLegSelfIds(possibleIds_ele2); emh1->AddTrackToEventPool(key_df_collision, g2pair); - // emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M())); used_dileptonIds.emplace_back(tuple_tmp_id2); } } } // end of g2 loop - } // end of g1 loop + } // end of g1 loop used_pairs_per_collision.clear(); used_pairs_per_collision.shrink_to_fit(); - } else if constexpr (pairtype == PairType::kPCMDalitzEE) { + } else if constexpr (pairtype == ggHBTPairType::kPCMEE) { 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); @@ -672,12 +954,12 @@ struct PhotonHBT { if (pos2.trackId() == ele2.trackId()) { // this is protection against pairing identical 2 tracks. // never happens. only for protection. continue; } - if (dileptoncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { continue; } } else { // cut-based - if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { + if (!cut2.template IsSelectedTrack(pos2, collision) || !cut2.template IsSelectedTrack(ele2, collision)) { continue; } } @@ -689,6 +971,12 @@ struct PhotonHBT { continue; } + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[std::make_pair(pos2.globalIndex(), ele2.globalIndex())]; + } + // LOGF(info, "g1.globalIndex() = %d, map_weight[std::make_pair(%d, %d)] = %f", g1.globalIndex(), pos2.globalIndex(), ele2.globalIndex(), weight); + float dca_pos2_3d = dca3DinSigma(pos2); float dca_ele2_3d = dca3DinSigma(ele2); float dca2_3d = std::sqrt((dca_pos2_3d * dca_pos2_3d + dca_ele2_3d * dca_ele2_3d) / 2.); @@ -696,23 +984,45 @@ struct PhotonHBT { ROOT::Math::PtEtaPhiMVector v_pos2(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v_ele2(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); ROOT::Math::PtEtaPhiMVector v2_ee = v_pos2 + v_ele2; - fillPairHistogram<0>(collision, v1_gamma, v2_ee, 0.0, dca2_3d); + + 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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, weight); + fRegistry.fill(HIST("Pair/same/hDeltaEtaDeltaPhi"), dphi_ele, deta_ele, weight); + + fillPairHistogram<0>(collision, v1_gamma, v2_ee, weight); ndiphoton++; std::pair pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex()); std::tuple tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.globalIndex(), ele2.globalIndex()); if (std::find(used_photonIds.begin(), used_photonIds.end(), pair_tmp_id1) == used_photonIds.end()) { - emh1->AddTrackToEventPool(key_df_collision, EMTrack(g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0)); + EMTrack g1tmp = EMTrack(ndf, g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0); + g1tmp.setConversionPointXYZ(g1.vx(), g1.vy(), g1.vz()); + g1tmp.setPositiveLegPtEtaPhiM(pos1.pt(), pos1.eta(), pos1.phi(), o2::constants::physics::MassElectron); + g1tmp.setNegativeLegPtEtaPhiM(ele1.pt(), ele1.eta(), ele1.phi(), o2::constants::physics::MassElectron); + emh1->AddTrackToEventPool(key_df_collision, g1tmp); used_photonIds.emplace_back(pair_tmp_id1); } if (std::find(used_dileptonIds.begin(), used_dileptonIds.end(), tuple_tmp_id2) == used_dileptonIds.end()) { - EMTrack g2pair = EMTrack(-1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M()); + EMTrack g2pair = EMTrack(ndf, -1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M()); g2pair.setPairDca3DinSigmaOTF(dca2_3d); + g2pair.setPositiveLegPtEtaPhiM(pos2.pt(), pos2.eta(), pos2.phi(), o2::constants::physics::MassElectron); + g2pair.setNegativeLegPtEtaPhiM(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron); emh2->AddTrackToEventPool(key_df_collision, g2pair); - // emh2->AddTrackToEventPool(key_df_collision, EMTrack(-1, collision.globalIndex(), -1, v2_ee.Pt(), v2_ee.Eta(), v2_ee.Phi(), v2_ee.M())); used_dileptonIds.emplace_back(tuple_tmp_id2); } } // end of g2 loop - } // end of g1 loop + } // end of g1 loop } // event mixing @@ -727,7 +1037,7 @@ struct PhotonHBT { auto collisionIds1_in_mixing_pool = emh1->GetCollisionIdsFromEventPool(key_bin); auto collisionIds2_in_mixing_pool = emh2->GetCollisionIdsFromEventPool(key_bin); - if constexpr (pairtype == PairType::kPCMPCM) { + if constexpr (pairtype == ggHBTPairType::kPCMPCM) { for (auto& mix_dfId_collisionId : collisionIds1_in_mixing_pool) { int mix_dfId = mix_dfId_collisionId.first; int64_t mix_collisionId = mix_dfId_collisionId.second; @@ -736,6 +1046,13 @@ struct PhotonHBT { 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()); @@ -743,11 +1060,39 @@ struct PhotonHBT { for (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.); - fillPairHistogram<1>(collision, v1, v2, 0.0, 0.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.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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/mix/hDeltaRDeltaZ"), dr, fabs(dz), 1.f); + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + fillPairHistogram<1>(collision, v1, v2, 1.f); } } } // end of loop over mixed event pool - } else if constexpr (pairtype == PairType::kEEEE) { + } else if constexpr (pairtype == ggHBTPairType::kEEEE) { for (auto& mix_dfId_collisionId : collisionIds1_in_mixing_pool) { int mix_dfId = mix_dfId_collisionId.first; int64_t mix_collisionId = mix_dfId_collisionId.second; @@ -755,19 +1100,61 @@ struct PhotonHBT { 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 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 (auto& g1 : selected_photons1_in_this_event) { for (auto& g2 : photons1_from_event_pool) { + auto v1amb_pos_Ids = g1.ambiguousPosLegIds(); + auto v1amb_neg_Ids = g1.ambiguousNegLegIds(); + auto v2amb_pos_Ids = g2.ambiguousPosLegIds(); + auto v2amb_neg_Ids = g2.ambiguousNegLegIds(); + + bool is_found_pos1 = std::find(v2amb_pos_Ids.begin(), v2amb_pos_Ids.end(), g1.globalIndexPos()) != v2amb_pos_Ids.end(); + bool is_found_neg1 = std::find(v2amb_neg_Ids.begin(), v2amb_neg_Ids.end(), g1.globalIndexPos()) != v2amb_neg_Ids.end(); + bool is_found_pos2 = std::find(v1amb_pos_Ids.begin(), v1amb_pos_Ids.end(), g2.globalIndexPos()) != v1amb_pos_Ids.end(); + 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(); + + 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()); + continue; // this is protection against pairing 2 identical tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + } + ROOT::Math::PtEtaPhiMVector v1(g1.pt(), g1.eta(), g1.phi(), g1.mass()); ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), g2.mass()); - fillPairHistogram<1>(collision, v1, v2, g1.pairDca3DinSigmaOTF(), g2.pairDca3DinSigmaOTF()); + + 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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + fillPairHistogram<1>(collision, v1, v2, 1.f); } } - } // end of loop over mixed event pool - } else if constexpr (pairtype == PairType::kPCMDalitzEE) { // [photon1 from event1, photon2 from event2] and [photon1 from event2, photon2 from event1] + } // end of loop over mixed event pool + } else if constexpr (pairtype == ggHBTPairType::kPCMEE) { // [photon1 from event1, photon2 from event2] and [photon1 from event2, photon2 from event1] for (auto& mix_dfId_collisionId : collisionIds1_in_mixing_pool) { int mix_dfId = mix_dfId_collisionId.first; int64_t mix_collisionId = mix_dfId_collisionId.second; @@ -775,6 +1162,12 @@ struct PhotonHBT { 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()); @@ -783,7 +1176,28 @@ struct PhotonHBT { for (auto& g2 : photons2_from_event_pool) { // dielectron 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()); - fillPairHistogram<1>(collision, v1, v2, 0.0, g2.pairDca3DinSigmaOTF()); + + 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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + fillPairHistogram<1>(collision, v1, v2, 1.f); } } } // end of loop over mixed event pool2 @@ -795,6 +1209,12 @@ struct PhotonHBT { 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 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()); @@ -803,7 +1223,28 @@ struct PhotonHBT { for (auto& g2 : photons1_from_event_pool) { // PCM 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()); - fillPairHistogram<1>(collision, v1, v2, 0.0, g1.pairDca3DinSigmaOTF()); + + 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 && std::pow(deta_pos / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_pos / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + if (ggpaircuts.applydEtadPhi && std::pow(deta_ele / ggpaircuts.cfgMinDeltaEta, 2) + std::pow(dphi_ele / ggpaircuts.cfgMinDeltaPhi, 2) < 1.f) { + continue; + } + + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_pos, deta_pos, 1.f); // distance between 2 LS tracks + fRegistry.fill(HIST("Pair/mix/hDeltaEtaDeltaPhi"), dphi_ele, deta_ele, 1.f); // distance between 2 LS tracks + fillPairHistogram<1>(collision, v1, v2, 1.f); } } } // end of loop over mixed event pool1 @@ -812,47 +1253,157 @@ struct PhotonHBT { 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 + } + + std::map, float> map_weight; // -> float + template + void fillDileptonPairWeightMap(TCollisions const& collisions, TTracks const& tracks, TCut const& cut) + { + std::vector> passed_pairIds; + passed_pairIds.reserve(positrons.size() * electrons.size()); + + 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 constexpr (isTriggerAnalysis) { + if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) { + continue; + } + // if (collision.spherocity_ptunweighted() < cfgSpherocityMin || cfgSpherocityMax < collision.spherocity_ptunweighted()) { + // continue; + // } + } + if (!fEMEventCut.IsSelected(collision)) { + continue; } + + 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 (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { + if (pos.trackId() == ele.trackId()) { // this is protection against pairing identical 2 tracks. // never happens. only for protection. + continue; + } + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(pos, collision) || !cut.template IsSelectedTrack(ele, collision)) { + continue; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(pos, collision) || !cut.template IsSelectedTrack(ele, collision)) { + continue; + } + } + if (!cut.IsSelectedPair(pos, ele, d_bz)) { + continue; + } + passed_pairIds.emplace_back(std::make_pair(pos.globalIndex(), ele.globalIndex())); + } // end of dielectron pairing loop } // end of collision loop + + for (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()) { + if (std::find(passed_pairIds.begin(), passed_pairIds.end(), std::make_pair(ambId1, ambId2)) != passed_pairIds.end()) { + // LOGF(info, "repeated pair is found. t1.globalIndex() = %d, t2.globalIndex() = %d, ambId1 = %d, ambId2 = %d", t1.globalIndex(), t2.globalIndex(), ambId1, ambId2); + n += 1.f; + } + } + } + map_weight[pairId] = 1.f / n; + + } // end of passed_pairIds loop + + passed_pairIds.clear(); + passed_pairIds.shrink_to_fit(); } - 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); + Filter trackFilter = 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 = (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 ttcaFilter = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); + + Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0); 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; SliceCache cache; Preslice perCollision_pcm = aod::v0photonkf::emeventId; - Preslice perCollision_electron = aod::emprimaryelectron::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_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; int ndf = 0; void processAnalysis(FilteredMyCollisions const& collisions, Types const&... args) { - if constexpr (pairtype == PairType::kPCMPCM) { + if constexpr (pairtype == ggHBTPairType::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) { + runPairing(collisions, v0photons, v0photons, v0legs, v0legs, perCollision_pcm, perCollision_pcm, fV0PhotonCut, fV0PhotonCut); + } else if constexpr (pairtype == ggHBTPairType::kPCMEE) { auto v0photons = std::get<0>(std::tie(args...)); auto v0legs = std::get<1>(std::tie(args...)); auto emprimaryelectrons = std::get<2>(std::tie(args...)); - runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut); - } else if constexpr (pairtype == PairType::kEEEE) { + if (cfgApplyWeightTTCA) { + fillDileptonPairWeightMap(collisions, emprimaryelectrons, fDielectronCut); + } + runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDielectronCut); + } else if constexpr (pairtype == ggHBTPairType::kEEEE) { auto emprimaryelectrons = std::get<0>(std::tie(args...)); - runPairing(collisions, nullptr, nullptr, emprimaryelectrons, emprimaryelectrons, perCollision_electron, perCollision_electron, fDileptonCut, fDileptonCut); + if (cfgApplyWeightTTCA) { + fillDileptonPairWeightMap(collisions, emprimaryelectrons, fDielectronCut); + } + runPairing(collisions, nullptr, nullptr, emprimaryelectrons, emprimaryelectrons, perCollision_electron, perCollision_electron, fDielectronCut, fDielectronCut); } - ndf++; } PROCESS_SWITCH(PhotonHBT, processAnalysis, "pairing for analysis", false); + using FilteredMyCollisionsWithSWT = soa::Filtered; + void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, Types const&... args) + { + if constexpr (pairtype == ggHBTPairType::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 == ggHBTPairType::kPCMEE) { + auto v0photons = std::get<0>(std::tie(args...)); + auto v0legs = std::get<1>(std::tie(args...)); + auto emprimaryelectrons = std::get<2>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillDileptonPairWeightMap(collisions, emprimaryelectrons, fDielectronCut); + } + runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDielectronCut); + } else if constexpr (pairtype == ggHBTPairType::kEEEE) { + auto emprimaryelectrons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillDileptonPairWeightMap(collisions, emprimaryelectrons, fDielectronCut); + } + runPairing(collisions, nullptr, nullptr, emprimaryelectrons, emprimaryelectrons, perCollision_electron, perCollision_electron, fDielectronCut, fDielectronCut); + } + ndf++; + } + PROCESS_SWITCH(PhotonHBT, processTriggerAnalysis, "pairing analysis on trigger data", false); + void processDummy(MyCollisions const&) {} PROCESS_SWITCH(PhotonHBT, processDummy, "Dummy function", true); }; diff --git a/PWGEM/Dilepton/Core/SingleTrackQC.h b/PWGEM/Dilepton/Core/SingleTrackQC.h new file mode 100644 index 00000000000..6bc3f83a2fe --- /dev/null +++ b/PWGEM/Dilepton/Core/SingleTrackQC.h @@ -0,0 +1,759 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 electrons for QC. +// Please write to: daiki.sekihata@cern.ch + +#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/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.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::dilepton::utils::emtrackutil; + +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; + +template +struct SingleTrackQC { + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + 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 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"}; + + 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", 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"}; + } eventcuts; + + DielectronCut fDielectronCut; + struct : ConfigurableGroup { + std::string prefix = "dielectroncut_group"; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max 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_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", 0.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "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 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_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 enableTTCA{"enableTTCA", true, "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_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_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_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"}; + } dimuoncuts; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; // 1 HistogramRegistry can keep up to 512 histograms + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + + ~SingleTrackQC() {} + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + 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}; + + // 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/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/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/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, 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/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, 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/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/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/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/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); + 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)"}; + + // track info + fRegistry.add("Track/positive/hs", "rec. single muon", 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/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/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/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/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); + fRegistry.addClone("Track/positive/", "Track/negative/"); + } + } + + int mRunNumber; + void init(InitContext&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + DefineEMEventCut(); + DefineDielectronCut(); + DefineDimuonCut(); + addhistograms(); + mRunNumber = 0; + + 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); + } + } + + template + void initCCDB(TCollision const& collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + 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()); + } + } + + 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.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + } + + o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; + void DefineDielectronCut() + { + fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + 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.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(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.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); + + // 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.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); + + 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 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.; + } + 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 track + fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); + fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); + 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); }); + } + + template + void fillElectronInfo(TTrack const& track) + { + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[track.globalIndex()]; + } + + float dca = dca3DinSigma(track); + if (cfgDCAType == 1) { + dca = dcaXYinSigma(track); + } else if (cfgDCAType == 2) { + dca = 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/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/hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/positive/hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/positive/hNcrTPC"), 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()); + fRegistry.fill(HIST("Track/positive/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + fRegistry.fill(HIST("Track/positive/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/positive/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/positive/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/positive/hChi2TOF"), track.p(), track.tofChi2()); + + fRegistry.fill(HIST("Track/positive/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + 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/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/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/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, 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/hNclsITS"), track.itsNCls()); + fRegistry.fill(HIST("Track/negative/hNclsTPC"), track.tpcNClsFound()); + fRegistry.fill(HIST("Track/negative/hNcrTPC"), 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()); + fRegistry.fill(HIST("Track/negative/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + fRegistry.fill(HIST("Track/negative/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/negative/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/negative/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/negative/hChi2TOF"), track.p(), track.tofChi2()); + + fRegistry.fill(HIST("Track/negative/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + 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/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/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/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()); + } + } + + template + void fillMuonInfo(TTrack const& track) + { + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[track.globalIndex()]; + } + float dca_xy = fwdDcaXYinSigma(track); + if (track.sign() > 0) { + fRegistry.fill(HIST("Track/positive/hs"), track.pt(), track.eta(), track.phi(), dca_xy, 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/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/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/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/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/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); + fRegistry.fill(HIST("Track/negative/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); + fRegistry.fill(HIST("Track/negative/hMFTClusterMap"), track.mftClusterMap()); + } + } + + template + void runQC(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut) + { + for (auto& collision : collisions) { + initCCDB(collision); + 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::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision); + if (!fEMEventCut.IsSelected(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()); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + for (auto& track : tracks_per_coll) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(track, collision)) { + continue; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(track)) { + continue; + } + } + 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)) { + continue; + } + fillMuonInfo(track); + } // end of track loop + } + } // end of collision loop + } + + std::unordered_map map_weight; + template + void fillTrackWeightMap(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut) + { + std::vector passed_trackIds; + passed_trackIds.reserve(tracks.size()); + for (auto& collision : collisions) { + initCCDB(collision); + 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; + } + + 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) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(track, collision)) { + continue; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(track)) { + continue; + } + } + 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)) { + continue; + } + passed_trackIds.emplace_back(track.globalIndex()); + } // end of track loop + } + } // end of collision loop + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + for (auto& trackId : passed_trackIds) { + auto track = tracks.rawIteratorAt(trackId); + auto ambIds = track.ambiguousElectronsIds(); + float n = 1.f; // include myself. + for (auto& ambId : ambIds) { + if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { + n += 1.f; + } + } + map_weight[trackId] = 1.f / n; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + for (auto& trackId : passed_trackIds) { + auto track = tracks.rawIteratorAt(trackId); + auto ambIds = track.ambiguousMuonsIds(); + float n = 1.f; // include myself. + for (auto& ambId : ambIds) { + if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { + n += 1.f; + } + } + map_weight[trackId] = 1.f / n; + } + } + + passed_trackIds.clear(); + passed_trackIds.shrink_to_fit(); + } + + 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 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 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; + using FilteredMyCollisions = soa::Filtered; + + void processQC(FilteredMyCollisions const& collisions, Types const&... args) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + auto electrons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, electrons, perCollision_electron, fDielectronCut); + } + runQC(collisions, electrons, perCollision_electron, fDielectronCut); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + auto muons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, muons, perCollision_muon, fDimuonCut); + } + runQC(collisions, muons, perCollision_muon, fDimuonCut); + } + + map_weight.clear(); + } + PROCESS_SWITCH(SingleTrackQC, processQC, "run single track QC", true); + + using FilteredMyCollisionsWithSWT = soa::Filtered; + void processQC_TriggeredData(FilteredMyCollisionsWithSWT const& collisions, Types const&... args) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + auto electrons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, electrons, perCollision_electron, fDielectronCut); + } + runQC(collisions, electrons, perCollision_electron, fDielectronCut); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + auto muons = std::get<0>(std::tie(args...)); + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, muons, perCollision_muon, fDimuonCut); + } + runQC(collisions, muons, perCollision_muon, fDimuonCut); + } + + map_weight.clear(); + } + PROCESS_SWITCH(SingleTrackQC, processQC_TriggeredData, "run single track QC on triggered data", false); + + void processNorm(aod::EMEventNormInfos const& collisions) + { + for (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); + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 6.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 7.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 8.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 9.0); + } + if (collision.sel8()) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); + } + if (abs(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 (!fEMEventCut.IsSelected(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 processDummy(MyCollisions const&) {} + PROCESS_SWITCH(SingleTrackQC, processDummy, "Dummy function", false); +}; +#endif // PWGEM_DILEPTON_CORE_SINGLETRACKQC_H_ diff --git a/PWGEM/Dilepton/Core/SingleTrackQCMC.h b/PWGEM/Dilepton/Core/SingleTrackQCMC.h new file mode 100644 index 00000000000..0ca97194716 --- /dev/null +++ b/PWGEM/Dilepton/Core/SingleTrackQCMC.h @@ -0,0 +1,1048 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 electrons for QC in MC. +// Please write to: daiki.sekihata@cern.ch + +#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/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.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::dilepton::utils::mcutil; +using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyMCElectrons = soa::Join; +using MyMCElectron = MyMCElectrons::iterator; +using FilteredMyMCElectrons = soa::Filtered; + +using MyMCMuons = soa::Join; +using MyMCMuon = MyMCMuons::iterator; +using FilteredMyMCMuons = soa::Filtered; + +using MySmearedElectrons = soa::Join; +using MySmearedElectron = MySmearedElectrons::iterator; + +using MySmearedMuons = soa::Join; +using MySmearedMuon = MySmearedMuons::iterator; + +template +struct SingleTrackQCMC { + + // Configurables + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + 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 cfgCentMin{"cfgCentMin", 0, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgNtracksPV08Min{"cfgNtracksPV08Min", -1, "min. multNTracksPV"}; + 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"}; + + 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"}; + + 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", 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"}; + } eventcuts; + + DielectronCut fDielectronCut; + struct : ConfigurableGroup { + std::string prefix = "dielectroncut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min pT for single track"}; + Configurable cfg_min_eta_track{"cfg_min_eta_track", -0.8, "max 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_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", 0.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "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 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_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 enableTTCA{"enableTTCA", true, "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_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_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_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"}; + } dimuoncuts; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + + struct : ConfigurableGroup { + std::string prefix = "mctrackcut_group"; + Configurable min_mcPt{"min_mcPt", 0.2, "min. MC pT"}; + Configurable max_mcPt{"max_mcPt", 1e+10, "max. MC pT"}; + Configurable min_mcEta{"min_mcEta", -0.8, "max. MC eta"}; + Configurable max_mcEta{"max_mcEta", +0.8, "max. MC eta"}; + } mctrackcuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; // 1 HistogramRegistry can keep up to 512 histograms + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + static constexpr std::string_view lepton_source_types[9] = {"lf/", "Photon/", "PromptJPsi/", "NonPromptJPsi/", "PromptPsi2S/", "NonPromptPsi2S/", "c2l/", "b2l/", "b2c2l/"}; + + ~SingleTrackQCMC() {} + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms<-1>(&fRegistry); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + 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.)"}; + 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}; + + // generated info + fRegistry.add("Generated/lf/hs", "gen. single electron", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_charge_gen}, true); + fRegistry.addClone("Generated/lf/", "Generated/PromptJPsi/"); + fRegistry.addClone("Generated/lf/", "Generated/NonPromptJPsi/"); + fRegistry.addClone("Generated/lf/", "Generated/PromptPsi2S/"); + fRegistry.addClone("Generated/lf/", "Generated/NonPromptPsi2S/"); + fRegistry.addClone("Generated/lf/", "Generated/c2l/"); + fRegistry.addClone("Generated/lf/", "Generated/b2l/"); + 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); + 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/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); + fRegistry.add("Track/lf/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/lf/positive/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("Track/lf/positive/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("Track/lf/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/lf/positive/hChi2TOF", "TOF Chi2;p_{pv} (GeV/c);chi2", kTH2F, {{1000, 0, 10}, {100, 0, 10}}, false); + fRegistry.add("Track/lf/positive/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("Track/lf/positive/hPtGen_DeltaPtOverPtGen", "electron p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{200, 0, 10}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("Track/lf/positive/hPtGen_DeltaEta", "electron #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{200, 0, 10}, {100, -0.05f, 0.05f}}, true); + fRegistry.add("Track/lf/positive/hPtGen_DeltaPhi", "electron #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{200, 0, 10}, {100, -0.05f, 0.05f}}, true); + } + fRegistry.addClone("Track/lf/positive/", "Track/lf/negative/"); + fRegistry.addClone("Track/lf/", "Track/Photon/"); // this is not for efficiency! only for contamination. We don't store generated photon conversions. + fRegistry.addClone("Track/lf/", "Track/PromptJPsi/"); + fRegistry.addClone("Track/lf/", "Track/NonPromptJPsi/"); + fRegistry.addClone("Track/lf/", "Track/PromptPsi2S/"); + fRegistry.addClone("Track/lf/", "Track/NonPromptPsi2S/"); + fRegistry.addClone("Track/lf/", "Track/c2l/"); + fRegistry.addClone("Track/lf/", "Track/b2l/"); + fRegistry.addClone("Track/lf/", "Track/b2c2l/"); + + 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/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, 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/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/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/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/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.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_phi{36, 0.0, 2 * M_PI, "#varphi_{#mu} (rad.)"}; + const AxisSpec axis_dca{ConfDCABins, "DCA_{#mu}^{XY} (#sigma)"}; + const AxisSpec axis_charge_gen{3, -1.5, +1.5, "true charge"}; + + // generated info + fRegistry.add("Generated/lf/hs", "gen. single muon", kTHnSparseD, {axis_pt, axis_eta, axis_phi, axis_charge_gen}, true); + fRegistry.addClone("Generated/lf/", "Generated/PromptJPsi/"); + fRegistry.addClone("Generated/lf/", "Generated/NonPromptJPsi/"); + fRegistry.addClone("Generated/lf/", "Generated/PromptPsi2S/"); + fRegistry.addClone("Generated/lf/", "Generated/NonPromptPsi2S/"); + fRegistry.addClone("Generated/lf/", "Generated/c2l/"); + fRegistry.addClone("Generated/lf/", "Generated/b2l/"); + fRegistry.addClone("Generated/lf/", "Generated/b2c2l/"); + + // 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 (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/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/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/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/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); + fRegistry.add("Track/lf/positive/hPtGen_DeltaPtOverPtGen", "muon p_{T} resolution;p_{T}^{gen} (GeV/c);(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{200, 0, 10}, {200, -1.0f, 1.0f}}, true); + fRegistry.add("Track/lf/positive/hPtGen_DeltaEta", "muon #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{200, 0, 10}, {100, -0.05f, 0.05f}}, true); + fRegistry.add("Track/lf/positive/hPtGen_DeltaPhi", "muon #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{200, 0, 10}, {100, -0.05f, 0.05f}}, true); + } + fRegistry.addClone("Track/lf/positive/", "Track/lf/negative/"); + fRegistry.addClone("Track/lf/", "Track/Photon/"); // this is not for efficiency! only for contamination. We don't store generated photon conversions. + fRegistry.addClone("Track/lf/", "Track/PromptJPsi/"); + fRegistry.addClone("Track/lf/", "Track/NonPromptJPsi/"); + fRegistry.addClone("Track/lf/", "Track/PromptPsi2S/"); + fRegistry.addClone("Track/lf/", "Track/NonPromptPsi2S/"); + fRegistry.addClone("Track/lf/", "Track/c2l/"); + fRegistry.addClone("Track/lf/", "Track/b2l/"); + fRegistry.addClone("Track/lf/", "Track/b2c2l/"); + } + } + + 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."); + } + + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + DefineEMEventCut(); + addhistograms(); + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pdg_lepton = 11; + DefineDielectronCut(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + pdg_lepton = 13; + DefineDimuonCut(); + } + fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter"); + } + + 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.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); + fEMEventCut.SetRequireNoCollInTimeRangeStrict(eventcuts.cfgRequireNoCollInTimeRangeStrict); + fEMEventCut.SetRequireNoCollInITSROFStandard(eventcuts.cfgRequireNoCollInITSROFStandard); + fEMEventCut.SetRequireNoCollInITSROFStrict(eventcuts.cfgRequireNoCollInITSROFStrict); + } + + o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; + void DefineDielectronCut() + { + fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + 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.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(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.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); + + // 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.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); + + 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 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.; + } + 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 track + fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); + fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); + 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); }); + } + + template + bool isInAcceptance(T const& lepton) + { + float pt = 0.f, eta = 0.f; + if constexpr (isSmeared) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pt = lepton.ptSmeared(); + eta = lepton.etaSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + pt = lepton.ptSmeared_sa_muon(); + eta = lepton.etaSmeared_sa_muon(); + } else if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + pt = lepton.ptSmeared_gl_muon(); + eta = lepton.etaSmeared_gl_muon(); + } else { + pt = lepton.pt(); + eta = lepton.eta(); + } + } + } else { + pt = lepton.pt(); + eta = lepton.eta(); + } + + if ((mctrackcuts.min_mcPt < pt && pt < mctrackcuts.max_mcPt) && (mctrackcuts.min_mcEta < eta && eta < mctrackcuts.max_mcEta)) { + return true; + } else { + return false; + } + } + + template + void fillTrackInfo(TTrack const& track) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + fillElectronInfo(track); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + fillMuonInfo(track); + } + } + + template + 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 weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[track.globalIndex()]; + } + // 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); + 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/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/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()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hChi2TOF"), track.p(), track.tofChi2()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); + + fRegistry.fill(HIST("Track/PID/positive/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST("Track/PID/positive/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/PID/positive/hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + 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/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.tpcInnerParam(), track.tofNSigmaEl()); + fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); + fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); + fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); + fRegistry.fill(HIST("Track/PID/positive/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); + } + } 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); + 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/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/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()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hChi2TOF"), track.p(), track.tofChi2()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hDeltaPin"), track.p(), (track.tpcInnerParam() - track.p()) / track.p()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hITSClusterMap"), track.itsClusterMap()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); + + fRegistry.fill(HIST("Track/PID/negative/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + fRegistry.fill(HIST("Track/PID/negative/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/PID/negative/hMeanClusterSizeITS"), track.p(), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); + 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/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.tpcInnerParam(), track.tofNSigmaEl()); + fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); + fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); + fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); + fRegistry.fill(HIST("Track/PID/negative/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); + } + } + } + + template + void fillMuonInfo(TTrack const& track) + { + auto mctrack = track.template emmcparticle_as(); + float dca_xy = fwdDcaXYinSigma(track); + + float weight = 1.f; + if (cfgApplyWeightTTCA) { + weight = map_weight[track.globalIndex()]; + } + // 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_xy, -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/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/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/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()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("positive/hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); + } + } 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 (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/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/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/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()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); + fRegistry.fill(HIST("Track/") + HIST(lepton_source_types[lepton_source_id]) + HIST("negative/hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); + } + } + } + + template + void runQCMC(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut, TMCCollisions const&, TMCParticles const& mcparticles) + { + for (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; + } + 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) { + auto mctrack = track.template emmcparticle_as(); + if (abs(mctrack.pdgCode()) != pdg_lepton) { + continue; + } + + if (!isInAcceptance(mctrack)) { + 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 constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(track, collision)) { + continue; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(track)) { + continue; + } + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (!cut.template IsSelectedTrack(track)) { + continue; + } + } + + if (!mctrack.has_mothers()) { + continue; + } + auto mcmother = mcparticles.iteratorAt(mctrack.mothersIds()[0]); + int pdg_mother = 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) { + fillTrackInfo<0, TMCParticles>(track); + } else if (pdg_mother == 443) { + if (IsFromBeauty(mcmother, mcparticles) > 0) { // b is found in full decay chain. + fillTrackInfo<3, TMCParticles>(track); + } else { + fillTrackInfo<2, TMCParticles>(track); + } + } else if (pdg_mother == 100443) { + if (IsFromBeauty(mcmother, mcparticles) > 0) { // b is found in full decay chain. + fillTrackInfo<5, TMCParticles>(track); + } else { + fillTrackInfo<4, TMCParticles>(track); + } + } else if (IsFromBeauty(mctrack, mcparticles) > 0) { // b is found in full decay chain. + if (IsFromCharm(mctrack, mcparticles) > 0) { // c is found in full decay chain. + fillTrackInfo<8, TMCParticles>(track); + } else { + fillTrackInfo<7, TMCParticles>(track); + } + } else if (IsFromCharm(mctrack, mcparticles) > 0) { // c is found in full decay chain. Not from b. + fillTrackInfo<6, TMCParticles>(track); + } + } else { + fillTrackInfo<1, TMCParticles>(track); + } + } // end of track loop + + } // end of collision loop + + } // end of process + + template + void runGenInfo(TCollisions const& collisions, TMCLeptons const& leptonsMC, TMCCollisions const& mccollisions, TMCParticles const& mcparticles) + { + for (auto& mccollision : mccollisions) { + if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + auto rec_colls_per_mccoll = collisions.sliceBy(recColperMcCollision, mccollision.globalIndex()); + 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 + } + } + + if (rec_colls_per_mccoll.size() < 1) { + continue; + } + + auto collision = collisions.rawIteratorAt(rec_col_globalIndex); + + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + auto leptonsMC_per_coll = leptonsMC.sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); + for (auto& lepton : leptonsMC_per_coll) { + if (!(lepton.isPhysicalPrimary() || lepton.producedByGenerator())) { + continue; + } + if (!isInAcceptance(lepton)) { + continue; + } + if (!lepton.has_mothers()) { + continue; + } + auto mcmother = mcparticles.iteratorAt(lepton.mothersIds()[0]); + int pdg_mother = abs(mcmother.pdgCode()); + + float pt = 0.f, eta = 0.f, phi = 0.f; + if constexpr (isSmeared) { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + pt = lepton.ptSmeared(); + eta = lepton.etaSmeared(); + phi = lepton.phiSmeared(); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + pt = lepton.ptSmeared_sa_muon(); + eta = lepton.etaSmeared_sa_muon(); + phi = lepton.phiSmeared_sa_muon(); + } else if (dimuoncuts.cfg_track_type == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + pt = lepton.ptSmeared_gl_muon(); + eta = lepton.etaSmeared_gl_muon(); + phi = lepton.phiSmeared_gl_muon(); + } else { + pt = lepton.pt(); + eta = lepton.eta(); + phi = lepton.phi(); + } + } + } else { + pt = lepton.pt(); + eta = lepton.eta(); + phi = lepton.phi(); + } + + if (pdg_mother == 111 || pdg_mother == 221 || pdg_mother == 331 || pdg_mother == 113 || pdg_mother == 223 || pdg_mother == 333) { + fRegistry.fill(HIST("Generated/lf/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } else if (pdg_mother == 443) { + if (IsFromBeauty(mcmother, mcparticles) > 0) { // b is found in full decay chain. + fRegistry.fill(HIST("Generated/NonPromptJPsi/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } else { + fRegistry.fill(HIST("Generated/PromptJPsi/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } + } else if (pdg_mother == 100443) { + if (IsFromBeauty(mcmother, mcparticles) > 0) { // b is found in full decay chain. + fRegistry.fill(HIST("Generated/NonPromptPsi2S/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } else { + fRegistry.fill(HIST("Generated/PromptPsi2S/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } + } else if (IsFromBeauty(lepton, mcparticles) > 0) { // b is found in full decay chain. + if (IsFromCharm(lepton, mcparticles) > 0) { // c is found in full decay chain. + fRegistry.fill(HIST("Generated/b2c2l/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } else { + fRegistry.fill(HIST("Generated/b2l/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } + } else if (IsFromCharm(lepton, mcparticles) > 0) { // c is found in full decay chain. Not from b. + fRegistry.fill(HIST("Generated/c2l/hs"), pt, eta, phi, -lepton.pdgCode() / pdg_lepton); + } + } // end of mc lepton loop per collision + + } // end of mc collision loop + } + + std::unordered_map map_weight; // map of track global index -> weight + template + void fillTrackWeightMap(TCollisions const& collisions, TTracks const& tracks, TPreslice const& perCollision, TCut const& cut, TMCCollisions const&, TMCParticles const&) + { + std::vector passed_trackIds; + passed_trackIds.reserve(tracks.size()); + for (auto& collision : collisions) { + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + // auto mccollision = collision.template emmcevent_as(); + // if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + // 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) { + auto mctrack = track.template emmcparticle_as(); + auto mccollision_from_track = mctrack.template emmcevent_as(); + if (cfgEventGeneratorType >= 0 && mccollision_from_track.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { + if (!cut.template IsSelectedTrack(track, collision)) { + continue; + } + } else { // cut-based + if (!cut.template IsSelectedTrack(track)) { + continue; + } + } + 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) { + 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; + } + passed_trackIds.emplace_back(track.globalIndex()); + } // end of track loop + } + } // end of collision loop + + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + for (auto& trackId : passed_trackIds) { + auto track = tracks.rawIteratorAt(trackId); + auto ambIds = track.ambiguousElectronsIds(); + float n = 1.f; // include myself. + for (auto& ambId : ambIds) { + if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { + n += 1.f; + } + } + map_weight[trackId] = 1.f / n; + } + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + for (auto& trackId : passed_trackIds) { + auto track = tracks.rawIteratorAt(trackId); + auto ambIds = track.ambiguousMuonsIds(); + float n = 1.f; // include myself. + for (auto& ambId : ambIds) { + if (std::find(passed_trackIds.begin(), passed_trackIds.end(), ambId) != passed_trackIds.end()) { + n += 1.f; + } + } + map_weight[trackId] = 1.f / n; + } + } + + passed_trackIds.clear(); + passed_trackIds.shrink_to_fit(); + } + + 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 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_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; + using FilteredMyCollisions = soa::Filtered; + + Partition electronsMC = nabs(o2::aod::mcparticle::pdgCode) == 11; // e+, e- + Partition muonsMC = nabs(o2::aod::mcparticle::pdgCode) == 13; // mu+, mu- + PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; + + PresliceUnsorted recColperMcCollision = aod::emmceventlabel::emmceventId; + + void processQCMC(FilteredMyCollisions const& collisions, aod::EMMCEvents const& mccollisions, aod::EMMCParticles const& mcparticles, TLeptons const& tracks) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, tracks, perCollision_electron, fDielectronCut, mccollisions, mcparticles); + } + runQCMC(collisions, tracks, perCollision_electron, fDielectronCut, mccollisions, mcparticles); + runGenInfo(collisions, electronsMC, mccollisions, mcparticles); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, tracks, perCollision_muon, fDimuonCut, mccollisions, mcparticles); + } + runQCMC(collisions, tracks, perCollision_muon, fDimuonCut, mccollisions, mcparticles); + runGenInfo(collisions, muonsMC, mccollisions, mcparticles); + } + map_weight.clear(); + } + PROCESS_SWITCH(SingleTrackQCMC, processQCMC, "run single track QC MC", true); + + Partition electronsMC_smeared = nabs(o2::aod::mcparticle::pdgCode) == 11; // e+, e- + Partition muonsMC_smeared = nabs(o2::aod::mcparticle::pdgCode) == 13; // mu+, mu- + + void processQCMC_Smeared(FilteredMyCollisions const& collisions, aod::EMMCEvents const& mccollisions, TLeptons const& tracks, TSmearedMCParticles const& mcparticles_smeared) + { + if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) { + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, tracks, perCollision_electron, fDielectronCut, mccollisions, mcparticles_smeared); + } + runQCMC(collisions, tracks, perCollision_electron, fDielectronCut, mccollisions, mcparticles_smeared); + runGenInfo(collisions, electronsMC_smeared, mccollisions, mcparticles_smeared); + } else if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDimuon) { + if (cfgApplyWeightTTCA) { + fillTrackWeightMap(collisions, tracks, perCollision_muon, fDimuonCut, mccollisions, mcparticles_smeared); + } + runQCMC(collisions, tracks, perCollision_muon, fDimuonCut, mccollisions, mcparticles_smeared); + runGenInfo(collisions, muonsMC_smeared, mccollisions, mcparticles_smeared); + } + map_weight.clear(); + } + PROCESS_SWITCH(SingleTrackQCMC, processQCMC_Smeared, "run single track QC MC with smearing", false); + + void processNorm(aod::EMEventNormInfos const& collisions) + { + for (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); + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 6.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 7.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 8.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 9.0); + } + if (collision.sel8()) { + fRegistry.fill(HIST("Event/norm/hCollisionCounter"), 10.0); + } + if (abs(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 (!fEMEventCut.IsSelected(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 processDummy(MyCollisions const&) {} + PROCESS_SWITCH(SingleTrackQCMC, processDummy, "Dummy function", false); +}; + +#endif // PWGEM_DILEPTON_CORE_SINGLETRACKQCMC_H_ diff --git a/PWGEM/Dilepton/DataModel/dileptonTables.h b/PWGEM/Dilepton/DataModel/dileptonTables.h index 50bc41fd82e..7f252fc4f67 100644 --- a/PWGEM/Dilepton/DataModel/dileptonTables.h +++ b/PWGEM/Dilepton/DataModel/dileptonTables.h @@ -9,12 +9,14 @@ // 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/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" -#include "Common/DataModel/CaloClusters.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Qvectors.h" @@ -25,37 +27,87 @@ namespace o2::aod { +namespace pwgem::dilepton::swt +{ +enum class swtAliases : int { // software trigger aliases for EM + kHighTrackMult = 0, + kHighFt0Mult, + kSingleE, + kLMeeIMR, + kLMeeHMR, + kDiElectron, + kSingleMuLow, + kSingleMuHigh, + kDiMuon, + kNaliases +}; + +const std::unordered_map aliasLabels = { + {"fHighTrackMult", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kHighTrackMult)}, + {"fHighFt0Mult", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kHighFt0Mult)}, + {"fSingleE", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kSingleE)}, + {"fLMeeIMR", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kLMeeIMR)}, + {"fLMeeHMR", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kLMeeHMR)}, + {"fDiElectron", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kDiElectron)}, + {"fSingleMuLow", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kSingleMuLow)}, + {"fSingleMuHigh", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kSingleMuHigh)}, + {"fDiMuon", static_cast(o2::aod::pwgem::dilepton::swt::swtAliases::kDiMuon)}, +}; +} // namespace pwgem::dilepton::swt + namespace emevent { DECLARE_SOA_COLUMN(CollisionId, collisionId, int); +DECLARE_SOA_BITMAP_COLUMN(SWTAliasTmp, swtaliastmp, 16); //! Bitmask of fired trigger aliases (see above for definitions) to be join to aod::Collisions for skimming +DECLARE_SOA_BITMAP_COLUMN(SWTAlias, swtalias, 16); //! Bitmask of fired trigger aliases (see above for definitions) to be join to aod::EMEvents for analysis +DECLARE_SOA_COLUMN(NInspectedTVX, nInspectedTVX, uint64_t); DECLARE_SOA_COLUMN(NeeULS, neeuls, int); DECLARE_SOA_COLUMN(NeeLSpp, neelspp, int); DECLARE_SOA_COLUMN(NeeLSmm, neelsmm, int); -DECLARE_SOA_COLUMN(Bz, bz, float); //! kG -DECLARE_SOA_COLUMN(Q2xFT0M, q2xft0m, float); //! Qx for 2nd harmonics in FT0M (i.e. positive eta) -DECLARE_SOA_COLUMN(Q2yFT0M, q2yft0m, float); //! Qy for 2nd harmonics in FT0M (i.e. positive eta) -DECLARE_SOA_COLUMN(Q2xFT0A, q2xft0a, float); //! Qx for 2nd harmonics in FT0A (i.e. positive eta) -DECLARE_SOA_COLUMN(Q2yFT0A, q2yft0a, float); //! Qy for 2nd harmonics in FT0A (i.e. positive eta) -DECLARE_SOA_COLUMN(Q2xFT0C, q2xft0c, float); //! Qx for 2nd harmonics in FT0C (i.e. negative eta) -DECLARE_SOA_COLUMN(Q2yFT0C, q2yft0c, float); //! Qy for 2nd harmonics in FT0C (i.e. negative eta) -DECLARE_SOA_COLUMN(Q2xBPos, q2xbpos, float); //! Qx for 2nd harmonics in Barrel positive eta region -DECLARE_SOA_COLUMN(Q2yBPos, q2ybpos, float); //! Qy for 2nd harmonics in Barrel positive eta region -DECLARE_SOA_COLUMN(Q2xBNeg, q2xbneg, float); //! Qx for 2nd harmonics in Barrel negative eta region -DECLARE_SOA_COLUMN(Q2yBNeg, q2ybneg, float); //! Qy for 2nd harmonics in Barrel negative eta region -DECLARE_SOA_COLUMN(Q2xBTot, q2xbtot, float); //! Qx for 2nd harmonics in Barrel full eta region -DECLARE_SOA_COLUMN(Q2yBTot, q2ybtot, float); //! Qy for 2nd harmonics in Barrel full eta region -DECLARE_SOA_COLUMN(Q3xFT0M, q3xft0m, float); //! Qx for 3rd harmonics in FT0M (i.e. positive eta) -DECLARE_SOA_COLUMN(Q3yFT0M, q3yft0m, float); //! Qy for 3rd harmonics in FT0M (i.e. positive eta) -DECLARE_SOA_COLUMN(Q3xFT0A, q3xft0a, float); //! Qx for 3rd harmonics in FT0A (i.e. positive eta) -DECLARE_SOA_COLUMN(Q3yFT0A, q3yft0a, float); //! Qy for 3rd harmonics in FT0A (i.e. positive eta) -DECLARE_SOA_COLUMN(Q3xFT0C, q3xft0c, float); //! Qx for 3rd harmonics in FT0C (i.e. negative eta) -DECLARE_SOA_COLUMN(Q3yFT0C, q3yft0c, float); //! Qy for 3rd harmonics in FT0C (i.e. negative eta) -DECLARE_SOA_COLUMN(Q3xBPos, q3xbpos, float); //! Qx for 3rd harmonics in Barrel positive eta region -DECLARE_SOA_COLUMN(Q3yBPos, q3ybpos, float); //! Qy for 3rd harmonics in Barrel positive eta region -DECLARE_SOA_COLUMN(Q3xBNeg, q3xbneg, float); //! Qx for 3rd harmonics in Barrel negative eta region -DECLARE_SOA_COLUMN(Q3yBNeg, q3ybneg, float); //! Qy for 3rd harmonics in Barrel negative eta region -DECLARE_SOA_COLUMN(Q3xBTot, q3xbtot, float); //! Qx for 3rd harmonics in Barrel full eta region -DECLARE_SOA_COLUMN(Q3yBTot, q3ybtot, float); //! Qy for 3rd harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Bz, bz, float); //! kG +DECLARE_SOA_COLUMN(Q2xFT0M, q2xft0m, float); //! Qx for 2nd harmonics in FT0M +DECLARE_SOA_COLUMN(Q2yFT0M, q2yft0m, float); //! Qy for 2nd harmonics in FT0M +DECLARE_SOA_COLUMN(Q2xFT0A, q2xft0a, float); //! Qx for 2nd harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q2yFT0A, q2yft0a, float); //! Qy for 2nd harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q2xFT0C, q2xft0c, float); //! Qx for 2nd harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q2yFT0C, q2yft0c, float); //! Qy for 2nd harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q2xBPos, q2xbpos, float); //! Qx for 2nd harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q2yBPos, q2ybpos, float); //! Qy for 2nd harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q2xBNeg, q2xbneg, float); //! Qx for 2nd harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q2yBNeg, q2ybneg, float); //! Qy for 2nd harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q2xBTot, q2xbtot, float); //! Qx for 2nd harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Q2yBTot, q2ybtot, float); //! Qy for 2nd harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Q3xFT0M, q3xft0m, float); //! Qx for 3rd harmonics in FT0M +DECLARE_SOA_COLUMN(Q3yFT0M, q3yft0m, float); //! Qy for 3rd harmonics in FT0M +DECLARE_SOA_COLUMN(Q3xFT0A, q3xft0a, float); //! Qx for 3rd harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q3yFT0A, q3yft0a, float); //! Qy for 3rd harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q3xFT0C, q3xft0c, float); //! Qx for 3rd harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q3yFT0C, q3yft0c, float); //! Qy for 3rd harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q3xBPos, q3xbpos, float); //! Qx for 3rd harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q3yBPos, q3ybpos, float); //! Qy for 3rd harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q3xBNeg, q3xbneg, float); //! Qx for 3rd harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q3yBNeg, q3ybneg, float); //! Qy for 3rd harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q3xBTot, q3xbtot, float); //! Qx for 3rd harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Q3yBTot, q3ybtot, float); //! Qy for 3rd harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Q4xFT0M, q4xft0m, float); //! Qx for 4th harmonics in FT0M +DECLARE_SOA_COLUMN(Q4yFT0M, q4yft0m, float); //! Qy for 4th harmonics in FT0M +DECLARE_SOA_COLUMN(Q4xFT0A, q4xft0a, float); //! Qx for 4th harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q4yFT0A, q4yft0a, float); //! Qy for 4th harmonics in FT0A (i.e. positive eta) +DECLARE_SOA_COLUMN(Q4xFT0C, q4xft0c, float); //! Qx for 4th harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q4yFT0C, q4yft0c, float); //! Qy for 4th harmonics in FT0C (i.e. negative eta) +DECLARE_SOA_COLUMN(Q4xBPos, q4xbpos, float); //! Qx for 4th harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q4yBPos, q4ybpos, float); //! Qy for 4th harmonics in Barrel positive eta region +DECLARE_SOA_COLUMN(Q4xBNeg, q4xbneg, float); //! Qx for 4th harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q4yBNeg, q4ybneg, float); //! Qy for 4th harmonics in Barrel negative eta region +DECLARE_SOA_COLUMN(Q4xBTot, q4xbtot, float); //! Qx for 4th harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(Q4yBTot, q4ybtot, float); //! Qy for 4th harmonics in Barrel full eta region +DECLARE_SOA_COLUMN(SpherocityPtWeighted, spherocity_ptweighted, float); //! transverse spherocity +DECLARE_SOA_COLUMN(SpherocityPtUnWeighted, spherocity_ptunweighted, float); //! transverse spherocity +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(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; }); DECLARE_SOA_DYNAMIC_COLUMN(Sel8, sel8, [](uint64_t selection_bit) -> bool { return (selection_bit & BIT(o2::aod::evsel::kIsTriggerTVX)) && (selection_bit & BIT(o2::aod::evsel::kNoTimeFrameBorder)) && (selection_bit & BIT(o2::aod::evsel::kNoITSROFrameBorder)); }); DECLARE_SOA_DYNAMIC_COLUMN(EP2FT0M, ep2ft0m, [](float q2x, float q2y) -> float { return std::atan2(q2y, q2x) / 2.0; }); @@ -70,29 +122,41 @@ DECLARE_SOA_DYNAMIC_COLUMN(EP3FT0C, ep3ft0c, [](float q3x, float q3y) -> float { DECLARE_SOA_DYNAMIC_COLUMN(EP3BPos, ep3bpos, [](float q3x, float q3y) -> float { return std::atan2(q3y, q3x) / 3.0; }); DECLARE_SOA_DYNAMIC_COLUMN(EP3BNeg, ep3bneg, [](float q3x, float q3y) -> float { return std::atan2(q3y, q3x) / 3.0; }); DECLARE_SOA_DYNAMIC_COLUMN(EP3BTot, ep3btot, [](float q3x, float q3y) -> float { return std::atan2(q3y, q3x) / 3.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4FT0M, ep4ft0m, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4FT0A, ep4ft0a, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4FT0C, ep4ft0c, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4BPos, ep4bpos, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4BNeg, ep4bneg, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); +DECLARE_SOA_DYNAMIC_COLUMN(EP4BTot, ep4btot, [](float q4x, float q4y) -> float { return std::atan2(q4y, q4x) / 4.0; }); } // namespace emevent -DECLARE_SOA_TABLE(EMEvents, "AOD", "EMEVENT", //! Main event information table +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; using EMEvent = EMEvents::iterator; DECLARE_SOA_TABLE(EMEventsCov, "AOD", "EMEVENTCOV", //! joinable to EMEvents - collision::CovXX, collision::CovXY, collision::CovXZ, collision::CovYY, collision::CovYZ, collision::CovZZ, collision::Chi2); + collision::CovXX, collision::CovXY, collision::CovXZ, collision::CovYY, collision::CovYZ, collision::CovZZ, collision::Chi2, o2::soa::Marker<1>); using EMEventCov = EMEventsCov::iterator; DECLARE_SOA_TABLE(EMEventsBz, "AOD", "EMEVENTBZ", emevent::Bz); // joinable to EMEvents using EMEventBz = EMEventsBz::iterator; DECLARE_SOA_TABLE(EMEventsMult, "AOD", "EMEVENTMULT", //! event multiplicity table, joinable to EMEvents - mult::MultFT0A, mult::MultFT0C, - mult::MultTPC, mult::MultNTracksPV, mult::MultNTracksPVeta1, mult::MultNTracksPVetaHalf, + mult::MultFT0A, mult::MultFT0C, mult::MultNTracksPV, mult::MultNTracksPVeta1, mult::MultNTracksPVetaHalf, mult::IsInelGt0, mult::IsInelGt1, mult::MultFT0M); using EMEventMult = EMEventsMult::iterator; DECLARE_SOA_TABLE(EMEventsCent, "AOD", "EMEVENTCENT", //! event centrality table, joinable to EMEvents - cent::CentFT0M, cent::CentFT0A, cent::CentFT0C, cent::CentNTPV); + cent::CentFT0M, cent::CentFT0A, cent::CentFT0C); using EMEventCent = EMEventsCent::iterator; DECLARE_SOA_TABLE(EMEventsQvec, "AOD", "EMEVENTQVEC", //! event q vector table, joinable to EMEvents @@ -100,6 +164,8 @@ DECLARE_SOA_TABLE(EMEventsQvec, "AOD", "EMEVENTQVEC", //! event q vector table emevent::Q2xBPos, emevent::Q2yBPos, emevent::Q2xBNeg, emevent::Q2yBNeg, emevent::Q2xBTot, emevent::Q2yBTot, emevent::Q3xFT0M, emevent::Q3yFT0M, emevent::Q3xFT0A, emevent::Q3yFT0A, emevent::Q3xFT0C, emevent::Q3yFT0C, emevent::Q3xBPos, emevent::Q3yBPos, emevent::Q3xBNeg, emevent::Q3yBNeg, emevent::Q3xBTot, emevent::Q3yBTot, + // emevent::Q4xFT0M, emevent::Q4yFT0M, emevent::Q4xFT0A, emevent::Q4yFT0A, emevent::Q4xFT0C, emevent::Q4yFT0C, + // emevent::Q4xBPos, emevent::Q4yBPos, emevent::Q4xBNeg, emevent::Q4yBNeg, emevent::Q4xBTot, emevent::Q4yBTot, // Dynamic columns emevent::EP2FT0M, @@ -114,11 +180,41 @@ DECLARE_SOA_TABLE(EMEventsQvec, "AOD", "EMEVENTQVEC", //! event q vector table emevent::EP3BPos, emevent::EP3BNeg, emevent::EP3BTot); +// emevent::EP4FT0M, +// emevent::EP4FT0A, +// emevent::EP4FT0C, +// emevent::EP4BPos, +// emevent::EP4BNeg, +// emevent::EP4BTot using EMEventQvec = EMEventsQvec::iterator; -DECLARE_SOA_TABLE(EMEventsNee, "AOD", "EMEVENTNEE", emevent::NeeULS, emevent::NeeLSpp, emevent::NeeLSmm); // joinable to EMEvents +DECLARE_SOA_TABLE(EMSWTriggerInfos, "AOD", "EMSWTRIGGERINFO", //! joinable to EMEvents + emevent::SWTAlias, emevent::NInspectedTVX); +using EMSWTriggerInfo = EMSWTriggerInfos::iterator; + +DECLARE_SOA_TABLE(EMSWTriggerInfosTMP, "AOD", "EMSWTTMP", //! joinable to aod::Collisions + emevent::SWTAliasTmp, emevent::NInspectedTVX); +using EMSWTriggerInfoTMP = EMSWTriggerInfosTMP::iterator; + +DECLARE_SOA_TABLE(EMEventsProperty, "AOD", "EMEVENTPROP", //! joinable to EMEvents + emevent::SpherocityPtWeighted, emevent::SpherocityPtUnWeighted, emevent::NtrackSpherocity); +using EMEventProperty = EMEventsProperty::iterator; + +DECLARE_SOA_TABLE(EMEventsNee, "AOD", "EMEVENTNEE", emevent::NeeULS, emevent::NeeLSpp, emevent::NeeLSmm); // joinable to EMEvents or aod::Collisions using EMEventNee = EMEventsNee::iterator; +DECLARE_SOA_TABLE(EMEvSels, "AOD", "EMEVSEL", //! joinable to aod::Collisions + emevent::IsSelected); +using EMEvSel = EMEvSels::iterator; + +DECLARE_SOA_TABLE(EMEoIs, "AOD", "EMEOI", //! joinable to aod::Collisions in createEMEventDilepton.cxx + emevent::IsEoI); +using EMEoI = EMEoIs::iterator; + +DECLARE_SOA_TABLE(EMEventNormInfos, "AOD", "EMEVENTNORMINFO", //! event information for normalization + o2::soa::Index<>, evsel::Alias, evsel::Selection, emevent::PosZint16, emevent::PosZ, emevent::Sel8); +using EMEventNormInfo = EMEventNormInfos::iterator; + namespace emmcevent { DECLARE_SOA_COLUMN(McCollisionId, mcCollisionId, int); @@ -127,7 +223,7 @@ DECLARE_SOA_COLUMN(McCollisionId, mcCollisionId, int); DECLARE_SOA_TABLE(EMMCEvents, "AOD", "EMMCEVENT", //! MC event information table o2::soa::Index<>, emmcevent::McCollisionId, mccollision::GeneratorsID, mccollision::PosX, mccollision::PosY, mccollision::PosZ, - mccollision::T, mccollision::ImpactParameter, + mccollision::ImpactParameter, mccollision::EventPlaneAngle, // dynamic column mccollision::GetGeneratorId, @@ -165,7 +261,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(Y, y, //! Particle rapidity }); } // namespace emmcparticle -// This table contains all MC truth tracks (both v0 and calos) +// This table contains all MC truth tracks DECLARE_SOA_TABLE_FULL(EMMCParticles, "EMMCParticles", "AOD", "EMMCPARTICLE", //! MC track information (on disk) o2::soa::Index<>, emmcparticle::EMMCEventId, mcparticle::PdgCode, mcparticle::Flags, @@ -186,6 +282,60 @@ DECLARE_SOA_TABLE_FULL(EMMCParticles, "EMMCParticles", "AOD", "EMMCPARTICLE", // using EMMCParticle = EMMCParticles::iterator; +namespace emmcgenvectormeson +{ +DECLARE_SOA_INDEX_COLUMN(EMMCEvent, emmcevent); +DECLARE_SOA_COLUMN(DownScalingFactor, dsf, float); //! down scaling factor to store this mc particle in reduced AO2D.root +} // namespace emmcgenvectormeson + +DECLARE_SOA_TABLE_FULL(EMMCGenVectorMesons, "EMMCGenVectorMesons", "AOD", "EMMCGENVM", //! generated omega, phi information + o2::soa::Index<>, emmcgenvectormeson::EMMCEventId, + mcparticle::PdgCode, mcparticle::Flags, + mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, + emmcgenvectormeson::DownScalingFactor, + + // dynamic column + emmcparticle::Pt, + emmcparticle::Eta, + emmcparticle::Phi, + + emmcparticle::P, + emmcparticle::Y, + mcparticle::ProducedByGenerator, + mcparticle::FromBackgroundEvent, + mcparticle::IsPhysicalPrimary); + +using EMMCGenVectorMeson = EMMCGenVectorMesons::iterator; + +namespace smearedtrack +{ +DECLARE_SOA_COLUMN(PtSmeared, ptSmeared, float); +DECLARE_SOA_COLUMN(EtaSmeared, etaSmeared, float); +DECLARE_SOA_COLUMN(PhiSmeared, phiSmeared, float); +DECLARE_SOA_COLUMN(Efficiency, efficiency, float); +DECLARE_SOA_COLUMN(DCA, dca, float); + +DECLARE_SOA_COLUMN(PtSmearedSAMuon, ptSmeared_sa_muon, float); +DECLARE_SOA_COLUMN(EtaSmearedSAMuon, etaSmeared_sa_muon, float); +DECLARE_SOA_COLUMN(PhiSmearedSAMuon, phiSmeared_sa_muon, float); +DECLARE_SOA_COLUMN(EfficiencySAMuon, efficiency_sa_muon, float); +DECLARE_SOA_COLUMN(DCASAMuon, dca_sa_muon, float); +DECLARE_SOA_COLUMN(PtSmearedGLMuon, ptSmeared_gl_muon, float); +DECLARE_SOA_COLUMN(EtaSmearedGLMuon, etaSmeared_gl_muon, float); +DECLARE_SOA_COLUMN(PhiSmearedGLMuon, phiSmeared_gl_muon, float); +DECLARE_SOA_COLUMN(EfficiencyGLMuon, efficiency_gl_muon, float); +DECLARE_SOA_COLUMN(DCAGLMuon, dca_gl_muon, float); +} // namespace smearedtrack + +DECLARE_SOA_TABLE(SmearedElectrons, "AOD", "SMEAREDEL", // usage Join + smearedtrack::PtSmeared, smearedtrack::EtaSmeared, smearedtrack::PhiSmeared, smearedtrack::Efficiency, smearedtrack::DCA); +using SmearedElectron = SmearedElectrons::iterator; + +DECLARE_SOA_TABLE(SmearedMuons, "AOD", "SMEAREDMU", // usage Join + smearedtrack::PtSmearedSAMuon, smearedtrack::EtaSmearedSAMuon, smearedtrack::PhiSmearedSAMuon, smearedtrack::EfficiencySAMuon, smearedtrack::DCASAMuon, + smearedtrack::PtSmearedGLMuon, smearedtrack::EtaSmearedGLMuon, smearedtrack::PhiSmearedGLMuon, smearedtrack::EfficiencyGLMuon, smearedtrack::DCAGLMuon); +using SmearedMuon = SmearedMuons::iterator; + namespace emprimaryelectronmclabel { DECLARE_SOA_INDEX_COLUMN(EMMCParticle, emmcparticle); //! @@ -217,11 +367,13 @@ DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(AmbiguousElectrons, ambiguousElectrons); DECLARE_SOA_COLUMN(IsAssociatedToMPC, isAssociatedToMPC, bool); //! is associated to most probable collision DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! DECLARE_SOA_COLUMN(PrefilterBit, pfb, uint8_t); //! +DECLARE_SOA_COLUMN(PrefilterBitPi0, pfbpi0, uint16_t); //! 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(MeanClusterSizeITS, meanClusterSizeITS, [](uint32_t itsClusterSizes) -> float { int total_cluster_size = 0, nl = 0; for (unsigned int layer = 0; layer < 7; layer++) { @@ -268,11 +420,11 @@ DECLARE_SOA_DYNAMIC_COLUMN(MeanClusterSizeITSob, meanClusterSizeITSob, [](uint32 } }); } // namespace emprimaryelectron -DECLARE_SOA_TABLE(EMPrimaryElectrons, "AOD", "EMPRIMARYEL", //! +DECLARE_SOA_TABLE(EMPrimaryElectrons_000, "AOD", "EMPRIMARYEL", //! 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::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, @@ -284,17 +436,49 @@ DECLARE_SOA_TABLE(EMPrimaryElectrons, "AOD", "EMPRIMARYEL", //! 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, + 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_001, "AOD", "EMPRIMARYEL", 1, //! + 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, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, + track::X, track::Alpha, track::Y, track::Z, track::Snp, track::Tgl, emprimaryelectron::IsAssociatedToMPC, + + // 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); + +using EMPrimaryElectrons = EMPrimaryElectrons_001; // iterators using EMPrimaryElectron = EMPrimaryElectrons::iterator; @@ -313,7 +497,7 @@ DECLARE_SOA_TABLE(EMPrimaryElectronsCov, "AOD", "EMPRIMARYELCOV", //! aod::track::C1PtZ, aod::track::C1PtSnp, aod::track::C1PtTgl, - aod::track::C1Pt21Pt2); + aod::track::C1Pt21Pt2, o2::soa::Marker<1>); // iterators using EMPrimaryElectronCov = EMPrimaryElectronsCov::iterator; @@ -329,6 +513,10 @@ DECLARE_SOA_TABLE(EMAmbiguousElectronSelfIds, "AOD", "EMAMBELSELFID", emprimarye // iterators using EMAmbiguousElectronSelfId = EMAmbiguousElectronSelfIds::iterator; +DECLARE_SOA_TABLE(EMPrimaryElectronsPrefilterBitPi0, "AOD", "PRMELPFBPI0", emprimaryelectron::PrefilterBitPi0); // To be joined with EMPrimaryElectrons table at analysis level. +// iterators +using EMPrimaryElectronPrefilterBitPi0 = EMPrimaryElectronsPrefilterBitPi0::iterator; + namespace emprimarymuon { DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! @@ -344,6 +532,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * 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 { @@ -388,6 +577,7 @@ DECLARE_SOA_TABLE(EMPrimaryMuons, "AOD", "EMPRIMARYMU", //! emprimarymuon::Px, emprimarymuon::Py, emprimarymuon::Pz, + emprimarymuon::Theta, emprimarymuon::DcaXY); // iterators using EMPrimaryMuon = EMPrimaryMuons::iterator; diff --git a/PWGEM/Dilepton/DataModel/lmeeMLTables.h b/PWGEM/Dilepton/DataModel/lmeeMLTables.h index a42eba65846..1c925cf9bc7 100644 --- a/PWGEM/Dilepton/DataModel/lmeeMLTables.h +++ b/PWGEM/Dilepton/DataModel/lmeeMLTables.h @@ -76,7 +76,7 @@ DECLARE_SOA_TABLE(EMPrimaryTracks, "AOD", "EMPTRACK", //! 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::DetectorMap, emprimarytrack::PIDLabel, emprimarytrack::TrackType, + track::ITSClusterSizes, track::ITSChi2NCl, track::TOFChi2, track::DetectorMap, emprimarytrack::PIDLabel, emprimarytrack::TrackType, // dynamic column emprimarytrack::P, diff --git a/PWGEM/Dilepton/TableProducer/CMakeLists.txt b/PWGEM/Dilepton/TableProducer/CMakeLists.txt index 61185142633..c95928b3eb1 100644 --- a/PWGEM/Dilepton/TableProducer/CMakeLists.txt +++ b/PWGEM/Dilepton/TableProducer/CMakeLists.txt @@ -20,16 +20,6 @@ o2physics_add_dpl_workflow(tree-creator-electron-ml-dda PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dielectron-ml - SOURCES dielectronMl.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore - COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(tree-creator-single-electron-qa - SOURCES treeCreatorSingleElectronQA.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(skimmer-primary-electron SOURCES skimmerPrimaryElectron.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore @@ -40,13 +30,38 @@ 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 + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(create-emevent-dilepton SOURCES createEMEventDilepton.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(skimmer-ots + SOURCES skimmerOTS.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(associate-mc-info-dilepton SOURCES associateMCinfoDilepton.cxx 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 + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(filter-eoi + SOURCES filterEoI.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx index 36879452f92..6cf6b0865d0 100644 --- a/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/associateMCinfoDilepton.cxx @@ -14,11 +14,13 @@ // 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" @@ -27,7 +29,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::soa; -using MyCollisionsMC = soa::Join; +using MyCollisionsMC = soa::Join; using TracksMC = soa::Join; using FwdTracksMC = soa::Join; @@ -41,34 +43,94 @@ struct AssociateMCInfoDilepton { Produces mcevents; Produces mceventlabels; Produces emmcparticles; + Produces emmcgenvms; Produces v0legmclabels; Produces emprimaryelectronmclabels; Produces emprimarymuonmclabels; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; - Configurable max_rxy_gen{"max_rxy_gen", 100, "max rxy to store generated information"}; - 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 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 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"}; HistogramRegistry registry{"EMMCEvent"}; + std::mt19937 engine; + std::uniform_real_distribution dist01; 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"); + + std::random_device seed_gen; + engine = std::mt19937(seed_gen()); + dist01 = std::uniform_real_distribution(0.0f, 1.0f); + } + + template + bool isDecayDielectronInAcceptance(TMCParticle const& mctrack, TMCParticles const& mcTracks) + { + if (!mctrack.has_daughters()) { + return false; + } + + bool is_lepton = false, is_anti_lepton = false; + for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { + auto daughter = mcTracks.iteratorAt(d); + if (daughter.pdgCode() == 11 && (min_eta_gen_primary < daughter.eta() && daughter.eta() < max_eta_gen_primary)) { + is_lepton = true; + } + if (daughter.pdgCode() == -11 && (min_eta_gen_primary < daughter.eta() && daughter.eta() < max_eta_gen_primary)) { + is_anti_lepton = true; + } + } + if (is_lepton && is_anti_lepton) { + return true; + } else { + return false; + } + } + + template + bool isDecayDimuonInAcceptance(TMCParticle const& mctrack, TMCParticles const& mcTracks) + { + if (!mctrack.has_daughters()) { + return false; + } + + bool is_lepton = false, is_anti_lepton = false; + for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) { + auto daughter = mcTracks.iteratorAt(d); + if (daughter.pdgCode() == 13 && (min_eta_gen_primary_fwd < daughter.eta() && daughter.eta() < max_eta_gen_primary_fwd)) { + is_lepton = true; + } + if (daughter.pdgCode() == -13 && (min_eta_gen_primary_fwd < daughter.eta() && daughter.eta() < max_eta_gen_primary_fwd)) { + is_anti_lepton = true; + } + } + if (is_lepton && is_anti_lepton) { + return true; + } else { + return false; + } } + SliceCache cache; Preslice perMcCollision = aod::mcparticle::mcCollisionId; Preslice perCollision_pcm = aod::v0photonkf::collisionId; Preslice perCollision_el = aod::emprimaryelectron::collisionId; Preslice perCollision_mu = aod::emprimarymuon::collisionId; + // apply rapidity cut for electrons + Partition mcelectrons = nabs(o2::aod::mcparticle::pdgCode) == 11 && min_eta_gen_primary < o2::aod::mcparticle::eta && o2::aod::mcparticle::eta < max_eta_gen_primary; + 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&, aod::McParticles const& mcTracks, TTracks const& o2tracks, TFwdTracks const& o2fwdtracks, TPCMs const& v0photons, TPCMLegs const& /*v0legs*/, TEMPrimaryElectrons const& emprimaryelectrons, TEMPrimaryMuons const& emprimarymuons) + 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) { // temporary variables used for the indexing of the skimmed MC stack std::map fNewLabels; @@ -78,6 +140,16 @@ struct AssociateMCInfoDilepton { std::map fEventLabels; 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) { + // 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()); + fEventLabels[mcCollision.globalIndex()] = fCounters[1]; + fCounters[1]++; + } + } // end of mc collision loop + for (auto& collision : collisions) { registry.fill(HIST("hEventCounter"), 1); @@ -86,165 +158,192 @@ struct AssociateMCInfoDilepton { 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; } registry.fill(HIST("hEventCounter"), 2); - auto mcCollision = collision.mcCollision(); - // store mc particles - auto groupedMcTracks = mcTracks.sliceBy(perMcCollision, mcCollision.globalIndex()); + mceventlabels(fEventLabels.find(mcCollision.globalIndex())->second, collision.mcMask()); - // 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.t(), mcCollision.impactParameter()); - fEventLabels[mcCollision.globalIndex()] = fCounters[1]; - fCounters[1]++; - } + } // end of reconstructed collision loop - mceventlabels(fEventLabels.find(mcCollision.globalIndex())->second, collision.mcMask()); + for (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 : 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) { - continue; - } - int pdg = mctrack.pdgCode(); - if (abs(pdg) > 1e+9) { + for (auto& mctrack : mcelectrons_per_mccollision) { // store necessary information for denominator of efficiency + if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { continue; } + // auto mcCollision = mcCollisions.iteratorAt(mctrack.mcCollisionId()); - // Note that pi0 from weak decay gives producedByGenerator() = false - if ( - abs(pdg) != 11 // electron - && (abs(pdg) != 13) // muon - && (abs(pdg) != 223) // omega - && (abs(pdg) != 333) // phi - ) { - continue; + // only for temporary protection, as of 15.July.2024 (by Daiki Sekihata) + int motherid_tmp = -999; // first mother index tmp + if (mctrack.has_mothers()) { + motherid_tmp = mctrack.mothersIds()[0]; // first mother index } - // LOGF(info,"index = %d , mc track pdg = %d , producedByGenerator = %d , isPhysicalPrimary = %d", mctrack.index(), mctrack.pdgCode(), mctrack.producedByGenerator(), mctrack.isPhysicalPrimary()); + auto mp_tmp = mcTracks.iteratorAt(motherid_tmp); + int ndau_tmp = mp_tmp.daughtersIds()[1] - mp_tmp.daughtersIds()[0] + 1; + if (ndau_tmp < 10) { - if (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator()) { // primary leptons + 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.globalIndex())->second; + fCounters[0]++; + } - if ((abs(mctrack.eta()) < max_eta_gen_primary) || (min_eta_gen_primary_fwd < mctrack.eta() && mctrack.eta() < max_eta_gen_primary_fwd)) { // primary leptons + 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 (abs(pdg) == 11 || abs(pdg) == 13) { - 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.globalIndex())->second; + // 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.globalIndex())->second; fCounters[0]++; } - int motherid = -999; // first mother index - if (mctrack.has_mothers()) { - motherid = mctrack.mothersIds()[0]; // first mother index + if (mp.has_mothers()) { + motherid = mp.mothersIds()[0]; // first mother index + } else { + motherid = -999; } - while (motherid > -1) { - if (motherid < mcTracks.size()) { // protect against bad mother indices. why is this needed? - auto mp = mcTracks.iteratorAt(motherid); + } else { + motherid = -999; + } + } // end of mother chain loop + } // end of ndau protection + } // end of mc electron loop - // 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.globalIndex())->second; - fCounters[0]++; - } + for (auto& mctrack : mcmuons_per_mccollision) { // store necessary information for denominator of efficiency + if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { + continue; + } + // auto mcCollision = mcCollisions.iteratorAt(mctrack.mcCollisionId()); - if (mp.has_mothers()) { - motherid = mp.mothersIds()[0]; // first mother index - } else { - motherid = -999; - } - } else { - motherid = -999; - } - } // end of mother chain loop - } else if (pdg == 223 || pdg == 333) { // for denominator of efficiency - 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.globalIndex())->second; + // only for temporary protection, as of 15.July.2024 (by Daiki Sekihata) + int motherid_tmp = -999; // first mother index tmp + if (mctrack.has_mothers()) { + motherid_tmp = mctrack.mothersIds()[0]; // first mother index + } + auto mp_tmp = mcTracks.iteratorAt(motherid_tmp); + int ndau_tmp = mp_tmp.daughtersIds()[1] - mp_tmp.daughtersIds()[0] + 1; + if (ndau_tmp < 10) { + + 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.globalIndex())->second; + fCounters[0]++; + } + + 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.globalIndex())->second; fCounters[0]++; } - // store daughter of vector mesons - if (mctrack.has_daughters()) { - bool is_lepton_involved = false; - 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 daughter = mcTracks.iteratorAt(d); - if (abs(daughter.pdgCode()) == 11 || abs(daughter.pdgCode()) == 13) { - is_lepton_involved = true; - break; - } - } else { - std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; - } - } - - if (is_lepton_involved) { - 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 daughter = mcTracks.iteratorAt(d); - - // 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(daughter.globalIndex()) != fNewLabels.end())) { - fNewLabels[daughter.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = daughter.globalIndex(); - // fMCFlags[daughter.globalIndex()] = mcflags; - fEventIdx[daughter.globalIndex()] = fEventLabels.find(mcCollision.globalIndex())->second; - fCounters[0]++; - } - } else { - std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; - std::cout << " Check the MC generator" << std::endl; - } - } // end of daughter loop - } + if (mp.has_mothers()) { + motherid = mp.mothersIds()[0]; // first mother index + } else { + motherid = -999; } - } // end of primary omega, phi - } + } else { + motherid = -999; + } + } // end of mother chain loop + } // end of ndau protection + } // end of mc muon loop + + for (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. - } else if (abs(pdg) == 11 && mctrack.has_mothers()) { // secondary electrons. i.e. ele/pos from photon conversions. - int motherid = mctrack.mothersIds()[0]; // first mother index - auto mp = mcTracks.iteratorAt(motherid); + if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { + continue; + } - 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) { - continue; + if (!isDecayDielectronInAcceptance(mctrack, mcTracks) && !isDecayDimuonInAcceptance(mctrack, mcTracks)) { // acceptance cut to decay dileptons + continue; + } + + // auto mcCollision = mcCollisions.iteratorAt(mctrack.mcCollisionId()); + + int ndau = mctrack.daughtersIds()[1] - mctrack.daughtersIds()[0] + 1; + if (ndau < 10) { + + 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.globalIndex())->second; + fCounters[0]++; } - if (mp.pdgCode() == 22 && (mp.isPhysicalPrimary() || mp.producedByGenerator()) && abs(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; - fCounters[0]++; + // store daughter of vector mesons + if (mctrack.has_daughters()) { + bool is_lepton_involved = false; + 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 daughter = mcTracks.iteratorAt(d); + if (abs(daughter.pdgCode()) == 11 || abs(daughter.pdgCode()) == 13) { + is_lepton_involved = true; + break; + } + } else { + std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; + std::cout << " Check the MC generator" << std::endl; + } } - // 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())) { // store conversion photon - fNewLabels[mp.globalIndex()] = fCounters[0]; - fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); - // fMCFlags[mp.globalIndex()] = mcflags; - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision.globalIndex())->second; - fCounters[0]++; + if (is_lepton_involved) { + // 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 daughter = mcTracks.iteratorAt(d); + // 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(daughter.globalIndex()) != fNewLabels.end())) { + fNewLabels[daughter.globalIndex()] = fCounters[0]; + fNewLabelsReversed[fCounters[0]] = daughter.globalIndex(); + // fMCFlags[daughter.globalIndex()] = mcflags; + fEventIdx[daughter.globalIndex()] = fEventLabels.find(mcCollision.globalIndex())->second; + fCounters[0]++; + } + } else { + std::cout << "Daughter label (" << d << ") exceeds the McParticles size (" << mcTracks.size() << ")" << std::endl; + std::cout << " Check the MC generator" << std::endl; + } + } // end of daughter loop } } - } - } // end of mc track loop + } // end of ndau protection + } // end of generated vector mesons loop - } // end of rec. collision loop + } // end of mc collision loop if constexpr (static_cast(system & kPCM)) { for (auto& v0 : v0photons) { @@ -252,13 +351,12 @@ struct AssociateMCInfoDilepton { if (!collision_from_v0.has_mcCollision()) { continue; } - auto mcCollision_from_v0 = collision_from_v0.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 o2track_ele = o2tracks.iteratorAt(ele.trackId()); + auto o2track_pos = o2tracks.iteratorAt(pos.trackId()); if (!o2track_ele.has_mcParticle() || !o2track_pos.has_mcParticle()) { continue; // If no MC particle is found, skip the v0 @@ -274,7 +372,7 @@ struct AssociateMCInfoDilepton { fNewLabels[mctrack.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_v0.globalIndex())->second; + fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mctrack.mcCollisionId())->second; fCounters[0]++; } v0legmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); @@ -293,7 +391,7 @@ struct AssociateMCInfoDilepton { 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(mp.mcCollisionId())->second; fCounters[0]++; } @@ -306,8 +404,8 @@ struct AssociateMCInfoDilepton { 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)) { @@ -317,7 +415,6 @@ struct AssociateMCInfoDilepton { 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()) { @@ -330,7 +427,7 @@ struct AssociateMCInfoDilepton { fNewLabels[mctrack.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_el.globalIndex())->second; + fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mctrack.mcCollisionId())->second; fCounters[0]++; } emprimaryelectronmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); @@ -349,7 +446,7 @@ struct AssociateMCInfoDilepton { 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(mp.mcCollisionId())->second; fCounters[0]++; } @@ -365,6 +462,7 @@ struct AssociateMCInfoDilepton { } // end of em primary electron loop } + if constexpr (static_cast(system & kFwdMuon)) { // auto emprimarymuons_coll = emprimarymuons.sliceBy(perCollision_mu, collision.globalIndex()); for (auto& emprimarymuon : emprimarymuons) { @@ -372,7 +470,6 @@ struct AssociateMCInfoDilepton { if (!collision_from_mu.has_mcCollision()) { continue; } - auto mcCollision_from_mu = collision_from_mu.mcCollision(); auto o2track = o2fwdtracks.iteratorAt(emprimarymuon.fwdtrackId()); if (!o2track.has_mcParticle()) { @@ -385,7 +482,7 @@ struct AssociateMCInfoDilepton { fNewLabels[mctrack.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mctrack.globalIndex(); // fMCFlags[mctrack.globalIndex()] = mcflags; - fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mcCollision_from_mu.globalIndex())->second; + fEventIdx[mctrack.globalIndex()] = fEventLabels.find(mctrack.mcCollisionId())->second; fCounters[0]++; } emprimarymuonmclabels(fNewLabels.find(mctrack.index())->second, o2track.mcMask()); @@ -404,7 +501,7 @@ struct AssociateMCInfoDilepton { fNewLabels[mp.globalIndex()] = fCounters[0]; fNewLabelsReversed[fCounters[0]] = mp.globalIndex(); // fMCFlags[mp.globalIndex()] = mcflags; - fEventIdx[mp.globalIndex()] = fEventLabels.find(mcCollision_from_mu.globalIndex())->second; + fEventIdx[mp.globalIndex()] = fEventLabels.find(mp.mcCollisionId())->second; fCounters[0]++; } @@ -443,12 +540,19 @@ struct AssociateMCInfoDilepton { // 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()); + // // 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); } @@ -463,8 +567,33 @@ struct AssociateMCInfoDilepton { 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 + // only for omega, phi mesons + for (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 + if (!mctrack.isPhysicalPrimary() && !mctrack.producedByGenerator()) { + continue; + } + + if (mctrack.pdgCode() == 223) { + if (dist01(engine) < down_scaling_omega) { + emmcgenvms(fEventLabels[mcCollision.globalIndex()], mctrack.pdgCode(), mctrack.flags(), mctrack.px(), mctrack.py(), mctrack.pz(), mctrack.e(), down_scaling_omega.value); + } + } else if (mctrack.pdgCode() == 333) { + if (dist01(engine) < down_scaling_phi) { + emmcgenvms(fEventLabels[mcCollision.globalIndex()], mctrack.pdgCode(), mctrack.flags(), mctrack.px(), mctrack.py(), mctrack.pz(), mctrack.e(), down_scaling_phi.value); + } + } + } // end of generated vector meson loop + } // end of reconstructed collision loop + fNewLabels.clear(); fNewLabelsReversed.clear(); // fMCFlags.clear(); diff --git a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx index 8d49ee134f5..9684d394d46 100644 --- a/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx +++ b/PWGEM/Dilepton/TableProducer/createEMEventDilepton.cxx @@ -14,6 +14,8 @@ // 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" @@ -24,6 +26,7 @@ #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "Common/Core/TableHelper.h" #include "PWGEM/Dilepton/DataModel/dileptonTables.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" @@ -36,12 +39,16 @@ using namespace o2::soa; 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 = 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 = soa::Join; // centrality table has dependency on multiplicity table. using MyCollisionsMC_Cent_Qvec = soa::Join; struct CreateEMEventDilepton { @@ -50,6 +57,8 @@ struct CreateEMEventDilepton { Produces event_mult; Produces event_cent; Produces event_qvec; + Produces emswtbit; + Produces event_norm_info; enum class EMEventType : int { kEvent = 0, @@ -63,16 +72,24 @@ struct CreateEMEventDilepton { 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", -999, "bz field, -999 is automatic"}; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; HistogramRegistry registry{"registry"}; void init(o2::framework::InitContext&) { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + 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); } + ~CreateEMEventDilepton() {} + int mRunNumber; float d_bz; Service ccdb; @@ -120,7 +137,7 @@ struct CreateEMEventDilepton { PresliceUnsorted perCollision_el = aod::emprimaryelectron::collisionId; PresliceUnsorted perCollision_mu = aod::emprimarymuon::collisionId; - template + template void skimEvent(TCollisions const& collisions, TBCs const&) { for (auto& collision : collisions) { @@ -129,97 +146,128 @@ struct CreateEMEventDilepton { continue; } } + registry.fill(HIST("hEventCounter"), 1); 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))) { + event_norm_info(collision.alias_raw(), collision.selection_raw(), static_cast(10.f * collision.posZ())); + + if (!collision.isSelected() || !collision.isEoI()) { continue; } - registry.fill(HIST("hEventCounter"), 1); - - if (collision.sel8()) { - registry.fill(HIST("hEventCounter"), 2); + if constexpr (isTriggerAnalysis) { + if (collision.swtaliastmp_raw() == 0) { + continue; + } else { + emswtbit(collision.swtaliastmp_raw(), collision.nInspectedTVX()); + } } - // uint64_t tag = collision.selection_raw(); + 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(), - collision.numContrib(), collision.trackOccupancyInTimeRange()); + 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.multTPC(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - - 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; + 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, 105.f); - 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); + 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(), collision.centNTPV()); - 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); + 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(), collision.centNTPV()); - - // std::vector qvec; - // std::copy(collision.qvecFT0MReVec().begin(), collision.qvecFT0MReVec().end(), std::back_inserter(qvec)); - // LOGF(info, "qvec.at(0) = %f", qvec.at(0)); + 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; - // LOGF(info, "collision.qvecFT0MReVec()[0] = %f, collision.qvecFT0MImVec()[0] = %f, collision.qvecFT0MReVec()[1] = %f, collision.qvecFT0MImVec()[1] = %f", collision.qvecFT0MReVec()[0], collision.qvecFT0MImVec()[0], collision.qvecFT0MReVec()[1], collision.qvecFT0MImVec()[1]); - - if (collision.qvecFT0CReVec().size() >= 2) { // both harmonics 2,3 + 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) { // only harmonics 2 + } 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); + 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, 105.f); - 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); + 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 + } // end of skimEvent + + //---------- for data ---------- void processEvent(MyCollisions const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEvent, "process event info", false); void processEvent_Cent(MyCollisions_Cent const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEvent_Cent, "process event info", false); void processEvent_Cent_Qvec(MyCollisions_Cent_Qvec const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEvent_Cent_Qvec, "process event info", false); + //---------- for data with swt---------- + + void processEvent_SWT(MyCollisionsWithSWT const& collisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + } + PROCESS_SWITCH(CreateEMEventDilepton, processEvent_SWT, "process event info", false); + + void processEvent_SWT_Cent(MyCollisionsWithSWT_Cent const& collisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + } + PROCESS_SWITCH(CreateEMEventDilepton, 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(CreateEMEventDilepton, processEvent_SWT_Cent_Qvec, "process event info", false); + + //---------- for MC ---------- + void processEventMC(MyCollisionsMC const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEventMC, "process event info", false); void processEventMC_Cent(MyCollisionsMC_Cent const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEventMC_Cent, "process event info", false); void processEventMC_Cent_Qvec(MyCollisionsMC_Cent_Qvec const& collisions, MyBCs const& bcs) { - skimEvent(collisions, bcs); + skimEvent(collisions, bcs); } PROCESS_SWITCH(CreateEMEventDilepton, processEventMC_Cent_Qvec, "process event info", false); @@ -244,11 +292,10 @@ struct AssociateDileptonToEMEvent { 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 + } // end of collision loop } // This struct is for both data and MC. @@ -276,9 +323,128 @@ struct AssociateDileptonToEMEvent { PROCESS_SWITCH(AssociateDileptonToEMEvent, processFwdMuon, "process forward muon indexing", false); PROCESS_SWITCH(AssociateDileptonToEMEvent, processDummy, "process dummy", true); }; +struct EMEventPropertyTask { + SliceCache cache; + Preslice perCollision = aod::track::collisionId; + using Run3Tracks = soa::Join; + + Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; + + Produces evprop; + struct : ConfigurableGroup { + std::string prefix = "spherocity_cutgroup"; + Configurable require_isPVContributor{"require_isPVContributor", false, "require tracks to be PV contributors"}; + Configurable min_ntrack{"min_ntrack", 3, "min. number of tracks"}; + Configurable min_pt{"min_pt", 0.15, "min. pT of track in GeV/c"}; + Configurable min_eta{"min_eta", -0.8, "min. eta of track"}; + Configurable max_eta{"max_eta", +0.8, "max. eta of track"}; + Configurable max_dcaxy{"max_dcaxy", 2.4, "max. DCAxy of track in cm"}; + Configurable max_dcaz{"max_dcaz", 3.2, "max. DCAz of track in cm"}; + Configurable min_ncluster_tpc{"min_ncluster_tpc", 50, "min. number of TPC clusters"}; + Configurable max_chi2tpc{"max_chi2tpc", 4.0, "max. chi2/ncls TPC"}; + } spherocity_cuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + void init(InitContext&) + { + if (fillQAHistogram) { + fRegistry.add("Spherocity/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{200, 0.0f, 10}}, false); + fRegistry.add("Spherocity/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -1.0f, 1.0f}}, false); + fRegistry.add("Spherocity/hSpherocity_ptweighted", "spherocity;Number of used tracks;spherocity", kTH2F, {{101, -0.5, 100.5}, {100, 0.0f, 1}}, false); + fRegistry.add("Spherocity/hSpherocity_ptunweighted", "spherocity;Number of used tracks;spherocity", kTH2F, {{101, -0.5, 100.5}, {100, 0.0f, 1}}, false); + } + } + + template + int getSpherocity(TTracks const& tracks, float& spherocity_ptweighted, float& spherocity_ptunweighted) + { + // Reference for spherocity : https://arxiv.org/pdf/1905.07208, https://arxiv.org/abs/2310.20406, https://arxiv.org/abs/1205.3963 + int used_ntrack_spherocity = 0; + float sum_pt = 0.f, sum_ntrack = 0.f; + + for (auto const& track : tracks) { + if (spherocity_cuts.require_isPVContributor && !track.isPVContributor()) { + continue; + } + if (track.tpcNClsFound() < spherocity_cuts.min_ncluster_tpc) { + continue; + } + + sum_pt += track.pt(); + sum_ntrack += 1.f; + + if (fillQAHistogram) { + fRegistry.fill(HIST("Spherocity/hPt"), track.pt()); + fRegistry.fill(HIST("Spherocity/hEtaPhi"), track.phi(), track.eta()); + } + used_ntrack_spherocity++; + } // end of track loop per collision + + float tempSph = 1.f, tempSph_pt1 = 1.f; + for (int i = 0; i < 360 / 0.1; i++) { + float nx = std::cos(M_PI / 180.f * i * 0.1); + float ny = std::sin(M_PI / 180.f * i * 0.1); + float sum_crossprod = 0.f, sum_crossprod_pt1 = 0.f; + for (auto const& track : tracks) { + if (spherocity_cuts.require_isPVContributor && !track.isPVContributor()) { + continue; + } + if (track.tpcNClsFound() < spherocity_cuts.min_ncluster_tpc) { + continue; + } + float px = track.px(); + float py = track.py(); + sum_crossprod += abs(px * ny - py * nx); + sum_crossprod_pt1 += abs(std::cos(track.phi()) * ny - std::sin(track.phi()) * nx); + } + float sph = std::pow(sum_crossprod / sum_pt, 2); + float sph_pt1 = std::pow(sum_crossprod_pt1 / sum_ntrack, 2); + if (sph < tempSph) { + tempSph = sph; + } + if (sph_pt1 < tempSph_pt1) { + tempSph_pt1 = sph_pt1; + } + } // end of track loop per collision + spherocity_ptweighted = std::pow(M_PI_2, 2) * tempSph; + spherocity_ptunweighted = std::pow(M_PI_2, 2) * tempSph_pt1; + if (used_ntrack_spherocity < spherocity_cuts.min_ntrack) { + spherocity_ptweighted = -1.f; + spherocity_ptunweighted = -1.f; + } + return used_ntrack_spherocity; + } + + Partition tracks_for_spherocity = spherocity_cuts.min_pt < aod::track::pt && spherocity_cuts.min_eta < o2::aod::track::eta && o2::aod::track::eta < spherocity_cuts.max_eta && nabs(o2::aod::track::dcaXY) < spherocity_cuts.max_dcaxy && nabs(o2::aod::track::dcaZ) < spherocity_cuts.max_dcaz && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::TPC) == true && o2::aod::track::tpcChi2NCl < spherocity_cuts.max_chi2tpc; // ITS-TPC matched tracks + + void processProp(aod::EMEvents const& collisions, Run3Tracks const&) + { + for (auto& collision : collisions) { + auto tracks_for_spherocity_per_collision = tracks_for_spherocity->sliceByCached(o2::aod::track::collisionId, collision.collisionId(), cache); + float spherocity_ptweighted = -1.f, spherocity_ptunweighted = -1.f; + int ntrack = getSpherocity(tracks_for_spherocity_per_collision, spherocity_ptweighted, spherocity_ptunweighted); + if (fillQAHistogram) { + fRegistry.fill(HIST("Spherocity/hSpherocity_ptweighted"), ntrack, spherocity_ptweighted); + fRegistry.fill(HIST("Spherocity/hSpherocity_ptunweighted"), ntrack, spherocity_ptunweighted); + } + evprop(spherocity_ptweighted, spherocity_ptunweighted, ntrack); + } // end of collision loop + } + PROCESS_SWITCH(EMEventPropertyTask, processProp, "process event property", true); + + void processDummy(aod::EMEvents const& collisions) + { + for (int i = 0; i < collisions.size(); i++) { + evprop(-1.f, -1.f, 0); + } // end of collision loop + } + PROCESS_SWITCH(EMEventPropertyTask, processDummy, "process dummy", false); +}; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc, TaskName{"create-emevent-dilepton"}), - adaptAnalysisTask(cfgc, TaskName{"associate-dilepton-to-emevent"})}; + adaptAnalysisTask(cfgc, TaskName{"associate-dilepton-to-emevent"}), + adaptAnalysisTask(cfgc, TaskName{"emevent-property"}), + }; } diff --git a/PWGEM/Dilepton/TableProducer/dielectronMl.cxx b/PWGEM/Dilepton/TableProducer/dielectronMl.cxx deleted file mode 100644 index 7ef2a8a4762..00000000000 --- a/PWGEM/Dilepton/TableProducer/dielectronMl.cxx +++ /dev/null @@ -1,361 +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 dielectronMl.cxx -/// \task for testing ML application for dielectron analyses -/// \author Daniel Samitz, , SMI Vienna -/// Elisa Meninno, , SMI Vienna - -#include "Framework/AnalysisTask.h" -#include "Framework/runDataProcessing.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" -#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h" -#include "PWGEM/Dilepton/Utils/MlResponseDielectronPair.h" - -using namespace o2; -using namespace o2::analysis; -using namespace o2::framework; -using namespace o2::aod; - -namespace o2::aod -{ - -namespace dielectronMlSelection -{ -DECLARE_SOA_COLUMN(IsSelMlSingleTrack, isSelMlSingleTrack, bool); -DECLARE_SOA_COLUMN(IsSelMlPair, isSelMlPair, bool); -DECLARE_SOA_COLUMN(MlScoreSingleTrack, mlScoreSingleTrack, std::vector); -DECLARE_SOA_COLUMN(MlScorePair, mlScorePair, std::vector); -} // namespace dielectronMlSelection - -DECLARE_SOA_TABLE(dielectronMlSelectionSingleTrack, "AOD", "DIELEMLSELST", //! - dielectronMlSelection::IsSelMlSingleTrack); -DECLARE_SOA_TABLE(dielectronMlScoreSingleTrack, "AOD", "DIELEMLSCOREST", //! - dielectronMlSelection::MlScoreSingleTrack); -DECLARE_SOA_TABLE(dielectronMlSelectionPair, "AOD", "DIELEMLSELP", //! - dielectronMlSelection::IsSelMlPair); -DECLARE_SOA_TABLE(dielectronMlScorePair, "AOD", "DIELEMLSCOREP", //! - dielectronMlSelection::MlScorePair); -} // namespace o2::aod - -using MySkimmedTracks = soa::Join; -using MySkimmedTracksWithPID = soa::Join; -using MyTracksWithPID = soa::Join; - -// define some default values for single track analysis -namespace dielectron_ml_cuts_single_track -{ -// direction of the cut -enum CutDirection { - CutGreater = 0, // require score < cut value - CutSmaller, // require score > cut value - CutNot // do not cut on score -}; - -static constexpr int nBinsPt = 1; -static constexpr int nCutScores = 2; -// default values for the pT bin edges, offset by 1 from the bin numbers in cuts array -constexpr double binsPt[nBinsPt + 1] = { - 0., - 999.}; -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] = {CutSmaller, CutGreater}; -auto vecCutDir = std::vector{cutDir, cutDir + nCutScores}; - -// default values for the cuts -constexpr double cuts[nBinsPt][nCutScores] = { - {0.5, 0.5}}; - -// row labels -static const std::vector labelsPt = { - "pT bin 0"}; - -// column labels -static const std::vector labelsCutScore = {"Signal", "Background"}; -} // namespace dielectron_ml_cuts_single_track - -// define some default values for pair analysis -namespace dielectron_ml_cuts_pair -{ -// direction of the cut -enum CutDirection { - CutGreater = 0, // require score < cut value - CutSmaller, // require score > cut value - CutNot // do not cut on score -}; - -static constexpr int nBinsM = 1; -static constexpr int nCutScores = 2; -// default values for the mass bin edges, offset by 1 from the bin numbers in cuts array -constexpr double binsM[nBinsM + 1] = { - 0., - 999.}; -auto vecBinsM = std::vector{binsM, binsM + nBinsM + 1}; - -// default values for the ML model paths, one model per mass bin -static const std::vector modelPaths = { - ""}; - -// default values for the cut directions -constexpr int cutDir[nCutScores] = {CutSmaller, CutGreater}; -auto vecCutDir = std::vector{cutDir, cutDir + nCutScores}; - -// default values for the cuts -constexpr double cuts[nBinsM][nCutScores] = { - {0.5, 0.5}}; - -// row labels -static const std::vector labelsM = { - "mass bin 0"}; - -// column labels -static const std::vector labelsCutScore = {"Signal", "Background"}; -} // namespace dielectron_ml_cuts_pair - -struct DielectronMlSingleTrack { - Produces singleTrackSelection; - Produces singleTrackScore; - - // ML inference - Configurable> binsPtMl{"binsPtMl", std::vector{dielectron_ml_cuts_single_track::vecBinsPt}, "pT bin limits for ML application"}; - Configurable> cutDirMl{"cutDirMl", std::vector{dielectron_ml_cuts_single_track::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {dielectron_ml_cuts_single_track::cuts[0], dielectron_ml_cuts_single_track::nBinsPt, dielectron_ml_cuts_single_track::nCutScores, dielectron_ml_cuts_single_track::labelsPt, dielectron_ml_cuts_single_track::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(dielectron_ml_cuts_single_track::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{""}, "Paths of models on CCDB"}; - Configurable> onnxFileNames{"onnxFileNames", std::vector{""}, "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"}; - // preselection cuts (from treeCreatorElectronMl.cxx) - Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; - Configurable maxchi2tpc{"maxchi2tpc", 4.0, "max. chi2/NclsTPC"}; - Configurable maxeta{"maxeta", 0.9, "eta acceptance"}; - // table output - Configurable fillScoreTable{"fillScoreTable", false, "fill table with scores from ML model"}; - - o2::analysis::MlResponseDielectronSingleTrack mlResponse; - o2::ccdb::CcdbApi ccdbApi; - std::vector> hModelScore; - std::vector> hModelScoreVsPt; - - HistogramRegistry registry{"registry", {}}; - - void init(InitContext&) - { - if (doprocessSkimmedSingleTrack || doprocessAO2DSingleTrack) { - mlResponse.configure(binsPtMl, cutsMl, cutDirMl, nClassesMl); - if (loadModelsFromCCDB) { - ccdbApi.init(ccdbUrl); - mlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); - } else { - mlResponse.setModelPathsLocal(onnxFileNames); - } - mlResponse.cacheInputFeaturesIndices(namesInputFeatures); - mlResponse.init(); - - // load histograms for ML score - AxisSpec axisScore = {100, 0, 1, "score"}; - AxisSpec axisBinsPt = {binsPtMl, "#it{p}_{T} (GeV/#it{c})"}; - for (int classMl = 0; classMl < nClassesMl; classMl++) { - hModelScore.push_back(registry.add("hMlScore" + TString(cutsMl->getLabelsCols()[classMl]), "Model score distribution;Model score;counts", HistType::kTH1F, {axisScore})); - hModelScoreVsPt.push_back(registry.add("hMlScore" + TString(cutsMl->getLabelsCols()[classMl]) + "VsPt", "Model score distribution;Model score;counts", HistType::kTH2F, {axisScore, axisBinsPt})); - } - } - } - - template - bool applyPreSelectionCuts(T const& track) - { - // consistent with treeCreatorElectronMl.cxx - if (!track.hasITS()) { - return false; - } - if (!track.hasTPC()) { - return false; - } - if (track.tpcNClsCrossedRows() < mincrossedrows) { - return false; - } - if (track.itsChi2NCl() < -1) { // if tracks are not reconstructed properly, chi2/ITSncls is set to -999; - return false; - } - if (abs(track.eta()) > maxeta) { - return false; - } - if (track.tpcChi2NCl() > maxchi2tpc) { - return false; - } - if (abs(track.dcaXY()) > 1.) { - return false; - } - if (abs(track.dcaZ()) > 1.) { - return false; - } - return true; - } - - template - void runSingleTracks(T const& tracks) - { - for (const auto& track : tracks) { - if (!applyPreSelectionCuts(track)) { - singleTrackSelection(false); - if (fillScoreTable) { - std::vector outputMl(nClassesMl, -1); - singleTrackScore(outputMl); - } - continue; - } - auto pt = track.pt(); - std::vector inputFeatures = mlResponse.getInputFeatures(track); - std::vector outputMl = {}; - - bool isSelected = mlResponse.isSelectedMl(inputFeatures, pt, outputMl); - for (int classMl = 0; classMl < nClassesMl; classMl++) { - hModelScore[classMl]->Fill(outputMl[classMl]); - hModelScoreVsPt[classMl]->Fill(outputMl[classMl], pt); - } - singleTrackSelection(isSelected); - if (fillScoreTable) { - singleTrackScore(outputMl); - } - } - } - - void processSkimmedSingleTrack(MySkimmedTracksWithPID const& tracks) - { - runSingleTracks(tracks); - } - PROCESS_SWITCH(DielectronMlSingleTrack, processSkimmedSingleTrack, "Apply ML selection on skimmed output on single tracks", true); - - void processAO2DSingleTrack(MyTracksWithPID const& tracks) - { - runSingleTracks(tracks); - } - PROCESS_SWITCH(DielectronMlSingleTrack, processAO2DSingleTrack, "Apply ML selection on skimmed output on single tracks", false); - - void processDummy(DielectronsExtra const&) - { - // dummy - } - PROCESS_SWITCH(DielectronMlSingleTrack, processDummy, "Dummy", false); -}; - -struct DielectronMlPair { - Produces pairSelection; - Produces pairScore; - - // ML inference - Configurable> binsMMl{"binsMMl", std::vector{dielectron_ml_cuts_pair::vecBinsM}, "Mass bin limits for ML application"}; - Configurable> cutDirMl{"cutDirMl", std::vector{dielectron_ml_cuts_pair::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; - Configurable> cutsMl{"cutsMl", {dielectron_ml_cuts_pair::cuts[0], dielectron_ml_cuts_pair::nBinsM, dielectron_ml_cuts_pair::nCutScores, dielectron_ml_cuts_pair::labelsM, dielectron_ml_cuts_pair::labelsCutScore}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", static_cast(dielectron_ml_cuts_pair::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{""}, "Paths of models on CCDB"}; - Configurable> onnxFileNames{"onnxFileNames", std::vector{""}, "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"}; - // table output - Configurable fillScoreTable{"fillScoreTable", false, "fill table with scores from ML model"}; - - o2::analysis::MlResponseDielectronPair mlResponse; - o2::ccdb::CcdbApi ccdbApi; - std::vector> hModelScore; - std::vector> hModelScoreVsM; - - HistogramRegistry registry{"registry", {}}; - - void init(InitContext&) - { - if (doprocessPair) { - mlResponse.configure(binsMMl, cutsMl, cutDirMl, nClassesMl); - if (loadModelsFromCCDB) { - ccdbApi.init(ccdbUrl); - mlResponse.setModelPathsCCDB(onnxFileNames, ccdbApi, modelPathsCCDB, timestampCCDB); - } else { - mlResponse.setModelPathsLocal(onnxFileNames); - } - mlResponse.cacheInputFeaturesIndices(namesInputFeatures); - mlResponse.init(); - - // load histograms for ML score - AxisSpec axisScore = {100, 0, 1, "score"}; - AxisSpec axisBinsM = {binsMMl, "#it{M} (GeV/#it{c^{2}})"}; - for (int classMl = 0; classMl < nClassesMl; classMl++) { - hModelScore.push_back(registry.add("hMlScore" + TString(cutsMl->getLabelsCols()[classMl]), "Model score distribution;Model score;counts", HistType::kTH1F, {axisScore})); - hModelScoreVsM.push_back(registry.add("hMlScore" + TString(cutsMl->getLabelsCols()[classMl]) + "VsM", "Model score distribution;Model score;counts", HistType::kTH2F, {axisScore, axisBinsM})); - } - } - } - - void processPair(DielectronsExtra const& dielectrons, MySkimmedTracks const&) - { - // dummy value for magentic field. ToDo: take it from ccdb! - float d_bz = 1.; - mlResponse.setBz(d_bz); - for (const auto& dielectron : dielectrons) { - const auto& track1 = dielectron.index0_as(); - const auto& track2 = dielectron.index1_as(); - if (track1.sign() == track2.sign()) { - continue; - } - ROOT::Math::PtEtaPhiMVector v1(track1.pt(), track1.eta(), track1.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v2(track2.pt(), track2.eta(), track2.phi(), o2::constants::physics::MassElectron); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - auto m = v12.M(); - std::vector inputFeatures = mlResponse.getInputFeatures(track1, track2); - std::vector outputMl = {}; - - bool isSelected = mlResponse.isSelectedMl(inputFeatures, m, outputMl); - for (int classMl = 0; classMl < nClassesMl; classMl++) { - hModelScore[classMl]->Fill(outputMl[classMl]); - hModelScoreVsM[classMl]->Fill(outputMl[classMl], m); - } - pairSelection(isSelected); - if (fillScoreTable) { - pairScore(outputMl); - } - } - } - PROCESS_SWITCH(DielectronMlPair, processPair, "Apply ML selection at pair level", false); - - void processDummyAO2D(MyTracksWithPID const&) - { - // dummy - } - PROCESS_SWITCH(DielectronMlPair, processDummyAO2D, "Dummy", false); - - void processDummySkimmed(MySkimmedTracks const&) - { - // dummy - } - PROCESS_SWITCH(DielectronMlPair, processDummySkimmed, "Dummy", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGEM/Dilepton/TableProducer/eventSelection.cxx b/PWGEM/Dilepton/TableProducer/eventSelection.cxx new file mode 100644 index 00000000000..dfe19f1a2e9 --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/eventSelection.cxx @@ -0,0 +1,128 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 event selection table for PWG-EM. +// 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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +using MyCollisions = soa::Join; +using MyCollisions_Cent = soa::Join; + +using MyCollisionsMC = soa::Join; +using MyCollisionsMC_Cent = soa::Join; + +struct EMEventSelection { + Produces emevsel; + + // Configurables + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", 0.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"}; + 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. occupancy"}; + Configurable cfgFT0COccupancyMax{"cfgFT0COccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; + + void init(InitContext&) {} + + template + bool isSelectedEvent(TCollision const& collision) + { + if constexpr (std::is_same_v, MyCollisionsMC::iterator> || std::is_same_v, MyCollisionsMC_Cent::iterator>) { + if (!collision.has_mcCollision()) { + return false; + } + } + + if (fabs(collision.posZ()) > cfgZvtxMax) { + return false; + } + + if (cfgRequireFT0AND && !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + return false; + } + + if (cfgRequireNoTFB && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + if (cfgRequireNoITSROFB && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + + if (cfgRequireNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + + if (cfgRequireGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + + if (cfgRequireNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + + if (!(cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < cfgTrackOccupancyMax)) { + return false; + } + + if (!(cfgFT0COccupancyMin < collision.ft0cOccupancyInTimeRange() && collision.ft0cOccupancyInTimeRange() < cfgFT0COccupancyMax)) { + return false; + } + + if constexpr (std::is_same_v, MyCollisions_Cent::iterator>) { + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + return false; + } + } + + return true; + } + + template + void processEventSelection(TCollisions const& collisions) + { + for (auto& collision : collisions) { + emevsel(isSelectedEvent(collision)); + } // end of collision loop + } // end of process + + PROCESS_SWITCH_FULL(EMEventSelection, processEventSelection, processEventSelection, "event selection", true); + PROCESS_SWITCH_FULL(EMEventSelection, processEventSelection, processEventSelection_Cent, "event selection with cent", false); + PROCESS_SWITCH_FULL(EMEventSelection, processEventSelection, processEventSelectionMC, "event selection MC", false); + PROCESS_SWITCH_FULL(EMEventSelection, processEventSelection, processEventSelectionMC_Cent, "event selection MC with cent", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"em-event-selection"})}; +} diff --git a/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx b/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx new file mode 100644 index 00000000000..7e9155c04bc --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/filterDielectronEvent.cxx @@ -0,0 +1,1366 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "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", 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 max_mean_its_cluster_size{"max_mean_its_cluster_size", 16.f, "max. x cos(lambda)"}; + Configurable max_p_for_its_cluster_size{"max_p_for_its_cluster_size", 0.2, "its cluster size cut is applied below this p"}; + Configurable max_pin_for_pion_rejection{"max_pin_for_pion_rejection", -1, "pion rejection is applied below this pin"}; + 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", -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 maxMee{"maxMee", 0.02, "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}; + + 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/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() < 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; + } + + 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 && track.p() < max_p_for_its_cluster_size) { + 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; + } + + 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) + { + if (track.tpcInnerParam() < max_pin_for_pion_rejection && (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi)) { + return false; + } + if (track.hasTOF()) { + return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl && fabs(track.tofNSigmaEl()) < maxTOFNsigmaEl; + } else { + return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl; + } + } + + 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(), 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 new file mode 100644 index 00000000000..ca7b524e19d --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/filterEoI.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. +// +// ======================== +// +// 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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct filterEoI { + enum SubSystem { + kElectron = 0x1, + kFwdMuon = 0x2, + }; + Produces emeoi; + + HistogramRegistry fRegistry{"output"}; + void init(o2::framework::InitContext&) + { + auto hEventCounter = fRegistry.add("hEventCounter", "hEventCounter", kTH1D, {{5, 0.5f, 5.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"); + } + + SliceCache cache; + Preslice perCollision_el = aod::emprimaryelectron::collisionId; + Preslice perCollision_mu = aod::emprimarymuon::collisionId; + + template + void selectEoI(TCollisions const& collisions, TElectrons const& electrons, TMuons const& muons) + { + for (auto& collision : collisions) { + bool does_electron_exist = false; + bool does_fwdmuon_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) { + 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) { + does_fwdmuon_exist = true; + fRegistry.fill(HIST("hEventCounter"), 3); + } + } + + if (does_electron_exist || does_fwdmuon_exist) { + fRegistry.fill(HIST("hEventCounter"), 4); + } + if (does_electron_exist && does_fwdmuon_exist) { + fRegistry.fill(HIST("hEventCounter"), 5); + } + + emeoi(does_electron_exist || does_fwdmuon_exist); + + } // end of collision loop + + } // end of selectEoI + + void process_Electron(aod::Collisions const& collisions, aod::EMPrimaryElectrons const& electrons) + { + const uint8_t sysflag = kElectron; + selectEoI(collisions, electrons, nullptr); + } + + void process_FwdMuon(aod::Collisions const& collisions, aod::EMPrimaryMuons const& muons) + { + const uint8_t sysflag = kFwdMuon; + selectEoI(collisions, nullptr, muons); + } + + 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); + } + + void processDummy(aod::Collisions const& collisions) + { + for (int i = 0; i < collisions.size(); i++) { + emeoi(true); + } + } + + 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_Electron_FwdMuon, "create filter bit for Electron, FwdMuon", false); + PROCESS_SWITCH(filterEoI, processDummy, "processDummy", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"filter-eoi"})}; +} diff --git a/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx new file mode 100644 index 00000000000..3ea6dc842d8 --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/skimmerOTS.cxx @@ -0,0 +1,128 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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 "CCDB/BasicCCDBManager.h" +#include "EventFiltering/Zorro.h" +#include "Common/Core/TableHelper.h" + +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct skimmerOTS { + Produces swt_tmp; + + // CCDB options + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfg_swt_names{"cfg_swt_names", "fHighTrackMult,fHighFt0Mult", "comma-separated software trigger names"}; // !trigger names have to be pre-registered in dileptonTable.h for bit operation! + + std::vector swt_names; + int mRunNumber; + Service ccdb; + + HistogramRegistry registry{"registry"}; + void init(o2::framework::InitContext&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + LOGF(info, "enable software triggers : %s", cfg_swt_names.value.data()); + std::stringstream tokenizer(cfg_swt_names.value); + std::string token; + while (std::getline(tokenizer, token, ',')) { + swt_names.emplace_back(token); + } + + const int nbin = swt_names.size(); + auto hEventCounter = registry.add("hEventCounter", "hEventCounter;;Number of Events", kTH1D, {{nbin + 1, 0.5f, nbin + 1 + 0.5f}}); + hEventCounter->GetXaxis()->SetBinLabel(1, "all"); + for (int idx = 0; idx < nbin; idx++) { + hEventCounter->GetXaxis()->SetBinLabel(idx + 2, swt_names[idx].data()); + } + + registry.add("hNInspectedTVX", "N inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true); + } + + ~skimmerOTS() + { + swt_names.clear(); + swt_names.shrink_to_fit(); + } + + Zorro zorro; + std::vector mTOIidx; + uint64_t mNinspectedTVX{0}; + + template + void initCCDB(TBC const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + mTOIidx = zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), cfg_swt_names.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()); + registry.fill(HIST("hNInspectedTVX"), bc.runNumber(), mNinspectedTVX); + + mRunNumber = bc.runNumber(); + } + + using MyBCs = soa::Join; + using MyCollisions = soa::Join; + + void process(MyCollisions const& collisions, MyBCs const&) + { + for (auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + uint16_t trigger_bitmap = 0; + registry.fill(HIST("hEventCounter"), 1); // all + if (zorro.isSelected(bc.globalBC())) { // triggered event + auto swt_bitset = zorro.getLastResult(); // this has to be called after zorro::isSelected, or simply call zorro.fetch + // LOGF(info, "swt_bitset.to_string().c_str() = %s", swt_bitset.to_string().c_str()); + for (size_t idx = 0; idx < mTOIidx.size(); idx++) { + if (swt_bitset.test(mTOIidx[idx])) { + auto swtname = swt_names[idx]; + trigger_bitmap |= BIT(o2::aod::pwgem::dilepton::swt::aliasLabels.at(swtname)); + // LOGF(info, "swtname = %s is fired. swt index in original swt table = %d, swt index for EM table = %d", swtname.data(), mTOIidx[idx], o2::aod::pwgem::dilepton::swt::aliasLabels.at(swtname)); + registry.fill(HIST("hEventCounter"), idx + 2); // fired trigger + } + } + } + // LOGF(info, "trigger_bitmap = %d, mNinspectedTVX = %d", trigger_bitmap, mNinspectedTVX); + swt_tmp(trigger_bitmap, mNinspectedTVX); + } // end of collision loop + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"skimmer-ots"})}; +} diff --git a/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx b/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx index 957d2c7159b..e132db33c06 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerPrimaryElectron.cxx @@ -12,7 +12,7 @@ /// \brief write relevant information about primary electrons. /// \author daiki.sekihata@cern.ch -#include +#include #include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -25,6 +25,7 @@ #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/Dilepton/Utils/PairUtilities.h" @@ -34,7 +35,9 @@ using namespace o2::soa; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::constants::physics; -// using namespace o2::aod::pwgem::photonmeson; + +using MyCollisions = soa::Join; +using MyCollisionsWithSWT = soa::Join; using MyTracks = soa::Join; using MyTrackMC = MyTracksMC::iterator; struct skimmerPrimaryElectron { - enum class EM_EEPairType : int { - kULS = 0, - kLSpp = +1, - kLSmm = -1, - }; - SliceCache cache; Preslice perCol = o2::aod::track::collisionId; Produces emprimaryelectrons; @@ -63,12 +60,12 @@ struct skimmerPrimaryElectron { // Operation and minimisation criteria Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; - 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", 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 max_mean_itsob_cluster_size{"max_mean_itsob_cluster_size", 16.f, "max. x cos(lambda)"}; // this is to suppress random combination. default 4 + 1 for skimming. + Configurable max_mean_its_cluster_size{"max_mean_its_cluster_size", 16.f, "max. x cos(lambda)"}; // this is to suppress random combination. default 4 + 1 for skimming. + Configurable max_p_for_its_cluster_size{"max_p_for_its_cluster_size", 0.0, "its cluster size cut is applied below this p"}; 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"}; @@ -82,10 +79,11 @@ struct skimmerPrimaryElectron { Configurable maxTOFNsigmaEl{"maxTOFNsigmaEl", 3.5, "max. TOF 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"}; // set to -2 for lowB, -1e+10 for nominalB - Configurable maxTPCNsigmaKa{"maxTPCNsigmaKa", 0.0, "max. TPC n sigma for kaon exclusion"}; - Configurable minTPCNsigmaKa{"minTPCNsigmaKa", 0.0, "min. TPC n sigma for kaon exclusion"}; - Configurable maxTPCNsigmaPr{"maxTPCNsigmaPr", 0.0, "max. TPC n sigma for proton exclusion"}; - Configurable minTPCNsigmaPr{"minTPCNsigmaPr", 0.0, "min. TPC n sigma for proton exclusion"}; + Configurable maxTPCNsigmaKa{"maxTPCNsigmaKa", 2.5, "max. TPC n sigma for kaon exclusion"}; + Configurable minTPCNsigmaKa{"minTPCNsigmaKa", -2.5, "min. TPC n sigma for kaon exclusion"}; + 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"}; HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; @@ -112,21 +110,19 @@ struct skimmerPrimaryElectron { 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/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/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/hChi2TOF", "chi2 of TOF", 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);#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, 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_{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); @@ -134,10 +130,11 @@ struct skimmerPrimaryElectron { 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/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; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, 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); } } @@ -191,6 +188,10 @@ struct skimmerPrimaryElectron { } } + if (requireTOF && !(track.hasTOF() && abs(track.tofNSigmaEl()) < maxTOFNsigmaEl)) { + return false; + } + if (track.tpcChi2NCl() > maxchi2tpc) { return false; } @@ -213,14 +214,14 @@ struct skimmerPrimaryElectron { uint32_t itsClusterSizes = track.itsClusterSizes(); int total_cluster_size = 0, nl = 0; - for (unsigned int layer = 3; layer < 7; layer++) { + 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_itsob_cluster_size) { + if (static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl())) > max_mean_its_cluster_size && track.p() < max_p_for_its_cluster_size) { return false; } @@ -236,7 +237,7 @@ struct skimmerPrimaryElectron { return false; } - if ((0.0 < track.beta() && track.beta() < 0.95) || 1.05 < track.beta()) { + if (track.hasTOF() && (maxTOFNsigmaEl < fabs(track.tofNSigmaEl()))) { return false; } @@ -249,11 +250,11 @@ struct skimmerPrimaryElectron { float dcaXY = dcaInfo[0]; float dcaZ = dcaInfo[1]; - if (abs(dcaXY) > dca_xy_max || abs(dcaZ) > dca_z_max) { + if (fabs(dcaXY) > dca_xy_max || fabs(dcaZ) > dca_z_max) { return false; } - if (track_par_cov_recalc.getPt() < minpt || abs(track_par_cov_recalc.getEta()) > maxeta) { + if (track_par_cov_recalc.getPt() < minpt || fabs(track_par_cov_recalc.getEta()) > maxeta) { return false; } @@ -263,7 +264,7 @@ struct skimmerPrimaryElectron { 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(std::abs(chi2) / 2.); + dca_3d = std::sqrt(std::fabs(chi2) / 2.); } if (dca_3d > dca_3d_sigma_max) { return false; @@ -275,7 +276,7 @@ struct skimmerPrimaryElectron { template bool isElectron(TTrack const& track) { - return isElectron_TPChadrej(track) || isElectron_TOFrecovery(track); + return isElectron_TPChadrej(track) || isElectron_TOFreq(track); } template @@ -293,28 +294,25 @@ struct skimmerPrimaryElectron { if (minTPCNsigmaPr < track.tpcNSigmaPr() && track.tpcNSigmaPr() < maxTPCNsigmaPr) { return false; } - if (!(track.beta() < 0.f || (0.96 < track.beta() && track.beta() < 1.04))) { + if (track.hasTOF() && (maxTOFNsigmaEl < fabs(track.tofNSigmaEl()))) { return false; } return true; } template - bool isElectron_TOFrecovery(TTrack const& track) + bool isElectron_TOFreq(TTrack const& track) { if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi) { return false; } - if (!(track.beta() < 0.f || (0.96 < track.beta() && track.beta() < 1.04))) { - return false; - } - return minTPCNsigmaEl < track.tpcNSigmaEl() && track.tpcNSigmaEl() < maxTPCNsigmaEl && abs(track.tofNSigmaEl()) < maxTOFNsigmaEl; + 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::make_pair(collision.globalIndex(), track.globalIndex())) == stored_trackIds.end()) { + 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); @@ -332,11 +330,11 @@ struct skimmerPrimaryElectron { emprimaryelectrons(collision.globalIndex(), track.globalIndex(), track.sign(), pt_recalc, eta_recalc, phi_recalc, dcaXY, dcaZ, - track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), + 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.itsChi2NCl(), track.detectorMap(), + track.itsClusterSizes(), 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( @@ -356,12 +354,12 @@ struct skimmerPrimaryElectron { track_par_cov_recalc.getSigma1PtTgl(), track_par_cov_recalc.getSigma1Pt2()); - stored_trackIds.emplace_back(std::make_pair(collision.globalIndex(), track.globalIndex())); + 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++) { + for (unsigned int layer = 0; layer < 7; layer++) { int cluster_size_per_layer = (itsClusterSizes >> (layer * 4)) & 0xf; if (cluster_size_per_layer > 0) { nl++; @@ -374,8 +372,6 @@ struct skimmerPrimaryElectron { 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/hDCAxy_Pt"), pt_recalc, dcaXY); - fRegistry.fill(HIST("Track/hDCAz_Pt"), pt_recalc, dcaZ); 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()); @@ -383,18 +379,19 @@ struct skimmerPrimaryElectron { 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/hMeanClusterSizeITS"), static_cast(total_cluster_size) / static_cast(nl) * std::cos(std::atan(track.tgl()))); + 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/hTOFbeta"), track.p(), 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()); @@ -404,9 +401,10 @@ struct skimmerPrimaryElectron { } } - std::vector> stored_trackIds; + 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 && ((0.96f < o2::aod::pidtofbeta::beta && o2::aod::pidtofbeta::beta < 1.04f) || o2::aod::pidtofbeta::beta < 0.f) && (o2::aod::pidtpc::tpcNSigmaPi < minTPCNsigmaPi || maxTPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); + Filter pidFilter = minTPCNsigmaEl < o2::aod::pidtpc::tpcNSigmaEl && o2::aod::pidtpc::tpcNSigmaEl < maxTPCNsigmaEl && (o2::aod::pidtpc::tpcNSigmaPi < minTPCNsigmaPi || maxTPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); using MyFilteredTracks = soa::Filtered; Partition posTracks = o2::aod::track::signed1Pt > 0.f; @@ -414,15 +412,15 @@ struct skimmerPrimaryElectron { // ---------- for data ---------- - void processRec_SA(Join const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) + void processRec_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) { stored_trackIds.reserve(tracks.size()); for (auto& collision : collisions) { - auto bc = collision.bc_as(); + 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; } @@ -441,24 +439,19 @@ struct skimmerPrimaryElectron { } PROCESS_SWITCH(skimmerPrimaryElectron, processRec_SA, "process reconstructed info only", true); // standalone - Preslice trackIndicesPerCollision = aod::track_association::collisionId; - void processRec_TTCA(Join const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::TrackAssoc const& trackIndices) + 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.bc_as(); + 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 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(); @@ -467,10 +460,6 @@ struct skimmerPrimaryElectron { } fillTrackTable(collision, track); } - // 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(); @@ -478,12 +467,74 @@ struct skimmerPrimaryElectron { } PROCESS_SWITCH(skimmerPrimaryElectron, processRec_TTCA, "process reconstructed info only", false); // with TTCA + void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const& tracks) + { + stored_trackIds.reserve(tracks.size()); + + for (auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!collision.isSelected()) { + continue; + } + + if (collision.swtaliastmp_raw() == 0) { + continue; + } + + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (auto& track : tracks_per_coll) { + if (!checkTrack(collision, track) || !isElectron(track)) { + continue; + } + fillTrackTable(collision, track); + } + + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryElectron, processRec_SA_SWT, "process reconstructed info only", false); // standalone with swt + + 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()) { + continue; + } + if (collision.swtaliastmp_raw() == 0) { + continue; + } + + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, collision.globalIndex()); + + for (auto& trackId : trackIdsThisCollision) { + auto track = trackId.template track_as(); + if (!checkTrack(collision, track) || !isElectron(track)) { + continue; + } + fillTrackTable(collision, track); + } + } // end of collision loop + + stored_trackIds.clear(); + stored_trackIds.shrink_to_fit(); + } + PROCESS_SWITCH(skimmerPrimaryElectron, processRec_TTCA_SWT, "process reconstructed info only", false); // with TTCA with swt + // ---------- 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) + void processMC_SA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks) { stored_trackIds.reserve(tracks.size()); @@ -491,10 +542,10 @@ struct skimmerPrimaryElectron { if (!collision.has_mcCollision()) { continue; } - auto bc = collision.bc_as(); + 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; } @@ -512,7 +563,7 @@ 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&, MyFilteredTracksMC const& tracks, aod::TrackAssoc const& trackIndices) + void processMC_TTCA(soa::Join const& collisions, aod::McCollisions const&, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::TrackAssoc const& trackIndices) { stored_trackIds.reserve(tracks.size() * 2); @@ -520,18 +571,14 @@ struct skimmerPrimaryElectron { if (!collision.has_mcCollision()) { continue; } - auto bc = collision.bc_as(); + 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 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(); @@ -540,10 +587,6 @@ struct skimmerPrimaryElectron { } fillTrackTable(collision, track); } - // 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(); @@ -570,7 +613,6 @@ struct prefilterPrimaryElectron { 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", -999, "bz field, -999 is automatic"}; Configurable max_pt_itsonly{"max_pt_itsonly", 0.15, "max pT for ITSonly tracks at PV"}; @@ -686,14 +728,14 @@ struct prefilterPrimaryElectron { 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 (abs(dcaInfo[0]) < min_dcatopv) { + if (fabs(dcaInfo[0]) < min_dcatopv) { return false; } if (isITSonlyTrack(track) && track_par_cov_recalc.getPt() > max_pt_itsonly) { return false; } - if (abs(track_par_cov_recalc.getEta()) > maxeta) { + if (fabs(track_par_cov_recalc.getEta()) > maxeta) { return false; } @@ -744,7 +786,6 @@ struct prefilterPrimaryElectron { Preslice trackIndicesPerCollision = aod::track_association::collisionId; - // Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& min_dcatopv < nabs(o2::aod::track::dcaXY) && ncheckbit(aod::track::v001::detectorMap, (uint8_t)o2::aod::track::ITS) == true; 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; using MyFilteredTracks = soa::Filtered; Partition posTracks = o2::aod::track::signed1Pt > 0.f; @@ -753,14 +794,14 @@ struct prefilterPrimaryElectron { Partition positrons = o2::aod::emprimaryelectron::sign > int8_t(0); Partition electrons = o2::aod::emprimaryelectron::sign < int8_t(0); - void processPrefilter_TTCA(Join const& collisions, aod::BCsWithTimestamps const&, MyTracks const&, aod::EMPrimaryElectrons const& primaryelectrons, aod::TrackAssoc const& trackIndices) + void processPrefilter_TTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const&, aod::EMPrimaryElectrons const& primaryelectrons, aod::TrackAssoc const& trackIndices) { - std::map pfb_map; // map track.globalIndex -> prefilter bit + std::unordered_map pfb_map; // map track.globalIndex -> prefilter bit for (auto& collision : collisions) { - auto bc = collision.template bc_as(); + 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; } @@ -800,7 +841,7 @@ struct prefilterPrimaryElectron { pfb_map[empos.globalIndex()] |= (uint8_t(1) << static_cast(EM_Electron_PF::kElFromPC)); } } // end of loose electron loop - } // end of signal positon loop + } // end of signal positon loop for (auto& emele : electrons_per_coll) { // auto ele = tracks.rawIteratorAt(emele.trackId()); // use rawIterator, if the table is filtered. @@ -816,7 +857,7 @@ struct prefilterPrimaryElectron { pfb_map[emele.globalIndex()] |= (uint8_t(1) << static_cast(EM_Electron_PF::kElFromPC)); } } // end of loose positon loop - } // end of signal electron loop + } // end of signal electron loop posTracks_per_coll.clear(); negTracks_per_coll.clear(); @@ -832,14 +873,14 @@ struct prefilterPrimaryElectron { } PROCESS_SWITCH(prefilterPrimaryElectron, processPrefilter_TTCA, "process prefilter with TTCA", false); - void processPrefilter_SA(Join const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const&, aod::EMPrimaryElectrons const& primaryelectrons) + void processPrefilter_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracks const&, aod::EMPrimaryElectrons const& primaryelectrons) { - std::map pfb_map; // map track.globalIndex -> prefilter bit + std::unordered_map pfb_map; // map track.globalIndex -> prefilter bit for (auto& collision : collisions) { - auto bc = collision.template bc_as(); + 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; } @@ -908,11 +949,11 @@ struct associateAmbiguousElectron { 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. + for (auto& amb_ele : electrons_with_same_trackId) { + if (amb_ele.globalIndex() == electron.globalIndex()) { // don't store myself. continue; } - ambele_self_Ids.emplace_back(amp_ele.globalIndex()); + ambele_self_Ids.emplace_back(amb_ele.globalIndex()); } em_amb_ele_ids(ambele_self_Ids); ambele_self_Ids.clear(); diff --git a/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx b/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx index 2ff2cf1077b..fc46cf4760e 100644 --- a/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx +++ b/PWGEM/Dilepton/TableProducer/skimmerPrimaryMuon.cxx @@ -21,6 +21,7 @@ #include "Framework/AnalysisDataModel.h" #include "CommonConstants/PhysicsConstants.h" #include "Common/DataModel/CollisionAssociationTables.h" +#include "Common/Core/TableHelper.h" #include "CCDB/BasicCCDBManager.h" #include "DataFormatsParameters/GRPMagField.h" @@ -41,6 +42,9 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::constants::physics; +using MyCollisions = soa::Join; +using MyCollisionsWithSWT = soa::Join; + using MyTracks = soa::Join; // muon tracks are repeated. i.e. not exclusive. using MyTrack = MyTracks::iterator; @@ -51,12 +55,6 @@ using MFTTracksMC = soa::Join; using MFTTrackMC = MFTTracksMC::iterator; struct skimmerPrimaryMuon { - enum class EM_MuMuPairType : int { - kULS = 0, - kLSpp = +1, - kLSnn = -1, - }; - // Index used to set different options for Muon propagation enum class MuonExtrapolation : int { kToVertex = 0, // propagtion to vertex by default @@ -75,19 +73,17 @@ struct skimmerPrimaryMuon { // Configurables Configurable fillQAHistogram{"fillQAHistogram", false, "flag to fill QA histograms"}; - Configurable applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; 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.1, "min pt for track"}; + 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 minRabs{"minRabs", 17.6, "min. R at absorber end"}; Configurable maxRabs{"maxRabs", 89.5, "max. R at absorber end"}; - // Configurable maxPDCA{"maxPDCA", 1e+3, "max. p DCA to reject beam-gas background"}; o2::ccdb::CcdbApi ccdbApi; Service ccdb; @@ -97,7 +93,7 @@ struct skimmerPrimaryMuon { HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; static constexpr std::string_view muon_types[5] = {"MFTMCHMID/", "MFTMCHMIDOtherMatch/", "MFTMCH/", "MCHMID/", "MCH/"}; - void init(InitContext const&) + void init(InitContext&) { ccdb->setURL(ccdburl); ccdb->setCaching(true); @@ -105,7 +101,6 @@ struct skimmerPrimaryMuon { ccdb->setFatalWhenNull(false); ccdbApi.init(ccdburl); - o2::mch::TrackExtrap::setField(); addHistograms(); mRunNumber = 0; @@ -170,7 +165,6 @@ struct skimmerPrimaryMuon { { 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); - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(track, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); float p = propmuonAtPV.getP(); float pt = propmuonAtPV.getPt(); @@ -194,6 +188,7 @@ struct skimmerPrimaryMuon { 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); @@ -220,47 +215,24 @@ struct skimmerPrimaryMuon { dcaXYinSigma = std::sqrt(std::abs(chi2) / 2.); // in sigma } - if (fillQAHistogram) { - 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 - bool isGlobalMuon(TTrack const& track) - { - if (track.trackType() != static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { - return false; - } - if (track.eta() < mineta_mft || maxeta_mft < track.eta()) { - return false; - } - return true; - } - - template - bool isStandaloneMuon(TTrack const& track) - { - if (track.trackType() != static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { - return false; - } - return true; + 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 @@ -268,9 +240,9 @@ struct skimmerPrimaryMuon { { 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()}; + 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; @@ -307,6 +279,10 @@ struct skimmerPrimaryMuon { propmuon.setZ(fwdtrack.getZ()); propmuon.setCovariances(fwdtrack.getCovariances()); } + + v1.clear(); + v1.shrink_to_fit(); + return propmuon; } @@ -320,13 +296,15 @@ struct skimmerPrimaryMuon { } o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToVertex); - o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToDCA); - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); - // float pt = propmuonAtPV.getPt(); + float pt = propmuonAtPV.getPt(); float eta = propmuonAtPV.getEta(); float phi = propmuonAtPV.getPhi(); + if (pt < minpt) { + return false; + } + if (eta < mineta || maxeta < eta) { return false; } @@ -345,6 +323,7 @@ struct skimmerPrimaryMuon { return false; } } else 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 @@ -363,7 +342,6 @@ struct skimmerPrimaryMuon { { o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToVertex); o2::dataformats::GlobalFwdTrack propmuonAtDCA = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToDCA); - o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, skimmerPrimaryMuon::MuonExtrapolation::kToRabs); float pt = propmuonAtPV.getPt(); float eta = propmuonAtPV.getEta(); @@ -376,6 +354,7 @@ struct skimmerPrimaryMuon { float rAtAbsorberEnd = muon.rAtAbsorberEnd(); 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 @@ -424,19 +403,17 @@ struct skimmerPrimaryMuon { // Preslice fwdtrackIndicesPerMFTsa = aod::fwdtrack::matchMFTTrackId; - // Filter muonFilter = (o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) || o2::aod::fwdtrack::trackType == uint8_t(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)); - // using MyFilteredTracks = soa::Filtered; - + 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 - void processRec_SA(Join const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&) + void processRec_SA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&) { for (auto& collision : collisions) { - auto bc = collision.bc_as(); + auto bc = collision.template foundBC_as(); initCCDB(bc); fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); - 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; } @@ -447,18 +424,18 @@ struct skimmerPrimaryMuon { int offset = emprimarymuons.lastIndex() + 1; for (auto& track : sa_muons_per_coll) { - fillTrackHistogram<3>(track, collision); - // fRegistry.fill(HIST("Track/MCHMID/hNclustersMFT"), 0); - + 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) { - fillTrackHistogram<0>(track, collision); - // auto mftsa_track = track.template matchMFTTrack_as(); - // fRegistry.fill(HIST("Track/MFTMCHMID/hNclustersMFT"), mftsa_track.nClusters()); + 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; @@ -489,14 +466,13 @@ struct skimmerPrimaryMuon { } PROCESS_SWITCH(skimmerPrimaryMuon, processRec_SA, "process reconstructed info only with standalone", true); - Preslice fwdtrackIndicesPerCollision = aod::track_association::collisionId; - void processRec_TTCA(Join const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) + void processRec_TTCA(MyCollisions const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { - auto bc = collision.bc_as(); + auto bc = collision.template foundBC_as(); initCCDB(bc); fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); - 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; } @@ -508,23 +484,149 @@ struct skimmerPrimaryMuon { 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 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)) { - fillTrackHistogram<3>(track, collision); - // fRegistry.fill(HIST("Track/MCHMID/hNclustersMFT"), 0); - + 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++; + } + } + } // 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())]); + } + } + + map_new_sa_muon_index.clear(); + } // end of collision loop + } + PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA, "process reconstructed info only with TTCA", false); + + void processRec_SA_SWT(MyCollisionsWithSWT const& collisions, aod::BCsWithTimestamps const&, MyTracks const& tracks, aod::MFTTracks const&) + { + for (auto& collision : collisions) { + auto bc = collision.template foundBC_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); - // auto mftsa_track = track.template matchMFTTrack_as(); - // fRegistry.fill(HIST("Track/MFTMCHMID/hNclustersMFT"), mftsa_track.nClusters()); + } + + 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())]); + } + } + + map_new_sa_muon_index.clear(); + } // end of collision loop + } + 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) + { + for (auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); + if (!collision.isSelected()) { + continue; + } + if (collision.swtaliastmp_raw() == 0) { + 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++; @@ -551,21 +653,21 @@ struct skimmerPrimaryMuon { map_new_sa_muon_index.clear(); } // end of collision loop } - PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA, "process reconstructed info only with TTCA", false); + PROCESS_SWITCH(skimmerPrimaryMuon, processRec_TTCA_SWT, "process reconstructed info only with TTCA", 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, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, MFTTracksMC const&) { for (auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } - auto bc = collision.bc_as(); + auto bc = collision.template foundBC_as(); initCCDB(bc); fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); - 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; } @@ -576,9 +678,9 @@ struct skimmerPrimaryMuon { int offset = emprimarymuons.lastIndex() + 1; for (auto& track : sa_muons_mc_per_coll) { - fillTrackHistogram<3>(track, collision); - // fRegistry.fill(HIST("Track/MCHMID/hNclustersMFT"), 0); - + 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++; @@ -589,10 +691,9 @@ struct skimmerPrimaryMuon { if (!sa_muon.has_mcParticle()) { continue; } - fillTrackHistogram<0>(track, collision); - // auto mftsa_track = track.template matchMFTTrack_as(); - // fRegistry.fill(HIST("Track/MFTMCHMID/hNclustersMFT"), mftsa_track.nClusters()); - + 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++; @@ -622,16 +723,16 @@ struct skimmerPrimaryMuon { } 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, aod::BCsWithTimestamps const&, MyTracksMC const& tracks, MFTTracksMC const&, aod::FwdTrackAssoc const& fwdtrackIndices) { for (auto& collision : collisions) { if (!collision.has_mcCollision()) { continue; } - auto bc = collision.bc_as(); + auto bc = collision.template foundBC_as(); initCCDB(bc); fRegistry.fill(HIST("Event/hCollisionCounter"), 0.f); - 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; } @@ -644,9 +745,9 @@ struct skimmerPrimaryMuon { // 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)) { - fillTrackHistogram<3>(track, collision); - // fRegistry.fill(HIST("Track/MCHMID/hNclustersMFT"), 0); - + 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++; @@ -656,10 +757,9 @@ struct skimmerPrimaryMuon { if (!sa_muon.has_mcParticle()) { continue; } - fillTrackHistogram<0>(track, collision); - // auto mftsa_track = mftsatracks.iteratorAt(track.matchMFTTrackId()); - // fRegistry.fill(HIST("Track/MFTMCHMID/hNclustersMFT"), mftsa_track.nClusters()); - + 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++; diff --git a/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx b/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx new file mode 100644 index 00000000000..1790c89c052 --- /dev/null +++ b/PWGEM/Dilepton/TableProducer/skimmerSecondaryElectron.cxx @@ -0,0 +1,621 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "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(), 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 c1413a8aa68..41e9e58209c 100644 --- a/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx +++ b/PWGEM/Dilepton/TableProducer/treeCreatorElectronML.cxx @@ -14,6 +14,9 @@ // 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" @@ -37,6 +40,7 @@ #include "CCDB/BasicCCDBManager.h" #include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" using namespace o2; using namespace o2::framework; @@ -64,10 +68,9 @@ DECLARE_SOA_COLUMN(MCPosY, mcposY, float); //! DECLARE_SOA_COLUMN(MCPosZ, mcposZ, float); //! } // namespace mycollision DECLARE_SOA_TABLE(MyCollisions, "AOD", "MYCOLLISION", //! vertex information of collision - o2::soa::Index<>, bc::GlobalBC, bc::RunNumber, collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, evsel::Sel8, mycollision::Bz, - mccollision::GeneratorsID, mycollision::MCPosX, mycollision::MCPosY, mycollision::MCPosZ, - mult::MultTPC, mult::MultFV0A, mult::MultFV0C, mult::MultFT0A, mult::MultFT0C, - mult::MultFDDA, mult::MultFDDC, mult::MultZNA, mult::MultZNC, mult::MultTracklets, mult::MultNTracksPV, mult::MultNTracksPVeta1); + o2::soa::Index<>, bc::GlobalBC, bc::RunNumber, collision::PosX, collision::PosY, collision::PosZ, collision::NumContrib, evsel::NumTracksInTimeRange, evsel::SumAmpFT0CInTimeRange, evsel::Sel8, mycollision::Bz, + mccollision::GeneratorsID, mycollision::MCPosX, mycollision::MCPosY, mycollision::MCPosZ, mult::MultNTracksPV, + cent::CentFT0M, cent::CentFT0A, cent::CentFT0C); using MyCollision = MyCollisions::iterator; namespace mytrack @@ -89,14 +92,13 @@ DECLARE_SOA_COLUMN(MotherPdgCodes, motherpdgCodes, std::vector); //! eta va // reconstructed track information DECLARE_SOA_TABLE(MyTracks, "AOD", "MYTRACK", //! o2::soa::Index<>, mytrack::MyCollisionId, mytrack::Sign, - track::Pt, track::Eta, track::Phi, + track::Pt, track::Eta, track::Phi, track::Tgl, 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::TOFChi2, track::ITSChi2NCl, track::ITSClusterSizes, - track::TRDSignal, track::TRDPattern, mytrack::MCVx, mytrack::MCVy, mytrack::MCVz, mcparticle::PdgCode, mytrack::IsPhysicalPrimary, mytrack::MotherIds, mytrack::MotherPdgCodes); @@ -132,7 +134,7 @@ DECLARE_SOA_TABLE(MyPairs, "AOD", "MYPAIR", //! mypair::Mass, mypair::Pt, mypair::Eta, mypair::Phi, mypair::PhiV, mypair::PairDCAxy, mypair::PairDCAz, mypair::CosOpAng, mypair::CosPA, mypair::Lxy, mypair::Chi2PCA, mypair::IsSM, mypair::IsHF, mypair::PairType, mypair::IsPrompt, - mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, + mcparticle::PdgCode, mcparticle::Flags, mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, // dynamic column @@ -163,7 +165,7 @@ struct TreeCreatorElectronML { HistogramRegistry registry{ "registry", { - {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{5, 0.5f, 5.5f}}}}, + {"hEventCounter", "hEventCounter", {HistType::kTH1F, {{2, 0.f, 2.f}}}}, }, }; @@ -180,6 +182,11 @@ struct TreeCreatorElectronML { Configurable d_UseWeightedPCA{"d_UseWeightedPCA", false, "Vertices use cov matrices"}; Configurable useMatCorrType{"useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; + // collision + Configurable maxVtxZ{"maxVtxZ", 10.0, "max VtxZ [cm]"}; + Configurable maxTrackOccupancy{"maxTrackOccupancy", 999999, "max. track occupancy"}; + Configurable maxFT0Occupancy{"maxFT0Occupancy", 999999, "max. FT0 occupancy"}; + // track Configurable mincrossedrows{"mincrossedrows", 70, "min. crossed rows"}; Configurable mintpcclusters{"mintpcclusters", 90, "min. tpc clusters"}; @@ -189,8 +196,8 @@ struct TreeCreatorElectronML { Configurable minpt{"minpt", 0.2, "min. pT"}; Configurable maxDcaZ{"maxDcaZ", 1.0, "max DCA Z"}; Configurable maxDcaXY{"maxDcaXY", 1.0, "max DCA XY"}; - Configurable minITSClusters{"minITSLayers", 5, "min. of ITS clusters"}; - Configurable minITSClustersIB{"minITSClustersIB", 3, "min. number of ITS clusters in inner barrel"}; + Configurable minITSClusters{"minITSLayers", 5, "min. of ITS clusters"}; + Configurable minITSClustersIB{"minITSClustersIB", 3, "min. number of ITS clusters in inner barrel"}; Configurable downSampleEl{"downSampleEl", 1.0, "down scaling factor for electrons"}; Configurable downSamplePi{"downSamplePi", 1.0, "down scaling factor for pions"}; Configurable downSampleKa{"downSampleKa", 1.0, "down scaling factor for kaons"}; @@ -198,6 +205,10 @@ struct TreeCreatorElectronML { Configurable downSampleMu{"downSampleMu", 1.0, "down scaling factor for muons"}; Configurable downSampleNucl{"downSampleNucl", 1.0, "down scaling factor for nuclei"}; + // pid + Configurable maxNSigmaElTPC{"maxNSigmaElTPC", 999, "max nsigma_el for TPC"}; + Configurable maxNSigmaElTOF{"maxNSigmaElTOF", 999, "max nsgima_el for TOF (if available)"}; + // pair Configurable minPairPt{"minPairPt", 0.2, "min. pT,ee"}; Configurable minMass{"minMass", 0.0, "min. pair invariant mass"}; @@ -257,7 +268,8 @@ struct TreeCreatorElectronML { fitter.setMatCorrType(matCorr); } - void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + template + void initCCDB(TBC const& bc) { if (mRunNumber == bc.runNumber()) { return; @@ -306,102 +318,6 @@ struct TreeCreatorElectronML { } } - template - float get_phiv(TTrack const& t1, TTrack const& t2) - { - // cos(phiv) = w*a /|w||a| - // with w = u x v - // and a = u x z / |u x z| , unit vector perpendicular to v12 and z-direction (magnetic field) - // u = v12 / |v12| , the unit vector of v12 - // v = v1 x v2 / |v1 x v2| , unit vector perpendicular to v1 and v2 - - // float bz = fgFitterTwoProngBarrel.getBz(); - - 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; - - bool swapTracks = false; - if (v1.Pt() < v2.Pt()) { // ordering of track, pt1 > pt2 - ROOT::Math::PtEtaPhiMVector v3 = v1; - v1 = v2; - v2 = v3; - swapTracks = true; - } - - // momentum of e+ and e- in (ax,ay,az) axis. Note that az=0 by definition. - // vector product of pep X pem - float vpx = 0, vpy = 0, vpz = 0; - if (t1.sign() * t2.sign() > 0) { // Like Sign - if (!swapTracks) { - if (d_bz * t1.sign() < 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } else { // swaped tracks - if (d_bz * t2.sign() < 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } - } else { // Unlike Sign - if (!swapTracks) { - if (d_bz * t1.sign() > 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } else { // swaped tracks - if (d_bz * t2.sign() > 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } - } - - // unit vector of pep X pem - float vx = vpx / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - float vy = vpy / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - float vz = vpz / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - - float px = v12.Px(); - float py = v12.Py(); - float pz = v12.Pz(); - - // unit vector of (pep+pem) - float ux = px / TMath::Sqrt(px * px + py * py + pz * pz); - float uy = py / TMath::Sqrt(px * px + py * py + pz * pz); - float uz = pz / TMath::Sqrt(px * px + py * py + pz * pz); - float ax = uy / TMath::Sqrt(ux * ux + uy * uy); - float ay = -ux / TMath::Sqrt(ux * ux + uy * uy); - - // The third axis defined by vector product (ux,uy,uz)X(vx,vy,vz) - float wx = uy * vz - uz * vy; - float wy = uz * vx - ux * vz; - // by construction, (wx,wy,wz) must be a unit vector. Measure angle between (wx,wy,wz) and (ax,ay,0). - // The angle between them should be small if the pair is conversion. This function then returns values close to pi! - return TMath::ACos(wx * ax + wy * ay); // phiv in [0,pi] //cosPhiV = wx * ax + wy * ay; - } - template int FindCommonMotherFrom2Prongs(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcparticles) { @@ -466,6 +382,15 @@ struct TreeCreatorElectronML { if (track.itsNClsInnerBarrel() < minITSClustersIB) { return false; } + + if (fabs(track.tpcNSigmaEl()) > maxNSigmaElTPC) { + return false; + } + if (track.hasTOF()) { + if (fabs(track.tofNSigmaEl()) > maxNSigmaElTOF) { + return false; + } + } return true; } @@ -516,18 +441,14 @@ struct TreeCreatorElectronML { } template - void doPair(TTrack const& t1, TTrack const& t2, int pairtype, TMCParticles const& mctracks, TCollision const& collision, std::map& fNewLabels, std::vector& fSelected_old_labels, int& fCounter) + void doPair(TTrack const& t1, TTrack const& t2, int mc1_id, int mc2_id, int pairtype, TMCParticles const& mctracks, TCollision const& collision, std::map& fNewLabels, std::vector& fSelected_old_labels, int& fCounter, uint64_t collisionId, std::vector& collisions_old_labels, int& collisions_counter) { if (!IsSelected(t1) || !IsSelected(t2)) { return; } - if (!t1.has_mcParticle() || !t2.has_mcParticle()) { - return; - } - - auto mc1 = mctracks.iteratorAt(t1.mcParticleId()); - auto mc2 = mctracks.iteratorAt(t2.mcParticleId()); + auto mc1 = mctracks.iteratorAt(mc1_id); + auto mc2 = mctracks.iteratorAt(mc2_id); if (abs(mc1.pdgCode()) != 11 || abs(mc2.pdgCode()) != 11) { return; @@ -541,7 +462,7 @@ struct TreeCreatorElectronML { return; } - float phiv = get_phiv(t1, t2); + 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 pair_dca_xy = sqrt((pow(t1.dcaXY() / sqrt(t1.cYY()), 2) + pow(t2.dcaXY() / sqrt(t2.cYY()), 2)) / 2.); float pair_dca_z = sqrt((pow(t1.dcaZ() / sqrt(t1.cZZ()), 2) + pow(t2.dcaZ() / sqrt(t2.cZZ()), 2)) / 2.); @@ -557,7 +478,6 @@ struct TreeCreatorElectronML { bool is_prompt = false; int pdgCode = 0; - int statusCode = 0; uint8_t flags = 0; float vx = 0.f; float vy = 0.f; @@ -572,7 +492,6 @@ struct TreeCreatorElectronML { auto mcpair = mctracks.iteratorAt(common_mother_id); is_prompt = true; // only relevant for prompt jpsi pdgCode = mcpair.pdgCode(); - statusCode = mcpair.statusCode(); flags = mcpair.flags(); vx = mcpair.vx(); vy = mcpair.vy(); @@ -617,181 +536,290 @@ struct TreeCreatorElectronML { fSelected_old_labels.push_back(t2.globalIndex()); fCounter++; } - mypair(mycollision.lastIndex(), fNewLabels[t1.globalIndex()], fNewLabels[t2.globalIndex()], + if (find(collisions_old_labels.begin(), collisions_old_labels.end(), collisionId) == collisions_old_labels.end()) { + collisions_counter++; + collisions_old_labels.push_back(collisionId); + } + mypair(collisions_counter, fNewLabels[t1.globalIndex()], fNewLabels[t2.globalIndex()], v12.M(), v12.Pt(), v12.Eta(), v12.Phi(), phiv, pair_dca_xy, pair_dca_z, cosOpAng, cosPA, lxy_proper, pow(pca, 2), - isSM, isHF, pairtype, is_prompt, pdgCode, statusCode, flags, + isSM, isHF, pairtype, is_prompt, pdgCode, flags, vx, vy, vz); } } + template + void doSingleTrack(TTrack& track, TMCParticle& mctrack, TMCParticles& mctracks, uint64_t collisionId, std::vector& collisions_old_labels, int& collisions_counter, bool use_downsample = true) + { + if (!IsSelected(track)) { + return; + } + + if ((!use_downsample) || (downSample(abs(mctrack.pdgCode())))) { + // store all mother relation + std::vector mothers_id; + std::vector mothers_pdg; + if (mctrack.has_mothers()) { + int 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); + mothers_id.emplace_back(motherid); + mothers_pdg.emplace_back(mp.pdgCode()); + + if (mp.has_mothers()) { + motherid = mp.mothersIds()[0]; + } else { + motherid = -999; + } + } else { + LOGF(info, "Mother label(%d) exceeds the McParticles size(%d)", motherid, mctracks.size()); + } + } + } + if (find(collisions_old_labels.begin(), collisions_old_labels.end(), collisionId) == collisions_old_labels.end()) { + collisions_counter++; + collisions_old_labels.push_back(collisionId); + } + mytrack(collisions_counter, + 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.tofChi2(), track.itsChi2NCl(), track.itsClusterSizes(), + mctrack.vx(), mctrack.vy(), mctrack.vz(), + mctrack.pdgCode(), mctrack.isPhysicalPrimary(), mothers_id, mothers_pdg); + + mothers_id.shrink_to_fit(); + mothers_pdg.shrink_to_fit(); + } + } + + template + void doCollision(TCollision& collision, TMCCollision& mccollision, uint64_t globalBC, int runNumber) + { + registry.fill(HIST("hEventCounter"), 1.5); + mycollision(globalBC, runNumber, collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange(), collision.sel8(), d_bz, + mccollision.generatorsID(), mccollision.posX(), mccollision.posY(), mccollision.posZ(), + collision.multNTracksPV(), collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); + } + + template + void doCollision(TCollision& collision, TBC& bc, TMCCollision& mccollision) + { + doCollision(collision, mccollision, bc.globalBC(), bc.runNumber()); + } + Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& o2::aod::track::itsChi2NCl < maxchi2its&& o2::aod::track::tpcChi2NCl < maxchi2tpc&& nabs(o2::aod::track::dcaXY) < maxDcaXY&& nabs(o2::aod::track::dcaZ) < maxDcaZ; using MyFilteredTracksMC = soa::Filtered; Preslice perCollision = aod::track::collisionId; - void processSingleTrack(soa::Join const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::McParticles const& mctracks, aod::McCollisions const&) + Filter collisionFilter = nabs(o2::aod::collision::posZ) < maxVtxZ && o2::aod::evsel::trackOccupancyInTimeRange < maxTrackOccupancy && o2::aod::evsel::ft0cOccupancyInTimeRange < maxFT0Occupancy; + using MyFilteredCollisions = soa::Filtered>; + + void processSingleTrack(MyFilteredCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::McParticles const& mctracks, aod::McCollisions const&) { + int collisions_counter = -1; + std::vector collisions_old_labels; + for (auto& collision : collisions) { - // TODO: investigate the collisions without corresponding mcCollision if (!collision.has_mcCollision()) { continue; } - - registry.fill(HIST("hEventCounter"), 1.0); // all - - auto bc = collision.bc_as(); - auto mccollision = collision.mcCollision(); - mycollision(bc.globalBC(), bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.sel8(), d_bz, - mccollision.generatorsID(), mccollision.posX(), mccollision.posY(), mccollision.posZ(), - collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), - collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), collision.multNTracksPVeta1()); + registry.fill(HIST("hEventCounter"), 0.5); auto tracks_coll = tracks.sliceBy(perCollision, collision.globalIndex()); for (auto& track : tracks_coll) { - - if (!IsSelected(track)) { - continue; - } - if (!track.has_mcParticle()) { - continue; // If no MC particle is found, skip the track + continue; } auto mctrack = track.mcParticle_as(); + doSingleTrack(track, mctrack, mctracks, collision.globalIndex(), collisions_old_labels, collisions_counter); + } + } - // store all mother relation - std::vector mothers_id; - std::vector mothers_pdg; - if (mctrack.has_mothers()) { - int 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); - mothers_id.emplace_back(motherid); - mothers_pdg.emplace_back(mp.pdgCode()); - - if (mp.has_mothers()) { - motherid = mp.mothersIds()[0]; - } else { - motherid = -999; - } - } else { - LOGF(info, "Mother label(%d) exceeds the McParticles size(%d)", motherid, mctracks.size()); - } - } - } + for (uint64_t collision_label : collisions_old_labels) { + auto collision = collisions.rawIteratorAt(collision_label); + auto bc = collision.bc_as(); + auto mccollision = collision.mcCollision(); + doCollision(collision, bc, mccollision); + } + } + PROCESS_SWITCH(TreeCreatorElectronML, processSingleTrack, "produce ML input for single track level", false); + + using MyFilteredCollisionsSkimmed = soa::Filtered>; + using MyFilteredTracksMCSkimmed = soa::Filtered>; + Preslice perCollisionSkimmed = aod::emprimaryelectron::emeventId; - if (downSample(abs(mctrack.pdgCode()))) { - mytrack(mycollision.lastIndex(), - track.sign(), track.pt(), track.eta(), track.phi(), 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.tofChi2(), track.itsChi2NCl(), track.itsClusterSizes(), - track.trdSignal(), track.trdPattern(), - mctrack.vx(), mctrack.vy(), mctrack.vz(), - mctrack.pdgCode(), mctrack.isPhysicalPrimary(), mothers_id, mothers_pdg); + void processSingleTrackSkimmed(MyFilteredCollisionsSkimmed const& collisions, MyFilteredTracksMCSkimmed const& tracks, aod::EMMCParticles const& mctracks, aod::EMMCEvents const&) + { + int collisions_counter = -1; + std::vector collisions_old_labels; + + for (auto& collision : collisions) { + if (!collision.has_emmcevent()) { + continue; + } + registry.fill(HIST("hEventCounter"), 0.5); + + auto tracks_coll = tracks.sliceBy(perCollisionSkimmed, collision.globalIndex()); + for (auto& track : tracks_coll) { + if (!track.has_emmcparticle()) { + continue; } - mothers_id.shrink_to_fit(); - mothers_pdg.shrink_to_fit(); + auto mctrack = track.emmcparticle_as(); + doSingleTrack(track, mctrack, mctracks, collision.globalIndex(), collisions_old_labels, collisions_counter); + } + } - } // end of track loop - } // end of collision loop - } // end of process - PROCESS_SWITCH(TreeCreatorElectronML, processSingleTrack, "produce ML input for single track level", false); + for (uint64_t collision_label : collisions_old_labels) { + auto collision = collisions.rawIteratorAt(collision_label); + auto mccollision = collision.emmcevent(); + doCollision(collision, mccollision, collision.globalBC(), collision.runNumber()); + } + } + PROCESS_SWITCH(TreeCreatorElectronML, processSingleTrackSkimmed, "produce ML input for single track level on skimmed data", false); Partition posTracks = o2::aod::track::signed1Pt > 0.f; Partition negTracks = o2::aod::track::signed1Pt < 0.f; - void processPair(soa::Join const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::McParticles const& mctracks, aod::McCollisions const&) + void processPair(MyFilteredCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredTracksMC const& tracks, aod::McParticles const& mctracks, aod::McCollisions const&) { std::map fNewLabels; int fCounter = 0; + std::vector collisions_old_labels; + int collisions_counter = -1; + for (auto& collision : collisions) { - std::vector fSelected_old_labels; - // TODO: investigate the collisions without corresponding mcCollision if (!collision.has_mcCollision()) { continue; } + registry.fill(HIST("hEventCounter"), 0.5); auto bc = collision.bc_as(); - auto mccollision = collision.mcCollision(); initCCDB(bc); - - registry.fill(HIST("hEventCounter"), 1.0); // all - - mycollision(bc.globalBC(), bc.runNumber(), collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), collision.sel8(), d_bz, - mccollision.generatorsID(), mccollision.posX(), mccollision.posY(), mccollision.posZ(), - collision.multTPC(), collision.multFV0A(), collision.multFV0C(), collision.multFT0A(), collision.multFT0C(), - collision.multFDDA(), collision.multFDDC(), collision.multZNA(), collision.multZNC(), collision.multTracklets(), collision.multNTracksPV(), collision.multNTracksPVeta1()); + std::vector fSelected_old_labels; auto negTracks_coll = negTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); auto posTracks_coll = posTracks->sliceByCached(o2::aod::track::collisionId, collision.globalIndex(), cache); for (auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(negTracks_coll, posTracks_coll))) { - doPair(pos, ele, EM_EEPairType::kULS, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter); + if (!ele.has_mcParticle() || !pos.has_mcParticle()) { + continue; + } + doPair(pos, ele, pos.mcParticleId(), ele.mcParticleId(), EM_EEPairType::kULS, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); } if (!doLS) { continue; } for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_coll, posTracks_coll))) { - doPair(pos1, pos2, EM_EEPairType::kLSpp, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter); + if (!pos1.has_mcParticle() || !pos2.has_mcParticle()) { + continue; + } + doPair(pos1, pos2, pos1.mcParticleId(), pos2.mcParticleId(), EM_EEPairType::kLSpp, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); } for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_coll, negTracks_coll))) { - doPair(ele1, ele2, EM_EEPairType::kLSnn, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter); + if (!ele1.has_mcParticle() || !ele2.has_mcParticle()) { + continue; + } + doPair(ele1, ele2, ele1.mcParticleId(), ele2.mcParticleId(), EM_EEPairType::kLSnn, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); } // single tracks, only if selected in at least one pair for (uint64_t track_label : fSelected_old_labels) { auto track = tracks.rawIteratorAt(track_label); auto mctrack = track.mcParticle_as(); - // store all mother relation - std::vector mothers_id; - std::vector mothers_pdg; - if (mctrack.has_mothers()) { - int 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); - mothers_id.emplace_back(motherid); - mothers_pdg.emplace_back(mp.pdgCode()); - - if (mp.has_mothers()) { - motherid = mp.mothersIds()[0]; - } else { - motherid = -999; - } - } else { - LOGF(info, "Mother label(%d) exceeds the McParticles size(%d)", motherid, mctracks.size()); - } - } - } - - mytrack(mycollision.lastIndex(), - track.sign(), track.pt(), track.eta(), track.phi(), 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.tofChi2(), track.itsChi2NCl(), track.itsClusterSizes(), - track.trdSignal(), track.trdPattern(), - mctrack.vx(), mctrack.vy(), mctrack.vz(), - mctrack.pdgCode(), mctrack.isPhysicalPrimary(), mothers_id, mothers_pdg); - mothers_id.shrink_to_fit(); - mothers_pdg.shrink_to_fit(); + doSingleTrack(track, mctrack, mctracks, collision.globalIndex(), collisions_old_labels, collisions_counter, false); } // end of track loop } // end of collision loop + + for (uint64_t collision_label : collisions_old_labels) { + auto collision = collisions.rawIteratorAt(collision_label); + auto bc = collision.bc_as(); + auto mccollision = collision.mcCollision(); + doCollision(collision, bc, mccollision); + } + fNewLabels.clear(); fCounter = 0; } // end of process PROCESS_SWITCH(TreeCreatorElectronML, processPair, "produce ML input for pair level", false); - void processDummy(soa::Join const&) {} - PROCESS_SWITCH(TreeCreatorElectronML, processDummy, "process dummy", true); + Partition posTracksSkimmed = o2::aod::emprimaryelectron::sign > static_cast(0); + Partition negTracksSkimmed = o2::aod::emprimaryelectron::sign < static_cast(0); + + void processPairSkimmed(MyFilteredCollisionsSkimmed const& collisions, MyFilteredTracksMCSkimmed const& tracks, aod::EMMCParticles const& mctracks, aod::EMMCEvents const&) + { + std::map fNewLabels; + int fCounter = 0; + + std::vector collisions_old_labels; + int collisions_counter = -1; + std::vector collisions_old_labels_track = {}; + int collisions_counter_track = -1; + + for (auto& collision : collisions) { + if (!collision.has_emmcevent()) { + continue; + } + registry.fill(HIST("hEventCounter"), 0.5); + + initCCDB(collision); + std::vector fSelected_old_labels; + + auto negTracks_coll = negTracksSkimmed->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto posTracks_coll = posTracksSkimmed->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + for (auto& [ele, pos] : combinations(CombinationsFullIndexPolicy(negTracks_coll, posTracks_coll))) { + if (!ele.has_emmcparticle() || !pos.has_emmcparticle()) { + continue; + } + doPair(pos, ele, pos.emmcparticleId(), ele.emmcparticleId(), EM_EEPairType::kULS, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); + } + + if (!doLS) { + continue; + } + for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_coll, posTracks_coll))) { + if (!pos1.has_emmcparticle() || !pos2.has_emmcparticle()) { + continue; + } + doPair(pos1, pos2, pos1.emmcparticleId(), pos2.emmcparticleId(), EM_EEPairType::kLSpp, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); + } + + for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_coll, negTracks_coll))) { + if (!ele1.has_emmcparticle() || !ele2.has_emmcparticle()) { + continue; + } + doPair(ele1, ele2, ele1.emmcparticleId(), ele2.emmcparticleId(), EM_EEPairType::kLSnn, mctracks, collision, fNewLabels, fSelected_old_labels, fCounter, collision.globalIndex(), collisions_old_labels, collisions_counter); + } + + // single tracks, only if selected in at least one pair + for (uint64_t track_label : fSelected_old_labels) { + auto track = tracks.rawIteratorAt(track_label); + auto mctrack = track.emmcparticle_as(); + + doSingleTrack(track, mctrack, mctracks, collision.globalIndex(), collisions_old_labels_track, collisions_counter_track, false); + + } // end of track loop + + } // end of collision loop + + for (uint64_t collision_label : collisions_old_labels) { + auto collision = collisions.rawIteratorAt(collision_label); + auto mccollision = collision.emmcevent(); + doCollision(collision, mccollision, collision.globalBC(), collision.runNumber()); + } + + fNewLabels.clear(); + fCounter = 0; + } // end of process + PROCESS_SWITCH(TreeCreatorElectronML, processPairSkimmed, "produce ML input for pair level on skimmed data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx b/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx index a3f25e08021..2e5e0164aec 100644 --- a/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx +++ b/PWGEM/Dilepton/TableProducer/treeCreatorElectronMLDDA.cxx @@ -469,7 +469,7 @@ struct TreeCreatorElectronMLDDA { 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.detectorMap(), pidlabel, tracktype); + track.itsClusterSizes(), track.itsChi2NCl(), track.tofChi2(), track.detectorMap(), pidlabel, tracktype); stored_trackIds.emplace_back(track.globalIndex()); } } diff --git a/PWGEM/Dilepton/TableProducer/treeCreatorSingleElectronQA.cxx b/PWGEM/Dilepton/TableProducer/treeCreatorSingleElectronQA.cxx deleted file mode 100644 index c775ccc836c..00000000000 --- a/PWGEM/Dilepton/TableProducer/treeCreatorSingleElectronQA.cxx +++ /dev/null @@ -1,416 +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 for dalitz ee analysis to an AO2D.root file. This file is then the only necessary input to perform pcm analysis. -/// \author daiki.sekihata@cern.ch - -#include -#include - -#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 "PWGEM/PhotonMeson/DataModel/gammaTables.h" - -using namespace o2; -using namespace o2::soa; -using namespace o2::framework; -using namespace o2::framework::expressions; - -using MyBCs = soa::Join; - -using MyCollisions = soa::Join; -using MyCollisions_Cent = soa::Join; // centrality table has dependency on multiplicity table. - -using MyCollisionsMC = soa::Join; -using MyCollisionsMC_Cent = soa::Join; // centrality table has dependency on multiplicity table. - -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; -using MyTracksMC = soa::Join; -using MyTrackMC = MyTracksMC::iterator; - -struct TreeCreatorSingleElectronQA { - - Produces event; - Produces event_mult; - Produces event_cent; - Produces emprimaryelectrons; - Produces prmeleventid; - - // 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 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 maxchi2tpc{"maxchi2tpc", 5.0, "max. chi2/NclsTPC"}; - Configurable maxchi2its{"maxchi2its", 6.0, "max. chi2/NclsITS"}; - Configurable minpt{"minpt", 0.1, "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 minTPCNsigmaEl{"minTPCNsigmaEl", -1e+10, "min. TPC n sigma for electron inclusion"}; - Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", +1e+10, "max. TPC n sigma for electron inclusion"}; - Configurable minTPCNsigmaPi{"minTPCNsigmaPi", 0.0, "min. TPC n sigma for pion exclusion"}; - Configurable maxTPCNsigmaPi{"maxTPCNsigmaPi", 0.0, "max. TPC n sigma for pion exclusion"}; - Configurable down_scaling{"down_scaling", 1e-3, "down scaling factor to store charged particles"}; - - 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; - - HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - std::mt19937 engine; - std::uniform_real_distribution dist01; - - void init(InitContext&) - { - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - addHistograms(); - std::random_device seed_gen; - engine = std::mt19937(seed_gen()); - dist01 = std::uniform_real_distribution(0.0f, 1.0f); - } - - void addHistograms() - { - fRegistry.add("hCollisionCounter", "collision counter", kTH1F, {{2, -0.5f, 1.5}}, false); - // for track info - fRegistry.add("Track/positive/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/positive/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/positive/hPtPhi", "pT vs. #varphi;#varphi (rad.);p_{T} (GeV/c)", kTH2F, {{360, 0, 2 * M_PI}, {1000, 0.0f, 10.f}}, false); - fRegistry.add("Track/positive/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{360, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, 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, {{1000, 0, 10}, {100, 0., 1000}}, false); - fRegistry.add("Track/positive/hDCAzRes_Pt", "DCA_{z} resolution vs. pT;p_{T} (GeV/c);DCA_{z} resolution (#mum)", kTH2F, {{1000, 0, 10}, {100, 0., 1000}}, 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/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/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_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {600, 0, 1.2}}, false); - fRegistry.add("Track/positive/h1OverTOFbeta", "1/TOF beta;p_{in} (GeV/c);1/#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, false); - fRegistry.add("Track/positive/hTOFNsigmaEl", "TOF n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaMu", "TOF n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/positive/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, 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/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/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.addClone("Track/positive/", "Track/negative/"); - } - - template - void initCCDB(TBC 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.pt() < minpt || abs(track.eta()) > maxeta) { - 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 (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { - return false; - } - if (minTPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < maxTPCNsigmaPi) { - return false; - } - - return true; - } - - template - void fillTrackHistograms(TTrack const& track) - { - if (track.sign() > 0) { - fRegistry.fill(HIST("Track/positive/hPt"), track.pt()); - fRegistry.fill(HIST("Track/positive/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/positive/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/positive/hPtPhi"), track.phi(), 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/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/positive/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/positive/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/positive/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/positive/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/positive/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/positive/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/positive/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/positive/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - 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/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/hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/positive/h1OverTOFbeta"), track.tpcInnerParam(), 1.f / track.beta()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/positive/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - } else { - fRegistry.fill(HIST("Track/negative/hPt"), track.pt()); - fRegistry.fill(HIST("Track/negative/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/negative/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/negative/hPtPhi"), track.phi(), 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/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/negative/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/negative/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/negative/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/negative/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/negative/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/negative/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/negative/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/negative/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - 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/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/hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/negative/h1OverTOFbeta"), track.tpcInnerParam(), 1.f / track.beta()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/negative/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - } - } - - template - void fillTrackTable(TTrack const& track) - { - emprimaryelectrons(track.collisionId(), 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.tpcNSigmaMu(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), - track.beta(), track.tofNSigmaEl(), track.tofNSigmaMu(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.itsClusterSizes(), track.itsChi2NCl(), track.detectorMap(), track.x(), track.alpha(), track.y(), track.z(), track.snp(), track.tgl(), true); - } - - SliceCache cache; - Preslice perCollision_track = o2::aod::track::collisionId; - PresliceUnsorted preslice_collisions_per_bc = o2::aod::evsel::foundBCId; - std::unordered_map map_ncolls_per_bc; - - Filter trackFilter = o2::aod::track::pt > minpt&& nabs(o2::aod::track::eta) < maxeta&& nabs(o2::aod::track::dcaXY) < dca_xy_max&& nabs(o2::aod::track::dcaZ) < dca_z_max&& 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) && (o2::aod::pidtpc::tpcNSigmaPi < minTPCNsigmaPi || maxTPCNsigmaPi < o2::aod::pidtpc::tpcNSigmaPi); - using MyFilteredTracks = soa::Filtered; - - // ---------- for data ---------- - void processRec(MyCollisions_Cent const& collisions, MyBCs const& bcs, MyFilteredTracks const& tracks) - { - for (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(); - } - - for (auto& collision : collisions) { - auto bc = collision.bc_as(); - initCCDB(bc); - - fRegistry.fill(HIST("hCollisionCounter"), 0.f); - if (dist01(engine) > down_scaling) { - continue; - } - fRegistry.fill(HIST("hCollisionCounter"), 1.f); - - 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()); - event_mult(collision.multFT0A(), collision.multFT0C(), collision.multTPC(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV()); - - auto tracks_per_collision = tracks.sliceBy(perCollision_track, collision.globalIndex()); - - for (auto& track : tracks_per_collision) { - if (!checkTrack(track)) { - continue; - } - fillTrackTable(track); - prmeleventid(event.lastIndex()); - fillTrackHistograms(track); - } // end of track loop - - } // end of collision loop - } - PROCESS_SWITCH(TreeCreatorSingleElectronQA, processRec, "process reconstructed info only", true); // standalone - - // ---------- for MC ---------- - using MyFilteredTracksMC = soa::Filtered; - void processMC(MyCollisionsMC_Cent const& collisions, aod::McCollisions const&, MyBCs const& bcs, MyFilteredTracksMC const& tracks) - { - for (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(); - } - - for (auto& collision : collisions) { - if (!collision.has_mcCollision()) { - continue; - } - auto bc = collision.bc_as(); - initCCDB(bc); - - fRegistry.fill(HIST("hCollisionCounter"), 0.f); - if (dist01(engine) > down_scaling) { - continue; - } - fRegistry.fill(HIST("hCollisionCounter"), 1.f); - - 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()); - event_mult(collision.multFT0A(), collision.multFT0C(), collision.multTPC(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV()); - - auto tracks_per_collision = tracks.sliceBy(perCollision_track, collision.globalIndex()); - - for (auto& track : tracks_per_collision) { - if (!checkTrack(track)) { - continue; - } - fillTrackTable(track); - prmeleventid(event.lastIndex()); - fillTrackHistograms(track); - } // end of track loop - - } // end of collision loop - } - PROCESS_SWITCH(TreeCreatorSingleElectronQA, processMC, "process reconstructed and MC info ", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"tree-creator-single-electron-qa"}), - }; -} diff --git a/PWGEM/Dilepton/Tasks/CMakeLists.txt b/PWGEM/Dilepton/Tasks/CMakeLists.txt index cd42c389ba1..f84c8513ac9 100644 --- a/PWGEM/Dilepton/Tasks/CMakeLists.txt +++ b/PWGEM/Dilepton/Tasks/CMakeLists.txt @@ -9,15 +9,16 @@ # 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(efficiency-ee SOURCES emEfficiencyEE.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) -o2physics_add_executable(lmee-lf-cocktail +o2physics_add_dpl_workflow(lmee-lf-cocktail SOURCES lmeeLFCocktail.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::SimulationDataFormat O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lmee-hf-cocktail @@ -35,39 +36,69 @@ o2physics_add_dpl_workflow(smearing PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(create-resolution-map + SOURCES createResolutionMap.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::GlobalTracking + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(table-reader-barrel SOURCES tableReaderBarrel.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dielectron-qc - SOURCES dielectronQC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(event-qc + SOURCES eventQC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dielectron-qc-mc - SOURCES dielectronQCMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(single-electron-qc + SOURCES singleElectronQC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dimuon-qc - SOURCES dimuonQC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2::GlobalTracking O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(single-electron-qc-mc + SOURCES singleElectronQCMC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(dimuon-qc-mc - SOURCES dimuonQCMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter O2::GlobalTracking O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(vp-pair-qc + SOURCES vpPairQC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(emu-correlation - SOURCES emuCorrelation.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::GlobalTracking O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(vp-pair-qc-mc + SOURCES vpPairQCMC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(emu-correlation-mc - SOURCES emuCorrelationMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::GlobalTracking O2Physics::PWGEMDileptonCore +o2physics_add_dpl_workflow(single-muon-qc + SOURCES singleMuonQC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(single-muon-qc-mc + SOURCES singleMuonQCMC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMDileptonCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dielectron + SOURCES dielectron.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::MLCore O2::DCAFitter 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 + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(dimuon + SOURCES dimuon.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DCAFitter 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 COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(photon-hbt-pcmpcm @@ -85,3 +116,8 @@ o2physics_add_dpl_workflow(photon-hbt-pcmee PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::MLCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(prefilter-dielectron + SOURCES prefilterDielectron.cxx + PUBLIC_LINK_LIBRARIES O2::Framework 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 new file mode 100644 index 00000000000..b4c302a111e --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(event-converter1 + SOURCES eventConverter1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(electron-converter1 + SOURCES electronConverter1.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGEM/Dilepton/Tasks/Converters/electronConverter1.cxx b/PWGEM/Dilepton/Tasks/Converters/electronConverter1.cxx new file mode 100644 index 00000000000..f908b6809b2 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/electronConverter1.cxx @@ -0,0 +1,78 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct electronConverter1 { + Produces track_001; + + void process(aod::EMPrimaryElectrons_000 const& tracks) + { + for (auto& track : tracks) { + track_001(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.itsChi2NCl(), + -1.f, + track.detectorMap(), + track.x(), + track.alpha(), + track.y(), + track.z(), + track.snp(), + track.tgl(), + track.isAssociatedToMPC()); + } // end of track loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"electron-converter1"})}; +} diff --git a/PWGEM/Dilepton/Tasks/Converters/eventConverter1.cxx b/PWGEM/Dilepton/Tasks/Converters/eventConverter1.cxx new file mode 100644 index 00000000000..148ff43bd88 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/Converters/eventConverter1.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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; + +struct eventConverter1 { + Produces event_001; + + void process(aod::EMEvents_000 const& collisions) + { + for (auto& collision : collisions) { + event_001( + collision.globalIndex(), + collision.runNumber(), + collision.globalBC(), + collision.alias_raw(), + collision.selection_raw(), + collision.timestamp(), + collision.posX(), + collision.posY(), + collision.posZ(), + collision.numContrib(), + collision.trackOccupancyInTimeRange(), + -1.f); + } // end of collision loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"event-converter1"})}; +} diff --git a/PWGEM/Dilepton/Tasks/MCtemplates.cxx b/PWGEM/Dilepton/Tasks/MCtemplates.cxx index 5b1bf9548ae..30b60856cb5 100644 --- a/PWGEM/Dilepton/Tasks/MCtemplates.cxx +++ b/PWGEM/Dilepton/Tasks/MCtemplates.cxx @@ -243,13 +243,13 @@ struct AnalysisTrackSelection { if (fConfigQA) { if (fConfigMCTruthGen) { // Add histogram classes for each MC signal at generated level - std::vector mcnamesgen; + // std::vector mcnamesgen; for (int isig = 0; isig < sigNamesArray->GetEntries(); ++isig) { MCSignal* sig = o2::aod::dqmcsignals::GetMCSignal(sigNamesArray->At(isig)->GetName()); if (sig) { if (sig->GetNProngs() == 1) { // NOTE: only 1 prong signals TString nameStr2 = Form("MCTruthGenTrack_%s", sig->GetName()); - mcnamesgen.push_back(nameStr2); + // mcnamesgen.push_back(nameStr2); histClasses += Form("%s;", nameStr2.Data()); // TODO: Add these names to a std::vector to avoid using Form in the process function } } @@ -333,9 +333,9 @@ 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 + } // end runTrackSelection template void runMCGenTrack(TTracksMC const& groupedMCTracks) diff --git a/PWGEM/Dilepton/Tasks/PhotonHBTEEEE.cxx b/PWGEM/Dilepton/Tasks/PhotonHBTEEEE.cxx index c7d7c55cc9b..b26a40af6fc 100644 --- a/PWGEM/Dilepton/Tasks/PhotonHBTEEEE.cxx +++ b/PWGEM/Dilepton/Tasks/PhotonHBTEEEE.cxx @@ -32,7 +32,6 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/Dilepton/Core/PhotonHBT.h" using namespace o2; @@ -41,5 +40,5 @@ using namespace o2::aod; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-eeee"})}; + adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-eeee"})}; } diff --git a/PWGEM/Dilepton/Tasks/PhotonHBTPCMEE.cxx b/PWGEM/Dilepton/Tasks/PhotonHBTPCMEE.cxx index 89e524c9f2d..3e792f9d27a 100644 --- a/PWGEM/Dilepton/Tasks/PhotonHBTPCMEE.cxx +++ b/PWGEM/Dilepton/Tasks/PhotonHBTPCMEE.cxx @@ -32,7 +32,6 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/Dilepton/Core/PhotonHBT.h" using namespace o2; @@ -41,5 +40,5 @@ using namespace o2::aod; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-pcmee"})}; + adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-pcmee"})}; } diff --git a/PWGEM/Dilepton/Tasks/PhotonHBTPCMPCM.cxx b/PWGEM/Dilepton/Tasks/PhotonHBTPCMPCM.cxx index 7c974b9a8a2..ddcbe423eae 100644 --- a/PWGEM/Dilepton/Tasks/PhotonHBTPCMPCM.cxx +++ b/PWGEM/Dilepton/Tasks/PhotonHBTPCMPCM.cxx @@ -32,7 +32,6 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" -#include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/Dilepton/Core/PhotonHBT.h" using namespace o2; @@ -41,5 +40,5 @@ using namespace o2::aod; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-pcmpcm"})}; + adaptAnalysisTask>(cfgc, TaskName{"photon-hbt-pcmpcm"})}; } diff --git a/PWGEM/Dilepton/Tasks/createResolutionMap.cxx b/PWGEM/Dilepton/Tasks/createResolutionMap.cxx new file mode 100644 index 00000000000..bfcf7e4f8f4 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/createResolutionMap.cxx @@ -0,0 +1,407 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// +// Analysis task to produce resolution mapfor electrons/muons in dilepton analysis +// Please write to: daiki.sekihata@cern.ch + +#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 "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "TGeoGlobalMagField.h" +#include "Field/MagneticField.h" + +#include "DetectorsBase/Propagator.h" +#include "GlobalTracking/MatchGlobalFwd.h" +#include "MCHTracking/TrackExtrap.h" +#include "MCHTracking/TrackParam.h" +#include "ReconstructionDataFormats/TrackFwd.h" + +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 MyMCTracks = soa::Join; +using MyMCTrack = MyMCTracks::iterator; + +using MyMCFwdTracks = soa::Join; +using MyMCFwdTrack = MyMCFwdTracks::iterator; + +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 applyEveSel_at_skimming{"applyEveSel_at_skimming", false, "flag to apply minimal event selection at the skimming level"}; + 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 cfgEventGeneratorType{"cfgEventGeneratorType", -1, "if positive, select event generator type. i.e. gap or signal"}; + + struct : ConfigurableGroup { + std::string prefix = "electroncut_group"; + 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", -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_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_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"}; + } 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.0, "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_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_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"}; + } muoncuts; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + o2::globaltracking::MatchGlobalFwd mMatching; + int mRunNumber = 0; + + void init(o2::framework::InitContext&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + ccdbApi.init(ccdburl); + + const AxisSpec axis_pt_gen{{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}, "p_{T,l}^{gen} (GeV/c)"}; + const AxisSpec axis_dpt{400, -1, 1, "(p_{T,l}^{gen.} - p_{T,l}^{rec.})/p_{T,l}^{gen.}"}; + const AxisSpec axis_deta{500, -0.5, +0.5, "#eta_{l}^{gen.} - #eta_{l}^{rec.}"}; + const AxisSpec axis_dphi{500, -0.5, +0.5, "#varphi_{l}^{gen.} - #varphi_{l}^{rec.} (rad.)"}; + + 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/"); + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + + 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); + if (!o2::base::GeometryManager::isGeometryLoaded()) { + ccdb->get(geoPath); + } + o2::mch::TrackExtrap::setField(); + } + + 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) + { + if (track.tpcChi2NCl() > electroncuts.cfg_max_chi2tpc) { + return false; + } + + if (track.itsChi2NCl() > electroncuts.cfg_max_chi2its) { + return false; + } + + if (track.itsNCls() < electroncuts.cfg_min_ncluster_its) { + return false; + } + + auto hits = std::count_if(itsRequirement_ibany.second.begin(), itsRequirement_ibany.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); + if (hits < itsRequirement_ibany.first) { + return false; + } + if (electroncuts.cfg_require_itsib_1st) { + auto hit_ib1st = std::count_if(itsRequirement_ib1st.second.begin(), itsRequirement_ib1st.second.end(), [&](auto&& requiredLayer) { return track.itsClusterMap() & (1 << requiredLayer); }); + if (hit_ib1st < itsRequirement_ib1st.first) { + 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; + } + + return true; + } + + template + o2::dataformats::GlobalFwdTrack PropagateMuon(T const& muon, C const& collision, const CreateResolutionMap::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 == 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; + } + + template + bool checkFwdTrack(TMuon const& muon, TCollision const& collision) + { + o2::dataformats::GlobalFwdTrack propmuonAtPV = PropagateMuon(muon, collision, CreateResolutionMap::MuonExtrapolation::kToVertex); + float pt = propmuonAtPV.getPt(); + float eta = propmuonAtPV.getEta(); + float phi = propmuonAtPV.getPhi(); + + if (pt < muoncuts.cfg_min_pt_track) { + return false; + } + + if (eta < muoncuts.cfg_min_eta_track || muoncuts.cfg_max_eta_track < eta) { + return false; + } + + o2::math_utils::bringTo02Pi(phi); + if (phi < 0.f || 2.f * M_PI < phi) { + return false; + } + + float rAtAbsorberEnd = muon.rAtAbsorberEnd(); + if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + o2::dataformats::GlobalFwdTrack propmuonAtRabs = PropagateMuon(muon, collision, CreateResolutionMap::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 (rAtAbsorberEnd < muoncuts.cfg_min_rabs || muoncuts.cfg_max_rabs < rAtAbsorberEnd) { + return false; + } + + if (rAtAbsorberEnd < 26.5) { + if (muon.pDca() > 594.f) { + return false; + } + } else { + if (muon.pDca() > 324.f) { + return false; + } + } + + if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack) && muon.chi2MatchMCHMFT() > muoncuts.cfg_max_matching_chi2_mftmch) { + return false; + } + + auto mctrack = muon.template mcParticle_as(); + if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack)) { + 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); + } + } else if (muon.trackType() == static_cast(o2::aod::fwdtrack::ForwardTrackTypeEnum::GlobalMuonTrack)) { + 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); + } + } + return true; + } + + 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; + + 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; + + 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 + + void process(MyFilteredCollisions const& collisions, aod::BCsWithTimestamps const&, MyFilteredMCTracks const& tracks, MyMCFwdTracks const&, aod::McCollisions const&, aod::McParticles const&) + { + for (auto& collision : collisions) { + auto bc = collision.template foundBC_as(); + initCCDB(bc); + + if (!collision.has_mcCollision()) { + continue; + } + + auto mccollision = collision.template mcCollision_as(); + if (cfgEventGeneratorType >= 0 && mccollision.getSubGeneratorId() != cfgEventGeneratorType) { + continue; + } + + auto tracks_per_coll = tracks.sliceBy(perCollision_mid, collision.globalIndex()); + for (auto& track : tracks_per_coll) { + if (!track.has_mcParticle()) { + continue; + } + auto mctrack = track.template mcParticle_as(); + if (mctrack.mcCollisionId() != collision.mcCollisionId()) { + continue; + } + if (abs(mctrack.pdgCode()) != 11 || !(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator())) { + continue; + } + if (!checkTrack(track)) { + continue; + } + + 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()); + } + + } // end of track loop + + 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) { + 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)) { + continue; + } + } // end of standalone muon loop + + for (auto& muon : global_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)) { + continue; + } + + } // end of global muon loop + + } // end of collision loop + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"create-resolution-map"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dielectron.cxx b/PWGEM/Dilepton/Tasks/dielectron.cxx new file mode 100644 index 00000000000..c8fa31b0e3b --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dielectron.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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/Dilepton.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dielectron"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dielectronMC.cxx b/PWGEM/Dilepton/Tasks/dielectronMC.cxx new file mode 100644 index 00000000000..3c525c29c6e --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dielectronMC.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 runs loop over dalitz ee table for dalitz QC. +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/DileptonMC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dielectron-mc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dielectronQC.cxx b/PWGEM/Dilepton/Tasks/dielectronQC.cxx deleted file mode 100644 index fb814cd01a9..00000000000 --- a/PWGEM/Dilepton/Tasks/dielectronQC.cxx +++ /dev/null @@ -1,957 +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 dalitz ee table for dalitz QC. -// 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/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.h" -#include "CommonConstants/LHCConstants.h" -#include "DataFormatsParameters/GRPLHCIFData.h" -#include "DataFormatsParameters/GRPECSObject.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.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/EventMixingHandler.h" -#include "PWGEM/Dilepton/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.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::dilepton::utils::emtrackutil; -using namespace o2::aod::pwgem::dilepton::utils; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; - -using MyEMH = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrackWithCov>; - -struct dielectronQC { - - // 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 beam1_str{"beam1_str", "p", "p or Pb"}; - // Configurable beam2_str{"beam2_str", "p", "p or Pb"}; - // Configurable beam1_energy_GeV{"beam1_energy_GeV", 6800, "beam energy for beam1"}; - // Configurable beam2_energy_GeV{"beam2_energy_GeV", 6800, "beam energy for beam2"}; - - Configurable cfgAnalysisType{"cfgAnalysisType", static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC), "kQC:0, kUPC:1, kFlowV2:2, kFlowV3:3, kFlowV4:4, kPolarization:5, kHFll:6"}; - 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.f, "max. centrality"}; - Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; - Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - // Configurable cfgDo_v2{"cfgDo_v2", false, "flag to analyze v2"}; - // Configurable cfgDo_v3{"cfgDo_v3", false, "flag to analyze v3"}; - 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 ConfMeeBins{"ConfMeeBins", {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.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.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00}, "mee bins for output histograms"}; - ConfigurableAxis ConfPteeBins{"ConfPteeBins", {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.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}, "pTee bins for output histograms"}; - ConfigurableAxis ConfDCAeeBins{"ConfDCAeeBins", {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}, "DCAee bins for output histograms"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - DielectronCut fDielectonCut; - 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_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_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"}; - Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; - - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "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", 100, "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(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3]"}; - 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_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 enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; - - // CCDB configuration for PID ML - Configurable BDTLocalPathGamma{"BDTLocalPathGamma", "pid_ml_xgboost.onnx", "Path to the local .onnx file"}; - Configurable BDTPathCCDB{"BDTPathCCDB", "Users/d/dsekihat/pwgem/pidml/", "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)"}; - } dielectroncuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - int mRunNumber; - float d_bz; - // o2::vertexing::DCAFitterN<2> fitter; - // 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 ep_bin_edges; - std::vector occ_bin_edges; - int nmod = -1; // this is for flow analysis - - float beamM1 = o2::constants::physics::MassProton; // mass of beam - float beamM2 = o2::constants::physics::MassProton; // mass of beam - float beamE1 = 0.f; // beam energy - float beamE2 = 0.f; // beam energy - float beamP1 = 0.f; // beam momentum - float beamP2 = 0.f; // beam momentum - - void init(InitContext& /*context*/) - { - 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()); - - occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); - occ_bin_edges.erase(occ_bin_edges.begin()); - - emh_pos = new MyEMH(ndepth); - emh_ele = new MyEMH(ndepth); - - DefineEMEventCut(); - DefineDileptonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - // 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); - } - - 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(); - // fitter.setBz(d_bz); - 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(); - // fitter.setBz(d_bz); - - auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", collision.timestamp()); - int beamZ1 = grplhcif->getBeamZ(o2::constants::lhc::BeamC); - int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamA); - int beamA1 = grplhcif->getBeamA(o2::constants::lhc::BeamC); - int beamA2 = grplhcif->getBeamA(o2::constants::lhc::BeamA); - beamE1 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamC); - beamE2 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamA); - beamM1 = o2::constants::physics::MassProton * beamA1; - beamM2 = o2::constants::physics::MassProton * beamA2; - beamP1 = std::sqrt(std::pow(beamE1, 2) - std::pow(beamM1, 2)); - beamP2 = std::sqrt(std::pow(beamE2, 2) - std::pow(beamM2, 2)); - LOGF(info, "beamZ1 = %d, beamZ2 = %d, beamA1 = %d, beamA2 = %d, beamE1 = %f (GeV), beamE2 = %f (GeV), beamM1 = %f (GeV), beamM2 = %f (GeV), beamP1 = %f (GeV), beamP2 = %f (GeV)", beamZ1, beamZ2, beamA1, beamA2, beamE1, beamE2, beamM1, beamM2, beamP1, beamP2); - } - - ~dielectronQC() - { - delete emh_pos; - emh_pos = 0x0; - delete emh_ele; - emh_ele = 0x0; - - map_mixed_eventId_to_qvector.clear(); - - used_trackIds.clear(); - used_trackIds.shrink_to_fit(); - } - - void addhistograms() - { - // pair info - const AxisSpec axis_mass{ConfMeeBins, "m_{ee} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPteeBins, "p_{T,ee} (GeV/c)"}; - const AxisSpec axis_dca{ConfDCAeeBins, "DCA_{ee}^{3D} (#sigma)"}; - std::string_view qvec_det_names[3] = {"FT0M", "FT0A", "FT0C"}; - - if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC)) { - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kUPC)) { - const AxisSpec axis_aco{10, 0, 1.f, "#alpha = 1 - #frac{|#varphi_{l^{+}} - #varphi_{l^{-}}|}{#pi}"}; - const AxisSpec axis_asym_pt{10, 0, 1.f, "A = #frac{|p_{T,l^{+}} - p_{T,l^{-}}|}{|p_{T,l^{+}} + p_{T,l^{-}}|}"}; - const AxisSpec axis_dphi_e_ee{18, 0, M_PI, "#Delta#varphi = #varphi_{e} - #varphi_{ee} (rad.)"}; - const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_cos_theta_cs}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV2)) { - nmod = 2; - const AxisSpec axis_sp2{20, -5.f, 5.f, Form("u_{2}^{ee} #upoint Q_{2}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp2}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - - const AxisSpec axis_sp2_l1{20, -5.f, 5.f, Form("u_{2,e1} #upoint Q_{2,1}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_sp2_l2{20, -5.f, 5.f, Form("u_{2,e2} #upoint Q_{2,2}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_cos_2dphi1{10, -1.f, 1.f, "cos(2 (#varphi_{e1} - #varphi_{ee}))"}; - const AxisSpec axis_cos_2dphi2{10, -1.f, 1.f, "cos(2 (#varphi_{e2} - #varphi_{ee}))"}; - fRegistry.add("Pair/mix/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp2_l1, axis_cos_2dphi1, axis_sp2_l2, axis_cos_2dphi2}, true); - fRegistry.add("Pair/mix/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lspp/"); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lsmm/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV3)) { - nmod = 3; - const AxisSpec axis_sp3{20, -5.f, 5.f, Form("u_{3}^{ee} #upoint Q_{3}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp3}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - - const AxisSpec axis_sp3_l1{20, -5.f, 5.f, Form("u_{3,e1} #upoint Q_{3,1}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_sp3_l2{20, -5.f, 5.f, Form("u_{3,e2} #upoint Q_{3,2}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_cos_3dphi1{10, -1.f, 1.f, "cos(3 (#varphi_{e1} - #varphi_{ee}))"}; - const AxisSpec axis_cos_3dphi2{10, -1.f, 1.f, "cos(3 (#varphi_{e2} - #varphi_{ee}))"}; - fRegistry.add("Pair/mix/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp3_l1, axis_cos_3dphi1, axis_sp3_l2, axis_cos_3dphi2}, true); - fRegistry.add("Pair/mix/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lspp/"); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lsmm/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kFlowV4)) { - nmod = 4; - const AxisSpec axis_sp4{20, -5.f, 5.f, Form("u_{4}^{ee} #upoint Q_{4}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp4}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - - const AxisSpec axis_sp4_l1{20, -5.f, 5.f, Form("u_{4,e1} #upoint Q_{4,1}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_sp4_l2{20, -5.f, 5.f, Form("u_{4,e2} #upoint Q_{4,2}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_cos_4dphi1{10, -1.f, 1.f, "cos(4 (#varphi_{e1} - #varphi_{ee}))"}; - const AxisSpec axis_cos_4dphi2{10, -1.f, 1.f, "cos(4 (#varphi_{e2} - #varphi_{ee}))"}; - fRegistry.add("Pair/mix/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp4_l1, axis_cos_4dphi1, axis_sp4_l2, axis_cos_4dphi2}, true); - fRegistry.add("Pair/mix/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lspp/"); - fRegistry.addClone("Pair/mix/uls/", "Pair/mix/lsmm/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kPolarization)) { - const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; - const AxisSpec axis_phi_cs{18, 0.f, M_PI, "|#varphi_{CS}| (rad.)"}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_cos_theta_cs, axis_phi_cs}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kHFll)) { - const AxisSpec axis_dphi_ee{18, 0, M_PI, "#Delta#varphi = #varphi_{e1} - #varphi_{e2} (rad.)"}; - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_dphi_ee}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - } else { // same as kQC to avoid seg. fault - fRegistry.add("Pair/same/uls/hs", "dielectron", kTHnSparseD, {axis_mass, axis_pt, axis_dca}, true); - fRegistry.add("Pair/same/uls/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2D, {{90, 0, M_PI}, {100, 0.0f, 0.1f}}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - } - - // for 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/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/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/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);#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; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, nmod > 0); - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - void DefineDileptonCut() - { - fDielectonCut = DielectronCut("fDielectonCut", "fDielectonCut"); - - // for pair - fDielectonCut.SetMeeRange(dielectroncuts.cfg_min_mass, dielectroncuts.cfg_max_mass); - fDielectonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); - fDielectonCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma - fDielectonCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectonCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); - fDielectonCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); - fDielectonCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); - - // for track - fDielectonCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); - fDielectonCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); - fDielectonCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); - fDielectonCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); - fDielectonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - fDielectonCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); - fDielectonCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); - fDielectonCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectonCut.SetMeanClusterSizeITSob(0, 16); - fDielectonCut.SetMaxDcaXY(dielectroncuts.cfg_max_dcaxy); - fDielectonCut.SetMaxDcaZ(dielectroncuts.cfg_max_dcaz); - - // for eID - fDielectonCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); - fDielectonCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectonCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); - fDielectonCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); - fDielectonCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); - fDielectonCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); - fDielectonCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut - o2::ml::OnnxModel* eid_bdt = new o2::ml::OnnxModel(); - if (dielectroncuts.loadModelsFromCCDB) { - ccdbApi.init(ccdburl); - std::map metadata; - bool retrieveSuccessGamma = ccdbApi.retrieveBlob(dielectroncuts.BDTPathCCDB.value, ".", metadata, dielectroncuts.timestampCCDB.value, false, dielectroncuts.BDTLocalPathGamma.value); - if (retrieveSuccessGamma) { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.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 { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.enableOptimizations.value); - } - - fDielectonCut.SetPIDModel(eid_bdt); - } // end of PID ML - } - - template - // bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, std::array q2bpos_mix, etc is better) - bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, const std::array qvector_mix = {999.f, 999.f}) - { - if constexpr (ev_id == 1) { - if (t1.has_ambiguousElectrons() && t2.has_ambiguousElectrons()) { - for (auto& possible_id1 : t1.ambiguousElectronsIds()) { - for (auto& possible_id2 : t2.ambiguousElectronsIds()) { - if (possible_id1 == possible_id2) { - // LOGF(info, "event id = %d: same track is found. t1.trackId() = %d, t1.collisionId() = %d, t1.pt() = %f, t1.eta() = %f, t1.phi() = %f, t2.trackId() = %d, t2.collisionId() = %d, t2.pt() = %f, t2.eta() = %f, t2.phi() = %f", ev_id, t1.trackId(), t1.collisionId(), t1.pt(), t1.eta(), t1.phi(), t2.trackId(), t2.collisionId(), t2.pt(), t2.eta(), t2.phi()); - 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 (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!fDielectonCut.IsSelectedTrack(t1, collision) || !fDielectonCut.IsSelectedTrack(t2, collision)) { - return false; - } - } else { // cut-based - if (!fDielectonCut.IsSelectedTrack(t1) || !fDielectonCut.IsSelectedTrack(t2)) { - return false; - } - } - } - - if (!fDielectonCut.IsSelectedPair(t1, t2, d_bz)) { - 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); - - 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) { - return false; - } - - float dca_t1_3d = dca3DinSigma(t1); - float dca_t2_3d = dca3DinSigma(t2); - float dca_ee_3d = std::sqrt((dca_t1_3d * dca_t1_3d + dca_t2_3d * dca_t2_3d) / 2.); - 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 (t1.sign() * t2.sign() < 0) { // ULS - // fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d); - // fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - // } 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(), dca_ee_3d); - // fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - // } 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(), dca_ee_3d); - // fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - // } - - if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kQC)) { - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - } 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 dphi_e_ee = v1.Phi() - v12.Phi(); - o2::math_utils::bringToPMPi(dphi_e_ee); - - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, 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(), dca_ee_3d, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, aco, asym, abs(dphi_e_ee), abs(cos_thetaCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - - } 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()}; - std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; - std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; - std::array q2bpos = {collision.q2xbpos(), collision.q2ybpos()}; - std::array q2bneg = {collision.q2xbneg(), collision.q2ybneg()}; - // const std::array q2vector[5] = {q2ft0m, q2ft0a, q2ft0c, q2bpos, q2bneg}; - std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; - std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; - std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; - std::array q3bpos = {collision.q3xbpos(), collision.q3ybpos()}; - std::array q3bneg = {collision.q3xbneg(), collision.q3ybneg()}; - // const std::array q3vector[5] = {q3ft0m, q3ft0a, q3ft0c, q3bpos, q3bneg}; - - std::vector>> qvectors = { - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 0th harmonics - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 1st harmonics - {q2ft0m, q2ft0a, q2ft0c, q2bpos, q2bneg}, // 2nd harmonics - {q3ft0m, q3ft0a, q3ft0c, q3bpos, q3bneg}, // 3rd harmonics - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 4th harmonics - }; - - float sp = 0.0; // for same event - float sp1 = 999.f, sp2 = 999.f; // for mixed event - float cos_dphi1 = 999.f, cos_dphi2 = 999.f; - if constexpr (ev_id == 0) { - sp = RecoDecay::dotProd(std::array{static_cast(std::cos(nmod * v12.Phi())), static_cast(std::sin(nmod * v12.Phi()))}, qvectors[nmod][cfgQvecEstimator]); - - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d, sp); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, sp); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, sp); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - - } else if constexpr (ev_id == 1) { - sp1 = RecoDecay::dotProd(std::array{static_cast(std::cos(nmod * v1.Phi())), static_cast(std::sin(nmod * v1.Phi()))}, qvectors[nmod][cfgQvecEstimator]); - sp2 = RecoDecay::dotProd(std::array{static_cast(std::cos(nmod * v2.Phi())), static_cast(std::sin(nmod * v2.Phi()))}, qvector_mix); - cos_dphi1 = std::cos(nmod * (v1.Phi() - v12.Phi())); - cos_dphi2 = std::cos(nmod * (v2.Phi() - v12.Phi())); - - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d, sp1, cos_dphi1, sp2, cos_dphi2); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, sp1, cos_dphi1, sp2, cos_dphi2); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, sp1, cos_dphi1, sp2, cos_dphi2); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - } - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kPolarization)) { - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); - // LOGF(info, "cos_thetaCS = %f, phiCS = %f", cos_thetaCS, phiCS); - 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(), dca_ee_3d, abs(cos_thetaCS), abs(phiCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, abs(cos_thetaCS), abs(phiCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, abs(cos_thetaCS), abs(phiCS)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - - } else if (cfgAnalysisType == static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonAnalysisType::kHFll)) { - float dphi = v1.Phi() - v2.Phi(); - o2::math_utils::bringToPMPi(dphi); - - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d, abs(dphi)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, abs(dphi)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d, abs(dphi)); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - - } else { // same as kQC to avoid seg. fault - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lspp/hMvsPhiV"), phiv, v12.M()); - } 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(), dca_ee_3d); - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("lsmm/hMvsPhiV"), phiv, v12.M()); - } - } - - // 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; - 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); - fillTrackInfo(t1); - if (cfgDoMix) { - if (t1.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron, 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())); - } else { - emh_ele->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron, 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())); - } - } - } - if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) { - used_trackIds.emplace_back(pair_tmp_id2); - fillTrackInfo(t2); - if (cfgDoMix) { - if (t2.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds1, - 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())); - } else { - emh_ele->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t2.globalIndex(), collision.globalIndex(), t2.trackId(), t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassElectron, t2.sign(), t2.dcaXY(), t2.dcaZ(), possibleIds1, - 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())); - } - } - } - } - return true; - } - - 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/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/hDCAxy_Pt"), track.pt(), track.dcaXY()); - fRegistry.fill(HIST("Track/hDCAz_Pt"), track.pt(), track.dcaZ()); - 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/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/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()); - } - - 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; - - SliceCache cache; - Preslice perCollision_track = aod::emprimaryelectron::emeventId; - Filter trackFilter = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(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 = (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) && ((0.96f < o2::aod::pidtofbeta::beta && o2::aod::pidtofbeta::beta < 1.04f) || o2::aod::pidtofbeta::beta < 0.f); - Filter ttcaFilter = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); - using FilteredMyTracks = soa::Filtered; - using FilteredMyTrack = FilteredMyTracks::iterator; - - MyEMH* emh_pos = nullptr; - MyEMH* emh_ele = nullptr; - - Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); - Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); - - std::map, std::array> map_mixed_eventId_to_qvector; - - std::vector> used_trackIds; - int ndf = 0; - void processQC(FilteredMyCollisions const& collisions, FilteredMyTracks const& /*tracks*/) - { - for (auto& collision : collisions) { - initCCDB(collision); - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, nmod > 0); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, nmod > 0); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; - std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; - std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; - std::array q2bpos = {collision.q2xbpos(), collision.q2ybpos()}; - std::array q2bneg = {collision.q2xbneg(), collision.q2ybneg()}; - // const std::array q2vector[5] = {q2ft0m, q2ft0a, q2ft0c, q2bpos, q2bneg}; - std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; - std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; - std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; - std::array q3bpos = {collision.q3xbpos(), collision.q3ybpos()}; - std::array q3bneg = {collision.q3xbneg(), collision.q3ybneg()}; - // const std::array q3vector[5] = {q3ft0m, q3ft0a, q3ft0c, q3bpos, q3bneg}; - - std::vector>> qvectors = { - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 0th harmonics - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 1st harmonics - {q2ft0m, q2ft0a, q2ft0c, q2bpos, q2bneg}, // 2nd harmonics - {q3ft0m, q3ft0a, q3ft0c, q3bpos, q3bneg}, // 3rd harmonics - {{999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}, {999.f, 999.f}}, // 4th harmonics - }; - - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - // 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - bool is_pair_ok = fillPairInfo<0>(collision, pos, ele); - 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); - if (is_pair_ok) { - nlspp++; - } - } - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- - bool is_pair_ok = fillPairInfo<0>(collision, ele1, ele2); - if (is_pair_ok) { - nlsmm++; - } - } - - 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; - } - - 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 = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - 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()); - - // make a vector of selected photons in this collision. - auto selected_posTracks_in_this_event = emh_pos->GetTracksPerCollision(key_df_collision); - auto selected_negTracks_in_this_event = emh_ele->GetTracksPerCollision(key_df_collision); - // LOGF(info, "N selected tracks in current event (%d, %d), zvtx = %f, centrality = %f , npos = %d , nele = %d, nuls = %d , nlspp = %d, nlsmm = %d", ndf, collision.globalIndex(), collision.posZ(), centralities[cfgCentEstimator], selected_posTracks_in_this_event.size(), selected_negTracks_in_this_event.size(), nuls, nlspp, nlsmm); - - auto collisionIds_in_mixing_pool = emh_pos->GetCollisionIdsFromEventPool(key_bin); // pos/ele 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) { - 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; - } - - // float q2x_mixed = map_mixed_eventId_to_qvector[mix_dfId_collisionId][0]; - // float q2y_mixed = map_mixed_eventId_to_qvector[mix_dfId_collisionId][1]; - - std::array qvector_mix = map_mixed_eventId_to_qvector[mix_dfId_collisionId]; - - // LOGF(info, "mix_df = %d, mix_collisionId = %d, q2x_mixed = %f, q2y_mixed = %f", mix_dfId, mix_collisionId, q2x_mixed, q2y_mixed); - - auto posTracks_from_event_pool = emh_pos->GetTracksPerCollision(mix_dfId_collisionId); - auto negTracks_from_event_pool = emh_ele->GetTracksPerCollision(mix_dfId_collisionId); - // LOGF(info, "Do event mixing: current event (%d, %d) | event pool (%d, %d), npos = %d , nele = %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& ele : negTracks_from_event_pool) { - fillPairInfo<1>(collision, pos, ele, qvector_mix); - } - } - - for (auto& ele : selected_negTracks_in_this_event) { // ULS mix - for (auto& pos : posTracks_from_event_pool) { - fillPairInfo<1>(collision, ele, pos, qvector_mix); - } - } - - for (auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix - for (auto& pos2 : posTracks_from_event_pool) { - fillPairInfo<1>(collision, pos1, pos2, qvector_mix); - } - } - - for (auto& ele1 : selected_negTracks_in_this_event) { // LS-- mix - for (auto& ele2 : negTracks_from_event_pool) { - fillPairInfo<1>(collision, ele1, ele2, qvector_mix); - } - } - } // end of loop over mixed event pool - - if (nuls > 0 || nlspp > 0 || nlsmm > 0) { - // LOGF(info, "adding : ndf = %d, collision.globalIndex() = %d, q2x = %f, q2y = %f", ndf, collision.globalIndex(), q2vector[cfgQvecEstimator][0], q2vector[cfgQvecEstimator][1]); - map_mixed_eventId_to_qvector[key_df_collision] = qvectors[nmod][cfgQvecEstimator]; - emh_pos->AddCollisionIdAtLast(key_bin, key_df_collision); - emh_ele->AddCollisionIdAtLast(key_bin, key_df_collision); - } - - } // end of collision loop - - ndf++; - } // end of process - PROCESS_SWITCH(dielectronQC, processQC, "run dielectron QC", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(dielectronQC, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"dielectron-qc"})}; -} diff --git a/PWGEM/Dilepton/Tasks/dielectronQCMC.cxx b/PWGEM/Dilepton/Tasks/dielectronQCMC.cxx deleted file mode 100644 index 45ae8b1f617..00000000000 --- a/PWGEM/Dilepton/Tasks/dielectronQCMC.cxx +++ /dev/null @@ -1,1188 +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 dalitz ee table for dalitz QC. -// Please write to: daiki.sekihata@cern.ch - -#include "TString.h" -#include "Math/Vector4D.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisTask.h" -#include "Framework/ASoAHelpers.h" -#include "CommonConstants/LHCConstants.h" -#include "DataFormatsParameters/GRPLHCIFData.h" -#include "DataFormatsParameters/GRPECSObject.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.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/Utils/EMTrackUtilities.h" -#include "PWGEM/Dilepton/Utils/PairUtilities.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::dilepton::utils::mcutil; -using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyMCTracks = soa::Join; -using MyMCTrack = MyMCTracks::iterator; - -struct dielectronQCMC { - - // 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::DileptonAnalysisType::kQC), "kQC:0, kUPC:1, kFlowV2:2, kFlowV3:3, kFlowV4:4, kPolarization:5, kHFll:6"}; - Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; - Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; - Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; - Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - - ConfigurableAxis ConfMeeBins{"ConfMeeBins", {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.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.30, 3.40, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00}, "mee bins for output histograms"}; - ConfigurableAxis ConfPteeBins{"ConfPteeBins", {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.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}, "pTee bins for output histograms"}; - ConfigurableAxis ConfDCAeeBins{"ConfDCAeeBins", {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}, "DCAee bins for output histograms"}; - // ConfigurableAxis ConfPCAeeBins{"ConfPCAeeBins", {VARIABLE_WIDTH, 0.0, 0.5, 1.0, 1.5, 2, 3, 4, 5}, "PCAee bins for output histograms in mm"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - DielectronCut fDielectonCut; - 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_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_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"}; - Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; - - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "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", 100, "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(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3]"}; - 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_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 enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; - - // CCDB configuration for PID ML - Configurable BDTLocalPathGamma{"BDTLocalPathGamma", "pid_ml_xgboost.onnx", "Path to the local .onnx file"}; - Configurable BDTPathCCDB{"BDTPathCCDB", "Users/d/dsekihat/pwgem/pidml/", "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)"}; - } dielectroncuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - // o2::vertexing::DCAFitterN<2> fitter; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - int mRunNumber; - float d_bz; - - struct : ConfigurableGroup { - std::string prefix = "mctrackcut_group"; - Configurable min_mcPt{"min_mcPt", 0.05, "min. MC pT"}; - Configurable max_mcPt{"max_mcPt", 1e+10, "max. MC pT"}; - Configurable min_mcEta{"min_mcEta", -0.9, "max. MC eta"}; - Configurable max_mcEta{"max_mcEta", +0.9, "max. MC eta"}; - } mctrackcuts; - - HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; - static constexpr std::string_view ele_source_types[9] = {"lf/", "Photon/", "PromptJPsi/", "NonPromptJPsi/", "PromptPsi2S/", "NonPromptPsi2S/", "c2e/", "b2e/", "b2c2e/"}; - - ~dielectronQCMC() {} - - void addhistograms() - { - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, cfgDoFlow); - - const AxisSpec axis_mass{ConfMeeBins, "m_{ee} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPteeBins, "p_{T,ee} (GeV/c)"}; - const AxisSpec axis_dca{ConfDCAeeBins, "DCA_{ee}^{3D} (#sigma)"}; - // const AxisSpec axis_pca{ConfPCAeeBins, "PCA (mm)"}; // particle closest approach - const AxisSpec axis_pt_meson{ConfPteeBins, "p_{T} (GeV/c)"}; // for omega, phi meson pT spectra - const AxisSpec axis_y_meson{20, -1.f, +1.f, "y"}; // rapidity of meson - - const AxisSpec axis_dphi_ee{18, 0, M_PI, "#Delta#varphi = #varphi_{e1} - #varphi_{e2} (rad.)"}; // for kHFll - const AxisSpec axis_cos_theta_cs{10, 0.f, 1.f, "|cos(#theta_{CS})|"}; // for kPolarization - 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_{e} - #varphi_{ee} (rad.)"}; // for kUPC - - // generated info - fRegistry.add("Generated/sm/Pi0/hs", "m_{ee} vs. p_{T,ee} ULS", kTHnSparseF, {axis_mass, axis_pt, axis_dphi_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/Omega2ee/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Phi/"); - fRegistry.addClone("Generated/sm/Pi0/", "Generated/sm/Phi2ee/"); - 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/Omega2ee/hPt", "pT of #omega meson", kTH1F, {axis_pt_meson}, true); - fRegistry.add("Generated/sm/Omega2ee/hY", "rapidity of #omega meson", kTH1F, {axis_y_meson}, true); - fRegistry.add("Generated/sm/Phi2ee/hPt", "pT of #phi meson", kTH1F, {axis_pt_meson}, true); - fRegistry.add("Generated/sm/Phi2ee/hY", "rapidity of #phi meson", kTH1F, {axis_y_meson}, true); - - fRegistry.add("Generated/ccbar/c2e_c2e/hadron_hadron/hs", "m_{ee} vs. p_{T,ee}", kTHnSparseF, {axis_mass, axis_pt, axis_dphi_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee}, true); - fRegistry.addClone("Generated/ccbar/c2e_c2e/hadron_hadron/", "Generated/ccbar/c2e_c2e/meson_meson/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/hadron_hadron/", "Generated/ccbar/c2e_c2e/baryon_baryon/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/hadron_hadron/", "Generated/ccbar/c2e_c2e/meson_baryon/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/", "Generated/bbbar/b2e_b2e/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/", "Generated/bbbar/b2c2e_b2c2e/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/", "Generated/bbbar/b2c2e_b2e_sameb/"); - fRegistry.addClone("Generated/ccbar/c2e_c2e/", "Generated/bbbar/b2c2e_b2e_diffb/"); // LS - - // reconstructed pair info - fRegistry.add("Pair/sm/Photon/hs", "hs pair", kTHnSparseF, {axis_mass, axis_pt, axis_dphi_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); - 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, 0.1f}}, true); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Pi0/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Eta/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/EtaPrime/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Rho/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Omega/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Omega2ee/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Phi/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Phi2ee/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/PromptJPsi/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/NonPromptJPsi/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/PromptPsi2S/"); - fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/NonPromptPsi2S/"); - - fRegistry.add("Pair/ccbar/c2e_c2e/hadron_hadron/hs", "hs pair", kTHnSparseF, {axis_mass, axis_pt, axis_dphi_ee, axis_cos_theta_cs, axis_phi_cs, axis_aco, axis_asym_pt, axis_dphi_e_ee, axis_dca}, true); - fRegistry.addClone("Pair/ccbar/c2e_c2e/hadron_hadron/", "Pair/ccbar/c2e_c2e/meson_meson/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/hadron_hadron/", "Pair/ccbar/c2e_c2e/baryon_baryon/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/hadron_hadron/", "Pair/ccbar/c2e_c2e/meson_baryon/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/", "Pair/bbbar/b2e_b2e/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/", "Pair/bbbar/b2c2e_b2c2e/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/", "Pair/bbbar/b2c2e_b2e_sameb/"); - fRegistry.addClone("Pair/ccbar/c2e_c2e/", "Pair/bbbar/b2c2e_b2e_diffb/"); // LS - - // track info - fRegistry.add("Track/lf/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/lf/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/lf/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); - fRegistry.add("Track/lf/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/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/hDCAxy_Pt", "DCA_{xy} vs. pT;p_{T} (GeV/c);DCA_{xy} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/lf/hDCAz_Pt", "DCA_{z} vs. pT;p_{T} (GeV/c);DCA_{z} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/lf/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/lf/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/lf/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/lf/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/lf/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/lf/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/lf/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTOFbeta", "TOF #beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {600, 0, 1.2}}, false); - fRegistry.add("Track/lf/h1overTOFbeta", "TOF 1/#beta;p_{in} (GeV/c);1/#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, false); - fRegistry.add("Track/lf/hTOFNsigmaEl", "TOF n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTOFNsigmaMu", "TOF n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/lf/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/lf/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/lf/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/lf/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/lf/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/lf/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - fRegistry.add("Track/lf/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("Track/lf/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("Track/lf/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("Track/lf/", "Track/Photon/"); - fRegistry.addClone("Track/lf/", "Track/PromptJPsi/"); - fRegistry.addClone("Track/lf/", "Track/NonPromptJPsi/"); - fRegistry.addClone("Track/lf/", "Track/PromptPsi2S/"); - fRegistry.addClone("Track/lf/", "Track/NonPromptPsi2S/"); - fRegistry.addClone("Track/lf/", "Track/c2e/"); - fRegistry.addClone("Track/lf/", "Track/b2e/"); - fRegistry.addClone("Track/lf/", "Track/b2c2e/"); - } - - float beamM1 = o2::constants::physics::MassProton; // mass of beam - float beamM2 = o2::constants::physics::MassProton; // mass of beam - float beamE1 = 0.f; // beam energy - float beamE2 = 0.f; // beam energy - float beamP1 = 0.f; // beam momentum - float beamP2 = 0.f; // beam momentum - - bool cfgDoFlow = false; - void init(InitContext&) - { - DefineEMEventCut(); - DefineDileptonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - // 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); - } - - 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(); - // fitter.setBz(d_bz); - 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(); - // fitter.setBz(d_bz); - - auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", collision.timestamp()); - int beamZ1 = grplhcif->getBeamZ(o2::constants::lhc::BeamC); - int beamZ2 = grplhcif->getBeamZ(o2::constants::lhc::BeamA); - int beamA1 = grplhcif->getBeamA(o2::constants::lhc::BeamC); - int beamA2 = grplhcif->getBeamA(o2::constants::lhc::BeamA); - beamE1 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamC); - beamE2 = grplhcif->getBeamEnergyPerNucleonInGeV(o2::constants::lhc::BeamA); - beamM1 = o2::constants::physics::MassProton * beamA1; - beamM2 = o2::constants::physics::MassProton * beamA2; - beamP1 = std::sqrt(std::pow(beamE1, 2) - std::pow(beamM1, 2)); - beamP2 = std::sqrt(std::pow(beamE2, 2) - std::pow(beamM2, 2)); - LOGF(info, "beamZ1 = %d, beamZ2 = %d, beamA1 = %d, beamA2 = %d, beamE1 = %f (GeV), beamE2 = %f (GeV), beamM1 = %f (GeV), beamM2 = %f (GeV), beamP1 = %f (GeV), beamP2 = %f (GeV)", beamZ1, beamZ2, beamA1, beamA2, beamE1, beamE2, beamM1, beamM2, beamP1, beamP2); - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - void DefineDileptonCut() - { - fDielectonCut = DielectronCut("fDielectonCut", "fDielectonCut"); - - // for pair - fDielectonCut.SetMeeRange(dielectroncuts.cfg_min_mass, dielectroncuts.cfg_max_mass); - fDielectonCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); - fDielectonCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma - fDielectonCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectonCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); - fDielectonCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); - fDielectonCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); - - // for track - fDielectonCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); - fDielectonCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); - fDielectonCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); - fDielectonCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); - fDielectonCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - fDielectonCut.SetChi2PerClusterTPC(0.0, dielectroncuts.cfg_max_chi2tpc); - fDielectonCut.SetChi2PerClusterITS(0.0, dielectroncuts.cfg_max_chi2its); - fDielectonCut.SetNClustersITS(dielectroncuts.cfg_min_ncluster_its, 7); - fDielectonCut.SetMeanClusterSizeITSob(0, 16); - fDielectonCut.SetMaxDcaXY(dielectroncuts.cfg_max_dcaxy); - fDielectonCut.SetMaxDcaZ(dielectroncuts.cfg_max_dcaz); - - // for eID - fDielectonCut.SetPIDScheme(dielectroncuts.cfg_pid_scheme); - fDielectonCut.SetTPCNsigmaElRange(dielectroncuts.cfg_min_TPCNsigmaEl, dielectroncuts.cfg_max_TPCNsigmaEl); - fDielectonCut.SetTPCNsigmaMuRange(dielectroncuts.cfg_min_TPCNsigmaMu, dielectroncuts.cfg_max_TPCNsigmaMu); - fDielectonCut.SetTPCNsigmaPiRange(dielectroncuts.cfg_min_TPCNsigmaPi, dielectroncuts.cfg_max_TPCNsigmaPi); - fDielectonCut.SetTPCNsigmaKaRange(dielectroncuts.cfg_min_TPCNsigmaKa, dielectroncuts.cfg_max_TPCNsigmaKa); - fDielectonCut.SetTPCNsigmaPrRange(dielectroncuts.cfg_min_TPCNsigmaPr, dielectroncuts.cfg_max_TPCNsigmaPr); - fDielectonCut.SetTOFNsigmaElRange(dielectroncuts.cfg_min_TOFNsigmaEl, dielectroncuts.cfg_max_TOFNsigmaEl); - - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut - o2::ml::OnnxModel* eid_bdt = new o2::ml::OnnxModel(); - if (dielectroncuts.loadModelsFromCCDB) { - ccdbApi.init(ccdburl); - std::map metadata; - bool retrieveSuccessGamma = ccdbApi.retrieveBlob(dielectroncuts.BDTPathCCDB.value, ".", metadata, dielectroncuts.timestampCCDB.value, false, dielectroncuts.BDTLocalPathGamma.value); - if (retrieveSuccessGamma) { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.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 { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.enableOptimizations.value); - } - - fDielectonCut.SetPIDModel(eid_bdt); - } // end of PID ML - } - - template - int FindLF(TTrack const& posmc, TTrack const& elemc, TMCParticles const& mcparticles) - { - int arr[] = { - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 111, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 221, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 331, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 113, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 223, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 333, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 443, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 100443, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 100553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 200553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 300553, mcparticles)}; - int size = sizeof(arr) / sizeof(*arr); - int max = *std::max_element(arr, arr + size); - return max; - } - - template - bool isInAcceptance(T const& t1) - { - if ((mctrackcuts.min_mcPt < t1.pt() && t1.pt() < mctrackcuts.max_mcPt) && (mctrackcuts.min_mcEta < t1.eta() && t1.eta() < mctrackcuts.max_mcEta)) { - return true; - } else { - return false; - } - } - - template - void fillTrackInfo(TTrack const& track) - { - // fill track info that belong to true pairs. - if (std::find(used_trackIds.begin(), used_trackIds.end(), track.globalIndex()) == used_trackIds.end()) { - auto mctrack = track.template emmcparticle_as(); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPt"), track.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxy_Pt"), track.pt(), track.dcaXY()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAz_Pt"), track.pt(), track.dcaZ()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hMeanClusterSizeITS"), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("h1overTOFbeta"), track.tpcInnerParam(), 1. / track.beta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); - used_trackIds.emplace_back(track.globalIndex()); - } - } - - template - bool fillTruePairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, TMCParticles const& mcparticles) - { - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!fDielectonCut.IsSelectedTrack(t1, collision) || !fDielectonCut.IsSelectedTrack(t2, collision)) { - return false; - } - } else { // cut-based - if (!fDielectonCut.IsSelectedTrack(t1) || !fDielectonCut.IsSelectedTrack(t2)) { - return false; - } - } - - if (!fDielectonCut.IsSelectedPair(t1, t2, d_bz)) { - 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); - - auto t1mc = t1.template emmcparticle_as(); - auto t2mc = t2.template emmcparticle_as(); - if (abs(t1mc.pdgCode()) != 11 || abs(t2mc.pdgCode()) != 11) { - return false; - } - if (t1mc.emmceventId() != t2mc.emmceventId()) { - return false; - } - - int mother_id = FindLF(t1mc, t2mc, mcparticles); - int hfee_type = IsHF(t1mc, t2mc, mcparticles); - if (mother_id < 0 && hfee_type < 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) { - return false; - } - - float dca_t1_3d = dca3DinSigma(t1); - float dca_t2_3d = dca3DinSigma(t2); - float dca_ee_3d = std::sqrt((dca_t1_3d * dca_t1_3d + dca_t2_3d * dca_t2_3d) / 2.); - 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 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 dphi_e_ee = v1.Phi() - v12.Phi(); - o2::math_utils::bringToPMPi(dphi_e_ee); - - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); - - if (mother_id > -1 && t1mc.pdgCode() * t2mc.pdgCode() < 0) { - auto mcmother = mcparticles.iteratorAt(mother_id); - if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { - case 111: - fRegistry.fill(HIST("Pair/sm/Pi0/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Pi0/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 221: - fRegistry.fill(HIST("Pair/sm/Eta/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Eta/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 331: - fRegistry.fill(HIST("Pair/sm/EtaPrime/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/EtaPrime/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 113: - fRegistry.fill(HIST("Pair/sm/Rho/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Rho/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 223: - fRegistry.fill(HIST("Pair/sm/Omega/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Omega/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - if (mcmother.daughtersIds().size() == 2) { // omeag->ee - fRegistry.fill(HIST("Pair/sm/Omega2ee/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Omega2ee/hMvsPhiV"), phiv, v12.M()); - } - break; - case 333: - fRegistry.fill(HIST("Pair/sm/Phi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Phi/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - if (mcmother.daughtersIds().size() == 2) { // omeag->ee - fRegistry.fill(HIST("Pair/sm/Phi2ee/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Phi2ee/hMvsPhiV"), phiv, v12.M()); - } - break; - case 443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<3, TMCParticles>(t1); - fillTrackInfo<3, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/PromptJPsi/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<2, TMCParticles>(t1); - fillTrackInfo<2, TMCParticles>(t2); - } - break; - } - case 100443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/NonPromptPsi2S/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<5, TMCParticles>(t1); - fillTrackInfo<5, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/PromptPsi2S/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<4, TMCParticles>(t1); - fillTrackInfo<4, TMCParticles>(t2); - } - break; - } - default: - break; - } - - } else if (!(t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && !(t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { - case 22: - fRegistry.fill(HIST("Pair/sm/Photon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fRegistry.fill(HIST("Pair/sm/Photon/hMvsPhiV"), phiv, v12.M()); - fillTrackInfo<1, TMCParticles>(t1); - fillTrackInfo<1, TMCParticles>(t2); - break; - default: - break; - } - } // end of primary/secondary selection - } // end of primary selection for same mother - } else if (hfee_type > -1) { - if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - auto mp1 = mcparticles.iteratorAt(t1mc.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2mc.mothersIds()[0]); - if (t1mc.pdgCode() * t2mc.pdgCode() < 0) { // ULS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<8, TMCParticles>(t1); - fillTrackInfo<8, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<8, TMCParticles>(t1); - fillTrackInfo<8, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - fillTrackInfo<8, TMCParticles>(t1); - fillTrackInfo<8, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_sameb/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } - if ((isCharmMeson(mp1) || isCharmBaryon(mp1)) && (isBeautyMeson(mp2) || isBeautyBaryon(mp2))) { - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<8, TMCParticles>(t2); - } else { - fillTrackInfo<8, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } else { // LS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2e_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee), dca_ee_3d); - } - if ((isCharmMeson(mp1) || isCharmBaryon(mp1)) && (isBeautyMeson(mp2) || isBeautyBaryon(mp2))) { - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<8, TMCParticles>(t2); - } else { - fillTrackInfo<8, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } - break; - } - default: - break; - } - } - } - } // end of HF evaluation - return true; - } - - std::vector used_trackIds; - SliceCache cache; - Preslice perCollision_track = aod::emprimaryelectron::emeventId; - Filter trackFilter = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(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 = (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) && ((0.96f < o2::aod::pidtofbeta::beta && o2::aod::pidtofbeta::beta < 1.04f) || o2::aod::pidtofbeta::beta < 0.f); - Filter ttcaFilter = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); - using FilteredMyMCTracks = soa::Filtered; - Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); - Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); - - 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 processQCMC(FilteredMyCollisions const& collisions, FilteredMyMCTracks const& tracks, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const&) - { - used_trackIds.reserve(tracks.size()); - - for (auto& collision : collisions) { - initCCDB(collision); - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, cfgDoFlow); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, cfgDoFlow); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - fillTruePairInfo(collision, pos, ele, mcparticles); - } // end of ULS pair loop - - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ - fillTruePairInfo(collision, pos1, pos2, mcparticles); - } // end of ULS pair loop - - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS__ - fillTruePairInfo(collision, ele1, ele2, mcparticles); - } // end of ULS pair loop - - } // end of collision loop - - used_trackIds.clear(); - used_trackIds.shrink_to_fit(); - - } // end of process - PROCESS_SWITCH(dielectronQCMC, processQCMC, "run dielectron QC MC", true); - - Partition posTracksMC = o2::aod::mcparticle::pdgCode == -11; // e+ - Partition negTracksMC = o2::aod::mcparticle::pdgCode == +11; // e- - PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; - void processGen(MyCollisions const& collisions, aod::EMMCEvents const&, aod::EMMCParticles const& mcparticles) - { - // loop over mc stack and fill histograms for pure MC truth signals - // all MC tracks which belong to the MC event corresponding to the current reconstructed event - - for (auto& collision : collisions) { - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - auto mccollision = collision.emmcevent_as(); - - auto posTracks_per_coll = posTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - auto negTracks_per_coll = negTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int mother_id = FindLF(t1, t2, mcparticles); - int hfee_type = IsHF(t1, t2, mcparticles); - if (mother_id < 0 && hfee_type < 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) { - continue; - } - - 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 dphi_e_ee = v1.Phi() - v12.Phi(); - o2::math_utils::bringToPMPi(dphi_e_ee); - - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); - - if (mother_id > -1) { - auto mcmother = mcparticles.iteratorAt(mother_id); - if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - - switch (abs(mcmother.pdgCode())) { - case 111: - fRegistry.fill(HIST("Generated/sm/Pi0/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - break; - case 221: - fRegistry.fill(HIST("Generated/sm/Eta/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - break; - case 331: - fRegistry.fill(HIST("Generated/sm/EtaPrime/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - break; - case 113: - fRegistry.fill(HIST("Generated/sm/Rho/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - break; - case 223: - fRegistry.fill(HIST("Generated/sm/Omega/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - // LOGF(info, "mcmother.daughtersIds().size() = %d, v12.M() = %f, v12.Rapidity() = %f, mcmother.y() = %f, v12.Pt() = %f, mcmother.pt() = %f", mcmother.daughtersIds().size(), v12.M(), v12.Rapidity(), mcmother.y(), v12.Pt(), mcmother.pt()); - // for (auto& daughterId : mcmother.daughtersIds()) { - // auto daughter = mcparticles.iteratorAt(daughterId); - // LOGF(info, "daughter.globalIndex() = %d, daughter.pdgCode() = %d", daughter.globalIndex(), daughter.pdgCode()); - // } - if (mcmother.daughtersIds().size() == 2) { // omega->ee - fRegistry.fill(HIST("Generated/sm/Omega2ee/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - case 333: - fRegistry.fill(HIST("Generated/sm/Phi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if (mcmother.daughtersIds().size() == 2) { // phi->ee - fRegistry.fill(HIST("Generated/sm/Phi2ee/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - case 443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - case 100443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - default: - break; - } - } - } else if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2c2e/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2e/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_sameb/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } // end of HF evaluation - } // end of true ULS pair loop - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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) { - continue; - } - 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 dphi_e_ee = v1.Phi() - v12.Phi(); - o2::math_utils::bringToPMPi(dphi_e_ee); - - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); - - if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2e_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - default: - break; - } - } - } // end of true LS++ pair loop - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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) { - continue; - } - 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 dphi_e_ee = v1.Phi() - v12.Phi(); - o2::math_utils::bringToPMPi(dphi_e_ee); - - float cos_thetaCS = 999, phiCS = 999.f; - o2::aod::pwgem::dilepton::utils::pairutil::getAngleCS(t1, t2, o2::constants::physics::MassElectron, o2::constants::physics::MassElectron, beamE1, beamE2, beamP1, beamP2, cos_thetaCS, phiCS); - if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2e_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), abs(dphi), abs(cos_thetaCS), abs(phiCS), aco, asym, abs(dphi_e_ee)); - } - break; - } - default: - break; - } - } - } // end of true LS++ pair loop - - } // end of collision loop - - // for oemga, phi efficiency - for (auto& collision : collisions) { - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - auto mccollision = collision.emmcevent_as(); - - auto mctracks_per_coll = mcparticles.sliceBy(perMcCollision, mccollision.globalIndex()); - - for (auto& mctrack : mctracks_per_coll) { - if (!(mctrack.isPhysicalPrimary() || mctrack.producedByGenerator()) || abs(mctrack.y()) > maxY) { - continue; - } - switch (abs(mctrack.pdgCode())) { - case 223: - fRegistry.fill(HIST("Generated/sm/Omega2ee/hPt"), mctrack.pt()); - fRegistry.fill(HIST("Generated/sm/Omega2ee/hY"), mctrack.y()); - break; - case 333: - fRegistry.fill(HIST("Generated/sm/Phi2ee/hPt"), mctrack.pt()); - fRegistry.fill(HIST("Generated/sm/Phi2ee/hY"), mctrack.y()); - break; - default: - break; - } - - } // end of mctracks per mccollision - - } // end of collision loop - } - PROCESS_SWITCH(dielectronQCMC, processGen, "run genrated info", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(dielectronQCMC, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"dielectron-qc-mc"})}; -} diff --git a/PWGEM/Dilepton/Tasks/dimuon.cxx b/PWGEM/Dilepton/Tasks/dimuon.cxx new file mode 100644 index 00000000000..51b92ab81b7 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dimuon.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 "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/Dilepton.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dimuon"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dimuonMC.cxx b/PWGEM/Dilepton/Tasks/dimuonMC.cxx new file mode 100644 index 00000000000..f505c073dc3 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/dimuonMC.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 runs loop over dalitz ee table for dalitz QC. +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/DileptonMC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"dimuon-mc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/dimuonQC.cxx b/PWGEM/Dilepton/Tasks/dimuonQC.cxx deleted file mode 100644 index cca97e86214..00000000000 --- a/PWGEM/Dilepton/Tasks/dimuonQC.cxx +++ /dev/null @@ -1,669 +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. -// -// ======================== -// -// Analysis task for dimuon. -// 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/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" - -#include "DCAFitter/FwdDCAFitterN.h" -#include "MCHTracking/TrackExtrap.h" -#include "MCHTracking/TrackParam.h" -#include "TGeoGlobalMagField.h" -#include "Field/MagneticField.h" -#include "GlobalTracking/MatchGlobalFwd.h" -#include "ReconstructionDataFormats/TrackFwd.h" - -#include "DetectorsBase/Propagator.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/DimuonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.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" - -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::emtrackutil; -using namespace o2::aod::pwgem::dilepton::utils; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyTracks = soa::Join; -using MyTrack = MyTracks::iterator; - -using MyEMH = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrackWithCov>; - -struct dimuonQC { - - // 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 geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; - 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", 3, "FT0M:0, FT0A:1, FT0C:2, BTOT:3"}; - Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; - Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; - Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; - Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; - Configurable cfgDo_v2{"cfgDo_v2", false, "flag to analyze v2"}; - Configurable cfgDo_v3{"cfgDo_v3", false, "flag to analyze v3"}; - Configurable minY{"minY", -4.0, "minimum rapidity for reconstructed pairs"}; - Configurable maxY{"maxY", -2.5, "maximum rapidity for reconstructed pairs"}; - 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.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 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.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.10, 11.20, 11.30, 11.40, 11.50, 11.60, 11.70, 11.80, 11.90, 12.00}, "mmumu bins for output histograms"}; - ConfigurableAxis ConfPtmumuBins{"ConfPtmumuBins", {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.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}, "pTmumu bins for output histograms"}; - ConfigurableAxis ConfDCAmumuBins{"ConfDCAmumuBins", {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}, "DCAmumu bins for output histograms"}; - // ConfigurableAxis ConfPCAmumuBins{"ConfPCAmumuBins", {VARIABLE_WIDTH, 0.0, 0.5, 1, 1.5, 2, 3, 4, 5}, "PCAmumu bins for output histograms in mm"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - 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_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_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_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_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_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"}; - } dimuoncuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - int mRunNumber; - float d_bz; - o2::vertexing::FwdDCAFitterN<2> fitter; - 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 ep_bin_edges; - std::vector occ_bin_edges; - - void init(InitContext& /*context*/) - { - 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()); - - occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); - occ_bin_edges.erase(occ_bin_edges.begin()); - - emh_pos = new MyEMH(ndepth); - emh_neg = new MyEMH(ndepth); - - DefineEMEventCut(); - DefineDimuonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - fitter.setPropagateToPCA(true); - fitter.setMaxR(90.f); - fitter.setMinParamChange(1e-3); - fitter.setMinRelChi2Change(0.9); - fitter.setMaxChi2(1e9); - fitter.setUseAbsDCA(true); - fitter.setTGeoMat(false); - // fitter.setMatCorrType(matCorr); - } - - 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(); - fitter.setBz(d_bz); - 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(); - fitter.setBz(d_bz); - - o2::base::Propagator::initFieldFromGRP(grpmag); - if (!o2::base::GeometryManager::isGeometryLoaded()) { - ccdb->get(geoPath); - } - o2::mch::TrackExtrap::setField(); - } - - ~dimuonQC() - { - delete emh_pos; - emh_pos = 0x0; - delete emh_neg; - emh_neg = 0x0; - - map_mixed_eventId_to_q2vector.clear(); - map_mixed_eventId_to_q3vector.clear(); - - used_trackIds.clear(); - used_trackIds.shrink_to_fit(); - } - - void addhistograms() - { - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, cfgDo_v2 || cfgDo_v3); - - // pair info - const AxisSpec axis_mass{ConfMmumuBins, "m_{#mu#mu} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPtmumuBins, "p_{T,#mu#mu} (GeV/c)"}; - const AxisSpec axis_dca{ConfDCAmumuBins, "DCA_{#mu#mu}^{xy} (#sigma)"}; - // const AxisSpec axis_pca{ConfPCAmumuBins, "PCA (mm)"}; // particle closest approach - - std::string_view qvec_det_names[4] = {"FT0M", "FT0A", "FT0C", "BTOT"}; - int nbin_sp2 = 1; - int nbin_sp3 = 1; - if (cfgDo_v2) { - nbin_sp2 = 100; - } - if (cfgDo_v3) { - nbin_sp3 = 100; - } - const AxisSpec axis_sp2{nbin_sp2, -5.f, 5.f, Form("u_{2}^{#mu#mu} #upoint Q_{2}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - const AxisSpec axis_sp3{nbin_sp3, -5.f, 5.f, Form("u_{3}^{#mu#mu} #upoint Q_{3}^{%s}", qvec_det_names[cfgQvecEstimator].data())}; - - fRegistry.add("Pair/same/uls/hs", "dimuon", kTHnSparseD, {axis_mass, axis_pt, axis_dca, axis_sp2, axis_sp3}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - - // for 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}, {25, -4.5f, -2.0f}}, false); - fRegistry.add("Track/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/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/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/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); - fRegistry.add("Track/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/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/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - 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.SetPairDCAxyRange(dimuoncuts.cfg_min_pair_dcaxy, dimuoncuts.cfg_max_pair_dcaxy); // DCAxy in cm - - // for track - fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); - fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_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); }); - } - - template - bool fillPairInfo(TCollision const& collision, TTrack1 const& t1, TTrack2 const& t2, const float q2x_mixed = 0.f, const float q2y_mixed = 0.f, const float q3x_mixed = 0.f, const float q3y_mixed = 0.f) - { - if constexpr (ev_id == 1) { - if (t1.has_ambiguousMuons() && t2.has_ambiguousMuons()) { - for (auto& possible_id1 : t1.ambiguousMuonsIds()) { - for (auto& possible_id2 : t2.ambiguousMuonsIds()) { - if (possible_id1 == possible_id2) { - // LOGF(info, "event id = %d: same track is found. t1.fwdtrackId() = %d, t1.collisionId() = %d, t1.pt() = %f, t1.eta() = %f, t1.phi() = %f, t2.fwdtrackId() = %d, t2.collisionId() = %d, t2.pt() = %f, t2.eta() = %f, t2.phi() = %f", ev_id, t1.fwdtrackId(), t1.collisionId(), t1.pt(), t1.eta(), t1.phi(), t2.fwdtrackId(), t2.collisionId(), t2.pt(), t2.eta(), t2.phi()); - 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 (!fDimuonCut.IsSelectedTrack(t1) || !fDimuonCut.IsSelectedTrack(t2)) { - return false; - } - } - - if (!fDimuonCut.IsSelectedPair(t1, t2)) { - return false; - } - - // float pca = 999.f, lxy = 999.f; // in unit of cm - // o2::aod::pwgem::dilepton::utils::pairutil::isSVFoundFwd(fitter, collision, t1, t2, pca, lxy); - - std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; - std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; - std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; - std::array q2btot = {collision.q2xbtot(), collision.q2ybtot()}; - const std::array q2vector[4] = {q2ft0m, q2ft0a, q2ft0c, q2btot}; - - std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; - std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; - std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; - std::array q3btot = {collision.q3xbtot(), collision.q3ybtot()}; - const std::array q3vector[4] = {q3ft0m, q3ft0a, q3ft0c, q3btot}; - - ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (v12.Rapidity() < minY || maxY < v12.Rapidity()) { - return false; - } - - float dca_xy_t1 = fwdDcaXYinSigma(t1); - float dca_xy_t2 = fwdDcaXYinSigma(t2); - float dca_mumu_xy = std::sqrt((dca_xy_t1 * dca_xy_t1 + dca_xy_t2 * dca_xy_t2) / 2.); - - float sp2 = 0.f, sp3 = 0.f; - if constexpr (ev_id == 0) { - if (cfgDo_v2) { - std::array u2_ll = {static_cast(std::cos(2 * v12.Phi())), static_cast(std::sin(2 * v12.Phi()))}; - sp2 = RecoDecay::dotProd(u2_ll, q2vector[cfgQvecEstimator]); - } - if (cfgDo_v3) { - std::array u3_ll = {static_cast(std::cos(3 * v12.Phi())), static_cast(std::sin(3 * v12.Phi()))}; - sp3 = RecoDecay::dotProd(u3_ll, q3vector[cfgQvecEstimator]); - } - } else if constexpr (ev_id == 1) { - if (cfgDo_v2) { - std::array u2_l1 = {static_cast(std::cos(2 * v1.Phi())), static_cast(std::sin(2 * v1.Phi()))}; - std::array u2_l2 = {static_cast(std::cos(2 * v2.Phi())), static_cast(std::sin(2 * v2.Phi()))}; - sp2 = RecoDecay::dotProd(u2_l1, std::array{q2vector[cfgQvecEstimator][0], q2vector[cfgQvecEstimator][1]}) * std::cos(2 * (v1.Phi() - v12.Phi())) + RecoDecay::dotProd(u2_l2, std::array{q2x_mixed, q2y_mixed}) * std::cos(2 * (v2.Phi() - v12.Phi())); - } - if (cfgDo_v3) { - std::array u3_l1 = {static_cast(std::cos(3 * v1.Phi())), static_cast(std::sin(3 * v1.Phi()))}; - std::array u3_l2 = {static_cast(std::cos(3 * v2.Phi())), static_cast(std::sin(3 * v2.Phi()))}; - sp3 = RecoDecay::dotProd(u3_l1, std::array{q3vector[cfgQvecEstimator][0], q3vector[cfgQvecEstimator][1]}) * std::cos(3 * (v1.Phi() - v12.Phi())) + RecoDecay::dotProd(u3_l2, std::array{q3x_mixed, q3y_mixed}) * std::cos(3 * (v2.Phi() - v12.Phi())); - } - } - - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), dca_mumu_xy, sp2, sp3); - } 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(), dca_mumu_xy, sp2, sp3); - } 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(), dca_mumu_xy, sp2, sp3); - } - - // 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; - 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); - fillTrackInfo(t1); - if (cfgDoMix) { - if (t1.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } - } - } - if (std::find(used_trackIds.begin(), used_trackIds.end(), pair_tmp_id2) == used_trackIds.end()) { - used_trackIds.emplace_back(pair_tmp_id2); - fillTrackInfo(t2); - if (cfgDoMix) { - if (t2.sign() > 0) { - emh_pos->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } else { - emh_neg->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } - } - } - } - return true; - } - - 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/hTrackType"), track.trackType()); - fRegistry.fill(HIST("Track/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/hDCAxySigma"), track.fwdDcaX() / sqrt(track.cXX()), track.fwdDcaY() / sqrt(track.cYY())); - fRegistry.fill(HIST("Track/hDCAxRes_Pt"), track.pt(), sqrt(track.cXX()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hDCAyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/hNclsMCH"), track.nClusters()); - fRegistry.fill(HIST("Track/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/hChi2"), track.chi2()); - fRegistry.fill(HIST("Track/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); - fRegistry.fill(HIST("Track/hMFTClusterMap"), track.mftClusterMap()); - } - - 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; - - SliceCache cache; - Preslice perCollision_track = aod::emprimarymuon::emeventId; - Filter trackFilter = 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; - Filter ttcaFilter = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); - using FilteredMyTracks = soa::Filtered; - - MyEMH* emh_pos = nullptr; - MyEMH* emh_neg = nullptr; - - Partition posTracks = o2::aod::emprimarymuon::sign > int8_t(0); - Partition negTracks = o2::aod::emprimarymuon::sign < int8_t(0); - - std::map, std::array> map_mixed_eventId_to_q2vector; - std::map, std::array> map_mixed_eventId_to_q3vector; - - std::vector> used_trackIds; - int ndf = 0; - void processQC(FilteredMyCollisions const& collisions, FilteredMyTracks const& /*tracks*/) - { - for (auto& collision : collisions) { - initCCDB(collision); - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, cfgDo_v2 || cfgDo_v3); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, cfgDo_v2 || cfgDo_v3); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; - std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; - std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; - std::array q2btot = {collision.q2xbtot(), collision.q2ybtot()}; - const std::array q2vector[4] = {q2ft0m, q2ft0a, q2ft0c, q2btot}; - - std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; - std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; - std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; - std::array q3btot = {collision.q3xbtot(), collision.q3ybtot()}; - const std::array q3vector[4] = {q3ft0m, q3ft0a, q3ft0c, q3btot}; - - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - // 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()); - - // for (auto& neg : negTracks_per_coll) { - // LOGF(info, "neg.trackType() = %d , neg.pt() = %f", neg.trackType(), neg.pt()); - // } - - int nuls = 0, nlspp = 0, nlsmm = 0; - for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - bool is_pair_ok = fillPairInfo<0>(collision, pos, ele); - 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); - if (is_pair_ok) { - nlspp++; - } - } - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- - bool is_pair_ok = fillPairInfo<0>(collision, ele1, ele2); - if (is_pair_ok) { - nlsmm++; - } - } - - 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; - } - - 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.ep2ft0c(); - 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 = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - 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()); - - // make a vector of selected photons 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); - // LOGF(info, "N selected tracks in current event (%d, %d), zvtx = %f, centrality = %f , npos = %d , nele = %d, nuls = %d , nlspp = %d, nlsmm = %d", ndf, collision.globalIndex(), collision.posZ(), centralities[cfgCentEstimator], selected_posTracks_in_this_event.size(), selected_negTracks_in_this_event.size(), nuls, nlspp, nlsmm); - - auto collisionIds_in_mixing_pool = emh_pos->GetCollisionIdsFromEventPool(key_bin); // pos/ele 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) { - 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; - } - - float q2x_mixed = map_mixed_eventId_to_q2vector[mix_dfId_collisionId][0]; - float q2y_mixed = map_mixed_eventId_to_q2vector[mix_dfId_collisionId][1]; - float q3x_mixed = map_mixed_eventId_to_q3vector[mix_dfId_collisionId][0]; - float q3y_mixed = map_mixed_eventId_to_q3vector[mix_dfId_collisionId][1]; - - auto posTracks_from_event_pool = emh_pos->GetTracksPerCollision(mix_dfId_collisionId); - 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 , nele = %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& ele : negTracks_from_event_pool) { - fillPairInfo<1>(collision, pos, ele, q2x_mixed, q2y_mixed, q3x_mixed, q3y_mixed); - } - } - - for (auto& ele : selected_negTracks_in_this_event) { // ULS mix - for (auto& pos : posTracks_from_event_pool) { - fillPairInfo<1>(collision, ele, pos, q2x_mixed, q2y_mixed, q3x_mixed, q3y_mixed); - } - } - - for (auto& pos1 : selected_posTracks_in_this_event) { // LS++ mix - for (auto& pos2 : posTracks_from_event_pool) { - fillPairInfo<1>(collision, pos1, pos2, q2x_mixed, q2y_mixed, q3x_mixed, q3y_mixed); - } - } - - for (auto& ele1 : selected_negTracks_in_this_event) { // LS-- mix - for (auto& ele2 : negTracks_from_event_pool) { - fillPairInfo<1>(collision, ele1, ele2, q2x_mixed, q2y_mixed, q3x_mixed, q3y_mixed); - } - } - } // end of loop over mixed event pool - - if (nuls > 0 || nlspp > 0 || nlsmm > 0) { - map_mixed_eventId_to_q2vector[key_df_collision] = q2vector[cfgQvecEstimator]; - map_mixed_eventId_to_q3vector[key_df_collision] = q3vector[cfgQvecEstimator]; - emh_pos->AddCollisionIdAtLast(key_bin, key_df_collision); - emh_neg->AddCollisionIdAtLast(key_bin, key_df_collision); - } - - } // end of collision loop - - ndf++; - } // end of process - PROCESS_SWITCH(dimuonQC, processQC, "run dimuon QC", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(dimuonQC, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"dimuon-qc"})}; -} diff --git a/PWGEM/Dilepton/Tasks/dimuonQCMC.cxx b/PWGEM/Dilepton/Tasks/dimuonQCMC.cxx deleted file mode 100644 index bc7b1d7eda7..00000000000 --- a/PWGEM/Dilepton/Tasks/dimuonQCMC.cxx +++ /dev/null @@ -1,926 +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 dalitz ee table for dalitz QC. -// Please write to: daiki.sekihata@cern.ch - -#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 "Tools/ML/model.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/FwdDCAFitterN.h" - -#include "PWGEM/Dilepton/DataModel/dileptonTables.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" - -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::mcutil; -using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyMCTracks = soa::Join; -using MyMCTrack = MyMCTracks::iterator; - -struct dimuonQCMC { - - // 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.f, "max. centrality"}; - Configurable minY{"minY", -4.0, "minimum rapidity for reconstructed pairs"}; - Configurable maxY{"maxY", -2.5, "maximum rapidity for reconstructed pairs"}; - - 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.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.10, 11.20, 11.30, 11.40, 11.50, 11.60, 11.70, 11.80, 11.90, 12.00}, "mmumu bins for output histograms"}; - ConfigurableAxis ConfPtmumuBins{"ConfPtmumuBins", {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.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}, "pTmumu bins for output histograms"}; - ConfigurableAxis ConfDCAmumuBins{"ConfDCAmumuBins", {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}, "DCAmumu bins for output histograms"}; - // ConfigurableAxis ConfPCAmumuBins{"ConfPCAmumuBins", {VARIABLE_WIDTH, 0.0, 0.5, 1, 1.5, 2, 3, 4, 5}, "PCAmumu bins for output histograms in mm"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - 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_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_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_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_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_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"}; - } dimuoncuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - o2::vertexing::FwdDCAFitterN<2> fitter; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - int mRunNumber; - float d_bz; - - struct : ConfigurableGroup { - std::string prefix = "mctrackcut_group"; - Configurable min_mcPt{"min_mcPt", 0.05, "min. MC pT"}; - Configurable max_mcPt{"max_mcPt", 1e+10, "max. MC pT"}; - Configurable min_mcEta{"min_mcEta", -4.0, "min. MC eta"}; - Configurable max_mcEta{"max_mcEta", -2.5, "max. MC eta"}; - } mctrackcuts; - - HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; - static constexpr std::string_view ele_source_types[8] = {"lf/", "PromptJPsi/", "NonPromptJPsi/", "PromptPsi2S/", "NonPromptPsi2S/", "c2mu/", "b2mu/", "b2c2mu/"}; - - ~dimuonQCMC() {} - - void addhistograms() - { - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, cfgDoFlow); - - const AxisSpec axis_mass{ConfMmumuBins, "m_{#mu#mu} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPtmumuBins, "p_{T,#mu#mu} (GeV/c)"}; - const AxisSpec axis_dca{ConfDCAmumuBins, "DCA_{#mu#mu}^{xy} (#sigma)"}; - // const AxisSpec axis_pca{ConfPCAmumuBins, "PCA (mm)"}; // particle closest approach - - // generated info - fRegistry.add("Generated/sm/Eta/hMvsPt", "m_{#mu#mu} vs. p_{T,#mu#mu} ULS", kTH2F, {axis_mass, axis_pt}, true); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/EtaPrime/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/Rho/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/Omega/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/Phi/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/PromptJPsi/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/NonPromptJPsi/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/PromptPsi2S/"); - fRegistry.addClone("Generated/sm/Eta/", "Generated/sm/NonPromptPsi2S/"); - - fRegistry.add("Generated/ccbar/c2mu_c2mu/hadron_hadron/hMvsPt", "m_{#mu#mu} vs. p_{T,#mu#mu}", kTH2F, {axis_mass, axis_pt}, true); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/hadron_hadron/", "Generated/ccbar/c2mu_c2mu/meson_meson/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/hadron_hadron/", "Generated/ccbar/c2mu_c2mu/baryon_baryon/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/hadron_hadron/", "Generated/ccbar/c2mu_c2mu/meson_baryon/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/", "Generated/bbbar/b2mu_b2mu/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/", "Generated/bbbar/b2c2mu_b2c2mu/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/", "Generated/bbbar/b2c2mu_b2mu_sameb/"); - fRegistry.addClone("Generated/ccbar/c2mu_c2mu/", "Generated/bbbar/b2c2mu_b2mu_diffb/"); // LS - - // reconstructed pair info - fRegistry.add("Pair/sm/Eta/hs", "hs pair", kTHnSparseF, {axis_mass, axis_pt, axis_dca}, true); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/EtaPrime/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/Rho/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/Omega/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/Phi/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/PromptJPsi/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/NonPromptJPsi/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/PromptPsi2S/"); - fRegistry.addClone("Pair/sm/Eta/", "Pair/sm/NonPromptPsi2S/"); - - fRegistry.add("Pair/ccbar/c2mu_c2mu/hadron_hadron/hs", "hs pair", kTHnSparseF, {axis_mass, axis_pt, axis_dca}, true); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/hadron_hadron/", "Pair/ccbar/c2mu_c2mu/meson_meson/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/hadron_hadron/", "Pair/ccbar/c2mu_c2mu/baryon_baryon/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/hadron_hadron/", "Pair/ccbar/c2mu_c2mu/meson_baryon/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/", "Pair/bbbar/b2mu_b2mu/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/", "Pair/bbbar/b2c2mu_b2c2mu/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/", "Pair/bbbar/b2c2mu_b2mu_sameb/"); - fRegistry.addClone("Pair/ccbar/c2mu_c2mu/", "Pair/bbbar/b2c2mu_b2mu_diffb/"); // LS - - // track info - fRegistry.add("Track/lf/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/lf/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/lf/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {30, -4.5f, -2.0f}}, false); - fRegistry.add("Track/lf/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/lf/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/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/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/lf/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/lf/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); - fRegistry.add("Track/lf/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/lf/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/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/lf/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/lf/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/lf/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); - fRegistry.add("Track/lf/hPtGen_DeltaPtOverPtGen", "muon 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("Track/lf/hPtGen_DeltaEta", "muon #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("Track/lf/hPtGen_DeltaPhi", "muon #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.addClone("Track/lf/", "Track/PromptJPsi/"); - fRegistry.addClone("Track/lf/", "Track/NonPromptJPsi/"); - fRegistry.addClone("Track/lf/", "Track/PromptPsi2S/"); - fRegistry.addClone("Track/lf/", "Track/NonPromptPsi2S/"); - fRegistry.addClone("Track/lf/", "Track/c2mu/"); - fRegistry.addClone("Track/lf/", "Track/b2mu/"); - fRegistry.addClone("Track/lf/", "Track/b2c2mu/"); - } - - bool cfgDoFlow = false; - void init(InitContext&) - { - DefineEMEventCut(); - DefineDimuonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - fitter.setPropagateToPCA(true); - fitter.setMaxR(90.f); - fitter.setMinParamChange(1e-3); - fitter.setMinRelChi2Change(0.9); - fitter.setMaxChi2(1e9); - fitter.setUseAbsDCA(true); - fitter.setTGeoMat(false); - // fitter.setMatCorrType(matCorr); - } - - 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(); - fitter.setBz(d_bz); - 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(); - fitter.setBz(d_bz); - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - 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.SetPairDCAxyRange(dimuoncuts.cfg_min_pair_dcaxy, dimuoncuts.cfg_max_pair_dcaxy); // DCAxy in cm - - // for track - fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); - fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_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); }); - } - - template - int FindLF(TTrack const& posmc, TTrack const& elemc, TMCParticles const& mcparticles) - { - int arr[] = { - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 221, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 331, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 113, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 223, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 333, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 443, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 100443, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 100553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 200553, mcparticles), - FindCommonMotherFrom2Prongs(posmc, elemc, -13, 13, 300553, mcparticles)}; - int size = sizeof(arr) / sizeof(*arr); - int max = *std::max_element(arr, arr + size); - return max; - } - - template - bool isInAcceptance(T const& t1) - { - if ((mctrackcuts.min_mcPt < t1.pt() && t1.pt() < mctrackcuts.max_mcPt) && (mctrackcuts.min_mcEta < t1.eta() && t1.eta() < mctrackcuts.max_mcEta)) { - return true; - } else { - return false; - } - } - - template - void fillTrackInfo(TTrack const& track) - { - // fill track info that belong to true pairs. - if (std::find(used_trackIds.begin(), used_trackIds.end(), track.globalIndex()) == used_trackIds.end()) { - auto mctrack = track.template emmcparticle_as(); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPt"), track.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hTrackType"), track.trackType()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxySigma"), track.fwdDcaX() / std::sqrt(track.cXX()), track.fwdDcaY() / std::sqrt(track.cYY())); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAxRes_Pt"), track.pt(), std::sqrt(track.cXX()) * 1e+4); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hDCAyRes_Pt"), track.pt(), std::sqrt(track.cYY()) * 1e+4); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hNclsMCH"), track.nClusters()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hChi2"), track.chi2()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hChi2MatchMCHMID"), track.chi2MatchMCHMID()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hMFTClusterMap"), track.mftClusterMap()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); - fRegistry.fill(HIST("Track/") + HIST(ele_source_types[e_source_id]) + HIST("hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); - used_trackIds.emplace_back(track.globalIndex()); - } - } - - template - bool fillTruePairInfo(TCollision const& /*collision*/, TTrack1 const& t1, TTrack2 const& t2, TMCParticles const& mcparticles) - { - if (!fDimuonCut.IsSelectedTrack(t1) || !fDimuonCut.IsSelectedTrack(t2)) { - return false; - } - - if (!fDimuonCut.IsSelectedPair(t1, t2)) { - return false; - } - - // float pca = 999.f, lxy = 999.f; // in unit of cm - // o2::aod::pwgem::dilepton::utils::pairutil::isSVFoundFwd(fitter, collision, t1, t2, pca, lxy); - - auto t1mc = t1.template emmcparticle_as(); - auto t2mc = t2.template emmcparticle_as(); - - if (abs(t1mc.pdgCode()) != 13 || abs(t2mc.pdgCode()) != 13) { - return false; - } - if (t1mc.emmceventId() != t2mc.emmceventId()) { - return false; - } - - int mother_id = FindLF(t1mc, t2mc, mcparticles); - int hfee_type = IsHF(t1mc, t2mc, mcparticles); - if (mother_id < 0 && hfee_type < 0) { - return false; - } - ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - - if (v12.Rapidity() < minY || maxY < v12.Rapidity()) { - return false; - } - - float dca_xy_t1 = fwdDcaXYinSigma(t1); - float dca_xy_t2 = fwdDcaXYinSigma(t2); - float dca_mumu_xy = std::sqrt((dca_xy_t1 * dca_xy_t1 + dca_xy_t2 * dca_xy_t2) / 2.); - - if (mother_id > -1 && t1mc.pdgCode() * t2mc.pdgCode() < 0) { - auto mcmother = mcparticles.iteratorAt(mother_id); - if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - switch (abs(mcmother.pdgCode())) { - case 221: - fRegistry.fill(HIST("Pair/sm/Eta/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 331: - fRegistry.fill(HIST("Pair/sm/EtaPrime/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 113: - fRegistry.fill(HIST("Pair/sm/Rho/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 223: - fRegistry.fill(HIST("Pair/sm/Omega/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 333: - fRegistry.fill(HIST("Pair/sm/Phi/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<0, TMCParticles>(t1); - fillTrackInfo<0, TMCParticles>(t2); - break; - case 443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptJPsi/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<2, TMCParticles>(t1); - fillTrackInfo<2, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/sm/PromptJPsi/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<1, TMCParticles>(t1); - fillTrackInfo<1, TMCParticles>(t2); - } - break; - } - case 100443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Pair/sm/NonPromptPsi2S/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<4, TMCParticles>(t1); - fillTrackInfo<4, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/sm/PromptPsi2S/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<3, TMCParticles>(t1); - fillTrackInfo<3, TMCParticles>(t2); - } - break; - } - default: - break; - } - } - } // end of primary selection for same mother - } else if (hfee_type > -1) { - if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { - auto mp1 = mcparticles.iteratorAt(t1mc.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2mc.mothersIds()[0]); - if (t1mc.pdgCode() * t2mc.pdgCode() < 0) { // ULS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Pair/ccbar/c2mu_c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2mu_c2mu/meson_meson/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<5, TMCParticles>(t1); - fillTrackInfo<5, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2mu_c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<5, TMCParticles>(t1); - fillTrackInfo<5, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/ccbar/c2mu_c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<5, TMCParticles>(t1); - fillTrackInfo<5, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Pair/bbbar/b2mu_b2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2mu_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2mu_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2mu_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2c2mu/meson_meson/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_sameb/meson_meson/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } - if ((isCharmMeson(mp1) || isCharmBaryon(mp1)) && (isBeautyMeson(mp2) || isBeautyBaryon(mp2))) { - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else { - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } else { // LS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2mu_b2mu_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_diffb/meson_meson/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2mu_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), dca_mumu_xy); - } - if ((isCharmMeson(mp1) || isCharmBaryon(mp1)) && (isBeautyMeson(mp2) || isBeautyBaryon(mp2))) { - fillTrackInfo<6, TMCParticles>(t1); - fillTrackInfo<7, TMCParticles>(t2); - } else { - fillTrackInfo<7, TMCParticles>(t1); - fillTrackInfo<6, TMCParticles>(t2); - } - break; - } - default: - break; - } - } - } - } // end of HF evaluation - return true; - } - - std::vector used_trackIds; - SliceCache cache; - Preslice perCollision_track = aod::emprimarymuon::emeventId; - Filter trackFilter = 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; - Filter ttcaFilter = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); - - using FilteredMyMCTracks = soa::Filtered; - Partition posTracks = o2::aod::emprimarymuon::sign > int8_t(0); - Partition negTracks = o2::aod::emprimarymuon::sign < int8_t(0); - - 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 processQCMC(FilteredMyCollisions const& collisions, FilteredMyMCTracks const& tracks, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const&) - { - used_trackIds.reserve(tracks.size()); - - for (auto& collision : collisions) { - initCCDB(collision); - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, cfgDoFlow); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, cfgDoFlow); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - - auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimarymuon::emeventId, 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS - fillTruePairInfo(collision, pos, ele, mcparticles); - } // end of ULS pair loop - - for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ - fillTruePairInfo(collision, pos1, pos2, mcparticles); - } // end of ULS pair loop - - for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS__ - fillTruePairInfo(collision, ele1, ele2, mcparticles); - } // end of ULS pair loop - - } // end of collision loop - - used_trackIds.clear(); - used_trackIds.shrink_to_fit(); - - } // end of process - PROCESS_SWITCH(dimuonQCMC, processQCMC, "run dimuon QC MC", true); - - Partition posTracksMC = o2::aod::mcparticle::pdgCode == -13; // mu+ - Partition negTracksMC = o2::aod::mcparticle::pdgCode == +13; // mu- - PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; - void processGen(MyCollisions const& collisions, aod::EMMCEvents const&, aod::EMMCParticles const& mcparticles) - { - // loop over mc stack and fill histograms for pure MC truth signals - // all MC tracks which belong to the MC event corresponding to the current reconstructed event - - for (auto& collision : collisions) { - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - auto mccollision = collision.emmcevent_as(); - - auto posTracks_per_coll = posTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - auto negTracks_per_coll = negTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int mother_id = FindLF(t1, t2, mcparticles); - int hfee_type = IsHF(t1, t2, mcparticles); - if (mother_id < 0 && hfee_type < 0) { - continue; - } - ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - - if (v12.Rapidity() < minY || maxY < v12.Rapidity()) { - continue; - } - - if (mother_id > -1) { - auto mcmother = mcparticles.iteratorAt(mother_id); - if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { - - switch (abs(mcmother.pdgCode())) { - case 221: - fRegistry.fill(HIST("Generated/sm/Eta/hMvsPt"), v12.M(), v12.Pt()); - break; - case 331: - fRegistry.fill(HIST("Generated/sm/EtaPrime/hMvsPt"), v12.M(), v12.Pt()); - break; - case 113: - fRegistry.fill(HIST("Generated/sm/Rho/hMvsPt"), v12.M(), v12.Pt()); - break; - case 223: - fRegistry.fill(HIST("Generated/sm/Omega/hMvsPt"), v12.M(), v12.Pt()); - break; - case 333: - fRegistry.fill(HIST("Generated/sm/Phi/hMvsPt"), v12.M(), v12.Pt()); - break; - case 443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptJPsi/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/sm/PromptJPsi/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - case 100443: { - if (IsFromBeauty(mcmother, mcparticles) > 0) { - fRegistry.fill(HIST("Generated/sm/NonPromptPsi2S/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/sm/PromptPsi2S/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - default: - break; - } - } - } else if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Generated/ccbar/c2mu_c2mu/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2mu_c2mu/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2mu_c2mu/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/ccbar/c2mu_c2mu/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2c2mu/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2mu_b2mu/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_sameb/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_sameb/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_sameb/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_sameb/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } // end of HF evaluation - } // end of true ULS pair loop - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 0) { - continue; - } - ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (v12.Rapidity() < minY || maxY < v12.Rapidity()) { - continue; - } - if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2mu_b2mu_diffb/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - default: - break; - } - } - } // end of true LS++ pair loop - - for (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)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 0) { - continue; - } - ROOT::Math::PtEtaPhiMVector v1(t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v2(t2.pt(), t2.eta(), t2.phi(), o2::constants::physics::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - if (v12.Rapidity() < minY || maxY < v12.Rapidity()) { - continue; - } - if (hfee_type > -1) { - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - 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/b2c2mu_b2mu_diffb/hadron_hadron/hMvsPt"), v12.M(), v12.Pt()); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/meson_meson/hMvsPt"), v12.M(), v12.Pt()); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/baryon_baryon/hMvsPt"), v12.M(), v12.Pt()); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2mu_diffb/meson_baryon/hMvsPt"), v12.M(), v12.Pt()); - } - break; - } - default: - break; - } - } - } // end of true LS++ pair loop - - } // end of collision loop - } - PROCESS_SWITCH(dimuonQCMC, processGen, "run genrated info", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(dimuonQCMC, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"dimuon-qc-mc"})}; -} diff --git a/PWGEM/Dilepton/Tasks/emEfficiencyEE.cxx b/PWGEM/Dilepton/Tasks/emEfficiencyEE.cxx index c9860ca0916..7cc41a190d2 100644 --- a/PWGEM/Dilepton/Tasks/emEfficiencyEE.cxx +++ b/PWGEM/Dilepton/Tasks/emEfficiencyEE.cxx @@ -46,6 +46,7 @@ #include "DataFormatsParameters/GRPMagField.h" #include "Field/MagneticField.h" #include "TGeoGlobalMagField.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" using std::cout; using std::endl; @@ -88,7 +89,7 @@ using MyBarrelTracksSelectedNoSkimmed = soa::Join; -using MyMCTrackNoSkimmed = soa::Join; +using MyMCTrackNoSkimmed = soa::Join; constexpr static uint32_t gkEventFillMapNoSkimmed = VarManager::ObjTypes::Collision; constexpr static uint32_t gkMCEventFillMapNoSkimmed = VarManager::ObjTypes::CollisionMC; @@ -101,7 +102,7 @@ using MyEventsSelected = soa::Join; using MyBarrelTracks = soa::Join; using MyBarrelTracksSelected = soa::Join; -using MyMCReducedTracks = soa::Join; +using MyMCReducedTracks = soa::Join; // constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended; constexpr static uint32_t gkMCEventFillMap = VarManager::ObjTypes::ReducedEventMC; @@ -118,9 +119,12 @@ struct AnalysisEventSelection { Configurable fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"}; Configurable fConfigQA{"cfgQA", false, "If true, fill QA histograms"}; Configurable fConfigAddEventHistogram{"cfgAddEventHistogram", "", "Comma separated list of histograms"}; + Configurable fConfigOnlyInjectedEvents{"cfgOnlyInjectedEvents", false, "Use only on Non-skimmed data! If true, select only injected events"}; + Configurable> fSubGenIDs{"cfgSubGenIDs", {0, 1, 2, 3}, "Use only on Non-skimmed data! Provide a comma separated list of subGenIDs to select, e.g. 0,1,2,3"}; HistogramManager* fHistMan; AnalysisCompositeCut* fEventCut; + HistogramRegistry registry{"HistoAnalysisEvent", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { @@ -135,8 +139,13 @@ struct AnalysisEventSelection { fHistMan->SetUseDefaultVariableNames(kTRUE); fHistMan->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); DefineHistograms(fHistMan, "Event_BeforeCuts;Event_AfterCuts;", fConfigAddEventHistogram); // define all histograms - VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + VarManager::SetUseVars(fHistMan->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fOutputList.setObject(fHistMan->GetMainHistogramList()); + + AxisSpec axisSubGen = {4, -0.5, 3.5, "MC SubGenerator ID"}; + registry.add("Generator/SubGenerator_BeforeCuts", "", HistType::kTH1D, {axisSubGen}, true); + registry.add("Generator/SubGenerator_SelectedInjected", "", HistType::kTH1D, {axisSubGen}, true); + registry.add("Generator/SubGenerator_AfterCuts", "", HistType::kTH1D, {axisSubGen}, true); } } @@ -147,23 +156,40 @@ struct AnalysisEventSelection { VarManager::ResetValues(0, VarManager::kNEventWiseVariables); bool pass = true; + int32_t subGeneratorID = -999; VarManager::FillEvent(event); if constexpr ((TEventMCFillMap & VarManager::ObjTypes::ReducedEventMC) > 0) { VarManager::FillEvent(event.reducedMCevent()); + // TODO: Get access to subgenerator ID in skimmed data + // generatorID = event.reducedMCevent().generatorsID(); } if constexpr ((TEventMCFillMap & VarManager::ObjTypes::CollisionMC) > 0) { if (!event.has_mcCollision()) { pass = false; } else { VarManager::FillEvent(event.mcCollision()); + subGeneratorID = event.mcCollision().getSubGeneratorId(); } } + + registry.fill(HIST("Generator/SubGenerator_BeforeCuts"), subGeneratorID); + + // check if SubGeneratorID is part of list: + // if SubGenerator is not part of it, reject event, return + // fill event histos only if event is from SubGenerator + if (fConfigOnlyInjectedEvents && !(std::find(fSubGenIDs->begin(), fSubGenIDs->end(), subGeneratorID) != fSubGenIDs->end())) { + eventSel(0); + return; + } + if (fConfigQA) { fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues); // automatically fill all the histograms in the class Event + registry.fill(HIST("Generator/SubGenerator_SelectedInjected"), subGeneratorID); } if (fEventCut->IsSelected(VarManager::fgValues) && pass) { if (fConfigQA) { fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues); + registry.fill(HIST("Generator/SubGenerator_AfterCuts"), subGeneratorID); } eventSel(1); } else { @@ -196,6 +222,7 @@ struct AnalysisEventSelection { PROCESS_SWITCH(AnalysisEventSelection, processDummy, "Dummy process function", false); PROCESS_SWITCH(AnalysisEventSelection, processDummyNoSkimmed, "Dummy process function", false); }; + struct AnalysisEventQa { Filter filterEventSelected = aod::emanalysisflags::isEventSelected == 1; @@ -413,16 +440,17 @@ struct AnalysisTrackSelection { // 3D histos for efficiency Configurable fConfigUsePtVec{"cfgUsePtVecEff", true, "If true, non-linear pt bins but vector pt bins"}; - ConfigurableAxis ptBinsVec{"ptBinsVec", {0., 0., 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.155, 0.16, 0.165, 0.17, 0.175, 0.18, 0.185, 0.19, 0.195, 0.20, 0.205, 0.21, 0.215, 0.22, 0.225, 0.23, 0.235, 0.24, 0.245, 0.25, 0.255, 0.26, 0.265, 0.27, 0.275, 0.28, 0.285, 0.29, 0.295, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.43, 0.46, 0.49, 0.52, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.90, 1.00, 1.10, 1.20, 1.40, 1.60, 1.80, 2.00, 2.40, 2.80, 3.20, 3.70, 4.50, 6.00, 8.00, 10.}, "Pt binning vector"}; + ConfigurableAxis ptBinsVec{"ptBinsVec", {0., 0., 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.155, 0.16, 0.165, 0.17, 0.175, 0.18, 0.185, 0.19, 0.195, 0.20, 0.205, 0.21, 0.215, 0.22, 0.225, 0.23, 0.235, 0.24, 0.245, 0.25, 0.255, 0.26, 0.265, 0.27, 0.275, 0.28, 0.285, 0.29, 0.295, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.43, 0.46, 0.49, 0.52, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.90, 1.00, 1.10, 1.20, 1.40, 1.60, 1.80, 2.00, 2.40, 2.80, 3.20, 3.70, 4.50, 6.00, 8.00, 10., 12., 14., 16., 18., 20.}, "Pt binning vector"}; ConfigurableAxis ptBins{"ptBins", {10, 0.f, 10.f}, "Pt binning"}; ConfigurableAxis etaBins{"etaBins", {16, -0.8f, 0.8f}, "Eta binning"}; ConfigurableAxis phiBins{"phiBins", {63, -0.f, 6.3f}, "Phi binning"}; Configurable fConfigRecWithMC{"cfgEffRecWithMCVars", false, "If true, fill also 3D histograms at reconstructed level with mc variables"}; + Configurable fConfigMCCollz{"cfgMCCollz", false, "If true, look only at reconstructed track associated to mc track from a MC collision within 10cm"}; // Resolution histos Configurable fConfigResolutionOn{"cfgResolution", false, "If true, fill resolution histograms"}; Configurable fConfigUsePtVecRes{"cfgUsePtVecRes", true, "If true, non-linear pt bins predefined in res histos"}; - ConfigurableAxis ptResBinsVec{"ptResBinsVec", {0., 0., 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.155, 0.16, 0.165, 0.17, 0.175, 0.18, 0.185, 0.19, 0.195, 0.20, 0.205, 0.21, 0.215, 0.22, 0.225, 0.23, 0.235, 0.24, 0.245, 0.25, 0.255, 0.26, 0.265, 0.27, 0.275, 0.28, 0.285, 0.29, 0.295, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.43, 0.46, 0.49, 0.52, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.90, 1.00, 1.10, 1.20, 1.40, 1.60, 1.80, 2.00, 2.40, 2.80, 3.20, 3.70, 4.50, 6.00, 8.00, 10., 12.0, 14., 16., 18., 20.}, "Pt binning vector for resolution"}; + ConfigurableAxis ptResBinsVec{"ptResBinsVec", {0., 0., 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.155, 0.16, 0.165, 0.17, 0.175, 0.18, 0.185, 0.19, 0.195, 0.20, 0.205, 0.21, 0.215, 0.22, 0.225, 0.23, 0.235, 0.24, 0.245, 0.25, 0.255, 0.26, 0.265, 0.27, 0.275, 0.28, 0.285, 0.29, 0.295, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.43, 0.46, 0.49, 0.52, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.90, 1.00, 1.10, 1.20, 1.40, 1.60, 1.80, 2.00, 2.40, 2.80, 3.20, 3.70, 4.50, 6.00, 8.00, 10., 12., 14., 16., 18., 20.}, "Pt binning vector for resolution"}; ConfigurableAxis ptResBins{"ptResBins", {20, 0.f, 20.f}, "Pt binning for resolution"}; ConfigurableAxis deltaptResBins{"deltaptResBins", {500, -0.5f, 0.5f}, "DeltaPt binning for resolution"}; ConfigurableAxis deltaetaResBins{"deltaetaResBins", {500, -0.5f, 0.5f}, "DeltaEta binning for resolution"}; @@ -452,6 +480,13 @@ struct AnalysisTrackSelection { std::vector> fHistRecNegPart; std::vector> fHistRecPosPartMC; std::vector> fHistRecNegPartMC; + // + std::vector> fHistRecPosSingleRecPartMC; + std::vector> fHistRecNegSingleRecPartMC; + std::vector> fHistRecPosClassCollDoubleCountPartMC; + std::vector> fHistRecNegClassCollDoubleCountPartMC; + std::vector> fHistRecPosClassAmbigCollDoubleCountPartMC; + std::vector> fHistRecNegClassAmbigCollDoubleCountPartMC; // Res histos std::vector> fHistRes; @@ -460,7 +495,7 @@ struct AnalysisTrackSelection { HistogramManager* fHistManQA; // histo manager std::vector fHistNamesRecoQA; // list of histo names for all reconstructed tracks in histo manager std::vector> fHistNamesMCMatchedQA; // list of histo names for reconstructed signals in histo manager - std::vector> fHistNamesMCQA; // list of histo names for generated signals in histo manager + std::vector fHistNamesMCQA; // list of histo names for generated signals in histo manager void init(o2::framework::InitContext&) { @@ -474,6 +509,9 @@ struct AnalysisTrackSelection { AxisSpec axisEta{etaBins, "#it{#eta}_{e}"}; AxisSpec axisPhi{phiBins, "#it{#varphi}_{e} (rad)"}; AxisSpec axisPt{ptBins, "#it{p}_{T,e} (GeV/#it{c})"}; + AxisSpec axisMCColl = {3, -0.5, 2.5, "MCcoll info"}; + AxisSpec axisDoubleCount = {2, -0.5, 1.5, "Double count info"}; + AxisSpec axisAmbig = {2, -0.5, 1.5, "Ambiguous info"}; // List of track cuts TString cutNamesStr = fConfigCuts.value; @@ -542,21 +580,51 @@ struct AnalysisTrackSelection { if (fConfigRecWithMC) { for (unsigned int list_i = 0; list_i < fTrackCuts.size(); ++list_i) { for (unsigned int i = 0; i < fMCSignals.size(); ++i) { - if (!fConfigUsePtVec) { fHistRecPosPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); fHistRecNegPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecPosSingleRecPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_SingleRec_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecNegSingleRecPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_SingleRec_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecPosClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_ClassCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_ClassCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisMCColl, axisDoubleCount}, true)); } else { fHistRecPosPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); fHistRecNegPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecPosSingleRecPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_SingleRec_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecNegSingleRecPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_SingleRec_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecPosClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_ClassCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_ClassCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisMCColl, axisDoubleCount}, true)); } + fHistRecPosClassAmbigCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Pos_ClassAmigCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisAmbig, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassAmbigCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/%s_MCVars/Nrec_Neg_ClassAmigCollDoubleCount_%s", fTrackCuts.at(list_i).GetName(), fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisAmbig, axisMCColl, axisDoubleCount}, true)); } } + // Histo without track cut + for (unsigned int i = 0; i < fMCSignals.size(); ++i) { + + if (!fConfigUsePtVec) { + fHistRecPosPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecNegPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecPosSingleRecPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_SingleRec_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecNegSingleRecPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_SingleRec_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisEta, axisPhi}, true)); + fHistRecPosClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_ClassCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_ClassCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisPt, axisMCColl, axisDoubleCount}, true)); + + } else { + fHistRecPosPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecNegPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecPosSingleRecPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_SingleRec_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecNegSingleRecPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_SingleRec_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisEta, axisPhi}, true)); + fHistRecPosClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_ClassCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_ClassCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {{ptBinsVec, "#it{p}_{T,e} (GeV/#it{c})"}, axisMCColl, axisDoubleCount}, true)); + } + fHistRecPosClassAmbigCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Pos_ClassAmigCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisAmbig, axisMCColl, axisDoubleCount}, true)); + fHistRecNegClassAmbigCollDoubleCountPartMC.push_back(registry.add(Form("SingleElectron/NoCut_MCVars/Nrec_Neg_ClassAmigCollDoubleCount_%s", fMCSignals.at(i).GetName()), "", HistType::kTH3D, {axisAmbig, axisMCColl, axisDoubleCount}, true)); + } } // Resolution histogramms if (fConfigResolutionOn) { - // Binning for resolution AxisSpec axisPtRes{ptResBins, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}; AxisSpec axisDeltaptRes{deltaptResBins, "(p^{gen}_{T} - p^{rec}_{T}) / p^{gen}_{T} (GeV/c)"}; @@ -598,19 +666,20 @@ struct AnalysisTrackSelection { } // Add histogram classes for each MC signal at generated level - std::vector mcnamesgen; + // std::vector mcnamesgen; for (unsigned int isig = 0; isig < fMCSignals.size(); ++isig) { TString nameStr2 = Form("MCTruthGen_%s", fMCSignals.at(isig).GetName()); - mcnamesgen.push_back(nameStr2); + fHistNamesMCQA.push_back(nameStr2); + // mcnamesgen.push_back(nameStr2); histClassesQA += Form("%s;", nameStr2.Data()); } - fHistNamesMCQA.push_back(mcnamesgen); + // fHistNamesMCQA.push_back(mcnamesgen); fHistManQA = new HistogramManager("SingleElectronQA", "aa", VarManager::kNVars); fHistManQA->SetUseDefaultVariableNames(kTRUE); fHistManQA->SetDefaultVarNames(VarManager::fgVariableNames, VarManager::fgVariableUnits); DefineHistograms(fHistManQA, histClassesQA.Data(), fConfigAddTrackHistogram); // define all histograms - VarManager::SetUseVars(fHistManQA->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill + VarManager::SetUseVars(fHistManQA->GetUsedVars()); // provide the list of required variables so that VarManager knows what to fill fQASingleElectronList = fHistManQA->GetMainHistogramList(); } fOutputQA.setObject(fQASingleElectronList); @@ -700,6 +769,16 @@ struct AnalysisTrackSelection { runRecTrack(tracks, tracksMC, true, write); } + template + void runDataFillMore(TEvents const& events, TEventsMC eventsMC, TTracks const& tracks, TTracksMC const& tracksMC, TAmbigTracks const& ambiTracksMid) + { + + VarManager::ResetValues(0, VarManager::kNEventWiseVariables); + VarManager::ResetValues(0, VarManager::kNMCParticleVariables); + + runRecTrackMore(events, eventsMC, tracks, tracksMC, ambiTracksMid); + } + template void runMCFill(TEventsMC const& eventMC, TTracksMC const& tracksMC) { @@ -708,6 +787,14 @@ struct AnalysisTrackSelection { runMCGenTrack(tracksMC); } + template + void runMCFillMore(TEventsMC const& eventMC, TTracksMC const& tracksMC) + { + VarManager::ResetValues(0, VarManager::kNEventWiseVariables); + VarManager::FillEvent(eventMC); + runMCGenTrackMore(tracksMC, eventMC); + } + template void runDataSelection(TTracks const& tracks, TTracksMC const& tracksMC) { @@ -717,9 +804,52 @@ struct AnalysisTrackSelection { template void runMCGenTrack(TTracksMC const& groupedMCTracks) + { + for (auto& mctrack : groupedMCTracks) { + VarManager::ResetValues(0, VarManager::kNMCParticleVariables); + VarManager::FillTrackMC(groupedMCTracks, mctrack); + int isig = 0; + for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { + bool checked = false; + if constexpr (soa::is_soa_filtered_v) { + auto mctrack_raw = groupedMCTracks.rawIteratorAt(mctrack.globalIndex()); + checked = (*sig).CheckSignal(true, mctrack_raw); + } else { + checked = (*sig).CheckSignal(true, mctrack); + } + if (checked) { + if (mctrack.pdgCode() > 0) { + fHistGenNegPart[isig]->Fill(mctrack.pt(), mctrack.eta(), mctrack.phi()); + if constexpr (smeared) + fHistGenSmearedNegPart[isig]->Fill(mctrack.ptSmeared(), mctrack.etaSmeared(), mctrack.phiSmeared()); + } else { + fHistGenPosPart[isig]->Fill(mctrack.pt(), mctrack.eta(), mctrack.phi()); + if constexpr (smeared) + fHistGenSmearedPosPart[isig]->Fill(mctrack.ptSmeared(), mctrack.etaSmeared(), mctrack.phiSmeared()); + } + if (fConfigQA) { + fHistManQA->FillHistClass(fHistNamesMCQA[isig].Data(), VarManager::fgValues); + } + } + } + } + } + + template + void runMCGenTrackMore(TTracksMC const& groupedMCTracks, TEventsMC const& /*eventMC*/) { for (auto& mctrack : groupedMCTracks) { + + bool mccollisionwithin10 = false; + auto mccollision = mctrack.mcCollision(); + Double_t zmc = mccollision.posZ(); + if (TMath::Abs(zmc) < 10.) + mccollisionwithin10 = true; + + if (!mccollisionwithin10 && fConfigMCCollz) + continue; + VarManager::ResetValues(0, VarManager::kNMCParticleVariables); VarManager::FillTrackMC(groupedMCTracks, mctrack); int isig = 0; @@ -742,7 +872,8 @@ struct AnalysisTrackSelection { fHistGenSmearedPosPart[isig]->Fill(mctrack.ptSmeared(), mctrack.etaSmeared(), mctrack.phiSmeared()); } if (fConfigQA) - fHistManQA->FillHistClass(Form("MCTruthGen_%s", (*sig).GetName()), VarManager::fgValues); + // fHistManQA->FillHistClass(Form("MCTruthGen_%s", (*sig).GetName()), VarManager::fgValues); + fHistManQA->FillHistClass(fHistNamesMCQA[isig].Data(), VarManager::fgValues); } } } @@ -900,6 +1031,254 @@ struct AnalysisTrackSelection { } // end loop over reconstructed track belonging to the events } + template + void runRecTrackMore(TEvents const& events, TEventsMC const& /*eventsMC*/, TTracks const& groupedTracks, TTracksMC const& tracksMC, TAmbigTracks const& ambiTracksMid) + { + + std::map fRecTrackLabels[fTrackCuts.size() + 1]; + + uint32_t filterMap = 0; + trackSel.reserve(groupedTracks.size()); + + for (auto& track : groupedTracks) { + + // How many time the associated MC track was seen for this cut + Int_t fRecCounters[fTrackCuts.size() + 1]; + for (unsigned int k = 0; k < fTrackCuts.size() + 1; k++) { + fRecCounters[k] = 0; + } + + filterMap = 0; + Int_t ambiguousinfo = 0; + Int_t collisioninfo = -1; + Int_t mcCollisionIddmctrack = -999; + Int_t mcCollisionIdrectrack = -999; + bool mccollisionwithin10 = false; + + VarManager::FillTrack(track); // compute track quantities + + // Do ambiguous tracks + for (auto& ambiTrackMid : ambiTracksMid) { + if (ambiTrackMid.trackId() == track.globalIndex()) { + ambiguousinfo = 1; + break; + } + } + + // Do matching + // if (!track.has_collision()) printf("CollisionId %d\n",track.collisionId()); + if (track.has_collision()) { + Int_t reccollisionid = track.collisionId(); + if (ambiguousinfo == 1) + printf("Has reccollision but is ambiguous\n"); + // printf("Look for the reconstructed collision %d\n",reccollisionid); + bool pass = 0; + for (auto& event : events) { + if (event.isEventSelected() == 1) { + VarManager::FillEvent(event); + // printf("Global index of collision %d\n",event.globalIndex()); + if (reccollisionid == event.globalIndex()) { + pass = 1; + // printf("Found a collision with the same id %d and %d\n",reccollisionid,event.globalIndex()); + if (ambiguousinfo == 1) + printf("Has reccollision and found it in the list but is ambiguous\n"); + if (event.has_mcCollision()) { + mcCollisionIdrectrack = event.mcCollisionId(); + if (ambiguousinfo == 1) + printf("Has reccollision with mccollision but is ambiguous\n"); + } else { + if (ambiguousinfo == 1) + printf("Has reccollision but without mccollision and is ambiguous\n"); + } + break; + } + } + } + if (!pass) // rec collision of track is not selected by isSelected + continue; + // else rec collision of track is selected by isSelected + } else { + // printf("Not attached to a reconstructed collision\n"); + } + + if constexpr ((TTrackFillMap & VarManager::ObjTypes::Track) > 0) { + // If no MC particle is found, skip the track + if (track.has_mcParticle()) { + // if (ambiguousinfo == 1) printf("Has mcparticle but is ambiguous\n"); + // printf("Found a mc track\n"); + auto mctrack = track.template mcParticle_as(); + mcCollisionIddmctrack = mctrack.mcCollisionId(); + auto mccollision = mctrack.mcCollision(); + Double_t zmc = mccollision.posZ(); + if (TMath::Abs(zmc) < 10.) + mccollisionwithin10 = true; + VarManager::FillTrackMC(tracksMC, mctrack); + } + } + + // no track cut + if (fConfigQA) { + fHistManQA->FillHistClass("TrackBarrel_BeforeCuts", VarManager::fgValues); + } + + // if (ambiguousinfo == 1) printf("Values are %d and %d\n",mcCollisionIddmctrack,mcCollisionIdrectrack); + // compute collision and mccollision info + if (mcCollisionIddmctrack != -999 && mcCollisionIdrectrack != -999) { + if (mcCollisionIddmctrack == mcCollisionIdrectrack) + collisioninfo = 0; + else + collisioninfo = 1; + } else { + collisioninfo = 2; + } + // printf("collision info %d\n",collisioninfo); + + // compute track selection and publish the bit map + int i = 0; + for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, i++) { + if ((*cut).IsSelected(VarManager::fgValues)) { + filterMap |= (uint32_t(1) << i); + if (fConfigQA) { + fHistManQA->FillHistClass(fHistNamesRecoQA[i].Data(), VarManager::fgValues); + } + } + } + + // compute MC matching decisions + uint32_t mcDecision = 0; + int isig = 0; + Int_t mctrackindex = -999; + Int_t doublereconstructedtrack[fTrackCuts.size() + 1]; + for (unsigned int k = 0; k < fTrackCuts.size() + 1; k++) { + doublereconstructedtrack[k] = 0; + } + for (auto sig = fMCSignals.begin(); sig != fMCSignals.end(); sig++, isig++) { + if constexpr ((TTrackFillMap & VarManager::ObjTypes::Track) > 0) { + if (track.has_mcParticle()) { + auto mctrack = track.template mcParticle_as(); + if ((*sig).CheckSignal(true, mctrack)) { + mcDecision |= (uint32_t(1) << isig); + mctrackindex = mctrack.globalIndex(); + } + } + } + } + + // // Double reconstructed track only for the signal (they should not be redundant or crossing!!) + // for (unsigned int i = 0; i < fMCSignals.size(); i++) { + // if (!(mcDecision & (uint32_t(1) << i))) { + // continue; + // } + + // no track cuts + if (!(fRecTrackLabels[fTrackCuts.size()].find(mctrackindex) != fRecTrackLabels[fTrackCuts.size()].end())) { + fRecTrackLabels[fTrackCuts.size()][mctrackindex] = fRecCounters[fTrackCuts.size()]; + fRecCounters[fTrackCuts.size()]++; + } else { + // printf("For cut %d, found a mc collision track already reconstructed %d for selected collision with the same mc collision %d\n",j,mctrackindex,mcCollisionId); + doublereconstructedtrack[fTrackCuts.size()] = 1; + fRecTrackLabels[fTrackCuts.size()][mctrackindex] = fRecTrackLabels[fTrackCuts.size()].find(mctrackindex)->second + 1; + } + // track cuts + for (unsigned int j = 0; j < fTrackCuts.size(); j++) { + if (filterMap & (uint8_t(1) << j)) { + + if (!(fRecTrackLabels[j].find(mctrackindex) != fRecTrackLabels[j].end())) { + fRecTrackLabels[j][mctrackindex] = fRecCounters[j]; + fRecCounters[j]++; + } else { + // printf("For cut %d, found a mc collision track already reconstructed %d for selected collision with the same mc collision %d\n",j,mctrackindex,mcCollisionId); + doublereconstructedtrack[j] = 1; + fRecTrackLabels[j][mctrackindex] = fRecTrackLabels[j].find(mctrackindex)->second + 1; + } + } + } + // } + + // fill histograms + for (unsigned int i = 0; i < fMCSignals.size(); i++) { + if (!(mcDecision & (uint32_t(1) << i))) { + continue; + } + Double_t mmcpt = -10000.; + Double_t mmceta = -10000.; + Double_t mmcphi = -1000.; + // No track cut + if (fConfigRecWithMC) { + if constexpr ((TTrackFillMap & VarManager::ObjTypes::ReducedTrack) > 0) { + auto mctrack = track.reducedMCTrack(); + mmcpt = mctrack.pt(); + mmceta = mctrack.eta(); + mmcphi = mctrack.phi(); + } + if constexpr ((TTrackFillMap & VarManager::ObjTypes::Track) > 0) { + if (track.has_mcParticle()) { + auto mctrack = track.template mcParticle_as(); + mmcpt = mctrack.pt(); + mmceta = mctrack.eta(); + mmcphi = mctrack.phi(); + } + } + + if ((mccollisionwithin10 && fConfigMCCollz) || (!fConfigMCCollz)) { + if (track.sign() < 0) { + fHistRecNegPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (doublereconstructedtrack[fTrackCuts.size()] == 0) + fHistRecNegSingleRecPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (TMath::Abs(mmceta) < 0.8) { + fHistRecNegClassCollDoubleCountPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + fHistRecNegClassAmbigCollDoubleCountPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(ambiguousinfo, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + } + } else { + fHistRecPosPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (doublereconstructedtrack[fTrackCuts.size()] == 0) + fHistRecPosSingleRecPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (TMath::Abs(mmceta) < 0.8) { + fHistRecPosClassCollDoubleCountPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(mmcpt, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + fHistRecPosClassAmbigCollDoubleCountPartMC[fTrackCuts.size() * fMCSignals.size() + i]->Fill(ambiguousinfo, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + } + } + } + } + // track cuts + for (unsigned int j = 0; j < fTrackCuts.size(); j++) { + if (filterMap & (uint8_t(1) << j)) { + if (track.sign() < 0) { + fHistRecNegPart[j * fMCSignals.size() + i]->Fill(track.pt(), track.eta(), track.phi()); + } else { + fHistRecPosPart[j * fMCSignals.size() + i]->Fill(track.pt(), track.eta(), track.phi()); + } + + if (fConfigRecWithMC) { + if ((mccollisionwithin10 && fConfigMCCollz) || (!fConfigMCCollz)) { + if (track.sign() < 0) { + fHistRecNegPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (doublereconstructedtrack[j] == 0) + fHistRecNegSingleRecPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (TMath::Abs(mmceta) < 0.8) { + fHistRecNegClassCollDoubleCountPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, collisioninfo, doublereconstructedtrack[j]); + fHistRecNegClassAmbigCollDoubleCountPartMC[j * fMCSignals.size() + i]->Fill(ambiguousinfo, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + } + } else { + fHistRecPosPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (doublereconstructedtrack[j] == 0) + fHistRecPosSingleRecPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, mmceta, mmcphi); + if (TMath::Abs(mmceta) < 0.8) { + fHistRecPosClassCollDoubleCountPartMC[j * fMCSignals.size() + i]->Fill(mmcpt, collisioninfo, doublereconstructedtrack[j]); + fHistRecPosClassAmbigCollDoubleCountPartMC[j * fMCSignals.size() + i]->Fill(ambiguousinfo, collisioninfo, doublereconstructedtrack[fTrackCuts.size()]); + } + } + } + } + + if (fConfigQA) + fHistManQA->FillHistClass(fHistNamesMCMatchedQA[j][i].Data(), VarManager::fgValues); + } + } // end loop over cuts + } // end loop over MC signals + } // end loop over reconstructed track belonging to the events + } + void processSkimmed(soa::Filtered const& events, MyBarrelTracks const& tracks, ReducedMCEvents const& eventsMC, ReducedMCTracks const& tracksMC) { runSelection(events, tracks, eventsMC, tracksMC, true); @@ -925,15 +1304,48 @@ struct AnalysisTrackSelection { } void processMCNoSkimmed(soa::Filtered::iterator const& eventMC, MyMCTrackNoSkimmed const& tracksMC) + // void processMCNoSkimmed(aod::McCollisions::iterator const& eventMC, MyMCTrackNoSkimmed const& tracksMC) { runMCFill(eventMC, tracksMC); } + // void processMCNoSkimmed(MyMCTrackNoSkimmed const& tracksMC) + // { + // runMCGenTrack(tracksMC); + // } + + void processMCNoSkimmedMore(soa::Filtered::iterator const& eventMC, MyMCTrackNoSkimmed const& tracksMC) + // void processMCNoSkimmedMore(aod::McCollisions::iterator const& eventMC, MyMCTrackNoSkimmed const& tracksMC) + { + runMCFillMore(eventMC, tracksMC); + } + + // void processMCNoSkimmedMore(MyMCTrackNoSkimmed const& tracksMC, aod::McCollisions const& eventsMC) + // { + // runMCGenTrackMore(tracksMC, eventsMC); + // } + void processDataNoSkimmed(soa::Filtered::iterator const& event, MyBarrelTracksNoSkimmed const& tracks, aod::McParticles const& tracksMC) { runDataFill(event, tracks, tracksMC, false); } + // void processDataNoSkimmed(MyBarrelTracksNoSkimmed const& tracks, aod::McParticles const& tracksMC) + // { + // runRecTrack(tracks, tracksMC, true, false); + // // runDataFill(event, tracks, tracksMC, false); + // } + + void processDataNoSkimmedMore(soa::Filtered const& events, aod::McCollisions const& eventsMC, MyBarrelTracksNoSkimmed const& tracks, aod::McParticles const& tracksMC, aod::AmbiguousTracks const& ambiTracksMid) + { + runDataFillMore(events, eventsMC, tracks, tracksMC, ambiTracksMid); + } + + // void processDataNoSkimmedMore(MyBarrelTracksNoSkimmed const& tracks, aod::McParticles const& tracksMC, aod::AmbiguousTracks const& ambiTracksMid, MyEventsNoSkimmed const& events, aod::McCollisions const& eventsMC) + // { + // runRecTrackMore(events, eventsMC, tracks, tracksMC, ambiTracksMid); + // } + void processDummy(MyEvents&) { // do nothing @@ -946,7 +1358,9 @@ struct AnalysisTrackSelection { PROCESS_SWITCH(AnalysisTrackSelection, processDataSelectionNoSkimmed, "Run barrel track selection without skimming", false); PROCESS_SWITCH(AnalysisTrackSelection, processMCNoSkimmed, "Run the barrel MC track filling without skimming", false); + PROCESS_SWITCH(AnalysisTrackSelection, processMCNoSkimmedMore, "Run the barrel MC track filling without skimming", false); PROCESS_SWITCH(AnalysisTrackSelection, processDataNoSkimmed, "Run the barrel data track filling without skimming", false); + PROCESS_SWITCH(AnalysisTrackSelection, processDataNoSkimmedMore, "Run the barrel data track filling without skimming", false); PROCESS_SWITCH(AnalysisTrackSelection, processSkimmed, "Run the data and mc barrel data track selection and filling on DQ skimmed tracks", false); PROCESS_SWITCH(AnalysisTrackSelection, processDataSkimmed, "Run the barrel data track selection and filling on DQ skimmed tracks", false); PROCESS_SWITCH(AnalysisTrackSelection, processMCSkimmed, "Run the barrel mc track filling on DQ skimmed tracks", false); @@ -1200,6 +1614,7 @@ struct AnalysisSameEventPairing { template void runDataPairing(TEvent const& event, TTracks const& tracks, TTracksMC const& tracksMC) { + VarManager::ResetValues(0, VarManager::kNEventWiseVariables); // fill event information which might be needed in histograms that combine track and event properties VarManager::FillEvent(event); @@ -1622,7 +2037,7 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses, Configurab histMan->AddHistogram(objArray->At(iclass)->GetName(), "Phi", "MC generator #varphi distribution", false, 500, -6.3, 6.3, VarManager::kMCPhi); } if (classStr.Contains("MCTruthGen")) { - dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth"); + dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth_track"); } if (classStr.Contains("DileptonsSelected")) { dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "pair_barrel"); diff --git a/PWGEM/Dilepton/Tasks/emuCorrelation.cxx b/PWGEM/Dilepton/Tasks/emuCorrelation.cxx deleted file mode 100644 index 2ff6fc40e88..00000000000 --- a/PWGEM/Dilepton/Tasks/emuCorrelation.cxx +++ /dev/null @@ -1,830 +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 dalitz ee table for dalitz QC. -// 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/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.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" - -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::emtrackutil; -using namespace o2::aod::pwgem::dilepton::utils; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyElectrons = soa::Join; -using MyElectron = MyElectrons::iterator; - -using MyMuons = soa::Join; -using MyMuon = MyMuons::iterator; - -using MyEMH_el = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMTrackWithCov>; -using MyEMH_mu = o2::aod::pwgem::dilepton::utils::EventMixingHandler, std::pair, EMFwdTrackWithCov>; - -struct emuCorrelation { - - // 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 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.f, "max. centrality"}; - Configurable cfgDoMix{"cfgDoMix", true, "flag for event mixing"}; - Configurable ndepth{"ndepth", 1000, "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 ConfMemuBins{"ConfMemuBins", {VARIABLE_WIDTH, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0}, "memu bins for output histograms"}; - ConfigurableAxis ConfPtemuBins{"ConfPtemuBins", {VARIABLE_WIDTH, 0.00, 10.00}, "pTemu bins for output histograms"}; - ConfigurableAxis ConfDCAemuBins{"ConfDCAemuBins", {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}, "single leg DCA bins for output histograms"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - DielectronCut fDielectronCut; - 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_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_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"}; - Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; - - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "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", 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_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(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3]"}; - 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_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 enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; - - // CCDB configuration for PID ML - Configurable BDTLocalPathGamma{"BDTLocalPathGamma", "pid_ml_xgboost.onnx", "Path to the local .onnx file"}; - Configurable BDTPathCCDB{"BDTPathCCDB", "Users/d/dsekihat/pwgem/pidml/", "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)"}; - } 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_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_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_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_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_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"}; - } dimuoncuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - int mRunNumber; - float d_bz; - o2::vertexing::DCAFitterN<2> fitter; - 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 ep_bin_edges; - std::vector occ_bin_edges; - - void init(InitContext& /*context*/) - { - 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()); - - occ_bin_edges = std::vector(ConfOccupancyBins.value.begin(), ConfOccupancyBins.value.end()); - occ_bin_edges.erase(occ_bin_edges.begin()); - - emh_el_pos = new MyEMH_el(ndepth); - emh_mu_pos = new MyEMH_mu(ndepth); - emh_el_neg = new MyEMH_el(ndepth); - emh_mu_neg = new MyEMH_mu(ndepth); - - DefineEMEventCut(); - DefineDielectronCut(); - DefineDimuonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - 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); - } - - 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(); - fitter.setBz(d_bz); - 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(); - fitter.setBz(d_bz); - } - - ~emuCorrelation() - { - delete emh_el_pos; - emh_el_pos = 0x0; - delete emh_mu_pos; - emh_mu_pos = 0x0; - - delete emh_el_neg; - emh_el_neg = 0x0; - delete emh_mu_neg; - emh_mu_neg = 0x0; - - used_electronIds.clear(); - used_electronIds.shrink_to_fit(); - used_muonIds.clear(); - used_muonIds.shrink_to_fit(); - } - - void addhistograms() - { - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, false); - - // pair info - const AxisSpec axis_mass{ConfMemuBins, "m_{e#mu} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPtemuBins, "p_{T,e#mu} (GeV/c)"}; - const AxisSpec axis_rapidity{48, -4.0, +0.8, "y_{e#mu}"}; - const AxisSpec axis_dca_el{ConfDCAemuBins, "DCA_{e}^{3D} (#sigma)"}; - const AxisSpec axis_dca_mu{ConfDCAemuBins, "DCA_{#mu}^{XY} (#sigma)"}; - const AxisSpec axis_dphi{18, 0, M_PI, "#Delta#varphi_{e#mu} (rad.)"}; - - // std::string_view qvec_det_names[3] = {"FT0M", "FT0A", "FT0C"}; - - fRegistry.add("Pair/same/uls/hs", "e#mu", kTHnSparseD, {axis_mass, axis_pt, axis_rapidity, axis_dphi, axis_dca_el, axis_dca_mu}, true); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lspp/"); - fRegistry.addClone("Pair/same/uls/", "Pair/same/lsmm/"); - fRegistry.addClone("Pair/same/", "Pair/mix/"); - - // for electron info - fRegistry.add("Track/Electron/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/Electron/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/Electron/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); - fRegistry.add("Track/Electron/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/Electron/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/Electron/hDCAxy_Pt", "DCA_{xy} vs. pT;p_{T} (GeV/c);DCA_{xy} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/Electron/hDCAz_Pt", "DCA_{z} vs. pT;p_{T} (GeV/c);DCA_{z} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/Electron/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/Electron/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/Electron/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/Electron/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/Electron/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/Electron/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/Electron/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTOFbeta", "TOF beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {600, 0, 1.2}}, false); - fRegistry.add("Track/Electron/h1overTOFbeta", "TOF beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, false); - fRegistry.add("Track/Electron/hTOFNsigmaEl", "TOF n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTOFNsigmaMu", "TOF n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/Electron/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/Electron/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/Electron/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/Electron/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/Electron/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - - // for muon info - fRegistry.add("Track/Muon/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/Muon/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/Muon/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {25, -4.5f, -2.0f}}, false); - fRegistry.add("Track/Muon/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/Muon/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/Muon/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/Muon/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/Muon/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/Muon/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); - fRegistry.add("Track/Muon/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/Muon/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/Muon/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - void DefineDielectronCut() - { - fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); - - // for pair - fDielectronCut.SetMeeRange(dielectroncuts.cfg_min_mass, dielectroncuts.cfg_max_mass); - fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); - fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma - fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); - fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); - fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); - - // for track - fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); - fDielectronCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); - fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); - fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - 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.SetMeanClusterSizeITSob(0, 16); - fDielectronCut.SetMaxDcaXY(dielectroncuts.cfg_max_dcaxy); - fDielectronCut.SetMaxDcaZ(dielectroncuts.cfg_max_dcaz); - - // 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.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); - - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut - o2::ml::OnnxModel* eid_bdt = new o2::ml::OnnxModel(); - if (dielectroncuts.loadModelsFromCCDB) { - ccdbApi.init(ccdburl); - std::map metadata; - bool retrieveSuccessGamma = ccdbApi.retrieveBlob(dielectroncuts.BDTPathCCDB.value, ".", metadata, dielectroncuts.timestampCCDB.value, false, dielectroncuts.BDTLocalPathGamma.value); - if (retrieveSuccessGamma) { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.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 { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.enableOptimizations.value); - } - - fDielectronCut.SetPIDModel(eid_bdt); - } // 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.SetPairDCAxyRange(dimuoncuts.cfg_min_pair_dcaxy, dimuoncuts.cfg_max_pair_dcaxy); // DCAxy in cm - - // for track - fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); - fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_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); }); - } - - template - bool fillPairInfo(TCollision const& collision, TElectron const& t1, TMuon const& t2) - { - // if constexpr (ev_id == 1) { - // if (t1.has_ambiguousElectrons() && t2.has_ambiguousMuons()) { - // for (auto& possible_id1 : t1.ambiguousElectronsIds()) { - // for (auto& possible_id2 : t2.ambiguousMuonsIds()) { - // if (possible_id1 == possible_id2) { - // // LOGF(info, "event id = %d: same track is found. t1.trackId() = %d, t1.collisionId() = %d, t1.pt() = %f, t1.eta() = %f, t1.phi() = %f, t2.trackId() = %d, t2.collisionId() = %d, t2.pt() = %f, t2.eta() = %f, t2.phi() = %f", ev_id, t1.trackId(), t1.collisionId(), t1.pt(), t1.eta(), t1.phi(), t2.trackId(), t2.collisionId(), t2.pt(), t2.eta(), t2.phi()); - // 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. This never happens in e-mu correlation. - // } - // } - // } - // } - // } - - if constexpr (ev_id == 0) { - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!fDielectronCut.IsSelectedTrack(t1, collision)) { - return false; - } - } else { // cut-based - if (!fDielectronCut.IsSelectedTrack(t1)) { - return false; - } - } - - if (!fDimuonCut.IsSelectedTrack(t2)) { - 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - - float dca_3d_el = dca3DinSigma(t1); - float dca_xy_mu = fwdDcaXYinSigma(t2); - - if (t1.sign() * t2.sign() < 0) { // ULS - fRegistry.fill(HIST("Pair/") + HIST(event_pair_types[ev_id]) + HIST("uls/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } 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(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } 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(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } - - // 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; - std::copy(t1.ambiguousElectronsIds().begin(), t1.ambiguousElectronsIds().end(), std::back_inserter(possibleIds1)); - std::copy(t2.ambiguousMuonsIds().begin(), t2.ambiguousMuonsIds().end(), std::back_inserter(possibleIds2)); - - if (std::find(used_electronIds.begin(), used_electronIds.end(), pair_tmp_id1) == used_electronIds.end()) { - used_electronIds.emplace_back(pair_tmp_id1); - fillElectronInfo(t1); - if (cfgDoMix) { - if (t1.sign() > 0) { - emh_el_pos->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron, 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())); - } else { - emh_el_neg->AddTrackToEventPool(key_df_collision, EMTrackWithCov(t1.globalIndex(), collision.globalIndex(), t1.trackId(), t1.pt(), t1.eta(), t1.phi(), o2::constants::physics::MassElectron, 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())); - } - } - } - if (std::find(used_muonIds.begin(), used_muonIds.end(), pair_tmp_id2) == used_muonIds.end()) { - used_muonIds.emplace_back(pair_tmp_id2); - fillMuonInfo(t2); - if (cfgDoMix) { - if (t2.sign() > 0) { - emh_mu_pos->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } else { - emh_mu_neg->AddTrackToEventPool(key_df_collision, EMFwdTrackWithCov(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())); - } - } - } - } - return true; - } - - template - void fillElectronInfo(TTrack const& track) - { - fRegistry.fill(HIST("Track/Electron/hPt"), track.pt()); - fRegistry.fill(HIST("Track/Electron/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/Electron/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/Electron/hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/Electron/hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/Electron/hDCAxy_Pt"), track.pt(), track.dcaXY()); - fRegistry.fill(HIST("Track/Electron/hDCAz_Pt"), track.pt(), track.dcaZ()); - fRegistry.fill(HIST("Track/Electron/hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Electron/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Electron/hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/Electron/hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/Electron/hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/Electron/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/Electron/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/Electron/hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/Electron/hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/Electron/hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/Electron/hMeanClusterSizeITS"), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/Electron/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/Electron/hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/Electron/hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); - fRegistry.fill(HIST("Track/Electron/hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - fRegistry.fill(HIST("Track/Electron/hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); - fRegistry.fill(HIST("Track/Electron/hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/Electron/hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/Electron/h1overTOFbeta"), track.tpcInnerParam(), 1. / track.beta()); - fRegistry.fill(HIST("Track/Electron/hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/Electron/hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/Electron/hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/Electron/hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/Electron/hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - } - - template - void fillMuonInfo(TTrack const& track) - { - fRegistry.fill(HIST("Track/Muon/hPt"), track.pt()); - fRegistry.fill(HIST("Track/Muon/hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/Muon/hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/Muon/hTrackType"), track.trackType()); - fRegistry.fill(HIST("Track/Muon/hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/Muon/hDCAxySigma"), track.fwdDcaX() / sqrt(track.cXX()), track.fwdDcaY() / sqrt(track.cYY())); - fRegistry.fill(HIST("Track/Muon/hDCAxRes_Pt"), track.pt(), sqrt(track.cXX()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Muon/hDCAyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Muon/hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/Muon/hNclsMCH"), track.nClusters()); - fRegistry.fill(HIST("Track/Muon/hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/Muon/hChi2"), track.chi2()); - fRegistry.fill(HIST("Track/Muon/hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/Muon/hChi2MatchMCHMID"), track.chi2MatchMCHMID()); - fRegistry.fill(HIST("Track/Muon/hMFTClusterMap"), track.mftClusterMap()); - } - 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; - - SliceCache cache; - Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_el = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(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 = (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) && ((0.96f < o2::aod::pidtofbeta::beta && o2::aod::pidtofbeta::beta < 1.04f) || o2::aod::pidtofbeta::beta < 0.f); - Filter ttcaFilter_el = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); - using FilteredMyElectrons = soa::Filtered; - using FilteredMyElectron = FilteredMyElectrons::iterator; - - Preslice perCollision_muon = aod::emprimarymuon::emeventId; - Filter trackFilter_mu = 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; - Filter ttcaFilter_mu = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); - using FilteredMyMuons = soa::Filtered; - - MyEMH_el* emh_el_pos = nullptr; - MyEMH_mu* emh_mu_pos = nullptr; - MyEMH_el* emh_el_neg = nullptr; - MyEMH_mu* emh_mu_neg = nullptr; - - Partition posTracks_el = o2::aod::emprimaryelectron::sign > int8_t(0); - Partition negTracks_el = o2::aod::emprimaryelectron::sign < int8_t(0); - Partition posTracks_mu = o2::aod::emprimarymuon::sign > int8_t(0); - Partition negTracks_mu = o2::aod::emprimarymuon::sign < int8_t(0); - - std::vector> used_electronIds; - std::vector> used_muonIds; - int ndf = 0; - void processQC(FilteredMyCollisions const& collisions, FilteredMyElectrons const&, FilteredMyMuons const&) - { - for (auto& collision : collisions) { - initCCDB(collision); - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, false); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, false); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - - auto posTracks_el_per_coll = posTracks_el->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto negTracks_el_per_coll = negTracks_el->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto posTracks_mu_per_coll = posTracks_mu->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - auto negTracks_mu_per_coll = negTracks_mu->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - - // LOGF(info, "posTracks_el_per_coll.size() = %d, negTracks_el_per_coll.size() = %d, posTracks_mu_per_coll.size() = %d, negTracks_mu_per_coll.size() = %d", posTracks_el_per_coll.size(), negTracks_el_per_coll.size(), posTracks_mu_per_coll.size(), negTracks_mu_per_coll.size() ); - - int nuls = 0, nlspp = 0, nlsmm = 0; - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_el_per_coll, negTracks_mu_per_coll))) { // ULS+- - bool is_pair_ok = fillPairInfo<0>(collision, pos, neg); - if (is_pair_ok) { - nuls++; - } - } - - for (auto& [neg, pos] : combinations(CombinationsFullIndexPolicy(negTracks_el_per_coll, posTracks_mu_per_coll))) { // ULS-+ - bool is_pair_ok = fillPairInfo<0>(collision, neg, pos); - if (is_pair_ok) { - nuls++; - } - } - - for (auto& [pos1, pos2] : combinations(CombinationsFullIndexPolicy(posTracks_el_per_coll, posTracks_mu_per_coll))) { // LS++ - bool is_pair_ok = fillPairInfo<0>(collision, pos1, pos2); - if (is_pair_ok) { - nlspp++; - } - } - for (auto& [neg1, neg2] : combinations(CombinationsFullIndexPolicy(negTracks_el_per_coll, negTracks_mu_per_coll))) { // LS-- - bool is_pair_ok = fillPairInfo<0>(collision, neg1, neg2); - if (is_pair_ok) { - nlsmm++; - } - } - - 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; - } - - 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 = lower_bound(occ_bin_edges.begin(), occ_bin_edges.end(), collision.trackOccupancyInTimeRange()) - 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()); - - // make a vector of selected photons in this collision. - auto selected_posTracks_el_in_this_event = emh_el_pos->GetTracksPerCollision(key_df_collision); - auto selected_negTracks_el_in_this_event = emh_el_neg->GetTracksPerCollision(key_df_collision); - auto selected_posTracks_mu_in_this_event = emh_mu_pos->GetTracksPerCollision(key_df_collision); - auto selected_negTracks_mu_in_this_event = emh_mu_neg->GetTracksPerCollision(key_df_collision); - - auto collisionIds_in_mixing_pool = emh_el_pos->GetCollisionIdsFromEventPool(key_bin); // pos/ele 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) { - 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; - } - - // LOGF(info, "mix_df = %d, mix_collisionId = %d, q2x_mixed = %f, q2y_mixed = %f", mix_dfId, mix_collisionId, q2x_mixed, q2y_mixed); - - auto posTracks_el_from_event_pool = emh_el_pos->GetTracksPerCollision(mix_dfId_collisionId); - auto negTracks_el_from_event_pool = emh_el_neg->GetTracksPerCollision(mix_dfId_collisionId); - auto posTracks_mu_from_event_pool = emh_mu_pos->GetTracksPerCollision(mix_dfId_collisionId); - auto negTracks_mu_from_event_pool = emh_mu_neg->GetTracksPerCollision(mix_dfId_collisionId); - // LOGF(info, "Do event mixing: current event (%d, %d) | event pool (%d, %d), npos = %d , nele = %d", ndf, collision.globalIndex(), mix_dfId, mix_collisionId, posTracks_from_event_pool.size(), negTracks_from_event_pool.size()); - - for (auto& pos : selected_posTracks_el_in_this_event) { // ULS mix - for (auto& neg : negTracks_mu_from_event_pool) { - fillPairInfo<1>(collision, pos, neg); - } - } - - for (auto& neg : selected_negTracks_el_in_this_event) { // ULS mix - for (auto& pos : posTracks_mu_from_event_pool) { - fillPairInfo<1>(collision, neg, pos); - } - } - - for (auto& pos : selected_posTracks_mu_in_this_event) { // ULS mix - for (auto& neg : negTracks_el_from_event_pool) { - fillPairInfo<1>(collision, neg, pos); - } - } - - for (auto& neg : selected_negTracks_mu_in_this_event) { // ULS mix - for (auto& pos : posTracks_el_from_event_pool) { - fillPairInfo<1>(collision, pos, neg); - } - } - - for (auto& pos1 : selected_posTracks_el_in_this_event) { // LS++ mix - for (auto& pos2 : posTracks_mu_from_event_pool) { - fillPairInfo<1>(collision, pos1, pos2); - } - } - - for (auto& pos1 : selected_posTracks_mu_in_this_event) { // LS++ mix - for (auto& pos2 : posTracks_el_from_event_pool) { - fillPairInfo<1>(collision, pos2, pos1); - } - } - - for (auto& neg1 : selected_negTracks_el_in_this_event) { // LS-- mix - for (auto& neg2 : negTracks_mu_from_event_pool) { - fillPairInfo<1>(collision, neg1, neg2); - } - } - - for (auto& neg1 : selected_negTracks_mu_in_this_event) { // LS-- mix - for (auto& neg2 : negTracks_el_from_event_pool) { - fillPairInfo<1>(collision, neg2, neg1); - } - } - - } // end of loop over mixed event pool - - if (nuls > 0 || nlspp > 0 || nlsmm > 0) { - // LOGF(info, "adding : ndf = %d, collision.globalIndex() = %d, q2x = %f, q2y = %f", ndf, collision.globalIndex(), q2vector[cfgQvecEstimator][0], q2vector[cfgQvecEstimator][1]); - emh_el_pos->AddCollisionIdAtLast(key_bin, key_df_collision); - emh_mu_pos->AddCollisionIdAtLast(key_bin, key_df_collision); - emh_el_neg->AddCollisionIdAtLast(key_bin, key_df_collision); - emh_mu_neg->AddCollisionIdAtLast(key_bin, key_df_collision); - } - - } // end of collision loop - - ndf++; - } // end of process - PROCESS_SWITCH(emuCorrelation, processQC, "run dielectron QC", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(emuCorrelation, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"emu-correlation"})}; -} diff --git a/PWGEM/Dilepton/Tasks/emuCorrelationMC.cxx b/PWGEM/Dilepton/Tasks/emuCorrelationMC.cxx deleted file mode 100644 index 4102d3ebbb1..00000000000 --- a/PWGEM/Dilepton/Tasks/emuCorrelationMC.cxx +++ /dev/null @@ -1,1172 +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 dalitz ee table for dalitz QC. -// 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/ASoAHelpers.h" -#include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "DCAFitter/DCAFitterN.h" - -#include "DetectorsBase/GeometryManager.h" -#include "DataFormatsParameters/GRPObject.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "CCDB/BasicCCDBManager.h" -#include "Tools/ML/MlResponse.h" -#include "Tools/ML/model.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/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::dilepton::utils; -using namespace o2::aod::pwgem::dilepton::utils::mcutil; -using namespace o2::aod::pwgem::dilepton::utils::emtrackutil; - -using MyCollisions = soa::Join; -using MyCollision = MyCollisions::iterator; - -using MyElectrons = soa::Join; -using MyElectron = MyElectrons::iterator; - -using MyMuons = soa::Join; -using MyMuon = MyMuons::iterator; - -struct emuCorrelationMC { - - // 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 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.f, "max. centrality"}; - - ConfigurableAxis ConfMemuBins{"ConfMemuBins", {VARIABLE_WIDTH, 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0}, "memu bins for output histograms"}; - ConfigurableAxis ConfPtemuBins{"ConfPtemuBins", {VARIABLE_WIDTH, 0.00, 10.00}, "pTemu bins for output histograms"}; - ConfigurableAxis ConfDCAemuBins{"ConfDCAemuBins", {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}, "single leg DCA bins for output histograms"}; - - EMEventCut 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; - } eventcuts; - - DielectronCut fDielectronCut; - 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_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_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"}; - Configurable cfg_phiv_intercept{"cfg_phiv_intercept", -0.0280, "intercept for m vs. phiv"}; - - Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "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", 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_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(DielectronCut::PIDSchemes::kTPChadrejORTOFreq), "pid scheme [kTOFreq : 0, kTPChadrej : 1, kTPChadrejORTOFreq : 2, kTPConly : 3]"}; - 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_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 enableTTCA{"enableTTCA", true, "Flag to enable or disable TTCA"}; - - // CCDB configuration for PID ML - Configurable BDTLocalPathGamma{"BDTLocalPathGamma", "pid_ml_xgboost.onnx", "Path to the local .onnx file"}; - Configurable BDTPathCCDB{"BDTPathCCDB", "Users/d/dsekihat/pwgem/pidml/", "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)"}; - } 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_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_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_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_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_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"}; - } dimuoncuts; - - struct : ConfigurableGroup { - std::string prefix = "mctrackcut_group"; - Configurable min_mcPt_electron{"min_mcPt_electron", 0.05, "min. MC pT"}; - Configurable max_mcPt_electron{"max_mcPt_electron", 1e+10, "max. MC pT"}; - Configurable min_mcEta_electron{"min_mcEta_electron", -0.9, "max. MC eta"}; - Configurable max_mcEta_electron{"max_mcEta_electron", +0.9, "max. MC eta"}; - - Configurable min_mcPt_muon{"min_mcPt_muon", 0.05, "min. MC pT"}; - Configurable max_mcPt_muon{"max_mcPt_muon", 1e+10, "max. MC pT"}; - Configurable min_mcEta_muon{"min_mcEta_muon", -4.0, "min. MC eta"}; - Configurable max_mcEta_muon{"max_mcEta_muon", -2.5, "max. MC eta"}; - } mctrackcuts; - - o2::ccdb::CcdbApi ccdbApi; - Service ccdb; - int mRunNumber; - float d_bz; - o2::vertexing::DCAFitterN<2> fitter; - 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 lepton_source_types[6] = {"c2e/", "b2e/", "b2c2e/", "c2mu/", "b2mu/", "b2c2mu/"}; - - void init(InitContext& /*context*/) - { - DefineEMEventCut(); - DefineDielectronCut(); - DefineDimuonCut(); - addhistograms(); - - mRunNumber = 0; - d_bz = 0; - - ccdb->setURL(ccdburl); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - ccdb->setFatalWhenNull(false); - - 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); - } - - 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(); - fitter.setBz(d_bz); - 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(); - fitter.setBz(d_bz); - } - - ~emuCorrelationMC() {} - - void addhistograms() - { - // event info - o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry, false); - - // pair info - const AxisSpec axis_mass{ConfMemuBins, "m_{e#mu} (GeV/c^{2})"}; - const AxisSpec axis_pt{ConfPtemuBins, "p_{T,e#mu} (GeV/c)"}; - const AxisSpec axis_rapidity{48, -4.0, +0.8, "y_{e#mu}"}; - const AxisSpec axis_dca_el{ConfDCAemuBins, "DCA_{e}^{3D} (#sigma)"}; - const AxisSpec axis_dca_mu{ConfDCAemuBins, "DCA_{#mu}^{XY} (#sigma)"}; - const AxisSpec axis_dphi{18, 0, M_PI, "#Delta#varphi_{e#mu} (rad.)"}; - - fRegistry.add("Pair/ccbar/c2e_c2mu/hadron_hadron/hs", "hs pair", kTHnSparseF, {axis_mass, axis_pt, axis_rapidity, axis_dphi, axis_dca_el, axis_dca_mu}, true); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/hadron_hadron/", "Pair/ccbar/c2e_c2mu/meson_meson/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/hadron_hadron/", "Pair/ccbar/c2e_c2mu/baryon_baryon/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/hadron_hadron/", "Pair/ccbar/c2e_c2mu/meson_baryon/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2e_b2mu/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2c2e_b2c2mu/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2c2e_b2mu_sameb/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2c2e_b2mu_diffb/"); // LS - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2c2mu_b2e_sameb/"); - fRegistry.addClone("Pair/ccbar/c2e_c2mu/", "Pair/bbbar/b2c2mu_b2e_diffb/"); // LS - - // for electron info - fRegistry.add("Track/Electron/c2e/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/Electron/c2e/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/Electron/c2e/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, false); - fRegistry.add("Track/Electron/c2e/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/Electron/c2e/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/Electron/c2e/hDCAxy_Pt", "DCA_{xy} vs. pT;p_{T} (GeV/c);DCA_{xy} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/Electron/c2e/hDCAz_Pt", "DCA_{z} vs. pT;p_{T} (GeV/c);DCA_{z} (cm)", kTH2F, {{1000, 0, 10}, {200, -1, 1}}, false); - fRegistry.add("Track/Electron/c2e/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/Electron/c2e/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/Electron/c2e/hNclsTPC", "number of TPC clusters", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/Electron/c2e/hNcrTPC", "number of TPC crossed rows", kTH1F, {{161, -0.5, 160.5}}, false); - fRegistry.add("Track/Electron/c2e/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/Electron/c2e/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNsigmaMu", "TPC n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNsigmaKa", "TPC n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNsigmaPr", "TPC n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTOFbeta", "TOF beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {600, 0, 1.2}}, false); - fRegistry.add("Track/Electron/c2e/h1overTOFbeta", "TOF beta;p_{in} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {1000, 0.8, 1.8}}, false); - fRegistry.add("Track/Electron/c2e/hTOFNsigmaEl", "TOF n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTOFNsigmaMu", "TOF n sigma mu;p_{in} (GeV/c);n #sigma_{#mu}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTOFNsigmaPi", "TOF n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTOFNsigmaKa", "TOF n sigma ka;p_{in} (GeV/c);n #sigma_{K}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTOFNsigmaPr", "TOF n sigma pr;p_{in} (GeV/c);n #sigma_{p}^{TOF}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/Electron/c2e/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("Track/Electron/c2e/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("Track/Electron/c2e/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("Track/Electron/c2e/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("Track/Electron/c2e/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - fRegistry.add("Track/Electron/c2e/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("Track/Electron/c2e/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("Track/Electron/c2e/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("Track/Electron/c2e/", "Track/Electron/b2e/"); - fRegistry.addClone("Track/Electron/c2e/", "Track/Electron/b2c2e/"); - - // for muon info - fRegistry.add("Track/Muon/c2mu/hPt", "pT;p_{T} (GeV/c)", kTH1F, {{1000, 0.0f, 10}}, false); - fRegistry.add("Track/Muon/c2mu/hQoverPt", "q/pT;q/p_{T} (GeV/c)^{-1}", kTH1F, {{400, -20, 20}}, false); - fRegistry.add("Track/Muon/c2mu/hEtaPhi", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {25, -4.5f, -2.0f}}, false); - fRegistry.add("Track/Muon/c2mu/hTrackType", "track type", kTH1F, {{6, -0.5f, 5.5}}, false); - fRegistry.add("Track/Muon/c2mu/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/Muon/c2mu/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/Muon/c2mu/hDCAxRes_Pt", "DCA_{x} resolution vs. pT;p_{T} (GeV/c);DCA_{x} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/Muon/c2mu/hDCAyRes_Pt", "DCA_{y} resolution vs. pT;p_{T} (GeV/c);DCA_{y} resolution (#mum)", kTH2F, {{1000, 0, 10}, {200, 0., 200}}, false); - fRegistry.add("Track/Muon/c2mu/hNclsMCH", "number of MCH clusters", kTH1F, {{21, -0.5, 20.5}}, false); - fRegistry.add("Track/Muon/c2mu/hNclsMFT", "number of MFT clusters", kTH1F, {{11, -0.5, 10.5}}, false); - fRegistry.add("Track/Muon/c2mu/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/Muon/c2mu/hChi2", "chi2;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/c2mu/hChi2MatchMCHMID", "chi2 match MCH-MID;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/c2mu/hChi2MatchMCHMFT", "chi2 match MCH-MFT;chi2", kTH1F, {{100, 0.0f, 100}}, false); - fRegistry.add("Track/Muon/c2mu/hMFTClusterMap", "MFT cluster map", kTH1F, {{1024, -0.5, 1023.5}}, false); - fRegistry.add("Track/Muon/c2mu/hPtGen_DeltaPtOverPtGen", "muon 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("Track/Muon/c2mu/hPtGen_DeltaEta", "muon #eta resolution;p_{T}^{gen} (GeV/c);#eta^{rec} - #eta^{gen}", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("Track/Muon/c2mu/hPtGen_DeltaPhi", "muon #varphi resolution;p_{T}^{gen} (GeV/c);#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{1000, 0, 10}, {400, -1.0f, 1.0f}}, true); - fRegistry.addClone("Track/Muon/c2mu/", "Track/Muon/b2mu/"); - fRegistry.addClone("Track/Muon/c2mu/", "Track/Muon/b2c2mu/"); - - // for generated info - fRegistry.add("Generated/ccbar/c2e_c2mu/hadron_hadron/hs", "gen. e#mu correlation", kTHnSparseD, {axis_mass, axis_pt, axis_rapidity, axis_dphi}, true); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/hadron_hadron/", "Generated/ccbar/c2e_c2mu/meson_meson/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/hadron_hadron/", "Generated/ccbar/c2e_c2mu/baryon_baryon/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/hadron_hadron/", "Generated/ccbar/c2e_c2mu/meson_baryon/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2e_b2mu/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2c2e_b2c2mu/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2c2e_b2mu_sameb/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2c2e_b2mu_diffb/"); // LS - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2c2mu_b2e_sameb/"); - fRegistry.addClone("Generated/ccbar/c2e_c2mu/", "Generated/bbbar/b2c2mu_b2e_diffb/"); // LS - } - - void DefineEMEventCut() - { - fEMEventCut = EMEventCut("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.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); - } - - void DefineDielectronCut() - { - fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); - - // for pair - fDielectronCut.SetMeeRange(dielectroncuts.cfg_min_mass, dielectroncuts.cfg_max_mass); - fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); - fDielectronCut.SetPairDCARange(dielectroncuts.cfg_min_pair_dca3d, dielectroncuts.cfg_max_pair_dca3d); // in sigma - fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); - fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); - fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); - fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); - - // for track - fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); - fDielectronCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); - fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); - fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); - fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); - 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.SetMeanClusterSizeITSob(0, 16); - fDielectronCut.SetMaxDcaXY(dielectroncuts.cfg_max_dcaxy); - fDielectronCut.SetMaxDcaZ(dielectroncuts.cfg_max_dcaz); - - // 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.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); - - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { // please call this at the end of DefineDileptonCut - o2::ml::OnnxModel* eid_bdt = new o2::ml::OnnxModel(); - if (dielectroncuts.loadModelsFromCCDB) { - ccdbApi.init(ccdburl); - std::map metadata; - bool retrieveSuccessGamma = ccdbApi.retrieveBlob(dielectroncuts.BDTPathCCDB.value, ".", metadata, dielectroncuts.timestampCCDB.value, false, dielectroncuts.BDTLocalPathGamma.value); - if (retrieveSuccessGamma) { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.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 { - eid_bdt->initModel(dielectroncuts.BDTLocalPathGamma.value, dielectroncuts.enableOptimizations.value); - } - - fDielectronCut.SetPIDModel(eid_bdt); - } // 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.SetPairDCAxyRange(dimuoncuts.cfg_min_pair_dcaxy, dimuoncuts.cfg_max_pair_dcaxy); // DCAxy in cm - - // for track - fDimuonCut.SetTrackType(dimuoncuts.cfg_track_type); - fDimuonCut.SetTrackPtRange(dimuoncuts.cfg_min_pt_track, 1e10f); - fDimuonCut.SetTrackEtaRange(dimuoncuts.cfg_min_eta_track, dimuoncuts.cfg_max_eta_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); }); - } - - template - bool fillTruePairInfo(TCollision const& collision, TElectron const& t1, TMuon const& t2, TMCParticles const& mcparticles) - { - if (dielectroncuts.cfg_pid_scheme == static_cast(DielectronCut::PIDSchemes::kPIDML)) { - if (!fDielectronCut.IsSelectedTrack(t1, collision)) { - return false; - } - } else { // cut-based - if (!fDielectronCut.IsSelectedTrack(t1)) { - return false; - } - } - - if (!fDimuonCut.IsSelectedTrack(t2)) { - return false; - } - - auto t1mc = t1.template emmcparticle_as(); - auto t2mc = t2.template emmcparticle_as(); - if (abs(t1mc.pdgCode()) != 11 || abs(t2mc.pdgCode()) != 13) { - return false; - } - - if (!t1mc.isPhysicalPrimary() && !t1mc.producedByGenerator()) { - return false; - } - if (!t2mc.isPhysicalPrimary() && !t2mc.producedByGenerator()) { - return false; - } - - if (t1mc.emmceventId() != t2mc.emmceventId()) { - return false; - } - - int hfee_type = IsHF(t1mc, t2mc, mcparticles); - if (hfee_type < 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - - float dca_3d_el = dca3DinSigma(t1); - float dca_xy_mu = fwdDcaXYinSigma(t2); - - auto mp1 = mcparticles.iteratorAt(t1mc.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2mc.mothersIds()[0]); - if (t1mc.pdgCode() * t2mc.pdgCode() < 0) { // ULS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<0, TMCParticles>(t1); - fillMuonInfo<3, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<0, TMCParticles>(t1); - fillMuonInfo<3, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/ccbar/c2e_c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<0, TMCParticles>(t1); - fillMuonInfo<3, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<1, TMCParticles>(t1); - fillMuonInfo<4, TMCParticles>(t2); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<1, TMCParticles>(t1); - fillMuonInfo<4, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2e_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<1, TMCParticles>(t1); - fillMuonInfo<4, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<2, TMCParticles>(t1); - fillMuonInfo<5, TMCParticles>(t2); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<2, TMCParticles>(t1); - fillMuonInfo<5, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - fillElectronInfo<2, TMCParticles>(t1); - fillMuonInfo<5, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } - fillElectronInfo<2, TMCParticles>(t1); - fillMuonInfo<4, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } - fillElectronInfo<1, TMCParticles>(t1); - fillMuonInfo<5, TMCParticles>(t2); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } else { // LS - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - LOGF(info, "You should not see kBCe_Be_SameB in LS. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2e_b2mu_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } - fillElectronInfo<2, TMCParticles>(t1); - fillMuonInfo<4, TMCParticles>(t2); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } else { - fRegistry.fill(HIST("Pair/bbbar/b2c2mu_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi, dca_3d_el, dca_xy_mu); - } - fillElectronInfo<1, TMCParticles>(t1); - fillMuonInfo<5, TMCParticles>(t2); - } - break; - } - default: - break; - } - } - - fillElectronInfo<0, TMCParticles>(t1); - fillMuonInfo<0, TMCParticles>(t2); - return true; - } - - template - void fillElectronInfo(TTrack const& track) - { - if (std::find(used_electronIds.begin(), used_electronIds.end(), track.globalIndex()) == used_electronIds.end()) { - auto mctrack = track.template emmcparticle_as(); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hPt"), track.pt()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxyz"), track.dcaXY(), track.dcaZ()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxyzSigma"), track.dcaXY() / sqrt(track.cYY()), track.dcaZ() / sqrt(track.cZZ())); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxy_Pt"), track.pt(), track.dcaXY()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAz_Pt"), track.pt(), track.dcaZ()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hNclsITS"), track.itsNCls()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hNclsTPC"), track.tpcNClsFound()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hNcrTPC"), track.tpcNClsCrossedRows()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hChi2TPC"), track.tpcChi2NCl()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hChi2ITS"), track.itsChi2NCl()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hITSClusterMap"), track.itsClusterMap()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hMeanClusterSizeITS"), track.meanClusterSizeITS() * std::cos(std::atan(track.tgl()))); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNsigmaEl"), track.tpcInnerParam(), track.tpcNSigmaEl()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNsigmaMu"), track.tpcInnerParam(), track.tpcNSigmaMu()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNsigmaPi"), track.tpcInnerParam(), track.tpcNSigmaPi()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNsigmaKa"), track.tpcInnerParam(), track.tpcNSigmaKa()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTPCNsigmaPr"), track.tpcInnerParam(), track.tpcNSigmaPr()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFbeta"), track.tpcInnerParam(), track.beta()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("h1overTOFbeta"), track.tpcInnerParam(), 1. / track.beta()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFNsigmaEl"), track.tpcInnerParam(), track.tofNSigmaEl()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFNsigmaMu"), track.tpcInnerParam(), track.tofNSigmaMu()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFNsigmaPi"), track.tpcInnerParam(), track.tofNSigmaPi()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFNsigmaKa"), track.tpcInnerParam(), track.tofNSigmaKa()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hTOFNsigmaPr"), track.tpcInnerParam(), track.tofNSigmaPr()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); - fRegistry.fill(HIST("Track/Electron/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); - used_electronIds.emplace_back(track.globalIndex()); - } - } - - template - void fillMuonInfo(TTrack const& track) - { - if (std::find(used_muonIds.begin(), used_muonIds.end(), track.globalIndex()) == used_muonIds.end()) { - auto mctrack = track.template emmcparticle_as(); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hPt"), track.pt()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hQoverPt"), track.sign() / track.pt()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hEtaPhi"), track.phi(), track.eta()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hTrackType"), track.trackType()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxy"), track.fwdDcaX(), track.fwdDcaY()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxySigma"), track.fwdDcaX() / sqrt(track.cXX()), track.fwdDcaY() / sqrt(track.cYY())); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAxRes_Pt"), track.pt(), sqrt(track.cXX()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hDCAyRes_Pt"), track.pt(), sqrt(track.cYY()) * 1e+4); // convert cm to um - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hNclsMFT"), track.nClustersMFT()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hNclsMCH"), track.nClusters()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hPDCA"), track.pt(), track.pDca()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hChi2"), track.chi2()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hChi2MatchMCHMFT"), track.chi2MatchMCHMFT()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hChi2MatchMCHMID"), track.chi2MatchMCHMID()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hMFTClusterMap"), track.mftClusterMap()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaPtOverPtGen"), mctrack.pt(), (track.pt() - mctrack.pt()) / mctrack.pt()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaEta"), mctrack.pt(), track.eta() - mctrack.eta()); - fRegistry.fill(HIST("Track/Muon/") + HIST(lepton_source_types[e_source_id]) + HIST("hPtGen_DeltaPhi"), mctrack.pt(), track.phi() - mctrack.phi()); - used_muonIds.emplace_back(track.globalIndex()); - } - } - - template - bool isElectronInAcceptance(T const& t1) - { - if ((mctrackcuts.min_mcPt_electron < t1.pt() && t1.pt() < mctrackcuts.max_mcPt_electron) && mctrackcuts.min_mcEta_electron < t1.eta() && t1.eta() < mctrackcuts.max_mcEta_electron) { - return true; - } else { - return false; - } - } - - template - bool isMuonInAcceptance(T const& t1) - { - if ((mctrackcuts.min_mcPt_muon < t1.pt() && t1.pt() < mctrackcuts.max_mcPt_muon) && mctrackcuts.min_mcEta_muon < t1.eta() && t1.eta() < mctrackcuts.max_mcEta_muon) { - return true; - } else { - return false; - } - } - - 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; - - SliceCache cache; - Preslice perCollision_electron = aod::emprimaryelectron::emeventId; - Filter trackFilter_el = dielectroncuts.cfg_min_pt_track < o2::aod::track::pt && nabs(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 = (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) && ((0.96f < o2::aod::pidtofbeta::beta && o2::aod::pidtofbeta::beta < 1.04f) || o2::aod::pidtofbeta::beta < 0.f); - Filter ttcaFilter_el = ifnode(dielectroncuts.enableTTCA.node(), o2::aod::emprimaryelectron::isAssociatedToMPC == true || o2::aod::emprimaryelectron::isAssociatedToMPC == false, o2::aod::emprimaryelectron::isAssociatedToMPC == true); - using FilteredMyElectrons = soa::Filtered; - using FilteredMyElectron = FilteredMyElectrons::iterator; - - Preslice perCollision_muon = aod::emprimarymuon::emeventId; - Filter trackFilter_mu = 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; - Filter ttcaFilter_mu = ifnode(dimuoncuts.enableTTCA.node(), o2::aod::emprimarymuon::isAssociatedToMPC == true || o2::aod::emprimarymuon::isAssociatedToMPC == false, o2::aod::emprimarymuon::isAssociatedToMPC == true); - using FilteredMyMuons = soa::Filtered; - - Partition posTracks_el = o2::aod::emprimaryelectron::sign > int8_t(0); - Partition negTracks_el = o2::aod::emprimaryelectron::sign < int8_t(0); - Partition posTracks_mu = o2::aod::emprimarymuon::sign > int8_t(0); - Partition negTracks_mu = o2::aod::emprimarymuon::sign < int8_t(0); - - std::vector used_electronIds; - std::vector used_muonIds; - void processQCMC(FilteredMyCollisions const& collisions, FilteredMyElectrons const&, FilteredMyMuons const&, aod::EMMCParticles const& mcparticles) - { - for (auto& collision : collisions) { - initCCDB(collision); - const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, false); - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, false); - fRegistry.fill(HIST("Event/before/hCollisionCounter"), 10.0); // accepted - fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted - - auto posTracks_el_per_coll = posTracks_el->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto negTracks_el_per_coll = negTracks_el->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); - auto posTracks_mu_per_coll = posTracks_mu->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - auto negTracks_mu_per_coll = negTracks_mu->sliceByCached(o2::aod::emprimarymuon::emeventId, collision.globalIndex(), cache); - - // LOGF(info, "posTracks_el_per_coll.size() = %d, negTracks_el_per_coll.size() = %d, posTracks_mu_per_coll.size() = %d, negTracks_mu_per_coll.size() = %d", posTracks_el_per_coll.size(), negTracks_el_per_coll.size(), posTracks_mu_per_coll.size(), negTracks_mu_per_coll.size() ); - - for (auto& [pos, neg] : combinations(CombinationsFullIndexPolicy(posTracks_el_per_coll, negTracks_mu_per_coll))) { // ULS+- - fillTruePairInfo(collision, pos, neg, mcparticles); - } - - for (auto& [neg, pos] : combinations(CombinationsFullIndexPolicy(negTracks_el_per_coll, posTracks_mu_per_coll))) { // ULS-+ - fillTruePairInfo(collision, neg, pos, mcparticles); - } - - for (auto& [pos1, pos2] : combinations(CombinationsFullIndexPolicy(posTracks_el_per_coll, posTracks_mu_per_coll))) { // LS++ - fillTruePairInfo(collision, pos1, pos2, mcparticles); - } - for (auto& [neg1, neg2] : combinations(CombinationsFullIndexPolicy(negTracks_el_per_coll, negTracks_mu_per_coll))) { // LS-- - fillTruePairInfo(collision, neg1, neg2, mcparticles); - } - - } // end of collision loop - - used_electronIds.clear(); - used_electronIds.shrink_to_fit(); - used_muonIds.clear(); - used_muonIds.shrink_to_fit(); - } // end of process - PROCESS_SWITCH(emuCorrelationMC, processQCMC, "run dielectron QCMC", true); - - Partition pos_els_MC = o2::aod::mcparticle::pdgCode == -11; // e+ - Partition neg_els_MC = o2::aod::mcparticle::pdgCode == +11; // e- - Partition pos_mus_MC = o2::aod::mcparticle::pdgCode == -13; // mu+ - Partition neg_mus_MC = o2::aod::mcparticle::pdgCode == +13; // mu- - PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; - void processGen(MyCollisions const& collisions, aod::EMMCEvents const&, aod::EMMCParticles const& mcparticles) - { - // loop over mc stack and fill histograms for pure MC truth signals - // all MC tracks which belong to the MC event corresponding to the current reconstructed event - - for (auto& collision : collisions) { - float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; - if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { - continue; - } - - if (!fEMEventCut.IsSelected(collision)) { - continue; - } - auto mccollision = collision.emmcevent_as(); - auto pos_els_per_coll = pos_els_MC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - auto neg_els_per_coll = neg_els_MC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - auto pos_mus_per_coll = pos_mus_MC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - auto neg_mus_per_coll = neg_mus_MC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); - - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(pos_els_per_coll, neg_mus_per_coll))) { // ULS+- - - if (!isElectronInAcceptance(t1) || !isMuonInAcceptance(t2)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { // muon is from b hadron. - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } else { // electron is from b hadron - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } // end of true ULS pair loop - - for (auto& [t1, t2] : combinations(CombinationsFullIndexPolicy(neg_els_per_coll, pos_mus_per_coll))) { // ULS-+ - - if (!isElectronInAcceptance(t1) || !isMuonInAcceptance(t2)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/ccbar/c2e_c2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBe_Be): { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isBeautyMeson(mp1) && isBeautyMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isBeautyBaryon(mp1) && isBeautyBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBCe_BCe): { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2c2mu/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if (isCharmMeson(mp1) && isCharmMeson(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if (isCharmBaryon(mp1) && isCharmBaryon(mp2)) { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2e_b2mu/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_SameB): { // ULS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { // muon is from b hadron. - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } else { // electron is from b hadron - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_sameb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } - break; - } - case static_cast(EM_HFeeType::kBCe_Be_DiffB): // LS - LOGF(info, "You should not see kBCe_Be_DiffB in ULS. Good luck."); - break; - default: - break; - } - } // end of true ULS pair loop - - for (auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(pos_els_per_coll, pos_mus_per_coll))) { - // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); - - if (!isElectronInAcceptance(t1) || !isMuonInAcceptance(t2)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - LOGF(info, "You should not see kBCe_Be_SameB in LS++. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { // muon is from b hadron. - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } else { // electron is from b hadron - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } - break; - } - default: - break; - } - } // end of true LS++ pair loop - - for (auto& [t1, t2] : combinations(CombinationsStrictlyUpperIndexPolicy(neg_els_per_coll, neg_mus_per_coll))) { - // LOGF(info, "pdg1 = %d, pdg2 = %d", t1.pdgCode(), t2.pdgCode()); - - if (!isElectronInAcceptance(t1) || !isMuonInAcceptance(t2)) { - continue; - } - - if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { - continue; - } - if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { - continue; - } - - int hfee_type = IsHF(t1, t2, mcparticles); - if (hfee_type < 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::MassMuon); - ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; - float dphi = t1.phi() - t2.phi(); - if (-2 * M_PI < dphi && dphi < -M_PI) { - dphi += 2 * M_PI; - } else if (-M_PI < dphi && dphi < 0) { - dphi += M_PI; - } else if (dphi > M_PI) { - dphi -= M_PI; - } - auto mp1 = mcparticles.iteratorAt(t1.mothersIds()[0]); - auto mp2 = mcparticles.iteratorAt(t2.mothersIds()[0]); - switch (hfee_type) { - case static_cast(EM_HFeeType::kCe_Ce): - LOGF(info, "You should not see kCe_Ce in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBe_Be): - LOGF(info, "You should not see kBe_Be in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_BCe): - LOGF(info, "You should not see kBCe_BCe in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_SameB): // ULS - LOGF(info, "You should not see kBCe_Be_SameB in LS--. Good luck."); - break; - case static_cast(EM_HFeeType::kBCe_Be_DiffB): { // LS - if (isBeautyMeson(mp2) || isBeautyBaryon(mp2)) { // muon is from b hadron. - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2e_b2mu_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } else { // electron is from b hadron - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/hadron_hadron/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - if ((isCharmMeson(mp1) && isBeautyMeson(mp2)) || (isCharmMeson(mp2) && isBeautyMeson(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/meson_meson/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else if ((isCharmBaryon(mp1) && isBeautyBaryon(mp2)) || (isCharmBaryon(mp2) && isBeautyBaryon(mp1))) { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/baryon_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } else { - fRegistry.fill(HIST("Generated/bbbar/b2c2mu_b2e_diffb/meson_baryon/hs"), v12.M(), v12.Pt(), v12.Rapidity(), dphi); - } - } - break; - } - default: - break; - } - } // end of true LS++ pair loop - } // end of collision loop - } - PROCESS_SWITCH(emuCorrelationMC, processGen, "run genrated info", true); - - void processDummy(MyCollisions const&) {} - PROCESS_SWITCH(emuCorrelationMC, processDummy, "Dummy function", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"emu-correlation-mc"})}; -} diff --git a/PWGEM/Dilepton/Tasks/eventQC.cxx b/PWGEM/Dilepton/Tasks/eventQC.cxx new file mode 100644 index 00000000000..640038992dc --- /dev/null +++ b/PWGEM/Dilepton/Tasks/eventQC.cxx @@ -0,0 +1,724 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 event QC for PWG-EM. +// Please write to: daiki.sekihata@cern.ch + +#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/TrackSelectionTables.h" +#include "CCDB/BasicCCDBManager.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 MyQvectors = soa::Join; + +using MyCollisions = soa::Join; +using MyCollisions_Qvec = soa::Join; + +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 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"}; + 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", 40, "number of eta bins for output histograms"}; + Configurable cfgNbinsPhi{"cfgNbinsPhi", 360, "number of phi bins for output histograms"}; + + 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 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"}; + } eventcuts; + + struct : ConfigurableGroup { + std::string prefix = "trackcut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.15, "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", 999.f, "max fraction of shared clusters in TPC"}; + Configurable cfg_min_ncrossedrows_tpc{"cfg_min_ncrossedrows_tpc", 80, "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 its"}; + 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.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "max dca Z for single track in cm"}; + 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", 0.0, "min n sigma pi in TPC for exclusion"}; + Configurable cfg_max_TPCNsigmaPi{"cfg_max_TPCNsigmaPi", 0.0, "max n sigma pi in TPC for exclusion"}; + Configurable cfg_min_TOFNsigmaEl{"cfg_min_TOFNsigmaEl", -1e+10, "min n sigma e in TOF"}; + Configurable cfg_max_TOFNsigmaEl{"cfg_max_TOFNsigmaEl", +1e+10, "max n sigma e in TOF"}; + Configurable cfg_requireTOF{"cfg_requireTOF", false, "require TOF hit"}; + } trackcuts; + + Service ccdb; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_types[2] = {"before/", "after/"}; + + void init(InitContext&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + addhistograms(); + } + + ~eventQC() {} + + void addhistograms() + { + // event info + + const int nbin_ev = 13; + 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"); + hCollisionCounter->GetXaxis()->SetBinLabel(3, "No TF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(4, "No ITS ROF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(5, "No Same Bunch Pileup"); + hCollisionCounter->GetXaxis()->SetBinLabel(6, "Is Good Zvtx FT0vsPV"); + hCollisionCounter->GetXaxis()->SetBinLabel(7, "Is Vertex ITS-TPC"); + hCollisionCounter->GetXaxis()->SetBinLabel(8, "Is Vertex ITS-TPC-TRD"); + hCollisionCounter->GetXaxis()->SetBinLabel(9, "Is Vertex ITS-TPC-TOF"); + hCollisionCounter->GetXaxis()->SetBinLabel(10, "sel8"); + hCollisionCounter->GetXaxis()->SetBinLabel(11, "|Z_{vtx}| < 10 cm"); + hCollisionCounter->GetXaxis()->SetBinLabel(12, "NoCollInTimeRangeStandard"); + hCollisionCounter->GetXaxis()->SetBinLabel(13, "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); + 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); + + for (int i = 0; i < static_cast(cfgnMods->size()); i++) { + int nmod = cfgnMods->at(i); + fRegistry.add(Form("Event/after/Qvector/hQ%dxFT0M_CentFT0C", nmod), Form("hQ%dxFT0M_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{FT0M}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyFT0M_CentFT0C", nmod), Form("hQ%dyFT0M_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{FT0M}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dxFT0A_CentFT0C", nmod), Form("hQ%dxFT0A_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{FT0A}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyFT0A_CentFT0C", nmod), Form("hQ%dyFT0A_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{FT0A}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dxFT0C_CentFT0C", nmod), Form("hQ%dxFT0C_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{FT0C}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyFT0C_CentFT0C", nmod), Form("hQ%dyFT0C_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{FT0C}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dxBPos_CentFT0C", nmod), Form("hQ%dxBPos_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{BPos}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyBPos_CentFT0C", nmod), Form("hQ%dyBPos_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{BPos}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dxBNeg_CentFT0C", nmod), Form("hQ%dxBNeg_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{BNeg}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyBNeg_CentFT0C", nmod), Form("hQ%dyBNeg_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{BNeg}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dxBTot_CentFT0C", nmod), Form("hQ%dxBTot_CentFT0C;centrality FT0C (%%);Q_{%d,x}^{BTot}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry.add(Form("Event/after/Qvector/hQ%dyBTot_CentFT0C", nmod), Form("hQ%dyBTot_CentFT0C;centrality FT0C (%%);Q_{%d,y}^{BTot}", nmod, nmod), kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0MQ%dBPos_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0M} #upoint Q_{%d}^{BPos};centrality FT0C (%%);Q_{%d}^{FT0M} #upoint Q_{%d}^{BPos}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0MQ%dBNeg_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0M} #upoint Q_{%d}^{BNeg};centrality FT0C (%%);Q_{%d}^{FT0M} #upoint Q_{%d}^{BNeg}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dBPosQ%dBNeg_CentFT0C", nmod, nmod), Form("Q_{%d}^{BPos} #upoint Q_{%d}^{BNeg};centrality FT0C (%%);Q_{%d}^{BPos} #upoint Q_{%d}^{BNeg}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0CQ%dBPos_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0C} #upoint Q_{%d}^{BPos};centrality FT0C (%%);Q_{%d}^{FT0C} #upoint Q_{%d}^{BPos}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0CQ%dBNeg_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0C} #upoint Q_{%d}^{BNeg};centrality FT0C (%%);Q_{%d}^{FT0C} #upoint Q_{%d}^{BNeg}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0CQ%dBTot_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0C} #upoint Q_{%d}^{BTot};centrality FT0C (%%);Q_{%d}^{FT0C} #upoint Q_{%d}^{BTot}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0AQ%dBPos_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0A} #upoint Q_{%d}^{BPos};centrality FT0C (%%);Q_{%d}^{FT0A} #upoint Q_{%d}^{BPos}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0AQ%dBNeg_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0A} #upoint Q_{%d}^{BNeg};centrality FT0C (%%);Q_{%d}^{FT0A} #upoint Q_{%d}^{BNeg}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0AQ%dBTot_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0A} #upoint Q_{%d}^{BTot};centrality FT0C (%%);Q_{%d}^{FT0A} #upoint Q_{%d}^{BTot}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfQ%dFT0AQ%dFT0C_CentFT0C", nmod, nmod), Form("Q_{%d}^{FT0A} #upoint Q_{%d}^{FT0C};centrality FT0C (%%);Q_{%d}^{FT0A} #upoint Q_{%d}^{FT0C}", nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + + fRegistry.add(Form("Event/after/Qvector/hEP%dFT0M_CentFT0C", nmod), Form("event plane FT0M;centrality FT0C (%%);#Psi_{%d}^{FT0M} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry.add(Form("Event/after/Qvector/hEP%dFT0A_CentFT0C", nmod), Form("event plane FT0A;centrality FT0C (%%);#Psi_{%d}^{FT0A} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry.add(Form("Event/after/Qvector/hEP%dFT0C_CentFT0C", nmod), Form("event plane FT0C;centrality FT0C (%%);#Psi_{%d}^{FT0C} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry.add(Form("Event/after/Qvector/hEP%dBPos_CentFT0C", nmod), Form("event plane BPos;centrality FT0C (%%);#Psi_{%d}^{BPos} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry.add(Form("Event/after/Qvector/hEP%dBNeg_CentFT0C", nmod), Form("event plane BNeg;centrality FT0C (%%);#Psi_{%d}^{BNeg} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry.add(Form("Event/after/Qvector/hEP%dBTot_CentFT0C", nmod), Form("event plane BTot;centrality FT0C (%%);#Psi_{%d}^{BTot} (rad.)", nmod), kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0MEP%dBPos_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0M} - #Psi_{%d}^{BPos}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0M} - #Psi_{%d}^{BPos}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0MEP%dBNeg_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0M} - #Psi_{%d}^{BNeg}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0M} - #Psi_{%d}^{BNeg}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dBPosEP%dBNeg_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{BPos} - #Psi_{%d}^{BNeg}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{BPos} - #Psi_{%d}^{BNeg}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0CEP%dBPos_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BPos}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BPos}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0CEP%dBNeg_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BNeg}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BNeg}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0CEP%dBTot_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BTot}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0C} - #Psi_{%d}^{BTot}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0AEP%dBPos_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BPos}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BPos}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0AEP%dBNeg_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BNeg}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BNeg}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0AEP%dBTot_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BTot}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{BTot}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + fRegistry.add(Form("Event/after/Qvector/hPrfCosDiffEP%dFT0AEP%dFT0C_CentFT0C", nmod, nmod), Form("cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{FT0C}));centrality FT0C (%%);cos(%d(#Psi_{%d}^{FT0A} - #Psi_{%d}^{FT0C}))", nmod, nmod, nmod, nmod, nmod, nmod), kTProfile, {{100, 0, 100}}, false); + } + + std::vector tmp_ptbins; + for (int i = 0; i < 100; i++) { + tmp_ptbins.emplace_back(0.01 * i); // every 0.01 GeV/c from 0 to 1 GeV/c + } + for (int i = 0; i < 91; i++) { + tmp_ptbins.emplace_back(0.1 * i + 1.f); // every 0.1 GeV/c from 1 to 10 GeV/c + } + 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_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 (%)"}; + + for (int i = 0; i < static_cast(cfgnMods->size()); i++) { + int nmod = cfgnMods->at(i); + const AxisSpec axis_sp{100, -5, +5, Form("#vec{u_{%d}} #upoint #vec{Q_{%d}}", nmod, nmod)}; + const AxisSpec axis_cos{200, -1, +1, Form("cos(%d(#varphi - #Psi_{%d}))", nmod, nmod)}; + fRegistry.add(Form("Track/hV%d", nmod), Form("charged particle v_{%d}", nmod), kTHnSparseD, {axis_cent, axis_pt, axis_sp, axis_cos}, false); + } + 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", kTH1F, {{100, 0, 10}}, false); + + if (cfgFillPID) { + fRegistry.add("Track/hTPCdEdx", "TPC dE/dx;p_{pv} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("Track/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, 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/hTPCNsigmaEl", "TPC n sigma el;p_{pv} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTPCNsigmaMu", "TPC n sigma mu;p_{pv} (GeV/c);n #sigma_{#mu}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTPCNsigmaPi", "TPC n sigma pi;p_{pv} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTPCNsigmaKa", "TPC n sigma ka;p_{pv} (GeV/c);n #sigma_{K}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("Track/hTPCNsigmaPr", "TPC n sigma pr;p_{pv} (GeV/c);n #sigma_{p}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, 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); + } + } + + 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.tofChi2()); + + if (cfgFillPID) { + int nsize = 0; + for (int il = 0; il < 7; il++) { + nsize += track.itsClsSizeInLayer(il); + } + fRegistry.fill(HIST("Track/hTPCdEdx"), track.p(), track.tpcSignal()); + fRegistry.fill(HIST("Track/hTOFbeta"), track.p(), track.beta()); + fRegistry.fill(HIST("Track/hMeanClusterSizeITS"), track.p(), static_cast(nsize) / static_cast(track.itsNCls()) * std::cos(std::atan(track.tgl()))); + fRegistry.fill(HIST("Track/hTPCNsigmaEl"), track.p(), track.tpcNSigmaEl()); + fRegistry.fill(HIST("Track/hTPCNsigmaMu"), track.p(), track.tpcNSigmaMu()); + fRegistry.fill(HIST("Track/hTPCNsigmaPi"), track.p(), track.tpcNSigmaPi()); + fRegistry.fill(HIST("Track/hTPCNsigmaKa"), track.p(), track.tpcNSigmaKa()); + fRegistry.fill(HIST("Track/hTPCNsigmaPr"), track.p(), track.tpcNSigmaPr()); + 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 + void fillEventInfo(TCollision const& collision) + { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 1.0); + if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 2.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 3.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 4.0); + } + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 5.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 6.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 7.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); + } + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); + } + if (collision.sel8()) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 10.0); + } + if (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)) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 12.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()); + 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("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("hNTracksPVvsOccupancy"), collision.multNTracksPV(), collision.trackOccupancyInTimeRange()); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCorrOccupancy"), collision.ft0cOccupancyInTimeRange(), collision.trackOccupancyInTimeRange()); + + 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()); + + if constexpr (ev_id == 1 && std::is_same_v, FilteredMyCollision_Qvec>) { + if (std::find(cfgnMods->begin(), cfgnMods->end(), 2) != cfgnMods->end()) { + fillQvectorInfo(collision); + } + if (std::find(cfgnMods->begin(), cfgnMods->end(), 3) != cfgnMods->end()) { + fillQvectorInfo(collision); + } + if (std::find(cfgnMods->begin(), cfgnMods->end(), 4) != cfgnMods->end()) { + fillQvectorInfo(collision); + } + } + } + + template + void fillQvectorInfo(TCollision const& collision) + { + int idx = std::distance(cfgnMods->begin(), std::find(cfgnMods->begin(), cfgnMods->end(), nmod)); + float qxft0m = collision.qvecFT0MReVec()[idx], qxft0a = collision.qvecFT0AReVec()[idx], qxft0c = collision.qvecFT0CReVec()[idx], qxbpos = collision.qvecBPosReVec()[idx], qxbneg = collision.qvecBNegReVec()[idx], qxbtot = collision.qvecBTotReVec()[idx]; + float qyft0m = collision.qvecFT0MImVec()[idx], qyft0a = collision.qvecFT0AImVec()[idx], qyft0c = collision.qvecFT0CImVec()[idx], qybpos = collision.qvecBPosImVec()[idx], qybneg = collision.qvecBNegImVec()[idx], qybtot = collision.qvecBTotImVec()[idx]; + std::array qft0m = {qxft0m, qyft0m}; + std::array qft0a = {qxft0a, qyft0a}; + std::array qft0c = {qxft0c, qyft0c}; + std::array qbpos = {qxbpos, qybpos}; + std::array qbneg = {qxbneg, qybneg}; + std::array qbtot = {qxbtot, qybtot}; + std::vector> qvectors = {qft0m, qft0a, qft0c, qbpos, qbneg, qbtot}; + + if (!isGoodQvector(qvectors)) { + return; + } + + if constexpr (nmod == 2) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xFT0M_CentFT0C"), collision.centFT0C(), qxft0m); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yFT0M_CentFT0C"), collision.centFT0C(), qyft0m); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xFT0A_CentFT0C"), collision.centFT0C(), qxft0a); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yFT0A_CentFT0C"), collision.centFT0C(), qyft0a); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xFT0C_CentFT0C"), collision.centFT0C(), qxft0c); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yFT0C_CentFT0C"), collision.centFT0C(), qyft0c); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xBPos_CentFT0C"), collision.centFT0C(), qxbpos); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yBPos_CentFT0C"), collision.centFT0C(), qybpos); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xBNeg_CentFT0C"), collision.centFT0C(), qxbneg); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yBNeg_CentFT0C"), collision.centFT0C(), qybneg); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2xBTot_CentFT0C"), collision.centFT0C(), qxbtot); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ2yBTot_CentFT0C"), collision.centFT0C(), qybtot); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0MQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0m, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0MQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0m, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2BPosQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qbpos, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0AQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0AQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0AQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbtot)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0CQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0CQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0CQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbtot)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ2FT0AQ2FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qft0c)); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2FT0M_CentFT0C"), collision.centFT0C(), getEP(qxft0m, qyft0m, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2FT0A_CentFT0C"), collision.centFT0C(), getEP(qxft0a, qyft0a, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2FT0C_CentFT0C"), collision.centFT0C(), getEP(qxft0c, qyft0c, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2BPos_CentFT0C"), collision.centFT0C(), getEP(qxbpos, qybpos, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2BNeg_CentFT0C"), collision.centFT0C(), getEP(qxbneg, qybneg, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP2BTot_CentFT0C"), collision.centFT0C(), getEP(qxbtot, qybtot, nmod)); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0MEP2BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0m, qyft0m, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0MEP2BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0m, qyft0m, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2BPosEP2BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxbpos, qybpos, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0AEP2BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0AEP2BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0AEP2BTot_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbtot, qybtot, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0CEP2BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0CEP2BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0CEP2BTot_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbtot, qybtot, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP2FT0AEP2FT0C_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxft0c, qyft0c, nmod)))); + } else if constexpr (nmod == 3) { + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xFT0M_CentFT0C"), collision.centFT0C(), qxft0m); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yFT0M_CentFT0C"), collision.centFT0C(), qyft0m); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xFT0A_CentFT0C"), collision.centFT0C(), qxft0a); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yFT0A_CentFT0C"), collision.centFT0C(), qyft0a); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xFT0C_CentFT0C"), collision.centFT0C(), qxft0c); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yFT0C_CentFT0C"), collision.centFT0C(), qyft0c); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xBPos_CentFT0C"), collision.centFT0C(), qxbpos); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yBPos_CentFT0C"), collision.centFT0C(), qybpos); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xBNeg_CentFT0C"), collision.centFT0C(), qxbneg); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yBNeg_CentFT0C"), collision.centFT0C(), qybneg); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3xBTot_CentFT0C"), collision.centFT0C(), qxbtot); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hQ3yBTot_CentFT0C"), collision.centFT0C(), qybtot); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0MQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0m, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0MQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0m, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3BPosQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qbpos, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0AQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0AQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0AQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qbtot)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0CQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbpos)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0CQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbneg)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0CQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0c, qbtot)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfQ3FT0AQ3FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(qft0a, qft0c)); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3FT0M_CentFT0C"), collision.centFT0C(), getEP(qxft0m, qyft0m, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3FT0A_CentFT0C"), collision.centFT0C(), getEP(qxft0a, qyft0a, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3FT0C_CentFT0C"), collision.centFT0C(), getEP(qxft0c, qyft0c, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3BPos_CentFT0C"), collision.centFT0C(), getEP(qxbpos, qybpos, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3BNeg_CentFT0C"), collision.centFT0C(), getEP(qxbneg, qybneg, nmod)); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hEP3BTot_CentFT0C"), collision.centFT0C(), getEP(qxbtot, qybtot, nmod)); + + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0MEP3BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0m, qyft0m, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0MEP3BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0m, qyft0m, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3BPosEP3BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxbpos, qybpos, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0AEP3BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0AEP3BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0AEP3BTot_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxbtot, qybtot, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0CEP3BPos_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbpos, qybpos, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0CEP3BNeg_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbneg, qybneg, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0CEP3BTot_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0c, qyft0c, nmod) - getEP(qxbtot, qybtot, nmod)))); + fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("Qvector/hPrfCosDiffEP3FT0AEP3FT0C_CentFT0C"), collision.centFT0C(), std::cos(nmod * (getEP(qxft0a, qyft0a, nmod) - getEP(qxft0c, qyft0c, nmod)))); + } + } + + template + void fillVn(TCollision const& collision, TTrack const& track) + { + int idx = std::distance(cfgnMods->begin(), std::find(cfgnMods->begin(), cfgnMods->end(), nmod)); + float qxft0m = collision.qvecFT0MReVec()[idx], qxft0a = collision.qvecFT0AReVec()[idx], qxft0c = collision.qvecFT0CReVec()[idx], qxbpos = collision.qvecBPosReVec()[idx], qxbneg = collision.qvecBNegReVec()[idx], qxbtot = collision.qvecBTotReVec()[idx]; + float qyft0m = collision.qvecFT0MImVec()[idx], qyft0a = collision.qvecFT0AImVec()[idx], qyft0c = collision.qvecFT0CImVec()[idx], qybpos = collision.qvecBPosImVec()[idx], qybneg = collision.qvecBNegImVec()[idx], qybtot = collision.qvecBTotImVec()[idx]; + std::array qft0m = {qxft0m, qyft0m}; + std::array qft0a = {qxft0a, qyft0a}; + std::array qft0c = {qxft0c, qyft0c}; + std::array qbpos = {qxbpos, qybpos}; + std::array qbneg = {qxbneg, qybneg}; + std::array qbtot = {qxbtot, qybtot}; + std::vector> qvectors = {qft0m, qft0a, qft0c, qbpos, qbneg, qbtot}; + + if (!isGoodQvector(qvectors)) { + return; + } + + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + + float sp = RecoDecay::dotProd(std::array{static_cast(std::cos(nmod * track.phi())), static_cast(std::sin(nmod * track.phi()))}, qvectors[cfgQvecEstimator]); + float cos = std::cos(nmod * (track.phi() - getEP(qvectors[cfgQvecEstimator][0], qvectors[cfgQvecEstimator][1], nmod))); + if constexpr (nmod == 2) { + fRegistry.fill(HIST("Track/hV2"), centralities[cfgCentEstimator], track.pt(), sp, cos); + } else if constexpr (nmod == 3) { + fRegistry.fill(HIST("Track/hV3"), centralities[cfgCentEstimator], track.pt(), sp, cos); + } + } + + float getEP(float qx, float qy, int nmod) + { + return std::atan2(qy, qx) / static_cast(nmod); + } + + template + bool isGoodQvector(TQvectors const& qvectors) + { + bool is_good = true; + for (auto& qvec : qvectors) { + if (fabs(qvec[0]) > 20.f || fabs(qvec[1]) > 20.f) { + is_good = false; + break; + } + } + return is_good; + } + + template + bool isSelectedTrack(TTrack const& track) + { + if (track.itsNCls() < trackcuts.cfg_min_ncluster_its) { + return false; + } + + if (track.itsNClsInnerBarrel() < trackcuts.cfg_min_ncluster_itsib) { + return false; + } + + if (track.tpcNClsFound() < trackcuts.cfg_min_ncluster_tpc) { + return false; + } + + if (track.tpcNClsCrossedRows() < trackcuts.cfg_min_ncrossedrows_tpc) { + 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; + } + + return true; + } + + template + bool isElectron(TTrack const& track) + { + if (track.tpcNSigmaEl() < trackcuts.cfg_min_TPCNsigmaEl || trackcuts.cfg_max_TPCNsigmaEl < track.tpcNSigmaEl()) { + return false; + } + + if (trackcuts.cfg_min_TPCNsigmaPi < track.tpcNSigmaPi() && track.tpcNSigmaPi() < trackcuts.cfg_max_TPCNsigmaPi) { + return false; + } + + if (trackcuts.cfg_requireTOF && !track.hasTOF()) { + return false; + } + + if (track.hasTOF() && (track.tofNSigmaEl() < trackcuts.cfg_min_TOFNsigmaEl || trackcuts.cfg_max_TOFNsigmaEl < track.tofNSigmaEl())) { + return false; + } + + return true; + } + + template + bool isSelectedEvent(TCollision const& collision) + { + if (!collision.sel8()) { + return false; + } + + if (fabs(collision.posZ()) > eventcuts.cfgZvtxMax) { + 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.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.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + return false; + } + + 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_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_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; + using FilteredMyCollisions = soa::Filtered; + using FilteredMyCollisions_Qvec = soa::Filtered; + + using FilteredMyCollision = FilteredMyCollisions::iterator; + using FilteredMyCollision_Qvec = FilteredMyCollisions_Qvec::iterator; + + Filter trackFilter = (trackcuts.cfg_min_pt_track < o2::aod::track::pt && o2::aod::track::pt < trackcuts.cfg_max_pt_track) && (trackcuts.cfg_min_eta_track < o2::aod::track::eta && o2::aod::track::eta < trackcuts.cfg_max_eta_track) && nabs(o2::aod::track::dcaXY) < trackcuts.cfg_max_dcaxy && nabs(o2::aod::track::dcaZ) < trackcuts.cfg_max_dcaz && o2::aod::track::tpcChi2NCl < trackcuts.cfg_max_chi2tpc && o2::aod::track::itsChi2NCl < trackcuts.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; + using FilteredMyTracks = soa::Filtered; + + SliceCache cache; + Preslice perCol = o2::aod::track::collisionId; + + template + void processQC(TCollisions const& collisions, FilteredMyTracks const& tracks) + { + for (auto& collision : collisions) { + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + fillEventInfo<0>(collision); + if (!isSelectedEvent(collision)) { + continue; + } + fillEventInfo<1>(collision); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 13); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 13); // accepted + + int nGlobalTracks = 0, nGlobalTracksPV = 0; + auto tracks_per_coll = tracks.sliceBy(perCol, collision.globalIndex()); + for (auto& track : tracks_per_coll) { + if (!isSelectedTrack(track)) { + continue; + } + if (isElectron(track)) { + fillTrackInfo(track); + } + if (fabs(track.eta()) < 0.8) { + nGlobalTracks++; + + if constexpr (std::is_same_v, FilteredMyCollisions_Qvec>) { + for (int i = 0; i < static_cast(cfgnMods->size()); i++) { + if (cfgnMods->at(i) == 2) { + fillVn<2>(collision, track); + } else if (cfgnMods->at(i) == 3) { + fillVn<3>(collision, track); + } + } + } + + if (track.isPVContributor()) { + 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>) { + fRegistry.fill(HIST("Event/after/hCentFT0CvsMultNGlobalTracks"), collision.centFT0C(), nGlobalTracks); + fRegistry.fill(HIST("Event/after/hCentFT0CvsMultNGlobalTracksPV"), collision.centFT0C(), nGlobalTracksPV); + } + } // end of collision loop + } // end of process + + PROCESS_SWITCH_FULL(eventQC, processQC, processEventQC, "event QC", true); + PROCESS_SWITCH_FULL(eventQC, processQC, processEventQC_Cent_Qvec, "event QC + q vector", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"event-qc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx b/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx index 59bf2488033..604f11ffde4 100644 --- a/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx +++ b/PWGEM/Dilepton/Tasks/lmeeHFCocktail.cxx @@ -15,20 +15,23 @@ /// \author Daniel Samitz, , SMI Vienna /// Elisa Meninno, , SMI Vienna +#include + #include "Math/Vector4D.h" +#include "MathUtils/Utils.h" #include "Framework/Task.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "PWGDQ/DataModel/ReducedInfoTables.h" #include "PWGEM/Dilepton/Utils/MCUtilities.h" +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::aod::pwgem::dilepton::utils::mcutil; -using McParticlesSmeared = soa::Join; +using McParticlesSmeared = soa::Join; enum EFromHFType { kNoE = -1, @@ -71,7 +74,7 @@ void doSingle(T& p, std::vector> hEta, std::vector cut_pt[i] && abs(eta[i]) < cut_eta[i]) { + if (pt[i] > cut_pt[i] && fabs(eta[i]) < cut_eta[i]) { hEta[i]->Fill(eta[i], weight[i]); hPt[i]->Fill(pt[i], weight[i]); hPtEta[i]->Fill(pt[i], eta[i], weight[i]); @@ -80,7 +83,7 @@ void doSingle(T& p, std::vector> hEta, std::vector -void doPair(T& p1, T& p2, std::vector> hMee, std::vector> hMeePtee, float ptMin, float etaMax) +void doPair(T& p1, T& p2, std::vector> hMee, std::vector> hMeePtee, float ptMin, float etaMax, bool apply_detadphi, float min_deta, float min_dphi) { ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); @@ -100,8 +103,15 @@ void doPair(T& p1, T& p2, std::vector> hMee, std::vector cut_pt[i] && pt2[i] > cut_pt[i] && abs(eta1[i]) < cut_eta[i] && abs(eta2[i]) < cut_eta[i]) { + if (pt1[i] > cut_pt[i] && pt2[i] > cut_pt[i] && fabs(eta1[i]) < cut_eta[i] && fabs(eta2[i]) < cut_eta[i]) { hMee[i]->Fill(mass[i], weight[i]); hMeePtee[i]->Fill(mass[i], pt[i], weight[i]); } @@ -115,7 +125,9 @@ struct MyConfigs : ConfigurableGroup { ConfigurableAxis fConfigEtaBins{"cfgEtaBins", {200, -10.f, 10.f}, "eta binning"}; ConfigurableAxis fConfigMeeBins{"cfgMeeBins", {800, 0.f, 8.f}, "Mee binning"}; ConfigurableAxis fConfigPteeBins{"cfgPteeBins", {400, 0.f, 10.f}, "pTee binning"}; - Configurable fConfigCheckPartonic{"cfgCheckPartonic", true, "check entire partonic history for pairs"}; + Configurable fConfigApplyDEtaDPhi{"cfgApplyDEtaDPhi", false, "flag to apply deta-phi cut"}; + Configurable fConfigMinDEta{"cfgMinDEta", 0.02, "minimum deta"}; + Configurable fConfigMinDPhi{"cfgMinDPhi", 0.2, "minimum dphi"}; }; struct lmeehfcocktailprefilter { @@ -148,15 +160,16 @@ struct lmeehfcocktailprefilter { int bQuarkOriginId = -1; int isHF = EFromHFType::kNoHFE; - if (direct_charm_mother && bHadronId < 0) { // c->e - isHF = EFromHFType::kCE; - auto cHadron = mcParticles.iteratorAt(cHadronId); - cQuarkId = searchMothers(cHadron, mcParticles, 4, true); - if (cQuarkId > -1) { - auto cQuark = mcParticles.iteratorAt(cQuarkId); - cQuarkOriginId = searchMothers(cQuark, mcParticles, 4, false); + + if (direct_beauty_mother) { // b->e + isHF = EFromHFType::kBE; + auto bHadron = mcParticles.iteratorAt(bHadronId); + bQuarkId = searchMothers(bHadron, mcParticles, 5, true); + if (bQuarkId > -1) { + auto bQuark = mcParticles.iteratorAt(bQuarkId); + bQuarkOriginId = searchMothers(bQuark, mcParticles, 5, false); } - } else if (direct_charm_mother && bHadronId > -1) { // b->c->e + } else if (bHadronId > -1 && direct_charm_mother) { // b->c->e isHF = EFromHFType::kBCE; auto bHadron = mcParticles.iteratorAt(bHadronId); bQuarkId = searchMothers(bHadron, mcParticles, 5, true); @@ -170,15 +183,16 @@ struct lmeehfcocktailprefilter { auto cQuark = mcParticles.iteratorAt(cQuarkId); cQuarkOriginId = searchMothers(cQuark, mcParticles, 4, false); } - } else if (direct_beauty_mother) { // b->e - isHF = EFromHFType::kBE; - auto bHadron = mcParticles.iteratorAt(bHadronId); - bQuarkId = searchMothers(bHadron, mcParticles, 5, true); - if (bQuarkId > -1) { - auto bQuark = mcParticles.iteratorAt(bQuarkId); - bQuarkOriginId = searchMothers(bQuark, mcParticles, 5, false); + } else if (bHadronId < 0 && direct_charm_mother) { // c->e + isHF = EFromHFType::kCE; + auto cHadron = mcParticles.iteratorAt(cHadronId); + cQuarkId = searchMothers(cHadron, mcParticles, 4, true); + if (cQuarkId > -1) { + auto cQuark = mcParticles.iteratorAt(cQuarkId); + cQuarkOriginId = searchMothers(cQuark, mcParticles, 4, false); } } + hfTable(isHF, bHadronId, cHadronId, bQuarkId, cQuarkId, bQuarkOriginId, cQuarkOriginId); } } @@ -188,15 +202,18 @@ struct lmeehfcocktailbeauty { HistogramRegistry registry{"registry", {}}; - std::vector>> hEta, hPt, hULS_Mee; - std::vector>> hPtEta, hULS_MeePtee; - std::vector> hLSpp_Mee, hLSmm_Mee; - std::vector> hLSpp_MeePtee, hLSmm_MeePtee; + std::vector>> hEta, hPt; + std::vector>> hPtEta; + std::vector> hLS_Mee, hULS_Mee; + std::vector> hLS_MeePtee, hULS_MeePtee; + + std::vector> hLS_Mee_wPartonicCheck, hULS_Mee_wPartonicCheck; + std::vector> hLS_MeePtee_wPartonicCheck, hULS_MeePtee_wPartonicCheck; MyConfigs myConfigs; Filter hfFilter = o2::aod::hftable::isHF == static_cast(EFromHFType::kBE) || o2::aod::hftable::isHF == static_cast(EFromHFType::kBCE); - using MyFilteredMcParticlesSmeared = soa::Filtered>; + using MyFilteredMcParticlesSmeared = soa::Filtered>; Preslice perCollision = aod::mcparticle::mcCollisionId; @@ -207,8 +224,6 @@ struct lmeehfcocktailbeauty { { registry.add("NEvents", "NEvents", HistType::kTH1F, {{1, 0, 1}}, false); - const char* typeNamesPairULS[4] = {"Be_Be", "BCe_BCe", "BCe_Be_SameB", "allB"}; - const char* typeNamesPairLS = "BCe_Be_DiffB"; const char* typeNamesSingle[2] = {"be", "bce"}; const char* typeTitlesSingle[2] = {"b->e", "b->c->e"}; @@ -233,31 +248,26 @@ struct lmeehfcocktailbeauty { // pair histograms // ULS - for (int i = 0; i < 4; i++) { - std::vector> hMee_temp; - std::vector> hMeePtee_temp; - for (int j = 0; j < 3; j++) { - hMee_temp.push_back(registry.add(Form("ULS_Mee_%s_%s", typeNamesPairULS[i], stageNames[j]), Form("ULS Mee %s %s", typeNamesPairULS[i], stageNames[j]), HistType::kTH1F, {mass_axis}, true)); - hMeePtee_temp.push_back(registry.add(Form("ULS_MeePtee_%s_%s", typeNamesPairULS[i], stageNames[j]), Form("ULS Mee vs. Ptee %s %s", typeNamesPairULS[i], stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); - } - hULS_Mee.push_back(hMee_temp); - hULS_MeePtee.push_back(hMeePtee_temp); + for (int j = 0; j < 3; j++) { + hULS_Mee.push_back(registry.add(Form("ULS_Mee_%s", stageNames[j]), Form("ULS Mee %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hULS_MeePtee.push_back(registry.add(Form("ULS_MeePtee_%s", stageNames[j]), Form("ULS Mee vs. Ptee %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + + hULS_Mee_wPartonicCheck.push_back(registry.add(Form("ULS_Mee_wPartonicCheck_%s", stageNames[j]), Form("ULS Mee wPartonicCheck %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hULS_MeePtee_wPartonicCheck.push_back(registry.add(Form("ULS_MeePtee_wPartonicCheck_%s", stageNames[j]), Form("ULS Mee vs. Ptee wPartonicCheck %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); } // LS for (int j = 0; j < 3; j++) { - hLSpp_Mee.push_back(registry.add(Form("LSpp_Mee_%s_%s", typeNamesPairLS, stageNames[j]), Form("LS++ Mee %s %s", typeNamesPairLS, stageNames[j]), HistType::kTH1F, {mass_axis}, true)); - hLSmm_Mee.push_back(registry.add(Form("LSmm_Mee_%s_%s", typeNamesPairLS, stageNames[j]), Form("LS-- Mee %s %s", typeNamesPairLS, stageNames[j]), HistType::kTH1F, {mass_axis}, true)); - hLSpp_MeePtee.push_back(registry.add(Form("LSpp_MeePtee_%s_%s", typeNamesPairLS, stageNames[j]), Form("LS++ Mee vs. Ptee %s %s", typeNamesPairLS, stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); - hLSmm_MeePtee.push_back(registry.add(Form("LSmm_MeePtee_%s_%s", typeNamesPairLS, stageNames[j]), Form("LS-- Mee vs. Ptee %s %s", typeNamesPairLS, stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + hLS_Mee.push_back(registry.add(Form("LS_Mee_%s", stageNames[j]), Form("LS Mee %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hLS_MeePtee.push_back(registry.add(Form("LS_MeePtee_%s", stageNames[j]), Form("LS Mee vs. Ptee %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + + hLS_Mee_wPartonicCheck.push_back(registry.add(Form("LS_Mee_wPartonicCheck_%s", stageNames[j]), Form("LS Mee wPartonicCheck %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hLS_MeePtee_wPartonicCheck.push_back(registry.add(Form("LS_MeePtee_wPartonicCheck_%s", stageNames[j]), Form("LS Mee vs. Ptee wPartonicCheck %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); } } - void processBeauty(aod::McCollisions const& collisions, MyFilteredMcParticlesSmeared const& mcParticles, aod::McParticles const& mcParticlesAll) + void processBeauty(aod::McCollisions const& collisions, MyFilteredMcParticlesSmeared const& mcParticles) { for (auto const& p : mcParticles) { - if (myConfigs.fConfigCheckPartonic && p.bQuarkOriginId() < 0) { - continue; - } int from_quark = p.isHF() - 2; doSingle(p, hEta[from_quark], hPt[from_quark], hPtEta[from_quark], myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); } @@ -270,49 +280,41 @@ struct lmeehfcocktailbeauty { auto const positronsGrouped = Positrons->sliceBy(perCollision, collision.globalIndex()); // ULS spectrum for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsFullIndexPolicy(electronsGrouped, positronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) - continue; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - int type = IsHF(particle1, particle2, mcParticlesAll); - if (type == static_cast(EM_HFeeType::kUndef)) + + doPair(particle1, particle2, hULS_Mee, hULS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) continue; - if ((type < static_cast(EM_HFeeType::kBe_Be)) || (type > static_cast(EM_HFeeType::kBCe_Be_SameB))) { - LOG(error) << "Something is wrong here. There should only be pairs of type kBe_Be = 1, kBCe_BCe = 2 and kBCe_Be_SameB = 3 left at this point."; - } - doPair(particle1, particle2, hULS_Mee[type - 1], hULS_MeePtee[type - 1], myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); - doPair(particle1, particle2, hULS_Mee[3], hULS_MeePtee[3], myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); // fill the 'allB' histograms that holds the sum of the others + doPair(particle1, particle2, hULS_Mee_wPartonicCheck, hULS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } // LS spectrum for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(electronsGrouped, electronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) - continue; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - int type = IsHF(particle1, particle2, mcParticlesAll); - if (type == static_cast(EM_HFeeType::kUndef)) + + doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) continue; - if (myConfigs.fConfigCheckPartonic) { - if (type != static_cast(EM_HFeeType::kBCe_Be_DiffB)) { - LOG(error) << "Something is wrong here. There should only be pairs of type kBCe_Be_DiffB = 4 left at this point."; - } - } - doPair(particle1, particle2, hLSmm_Mee, hLSmm_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); + doPair(particle1, particle2, hLS_Mee_wPartonicCheck, hLS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(positronsGrouped, positronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) - continue; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - int type = IsHF(particle1, particle2, mcParticlesAll); - if (type == static_cast(EM_HFeeType::kUndef)) + + doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.bQuarkOriginId() < 0 || particle2.bQuarkOriginId() < 0 || particle1.bQuarkOriginId() != particle2.bQuarkOriginId()) continue; - if (myConfigs.fConfigCheckPartonic) { - if (type != static_cast(EM_HFeeType::kBCe_Be_DiffB)) { - LOG(error) << "Something is wrong here. There should only be pairs of type kBCe_Be_DiffB = 4 left at this point."; - } - } - doPair(particle1, particle2, hLSpp_Mee, hLSpp_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); + doPair(particle1, particle2, hLS_Mee_wPartonicCheck, hLS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } } } @@ -332,11 +334,13 @@ struct lmeehfcocktailcharm { std::vector> hEta, hPt, hULS_Mee, hLS_Mee; std::vector> hPtEta, hULS_MeePtee, hLS_MeePtee; + std::vector> hULS_Mee_wPartonicCheck, hLS_Mee_wPartonicCheck; + std::vector> hULS_MeePtee_wPartonicCheck, hLS_MeePtee_wPartonicCheck; MyConfigs myConfigs; Filter hfFilter = o2::aod::hftable::isHF == static_cast(EFromHFType::kCE); - using MyFilteredMcParticlesSmeared = soa::Filtered>; + using MyFilteredMcParticlesSmeared = soa::Filtered>; Preslice perCollision = aod::mcparticle::mcCollisionId; @@ -347,7 +351,6 @@ struct lmeehfcocktailcharm { { registry.add("NEvents", "NEvents", HistType::kTH1F, {{1, 0, 1}}, false); - const char* typeNamesPairULS = "Ce_Ce"; const char* typeNamesSingle = "ce"; const char* typeTitlesSingle = "c->e"; @@ -366,21 +369,25 @@ struct lmeehfcocktailcharm { // pair histograms // ULS for (int j = 0; j < 3; j++) { - hULS_Mee.push_back(registry.add(Form("ULS_Mee_%s_%s", typeNamesPairULS, stageNames[j]), Form("ULS Mee %s %s", typeNamesPairULS, stageNames[j]), HistType::kTH1F, {mass_axis}, true)); - hULS_MeePtee.push_back(registry.add(Form("ULS_MeePtee_%s_%s", typeNamesPairULS, stageNames[j]), Form("ULS MeePtee %s %s", typeNamesPairULS, stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + hULS_Mee.push_back(registry.add(Form("ULS_Mee_%s", stageNames[j]), Form("ULS Mee %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hULS_MeePtee.push_back(registry.add(Form("ULS_MeePtee_%s", stageNames[j]), Form("ULS Mee vs Ptee %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + + hULS_Mee_wPartonicCheck.push_back(registry.add(Form("ULS_Mee_wPartonicCheck_%s", stageNames[j]), Form("ULS Mee wPartonicCheck %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hULS_MeePtee_wPartonicCheck.push_back(registry.add(Form("ULS_MeePtee_wPartonicCheck_%s", stageNames[j]), Form("ULS Mee vs Ptee wPartonicCheck %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); } + // LS for (int j = 0; j < 3; j++) { - hLS_Mee.push_back(registry.add(Form("LS_Mee_%s_%s", typeNamesPairULS, stageNames[j]), Form("LS Mee %s %s", typeNamesPairULS, stageNames[j]), HistType::kTH1F, {mass_axis}, true)); - hLS_MeePtee.push_back(registry.add(Form("LS_MeePtee_%s_%s", typeNamesPairULS, stageNames[j]), Form("LS MeePtee %s %s", typeNamesPairULS, stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + hLS_Mee.push_back(registry.add(Form("LS_Mee_%s", stageNames[j]), Form("LS Mee %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hLS_MeePtee.push_back(registry.add(Form("LS_MeePtee_%s", stageNames[j]), Form("LS Mee vs Ptee %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); + + hLS_Mee_wPartonicCheck.push_back(registry.add(Form("LS_Mee_wPartonicCheck_%s", stageNames[j]), Form("LS Mee wPartonicCheck %s", stageNames[j]), HistType::kTH1F, {mass_axis}, true)); + hLS_MeePtee_wPartonicCheck.push_back(registry.add(Form("LS_MeePtee_wPartonicCheck_%s", stageNames[j]), Form("LS Mee vs Ptee wPartonicCheck %s", stageNames[j]), HistType::kTH2F, {mass_axis, ptee_axis}, true)); } } - void processCharm(aod::McCollisions const& collisions, MyFilteredMcParticlesSmeared const& mcParticles, aod::McParticles const& mcParticlesAll) + void processCharm(aod::McCollisions const& collisions, MyFilteredMcParticlesSmeared const& mcParticles) { for (auto const& p : mcParticles) { - if (myConfigs.fConfigCheckPartonic && p.cQuarkOriginId() < 0) { - continue; - } doSingle(p, hEta, hPt, hPtEta, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); } @@ -392,29 +399,41 @@ struct lmeehfcocktailcharm { auto const positronsGrouped = Positrons->sliceBy(perCollision, collision.globalIndex()); // ULS spectrum for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsFullIndexPolicy(electronsGrouped, positronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) - continue; - } - if (IsHF(particle1, particle2, mcParticlesAll) != static_cast(EM_HFeeType::kCe_Ce)) { - LOG(error) << "Something is wrong here. There should only be pairs of type kCe_Ce = 0 left at this point."; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - doPair(particle1, particle2, hULS_Mee, hULS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); + + doPair(particle1, particle2, hULS_Mee, hULS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) + continue; + doPair(particle1, particle2, hULS_Mee_wPartonicCheck, hULS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } // LS for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(electronsGrouped, electronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) - continue; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); + + doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) + continue; + doPair(particle1, particle2, hLS_Mee_wPartonicCheck, hLS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } for (auto const& [particle1, particle2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(positronsGrouped, positronsGrouped))) { - if (myConfigs.fConfigCheckPartonic) { - if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) - continue; + + if (particle1.mothersIds()[0] == particle2.mothersIds()[0]) { + LOG(error) << "Something is wrong here. There should not be dielectrons with same mother."; } - doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax); + + doPair(particle1, particle2, hLS_Mee, hLS_MeePtee, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); + + if (particle1.cQuarkOriginId() < 0 || particle2.cQuarkOriginId() < 0 || particle1.cQuarkOriginId() != particle2.cQuarkOriginId()) + continue; + doPair(particle1, particle2, hLS_Mee_wPartonicCheck, hLS_MeePtee_wPartonicCheck, myConfigs.fConfigPtMin, myConfigs.fConfigEtaMax, myConfigs.fConfigApplyDEtaDPhi, myConfigs.fConfigMinDEta, myConfigs.fConfigMinDPhi); } } } diff --git a/PWGEM/Dilepton/Tasks/lmeeLFCocktail.cxx b/PWGEM/Dilepton/Tasks/lmeeLFCocktail.cxx index 2799fcd8341..86b69e3a78d 100644 --- a/PWGEM/Dilepton/Tasks/lmeeLFCocktail.cxx +++ b/PWGEM/Dilepton/Tasks/lmeeLFCocktail.cxx @@ -10,986 +10,540 @@ // or submit itself to any jurisdiction. // // -// Analysis task for lmee light flavour cocktail +/// \file lmeeLFCocktail.cxx +/// \analysis task for lmee light flavour cocktail +/// \author Daniel Samitz, , SMI Vienna +#include #include -#include "Framework/Task.h" +#include + +#include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" -#include "Framework/Logger.h" -#include "SimulationDataFormat/MCTrack.h" -#include "PWGEM/Dilepton/Utils/MomentumSmearer.h" -#include "Math/Vector4D.h" -#include "Math/Vector3D.h" -#include "TFile.h" -#include "TF1.h" -#include "TRandom.h" -#include "TDatabasePDG.h" -#include "TGenPhaseSpace.h" -#include "TGrid.h" -#include "TTree.h" -#include +#include "PWGEM/Dilepton/DataModel/dileptonTables.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +using namespace o2; using namespace o2::framework; -using namespace ROOT::Math; - -struct eeTTree { - float fd1DCA; - float fd2DCA; - float fpairDCA; - float fd1origpt; - float fd1origp; - float fd1origeta; - float fd1origphi; - float fd2origpt; - float fd2origp; - float fd2origeta; - float fd2origphi; - float fd1pt; - float fd1p; - float fd1eta; - float fd1phi; - float fd2pt; - float fd2p; - float fd2eta; - float fd2phi; - float feeorigpt; - float feeorigp; - float feeorigm; - float feeorigeta; - float feeorigphi; - float feeorigphiv; - float feept; - float feemt; - float feep; - float feem; - float feeeta; - float feephi; - float feephiv; - float fmotherpt; - float fmothermt; - float fmotherp; - float fmotherm; - float fmothereta; - float fmotherphi; - int fID; - int fdectyp; - int fdau3pdg; - float fweight; - float fwEffpT; - float fwMultpT; - float fwMultmT; - float fwMultpT2; - float fwMultmT2; - bool fpass; - float feeorigrap; // only in histogram, not in tree? - float feerap; // only in histogram, not in tree? -}; - -struct lmeelfcocktail { - OutputObj tree{"eeTTree"}; - - HistogramRegistry registry{"registry", {}}; - Int_t nInputParticles = 17; - std::vector fParticleListNames = {"Pi0", "Eta", "EtaP", "EtaP_dalitz_photon", "EtaP_dalitz_omega", "Rho", "Omega", "Omega_2body", "Omega_dalitz", "Phi", "Phi_2body", "Phi_dalitz_eta", "Phi_dalitz_pi0", "Jpsi", "Jpsi_2body", "Jpsi_radiative", "Virtual_Photon"}; - TH1F* fhwEffpT; - TH1F* fhwMultpT; - TH1F* fhwMultmT; - TH1F* fhwMultpT2; - TH1F* fhwMultmT2; - TH1F* fhKW; - TF1* ffVPHpT; - std::vector> fmee_orig, fmotherpT_orig, fphi_orig, frap_orig, fmee_orig_wALT, fmotherpT_orig_wALT, fmee, fphi, frap, fmee_wALT; - std::vector> fpteevsmee_wALT, fpteevsmee_orig_wALT, fpteevsmee_orig, fpteevsmee; +using McParticlesSmeared = soa::Join; - eeTTree treeWords; +struct lmeelfcocktail { - std::vector DCATemplateEdges; - int nbDCAtemplate; - TH1F** fh_DCAtemplates; + enum recLevel { + kGen = 0, + kRec, + kNRecLevels + }; + + struct mesonInfo { + TString name; + std::vector decayModes; + }; + + std::map decays = { + {-1, "e_e/"}, + {-2, "e_e_e_e/"}, + {22, "gamma_e_e/"}, + {223, "omega_e_e/"}, + {211 * 211, "pi_pi_e_e/"}, + {111, "pi0_e_e/"}, + {221, "eta_e_e/"}}; + + std::map mesons = { + {111, {"pi0/", {22, -2}}}, + {221, {"eta/", {22, 211 * 211, -2}}}, + {331, {"etaP/", {22, 223, 211 * 211}}}, + {113, {"rho/", {-1}}}, + {223, {"omega/", {-1, 111}}}, + {333, {"phi/", {-1, 111, 221}}}}; + + std::map histogramId; + + std::vector stage = {"gen/", "rec/"}; - MomentumSmearer smearer; + HistogramRegistry registry{"registry", {}}; - Double_t eMass; + Configurable fConfigApplyDEtaDPhi{"cfgApplyDEtaDPhi", false, "flag to apply deta-phi cut"}; + Configurable fConfigMinDEta{"cfgMinDEta", 0.02, "minimum deta"}; + Configurable fConfigMinDPhi{"cfgMinDPhi", 0.2, "minimum dphi"}; - Configurable fCollisionSystem{"cfgCollisionSystem", 200, "set the collision system"}; - Configurable fConfigWriteTTree{"cfgWriteTTree", false, "write tree output"}; - Configurable fConfigDoPairing{"cfgDoPairing", true, "do like and unlike sign pairing"}; Configurable fConfigMaxEta{"cfgMaxEta", 0.8, "maxium |eta|"}; Configurable fConfigMinPt{"cfgMinPt", 0.2, "minium pT"}; Configurable fConfigMaxPt{"cfgMaxPt", 8.0, "maximum pT"}; - Configurable fConfigNBinsMee{"cfgNBinsMee", 1200, "number of bins in invariant mass"}; - Configurable fConfigMinMee{"cfgMinMee", 0.0, "lowest bin in invariant mass"}; - Configurable fConfigMaxMee{"cfgMaxMee", 6.0, "highest bin in invariant mass"}; - Configurable fConfigNBinsPtee{"cfgNBinsPtee", 400, "number of bins in pT"}; - Configurable fConfigMinPtee{"cfgMinPtee", 0.0, "lowest bin in pT"}; - Configurable fConfigMaxPtee{"cfgMaxPtee", 10.0, "hightest bin in pT"}; - Configurable fConfigALTweight{"cfgALTweight", 1, "set alternative weighting type"}; - Configurable fConfigResFileName{"cfgResFileName", "", "name of resolution file"}; - Configurable fConfigEffFileName{"cfgEffFileName", "", "name of efficiency file"}; - Configurable fConfigMinOpAng{"cfgMinOpAng", 0.050, "minimum opening angle"}; - Configurable fConfigNBinsPhi{"cfgNBinsPhi", 240, "number of bins in phi"}; - Configurable fConfigNBinsRap{"cfgNBinsRap", 240, "number of bins in rap"}; - Configurable fConfigMaxAbsRap{"cfgMaxAbsRap", 1.2, "bin range in rap"}; - Configurable fConfigEffHistName{"cfgEffHistName", "fhwEffpT", "hisogram name in efficiency file"}; - Configurable fConfigResPHistName{"cfgResPHistName", "ptSlices", "histogram name for p in resolution file"}; - Configurable fConfigResPtHistName{"cfgResPtHistName", "RelPtResArrCocktail", "histogram name for pt in resolution file"}; - Configurable fConfigResEtaHistName{"cfgResEtaHistName", "EtaResArr", "histogram name for eta in resolution file"}; - Configurable fConfigResPhiPosHistName{"cfgResPhiPosHistName", "PhiPosResArr", "histogram name for phi pos in resolution file"}; - Configurable fConfigResPhiNegHistName{"cfgResPhiNegHistName", "PhiEleResArr", "hisogram for phi neg in resolution file"}; - Configurable fConfigDCAFileName{"cfgDCAFileName", "", "DCA file name"}; - Configurable fConfigDCAHistName{"cfgDCAHistName", "fh_DCAtemplate", "histogram name in DCA file"}; - Configurable fConfigMultFileName{"cfgMultFileName", "", "multiplicity file name"}; - Configurable fConfigMultHistPtName{"cfgMultHistPtName", "fhwMultpT", "hisogram name for pt in multiplicity file"}; - Configurable fConfigMultHistPt2Name{"cfgMultHistPt2Name", "fhwMultpT_upperlimit", "histogram name for pt 2 in multiplicity file"}; - Configurable fConfigMultHistMtName{"cfgMultHistMtName", "fhwMultmT", "histogram name for mt in multiplicity file"}; - Configurable fConfigMultHistMt2Name{"cfgMultHistMt2Name", "fhwMultmT_upperlimit", "histogram name for mt 2 in multiplicity file"}; - Configurable fConfigKWMax{"cfgKWMax", 1.1, "upper bound of Kroll-Wada"}; - Configurable fConfigDoVirtPh{"cfgDoVirtPh", false, "generate one virt. photon for each pion"}; - Configurable fConfigPhotonPtFileName{"cfgPhotonPtFileName", "", "file name for photon pT parametrization"}; - Configurable fConfigPhotonPtDirName{"cfgPhotonPtDirName", "", "directory name for photon pT parametrization"}; - Configurable fConfigPhotonPtFuncName{"cfgPhotonPtFuncName", "111_pt", "function name for photon pT parametrization"}; - - ConfigurableAxis fConfigPtBins{"cfgPtBins", {VARIABLE_WIDTH, 0., 0.5, 1, 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6., 6.5, 7., 7.5, 8.}, "pT bins"}; - ConfigurableAxis fConfigMBins{"cfgMBins", {VARIABLE_WIDTH, 0., 0.08, 0.14, 0.2, 1.1, 2.7, 2.8, 3.2, 5.0}, "mee bins"}; - ConfigurableAxis fConfigDCABins{"cfgDCABins", {VARIABLE_WIDTH, 0., 0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 3., 4., 5., 7., 10.}, "DCA bins"}; - - Configurable> fConfigDCATemplateEdges{"cfgDCATemplateEdges", {0., .3, .4, .6, 1., 2.}, "DCA template edges"}; - - void init(o2::framework::InitContext&) + Configurable fConfigMinOpAng{"cfgMinOpAng", 0, "minimum opening angle"}; + Configurable fConfigMinPtee{"cfgMinPtee", 0, "minimum pair pT"}; + Configurable fConfigMaxRapee{"cfgMaxRapee", 999., "maximum pair rapidity"}; + ConfigurableAxis fConfigMeeBins{"cfgMeeBins", {600, 0.f, 6.f}, "Mee binning"}; + ConfigurableAxis fConfigPteeBins{"cfgPteeBins", {400, 0.f, 10.f}, "pTee binning"}; + ConfigurableAxis fConfigCos2DPhi{"cfgCos2DPhi", {200, -1.f, +1.f}, "cos(2x(phiee-PsiRP)) binning"}; // for dilepton v2. + ConfigurableAxis fConfigPtBins{"cfgPtBins", {200, 0.f, 10.f}, "pT binning"}; + ConfigurableAxis fConfigEtaBins{"cfgEtaBins", {200, -5.f, 5.f}, "eta binning"}; + ConfigurableAxis fConfigPhiBins{"cfgPhiBins", {200, -TMath::Pi(), TMath::Pi()}, "phi binning"}; + ConfigurableAxis fConfigPhiVBins{"cfgPhiVBins", {200, 0, TMath::Pi()}, "phiV binning"}; + ConfigurableAxis fConfigOpAngBins{"cfgOpAngBins", {200, 0, TMath::Pi()}, "opening angle binning"}; + ConfigurableAxis fConfigDcaBins{"cfgDcaBins", {VARIABLE_WIDTH, 0., 0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 3., 4., 5., 7., 10.}, "dca binning"}; + + std::vector> histograms1D; + std::vector> histograms2D; + std::vector> histogramsND; + + template + bool from_primary(T& p1, U& mcParticles) { - if (fConfigWriteTTree) { - SetTree(); + if (!p1.has_mothers()) { + return false; } - SetHistograms(); - DCATemplateEdges = fConfigDCATemplateEdges; - nbDCAtemplate = DCATemplateEdges.size(); - DCATemplateEdges.push_back(10000000.); - - if ((TString(fConfigEffFileName).BeginsWith("alien://") && TString(fConfigEffFileName).EndsWith(".root")) || (TString(fConfigResFileName).BeginsWith("alien://") && TString(fConfigResFileName).EndsWith(".root")) || (TString(fConfigDCAFileName).BeginsWith("alien://") && TString(fConfigDCAFileName).EndsWith(".root")) || (TString(fConfigMultFileName).BeginsWith("alien://") && TString(fConfigMultFileName).EndsWith(".root")) || (TString(fConfigPhotonPtFileName).BeginsWith("alien://") && TString(fConfigPhotonPtFileName).EndsWith(".root"))) { - LOGP(info, "Connecting to grid via TGrid"); - TGrid::Connect("alien://"); + auto mother = mcParticles.iteratorAt(p1.mothersIds()[0]); + if (mother.has_mothers()) { + return false; } - - GetEffHisto(TString(fConfigEffFileName), TString(fConfigEffHistName)); - InitSmearer(TString(fConfigResFileName), TString(fConfigResPtHistName), TString(fConfigResEtaHistName), TString(fConfigResPhiPosHistName), TString(fConfigResPhiNegHistName)); - GetDCATemplates(TString(fConfigDCAFileName), TString(fConfigDCAHistName)); - GetMultHisto(TString(fConfigMultFileName), TString(fConfigMultHistPtName), TString(fConfigMultHistPt2Name), TString(fConfigMultHistMtName), TString(fConfigMultHistMt2Name)); - if (fConfigDoVirtPh) { - GetPhotonPtParametrization(TString(fConfigPhotonPtFileName), TString(fConfigPhotonPtDirName), TString(fConfigPhotonPtFuncName)); - } - - eMass = (TDatabasePDG::Instance()->GetParticle(11))->Mass(); - - fillKrollWada(); + return true; } - void run(o2::framework::ProcessingContext& pc) + bool isAcceptedSingle(ROOT::Math::PtEtaPhiMVector p1) { - // get number of events per timeframe - auto Nparts = pc.inputs().getNofParts(0); - - for (auto i = 0U; i < Nparts; ++i) { - registry.fill(HIST("NEvents"), 0.5); - // get the tracks - auto mctracks = pc.inputs().get>("mctracks", i); - - std::vector eBuff; - std::vector echBuff; - std::vector eweightBuff; - - bool skipNext = false; - - int trackID = -1; - // Loop over all MC particle - for (auto& mctrack : mctracks) { - trackID++; - if (o2::mcgenstatus::getHepMCStatusCode(mctrack.getStatusCode()) != 1) - continue; - if (abs(mctrack.GetPdgCode()) == 11) { - // get the electron - //--------------- - if (fConfigDoPairing) { - // LS and ULS spectra - PxPyPzEVector e, dielectron; - Char_t ech, dielectron_ch; - Double_t eweight, dielectron_weight; - e.SetPxPyPzE(mctrack.Px(), mctrack.Py(), mctrack.Pz(), - mctrack.GetEnergy()); - if (mctrack.GetPdgCode() > 0) { - ech = 1.; - } else { - ech = -1.; - } - eweight = mctrack.getWeight(); - // put in the buffer - //----------------- - eBuff.push_back(e); - echBuff.push_back(ech); - eweightBuff.push_back(eweight); - // loop the buffer and pair - //------------------------ - for (Int_t jj = eBuff.size() - 2; jj >= 0; jj--) { - dielectron = eBuff.at(jj) + e; - dielectron_ch = (echBuff.at(jj) + ech) / 2; - dielectron_weight = eweightBuff.at(jj) * eweight; - - if (dielectron_ch == 0) - registry.fill(HIST("ULS_orig"), dielectron.M(), dielectron.Pt(), dielectron_weight); - if (dielectron_ch > 0) - registry.fill(HIST("LSpp_orig"), dielectron.M(), dielectron.Pt(), dielectron_weight); - if (dielectron_ch < 0) - registry.fill(HIST("LSmm_orig"), dielectron.M(), dielectron.Pt(), dielectron_weight); - if (e.Pt() > fConfigMinPt && eBuff.at(jj).Pt() > fConfigMinPt && e.Pt() < fConfigMaxPt && eBuff.at(jj).Pt() < fConfigMaxPt && TMath::Abs(e.Eta()) < fConfigMaxEta && TMath::Abs(eBuff.at(jj).Eta()) < fConfigMaxEta && e.Vect().Unit().Dot(eBuff.at(jj).Vect().Unit()) < TMath::Cos(fConfigMinOpAng)) { - if (dielectron_ch == 0) - registry.fill(HIST("ULS"), dielectron.M(), dielectron.Pt(), dielectron_weight); - if (dielectron_ch > 0) - registry.fill(HIST("LSpp"), dielectron.M(), dielectron.Pt(), dielectron_weight); - if (dielectron_ch < 0) - registry.fill(HIST("LSmm"), dielectron.M(), dielectron.Pt(), dielectron_weight); - } - } - } - - if (skipNext) { - skipNext = false; - continue; // skip if marked as second electron - } - - if (!(mctrack.getMotherTrackId() > -1)) - continue; // has no mother - - auto const& mother = mctracks[mctrack.getMotherTrackId()]; - - if (mother.getMotherTrackId() > -1) - continue; // mother is not primary - - if (mctrack.getSecondMotherTrackId() - mctrack.getMotherTrackId() > 0) - continue; // more than one mother - - // skip for the moment other particles rather than pi0, eta, etaprime, - // omega, rho, phi. - switch (mother.GetPdgCode()) { - case 111: - break; - case 221: - break; - case 331: - break; - case 113: - break; - case 223: - break; - case 333: - break; - case 443: - break; - default: - continue; - } - - /* - // Not sure about this cut. From GammaConv group. Harmless a priori. - if (!(fabs(mctrack.GetEnergy() - mctrack.Pz()) > 0.)) - continue; - - // ???? this applied only to first daughter! - Double_t yPre = (mctrack.GetEnergy() + mctrack.Pz()) / (mctrack.GetEnergy() - mctrack.Pz()); - Double_t y = 0.5 * TMath::Log(yPre); - if (fConfigDoRapidityCut) { // Apply rapidity cut on mother consistent with GammaConv group. (??? but it is not applied on mother?) - if (yPre <= 0.) - continue; - if (TMath::Abs(y) > fConfigRapidityCut) - continue; - } else { - if (yPre == 0.) - continue; - }*/ - - treeWords.fdectyp = mother.getLastDaughterTrackId() - mother.getFirstDaughterTrackId() + 1; // fdectyp: decay type (based on number of daughters). - if (treeWords.fdectyp > 4) - continue; // exclude five or more particles decay - - if (trackID == mctracks.size()) - continue; // no particle left in the list - auto mctrack2 = mctracks[trackID + 1]; - if (!(mctrack2.getMotherTrackId() == mctrack.getMotherTrackId())) - continue; // no matching second electron - if (!(mctrack.getSecondMotherTrackId() == -1)) - continue; // second daughter has more than one mother - if (!(abs(mctrack2.GetPdgCode()) == 11)) - continue; // not an electron - - skipNext = true; // is matching electron --> next particle in list will be skipped - - PxPyPzEVector dau1, dau2, ee; - dau1.SetPxPyPzE(mctrack.Px(), mctrack.Py(), mctrack.Pz(), mctrack.GetEnergy()); - dau2.SetPxPyPzE(mctrack2.Px(), mctrack2.Py(), mctrack2.Pz(), mctrack2.GetEnergy()); - - // create dielectron before resolution effects: - ee = dau1 + dau2; - - // get info of the other particles in the decay: - treeWords.fdau3pdg = 0; - for (Int_t jj = mother.getFirstDaughterTrackId(); jj <= mother.getLastDaughterTrackId(); jj++) { - if (jj == trackID || jj == trackID + 1) { - continue; // first or second electron - } - auto mctrack3 = mctracks[jj]; - treeWords.fdau3pdg = abs(mctrack3.GetPdgCode()); - } - - // get index for histograms - Int_t hindex[3]; - for (Int_t jj = 0; jj < 3; jj++) { - hindex[jj] = -1; - } - switch (mother.GetPdgCode()) { - case 111: - hindex[0] = 0; - break; - case 221: - hindex[0] = 1; - break; - case 331: - hindex[0] = 2; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 22) - hindex[1] = 3; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 223) - hindex[1] = 4; - break; - case 113: - hindex[0] = 5; - break; - case 223: - hindex[0] = 6; - if (treeWords.fdectyp == 2) - hindex[1] = 7; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 111) - hindex[1] = 8; - break; - case 333: - hindex[0] = 9; - if (treeWords.fdectyp == 2) - hindex[1] = 10; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 221) - hindex[1] = 11; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 111) - hindex[1] = 12; - break; - case 443: - hindex[0] = 13; - if (treeWords.fdectyp == 2) - hindex[1] = 14; - if (treeWords.fdectyp == 3 && treeWords.fdau3pdg == 22) - hindex[1] = 15; - break; - } - - hindex[2] = nInputParticles; - - if (hindex[0] < 0) { - LOGP(error, "hindex[0]<0"); - continue; - } - - // Fill tree words before resolution/acceptance - treeWords.fd1origpt = dau1.Pt(); - treeWords.fd1origp = dau1.P(); - treeWords.fd1origeta = dau1.Eta(); - treeWords.fd1origphi = dau1.Phi(); - treeWords.fd2origpt = dau2.Pt(); - treeWords.fd2origp = dau2.P(); - treeWords.fd2origeta = dau2.Eta(); - treeWords.fd2origphi = dau2.Phi(); - treeWords.feeorigpt = ee.Pt(); - treeWords.feeorigp = ee.P(); - treeWords.feeorigm = ee.M(); - treeWords.feeorigeta = ee.Eta(); - treeWords.feeorigrap = ee.Rapidity(); - treeWords.feeorigphi = ee.Phi(); - if (mctrack.GetPdgCode() > 0) { - treeWords.feeorigphiv = PhiV(dau1, dau2); - } else { - treeWords.feeorigphiv = PhiV(dau2, dau1); - } - - // get the efficiency weight - Int_t effbin = fhwEffpT->FindBin(treeWords.fd1origpt); - treeWords.fwEffpT = fhwEffpT->GetBinContent(effbin); - effbin = fhwEffpT->FindBin(treeWords.fd2origpt); - treeWords.fwEffpT = treeWords.fwEffpT * fhwEffpT->GetBinContent(effbin); - - // Resolution and acceptance - //------------------------- - int ch1 = 1; - int ch2 = 1; - if (mctrack.GetPdgCode() > 0) { - ch1 = -1; - } - if (mctrack2.GetPdgCode() > 0) { - ch2 = -1; - } - dau1 = applySmearingPxPyPzE(ch1, dau1); - dau2 = applySmearingPxPyPzE(ch2, dau2); - - treeWords.fd1pt = dau1.Pt(); - treeWords.fd1eta = dau1.Eta(); - treeWords.fd2pt = dau2.Pt(); - treeWords.fd2eta = dau2.Eta(); - treeWords.fpass = true; - if (treeWords.fd1pt < fConfigMinPt || treeWords.fd2pt < fConfigMinPt) - treeWords.fpass = false; // leg pT cut - if (treeWords.fd1pt > fConfigMaxPt || treeWords.fd2pt > fConfigMaxPt) - treeWords.fpass = false; // leg pT cut - if (dau1.Vect().Unit().Dot(dau2.Vect().Unit()) > TMath::Cos(fConfigMinOpAng)) - treeWords.fpass = false; // opening angle cut - if (TMath::Abs(treeWords.fd1eta) > fConfigMaxEta || TMath::Abs(treeWords.fd2eta) > fConfigMaxEta) - treeWords.fpass = false; - - // get the pair DCA (based in smeared pT) - for (int jj = 0; jj < nbDCAtemplate; jj++) { // loop over DCA templates - if (dau1.Pt() >= DCATemplateEdges[jj] && dau1.Pt() < DCATemplateEdges[jj + 1]) { - treeWords.fd1DCA = fh_DCAtemplates[jj]->GetRandom(); - } - if (dau2.Pt() >= DCATemplateEdges[jj] && dau2.Pt() < DCATemplateEdges[jj + 1]) { - treeWords.fd2DCA = fh_DCAtemplates[jj]->GetRandom(); - } - } - treeWords.fpairDCA = sqrt((pow(treeWords.fd1DCA, 2) + pow(treeWords.fd2DCA, 2)) / 2); - - // Fill tree words after resolution/acceptance - ee = dau1 + dau2; - treeWords.fd1p = dau1.P(); - treeWords.fd1phi = dau1.Phi(); - treeWords.fd2p = dau2.P(); - treeWords.fd2phi = dau2.Phi(); - treeWords.feept = ee.Pt(); - treeWords.feemt = ee.Mt(); - treeWords.feep = ee.P(); - treeWords.feem = ee.M(); - treeWords.feeeta = ee.Eta(); - treeWords.feerap = ee.Rapidity(); - treeWords.feephi = ee.Phi(); - if (mctrack.GetPdgCode() > 0) { - treeWords.feephiv = PhiV(dau1, dau2); - } else { - treeWords.feephiv = PhiV(dau2, dau1); - } - treeWords.fmotherpt = mother.GetPt(); - treeWords.fmotherm = sqrt(pow(mother.GetEnergy(), 2) + pow(mother.GetP(), 2)); - treeWords.fmothermt = sqrt(pow(treeWords.fmotherm, 2) + pow(treeWords.fmotherpt, 2)); - treeWords.fmotherp = mother.GetP(); - treeWords.fmothereta = mother.GetEta(); - treeWords.fmotherphi = mother.GetPhi(); - treeWords.fID = mother.GetPdgCode(); - treeWords.fweight = mctrack.getWeight(); // get particle weight from generator - - // get multiplicity based weight: - int iwbin = fhwMultpT->FindBin(treeWords.fmotherpt); - treeWords.fwMultpT = fhwMultpT->GetBinContent(iwbin); // pT weight - treeWords.fwMultpT2 = fhwMultpT2->GetBinContent(iwbin); // pT weight - double min_mT = fhwMultmT->GetBinLowEdge(1); // consider as minimum valid mT value the edge of the weight histo. - if (treeWords.fmothermt > min_mT) { - iwbin = fhwMultmT->FindBin(treeWords.fmothermt); - treeWords.fwMultmT = fhwMultmT->GetBinContent(iwbin); // mT weight - treeWords.fwMultmT2 = fhwMultmT2->GetBinContent(iwbin); // mT weight - } else { - LOGP(error, "Generated particle with mT < Pion mass cannot be weighted"); - treeWords.fwMultmT = 0.; - treeWords.fwMultmT2 = 0.; - } - - // Which ALT weight to use?: - Double_t fwALT = treeWords.fwEffpT; // by default use pt efficiency weight - if (fConfigALTweight == 1) - fwALT = treeWords.fwMultmT; // mT multiplicity weight - if (fConfigALTweight == 11) - fwALT = treeWords.fwMultmT2; // mT multiplicity weight, higher mult - if (fConfigALTweight == 2) - fwALT = treeWords.fwMultpT; // pT multiplicity weight - if (fConfigALTweight == 22) - fwALT = treeWords.fwMultpT2; // pT multiplicity weight, higher mult - - // fill the tree - if (fConfigWriteTTree) { - tree->Fill(); - } + if (p1.Pt() < fConfigMinPt) + return false; + if (p1.Pt() > fConfigMaxPt) + return false; + if (fabs(p1.Eta()) > fConfigMaxEta) + return false; + return true; + } - // fill the histograms - if (treeWords.fdectyp < 4) { // why here <4 and before <5 ??? - for (Int_t jj = 0; jj < 3; jj++) { // fill the different hindex -> particles - if (hindex[jj] > -1) { - fmee_orig[hindex[jj]]->Fill(treeWords.feeorigm, treeWords.fweight); - if (fConfigALTweight == 1 || fConfigALTweight == 11) { - fmotherpT_orig[hindex[jj]]->Fill(treeWords.fmothermt, treeWords.fweight); - } else if (fConfigALTweight == 2 || fConfigALTweight == 22 || fConfigALTweight == 0) { - fmotherpT_orig[hindex[jj]]->Fill(treeWords.fmotherpt, treeWords.fweight); - } - fpteevsmee_orig[hindex[jj]]->Fill(treeWords.feeorigm, treeWords.feept, treeWords.fweight); - fphi_orig[hindex[jj]]->Fill(treeWords.feeorigphi, treeWords.fweight); - frap_orig[hindex[jj]]->Fill(treeWords.feeorigrap, treeWords.fweight); - fmee_orig_wALT[hindex[jj]]->Fill(treeWords.feeorigm, treeWords.fweight * fwALT); - fpteevsmee_orig_wALT[hindex[jj]]->Fill(treeWords.feeorigm, treeWords.feept, treeWords.fweight * fwALT); - if (fConfigALTweight == 1 || fConfigALTweight == 11) { - fmotherpT_orig_wALT[hindex[jj]]->Fill(treeWords.fmothermt, treeWords.fweight * fwALT); - } else if (fConfigALTweight == 2 || fConfigALTweight == 22 || fConfigALTweight == 0) { - fmotherpT_orig_wALT[hindex[jj]]->Fill(treeWords.fmotherpt, treeWords.fweight * fwALT); - } - if (treeWords.fpass) { - fmee[hindex[jj]]->Fill(treeWords.feem, treeWords.fweight); - fpteevsmee[hindex[jj]]->Fill(treeWords.feem, treeWords.feept, treeWords.fweight); - fphi[hindex[jj]]->Fill(treeWords.feephi, treeWords.fweight); - frap[hindex[jj]]->Fill(treeWords.feerap, treeWords.fweight); - registry.fill(HIST("DCAeevsmee"), treeWords.feem, treeWords.fpairDCA, treeWords.fweight); - registry.fill(HIST("DCAeevsptee"), treeWords.feept, treeWords.fpairDCA, treeWords.fweight); - fmee_wALT[hindex[jj]]->Fill(treeWords.feem, treeWords.fweight * fwALT); - fpteevsmee_wALT[hindex[jj]]->Fill(treeWords.feem, treeWords.feept, treeWords.fweight * fwALT); - } - } - } - } + bool isAcceptedPair(ROOT::Math::PtEtaPhiMVector p1, ROOT::Math::PtEtaPhiMVector p2) + { + if (!isAcceptedSingle(p1)) { + return false; + } + if (!isAcceptedSingle(p2)) { + return false; + } + ROOT::Math::PtEtaPhiMVector p12 = p1 + p2; + if (p12.Pt() < fConfigMinPtee) { + return false; + } + if (o2::aod::pwgem::dilepton::utils::pairutil::getOpeningAngle(p1.Px(), p1.Py(), p1.Pz(), p2.Px(), p2.Py(), p2.Pz()) < fConfigMinOpAng) { + return false; + } + if (fabs(p12.Rapidity()) > fConfigMaxRapee) { + return false; + } - if (fConfigDoVirtPh) { - // Virtual photon generation - //------------------------- - // We will generate one virtual photon per histogrammed pion - if (mother.GetPdgCode() == 111) { - // get mass and pt from histos and flat eta and phi - Double_t VPHpT = ffVPHpT->GetRandom(); - Double_t VPHmass = fhKW->GetRandom(); - Double_t VPHeta = -1. + gRandom->Rndm() * 2.; - Double_t VPHphi = 2.0 * TMath::ACos(-1.) * gRandom->Rndm(); - TLorentzVector beam; - beam.SetPtEtaPhiM(VPHpT, VPHeta, VPHphi, VPHmass); - Double_t decaymasses[2] = {(TDatabasePDG::Instance()->GetParticle(11))->Mass(), (TDatabasePDG::Instance()->GetParticle(11))->Mass()}; - TGenPhaseSpace VPHgen; - Bool_t SetDecay; - SetDecay = VPHgen.SetDecay(beam, 2, decaymasses); - if (SetDecay == 0) - LOGP(error, "Decay not permitted by kinematics"); - Double_t VPHweight = VPHgen.Generate(); - // get electrons from the decay - TLorentzVector *decay1, *decay2; - decay1 = VPHgen.GetDecay(0); - decay2 = VPHgen.GetDecay(1); - dau1.SetPxPyPzE(decay1->Px(), decay1->Py(), decay1->Pz(), decay1->E()); - dau2.SetPxPyPzE(decay2->Px(), decay2->Py(), decay2->Pz(), decay2->E()); - - // create dielectron before resolution effects: - ee = dau1 + dau2; - - // get index for histograms - hindex[0] = nInputParticles - 1; - hindex[1] = -1; - hindex[2] = -1; - - // Fill tree words before resolution/acceptance - treeWords.fd1origpt = dau1.Pt(); - treeWords.fd1origp = dau1.P(); - treeWords.fd1origeta = dau1.Eta(); - treeWords.fd1origphi = dau1.Phi(); - treeWords.fd2origpt = dau2.Pt(); - treeWords.fd2origp = dau2.P(); - treeWords.fd2origeta = dau2.Eta(); - treeWords.fd2origphi = dau2.Phi(); - treeWords.feeorigpt = ee.Pt(); - treeWords.feeorigp = ee.P(); - treeWords.feeorigm = ee.M(); - treeWords.feeorigeta = ee.Eta(); - treeWords.feeorigrap = ee.Rapidity(); - treeWords.feeorigphi = ee.Phi(); - treeWords.feeorigphiv = PhiV(dau1, dau2); - - // get the efficiency weight - Int_t effbin = fhwEffpT->FindBin(treeWords.fd1origpt); - treeWords.fwEffpT = fhwEffpT->GetBinContent(effbin); - effbin = fhwEffpT->FindBin(treeWords.fd2origpt); - treeWords.fwEffpT = treeWords.fwEffpT * fhwEffpT->GetBinContent(effbin); - - // Resolution and acceptance - //------------------------- - dau1 = applySmearingPxPyPzE(1, dau1); - dau2 = applySmearingPxPyPzE(-1, dau2); - treeWords.fpass = true; - if (dau1.Pt() < fConfigMinPt || dau2.Pt() < fConfigMinPt) - treeWords.fpass = false; // leg pT cut - if (dau1.Pt() > fConfigMaxPt || dau2.Pt() > fConfigMaxPt) - treeWords.fpass = false; // leg pT cut - if (dau1.Vect().Unit().Dot(dau2.Vect().Unit()) > TMath::Cos(fConfigMinOpAng)) - treeWords.fpass = false; // opening angle cut - if (TMath::Abs(dau1.Eta()) > fConfigMaxEta || TMath::Abs(dau2.Eta()) > fConfigMaxEta) - treeWords.fpass = false; - - treeWords.fpairDCA = 10000.; // ?? - - // Fill tree words after resolution/acceptance - ee = dau1 + dau2; - treeWords.fd1pt = dau1.Pt(); - treeWords.fd1p = dau1.P(); - treeWords.fd1eta = dau1.Eta(); - treeWords.fd1phi = dau1.Phi(); - treeWords.fd2pt = dau2.Pt(); - treeWords.fd2p = dau2.P(); - treeWords.fd2eta = dau2.Eta(); - treeWords.fd2phi = dau2.Phi(); - treeWords.feept = ee.Pt(); - treeWords.feemt = ee.Mt(); - treeWords.feep = ee.P(); - treeWords.feem = ee.M(); - treeWords.feeeta = ee.Eta(); - treeWords.feerap = ee.Rapidity(); - treeWords.feephi = ee.Phi(); - treeWords.feephiv = PhiV(dau1, dau2); - treeWords.fmotherpt = beam.Pt(); - treeWords.fmothermt = sqrt(pow(beam.M(), 2) + pow(beam.Pt(), 2)); - treeWords.fmotherp = beam.P(); - treeWords.fmotherm = beam.M(); - treeWords.fmothereta = beam.Eta(); - treeWords.fmotherphi = beam.Phi(); - treeWords.fID = 0; // set ID to Zero for VPH - treeWords.fweight = VPHweight; - // get multiplicity based weight: - treeWords.fwMultmT = 1; // no weight for photons so far - - // Fill the tree - if (fConfigWriteTTree) { // many parameters not set for photons: d1DCA,fd2DCA, fdectyp,fdau3pdg,fwMultpT,fwMultpT2,fwMultmT2 - tree->Fill(); - } - - // Fill the histograms - for (Int_t jj = 0; jj < 3; jj++) { // fill the different hindex -> particles - if (hindex[jj] > -1) { - fmee_orig[hindex[jj]]->Fill(treeWords.feeorigm, VPHweight); - fpteevsmee_orig[hindex[jj]]->Fill(treeWords.feeorigm, treeWords.feept, VPHweight); - fphi_orig[hindex[jj]]->Fill(treeWords.feeorigphi, VPHweight); - frap_orig[hindex[jj]]->Fill(treeWords.feeorigrap, VPHweight); - fmotherpT_orig[hindex[jj]]->Fill(treeWords.fmotherpt, treeWords.fweight); - if (treeWords.fpass) { - fmee[hindex[jj]]->Fill(treeWords.feem, VPHweight); - fpteevsmee[hindex[jj]]->Fill(treeWords.feem, treeWords.feept, VPHweight); - fphi[hindex[jj]]->Fill(treeWords.feephi, VPHweight); - frap[hindex[jj]]->Fill(treeWords.feerap, VPHweight); - } - } - } - - } // mother.pdgCode()==111 - } // fConfigDoVirtPh - - } // abs(pdgCode())==11 - - } // loop over mctracks - - // Clear buffers - eBuff.clear(); - echBuff.clear(); - eweightBuff.clear(); + float deta = p1.Eta() - p2.Eta(); + float dphi = p1.Phi() - p2.Phi(); + o2::math_utils::bringToPMPi(dphi); + if (fConfigApplyDEtaDPhi && std::pow(deta / fConfigMinDEta, 2) + std::pow(dphi / fConfigMinDPhi, 2) < 1.f) { + return false; } + return true; } - Double_t PhiV(PxPyPzEVector e1, PxPyPzEVector e2) + template + bool isAcceptedPair(T& p1, T& p2) { - Double_t outPhiV; - XYZVector p1 = e1.Vect(); - XYZVector p2 = e2.Vect(); - XYZVector p12 = p1 + p2; - XYZVector u = p12.Unit(); - XYZVector p1u = p1.Unit(); - XYZVector p2u = p2.Unit(); - XYZVector v = p1u.Cross(p2u); - XYZVector w = u.Cross(v); - XYZVector zu(0, 0, 1); - XYZVector wc = u.Cross(zu); - outPhiV = TMath::ACos(wc.Unit().Dot(w.Unit())); - return outPhiV; + ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(p2.ptSmeared(), p2.etaSmeared(), p2.phiSmeared(), o2::constants::physics::MassElectron); + return isAcceptedPair(v1, v2); } - PxPyPzEVector applySmearingPxPyPzE(int ch, PxPyPzEVector vec) + template + bool isAcceptedSingle(T& p1) { - PxPyPzEVector vecsmeared; - float ptsmeared, etasmeared, phismeared; - smearer.applySmearing(ch, vec.Pt(), vec.Eta(), vec.Phi(), ptsmeared, etasmeared, phismeared); - float sPx = ptsmeared * cos(phismeared); - float sPy = ptsmeared * sin(phismeared); - float sPz = ptsmeared * sinh(etasmeared); - float sP = ptsmeared * cosh(etasmeared); - float sE = sqrt(sP * sP + eMass * eMass); - - vecsmeared.SetPxPyPzE(sPx, sPy, sPz, sE); - - return vecsmeared; + ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); + return isAcceptedSingle(v1); } - void SetHistograms() + void addHistogram1D_stage(TString histname, AxisSpec axis, int& i, TString s) { - - AxisSpec ptAxis = {fConfigNBinsPtee, fConfigMinPtee, fConfigMaxPtee, "#it{p}_{T,ee} (GeV/c)"}; - AxisSpec mAxis = {fConfigNBinsMee, fConfigMinMee, fConfigMaxMee, "#it{m}_{ee} (GeV/c^{2})"}; - AxisSpec phiAxis = {fConfigNBinsPhi, -TMath::TwoPi() / 2, TMath::TwoPi() / 2, "#it{phi}_{ee}"}; - AxisSpec rapAxis = {fConfigNBinsRap, -fConfigMaxAbsRap, fConfigMaxAbsRap, "#it{y}_{ee}"}; - - registry.add("NEvents", "NEvents", HistType::kTH1F, {{1, 0, 1}}, false); - - if (fConfigDoPairing) { - registry.add("ULS", "ULS", HistType::kTH2F, {mAxis, ptAxis}, true); - registry.add("LSpp", "LSpp", HistType::kTH2F, {mAxis, ptAxis}, true); - registry.add("LSmm", "LSmm", HistType::kTH2F, {mAxis, ptAxis}, true); - - registry.add("ULS_orig", "ULS_orig", HistType::kTH2F, {mAxis, ptAxis}, true); - registry.add("LSpp_orig", "LSpp_orig", HistType::kTH2F, {mAxis, ptAxis}, true); - registry.add("LSmm_orig", "LSmm_orig", HistType::kTH2F, {mAxis, ptAxis}, true); + i++; + TString name = s + histname; + histogramId[name] = i; + histograms1D.push_back(registry.add(name, histname, HistType::kTH1F, {axis}, true)); + for (auto const& [pdg, meson] : mesons) { + i++; + name = s + meson.name + histname; + histogramId[name] = i; + histograms1D.push_back(registry.add(name, histname, HistType::kTH1F, {axis}, true)); + for (auto const& mode : meson.decayModes) { + i++; + name = s + meson.name + decays[mode] + histname; + histogramId[name] = i; + histograms1D.push_back(registry.add(name, histname, HistType::kTH1F, {axis}, true)); + } } + } - registry.add("DCAeevsmee", "DCAeevsmee", HistType::kTH2F, {{fConfigMBins, "#it{m}_{ee} (GeV/c^{2})"}, {fConfigDCABins, "DCA_{xy}^{ee} (cm)"}}, true); - registry.add("DCAeevsptee", "DCAeevsptee", HistType::kTH2F, {{fConfigPtBins, "#it{p}_{T,ee} (GeV/c)"}, {fConfigDCABins, "DCA_{xy}^{ee} (cm)"}}, true); - - for (auto& particle : fParticleListNames) { - fmee.push_back(registry.add(Form("mee_%s", particle.Data()), Form("mee_%s", particle.Data()), HistType::kTH1F, {mAxis}, true)); - fmee_orig.push_back(registry.add(Form("mee_orig_%s", particle.Data()), Form("mee_orig_%s", particle.Data()), HistType::kTH1F, {mAxis}, true)); - fmotherpT_orig.push_back(registry.add(Form("motherpT_orig_%s", particle.Data()), Form("motherpT_orig_%s", particle.Data()), HistType::kTH1F, {ptAxis}, true)); - fphi.push_back(registry.add(Form("phi_%s", particle.Data()), Form("phi_%s", particle.Data()), HistType::kTH1F, {phiAxis}, true)); - fphi_orig.push_back(registry.add(Form("phi_orig_%s", particle.Data()), Form("phi_orig_%s", particle.Data()), HistType::kTH1F, {phiAxis}, true)); - frap.push_back(registry.add(Form("rap_%s", particle.Data()), Form("rap_%s", particle.Data()), HistType::kTH1F, {rapAxis}, true)); - frap_orig.push_back(registry.add(Form("rap_orig_%s", particle.Data()), Form("rap_orig_%s", particle.Data()), HistType::kTH1F, {rapAxis}, true)); - fpteevsmee.push_back(registry.add(Form("pteevsmee_%s", particle.Data()), Form("pteevsmee_%s", particle.Data()), HistType::kTH2F, {mAxis, ptAxis}, true)); - fpteevsmee_orig.push_back(registry.add(Form("pteevsmee_orig_%s", particle.Data()), Form("pteevsmee_orig_%s", particle.Data()), HistType::kTH2F, {mAxis, ptAxis}, true)); - fmee_wALT.push_back(registry.add(Form("mee_wALT_%s", particle.Data()), Form("mee_wALT_%s", particle.Data()), HistType::kTH1F, {mAxis}, true)); - fmee_orig_wALT.push_back(registry.add(Form("mee_orig_wALT_%s", particle.Data()), Form("mee_orig_wALT_%s", particle.Data()), HistType::kTH1F, {mAxis}, true)); - fmotherpT_orig_wALT.push_back(registry.add(Form("motherpT_orig_wALT_%s", particle.Data()), Form("motherpT_orig_wALT%s", particle.Data()), HistType::kTH1F, {ptAxis}, true)); - fpteevsmee_wALT.push_back(registry.add(Form("pteevsmee_wALT%s", particle.Data()), Form("pteevsmee_wALT_%s", particle.Data()), HistType::kTH2F, {mAxis, ptAxis}, true)); - fpteevsmee_orig_wALT.push_back(registry.add(Form("pteevsmee_orig_wALT%s", particle.Data()), Form("pteevsmee_orig_wALT_%s", particle.Data()), HistType::kTH2F, {mAxis, ptAxis}, true)); + void addHistogram1D(TString histname, AxisSpec axis, int& i) + { + for (auto s : stage) { + addHistogram1D_stage(histname, axis, i, s); } - - fmee.push_back(registry.add("mee", "mee", HistType::kTH1F, {mAxis}, true)); - fmee_orig.push_back(registry.add("mee_orig", "mee_orig", HistType::kTH1F, {mAxis}, true)); - fmotherpT_orig.push_back(registry.add("motherpT_orig", "motherpT_orig", HistType::kTH1F, {ptAxis}, true)); - fphi.push_back(registry.add("phi", "phi", HistType::kTH1F, {phiAxis}, true)); - fphi_orig.push_back(registry.add("phi_orig", "phi_orig", HistType::kTH1F, {phiAxis}, true)); - frap.push_back(registry.add("rap", "rap", HistType::kTH1F, {rapAxis}, true)); - frap_orig.push_back(registry.add("rap_orig", "rap_orig", HistType::kTH1F, {rapAxis}, true)); - fpteevsmee.push_back(registry.add("pteevsmee", "pteevsmee", HistType::kTH2F, {mAxis, ptAxis}, true)); - fpteevsmee_orig.push_back(registry.add("pteevsmee_orig", "pteevsmee_orig", HistType::kTH2F, {mAxis, ptAxis}, true)); - fmee_wALT.push_back(registry.add("mee_wALT", "mee_wALT", HistType::kTH1F, {mAxis}, true)); - fmee_orig_wALT.push_back(registry.add("mee_orig_wALT", "mee_orig_wALT", HistType::kTH1F, {mAxis}, true)); - fmotherpT_orig_wALT.push_back(registry.add("motherpT_orig_wALT", "motherpT_orig_wALT", HistType::kTH1F, {ptAxis}, true)); - fpteevsmee_wALT.push_back(registry.add("pteevsmee_wALT", "pteevsmee_wALT", HistType::kTH2F, {mAxis, ptAxis}, true)); - fpteevsmee_orig_wALT.push_back(registry.add("pteevsmee_orig_wALT", "pteevsmee_orig_wALT", HistType::kTH2F, {mAxis, ptAxis}, true)); } - void SetTree() + void addHistogram1D_mother(TString histname, AxisSpec axis, int& i) // mother histograms only for gen. level, no decay channels { - tree.setObject(new TTree("eeTTree", "eeTTree")); - - tree->Branch("fd1DCA", &treeWords.fd1DCA, "fd1DCA/F"); - tree->Branch("fd2DCA", &treeWords.fd2DCA, "fd2DCA/F"); - tree->Branch("fpairDCA", &treeWords.fpairDCA, "fpairDCA/F"); - tree->Branch("fd1origpt", &treeWords.fd1origpt, "fd1origpt/F"); - tree->Branch("fd1origp", &treeWords.fd1origp, "fd1origp/F"); - tree->Branch("fd1origeta", &treeWords.fd1origeta, "fd1origeta/F"); - tree->Branch("fd1origphi", &treeWords.fd1origphi, "fd1origphi/F"); - tree->Branch("fd2origpt", &treeWords.fd2origpt, "fd2origpt/F"); - tree->Branch("fd2origp", &treeWords.fd2origp, "fd2origp/F"); - tree->Branch("fd2origeta", &treeWords.fd2origeta, "fd2origeta/F"); - tree->Branch("fd2origphi", &treeWords.fd2origphi, "fd2origphi/F"); - tree->Branch("fd1pt", &treeWords.fd1pt, "fd1pt/F"); - tree->Branch("fd1p", &treeWords.fd1p, "fd1p/F"); - tree->Branch("fd1eta", &treeWords.fd1eta, "fd1eta/F"); - tree->Branch("fd1phi", &treeWords.fd1phi, "fd1phi/F"); - tree->Branch("fd2pt", &treeWords.fd2pt, "fd2pt/F"); - tree->Branch("fd2p", &treeWords.fd2p, "fd2p/F"); - tree->Branch("fd2eta", &treeWords.fd2eta, "fd2eta/F"); - tree->Branch("fd2phi", &treeWords.fd2phi, "fd2phi/F"); - tree->Branch("feeorigpt", &treeWords.feeorigpt, "feeorigpt/F"); - tree->Branch("feeorigp", &treeWords.feeorigp, "feeorigp/F"); - tree->Branch("feeorigm", &treeWords.feeorigm, "feeorigm/F"); - tree->Branch("feeorigeta", &treeWords.feeorigeta, "feeorigeta/F"); - tree->Branch("feeorigphi", &treeWords.feeorigphi, "feeorigphi/F"); - tree->Branch("feeorigphiv", &treeWords.feeorigphiv, "feeorigphiv/F"); - tree->Branch("feept", &treeWords.feept, "feept/F"); - tree->Branch("feemt", &treeWords.feemt, "feemt/F"); - tree->Branch("feep", &treeWords.feep, "feep/F"); - tree->Branch("feem", &treeWords.feem, "feem/F"); - tree->Branch("feeeta", &treeWords.feeeta, "feeeta/F"); - tree->Branch("feephi", &treeWords.feephi, "feephi/F"); - tree->Branch("feephiv", &treeWords.feephiv, "feephiv/F"); - tree->Branch("fmotherpt", &treeWords.fmotherpt, "fmotherpt/F"); - tree->Branch("fmothermt", &treeWords.fmothermt, "fmothermt/F"); - tree->Branch("fmotherp", &treeWords.fmotherp, "fmotherp/F"); - tree->Branch("fmotherm", &treeWords.fmotherm, "fmotherm/F"); - tree->Branch("fmothereta", &treeWords.fmothereta, "fmothereta/F"); - tree->Branch("fmotherphi", &treeWords.fmotherphi, "fmotherphi/F"); - tree->Branch("fID", &treeWords.fID, "fID/I"); - tree->Branch("fdectyp", &treeWords.fdectyp, "fdectyp/I"); - tree->Branch("fdau3pdg", &treeWords.fdau3pdg, "fdau3pdg/I"); - tree->Branch("fweight", &treeWords.fweight, "fweight/F"); - tree->Branch("fwEffpT", &treeWords.fwEffpT, "fwEffpT/F"); - tree->Branch("fwMultpT", &treeWords.fwMultpT, "fwMultpT/F"); - tree->Branch("fwMultmT", &treeWords.fwMultmT, "fwMultmT/F"); - tree->Branch("fwMultpT2", &treeWords.fwMultpT2, "fwMultpT2/F"); - tree->Branch("fwMultmT2", &treeWords.fwMultmT2, "fwMultmT2/F"); - tree->Branch("fpass", &treeWords.fpass, "fpass/B"); + i++; + TString name = stage[0] + histname; + histogramId[name] = i; + histograms1D.push_back(registry.add(name, histname, HistType::kTH1F, {axis}, true)); + for (auto const& [pdg, meson] : mesons) { + i++; + name = stage[0] + meson.name + histname; + histogramId[name] = i; + histograms1D.push_back(registry.add(name, histname, HistType::kTH1F, {axis}, true)); + } } - void GetEffHisto(TString filename, TString histname) + void addHistogram2D_stage(TString histname, AxisSpec axis1, AxisSpec axis2, int& i, TString s) { - // get efficiency histo - LOGP(info, "Set Efficiency histo"); - // Get Efficiency weight file: - TFile* fFile = TFile::Open(filename.Data()); - if (!fFile) { - LOGP(error, "Could not open Efficiency file {}", filename.Data()); - return; - } - if (fFile->GetListOfKeys()->Contains(histname.Data())) { - fhwEffpT = reinterpret_cast(fFile->Get(histname.Data())); // histo: eff weight in function of pT. - fhwEffpT->SetDirectory(nullptr); - } else { - LOGP(error, "Could not open histogram {} from file {}", histname.Data(), filename.Data()); + i++; + TString name = s + histname; + histogramId[name] = i; + histograms2D.push_back(registry.add(name, histname, HistType::kTH2F, {axis1, axis2}, true)); + for (auto const& [pdg, meson] : mesons) { + i++; + name = s + meson.name + histname; + histogramId[name] = i; + histograms2D.push_back(registry.add(name, histname, HistType::kTH2F, {axis1, axis2}, true)); + for (auto const& mode : meson.decayModes) { + i++; + name = s + meson.name + decays[mode] + histname; + histogramId[name] = i; + histograms2D.push_back(registry.add(name, histname, HistType::kTH2F, {axis1, axis2}, true)); + } } - - fFile->Close(); } - void InitSmearer(TString filename, TString ptHistName, TString etaHistName, TString phiPosHistName, TString phiNegHistName) + void addHistogram2D(TString histname, AxisSpec axis1, AxisSpec axis2, int& i) { - smearer.setResFileName(filename); - smearer.setResPtHistName(ptHistName); - smearer.setResEtaHistName(etaHistName); - smearer.setResPhiPosHistName(phiPosHistName); - smearer.setResPhiNegHistName(phiNegHistName); - smearer.init(); + for (auto s : stage) { + addHistogram2D_stage(histname, axis1, axis2, i, s); + } } - void GetDCATemplates(TString filename, TString histname) + template + void addHistogramND_stage(TString histname, TAxes const& axes, int& i, TString s) { - // get dca tamplates - LOGP(info, "Set DCA templates"); - // Get file: - TFile* fFile = TFile::Open(filename.Data()); - if (!fFile) { - LOGP(error, "Could not open DCATemplate file {}", filename.Data()); - return; - } - fh_DCAtemplates = new TH1F*[nbDCAtemplate]; - for (int jj = 0; jj < nbDCAtemplate; jj++) { - if (fFile->GetListOfKeys()->Contains(Form("%s%d", histname.Data(), jj + 1))) { - fh_DCAtemplates[jj] = reinterpret_cast(fFile->Get(Form("%s%d", histname.Data(), jj + 1))); - } else { - LOGP(error, "Could not open {}{} from file {}", histname.Data(), jj + 1, filename.Data()); + i++; + TString name = s + histname; + histogramId[name] = i; + histogramsND.push_back(registry.add(name, histname, HistType::kTHnSparseF, axes, true)); + for (auto const& [pdg, meson] : mesons) { + i++; + name = s + meson.name + histname; + histogramId[name] = i; + histogramsND.push_back(registry.add(name, histname, HistType::kTHnSparseF, axes, true)); + for (auto const& mode : meson.decayModes) { + i++; + name = s + meson.name + decays[mode] + histname; + histogramId[name] = i; + histogramsND.push_back(registry.add(name, histname, HistType::kTHnSparseF, axes, true)); } } - fFile->Close(); } - void GetMultHisto(TString filename, TString histnamept, TString histnamept2, TString histnamemt, TString histnamemt2) + template + void addHistogramND(TString histname, TAxes const& axes, int& i) { - // get multiplicity weights - LOGP(info, "Set Multiplicity weight files"); - TFile* fFile = TFile::Open(filename.Data()); - if (!fFile) { - LOGP(error, "Could not open Multiplicity weight file {}", filename.Data()); - return; + for (auto s : stage) { + addHistogramND_stage(histname, axes, i, s); } + } - if (fFile->GetListOfKeys()->Contains(histnamept.Data())) { - fhwMultpT = reinterpret_cast(fFile->Get(histnamept.Data())); // histo: multiplicity weight in function of pT. - } else { - LOGP(error, "Could not open {} from file {}", histnamept.Data(), filename.Data()); - } + void fillHistogram1D(TString histname, int s, int pdg, int other_daughter_pdg, float value, float weight) + { + histograms1D[histogramId[stage[s] + histname]]->Fill(value, weight); + histograms1D[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(value, weight); + histograms1D[histogramId[stage[s] + mesons[pdg].name + decays[other_daughter_pdg] + histname]]->Fill(value, weight); + } - if (fFile->GetListOfKeys()->Contains(histnamemt.Data())) { - fhwMultmT = reinterpret_cast(fFile->Get(histnamemt.Data())); // histo: multiplicity weight in function of mT. - } else { - LOGP(error, "Could not open {} from file {}", histnamemt.Data(), filename.Data()); - } + void fillHistogram1D_mother(TString histname, int pdg, float value, float weight) + { + histograms1D[histogramId[stage[0] + histname]]->Fill(value, weight); + histograms1D[histogramId[stage[0] + mesons[pdg].name + histname]]->Fill(value, weight); + } - if (fFile->GetListOfKeys()->Contains(histnamept2.Data())) { - fhwMultpT2 = reinterpret_cast(fFile->Get(histnamept2.Data())); // histo: multiplicity weight in function of pT. - } else { - LOGP(error, "Could not open {} from file {}", histnamept2.Data(), filename.Data()); - } + void fillHistogram2D(TString histname, int s, int pdg, int other_daughter_pdg, float value1, float value2, float weight) + { + histograms2D[histogramId[stage[s] + histname]]->Fill(value1, value2, weight); + histograms2D[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(value1, value2, weight); + histograms2D[histogramId[stage[s] + mesons[pdg].name + decays[other_daughter_pdg] + histname]]->Fill(value1, value2, weight); + } + + void fillHistogramND(TString histname, int s, int pdg, int other_daughter_pdg, double* values, double weight) + { + histogramsND[histogramId[stage[s] + histname]]->Fill(values, weight); + histogramsND[histogramId[stage[s] + mesons[pdg].name + histname]]->Fill(values, weight); + histogramsND[histogramId[stage[s] + mesons[pdg].name + decays[other_daughter_pdg] + histname]]->Fill(values, weight); + } - if (fFile->GetListOfKeys()->Contains(histnamemt2.Data())) { - fhwMultmT2 = reinterpret_cast(fFile->Get(histnamemt2)); // histo: multiplicity weight in function of mT. - } else { - LOGP(error, "Could not open {} from file {}", histnamemt2.Data(), filename.Data()); + void init(InitContext& context) + { + registry.add("NEvents", "NEvents", HistType::kTH1F, {{1, 0., 1.}}, false); + + AxisSpec mass_axis = {fConfigMeeBins, "m_{ee} (GeV/#it{c}^{2})"}; + AxisSpec ptee_axis = {fConfigPteeBins, "#it{p}_{T,ee} (GeV/#it{c})"}; + AxisSpec cos2dphi_axis = {fConfigCos2DPhi, "cos(2(#varphi_{ee} - #Psi_{RP}))"}; // PsiRP = 0 rad. in generator. + AxisSpec eta_axis = {fConfigEtaBins, "#it{#eta}_{e}"}; + AxisSpec pt_axis = {fConfigPtBins, "#it{p}_{T,e} (GeV/c)"}; + AxisSpec phi_axis = {fConfigPhiBins, "#it{#varphi}_{e}"}; + AxisSpec phiV_axis = {fConfigPhiVBins, "#it{#varphi}_{V,ee}"}; + AxisSpec opAng_axis = {fConfigOpAngBins, "#it{#omega}_{ee}"}; + AxisSpec eta_axis_mother = {fConfigEtaBins, "#it{#eta}_{mother}"}; + AxisSpec pt_axis_mother = {fConfigPtBins, "#it{p}_{T,mother} (GeV/#it{c})"}; + AxisSpec phi_axis_mother = {fConfigPhiBins, "#it{#varphi}_{mother}"}; + AxisSpec dca_axis = {fConfigDcaBins, "DCA_{e}"}; + AxisSpec dcaee_axis = {fConfigDcaBins, "DCA_{ee}"}; + + if (context.mOptions.get("processPairing")) { + registry.add("gen/ULS", "ULS gen.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + registry.add("gen/LSpp", "LS++ gen.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + registry.add("gen/LSmm", "LS-- gen.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + registry.add("rec/ULS", "ULS rec.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + registry.add("rec/LSpp", "LS++ rec.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + registry.add("rec/LSmm", "LS-- rec.", HistType::kTH2F, {mass_axis, ptee_axis}, true); + } + if (context.mOptions.get("processCocktail")) { + int i = -1; + addHistogram1D("Pt", pt_axis, i); + addHistogram1D("Eta", eta_axis, i); + addHistogram1D("Phi", phi_axis, i); + addHistogram1D_mother("Mother_Pt", pt_axis_mother, i); + addHistogram1D_mother("Mother_Eta", eta_axis_mother, i); + addHistogram1D_mother("Mother_Phi", phi_axis_mother, i); + addHistogram1D("PhiV", phiV_axis, i); + addHistogram1D("OpAng", opAng_axis, i); + addHistogram1D("Mee", mass_axis, i); + addHistogram1D("Ptee", ptee_axis, i); + addHistogram1D_stage("Dca", dca_axis, i, "rec/"); + addHistogram1D_stage("Dcaee", dcaee_axis, i, "rec/"); + i = -1; + addHistogram2D_stage("DcaVsPt", dca_axis, pt_axis, i, "rec/"); + addHistogram2D_stage("DcaeeVsPtee", dcaee_axis, ptee_axis, i, "rec/"); + addHistogram2D_stage("DcaeeVsMee", dcaee_axis, mass_axis, i, "rec/"); + i = -1; + addHistogramND("MeeVsPteeVsCos2DPhiRP", std::vector{mass_axis, ptee_axis, cos2dphi_axis}, i); } - fFile->Close(); } - void GetPhotonPtParametrization(TString filename, TString dirname, TString funcname) + void processCocktail(aod::McCollision const&, McParticlesSmeared const& mcParticles) { - LOGP(info, "Set photon parametrization"); + registry.fill(HIST("NEvents"), 0.5); - if (filename.EndsWith(".root")) { // read from ROOT file - TFile* fFile = TFile::Open(filename.Data()); - if (!fFile) { - LOGP(error, "Could not open photon parametrization from file {}", filename.Data()); - return; + for (auto const& particle : mcParticles) { + if (particle.has_mothers()) { + continue; + } + int pdg = abs(particle.pdgCode()); + if (mesons.find(pdg) == mesons.end()) { + LOG(error) << "Found mother particle with pdg = " << pdg << " that is not in list of mesons"; + } + if (!particle.has_daughters()) { + LOG(error) << "Found meson with pdg = " << pdg << "that has no daughters"; } - bool good = false; - if (fFile->GetListOfKeys()->Contains(dirname.Data())) { - TDirectory* dir = fFile->GetDirectory(dirname.Data()); - if (dir->GetListOfKeys()->Contains(funcname.Data())) { - ffVPHpT = reinterpret_cast(dir->Get(funcname.Data())); - ffVPHpT->SetNpx(10000); - good = true; + + int other_daughter_pdg = -1; + int nEle = 0; + int nPos = 0; + + ROOT::Math::PtEtaPhiMVector pEleGen, pPosGen, pEleRec, pPosRec; + float weight(1.), effEle(1.), effPos(1.), dcaEle(0.), dcaPos(0.); + for (const auto& daughter : particle.daughters_as()) { + int temp_pdg = daughter.pdgCode(); + if (temp_pdg == 11) { + ROOT::Math::PtEtaPhiMVector temp_p_gen(daughter.pt(), daughter.eta(), daughter.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector temp_p(daughter.ptSmeared(), daughter.etaSmeared(), daughter.phiSmeared(), o2::constants::physics::MassElectron); + pEleGen = temp_p_gen; + pEleRec = temp_p; + weight = daughter.weight(); + effEle = daughter.efficiency(); + dcaEle = daughter.dca(); + nEle++; + continue; + } + if (temp_pdg == -11) { + ROOT::Math::PtEtaPhiMVector temp_p_gen(daughter.pt(), daughter.eta(), daughter.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector temp_p(daughter.ptSmeared(), daughter.etaSmeared(), daughter.phiSmeared(), o2::constants::physics::MassElectron); + pPosGen = temp_p_gen; + pPosRec = temp_p; + effPos = daughter.efficiency(); + dcaPos = daughter.dca(); + nPos++; + continue; } + other_daughter_pdg = abs(other_daughter_pdg * temp_pdg); + } + if (!(((nEle == 1) && (nPos == 1)) || ((nEle == 2) && (nPos == 2)))) { + LOG(error) << "Found decay with wrong number of electrons in decay of meson with pdg " << pdg << ": nElectrons = " << nEle << ", nPositrons = " << nPos; + continue; } - if (!good) { - LOGP(error, "Could not open photon parametrization {}/{} from file {}", dirname.Data(), funcname.Data(), filename.Data()); + if ((nEle == 2) && (nPos == 2) && (other_daughter_pdg == -1)) { + other_daughter_pdg = -2; + weight = 2 * weight; } - fFile->Close(); - } else if (filename.EndsWith(".json")) { // read from JSON file - std::ifstream fFile(filename.Data()); - if (!fFile) { - LOGP(error, "Could not open photon parametrization from file {}", filename.Data()); - return; + auto this_meson_decays = mesons[pdg].decayModes; + if (std::find(this_meson_decays.begin(), this_meson_decays.end(), other_daughter_pdg) == this_meson_decays.end()) { + LOG(error) << "Found decay with code = " << other_daughter_pdg << " that is not in list of decays of meson with pdg " << pdg; + continue; } - nlohmann::json paramfile = nlohmann::json::parse(fFile); - if (paramfile.contains(dirname.Data())) { - nlohmann::json dir = paramfile[dirname.Data()]; - if (dir.contains(funcname.Data())) { - std::string formula = dir[funcname.Data()]; - ffVPHpT = new TF1(TString(funcname.Data()), TString(formula), 0, 100); - if (ffVPHpT) { - ffVPHpT->SetNpx(10000); - return; + + for (int s = 0; s < kNRecLevels; s++) { // s=0: gen, s=1: rec + + ROOT::Math::PtEtaPhiMVector pEle, pPos; + float pairWeight(1.), weightEle(1.), weightPos(1.); + bool acceptedEle(true), acceptedPos(true), acceptedPair(true); + + if (s == kGen) { + pEle = pEleGen; + pPos = pPosGen; + pairWeight = weight; + weightEle = weight; + weightPos = weight; + acceptedEle = true; + acceptedPos = true; + acceptedPair = true; + } else if (s == kRec) { + pEle = pEleRec; + pPos = pPosRec; + pairWeight = weight * effEle * effPos; + weightEle = weight * effEle; + weightPos = weight * effPos; + acceptedEle = isAcceptedSingle(pEle); + acceptedPos = isAcceptedSingle(pPos); + acceptedPair = isAcceptedPair(pEle, pPos); + } + + // single track histograms + if (acceptedEle) + fillHistogram1D("Pt", s, pdg, other_daughter_pdg, pEle.Pt(), weightEle); + if (acceptedPos) + fillHistogram1D("Pt", s, pdg, other_daughter_pdg, pPos.Pt(), weightPos); + + if (acceptedEle) + fillHistogram1D("Eta", s, pdg, other_daughter_pdg, pEle.Eta(), weightEle); + if (acceptedPos) + fillHistogram1D("Eta", s, pdg, other_daughter_pdg, pPos.Eta(), weightPos); + + if (acceptedEle) + fillHistogram1D("Phi", s, pdg, other_daughter_pdg, pEle.Phi(), weightEle); + if (acceptedPos) + fillHistogram1D("Phi", s, pdg, other_daughter_pdg, pPos.Phi(), weightPos); + + if (s == kRec) { // dca only at rec. level + if (acceptedEle) { + fillHistogram1D("Dca", s, pdg, other_daughter_pdg, dcaEle, weightEle); + fillHistogram2D("DcaVsPt", s, pdg, other_daughter_pdg, dcaEle, pEle.Pt(), weightEle); + } + if (acceptedPos) { + fillHistogram1D("Dca", s, pdg, other_daughter_pdg, dcaPos, weightPos); + fillHistogram2D("DcaVsPt", s, pdg, other_daughter_pdg, dcaPos, pPos.Pt(), weightPos); + } + } + + // mother histograms + if (s == kGen) { // only at gen. level + fillHistogram1D_mother("Mother_Pt", pdg, particle.pt(), weight); + fillHistogram1D_mother("Mother_Eta", pdg, particle.eta(), weight); + fillHistogram1D_mother("Mother_Phi", pdg, particle.phi(), weight); + } + + // pair historams + if (acceptedPair) { + ROOT::Math::PtEtaPhiMVector p12 = pEle + pPos; + float mee = p12.M(); + float ptee = p12.Pt(); + float opAng = o2::aod::pwgem::dilepton::utils::pairutil::getOpeningAngle(pPos.Px(), pPos.Py(), pPos.Pz(), pEle.Px(), pEle.Py(), pEle.Pz()); + float phiV = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(pPos.Px(), pPos.Py(), pPos.Pz(), pEle.Px(), pEle.Py(), pEle.Pz(), 1, -1, 1); + float dcaee = sqrt((pow(dcaEle, 2) + pow(dcaPos, 2)) / 2); + float cos2dphi = std::cos(2.f * p12.Phi()); // PsiRP = 0 rad. + double values[3] = {mee, ptee, cos2dphi}; + fillHistogramND("MeeVsPteeVsCos2DPhiRP", s, pdg, other_daughter_pdg, values, pairWeight); + fillHistogram1D("Mee", s, pdg, other_daughter_pdg, mee, pairWeight); + fillHistogram1D("Ptee", s, pdg, other_daughter_pdg, ptee, pairWeight); + fillHistogram1D("PhiV", s, pdg, other_daughter_pdg, phiV, pairWeight); + fillHistogram1D("OpAng", s, pdg, other_daughter_pdg, opAng, pairWeight); + if (s == kRec) { // dca only at rec. level + fillHistogram1D("Dcaee", s, pdg, other_daughter_pdg, dcaee, pairWeight); + fillHistogram2D("DcaeeVsPtee", s, pdg, other_daughter_pdg, dcaee, ptee, pairWeight); + fillHistogram2D("DcaeeVsMee", s, pdg, other_daughter_pdg, dcaee, mee, pairWeight); } } } - LOGP(error, "Could not open photon parametrization {}/{} from file {}", dirname.Data(), funcname.Data(), filename.Data()); - return; - } else { // neither ROOT nor JSON - LOGP(error, "Not compatible file format for {}", filename.Data()); - } + + } // end particle loop } + PROCESS_SWITCH(lmeelfcocktail, processCocktail, "Process cocktail", true); + + // ULS and LS spectra + Preslice perCollision = aod::mcparticle::mcCollisionId; + Partition Electrons = (aod::mcparticle::pdgCode == 11); + Partition Positrons = (aod::mcparticle::pdgCode == -11); - void fillKrollWada() + void processPairing(aod::McCollisions const& mcCollisions, McParticlesSmeared const& mcParticles) { - // Build Kroll-wada for virtual photon mass parametrization: - Double_t KWmass = 0.; - Int_t KWnbins = 10000; - Float_t KWmin = 2. * eMass; - Double_t KWbinwidth = (fConfigKWMax - KWmin) / (Double_t)KWnbins; - fhKW = new TH1F("fhKW", "fhKW", KWnbins, KWmin, fConfigKWMax); - for (Int_t ibin = 1; ibin <= KWnbins; ibin++) { - KWmass = KWmin + (Double_t)(ibin - 1) * KWbinwidth + KWbinwidth / 2.0; - fhKW->AddBinContent(ibin, 2. * (1. / 137.03599911) / 3. / 3.14159265359 / KWmass * sqrt(1. - 4. * eMass * eMass / KWmass / KWmass) * (1. + 2. * eMass * eMass / KWmass / KWmass)); + + for (auto const& mcCollision : mcCollisions) { + auto const electronsGrouped = Electrons->sliceBy(perCollision, mcCollision.globalIndex()); + auto const positronsGrouped = Positrons->sliceBy(perCollision, mcCollision.globalIndex()); + + // ULS spectrum + for (auto const& [p1, p2] : combinations(o2::soa::CombinationsFullIndexPolicy(electronsGrouped, positronsGrouped))) { + if (!(from_primary(p1, mcParticles) && from_primary(p2, mcParticles))) { + continue; + } + ROOT::Math::PtEtaPhiMVector v1_gen(p1.pt(), p1.eta(), p1.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2_gen(p2.pt(), p2.eta(), p2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12_gen = v1_gen + v2_gen; + registry.fill(HIST("gen/ULS"), v12_gen.M(), v12_gen.Pt(), p1.weight() * p2.weight()); + if (isAcceptedPair(p1, p2)) { + ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(p2.ptSmeared(), p2.etaSmeared(), p2.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + registry.fill(HIST("rec/ULS"), v12.M(), v12.Pt(), p1.weight() * p2.weight() * p1.efficiency() * p2.efficiency()); + } + } + // LS spectra + for (auto& [p1, p2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(electronsGrouped, electronsGrouped))) { + if (!(from_primary(p1, mcParticles) && from_primary(p2, mcParticles))) { + continue; + } + ROOT::Math::PtEtaPhiMVector v1_gen(p1.pt(), p1.eta(), p1.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2_gen(p2.pt(), p2.eta(), p2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12_gen = v1_gen + v2_gen; + registry.fill(HIST("gen/LSmm"), v12_gen.M(), v12_gen.Pt(), p1.weight() * p2.weight()); + if (isAcceptedPair(p1, p2)) { + ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(p2.ptSmeared(), p2.etaSmeared(), p2.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + registry.fill(HIST("rec/LSmm"), v12.M(), v12.Pt(), p1.weight() * p2.weight() * p1.efficiency() * p2.efficiency()); + } + } + for (auto& [p1, p2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(positronsGrouped, positronsGrouped))) { + if (!(from_primary(p1, mcParticles) && from_primary(p2, mcParticles))) { + continue; + } + ROOT::Math::PtEtaPhiMVector v1_gen(p1.pt(), p1.eta(), p1.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2_gen(p2.pt(), p2.eta(), p2.phi(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12_gen = v1_gen + v2_gen; + registry.fill(HIST("gen/LSpp"), v12_gen.M(), v12_gen.Pt(), p1.weight() * p2.weight()); + if (isAcceptedPair(p1, p2)) { + ROOT::Math::PtEtaPhiMVector v1(p1.ptSmeared(), p1.etaSmeared(), p1.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v2(p2.ptSmeared(), p2.etaSmeared(), p2.phiSmeared(), o2::constants::physics::MassElectron); + ROOT::Math::PtEtaPhiMVector v12 = v1 + v2; + registry.fill(HIST("rec/LSpp"), v12.M(), v12.Pt(), p1.weight() * p2.weight() * p1.efficiency() * p2.efficiency()); + } + } } } + PROCESS_SWITCH(lmeelfcocktail, processPairing, "Process ULS and LS pairing", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - WorkflowSpec specs; - std::vector inputs; - inputs.emplace_back("mctracks", "MC", "MCTRACKS", 0., Lifetime::Timeframe); - DataProcessorSpec dSpec = adaptAnalysisTask(cfgc, TaskName{"em-lmee-lf-cocktail"}); - dSpec.inputs = inputs; - specs.emplace_back(dSpec); - return specs; + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName("em-lmee-lf-cocktail"))}; } diff --git a/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx b/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx new file mode 100644 index 00000000000..9d908c24de9 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/prefilterDielectron.cxx @@ -0,0 +1,524 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 dielectron. +// 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/Utils/EMTrack.h" +#include "PWGEM/Dilepton/Utils/EventHistograms.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.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::dilepton::utils::emtrackutil; +using namespace o2::aod::pwgem::dilepton::utils::pairutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; + +struct prefilterDielectron { + Produces pfb_pi0; + + // 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> cfgMaxMee{"cfgMaxMee", {0.01, 0.02, 0.04, 0.06, 0.08, 0.10}, "max mee steps for prefilter. Don't exceed 15 values!"}; + Configurable cfgCentEstimator{"cfgCentEstimator", 2, "FT0M:0, FT0A:1, FT0C:2"}; + Configurable cfgCentMin{"cfgCentMin", -1, "min. centrality"}; + Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; + Configurable cfgMaxMee{"cfgMaxMee", 0.01, "max mee for prefilter in GeV/c2"}; // only for ULS + Configurable cfgMaxMee_for_phiv_uls{"cfgMaxMee_for_phiv_uls", 0.65, "max mee at phiv = pi for ULS"}; // GeV/c2 + Configurable cfgMinPhiV_uls{"cfgMinPhiV_uls", 2.9, "min phiv for in ULS"}; // radian + Configurable cfgMaxMee_for_phiv_ls{"cfgMinMee_for_phiv", 0.25, "max mee at phiv = 0 and pi for LS"}; // GeV/c2 // symmetric + Configurable cfgMinPhiVv_ls{"cfgMinPhiVv_ls", 2.5, "min phiv for LS"}; // radian + + EMEventCut 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", true, "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; + + DielectronCut fDielectronCut; + struct : ConfigurableGroup { + std::string prefix = "dielectroncut_group"; + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.2, "min 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", 0.2, "max dca XY for single track in cm"}; + Configurable cfg_max_dcaz{"cfg_max_dcaz", 0.2, "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 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, 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_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 enableTTCA{"enableTTCA", true, "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; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + void init(InitContext& /*context*/) + { + DefineEMEventCut(); + DefineDielectronCut(); + addhistograms(); + + 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(); + } + + ~prefilterDielectron() {} + + void addhistograms() + { + const AxisSpec axis_mass{400, 0, 4, "m_{ee} (GeV/c^{2})"}; + const AxisSpec axis_pair_pt{100, 0, 10, "p_{T,ee} (GeV/c)"}; + const AxisSpec axis_phiv{90, 0, M_PI, "#varphi_{V} (rad.)"}; + + // for pair + 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", "d#eta-d#varphi between 2 tracks;#Delta#varphi (rad.);#Delta#eta;", kTH2D, {{180, -M_PI, M_PI}, {100, -0.5, +0.5}}, true); + fRegistry.addClone("Pair/before/uls/", "Pair/before/lspp/"); + fRegistry.addClone("Pair/before/uls/", "Pair/before/lsmm/"); + fRegistry.addClone("Pair/before/", "Pair/after/"); + } + + void DefineEMEventCut() + { + fEMEventCut = EMEventCut("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); + } + + o2::analysis::MlResponseDielectronSingleTrack mlResponseSingleTrack; + void DefineDielectronCut() + { + fDielectronCut = DielectronCut("fDielectronCut", "fDielectronCut"); + + // for pair + fDielectronCut.SetMeeRange(0, 1e+10); + fDielectronCut.SetPairPtRange(0.f, 1e+10); + fDielectronCut.SetPairYRange(-1e+10, +1e+10); + fDielectronCut.SetPairDCARange(0.f, 1e+10); // in sigma + fDielectronCut.ApplyPhiV(false); + fDielectronCut.ApplyPrefilter(false); + fDielectronCut.SetMindEtadPhi(false, 1.f, 1.f); + fDielectronCut.SetPairOpAng(0.f, 3.2f); + fDielectronCut.SetRequireDifferentSides(false); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + 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.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(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.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); + + // 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.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); + + 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 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.; + } + 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 + } + + std::unordered_map map_pfb; // map track.globalIndex -> prefilter bit + + SliceCache cache; + Preslice perCollision_track = aod::emprimaryelectron::emeventId; + Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); + + 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; + + void processPFB(FilteredMyCollisions const& collisions, MyTracks const& tracks) + { + for (auto& track : tracks) { + map_pfb[track.globalIndex()] = 0; + } // end of track loop + + for (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 posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + if (!fEMEventCut.IsSelected(collision) || !is_cent_ok) { + for (auto& pos : posTracks_per_coll) { + map_pfb[pos.globalIndex()] = 0; + } + for (auto& neg : negTracks_per_coll) { + map_pfb[neg.globalIndex()] = 0; + } + continue; + } + + // 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + if (!fDielectronCut.IsSelectedTrack(pos) || !fDielectronCut.IsSelectedTrack(ele)) { + continue; + } + // don't apply pair cut when you produce prefilter bit. + + 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(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), pos.sign(), ele.sign(), d_bz); + float deta = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + + fRegistry.fill(HIST("Pair/before/uls/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/before/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/before/uls/hDeltaEtaDeltaPhi"), dphi, deta); + + if (v12.M() < cfgMaxMee) { + map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kMee); + map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kMee); + } + if (v12.M() < cfgMaxMee_for_phiv_uls && cfgMinPhiV_uls < phiv) { + map_pfb[pos.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + map_pfb[ele.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + } + } + + for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + if (!fDielectronCut.IsSelectedTrack(pos1) || !fDielectronCut.IsSelectedTrack(pos2)) { + continue; + } + // don't apply pair cut when you produce prefilter bit. + + 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; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), pos1.sign(), pos2.sign(), d_bz); + float deta = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + + 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); + + float slope = cfgMaxMee_for_phiv_ls / (M_PI - cfgMinPhiVv_ls); + float intercept = cfgMaxMee_for_phiv_ls - slope * M_PI; + if (v12.M() < phiv * slope + intercept || v12.M() < (M_PI - phiv) * slope + intercept) { + map_pfb[pos1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + map_pfb[pos2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + } + } + + for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + if (!fDielectronCut.IsSelectedTrack(ele1) || !fDielectronCut.IsSelectedTrack(ele2)) { + continue; + } + // don't apply pair cut when you produce prefilter bit. + + 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; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), ele1.sign(), ele2.sign(), d_bz); + float deta = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + + 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); + float slope = cfgMaxMee_for_phiv_ls / (M_PI - cfgMinPhiVv_ls); + float intercept = cfgMaxMee_for_phiv_ls - slope * M_PI; + if (v12.M() < phiv * slope + intercept || v12.M() < (M_PI - phiv) * slope + intercept) { + map_pfb[ele1.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + map_pfb[ele2.globalIndex()] |= 1 << static_cast(o2::aod::pwgem::dilepton::utils::pairutil::DileptonPrefilterBit::kFakeMatchITSTPC); + } + } + + } // end of collision loop + + for (auto& track : tracks) { + // LOGF(info, "map_pfb[%d] = %d", track.globalIndex(), map_pfb[track.globalIndex()]); + pfb_pi0(map_pfb[track.globalIndex()]); + } // end of track loop + + // check pfb. + for (auto& collision : collisions) { + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + + for (auto& [pos, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + if (!fDielectronCut.IsSelectedTrack(pos) || !fDielectronCut.IsSelectedTrack(ele)) { + continue; + } + if (map_pfb[pos.globalIndex()] != 0 || map_pfb[ele.globalIndex()] != 0) { + 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(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), pos.sign(), ele.sign(), d_bz); + float deta = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = pos.sign() * v1.Pt() > ele.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + fRegistry.fill(HIST("Pair/after/uls/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/after/uls/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/after/uls/hDeltaEtaDeltaPhi"), dphi, deta); + } + + for (auto& [pos1, pos2] : combinations(CombinationsStrictlyUpperIndexPolicy(posTracks_per_coll, posTracks_per_coll))) { // LS++ + if (!fDielectronCut.IsSelectedTrack(pos1) || !fDielectronCut.IsSelectedTrack(pos2)) { + continue; + } + if (map_pfb[pos1.globalIndex()] != 0 || map_pfb[pos2.globalIndex()] != 0) { + 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; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), pos1.sign(), pos2.sign(), d_bz); + float deta = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = pos1.sign() * v1.Pt() > pos2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + 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); + } + + for (auto& [ele1, ele2] : combinations(CombinationsStrictlyUpperIndexPolicy(negTracks_per_coll, negTracks_per_coll))) { // LS-- + if (!fDielectronCut.IsSelectedTrack(ele1) || !fDielectronCut.IsSelectedTrack(ele2)) { + continue; + } + if (map_pfb[ele1.globalIndex()] != 0 || map_pfb[ele2.globalIndex()] != 0) { + 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; + float phiv = o2::aod::pwgem::dilepton::utils::pairutil::getPhivPair(v1.Px(), v1.Py(), v1.Pz(), v2.Px(), v2.Py(), v2.Pz(), ele1.sign(), ele2.sign(), d_bz); + float deta = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Eta() - v2.Eta() : v2.Eta() - v1.Eta(); + float dphi = ele1.sign() * v1.Pt() > ele2.sign() * v2.Pt() ? v1.Phi() - v2.Phi() : v2.Phi() - v1.Phi(); + o2::math_utils::bringToPMPi(dphi); + 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); + } + + } // end of collision loop + + map_pfb.clear(); + } // end of process + PROCESS_SWITCH(prefilterDielectron, processPFB, "produce prefilter bit", false); + + void processDummy(MyTracks const& tracks) + { + for (int i = 0; i < tracks.size(); i++) { + pfb_pi0(0); + } + } + PROCESS_SWITCH(prefilterDielectron, processDummy, "dummy", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"prefilter-dielectron"})}; +} diff --git a/PWGEM/Dilepton/Tasks/singleElectronQC.cxx b/PWGEM/Dilepton/Tasks/singleElectronQC.cxx new file mode 100644 index 00000000000..4a687e82217 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/singleElectronQC.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. +// +// ======================== +// +// Analysis task for single electron QC +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/SingleTrackQC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"single-electron-qc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/singleElectronQCMC.cxx b/PWGEM/Dilepton/Tasks/singleElectronQCMC.cxx new file mode 100644 index 00000000000..da2617158ec --- /dev/null +++ b/PWGEM/Dilepton/Tasks/singleElectronQCMC.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. +// +// ======================== +// +// Analysis task for single electron QC in MC +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/SingleTrackQCMC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"single-electron-qc-mc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/singleMuonQC.cxx b/PWGEM/Dilepton/Tasks/singleMuonQC.cxx new file mode 100644 index 00000000000..b9ccb722ea3 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/singleMuonQC.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. +// +// ======================== +// +// Analysis task for single muon QC +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/SingleTrackQC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"single-muon-qc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/singleMuonQCMC.cxx b/PWGEM/Dilepton/Tasks/singleMuonQCMC.cxx new file mode 100644 index 00000000000..7b7176238c1 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/singleMuonQCMC.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. +// +// ======================== +// +// Analysis task for single muon QC in MC +// Please write to: daiki.sekihata@cern.ch + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" + +#include "PWGEM/Dilepton/Core/SingleTrackQCMC.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask>(cfgc, TaskName{"single-muon-qc-mc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/smearing.cxx b/PWGEM/Dilepton/Tasks/smearing.cxx index 1c5eda15739..82944dc48a0 100644 --- a/PWGEM/Dilepton/Tasks/smearing.cxx +++ b/PWGEM/Dilepton/Tasks/smearing.cxx @@ -10,11 +10,13 @@ // or submit itself to any jurisdiction. // // -// Analysis task to produce smeared pt,eta,phi for electrons/muons in dilepton analysis +// 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 "CCDB/BasicCCDBManager.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -22,8 +24,9 @@ #include "Framework/ASoA.h" #include "Framework/DataTypes.h" #include "Framework/HistogramRegistry.h" -#include "PWGDQ/DataModel/ReducedInfoTables.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" using namespace o2; using namespace o2::framework; @@ -31,47 +34,125 @@ using namespace o2::framework::expressions; using namespace o2::aod; struct ApplySmearing { - Produces smearedtrack; - - // Run for electrons or muons (For the moment the task is not designed for both at the same time) - Configurable fPdgCode{"cfgPdgCode", 11, "Set the type of particle to be smeared"}; - // Maps - Configurable fConfigResFileName{"cfgResFileName", "", "name of resolution file"}; - Configurable fConfigResPtHistName{"cfgResPtHistName", "RelPtResArrCocktail", "histogram name for pt in resolution file"}; - Configurable fConfigResEtaHistName{"cfgResEtaHistName", "EtaResArr", "histogram name for eta in resolution file"}; - Configurable fConfigResPhiPosHistName{"cfgResPhiPosHistName", "PhiPosResArr", "histogram name for phi pos in resolution file"}; - Configurable fConfigResPhiNegHistName{"cfgResPhiNegHistName", "PhiEleResArr", "hisogram for phi neg in resolution file"}; - Configurable fConfigEffFileName{"cfgEffFileName", "", "name of efficiency file"}; - Configurable fConfigEffHistName{"cfgEffHistName", "fhwEffpT", "name of efficiency histogram"}; + Produces smearedelectron; + Produces smearedmuon; + Configurable fFromCcdb{"cfgFromCcdb", false, "get resolution and efficiency histos from CCDB"}; - Configurable fConfigCcdbPathRes{"cfgCcdbPathRes", "", "path to the ccdb object for resolution"}; - Configurable fConfigCcdbPathEff{"cfgCcdbPahtEff", "", "path to the ccdb object for efficiency"}; Configurable fConfigCcdbUrl{"cfgCcdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable fConfigCcdbNoLaterThan{"cfgCcdbNoLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; + Configurable fTimestamp{"cfgCcdbTimestamp", 10, "valid timestamp of CCDB object"}; + + struct : ConfigurableGroup { + std::string prefix = "electron_filename_group"; + Configurable fConfigResFileName{"cfgResFileName", "", "name of resolution file"}; + Configurable fConfigResPtHistName{"cfgResPtHistName", "RelPtResArrCocktail", "histogram name for pt in resolution file"}; + Configurable fConfigResEtaHistName{"cfgResEtaHistName", "EtaResArr", "histogram name for eta in resolution file"}; + Configurable fConfigResPhiPosHistName{"cfgResPhiPosHistName", "PhiPosResArr", "histogram name for phi pos in resolution file"}; + Configurable fConfigResPhiNegHistName{"cfgResPhiNegHistName", "PhiEleResArr", "hisogram for phi neg in resolution file"}; + Configurable fConfigEffFileName{"cfgEffFileName", "", "name of efficiency file"}; + Configurable fConfigEffHistName{"cfgEffHistName", "fhwEffpT", "name of efficiency histogram"}; + Configurable fConfigDCAFileName{"cfgDCAFileName", "", "name of DCA template file"}; + Configurable fConfigDCAHistName{"cfgDCAHistName", "fh_DCAtempaltes", "histogram name of the DCA templates"}; + Configurable fConfigCcdbPathRes{"cfgCcdbPathRes", "", "path to the ccdb object for resolution"}; + Configurable fConfigCcdbPathEff{"cfgCcdbPahtEff", "", "path to the ccdb object for efficiency"}; + Configurable fConfigCcdbPathDCA{"cfgCcdbPahtDCA", "", "path to the ccdb object for dca"}; + } electron_filenames; + + struct : ConfigurableGroup { + std::string prefix = "sa_muon_filename_group"; + Configurable fConfigResFileName{"cfgResFileName", "", "name of resolution file"}; + Configurable fConfigResPtHistName{"cfgResPtHistName", "RelPtResArrCocktail", "histogram name for pt in resolution file"}; + Configurable fConfigResEtaHistName{"cfgResEtaHistName", "EtaResArr", "histogram name for eta in resolution file"}; + Configurable fConfigResPhiPosHistName{"cfgResPhiPosHistName", "PhiPosResArr", "histogram name for phi pos in resolution file"}; + Configurable fConfigResPhiNegHistName{"cfgResPhiNegHistName", "PhiEleResArr", "hisogram for phi neg in resolution file"}; + Configurable fConfigEffFileName{"cfgEffFileName", "", "name of efficiency file"}; + Configurable fConfigEffHistName{"cfgEffHistName", "fhwEffpT", "name of efficiency histogram"}; + Configurable fConfigDCAFileName{"cfgDCAFileName", "", "name of DCA template file"}; + Configurable fConfigDCAHistName{"cfgDCAHistName", "fh_DCAtempaltes", "histogram name of the DCA templates"}; + Configurable fConfigCcdbPathRes{"cfgCcdbPathRes", "", "path to the ccdb object for resolution"}; + Configurable fConfigCcdbPathEff{"cfgCcdbPahtEff", "", "path to the ccdb object for efficiency"}; + Configurable fConfigCcdbPathDCA{"cfgCcdbPahtDCA", "", "path to the ccdb object for dca"}; + } sa_muon_filenames; + + struct : ConfigurableGroup { + std::string prefix = "gl_muon_filename_group"; + Configurable fConfigResFileName{"cfgResFileName", "", "name of resolution file"}; + Configurable fConfigResPtHistName{"cfgResPtHistName", "RelPtResArrCocktail", "histogram name for pt in resolution file"}; + Configurable fConfigResEtaHistName{"cfgResEtaHistName", "EtaResArr", "histogram name for eta in resolution file"}; + Configurable fConfigResPhiPosHistName{"cfgResPhiPosHistName", "PhiPosResArr", "histogram name for phi pos in resolution file"}; + Configurable fConfigResPhiNegHistName{"cfgResPhiNegHistName", "PhiEleResArr", "hisogram for phi neg in resolution file"}; + Configurable fConfigEffFileName{"cfgEffFileName", "", "name of efficiency file"}; + Configurable fConfigEffHistName{"cfgEffHistName", "fhwEffpT", "name of efficiency histogram"}; + Configurable fConfigDCAFileName{"cfgDCAFileName", "", "name of DCA template file"}; + Configurable fConfigDCAHistName{"cfgDCAHistName", "fh_DCAtempaltes", "histogram name of the DCA templates"}; + Configurable fConfigCcdbPathRes{"cfgCcdbPathRes", "", "path to the ccdb object for resolution"}; + Configurable fConfigCcdbPathEff{"cfgCcdbPahtEff", "", "path to the ccdb object for efficiency"}; + Configurable fConfigCcdbPathDCA{"cfgCcdbPahtDCA", "", "path to the ccdb object for dca"}; + } gl_muon_filenames; - MomentumSmearer smearer; + MomentumSmearer smearer_Electron; + MomentumSmearer smearer_StandaloneMuon; + MomentumSmearer smearer_GlobalMuon; Service ccdb; void init(InitContext&) { - smearer.setResFileName(TString(fConfigResFileName)); - smearer.setResPtHistName(TString(fConfigResPtHistName)); - smearer.setResEtaHistName(TString(fConfigResEtaHistName)); - smearer.setResPhiPosHistName(TString(fConfigResPhiPosHistName)); - smearer.setResPhiNegHistName(TString(fConfigResPhiNegHistName)); - smearer.setEffFileName(TString(fConfigEffFileName)); - smearer.setEffHistName(TString(fConfigEffHistName)); + smearer_Electron.setResFileName(TString(electron_filenames.fConfigResFileName)); + smearer_Electron.setResPtHistName(TString(electron_filenames.fConfigResPtHistName)); + smearer_Electron.setResEtaHistName(TString(electron_filenames.fConfigResEtaHistName)); + smearer_Electron.setResPhiPosHistName(TString(electron_filenames.fConfigResPhiPosHistName)); + smearer_Electron.setResPhiNegHistName(TString(electron_filenames.fConfigResPhiNegHistName)); + smearer_Electron.setEffFileName(TString(electron_filenames.fConfigEffFileName)); + smearer_Electron.setEffHistName(TString(electron_filenames.fConfigEffHistName)); + smearer_Electron.setDCAFileName(TString(electron_filenames.fConfigDCAFileName)); + smearer_Electron.setDCAHistName(TString(electron_filenames.fConfigDCAHistName)); + + smearer_StandaloneMuon.setResFileName(TString(sa_muon_filenames.fConfigResFileName)); + smearer_StandaloneMuon.setResPtHistName(TString(sa_muon_filenames.fConfigResPtHistName)); + smearer_StandaloneMuon.setResEtaHistName(TString(sa_muon_filenames.fConfigResEtaHistName)); + smearer_StandaloneMuon.setResPhiPosHistName(TString(sa_muon_filenames.fConfigResPhiPosHistName)); + smearer_StandaloneMuon.setResPhiNegHistName(TString(sa_muon_filenames.fConfigResPhiNegHistName)); + smearer_StandaloneMuon.setEffFileName(TString(sa_muon_filenames.fConfigEffFileName)); + smearer_StandaloneMuon.setEffHistName(TString(sa_muon_filenames.fConfigEffHistName)); + smearer_StandaloneMuon.setDCAFileName(TString(sa_muon_filenames.fConfigDCAFileName)); + smearer_StandaloneMuon.setDCAHistName(TString(sa_muon_filenames.fConfigDCAHistName)); + + smearer_GlobalMuon.setResFileName(TString(gl_muon_filenames.fConfigResFileName)); + smearer_GlobalMuon.setResPtHistName(TString(gl_muon_filenames.fConfigResPtHistName)); + smearer_GlobalMuon.setResEtaHistName(TString(gl_muon_filenames.fConfigResEtaHistName)); + smearer_GlobalMuon.setResPhiPosHistName(TString(gl_muon_filenames.fConfigResPhiPosHistName)); + smearer_GlobalMuon.setResPhiNegHistName(TString(gl_muon_filenames.fConfigResPhiNegHistName)); + smearer_GlobalMuon.setEffFileName(TString(gl_muon_filenames.fConfigEffFileName)); + smearer_GlobalMuon.setEffHistName(TString(gl_muon_filenames.fConfigEffHistName)); + smearer_GlobalMuon.setDCAFileName(TString(gl_muon_filenames.fConfigDCAFileName)); + smearer_GlobalMuon.setDCAHistName(TString(gl_muon_filenames.fConfigDCAHistName)); + if (fFromCcdb) { ccdb->setURL(fConfigCcdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - ccdb->setCreatedNotAfter(fConfigCcdbNoLaterThan); - smearer.setCcdbPathRes(TString(fConfigCcdbPathRes)); - smearer.setCcdbPathEff(TString(fConfigCcdbPathEff)); - smearer.setTimestamp(fConfigCcdbNoLaterThan); - smearer.setCcdb(ccdb); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); // now + + smearer_Electron.setCcdbPathRes(TString(electron_filenames.fConfigCcdbPathRes)); + smearer_Electron.setCcdbPathEff(TString(electron_filenames.fConfigCcdbPathEff)); + smearer_Electron.setCcdbPathDCA(TString(electron_filenames.fConfigCcdbPathDCA)); + smearer_Electron.setTimestamp(fTimestamp); + smearer_Electron.setCcdb(ccdb); + + smearer_StandaloneMuon.setCcdbPathRes(TString(sa_muon_filenames.fConfigCcdbPathRes)); + smearer_StandaloneMuon.setCcdbPathEff(TString(sa_muon_filenames.fConfigCcdbPathEff)); + smearer_StandaloneMuon.setCcdbPathDCA(TString(sa_muon_filenames.fConfigCcdbPathDCA)); + smearer_StandaloneMuon.setTimestamp(fTimestamp); + smearer_StandaloneMuon.setCcdb(ccdb); + + smearer_GlobalMuon.setCcdbPathRes(TString(gl_muon_filenames.fConfigCcdbPathRes)); + smearer_GlobalMuon.setCcdbPathEff(TString(gl_muon_filenames.fConfigCcdbPathEff)); + smearer_GlobalMuon.setCcdbPathDCA(TString(gl_muon_filenames.fConfigCcdbPathDCA)); + smearer_GlobalMuon.setTimestamp(fTimestamp); + smearer_GlobalMuon.setCcdb(ccdb); } - smearer.init(); + smearer_Electron.init(); + smearer_StandaloneMuon.init(); + smearer_GlobalMuon.init(); } template @@ -82,27 +163,57 @@ struct ApplySmearing { float etagen = mctrack.eta(); float phigen = mctrack.phi(); float efficiency = 1.; + float dca = 0.; int pdgCode = mctrack.pdgCode(); - if (abs(pdgCode) == fPdgCode) { + if (abs(pdgCode) == 11) { int ch = -1; if (pdgCode < 0) { ch = 1; } // apply smearing for electrons or muons. float ptsmeared, etasmeared, phismeared; - smearer.applySmearing(ch, ptgen, etagen, phigen, ptsmeared, etasmeared, phismeared); + smearer_Electron.applySmearing(ch, ptgen, etagen, phigen, ptsmeared, etasmeared, phismeared); // get the efficiency - efficiency = smearer.getEfficiency(ptgen, etagen, phigen); - smearedtrack(ptsmeared, etasmeared, phismeared, efficiency); + efficiency = smearer_Electron.getEfficiency(ptgen, etagen, phigen); + // get DCA + dca = smearer_Electron.getDCA(ptsmeared); + // 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) { + int ch = -1; + if (pdgCode < 0) { + ch = 1; + } + // apply smearing for muons based on resolution map of standalone muons + float ptsmeared_sa = 0.f, etasmeared_sa = 0.f, phismeared_sa = 0.f, efficiency_sa = 1.f, dca_sa = 0.f; + smearer_StandaloneMuon.applySmearing(ch, ptgen, etagen, phigen, ptsmeared_sa, etasmeared_sa, phismeared_sa); + efficiency_sa = smearer_StandaloneMuon.getEfficiency(ptgen, etagen, phigen); + dca_sa = smearer_StandaloneMuon.getDCA(ptsmeared_sa); + + float ptsmeared_gl = 0.f, etasmeared_gl = 0.f, phismeared_gl = 0.f, efficiency_gl = 1.f, dca_gl = 0.f; + // apply smearing for muons based on resolution map of global muons + smearer_GlobalMuon.applySmearing(ch, ptgen, etagen, phigen, ptsmeared_gl, etasmeared_gl, phismeared_gl); + 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 - smearedtrack(ptgen, etagen, phigen, efficiency); + smearedelectron(ptgen, etagen, phigen, efficiency, dca); + smearedmuon(ptgen, etagen, phigen, efficiency, dca, ptgen, etagen, phigen, efficiency, dca); } } } - void processMCanalysis(ReducedMCTracks const& tracksMC) + void processMCanalysisEM(aod::EMMCParticles const& tracksMC) + { + applySmearing(tracksMC); + } + + void processMCanalysisDQ(ReducedMCTracks const& tracksMC) { applySmearing(tracksMC); } @@ -112,19 +223,35 @@ struct ApplySmearing { applySmearing(tracksMC); } - void processDummyCocktail(aod::McParticles const&) {} + void processDummyCocktail(aod::McParticles const& tracksMC) + { + // don't apply smearing + for (auto& mctrack : tracksMC) { + int pdgCode = mctrack.pdgCode(); + if (abs(pdgCode) == 11) { + 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); + smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0); + } + } + } void processDummyMCanalysis(ReducedMCTracks const&) {} - PROCESS_SWITCH(ApplySmearing, processMCanalysis, "Run for MC analysis", false); + 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, processDummyMCanalysis, "Dummy process function", false); PROCESS_SWITCH(ApplySmearing, processDummyCocktail, "Dummy process function", true); }; struct CheckSmearing { - using MyReducedTracks = soa::Join; - using MyCocktailTracks = soa::Join; + 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 // Run for electrons or muons Configurable fPdgCode{"cfgPdgCode", 11, "Set the type of particle to be checked"}; @@ -137,30 +264,30 @@ struct CheckSmearing { ConfigurableAxis deltaetaResBins{"deltaetaResBins", {500, -0.5f, 0.5f}, "DeltaEta binning for resolution"}; ConfigurableAxis deltaphiResBins{"deltaphiResBins", {500, -0.5f, 0.5f}, "DeltaPhi binning for resolution"}; - HistogramRegistry registry{"HistoAnalysisTrackSelection", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registry{"output", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(o2::framework::InitContext&) { - registry.add("hCorrelation_Pt", "pT correlation", {HistType::kTH2F, {{1000, 0.0f, 10.0f}, {1000, 0.0f, 10.0f}}}); - registry.add("hCorrelation_Eta", "eta correlation", {HistType::kTH2F, {{200, -1.0f, +1.0f}, {200, -1.0f, +1.0f}}}); - registry.add("hCorrelation_Phi", "phi correlation", {HistType::kTH2F, {{100, 0.0f, TMath::TwoPi()}, {100, 0.0f, TMath::TwoPi()}}}); + 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()}}}); // Binning for resolution - AxisSpec axisPtRes{ptResBins, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}; + AxisSpec axisPtRes{ptResBins, "#it{p}^{gen}_{T,l} (GeV/#it{c})"}; AxisSpec axisDeltaptRes{deltaptResBins, "(p^{gen}_{T} - p^{rec}_{T}) / p^{gen}_{T}"}; AxisSpec axisDeltaetaRes{deltaetaResBins, "#eta^{gen} - #eta^{rec}"}; - AxisSpec axisDeltaphiRes{deltaphiResBins, "#varphi^{gen} - #varphi^{rec} (rad)"}; + 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_Ele", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); + registry.add("PtGen_DeltaPhi_Neg", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); registry.add("PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {axisPtRes, axisDeltaphiRes}, true); } else { - registry.add("PtGen_DeltaPtOverPtGen", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}, axisDeltaptRes}, true); - registry.add("PtGen_DeltaEta", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}, axisDeltaetaRes}, true); - registry.add("PtGen_DeltaPhi_Ele", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}, axisDeltaphiRes}, true); - registry.add("PtGen_DeltaPhi_Pos", "", HistType::kTH2D, {{ptResBinsVec, "#it{p}^{gen}_{T,e} (GeV/#it{c})"}, axisDeltaphiRes}, true); + 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); } } @@ -180,7 +307,7 @@ struct CheckSmearing { 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_Ele"), mctrack.pt(), deltaphi); + registry.fill(HIST("PtGen_DeltaPhi_Neg"), mctrack.pt(), deltaphi); } else { registry.fill(HIST("PtGen_DeltaPhi_Pos"), mctrack.pt(), deltaphi); } @@ -190,7 +317,12 @@ struct CheckSmearing { } // end of mctrack loop } - void processCheckMCanalysis(MyReducedTracks const& tracksMC) + void processCheckMCanalysisEM(EMMCParticlesWithSmearing const& tracksMC) + { + Check(tracksMC); + } + + void processCheckMCanalysisDQ(MyReducedTracks const& tracksMC) { Check(tracksMC); } @@ -200,12 +332,15 @@ struct CheckSmearing { Check(tracksMC); } - void processDummyMCanalysis(ReducedMCTracks const&) {} + void processDummyMCanalysisEM(aod::EMMCParticles const&) {} + void processDummyMCanalysisDQ(ReducedMCTracks const&) {} void processDummyCocktail(aod::McParticles const&) {} - PROCESS_SWITCH(CheckSmearing, processCheckMCanalysis, "Run for MC analysis", false); + 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, processDummyMCanalysis, "Dummy process function", 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/tableReaderBarrel.cxx b/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx index 227e070baca..7c960add267 100644 --- a/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx +++ b/PWGEM/Dilepton/Tasks/tableReaderBarrel.cxx @@ -11,6 +11,10 @@ // // Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no // + +#include +#include +#include #include #include #include @@ -137,8 +141,8 @@ struct AnalysisEventSelection { Configurable cfgRequireGoodZvtxFT0vsPV{"cfgRequireGoodZvtxFT0vsPV", false, "require good Zvtx between FT0 vs. PV in event cut"}; Configurable cfgCentFT0CMin{"cfgCentralityMin", -1000000000.f, "min. centrality"}; Configurable cfgCentFT0CMax{"cfgCentralityMax", 1000000000.f, "max. centrality"}; - Configurable cfgOccupancyMin{"cfgOccupancyMin", -1000000000, "min. occupancy"}; - Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgTrackOccupancyMin{"cfgTrackOccupancyMin", -1000000000, "min. occupancy"}; + Configurable cfgTrackOccupancyMax{"cfgTrackOccupancyMax", 1000000000, "max. occupancy"}; } eventcuts; HistogramManager* fHistMan = nullptr; @@ -233,7 +237,7 @@ struct AnalysisEventSelection { if (eventcuts.cfgRequireGoodZvtxFT0vsPV) cut->AddCut(VarManager::kIsGoodZvtxFT0vsPV, 0.5, 1.5); cut->AddCut(VarManager::kCentFT0C, eventcuts.cfgCentFT0CMin, eventcuts.cfgCentFT0CMax); - cut->AddCut(VarManager::kTrackOccupancyInTimeRange, eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); + cut->AddCut(VarManager::kTrackOccupancyInTimeRange, eventcuts.cfgTrackOccupancyMin, eventcuts.cfgTrackOccupancyMax); return cut; } @@ -289,7 +293,7 @@ struct AnalysisTrackSelection { 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"}; + Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of cuts including prefilter cut, need to be below 30"}; std::vector fTrackCuts; struct : ConfigurableGroup { @@ -341,10 +345,9 @@ struct AnalysisTrackSelection { { fCurrentRun = 0; - int nbofcuts = fConfigNbTrackCut; - if (nbofcuts > 0 && CheckSize()) { - for (unsigned int icut = 0; icut < nbofcuts; ++icut) { - AnalysisCompositeCut* cut = new AnalysisCompositeCut(Form("trackcut%d", icut), Form("trackcut%d", icut)); + if (fConfigNbTrackCut > 0 && CheckSize()) { + for (std::size_t icut = 0; icut < fConfigNbTrackCut; ++icut) { + AnalysisCompositeCut* cut = new AnalysisCompositeCut(Form("trackcut%zu", icut), Form("trackcut%zu", icut)); cut->AddCut(GetTrackCut(icut)); cut->AddCut(GetPIDCut(icut)); fTrackCuts.push_back(*cut); @@ -639,7 +642,7 @@ struct AnalysisTrackSelection { for (auto cut = fTrackCuts.begin(); cut != fTrackCuts.end(); cut++, iCut++) { if ((*cut).IsSelected(VarManager::fgValues)) { if (iCut != fConfigPrefilterCutId) { - filterMap |= (uint32_t(1) << iCut); + filterMap |= (static_cast(1) << iCut); } if (iCut == fConfigPrefilterCutId) { prefilterSelected = true; @@ -791,7 +794,7 @@ struct AnalysisEventMixing { // single particle selection tasks to preserve the correspondence between the track cut name and its // bit position in the cuts bitmap // TODO: Create a configurable to specify exactly on which of the bits one should run the event mixing - Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of cuts without prefilter cut, need to be consistent with the track selection"}; + Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of cuts without prefilter cut, need to be consistent with the track selection"}; Configurable fConfigMixingDepth{"cfgMixingDepth", 100, "Number of Events stored for event mixing"}; Configurable fConfigAddEventMixingHistogram{"cfgAddEventMixingHistogram", "", "Comma separated list of histograms"}; Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -828,14 +831,14 @@ struct AnalysisEventMixing { // Keep track of all the histogram class names to avoid composing strings in the event mixing pairing TString histNames = ""; if (fConfigNbTrackCut > 0 && fConfigNbTrackCut < 31) { - for (int icut = 0; icut < fConfigNbTrackCut; ++icut) { + for (std::size_t icut = 0; icut < fConfigNbTrackCut; ++icut) { std::vector names = { - Form("PairsBarrelMEPM_trackcut%d", icut), - Form("PairsBarrelMEPP_trackcut%d", icut), - Form("PairsBarrelMEMM_trackcut%d", icut)}; + Form("PairsBarrelMEPM_trackcut%zu", icut), + Form("PairsBarrelMEPP_trackcut%zu", icut), + Form("PairsBarrelMEMM_trackcut%zu", icut)}; histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackHistNames.push_back(names); - fTwoTrackFilterMask |= (uint32_t(1) << icut); + fTwoTrackFilterMask |= (static_cast(1) << icut); } } @@ -854,7 +857,7 @@ struct AnalysisEventMixing { uint32_t twoTrackFilter = 0; for (auto& track1 : tracks1) { for (auto& track2 : tracks2) { - twoTrackFilter = uint32_t(track1.isBarrelSelected()) & uint32_t(track2.isBarrelSelected()) & fTwoTrackFilterMask; + twoTrackFilter = static_cast(track1.isBarrelSelected()) & static_cast(track2.isBarrelSelected()) & fTwoTrackFilterMask; if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue continue; @@ -871,7 +874,7 @@ struct AnalysisEventMixing { } for (unsigned int icut = 0; icut < ncuts; icut++) { - if (twoTrackFilter & (uint32_t(1) << icut)) { + if (twoTrackFilter & (static_cast(1) << icut)) { if (track1.sign() * track2.sign() < 0) { fHistMan->FillHistClass(histNames[icut][0].Data(), VarManager::fgValues); } else { @@ -882,9 +885,9 @@ struct AnalysisEventMixing { } } } // end if (filter bits) - } // end for (cuts) - } // end for (track2) - } // end for (track1) + } // end for (cuts) + } // end for (track2) + } // end for (track1) } // barrel-barrel and muon-muon event mixing @@ -948,8 +951,8 @@ struct AnalysisSameEventPairing { int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc. OutputObj fOutputList{"output"}; - Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of track cuts without prefilter cut, need to be consistent with the track selection"}; - Configurable fConfigNbPairCut{"cfgNbPairCut", 1, "Number of pair cuts, need to be below 4 right now"}; + Configurable fConfigNbTrackCut{"cfgNbTrackCut", 1, "Number of track cuts without prefilter cut, need to be consistent with the track selection"}; + Configurable fConfigNbPairCut{"cfgNbPairCut", 1, "Number of pair cuts, need to be below 4 right now"}; Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable ccdbPath{"ccdb-path", "Users/lm", "base path to the ccdb object"}; 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"}; @@ -1069,35 +1072,34 @@ struct AnalysisSameEventPairing { std::vector names; if (fConfigNbPairCut > 0 && CheckSize()) { - for (int icut = 0; icut < fConfigNbPairCut; ++icut) { + for (std::size_t icut = 0; icut < fConfigNbPairCut; ++icut) { fPairCuts.push_back(*GetPairCut(icut)); } } if (fConfigNbTrackCut > 0 && fConfigNbTrackCut < 31) { // if track cuts - for (int icut = 0; icut < fConfigNbTrackCut; ++icut) { // loop over track cuts - fTwoTrackFilterMask |= (uint32_t(1) << icut); + for (std::size_t icut = 0; icut < fConfigNbTrackCut; ++icut) { // loop over track cuts + fTwoTrackFilterMask |= (static_cast(1) << icut); // no pair cuts names = { - Form("PairsBarrelSEPM_trackcut%d", icut), - Form("PairsBarrelSEPP_trackcut%d", icut), - Form("PairsBarrelSEMM_trackcut%d", icut)}; + Form("PairsBarrelSEPM_trackcut%zu", icut), + Form("PairsBarrelSEPP_trackcut%zu", icut), + Form("PairsBarrelSEMM_trackcut%zu", icut)}; histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackHistNames.push_back(names); - unsigned int npaircuts = fPairCuts.size(); - for (int iPairCut = 0; iPairCut < npaircuts; ++iPairCut) { // loop over pair cuts + for (std::size_t iPairCut = 0; iPairCut < fPairCuts.size(); ++iPairCut) { // loop over pair cuts names = { - Form("PairsBarrelSEPM_trackcut%d_paircut%d", icut, iPairCut), - Form("PairsBarrelSEPP_trackcut%d_paircut%d", icut, iPairCut), - Form("PairsBarrelSEMM_trackcut%d_paircut%d", icut, iPairCut)}; + Form("PairsBarrelSEPM_trackcut%zu_paircut%zu", icut, iPairCut), + Form("PairsBarrelSEPP_trackcut%zu_paircut%zu", icut, iPairCut), + Form("PairsBarrelSEMM_trackcut%zu_paircut%zu", icut, iPairCut)}; histNames += Form("%s;%s;%s;", names[0].Data(), names[1].Data(), names[2].Data()); fTrackHistNames.push_back(names); - } // end loop (pair cuts) - } // end loop (track cuts) - } // end if (track cuts) + } // end loop (pair cuts) + } // end loop (track cuts) + } // end if (track cuts) VarManager::SetCollisionSystem((TString)fCollisionSystem, fCenterMassEnergy); // set collision system and center of mass energy @@ -1125,7 +1127,7 @@ struct AnalysisSameEventPairing { uint32_t twoTrackFilter = 0; for (auto& [t1, t2] : combinations(tracks1, tracks2)) { - twoTrackFilter = uint32_t(t1.isBarrelSelected()) & uint32_t(t2.isBarrelSelected()) & fTwoTrackFilterMask; + twoTrackFilter = static_cast(t1.isBarrelSelected()) & static_cast(t2.isBarrelSelected()) & fTwoTrackFilterMask; if (!twoTrackFilter) { // the tracks must have at least one filter bit in common to continue continue; @@ -1143,8 +1145,8 @@ struct AnalysisSameEventPairing { } int iCut = 0; - for (int icut = 0; icut < fConfigNbTrackCut; icut++) { - if (twoTrackFilter & (uint32_t(1) << icut)) { + for (std::size_t icut = 0; icut < fConfigNbTrackCut; icut++) { + if (twoTrackFilter & (static_cast(1) << icut)) { if (t1.sign() * t2.sign() < 0) { fHistMan->FillHistClass(histNames[iCut][0].Data(), VarManager::fgValues); } else { @@ -1168,12 +1170,12 @@ struct AnalysisSameEventPairing { fHistMan->FillHistClass(histNames[iCut][2].Data(), VarManager::fgValues); } } - } // end loop (pair cuts) + } // end loop (pair cuts) } else { // end if (filter bits) iCut = iCut + 1 + fPairCuts.size(); } } // end loop (cuts) - } // end loop over pairs + } // end loop over pairs } void processDecayToEESkimmed(soa::Filtered::iterator const& event, soa::Filtered const& tracks) diff --git a/PWGEM/Dilepton/Tasks/vpPairQC.cxx b/PWGEM/Dilepton/Tasks/vpPairQC.cxx new file mode 100644 index 00000000000..f39f89bed10 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/vpPairQC.cxx @@ -0,0 +1,542 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +#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/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" + +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::emtrackutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyTracks = soa::Join; +using MyTrack = MyTracks::iterator; + +struct vpPairQC { + // 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.f, "max. centrality"}; + ConfigurableAxis ConfPtlBins{"ConfPtlBins", {VARIABLE_WIDTH, 0.00, 0.10, 0.11, 0.12, 0.13, 0.14, 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"}; + + EMEventCut 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 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"}; + } 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", 0.01, "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.9, "min pair rapidity"}; + Configurable cfg_max_pair_y{"cfg_max_pair_y", +0.9, "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_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_apply_phiv_meedep{"cfg_apply_phiv_meedep", true, "flag to apply mee-dependent phiv cut"}; + 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_min_mee_for_phiv{"cfg_min_mee_for_phiv", 0.0, "min mee for phiv (constant)"}; + Configurable cfg_max_mee_for_phiv{"cfg_max_mee_for_phiv", 1e+10, "max mee for phiv (constant)"}; + + Configurable cfg_min_pt_track{"cfg_min_pt_track", 0.1, "min 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_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1e+10, "max DCA 3D in sigma"}; + 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_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_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 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_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"}; + Configurable cfg_max_TPCNsigmaKa{"cfg_max_TPCNsigmaKa", +0.0, "max. TPC n sigma for kaon exclusion"}; + Configurable cfg_min_TPCNsigmaPr{"cfg_min_TPCNsigmaPr", -0.0, "min. TPC n sigma for proton exclusion"}; + 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_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"}; + + // 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; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + + void init(InitContext& /*context*/) + { + DefineEMEventCut(); + DefineDielectronCut(); + addhistograms(); + + 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(); + } + + ~vpPairQC() {} + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::utils::eventhistogram::addEventHistograms(&fRegistry); + + 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.)"}; + const AxisSpec axis_dca{{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_{e}^{3D} (#sigma)"}; + 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/hPResolution", "p resolution;p (GeV/c);#Deltap/p", kTH2F, {{1000, 0.0f, 10.0f}, {100, 0.0f, 0.1f}}, false); + fRegistry.add("Track/positive/hPtResolution", "p_{T} resolution;p (GeV/c);#Deltap_{T}/p_{T}", kTH2F, {{1000, 0.0f, 10.0f}, {100, 0.0f, 0.1f}}, false); + fRegistry.add("Track/positive/hThetaResolution", "#theta resolution;p (GeV/c);#Delta#theta (rad.)", kTH2F, {{1000, 0.0f, 10.0f}, {100, 0.0f, 0.01f}}, false); + fRegistry.add("Track/positive/hEtaResolution", "#eta resolution;p (GeV/c);#Delta#eta", kTH2F, {{1000, 0.0f, 10.0f}, {100, 0.0f, 0.01f}}, false); + fRegistry.add("Track/positive/hPhiResolution", "#varphi resolution;p (GeV/c);#Delta#varphi (rad.)", kTH2F, {{1000, 0.0f, 10.0f}, {100, 0.0f, 0.01f}}, 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/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/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/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, 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/hTOFbeta", "TOF #beta;p_{pv} (GeV/c);#beta", kTH2F, {{1000, 0, 10}, {240, 0, 1.2}}, 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/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/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); + fRegistry.addClone("Track/positive/", "Track/negative/"); + + const AxisSpec axis_mass{50, 0, 0.05, "m_{ee} (GeV/c^{2})"}; + const AxisSpec axis_pair_pt{200, 0, 2, "p_{T,ee} (GeV/c)"}; + const AxisSpec axis_pair_dca_3d{100, 0, 10, "DCA_{ee}^{3D} (#sigma)"}; + const AxisSpec axis_pair_dca_xy{100, 0, 10, "DCA_{ee}^{XY} (#sigma)"}; + const AxisSpec axis_phiv{90, 0, M_PI, "#varphi_{V} (rad.)"}; + // for pair + fRegistry.add("Pair/hMvsPt", "m_{ee} vs. p_{T,ee};m_{ee} (GeV/c^{2});p_{T,ee} (GeV/c)", kTH2F, {axis_mass, axis_pair_pt}, true); + fRegistry.add("Pair/hMvsPhiV", "m_{ee} vs. #varphi_{V};#varphi (rad.);m_{ee} (GeV/c^{2})", kTH2F, {axis_phiv, axis_mass}, true); + fRegistry.add("Pair/hDCA3DvsPhiV", "DCA_{ee}^{3D} vs. #varphi_{V};#varphi_{V} (rad.);DCA_{ee}^{3D} (#sigma)", kTH2F, {axis_phiv, axis_pair_dca_3d}, true); + fRegistry.add("Pair/hDCAXYvsPhiV", "DCA_{ee}^{XY} vs. #varphi_{V};#varphi_{V} (rad.);DCA_{ee}^{XY} (#sigma)", kTH2F, {axis_phiv, axis_pair_dca_xy}, true); + } + + void DefineEMEventCut() + { + fEMEventCut = EMEventCut("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); + } + + 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 + if (dielectroncuts.cfg_apply_phiv_meedep) { + fDielectronCut.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); + } else { + fDielectronCut.SetPhivPairRange(dielectroncuts.cfg_min_phiv, dielectroncuts.cfg_max_phiv, dielectroncuts.cfg_min_mee_for_phiv, dielectroncuts.cfg_max_mee_for_phiv); + } + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); + fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); + fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + fDielectronCut.SetTrackEtaRange(dielectroncuts.cfg_min_eta_track, dielectroncuts.cfg_max_eta_track); + fDielectronCut.SetTrackDca3DRange(0.f, dielectroncuts.cfg_max_dca3dsigma_track); // in sigma + fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); + fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); + fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + 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.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); + + // 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.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); + + 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 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.; + } + 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 + } + + template + bool fillPairInfo(TCollision const&, TTrack1 const& t1, TTrack2 const& t2) + { + // if (t1.trackId() == t2.trackId()) { // this is protection against pairing identical 2 tracks. This happens, when TTCA is used. TTCA can assign a track to several possible collisions. + // return false; + // } + + if (!fDielectronCut.IsSelectedTrack(t1) || !fDielectronCut.IsSelectedTrack(t2)) { + return false; + } + + if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz)) { + 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; + 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 dca_t1 = dca3DinSigma(t1); + float dca_t2 = dca3DinSigma(t2); + float pair_dca_3d = std::sqrt((dca_t1 * dca_t1 + dca_t2 * dca_t2) / 2.); + float pair_dca_xy = std::sqrt((std::pow(t1.dcaXY() / std::sqrt(t1.cYY()), 2) + std::pow(t2.dcaXY() / std::sqrt(t2.cYY()), 2)) / 2.); + + fRegistry.fill(HIST("Pair/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/hMvsPhiV"), phiv, v12.M()); + fRegistry.fill(HIST("Pair/hDCA3DvsPhiV"), phiv, pair_dca_3d); + fRegistry.fill(HIST("Pair/hDCAXYvsPhiV"), phiv, pair_dca_xy); + + 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(), t2.globalIndex()) == used_trackIds.end()) { + used_trackIds.emplace_back(t2.globalIndex()); + fillTrackInfo(t2); + } + + return true; + } + + template + void fillTrackInfo(TTrack const& track) + { + float weight = 1.f; + float dca_3d = dca3DinSigma(track); + 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 + fRegistry.fill(HIST("Track/positive/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 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/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/positive/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/positive/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/positive/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/positive/hITSClusterMap"), track.itsClusterMap()); + + fRegistry.fill(HIST("Track/positive/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + 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/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/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 + fRegistry.fill(HIST("Track/negative/hDCAzRes_Pt"), track.pt(), sqrt(track.cZZ()) * 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/hTPCNcr2Nf"), track.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("Track/negative/hTPCNcls2Nf"), track.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("Track/negative/hChi2TPC"), track.tpcChi2NCl()); + fRegistry.fill(HIST("Track/negative/hChi2ITS"), track.itsChi2NCl()); + fRegistry.fill(HIST("Track/negative/hITSClusterMap"), track.itsClusterMap()); + + fRegistry.fill(HIST("Track/negative/hTPCdEdx"), track.tpcInnerParam(), track.tpcSignal()); + 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/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/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()); + } + } + + 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; + + SliceCache cache; + Preslice perCollision_track = 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 && 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); + using FilteredMyTracks = soa::Filtered; + + Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); + + std::vector used_trackIds; + void processQC(FilteredMyCollisions const& collisions, FilteredMyTracks const& /*tracks*/) + { + for (auto& collision : collisions) { + initCCDB(collision); + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<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 posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + fillPairInfo(collision, pos, ele); + } + } // end of collision loop + + used_trackIds.clear(); + used_trackIds.shrink_to_fit(); + + } // end of process + PROCESS_SWITCH(vpPairQC, processQC, "run vp pair QC", true); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(vpPairQC, processDummy, "Dummy function", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"vp-pair-qc"})}; +} diff --git a/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx b/PWGEM/Dilepton/Tasks/vpPairQCMC.cxx new file mode 100644 index 00000000000..bfe6e1f3429 --- /dev/null +++ b/PWGEM/Dilepton/Tasks/vpPairQCMC.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. +// +// ======================== +// +// 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/Utils/EMTrackUtilities.h" +#include "PWGEM/Dilepton/Utils/PairUtilities.h" +#include "PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.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::dilepton::utils::mcutil; + +using MyCollisions = soa::Join; +using MyCollision = MyCollisions::iterator; + +using MyMCTracks = soa::Join; +using MyMCTrack = MyMCTracks::iterator; + +struct vpPairQCMC { + + // 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.f, "max. centrality"}; + Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; + + EMEventCut 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 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"}; + } 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", 0.01, "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.9, "min pair rapidity"}; + Configurable cfg_max_pair_y{"cfg_max_pair_y", +0.9, "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_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.1, "min 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_max_dca3dsigma_track{"cfg_max_dca3dsigma_track", 1e+10, "max DCA 3D in sigma"}; + 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_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_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 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_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"}; + Configurable cfg_max_TPCNsigmaKa{"cfg_max_TPCNsigmaKa", +0.0, "max. TPC n sigma for kaon exclusion"}; + Configurable cfg_min_TPCNsigmaPr{"cfg_min_TPCNsigmaPr", -0.0, "min. TPC n sigma for proton exclusion"}; + 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_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"}; + + // 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; + + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + int mRunNumber; + float d_bz; + + struct : ConfigurableGroup { + std::string prefix = "mctrackcut_group"; + Configurable min_mcPt{"min_mcPt", 0.05, "min. MC pT"}; + Configurable max_mcPt{"max_mcPt", 1e+10, "max. MC pT"}; + Configurable max_mcEta{"max_mcEta", 0.9, "max. MC eta"}; + } mctrackcuts; + + HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + static constexpr std::string_view event_cut_types[2] = {"before/", "after/"}; + + ~vpPairQCMC() {} + + void addhistograms() + { + // event info + o2::aod::pwgem::dilepton::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)"}; + + // generated info + fRegistry.add("Generated/sm/Pi0/hMvsPt", "m_{ee} vs. p_{T,ee} ULS", kTH2F, {axis_mass, axis_pt}, 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/Phi/"); + + // reconstructed pair info + fRegistry.add("Pair/sm/Photon/hMvsPt", "m_{ee} vs. p_{T,ee} ULS", kTH2F, {axis_mass, axis_pt}, true); + 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, 0.1f}}, false); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Pi0/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Eta/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/EtaPrime/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Rho/"); + fRegistry.addClone("Pair/sm/Photon/", "Pair/sm/Omega/"); + 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); + } + + void init(InitContext&) + { + DefineEMEventCut(); + DefineDielectronCut(); + addhistograms(); + + 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(); + } + + void DefineEMEventCut() + { + fEMEventCut = EMEventCut("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); + } + + 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.SetMaxPhivPairMeeDep([&](float mll) { return (mll - dielectroncuts.cfg_phiv_intercept) / dielectroncuts.cfg_phiv_slope; }); + fDielectronCut.ApplyPhiV(dielectroncuts.cfg_apply_phiv); + fDielectronCut.ApplyPrefilter(dielectroncuts.cfg_apply_pf); + fDielectronCut.RequireITSibAny(dielectroncuts.cfg_require_itsib_any); + fDielectronCut.RequireITSib1st(dielectroncuts.cfg_require_itsib_1st); + + // for track + fDielectronCut.SetTrackPtRange(dielectroncuts.cfg_min_pt_track, 1e+10f); + fDielectronCut.SetTrackEtaRange(-dielectroncuts.cfg_max_eta_track, +dielectroncuts.cfg_max_eta_track); + fDielectronCut.SetTrackDca3DRange(0.f, dielectroncuts.cfg_max_dca3dsigma_track); // in sigma + fDielectronCut.SetMinNClustersTPC(dielectroncuts.cfg_min_ncluster_tpc); + fDielectronCut.SetMinNCrossedRowsTPC(dielectroncuts.cfg_min_ncrossedrows); + fDielectronCut.SetMinNCrossedRowsOverFindableClustersTPC(0.8); + 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.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); + + // 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.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); + + 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 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.; + } + 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 + } + + template + int FindLF(TTrack const& posmc, TTrack const& elemc, TMCParticles const& mcparticles) + { + int arr[] = { + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 111, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 221, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 331, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 113, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 223, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 333, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 443, mcparticles), + FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 100443, mcparticles)}; + int size = sizeof(arr) / sizeof(*arr); + int max = *std::max_element(arr, arr + size); + return max; + } + + template + bool isInAcceptance(T const& t1) + { + if ((mctrackcuts.min_mcPt < t1.pt() && t1.pt() < mctrackcuts.max_mcPt) && abs(t1.eta()) < mctrackcuts.max_mcEta) { + return true; + } else { + return false; + } + } + + template + bool fillTruePairInfo(TCollision const&, TTrack1 const& t1, TTrack2 const& t2, TMCParticles const& mcparticles) + { + if (!fDielectronCut.IsSelectedTrack(t1) || !fDielectronCut.IsSelectedTrack(t2)) { + return false; + } + + if (!fDielectronCut.IsSelectedPair(t1, t2, d_bz)) { + return false; + } + + auto t1mc = t1.template emmcparticle_as(); + 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) { + 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) { + 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 (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { + if ((t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && (t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { + switch (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()); + break; + case 221: + fRegistry.fill(HIST("Pair/sm/Eta/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/sm/Eta/hMvsPhiV"), phiv, v12.M()); + break; + case 331: + fRegistry.fill(HIST("Pair/sm/EtaPrime/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/sm/EtaPrime/hMvsPhiV"), phiv, v12.M()); + break; + case 113: + fRegistry.fill(HIST("Pair/sm/Rho/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/sm/Rho/hMvsPhiV"), phiv, v12.M()); + break; + case 223: + fRegistry.fill(HIST("Pair/sm/Omega/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/sm/Omega/hMvsPhiV"), phiv, v12.M()); + break; + case 333: + fRegistry.fill(HIST("Pair/sm/Phi/hMvsPt"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/sm/Phi/hMvsPhiV"), phiv, v12.M()); + break; + default: + break; + } + } else if (!(t1mc.isPhysicalPrimary() || t1mc.producedByGenerator()) && !(t2mc.isPhysicalPrimary() || t2mc.producedByGenerator())) { + switch (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()); + break; + default: + break; + } + } // 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 + 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()); + } + + std::vector used_trackIds; + SliceCache cache; + Preslice perCollision_track = 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 && 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); + + using FilteredMyMCTracks = soa::Filtered; + Partition posTracks = o2::aod::emprimaryelectron::sign > int8_t(0); + Partition negTracks = o2::aod::emprimaryelectron::sign < int8_t(0); + + 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 processQCMC(FilteredMyCollisions const& collisions, FilteredMyMCTracks const& tracks, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const&) + { + used_trackIds.reserve(tracks.size()); + + for (auto& collision : collisions) { + initCCDB(collision); + + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision); + fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0); // accepted + fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0); // accepted + + auto posTracks_per_coll = posTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, collision.globalIndex(), cache); + auto negTracks_per_coll = negTracks->sliceByCached(o2::aod::emprimaryelectron::emeventId, 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, ele] : combinations(CombinationsFullIndexPolicy(posTracks_per_coll, negTracks_per_coll))) { // ULS + fillTruePairInfo(collision, pos, ele, mcparticles); + } // end of ULS pair loop + + } // end of collision loop + + used_trackIds.clear(); + used_trackIds.shrink_to_fit(); + } // end of process + PROCESS_SWITCH(vpPairQCMC, processQCMC, "run Dalitz QC", true); + + Partition posTracksMC = o2::aod::mcparticle::pdgCode == -11; // e+ + Partition negTracksMC = o2::aod::mcparticle::pdgCode == +11; // e- + PresliceUnsorted perMcCollision = aod::emmcparticle::emmceventId; + void processGen(MyCollisions const& collisions, aod::EMMCEvents const&, aod::EMMCParticles const& mcparticles) + { + // loop over mc stack and fill histograms for pure MC truth signals + // all MC tracks which belong to the MC event corresponding to the current reconstructed event + + for (auto& collision : collisions) { + float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; + if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { + continue; + } + + if (!fEMEventCut.IsSelected(collision)) { + continue; + } + auto mccollision = collision.emmcevent_as(); + + auto posTracks_per_coll = posTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); + auto negTracks_per_coll = negTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); + + for (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)) { + continue; + } + + if (!t1.isPhysicalPrimary() && !t1.producedByGenerator()) { + continue; + } + if (!t2.isPhysicalPrimary() && !t2.producedByGenerator()) { + continue; + } + + int mother_id = FindLF(t1, t2, mcparticles); + int hfee_type = IsHF(t1, t2, mcparticles); + if (mother_id < 0 && hfee_type < 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) { + continue; + } + + if (mother_id > -1) { + auto mcmother = mcparticles.iteratorAt(mother_id); + if (mcmother.isPhysicalPrimary() || mcmother.producedByGenerator()) { + + switch (abs(mcmother.pdgCode())) { + case 111: + fRegistry.fill(HIST("Generated/sm/Pi0/hMvsPt"), v12.M(), v12.Pt()); + break; + case 221: + fRegistry.fill(HIST("Generated/sm/Eta/hMvsPt"), v12.M(), v12.Pt()); + break; + case 331: + fRegistry.fill(HIST("Generated/sm/EtaPrime/hMvsPt"), v12.M(), v12.Pt()); + break; + case 113: + fRegistry.fill(HIST("Generated/sm/Rho/hMvsPt"), v12.M(), v12.Pt()); + break; + case 223: + fRegistry.fill(HIST("Generated/sm/Omega/hMvsPt"), v12.M(), v12.Pt()); + break; + case 333: + fRegistry.fill(HIST("Generated/sm/Phi/hMvsPt"), v12.M(), v12.Pt()); + break; + default: + break; + } + } + } + } // end of true ULS pair loop + } // end of collision loop + } + PROCESS_SWITCH(vpPairQCMC, processGen, "run genrated info", true); + + void processDummy(MyCollisions const&) {} + PROCESS_SWITCH(vpPairQCMC, processDummy, "Dummy function", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"vp-pair-qc-mc"})}; +} diff --git a/PWGEM/Dilepton/Utils/EMFwdTrack.h b/PWGEM/Dilepton/Utils/EMFwdTrack.h index c38d644e714..0aa590c6fb2 100644 --- a/PWGEM/Dilepton/Utils/EMFwdTrack.h +++ b/PWGEM/Dilepton/Utils/EMFwdTrack.h @@ -22,8 +22,9 @@ namespace o2::aod::pwgem::dilepton::utils class EMFwdTrack { public: - EMFwdTrack(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 = 0, float dcaX = 0.f, float dcaY = 0.f, std::vector amb_muon_self_ids = {}) { + fDFId = dfId; fGlobalId = globalId; fCollisionId = collisionId; fTrackId = trackId; @@ -46,6 +47,7 @@ class EMFwdTrack ~EMFwdTrack() {} + int dfId() const { return fDFId; } int globalIndex() const { return fGlobalId; } int collisionId() const { return fCollisionId; } int fwdtrackId() const { return fTrackId; } @@ -57,6 +59,7 @@ class EMFwdTrack float fwdDcaX() const { return fDCAx; } float fwdDcaY() const { return fDCAy; } float fwdDcaXY() const { return std::sqrt(std::pow(fDCAx, 2) + std::pow(fDCAy, 2)); } + float p() const { return fPt * std::cosh(fEta); } float px() const { return fPt * std::cos(fPhi); } float py() const { return fPt * std::sin(fPhi); } float pz() const { return fPt * std::sinh(fEta); } @@ -68,6 +71,7 @@ class EMFwdTrack void setPairDcaXYinSigmaOTF(float dca) { fPairDCAXYinSigmaOTF = dca; } protected: + int fDFId; int fGlobalId; int fCollisionId; int fTrackId; @@ -86,12 +90,12 @@ class EMFwdTrack class EMFwdTrackWithCov : public EMFwdTrack { public: - EMFwdTrackWithCov(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 = {}, + 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(globalId, collisionId, trackId, pt, eta, phi, mass, charge, dcaX, dcaY, amb_muon_self_ids) + 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; diff --git a/PWGEM/Dilepton/Utils/EMTrack.h b/PWGEM/Dilepton/Utils/EMTrack.h index 9d0ada11303..0f894d5b4dc 100644 --- a/PWGEM/Dilepton/Utils/EMTrack.h +++ b/PWGEM/Dilepton/Utils/EMTrack.h @@ -16,14 +16,16 @@ #define PWGEM_DILEPTON_UTILS_EMTRACK_H_ #include +#include "Math/Vector4D.h" namespace o2::aod::pwgem::dilepton::utils { class EMTrack { public: - EMTrack(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 = {}) { + fDFId = dfId; fGlobalId = globalId; fCollisionId = collisionId; fTrackId = trackId; @@ -42,10 +44,30 @@ class EMTrack } else { fIsAmbiguous = false; } + fVx = 0.f; + fVy = 0.f; + fVz = 0.f; + fVPos = ROOT::Math::PtEtaPhiMVector(0, 0, 0, 0); + fVNeg = ROOT::Math::PtEtaPhiMVector(0, 0, 0, 0); + fAmbPosLegSelfIds.clear(); + fAmbNegLegSelfIds.clear(); + fAmbPosLegSelfIds.shrink_to_fit(); + fAmbNegLegSelfIds.shrink_to_fit(); + fGlobalPosId = 0; + fGlobalNegId = 0; } - ~EMTrack() {} + ~EMTrack() + { + fAmbEleSelfIds.clear(); + fAmbEleSelfIds.shrink_to_fit(); + fAmbPosLegSelfIds.clear(); + fAmbNegLegSelfIds.clear(); + fAmbPosLegSelfIds.shrink_to_fit(); + fAmbNegLegSelfIds.shrink_to_fit(); + } + int dfId() const { return fDFId; } int globalIndex() const { return fGlobalId; } int collisionId() const { return fCollisionId; } int trackId() const { return fTrackId; } @@ -56,6 +78,7 @@ class EMTrack int8_t sign() const { return fCharge; } float dcaXY() const { return fDCAxy; } float dcaZ() const { return fDCAz; } + float p() const { return fPt * std::cosh(fEta); } float px() const { return fPt * std::cos(fPhi); } float py() const { return fPt * std::sin(fPhi); } float pz() const { return fPt * std::sinh(fEta); } @@ -66,7 +89,49 @@ class EMTrack float pairDca3DinSigmaOTF() const { return fPairDCA3DinSigmaOTF; } void setPairDca3DinSigmaOTF(float dca) { fPairDCA3DinSigmaOTF = dca; } + void setConversionPointXYZ(float x, float y, float z) + { + fVx = x; + fVy = y; + fVz = z; + } + float vx() const { return fVx; } + float vy() const { return fVy; } + float vz() const { return fVz; } + float v0radius() const { return std::sqrt(std::pow(fVx, 2) + std::pow(fVy, 2)); } + float eta_cp() const { return std::atanh(fVz / sqrt(pow(fVx, 2) + pow(fVy, 2) + pow(fVz, 2))); } + float phi_cp() const { return std::atan2(fVy, fVx); } + + void setPositiveLegPtEtaPhiM(float pt, float eta, float phi, float m) + { + fVPos.SetPt(pt); + fVPos.SetEta(eta); + fVPos.SetPhi(phi); + fVPos.SetM(m); + } + void setNegativeLegPtEtaPhiM(float pt, float eta, float phi, float m) + { + fVNeg.SetPt(pt); + fVNeg.SetEta(eta); + fVNeg.SetPhi(phi); + fVNeg.SetM(m); + } + + ROOT::Math::PtEtaPhiMVector getPositiveLeg() const { return fVPos; } + ROOT::Math::PtEtaPhiMVector getNegativeLeg() const { return fVNeg; } + + void setGlobalPosId(int id) { fGlobalPosId = id; } + void setGlobalNegId(int id) { fGlobalNegId = id; } + int globalIndexPos() const { return fGlobalPosId; } + int globalIndexNeg() const { return fGlobalNegId; } + + void setAmbPosLegSelfIds(std::vector selfIds) { fAmbPosLegSelfIds = selfIds; } + void setAmbNegLegSelfIds(std::vector selfIds) { fAmbNegLegSelfIds = selfIds; } + std::vector ambiguousPosLegIds() const { return fAmbPosLegSelfIds; } + std::vector ambiguousNegLegIds() const { return fAmbNegLegSelfIds; } + protected: + int fDFId; int fGlobalId; int fCollisionId; int fTrackId; @@ -80,17 +145,29 @@ class EMTrack float fPairDCA3DinSigmaOTF; bool fIsAmbiguous; std::vector fAmbEleSelfIds; + + int fGlobalPosId; + int fGlobalNegId; + ROOT::Math::PtEtaPhiMVector fVPos; + ROOT::Math::PtEtaPhiMVector fVNeg; + std::vector fAmbPosLegSelfIds; // for dileptons + std::vector fAmbNegLegSelfIds; // for dileptons + + // only for photon conversion point + float fVx; + float fVy; + float fVz; }; class EMTrackWithCov : public EMTrack { public: - EMTrackWithCov(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 = {}, + EMTrackWithCov(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 X = 0.f, float Y = 0.f, float Z = 0.f, float Alpha = 0.f, float Snp = 0.f, float Tgl = 0.f, float CYY = 0.f, float CZY = 0.f, float CZZ = 0.f, float CSnpY = 0.f, float CSnpZ = 0.f, float CSnpSnp = 0.f, float CTglY = 0.f, float CTglZ = 0.f, float CTglSnp = 0.f, float CTglTgl = 0.f, - float C1PtY = 0.f, float C1PtZ = 0.f, float C1PtSnp = 0.f, float C1PtTgl = 0.f, float C1Pt21Pt2 = 0.f) : EMTrack(globalId, collisionId, trackId, pt, eta, phi, mass, charge, dcaXY, dcaZ, amb_ele_self_ids) + float C1PtY = 0.f, float C1PtZ = 0.f, float C1PtSnp = 0.f, float C1PtTgl = 0.f, float C1Pt21Pt2 = 0.f) : EMTrack(dfId, globalId, collisionId, trackId, pt, eta, phi, mass, charge, dcaXY, dcaZ, amb_ele_self_ids) { fX = X; fY = Y; diff --git a/PWGEM/Dilepton/Utils/EMTrackUtilities.h b/PWGEM/Dilepton/Utils/EMTrackUtilities.h index 67830f4eee0..e26e9760bab 100644 --- a/PWGEM/Dilepton/Utils/EMTrackUtilities.h +++ b/PWGEM/Dilepton/Utils/EMTrackUtilities.h @@ -40,6 +40,18 @@ float dca3DinSigma(T const& track) } //_______________________________________________________________________ template +float dcaXYinSigma(T const& track) +{ + return track.dcaXY() / std::sqrt(track.cYY()); +} +//_______________________________________________________________________ +template +float dcaZinSigma(T const& track) +{ + return track.dcaZ() / std::sqrt(track.cZZ()); +} +//_______________________________________________________________________ +template float fwdDcaXYinSigma(T const& track) { float cXX = track.cXX(); @@ -56,6 +68,36 @@ float fwdDcaXYinSigma(T const& track) } } //_______________________________________________________________________ +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 04134c556eb..89609c336f8 100644 --- a/PWGEM/Dilepton/Utils/EventHistograms.h +++ b/PWGEM/Dilepton/Utils/EventHistograms.h @@ -18,20 +18,26 @@ using namespace o2::framework; namespace o2::aod::pwgem::dilepton::utils::eventhistogram { -void addEventHistograms(HistogramRegistry* fRegistry, bool doFlow) +const int nbin_ev = 14; +template +void addEventHistograms(HistogramRegistry* fRegistry) { // event info - auto hCollisionCounter = fRegistry->add("Event/before/hCollisionCounter", "collision counter;;Number of events", kTH1F, {{10, 0.5, 10.5}}, false); + auto hCollisionCounter = fRegistry->add("Event/before/hCollisionCounter", "collision counter;;Number of events", kTH1D, {{nbin_ev, 0.5, nbin_ev + 0.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(2, "FT0AND"); + hCollisionCounter->GetXaxis()->SetBinLabel(3, "No TF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(4, "No ITS ROF border"); + hCollisionCounter->GetXaxis()->SetBinLabel(5, "No Same Bunch Pileup"); 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"); + hCollisionCounter->GetXaxis()->SetBinLabel(7, "Is Vertex ITS-TPC"); + hCollisionCounter->GetXaxis()->SetBinLabel(8, "Is Vertex ITS-TPC-TRD"); + hCollisionCounter->GetXaxis()->SetBinLabel(9, "Is Vertex ITS-TPC-TOF"); + hCollisionCounter->GetXaxis()->SetBinLabel(10, "sel8"); + hCollisionCounter->GetXaxis()->SetBinLabel(11, "|Z_{vtx}| < 10 cm"); + hCollisionCounter->GetXaxis()->SetBinLabel(12, "NoCollInTimeRangeStandard"); + hCollisionCounter->GetXaxis()->SetBinLabel(13, "Calibrated Q vector"); + hCollisionCounter->GetXaxis()->SetBinLabel(14, "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); @@ -40,107 +46,119 @@ void addEventHistograms(HistogramRegistry* fRegistry, bool doFlow) 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, {{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); - - if (doFlow) { - // Q2 - fRegistry->add("Event/before/hQ2xFT0M_CentFT0C", "hQ2xFT0M_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0M}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yFT0M_CentFT0C", "hQ2yFT0M_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0M}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2xFT0A_CentFT0C", "hQ2xFT0A_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0A}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yFT0A_CentFT0C", "hQ2yFT0A_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0A}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2xFT0C_CentFT0C", "hQ2xFT0C_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yFT0C_CentFT0C", "hQ2yFT0C_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2xBPos_CentFT0C", "hQ2xBPos_CentFT0C;centrality FT0C (%);Q_{2,x}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yBPos_CentFT0C", "hQ2yBPos_CentFT0C;centrality FT0C (%);Q_{2,y}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2xBNeg_CentFT0C", "hQ2xBNeg_CentFT0C;centrality FT0C (%);Q_{2,x}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yBNeg_CentFT0C", "hQ2yBNeg_CentFT0C;centrality FT0C (%);Q_{2,y}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2xBTot_CentFT0C", "hQ2xBTot_CentFT0C;centrality FT0C (%);Q_{2,x}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2yBTot_CentFT0C", "hQ2yBTot_CentFT0C;centrality FT0C (%);Q_{2,y}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - - fRegistry->add("Event/before/hEP2FT0M_CentFT0C", "2nd harmonics event plane FT0M;centrality FT0C (%);#Psi_{2}^{FT0M} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP2FT0A_CentFT0C", "2nd harmonics event plane FT0A;centrality FT0C (%);#Psi_{2}^{FT0A} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP2FT0C_CentFT0C", "2nd harmonics event plane FT0C;centrality FT0C (%);#Psi_{2}^{FT0C} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP2BPos_CentFT0C", "2nd harmonics event plane BPos;centrality FT0C (%);#Psi_{2}^{BPos} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP2BNeg_CentFT0C", "2nd harmonics event plane BNeg;centrality FT0C (%);#Psi_{2}^{BNeg} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP2BTot_CentFT0C", "2nd harmonics event plane BTot;centrality FT0C (%);#Psi_{2}^{BTot} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - - fRegistry->add("Event/before/hQ2FT0MQ2BPos_CentFT0C", "Q_{2}^{FT0M} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0M} #upoint Q_{2}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0MQ2BNeg_CentFT0C", "Q_{2}^{FT0M} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0M} #upoint Q_{2}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2BPosQ2BNeg_CentFT0C", "Q_{2}^{BPos} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{BPos} #upoint Q_{2}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); // this is common for FT0M, FT0A, FT0C, FV0A resolution. - fRegistry->add("Event/before/hQ2FT0CQ2BPos_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0CQ2BNeg_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0CQ2BTot_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BTot};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0AQ2BPos_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0AQ2BNeg_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0AQ2BTot_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BTot};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ2FT0AQ2FT0C_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{FT0C};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); // this is necessary for dimuons - - // Q3 - fRegistry->add("Event/before/hQ3xFT0M_CentFT0C", "hQ3xFT0M_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0M}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yFT0M_CentFT0C", "hQ3yFT0M_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0M}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3xFT0A_CentFT0C", "hQ3xFT0A_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0A}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yFT0A_CentFT0C", "hQ3yFT0A_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0A}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3xFT0C_CentFT0C", "hQ3xFT0C_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yFT0C_CentFT0C", "hQ3yFT0C_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3xBPos_CentFT0C", "hQ3xBPos_CentFT0C;centrality FT0C (%);Q_{3,x}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yBPos_CentFT0C", "hQ3yBPos_CentFT0C;centrality FT0C (%);Q_{3,y}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3xBNeg_CentFT0C", "hQ3xBNeg_CentFT0C;centrality FT0C (%);Q_{3,x}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yBNeg_CentFT0C", "hQ3yBNeg_CentFT0C;centrality FT0C (%);Q_{3,y}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3xBTot_CentFT0C", "hQ3xBTot_CentFT0C;centrality FT0C (%);Q_{3,x}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3yBTot_CentFT0C", "hQ3yBTot_CentFT0C;centrality FT0C (%);Q_{3,y}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - - fRegistry->add("Event/before/hEP3FT0M_CentFT0C", "3rd harmonics event plane FT0M;centrality FT0C (%);#Psi_{3}^{FT0M} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP3FT0A_CentFT0C", "3rd harmonics event plane FT0A;centrality FT0C (%);#Psi_{3}^{FT0A} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP3FT0C_CentFT0C", "3rd harmonics event plane FT0C;centrality FT0C (%);#Psi_{3}^{FT0C} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP3BPos_CentFT0C", "3rd harmonics event plane BPos;centrality FT0C (%);#Psi_{3}^{BPos} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP3BNeg_CentFT0C", "3rd harmonics event plane BNeg;centrality FT0C (%);#Psi_{3}^{BNeg} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - fRegistry->add("Event/before/hEP3BTot_CentFT0C", "3rd harmonics event plane BTot;centrality FT0C (%);#Psi_{3}^{BTot} (rad.)", kTH2F, {{110, 0, 110}, {180, -M_PI_2, +M_PI_2}}, false); - - fRegistry->add("Event/before/hQ3FT0MQ3BPos_CentFT0C", "Q_{3}^{FT0M} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0M} #upoint Q_{3}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0MQ3BNeg_CentFT0C", "Q_{3}^{FT0M} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0M} #upoint Q_{3}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3BPosQ3BNeg_CentFT0C", "Q_{3}^{BPos} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{BPos} #upoint Q_{3}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); // this is common for FT0M, FT0A, FT0C, FV0A resolution. - fRegistry->add("Event/before/hQ3FT0CQ3BPos_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0CQ3BNeg_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0CQ3BTot_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BTot};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0AQ3BPos_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BPos}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0AQ3BNeg_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BNeg}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0AQ3BTot_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BTot};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BTot}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); - fRegistry->add("Event/before/hQ3FT0AQ3FT0C_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{FT0C};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{FT0C}", kTH2F, {{110, 0, 110}, {200, -10, +10}}, false); // this is necessary for dimuons + 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/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); + 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/hCorrOccupancy", "occupancy correlation;FT0C occupancy;track occupancy", kTH2F, {{200, 0, 200000}, {200, 0, 20000}}, false); + + if constexpr (nmod == 2) { // Q2 + fRegistry->add("Event/before/hQ2xFT0M_CentFT0C", "hQ2xFT0M_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0M}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yFT0M_CentFT0C", "hQ2yFT0M_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0M}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2xFT0A_CentFT0C", "hQ2xFT0A_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0A}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yFT0A_CentFT0C", "hQ2yFT0A_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0A}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2xFT0C_CentFT0C", "hQ2xFT0C_CentFT0C;centrality FT0C (%);Q_{2,x}^{FT0C}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yFT0C_CentFT0C", "hQ2yFT0C_CentFT0C;centrality FT0C (%);Q_{2,y}^{FT0C}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2xBPos_CentFT0C", "hQ2xBPos_CentFT0C;centrality FT0C (%);Q_{2,x}^{BPos}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yBPos_CentFT0C", "hQ2yBPos_CentFT0C;centrality FT0C (%);Q_{2,y}^{BPos}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2xBNeg_CentFT0C", "hQ2xBNeg_CentFT0C;centrality FT0C (%);Q_{2,x}^{BNeg}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yBNeg_CentFT0C", "hQ2yBNeg_CentFT0C;centrality FT0C (%);Q_{2,y}^{BNeg}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2xBTot_CentFT0C", "hQ2xBTot_CentFT0C;centrality FT0C (%);Q_{2,x}^{BTot}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ2yBTot_CentFT0C", "hQ2yBTot_CentFT0C;centrality FT0C (%);Q_{2,y}^{BTot}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + + fRegistry->add("Event/before/hEP2FT0M_CentFT0C", "2nd harmonics event plane FT0M;centrality FT0C (%);#Psi_{2}^{FT0M} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP2FT0A_CentFT0C", "2nd harmonics event plane FT0A;centrality FT0C (%);#Psi_{2}^{FT0A} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP2FT0C_CentFT0C", "2nd harmonics event plane FT0C;centrality FT0C (%);#Psi_{2}^{FT0C} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP2BPos_CentFT0C", "2nd harmonics event plane BPos;centrality FT0C (%);#Psi_{2}^{BPos} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP2BNeg_CentFT0C", "2nd harmonics event plane BNeg;centrality FT0C (%);#Psi_{2}^{BNeg} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP2BTot_CentFT0C", "2nd harmonics event plane BTot;centrality FT0C (%);#Psi_{2}^{BTot} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + + fRegistry->add("Event/before/hPrfQ2FT0MQ2BPos_CentFT0C", "Q_{2}^{FT0M} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0M} #upoint Q_{2}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0MQ2BNeg_CentFT0C", "Q_{2}^{FT0M} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0M} #upoint Q_{2}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2BPosQ2BNeg_CentFT0C", "Q_{2}^{BPos} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{BPos} #upoint Q_{2}^{BNeg}", kTProfile, {{100, 0, 100}}, false); // this is common for FT0M, FT0A, FT0C, FV0A resolution. + fRegistry->add("Event/before/hPrfQ2FT0CQ2BPos_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0CQ2BNeg_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0CQ2BTot_CentFT0C", "Q_{2}^{FT0C} #upoint Q_{2}^{BTot};centrality FT0C (%);Q_{2}^{FT0C} #upoint Q_{2}^{BTot}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0AQ2BPos_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BPos};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0AQ2BNeg_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BNeg};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0AQ2BTot_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{BTot};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{BTot}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ2FT0AQ2FT0C_CentFT0C", "Q_{2}^{FT0A} #upoint Q_{2}^{FT0C};centrality FT0C (%);Q_{2}^{FT0A} #upoint Q_{2}^{FT0C}", kTProfile, {{100, 0, 100}}, false); // this is necessary for dimuons + } else if constexpr (nmod == 3) { // Q3 + fRegistry->add("Event/before/hQ3xFT0M_CentFT0C", "hQ3xFT0M_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0M}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yFT0M_CentFT0C", "hQ3yFT0M_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0M}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3xFT0A_CentFT0C", "hQ3xFT0A_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0A}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yFT0A_CentFT0C", "hQ3yFT0A_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0A}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3xFT0C_CentFT0C", "hQ3xFT0C_CentFT0C;centrality FT0C (%);Q_{3,x}^{FT0C}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yFT0C_CentFT0C", "hQ3yFT0C_CentFT0C;centrality FT0C (%);Q_{3,y}^{FT0C}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3xBPos_CentFT0C", "hQ3xBPos_CentFT0C;centrality FT0C (%);Q_{3,x}^{BPos}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yBPos_CentFT0C", "hQ3yBPos_CentFT0C;centrality FT0C (%);Q_{3,y}^{BPos}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3xBNeg_CentFT0C", "hQ3xBNeg_CentFT0C;centrality FT0C (%);Q_{3,x}^{BNeg}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yBNeg_CentFT0C", "hQ3yBNeg_CentFT0C;centrality FT0C (%);Q_{3,y}^{BNeg}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3xBTot_CentFT0C", "hQ3xBTot_CentFT0C;centrality FT0C (%);Q_{3,x}^{BTot}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + fRegistry->add("Event/before/hQ3yBTot_CentFT0C", "hQ3yBTot_CentFT0C;centrality FT0C (%);Q_{3,y}^{BTot}", kTH2F, {{100, 0, 100}, {200, -10, +10}}, false); + + fRegistry->add("Event/before/hEP3FT0M_CentFT0C", "3rd harmonics event plane FT0M;centrality FT0C (%);#Psi_{3}^{FT0M} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP3FT0A_CentFT0C", "3rd harmonics event plane FT0A;centrality FT0C (%);#Psi_{3}^{FT0A} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP3FT0C_CentFT0C", "3rd harmonics event plane FT0C;centrality FT0C (%);#Psi_{3}^{FT0C} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP3BPos_CentFT0C", "3rd harmonics event plane BPos;centrality FT0C (%);#Psi_{3}^{BPos} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP3BNeg_CentFT0C", "3rd harmonics event plane BNeg;centrality FT0C (%);#Psi_{3}^{BNeg} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + fRegistry->add("Event/before/hEP3BTot_CentFT0C", "3rd harmonics event plane BTot;centrality FT0C (%);#Psi_{3}^{BTot} (rad.)", kTH2F, {{100, 0, 100}, {36, -M_PI_2, +M_PI_2}}, false); + + fRegistry->add("Event/before/hPrfQ3FT0MQ3BPos_CentFT0C", "Q_{3}^{FT0M} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0M} #upoint Q_{3}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0MQ3BNeg_CentFT0C", "Q_{3}^{FT0M} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0M} #upoint Q_{3}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3BPosQ3BNeg_CentFT0C", "Q_{3}^{BPos} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{BPos} #upoint Q_{3}^{BNeg}", kTProfile, {{100, 0, 100}}, false); // this is common for FT0M, FT0A, FT0C, FV0A resolution. + fRegistry->add("Event/before/hPrfQ3FT0CQ3BPos_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0CQ3BNeg_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0CQ3BTot_CentFT0C", "Q_{3}^{FT0C} #upoint Q_{3}^{BTot};centrality FT0C (%);Q_{3}^{FT0C} #upoint Q_{3}^{BTot}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0AQ3BPos_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BPos};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BPos}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0AQ3BNeg_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BNeg};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BNeg}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0AQ3BTot_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{BTot};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{BTot}", kTProfile, {{100, 0, 100}}, false); + fRegistry->add("Event/before/hPrfQ3FT0AQ3FT0C_CentFT0C", "Q_{3}^{FT0A} #upoint Q_{3}^{FT0C};centrality FT0C (%);Q_{3}^{FT0A} #upoint Q_{3}^{FT0C}", kTProfile, {{100, 0, 100}}, false); // this is necessary for dimuons } fRegistry->addClone("Event/before/", "Event/after/"); } -template -void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, const bool doFlow, const float /*weight*/ = 1.f) +template +void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, const float /*weight*/ = 1.f) { static constexpr std::string_view event_types[2] = {"before/", "after/"}; fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 1.0); - if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 2.0); } - if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 3.0); } - if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 4.0); } - if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 5.0); } if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 6.0); } - if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 7.0); } - if (collision.sel8()) { + if (collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 8.0); } - if (abs(collision.posZ()) < 10.0) { + if (collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 9.0); } + if (collision.sel8()) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 10.0); + } + if (abs(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)) { + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCollisionCounter"), 12.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()); @@ -149,12 +167,16 @@ 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()); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hNTracksPVvsOccupancy"), collision.multNTracksPV(), collision.trackOccupancyInTimeRange()); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hCorrOccupancy"), collision.ft0cOccupancyInTimeRange(), collision.trackOccupancyInTimeRange()); - if (doFlow) { - // Q2 + if constexpr (nmod == 2) { // Q2 std::array q2ft0m = {collision.q2xft0m(), collision.q2yft0m()}; std::array q2ft0a = {collision.q2xft0a(), collision.q2yft0a()}; std::array q2ft0c = {collision.q2xft0c(), collision.q2yft0c()}; @@ -182,18 +204,17 @@ void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, co fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hEP2BNeg_CentFT0C"), collision.centFT0C(), collision.ep2bneg()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hEP2BTot_CentFT0C"), collision.centFT0C(), collision.ep2btot()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0MQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0m, q2bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0MQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0m, q2bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2BPosQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2bpos, q2bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0AQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0AQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0AQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2btot)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0CQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0CQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0CQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2btot)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ2FT0AQ2FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2ft0c)); - - // Q3 + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0MQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0m, q2bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0MQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0m, q2bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2BPosQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2bpos, q2bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0AQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0AQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0AQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2btot)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0CQ2BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0CQ2BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0CQ2BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0c, q2btot)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ2FT0AQ2FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q2ft0a, q2ft0c)); + } else if constexpr (nmod == 3) { // Q3 std::array q3ft0m = {collision.q3xft0m(), collision.q3yft0m()}; std::array q3ft0a = {collision.q3xft0a(), collision.q3yft0a()}; std::array q3ft0c = {collision.q3xft0c(), collision.q3yft0c()}; @@ -221,19 +242,17 @@ void fillEventInfo(HistogramRegistry* fRegistry, TCollision const& collision, co fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hEP3BNeg_CentFT0C"), collision.centFT0C(), collision.ep3bneg()); fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hEP3BTot_CentFT0C"), collision.centFT0C(), collision.ep3btot()); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0MQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0m, q3bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0MQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0m, q3bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3BPosQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3bpos, q3bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0AQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0AQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0AQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3btot)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0CQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3bpos)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0CQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3bneg)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0CQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3btot)); - fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hQ3FT0AQ3FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3ft0c)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0MQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0m, q3bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0MQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0m, q3bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3BPosQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3bpos, q3bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0AQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0AQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0AQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3btot)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0CQ3BPos_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3bpos)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0CQ3BNeg_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3bneg)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0CQ3BTot_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0c, q3btot)); + fRegistry->fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hPrfQ3FT0AQ3FT0C_CentFT0C"), collision.centFT0C(), RecoDecay::dotProd(q3ft0a, q3ft0c)); } } - } // namespace o2::aod::pwgem::dilepton::utils::eventhistogram - #endif // PWGEM_DILEPTON_UTILS_EVENTHISTOGRAMS_H_ diff --git a/PWGEM/Dilepton/Utils/MCUtilities.h b/PWGEM/Dilepton/Utils/MCUtilities.h index e7eabd8a43c..668f1056e75 100644 --- a/PWGEM/Dilepton/Utils/MCUtilities.h +++ b/PWGEM/Dilepton/Utils/MCUtilities.h @@ -31,6 +31,63 @@ enum class EM_HFeeType : int { kBCe_Be_DiffB = 4, // LS }; +//_______________________________________________________________________ +template +int FindCommonMotherFrom2ProngsWithoutPDG(TMCParticle1 const& p1, TMCParticle2 const& p2) +{ + if (p1.globalIndex() == p2.globalIndex()) + return -1; // mc particle p1 and p2 is identical. reject. + + if (!p1.has_mothers()) + return -1; + if (!p2.has_mothers()) + return -1; + + // LOGF(info,"original motherid1 = %d , motherid2 = %d", p1.mothersIds()[0], p2.mothersIds()[0]); + + int motherid1 = p1.mothersIds()[0]; + int motherid2 = p2.mothersIds()[0]; + + // LOGF(info,"motherid1 = %d , motherid2 = %d", motherid1, motherid2); + + if (motherid1 != motherid2) + return -1; + return motherid1; +} +//_______________________________________________________________________ +template +int FindCommonMotherFrom3ProngsWithoutPDG(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticle3 const& p3) +{ + if (p1.globalIndex() == p2.globalIndex()) + return -1; // mc particle p1 and p2 are identical. reject. + if (p2.globalIndex() == p3.globalIndex()) + return -1; // mc particle p2 and p3 are identical. reject. + if (p3.globalIndex() == p1.globalIndex()) + return -1; // mc particle p3 and p1 are identical. reject. + + if (!p1.has_mothers()) + return -1; + if (!p2.has_mothers()) + return -1; + if (!p3.has_mothers()) + return -1; + + // LOGF(info,"original motherid1 = %d , motherid2 = %d", p1.mothersIds()[0], p2.mothersIds()[0]); + + int motherid1 = p1.mothersIds()[0]; + int motherid2 = p2.mothersIds()[0]; + int motherid3 = p3.mothersIds()[0]; + + // LOGF(info,"motherid1 = %d , motherid2 = %d", motherid1, motherid2); + + if (motherid1 != motherid2) + return -1; + if (motherid2 != motherid3) + return -1; + if (motherid3 != motherid1) + return -1; + return motherid1; +} //_______________________________________________________________________ template int FindCommonMotherFrom2Prongs(TMCParticle1 const& p1, TMCParticle2 const& p2, const int expected_pdg1, const int expected_pdg2, const int expected_mother_pdg, TMCParticles const& mcparticles) @@ -136,6 +193,11 @@ int IsFromBeauty(TMCParticle const& p, TMCParticles const& mcparticles) } int motherid = p.mothersIds()[0]; // first mother index + auto mp_tmp = mcparticles.iteratorAt(motherid); + if (abs(mp_tmp.pdgCode()) < 1e+9 && (std::to_string(abs(mp_tmp.pdgCode()))[std::to_string(abs(mp_tmp.pdgCode())).length() - 2] == '5' && std::to_string(abs(mp_tmp.pdgCode()))[std::to_string(abs(mp_tmp.pdgCode())).length() - 3] == '5') && abs(mp_tmp.pdgCode()) % 2 == 1) { + return -999; // reject bottomonia + } + while (motherid > -1) { if (motherid < mcparticles.size()) { // protect against bad mother indices. why is this needed? auto mp = mcparticles.iteratorAt(motherid); @@ -163,6 +225,10 @@ int IsFromCharm(TMCParticle const& p, TMCParticles const& mcparticles) } int motherid = p.mothersIds()[0]; // first mother index + auto mp_tmp = mcparticles.iteratorAt(motherid); + if (abs(mp_tmp.pdgCode()) < 1e+9 && (std::to_string(abs(mp_tmp.pdgCode()))[std::to_string(abs(mp_tmp.pdgCode())).length() - 2] == '4' && std::to_string(abs(mp_tmp.pdgCode()))[std::to_string(abs(mp_tmp.pdgCode())).length() - 3] == '4') && abs(mp_tmp.pdgCode()) % 2 == 1) { + return -999; // reject bottomonia + } while (motherid > -1) { if (motherid < mcparticles.size()) { // protect against bad mother indices. why is this needed? auto mp = mcparticles.iteratorAt(motherid); @@ -233,14 +299,14 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp } } - bool is_direct_from_b1 = abs(mothers_pdg1[0]) < 1e+9 && (std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 3] == '5' || std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 4] == '5'); - bool is_direct_from_b2 = abs(mothers_pdg2[0]) < 1e+9 && (std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 3] == '5' || std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 4] == '5'); - bool is_prompt_c1 = abs(mothers_pdg1[0]) < 1e+9 && (std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 3] == '4' || std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 4] == '4') && IsFromBeauty(p1, mcparticles) < 0; - bool is_prompt_c2 = abs(mothers_pdg2[0]) < 1e+9 && (std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 3] == '4' || std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 4] == '4') && IsFromBeauty(p2, mcparticles) < 0; - bool is_c_from_b1 = abs(mothers_pdg1[0]) < 1e+9 && (std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 3] == '4' || std::to_string(mothers_pdg1[0])[std::to_string(mothers_pdg1[0]).length() - 4] == '4') && IsFromBeauty(p1, mcparticles) > 0; - bool is_c_from_b2 = abs(mothers_pdg2[0]) < 1e+9 && (std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 3] == '4' || std::to_string(mothers_pdg2[0])[std::to_string(mothers_pdg2[0]).length() - 4] == '4') && IsFromBeauty(p2, mcparticles) > 0; + bool is_direct_from_b1 = IsFromBeauty(p1, mcparticles) > 0 && IsFromCharm(p1, mcparticles) < 0; + bool is_direct_from_b2 = IsFromBeauty(p2, mcparticles) > 0 && IsFromCharm(p2, mcparticles) < 0; + bool is_prompt_c1 = IsFromBeauty(p1, mcparticles) < 0 && IsFromCharm(p1, mcparticles) > 0; + bool is_prompt_c2 = IsFromBeauty(p2, mcparticles) < 0 && IsFromCharm(p2, mcparticles) > 0; + bool is_c_from_b1 = IsFromBeauty(p1, mcparticles) > 0 && IsFromCharm(p1, mcparticles) > 0; + bool is_c_from_b2 = IsFromBeauty(p2, mcparticles) > 0 && IsFromCharm(p2, mcparticles) > 0; - if (is_prompt_c1 && is_prompt_c2 && p1.pdgCode() * p2.pdgCode() < 0) { + if (is_direct_from_b1 && is_direct_from_b2 && p1.pdgCode() * p2.pdgCode() < 0) { mothers_id1.clear(); mothers_pdg1.clear(); mothers_id2.clear(); @@ -249,8 +315,9 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp mothers_pdg1.shrink_to_fit(); mothers_id2.shrink_to_fit(); mothers_pdg2.shrink_to_fit(); - return static_cast(EM_HFeeType::kCe_Ce); // cc->ee, decay type = 0 - } else if (is_direct_from_b1 && is_direct_from_b2 && p1.pdgCode() * p2.pdgCode() < 0) { + return static_cast(EM_HFeeType::kBe_Be); // bb->ee, decay type = 2 + } + if (is_prompt_c1 && is_prompt_c2 && p1.pdgCode() * p2.pdgCode() < 0) { mothers_id1.clear(); mothers_pdg1.clear(); mothers_id2.clear(); @@ -259,8 +326,9 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp mothers_pdg1.shrink_to_fit(); mothers_id2.shrink_to_fit(); mothers_pdg2.shrink_to_fit(); - return static_cast(EM_HFeeType::kBe_Be); // bb->ee, decay type = 2 - } else if (is_c_from_b1 && is_c_from_b2 && p1.pdgCode() * p2.pdgCode() < 0) { + return static_cast(EM_HFeeType::kCe_Ce); // cc->ee, decay type = 0 + } + if (is_c_from_b1 && is_c_from_b2 && p1.pdgCode() * p2.pdgCode() < 0) { mothers_id1.clear(); mothers_pdg1.clear(); mothers_id2.clear(); @@ -270,7 +338,8 @@ int IsHF(TMCParticle1 const& p1, TMCParticle2 const& p2, TMCParticles const& mcp mothers_id2.shrink_to_fit(); mothers_pdg2.shrink_to_fit(); return static_cast(EM_HFeeType::kBCe_BCe); // b->c->e and b->c->e, decay type = 1 - } else if ((is_direct_from_b1 && is_c_from_b2) || (is_direct_from_b2 && is_c_from_b1)) { + } + if ((is_direct_from_b1 && is_c_from_b2) || (is_direct_from_b2 && is_c_from_b1)) { if (p1.pdgCode() * p2.pdgCode() < 0) { // ULS for (auto& mid1 : mothers_id1) { for (auto& mid2 : mothers_id2) { diff --git a/PWGEM/Dilepton/Utils/MlResponseDielectronPair.h b/PWGEM/Dilepton/Utils/MlResponseDielectronPair.h deleted file mode 100644 index 40f97b67937..00000000000 --- a/PWGEM/Dilepton/Utils/MlResponseDielectronPair.h +++ /dev/null @@ -1,238 +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 MlResponseDiletponPair.h -/// \brief Class to compute the ML response for dielectron analyses at the pair level -/// \author Daniel Samitz , SMI Vienna -/// Elisa Meninno, , SMI Vienna - -#ifndef PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONPAIR_H_ -#define PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONPAIR_H_ - -#include -#include -#include - -#include "Math/Vector4D.h" -#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 -#define FILL_MAP_DIELECTRON_PAIR(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesDielectronPair::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 pair fourmomentum v12 -#define CHECK_AND_FILL_VEC_DIELECTRON_PAIR(FEATURE, GETTER) \ - case static_cast(InputFeaturesDielectronPair::FEATURE): { \ - inputFeatures.emplace_back(v12.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 FUNCTION on the tracks t1 and t2 -#define CHECK_AND_FILL_VEC_DIELECTRON_PAIR_FUNC(FEATURE, FUNCTION) \ - case static_cast(InputFeaturesDielectronPair::FEATURE): { \ - inputFeatures.emplace_back(FUNCTION(t1, t2)); \ - break; \ - } - -namespace o2::analysis -{ -// possible input features for ML -enum class InputFeaturesDielectronPair : uint8_t { - m, - pt, - eta, - phi, - phiv, - pairDcaXY, - pairDcaZ -}; - -template -class MlResponseDielectronPair : public MlResponse -{ - public: - /// Default constructor - MlResponseDielectronPair() = default; - /// Default destructor - virtual ~MlResponseDielectronPair() = default; - - template - float pair_dca_xy(T const& t1, T const& t2) - { - return sqrt((pow(t1.dcaXY() / sqrt(t1.cYY()), 2) + pow(t2.dcaXY() / sqrt(t2.cYY()), 2)) / 2.); - } - - template - float pair_dca_z(T const& t1, T const& t2) - { - return sqrt((pow(t1.dcaZ() / sqrt(t1.cZZ()), 2) + pow(t2.dcaZ() / sqrt(t2.cZZ()), 2)) / 2.); - } - - template - float get_phiv(T const& t1, T const& t2) - { - // cos(phiv) = w*a /|w||a| - // with w = u x v - // and a = u x z / |u x z| , unit vector perpendicular to v12 and z-direction (magnetic field) - // u = v12 / |v12| , the unit vector of v12 - // v = v1 x v2 / |v1 x v2| , unit vector perpendicular to v1 and v2 - - 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; - - bool swapTracks = false; - if (v1.Pt() < v2.Pt()) { // ordering of track, pt1 > pt2 - ROOT::Math::PtEtaPhiMVector v3 = v1; - v1 = v2; - v2 = v3; - swapTracks = true; - } - - // momentum of e+ and e- in (ax,ay,az) axis. Note that az=0 by definition. - // vector product of pep X pem - float vpx = 0, vpy = 0, vpz = 0; - if (t1.sign() * t2.sign() > 0) { // Like Sign - if (!swapTracks) { - if (d_bz * t1.sign() < 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } else { // swaped tracks - if (d_bz * t2.sign() < 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } - } else { // Unlike Sign - if (!swapTracks) { - if (d_bz * t1.sign() > 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } else { // swaped tracks - if (d_bz * t2.sign() > 0) { - vpx = v1.Py() * v2.Pz() - v1.Pz() * v2.Py(); - vpy = v1.Pz() * v2.Px() - v1.Px() * v2.Pz(); - vpz = v1.Px() * v2.Py() - v1.Py() * v2.Px(); - } else { - vpx = v2.Py() * v1.Pz() - v2.Pz() * v1.Py(); - vpy = v2.Pz() * v1.Px() - v2.Px() * v1.Pz(); - vpz = v2.Px() * v1.Py() - v2.Py() * v1.Px(); - } - } - } - - // unit vector of pep X pem - float vx = vpx / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - float vy = vpy / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - float vz = vpz / TMath::Sqrt(vpx * vpx + vpy * vpy + vpz * vpz); - - float px = v12.Px(); - float py = v12.Py(); - float pz = v12.Pz(); - - // unit vector of (pep+pem) - float ux = px / TMath::Sqrt(px * px + py * py + pz * pz); - float uy = py / TMath::Sqrt(px * px + py * py + pz * pz); - float uz = pz / TMath::Sqrt(px * px + py * py + pz * pz); - float ax = uy / TMath::Sqrt(ux * ux + uy * uy); - float ay = -ux / TMath::Sqrt(ux * ux + uy * uy); - - // The third axis defined by vector product (ux,uy,uz)X(vx,vy,vz) - float wx = uy * vz - uz * vy; - float wy = uz * vx - ux * vz; - // by construction, (wx,wy,wz) must be a unit vector. Measure angle between (wx,wy,wz) and (ax,ay,0). - // The angle between them should be small if the pair is conversion. This function then returns values close to pi! - return TMath::ACos(wx * ax + wy * ay); // phiv in [0,pi] //cosPhiV = wx * ax + wy * ay; - } - - /// Method to get the input features vector needed for ML inference - /// \param t1 is the first track - /// \param t2 is the second track - /// \return inputFeatures vector - template - std::vector getInputFeatures(T const& t1, T const& t2) - { - std::vector inputFeatures; - 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; - - for (const auto& idx : MlResponse::mCachedIndices) { - switch (idx) { - CHECK_AND_FILL_VEC_DIELECTRON_PAIR(m, M); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR(pt, Pt); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR(eta, Eta); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR(phi, Phi); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR_FUNC(phiv, get_phiv); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR_FUNC(pairDcaXY, pair_dca_xy); - CHECK_AND_FILL_VEC_DIELECTRON_PAIR_FUNC(pairDcaZ, pair_dca_z); - } - } - - return inputFeatures; - } - - void setBz(float bz) - { - d_bz = bz; - } - - protected: - /// Method to fill the map of available input features - void setAvailableInputFeatures() - { - MlResponse::mAvailableInputFeatures = { - FILL_MAP_DIELECTRON_PAIR(m), - FILL_MAP_DIELECTRON_PAIR(pt), - FILL_MAP_DIELECTRON_PAIR(eta), - FILL_MAP_DIELECTRON_PAIR(phi), - FILL_MAP_DIELECTRON_PAIR(phiv), - FILL_MAP_DIELECTRON_PAIR(pairDcaXY), - FILL_MAP_DIELECTRON_PAIR(pairDcaZ)}; - } - - float d_bz = 0.; -}; - -} // namespace o2::analysis - -#undef FILL_MAP_DIELECTRON_PAIR -#undef CHECK_AND_FILL_VEC_DIELECTRON_PAIR -#undef CHECK_AND_FILL_VEC_DIELECTRON_PAIR_FUNC - -#endif // PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONPAIR_H_ diff --git a/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h b/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h index d7217bb49d8..ef1c7b33474 100644 --- a/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h +++ b/PWGEM/Dilepton/Utils/MlResponseDielectronSingleTrack.h @@ -26,31 +26,66 @@ // 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_DIELECTRON_SINGLE_TRACK(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesDielectronSingleTrack::FEATURE) \ +#define FILL_MAP_DIELECTRON_SINGLE_TRACK(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesDielectronSingleTrack::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_VEC_DIELECTRON_SINGLE_TRACK(GETTER) \ +#define CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(GETTER) \ case static_cast(InputFeaturesDielectronSingleTrack::GETTER): { \ - inputFeatures.emplace_back(track.GETTER()); \ + inputFeature = track.GETTER(); \ break; \ } +// TPC+TOF combined nSigma +#define CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_TPCTOF(FEATURE, GETTER1, GETTER2, GETTER3) \ + case static_cast(InputFeaturesDielectronSingleTrack::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 form track and applying a sqrt -#define CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK_SQRT(FEATURE, GETTER) \ +// by calling the corresponding GETTER from track and applying a sqrt +#define CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_SQRT(FEATURE, GETTER) \ case static_cast(InputFeaturesDielectronSingleTrack::FEATURE): { \ - inputFeatures.emplace_back(sqrt(track.GETTER())); \ + 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_DIELECTRON_SINGLE_TRACK_COS(FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesDielectronSingleTrack::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 GETTER=FEATURE from collision +#define CHECK_AND_FILL_DIELECTRON_COLLISION(GETTER) \ + case static_cast(InputFeaturesDielectronSingleTrack::GETTER): { \ + inputFeature = collision.GETTER(); \ + break; \ + } + namespace o2::analysis { // possible input features for ML @@ -64,8 +99,9 @@ enum class InputFeaturesDielectronSingleTrack : uint8_t { dcaResXY, dcaResZ, tpcNClsFindable, - tpcNClsFound, - tpcNClsCrossedRows, + tpcNClsFindableMinusFound, + tpcNClsFindableMinusCrossedRows, + tpcNClsShared, tpcChi2NCl, tpcInnerParam, tpcSignal, @@ -80,8 +116,85 @@ enum class InputFeaturesDielectronSingleTrack : uint8_t { tofNSigmaPi, tofNSigmaKa, tofNSigmaPr, + tpctofNSigmaEl, + tpctofNSigmaMu, + tpctofNSigmaPi, + tpctofNSigmaKa, + tpctofNSigmaPr, + itsClusterSizes, + itsChi2NCl, + tofChi2, + detectorMap, + x, + alpha, + y, + z, + snp, + tgl, + isAssociatedToMPC, + tpcNClsFound, + tpcNClsCrossedRows, + tpcCrossedRowsOverFindableCls, + tpcFoundOverFindableCls, + tpcFractionSharedCls, itsClusterMap, - itsChi2NCl + itsNCls, + itsNClsInnerBarrel, + hasITS, + hasTPC, + hasTRD, + hasTOF, + signed1Pt, + p, + px, + py, + pz, + theta, + meanClusterSizeITS, + meanClusterSizeITSib, + meanClusterSizeITSob, + meanClusterSizeITSCos, + meanClusterSizeITSibCos, + meanClusterSizeITSobCos, + cYY, + cZY, + cZZ, + cSnpY, + cSnpZ, + cSnpSnp, + cTglY, + cTglZ, + cTglSnp, + cTglTgl, + c1PtY, + c1PtZ, + c1PtSnp, + c1PtTgl, + c1Pt21Pt2, + posX, + posY, + posZ, + numContrib, + trackOccupancyInTimeRange, + ft0cOccupancyInTimeRange, + // covXX, + // covXY, + // covXZ, + // covYY, + // covYZ, + // covZZ, + // chi2, + multFT0A, + multFT0C, + multNTracksPV, + multNTracksPVeta1, + multNTracksPVetaHalf, + isInelGt0, + isInelGt1, + multFT0M, + centFT0M, + centFT0A, + centFT0C }; template @@ -93,49 +206,153 @@ class MlResponseDielectronSingleTrack : public MlResponse /// Default destructor virtual ~MlResponseDielectronSingleTrack() = default; + template + float return_feature(uint8_t idx, T const& track, U const& collision) + { + float inputFeature = 0.; + switch (idx) { + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(sign); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(pt); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(eta); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(phi); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(dcaXY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(dcaZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_SQRT(dcaResXY, cYY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_SQRT(dcaResZ, cZZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsFindable); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsFindableMinusFound); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsFindableMinusCrossedRows); + 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(tpcSignal); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNSigmaEl); + 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(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(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); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(itsClusterSizes); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(itsChi2NCl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tofChi2); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(detectorMap); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(x); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(alpha); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(y); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(z); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(snp); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(isAssociatedToMPC); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsFound); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcNClsCrossedRows); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcCrossedRowsOverFindableCls); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcFoundOverFindableCls); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(tpcFractionSharedCls); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(itsClusterMap); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(itsNCls); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(itsNClsInnerBarrel); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(hasITS); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(hasTPC); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(hasTRD); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(hasTOF); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(signed1Pt); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(p); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(px); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(py); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(pz); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(theta); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(meanClusterSizeITS); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSib); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSob); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_COS(meanClusterSizeITSCos, meanClusterSizeITS, tgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_COS(meanClusterSizeITSibCos, meanClusterSizeITSib, tgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK_COS(meanClusterSizeITSobCos, meanClusterSizeITSob, tgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cYY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cZY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cZZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cSnpY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cSnpZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cSnpSnp); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cTglY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cTglZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cTglSnp); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(cTglTgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(c1PtY); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(c1PtZ); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(c1PtSnp); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(c1PtTgl); + CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK(c1Pt21Pt2); + CHECK_AND_FILL_DIELECTRON_COLLISION(posX); + CHECK_AND_FILL_DIELECTRON_COLLISION(posY); + CHECK_AND_FILL_DIELECTRON_COLLISION(posZ); + CHECK_AND_FILL_DIELECTRON_COLLISION(numContrib); + CHECK_AND_FILL_DIELECTRON_COLLISION(trackOccupancyInTimeRange); + CHECK_AND_FILL_DIELECTRON_COLLISION(ft0cOccupancyInTimeRange); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covXX); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covXY); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covXZ); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covYY); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covYZ); + // CHECK_AND_FILL_DIELECTRON_COLLISION(covZZ); + // CHECK_AND_FILL_DIELECTRON_COLLISION(chi2); + CHECK_AND_FILL_DIELECTRON_COLLISION(multFT0A); + CHECK_AND_FILL_DIELECTRON_COLLISION(multFT0C); + CHECK_AND_FILL_DIELECTRON_COLLISION(multNTracksPV); + CHECK_AND_FILL_DIELECTRON_COLLISION(multNTracksPVeta1); + CHECK_AND_FILL_DIELECTRON_COLLISION(multNTracksPVetaHalf); + CHECK_AND_FILL_DIELECTRON_COLLISION(isInelGt0); + CHECK_AND_FILL_DIELECTRON_COLLISION(isInelGt1); + CHECK_AND_FILL_DIELECTRON_COLLISION(multFT0M); + CHECK_AND_FILL_DIELECTRON_COLLISION(centFT0M); + CHECK_AND_FILL_DIELECTRON_COLLISION(centFT0A); + CHECK_AND_FILL_DIELECTRON_COLLISION(centFT0C); + } + return inputFeature; + } + /// Method to get the input features vector needed for ML inference - /// \param track is the single track + /// \param track is the single track, \param collision is the collision /// \return inputFeatures vector - template - std::vector getInputFeatures(T const& track) + template + std::vector getInputFeatures(T const& track, U const& collision) { std::vector inputFeatures; - for (const auto& idx : MlResponse::mCachedIndices) { - switch (idx) { - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(sign); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(pt); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(eta); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(phi); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(dcaXY); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(dcaZ); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK_SQRT(dcaResXY, cYY); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK_SQRT(dcaResZ, cZZ); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNClsFindable); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNClsFound); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNClsCrossedRows); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcChi2NCl); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcInnerParam); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcSignal); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNSigmaEl); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNSigmaMu); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNSigmaPi); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNSigmaKa); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tpcNSigmaPr); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(beta); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tofNSigmaEl); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tofNSigmaMu); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tofNSigmaPi); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tofNSigmaKa); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(tofNSigmaPr); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(itsClusterMap); - CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK(itsChi2NCl); - } + float inputFeature = return_feature(idx, track, 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& collision) + { + return return_feature(mCachedIndexBinning, track, 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() @@ -150,8 +367,9 @@ class MlResponseDielectronSingleTrack : public MlResponse FILL_MAP_DIELECTRON_SINGLE_TRACK(dcaResXY), FILL_MAP_DIELECTRON_SINGLE_TRACK(dcaResZ), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsFindable), - FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsFound), - FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsCrossedRows), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsFindableMinusFound), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsFindableMinusCrossedRows), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsShared), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcChi2NCl), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcInnerParam), FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcSignal), @@ -166,15 +384,97 @@ class MlResponseDielectronSingleTrack : public MlResponse 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(tpctofNSigmaPi), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaKa), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpctofNSigmaPr), + FILL_MAP_DIELECTRON_SINGLE_TRACK(itsClusterSizes), + FILL_MAP_DIELECTRON_SINGLE_TRACK(itsChi2NCl), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tofChi2), + FILL_MAP_DIELECTRON_SINGLE_TRACK(detectorMap), + FILL_MAP_DIELECTRON_SINGLE_TRACK(x), + FILL_MAP_DIELECTRON_SINGLE_TRACK(alpha), + FILL_MAP_DIELECTRON_SINGLE_TRACK(y), + FILL_MAP_DIELECTRON_SINGLE_TRACK(z), + FILL_MAP_DIELECTRON_SINGLE_TRACK(snp), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tgl), + FILL_MAP_DIELECTRON_SINGLE_TRACK(isAssociatedToMPC), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsFound), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcNClsCrossedRows), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcCrossedRowsOverFindableCls), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcFoundOverFindableCls), + FILL_MAP_DIELECTRON_SINGLE_TRACK(tpcFractionSharedCls), FILL_MAP_DIELECTRON_SINGLE_TRACK(itsClusterMap), - FILL_MAP_DIELECTRON_SINGLE_TRACK(itsChi2NCl)}; + FILL_MAP_DIELECTRON_SINGLE_TRACK(itsNCls), + FILL_MAP_DIELECTRON_SINGLE_TRACK(itsNClsInnerBarrel), + FILL_MAP_DIELECTRON_SINGLE_TRACK(hasITS), + FILL_MAP_DIELECTRON_SINGLE_TRACK(hasTPC), + FILL_MAP_DIELECTRON_SINGLE_TRACK(hasTRD), + FILL_MAP_DIELECTRON_SINGLE_TRACK(hasTOF), + FILL_MAP_DIELECTRON_SINGLE_TRACK(signed1Pt), + FILL_MAP_DIELECTRON_SINGLE_TRACK(p), + FILL_MAP_DIELECTRON_SINGLE_TRACK(px), + FILL_MAP_DIELECTRON_SINGLE_TRACK(py), + FILL_MAP_DIELECTRON_SINGLE_TRACK(pz), + FILL_MAP_DIELECTRON_SINGLE_TRACK(theta), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITS), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSib), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSob), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSCos), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSibCos), + FILL_MAP_DIELECTRON_SINGLE_TRACK(meanClusterSizeITSobCos), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cYY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cZY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cZZ), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cSnpY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cSnpZ), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cSnpSnp), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cTglY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cTglZ), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cTglSnp), + FILL_MAP_DIELECTRON_SINGLE_TRACK(cTglTgl), + FILL_MAP_DIELECTRON_SINGLE_TRACK(c1PtY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(c1PtZ), + FILL_MAP_DIELECTRON_SINGLE_TRACK(c1PtSnp), + FILL_MAP_DIELECTRON_SINGLE_TRACK(c1PtTgl), + FILL_MAP_DIELECTRON_SINGLE_TRACK(c1Pt21Pt2), + FILL_MAP_DIELECTRON_SINGLE_TRACK(posX), + FILL_MAP_DIELECTRON_SINGLE_TRACK(posY), + FILL_MAP_DIELECTRON_SINGLE_TRACK(posZ), + FILL_MAP_DIELECTRON_SINGLE_TRACK(numContrib), + FILL_MAP_DIELECTRON_SINGLE_TRACK(trackOccupancyInTimeRange), + FILL_MAP_DIELECTRON_SINGLE_TRACK(ft0cOccupancyInTimeRange), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covXX), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covXY), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covXZ), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covYY), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covYZ), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(covZZ), + // FILL_MAP_DIELECTRON_SINGLE_TRACK(chi2), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multFT0A), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multFT0C), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multNTracksPV), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multNTracksPVeta1), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multNTracksPVetaHalf), + FILL_MAP_DIELECTRON_SINGLE_TRACK(isInelGt0), + FILL_MAP_DIELECTRON_SINGLE_TRACK(isInelGt1), + FILL_MAP_DIELECTRON_SINGLE_TRACK(multFT0M), + FILL_MAP_DIELECTRON_SINGLE_TRACK(centFT0M), + FILL_MAP_DIELECTRON_SINGLE_TRACK(centFT0A), + FILL_MAP_DIELECTRON_SINGLE_TRACK(centFT0C)}; } + + uint8_t mCachedIndexBinning; // index correspondance between configurable and available input features }; } // namespace o2::analysis #undef FILL_MAP_DIELECTRON_SINGLE_TRACK -#undef CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK -#undef CHECK_AND_FILL_VEC_DIELECTRON_SINGLE_TRACK_SQRT +#undef CHECK_AND_FILL_DIELECTRON_SINGLE_TRACK +#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_COLLISION #endif // PWGEM_DILEPTON_UTILS_MLRESPONSEDIELECTRONSINGLETRACK_H_ diff --git a/PWGEM/Dilepton/Utils/MomentumSmearer.h b/PWGEM/Dilepton/Utils/MomentumSmearer.h index e126ba70fa1..002e7d6d247 100644 --- a/PWGEM/Dilepton/Utils/MomentumSmearer.h +++ b/PWGEM/Dilepton/Utils/MomentumSmearer.h @@ -18,10 +18,10 @@ #include #include #include -#include #include #include #include +#include #include "Framework/Logger.h" using namespace o2::framework; @@ -41,21 +41,40 @@ class MomentumSmearer setResEtaHistName(resEtaHistName); setResPhiPosHistName(resPhiPosHistName); setResPhiNegHistName(resPhiNegHistName); - setResPhiNegHistName(""); - setResPhiNegHistName(""); + setEffFileName(""); + setEffHistName(""); + setDCAFileName(""); + setDCAHistName(""); init(); } /// Constructor with resolution histograms and efficiency - MomentumSmearer(TString resFileName, TString resPtHistName, TString resEtaHistName, TString resPhiPosHistName, TString resPhiNegHistName, TString /*effFileName*/, TString /*effHistName*/) + MomentumSmearer(TString resFileName, TString resPtHistName, TString resEtaHistName, TString resPhiPosHistName, TString resPhiNegHistName, TString effFileName, TString effHistName) { setResFileName(resFileName); setResPtHistName(resPtHistName); setResEtaHistName(resEtaHistName); setResPhiPosHistName(resPhiPosHistName); setResPhiNegHistName(resPhiNegHistName); + setEffFileName(effFileName); + setEffHistName(effHistName); + setDCAFileName(""); + setDCAHistName(""); + init(); + } + + /// Constructor with resolution histograms and efficiency and dca + MomentumSmearer(TString resFileName, TString resPtHistName, TString resEtaHistName, TString resPhiPosHistName, TString resPhiNegHistName, TString effFileName, TString effHistName, TString dcaFileName, TString dcaHistName) + { + setResFileName(resFileName); + setResPtHistName(resPtHistName); + setResEtaHistName(resEtaHistName); + setResPhiPosHistName(resPhiPosHistName); setResPhiNegHistName(resPhiNegHistName); - setResPhiNegHistName(resPhiNegHistName); + setEffFileName(effFileName); + setEffHistName(effHistName); + setDCAFileName(dcaFileName); + setDCAHistName(dcaHistName); init(); } @@ -66,38 +85,42 @@ class MomentumSmearer void getResolutionHistos(TList* list) { - fArrResoPt = reinterpret_cast(list->FindObject(fResPtHistName)); - if (!fArrResoPt) { + fResoPt = reinterpret_cast(list->FindObject(fResPtHistName)); + if (!fResoPt) { LOGP(fatal, "Could not open {} from file {}", fResPtHistName.Data(), fResFileName.Data()); } - fArrResoEta = reinterpret_cast(list->FindObject(fResEtaHistName)); - if (!fArrResoEta) { + fResoEta = reinterpret_cast(list->FindObject(fResEtaHistName)); + if (!fResoEta) { LOGP(fatal, "Could not open {} from file {}", fResEtaHistName.Data(), fResFileName.Data()); } - fArrResoPhi_Pos = reinterpret_cast(list->FindObject(fResPhiPosHistName)); - if (!fArrResoPhi_Pos) { + fResoPhi_Pos = reinterpret_cast(list->FindObject(fResPhiPosHistName)); + if (!fResoPhi_Pos) { LOGP(fatal, "Could not open {} from file {}", fResPhiPosHistName.Data(), fResFileName.Data()); } - fArrResoPhi_Neg = reinterpret_cast(list->FindObject(fResPhiNegHistName)); - if (!fArrResoPhi_Neg) { + fResoPhi_Neg = reinterpret_cast(list->FindObject(fResPhiNegHistName)); + if (!fResoPhi_Neg) { LOGP(fatal, "Could not open {} from file {}", fResPhiNegHistName.Data(), fResFileName.Data()); } } - /*template - void getEfficiencyHistos(T dir){ - - }*/ + void fillVecReso(TH2F* fReso, std::vector& fVecReso) + { + TAxis* axisPt = fReso->GetXaxis(); + int nBinsPt = axisPt->GetNbins(); + for (int i = 1; i <= nBinsPt; i++) { + fVecReso.push_back(reinterpret_cast(fReso->ProjectionY("", i, i))); + } + } void init() { if (fInitialized) return; - if ((fResFileName.BeginsWith("alien://") || fEffFileName.BeginsWith("alien://")) && (!fFromCcdb)) { + if ((fResFileName.BeginsWith("alien://") || fEffFileName.BeginsWith("alien://") || fDCAFileName.BeginsWith("alien://")) && (!fFromCcdb)) { TGrid::Connect("alien://"); } @@ -134,27 +157,33 @@ class MomentumSmearer } } if (fResType != 0) { - fArrResoPt = reinterpret_cast(listRes->FindObject(fResPtHistName)); - if (!fArrResoPt) { + fResoPt = reinterpret_cast(listRes->FindObject(fResPtHistName)); + if (!fResoPt) { LOGP(fatal, "Could not open {} from file {}", fResPtHistName.Data(), fResFileName.Data()); } - fArrResoEta = reinterpret_cast(listRes->FindObject(fResEtaHistName)); - if (!fArrResoEta) { + fResoEta = reinterpret_cast(listRes->FindObject(fResEtaHistName)); + if (!fResoEta) { LOGP(fatal, "Could not open {} from file {}", fResEtaHistName.Data(), fResFileName.Data()); } - fArrResoPhi_Pos = reinterpret_cast(listRes->FindObject(fResPhiPosHistName)); - if (!fArrResoPhi_Pos) { + fResoPhi_Pos = reinterpret_cast(listRes->FindObject(fResPhiPosHistName)); + if (!fResoPhi_Pos) { LOGP(fatal, "Could not open {} from file {}", fResPhiPosHistName.Data(), fResFileName.Data()); } - fArrResoPhi_Neg = reinterpret_cast(listRes->FindObject(fResPhiNegHistName)); - if (!fArrResoPhi_Neg) { + fResoPhi_Neg = reinterpret_cast(listRes->FindObject(fResPhiNegHistName)); + if (!fResoPhi_Neg) { LOGP(fatal, "Could not open {} from file {}", fResPhiNegHistName.Data(), fResFileName.Data()); } + fillVecReso(fResoPt, fVecResoPt); + fillVecReso(fResoEta, fVecResoEta); + fillVecReso(fResoPhi_Pos, fVecResoPhi_Pos); + fillVecReso(fResoPhi_Neg, fVecResoPhi_Neg); } - delete listRes; + + if (!fFromCcdb) + delete listRes; LOGP(info, "Set efficiency histos"); TList* listEff = new TList(); @@ -189,85 +218,107 @@ class MomentumSmearer } } if (fEffType != 0) { - fArrEff = reinterpret_cast(listEff->FindObject(fEffHistName)); - if (!fArrEff) { + fEff = reinterpret_cast(listEff->FindObject(fEffHistName)); + if (!fEff) { LOGP(fatal, "Could not open {} from file {}", fEffHistName.Data(), fEffFileName.Data()); } // check which type is used - if (dynamic_cast(fArrEff)) { + if (dynamic_cast(fEff)) { fEffType = 3; LOGP(info, "Use 3d efficiency histo (pt, eta, phi)"); - } else if (dynamic_cast(fArrEff)) { + } else if (dynamic_cast(fEff)) { fEffType = 2; LOGP(info, "Use 2d efficiency histo (pt, eta)"); - } else if (dynamic_cast(fArrEff)) { + } else if (dynamic_cast(fEff)) { fEffType = 1; LOGP(info, "Use 1d efficiency histo (pt)"); } else { LOGP(fatal, "Could not identify type of histogram {}", fEffHistName.Data()); } } - delete listEff; + + if (!fFromCcdb) + delete listEff; + + LOGP(info, "Set DCA histos"); + TList* listDCA = new TList(); + if (fFromCcdb) { + if (fCcdbPathDCA.CompareTo("") != 0) { + fDCAType = 1; + listDCA = fCcdb->getForTimeStamp(fCcdbPathDCA.Data(), fTimestamp); + if (!listDCA) { + LOGP(fatal, "Could not get DCA file from CCDB"); + return; + } + } + } else { + if (fDCAFileName.CompareTo("") != 0) { + fDCAType = 1; + TFile* fFile = TFile::Open(fDCAFileName); + if (!fFile) { + LOGP(fatal, "Could not open DCA file {}", fDCAFileName.Data()); + return; + } + if (fFile->GetListOfKeys()->Contains("ccdb_object")) { + listDCA = reinterpret_cast(fFile->Get("ccdb_object")); + } else { + for (TObject* keyAsObj : *(fFile->GetListOfKeys())) { + auto key = dynamic_cast(keyAsObj); + TObject* arr = nullptr; + fFile->GetObject(key->GetName(), arr); + listDCA->Add(arr); + } + } + fFile->Close(); + } + } + if (fDCAType != 0) { + fDCA = reinterpret_cast(listDCA->FindObject(fDCAHistName)); + if (!fDCA) { + LOGP(fatal, "Could not open {} from file {}", fDCAHistName.Data(), fDCAFileName.Data()); + } + fillVecReso(fDCA, fVecDCA); + } + + if (!fFromCcdb) + delete listDCA; fInitialized = true; } - void applySmearing(const int ch, const float ptgen, const float etagen, const float phigen, float& ptsmeared, float& etasmeared, float& phismeared) + void applySmearing(float ptgen, float vargen, float multiply, float& varsmeared, TH2F* fReso, std::vector& fVecReso) { - if (fResType == 0) { - ptsmeared = ptgen; - etasmeared = etagen; - phismeared = phigen; - return; - } - // smear pt - int ptbin = reinterpret_cast(fArrResoPt->At(0))->GetXaxis()->FindBin(ptgen); + TAxis* axisPt = fReso->GetXaxis(); + int nBinsPt = axisPt->GetNbins(); + int ptbin = axisPt->FindBin(ptgen); if (ptbin < 1) { ptbin = 1; } - if (ptbin > fArrResoPt->GetLast()) { - ptbin = fArrResoPt->GetLast(); + if (ptbin > nBinsPt) { + ptbin = nBinsPt; } float smearing = 0.; - TH1D* thisHist = reinterpret_cast(fArrResoPt->At(ptbin)); - if (thisHist->GetEntries() > 0) { - smearing = thisHist->GetRandom() * ptgen; - } - ptsmeared = ptgen - smearing; - - // smear eta - ptbin = reinterpret_cast(fArrResoEta->At(0))->GetXaxis()->FindBin(ptgen); - if (ptbin < 1) { - ptbin = 1; - } - if (ptbin > fArrResoEta->GetLast()) { - ptbin = fArrResoEta->GetLast(); - } - smearing = 0.; - thisHist = reinterpret_cast(fArrResoEta->At(ptbin)); - if (thisHist->GetEntries() > 0) { - smearing = thisHist->GetRandom(); + if (fVecReso[ptbin - 1]->GetEntries() > 0) { + smearing = fVecReso[ptbin - 1]->GetRandom() * multiply; } - etasmeared = etagen - smearing; + varsmeared = vargen - smearing; + } - // smear phi - ptbin = reinterpret_cast(fArrResoPhi_Pos->At(0))->GetXaxis()->FindBin(ptgen); - if (ptbin < 1) { - ptbin = 1; - } - if (ptbin > fArrResoPhi_Pos->GetLast()) { - ptbin = fArrResoPhi_Pos->GetLast(); + void applySmearing(const int ch, const float ptgen, const float etagen, const float phigen, float& ptsmeared, float& etasmeared, float& phismeared) + { + if (fResType == 0) { + ptsmeared = ptgen; + etasmeared = etagen; + phismeared = phigen; + return; } - smearing = 0.; - if (ch < 0) { - thisHist = reinterpret_cast(fArrResoPhi_Neg->At(ptbin)); + applySmearing(ptgen, ptgen, ptgen, ptsmeared, fResoPt, fVecResoPt); + applySmearing(ptgen, etagen, 1., etasmeared, fResoEta, fVecResoEta); + if (ch > 0) { + applySmearing(ptgen, phigen, 1., phismeared, fResoPhi_Pos, fVecResoPhi_Pos); } else { - thisHist = reinterpret_cast(fArrResoPhi_Pos->At(ptbin)); + applySmearing(ptgen, phigen, 1., phismeared, fResoPhi_Neg, fVecResoPhi_Neg); } - if (thisHist->GetEntries() > 0) { - smearing = thisHist->GetRandom(); - } - phismeared = phigen - smearing; } float getEfficiency(float pt, float eta, float phi) @@ -278,7 +329,7 @@ class MomentumSmearer } if (fEffType == 1) { - TH1F* hist = reinterpret_cast(fArrEff); + TH1F* hist = reinterpret_cast(fEff); int ptbin = hist->GetXaxis()->FindBin(pt); int ptbin_max = hist->GetXaxis()->GetNbins(); // make sure that no underflow or overflow bins are used @@ -290,7 +341,7 @@ class MomentumSmearer } if (fEffType == 2) { - TH2F* hist = reinterpret_cast(fArrEff); + TH2F* hist = reinterpret_cast(fEff); int ptbin = hist->GetXaxis()->FindBin(pt); int ptbin_max = hist->GetXaxis()->GetNbins(); int etabin = hist->GetYaxis()->FindBin(eta); @@ -308,7 +359,7 @@ class MomentumSmearer } if (fEffType == 3) { - TH3F* hist = reinterpret_cast(fArrEff); + TH3F* hist = reinterpret_cast(fEff); int ptbin = hist->GetXaxis()->FindBin(pt); int ptbin_max = hist->GetXaxis()->GetNbins(); int etabin = hist->GetYaxis()->FindBin(eta); @@ -334,6 +385,28 @@ class MomentumSmearer return 1.; } + float getDCA(float ptsmeared) + { + if (fDCAType == 0) { + return 0.; + } + + TAxis* axisPt = fDCA->GetXaxis(); + int nBinsPt = axisPt->GetNbins(); + int ptbin = axisPt->FindBin(ptsmeared); + if (ptbin < 1) { + ptbin = 1; + } + if (ptbin > nBinsPt) { + ptbin = nBinsPt; + } + float dca = 0.; + if (fVecDCA[ptbin - 1]->GetEntries() > 0) { + dca = fVecDCA[ptbin - 1]->GetRandom(); + } + return dca; + } + // setters void setResFileName(TString resFileName) { fResFileName = resFileName; } void setResPtHistName(TString resPtHistName) { fResPtHistName = resPtHistName; } @@ -342,8 +415,11 @@ class MomentumSmearer void setResPhiNegHistName(TString resPhiNegHistName) { fResPhiNegHistName = resPhiNegHistName; } void setEffFileName(TString effFileName) { fEffFileName = effFileName; } void setEffHistName(TString effHistName) { fEffHistName = effHistName; } + void setDCAFileName(TString dcaFileName) { fDCAFileName = dcaFileName; } + void setDCAHistName(TString dcaHistName) { fDCAHistName = dcaHistName; } void setCcdbPathRes(TString ccdbPathRes) { fCcdbPathRes = ccdbPathRes; } void setCcdbPathEff(TString ccdbPathEff) { fCcdbPathEff = ccdbPathEff; } + void setCcdbPathDCA(TString ccdbPathDCA) { fCcdbPathDCA = ccdbPathDCA; } void setCcdb(Service ccdb) { fCcdb = ccdb; @@ -359,13 +435,16 @@ class MomentumSmearer TString getResPhiNegHistName() { return fResPhiNegHistName; } TString getEffFileName() { return fEffFileName; } TString getEffHistName() { return fEffHistName; } - TObjArray* getArrResoPt() { return fArrResoPt; } - TObjArray* getArrResoEta() { return fArrResoEta; } - TObjArray* getArrResoPhiPos() { return fArrResoPhi_Pos; } - TObjArray* getArrResoPhiNeg() { return fArrResoPhi_Neg; } - TObject* getArrEff() { return fArrEff; } + TString getDCAFileName() { return fDCAFileName; } + TString getDCaHistName() { return fDCAHistName; } + TH2F* getHistResoPt() { return fResoPt; } + TH2F* getHistResoEta() { return fResoEta; } + TH2F* getHistResoPhiPos() { return fResoPhi_Pos; } + TH2F* getHistResoPhiNeg() { return fResoPhi_Neg; } + TObject* getHistEff() { return fEff; } TString getCcdbPathRes() { return fCcdbPathRes; } TString getCcdbPathEff() { return fCcdbPathEff; } + TString getCcdbPathDCA() { return fCcdbPathDCA; } private: bool fInitialized = false; @@ -376,15 +455,25 @@ class MomentumSmearer TString fResPhiNegHistName; TString fEffFileName; TString fEffHistName; + TString fDCAFileName; + TString fDCAHistName; TString fCcdbPathRes; TString fCcdbPathEff; + TString fCcdbPathDCA; int fEffType = 0; int fResType = 0; - TObjArray* fArrResoPt; - TObjArray* fArrResoEta; - TObjArray* fArrResoPhi_Pos; - TObjArray* fArrResoPhi_Neg; - TObject* fArrEff; + int fDCAType = 0; + TH2F* fResoPt; + TH2F* fResoEta; + TH2F* fResoPhi_Pos; + TH2F* fResoPhi_Neg; + std::vector fVecResoPt; + std::vector fVecResoEta; + std::vector fVecResoPhi_Pos; + std::vector fVecResoPhi_Neg; + TObject* fEff; + TH2F* fDCA; + std::vector fVecDCA; int64_t fTimestamp; bool fFromCcdb = false; Service fCcdb; diff --git a/PWGEM/Dilepton/Utils/PairUtilities.h b/PWGEM/Dilepton/Utils/PairUtilities.h index a5d937c182e..293cb34dfa5 100644 --- a/PWGEM/Dilepton/Utils/PairUtilities.h +++ b/PWGEM/Dilepton/Utils/PairUtilities.h @@ -27,6 +27,7 @@ //_______________________________________________________________________ namespace o2::aod::pwgem::dilepton::utils::pairutil { + enum class DileptonPairType : int { kDielectron = 0, kDimuon = 1, @@ -36,31 +37,75 @@ enum class DileptonAnalysisType : int { kUPC = 1, kFlowV2 = 2, kFlowV3 = 3, - kFlowV4 = 4, - kPolarization = 5, + kPolarization = 4, + kVM = 5, kHFll = 6, }; +enum class DileptonPrefilterBit : int { + kMee = 0, // reject tracks from pi0 dalitz decays at very low mass where S/B > 1 + kPhiV = 1, // reject tracks from photon conversions + kFakeMatchITSTPC = 2, // reject tracks from photon conversions misreconstructed as ITS-TPC matched track +}; using SMatrix55 = ROOT::Math::SMatrix>; using SMatrix5 = ROOT::Math::SVector; +//_______________________________________________________________________ +template +void getAngleHX(TTrack1 const& t1, TTrack2 const& t2, const float m1, const float m2, const float beamE1, const float beamE2, const float beamP1, const float beamP2, float& cos_thetaHX, float& phiHX) +{ + ROOT::Math::PxPyPzEVector v1(t1.px(), t1.py(), t1.pz(), std::sqrt(std::pow(t1.p(), 2) + std::pow(m1, 2))); + ROOT::Math::PxPyPzEVector v2(t2.px(), t2.py(), t2.pz(), std::sqrt(std::pow(t2.p(), 2) + std::pow(m2, 2))); + ROOT::Math::PxPyPzEVector v12 = v1 + v2; + + ROOT::Math::PxPyPzEVector Beam1(0., 0., -beamP1, beamE1); + ROOT::Math::PxPyPzEVector Beam2(0., 0., beamP2, beamE2); + + // Boost to center of mass frame. i.e. rest frame of pair + 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()}; + // LOGF(info, "boostv12(v12).Vect().X() = %f, boostv12(v12).Vect().Y() = %f, boostv12(v12).Vect().Z() = %f", boostv12(v12).Vect().X(), boostv12(v12).Vect().Y(), boostv12(v12).Vect().Z()); // expected to be (0,0,0) + + // Helicity frame + ROOT::Math::XYZVectorF zaxis_HX{(v12.Vect()).Unit()}; + ROOT::Math::XYZVectorF yaxis_HX{(Beam1_CM.Cross(Beam2_CM)).Unit()}; + ROOT::Math::XYZVectorF xaxis_HX{(yaxis_HX.Cross(zaxis_HX)).Unit()}; + + // pdgCode : 11 for electron, -11 for positron + // pdgCode : 13 for negative muon, -13 for positive muon + // LOGF(info, "zaxis_HX.Dot(v1_CM) = %f , zaxis_HX.Dot(v2_CM) = %f", zaxis_HX.Dot(v1_CM), zaxis_HX.Dot(v2_CM)); // absolute value is identical. only sign is opposite. + + if constexpr (isMC) { + cos_thetaHX = t1.pdgCode() < 0 ? zaxis_HX.Dot(v1_CM) : zaxis_HX.Dot(v2_CM); + phiHX = t1.pdgCode() < 0 ? std::atan2(yaxis_HX.Dot(v1_CM), xaxis_HX.Dot(v1_CM)) : std::atan2(yaxis_HX.Dot(v2_CM), xaxis_HX.Dot(v2_CM)); + } else { + cos_thetaHX = t1.sign() > 0 ? zaxis_HX.Dot(v1_CM) : zaxis_HX.Dot(v2_CM); + phiHX = t1.sign() > 0 ? std::atan2(yaxis_HX.Dot(v1_CM), xaxis_HX.Dot(v1_CM)) : std::atan2(yaxis_HX.Dot(v2_CM), xaxis_HX.Dot(v2_CM)); + } +} + +//_______________________________________________________________________ //_______________________________________________________________________ template void getAngleCS(TTrack1 const& t1, TTrack2 const& t2, const float m1, const float m2, const float beamE1, const float beamE2, const float beamP1, const float beamP2, float& cos_thetaCS, float& phiCS) { - 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; + ROOT::Math::PxPyPzEVector v1(t1.px(), t1.py(), t1.pz(), std::sqrt(std::pow(t1.p(), 2) + std::pow(m1, 2))); + ROOT::Math::PxPyPzEVector v2(t2.px(), t2.py(), t2.pz(), std::sqrt(std::pow(t2.p(), 2) + std::pow(m2, 2))); + ROOT::Math::PxPyPzEVector v12 = v1 + v2; ROOT::Math::PxPyPzEVector Beam1(0., 0., -beamP1, beamE1); ROOT::Math::PxPyPzEVector Beam2(0., 0., beamP2, beamE2); - // Boost to center of mass frame + // Boost to center of mass frame. i.e. rest frame of pair 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()}; + // LOGF(info, "boostv12(v12).Vect().X() = %f, boostv12(v12).Vect().Y() = %f, boostv12(v12).Vect().Z() = %f", boostv12(v12).Vect().X(), boostv12(v12).Vect().Y(), boostv12(v12).Vect().Z()); // expected to be (0,0,0) // Collins-Soper frame ROOT::Math::XYZVectorF zaxis_CS{((Beam1_CM.Unit() - Beam2_CM.Unit()).Unit())}; @@ -69,6 +114,7 @@ void getAngleCS(TTrack1 const& t1, TTrack2 const& t2, const float m1, const floa // pdgCode : 11 for electron, -11 for positron // pdgCode : 13 for negative muon, -13 for positive muon + // LOGF(info, "zaxis_CS.Dot(v1_CM) = %f , zaxis_CS.Dot(v2_CM) = %f", zaxis_CS.Dot(v1_CM), zaxis_CS.Dot(v2_CM)); // absolute value is identical. only sign is opposite. if constexpr (isMC) { cos_thetaCS = t1.pdgCode() < 0 ? zaxis_CS.Dot(v1_CM) : zaxis_CS.Dot(v2_CM); @@ -275,5 +321,10 @@ inline float getOpeningAngle(float pxpos, float pypos, float pzpos, float pxneg, return std::acos(clipToPM1(argcos)); } //_______________________________________________________________________ +inline float pairDCAQuadSum(const float dca1, const float dca2) +{ + return std::sqrt((dca1 * dca1 + dca2 * dca2) / 2.); +} +//_______________________________________________________________________ } // namespace o2::aod::pwgem::dilepton::utils::pairutil #endif // PWGEM_DILEPTON_UTILS_PAIRUTILITIES_H_ diff --git a/PWGEM/PhotonMeson/Core/CMakeLists.txt b/PWGEM/PhotonMeson/Core/CMakeLists.txt index 2aaf9fa125d..72a17aa1497 100644 --- a/PWGEM/PhotonMeson/Core/CMakeLists.txt +++ b/PWGEM/PhotonMeson/Core/CMakeLists.txt @@ -15,6 +15,7 @@ o2physics_add_library(PWGEMPhotonMesonCore DalitzEECut.cxx EMCPhotonCut.cxx PairCut.cxx + EMPhotonEventCut.cxx CutsLibrary.cxx HistogramsLibrary.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::MLCore O2Physics::PWGEMDileptonCore) @@ -25,6 +26,7 @@ o2physics_target_root_dictionary(PWGEMPhotonMesonCore PHOSPhotonCut.h EMCPhotonCut.h PairCut.h + EMPhotonEventCut.h CutsLibrary.h HistogramsLibrary.h LINKDEF PWGEMPhotonMesonCoreLinkDef.h) diff --git a/PWGEM/PhotonMeson/Core/CutsLibrary.cxx b/PWGEM/PhotonMeson/Core/CutsLibrary.cxx index d76b789cf99..c2f313e6e62 100644 --- a/PWGEM/PhotonMeson/Core/CutsLibrary.cxx +++ b/PWGEM/PhotonMeson/Core/CutsLibrary.cxx @@ -36,9 +36,9 @@ std::vector splitString(const std::string& str, char delimiter) return ret; } //_______________________________________________ -EMEventCut* o2::aod::pwgem::photon::eventcuts::GetCut(const char* cutName) +EMPhotonEventCut* o2::aod::pwgem::photon::eventcuts::GetCut(const char* cutName) { - EMEventCut* cut = new EMEventCut(cutName, cutName); + EMPhotonEventCut* cut = new EMPhotonEventCut(cutName, cutName); std::string nameStr = cutName; if (!nameStr.compare("nocut")) { diff --git a/PWGEM/PhotonMeson/Core/CutsLibrary.h b/PWGEM/PhotonMeson/Core/CutsLibrary.h index 3ac6b9dbb6c..bf4fcfe7037 100644 --- a/PWGEM/PhotonMeson/Core/CutsLibrary.h +++ b/PWGEM/PhotonMeson/Core/CutsLibrary.h @@ -16,7 +16,7 @@ #define PWGEM_PHOTONMESON_CORE_CUTSLIBRARY_H_ #include -#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" #include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" #include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" @@ -29,7 +29,7 @@ namespace pwgem::photon { namespace eventcuts { -EMEventCut* GetCut(const char* cutName); +EMPhotonEventCut* GetCut(const char* cutName); } // namespace eventcuts namespace pcmcuts diff --git a/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx b/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx index 502e5b283a1..4fea46fe3cd 100644 --- a/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx +++ b/PWGEM/PhotonMeson/Core/EMCPhotonCut.cxx @@ -61,6 +61,11 @@ void EMCPhotonCut::SetUseExoticCut(bool flag) mUseExoticCut = flag; LOG(info) << "EMCal Photon Cut, set usage of exotic cluster cut to: " << mUseExoticCut; } +void EMCPhotonCut::SetUseTM(bool flag) +{ + mUseTM = flag; + LOG(info) << "EM Photon Cluster Cut, using TM cut is set to : " << mUseTM; +} void EMCPhotonCut::print() const { diff --git a/PWGEM/PhotonMeson/Core/EMCPhotonCut.h b/PWGEM/PhotonMeson/Core/EMCPhotonCut.h index 1a2e0f28b48..2ce3d91173c 100644 --- a/PWGEM/PhotonMeson/Core/EMCPhotonCut.h +++ b/PWGEM/PhotonMeson/Core/EMCPhotonCut.h @@ -49,33 +49,30 @@ class EMCPhotonCut : public TNamed template bool IsSelected(Cluster const& cluster) const { - // auto track = cluster.template MatchedTrack_as(); - auto track = nullptr; - if (!IsSelectedEMCal(EMCPhotonCuts::kEnergy, cluster, track)) { + if (!IsSelectedEMCal(EMCPhotonCuts::kEnergy, cluster)) { return false; } - if (!IsSelectedEMCal(EMCPhotonCuts::kNCell, cluster, track)) { + if (!IsSelectedEMCal(EMCPhotonCuts::kNCell, cluster)) { return false; } - if (!IsSelectedEMCal(EMCPhotonCuts::kM02, cluster, track)) { + if (!IsSelectedEMCal(EMCPhotonCuts::kM02, cluster)) { return false; } - if (!IsSelectedEMCal(EMCPhotonCuts::kTiming, cluster, track)) { + if (!IsSelectedEMCal(EMCPhotonCuts::kTiming, cluster)) { return false; } - if (!IsSelectedEMCal(EMCPhotonCuts::kTM, cluster, track)) { + if (mUseTM && (!IsSelectedEMCal(EMCPhotonCuts::kTM, cluster))) { return false; } - if (!IsSelectedEMCal(EMCPhotonCuts::kExotic, cluster, track)) { + if (!IsSelectedEMCal(EMCPhotonCuts::kExotic, cluster)) { return false; } return true; } - // Temporary function to check if cluster passes a given selection criteria. To be replaced by framework filters. // Returns true if a cluster survives the cuts! - template - bool IsSelectedEMCal(const EMCPhotonCuts& cut, Cluster const& cluster, Track const& /*track*/) const + template + bool IsSelectedEMCal(const EMCPhotonCuts& cut, Cluster const& cluster) const { switch (cut) { case EMCPhotonCuts::kEnergy: @@ -124,6 +121,7 @@ class EMCPhotonCut : public TNamed void SetTrackMatchingPhi(std::function funcTM); void SetMinEoverP(float min = 0.7f); void SetUseExoticCut(bool flag = true); + void SetUseTM(bool flag = true); /// @brief Print the cluster selection void print() const; @@ -138,6 +136,7 @@ class EMCPhotonCut : public TNamed float mMaxTime{25.f}; ///< maximum cluster timing float mMinEoverP{1.75f}; ///< minimum cluster energy over track momentum ratio needed for the pair to be considered matched bool mUseExoticCut{true}; ///< flag to decide if the exotic cluster cut is to be checked or not + bool mUseTM{true}; ///< flag to decide if track matching cut is to be checek or not std::function mTrackMatchingEta{}; ///< function to get check if a pre matched track and cluster pair is considered an actual match for eta std::function mTrackMatchingPhi{}; ///< function to get check if a pre matched track and cluster pair is considered an actual match for phi diff --git a/PWGEM/PhotonMeson/Core/EMPhotonEventCut.cxx b/PWGEM/PhotonMeson/Core/EMPhotonEventCut.cxx new file mode 100644 index 00000000000..285bf50eba4 --- /dev/null +++ b/PWGEM/PhotonMeson/Core/EMPhotonEventCut.cxx @@ -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. + +// +// Class for em photon event selection +// + +#include "Framework/Logger.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" + +ClassImp(EMPhotonEventCut); + +void EMPhotonEventCut::SetRequireEMCReadoutInMB(bool flag) +{ + mRequireEMCReadoutInMB = flag; + LOG(info) << "EM Photon Event Cut, require the EMC to be read out in an MB collision by checking kTVXinEMC: " << mRequireEMCReadoutInMB; +} + +void EMPhotonEventCut::SetRequireEMCHardwareTriggered(bool flag) +{ + mRequireEMCHardwareTriggered = flag; + LOG(info) << "EM Photon Event Cut, require the EMC to be triggered by requiring kEMC7 or kDMC7: " << mRequireEMCHardwareTriggered; +} diff --git a/PWGEM/PhotonMeson/Core/EMPhotonEventCut.h b/PWGEM/PhotonMeson/Core/EMPhotonEventCut.h new file mode 100644 index 00000000000..3b134ce882e --- /dev/null +++ b/PWGEM/PhotonMeson/Core/EMPhotonEventCut.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. + +// +// Class for em photon event selection +// + +#ifndef PWGEM_PHOTONMESON_CORE_EMPHOTONEVENTCUT_H_ +#define PWGEM_PHOTONMESON_CORE_EMPHOTONEVENTCUT_H_ + +#include "PWGEM/Dilepton/Core/EMEventCut.h" + +using namespace std; + +class EMPhotonEventCut : public EMEventCut +{ + public: + EMPhotonEventCut() = default; + EMPhotonEventCut(const char* name, const char* title) : EMEventCut(name, title) {} + + enum class EMPhotonEventCuts : int { + kEMCReadoutInMB = 0, + kEMCHardwareTriggered, + kNCuts + }; + + template + bool IsSelected(T const& collision) const + { + if (!EMEventCut::IsSelected(collision)) { + return false; + } + if (mRequireEMCReadoutInMB && !IsSelected(collision, EMPhotonEventCuts::kEMCReadoutInMB)) { + return false; + } + if (mRequireEMCHardwareTriggered && !IsSelected(collision, EMPhotonEventCuts::kEMCHardwareTriggered)) { + return false; + } + return true; + } + + template + bool IsSelected(T const& collision, const EMPhotonEventCuts& cut) const + { + switch (cut) { + case EMPhotonEventCuts::kEMCReadoutInMB: + return (collision.alias_bit(kTVXinEMC)); + + case EMPhotonEventCuts::kEMCHardwareTriggered: + return (collision.alias_bit(kEMC7) || collision.alias_bit(kDMC7)); + + default: + return true; + } + } + + // Setters + void SetRequireEMCReadoutInMB(bool flag); + void SetRequireEMCHardwareTriggered(bool flag); + + private: + bool mRequireEMCReadoutInMB{false}; + bool mRequireEMCHardwareTriggered{false}; + + ClassDef(EMPhotonEventCut, 1); +}; + +#endif // PWGEM_PHOTONMESON_CORE_EMPHOTONEVENTCUT_H_ diff --git a/PWGEM/PhotonMeson/Core/PWGEMPhotonMesonCoreLinkDef.h b/PWGEM/PhotonMeson/Core/PWGEMPhotonMesonCoreLinkDef.h index 963229d1d24..ff03b41a75e 100644 --- a/PWGEM/PhotonMeson/Core/PWGEMPhotonMesonCoreLinkDef.h +++ b/PWGEM/PhotonMeson/Core/PWGEMPhotonMesonCoreLinkDef.h @@ -20,6 +20,7 @@ #pragma link C++ class DalitzEECut + ; #pragma link C++ class PHOSPhotonCut + ; #pragma link C++ class EMCPhotonCut + ; +#pragma link C++ class EMPhotonEventCut + ; #pragma link C++ class PairCut + ; #endif // PWGEM_PHOTONMESON_CORE_PWGEMPHOTONMESONCORELINKDEF_H_ diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h index eb7f1dc73f7..e5437da59cf 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGamma.h @@ -49,7 +49,7 @@ #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" #include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.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" @@ -67,7 +67,7 @@ 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; @@ -80,7 +80,7 @@ using MyEMCClusters = soa::Join; using MyEMCCluster = MyEMCClusters::iterator; using MyPHOSClusters = soa::Join; -using MyPHOSCluster = MyEMCClusters::iterator; +using MyPHOSCluster = MyPHOSClusters::iterator; template struct Pi0EtaToGammaGamma { @@ -102,7 +102,7 @@ struct Pi0EtaToGammaGamma { 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"}; - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; @@ -117,6 +117,7 @@ struct Pi0EtaToGammaGamma { 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 onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -209,6 +210,7 @@ struct Pi0EtaToGammaGamma { Service ccdb; int mRunNumber; float d_bz; + o2::emcal::Geometry* emcalGeom; void init(InitContext&) { @@ -227,14 +229,13 @@ struct Pi0EtaToGammaGamma { emh1 = new MyEMH(ndepth); emh2 = new MyEMH(ndepth); - std::string_view qvec_det_names[3] = {"FT0M", "FT0A", "FT0C"}; o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); if constexpr (pairtype == PairType::kPCMDalitzEE) { - o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "ee#gamma", qvec_det_names[cfgQvecEstimator].data()); + 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", qvec_det_names[cfgQvecEstimator].data()); + o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "#mu#mu#gamma"); } else { - o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "#gamma#gamma", qvec_det_names[cfgQvecEstimator].data()); + o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, false, "#gamma#gamma"); } DefineEMEventCut(); DefinePCMCut(); @@ -244,7 +245,7 @@ struct Pi0EtaToGammaGamma { if constexpr (pairtype == kEMCEMC) { fRegistry.addClone("Pair/same/", "Pair/rotation/"); - o2::emcal::Geometry::GetInstanceFromRunNumber(300000); + emcalGeom = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); } mRunNumber = 0; @@ -310,7 +311,7 @@ struct Pi0EtaToGammaGamma { void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -321,7 +322,6 @@ struct Pi0EtaToGammaGamma { fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireEMCReadoutInMB(eventcuts.cfgRequireEMCReadoutInMB); fEMEventCut.SetRequireEMCHardwareTriggered(eventcuts.cfgRequireEMCHardwareTriggered); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); } void DefinePCMCut() @@ -417,13 +417,15 @@ struct Pi0EtaToGammaGamma { 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.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 + 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 + pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); @@ -436,7 +438,7 @@ struct Pi0EtaToGammaGamma { /// \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, aod::SkimEMCMTs const&) + 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, float eventWeight) { // if less than 3 clusters are present skip event since we need at least 3 clusters if (photons_coll.size() < 3) { @@ -448,12 +450,29 @@ struct Pi0EtaToGammaGamma { photon1 = rotationMatrix * photon1; photon2 = rotationMatrix * photon2; + int iCellID_photon1 = 0; + int iCellID_photon2 = 0; + + try { + iCellID_photon1 = emcalGeom->GetAbsCellIdFromEtaPhi(photon1.Eta(), photon1.Phi()); + } catch (o2::emcal::InvalidPositionException& e) { + iCellID_photon1 = -1; + } + try { + iCellID_photon2 = emcalGeom->GetAbsCellIdFromEtaPhi(photon2.Eta(), photon2.Phi()); + } catch (o2::emcal::InvalidPositionException& e) { + iCellID_photon2 = -1; + } + if (iCellID_photon1 == -1 && iCellID_photon2 == -1) { + return; + } + for (auto& photon : photons_coll) { if (photon.globalIndex() == ig1 || photon.globalIndex() == ig2) { // only combine rotated photons with other photons continue; } - if (!cut.template IsSelected(photon)) { + if (!(fEMCCut.IsSelected(photon))) { continue; } @@ -464,27 +483,14 @@ 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())); - int iCellID_photon1 = 0; - int iCellID_photon2 = 0; - - try { - iCellID_photon1 = o2::emcal::Geometry::GetInstance()->GetAbsCellIdFromEtaPhi(photon1.Eta(), photon1.Phi()); - } catch (o2::emcal::InvalidPositionException& e) { - iCellID_photon1 = -1; - } - try { - iCellID_photon2 = o2::emcal::Geometry::GetInstance()->GetAbsCellIdFromEtaPhi(photon2.Eta(), photon2.Phi()); - } catch (o2::emcal::InvalidPositionException& e) { - iCellID_photon2 = -1; - } - if (openingAngle1 > emccuts.minOpenAngle && abs(mother1.Rapidity()) < maxY && iCellID_photon1 > 0) { - fRegistry.fill(HIST("Pair/rotation/hs"), mother1.M(), mother1.Pt()); + fRegistry.fill(HIST("Pair/rotation/hs"), mother1.M(), mother1.Pt(), eventWeight); } if (openingAngle2 > emccuts.minOpenAngle && abs(mother2.Rapidity()) < maxY && iCellID_photon2 > 0) { - fRegistry.fill(HIST("Pair/rotation/hs"), mother2.M(), mother2.Pt()); + fRegistry.fill(HIST("Pair/rotation/hs"), mother2.M(), mother2.Pt(), eventWeight); } } + return; } SliceCache cache; @@ -502,13 +508,12 @@ struct Pi0EtaToGammaGamma { std::vector> used_photonIds; // std::vector> used_dileptonIds; // - template + 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, - TTracksMatchedWithEMC const& tracks_emc, TTracksMatchedWithPHOS const& /*tracks_phos*/) + TCut1 const& cut1, TCut2 const& cut2) { for (auto& collision : collisions) { initCCDB(collision); @@ -517,6 +522,10 @@ struct Pi0EtaToGammaGamma { continue; } + if (eventcuts.onlyKeepWeightedEvents && fabs(collision.weight() - 1.) < 1E-10) { + continue; + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; @@ -581,21 +590,21 @@ struct Pi0EtaToGammaGamma { continue; } - fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt(), collision.weight()); if constexpr (pairtype == PairType::kEMCEMC) { - RotationBackground(v12, v1, v2, photons2_per_collision, g1.globalIndex(), g2.globalIndex(), cut1, tracks_emc); + RotationBackground(v12, v1, v2, photons2_per_collision, g1.globalIndex(), g2.globalIndex(), 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(g1.globalIndex(), collision.globalIndex(), g1.globalIndex(), g1.pt(), g1.eta(), g1.phi(), 0)); + emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, 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(g2.globalIndex(), collision.globalIndex(), g2.globalIndex(), g2.pt(), g2.eta(), g2.phi(), 0)); + emh1->AddTrackToEventPool(key_df_collision, EMTrack(-1, g2.globalIndex(), collision.globalIndex(), g2.globalIndex(), g2.pt(), g2.eta(), g2.phi(), 0)); used_photonIds.emplace_back(pair_tmp_id2); } ndiphoton++; @@ -638,21 +647,21 @@ struct Pi0EtaToGammaGamma { continue; } - fRegistry.fill(HIST("Pair/same/hs"), veeg.M(), veeg.Pt()); + fRegistry.fill(HIST("Pair/same/hs"), veeg.M(), veeg.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(g1.globalIndex(), collision.globalIndex(), -1, g1.pt(), g1.eta(), g1.phi(), 0)); + 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, collision.globalIndex(), -1, v_ee.Pt(), v_ee.Eta(), v_ee.Phi(), v_ee.M())); + 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 + } // end of dielectron loop + } // end of g1 loop } else { // PCM-EMC, PCM-PHOS. Nightmare. don't run these pairs. auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); @@ -668,22 +677,22 @@ struct Pi0EtaToGammaGamma { continue; } - fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/same/hs"), v12.M(), v12.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(g1.globalIndex(), collision.globalIndex(), -1, g1.pt(), g1.eta(), g1.phi(), 0)); + 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(g2.globalIndex(), collision.globalIndex(), -1, g2.pt(), g2.eta(), g2.phi(), 0)); + 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 + } // end of pairing in same event // event mixing if (!cfgDoMix || !(ndiphoton > 0)) { @@ -718,7 +727,7 @@ struct Pi0EtaToGammaGamma { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); } } } // end of loop over mixed event pool @@ -746,7 +755,7 @@ struct Pi0EtaToGammaGamma { if (abs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); } } } // end of loop over mixed event pool @@ -772,7 +781,7 @@ struct Pi0EtaToGammaGamma { if (abs(v12.Rapidity()) > maxY) { continue; } - fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt()); + fRegistry.fill(HIST("Pair/mix/hs"), v12.M(), v12.Pt(), collision.weight()); } } } // end of loop over mixed event pool @@ -786,6 +795,7 @@ struct Pi0EtaToGammaGamma { } // end of collision loop } + Filter collisionFilter_occupancy = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; 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; @@ -796,20 +806,19 @@ struct Pi0EtaToGammaGamma { 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, nullptr, nullptr); + 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, nullptr, nullptr); + 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...)); - auto emcmatchedtracks = std::get<1>(std::tie(args...)); - runPairing(collisions, emcclusters, emcclusters, nullptr, nullptr, perCollision_emc, perCollision_emc, fEMCCut, fEMCCut, emcmatchedtracks, nullptr); + 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, nullptr, nullptr); + 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...)); diff --git a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h index 63146d41427..c342423eff9 100644 --- a/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h +++ b/PWGEM/PhotonMeson/Core/Pi0EtaToGammaGammaMC.h @@ -44,7 +44,7 @@ #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" #include "PWGEM/PhotonMeson/Core/PHOSPhotonCut.h" #include "PWGEM/PhotonMeson/Core/EMCPhotonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" #include "PWGEM/Dilepton/Utils/MCUtilities.h" using namespace o2; @@ -56,7 +56,7 @@ 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 MyMCCollisions = soa::Join; @@ -92,7 +92,7 @@ struct Pi0EtaToGammaGammaMC { 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"}; - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; @@ -107,6 +107,7 @@ struct Pi0EtaToGammaGammaMC { 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 onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -205,11 +206,11 @@ 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", ""); + 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", ""); + o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "#mu#mu#gamma"); } else { - o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "#gamma#gamma", ""); + o2::aod::pwgem::photonmeson::utils::nmhistogram::addNMHistograms(&fRegistry, true, "#gamma#gamma"); } DefineEMEventCut(); DefinePCMCut(); @@ -277,7 +278,7 @@ struct Pi0EtaToGammaGammaMC { void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -288,7 +289,6 @@ struct Pi0EtaToGammaGammaMC { fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireEMCReadoutInMB(eventcuts.cfgRequireEMCReadoutInMB); fEMEventCut.SetRequireEMCHardwareTriggered(eventcuts.cfgRequireEMCHardwareTriggered); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); } void DefinePCMCut() @@ -383,13 +383,15 @@ struct Pi0EtaToGammaGammaMC { 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.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 + 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 + pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); @@ -413,13 +415,12 @@ struct Pi0EtaToGammaGammaMC { // 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); - template + template void runTruePairing(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, - TTracksMatchedWithEMC const& /*tracks_emc*/, TTracksMatchedWithPHOS const& /*tracks_phos*/, TMCCollisions const& mccollisions, TMCParticles const& mcparticles) { for (auto& collision : collisions) { @@ -429,6 +430,10 @@ struct Pi0EtaToGammaGammaMC { continue; } + if (eventcuts.onlyKeepWeightedEvents && fabs(collision.weight() - 1.) < 1E-10) { + continue; + } + const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) { continue; @@ -504,10 +509,10 @@ struct Pi0EtaToGammaGammaMC { if (pi0id > 0) { auto pi0mc = mcparticles.iteratorAt(pi0id); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0); + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.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); + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); } } // end of pairing loop } else if constexpr (pairtype == PairType::kPCMDalitzEE) { @@ -564,13 +569,13 @@ struct Pi0EtaToGammaGammaMC { } if (pi0id > 0) { auto pi0mc = mcparticles.iteratorAt(pi0id); - o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0); + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.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); + o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, veeg, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); } - } // end of dielectron loop - } // end of pcm loop + } // end of dielectron loop + } // end of pcm loop } else { // PCM-EMC, PCM-PHOS. Nightmare. don't run these pairs. auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex()); auto photons2_per_collision = photons2.sliceBy(perCollision2, collision.globalIndex()); @@ -587,14 +592,14 @@ struct Pi0EtaToGammaGammaMC { } // if (pi0id > 0) { // auto pi0mc = mcparticles.iteratorAt(pi0id); - // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0); + // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.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); + // o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, etamc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight()); // } } // end of pairing loop - } // end of pairing in same event - } // end of collision loop + } // end of pairing in same event + } // end of collision loop } template @@ -652,11 +657,12 @@ 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, 1.f); - fillBinnedData<1>(binned_data_eta_gen, 1.f); + fillBinnedData<0>(binned_data_pi0_gen, collision.weight()); + fillBinnedData<1>(binned_data_eta_gen, collision.weight()); } // end of collision loop } + Filter collisionFilter_occupancy = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; 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; @@ -665,19 +671,18 @@ struct Pi0EtaToGammaGammaMC { 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, nullptr, nullptr, mccollisions, mcparticles); + 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, nullptr, nullptr, mccollisions, mcparticles); + 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...)); - auto emcmatchedtracks = std::get<1>(std::tie(args...)); - runTruePairing(collisions, emcclusters, emcclusters, nullptr, nullptr, perCollision_emc, perCollision_emc, fEMCCut, fEMCCut, emcmatchedtracks, nullptr, mccollisions, mcparticles); + runTruePairing(collisions, emcclusters, emcclusters, nullptr, nullptr, perCollision_emc, perCollision_emc, fEMCCut, fEMCCut, mccollisions, mcparticles); runGenInfo(collisions, mccollisions, mcparticles); } diff --git a/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx b/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx index cb4f71465fe..9c369df9514 100644 --- a/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx +++ b/PWGEM/PhotonMeson/Core/V0PhotonCut.cxx @@ -18,8 +18,6 @@ ClassImp(V0PhotonCut); -const char* V0PhotonCut::mCutNames[static_cast(V0PhotonCut::V0PhotonCuts::kNCuts)] = {"Mee", "V0PtRange", "V0EtaRange", "AP", " PsiPair", "PhivPair", "Rxy", "CosPA", "PCA", "RZLine", "OnWwireIB", "OnWwireOB", "TrackPtRange", "TrackEtaRange", "TPCNCls", "TPCCrossedRows", "TPCCrossedRowsOverNCls", "TPCChi2NDF", "TPCNsigmaEl", "TPCNsigmaPi", "DCAxy", "DCAz", "ITSNCls", "ITSChi2NDF", "IsWithinBeamPipe", "RequireITSTPC", "RequireITSonly", "RequireTPConly", "RequireTPCTRD", "RequireTPCTOF", "RequireTPCTRDTOF"}; - const std::pair> V0PhotonCut::its_ib_Requirement = {0, {0, 1, 2}}; // no hit on 3 ITS ib layers. const std::pair> V0PhotonCut::its_ob_Requirement = {4, {3, 4, 5, 6}}; // all hits on 4 ITS ob layers. const std::pair> V0PhotonCut::its_ob_Requirement_ITSTPC = {2, {3, 4, 5, 6}}; // at least 2 hits on 4 ITS ob layers. @@ -140,6 +138,11 @@ void V0PhotonCut::SetMinNCrossedRowsOverFindableClustersTPC(float minNCrossedRow mMinNCrossedRowsOverFindableClustersTPC = minNCrossedRowsOverFindableClustersTPC; LOG(info) << "V0 Photon Cut, set min N crossed rows over findable clusters TPC: " << mMinNCrossedRowsOverFindableClustersTPC; } +void V0PhotonCut::SetMaxFracSharedClustersTPC(float max) +{ + mMaxFracSharedClustersTPC = max; + LOG(info) << "V0 Photon Cut, set max fraction of shared clusters in TPC: " << mMaxFracSharedClustersTPC; +} void V0PhotonCut::SetChi2PerClusterTPC(float min, float max) { mMinChi2PerClusterTPC = min; @@ -224,37 +227,8 @@ void V0PhotonCut::SetRequireTPCTRDTOF(bool flag) LOG(info) << "V0 Photon Cut, require TPC-TOF track: " << mRequireTPCTRDTOF; } -void V0PhotonCut::print() const -{ - LOG(info) << "V0 Photon Cut:"; - for (int i = 0; i < static_cast(V0PhotonCuts::kNCuts); i++) { - switch (static_cast(i)) { - case V0PhotonCuts::kTrackPtRange: - LOG(info) << mCutNames[i] << " in [" << mMinTrackPt << ", " << mMaxTrackPt << "]"; - break; - case V0PhotonCuts::kTrackEtaRange: - LOG(info) << mCutNames[i] << " in [" << mMinTrackEta << ", " << mMaxTrackEta << "]"; - break; - case V0PhotonCuts::kTPCNCls: - LOG(info) << mCutNames[i] << " > " << mMinNClustersTPC; - break; - case V0PhotonCuts::kTPCCrossedRows: - LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsTPC; - break; - case V0PhotonCuts::kTPCCrossedRowsOverNCls: - LOG(info) << mCutNames[i] << " > " << mMinNCrossedRowsOverFindableClustersTPC; - break; - case V0PhotonCuts::kTPCChi2NDF: - LOG(info) << mCutNames[i] << " < " << mMaxChi2PerClusterTPC; - break; - case V0PhotonCuts::kDCAxy: - LOG(info) << mCutNames[i] << " < " << mMaxDcaXY; - break; - case V0PhotonCuts::kDCAz: - LOG(info) << mCutNames[i] << " < " << mMaxDcaZ; - break; - default: - LOG(fatal) << "Cut unknown!"; - } - } +void V0PhotonCut::SetDisableITSonly(bool flag) +{ + mDisableITSonly = flag; + LOG(info) << "V0 Photon Cut, disable ITS only track: " << mDisableITSonly; } diff --git a/PWGEM/PhotonMeson/Core/V0PhotonCut.h b/PWGEM/PhotonMeson/Core/V0PhotonCut.h index dff38d1ffd6..2acd533d14f 100644 --- a/PWGEM/PhotonMeson/Core/V0PhotonCut.h +++ b/PWGEM/PhotonMeson/Core/V0PhotonCut.h @@ -54,6 +54,7 @@ class V0PhotonCut : public TNamed kTPCNCls, kTPCCrossedRows, kTPCCrossedRowsOverNCls, + kTPCFracSharedClusters, kTPCChi2NDF, kTPCNsigmaEl, kTPCNsigmaPi, @@ -61,7 +62,7 @@ class V0PhotonCut : public TNamed kDCAz, kITSNCls, kITSChi2NDF, - kITSCluserSize, + kITSClusterSize, kIsWithinBeamPipe, kRequireITSTPC, kRequireITSonly, @@ -72,8 +73,6 @@ class V0PhotonCut : public TNamed kNCuts }; - static const char* mCutNames[static_cast(V0PhotonCuts::kNCuts)]; - template bool IsSelected(TV0 const& v0) const { @@ -144,6 +143,9 @@ class V0PhotonCut : public TNamed if (!track.hasITS() && !track.hasTPC()) { // track has to be ITSonly or TPConly or ITS-TPC return false; } + if (mDisableITSonly && isITSonlyTrack(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); }); @@ -205,7 +207,7 @@ class V0PhotonCut : public TNamed if (!IsSelectedTrack(track, V0PhotonCuts::kITSChi2NDF)) { return false; } - if (!IsSelectedTrack(track, V0PhotonCuts::kITSCluserSize)) { + if (!IsSelectedTrack(track, V0PhotonCuts::kITSClusterSize)) { return false; } return true; @@ -223,6 +225,9 @@ class V0PhotonCut : public TNamed if (!IsSelectedTrack(track, V0PhotonCuts::kTPCCrossedRowsOverNCls)) { return false; } + if (!IsSelectedTrack(track, V0PhotonCuts::kTPCFracSharedClusters)) { + return false; + } if (!IsSelectedTrack(track, V0PhotonCuts::kTPCChi2NDF)) { return false; } @@ -235,31 +240,6 @@ class V0PhotonCut : public TNamed return true; } - template - uint32_t IsSelectedMask(T const& track) const - { - uint32_t flag = 0; - - auto setFlag = [&](const V0PhotonCuts& cut) { - if (IsSelectedTrack(track, cut)) { - flag |= 1UL << static_cast(cut); - } - }; - - setFlag(V0PhotonCuts::kV0PtRange); - setFlag(V0PhotonCuts::kV0EtaRange); - setFlag(V0PhotonCuts::kTrackPtRange); - setFlag(V0PhotonCuts::kTrackEtaRange); - setFlag(V0PhotonCuts::kTPCNCls); - setFlag(V0PhotonCuts::kTPCCrossedRows); - setFlag(V0PhotonCuts::kTPCCrossedRowsOverNCls); - setFlag(V0PhotonCuts::kTPCChi2NDF); - setFlag(V0PhotonCuts::kDCAxy); - setFlag(V0PhotonCuts::kDCAz); - - return flag; - } - template bool IsSelectedV0(T const& v0, const V0PhotonCuts& cut) const { @@ -371,6 +351,9 @@ class V0PhotonCut : public TNamed case V0PhotonCuts::kTPCCrossedRowsOverNCls: return track.tpcCrossedRowsOverFindableCls() >= mMinNCrossedRowsOverFindableClustersTPC; + case V0PhotonCuts::kTPCFracSharedClusters: + return track.tpcFractionSharedCls() <= mMaxFracSharedClustersTPC; + case V0PhotonCuts::kTPCChi2NDF: return mMinChi2PerClusterTPC < track.tpcChi2NCl() && track.tpcChi2NCl() < mMaxChi2PerClusterTPC; @@ -392,7 +375,7 @@ class V0PhotonCut : public TNamed case V0PhotonCuts::kITSChi2NDF: return mMinChi2PerClusterITS < track.itsChi2NCl() && track.itsChi2NCl() < mMaxChi2PerClusterITS; - case V0PhotonCuts::kITSCluserSize: { + case V0PhotonCuts::kITSClusterSize: { if (!isITSonlyTrack(track)) { return true; } @@ -465,6 +448,7 @@ class V0PhotonCut : 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); @@ -483,9 +467,7 @@ class V0PhotonCut : public TNamed void SetRequireTPCTRD(bool flag); void SetRequireTPCTOF(bool flag); void SetRequireTPCTRDTOF(bool flag); - - /// @brief Print the track selection - void print() const; + void SetDisableITSonly(bool flag); private: static const std::pair> its_ib_Requirement; @@ -520,6 +502,7 @@ class V0PhotonCut : 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 mMinMeanClusterSizeITS{-1e10f}, mMaxMeanClusterSizeITS{1e10f}; // max x cos(Lmabda) @@ -534,6 +517,7 @@ class V0PhotonCut : public TNamed bool mRequireTPCTRD{false}; bool mRequireTPCTOF{false}; bool mRequireTPCTRDTOF{false}; + bool mDisableITSonly{false}; ClassDef(V0PhotonCut, 1); }; diff --git a/PWGEM/PhotonMeson/DataModel/gammaTables.h b/PWGEM/PhotonMeson/DataModel/gammaTables.h index 86ffa254c51..9b91eb0864f 100644 --- a/PWGEM/PhotonMeson/DataModel/gammaTables.h +++ b/PWGEM/PhotonMeson/DataModel/gammaTables.h @@ -13,14 +13,7 @@ #include #include "Common/Core/RecoDecay.h" -// #include "Framework/AnalysisDataModel.h" -// #include "Common/DataModel/PIDResponse.h" -// #include "Common/DataModel/EventSelection.h" -// #include "Common/DataModel/TrackSelectionTables.h" -// #include "Common/DataModel/CaloClusters.h" -// #include "Common/DataModel/Multiplicity.h" -// #include "Common/DataModel/Centrality.h" -// #include "Common/DataModel/Qvectors.h" +#include "Common/DataModel/CaloClusters.h" #include "PWGEM/Dilepton/DataModel/dileptonTables.h" @@ -177,7 +170,7 @@ DECLARE_SOA_TABLE(V0Legs, "AOD", "V0LEG", //! o2::soa::Index<>, v0leg::CollisionId, v0leg::TrackId, v0leg::Sign, v0leg::Px, v0leg::Py, v0leg::Pz, track::DcaXY, track::DcaZ, - track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, + track::TPCNClsFindable, track::TPCNClsFindableMinusFound, track::TPCNClsFindableMinusCrossedRows, track::TPCNClsShared, track::TPCChi2NCl, track::TPCInnerParam, track::TPCSignal, pidtpc::TPCNSigmaEl, pidtpc::TPCNSigmaPi, track::ITSClusterSizes, track::ITSChi2NCl, track::DetectorMap, @@ -192,6 +185,7 @@ DECLARE_SOA_TABLE(V0Legs, "AOD", "V0LEG", //! 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, @@ -202,10 +196,24 @@ DECLARE_SOA_TABLE(V0Legs, "AOD", "V0LEG", //! // iterators using V0Leg = V0Legs::iterator; +namespace emevent +{ +DECLARE_SOA_COLUMN(NgPCM, ngpcm, int); +DECLARE_SOA_COLUMN(Weight, weight, float); //! Weight of the event (e.g. for JJ MCs). Set to 1 for data and non-weighted MCs. +} // namespace emevent + +DECLARE_SOA_TABLE(EMEventsNgPCM, "AOD", "EMEVENTNGPCM", emevent::NgPCM); // joinable to EMEvents or aod::Collisions +using EMEventNgPCM = EMEventsNgPCM::iterator; + +DECLARE_SOA_TABLE(EMEventsWeight, "AOD", "EMEVENTWEIGHT", //! table contanint the weight for eache event (for JJ MCs), joinable to EMEvents + emevent::Weight); +using EMEventWeight = EMEventsWeight::iterator; + namespace v0photonkf { DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! +DECLARE_SOA_COLUMN(V0Id, v0Id, int); //! DECLARE_SOA_INDEX_COLUMN_FULL(PosTrack, posTrack, int, V0Legs, "_Pos"); //! DECLARE_SOA_INDEX_COLUMN_FULL(NegTrack, negTrack, int, V0Legs, "_Neg"); //! DECLARE_SOA_COLUMN(Vx, vx, float); //! secondary vertex x @@ -222,6 +230,12 @@ 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_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); }); @@ -231,7 +245,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float px, float py, float pz) -> float { ret DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0radius, [](float vx, float vy) -> float { return RecoDecay::sqrtSumOfSquares(vx, vy); }); } // namespace v0photonkf DECLARE_SOA_TABLE(V0PhotonsKF, "AOD", "V0PHOTONKF", //! - o2::soa::Index<>, v0photonkf::CollisionId, v0photonkf::PosTrackId, v0photonkf::NegTrackId, + 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, @@ -254,6 +268,11 @@ DECLARE_SOA_TABLE(V0KFEMEventIds, "AOD", "V0KFEMEVENTID", v0photonkf::EMEventId) // iterators using V0KFEMEventId = V0KFEMEventIds::iterator; +DECLARE_SOA_TABLE(V0PhotonsKFCov, "AOD", "V0PHOTONKFCOV", //! To be joined with V0PhotonsKF table at analysis level. + v0photonkf::SigmaPx2, v0photonkf::SigmaPy2, v0photonkf::SigmaPz2, v0photonkf::SigmaPxPy, v0photonkf::SigmaPyPz, v0photonkf::SigmaPzPx); +// iterators +using V0PhotonKFCov = V0PhotonsKFCov::iterator; + DECLARE_SOA_TABLE(EMPrimaryElectronsFromDalitz, "AOD", "EMPRIMARYELDA", //! o2::soa::Index<>, emprimaryelectron::CollisionId, emprimaryelectron::TrackId, emprimaryelectron::Sign, @@ -411,8 +430,8 @@ DECLARE_SOA_TABLE(McGammasTrue, "AOD", "MCGATRUE", namespace skimmedcluster { -DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! collisionID used as index for matched clusters -DECLARE_SOA_INDEX_COLUMN(BC, bc); //! bunch crossing ID used as index for ambiguous clusters +DECLARE_SOA_INDEX_COLUMN(EMEvent, emevent); //! +DECLARE_SOA_COLUMN(CollisionId, collisionId, int); //! DECLARE_SOA_COLUMN(ID, id, int); //! cluster ID identifying cluster in event DECLARE_SOA_COLUMN(E, e, float); //! cluster energy (GeV) DECLARE_SOA_COLUMN(Eta, eta, float); //! cluster pseudorapidity (calculated using vertex) @@ -440,12 +459,9 @@ DECLARE_SOA_COLUMN(TrackPt, trackpt, std::vector); 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 - o2::soa::Index<>, skimmedcluster::CollisionId, skimmedcluster::BCId, skimmedcluster::E, emccluster::CoreEnergy, - skimmedcluster::Eta, skimmedcluster::Phi, skimmedcluster::M02, skimmedcluster::M20, skimmedcluster::NCells, skimmedcluster::Time, - emccluster::IsExotic, skimmedcluster::DistanceToBadChannel, skimmedcluster::NLM, emccluster::Definition, - emccluster::TrackIds, emccluster::TrackEta, emccluster::TrackPhi, emccluster::TrackP, emccluster::TrackPt, - // dynamic column - emccluster::Pt); + o2::soa::Index<>, skimmedcluster::CollisionId, skimmedcluster::E, skimmedcluster::Eta, skimmedcluster::Phi, + skimmedcluster::M02, skimmedcluster::NCells, skimmedcluster::Time, emccluster::IsExotic, emccluster::TrackEta, + emccluster::TrackPhi, 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. diff --git a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt index a468376a761..7d58cb0cb7c 100644 --- a/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt +++ b/PWGEM/PhotonMeson/TableProducer/CMakeLists.txt @@ -21,7 +21,7 @@ o2physics_add_dpl_workflow(skimmer-gamma-conversion-truthonlymc o2physics_add_dpl_workflow(photon-conversion-builder SOURCES photonconversionbuilder.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2Physics::AnalysisCore KFParticle::KFParticle + PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2Physics::AnalysisCore KFParticle::KFParticle O2Physics::TPCDriftManager COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(create-pcm diff --git a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx index 9a9759c14d3..257450cce99 100644 --- a/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx +++ b/PWGEM/PhotonMeson/TableProducer/associateMCinfoPhoton.cxx @@ -142,18 +142,18 @@ struct AssociateMCInfoPhoton { 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(), mctrack.y()); // caution: pack + auto binNumber = hBinFinder->FindBin(mctrack.pt(), abs(mctrack.y())); // caution: pack switch (abs(mctrack.pdgCode())) { case 22: - registry.fill(HIST("Generated/h2PtY_Gamma"), mctrack.pt(), mctrack.y()); + registry.fill(HIST("Generated/h2PtY_Gamma"), mctrack.pt(), abs(mctrack.y())); genGamma[binNumber]++; break; case 111: - registry.fill(HIST("Generated/h2PtY_Pi0"), mctrack.pt(), mctrack.y()); + registry.fill(HIST("Generated/h2PtY_Pi0"), mctrack.pt(), abs(mctrack.y())); genPi0[binNumber]++; break; case 221: - registry.fill(HIST("Generated/h2PtY_Eta"), mctrack.pt(), mctrack.y()); + registry.fill(HIST("Generated/h2PtY_Eta"), mctrack.pt(), abs(mctrack.y())); genEta[binNumber]++; break; default: @@ -164,7 +164,7 @@ struct AssociateMCInfoPhoton { // 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.t(), mcCollision.impactParameter()); + 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); diff --git a/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx b/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx index bf7699009c6..1f1f3b17ead 100644 --- a/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx +++ b/PWGEM/PhotonMeson/TableProducer/createEMEventPhoton.cxx @@ -14,6 +14,9 @@ // This code produces reduced events for photon analyses. // Please write to: daiki.sekihata@cern.ch +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -24,6 +27,7 @@ #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "Common/CCDB/TriggerAliases.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" @@ -36,11 +40,11 @@ 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 = soa::Join; // centrality table has dependency on multiplicity table. using MyCollisions_Cent_Qvec = soa::Join; using MyCollisionsMC = soa::Join; -using MyCollisionsMC_Cent = soa::Join; // centrality table has dependency on multiplicity table. +using MyCollisionsMC_Cent = soa::Join; // centrality table has dependency on multiplicity table. using MyCollisionsMC_Cent_Qvec = soa::Join; struct CreateEMEvent { @@ -49,11 +53,13 @@ struct CreateEMEvent { Produces event_mult; Produces event_cent; Produces event_qvec; + Produces event_weights; enum class EMEventType : int { kEvent = 0, kEvent_Cent = 1, kEvent_Cent_Qvec = 2, + kEvent_JJ = 3, }; // CCDB options @@ -63,6 +69,8 @@ struct CreateEMEvent { Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; Configurable d_bz_input{"d_bz", -999, "bz field, -999 is automatic"}; Configurable applyEveSel_at_skimming{"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"}; HistogramRegistry registry{"registry"}; void init(o2::framework::InitContext&) @@ -141,6 +149,12 @@ struct CreateEMEvent { 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; } + if (needEMCTrigger && !collision.alias_bit(kTVXinEMC)) { + continue; + } + if (needPHSTrigger && !collision.alias_bit(kTVXinPHOS)) { + continue; + } // LOGF(info, "collision-loop | bc.globalIndex() = %d, ncolls_per_bc = %d", bc.globalIndex(), map_ncolls_per_bc[bc.globalIndex()]); registry.fill(HIST("hEventCounter"), 1); @@ -152,48 +166,68 @@ struct CreateEMEvent { // 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(), - collision.numContrib(), collision.trackOccupancyInTimeRange()); + 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.multTPC(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); + event_mult(collision.multFT0A(), collision.multFT0C(), collision.multNTracksPV(), collision.multNTracksPVeta1(), collision.multNTracksPVetaHalf()); + + if constexpr (eventype != EMEventType::kEvent_JJ) { + event_weights(1.f); + } 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 constexpr (eventype == EMEventType::kEvent) { - event_cent(105.f, 105.f, 105.f, 105.f); - 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); + event_cent(105.f, 105.f, 105.f); + 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 if constexpr (eventype == EMEventType::kEvent_Cent) { - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV()); - 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); + event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); + 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 if constexpr (eventype == EMEventType::kEvent_Cent_Qvec) { - event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV()); + event_cent(collision.centFT0M(), collision.centFT0A(), collision.centFT0C()); - // std::vector qvec; - // std::copy(collision.qvecFT0MReVec().begin(), collision.qvecFT0MReVec().end(), std::back_inserter(qvec)); - // LOGF(info, "qvec.at(0) = %f", qvec.at(0)); - - // LOGF(info, "collision.qvecFT0MReVec()[0] = %f, collision.qvecFT0MImVec()[0] = %f, collision.qvecFT0MReVec()[1] = %f, collision.qvecFT0MImVec()[1] = %f", collision.qvecFT0MReVec()[0], collision.qvecFT0MImVec()[0], collision.qvecFT0MReVec()[1], collision.qvecFT0MImVec()[1]); - - if (collision.qvecFT0CReVec().size() >= 2) { // both harmonics 2,3 + 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) { // only harmonics 2 + } 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); + 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, 105.f); - 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); + event_cent(105.f, 105.f, 105.f); + 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); } } // end of collision loop map_ncolls_per_bc.clear(); } // end of skimEvent + void fillEventWeights(MyCollisionsMC const& collisions, aod::McCollisions const&, MyBCs const&) + { + for (auto& collision : collisions) { + if (!collision.has_mcCollision()) { + continue; + } + + 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))) { + continue; + } + auto mcCollision = collision.mcCollision(); + event_weights(mcCollision.weight()); + } + } + void processEvent(MyCollisions const& collisions, MyBCs const& bcs) { skimEvent(collisions, bcs); @@ -206,6 +240,13 @@ struct CreateEMEvent { } PROCESS_SWITCH(CreateEMEvent, processEventMC, "process event info", false); + void processEventJJMC(MyCollisionsMC const& collisions, aod::McCollisions const& mcCollisions, MyBCs const& bcs) + { + skimEvent(collisions, bcs); + fillEventWeights(collisions, mcCollisions, bcs); + } + PROCESS_SWITCH(CreateEMEvent, processEventJJMC, "process event info", false); + void processEvent_Cent(MyCollisions_Cent const& collisions, MyBCs const& bcs) { skimEvent(collisions, bcs); @@ -257,7 +298,7 @@ struct AssociatePhotonToEMEvent { for (int ig = 0; ig < ng; ig++) { eventIds(collision.globalIndex()); } // end of photon loop - } // end of collision loop + } // end of collision loop } // This struct is for both data and MC. diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx index af5e5e5de18..9786329b601 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.cxx @@ -39,6 +39,8 @@ #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "Common/Core/TableHelper.h" +#include "Common/Core/TPCVDriftManager.h" #include "Tools/KFparticle/KFUtilities.h" @@ -54,7 +56,8 @@ using namespace o2::constants::physics; using namespace o2::pwgem::photonmeson; using std::array; -using MyCollisions = Join; +using MyCollisions = soa::Join; +using MyCollisionsWithSWT = soa::Join; using MyCollisionsMC = soa::Join; using MyTracksIU = soa::Join; @@ -62,7 +65,9 @@ using MyTracksIUMC = soa::Join; struct PhotonConversionBuilder { Produces v0photonskf; + Produces v0photonskfcov; Produces v0legs; + Produces events_ngpcm; // CCDB options Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; @@ -71,6 +76,7 @@ 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"}; @@ -78,12 +84,16 @@ struct PhotonConversionBuilder { 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", 10, "min ncluster tpc"}; - Configurable mincrossedrows{"mincrossedrows", 10, "min crossed rows"}; + 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 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 Configurable maxpt_itsonly{"maxpt_itsonly", 0.15, "max pT for ITSonly tracks at SV"}; Configurable maxTPCNsigmaEl{"maxTPCNsigmaEl", 4.0, "max. TPC n sigma for electron"}; + Configurable minTPCNsigmaEl{"minTPCNsigmaEl", -4.0, "min. TPC n sigma for electron"}; 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. @@ -123,6 +133,7 @@ struct PhotonConversionBuilder { Service ccdb; o2::base::MatLayerCylSet* lut = nullptr; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; + o2::aod::common::TPCVDriftManager mVDriftMgr; HistogramRegistry registry{ "registry", @@ -132,7 +143,7 @@ struct PhotonConversionBuilder { {"V0/hConversionPointXY", "conversion point in XY;X (cm);Y (cm)", {HistType::kTH2F, {{400, -100.0f, 100.0f}, {400, -100.f, 100.f}}}}, {"V0/hConversionPointRZ", "conversion point in RZ;Z (cm);R_{xy} (cm)", {HistType::kTH2F, {{200, -100.0f, 100.0f}, {200, 0.f, 100.f}}}}, {"V0/hPt", "pT of V0 at PV;p_{T,#gamma} (GeV/c)", {HistType::kTH1F, {{1000, 0.0f, 10.0f}}}}, - {"V0/hEtaPhi", "#eta vs. #varphi of V0 at PV;#varphi (rad.);#eta", {HistType::kTH2F, {{72, 0.0f, 2 * M_PI}, {400, -2, +2}}}}, + {"V0/hEtaPhi", "#eta vs. #varphi of V0 at PV;#varphi (rad.);#eta", {HistType::kTH2F, {{72, 0.0f, 2 * M_PI}, {200, -1, +1}}}}, {"V0/hCosPA", "cosine of pointing angle;cosine of pointing angle", {HistType::kTH1F, {{100, 0.9f, 1.f}}}}, {"V0/hCosPA_Rxy", "cosine of pointing angle;r_{xy} (cm);cosine of pointing angle", {HistType::kTH2F, {{200, 0, 100}, {100, 0.9f, 1.f}}}}, {"V0/hCosPAXY_Rxy", "cosine of pointing angle;r_{xy} (cm);cosine of pointing angle", {HistType::kTH2F, {{200, 0, 100}, {100, 0.9f, 1.f}}}}, @@ -149,14 +160,14 @@ struct PhotonConversionBuilder { {"V0/hRxy_minX_TPC_TPC", "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}}}}, {"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}, {400, -2, +2}}}}, + {"V0Leg/hEtaPhi", "#eta vs. #varphi of leg at SV;#varphi (rad.);#eta", {HistType::kTH2F, {{72, 0.0f, 2 * M_PI}, {200, -1, +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&) + void init(InitContext& initContext) { mRunNumber = 0; d_bz = 0; @@ -168,6 +179,10 @@ 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()) { @@ -179,10 +194,12 @@ struct PhotonConversionBuilder { lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); } - if (useMatCorrType == 1) + if (useMatCorrType == 1) { matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; - if (useMatCorrType == 2) + } + if (useMatCorrType == 2) { matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + } } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -204,18 +221,19 @@ struct PhotonConversionBuilder { } auto run3grp_timestamp = bc.timestamp(); - o2::parameters::GRPObject* grpo = 0x0; - o2::parameters::GRPMagField* grpmag = 0x0; - if (!skipGRPOquery) + o2::parameters::GRPObject* grpo = nullptr; + o2::parameters::GRPMagField* grpmag = nullptr; + if (!skipGRPOquery) { grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); - if (grpo) { + } + if (grpo != nullptr) { 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) { + if (grpmag == nullptr) { 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); @@ -230,8 +248,17 @@ struct PhotonConversionBuilder { o2::base::Propagator::Instance()->setMatLUT(lut); } /// Set magnetic field for KF vertexing - float magneticField = o2::base::Propagator::Instance()->getNominalBz(); + const float magneticField = o2::base::Propagator::Instance()->getNominalBz(); KFParticle::SetField(magneticField); + + mVDriftMgr.init(&ccdb->instance()); + } + + void updateCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + auto timestamp = bc.timestamp(); + + mVDriftMgr.update(timestamp); } std::pair> its_ib_Requirement = {0, {0, 1, 2}}; // no hit on 3 ITS ib layers. @@ -244,6 +271,10 @@ struct PhotonConversionBuilder { } } + if (disableITSonlyTracks && isITSonlyTrack(track)) { + return false; + } + if (track.x() > maxX) { return false; } @@ -263,7 +294,7 @@ struct PhotonConversionBuilder { if (track.tpcNClsCrossedRows() < mincrossedrows || track.tpcChi2NCl() > maxchi2tpc) { return false; } - if (abs(track.tpcNSigmaEl()) > maxTPCNsigmaEl) { + if (track.tpcNSigmaEl() < minTPCNsigmaEl || maxTPCNsigmaEl < track.tpcNSigmaEl()) { return false; } } @@ -335,25 +366,25 @@ struct PhotonConversionBuilder { return cospaRZ; } - template - void fillTrackTable(TTrack const& track, TKFParticle const& kfp, float dcaXY, float dcaZ) + template + void fillTrackTable(TTrack const& track, TShiftedTrack const& shiftedtrack, TKFParticle const& kfp, float dcaXY, float dcaZ) { v0legs(track.collisionId(), track.globalIndex(), track.sign(), kfp.GetPx(), kfp.GetPy(), kfp.GetPz(), dcaXY, dcaZ, - track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), + track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), track.tpcChi2NCl(), track.tpcInnerParam(), track.tpcSignal(), track.tpcNSigmaEl(), track.tpcNSigmaPi(), track.itsClusterSizes(), track.itsChi2NCl(), track.detectorMap(), - track.x(), track.y(), track.z(), track.tgl()); + shiftedtrack.getX(), shiftedtrack.getY(), shiftedtrack.getZ(), shiftedtrack.getTgl()); } - template + template void fillV0Table(TV0 const& v0, const bool filltable) { // Get tracks - auto pos = v0.template posTrack_as(); - auto ele = v0.template negTrack_as(); - auto collision = v0.template collision_as(); // collision where this v0 belongs to. + 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. if (pos.sign() * ele.sign() > 0) { // reject same sign pair return; @@ -370,6 +401,7 @@ struct PhotonConversionBuilder { if (isITSonlyTrack(pos) && !ele.hasITS()) { return; } + if (isITSonlyTrack(ele) && !pos.hasITS()) { return; } @@ -377,20 +409,31 @@ struct PhotonConversionBuilder { if (!checkV0leg(pos) || !checkV0leg(ele)) { return; } + // LOGF(info, "v0.collisionId() = %d , v0.posTrackId() = %d , v0.negTrackId() = %d", v0.collisionId(), v0.posTrackId(), v0.negTrackId()); // Calculate DCA with respect to the collision associated to the v0, not individual tracks gpu::gpustd::array dcaInfo; auto pTrack = getTrackParCov(pos); - pTrack.setPID(o2::track::PID::Electron); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, pTrack, 2.f, matCorr, &dcaInfo); + if (moveTPCTracks && isTPConlyTrack(pos) && !mVDriftMgr.moveTPCTrack(collision, pos, pTrack)) { + LOGP(error, "failed correction for positive tpc track"); + return; + } + auto pTrackC = pTrack; + pTrackC.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, pTrackC, 2.f, matCorr, &dcaInfo); auto posdcaXY = dcaInfo[0]; auto posdcaZ = dcaInfo[1]; auto nTrack = getTrackParCov(ele); - nTrack.setPID(o2::track::PID::Electron); - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, nTrack, 2.f, matCorr, &dcaInfo); + if (moveTPCTracks && isTPConlyTrack(ele) && !mVDriftMgr.moveTPCTrack(collision, ele, nTrack)) { + LOGP(error, "failed correction for negative tpc track"); + return; + } + auto nTrackC = nTrack; + nTrackC.setPID(o2::track::PID::Electron); + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, nTrackC, 2.f, matCorr, &dcaInfo); auto eledcaXY = dcaInfo[0]; auto eledcaZ = dcaInfo[1]; @@ -399,17 +442,17 @@ struct PhotonConversionBuilder { } float xyz[3] = {0.f, 0.f, 0.f}; - Vtx_recalculation(o2::base::Propagator::Instance(), pos, ele, xyz, matCorr); + Vtx_recalculationParCov(o2::base::Propagator::Instance(), pTrack, nTrack, xyz, matCorr); float rxy_tmp = RecoDecay::sqrtSumOfSquares(xyz[0], xyz[1]); if (rxy_tmp > maxX + margin_r_tpc) { return; } - if (rxy_tmp < abs(xyz[2]) * TMath::Tan(2 * TMath::ATan(TMath::Exp(-max_eta_v0))) - margin_z) { + if (rxy_tmp < fabs(xyz[2]) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { return; // RZ line cut } - KFPTrack kfp_track_pos = createKFPTrackFromTrack(pos); - KFPTrack kfp_track_ele = createKFPTrackFromTrack(ele); + KFPTrack kfp_track_pos = createKFPTrackFromTrackParCov(pTrack, pos.sign(), pos.tpcNClsFound(), pos.tpcChi2NCl()); + KFPTrack kfp_track_ele = createKFPTrackFromTrackParCov(nTrack, ele.sign(), ele.tpcNClsFound(), ele.tpcChi2NCl()); KFParticle kfp_pos(kfp_track_pos, -11); KFParticle kfp_ele(kfp_track_ele, 11); const KFParticle* GammaDaughters[2] = {&kfp_pos, &kfp_ele}; @@ -442,7 +485,7 @@ struct PhotonConversionBuilder { if (rxy > maxX + margin_r_tpc) { return; } - if (rxy < abs(gammaKF_DecayVtx.GetZ()) * TMath::Tan(2 * TMath::ATan(TMath::Exp(-max_eta_v0))) - margin_z) { + if (rxy < fabs(gammaKF_DecayVtx.GetZ()) * std::tan(2 * std::atan(std::exp(-max_eta_v0))) - margin_z) { return; // RZ line cut } if (rxy < min_v0radius) { @@ -451,30 +494,30 @@ struct PhotonConversionBuilder { if (!filltable) { if (isITSTPCTrack(pos) && isITSTPCTrack(ele)) { - registry.fill(HIST("V0/hRxy_minX_ITSTPC_ITSTPC"), std::min(pos.x(), ele.x()), std::min(pos.x(), ele.x()) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hRxy_minX_ITSTPC_ITSTPC"), std::min(pTrack.getX(), nTrack.getX()), std::min(pTrack.getX(), nTrack.getX()) - rxy); // trackiu.x() - rxy should be positive } else if (isITSonlyTrack(pos) && isITSonlyTrack(ele)) { - registry.fill(HIST("V0/hRxy_minX_ITSonly_ITSonly"), std::min(pos.x(), ele.x()), std::min(pos.x(), ele.x()) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hRxy_minX_ITSonly_ITSonly"), std::min(pTrack.getX(), nTrack.getX()), std::min(pTrack.getX(), nTrack.getX()) - rxy); // trackiu.x() - rxy should be positive } else if ((isITSTPCTrack(pos) && isITSonlyTrack(ele)) || (isITSTPCTrack(ele) && isITSonlyTrack(pos))) { - registry.fill(HIST("V0/hRxy_minX_ITSTPC_ITSonly"), std::min(pos.x(), ele.x()), std::min(pos.x(), ele.x()) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hRxy_minX_ITSTPC_ITSonly"), std::min(pTrack.getX(), nTrack.getX()), std::min(pTrack.getX(), nTrack.getX()) - rxy); // trackiu.x() - rxy should be positive } else if (isITSTPCTrack(pos) && !ele.hasITS()) { - registry.fill(HIST("V0/hRxy_minX_ITSTPC_TPC"), std::min(pos.x(), 83.f), std::min(pos.x(), 83.f) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hRxy_minX_ITSTPC_TPC"), std::min(pTrack.getX(), 83.f), std::min(pTrack.getX(), 83.f) - rxy); // trackiu.x() - rxy should be positive } else if (isITSTPCTrack(ele) && !pos.hasITS()) { - registry.fill(HIST("V0/hRxy_minX_ITSTPC_TPC"), std::min(ele.x(), 83.f), std::min(ele.x(), 83.f) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hRxy_minX_ITSTPC_TPC"), std::min(nTrack.getX(), 83.f), std::min(nTrack.getX(), 83.f) - rxy); // trackiu.x() - rxy should be positive } else { registry.fill(HIST("V0/hRxy_minX_TPC_TPC"), std::min(83.f, 83.f), std::min(83.f, 83.f) - rxy); // trackiu.x() - rxy should be positive } } if (pos.hasITS() && ele.hasITS()) { // ITSonly-ITSonly, ITSTPC-ITSTPC, ITSTPC-ITSonly - if (rxy > std::min(pos.x(), ele.x()) + margin_r_its) { + if (rxy > std::min(pTrack.getX(), nTrack.getX()) + margin_r_its) { return; } } else if (!pos.hasITS() && ele.hasITS()) { // ITSTPC-TPC - if (rxy > std::min(83.f, ele.x()) + margin_r_itstpc_tpc) { + if (rxy > std::min(83.f, nTrack.getX()) + margin_r_itstpc_tpc) { return; } } else if (pos.hasITS() && !ele.hasITS()) { // ITSTPC-TPC - if (rxy > std::min(pos.x(), 83.f) + margin_r_itstpc_tpc) { + if (rxy > std::min(pTrack.getX(), 83.f) + margin_r_itstpc_tpc) { return; } } else if (!pos.hasITS() && !ele.hasITS()) { // TPC-TPC @@ -587,7 +630,7 @@ struct PhotonConversionBuilder { registry.fill(HIST("V0/hPCA_CosPA"), cospa_kf, pca_kf); registry.fill(HIST("V0/hPCA_Rxy"), rxy, pca_kf); registry.fill(HIST("V0/hDCAxyz"), dca_xy_v0_to_pv, dca_z_v0_to_pv); - registry.fill(HIST("V0/hPCA_diffX"), pca_kf, std::min(pos.x(), ele.x()) - rxy); // trackiu.x() - rxy should be positive + registry.fill(HIST("V0/hPCA_diffX"), pca_kf, std::min(pTrack.getX(), nTrack.getX()) - rxy); // trackiu.x() - rxy should be positive float cospaXY_kf = cospaXY_KF(gammaKF_DecayVtx, KFPV); float cospaRZ_kf = cospaRZ_KF(gammaKF_DecayVtx, KFPV); @@ -607,8 +650,9 @@ struct PhotonConversionBuilder { for (auto& leg : {pos, ele}) { registry.fill(HIST("V0Leg/hdEdx_Pin"), leg.tpcInnerParam(), leg.tpcSignal()); registry.fill(HIST("V0Leg/hTPCNsigmaEl"), leg.tpcInnerParam(), leg.tpcNSigmaEl()); - registry.fill(HIST("V0Leg/hXZ"), leg.z(), leg.x()); } // end of leg loop + registry.fill(HIST("V0Leg/hXZ"), pTrack.getZ(), pTrack.getX()); + registry.fill(HIST("V0Leg/hXZ"), nTrack.getZ(), nTrack.getX()); registry.fill(HIST("V0Leg/hDCAxyz"), posdcaXY, posdcaZ); registry.fill(HIST("V0Leg/hDCAxyz"), eledcaXY, eledcaZ); @@ -617,48 +661,70 @@ struct PhotonConversionBuilder { ROOT::Math::PxPyPzMVector v0_sv = vpos_sv + vele_sv; registry.fill(HIST("V0/hMeeSV_Rxy"), rxy, v0_sv.M()); - v0photonskf(collision.globalIndex(), v0legs.lastIndex() + 1, v0legs.lastIndex() + 2, + 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); - fillTrackTable(pos, kfp_pos_DecayVtx, posdcaXY, posdcaZ); // positive leg first - fillTrackTable(ele, kfp_ele_DecayVtx, eledcaXY, eledcaZ); // negative leg second - } // end of fill table + 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 + } // end of fill table } Preslice perCollision = o2::aod::v0::collisionId; - std::map, float> pca_map; //(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> pca - std::map, float> cospa_map; //(v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> cospa - std::vector> stored_v0Ids; //(pos.globalIndex(), ele.globalIndex()) - - template - void build(TCollisions const& collisions, TV0s const& v0s, TTracks const& /*tracks*/, TBCs const&) + std::map, float> pca_map; // (v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> pca + std::map, float> cospa_map; // (v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) -> cospa + std::vector> stored_v0Ids; // (pos.globalIndex(), ele.globalIndex()) + std::vector> stored_fullv0Ids; // (v0.globalIndex(), collision.globalIndex(), pos.globalIndex(), ele.globalIndex()) + std::unordered_map nv0_map; // map collisionId -> nv0 + + template + void build(TCollisions const& collisions, TV0s const& v0s, TTracks const&, TBCs const&) { - for (auto& collision : collisions) { + for (const auto& collision : collisions) { if constexpr (isMC) { if (!collision.has_mcCollision()) { 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))) { - continue; + + if constexpr (enableFilter) { + if (!collision.isSelected()) { + continue; + } } - auto bc = collision.template bc_as(); + if constexpr (isTriggerAnalysis) { + if (collision.swtaliastmp_raw() == 0) { + continue; + } + } + + nv0_map[collision.globalIndex()] = 0; + + const auto& bc = collision.template bc_as(); initCCDB(bc); registry.fill(HIST("hCollisionCounter"), 1); - auto v0s_per_coll = v0s.sliceBy(perCollision, collision.globalIndex()); + 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()); // LOGF(info, "n v0 = %d", v0s_per_coll.size()); - for (auto& v0 : v0s_per_coll) { + for (const auto& v0 : v0s_per_coll) { // LOGF(info, "collision.globalIndex() = %d, v0.globalIndex() = %d, v0.posTrackId() = %d, v0.negTrackId() = %d", collision.globalIndex(), v0.globalIndex(), v0.posTrackId() , v0.negTrackId()); - fillV0Table(v0, false); + fillV0Table(v0, false); } // end of v0 loop - } // end of collision loop + } // end of collision loop - stored_v0Ids.reserve(pca_map.size()); // number of photon candidates per DF + stored_v0Ids.reserve(pca_map.size()); // number of photon candidates per DF + stored_fullv0Ids.reserve(pca_map.size()); // number of photon candidates per DF // find minimal pca for (const auto& [key, value] : pca_map) { @@ -698,20 +764,55 @@ struct PhotonConversionBuilder { bool is_stored = std::find(stored_v0Ids.begin(), stored_v0Ids.end(), std::make_pair(posId, eleId)) != stored_v0Ids.end(); if (is_closest_v0 && is_most_aligned_v0 && !is_stored) { - auto v0 = v0s.rawIteratorAt(v0Id); + // auto v0 = v0s.rawIteratorAt(v0Id); // auto collision = collisions.rawIteratorAt(collisionId); // auto pos = tracks.rawIteratorAt(posId); // auto ele = tracks.rawIteratorAt(eleId); // LOGF(info, "!accept! | collision id = %d | v0id1 = %d , posid1 = %d , eleid1 = %d , pca1 = %f , cospa = %f", collisionId, v0Id, posId, eleId, v0pca, cospa); - fillV0Table(v0, true); + + // fillV0Table(v0, true); stored_v0Ids.emplace_back(std::make_pair(posId, eleId)); + stored_fullv0Ids.emplace_back(std::make_tuple(v0Id, collisionId, posId, eleId)); + nv0_map[collisionId]++; } } // end of pca_map loop // LOGF(info, "pca_map.size() = %d", pca_map.size()); + + for (auto& fullv0Id : stored_fullv0Ids) { + auto v0Id = std::get<0>(fullv0Id); + // auto collisionId = std::get<1>(fullv0Id); + // auto posId = std::get<2>(fullv0Id); + // auto eleId = std::get<3>(fullv0Id); + // LOGF(info, "!accept! | collision id = %d | v0id = %d , posid = %d , eleid = %d", collisionId, v0Id, posId, eleId); + + auto v0 = v0s.rawIteratorAt(v0Id); + if constexpr (enableFilter) { + auto collision_tmp = v0.template collision_as(); // collision where this v0 belongs. + if (!(collision_tmp.neeuls() >= 1 || collision_tmp.neeuls() + nv0_map[collision_tmp.globalIndex()] >= 2)) { + continue; + } + // LOGF(info, "collision_tmp.globalIndex() = %d, collision_tmp.neeuls() = %d, nv0_map = %d", collision_tmp.globalIndex(), collision_tmp.neeuls(), nv0_map[collision_tmp.globalIndex()]); + } + + fillV0Table(v0, true); + } // end of fullv0Id loop + + for (auto& collision : collisions) { + if constexpr (isMC) { + if (!collision.has_mcCollision()) { + continue; + } + } + events_ngpcm(nv0_map[collision.globalIndex()]); + } // end of collision loop + pca_map.clear(); cospa_map.clear(); + nv0_map.clear(); stored_v0Ids.clear(); stored_v0Ids.shrink_to_fit(); + stored_fullv0Ids.clear(); + stored_fullv0Ids.shrink_to_fit(); } // end of build //! 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. @@ -720,15 +821,33 @@ struct PhotonConversionBuilder { void processRec(MyCollisions const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) { - build(collisions, v0s, tracks, bcs); + build(collisions, v0s, tracks, bcs); } PROCESS_SWITCH(PhotonConversionBuilder, processRec, "process reconstructed info for data", true); + void processRec_SWT(MyCollisionsWithSWT const& collisions, filteredV0s const& v0s, MyTracksIU const& tracks, aod::BCsWithTimestamps const& bcs) + { + build(collisions, v0s, tracks, bcs); + } + PROCESS_SWITCH(PhotonConversionBuilder, processRec_SWT, "process reconstructed info for data", false); + void processMC(MyCollisionsMC const& collisions, filteredV0s const& v0s, MyTracksIUMC const& tracks, aod::BCsWithTimestamps const& bcs) { - build(collisions, v0s, tracks, bcs); + build(collisions, v0s, tracks, bcs); } 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) + { + 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) + { + build(collisions, v0s, tracks, bcs); + } + PROCESS_SWITCH(PhotonConversionBuilder, processRec_SWT_OnlyIfDielectron, "process reconstructed info for data", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx b/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx index c3843080eaf..aff407a83f3 100644 --- a/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx +++ b/PWGEM/PhotonMeson/TableProducer/skimmerGammaCalo.cxx @@ -13,10 +13,14 @@ /// dependencies: emcal-correction-task /// \author marvin.hemmer@cern.ch +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Common/Core/TableHelper.h" + // includes for the R recalculation #include "DetectorsBase/GeometryManager.h" #include "DataFormatsParameters/GRPObject.h" @@ -44,44 +48,57 @@ struct skimmerGammaCalo { Configurable maxTime{"maxTime", +200., "Maximum cluster time for time cut"}; Configurable minM02{"minM02", 0.0, "Minimum M02 for M02 cut"}; Configurable maxM02{"maxM02", 1.0, "Maximum M02 for M02 cut"}; - Configurable hasPropagatedTracks{"hasPropagatedTracks", false, "temporary flag, only set to true when running over data which has the tracks propagated to EMCal/PHOS!"}; + Configurable minE{"minE", 0.5, "Minimum energy for energy cut"}; + 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"}; - HistogramRegistry historeg{ - "historeg", - {}, - OutputObjHandlingPolicy::QAObject, - false, - true}; + HistogramRegistry historeg{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; - void init(o2::framework::InitContext&) + void init(o2::framework::InitContext& initContext) { historeg.add("hCaloClusterEIn", "hCaloClusterEIn", gHistoSpec_clusterE); historeg.add("hCaloClusterEOut", "hCaloClusterEOut", gHistoSpec_clusterE); - historeg.add("hMTEtaPhi", "hMTEtaPhi", gHistoSpec_EtaPhi); - auto hCaloClusterFilter = historeg.add("hCaloClusterFilter", "hCaloClusterFilter", kTH1I, {{4, 0, 4}}); + historeg.add("hMTEtaPhi", "hMTEtaPhi", gHistoSpec_clusterTM_dEtadPhi); + auto hCaloClusterFilter = historeg.add("hCaloClusterFilter", "hCaloClusterFilter", kTH1I, {{5, 0, 5}}); hCaloClusterFilter->GetXaxis()->SetBinLabel(1, "in"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(2, "time cut"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(3, "M02 cut"); - hCaloClusterFilter->GetXaxis()->SetBinLabel(4, "out"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(2, "E cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(3, "time cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(4, "M02 cut"); + hCaloClusterFilter->GetXaxis()->SetBinLabel(5, "out"); - LOG(info) << "| Timing cut: " << minTime << " < t < " << maxTime << std::endl; - LOG(info) << "| M02 cut: " << minM02 << " < M02 < " << maxM02 << std::endl; + if (inherit_from_emevent_photon) { + getTaskOptionValue(initContext, "create-emevent-photon", "applyEveSel_at_skimming", applyEveSel_at_skimming.value, true); // for EM users. + } + + LOG(info) << "| Timing cut: " << minTime << " < t < " << maxTime; + LOG(info) << "| M02 cut: " << minM02 << " < M02 < " << maxM02; + LOG(info) << "| E cut: E > " << minE; } - void processRec(aod::Collision const&, 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))) { + return; + } for (const auto& emccluster : emcclusters) { historeg.fill(HIST("hCaloClusterEIn"), emccluster.energy()); historeg.fill(HIST("hCaloClusterFilter"), 0); + // Energy cut + if (emccluster.energy() < minE) { + historeg.fill(HIST("hCaloClusterFilter"), 1); + continue; + } // timing cut if (emccluster.time() > maxTime || emccluster.time() < minTime) { - historeg.fill(HIST("hCaloClusterFilter"), 1); + historeg.fill(HIST("hCaloClusterFilter"), 2); continue; } // M02 cut if (emccluster.nCells() > 1 && (emccluster.m02() > maxM02 || emccluster.m02() < minM02)) { - historeg.fill(HIST("hCaloClusterFilter"), 2); + historeg.fill(HIST("hCaloClusterFilter"), 3); continue; } @@ -104,50 +121,43 @@ struct skimmerGammaCalo { vP.reserve(groupedMTs.size()); vPt.reserve(groupedMTs.size()); for (const auto& emcmatchedtrack : groupedMTs) { - if (hasPropagatedTracks) { // only temporarily while not every data has the tracks propagated to EMCal/PHOS - historeg.fill(HIST("hMTEtaPhi"), 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()); - 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()); - } else { - historeg.fill(HIST("hMTEtaPhi"), emccluster.eta() - emcmatchedtrack.track_as().eta(), emccluster.phi() - emcmatchedtrack.track_as().phi()); - vTrackIds.emplace_back(emcmatchedtrack.trackId()); - vEta.emplace_back(emcmatchedtrack.track_as().eta()); - vPhi.emplace_back(emcmatchedtrack.track_as().phi()); - vP.emplace_back(emcmatchedtrack.track_as().p()); - vPt.emplace_back(emcmatchedtrack.track_as().pt()); - tableTrackEMCReco(emcmatchedtrack.emcalclusterId(), emcmatchedtrack.track_as().eta(), emcmatchedtrack.track_as().phi(), - emcmatchedtrack.track_as().p(), emcmatchedtrack.track_as().pt()); + if (std::abs(emccluster.eta() - emcmatchedtrack.track_as().trackEtaEmcal()) >= maxdEta || std::abs(emccluster.phi() - emcmatchedtrack.track_as().trackPhiEmcal()) >= maxdPhi) { + continue; } + historeg.fill(HIST("hMTEtaPhi"), 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()); + 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"), 3); + historeg.fill(HIST("hCaloClusterFilter"), 4); - tableGammaEMCReco(emccluster.collisionId(), emccluster.id(), - emccluster.energy(), emccluster.coreEnergy(), emccluster.eta(), emccluster.phi(), emccluster.m02(), - emccluster.m20(), emccluster.nCells(), emccluster.time(), emccluster.isExotic(), emccluster.distanceToBadChannel(), emccluster.nlm(), - emccluster.definition(), vTrackIds, vEta, vPhi, vP, vPt); + tableGammaEMCReco(emccluster.collisionId(), emccluster.energy(), emccluster.eta(), emccluster.phi(), emccluster.m02(), + emccluster.nCells(), emccluster.time(), emccluster.isExotic(), vEta, vPhi, vP, vPt); } } - void processMC(aod::Collision const&, 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))) { + return; + } for (const auto& emccluster : emcclusters) { - historeg.fill(HIST("hCaloClusterEIn"), emccluster.energy()); - historeg.fill(HIST("hCaloClusterFilter"), 0); + // Energy cut + if (emccluster.energy() < minE) { + continue; + } // timing cut if (emccluster.time() > maxTime || emccluster.time() < minTime) { - historeg.fill(HIST("hCaloClusterFilter"), 1); continue; } // M02 cut if (emccluster.nCells() > 1 && (emccluster.m02() > maxM02 || emccluster.m02() < minM02)) { - historeg.fill(HIST("hCaloClusterFilter"), 2); continue; } std::vector mcLabels; diff --git a/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx b/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx index 40334a036c0..bed52425fb5 100644 --- a/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx +++ b/PWGEM/PhotonMeson/TableProducer/skimmerGammaConversion.cxx @@ -181,7 +181,7 @@ struct skimmerGammaConversion { v0legs(theTrack.collisionId(), theTrack.globalIndex(), theTrack.sign(), kfp.GetPx(), kfp.GetPy(), kfp.GetPz(), theTrack.dcaXY(), theTrack.dcaZ(), - theTrack.tpcNClsFindable(), theTrack.tpcNClsFindableMinusFound(), theTrack.tpcNClsFindableMinusCrossedRows(), + theTrack.tpcNClsFindable(), theTrack.tpcNClsFindableMinusFound(), theTrack.tpcNClsFindableMinusCrossedRows(), theTrack.tpcNClsShared(), theTrack.tpcChi2NCl(), theTrack.tpcInnerParam(), theTrack.tpcSignal(), theTrack.tpcNSigmaEl(), theTrack.tpcNSigmaPi(), theTrack.itsClusterSizes(), theTrack.itsChi2NCl(), theTrack.detectorMap(), @@ -304,7 +304,7 @@ struct skimmerGammaConversion { float sign_tmp = dca_y_v0_to_pv > 0 ? +1 : -1; float dca_xy_v0_to_pv = RecoDecay::sqrtSumOfSquares(dca_x_v0_to_pv, dca_y_v0_to_pv) * sign_tmp; - v0photonskf(collision.globalIndex(), v0legs.lastIndex() + 1, v0legs.lastIndex() + 2, + v0photonskf(collision.globalIndex(), v0.globalIndex(), v0legs.lastIndex() + 1, v0legs.lastIndex() + 2, 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, @@ -342,7 +342,7 @@ struct skimmerGammaConversion { fillV0KF(collision, v0); } // end of v0 loop - } // end of collision loop + } // end of collision loop } PROCESS_SWITCH(skimmerGammaConversion, processRec, "process reconstructed info only", true); diff --git a/PWGEM/PhotonMeson/Tasks/CMakeLists.txt b/PWGEM/PhotonMeson/Tasks/CMakeLists.txt index 2291137a4c6..82dd5775d75 100644 --- a/PWGEM/PhotonMeson/Tasks/CMakeLists.txt +++ b/PWGEM/PhotonMeson/Tasks/CMakeLists.txt @@ -26,12 +26,12 @@ o2physics_add_dpl_workflow(emc-pi0-qc o2physics_add_dpl_workflow(pcm-qc SOURCES pcmQC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(pcm-qc-mc SOURCES pcmQCMC.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore O2Physics::PWGEMDileptonCore + PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(dalitz-ee-qc @@ -124,3 +124,7 @@ o2physics_add_dpl_workflow(check-mc-v0 PUBLIC_LINK_LIBRARIES O2::Framework O2::DCAFitter O2Physics::AnalysisCore COMPONENT_NAME Analysis) +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) diff --git a/PWGEM/PhotonMeson/Tasks/MaterialBudget.cxx b/PWGEM/PhotonMeson/Tasks/MaterialBudget.cxx index f2b0dcd4d12..b5c1a5d8fde 100644 --- a/PWGEM/PhotonMeson/Tasks/MaterialBudget.cxx +++ b/PWGEM/PhotonMeson/Tasks/MaterialBudget.cxx @@ -62,7 +62,7 @@ struct MaterialBudget { Configurable fDoMixing{"DoMixing", false, "do event mixing"}; Configurable fConfigEMEventCut{"cfgEMEventCut", "minbias", "em event cut"}; // only 1 event cut per wagon - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; diff --git a/PWGEM/PhotonMeson/Tasks/MaterialBudgetMC.cxx b/PWGEM/PhotonMeson/Tasks/MaterialBudgetMC.cxx index 7cdefdc3f74..3fe51c1ff7c 100644 --- a/PWGEM/PhotonMeson/Tasks/MaterialBudgetMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/MaterialBudgetMC.cxx @@ -71,7 +71,7 @@ struct MaterialBudgetMC { Configurable fConfigPairCuts{"cfgPairCuts", "nocut", "Comma separated list of pair cuts"}; Configurable fConfigEMEventCut{"cfgEMEventCut", "minbias", "em event cut"}; // only 1 event cut per wagon - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; diff --git a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaEMCEMC.cxx b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaEMCEMC.cxx index 30ab6b734f2..3b7893f7373 100644 --- a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaEMCEMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaEMCEMC.cxx @@ -32,6 +32,6 @@ using MyEMCCluster = MyEMCClusters::iterator; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask>(cfgc, TaskName{"pi0eta-to-gammagamma-emcemc"}), + adaptAnalysisTask>(cfgc, TaskName{"pi0eta-to-gammagamma-emcemc"}), }; } diff --git a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCEMCEMC.cxx b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCEMCEMC.cxx index 3de63aaad4a..7cd7ba3c492 100644 --- a/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCEMCEMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/Pi0EtaToGammaGammaMCEMCEMC.cxx @@ -32,6 +32,6 @@ using MyEMCCluster = MyEMCClusters::iterator; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask>(cfgc, TaskName{"pi0eta-to-gammagamma-mc-emcemc"}), + adaptAnalysisTask>(cfgc, TaskName{"pi0eta-to-gammagamma-mc-emcemc"}), }; } diff --git a/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx b/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx index bae378ab8ff..9c82fa7b09a 100644 --- a/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx +++ b/PWGEM/PhotonMeson/Tasks/SinglePhoton.cxx @@ -82,7 +82,7 @@ struct SinglePhoton { 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 - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; @@ -228,10 +228,10 @@ struct SinglePhoton { custom_cut->SetM02Range(EMC_minM02, EMC_maxM02); custom_cut->SetTimeRange(EMC_minTime, EMC_maxTime); - custom_cut->SetTrackMatchingEta([&a, &b, &c](float pT) { + custom_cut->SetTrackMatchingEta([a, b, c](float pT) { return a + pow(pT + b, c); }); - custom_cut->SetTrackMatchingPhi([&d, &e, &f](float pT) { + custom_cut->SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); @@ -331,8 +331,8 @@ struct SinglePhoton { reinterpret_cast(list_photon_det_cut->FindObject("hY"))->Fill(photon.eta()); reinterpret_cast(list_photon_det_cut->FindObject("hPhi"))->Fill(photon.phi()); } // 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. diff --git a/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx b/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx index 159ea287009..ccb33db7f3a 100644 --- a/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/SinglePhotonMC.cxx @@ -90,7 +90,7 @@ struct SinglePhotonMC { // 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 - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; diff --git a/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx b/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx index 938809d9863..2f91a62dc43 100644 --- a/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx +++ b/PWGEM/PhotonMeson/Tasks/TagAndProbe.cxx @@ -69,7 +69,7 @@ struct TagAndProbe { Configurable minOpenAngle{"minOpenAngle", 0.0202, "apply min opening angle"}; Configurable fConfigEMEventCut{"cfgEMEventCut", "minbias", "em event cut"}; // only 1 event cut per wagon - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx index 0a654bc9955..4d00ddb1a21 100644 --- a/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx +++ b/PWGEM/PhotonMeson/Tasks/TaggingPi0.cxx @@ -93,7 +93,7 @@ struct TaggingPi0 { 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 - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; @@ -313,10 +313,10 @@ struct TaggingPi0 { custom_cut->SetM02Range(EMC_minM02, EMC_maxM02); custom_cut->SetTimeRange(EMC_minTime, EMC_maxTime); - custom_cut->SetTrackMatchingEta([&a, &b, &c](float pT) { + custom_cut->SetTrackMatchingEta([a, b, c](float pT) { return a + pow(pT + b, c); }); - custom_cut->SetTrackMatchingPhi([&d, &e, &f](float pT) { + custom_cut->SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); diff --git a/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx b/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx index 2fdbb6f6423..335e8195d8b 100644 --- a/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx +++ b/PWGEM/PhotonMeson/Tasks/TaggingPi0MC.cxx @@ -101,7 +101,7 @@ struct TaggingPi0MC { 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 - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; static constexpr std::string_view event_types[2] = {"before", "after"}; OutputObj fOutputEvent{"Event"}; @@ -330,10 +330,10 @@ struct TaggingPi0MC { custom_cut->SetM02Range(EMC_minM02, EMC_maxM02); custom_cut->SetTimeRange(EMC_minTime, EMC_maxTime); - custom_cut->SetTrackMatchingEta([&a, &b, &c](float pT) { + custom_cut->SetTrackMatchingEta([a, b, c](float pT) { return a + pow(pT + b, c); }); - custom_cut->SetTrackMatchingPhi([&d, &e, &f](float pT) { + custom_cut->SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); diff --git a/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx b/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx index b98652dfa89..5def3ca8e03 100644 --- a/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/dalitzEEQC.cxx @@ -14,6 +14,9 @@ // This code runs loop over dalitz ee table for dalitz QC. // Please write to: daiki.sekihata@cern.ch +#include +#include + #include "TString.h" #include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" @@ -28,10 +31,9 @@ #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" #include "PWGEM/Dilepton/Utils/PairUtilities.h" #include "PWGEM/PhotonMeson/Utils/EventHistograms.h" -#include "PWGEM/Dilepton/Utils/EMTrackUtilities.h" using namespace o2; using namespace o2::aod; @@ -59,7 +61,7 @@ struct DalitzEEQC { Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; @@ -211,7 +213,7 @@ struct DalitzEEQC { void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -220,7 +222,6 @@ struct DalitzEEQC { fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); } void DefineDileptonCut() @@ -350,6 +351,9 @@ struct DalitzEEQC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) { + 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 diff --git a/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx b/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx index b9031347600..0f8e539f323 100644 --- a/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/dalitzEEQCMC.cxx @@ -14,6 +14,9 @@ // This code runs loop over dalitz ee table for dalitz QC. // Please write to: daiki.sekihata@cern.ch +#include +#include + #include "TString.h" #include "Math/Vector4D.h" #include "Framework/runDataProcessing.h" @@ -28,11 +31,10 @@ #include "Common/Core/RecoDecay.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Core/DalitzEECut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.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/EMTrackUtilities.h" #include "PWGEM/Dilepton/Utils/PairUtilities.h" using namespace o2; @@ -63,7 +65,7 @@ struct DalitzEEQCMC { Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; Configurable maxY{"maxY", 0.9, "maximum rapidity for reconstructed particles"}; - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; @@ -238,7 +240,7 @@ struct DalitzEEQCMC { void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -247,7 +249,6 @@ struct DalitzEEQCMC { fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); } void DefineDileptonCut() @@ -376,7 +377,7 @@ struct DalitzEEQCMC { break; } } // end of primary/secondary selection - } // end of primary selection for same mother + } // end of primary selection for same mother } // fill track info that belong to true pairs. @@ -455,6 +456,9 @@ struct DalitzEEQCMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) { + 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 @@ -491,6 +495,9 @@ struct DalitzEEQCMC { if (!fEMEventCut.IsSelected(collision)) { continue; } + if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) { + continue; + } auto mccollision = collision.emmcevent_as(); auto posTracks_per_coll = posTracksMC->sliceByCachedUnsorted(o2::aod::emmcparticle::emmceventId, mccollision.globalIndex(), cache); @@ -552,7 +559,7 @@ struct DalitzEEQCMC { } } } // end of true ULS pair loop - } // end of collision loop + } // end of collision loop } PROCESS_SWITCH(DalitzEEQCMC, processGen, "run genrated info", true); diff --git a/PWGEM/PhotonMeson/Tasks/emcalQC.cxx b/PWGEM/PhotonMeson/Tasks/emcalQC.cxx index e0ec5d45e79..dc5590fd795 100644 --- a/PWGEM/PhotonMeson/Tasks/emcalQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/emcalQC.cxx @@ -14,6 +14,8 @@ // This code runs loop over EMCal clusters for EMCal QC. // Please write to: nicolas.strangmann@cern.ch +#include +#include #include #include "TString.h" #include "THashList.h" @@ -42,7 +44,7 @@ using namespace o2::framework::expressions; using namespace o2::soa; using namespace o2::aod::pwgem::photon; -using MyCollisions = soa::Join; +using MyCollisions = soa::Join; using MyCollision = MyCollisions::iterator; using MyEMCClusters = soa::Join; @@ -53,7 +55,7 @@ struct emcalQC { Configurable cfgDo2DQA{"cfgDo2DQA", true, "perform 2 dimensional cluster QA"}; 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"}; - EMEventCut fEMEventCut; + EMPhotonEventCut fEMEventCut; struct : ConfigurableGroup { std::string prefix = "eventcut_group"; Configurable cfgZvtxMax{"cfgZvtxMax", 10.f, "max. Zvtx"}; @@ -68,6 +70,7 @@ struct emcalQC { 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 onlyKeepWeightedEvents{"onlyKeepWeightedEvents", false, "flag to keep only weighted events (for JJ MCs) and remove all MB events (with weight = 1)"}; } eventcuts; EMCPhotonCut fEMCCut; @@ -88,7 +91,7 @@ struct emcalQC { void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -99,7 +102,6 @@ struct emcalQC { fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); fEMEventCut.SetRequireEMCReadoutInMB(eventcuts.cfgRequireEMCReadoutInMB); fEMEventCut.SetRequireEMCHardwareTriggered(eventcuts.cfgRequireEMCHardwareTriggered); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); } void DefineEMCCut() @@ -118,8 +120,8 @@ struct emcalQC { 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 + pow(pT + b, c); }); + fEMCCut.SetTrackMatchingPhi([d, e, f](float pT) { return d + pow(pT + e, f); }); fEMCCut.SetMinEoverP(emccuts.EMC_Eoverp); fEMCCut.SetUseExoticCut(emccuts.EMC_UseExoticCut); @@ -137,6 +139,14 @@ struct emcalQC { DefineEMEventCut(); o2::aod::pwgem::photonmeson::utils::eventhistogram::addEventHistograms(&fRegistry); + auto hEMCCollisionCounter = fRegistry.add("Event/hEMCCollisionCounter", "Number of collisions after event cuts", HistType::kTH1F, {{7, 0.5, 7.5}}, false); + hEMCCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hEMCCollisionCounter->GetXaxis()->SetBinLabel(2, "+TVX"); // TVX + hEMCCollisionCounter->GetXaxis()->SetBinLabel(3, "+|z|<10cm"); // TVX with z < 10cm + hEMCCollisionCounter->GetXaxis()->SetBinLabel(4, "+Sel8"); // TVX with z < 10cm and Sel8 + hEMCCollisionCounter->GetXaxis()->SetBinLabel(5, "+Good z vtx"); // TVX with z < 10cm and Sel8 and good z xertex + hEMCCollisionCounter->GetXaxis()->SetBinLabel(6, "+unique"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC) + hEMCCollisionCounter->GetXaxis()->SetBinLabel(7, "+EMC readout"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC) and kTVXinEMC o2::aod::pwgem::photonmeson::utils::clusterhistogram::addClusterHistograms(&fRegistry, cfgDo2DQA); } @@ -146,25 +156,50 @@ struct emcalQC { { for (auto& collision : collisions) { + if (eventcuts.onlyKeepWeightedEvents && fabs(collision.weight() - 1.) < 1E-10) { + continue; + } + + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 1); + if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + fRegistry.fill(HIST("Event/hEMCCollisionCounter"), 2); + if (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); + } + } + } + } + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision); if (!fEMEventCut.IsSelected(collision)) { continue; } + if (!(eventcuts.cfgOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgOccupancyMax)) { + 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 auto clusters_per_coll = clusters.sliceBy(perCollision, collision.collisionId()); - fRegistry.fill(HIST("Cluster/before/hNgamma"), clusters_per_coll.size()); + fRegistry.fill(HIST("Cluster/before/hNgamma"), clusters_per_coll.size(), collision.weight()); int ng = 0; for (auto& cluster : clusters_per_coll) { // Fill the cluster properties before applying any cuts - o2::aod::pwgem::photonmeson::utils::clusterhistogram::fillClusterHistograms<0>(&fRegistry, cluster, cfgDo2DQA); + o2::aod::pwgem::photonmeson::utils::clusterhistogram::fillClusterHistograms<0>(&fRegistry, cluster, cfgDo2DQA, collision.weight()); // Apply cuts one by one and fill in hClusterQualityCuts histogram - fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), 0., cluster.e()); - auto track = nullptr; + fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), 0., cluster.e(), collision.weight()); // Define two boleans to see, whether the cluster "survives" the EMC cluster cuts to later check, whether the cuts in this task align with the ones in EMCPhotonCut.h: bool survivesIsSelectedEMCalCuts = true; // Survives "manual" cuts listed in this task @@ -172,8 +207,8 @@ struct emcalQC { for (int icut = 0; icut < static_cast(EMCPhotonCut::EMCPhotonCuts::kNCuts); icut++) { // Loop through different cut observables EMCPhotonCut::EMCPhotonCuts specificcut = static_cast(icut); - if (!fEMCCut.IsSelectedEMCal(specificcut, cluster, track)) { // Check whether cluster passes this cluster requirement, if not, fill why in the next row - fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), icut + 1, cluster.e()); + if (!fEMCCut.IsSelectedEMCal(specificcut, cluster)) { // Check whether cluster passes this cluster requirement, if not, fill why in the next row + fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), icut + 1, cluster.e(), collision.weight()); survivesIsSelectedEMCalCuts = false; } } @@ -183,14 +218,14 @@ struct emcalQC { } if (survivesIsSelectedCuts) { - o2::aod::pwgem::photonmeson::utils::clusterhistogram::fillClusterHistograms<1>(&fRegistry, cluster, cfgDo2DQA); - fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), 7., cluster.e()); + o2::aod::pwgem::photonmeson::utils::clusterhistogram::fillClusterHistograms<1>(&fRegistry, cluster, cfgDo2DQA, collision.weight()); + fRegistry.fill(HIST("Cluster/hClusterQualityCuts"), 7., cluster.e(), collision.weight()); ng++; } } - fRegistry.fill(HIST("Cluster/after/hNgamma"), ng); + fRegistry.fill(HIST("Cluster/after/hNgamma"), ng, collision.weight()); } // end of collision loop - } // end of process + } // end of process void processDummy(MyCollisions const&) {} diff --git a/PWGEM/PhotonMeson/Tasks/pcmQC.cxx b/PWGEM/PhotonMeson/Tasks/pcmQC.cxx index a76374301b2..aa034a2ec39 100644 --- a/PWGEM/PhotonMeson/Tasks/pcmQC.cxx +++ b/PWGEM/PhotonMeson/Tasks/pcmQC.cxx @@ -14,6 +14,9 @@ // This code runs loop over v0 photons for PCM QC. // Please write to: daiki.sekihata@cern.ch +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -22,7 +25,7 @@ #include "PWGEM/PhotonMeson/Utils/PCMUtilities.h" #include "PWGEM/PhotonMeson/DataModel/gammaTables.h" #include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" using namespace o2; using namespace o2::aod; @@ -34,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 { @@ -42,19 +45,20 @@ struct PCMQC { Configurable cfgCentMin{"cfgCentMin", 0, "min. centrality"}; Configurable cfgCentMax{"cfgCentMax", 999.f, "max. centrality"}; - EMEventCut fEMEventCut; + 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 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -65,7 +69,8 @@ struct PCMQC { 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.9, "max eta 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"}; @@ -76,10 +81,12 @@ struct PCMQC { 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"}; } pcmcuts; static constexpr std::string_view event_types[2] = {"before/", "after/"}; @@ -120,7 +127,7 @@ 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, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, 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.9f, 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.9f, 1.0f}}, false); @@ -136,12 +143,17 @@ struct PCMQC { 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/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, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, 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/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); @@ -151,18 +163,19 @@ struct PCMQC { fRegistry.add("V0Leg/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); fRegistry.add("V0Leg/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); fRegistry.add("V0Leg/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("V0Leg/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("V0Leg/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); fRegistry.add("V0Leg/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); fRegistry.add("V0Leg/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("V0Leg/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - fRegistry.add("V0Leg/hXY", "X vs. Y;X (cm);Y (cm)", kTH2F, {{100, 0, 100}, {100, -50, 50}}, false); + fRegistry.add("V0Leg/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {160, 0, 16}}, false); + fRegistry.add("V0Leg/hXY", "X vs. Y;X (cm);Y (cm)", kTH2F, {{100, 0, 100}, {80, -20, 20}}, false); fRegistry.add("V0Leg/hZX", "Z vs. X;Z (cm);X (cm)", kTH2F, {{200, -100, 100}, {100, 0, 100}}, false); - fRegistry.add("V0Leg/hZY", "Z vs. Y;Z (cm);Y (cm)", kTH2F, {{200, -100, 100}, {100, -50, 50}}, false); + fRegistry.add("V0Leg/hZY", "Z vs. Y;Z (cm);Y (cm)", kTH2F, {{200, -100, 100}, {80, -20, 20}}, false); } void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -171,7 +184,7 @@ struct PCMQC { fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); } void DefinePCMCut() @@ -180,7 +193,7 @@ struct PCMQC { // for v0 fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); - fV0PhotonCut.SetV0EtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_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.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); @@ -189,13 +202,16 @@ struct PCMQC { // 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.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); + 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); + if (pcmcuts.cfg_reject_v0_on_itsib) { fV0PhotonCut.SetNClustersITS(2, 4); } else { @@ -287,6 +303,11 @@ struct PCMQC { 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)); } template @@ -301,10 +322,13 @@ struct PCMQC { fRegistry.fill(HIST("V0Leg/hNcrTPC"), leg.tpcNClsCrossedRows()); fRegistry.fill(HIST("V0Leg/hTPCNcr2Nf"), leg.tpcCrossedRowsOverFindableCls()); fRegistry.fill(HIST("V0Leg/hTPCNcls2Nf"), leg.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("V0Leg/hTPCNclsShared"), leg.pt(), leg.tpcFractionSharedCls()); fRegistry.fill(HIST("V0Leg/hChi2TPC"), leg.tpcChi2NCl()); fRegistry.fill(HIST("V0Leg/hChi2ITS"), leg.itsChi2NCl()); fRegistry.fill(HIST("V0Leg/hITSClusterMap"), leg.itsClusterMap()); - fRegistry.fill(HIST("V0Leg/hMeanClusterSizeITS"), leg.meanClusterSizeITS() * std::cos(std::atan(leg.tgl()))); + if (leg.hasITS()) { + fRegistry.fill(HIST("V0Leg/hMeanClusterSizeITS"), leg.p(), leg.meanClusterSizeITS() * std::cos(std::atan(leg.tgl()))); + } fRegistry.fill(HIST("V0Leg/hTPCdEdx"), leg.tpcInnerParam(), leg.tpcSignal()); fRegistry.fill(HIST("V0Leg/hTPCNsigmaEl"), leg.tpcInnerParam(), leg.tpcNSigmaEl()); fRegistry.fill(HIST("V0Leg/hTPCNsigmaPi"), leg.tpcInnerParam(), leg.tpcNSigmaPi()); @@ -315,6 +339,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 = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; using FilteredMyCollisions = soa::Filtered; void processQC(FilteredMyCollisions const& collisions, MyV0Photons const& v0photons, aod::V0Legs const&) @@ -339,17 +364,18 @@ struct PCMQC { auto pos = v0.posTrack_as(); auto ele = v0.negTrack_as(); - if (fV0PhotonCut.IsSelected(v0)) { - nv0++; - fillV0Info(v0); - for (auto& leg : {pos, ele}) { - fillV0LegInfo(leg); - } + if (!fV0PhotonCut.IsSelected(v0)) { + continue; + } + fillV0Info(v0); + for (auto& leg : {pos, ele}) { + fillV0LegInfo(leg); } + nv0++; } // end of v0 loop fRegistry.fill(HIST("V0/hNgamma"), nv0); } // end of collision loop - } // end of process + } // end of process void processDummy(MyCollisions const&) {} diff --git a/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx b/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx index 8ef35da92b2..54ad5d116d1 100644 --- a/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx +++ b/PWGEM/PhotonMeson/Tasks/pcmQCMC.cxx @@ -14,6 +14,9 @@ // This code runs loop over v0 photons for PCM QC. // Please write to: daiki.sekihata@cern.ch +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -24,7 +27,7 @@ #include "PWGEM/PhotonMeson/Utils/MCUtilities.h" #include "PWGEM/Dilepton/Utils/MCUtilities.h" #include "PWGEM/PhotonMeson/Core/V0PhotonCut.h" -#include "PWGEM/Dilepton/Core/EMEventCut.h" +#include "PWGEM/PhotonMeson/Core/EMPhotonEventCut.h" using namespace o2; using namespace o2::aod; @@ -41,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; @@ -56,19 +59,20 @@ 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"}; - EMEventCut fEMEventCut; + 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 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 cfgOccupancyMin{"cfgOccupancyMin", -1, "min. occupancy"}; Configurable cfgOccupancyMax{"cfgOccupancyMax", 1000000000, "max. occupancy"}; + Configurable cfgRequireNoCollInTimeRangeStandard{"cfgRequireNoCollInTimeRangeStandard", false, "require no collision in time range standard"}; } eventcuts; V0PhotonCut fV0PhotonCut; @@ -79,7 +83,8 @@ struct PCMQCMC { 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.9, "max eta 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"}; @@ -90,14 +95,17 @@ struct PCMQCMC { 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"}; } pcmcuts; - static constexpr std::string_view event_types[2] = {"before/", "after/"}; 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/"}; void init(InitContext&) { @@ -123,14 +131,17 @@ struct PCMQCMC { } const AxisSpec axis_pt{ptbins, "p_{T,#gamma} (GeV/c)"}; const AxisSpec axis_rapidity{{0.0, +0.8, +0.9}, "rapidity |y_{#gamma}|"}; - 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); + + 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); + } // event info auto hCollisionCounter = fRegistry.add("Event/before/hCollisionCounter", "collision counter;;Number of events", kTH1F, {{10, 0.5, 10.5}}, false); @@ -157,89 +168,71 @@ struct PCMQCMC { fRegistry.addClone("Event/before/", "Event/after/"); // 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, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.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.9f, 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.9f, 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.9f, 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/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/hNgamma", "Number of #gamma candidates per collision", kTH1F, {{101, -0.5f, 100.5f}}); - - fRegistry.add("V0/hPt_Photon_Candidate", "pT of photon candidate;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); // for denominator of purity - fRegistry.add("V0/hEtaPhi_Photon_Candidate", "#eta vs. #varphi of photon candidate ;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, true); // for denominator of purity - - fRegistry.add("V0/hPt_Photon_Primary", "pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); // for MC efficiency - fRegistry.add("V0/hEtaPhi_Photon_Primary", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, true); // for MC efficiency - fRegistry.add("V0/hCosPA_Rxy_Photon_Primary", "cos PA vs. R_{xy};R_{xy} (cm);cosine pointing angle", kTH2F, {{200, 0.f, 100.f}, {100, 0.9f, 1.0f}}, true); - fRegistry.add("V0/hXY_Photon_Primary", "X vs. Y of photon rec.;X (cm);Y (cm)", kTH2F, {{400, -100.0f, +100}, {400, -100, +100}}, true); - fRegistry.add("V0/hXY_Photon_Primary_MC", "X vs. Y of photon gen.;X (cm);Y (cm)", kTH2F, {{400, -100.0f, +100}, {400, -100, +100}}, true); - fRegistry.add("V0/hRZ_Photon_Primary", "R vs. Z of photon rec.;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100.0f, +100}, {200, 0, 100}}, true); - fRegistry.add("V0/hRZ_Photon_Primary_MC", "R vs. Z of photon gen;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100.0f, +100}, {200, 0, 100}}, true); - - fRegistry.add("V0/hPt_Photon_FromWD", "pT;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); // for MC feed down correction - fRegistry.add("V0/hEtaPhi_Photon_FromWD", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, true); // for MC feed down correction - fRegistry.add("V0/hCosPA_Rxy_Photon_FromWD", "cos PA vs. R_{xy};R_{xy} (cm);cosine pointing angle", kTH2F, {{200, 0.f, 100.f}, {100, 0.9f, 1.0f}}, true); - - fRegistry.add("V0/hPt_Photon_hs", "pT of photon from hadronic shower in materials;p_{T} (GeV/c)", kTH1F, {axis_pt}, true); - fRegistry.add("V0/hEtaPhi_Photon_hs", "#eta vs. #varphi;#varphi (rad.);#eta", kTH2F, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.0f}}, true); - fRegistry.add("V0/hCosPA_Rxy_Photon_hs", "cos PA vs. R_{xy};R_{xy} (cm);cosine pointing angle", kTH2F, {{200, 0.f, 100.f}, {100, 0.9f, 1.0f}}, true); - fRegistry.add("V0/hXY_Photon_hs_MC", "X vs. Y of photon from hadronic shower in materials gen.;Z (cm);R_{xy} (cm)", kTH2F, {{400, -100.0f, +100}, {400, -100, 100}}, true); // production vertex of photons - fRegistry.add("V0/hRZ_Photon_hs_MC", "R vs. Z of photon from hadronic shower in materials gen.;Z (cm);R_{xy} (cm)", kTH2F, {{200, -100.0f, +100}, {200, 0, 100}}, true); // production vertex of photons - - fRegistry.add("V0/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/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/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/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/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/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/hEtaRec_DeltaPtOverPtGen", "photon p_{T} resolution;#eta^{rec} of conversion point;(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0/hEtaRec_DeltaEta", "photon #eta resolution;#eta^{rec} of conversion point;#eta^{rec} - #eta^{gen}", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0/hEtaRec_DeltaPhi", "photon #varphi resolution;#eta^{rec} of conversion point;#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); + 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.9f, 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.9f, 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.9f, 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/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/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 // 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, {{180, 0, 2 * M_PI}, {40, -2.0f, 2.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); - fRegistry.add("V0Leg/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("V0Leg/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); - fRegistry.add("V0Leg/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("V0Leg/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); - fRegistry.add("V0Leg/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("V0Leg/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); - fRegistry.add("V0Leg/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); - fRegistry.add("V0Leg/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); - fRegistry.add("V0Leg/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); - fRegistry.add("V0Leg/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH1F, {{32, 0, 16}}, false); - fRegistry.add("V0Leg/hXY", "X vs. Y;X (cm);Y (cm)", kTH2F, {{100, 0, 100}, {100, -50, 50}}, false); - fRegistry.add("V0Leg/hZX", "Z vs. X;Z (cm);X (cm)", kTH2F, {{200, -100, 100}, {100, 0, 100}}, false); - fRegistry.add("V0Leg/hZY", "Z vs. Y;Z (cm);Y (cm)", kTH2F, {{200, -100, 100}, {100, -50, 50}}, false); - - fRegistry.add("V0Leg/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/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/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.add("V0Leg/hEtaRec_DeltaPtOverPtGen", "electron p_{T} resolution;#eta^{rec} of conversion point;(p_{T}^{rec} - p_{T}^{gen})/p_{T}^{gen}", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0Leg/hEtaRec_DeltaEta", "electron #eta resolution;#eta^{rec} of conversion point;#eta^{rec} - #eta^{gen}", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); - fRegistry.add("V0Leg/hEtaRec_DeltaPhi", "electron #varphi resolution;#eta^{rec} of conversion point;#varphi^{rec} - #varphi^{gen} (rad.)", kTH2F, {{400, -2, +2}, {400, -1.0f, 1.0f}}, true); + 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/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); + fRegistry.add("V0Leg/primary/hChi2TPC", "chi2/number of TPC clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("V0Leg/primary/hTPCdEdx", "TPC dE/dx;p_{in} (GeV/c);TPC dE/dx (a.u.)", kTH2F, {{1000, 0, 10}, {200, 0, 200}}, false); + fRegistry.add("V0Leg/primary/hTPCNsigmaEl", "TPC n sigma el;p_{in} (GeV/c);n #sigma_{e}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("V0Leg/primary/hTPCNsigmaPi", "TPC n sigma pi;p_{in} (GeV/c);n #sigma_{#pi}^{TPC}", kTH2F, {{1000, 0, 10}, {100, -5, +5}}, false); + fRegistry.add("V0Leg/primary/hTPCNcr2Nf", "TPC Ncr/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("V0Leg/primary/hTPCNcls2Nf", "TPC Ncls/Nfindable", kTH1F, {{200, 0, 2}}, false); + fRegistry.add("V0Leg/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("V0Leg/primary/hNclsITS", "number of ITS clusters", kTH1F, {{8, -0.5, 7.5}}, false); + fRegistry.add("V0Leg/primary/hChi2ITS", "chi2/number of ITS clusters", kTH1F, {{100, 0, 10}}, false); + fRegistry.add("V0Leg/primary/hITSClusterMap", "ITS cluster map", kTH1F, {{128, -0.5, 127.5}}, false); + fRegistry.add("V0Leg/primary/hMeanClusterSizeITS", "mean cluster size ITS; on ITS #times cos(#lambda)", kTH2F, {{1000, 0, 10}, {160, 0, 16}}, false); + 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 } void DefineEMEventCut() { - fEMEventCut = EMEventCut("fEMEventCut", "fEMEventCut"); + fEMEventCut = EMPhotonEventCut("fEMEventCut", "fEMEventCut"); fEMEventCut.SetRequireSel8(eventcuts.cfgRequireSel8); fEMEventCut.SetRequireFT0AND(eventcuts.cfgRequireFT0AND); fEMEventCut.SetZvtxRange(-eventcuts.cfgZvtxMax, +eventcuts.cfgZvtxMax); @@ -248,7 +241,7 @@ struct PCMQCMC { fEMEventCut.SetRequireNoSameBunchPileup(eventcuts.cfgRequireNoSameBunchPileup); fEMEventCut.SetRequireVertexITSTPC(eventcuts.cfgRequireVertexITSTPC); fEMEventCut.SetRequireGoodZvtxFT0vsPV(eventcuts.cfgRequireGoodZvtxFT0vsPV); - fEMEventCut.SetOccupancyRange(eventcuts.cfgOccupancyMin, eventcuts.cfgOccupancyMax); + fEMEventCut.SetRequireNoCollInTimeRangeStandard(eventcuts.cfgRequireNoCollInTimeRangeStandard); } void DefinePCMCut() @@ -257,7 +250,7 @@ struct PCMQCMC { // for v0 fV0PhotonCut.SetV0PtRange(pcmcuts.cfg_min_pt_v0, 1e10f); - fV0PhotonCut.SetV0EtaRange(-pcmcuts.cfg_max_eta_v0, +pcmcuts.cfg_max_eta_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.SetRxyRange(pcmcuts.cfg_min_v0radius, pcmcuts.cfg_max_v0radius); @@ -266,13 +259,16 @@ struct PCMQCMC { // 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.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); + 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); + if (pcmcuts.cfg_reject_v0_on_itsib) { fV0PhotonCut.SetNClustersITS(2, 4); } else { @@ -344,57 +340,78 @@ struct PCMQCMC { fRegistry.fill(HIST("Event/") + HIST(event_types[ev_id]) + HIST("hMultFT0MvsMultNTracksPV"), collision.multFT0A() + collision.multFT0C(), collision.multNTracksPV()); } - template - void fillV0Info(TV0 const& v0, const float weight = 1.f) + template + void fillV0Info(TV0 const& v0, TMCV0 const& mcphoton, TMCLeg const& mcleg) { - fRegistry.fill(HIST("V0/hPt"), v0.pt(), weight); - fRegistry.fill(HIST("V0/hEtaPhi"), v0.phi(), v0.eta(), weight); - fRegistry.fill(HIST("V0/hRadius"), v0.vz(), v0.v0radius(), weight); - fRegistry.fill(HIST("V0/hCosPA"), v0.cospa(), weight); - fRegistry.fill(HIST("V0/hCosPA_Rxy"), v0.v0radius(), v0.cospa(), weight); - fRegistry.fill(HIST("V0/hPCA"), v0.pca(), weight); - fRegistry.fill(HIST("V0/hPCA_CosPA"), v0.cospa(), v0.pca(), weight); - fRegistry.fill(HIST("V0/hPCA_Rxy"), v0.v0radius(), v0.pca(), weight); - fRegistry.fill(HIST("V0/hDCAxyz"), v0.dcaXYtopv(), v0.dcaZtopv(), weight); - fRegistry.fill(HIST("V0/hAPplot"), v0.alpha(), v0.qtarm(), weight); - fRegistry.fill(HIST("V0/hMassGamma"), v0.v0radius(), v0.mGamma(), weight); - fRegistry.fill(HIST("V0/hGammaRxy"), v0.vx(), v0.vy(), weight); - fRegistry.fill(HIST("V0/hKFChi2vsM"), v0.mGamma(), v0.chiSquareNDF(), weight); - fRegistry.fill(HIST("V0/hKFChi2vsR"), v0.v0radius(), v0.chiSquareNDF(), weight); - fRegistry.fill(HIST("V0/hKFChi2vsX"), v0.vx(), v0.chiSquareNDF(), weight); - fRegistry.fill(HIST("V0/hKFChi2vsY"), v0.vy(), v0.chiSquareNDF(), weight); - fRegistry.fill(HIST("V0/hKFChi2vsZ"), v0.vz(), v0.chiSquareNDF(), weight); + 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("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("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("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("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("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))); } - template - void fillV0LegInfo(TLeg const& leg, const float weight = 1.f) + template + void fillV0LegInfo(TLeg const& leg) { - fRegistry.fill(HIST("V0Leg/hPt"), leg.pt(), weight); - fRegistry.fill(HIST("V0Leg/hQoverPt"), leg.sign() / leg.pt(), weight); - fRegistry.fill(HIST("V0Leg/hEtaPhi"), leg.phi(), leg.eta(), weight); - fRegistry.fill(HIST("V0Leg/hDCAxyz"), leg.dcaXY(), leg.dcaZ(), weight); - fRegistry.fill(HIST("V0Leg/hNclsITS"), leg.itsNCls(), weight); - fRegistry.fill(HIST("V0Leg/hNclsTPC"), leg.tpcNClsFound(), weight); - fRegistry.fill(HIST("V0Leg/hNcrTPC"), leg.tpcNClsCrossedRows(), weight); - fRegistry.fill(HIST("V0Leg/hTPCNcr2Nf"), leg.tpcCrossedRowsOverFindableCls(), weight); - fRegistry.fill(HIST("V0Leg/hTPCNcls2Nf"), leg.tpcFoundOverFindableCls(), weight); - fRegistry.fill(HIST("V0Leg/hChi2TPC"), leg.tpcChi2NCl(), weight); - fRegistry.fill(HIST("V0Leg/hChi2ITS"), leg.itsChi2NCl(), weight); - fRegistry.fill(HIST("V0Leg/hITSClusterMap"), leg.itsClusterMap(), weight); - fRegistry.fill(HIST("V0Leg/hMeanClusterSizeITS"), leg.meanClusterSizeITS() * std::cos(std::atan(leg.tgl())), weight); - fRegistry.fill(HIST("V0Leg/hTPCdEdx"), leg.tpcInnerParam(), leg.tpcSignal(), weight); - fRegistry.fill(HIST("V0Leg/hTPCNsigmaEl"), leg.tpcInnerParam(), leg.tpcNSigmaEl(), weight); - fRegistry.fill(HIST("V0Leg/hTPCNsigmaPi"), leg.tpcInnerParam(), leg.tpcNSigmaPi(), weight); - fRegistry.fill(HIST("V0Leg/hXY"), leg.x(), leg.y(), weight); - fRegistry.fill(HIST("V0Leg/hZX"), leg.z(), leg.x(), weight); - fRegistry.fill(HIST("V0Leg/hZY"), leg.z(), leg.y(), weight); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hPt"), leg.pt()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hQoverPt"), leg.sign() / leg.pt()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hEtaPhi"), leg.phi(), leg.eta()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hDCAxyz"), leg.dcaXY(), leg.dcaZ()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hNclsITS"), leg.itsNCls()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hNclsTPC"), leg.tpcNClsFound()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hNcrTPC"), leg.tpcNClsCrossedRows()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCNcr2Nf"), leg.tpcCrossedRowsOverFindableCls()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCNcls2Nf"), leg.tpcFoundOverFindableCls()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCNclsShared"), leg.pt(), leg.tpcFractionSharedCls()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hChi2TPC"), leg.tpcChi2NCl()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hChi2ITS"), leg.itsChi2NCl()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hITSClusterMap"), leg.itsClusterMap()); + if (leg.hasITS()) { + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hMeanClusterSizeITS"), leg.p(), leg.meanClusterSizeITS() * std::cos(std::atan(leg.tgl()))); + } + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCdEdx"), leg.tpcInnerParam(), leg.tpcSignal()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCNsigmaEl"), leg.tpcInnerParam(), leg.tpcNSigmaEl()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hTPCNsigmaPi"), leg.tpcInnerParam(), leg.tpcNSigmaPi()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hXY"), leg.x(), leg.y()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hZX"), leg.z(), leg.x()); + fRegistry.fill(HIST("V0Leg/") + HIST(mcphoton_types[mctype]) + HIST("hZY"), leg.z(), leg.y()); + auto mcleg = leg.template emmcparticle_as(); + 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()); } 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 = eventcuts.cfgOccupancyMin <= o2::aod::evsel::trackOccupancyInTimeRange && o2::aod::evsel::trackOccupancyInTimeRange < eventcuts.cfgOccupancyMax; using FilteredMyCollisions = soa::Filtered; Preslice perCollision = aod::v0photonkf::emeventId; - void processQCMC(FilteredMyCollisions const& collisions, MyV0Photons const& v0photons, MyMCV0Legs const&, aod::EMMCParticles const& mcparticles, MyMCCollisions const&) + void processQCMC(FilteredMyCollisions const& collisions, MyV0Photons const& v0photons, MyMCV0Legs const&, aod::EMMCParticles const& mcparticles, aod::EMMCEvents const&) { for (auto& collision : collisions) { const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()}; @@ -411,7 +428,7 @@ struct PCMQCMC { fRegistry.fill(HIST("Event/after/hCollisionCounter"), 10.0); // accepted auto V0Photons_coll = v0photons.sliceBy(perCollision, collision.globalIndex()); - int nv0 = 0; + int ng_primary = 0, ng_wd = 0, ng_hs = 0; for (auto& v0 : V0Photons_coll) { auto pos = v0.posTrack_as(); auto ele = v0.negTrack_as(); @@ -420,69 +437,41 @@ struct PCMQCMC { // LOGF(info, "posmc.isPhysicalPrimary() = %d, posmc.producedByGenerator() = %d, elemc.isPhysicalPrimary() = %d, elemc.producedByGenerator() = %d", posmc.isPhysicalPrimary(), posmc.producedByGenerator(), elemc.isPhysicalPrimary(), elemc.producedByGenerator()); - if (fV0PhotonCut.IsSelected(v0)) { - fRegistry.fill(HIST("V0/hPt_Photon_Candidate"), v0.pt()); - fRegistry.fill(HIST("V0/hEtaPhi_Photon_Candidate"), v0.phi(), v0.eta()); + if (!fV0PhotonCut.IsSelected(v0)) { + continue; + } + int photonid = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles); + if (photonid < 0) { + continue; + } + auto mcphoton = mcparticles.iteratorAt(photonid); - int photonid = FindCommonMotherFrom2Prongs(posmc, elemc, -11, 11, 22, mcparticles); - if (photonid < 0) { - 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); } - auto mcphoton = mcparticles.iteratorAt(photonid); - nv0++; // number of true photons regardless of primary or feeddown or hadronic shower - - if (IsConversionPointInAcceptance(mcphoton, maxRgen, pcmcuts.cfg_max_eta_v0, margin_z_mc, mcparticles)) { - if (mcphoton.isPhysicalPrimary() || mcphoton.producedByGenerator()) { - float rxy_rec = sqrt(v0.vx() * v0.vx() + v0.vy() * v0.vy()); - float rxy_mc = sqrt(posmc.vx() * posmc.vx() + posmc.vy() * posmc.vy()); - float eta_cp = std::atanh(v0.vz() / sqrt(pow(v0.vx(), 2) + pow(v0.vy(), 2) + pow(v0.vz(), 2))); - fillV0Info(v0, 1.f); - fRegistry.fill(HIST("V0/hPt_Photon_Primary"), v0.pt()); - fRegistry.fill(HIST("V0/hEtaPhi_Photon_Primary"), v0.phi(), v0.eta()); - fRegistry.fill(HIST("V0/hXY_Photon_Primary"), v0.vx(), v0.vy()); - fRegistry.fill(HIST("V0/hXY_Photon_Primary_MC"), posmc.vx(), posmc.vy()); - fRegistry.fill(HIST("V0/hRZ_Photon_Primary"), v0.vz(), rxy_rec); - fRegistry.fill(HIST("V0/hRZ_Photon_Primary_MC"), posmc.vz(), rxy_mc); - fRegistry.fill(HIST("V0/hCosPA_Rxy_Photon_Primary"), v0.v0radius(), v0.cospa()); - fRegistry.fill(HIST("V0/hPtGen_DeltaPtOverPtGen"), mcphoton.pt(), (v0.pt() - mcphoton.pt()) / mcphoton.pt()); - fRegistry.fill(HIST("V0/hPtGen_DeltaEta"), mcphoton.pt(), v0.eta() - mcphoton.eta()); - fRegistry.fill(HIST("V0/hPtGen_DeltaPhi"), mcphoton.pt(), v0.phi() - mcphoton.phi()); - fRegistry.fill(HIST("V0/hEtaRec_DeltaPtOverPtGen"), eta_cp, (v0.pt() - mcphoton.pt()) / mcphoton.pt()); - fRegistry.fill(HIST("V0/hEtaRec_DeltaEta"), eta_cp, v0.eta() - mcphoton.eta()); - fRegistry.fill(HIST("V0/hEtaRec_DeltaPhi"), eta_cp, v0.phi() - mcphoton.phi()); - fRegistry.fill(HIST("V0/hConvPoint_diffX"), elemc.vx(), v0.vx() - elemc.vx()); - fRegistry.fill(HIST("V0/hConvPoint_diffY"), elemc.vy(), v0.vy() - elemc.vy()); - fRegistry.fill(HIST("V0/hConvPoint_diffZ"), elemc.vz(), v0.vz() - elemc.vz()); - - for (auto& leg : {pos, ele}) { - fillV0LegInfo(leg, 1.f); - auto mcleg = leg.template emmcparticle_as(); - fRegistry.fill(HIST("V0Leg/hPtGen_DeltaPtOverPtGen"), mcleg.pt(), (leg.pt() - mcleg.pt()) / mcleg.pt()); - fRegistry.fill(HIST("V0Leg/hPtGen_DeltaEta"), mcleg.pt(), leg.eta() - mcleg.eta()); - fRegistry.fill(HIST("V0Leg/hPtGen_DeltaPhi"), mcleg.pt(), leg.phi() - mcleg.phi()); - fRegistry.fill(HIST("V0Leg/hEtaRec_DeltaPtOverPtGen"), eta_cp, (leg.pt() - mcleg.pt()) / mcleg.pt()); - fRegistry.fill(HIST("V0Leg/hEtaRec_DeltaEta"), eta_cp, leg.eta() - mcleg.eta()); - fRegistry.fill(HIST("V0Leg/hEtaRec_DeltaPhi"), eta_cp, leg.phi() - mcleg.phi()); - } - } else if (IsFromWD(mcphoton.template emmcevent_as(), mcphoton, mcparticles) > 0) { - fRegistry.fill(HIST("V0/hPt_Photon_FromWD"), v0.pt()); - fRegistry.fill(HIST("V0/hEtaPhi_Photon_FromWD"), v0.phi(), v0.eta()); - fRegistry.fill(HIST("V0/hCosPA_Rxy_Photon_FromWD"), v0.v0radius(), v0.cospa()); - } else { - // LOGF(info, "mcphoton.vx() = %f, mcphoton.vy() = %f, mcphoton.vz() = %f, mother_pdg = %d", mcphoton.vx(), mcphoton.vy(), mcphoton.vz(), mother_pdg); - float rxy_photon_hs = sqrt(mcphoton.vx() * mcphoton.vx() + mcphoton.vy() * mcphoton.vy()); - fRegistry.fill(HIST("V0/hPt_Photon_hs"), v0.pt()); - fRegistry.fill(HIST("V0/hEtaPhi_Photon_hs"), v0.phi(), v0.eta()); - fRegistry.fill(HIST("V0/hXY_Photon_hs_MC"), mcphoton.vx(), mcphoton.vy()); - fRegistry.fill(HIST("V0/hRZ_Photon_hs_MC"), mcphoton.vz(), rxy_photon_hs); - fRegistry.fill(HIST("V0/hCosPA_Rxy_Photon_hs"), v0.v0radius(), v0.cospa()); - } + 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); } } // end of v0 loop - fRegistry.fill(HIST("V0/hNgamma"), nv0); + fRegistry.fill(HIST("V0/primary/hNgamma"), ng_primary); + fRegistry.fill(HIST("V0/fromWD/hNgamma"), ng_wd); + fRegistry.fill(HIST("V0/fromHS/hNgamma"), ng_hs); } // end of collision loop - } // end of process + } // end of process template void fillBinnedData(TBinnedData const& binned_data, const float weight = 1.f) @@ -535,7 +524,7 @@ struct PCMQCMC { continue; } - if (abs(mctrack.pdgCode()) == 22 && (mctrack.isPhysicalPrimary() || mctrack.producedByGenerator()) && IsConversionPointInAcceptance(mctrack, maxRgen, pcmcuts.cfg_max_eta_v0, margin_z_mc, mcparticles)) { + 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()); @@ -546,7 +535,7 @@ struct PCMQCMC { fRegistry.fill(HIST("Generated/hPhotonPhivsRxy"), daughter.phi(), rxy_gen_e); } } // end of mctrack loop per collision - } // end of collision loop + } // end of collision loop } void processDummy(MyCollisions const&) {} diff --git a/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx b/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx new file mode 100644 index 00000000000..83d5af15a8e --- /dev/null +++ b/PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.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 taskPi0FlowEMC.cxx +/// \brief Analysis task for neutral pion flow with EMCal +/// +/// \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 "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" + +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 +}; + +struct EMfTaskPi0Flow { + // configurable for flow + Configurable harmonic{"harmonic", 2, "harmonic number"}; + Configurable qvecDetector{"qvecDetector", 0, "Detector for Q vector estimation (FT0M: 0, FT0A: 1, FT0C: 2, TPC Pos: 3, TPC Neg: 4, TPC Tot: 5)"}; + Configurable qvecSubADetector{"qvecSubADetector", 3, "Sub A Detector for Q vector estimation for resolution (FT0M: 0, FT0A: 1, FT0C: 2, TPC Pos: 3, TPC Neg: 4, TPC Tot: 5)"}; + Configurable qvecSubBDetector{"qvecSubBDetector", 4, "Sub B Detector for Q vector estimation for resolution (FT0M: 0, FT0A: 1, FT0C: 2, TPC Pos: 3, TPC Neg: 4, TPC Tot: 5)"}; + Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3)"}; + Configurable saveEpResoHisto{"saveEpResoHisto", false, "Flag to save event plane resolution histogram"}; + Configurable saveSPResoHist{"saveSPResoHist", false, "Flag to save scalar product resolution histogram"}; + 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 axis + ConfigurableAxis thnConfigAxisInvMass{"thnConfigAxisInvMass", {200, 0.0, 0.4}, ""}; + 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 thnConfigAxisScalarProd{"thnConfigAxisScalarProd", {100, -5., 5.}, ""}; + + 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", true, "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", -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 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)"}; + Configurable enableQA{"enableQA", false, "flag to turn QA plots on/off"}; + } eventcuts; + + EMCPhotonCut fEMCCut; + struct : ConfigurableGroup { + std::string prefix = "emccut_group"; + Configurable EMC_minTime{"EMC_minTime", -25., "Minimum cluster time for EMCal time cut"}; + Configurable EMC_maxTime{"EMC_maxTime", +30., "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 EMC_UseTM{"EMC_UseTM", false, "flag to use EMCal track matching cut or not"}; + Configurable enableQA{"enableQA", false, "flag to turn QA plots on/off"}; + } emccuts; + + struct : ConfigurableGroup { + std::string prefix = "meson"; + Configurable minOpenAngle{"minOpenAngle", 0.0202, "apply min opening angle. Default value one EMCal cell"}; + Configurable enableTanThetadPhi{"enableTanThetadPhi", false, "flag to turn cut opening angle in delta theta delta phi on/off"}; + Configurable minTanThetadPhi{"minTanThetadPhi", 4., "apply min opening angle in delta theta delta phi to cut on late conversion"}; + Configurable maxEnergyAsymmetry{"maxEnergyAsymmetry", 1., "apply max energy asymmetry for meson candidate"}; + Configurable enableQA{"enableQA", false, "flag to turn QA plots on/off"}; + ConfigurableAxis thConfigAxisTanThetaPhi{"thConfigAxisTanThetaPhi", {180, -90.f, 90.f}, ""}; + } mesonConfig; + + struct : ConfigurableGroup { + std::string prefix = "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}, "Mixing bins - centrality"}; + ConfigurableAxis ConfEPBins{"ConfEPBins", {8, -M_PI / 2, +M_PI / 2}, "Mixing bins - event plane angle"}; + ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, 0, 100, 500, 1000, 2000}, "Mixing bins - occupancy"}; + Configurable ConfMixingDepth{"ConfMixingDepth", 2, "Mixing depth"}; + } mixingConfig; + + SliceCache cache; + EventPlaneHelper epHelper; + o2::framework::Service ccdb; + + Filter clusterFilter = aod::skimmedcluster::time >= emccuts.EMC_minTime && aod::skimmedcluster::time <= emccuts.EMC_maxTime && aod::skimmedcluster::m02 >= emccuts.EMC_minM02 && aod::skimmedcluster::m02 <= emccuts.EMC_maxM02 && skimmedcluster::e >= emccuts.EMC_minE; + 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; + using FilteredEMCalPhotons = soa::Filtered>; + using EMCalPhotons = soa::Join; + using FilteredCollsWithQvecs = soa::Filtered>; + using CollsWithQvecs = soa::Join; + + Preslice perCollision_emc = aod::emccluster::emeventId; + Preslice perCollision_emc_filtered = aod::emccluster::emeventId; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + o2::emcal::Geometry* emcalGeom; + + 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 DefineEMCCut() + { + fEMCCut = EMCPhotonCut("fEMCCut", "fEMCCut"); + 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.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.SetMinEoverP(emccuts.EMC_Eoverp); + + 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.SetUseExoticCut(emccuts.EMC_UseExoticCut); + } + + void init(InitContext&) + { + if (harmonic != 2 && harmonic != 3) { + LOG(info) << "Harmonic was set to " << harmonic << " but can only be 2 or 3!"; + } + + DefineEMEventCut(); + DefineEMCCut(); + fEMCCut.SetUseTM(emccuts.EMC_UseTM); // 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 thAxisTanThetaPhi{mesonConfig.thConfigAxisTanThetaPhi, "atan(#Delta#theta/#Delta#varphi)"}; + const AxisSpec thAxisClusterEnergy{thnConfigAxisPt, "#it{E} (GeV)"}; + const AxisSpec thAxisAlpha{100, -1., +1, "#alpha"}; + const AxisSpec thAxisMult{1000, 0., +1000, "#it{N}_{ch}"}; + const AxisSpec thAxisEnergy{1000, 0., 100., "#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 thAxisNCell{17664, 0.5, +17664.5, "#it{N}_{cell}"}; + const AxisSpec thAxisPsi{360 / harmonic.value, -(1. / static_cast(harmonic.value)) * M_PI, (1. / static_cast(harmonic.value)) * M_PI, Form("#Psi_{%d}", 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}); + 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"); + hClusterCuts->GetXaxis()->SetBinLabel(3, "#it{M}_{#gamma#gamma}"); + hClusterCuts->GetXaxis()->SetBinLabel(4, "#it{p}_{T}"); + hClusterCuts->GetXaxis()->SetBinLabel(5, "conversion cut"); + hClusterCuts->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}); + registry.add("spReso/hSpResoFT0cTPCneg", "hSpResoFT0cTPCneg; centrality; Q_{FT0c} #bullet Q_{TPCneg}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0cTPCtot", "hSpResoFT0cTPCtot; centrality; Q_{FT0c} #bullet Q_{TPCtot}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0aTPCpos", "hSpResoFT0aTPCpos; centrality; Q_{FT0a} #bullet Q_{TPCpos}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0aTPCneg", "hSpResoFT0aTPCneg; centrality; Q_{FT0a} #bullet Q_{TPCneg}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0aTPCtot", "hSpResoFT0aTPCtot; centrality; Q_{FT0m} #bullet Q_{TPCtot}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0mTPCpos", "hSpResoFT0mTPCpos; centrality; Q_{FT0m} #bullet Q_{TPCpos}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0mTPCneg", "hSpResoFT0mTPCneg; centrality; Q_{FT0m} #bullet Q_{TPCneg}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoFT0mTPCtot", "hSpResoFT0mTPCtot; centrality; Q_{FT0m} #bullet Q_{TPCtot}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + registry.add("spReso/hSpResoTPCposTPCneg", "hSpResoTPCposTPCneg; centrality; Q_{TPCpos} #bullet Q_{TPCneg}", HistType::kTH2D, {thnAxisCent, thnConfigAxisScalarProd}); + } + + if (saveEpResoHisto) { + registry.add("hEventPlaneAngleFT0M", "hEventPlaneAngleFT0M", HistType::kTH2D, {thnAxisCent, thAxisPsi}); + registry.add("hEventPlaneAngleTPCpos", "hEventPlaneAngleTPCpos", HistType::kTH2D, {thnAxisCent, thAxisPsi}); + registry.add("hEventPlaneAngleTPCneg", "hEventPlaneAngleTPCneg", HistType::kTH2D, {thnAxisCent, thAxisPsi}); + registry.add("epReso/hEpResoFT0cFT0a", "hEpResoFT0cFT0a; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0cTPCpos", "hEpResoFT0cTPCpos; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0cTPCneg", "hEpResoFT0cTPCneg; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0cTPCtot", "hEpResoFT0cTPCtot; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0aTPCpos", "hEpResoFT0aTPCpos; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0aTPCneg", "hEpResoFT0aTPCneg; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0aTPCtot", "hEpResoFT0aTPCtot; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0mTPCpos", "hEpResoFT0mTPCpos; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0mTPCneg", "hEpResoFT0mTPCneg; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoFT0mTPCtot", "hEpResoFT0mTPCtot; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + registry.add("epReso/hEpResoTPCposTPCneg", "hEpResoTPCposTPCneg; centrality; #Delta#Psi_{sub}", HistType::kTH2D, {thnAxisCent, thnAxisCosNPhi}); + } + if (eventcuts.enableQA) { + auto hCollisionEMCCheck = registry.add("hCollisionEMCCheck", "collision counter;;Counts", kTH1D, {{7, 0.5, 7.5}}, false); + hCollisionEMCCheck->GetXaxis()->SetBinLabel(1, "all"); + hCollisionEMCCheck->GetXaxis()->SetBinLabel(2, "EMC MB Readout"); + hCollisionEMCCheck->GetXaxis()->SetBinLabel(3, "has clusters"); + hCollisionEMCCheck->GetXaxis()->SetBinLabel(4, "EMC MB Readout & has clusters"); + 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.enableQA) { + registry.add("hEClusterBefore", "Histo for cluster energy before cuts", HistType::kTH1D, {thAxisClusterEnergy}); + registry.add("hEClusterAfter", "Histo for cluster energy after cuts", HistType::kTH1D, {thAxisClusterEnergy}); + } + + if (mesonConfig.enableQA) { + 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}); + } + + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + LOG(info) << "thnConfigAxisInvMass.value[1] = " << thnConfigAxisInvMass.value[1] << " thnConfigAxisInvMass.value.back() = " << thnConfigAxisInvMass.value.back(); + LOG(info) << "thnConfigAxisPt.value[1] = " << thnConfigAxisPt.value[1] << " thnConfigAxisPt.value.back() = " << thnConfigAxisPt.value.back(); + }; // end init + + /// Change radians to degree + /// \param angle in radians + /// \return angle in degree + float getAngleDegree(float angle) + { + return angle * 180.f * std::numbers::inv_pi_v; + } + + /// Compute the delta psi in the range [0, pi/harmonic] + /// \param psi1 is the first angle + /// \param psi2 is the second angle + 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; + } + + /// 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 sp is the scalar product + void fillThn(float& mass, + float& pt, + float& cent, + float& sp) + { + registry.fill(HIST("hSparsePi0Flow"), mass, pt, cent, sp); + } + + /// Get the centrality + /// \param collision is the collision with the centrality information + float getCentrality(CollsWithQvecs::iterator const& collision) + { + float cent = -999.; + switch (centEstimator) { + case CentralityEstimator::CFT0M: + cent = collision.centFT0M(); + break; + case CentralityEstimator::CFT0A: + cent = collision.centFT0A(); + break; + case CentralityEstimator::CFT0C: + cent = collision.centFT0C(); + break; + default: + LOG(warning) << "Centrality estimator not valid. Possible values are T0M, T0A, T0C. Fallback to T0C"; + cent = collision.centFT0C(); + break; + } + return cent; + } + + /// Get all used Q vector + /// \param collision is the collision with the Q vector information + std::vector getAllQvec(CollsWithQvecs::iterator const& collision) + { + // Retrieve the Q vectors using the helper function for each detector + auto [xQVecMain, yQVecMain] = getQvec(collision, qvecDetector); + auto [xQVecSubA, yQVecSubA] = getQvec(collision, qvecSubADetector); + auto [xQVecSubB, yQVecSubB] = getQvec(collision, qvecSubBDetector); + + return {xQVecMain, yQVecMain, xQVecSubA, yQVecSubA, xQVecSubB, yQVecSubB}; + } + + /// Get the Q vector + /// \param collision is the collision with the Q vector information + std::pair getQvec(CollsWithQvecs::iterator const& collision, int detector) + { + float xQVec = -999.f; + float yQVec = -999.f; + + switch (detector) { + case QvecEstimator::FT0M: + if (harmonic == 2) { + xQVec = collision.q2xft0m(); + yQVec = collision.q2yft0m(); + } else if (harmonic == 3) { + xQVec = collision.q3xft0m(); + yQVec = collision.q3yft0m(); + } + break; + case QvecEstimator::FT0A: + if (harmonic == 2) { + xQVec = collision.q2xft0a(); + yQVec = collision.q2yft0a(); + } else if (harmonic == 3) { + xQVec = collision.q3xft0a(); + yQVec = collision.q3yft0a(); + } + break; + case QvecEstimator::FT0C: + if (harmonic == 2) { + xQVec = collision.q2xft0c(); + yQVec = collision.q2yft0c(); + } else if (harmonic == 3) { + xQVec = collision.q3xft0c(); + yQVec = collision.q3yft0c(); + } + break; + case QvecEstimator::TPCPos: + if (harmonic == 2) { + xQVec = collision.q2xbpos(); + yQVec = collision.q2ybpos(); + } else if (harmonic == 3) { + xQVec = collision.q3xbpos(); + yQVec = collision.q3ybpos(); + } + break; + case QvecEstimator::TPCNeg: + if (harmonic == 2) { + xQVec = collision.q2xbneg(); + yQVec = collision.q2ybneg(); + } else if (harmonic == 3) { + xQVec = collision.q3xbneg(); + yQVec = collision.q3ybneg(); + } + break; + case QvecEstimator::TPCTot: + if (harmonic == 2) { + xQVec = collision.q2xbtot(); + yQVec = collision.q2ybtot(); + } else if (harmonic == 3) { + xQVec = collision.q3xbtot(); + yQVec = collision.q3ybtot(); + } + break; + default: + LOG(warning) << "Q vector estimator not valid. Falling back to FT0M"; + if (harmonic == 2) { + xQVec = collision.q2xft0m(); + yQVec = collision.q2yft0m(); + } else if (harmonic == 3) { + xQVec = collision.q3xft0m(); + yQVec = collision.q3yft0m(); + } + break; + } + return {xQVec, yQVec}; + } + + /// Check if the QVector values are within reasonable range + /// \param collision is the collision with the Q vector information + bool isQvecGood(std::vector const& QVecs) + { + bool isgood = true; + for (auto& QVec : QVecs) { + if (std::fabs(QVec) > 20.f) { + isgood = false; + break; + } + } + return isgood; + } + + /// \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) { + return; + } + + auto [xQVec, yQVec] = getQvec(collision, qvecDetector); + float cent = getCentrality(collision); + int iCellID_photon1 = 0; + int iCellID_photon2 = 0; + + ROOT::Math::AxisAngle rotationAxis(meson.Vect(), cfgRotAngle.value); + ROOT::Math::Rotation3D rotationMatrix(rotationAxis); + photon1 = rotationMatrix * photon1; + photon2 = rotationMatrix * photon2; + + try { + iCellID_photon1 = emcalGeom->GetAbsCellIdFromEtaPhi(photon1.Eta(), photon1.Phi()); + } catch (o2::emcal::InvalidPositionException& e) { + iCellID_photon1 = -1; + } + try { + iCellID_photon2 = emcalGeom->GetAbsCellIdFromEtaPhi(photon2.Eta(), photon2.Phi()); + } catch (o2::emcal::InvalidPositionException& e) { + iCellID_photon2 = -1; + } + + if (iCellID_photon1 == -1 && iCellID_photon2 == -1) { + return; + } + for (auto& photon : photons_coll) { + if (photon.globalIndex() == ig1 || photon.globalIndex() == ig2) { + // only combine rotated photons with other photons + continue; + } + if (!(fEMCCut.IsSelected(photon))) { + continue; + } + ROOT::Math::PtEtaPhiMVector photon3(photon.pt(), photon.eta(), photon.phi(), 0.); + if (iCellID_photon1 > 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()); + float sinNPhi1 = std::sin(harmonic * mother1.Phi()); + float scalprodCand1 = cosNPhi1 * xQVec + sinNPhi1 * yQVec; + if (openingAngle1 > mesonConfig.minOpenAngle && thnConfigAxisInvMass.value[1] <= mother1.M() && thnConfigAxisInvMass.value.back() >= mother1.M() && thnConfigAxisPt.value[1] <= mother1.Pt() && thnConfigAxisPt.value.back() >= mother1.Pt()) { + if (mesonConfig.enableTanThetadPhi) { + float dTheta = photon1.Theta() - photon3.Theta(); + float dPhi = photon1.Phi() - photon3.Phi(); + if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(atan(dTheta / dPhi)))) { + registry.fill(HIST("hSparseBkgFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); + } + } else { + registry.fill(HIST("hSparseBkgFlow"), mother1.M(), mother1.Pt(), cent, scalprodCand1); + } + } + } + if (iCellID_photon2 > 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()); + float sinNPhi2 = std::sin(harmonic * mother2.Phi()); + float scalprodCand2 = cosNPhi2 * xQVec + sinNPhi2 * yQVec; + + if (openingAngle2 > mesonConfig.minOpenAngle && thnConfigAxisInvMass.value[1] <= mother2.M() && thnConfigAxisInvMass.value.back() >= mother2.M() && thnConfigAxisPt.value[1] <= mother2.Pt() && thnConfigAxisPt.value.back() >= mother2.Pt()) { + if (mesonConfig.enableTanThetadPhi) { + float dTheta = photon2.Theta() - photon3.Theta(); + float dPhi = photon2.Phi() - photon3.Phi(); + if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(atan(dTheta / dPhi)))) { + registry.fill(HIST("hSparseBkgFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); + } + } else { + registry.fill(HIST("hSparseBkgFlow"), mother2.M(), mother2.Pt(), cent, scalprodCand2); + } + } + } + } // end of loop over third photon + return; + } + + /// Compute the scalar product + /// \param collision is the collision with the Q vector information and event plane + /// \param meson are the selected candidates + void runFlowAnalysis(CollsWithQvecs::iterator const& collision, ROOT::Math::PtEtaPhiMVector const& meson) + { + auto [xQVec, yQVec] = getQvec(collision, qvecDetector); + float cent = getCentrality(collision); + + float massCand = meson.M(); + float ptCand = meson.Pt(); + float phiCand = meson.Phi(); + + float cosNPhi = std::cos(harmonic * phiCand); + float sinNPhi = std::sin(harmonic * phiCand); + float scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec; + + fillThn(massCand, ptCand, cent, scalprodCand); + return; + } + + // Pi0 from EMCal + void processEMCal(CollsWithQvecs const& collisions, EMCalPhotons const& clusters) + { + int NColl = 1; + for (auto& collision : collisions) { + auto photons_per_collision = clusters.sliceBy(perCollision_emc, collision.globalIndex()); + + if (eventcuts.enableQA) { + // TODO: check EMCal NCells in collisions without EMC Readout + registry.fill(HIST("hCollisionEMCCheck"), 1.); // all + if (collision.alias_bit(kTVXinEMC) == true) { + registry.fill(HIST("hCollisionEMCCheck"), 2.); // has EMC read out + if (photons_per_collision.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 (photons_per_collision.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 (auto& photon : photons_per_collision) { + 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 + } + } + } + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(®istry, collision); + if (!(fEMEventCut.IsSelected(collision))) { + // general event selection + continue; + continue; + } + if (!(eventcuts.cfgTrackOccupancyMin <= collision.trackOccupancyInTimeRange() && collision.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + // 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; + } + 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.enableQA) { + for (auto& photon : photons_per_collision) { + registry.fill(HIST("hEClusterBefore"), photon.e()); // before cuts + if (!(fEMCCut.IsSelected(photon))) { + continue; + } + registry.fill(HIST("hEClusterAfter"), photon.e()); // accepted after cuts + } + } + for (auto& [g1, g2] : combinations(CombinationsStrictlyUpperIndexPolicy(photons_per_collision, photons_per_collision))) { + if (!(fEMCCut.IsSelected(g1)) || !(fEMCCut.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 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); + if (openingAngle <= mesonConfig.minOpenAngle) { + registry.fill(HIST("hClusterCuts"), 2); + continue; + } + if (cfgDoRotation) { + if (NColl % cfgDownsampling.value == 0) { + RotationBackground(vMeson, v1, v2, photons_per_collision, g1.globalIndex(), g2.globalIndex(), collision); + } + } + if (thnConfigAxisInvMass.value[1] > vMeson.M() || thnConfigAxisInvMass.value.back() < vMeson.M()) { + registry.fill(HIST("hClusterCuts"), 3); + continue; + } + if (thnConfigAxisPt.value[1] > vMeson.Pt() || thnConfigAxisPt.value.back() < vMeson.Pt()) { + registry.fill(HIST("hClusterCuts"), 4); + continue; + } + if (mesonConfig.enableQA) { + registry.fill(HIST("hInvMassPt"), vMeson.M(), vMeson.Pt()); + registry.fill(HIST("hTanThetaPhi"), vMeson.M(), getAngleDegree(atan(dTheta / dPhi))); + registry.fill(HIST("hAlphaPt"), (v1.E() - v2.E()) / (v1.E() + v2.E()), vMeson.Pt()); + } + if (mesonConfig.enableTanThetadPhi && mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(atan(dTheta / dPhi)))) { + registry.fill(HIST("hClusterCuts"), 5); + continue; + } + registry.fill(HIST("hClusterCuts"), 6); + runFlowAnalysis(collision, vMeson); + } + if (cfgDoRotation) { + if (NColl % cfgDownsampling.value == 0) { + NColl = 1; // reset counter + } else { + NColl++; + } + } + } + } + PROCESS_SWITCH(EMfTaskPi0Flow, processEMCal, "Process EMCal Pi0 candidates", true); + + // Pi0 from EMCal + void processEMCalMixed(FilteredCollsWithQvecs const& collisions, FilteredEMCalPhotons const& clusters) + { + auto getClustersSize = + [&clusters, this](FilteredCollsWithQvecs::iterator const& col) { + auto associatedClusters = clusters.sliceByCached(emccluster::emeventId, col.globalIndex(), this->cache); // it's cached, so slicing/grouping happens only once + return associatedClusters.size(); + }; + + using BinningType = FlexibleBinningPolicy, aod::collision::PosZ, aod::cent::CentFT0C, emevent::EP2FT0M>; + BinningType binningWithLambda{{getClustersSize}, {mixingConfig.ConfVtxBins, mixingConfig.ConfCentBins, mixingConfig.ConfEPBins}, true}; + + auto clustersTuple = std::make_tuple(clusters); + SameKindPair pair{binningWithLambda, mixingConfig.ConfMixingDepth, -1, collisions, clustersTuple, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored + + for (auto& [c1, clusters1, c2, clusters2] : pair) { + if (!(fEMEventCut.IsSelected(c1)) || !(fEMEventCut.IsSelected(c2))) { + // general event selection + continue; + } + if (!(eventcuts.cfgTrackOccupancyMin <= c1.trackOccupancyInTimeRange() && c1.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax) || !(eventcuts.cfgTrackOccupancyMin <= c2.trackOccupancyInTimeRange() && c2.trackOccupancyInTimeRange() < eventcuts.cfgTrackOccupancyMax)) { + // occupancy selection + continue; + } + if (getCentrality(c1) < eventcuts.cfgMinCent || getCentrality(c1) > eventcuts.cfgMaxCent || getCentrality(c2) < eventcuts.cfgMinCent || getCentrality(c2) > eventcuts.cfgMaxCent) { + // event selection + continue; + } + if (!isQvecGood(getAllQvec(c1)) || !isQvecGood(getAllQvec(c2))) { + // selection based on QVector + continue; + } + for (auto& [g1, g2] : combinations(CombinationsFullIndexPolicy(clusters1, clusters2))) { + if (!(fEMCCut.IsSelected(g1)) || !(fEMCCut.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 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); + if (openingAngle <= mesonConfig.minOpenAngle) { + registry.fill(HIST("hClusterCuts"), 2); + continue; + } + if (thnConfigAxisInvMass.value[1] > vMeson.M() || thnConfigAxisInvMass.value.back() < vMeson.M()) { + registry.fill(HIST("hClusterCuts"), 3); + continue; + } + if (thnConfigAxisPt.value[1] > vMeson.Pt() || thnConfigAxisPt.value.back() < vMeson.Pt()) { + registry.fill(HIST("hClusterCuts"), 4); + continue; + } + if (mesonConfig.enableQA) { + registry.fill(HIST("hInvMassPt"), vMeson.M(), vMeson.Pt()); + registry.fill(HIST("hTanThetaPhi"), vMeson.M(), getAngleDegree(atan(dTheta / dPhi))); + registry.fill(HIST("hAlphaPt"), (v1.E() - v2.E()) / (v1.E() + v2.E()), vMeson.Pt()); + } + if (mesonConfig.minTanThetadPhi > std::fabs(getAngleDegree(atan(dTheta / dPhi)))) { + registry.fill(HIST("hClusterCuts"), 5); + continue; + } + registry.fill(HIST("hClusterCuts"), 6); + runFlowAnalysis(c1, vMeson); + } + } + } + PROCESS_SWITCH(EMfTaskPi0Flow, processEMCalMixed, "Process EMCal Pi0 mixed event candidates", false); + + // Resolution + void processResolution(CollsWithQvecs::iterator const& collision) + { + o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(®istry, collision); + if (!(fEMEventCut.IsSelected(collision))) { + // 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)) { + return; + } + float cent = getCentrality(collision); + if (cent < eventcuts.cfgMinCent || cent > eventcuts.cfgMaxCent) { + // event selection + return; + } + if (!isQvecGood(getAllQvec(collision))) { + // selection based on QVector + return; + } + 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 + + float centrality = getCentrality(collision); // centrality not updated in the rejection mask function + float xQVecFT0a = -999.f; + float yQVecFT0a = -999.f; + float xQVecFT0c = -999.f; + float yQVecFT0c = -999.f; + float xQVecFT0m = -999.f; + float yQVecFT0m = -999.f; + float xQVecBPos = -999.f; + float yQVecBPos = -999.f; + float xQVecBNeg = -999.f; + float yQVecBNeg = -999.f; + float xQVecBTot = -999.f; + float yQVecBTot = -999.f; + if (harmonic == 2) { + xQVecFT0a = collision.q2xft0a(); + yQVecFT0a = collision.q2yft0a(); + xQVecFT0c = collision.q2xft0c(); + yQVecFT0c = collision.q2yft0c(); + xQVecFT0m = collision.q2xft0m(); + yQVecFT0m = collision.q2yft0m(); + xQVecBPos = collision.q2xbpos(); + yQVecBPos = collision.q2ybpos(); + xQVecBNeg = collision.q2xbneg(); + yQVecBNeg = collision.q2ybneg(); + xQVecBTot = collision.q2xbtot(); + yQVecBTot = collision.q2ybtot(); + } else if (harmonic == 3) { + xQVecFT0a = collision.q3xft0a(); + yQVecFT0a = collision.q3yft0a(); + xQVecFT0c = collision.q3xft0c(); + yQVecFT0c = collision.q3yft0c(); + xQVecFT0m = collision.q3xft0m(); + yQVecFT0m = collision.q3yft0m(); + xQVecBPos = collision.q3xbpos(); + yQVecBPos = collision.q3ybpos(); + xQVecBNeg = collision.q3xbneg(); + yQVecBNeg = collision.q3ybneg(); + xQVecBTot = collision.q3xbtot(); + yQVecBTot = collision.q3ybtot(); + } + + if (saveSPResoHist) { + registry.fill(HIST("spReso/hSpResoFT0cFT0a"), centrality, xQVecFT0c * xQVecFT0a + yQVecFT0c * yQVecFT0a); + registry.fill(HIST("spReso/hSpResoFT0cTPCpos"), centrality, xQVecFT0c * xQVecBPos + yQVecFT0c * yQVecBPos); + registry.fill(HIST("spReso/hSpResoFT0cTPCneg"), centrality, xQVecFT0c * xQVecBNeg + yQVecFT0c * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0cTPCtot"), centrality, xQVecFT0c * xQVecBTot + yQVecFT0c * yQVecBTot); + registry.fill(HIST("spReso/hSpResoFT0aTPCpos"), centrality, xQVecFT0a * xQVecBPos + yQVecFT0a * yQVecBPos); + registry.fill(HIST("spReso/hSpResoFT0aTPCneg"), centrality, xQVecFT0a * xQVecBNeg + yQVecFT0a * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0aTPCtot"), centrality, xQVecFT0a * xQVecBTot + yQVecFT0a * yQVecBTot); + registry.fill(HIST("spReso/hSpResoFT0mTPCpos"), centrality, xQVecFT0m * xQVecBPos + yQVecFT0m * yQVecBPos); + registry.fill(HIST("spReso/hSpResoFT0mTPCneg"), centrality, xQVecFT0m * xQVecBNeg + yQVecFT0m * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0mTPCtot"), centrality, xQVecFT0m * xQVecBTot + yQVecFT0m * yQVecBTot); + registry.fill(HIST("spReso/hSpResoTPCposTPCneg"), centrality, xQVecBPos * xQVecBNeg + yQVecBPos * yQVecBNeg); + } + + if (saveEpResoHisto) { + float epFT0a = epHelper.GetEventPlane(xQVecFT0a, yQVecFT0a, harmonic); + float epFT0c = epHelper.GetEventPlane(xQVecFT0c, yQVecFT0c, harmonic); + float epFT0m = epHelper.GetEventPlane(xQVecFT0m, yQVecFT0m, harmonic); + float epBPoss = epHelper.GetEventPlane(xQVecBPos, yQVecBPos, harmonic); + float epBNegs = epHelper.GetEventPlane(xQVecBNeg, yQVecBNeg, harmonic); + float epBTots = epHelper.GetEventPlane(xQVecBTot, yQVecBTot, harmonic); + + registry.fill(HIST("hEventPlaneAngleFT0M"), centrality, epFT0m); + registry.fill(HIST("hEventPlaneAngleTPCpos"), centrality, epBPoss); + registry.fill(HIST("hEventPlaneAngleTPCneg"), centrality, epBNegs); + + registry.fill(HIST("epReso/hEpResoFT0cFT0a"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epFT0a))); + registry.fill(HIST("epReso/hEpResoFT0cTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBPoss))); + registry.fill(HIST("epReso/hEpResoFT0cTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBNegs))); + registry.fill(HIST("epReso/hEpResoFT0cTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBTots))); + registry.fill(HIST("epReso/hEpResoFT0aTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBPoss))); + registry.fill(HIST("epReso/hEpResoFT0aTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBNegs))); + registry.fill(HIST("epReso/hEpResoFT0aTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBTots))); + registry.fill(HIST("epReso/hEpResoFT0mTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0m, epBPoss))); + 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))); + } + } + PROCESS_SWITCH(EMfTaskPi0Flow, processResolution, "Process resolution", false); + +}; // End struct EMfTaskPi0Flow + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGEM/PhotonMeson/Utils/ClusterHistograms.h b/PWGEM/PhotonMeson/Utils/ClusterHistograms.h index 9dc2d16a2aa..5df8ca93de1 100644 --- a/PWGEM/PhotonMeson/Utils/ClusterHistograms.h +++ b/PWGEM/PhotonMeson/Utils/ClusterHistograms.h @@ -21,26 +21,25 @@ namespace o2::aod::pwgem::photonmeson::utils::clusterhistogram { void addClusterHistograms(HistogramRegistry* fRegistry, bool do2DQA) { - fRegistry->add("Cluster/before/hE", "E_{cluster};#it{E}_{cluster} (GeV);#it{N}_{cluster}", kTH1F, {{500, 0, 50}}, true); - fRegistry->add("Cluster/before/hPt", "Transverse momenta of clusters;#it{p}_{T} (GeV/c);#it{N}_{cluster}", kTH1F, {{1000, 0.0f, 20}}, true); - fRegistry->add("Cluster/before/hNgamma", "Number of #gamma candidates per collision;#it{N}_{#gamma} per collision;#it{N}_{collisions}", kTH1F, {{101, -0.5f, 100.5f}}, true); - fRegistry->add("Cluster/before/hEtaPhi", "#eta vs #varphi;#eta;#varphi (rad.)", kTH2F, {{200, -1.0f, 1.0f}, {180, 0, 2 * M_PI}}, true); - fRegistry->add("Cluster/before/hTrackEtaPhi", "d#eta vs. d#varphi of matched tracks;d#eta;d#varphi (rad.)", kTH2F, {{100, -0.5, 0.5}, {100, -0.5, 0.5}}, true); + 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); 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, {{51, -0.5, 50.5}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{E}_{cluster} (GeV)", kTH2F, {{500, 0, 5}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hM20", "Short ellipse axis;#it{M}_{20} (cm);#it{E}_{cluster} (GeV)", kTH2F, {{250, 0, 2.5}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{E}_{cluster} (GeV)", kTH2F, {{100, -250, 250}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hCellTime", "Cell time;#it{t}_{cell} (ns);#it{E}_{cluster} (GeV)", kTH2F, {{100, -250, 250}, {200, 0, 20}}, true); - fRegistry->add("Cluster/before/hDistToBC", "distance to bad channel;#it{d};#it{E}_{cluster} (GeV)", kTH2F, {{100, 0, 1500}, {200, 0, 20}}, true); + 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); } else { - fRegistry->add("Cluster/before/hNCell", "#it{N}_{cells};N_{cells} (GeV);#it{N}_{cluster}", kTH1F, {{51, -0.5, 50.5}}, true); - fRegistry->add("Cluster/before/hM02", "Long ellipse axis;#it{M}_{02} (cm);#it{N}_{cluster}", kTH1F, {{500, 0, 5}}, true); - fRegistry->add("Cluster/before/hM20", "Short ellipse axis;#it{M}_{20} (cm);#it{N}_{cluster}", kTH1F, {{250, 0, 2.5}}, true); - fRegistry->add("Cluster/before/hTime", "Cluster time;#it{t}_{cls} (ns);#it{N}_{cluster}", kTH1F, {{500, -250, 250}}, true); - fRegistry->add("Cluster/before/hCellTime", "Cluster time;#it{t}_{cell} (ns);#it{N}_{cluster}", kTH1F, {{500, -250, 250}}, true); - fRegistry->add("Cluster/before/hDistToBC", "distance to bad channel;#it{d};#it{N}_{cluster}", kTH1F, {{100, 0, 1500}}, true); + 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); } 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); @@ -57,27 +56,32 @@ void addClusterHistograms(HistogramRegistry* fRegistry, bool do2DQA) } template -void fillClusterHistograms(HistogramRegistry* fRegistry, SkimEMCCluster cluster, bool do2DQA) +void fillClusterHistograms(HistogramRegistry* fRegistry, SkimEMCCluster 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.pt()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hPt"), cluster.e()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hEtaPhi"), cluster.eta(), cluster.phi()); + 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("hTrackEtaPhi"), cluster.tracketa()[itrack] - cluster.eta(), cluster.trackphi()[itrack] - cluster.phi()); + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackdEtadPhi"), cluster.tracketa()[itrack] - cluster.eta(), cluster.trackphi()[itrack] - cluster.phi(), weight); } if (do2DQA) { - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNCell"), cluster.nCells(), cluster.e()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM02"), cluster.m02(), cluster.e()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM20"), cluster.m20(), cluster.e()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTime"), cluster.time(), cluster.e()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hDistToBC"), cluster.distanceToBadChannel(), cluster.e()); + 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++) { + 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); + } } else { - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hNCell"), cluster.nCells()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM02"), cluster.m02()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hM20"), cluster.m20()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTime"), cluster.time()); - fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hDistToBC"), cluster.distanceToBadChannel()); + 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++) { + fRegistry->fill(HIST("Cluster/") + HIST(cluster_types[cls_id]) + HIST("hTrackEOverP"), cluster.e() / cluster.trackp()[itrack], weight); + } } } diff --git a/PWGEM/PhotonMeson/Utils/NMHistograms.h b/PWGEM/PhotonMeson/Utils/NMHistograms.h index 073d0f4d812..95abaf92292 100644 --- a/PWGEM/PhotonMeson/Utils/NMHistograms.h +++ b/PWGEM/PhotonMeson/Utils/NMHistograms.h @@ -21,12 +21,11 @@ #include "PWGEM/PhotonMeson/Utils/MCUtilities.h" using namespace o2::framework; -// using namespace o2::aod::pwgem::photonmeson::photonpair; using namespace o2::aod::pwgem::photonmeson::utils::mcutil; namespace o2::aod::pwgem::photonmeson::utils::nmhistogram { -void addNMHistograms(HistogramRegistry* fRegistry, bool isMC, const char* pairname = "#gamma#gamma", const char* /*epdetname*/ = "") +void addNMHistograms(HistogramRegistry* fRegistry, bool isMC, const char* pairname = "#gamma#gamma") { // !!Don't change pt,eta,y binning. These binnings have to be consistent with binned data at skimming.!! std::vector ptbins; @@ -69,30 +68,29 @@ 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) +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()); + float weight = eventWeight; 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()); + fRegistry->fill(HIST("Pair/Pi0/hs_Primary"), v12.M(), v12.Pt(), weight); } else if (motherid_strhad > 0) { - float weight = 1.f; auto str_had = mcparticles.iteratorAt(motherid_strhad); if (abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) { - weight = f1fd_k0s_to_pi0->Eval(str_had.pt()); + weight *= f1fd_k0s_to_pi0->Eval(str_had.pt()); } fRegistry->fill(HIST("Pair/Pi0/hs_FromWD"), v12.M(), v12.Pt(), weight); } else { - float weight = 1.f; fRegistry->fill(HIST("Pair/Pi0/hs_FromHS"), v12.M(), v12.Pt(), weight); } break; } case 221: { if (mcparticle.isPhysicalPrimary() || mcparticle.producedByGenerator()) { - fRegistry->fill(HIST("Pair/Eta/hs_Primary"), v12.M(), v12.Pt()); + fRegistry->fill(HIST("Pair/Eta/hs_Primary"), v12.M(), v12.Pt(), weight); } break; } diff --git a/PWGEM/PhotonMeson/Utils/PCMUtilities.h b/PWGEM/PhotonMeson/Utils/PCMUtilities.h index 38492dae9e6..63101c41418 100644 --- a/PWGEM/PhotonMeson/Utils/PCMUtilities.h +++ b/PWGEM/PhotonMeson/Utils/PCMUtilities.h @@ -47,18 +47,11 @@ inline float v0_qt(float pxpos, float pypos, float pzpos, float pxneg, float pyn return std::sqrt(RecoDecay::p2(pxneg, pyneg, pzneg) - dp * dp / momTot); // qt of v0 } //_______________________________________________________________________ -template -inline void Vtx_recalculation(o2::base::Propagator* prop, T1 lTrackPos, T2 lTrackNeg, float xyz[3], o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE) +template +inline void Vtx_recalculationParCov(o2::base::Propagator* prop, const o2::track::TrackParametrizationWithError& trackPosInformation, const o2::track::TrackParametrizationWithError& trackNegInformation, float xyz[3], o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE) { float bz = prop->getNominalBz(); - //******************************************************* - - o2::track::TrackParametrizationWithError trackPosInformation = getTrackParCov(lTrackPos); // first get an object that stores Track information (positive) - o2::track::TrackParametrizationWithError trackNegInformation = getTrackParCov(lTrackNeg); // first get an object that stores Track information (negative) - trackPosInformation.setPID(o2::track::PID::Electron); - trackNegInformation.setPID(o2::track::PID::Electron); - o2::track::TrackAuxPar helixPos(trackPosInformation, bz); // This object is a descendant of a CircleXY and stores cirlce information with respect to the magnetic field. This object uses functions and information of the o2::track::TrackParametrizationWithError object (positive) o2::track::TrackAuxPar helixNeg(trackNegInformation, bz); // This object is a descendant of a CircleXY and stores cirlce information with respect to the magnetic field. This object uses functions and information of the o2::track::TrackParametrizationWithError object (negative) @@ -66,10 +59,8 @@ inline void Vtx_recalculation(o2::base::Propagator* prop, T1 lTrackPos, T2 lTrac xyz[1] = (helixPos.yC * helixNeg.rC + helixNeg.yC * helixPos.rC) / (helixPos.rC + helixNeg.rC); // If this calculation doesn't work check if the rotateZ function, because the "documentation" says I get global coordinates but maybe i don't. // I am unsure about the Z calculation but this is how it is done in AliPhysics as far as I understand - o2::track::TrackParametrizationWithError trackPosInformationCopy = o2::track::TrackParametrizationWithError(trackPosInformation); - o2::track::TrackParametrizationWithError trackNegInformationCopy = o2::track::TrackParametrizationWithError(trackNegInformation); - trackPosInformationCopy.setPID(o2::track::PID::Electron); - trackNegInformationCopy.setPID(o2::track::PID::Electron); + auto trackPosInformationCopy = trackPosInformation; + auto trackNegInformationCopy = trackNegInformation; // I think this calculation gets the closest point on the track to the conversion point // This alpha is a different alpha than the usual alpha and I think it is the angle between X axis and conversion point @@ -104,5 +95,89 @@ inline void Vtx_recalculation(o2::base::Propagator* prop, T1 lTrackPos, T2 lTrac xyz[2] = (trackPosInformationCopy.getZ() * helixNeg.rC + trackNegInformationCopy.getZ() * helixPos.rC) / (helixPos.rC + helixNeg.rC); } //_______________________________________________________________________ +template +inline void Vtx_recalculation(o2::base::Propagator* prop, T1 lTrackPos, T2 lTrackNeg, float xyz[3], o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE) +{ + // o2::track::TrackParametrizationWithError = TrackParCov, I use the full version to have control over the data type + o2::track::TrackParametrizationWithError trackPosInformation = getTrackParCov(lTrackPos); // first get an object that stores Track information (positive) + o2::track::TrackParametrizationWithError trackNegInformation = getTrackParCov(lTrackNeg); // first get an object that stores Track information (negative) + + 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))); +} +//_______________________________________________________________________ //_______________________________________________________________________ #endif // PWGEM_PHOTONMESON_UTILS_PCMUTILITIES_H_ diff --git a/PWGEM/Tasks/phosElId.cxx b/PWGEM/Tasks/phosElId.cxx index 3899075fe04..327061dbfbc 100644 --- a/PWGEM/Tasks/phosElId.cxx +++ b/PWGEM/Tasks/phosElId.cxx @@ -40,6 +40,7 @@ #include "DetectorsBase/Propagator.h" #include "TF1.h" +#include "TLorentzVector.h" /// \struct PHOS electron id analysis /// \brief Task for calculating electron identification parameters @@ -50,14 +51,37 @@ /// using namespace o2; +using namespace o2::soa; using namespace o2::aod::evsel; using namespace o2::framework; using namespace o2::framework::expressions; +namespace o2::aod +{ +namespace PHOSMatch +{ +DECLARE_SOA_INDEX_COLUMN(Collision, collision); +DECLARE_SOA_INDEX_COLUMN(Track, track); +DECLARE_SOA_INDEX_COLUMN(CaloCluster, caloCluster); +DECLARE_SOA_COLUMN(SignalCharge, signalCharge, float); +DECLARE_SOA_COLUMN(SignalZ, signalZ, float); +DECLARE_SOA_COLUMN(SignalPx, signalPx, double); +DECLARE_SOA_COLUMN(SignalPy, signalPy, double); +DECLARE_SOA_COLUMN(SignalPz, signalPz, double); +DECLARE_SOA_COLUMN(SignalE, signalE, double); +} // namespace PHOSMatch + +DECLARE_SOA_TABLE(PHOSMatchindexTable, "AOD", "PHSMTCH", //! + o2::soa::Index<>, PHOSMatch::CollisionId, PHOSMatch::CaloClusterId, PHOSMatch::TrackId); //! + +} // namespace o2::aod + struct phosElId { + Produces phosMatch; + using SelCollisions = soa::Join; - using tracks = soa::Join; + using myTracks = soa::Join; Configurable mMinCluE{"mMinCluE", 0.3, "Minimum cluster energy for analysis"}; Configurable mMinCluTime{"minCluTime", -25.e-9, "Min. cluster time"}; @@ -77,21 +101,53 @@ struct phosElId { Configurable mEpmin{"mEpmin", -1., "Min for E/p histograms"}; Configurable mEpmax{"mEpmax", 3., "Max for E/p histograms"}; - Configurable> pSigma_dz{"pSigma_dz", {20., 0.76, 6.6, 3.6, 0.1}, "parameters for sigma dz function"}; - Configurable> pSigma_dx{"pSigma_dx", {3, 2.3, 3.1}, "parameters for sigma dx function"}; + Configurable> pSigma_dz{"pSigma_dz", {0.642, 0., 1.77, 2.725, 0.}, "parameters for sigma dz function"}; + Configurable> pSigma_dx{"pSigma_dx", {2.17769, 1.60275, 2.24136}, "parameters for sigma dx function"}; + + Configurable> pPhosShiftZ{"pPhosShiftZ", {4.78838, 2.75138, 1.40825, 2.28735}, "Phos coordinate centering Z per module"}; + Configurable> pPhosShiftX{"pPhosShiftX", {2.158702, -1.526772, -0.814658, -1.852678}, "Phos coordinate centering X per module"}; - Configurable> pPhosShiftZ{"pPhosShiftZ", {4.5, 3., 2., 2.}, "Phos coordinate centering Z per module"}; - Configurable> pPhosShiftX{"pPhosShiftX", {1.99, -0.63, -1.55, -1.63}, "Phos coordinate centering X per module"}; + Configurable> pMean_dx_pos_mod1{"pMean_dx_pos_mod1", {-10.57, -0.42, 1.06}, "parameters for mean dx function on module 1 for positive tracks"}; + Configurable> pMean_dx_pos_mod2{"pMean_dx_pos_mod2", {-8.1, -0.42, 1.14}, "parameters for mean dx function on module 2 for positive tracks"}; + Configurable> pMean_dx_pos_mod3{"pMean_dx_pos_mod3", {-8.34, -0.42, 1.04}, "parameters for mean dx function on module 3 for positive tracks"}; + Configurable> pMean_dx_pos_mod4{"pMean_dx_pos_mod4", {-7.38, -0.42, 1.17}, "parameters for mean dx function on module 4 for positive tracks"}; - Configurable> pMean_dx_pos_mod1{"pMean_dx_pos_mod1", {-9.57, -0.47, 1.04}, "parameters for mean dx function on module 1 for positive tracks"}; - Configurable> pMean_dx_pos_mod2{"pMean_dx_pos_mod2", {-12.24, -0.18, 1.59}, "parameters for mean dx function on module 2 for positive tracks"}; - Configurable> pMean_dx_pos_mod3{"pMean_dx_pos_mod3", {-5.73, -0.58, 1.13}, "parameters for mean dx function on module 3 for positive tracks"}; - Configurable> pMean_dx_pos_mod4{"pMean_dx_pos_mod4", {-5.14, -0.67, 1.05}, "parameters for mean dx function on module 4 for positive tracks"}; + Configurable> pMean_dx_neg_mod1{"pMean_dx_neg_mod1", {9.92, -0.42, 1.29}, "parameters for mean dx function on module 1 for negative tracks"}; + Configurable> pMean_dx_neg_mod2{"pMean_dx_neg_mod2", {7.82, -0.4, 1.34}, "parameters for mean dx function on module 2 for negative tracks"}; + Configurable> pMean_dx_neg_mod3{"pMean_dx_neg_mod3", {8.45, -0.33, 1.5}, "parameters for mean dx function on module 3 for negative tracks"}; + Configurable> pMean_dx_neg_mod4{"pMean_dx_neg_mod4", {7.5, -0.42, 1.25}, "parameters for mean dx function on module 4 for negative tracks"}; - Configurable> pMean_dx_neg_mod1{"pMean_dx_neg_mod1", {10.29, -0.42, 1.12}, "parameters for mean dx function on module 1 for negative tracks"}; - Configurable> pMean_dx_neg_mod2{"pMean_dx_neg_mod2", {8.24, -0.42, 1.31}, "parameters for mean dx function on module 2 for negative tracks"}; - Configurable> pMean_dx_neg_mod3{"pMean_dx_neg_mod3", {11.83, -0.17, 1.71}, "parameters for mean dx function on module 3 for negative tracks"}; - Configurable> pMean_dx_neg_mod4{"pMean_dx_neg_mod4", {84.96, 0.79, 2.83}, "parameters for mean dx function on module 4 for negative tracks"}; + 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"}; + + 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; Service ccdb; std::unique_ptr geomPHOS; @@ -115,9 +171,9 @@ struct phosElId { { LOG(info) << "Initializing PHOS electron identification analysis task ..."; - std::vector momentum_binning = {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, + std::vector momentum_binning = {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, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10.}; + 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 10.}; std::vector parameters_sigma_dz = pSigma_dz; std::vector parameters_sigma_dx = pSigma_dx; std::vector vPhosShiftX = pPhosShiftX; @@ -150,6 +206,7 @@ struct phosElId { axisEta{200, -0.2, 0.2, "#eta"}, axisPhi{80, 240, 320, "#varphi"}, axisE{200, 0, 10, "E (GeV)", "E (GeV)"}, + axisMassSpectrum{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}, axisEp{nBinsEp, mEpmin, mEpmax, "E/p", "E_{cluster}/p_{track}"}, 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)"}, @@ -160,10 +217,10 @@ struct phosElId { axisZ{150, -75., 75., "z (cm)", "z (cm)"}, axisDCATrackXY{400, -.1, .1, "DCA XY (cm)", "DCA XY (cm)"}, axisDCATrackZ{400, -.1, .1, "DCA Z (cm)", "DCA Z (cm)"}, - axisVColX{400, -.1, .1, "colision vertex x (cm)", "colision vertex x (cm)"}, // make 3 different histo + axisVColX{400, -.1, .1, "colision vertex x (cm)", "colision vertex x (cm)"}, axisVColY{400, -.1, .1, "colision vertex y (cm)", "colision vertex y (cm)"}, axisVColZ{400, -20., 20., "colision vertex z (cm)", "colision vertex z (cm)"}, // should look like gauss - axisVTrackX{400, -10., 10., "track vertex x (cm)", "track vertex x (cm)"}, // make 3 different histo + axisVTrackX{400, -10., 10., "track vertex x (cm)", "track vertex x (cm)"}, axisVTrackY{400, -10., 10., "track vertex y (cm)", "track vertex y (cm)"}, axisVTrackZ{400, -10., 10., "track vertex z (cm)", "track vertex z (cm)"}; @@ -191,31 +248,54 @@ struct phosElId { 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("hCluE_v_p", "Cluster energy vs p", HistType::kTH3F, {axisE, axisP, axisModes}); - mHistManager.add("hCluE_v_p_disp", "Cluster energy vs p | OK dispersion", HistType::kTH3F, {axisE, axisP, axisModes}); - mHistManager.add("hCluE_v_p_1sigma", "Cluster energy vs p within trackmatch 1sigma", HistType::kTH3F, {axisE, axisP, axisModes}); - mHistManager.add("hCluE_v_p_1sigma_disp", "Cluster energy vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisE, axisP, axisModes}); - mHistManager.add("hCluE_v_p_2sigma", "Cluster energy vs p within trackmatch 2sigma", HistType::kTH3F, {axisE, axisP, axisModes}); - mHistManager.add("hCluE_v_p_2sigma_disp", "Cluster energy vs p within trackmatch 2sigma | OK dispersion", HistType::kTH3F, {axisE, axisP, axisModes}); - - mHistManager.add("hEp_v_p_disp", "E/p ratio vs p | OK dispersion", HistType::kTH3F, {axisEp, axisP, axisModes}); - mHistManager.add("hEp_v_p_1sigma", "E/p ratio vs p within trackmatch 1sigma", HistType::kTH3F, {axisEp, axisP, axisModes}); - mHistManager.add("hEp_v_p_1sigma_disp", "E/p ratio vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisEp, axisP, axisModes}); - mHistManager.add("hEp_v_p_2sigma", "E/p ratio vs p within trackmatch 2sigma", HistType::kTH3F, {axisEp, axisP, axisModes}); - mHistManager.add("hEp_v_p_2sigma_disp", "E/p ratio vs p within trackmatch 2sigma | OK dispersion", HistType::kTH3F, {axisEp, axisP, axisModes}); - - mHistManager.add("hdZpmod", "dz,p_{tr},module", HistType::kTH3F, {axisdZ, axisP, axisModes}); - mHistManager.add("hdZpmod_pos", "dz,p_{tr},module positive tracks", HistType::kTH3F, {axisdZ, axisP, axisModes}); - mHistManager.add("hdZpmod_neg", "dz,p_{tr},module negative tracks", HistType::kTH3F, {axisdZ, axisP, axisModes}); - mHistManager.add("hdXpmod", "dx,p_{tr},module", HistType::kTH3F, {axisdX, axisP, axisModes}); - mHistManager.add("hdXpmod_pos", "dx,p_{tr},module positive tracks", HistType::kTH3F, {axisdX, axisP, axisModes}); - mHistManager.add("hdXpmod_neg", "dx,p_{tr},module negative tracks", HistType::kTH3F, {axisdX, axisP, 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_1sigma", "Cluster energy vs p within trackmatch 1sigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_1sigma_disp", "Cluster energy vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_2sigma", "Cluster energy vs p within trackmatch 2sigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_2sigma_disp", "Cluster energy vs p within trackmatch 2sigma | 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_1sigma_TPC", "Cluster energy vs p within trackmatch 1sigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_1sigma_disp_TPC", "Cluster energy vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_2sigma_TPC", "Cluster energy vs p within trackmatch 2sigma", HistType::kTH3F, {axisE, axisPt, axisModes}); + mHistManager.add("hCluE_v_pt_2sigma_disp_TPC", "Cluster energy vs p within trackmatch 2sigma | 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_1sigma", "E/p ratio vs p within trackmatch 1sigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_1sigma_disp", "E/p ratio vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_2sigma", "E/p ratio vs p within trackmatch 2sigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_2sigma_disp", "E/p ratio vs p within trackmatch 2sigma | 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_1sigma", "E/p ratio vs cluster E within trackmatch 1sigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_1sigma_disp", "E/p ratio vs cluster E within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_2sigma", "E/p ratio vs cluster E within trackmatch 2sigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_2sigma_disp", "E/p ratio vs cluster E within trackmatch 2sigma | 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_1sigma_TPC", "E/p ratio vs p within trackmatch 1sigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_1sigma_disp_TPC", "E/p ratio vs p within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_2sigma_TPC", "E/p ratio vs p within trackmatch 2sigma", HistType::kTH3F, {axisEp, axisPt, axisModes}); + mHistManager.add("hEp_v_pt_2sigma_disp_TPC", "E/p ratio vs p within trackmatch 2sigma | 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_1sigma_TPC", "E/p ratio vs cluster E within trackmatch 1sigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_1sigma_disp_TPC", "E/p ratio vs cluster E within trackmatch 1sigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_2sigma_TPC", "E/p ratio vs cluster E within trackmatch 2sigma", HistType::kTH3F, {axisEp, axisE, axisModes}); + mHistManager.add("hEp_v_E_2sigma_disp_TPC", "E/p ratio vs cluster E within trackmatch 2sigma | OK dispersion", HistType::kTH3F, {axisEp, axisE, axisModes}); geomPHOS = std::make_unique("PHOS"); - fSigma_dz = new TF1("func", "[0]/(x+[1])^[2]+pol1(3)", 0.3, 10); + fSigma_dz = new TF1("fSigma_dz", "[0]/(x+[1])^[2]+pol1(3)", 0.3, 10); fSigma_dz->SetParameters(parameters_sigma_dz.at(0), parameters_sigma_dz.at(1), parameters_sigma_dz.at(2), parameters_sigma_dz.at(3), parameters_sigma_dz.at(4)); - fSigma_dx = new TF1("fSigma_dz_dx", "[0]/x^[1]+[2]", 0.1, 10); + fSigma_dx = new TF1("fSigma_dx", "[0]/x^[1]+[2]", 0.1, 10); fSigma_dx->SetParameters(parameters_sigma_dx.at(0), parameters_sigma_dx.at(1), parameters_sigma_dx.at(2)); fMean_dx_pos_mod1 = new TF1("funcMeandx_pos_mod1", "[0]/(x+[1])^[2]", 0.1, 10); @@ -239,7 +319,7 @@ struct phosElId { } void process(soa::Join::iterator const& collision, aod::CaloClusters& clusters, - tracks& tracks, + soa::Filtered const& tracks, aod::BCsWithTimestamps const&) { auto bc = collision.bc_as(); @@ -254,6 +334,8 @@ struct phosElId { LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; runNumber = bc.runNumber(); } + if (fabs(collision.posZ()) > 10.f) + return; mHistManager.fill(HIST("eventCounter"), 0.5); if (!collision.alias_bit(mEvSelTrig)) return; @@ -261,23 +343,31 @@ struct phosElId { 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()); for (auto const& track : tracks) { - if (!track.has_collision()) + if (!track.has_collision() || fabs(track.dcaXY()) > cfgDCAxyMax || fabs(track.dcaZ()) > cfgDCAzMax || !track.hasTPC() || fabs(track.eta()) > 0.15) + continue; + if (track.pt() < cfgPtMin || track.pt() > cfgPtMax) + continue; + if (track.itsChi2NCl() > cfgITSchi2Max) + continue; + if (track.itsNCls() < cfgITSnclsMin || track.itsNCls() > cfgITSnclsMax || !((track.itsClusterMap() & uint8_t(1)) > 0)) + continue; + if (track.tpcChi2NCl() > cfgTPCchi2Max) continue; + if (track.tpcNClsFound() < cfgTPCnclsMin || track.tpcNClsFound() > cfgTPCnclsMax) + continue; + if (track.tpcNClsCrossedRows() < cfgTPCnclsCRMin || track.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + continue; + mHistManager.fill(HIST("hTrackVX"), track.x()); mHistManager.fill(HIST("hTrackVY"), track.y()); mHistManager.fill(HIST("hTrackVZ"), track.z()); - mHistManager.fill(HIST("hColVX"), collision.posX()); - mHistManager.fill(HIST("hColVY"), collision.posY()); - mHistManager.fill(HIST("hColVZ"), collision.posZ()); - if (std::abs(track.collision_as().posZ()) > 10.f) - continue; - // calculate coordinate in PHOS plane - if (std::abs(track.eta()) > 0.3) - continue; int16_t module; float trackX = 999., trackZ = 999.; @@ -286,8 +376,28 @@ struct phosElId { continue; float trackMom = track.p(); + float trackPT = track.pt(); + + bool isElectron = false; + if (track.hasTPC()) { + float nsigmaTPCEl = track.tpcNSigmaEl(); + float nsigmaTOFEl = track.tofNSigmaEl(); + bool isTPC_electron = nsigmaTPCEl > cfgTPCNSigmaElMin && nsigmaTPCEl < cfgTPCNSigmaElMax; + bool isTOF_electron = nsigmaTOFEl > cfgTOFNSigmaElMin && nsigmaTOFEl < cfgTOFNSigmaElMax; + isElectron = isTPC_electron || isTOF_electron; + + 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; + if (isElectron && !(isPion || isKaon || isProton)) + isElectron = true; + } + bool posTrack = (track.sign() > 0 && bz > 0) || (track.sign() < 0 && bz < 0); - for (const auto& clu : clusters) { + for (auto const& clu : clusters) { if (module != clu.mod()) continue; double cluE = clu.e(); @@ -299,39 +409,70 @@ struct phosElId { continue; bool isDispOK = testLambda(cluE, clu.m02(), clu.m20()); + 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, trackMom, module); - mHistManager.fill(HIST("hdXpmod"), dX, trackMom, module); + mHistManager.fill(HIST("hdZpmod"), dZ, trackPT, module); + mHistManager.fill(HIST("hdXpmod"), dX, trackPT, module); if (posTrack) { - mHistManager.fill(HIST("hdZpmod_pos"), dZ, trackMom, module); - mHistManager.fill(HIST("hdXpmod_pos"), dX, trackMom, module); + mHistManager.fill(HIST("hdZpmod_pos"), dZ, trackPT, module); + mHistManager.fill(HIST("hdXpmod_pos"), dX, trackPT, module); } else { - mHistManager.fill(HIST("hdZpmod_neg"), dZ, trackMom, module); - mHistManager.fill(HIST("hdXpmod_neg"), dX, trackMom, module); + mHistManager.fill(HIST("hdZpmod_neg"), dZ, trackPT, module); + mHistManager.fill(HIST("hdXpmod_neg"), dX, trackPT, module); } - mHistManager.fill(HIST("hCluE_v_p"), cluE, trackMom, module); if (isDispOK) { - mHistManager.fill(HIST("hCluE_v_p_disp"), cluE, trackMom, module); - mHistManager.fill(HIST("hEp_v_p_disp"), Ep, trackMom, module); + 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); + 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); + } } - if (!isWithin2Sigma(module, trackMom, dZ, dX)) + if (!isWithin2Sigma(module, trackPT, dZ, dX)) continue; - mHistManager.fill(HIST("hCluE_v_p_2sigma"), cluE, trackMom, module); - mHistManager.fill(HIST("hEp_v_p_2sigma"), Ep, trackMom, module); + mHistManager.fill(HIST("hCluE_v_pt_2sigma"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_2sigma"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_2sigma"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("hCluE_v_pt_2sigma_TPC"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_2sigma_TPC"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_2sigma_TPC"), Ep, cluE, module); + } if (isDispOK) { - mHistManager.fill(HIST("hCluE_v_p_2sigma_disp"), cluE, trackMom, module); - mHistManager.fill(HIST("hEp_v_p_2sigma_disp"), Ep, trackMom, module); + mHistManager.fill(HIST("hCluE_v_pt_2sigma_disp"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_2sigma_disp"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_2sigma_disp"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("hCluE_v_pt_2sigma_disp_TPC"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_2sigma_disp_TPC"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_2sigma_disp_TPC"), Ep, cluE, module); + } + phosMatch(collision.index(), clu.index(), track.index()); } - if (isWithin1Sigma(module, trackMom, dZ, dX)) { - mHistManager.fill(HIST("hCluE_v_p_1sigma"), cluE, trackMom, module); - mHistManager.fill(HIST("hEp_v_p_1sigma"), Ep, trackMom, module); + if (isWithin1Sigma(module, trackPT, dZ, dX)) { + mHistManager.fill(HIST("hCluE_v_pt_1sigma"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_1sigma"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_1sigma"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("hCluE_v_pt_1sigma_TPC"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_1sigma_TPC"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_1sigma_TPC"), Ep, cluE, module); + } if (isDispOK) { - mHistManager.fill(HIST("hCluE_v_p_1sigma_disp"), cluE, trackMom, module); - mHistManager.fill(HIST("hEp_v_p_1sigma_disp"), Ep, trackMom, module); + mHistManager.fill(HIST("hCluE_v_pt_1sigma_disp"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_1sigma_disp"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_1sigma_disp"), Ep, cluE, module); + if (isElectron) { + mHistManager.fill(HIST("hCluE_v_pt_1sigma_disp_TPC"), cluE, trackPT, module); + mHistManager.fill(HIST("hEp_v_pt_1sigma_disp_TPC"), Ep, trackPT, module); + mHistManager.fill(HIST("hEp_v_E_1sigma_disp_TPC"), Ep, cluE, module); + } } } } @@ -342,7 +483,7 @@ struct phosElId { mHistManager.fill(HIST("hTrackPhosProjMod"), trackX, trackZ, module); } // end of double loop - for (const auto& clu : clusters) { + for (auto const& clu : clusters) { double cluE = clu.e(), cluTime = clu.time(); int mod = clu.mod(); if (cluE > mMinCluE) { @@ -497,9 +638,404 @@ struct phosElId { } }; +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> 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)"}; + + Service ccdb; + std::unique_ptr geomPHOS; + double bz{0.}; // magnetic field + int runNumber{0}; + + HistogramRegistry mHistManager{"MassSpectraHistograms"}; + TF1* fEp_sigma_phos; + + void init(InitContext const&) + { + LOG(info) << "Initializing PHOS electron identification analysis task ..."; + + std::vector momentum_binning = {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, ""}, + axisPt{momentum_binning, "p_{T} (GeV/c)"}, + axisE{200, 0, 10, "E (GeV)", "E (GeV)"}, + axisMassSpectrum{4000, 0, 4, "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_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_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}); + + geomPHOS = std::make_unique("PHOS"); + + std::vector EpSigmaPars = cfgEpSigmaPars; + fEp_sigma_phos = new TF1("fEp_sigma_phos", "sqrt([0]*[0]/x/x+[1]*[1]/x+[2]*[2])+[3]", 0.01, 10); + fEp_sigma_phos->SetParameters(EpSigmaPars.at(0), EpSigmaPars.at(1), EpSigmaPars.at(2), EpSigmaPars.at(3)); + } + + void process(soa::Join::iterator const& collision, + aod::CaloClusters const& clusters, + myTracks const& tracks, + o2::aod::PHOSMatchindexTable const& matches, + aod::BCsWithTimestamps const&) + { + auto bc = collision.bc_as(); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", 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(); + } + if (fabs(collision.posZ()) > 10.f) + return; + mHistManager.fill(HIST("eventCounter"), 0.5); + if (!collision.alias_bit(mEvSelTrig)) + return; + mHistManager.fill(HIST("TVXinPHOSCounter"), 0.5); + + if (clusters.size() == 0) + return; // Nothing to process + + for (auto const& TPCel : tracks) { + + if (!TPCel.has_collision() || fabs(TPCel.dcaXY()) > cfgDCAxyMax || fabs(TPCel.dcaZ()) > cfgDCAzMax || !TPCel.hasTPC() || fabs(TPCel.eta()) > 0.15) + continue; + if (TPCel.pt() < cfgPtMin || TPCel.pt() > cfgPtMax) + continue; + if (TPCel.itsChi2NCl() > cfgITSchi2Max) + continue; + if (TPCel.itsNCls() < cfgITSnclsMin || TPCel.itsNCls() > cfgITSnclsMax || !((TPCel.itsClusterMap() & uint8_t(1)) > 0)) + continue; + if (TPCel.tpcChi2NCl() > cfgTPCchi2Max) + continue; + if (TPCel.tpcNClsFound() < cfgTPCnclsMin || TPCel.tpcNClsFound() > cfgTPCnclsMax) + continue; + if (TPCel.tpcNClsCrossedRows() < cfgTPCnclsCRMin || TPCel.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + continue; + + bool isElectron = false; + float nsigmaTPCEl = TPCel.tpcNSigmaEl(); + float nsigmaTOFEl = TPCel.tofNSigmaEl(); + bool isTPC_electron = nsigmaTPCEl > cfgTPCNSigmaElMin && nsigmaTPCEl < cfgTPCNSigmaElMax; + bool isTOF_electron = nsigmaTOFEl > cfgTOFNSigmaElMin && nsigmaTOFEl < cfgTOFNSigmaElMax; + isElectron = isTPC_electron || isTOF_electron; + + 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; + if (isElectron && !(isPion || isKaon || isProton)) + isElectron = true; + if (!isElectron) + continue; + + for (auto const& match : matches) { + auto clust2 = clusters.iteratorAt(match.caloClusterId()); + auto track2 = tracks.iteratorAt(match.trackId()); + + if (TPCel.collisionId() != track2.collisionId()) + continue; + if (TPCel.index() >= track2.index()) + break; + + float mass_2tracks = 0, mom_2tracks = 0, cluE = clust2.e(); + TLorentzVector P1, P2; + P1.SetPxPyPzE(TPCel.px(), TPCel.py(), TPCel.pz(), TPCel.energy(0)); + P2.SetPxPyPzE(track2.px(), track2.py(), track2.pz(), track2.energy(0)); + mom_2tracks = (P1 + P2).Pt(); + mass_2tracks = (P1 + P2).M(); + bool posTrack = (TPCel.sign() > 0 && bz > 0) || (TPCel.sign() < 0 && bz < 0); + bool elCandidate = (fabs(clust2.e() / track2.p() - 1) < 2 * fEp_sigma_phos->Eval(mom_2tracks)); + + if (TPCel.sign() == track2.sign()) { + if (posTrack) { + mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_eh_pp_mass_spectra_v_E"), mass_2tracks, cluE); + if (elCandidate) { + mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_ee_pp_mass_spectra_v_E"), mass_2tracks, cluE); + } + } else { + mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_eh_mm_mass_spectra_v_E"), mass_2tracks, cluE); + if (elCandidate) { + mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_ee_mm_mass_spectra_v_E"), mass_2tracks, cluE); + } + } + } else { + mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_eh_mp_mass_spectra_v_E"), mass_2tracks, cluE); + if (elCandidate) { + mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_Pt"), mass_2tracks, mom_2tracks); + mHistManager.fill(HIST("h_ee_mp_mass_spectra_v_E"), mass_2tracks, cluE); + } + } + } + } // end of double loop + } +}; + +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"}; + + 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 tpcPi_rej = (aod::pidtpc::tpcNSigmaPi < cfgTPCNSigmaPiMin) || (aod::pidtpc::tpcNSigmaPi > cfgTPCNSigmaPiMax); + Filter tpcKa_rej = (aod::pidtpc::tpcNSigmaKa < cfgTPCNSigmaKaMin) || (aod::pidtpc::tpcNSigmaKa > cfgTPCNSigmaPrMax); + Filter tpcPr_rej = (aod::pidtpc::tpcNSigmaPr < cfgTPCNSigmaPrMin) || (aod::pidtpc::tpcNSigmaPr > cfgTPCNSigmaPrMax); + + Service ccdb; + double bz{0.}; // magnetic field + int runNumber{0}; + + HistogramRegistry mHistManager{"tpcElIdHistograms"}; + + void init(InitContext const&) + { + LOG(info) << "Initializing ee mass spectrum via TPC electron identification analysis task ..."; + + std::vector momentum_binning = {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, ""}, + 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)"}, + axisMassSpectrum{4000, 0, 4, "M (GeV/c^{2})", "Mass e^{+}e^{-} (GeV/c^{2})"}, + axisTPC{1000, 0, 200, "TPC signal (dE/dx)"}, + axisPt{momentum_binning, "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("hTPCspectra_isElectronRej", "isElectron with rejection | TPC dE/dx spectra", HistType::kTH2F, {axisPt, axisTPC}); + + mHistManager.add("h_TPCee_MS_mp", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) vs pair pt", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_mm", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) vs pair pt", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_pp", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) vs pair pt", HistType::kTH2F, {axisMassSpectrum, axisPt}); + + mHistManager.add("h_TPCee_MS_mp_phosRange", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_mm_phosRange", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_pp_phosRange", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + + mHistManager.add("h_TPCee_MS_mp_phosRange_kTVXinPHOS", "Mass e^{#pm}e^{#mp} vs momentum e^{#pm}e^{#mp} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_mm_phosRange_kTVXinPHOS", "Mass e^{-}e^{-} vs momentum e^{-}e^{-} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + mHistManager.add("h_TPCee_MS_pp_phosRange_kTVXinPHOS", "Mass e^{+}e^{+} vs momentum e^{+}e^{+} (from TPC candidates) vs pair pt with one e in phos acceptance range", HistType::kTH2F, {axisMassSpectrum, axisPt}); + + 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("hTrackVX_Cut", "Track vertex coordinate X after cut", HistType::kTH1F, {axisVTrackX}); + mHistManager.add("hTrackVY_Cut", "Track vertex coordinate Y after cut", HistType::kTH1F, {axisVTrackY}); + mHistManager.add("hTrackVZ_Cut", "Track vertex coordinate Z after cut", HistType::kTH1F, {axisVTrackZ}); + + mHistManager.add("hTrackPt", "Track pt", HistType::kTH1F, {axisPtBig}); + mHistManager.add("hTrackPt_Cut", "Track pt after cut", HistType::kTH1F, {axisPtBig}); + 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, + soa::Filtered const& tracks, + aod::BCsWithTimestamps const&) + { + auto bc = collision.bc_as(); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + o2::parameters::GRPMagField* grpo = ccdb->getForTimeStamp("GLO/Config/GRPMagField", 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(); + } + mHistManager.fill(HIST("eventCounter"), 0.5); + if (fabs(collision.posZ()) > 10.f) + return; + + for (auto& [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; + + TLorentzVector P1, P2; + P1.SetPxPyPzE(track1.px(), track1.py(), track1.pz(), track1.energy(0)); + P2.SetPxPyPzE(track2.px(), track2.py(), track2.pz(), track2.energy(0)); + + bool inPhosEtaRange1 = fabs(track1.eta()) < 0.12; + bool inPhosEtaRange2 = 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() > 0 && bz > 0) || (track1.sign() < 0 && bz < 0); + + if (track1.sign() == track2.sign()) { + if (posTrack) { + mHistManager.fill(HIST("h_TPCee_MS_pp"), (P1 + P2).M(), (P1 + P2).Pt()); + if (inPhosRange) { + mHistManager.fill(HIST("h_TPCee_MS_pp_phosRange"), (P1 + P2).M(), (P1 + P2).Pt()); + if (collision.alias_bit(kTVXinPHOS)) + mHistManager.fill(HIST("h_TPCee_MS_pp_phosRange_kTVXinPHOS"), (P1 + P2).M(), (P1 + P2).Pt()); + } + } else { + mHistManager.fill(HIST("h_TPCee_MS_mm"), (P1 + P2).M(), (P1 + P2).Pt()); + if (inPhosRange) { + mHistManager.fill(HIST("h_TPCee_MS_mm_phosRange"), (P1 + P2).M(), (P1 + P2).Pt()); + if (collision.alias_bit(kTVXinPHOS)) + mHistManager.fill(HIST("h_TPCee_MS_mm_phosRange_kTVXinPHOS"), (P1 + P2).M(), (P1 + P2).Pt()); + } + } + } else { + mHistManager.fill(HIST("h_TPCee_MS_mp"), (P1 + P2).M(), (P1 + P2).Pt()); + if (inPhosRange) { + mHistManager.fill(HIST("h_TPCee_MS_mp_phosRange"), (P1 + P2).M(), (P1 + P2).Pt()); + if (collision.alias_bit(kTVXinPHOS)) + mHistManager.fill(HIST("h_TPCee_MS_mp_phosRange_kTVXinPHOS"), (P1 + P2).M(), (P1 + P2).Pt()); + } + } + } + + 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 (!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)) + continue; + if (track1.tpcNClsFound() < cfgTPCnclsMin || track1.tpcNClsFound() > cfgTPCnclsMax) + continue; + if (track1.tpcNClsCrossedRows() < cfgTPCnclsCRMin || track1.tpcNClsCrossedRows() > cfgTPCnclsCRMax) + continue; + + mHistManager.fill(HIST("hTPCspectra_isElectronRej"), track1.pt(), track1.tpcSignal()); + + 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()); + } + } +}; + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { auto workflow = WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; return workflow; } diff --git a/PWGHF/Core/CentralityEstimation.h b/PWGHF/Core/CentralityEstimation.h index 23fd5d6ebb7..ea9d1f257b6 100644 --- a/PWGHF/Core/CentralityEstimation.h +++ b/PWGHF/Core/CentralityEstimation.h @@ -28,6 +28,91 @@ enum CentralityEstimator { NTracksPV, NCentralityEstimators }; + +template +concept hasFT0ACent = requires(T collision) +{ + collision.centFT0A(); +}; + +template +concept hasFT0CCent = requires(T collision) +{ + collision.centFT0C(); +}; + +template +concept hasFT0MCent = requires(T collision) +{ + collision.centFT0M(); +}; + +template +concept hasFV0ACent = requires(T collision) +{ + collision.centFV0A(); +}; + +template +concept hasNTracksPVCent = requires(T collision) +{ + collision.centNTPV(); +}; + +/// Evaluate centrality/multiplicity percentile using FT0A estimator +/// \param candidate is candidate +/// \return centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll& collision) +{ + return collision.centFT0A(); +} + +/// Evaluate centrality/multiplicity percentile using FT0C estimator +/// \param candidate is candidate +/// \return centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll& collision) +{ + return collision.centFT0C(); +} + +/// Evaluate centrality/multiplicity percentile using FT0M estimator +/// \param candidate is candidate +/// \return centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll& collision) +{ + return collision.centFT0M(); +} + +/// Evaluate centrality/multiplicity percentile using FV0A estimator +/// \param candidate is candidate +/// \return centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll& collision) +{ + return collision.centFV0A(); +} + +/// Evaluate centrality/multiplicity percentile using NTracksPV estimator +/// \param candidate is candidate +/// \return centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll& collision) +{ + return collision.centNTPV(); +} + +/// Default case if no centrality/multiplicity estimator is provided +/// \param candidate is candidate +/// \return dummy value for centrality/multiplicity percentile of the collision +template +float getCentralityColl(const Coll&) +{ + return 105.0f; +} + } // namespace o2::hf_centrality #endif // PWGHF_CORE_CENTRALITYESTIMATION_H_ diff --git a/PWGHF/Core/HfHelper.h b/PWGHF/Core/HfHelper.h index 018f5ea52f3..b610c194fe9 100644 --- a/PWGHF/Core/HfHelper.h +++ b/PWGHF/Core/HfHelper.h @@ -370,6 +370,30 @@ class HfHelper return RecoDecay::m(std::array{candidate.pVectorProng1(), candidate.pVectorProng0()}, std::array{o2::constants::physics::MassKPlus, o2::constants::physics::MassPiPlus}); } + template + auto invMassPKPairLcToPKPi(const T& candidate) + { + return RecoDecay::m(std::array{candidate.pVectorProng0(), candidate.pVectorProng1()}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassKPlus}); + } + + template + auto invMassPKPairLcToPiKP(const T& candidate) + { + return RecoDecay::m(std::array{candidate.pVectorProng2(), candidate.pVectorProng1()}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassKPlus}); + } + + template + auto invMassPPiPairLcToPKPi(const T& candidate) + { + return RecoDecay::m(std::array{candidate.pVectorProng0(), candidate.pVectorProng2()}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPiPlus}); + } + + template + auto invMassPPiPairLcToPiKP(const T& candidate) + { + return RecoDecay::m(std::array{candidate.pVectorProng2(), candidate.pVectorProng0()}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPiPlus}); + } + // Ξc± → p± K∓ π± template diff --git a/PWGHF/Core/HfMlResponseB0ToDPi.h b/PWGHF/Core/HfMlResponseB0ToDPi.h index 08853a21eac..18584ae5258 100644 --- a/PWGHF/Core/HfMlResponseB0ToDPi.h +++ b/PWGHF/Core/HfMlResponseB0ToDPi.h @@ -21,6 +21,7 @@ #include #include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" // Fill the map of available input features // the key is the feature's name (std::string) @@ -58,31 +59,6 @@ break; \ } -namespace o2::pid_tpc_tof_utils -{ -template -float getTpcTofNSigmaPi1(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.tpcNSigmaPi(); - float tofNSigma = prong1.tofNSigmaPi(); - return sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma); - } - if (hasTpc) { - return abs(prong1.tpcNSigmaPi()); - } - if (hasTof) { - return abs(prong1.tofNSigmaPi()); - } - return defaultNSigma; -} -} // namespace o2::pid_tpc_tof_utils - namespace o2::analysis { diff --git a/PWGHF/Core/HfMlResponseBplusToD0Pi.h b/PWGHF/Core/HfMlResponseBplusToD0Pi.h index 8d47d4ade89..8a3b3875dae 100644 --- a/PWGHF/Core/HfMlResponseBplusToD0Pi.h +++ b/PWGHF/Core/HfMlResponseBplusToD0Pi.h @@ -21,6 +21,7 @@ #include #include "PWGHF/Core/HfMlResponse.h" +#include "PWGHF/D2H/Utils/utilsRedDataFormat.h" // Fill the map of available input features // the key is the feature's name (std::string) @@ -58,31 +59,6 @@ break; \ } -namespace o2::pid_tpc_tof_utils -{ -template -float getTpcTofNSigmaPi1(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.tpcNSigmaPi(); - float tofNSigma = prong1.tofNSigmaPi(); - return sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma); - } - if (hasTpc) { - return abs(prong1.tpcNSigmaPi()); - } - if (hasTof) { - return abs(prong1.tofNSigmaPi()); - } - return defaultNSigma; -} -} // namespace o2::pid_tpc_tof_utils - namespace o2::analysis { diff --git a/PWGHF/Core/HfMlResponseBsToDsPi.h b/PWGHF/Core/HfMlResponseBsToDsPi.h new file mode 100644 index 00000000000..821463e0ec8 --- /dev/null +++ b/PWGHF/Core/HfMlResponseBsToDsPi.h @@ -0,0 +1,191 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 HfMlResponsBsToDsPi.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" + +// 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(InputFeaturesBsToDsPi::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(InputFeaturesBsToDsPi::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(InputFeaturesBsToDsPi::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(InputFeaturesBsToDsPi::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesBsToDsPi : uint8_t { + ptProng0 = 0, + ptProng1, + impactParameter0, + impactParameter1, + impactParameterProduct, + chi2PCA, + decayLength, + decayLengthXY, + decayLengthNormalised, + decayLengthXYNormalised, + cpa, + cpaXY, + maxNormalisedDeltaIP, + prong0MlScoreBkg, + prong0MlScorePrompt, + prong0MlScoreNonprompt, + tpcNSigmaPi1, + tofNSigmaPi1, + tpcTofNSigmaPi1 +}; + +template +class HfMlResponseBsToDsPi : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseBsToDsPi() = default; + /// Default destructor + virtual ~HfMlResponseBsToDsPi() = 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) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + if constexpr (withDmesMl) { + 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(impactParameterProduct); + 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(prong0MlScoreBkg); + CHECK_AND_FILL_VEC_BS(prong0MlScorePrompt); + CHECK_AND_FILL_VEC_BS(prong0MlScoreNonprompt); + // Pion PID variables + CHECK_AND_FILL_VEC_BS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + CHECK_AND_FILL_VEC_BS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + CHECK_AND_FILL_VEC_BS_FUNC(prong1, tpcTofNSigmaPi1, o2::pid_tpc_tof_utils::getTpcTofNSigmaPi1); + } + } else { + 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(impactParameterProduct); + 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); + // Pion PID variables + CHECK_AND_FILL_VEC_BS_FULL(prong1, tpcNSigmaPi1, tpcNSigmaPi); + CHECK_AND_FILL_VEC_BS_FULL(prong1, tofNSigmaPi1, tofNSigmaPi); + CHECK_AND_FILL_VEC_BS_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_BS(ptProng0), + FILL_MAP_BS(ptProng1), + FILL_MAP_BS(impactParameter0), + FILL_MAP_BS(impactParameter1), + FILL_MAP_BS(impactParameterProduct), + 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(prong0MlScoreBkg), + FILL_MAP_BS(prong0MlScorePrompt), + FILL_MAP_BS(prong0MlScoreNonprompt), + // Pion PID variables + FILL_MAP_BS(tpcNSigmaPi1), + FILL_MAP_BS(tofNSigmaPi1), + FILL_MAP_BS(tpcTofNSigmaPi1)}; + } +}; + +} // 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_HFMLRESPONSEBSTODSPI_H_ diff --git a/PWGHF/Core/HfMlResponseD0ToKPi.h b/PWGHF/Core/HfMlResponseD0ToKPi.h index 91790751503..71ed542b269 100644 --- a/PWGHF/Core/HfMlResponseD0ToKPi.h +++ b/PWGHF/Core/HfMlResponseD0ToKPi.h @@ -29,9 +29,9 @@ // 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_D0(FEATURE) \ - { \ -#FEATURE, static_cast < uint8_t>(InputFeaturesD0ToKPi::FEATURE) \ +#define FILL_MAP_D0(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesD0ToKPi::FEATURE) \ } // Check if the index of mCachedIndices (index associated to a FEATURE) @@ -73,6 +73,32 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_D0_HFHELPER(OBJECT, FEATURE, GETTER) +// where GETTER1 and GETTER2 are methods of hfHelper, and the variable +// is filled depending on whether it is a D0 or a D0bar +#define CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + if (pdgCode == o2::constants::physics::kD0) { \ + inputFeatures.emplace_back(OBJECT1.GETTER()); \ + } else { \ + inputFeatures.emplace_back(OBJECT2.GETTER()); \ + } \ + break; \ + } + +// Variation of CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) +// where GETTER1 and GETTER2 are methods of the OBJECT, and the variable +// is filled depending on whether it is a D0 or a D0bar +#define CHECK_AND_FILL_VEC_D0_SIGNED(OBJECT, FEATURE, GETTER1, GETTER2) \ + case static_cast(InputFeaturesD0ToKPi::FEATURE): { \ + if (pdgCode == o2::constants::physics::kD0) { \ + inputFeatures.emplace_back(OBJECT.GETTER1()); \ + } else { \ + inputFeatures.emplace_back(OBJECT.GETTER2()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesD0ToKPi : uint8_t { @@ -100,6 +126,18 @@ enum class InputFeaturesD0ToKPi : uint8_t { nSigTofKa1, nSigTpcTofPi1, nSigTpcTofKa1, + nSigTpcPiExpPi, + nSigTpcKaExpPi, + nSigTpcPiExpKa, + nSigTpcKaExpKa, + nSigTofPiExpPi, + nSigTofKaExpPi, + nSigTofPiExpKa, + nSigTofKaExpKa, + nSigTpcTofPiExpPi, + nSigTpcTofKaExpPi, + nSigTpcTofPiExpKa, + nSigTpcTofKaExpKa, maxNormalisedDeltaIP, impactParameterProduct, cosThetaStar, @@ -121,12 +159,9 @@ class HfMlResponseD0ToKPi : public HfMlResponse /// Method to get the input features vector needed for ML inference /// \param candidate is the D0 candidate - /// \param prong0 is the candidate's prong0 - /// \param prong1 is the candidate's prong1 /// \return inputFeatures vector - template - std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, int const& pdgCode) + template + std::vector getInputFeatures(T1 const& candidate, int const& pdgCode) { std::vector inputFeatures; @@ -144,20 +179,44 @@ class HfMlResponseD0ToKPi : public HfMlResponse CHECK_AND_FILL_VEC_D0(impactParameterZ0); CHECK_AND_FILL_VEC_D0(impactParameterZ1); // TPC PID variables - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcPi0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcKa0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcPi1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcKa1, tpcNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcPi0, /*getter*/ nSigTpcPi0); + 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); + CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTpcKaExpKa, nSigTpcKa1, nSigTpcKa0); // TOF PID variables - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTofPi0, tofNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTofKa0, tofNSigmaKa); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofPi1, tofNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTofKa1, tofNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTofPi0, /*getter*/ nSigTofPi0); + 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); + CHECK_AND_FILL_VEC_D0_SIGNED(candidate, nSigTofKaExpKa, nSigTofKa1, nSigTofKa0); // Combined PID variables - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcTofPi0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong0, nSigTpcTofKa0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcTofPi1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_D0_FULL(prong1, nSigTpcTofKa1, tpcTofNSigmaKa); + CHECK_AND_FILL_VEC_D0_FULL(candidate, nSigTpcTofPi0, tpcTofNSigmaPi0); + 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(maxNormalisedDeltaIP); CHECK_AND_FILL_VEC_D0_FULL(candidate, impactParameterProduct, impactParameterProduct); @@ -192,16 +251,28 @@ class HfMlResponseD0ToKPi : public HfMlResponse FILL_MAP_D0(nSigTpcKa0), FILL_MAP_D0(nSigTpcPi1), FILL_MAP_D0(nSigTpcKa1), + FILL_MAP_D0(nSigTpcPiExpPi), + FILL_MAP_D0(nSigTpcKaExpPi), + FILL_MAP_D0(nSigTpcPiExpKa), + FILL_MAP_D0(nSigTpcKaExpKa), // TOF PID variables FILL_MAP_D0(nSigTofPi0), FILL_MAP_D0(nSigTofKa0), FILL_MAP_D0(nSigTofPi1), FILL_MAP_D0(nSigTofKa1), + FILL_MAP_D0(nSigTofPiExpPi), + FILL_MAP_D0(nSigTofKaExpPi), + FILL_MAP_D0(nSigTofPiExpKa), + FILL_MAP_D0(nSigTofKaExpKa), // Combined PID variables FILL_MAP_D0(nSigTpcTofPi0), FILL_MAP_D0(nSigTpcTofKa0), FILL_MAP_D0(nSigTpcTofPi1), FILL_MAP_D0(nSigTpcTofKa1), + FILL_MAP_D0(nSigTpcTofPiExpPi), + FILL_MAP_D0(nSigTpcTofKaExpPi), + FILL_MAP_D0(nSigTpcTofPiExpKa), + FILL_MAP_D0(nSigTpcTofKaExpKa), FILL_MAP_D0(maxNormalisedDeltaIP), FILL_MAP_D0(impactParameterProduct), @@ -219,5 +290,6 @@ class HfMlResponseD0ToKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_D0 #undef CHECK_AND_FILL_VEC_D0_HFHELPER #undef CHECK_AND_FILL_VEC_D0_HFHELPER_SIGNED +#undef CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED #endif // PWGHF_CORE_HFMLRESPONSED0TOKPI_H_ diff --git a/PWGHF/Core/HfMlResponseDsToKKPi.h b/PWGHF/Core/HfMlResponseDsToKKPi.h index 62e93882ddf..1b27d52adde 100644 --- a/PWGHF/Core/HfMlResponseDsToKKPi.h +++ b/PWGHF/Core/HfMlResponseDsToKKPi.h @@ -68,6 +68,19 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_DS_HFHELPER(OBJECT, FEATURE, GETTER) +// where OBJECT1 and OBJECT2 are the objects from which we call the GETTER method, and the variable +// is filled depending on whether it is a DsToKKPi or a DsToPiKK +#define CHECK_AND_FILL_VEC_DS_OBJECT_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) \ + case static_cast(InputFeaturesDsToKKPi::FEATURE): { \ + if (caseDsToKKPi) { \ + inputFeatures.emplace_back(OBJECT1.GETTER()); \ + } else { \ + inputFeatures.emplace_back(OBJECT2.GETTER()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesDsToKKPi : uint8_t { @@ -95,12 +108,24 @@ enum class InputFeaturesDsToKKPi : uint8_t { nSigTpcKa0, nSigTpcKa1, nSigTpcKa2, + nSigTofPi0, + nSigTofPi1, + nSigTofPi2, + nSigTofKa0, + nSigTofKa1, + nSigTofKa2, nSigTpcTofPi0, nSigTpcTofPi1, nSigTpcTofPi2, nSigTpcTofKa0, nSigTpcTofKa1, nSigTpcTofKa2, + nSigTpcKaExpKa0, + nSigTpcPiExpPi2, + nSigTofKaExpKa0, + nSigTofPiExpPi2, + nSigTpcTofKaExpKa0, + nSigTpcTofPiExpPi2, absCos3PiK, deltaMassPhi }; @@ -156,6 +181,17 @@ class HfMlResponseDsToKKPi : public HfMlResponse 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); + // Combined PID variables CHECK_AND_FILL_VEC_DS_FULL(prong0, nSigTpcTofPi0, tpcTofNSigmaPi); CHECK_AND_FILL_VEC_DS_FULL(prong1, nSigTpcTofPi1, tpcTofNSigmaPi); @@ -163,6 +199,8 @@ class HfMlResponseDsToKKPi : public HfMlResponse 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); // Ds specific variables CHECK_AND_FILL_VEC_DS_HFHELPER_SIGNED(candidate, absCos3PiK, absCos3PiKDsToKKPi, absCos3PiKDsToPiKK); @@ -193,6 +231,9 @@ class HfMlResponseDsToKKPi : public HfMlResponse FILL_MAP_DS(impactParameterXY0), FILL_MAP_DS(impactParameterXY1), FILL_MAP_DS(impactParameterXY2), + FILL_MAP_DS(impactParameterZ0), + FILL_MAP_DS(impactParameterZ1), + FILL_MAP_DS(impactParameterZ2), // TPC PID variables FILL_MAP_DS(nSigTpcPi0), FILL_MAP_DS(nSigTpcPi1), @@ -200,6 +241,16 @@ class HfMlResponseDsToKKPi : public HfMlResponse FILL_MAP_DS(nSigTpcKa0), FILL_MAP_DS(nSigTpcKa1), FILL_MAP_DS(nSigTpcKa2), + FILL_MAP_DS(nSigTofPi0), + FILL_MAP_DS(nSigTofPi1), + FILL_MAP_DS(nSigTofPi2), + FILL_MAP_DS(nSigTofKa0), + FILL_MAP_DS(nSigTofKa1), + FILL_MAP_DS(nSigTofKa2), + FILL_MAP_DS(nSigTpcKaExpKa0), + FILL_MAP_DS(nSigTpcPiExpPi2), + FILL_MAP_DS(nSigTofKaExpKa0), + FILL_MAP_DS(nSigTofPiExpPi2), // Combined PID variables FILL_MAP_DS(nSigTpcTofPi0), FILL_MAP_DS(nSigTpcTofPi1), @@ -207,6 +258,8 @@ class HfMlResponseDsToKKPi : public HfMlResponse FILL_MAP_DS(nSigTpcTofKa0), FILL_MAP_DS(nSigTpcTofKa1), FILL_MAP_DS(nSigTpcTofKa2), + FILL_MAP_DS(nSigTpcTofKaExpKa0), + FILL_MAP_DS(nSigTpcTofPiExpPi2), // Ds specific variables FILL_MAP_DS(absCos3PiK), @@ -221,5 +274,6 @@ class HfMlResponseDsToKKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_DS #undef CHECK_AND_FILL_VEC_DS_HFHELPER #undef CHECK_AND_FILL_VEC_DS_HFHELPER_SIGNED +#undef CHECK_AND_FILL_VEC_D0_OBJECT_HFHELPER_SIGNED #endif // PWGHF_CORE_HFMLRESPONSEDSTOKKPI_H_ diff --git a/PWGHF/Core/HfMlResponseDstarToD0Pi.h b/PWGHF/Core/HfMlResponseDstarToD0Pi.h index b583d93ed88..66fc3a712d4 100644 --- a/PWGHF/Core/HfMlResponseDstarToD0Pi.h +++ b/PWGHF/Core/HfMlResponseDstarToD0Pi.h @@ -61,6 +61,18 @@ break; \ } +// Very specific case of CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(OBJECT, FEATURE, GETTER) +// Use for push back different value for D*+ or D*- candidate getting the correct feature from two different objects (tracks) +#define CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE_FROMOBJECT(OBJECTPOS, OBJECTNEG, FEATURENAME, GETTER) \ + case static_cast(InputFeaturesDstarToD0Pi::FEATURENAME): { \ + if (candidate.signSoftPi() > 0) { \ + inputFeatures.emplace_back(OBJECTPOS.GETTER()); \ + } else { \ + inputFeatures.emplace_back(OBJECTNEG.GETTER()); \ + } \ + break; \ + } + // Very specific case of CHECK_AND_FILL_VEC_DSTAR_FULL(OBJECT, FEATURE, GETTER) // Use for push back deltaMassD0 for D*+ or D*- candidate #define CHECK_AND_FILL_VEC_DSTAR_DELTA_MASS_D0(FEATURENAME) \ @@ -156,36 +168,36 @@ class HfMlResponseDstarToD0Pi : public HfMlResponse CHECK_AND_FILL_VEC_DSTAR(cpaXYD0); CHECK_AND_FILL_VEC_DSTAR(deltaIPNormalisedMaxD0); CHECK_AND_FILL_VEC_DSTAR(impactParameterProductD0); - CHECK_AND_FILL_VEC_DSTAR(ptProng0); - CHECK_AND_FILL_VEC_DSTAR(ptProng1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(ptProng0, ptProng1, ptProng0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(ptProng1, ptProng0, ptProng1); CHECK_AND_FILL_VEC_DSTAR(ptSoftPi); - CHECK_AND_FILL_VEC_DSTAR(impactParameter0); - CHECK_AND_FILL_VEC_DSTAR(impactParameter1); - CHECK_AND_FILL_VEC_DSTAR(impactParameterZ0); - CHECK_AND_FILL_VEC_DSTAR(impactParameterZ1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameter0, impactParameter1, impactParameter0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameter1, impactParameter0, impactParameter1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterZ0, impactParameterZ1, impactParameterZ0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterZ1, impactParameterZ0, impactParameterZ1); CHECK_AND_FILL_VEC_DSTAR(impParamSoftPi); CHECK_AND_FILL_VEC_DSTAR(impParamZSoftPi); - CHECK_AND_FILL_VEC_DSTAR(impactParameterNormalised0); - CHECK_AND_FILL_VEC_DSTAR(impactParameterNormalised1); - CHECK_AND_FILL_VEC_DSTAR(impactParameterZNormalised0); - CHECK_AND_FILL_VEC_DSTAR(impactParameterZNormalised1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterNormalised0, impactParameterNormalised1, impactParameterNormalised0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterNormalised1, impactParameterNormalised0, impactParameterNormalised1); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterZNormalised0, impactParameterZNormalised1, impactParameterZNormalised0); + CHECK_AND_FILL_VEC_DSTAR_CHARGEBASE(impactParameterZNormalised1, impactParameterZNormalised0, impactParameterZNormalised1); CHECK_AND_FILL_VEC_DSTAR(normalisedImpParamSoftPi); CHECK_AND_FILL_VEC_DSTAR(normalisedImpParamZSoftPi); 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_FULL(prong0, nSigmaTPCPiPr0, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong0, nSigmaTPCKaPr0, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong0, nSigmaTOFPiPr0, tofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong0, nSigmaTOFKaPr0, tofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong0, nSigmaTPCTOFPiPr0, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong0, nSigmaTPCTOFKaPr0, tpcTofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTPCPiPr1, tpcNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTPCKaPr1, tpcNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTOFPiPr1, tofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTOFKaPr1, tofNSigmaKa); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTPCTOFPiPr1, tpcTofNSigmaPi); - CHECK_AND_FILL_VEC_DSTAR_FULL(prong1, nSigmaTPCTOFKaPr1, tpcTofNSigmaKa); + 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); diff --git a/PWGHF/Core/HfMlResponseLcToPKPi.h b/PWGHF/Core/HfMlResponseLcToPKPi.h index e011567c4d6..ea4767b85c6 100644 --- a/PWGHF/Core/HfMlResponseLcToPKPi.h +++ b/PWGHF/Core/HfMlResponseLcToPKPi.h @@ -54,6 +54,19 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) +// where OBJECT1 and OBJECT2 are the objects from which we call the GETTER method, and the variable +// is filled depending on whether it is a LcToPKPi or a LcToPiKP +#define CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) \ + case static_cast(InputFeaturesLcToPKPi::FEATURE): { \ + if (caseLcToPKPi) { \ + inputFeatures.emplace_back(OBJECT1.GETTER()); \ + } else { \ + inputFeatures.emplace_back(OBJECT2.GETTER()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesLcToPKPi : uint8_t { @@ -98,7 +111,13 @@ enum class InputFeaturesLcToPKPi : uint8_t { tpcTofNSigmaKa2, tpcTofNSigmaPr0, tpcTofNSigmaPr1, - tpcTofNSigmaPr2 + tpcTofNSigmaPr2, + tpcNSigmaPrExpPr0, + tpcNSigmaPiExpPi2, + tofNSigmaPrExpPr0, + tofNSigmaPiExpPi2, + tpcTofNSigmaPrExpPr0, + tpcTofNSigmaPiExpPi2 }; template @@ -118,7 +137,7 @@ class HfMlResponseLcToPKPi : public HfMlResponse /// \return inputFeatures vector template std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2) + T2 const& prong0, T2 const& prong1, T2 const& prong2, bool const& caseLcToPKPi) { std::vector inputFeatures; @@ -149,6 +168,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse 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); // TOF PID variables CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tofNSigmaP0, tofNSigmaPr); CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tofNSigmaKa0, tofNSigmaKa); @@ -159,6 +180,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse 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); // Combined PID variables CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong0, tpcTofNSigmaPi0, tpcTofNSigmaPi); CHECK_AND_FILL_VEC_LCTOPKPI_FULL(prong1, tpcTofNSigmaPi1, tpcTofNSigmaPi); @@ -169,6 +192,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse 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); } } @@ -205,6 +230,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse FILL_MAP_LCTOPKPI(tpcNSigmaP2), 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(tofNSigmaKa0), @@ -215,6 +242,8 @@ class HfMlResponseLcToPKPi : public HfMlResponse FILL_MAP_LCTOPKPI(tofNSigmaP2), FILL_MAP_LCTOPKPI(tofNSigmaKa2), FILL_MAP_LCTOPKPI(tofNSigmaPi2), + FILL_MAP_LCTOPKPI(tofNSigmaPrExpPr0), + FILL_MAP_LCTOPKPI(tofNSigmaPiExpPi2), // Combined PID variables FILL_MAP_LCTOPKPI(tpcTofNSigmaPi0), FILL_MAP_LCTOPKPI(tpcTofNSigmaPi1), @@ -224,7 +253,9 @@ class HfMlResponseLcToPKPi : public HfMlResponse FILL_MAP_LCTOPKPI(tpcTofNSigmaKa2), FILL_MAP_LCTOPKPI(tpcTofNSigmaPr0), FILL_MAP_LCTOPKPI(tpcTofNSigmaPr1), - FILL_MAP_LCTOPKPI(tpcTofNSigmaPr2)}; + FILL_MAP_LCTOPKPI(tpcTofNSigmaPr2), + FILL_MAP_LCTOPKPI(tpcTofNSigmaPrExpPr0), + FILL_MAP_LCTOPKPI(tpcTofNSigmaPiExpPi2)}; } }; @@ -234,5 +265,6 @@ class HfMlResponseLcToPKPi : public HfMlResponse #undef CHECK_AND_FILL_VEC_LCTOPKPI_FULL #undef CHECK_AND_FILL_VEC_LCTOPKPI #undef CHECK_AND_FILL_VEC_LCTOPKPI_HFHELPER +#undef CHECK_AND_FILL_VEC_LCTOPKPI_OBJECT_SIGNED #endif // PWGHF_CORE_HFMLRESPONSELCTOPKPI_H_ diff --git a/PWGHF/Core/HfMlResponseXicToPKPi.h b/PWGHF/Core/HfMlResponseXicToPKPi.h index 398357a66d6..94542745772 100644 --- a/PWGHF/Core/HfMlResponseXicToPKPi.h +++ b/PWGHF/Core/HfMlResponseXicToPKPi.h @@ -48,6 +48,19 @@ break; \ } +// Variation of CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) +// where OBJECT1 and OBJECT2 are the objects from which we call the GETTER method, and the variable +// is filled depending on whether it is a XicToPKPi or a XicToPiKP +#define CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED(OBJECT1, OBJECT2, FEATURE, GETTER) \ + case static_cast(InputFeaturesXicToPKPi::FEATURE): { \ + if (caseXicToPKPi) { \ + inputFeatures.emplace_back(OBJECT1.GETTER()); \ + } else { \ + inputFeatures.emplace_back(OBJECT2.GETTER()); \ + } \ + break; \ + } + namespace o2::analysis { enum class InputFeaturesXicToPKPi : uint8_t { @@ -92,8 +105,13 @@ enum class InputFeaturesXicToPKPi : uint8_t { tpcTofNSigmaKa2, tpcTofNSigmaPr0, tpcTofNSigmaPr1, - tpcTofNSigmaPr2 - + tpcTofNSigmaPr2, + tpcNSigmaPrExpPr0, + tpcNSigmaPiExpPi2, + tofNSigmaPrExpPr0, + tofNSigmaPiExpPi2, + tpcTofNSigmaPrExpPr0, + tpcTofNSigmaPiExpPi2 }; template @@ -113,7 +131,7 @@ class HfMlResponseXicToPKPi : public HfMlResponse /// \return inputFeatures vector template std::vector getInputFeatures(T1 const& candidate, - T2 const& prong0, T2 const& prong1, T2 const& prong2) + T2 const& prong0, T2 const& prong1, T2 const& prong2, bool const& caseXicToPKPi) { std::vector inputFeatures; @@ -144,6 +162,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse 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); // TOF PID variables CHECK_AND_FILL_VEC_XIC_FULL(prong0, tofNSigmaP0, tofNSigmaPr); CHECK_AND_FILL_VEC_XIC_FULL(prong0, tofNSigmaKa0, tofNSigmaKa); @@ -154,6 +174,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse 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); // Combined PID variables CHECK_AND_FILL_VEC_XIC_FULL(prong0, tpcTofNSigmaPi0, tpcTofNSigmaPi); CHECK_AND_FILL_VEC_XIC_FULL(prong1, tpcTofNSigmaPi1, tpcTofNSigmaPi); @@ -164,6 +186,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse 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); } } @@ -200,6 +224,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse FILL_MAP_XIC(tpcNSigmaP2), 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(tofNSigmaKa0), @@ -210,6 +236,8 @@ class HfMlResponseXicToPKPi : public HfMlResponse FILL_MAP_XIC(tofNSigmaP2), FILL_MAP_XIC(tofNSigmaKa2), FILL_MAP_XIC(tofNSigmaPi2), + FILL_MAP_XIC(tofNSigmaPrExpPr0), + FILL_MAP_XIC(tofNSigmaPiExpPi2), // Combined PID variables FILL_MAP_XIC(tpcTofNSigmaPi0), FILL_MAP_XIC(tpcTofNSigmaPi1), @@ -219,7 +247,9 @@ class HfMlResponseXicToPKPi : public HfMlResponse FILL_MAP_XIC(tpcTofNSigmaKa2), FILL_MAP_XIC(tpcTofNSigmaPr0), FILL_MAP_XIC(tpcTofNSigmaPr1), - FILL_MAP_XIC(tpcTofNSigmaPr2)}; + FILL_MAP_XIC(tpcTofNSigmaPr2), + FILL_MAP_XIC(tpcTofNSigmaPrExpPr0), + FILL_MAP_XIC(tpcTofNSigmaPiExpPi2)}; } }; @@ -228,5 +258,6 @@ class HfMlResponseXicToPKPi : public HfMlResponse #undef FILL_MAP_XIC #undef CHECK_AND_FILL_VEC_XIC_FULL #undef CHECK_AND_FILL_VEC_XIC +#undef CHECK_AND_FILL_VEC_XIC_OBJECT_SIGNED #endif // PWGHF_CORE_HFMLRESPONSEXICTOPKPI_H_ diff --git a/PWGHF/Core/HfMlResponseXicToXiPiPi.h b/PWGHF/Core/HfMlResponseXicToXiPiPi.h new file mode 100644 index 00000000000..0a290e14d1d --- /dev/null +++ b/PWGHF/Core/HfMlResponseXicToXiPiPi.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 HfMlResponseXicToXiPiPi.h +/// \brief Class to compute the ML response for Ξc± → Ξ∓ π± π± analysis selections +/// \author Jaeyoon Cho , Inha University + +#ifndef PWGHF_CORE_HFMLRESPONSEXICTOXIPIPI_H_ +#define PWGHF_CORE_HFMLRESPONSEXICTOXIPIPI_H_ + +#include +#include +#include + +#include "PWGHF/Core/HfMlResponse.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 +#define FILL_MAP_XICTOXIPIPI(FEATURE) \ + { \ + #FEATURE, static_cast(InputFeaturesXicToXiPiPi::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_XICTOXIPIPI_FULL(OBJECT, FEATURE, GETTER) \ + case static_cast(InputFeaturesXicToXiPiPi::FEATURE): { \ + inputFeatures.emplace_back(OBJECT.GETTER()); \ + break; \ + } + +// Specific case of CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL(OBJECT, FEATURE, GETTER) +// where OBJECT is named candidate and FEATURE = GETTER +#define CHECK_AND_FILL_VEC_XICTOXIPIPI(GETTER) \ + case static_cast(InputFeaturesXicToXiPiPi::GETTER): { \ + inputFeatures.emplace_back(candidate.GETTER()); \ + break; \ + } + +namespace o2::analysis +{ + +enum class InputFeaturesXicToXiPiPi : uint8_t { + ptProng0 = 0, + ptProng1, + ptProng2, + chi2PCA, + decayLength, + decayLengthNormalised, + decayLengthXY, + decayLengthXYNormalised, + cpa, + cpaXY, + cosPaXi, + cosPaXYXi, + cosPaLambda, + cosPaXYLambda, + impactParameterXY0, + impactParameterXY1, + impactParameterXY2 +}; + +template +class HfMlResponseXicToXiPiPi : public HfMlResponse +{ + public: + /// Default constructor + HfMlResponseXicToXiPiPi() = default; + /// Default destructor + virtual ~HfMlResponseXicToXiPiPi() = default; + + /// Method to get the input features vector needed for ML inference + /// \param candidate is the Xic candidate + /// \return inputFeatures vector + template + std::vector getInputFeatures(T1 const& candidate) + { + std::vector inputFeatures; + + for (const auto& idx : MlResponse::mCachedIndices) { + switch (idx) { + CHECK_AND_FILL_VEC_XICTOXIPIPI(ptProng0); + CHECK_AND_FILL_VEC_XICTOXIPIPI(ptProng1); + CHECK_AND_FILL_VEC_XICTOXIPIPI(ptProng2); + CHECK_AND_FILL_VEC_XICTOXIPIPI(chi2PCA); + CHECK_AND_FILL_VEC_XICTOXIPIPI(decayLength); + CHECK_AND_FILL_VEC_XICTOXIPIPI(decayLengthNormalised); + CHECK_AND_FILL_VEC_XICTOXIPIPI(decayLengthXY); + 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); + } + } + + return inputFeatures; + } + + protected: + /// Method to fill the map of available input features + void setAvailableInputFeatures() + { + MlResponse::mAvailableInputFeatures = { + FILL_MAP_XICTOXIPIPI(ptProng0), + FILL_MAP_XICTOXIPIPI(ptProng1), + FILL_MAP_XICTOXIPIPI(ptProng2), + FILL_MAP_XICTOXIPIPI(chi2PCA), + FILL_MAP_XICTOXIPIPI(decayLength), + FILL_MAP_XICTOXIPIPI(decayLengthNormalised), + FILL_MAP_XICTOXIPIPI(decayLengthXY), + 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)}; + } +}; + +} // namespace o2::analysis + +#undef FILL_MAP_XICTOXIPIPI +#undef CHECK_AND_FILL_VEC_XICTOXIPIPI_FULL +#undef CHECK_AND_FILL_VEC_XICTOXIPIPI + +#endif // PWGHF_CORE_HFMLRESPONSEXICTOXIPIPI_H_ diff --git a/PWGHF/Core/SelectorCuts.h b/PWGHF/Core/SelectorCuts.h index 92f62d72cca..014547d927d 100644 --- a/PWGHF/Core/SelectorCuts.h +++ b/PWGHF/Core/SelectorCuts.h @@ -462,7 +462,7 @@ 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 = 8; +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] = { @@ -479,17 +479,17 @@ constexpr double binsPt[nBinsPt + 1] = { 36.}; auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; -// default values for the cuts -constexpr double cuts[nBinsPt][nCutVars] = {{0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 0 < pT < 1 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 1 < pT < 2 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 2 < pT < 3 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 3 < pT < 4 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 4 < pT < 5 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 5 < pT < 6 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 6 < pT < 8 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 8 < pT < 12 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}, /* 12 < pT < 24 */ - {0.400, 0.4, 0.4, 0.4, 0., 0.005, 0., -1.}}; /* 24 < pT < 36 */ +// 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 */ + {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 */ + {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 4 < pT < 5 */ + {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 5 < pT < 6 */ + {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 6 < pT < 8 */ + {0.4, 0.4, 0.4, 0.4, 0., 0.005, 0., 0., 0., 1e+10, -1.}, /* 8 < pT < 12 */ + {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 */ // row labels static const std::vector labelsPt = { @@ -505,7 +505,7 @@ static const std::vector labelsPt = { "pT bin 9"}; // column labels -static const std::vector labelsCutVar = {"m", "pT p", "pT K", "pT Pi", "Chi2PCA", "decay length", "cos pointing angle", "mass (Kpi)"}; +static const std::vector labelsCutVar = {"m", "pT p", "pT K", "pT Pi", "Chi2PCA", "decay length", "cos pointing angle", "decLengthXY", "normDecLXY", "impParXY", "mass (Kpi)"}; } // namespace hf_cuts_lc_to_p_k_pi namespace hf_cuts_lc_to_k0s_p @@ -903,25 +903,50 @@ static const std::vector labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 namespace hf_cuts_bs_to_ds_pi { -static constexpr int nBinsPt = 2; +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] = { 0, 1.0, - 2.0}; + 2.0, + 3.0, + 4.0, + 5.0, + 8.0, + 10.0, + 12.0, + 16.0, + 24.0}; 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 */ - {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.}, /* 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 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 4 < pt < 5 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 5 < pt < 6 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 8 < pt < 10 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 10 < pt < 12 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}, /* 12 < pt < 16 */ + {1., 0.8, 1., 0.01, 0.01, 1.0, 0.15, 0.05, 0.05, 0.}}; /* 16 < pt < 24 */ + // row labels static const std::vector labelsPt = { "pT bin 0", - "pT bin 1"}; + "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 labelsCutVar = {"m", "CPA", "Chi2PCA", "d0 Ds", "d0 Pi", "pT Ds", "pT Pi", "Bs decLen", "Bs decLenXY", "Imp. Par. Product"}; diff --git a/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h b/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h new file mode 100644 index 00000000000..daa642f1601 --- /dev/null +++ b/PWGHF/D2H/Core/SelectorCutsRedDataFormat.h @@ -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 SelectorCutsRedDataFormat.h +/// \brief Default pT bins and cut arrays for heavy-flavour selectors and analysis tasks +/// +/// \author Luca Aglietta , Università degli Studi di Torino + +// namespace with D selections for reduced charmed-resonances analysis + +#ifndef PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_ +#define PWGHF_D2H_CORE_SELECTORCUTSREDDATAFORMAT_H_ + +#include // std::string +#include // std::vector + +namespace o2::analysis +{ +namespace hf_cuts_d_daughter +{ +static constexpr int nBinsPt = 7; +static constexpr int nCutVars = 6; +constexpr double binsPt[nBinsPt + 1] = { + 1., + 2., + 4., + 6., + 8., + 12., + 24., + 1000.}; +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 */ + {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 */ + {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 8 < pt < 12 */ + {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}, /* 12 < pt < 24 */ + {1.84, 1.89, 1.77, 1.81, 1.92, 1.96}}; /* 24 < pt < 1000 */ +// 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"}; +// column labels +static const std::vector labelsCutVar = {"invMassSignalLow", "invMassSignalHigh", "invMassLeftSBLow", "invMassLeftSBHigh", "invMassRightSBLow", "invMassRightSBHigh"}; +} // namespace hf_cuts_d_daughter + +// 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] = { + 0., + 1., + 2., + 4., + 8., + 12., + 24., + 1000.}; +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 */ + {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 */ + {0.48, 0.52, 0.99, 1., 0.9}, /* 8 < pt < 12 */ + {0.48, 0.52, 0.99, 1., 0.9}, /* 12 < pt < 24 */ + {0.48, 0.52, 0.99, 1., 0.9}}; /* 24 < pt < 1000 */ +// row labels +static const std::vector labelsPt{}; +// column labels +static const std::vector labelsCutVar = {"invMassLow", "invMassHigh", "cpaMin", "dcaMax", "radiusMin"}; +} // namespace hf_cuts_v0_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 391043904d5..d8c06e0d26f 100644 --- a/PWGHF/D2H/DataModel/ReducedDataModel.h +++ b/PWGHF/D2H/DataModel/ReducedDataModel.h @@ -16,6 +16,9 @@ /// /// \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) #ifndef PWGHF_D2H_DATAMODEL_REDUCEDDATAMODEL_H_ #define PWGHF_D2H_DATAMODEL_REDUCEDDATAMODEL_H_ @@ -29,6 +32,7 @@ #include "Common/DataModel/PIDResponse.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsPid.h" namespace o2 { @@ -37,6 +41,7 @@ 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 // 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(ZvtxSelectedCollisionCount, zvtxSelectedCollisionCount, int); //! Number of COLLISIONS with |zvtx| < zvtxMax @@ -51,6 +56,9 @@ DECLARE_SOA_TABLE(HfRedCollisions, "AOD", "HFREDCOLLISION", //! Table with colli collision::PosX, collision::PosY, collision::PosZ, + collision::NumContrib, + hf_reduced_collision::HfCollisionRejectionMap, + hf_reduced_collision::Bz, o2::soa::Marker<1>); DECLARE_SOA_TABLE(HfRedCollExtras, "AOD", "HFREDCOLLEXTRA", //! Table with collision extras for reduced workflow @@ -59,8 +67,7 @@ DECLARE_SOA_TABLE(HfRedCollExtras, "AOD", "HFREDCOLLEXTRA", //! Table with colli collision::CovYY, collision::CovXZ, collision::CovYZ, - collision::CovZZ, - hf_reduced_collision::Bz); + collision::CovZZ); using HfRedCollision = HfRedCollisions::iterator; @@ -126,10 +133,88 @@ DECLARE_SOA_COLUMN(TrackId, trackId, int); //! Original track ind DECLARE_SOA_COLUMN(Prong0Id, prong0Id, int); //! Original track index DECLARE_SOA_COLUMN(Prong1Id, prong1Id, int); //! Original track index DECLARE_SOA_COLUMN(Prong2Id, prong2Id, int); //! Original track index -DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); //! Flag to check if track has a TPC match -DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Flag to check if track has a TOF match } // namespace hf_track_index_reduced +namespace hf_track_vars_reduced +{ +// CAREFUL: the getters names shall be the same as the ones of the getTrackParCov method in Common/Core/trackUtilities.h +DECLARE_SOA_COLUMN(Px, px, float); //! x-component of momentum +DECLARE_SOA_COLUMN(Py, py, float); //! y-component of momentum +DECLARE_SOA_COLUMN(Pz, pz, float); //! z-component of momentum +DECLARE_SOA_COLUMN(Sign, sign, uint8_t); //! charge sign +DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); //! Flag to check if track has a TPC match +DECLARE_SOA_COLUMN(HasTOF, hasTOF, bool); //! Flag to check if track has a TOF match +DECLARE_SOA_COLUMN(HasTPCProng0, hasTPCProng0, bool); //! Flag to check if prong0 has a TPC match +DECLARE_SOA_COLUMN(HasTOFProng0, hasTOFProng0, bool); //! Flag to check if prong0 has a TOF match +DECLARE_SOA_COLUMN(HasTPCProng1, hasTPCProng1, bool); //! Flag to check if prong1 has a TPC match +DECLARE_SOA_COLUMN(HasTOFProng1, hasTOFProng1, bool); //! Flag to check if prong1 has a TOF match +DECLARE_SOA_COLUMN(HasTPCProng2, hasTPCProng2, bool); //! Flag to check if prong2 has a TPC match +DECLARE_SOA_COLUMN(HasTOFProng2, hasTOFProng2, bool); //! Flag to check if prong2 has a TOF match +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(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 +DECLARE_SOA_COLUMN(PtProngMin, ptProngMin, float); //! minimum value of transverse momentum for the decay daughter tracks +DECLARE_SOA_COLUMN(AbsEtaProngMin, absEtaProngMin, float); //! minimum value of absolute pseudorapidity for the decay daughter tracks + +// dynamic columns +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! transverse momentum + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! azimuthal angle + [](float px, float py) -> float { return RecoDecay::phi(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! pseudorapidity + [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); +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(PtProng2, ptProng2, //! + [](float pxProng2, float pyProng2) -> float { return RecoDecay::pt(pxProng2, pyProng2); }); +DECLARE_SOA_DYNAMIC_COLUMN(EtaProng0, etaProng0, //! + [](float pxProng0, float pyProng0, float pzProng0) -> float { return RecoDecay::eta(std::array{pxProng0, pyProng0, pzProng0}); }); +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}); }); +} // namespace hf_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 +// dynamic columns +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPi, tpcTofNSigmaPi, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKa, tpcTofNSigmaKa, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPr, tpcTofNSigmaPr, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng0, tpcTofNSigmaPiProng0, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng1, tpcTofNSigmaPiProng1, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaPiProng2, tpcTofNSigmaPiProng2, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaPi, float tofNSigmaPi) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi, tofNSigmaPi); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng0, tpcTofNSigmaKaProng0, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng1, tpcTofNSigmaKaProng1, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); +DECLARE_SOA_DYNAMIC_COLUMN(TPCTOFNSigmaKaProng2, tpcTofNSigmaKaProng2, //! Combination of NsigmaTPC and NsigmaTOF + [](float tpcNSigmaKa, float tofNSigmaKa) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa, tofNSigmaKa); }); +} // namespace hf_track_pid_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(HfRedTrackBases, "AOD", "HFREDTRACKBASE", //! Table with track information for reduced workflow @@ -137,6 +222,9 @@ DECLARE_SOA_TABLE(HfRedTrackBases, "AOD", "HFREDTRACKBASE", //! Table with track 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, @@ -149,10 +237,11 @@ DECLARE_SOA_TABLE(HfRedTracksCov, "AOD", "HFREDTRACKCOV", //! Table with track c // table with all attributes needed to call statusTpcAndTof() in the selector task DECLARE_SOA_TABLE(HfRedTracksPid, "AOD", "HFREDTRACKPID", //! Table with PID track information for reduced workflow o2::soa::Index<>, - hf_track_index_reduced::HasTPC, - hf_track_index_reduced::HasTOF, + hf_track_vars_reduced::HasTPC, + hf_track_vars_reduced::HasTOF, pidtpc::TPCNSigmaPi, - pidtof::TOFNSigmaPi); + pidtof::TOFNSigmaPi, + hf_track_pid_reduced::TPCTOFNSigmaPi); DECLARE_SOA_EXTENDED_TABLE_USER(HfRedTracksExt, HfRedTrackBases, "HFREDTRACKEXT", //! Track parameters at collision vertex aod::track::Pt); @@ -161,9 +250,8 @@ using HfRedTracks = HfRedTracksExt; namespace hf_charm_cand_reduced { -DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass of 2prong candidate in GeV/c2 -DECLARE_SOA_COLUMN(InvMassD0, invMassD0, float); //! Invariant mass of 2prong candidate in GeV/c2 -DECLARE_SOA_COLUMN(InvMassD0Bar, invMassD0Bar, float); //! Invariant mass of 2prong candidate in GeV/c2 +DECLARE_SOA_COLUMN(InvMassHypo0, invMassHypo0, float); //! Invariant mass of candidate in GeV/c2 (mass hypothesis 0) +DECLARE_SOA_COLUMN(InvMassHypo1, invMassHypo1, float); //! Invariant mass of candidate in GeV/c2 (mass hypothesis 1) DECLARE_SOA_COLUMN(MlScoreBkgMassHypo0, mlScoreBkgMassHypo0, float); //! ML score for background class (mass hypothesis 0) DECLARE_SOA_COLUMN(MlScorePromptMassHypo0, mlScorePromptMassHypo0, float); //! ML score for prompt class (mass hypothesis 0) DECLARE_SOA_COLUMN(MlScoreNonpromptMassHypo0, mlScoreNonpromptMassHypo0, float); //! ML score for non-prompt class (mass hypothesis 0) @@ -180,7 +268,9 @@ DECLARE_SOA_TABLE(HfRed2Prongs, "AOD", "HFRED2PRONG", //! Table with 2prong cand hf_track_index_reduced::HfRedCollisionId, HFTRACKPAR_COLUMNS, hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, - hf_charm_cand_reduced::InvMassD0, hf_charm_cand_reduced::InvMassD0Bar, + hf_charm_cand_reduced::InvMassHypo0, hf_charm_cand_reduced::InvMassHypo1, + hf_track_vars_reduced::PtProngMin, hf_track_vars_reduced::AbsEtaProngMin, + hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, aod::track::Px, aod::track::Py, aod::track::Pz, @@ -207,7 +297,9 @@ DECLARE_SOA_TABLE(HfRed3Prongs, "AOD", "HFRED3PRONG", //! Table with 3prong cand hf_track_index_reduced::HfRedCollisionId, HFTRACKPAR_COLUMNS, hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex, - hf_charm_cand_reduced::InvMass, + hf_charm_cand_reduced::InvMassHypo0, hf_charm_cand_reduced::InvMassHypo1, + hf_track_vars_reduced::PtProngMin, hf_track_vars_reduced::AbsEtaProngMin, + hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, aod::track::Px, aod::track::Py, aod::track::Pz, @@ -218,11 +310,52 @@ DECLARE_SOA_TABLE(HfRed3ProngsCov, "AOD", "HFRED3PRONGSCOV", //! Table with 3pro HFTRACKPARCOV_COLUMNS, o2::soa::Marker<2>); -DECLARE_SOA_TABLE(HfRed3ProngsMl, "AOD", "HFRED3PRONGML", //! Table with 3prong candidate ML scores +DECLARE_SOA_TABLE(HfRed3ProngsMl_000, "AOD", "HFRED3PRONGML", //! Table with 3prong candidate ML scores hf_charm_cand_reduced::MlScoreBkgMassHypo0, hf_charm_cand_reduced::MlScorePromptMassHypo0, hf_charm_cand_reduced::MlScoreNonpromptMassHypo0); +DECLARE_SOA_TABLE_VERSIONED(HfRed3ProngsMl_001, "AOD", "HFRED3PRONGML", 1, //! Table with 3prong candidate ML scores (format for 2 mass hypotheses needed for Ds and Lc) + hf_charm_cand_reduced::MlScoreBkgMassHypo0, + hf_charm_cand_reduced::MlScorePromptMassHypo0, + hf_charm_cand_reduced::MlScoreNonpromptMassHypo0, + hf_charm_cand_reduced::MlScoreBkgMassHypo1, + hf_charm_cand_reduced::MlScorePromptMassHypo1, + hf_charm_cand_reduced::MlScoreNonpromptMassHypo1, + o2::soa::Marker<1>); + +using HfRed3ProngsMl = HfRed3ProngsMl_001; + +DECLARE_SOA_TABLE(HfRedPidDau0s, "AOD", "HFREDPIDDAU0", //! + hf_track_pid_reduced::TPCNSigmaPiProng0, + hf_track_pid_reduced::TOFNSigmaPiProng0, + hf_track_pid_reduced::TPCNSigmaKaProng0, + hf_track_pid_reduced::TOFNSigmaKaProng0, + hf_track_vars_reduced::HasTOFProng0, + hf_track_vars_reduced::HasTPCProng0, + hf_track_pid_reduced::TPCTOFNSigmaPiProng0, + hf_track_pid_reduced::TPCTOFNSigmaKaProng0); + +DECLARE_SOA_TABLE(HfRedPidDau1s, "AOD", "HFREDPIDDAU1", //! + hf_track_pid_reduced::TPCNSigmaPiProng1, + hf_track_pid_reduced::TOFNSigmaPiProng1, + hf_track_pid_reduced::TPCNSigmaKaProng1, + hf_track_pid_reduced::TOFNSigmaKaProng1, + hf_track_vars_reduced::HasTOFProng1, + hf_track_vars_reduced::HasTPCProng1, + hf_track_pid_reduced::TPCTOFNSigmaPiProng1, + hf_track_pid_reduced::TPCTOFNSigmaKaProng1); + +DECLARE_SOA_TABLE(HfRedPidDau2s, "AOD", "HFREDPIDDAU2", //! + hf_track_pid_reduced::TPCNSigmaPiProng2, + hf_track_pid_reduced::TOFNSigmaPiProng2, + hf_track_pid_reduced::TPCNSigmaKaProng2, + hf_track_pid_reduced::TOFNSigmaKaProng2, + hf_track_vars_reduced::HasTOFProng2, + hf_track_vars_reduced::HasTPCProng2, + hf_track_pid_reduced::TPCTOFNSigmaPiProng2, + hf_track_pid_reduced::TPCTOFNSigmaKaProng2); + // Beauty candidates prongs namespace hf_cand_b0_reduced { @@ -256,7 +389,7 @@ 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(HfRedBplusD0Mls, "AOD", "HFREDBPLUSD0ML", //! Table with ML scores for the D+ daughter +DECLARE_SOA_TABLE(HfRedBplusD0Mls, "AOD", "HFREDBPLUSD0ML", //! Table with ML scores for the D0 daughter hf_cand_bplus_reduced::Prong0MlScoreBkg, hf_cand_bplus_reduced::Prong0MlScorePrompt, hf_cand_bplus_reduced::Prong0MlScoreNonprompt, @@ -264,6 +397,26 @@ DECLARE_SOA_TABLE(HfRedBplusD0Mls, "AOD", "HFREDBPLUSD0ML", //! Table with ML sc using HfRedCandBplus = 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 +} // 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(HfRedBsDsMls, "AOD", "HFREDBSDSML", //! Table with ML scores for the Ds daughter + hf_cand_bs_reduced::Prong0MlScoreBkg, + hf_cand_bs_reduced::Prong0MlScorePrompt, + hf_cand_bs_reduced::Prong0MlScoreNonprompt, + o2::soa::Marker<1>); + +using HfRedCandBs = soa::Join; + namespace hf_b0_mc { // MC Rec @@ -292,6 +445,7 @@ DECLARE_SOA_TABLE(HfMcRecRedDpPis, "AOD", "HFMCRECREDDPPI", //! Table with recon hf_cand_b0_reduced::Prong0Id, hf_cand_b0_reduced::Prong1Id, hf_cand_b0::FlagMcMatchRec, + hf_cand_b0::FlagWrongCollision, hf_cand_b0::DebugMcRec, hf_b0_mc::PtMother); @@ -309,6 +463,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::FlagWrongCollision, hf_cand_b0::DebugMcRec, hf_b0_mc::PtMother); @@ -371,6 +526,7 @@ DECLARE_SOA_TABLE(HfMcRecRedD0Pis, "AOD", "HFMCRECREDD0PI", //! Table with recon hf_cand_bplus_reduced::Prong0Id, hf_cand_bplus_reduced::Prong1Id, hf_cand_bplus::FlagMcMatchRec, + hf_cand_bplus::FlagWrongCollision, hf_cand_bplus::DebugMcRec, hf_bplus_mc::PtMother); @@ -385,6 +541,7 @@ 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::FlagWrongCollision, hf_cand_bplus::DebugMcRec, hf_bplus_mc::PtMother); @@ -421,20 +578,90 @@ DECLARE_SOA_TABLE(HfCandBpConfigs, "AOD", "HFCANDBPCONFIG", //! Table with confi hf_cand_bplus_config::MySelectionFlagD0bar, hf_cand_bplus_config::MyInvMassWindowD0Pi); -// Charm resonances analysis -namespace hf_reso_cand_reduced +namespace hf_bs_mc { -DECLARE_SOA_COLUMN(InvMass, invMass, float); //! Invariant mass in GeV/c2 -DECLARE_SOA_COLUMN(Pt, pt, float); //! Pt of Resonance candidate in GeV/c -DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Pt of D daughter in GeV/c -DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Pt of V0 daughter in GeV/c -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(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 -} // namespace hf_reso_cand_reduced +// 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_bs_mc + +// table with results of reconstruction level MC matching +DECLARE_SOA_TABLE(HfMcRecRedDsPis, "AOD", "HFMCRECREDDSPI", //! Table with reconstructed MC information on DsPi(<-Bs) pairs for reduced workflow + hf_cand_bs_reduced::Prong0Id, + hf_cand_bs_reduced::Prong1Id, + hf_cand_bs::FlagMcMatchRec, + 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 + hf_bs_mc::PdgCodeBeautyMother, + hf_bs_mc::PdgCodeCharmMother, + hf_bs_mc::PdgCodeProng0, + hf_bs_mc::PdgCodeProng1, + hf_bs_mc::PdgCodeProng2, + hf_bs_mc::PdgCodeProng3, + o2::soa::Marker<1>); + +// 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::FlagWrongCollision, + hf_cand_bs::DebugMcRec, + hf_bs_mc::PtMother); + +DECLARE_SOA_TABLE(HfMcCheckBss, "AOD", "HFMCCHECKBS", //! Table with reconstructed MC information on Bs candidates for MC checks in reduced workflow + hf_bs_mc::PdgCodeBeautyMother, + hf_bs_mc::PdgCodeCharmMother, + hf_bs_mc::PdgCodeProng0, + hf_bs_mc::PdgCodeProng1, + hf_bs_mc::PdgCodeProng2, + hf_bs_mc::PdgCodeProng3, + o2::soa::Marker<2>); + +DECLARE_SOA_TABLE(HfMcGenRedBss, "AOD", "HFMCGENREDBS", //! Generation-level MC information on Bs candidates for reduced workflow + hf_cand_bs::FlagMcMatchGen, + hf_bs_mc::PtTrack, + hf_bs_mc::YTrack, + hf_bs_mc::EtaTrack, + hf_bs_mc::PtProng0, + hf_bs_mc::YProng0, + hf_bs_mc::EtaProng0, + hf_bs_mc::PtProng1, + hf_bs_mc::YProng1, + hf_bs_mc::EtaProng1); + +// 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 +} // 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); + +// 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 @@ -449,12 +676,8 @@ DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! [](float pxProng0, float pxProng1, float pxProng2, float pyProng0, float pyProng1, float pyProng2) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1 + 1.f * pxProng2), (1.f * pyProng0 + 1.f * pyProng1 + 1.f * pyProng2)); }); DECLARE_SOA_DYNAMIC_COLUMN(InvMassDplus, invMassDplus, [](float px0, float py0, float pz0, float px1, float py1, float pz1, float px2, float py2, float pz2) -> float { return RecoDecay::m(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}, std::array{px2, py2, pz2}}, std::array{constants::physics::MassPiPlus, constants::physics::MassKPlus, constants::physics::MassPiPlus}); }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassDstar, invMassDstar, - [](float pxSoftPi, float pySoftPi, float pzSoftPi, float pxProng0, float pyProng0, float pzProng0, float pxProng1, float pyProng1, float pzProng1) - -> float { return RecoDecay::m(std::array{std::array{pxSoftPi, pySoftPi, pzSoftPi}, std::array{pxProng0, pyProng0, pzProng0}, std::array{pxProng1, pyProng1, pzProng1}}, std::array{constants::physics::MassPiPlus, constants::physics::MassPiPlus, constants::physics::MassKPlus}) - RecoDecay::m(std::array{std::array{pxProng0, pyProng0, pzProng0}, std::array{pxProng1, pyProng1, pzProng1}}, std::array{constants::physics::MassPiPlus, constants::physics::MassKPlus}); }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassAntiDstar, invMassAntiDstar, - [](float pxSoftPi, float pySoftPi, float pzSoftPi, float pxProng0, float pyProng0, float pzProng0, float pxProng1, float pyProng1, float pzProng1) - -> float { return RecoDecay::m(std::array{std::array{pxSoftPi, pySoftPi, pzSoftPi}, std::array{pxProng0, pyProng0, pzProng0}, std::array{pxProng1, pyProng1, pzProng1}}, std::array{constants::physics::MassPiPlus, constants::physics::MassKPlus, constants::physics::MassPiPlus}) - RecoDecay::m(std::array{std::array{pxProng0, pyProng0, pzProng0}, std::array{pxProng1, pyProng1, pzProng1}}, std::array{constants::physics::MassKPlus, constants::physics::MassPiPlus}); }); +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_v0 @@ -463,6 +686,7 @@ DECLARE_SOA_COLUMN(Cpa, cpa, float); //! Cosine of Pointing Angle of V0 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, //! [](float pxProng0, float pxProng1) -> float { return 1.f * pxProng0 + 1.f * pxProng1; }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! @@ -471,7 +695,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! [](float pzProng0, float pzProng1) -> float { return 1.f * pzProng0 + 1.f * 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)); }); -DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0radius, //! V0 decay radius (2D, centered at zero) +DECLARE_SOA_DYNAMIC_COLUMN(V0Radius, v0Radius, //! V0 decay radius (2D, centered at zero) [](float x, float y) -> float { return RecoDecay::sqrtSumOfSquares(x, y); }); DECLARE_SOA_DYNAMIC_COLUMN(InvMassLambda, invMassLambda, //! mass under lambda hypothesis [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::m(std::array{std::array{pxpos, pypos, pzpos}, std::array{pxneg, pyneg, pzneg}}, std::array{o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged}); }); @@ -479,30 +703,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(InvMassAntiLambda, invMassAntiLambda, //! mass under [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::m(std::array{std::array{pxpos, pypos, pzpos}, std::array{pxneg, pyneg, pzneg}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton}); }); DECLARE_SOA_DYNAMIC_COLUMN(InvMassK0s, invMassK0s, //! mass under K0short hypothesis [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> float { return RecoDecay::m(std::array{std::array{pxpos, pypos, pzpos}, std::array{pxneg, pyneg, pzneg}}, std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged}); }); +DECLARE_SOA_DYNAMIC_COLUMN(PVector, pVector, + [](float pxpos, float pypos, float pzpos, float pxneg, float pyneg, float pzneg) -> std::array { return std::array{pxpos + pxneg, pypos + pyneg, pzpos + pzneg}; }); } // namespace hf_reso_v0 -namespace hf_reso_track -{ -DECLARE_SOA_COLUMN(Px, px, float); //! x-component of momentum -DECLARE_SOA_COLUMN(Py, py, float); //! y-component of momentum -DECLARE_SOA_COLUMN(Pz, pz, float); //! z-component of momentum -DECLARE_SOA_COLUMN(Sign, sign, uint8_t); //! charge sign -DECLARE_SOA_COLUMN(NSigmaTpcPi, nSigmaTpcPi, float); //! TPC Nsigma for pion hypothesis -DECLARE_SOA_COLUMN(NSigmaTpcKa, nSigmaTpcKa, float); //! TPC Nsigma for kaon hypothesis -DECLARE_SOA_COLUMN(NSigmaTpcPr, nSigmaTpcPr, float); //! TPC Nsigma for proton hypothesis -DECLARE_SOA_COLUMN(NSigmaTofPi, nSigmaTofPi, float); //! TOF Nsigma for pion hypothesis -DECLARE_SOA_COLUMN(NSigmaTofKa, nSigmaTofKa, float); //! TOF Nsigma for kaon hypothesis -DECLARE_SOA_COLUMN(NSigmaTofPr, nSigmaTofPr, float); //! TOF Nsigma for proton hypothesis -DECLARE_SOA_COLUMN(HasTof, hasTof, bool); //! flag for presence of TOF -DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! - [](float px, float py) -> float { return RecoDecay::pt(px, py); }); -DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, //! - [](float px, float py) -> float { return RecoDecay::phi(px, py); }); -DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, //! - [](float px, float py, float pz) -> float { return RecoDecay::eta(std::array{px, py, pz}); }); - -} // namespace hf_reso_track - DECLARE_SOA_TABLE(HfRedVzeros, "AOD", "HFREDVZERO", //! Table with V0 candidate information for resonances reduced workflow o2::soa::Index<>, // Indices @@ -512,39 +716,53 @@ DECLARE_SOA_TABLE(HfRedVzeros, "AOD", "HFREDVZERO", //! Table with V0 candidate 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_reso_v0::Cpa, - hf_reso_v0::Dca, + hf_reso_v0::Cpa, hf_reso_v0::Dca, + hf_track_vars_reduced::ItsNClsProngMin, hf_track_vars_reduced::TpcNClsCrossedRowsProngMin, hf_track_vars_reduced::TpcChi2NClProngMax, hf_reso_v0::V0Type, // Dynamic hf_reso_v0::Px, hf_reso_v0::Py, hf_reso_v0::Pz, + hf_track_vars_reduced::PtProng0, + hf_track_vars_reduced::PtProng1, + hf_track_vars_reduced::EtaProng0, + hf_track_vars_reduced::EtaProng1, hf_reso_v0::InvMassK0s, hf_reso_v0::InvMassLambda, hf_reso_v0::InvMassAntiLambda, hf_reso_v0::V0Radius, - hf_reso_v0::Pt); + hf_reso_v0::Pt, + hf_cand::PVectorProng0, + hf_cand::PVectorProng1, + hf_reso_v0::PVector); DECLARE_SOA_TABLE(HfRedTrkNoParams, "AOD", "HFREDTRKNOPARAM", //! Table with tracks without track parameters for resonances reduced workflow o2::soa::Index<>, // Indices hf_track_index_reduced::HfRedCollisionId, // Static - hf_reso_track::Px, - hf_reso_track::Py, - hf_reso_track::Pz, - hf_reso_track::Sign, - hf_reso_track::NSigmaTpcPi, - hf_reso_track::NSigmaTpcKa, - hf_reso_track::NSigmaTpcPr, - hf_reso_track::NSigmaTofPi, - hf_reso_track::NSigmaTofKa, - hf_reso_track::NSigmaTofPr, - hf_reso_track::HasTof, + hf_track_vars_reduced::Px, + hf_track_vars_reduced::Py, + hf_track_vars_reduced::Pz, + hf_track_vars_reduced::Sign, + pidtpc::TPCNSigmaPi, + pidtpc::TPCNSigmaKa, + pidtpc::TPCNSigmaPr, + pidtof::TOFNSigmaPi, + pidtof::TOFNSigmaKa, + pidtof::TOFNSigmaPr, + hf_track_vars_reduced::HasTOF, + hf_track_vars_reduced::HasTPC, + hf_track_vars_reduced::ItsNCls, + hf_track_vars_reduced::TpcNClsCrossedRows, + hf_track_vars_reduced::TpcChi2NCl, // Dynamic - hf_reso_track::Pt, - hf_reso_track::Eta, - hf_reso_track::Phi); + hf_track_vars_reduced::Pt, + hf_track_vars_reduced::Eta, + hf_track_vars_reduced::Phi, + hf_track_pid_reduced::TPCTOFNSigmaPi, + hf_track_pid_reduced::TPCTOFNSigmaKa, + hf_track_pid_reduced::TPCTOFNSigmaPr); DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong candidate information for resonances reduced workflow o2::soa::Index<>, @@ -556,34 +774,140 @@ DECLARE_SOA_TABLE(HfRed3PrNoTrks, "AOD", "HFRED3PRNOTRK", //! Table with 3 prong 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::DType, // 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_reso_3_prong::InvMassDplus, - hf_reso_3_prong::InvMassDstar, - hf_reso_3_prong::InvMassAntiDstar, - hf_reso_3_prong::Pt); + hf_cand_dstar::InvMassDstar, + hf_cand_dstar::InvMassAntiDstar, + hf_cand_dstar::InvMassD0, + hf_cand_dstar::InvMassD0Bar, + hf_reso_3_prong::Pt, + hf_cand::PVectorProng0, + hf_cand::PVectorProng1, + hf_cand::PVectorProng2, + hf_reso_3_prong::PVector); + +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(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(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, //! + [](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 DECLARE_SOA_TABLE(HfCandCharmReso, "AOD", "HFCANDCHARMRESO", //! Table with Resonance candidate information for resonances reduced workflow o2::soa::Index<>, - hf_track_index_reduced::HfRedCollisionId, + // 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::Pt, hf_reso_cand_reduced::InvMassProng0, - hf_reso_cand_reduced::PtProng0, hf_reso_cand_reduced::InvMassProng1, - hf_reso_cand_reduced::PtProng1, hf_reso_v0::Cpa, hf_reso_v0::Dca, - hf_reso_v0::Radius); + hf_reso_v0::Radius, + hf_reso_cand_reduced::InvMassD0, + // Dynamic + hf_reso_cand_reduced::Pt, + hf_reso_cand_reduced::PtProng0, + hf_reso_cand_reduced::PtProng1, + hf_reso_v0::Px, + 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); + +DECLARE_SOA_TABLE(HfResoIndices, "AOD", "HFRESOINDICES", //! Table with Indices of resonance daughters for MC matching + 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>); + +// 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, + hf_reso_cand_reduced::FlagMcMatchRec, + hf_reso_cand_reduced::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_reso_cand_reduced::SignD0, + hf_b0_mc::PtMother, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(HfMcGenRedResos, "AOD", "HFMCGENREDRESO", //! Generation-level MC information on Ds-Resonances candidates for reduced workflow + hf_cand_b0::FlagMcMatchGen, + hf_reso_cand_reduced::Origin, + hf_b0_mc::PtTrack, + hf_b0_mc::YTrack, + hf_b0_mc::EtaTrack, + hf_b0_mc::PtProng0, + hf_b0_mc::YProng0, + hf_b0_mc::EtaProng0, + hf_b0_mc::PtProng1, + hf_b0_mc::YProng1, + hf_b0_mc::EtaProng1, + 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::DebugMcRec, + hf_reso_cand_reduced::Origin, + hf_b0_mc::PtMother, + o2::soa::Marker<1>); } // namespace aod namespace soa diff --git a/PWGHF/D2H/Macros/HFInvMassFitter.h b/PWGHF/D2H/Macros/HFInvMassFitter.h index 6ac9357c5c2..410450de273 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitter.h +++ b/PWGHF/D2H/Macros/HFInvMassFitter.h @@ -20,7 +20,8 @@ #ifndef PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ #define PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ -#include // std::string +#include // std::cout +#include // std::string #include #include @@ -121,7 +122,7 @@ class HFInvMassFitter : public TNamed { if (mean < meanLowLimit || mean > meanUpLimit) { - cout << "Invalid Gaussian mean limmit!" << endl; + std::cout << "Invalid Gaussian mean limmit!" << std::endl; } setInitialGaussianMean(mean); mMassLowLimit = meanLowLimit; @@ -132,7 +133,7 @@ class HFInvMassFitter : public TNamed { if (mean < meanLowLimit || mean > meanUpLimit) { - cout << "Invalid Gaussian mean limmit for reflection!" << endl; + std::cout << "Invalid Gaussian mean limmit for reflection!" << std::endl; } setInitialGaussianMean(mean); mMassReflLowLimit = meanLowLimit; @@ -153,7 +154,7 @@ class HFInvMassFitter : public TNamed void setFixSecondGaussianSigma(Double_t sigma) { if (mTypeOfSgnPdf != DoubleGaus) { - cout << "Fit type should be 2Gaus!" << endl; + std::cout << "Fit type should be 2Gaus!" << std::endl; } setInitialSecondGaussianSigma(sigma); mFixedSigmaDoubleGaus = kTRUE; @@ -162,7 +163,7 @@ class HFInvMassFitter : public TNamed { if (mTypeOfSgnPdf != DoubleGaus && mTypeOfSgnPdf != DoubleGausSigmaRatioPar) { - cout << "Fit type should be 2Gaus or 2GausSigmaRatio!" << endl; + std::cout << "Fit type should be 2Gaus or 2GausSigmaRatio!" << std::endl; } setInitialFracDoubleGaus(frac); mFixedFracDoubleGaus = kTRUE; @@ -170,7 +171,7 @@ class HFInvMassFitter : public TNamed void setFixRatioToGausSigma(Double_t sigmaFrac) { if (mTypeOfSgnPdf != DoubleGausSigmaRatioPar) { - cout << "Fit type should be set to k2GausSigmaRatioPar!" << endl; + std::cout << "Fit type should be set to k2GausSigmaRatioPar!" << std::endl; } setInitialRatioDoubleGausSigma(sigmaFrac); mFixedRatioDoubleGausSigma = kTRUE; diff --git a/PWGHF/D2H/TableProducer/CMakeLists.txt b/PWGHF/D2H/TableProducer/CMakeLists.txt index 3579b44cc6e..92eeda51051 100644 --- a/PWGHF/D2H/TableProducer/CMakeLists.txt +++ b/PWGHF/D2H/TableProducer/CMakeLists.txt @@ -21,6 +21,11 @@ o2physics_add_dpl_workflow(candidate-creator-bplus-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(candidate-creator-bs-reduced + SOURCES candidateCreatorBsReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(candidate-creator-charm-reso-reduced SOURCES candidateCreatorCharmResoReduced.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -38,6 +43,11 @@ o2physics_add_dpl_workflow(candidate-selector-bplus-to-d0-pi-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(candidate-selector-bs-to-ds-pi-reduced + SOURCES candidateSelectorBsToDsPiReduced.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + # Data creators o2physics_add_dpl_workflow(data-creator-charm-had-pi-reduced @@ -50,3 +60,9 @@ o2physics_add_dpl_workflow(data-creator-charm-reso-reduced 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 diff --git a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx index 383ca9c42b1..3e354c266ea 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx @@ -293,7 +293,7 @@ struct HfCandidateCreatorB0ReducedExpressions { if ((rowDPiMcRec.prong0Id() != candB0.prong0Id()) || (rowDPiMcRec.prong1Id() != candB0.prong1Id())) { continue; } - rowB0McRec(rowDPiMcRec.flagMcMatchRec(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); + rowB0McRec(rowDPiMcRec.flagMcMatchRec(), rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); filledMcInfo = true; if constexpr (checkDecayTypeMc) { rowB0McCheck(rowDPiMcRec.pdgCodeBeautyMother(), @@ -306,7 +306,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.f); + rowB0McRec(0, -1, -1, -1.f); if constexpr (checkDecayTypeMc) { rowB0McCheck(-1, -1, -1, -1, -1, -1); } diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx index d47ac5f3d4d..34edf46cba4 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx @@ -291,7 +291,7 @@ struct HfCandidateCreatorBplusReducedExpressions { if ((rowD0PiMcRec.prong0Id() != candBplus.prong0Id()) || (rowD0PiMcRec.prong1Id() != candBplus.prong1Id())) { continue; } - rowBplusMcRec(rowD0PiMcRec.flagMcMatchRec(), rowD0PiMcRec.debugMcRec(), rowD0PiMcRec.ptMother()); + rowBplusMcRec(rowD0PiMcRec.flagMcMatchRec(), rowD0PiMcRec.flagWrongCollision(), rowD0PiMcRec.debugMcRec(), rowD0PiMcRec.ptMother()); filledMcInfo = true; if constexpr (checkDecayTypeMc) { rowBplusMcCheck(rowD0PiMcRec.pdgCodeBeautyMother(), @@ -302,7 +302,7 @@ 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.f); + rowBplusMcRec(0, -1, -1, -1.f); if constexpr (checkDecayTypeMc) { rowBplusMcCheck(-1, -1, -1, -1); } diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx new file mode 100644 index 00000000000..f75b5608ca1 --- /dev/null +++ b/PWGHF/D2H/TableProducer/candidateCreatorBsReduced.cxx @@ -0,0 +1,331 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 candidateCreatorBsReduced.cxx +/// \brief Reconstruction of Bs candidates +/// +/// \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 "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" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; + +/// Reconstruction of Bs candidates +struct HfCandidateCreatorBsReduced { + Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateProngs; // table defined in ReducedDataModel.h + Produces rowCandidateDmesMlScores; // 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 B0 is smaller than this"}; + Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"}; + // selection + Configurable invMassWindowDPiTolerance{"invMassWindowDPiTolerance", 0.01, "invariant-mass window tolerance for DsPi pair preselections (GeV/c2)"}; + + float myInvMassWindowDPi{1.}; // variable that will store the value of invMassWindowCharmHadPi (defined in dataCreatorCharmHadPiReduced.cxx) + float massPi{o2::constants::physics::MassPiPlus}; + float massD{o2::constants::physics::MassDS}; + float massB{o2::constants::physics::MassBS}; + float bz{0.}; + + o2::vertexing::DCAFitterN<2> df2; // fitter for B vertex (2-prong vertex fitter) + + using HfRedCollisionsWithExtras = soa::Join; + + Preslice> candsDPerCollision = 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, doprocessDataWithDmesMl}; + 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("hMassBsToDsPi", "2-prong candidates;inv. mass (B^{0}_{s} #rightarrow D_{s}^{#minus}#pi^{#plus} #rightarrow #K^{#minus}K^{#plus}#pi^{#minus}#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 + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidates); + } + + /// Main function to perform Bs candidate creation + /// \param withDmesMl is the flag to use the table with ML scores for the Ds- daughter (only possible if present in the derived data) + /// \param collision the collision + /// \param candsDThisColl Bs candidates in this collision + /// \param tracksPionThisCollision pion tracks in this collision + /// \param invMass2DPiMin minimum Bs invariant-mass + /// \param invMass2DPiMax maximum Bs invariant-mass + template + void runCandidateCreation(Coll const& collision, + Cands const& candsDThisColl, + Pions const& tracksPionThisCollision, + const float& invMass2DPiMin, + const float& invMass2DPiMax) + { + auto primaryVertex = getPrimaryVertex(collision); + auto covMatrixPV = primaryVertex.getCov(); + + // Set the magnetic field from ccdb + bz = collision.bz(); + df2.setBz(bz); + + for (const auto& candD : candsDThisColl) { + auto trackParCovD = getTrackParCov(candD); + std::array pVecD = candD.pVector(); + + for (const auto& trackPion : tracksPionThisCollision) { + // this track is among daughters + if (trackPion.trackId() == candD.prong0Id() || trackPion.trackId() == candD.prong1Id() || trackPion.trackId() == candD.prong2Id()) { + continue; + } + + auto trackParCovPi = getTrackParCov(trackPion); + std::array pVecPion = trackPion.pVector(); + + // compute invariant mass square and apply selection + auto invMass2DPi = RecoDecay::m2(std::array{pVecD, pVecPion}, std::array{massD, massPi}); + if ((invMass2DPi < invMass2DPiMin) || (invMass2DPi > invMass2DPiMax)) { + continue; + } + // --------------------------------- + // reconstruct the 2-prong Bs 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); // DsPi passed Bs reconstruction + + // calculate relevant properties + const auto& secondaryVertexB = df2.getPCACandidate(); + auto chi2PCA = df2.getChi2AtPCACandidate(); + auto covMatrixPCA = df2.calcPCACovMatrixFlat(); + registry.fill(HIST("hCovSVXX"), covMatrixPCA[0]); + registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); + + // propagate Ds and Pi to the Bs vertex + df2.propagateTracksToVertex(); + // track.getPxPyPzGlo(pVec) modifies pVec of track + df2.getTrack(0).getPxPyPzGlo(pVecD); // momentum of Ds at the Bs vertex + df2.getTrack(1).getPxPyPzGlo(pVecPion); // momentum of Pi at the Bs vertex + + registry.fill(HIST("hMassBsToDsPi"), std::sqrt(invMass2DPi)); + + // compute impact parameters of Ds and Pi + o2::dataformats::DCA dcaD; + o2::dataformats::DCA dcaPion; + trackParCovD.propagateToDCA(primaryVertex, bz, &dcaD); + 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()}, secondaryVertexB, 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: + rowCandidateBase(collision.globalIndex(), + collision.posX(), collision.posY(), collision.posZ(), + secondaryVertexB[0], secondaryVertexB[1], secondaryVertexB[2], + errorDecayLength, errorDecayLengthXY, + chi2PCA, + pVecD[0], pVecD[1], pVecD[2], + pVecPion[0], pVecPion[1], pVecPion[2], + dcaD.getY(), dcaPion.getY(), + std::sqrt(dcaD.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2())); + + rowCandidateProngs(candD.globalIndex(), trackPion.globalIndex()); + + if constexpr (withDmesMl) { + if (candD.invMassHypo0() > 0) { + rowCandidateDmesMlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0()); + } else { + rowCandidateDmesMlScores(candD.mlScoreBkgMassHypo1(), candD.mlScorePromptMassHypo1(), candD.mlScoreNonpromptMassHypo1()); + } + // TODO: here we are assuming that only one of the two hypotheses is filled, to be checked + } + } // pi loop + } // D loop + } + + void processData(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsD, + soa::Join const& tracksPion, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCandBsConfigs const& configs) + { + // DsPi invariant-mass window cut + for (const auto& config : configs) { + myInvMassWindowDPi = config.myInvMassWindowDPi(); + } + // invMassWindowDPiTolerance is used to apply a slightly tighter cut than in DsPi pair preselection + // to avoid accepting DsPi pairs that were not formed in DsPi pair creator + float invMass2DPiMin = (massB - myInvMassWindowDPi + invMassWindowDPiTolerance) * (massB - myInvMassWindowDPi + invMassWindowDPiTolerance); + float invMass2DPiMax = (massB + myInvMassWindowDPi - invMassWindowDPiTolerance) * (massB + myInvMassWindowDPi - invMassWindowDPiTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + static int ncol = 0; + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + auto tracksPionThisCollision = tracksPion.sliceBy(tracksPionPerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, tracksPionThisCollision, invMass2DPiMin, invMass2DPiMax); + if (ncol % 10000 == 0) { + LOGP(debug, "collisions parsed {}", ncol); + } + ncol++; + } + } // processData + + PROCESS_SWITCH(HfCandidateCreatorBsReduced, processData, "Process data without any ML score", true); + + void processDataWithDmesMl(HfRedCollisionsWithExtras const& collisions, + soa::Join const& candsD, + soa::Join const& tracksPion, + aod::HfOrigColCounts const& collisionsCounter, + aod::HfCandBsConfigs const& configs) + { + // DPi invariant-mass window cut + for (const auto& config : configs) { + myInvMassWindowDPi = config.myInvMassWindowDPi(); + } + // invMassWindowDPiTolerance is used to apply a slightly tighter cut than in DsPi pair preselection + // to avoid accepting DPi pairs that were not formed in DsPi pair creator + float invMass2DPiMin = (massB - myInvMassWindowDPi + invMassWindowDPiTolerance) * (massB - myInvMassWindowDPi + invMassWindowDPiTolerance); + float invMass2DPiMax = (massB + myInvMassWindowDPi - invMassWindowDPiTolerance) * (massB + myInvMassWindowDPi - invMassWindowDPiTolerance); + + for (const auto& collisionCounter : collisionsCounter) { + registry.fill(HIST("hEvents"), 1, collisionCounter.originalCollisionCount()); + } + + static int ncol = 0; + for (const auto& collision : collisions) { + auto thisCollId = collision.globalIndex(); + auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + auto tracksPionThisCollision = tracksPion.sliceBy(tracksPionPerCollision, thisCollId); + runCandidateCreation(collision, candsDThisColl, tracksPionThisCollision, invMass2DPiMin, invMass2DPiMax); + if (ncol % 10000 == 0) { + LOGP(debug, "collisions parsed {}", ncol); + } + ncol++; + } + } // processDataWithDmesMl + + PROCESS_SWITCH(HfCandidateCreatorBsReduced, processDataWithDmesMl, "Process data with ML scores of D mesons", false); +}; // struct + +/// Extends the table base with expression columns and performs MC matching. +struct HfCandidateCreatorBsReducedExpressions { + Spawns rowCandidateBs; + Spawns rowTracksExt; + Produces rowBsMcRec; + Produces rowBsMcCheck; + + /// Fill candidate information at MC reconstruction level + /// \param checkDecayTypeMc + /// \param rowsDPiMcRec MC reco information on DsPi pairs + /// \param candsB prong global indices of Bs candidates + template + void fillBsMcRec(McRec const& rowsDPiMcRec, HfRedBsProngs const& candsB) + { + for (const auto& candB : candsB) { + bool filledMcInfo{false}; + for (const auto& rowDPiMcRec : rowsDPiMcRec) { + if ((rowDPiMcRec.prong0Id() != candB.prong0Id()) || (rowDPiMcRec.prong1Id() != candB.prong1Id())) { + continue; + } + rowBsMcRec(rowDPiMcRec.flagMcMatchRec(), rowDPiMcRec.flagWrongCollision(), rowDPiMcRec.debugMcRec(), rowDPiMcRec.ptMother()); + filledMcInfo = true; + if constexpr (checkDecayTypeMc) { + rowBsMcCheck(rowDPiMcRec.pdgCodeBeautyMother(), + rowDPiMcRec.pdgCodeCharmMother(), + rowDPiMcRec.pdgCodeProng0(), + rowDPiMcRec.pdgCodeProng1(), + rowDPiMcRec.pdgCodeProng2(), + rowDPiMcRec.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 DsPi creator + rowBsMcRec(0, -1, -1, -1.f); + if constexpr (checkDecayTypeMc) { + rowBsMcCheck(-1, -1, -1, -1, -1, -1); + } + } + } + } + + void processMc(HfMcRecRedDsPis const& rowsDPiMcRec, HfRedBsProngs const& candsB) + { + fillBsMcRec(rowsDPiMcRec, candsB); + } + PROCESS_SWITCH(HfCandidateCreatorBsReducedExpressions, processMc, "Process MC", false); + + void processMcWithDecayTypeCheck(soa::Join const& rowsDPiMcRec, HfRedBsProngs const& candsB) + { + fillBsMcRec(rowsDPiMcRec, candsB); + } + PROCESS_SWITCH(HfCandidateCreatorBsReducedExpressions, 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/candidateCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx index 79b6c92311e..062fb658128 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorCharmResoReduced.cxx @@ -13,6 +13,8 @@ /// \brief Reconstruction of Resonance candidates /// /// \author Luca Aglietta , Università degli Studi di Torino +#include +#include #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" @@ -22,33 +24,52 @@ #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/Utils/utilsAnalysis.h" using namespace o2; using namespace o2::aod; +using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; enum Selections : uint8_t { NoSel = 0, DSel, V0Sel, + TrackSel, NSelSteps }; enum DecayChannel : uint8_t { Ds1ToDstarK0s = 0, Ds2StarToDplusK0s, XcToDplusLambda, - LambdaDminus + LambdaDminus, + DstarTrack }; + enum V0Type : uint8_t { K0s = 0, Lambda, AntiLambda }; -const int nBins = 7; -constexpr double binsPt[nBins + 1] = { + +enum DecayTypeMc : uint8_t { + Ds1ToDStarK0ToD0PiK0s = 1, + Ds2StarToDplusK0sToPiKaPiPiPi, + Ds1ToDStarK0ToDPlusPi0K0s, + Ds1ToDStarK0ToD0PiK0sPart, + Ds1ToDStarK0ToD0NoPiK0sPart, + Ds1ToDStarK0ToD0PiK0sOneMu, + Ds2StarToDplusK0sOneMu +}; + +const int nBinsPt = 7; +constexpr double binsPt[nBinsPt + 1] = { 1., 2., 4., @@ -56,101 +77,123 @@ constexpr double binsPt[nBins + 1] = { 8., 12., 24., - 50.}; -auto vecBins = std::vector{binsPt, binsPt + nBins + 1}; + 1000.}; +auto vecBinsPt = std::vector{binsPt, binsPt + nBinsPt + 1}; struct HfCandidateCreatorCharmResoReduced { // Produces: Tables with resonance info Produces rowCandidateReso; - // Optional D daughter ML scores table + Produces rowCandidateResoTrack; + // Optional daughter ML scores table Produces mlScores; + // Table with candidate indices for MC matching + Produces rowCandidateResoIndices; // Configurables - Configurable invMassWindowD{"invMassWindowD", 0.5, "invariant-mass window for D candidates (GeV/c2)"}; - Configurable invMassWindowV0{"invMassWindowV0", 0.5, "invariant-mass window for V0 candidates (GeV/c2)"}; 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"}; - // Hist Axis - Configurable> binsPt{"binsPt", std::vector{vecBins}, "pT bin limits"}; + 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"}; - using reducedDWithMl = soa::Join; + // 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; + 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; - // aod::HfRedVzeros - // Useful constants - double massK0{0.}; - double massLambda{0.}; - double massDplus{0.}; - double massDstar{0.}; - double massD0{0.}; - - // Histogram registry: if task make it with a THNsparse with all variables you want to save + Preslice candsDPerCollisionWithMl = 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, doprocessXcToDplusLambda, doprocessXcToDplusLambdaWithMl, doprocessLambdaDminus, doprocessLambdaDminusWithMl}; + 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)vecBins, "#it{p}_{T} (GeV/#it{c})"}; - registry.add("hMassDs1", "Ds1 candidates;m_{Ds1} (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{100, 2.4, 2.7}, {(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, {{100, 2.4, 2.7}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassXcRes", "XcRes candidates; m_XcRes (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{100, 2.9, 3.3}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassLambdaDminus", "LambdaDminus candidates; m_LambdaDminus (GeV/#it{c}^{2}) ;entries", {HistType::kTH2F, {{100, 2.9, 3.3}, {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}}}); + 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.}}}); + } + 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()); } } - // mass constants - massK0 = o2::constants::physics::MassK0Short; - massLambda = o2::constants::physics::MassLambda; - massDplus = o2::constants::physics::MassDPlus; - massDstar = o2::constants::physics::MassDStar; - massD0 = o2::constants::physics::MassD0; } + /// 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) { - float massD{0.}; float invMassD{0.}; - // slection on D candidate mass + float ptD = candD.pt(); + int ptBin = findBin(binsPtD, ptD); + if (ptBin == -1) { + return false; + } if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) { - massD = massDplus; invMassD = candD.invMassDplus(); - } else if (channel == DecayChannel::Ds1ToDstarK0s) { - massD = massDstar - massD0; + } else if (channel == DecayChannel::Ds1ToDstarK0s || channel == DecayChannel::DstarTrack) { if (candD.dType() > 0) - invMassD = candD.invMassDstar(); + invMassD = candD.invMassDstar() - candD.invMassD0(); else - invMassD = candD.invMassAntiDstar(); + invMassD = candD.invMassAntiDstar() - candD.invMassD0Bar(); } - if (std::fabs(invMassD - massD) > invMassWindowD) { - return false; + // 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; + } } return true; } - /// Basic selection of V0 candidates + /// 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 @@ -159,11 +202,16 @@ struct HfCandidateCreatorCharmResoReduced { { float massV0{0.}; float invMassV0{0.}; + float ptV0 = candV0.pt(); + int ptBin = findBin(binsPtV0, ptV0); + if (ptBin == -1) { + return false; + } if (channel == DecayChannel::Ds2StarToDplusK0s || channel == DecayChannel::Ds1ToDstarK0s) { - massV0 = massK0; + massV0 = MassK0Short; invMassV0 = candV0.invMassK0s(); } else if (channel == DecayChannel::XcToDplusLambda || channel == DecayChannel::LambdaDminus) { - massV0 = massLambda; + massV0 = MassLambda; int wsFact{1}; if (channel == DecayChannel::LambdaDminus) wsFact = -1; @@ -175,21 +223,26 @@ struct HfCandidateCreatorCharmResoReduced { invMassV0 = candV0.invMassAntiLambda(); targetV0Type = V0Type::AntiLambda; } + // check skimming cuts if (!TESTBIT(candV0.v0Type(), targetV0Type)) { return false; } } - // slection on V0 candidate mass - if (std::fabs(invMassV0 - massV0) > invMassWindowV0) { + // selection on V0 candidate mass + if ((invMassV0 - massV0) > cutsV0->get(ptBin, "invMassLow") && (massV0 - invMassV0) < cutsV0->get(ptBin, "invMassLow")) { + 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")) { return false; } return true; } - template + template void runCandidateCreation(Coll const& collision, DRedTable const& candsD, - V0RedTable const& candsV0) + V0TrRedTable const& candsV0Tr) { // loop on D candidates for (const auto& candD : candsD) { @@ -204,87 +257,215 @@ struct HfCandidateCreatorCharmResoReduced { registry.fill(HIST("hSelections"), 1 + Selections::DSel); } float invMassD{0.}; + float invMassD0{0.}; if (std::abs(candD.dType()) == 1) invMassD = candD.invMassDplus(); - if (candD.dType() == 2) + if (candD.dType() == 2) { invMassD = candD.invMassDstar(); - if (candD.dType() == -2) + invMassD0 = candD.invMassD0(); + } + if (candD.dType() == -2) { invMassD = candD.invMassAntiDstar(); + invMassD0 = candD.invMassD0Bar(); + } std::array pVecD = {candD.px(), candD.py(), candD.pz()}; - float ptD = RecoDecay::pt(pVecD); - ; - // loop on V0 candidates + + // loop on V0 or track candidates bool alreadyCounted{false}; - for (const auto& candV0 : candsV0) { + for (const auto& candV0Tr : candsV0Tr) { if (rejectDV0PairsWithCommonDaughter) { const std::array dDaughtersIDs = {candD.prong0Id(), candD.prong1Id(), candD.prong2Id()}; - if (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0.prong0Id()) != dDaughtersIDs.end() || std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0.prong1Id()) != dDaughtersIDs.end()) { + if constexpr (channel == DecayChannel::DstarTrack) { + if (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.globalIndex()) != dDaughtersIDs.end()) { + continue; + } + } else { + if (std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong0Id()) != dDaughtersIDs.end() || std::find(dDaughtersIDs.begin(), dDaughtersIDs.end(), candV0Tr.prong1Id()) != dDaughtersIDs.end()) { + continue; + } + } + } + if constexpr (channel != DecayChannel::DstarTrack) { + if (!isV0Selected(candV0Tr, candD)) { continue; } + if (activateQA && !alreadyCounted) { + registry.fill(HIST("hSelections"), 1 + Selections::V0Sel); + alreadyCounted = true; + } } - if (!isV0Selected(candV0, candD)) { + 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}); + } else { + invMassReso = RecoDecay::m(std::array{pVectorCharmProngs[1], pVectorCharmProngs[0], pVectorCharmProngs[2], pVecV0Tr}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + } + 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; + } + } + // 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, + invMassV0, + candV0Tr.cpa(), + candV0Tr.dca(), + candV0Tr.v0Radius(), + invMassD0); + rowCandidateResoIndices(collision.globalIndex(), + candD.globalIndex(), + candV0Tr.globalIndex()); + } + if constexpr (fillMl) { + mlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0()); + } + } + } + } // main 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 + void runCandidateCreationMixedEvent(Coll const& collisions, + DRedTable const& candsD, + V0TrRedTable const& candsV0Tr) + { + using BinningType = ColumnBinningPolicy; + BinningType corrBinning{{zPoolBins, multPoolBins}, true}; + auto bachTuple = std::make_tuple(candsD, candsV0Tr); + Pair pairs{corrBinning, numberEventsMixed, 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)) { continue; } - if (activateQA && !alreadyCounted) { - registry.fill(HIST("hSelections"), 1 + Selections::V0Sel); - alreadyCounted = true; + // 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 pVecV0 = {candV0.px(), candV0.py(), candV0.pz()}; - float ptV0 = RecoDecay::pt(pVecV0); - float ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0, pVecD)); + std::array pVecV0Tr = {bachV0Tr.px(), bachV0Tr.py(), bachV0Tr.pz()}; + float ptReso = RecoDecay::pt(RecoDecay::sumOfVec(pVecV0Tr, pVecD)); switch (channel) { case DecayChannel::Ds1ToDstarK0s: - invMassV0 = candV0.invMassK0s(); - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0}, std::array{massDstar, massK0}); + 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 = candV0.invMassK0s(); - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0}, std::array{massDplus, massK0}); + 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 (candD.dType() > 0) { - invMassV0 = candV0.invMassLambda(); + if (bachD.dType() > 0) { + invMassV0 = bachV0Tr.invMassLambda(); } else { - invMassV0 = candV0.invMassAntiLambda(); + invMassV0 = bachV0Tr.invMassAntiLambda(); } - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0}, std::array{massDplus, massLambda}); + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassLambda}); registry.fill(HIST("hMassXcRes"), invMassReso, ptReso); break; case DecayChannel::LambdaDminus: - if (candD.dType() < 0) { - invMassV0 = candV0.invMassLambda(); + if (bachD.dType() < 0) { + invMassV0 = bachV0Tr.invMassLambda(); } else { - invMassV0 = candV0.invMassAntiLambda(); + invMassV0 = bachV0Tr.invMassAntiLambda(); } - invMassReso = RecoDecay::m(std::array{pVecD, pVecV0}, std::array{massDplus, massLambda}); + invMassReso = RecoDecay::m(std::array{pVecD, pVecV0Tr}, std::array{MassDPlus, MassLambda}); registry.fill(HIST("hMassLambdaDminus"), invMassReso, ptReso); break; default: break; } - // Filling Output table - rowCandidateReso(collision.globalIndex(), + // Fill output table + rowCandidateReso(pVecD[0], pVecD[1], pVecD[2], + pVecV0Tr[0], pVecV0Tr[1], pVecV0Tr[2], invMassReso, - ptReso, invMassD, - ptD, invMassV0, - ptV0, - candV0.cpa(), - candV0.dca(), - candV0.v0radius()); + bachV0Tr.cpa(), + bachV0Tr.dca(), + bachV0Tr.v0Radius(), + invMassD0); + rowCandidateResoIndices(collision1.globalIndex(), + bachD.globalIndex(), + bachV0Tr.globalIndex()); if constexpr (fillMl) { - mlScores(candD.mlScoreBkgMassHypo0(), candD.mlScorePromptMassHypo0(), candD.mlScoreNonpromptMassHypo0()); + mlScores(bachD.mlScoreBkgMassHypo0(), bachD.mlScorePromptMassHypo0(), bachD.mlScoreNonpromptMassHypo0()); } } } - } // main function + } // runCandidateCreationMixedEvent + // List of Process Functions void processDs2StarToDplusK0s(aod::HfRedCollisions const& collisions, aod::HfRed3PrNoTrks const& candsD, aod::HfRedVzeros const&) @@ -304,13 +485,29 @@ struct HfCandidateCreatorCharmResoReduced { { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); runCandidateCreation(collision, candsDThisColl, k0sThisColl); } } PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0sWithMl, "Process Ds2* candidates with Ml info", false); + void processDs2StarToDplusK0sMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks 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); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs2StarToDplusK0sMixedEventWithMl, "Process Ds2Star mixed Event with ML", false); + void processDs1ToDstarK0s(aod::HfRedCollisions const& collisions, aod::HfRed3PrNoTrks const& candsD, aod::HfRedVzeros const&) @@ -325,18 +522,34 @@ struct HfCandidateCreatorCharmResoReduced { PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0s, "Process Ds1 candidates without Ml info", false); void processDs1ToDstarK0sWithMl(aod::HfRedCollisions const& collisions, - reducedDWithMl const& candsD, + HfRed3PrNoTrksWithMl const& candsD, aod::HfRedVzeros const&) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); auto k0sThisColl = candidatesK0s.sliceBy(candsV0PerCollision, thisCollId); runCandidateCreation(collision, candsDThisColl, k0sThisColl); } } PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sWithMl, "Process Ds1 candidates with Ml info", false); + void processDs1ToDstarK0sMixedEvent(aod::HfRedCollisions const& collisions, + aod::HfRed3PrNoTrks const& candsD, + aod::HfRedVzeros const& candsV0) + { + runCandidateCreationMixedEvent(collisions, candsD, candsV0); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sMixedEvent, "Process Ds1 mixed Event without ML", false); + + void processDs1ToDstarK0sMixedEventWithMl(aod::HfRedCollisions const& collisions, + HfRed3PrNoTrksWithMl const& candsD, + aod::HfRedVzeros const& candsV0) + { + runCandidateCreationMixedEvent(collisions, candsD, candsV0); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDs1ToDstarK0sMixedEventWithMl, "Process Ds1 mixed Event with ML", false); + void processXcToDplusLambda(aod::HfRedCollisions const& collisions, aod::HfRed3PrNoTrks const& candsD, aod::HfRedVzeros const&) @@ -351,12 +564,12 @@ struct HfCandidateCreatorCharmResoReduced { PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processXcToDplusLambda, "Process Xc candidates without Ml info", false); void processXcToDplusLambdaWithMl(aod::HfRedCollisions const& collisions, - soa::Join const& candsD, + HfRed3PrNoTrksWithMl const& candsD, aod::HfRedVzeros const&) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + auto candsDThisColl = candsD.sliceBy(candsDPerCollisionWithMl, thisCollId); auto lambdaThisColl = candidatesLambda.sliceBy(candsV0PerCollision, thisCollId); runCandidateCreation(collision, candsDThisColl, lambdaThisColl); } @@ -377,21 +590,130 @@ struct HfCandidateCreatorCharmResoReduced { PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processLambdaDminus, "Process LambdaDminus candidates without Ml info", false); void processLambdaDminusWithMl(aod::HfRedCollisions const& collisions, - soa::Join const& candsD, + HfRed3PrNoTrksWithMl const& candsD, aod::HfRedVzeros const&) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); - auto candsDThisColl = candsD.sliceBy(candsDPerCollision, thisCollId); + 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) + { + 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); + } + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTrack, "Process DStar candidates without Ml info", false); + + void processDstarTrackWithMl(aod::HfRedCollisions const& collisions, + HfRed3PrNoTrksWithMl const& candsD, + aod::HfRedTrkNoParams const& candidatesTrack) + { + 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); + } + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReduced, processDstarTrackWithMl, "Process DStar candidates with Ml info", false); -}; // struct +}; // struct HfCandidateCreatorCharmResoReduced + +struct HfCandidateCreatorCharmResoReducedExpressions { + + Produces rowResoMcRec; + + using CandResoWithIndices = 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"}; + + void init(InitContext const&) + { + registry.add("hMassMcMatched", "Reso MC candidates Matched with generate particle;m (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisInvMassReso, axisPt}}); + 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 candsReso prong global indices of B0 candidates + template + void fillResoMcRec(McRec const& rowsDV0McRec, CandResoWithIndices const& candsReso) + { + for (const auto& candReso : candsReso) { + bool filledMcInfo{false}; + for (const auto& rowDV0McRec : rowsDV0McRec) { + if ((rowDV0McRec.prong0Id() != candReso.prong0Id()) || (rowDV0McRec.prong1Id() != candReso.prong1Id())) { + continue; + } + rowResoMcRec(rowDV0McRec.flagMcMatchRec(), rowDV0McRec.debugMcRec(), rowDV0McRec.origin(), rowDV0McRec.ptMother()); + 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) { + 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) { + 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); + registry.fill(HIST("hMassMcNoEntry"), candReso.invMass(), candReso.pt()); + } + } + } + + void processMc(aod::HfMcRecRedDV0s const& rowsDV0McRec, CandResoWithIndices const& candsReso) + { + fillResoMcRec(rowsDV0McRec, candsReso); + } + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processMc, "Process MC", false); + + void processDummy(CandResoWithIndices const&) {} + PROCESS_SWITCH(HfCandidateCreatorCharmResoReducedExpressions, processDummy, "Process dummy", true); +}; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx index 5bf352517e4..a47f9137f7c 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorB0ToDPiReduced.cxx @@ -15,6 +15,9 @@ /// \author Alexandre Bigot , IPHC Strasbourg /// \author Fabrizio Grosa , CERN +#include +#include + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -64,7 +67,7 @@ struct HfCandidateSelectorB0ToDPiReduced { 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", (int8_t)hf_cuts_ml::nCutScores, "Number of classes in ML model"}; + 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"}; @@ -114,6 +117,7 @@ struct HfCandidateSelectorB0ToDPiReduced { 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) { diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx index b10dfe22752..9960ce06946 100644 --- a/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateSelectorBplusToD0PiReduced.cxx @@ -14,6 +14,9 @@ /// /// \author Antonio Palasciano , Università degli Studi di Bari +#include +#include + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -63,7 +66,7 @@ struct HfCandidateSelectorBplusToD0PiReduced { 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", (int8_t)hf_cuts_ml::nCutScores, "Number of classes in ML model"}; + 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"}; @@ -114,6 +117,7 @@ struct HfCandidateSelectorBplusToD0PiReduced { 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) { diff --git a/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx new file mode 100644 index 00000000000..b89272f3059 --- /dev/null +++ b/PWGHF/D2H/TableProducer/candidateSelectorBsToDsPiReduced.cxx @@ -0,0 +1,245 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 candidateSelectorBsToDsPiReduced.cxx +/// \brief Bs → Ds- π+ candidate selector +/// +/// \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" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::analysis; + +struct HfCandidateSelectorBsToDsPiReduced { + Produces hfSelBsToDsPiCandidate; // table defined in CandidateSelectionTables.h + Produces hfMlBsToDsPiCandidate; // 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", 1, "PID selection method for the bachelor pion (0: none, 1: TPC or TOF, 2: 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_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"}; + // 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"}; + // 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> 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_BsToDsPi.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::HfMlResponseBsToDsPi hfMlResponse; + 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, 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 > 2) { + LOGP(fatal, "Invalid PID option in configurable, please set 0 (no PID), 1 (TPC or TOF), or 2 (TPC and TOF)"); + } + + if (pionPidMethod) { + 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 (applyBsMl) { + 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(); + } + } + + /// Main function to perform Bs candidate selection + /// \param withDmesMl is the flag to use the table with ML scores for the Ds- daughter (only possible if present in the derived data) + /// \param hfCandsBs Bs candidates + /// \param pionTracks pion tracks + /// \param configs config inherited from the charm-hadron data creator + template + void runSelection(Cands const& hfCandsBs, + TracksPion const&, + HfCandBsConfigs const&) + { + for (const auto& hfCandBs : hfCandsBs) { + int statusBsToDsPi = 0; + outputMl.clear(); + auto ptCandBs = hfCandBs.pt(); + + SETBIT(statusBsToDsPi, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusBsToDsPi = 1 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandBs); + } + + // topological cuts + if (!hfHelper.selectionBsToDsPiTopol(hfCandBs, cuts, binsPt)) { + hfSelBsToDsPiCandidate(statusBsToDsPi); + if (applyBsMl) { + hfMlBsToDsPiCandidate(outputMl); + } + continue; + } + + if constexpr (withDmesMl) { // we include it in the topological selections + if (!hfHelper.selectionDmesMlScoresForB(hfCandBs, cutsDmesMl, binsPtDmesMl)) { + hfSelBsToDsPiCandidate(statusBsToDsPi); + if (applyBsMl) { + hfMlBsToDsPiCandidate(outputMl); + } + continue; + } + } + + SETBIT(statusBsToDsPi, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusBsToDsPi = 3 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoTopol, ptCandBs); + } + + // track-level PID selection + auto trackPi = hfCandBs.template prong1_as(); + if (pionPidMethod) { + int pidTrackPi{TrackSelectorPID::Status::NotApplicable}; + if (pionPidMethod == 1) { + pidTrackPi = selectorPion.statusTpcOrTof(trackPi); + } else { + pidTrackPi = selectorPion.statusTpcAndTof(trackPi); + } + if (!hfHelper.selectionBsToDsPiPid(pidTrackPi, acceptPIDNotApplicable.value)) { + hfSelBsToDsPiCandidate(statusBsToDsPi); + if (applyBsMl) { + hfMlBsToDsPiCandidate(outputMl); + } + continue; + } + SETBIT(statusBsToDsPi, SelectionStep::RecoPID); // RecoPID = 2 --> statusBsToDsPi = 7 + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoPID, ptCandBs); + } + } + + if (applyBsMl) { + // Bs ML selections + std::vector inputFeatures = hfMlResponse.getInputFeatures(hfCandBs, trackPi); + bool isSelectedMl = hfMlResponse.isSelectedMl(inputFeatures, ptCandBs, outputMl); + hfMlBsToDsPiCandidate(outputMl); + + if (!isSelectedMl) { + hfSelBsToDsPiCandidate(statusBsToDsPi); + continue; + } + SETBIT(statusBsToDsPi, SelectionStep::RecoMl); // RecoML = 3 --> statusBsToDsPi = 15 if pionPidMethod, 11 otherwise + if (activateQA) { + registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoMl, ptCandBs); + } + } + + hfSelBsToDsPiCandidate(statusBsToDsPi); + } + } + + void processSelection(HfRedCandBs const& hfCandsBs, + TracksPion const& pionTracks, + HfCandBsConfigs const& configs) + { + runSelection(hfCandsBs, pionTracks, configs); + } // processSelection + + PROCESS_SWITCH(HfCandidateSelectorBsToDsPiReduced, processSelection, "Process selection without ML scores of D mesons", true); + + void processSelectionWithDmesMl(soa::Join const& hfCandsBs, + TracksPion const& pionTracks, + HfCandBsConfigs const& configs) + { + runSelection(hfCandsBs, pionTracks, configs); + } // processSelectionWithDmesMl + + PROCESS_SWITCH(HfCandidateSelectorBsToDsPiReduced, processSelectionWithDmesMl, "Process selection with ML scores of D mesons", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx b/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.cxx new file mode 100644 index 00000000000..ea9450eca08 --- /dev/null +++ b/PWGHF/D2H/TableProducer/converterReduced3ProngsMl.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. + +/// \file converterReduced3ProngsMl.cxx +/// \brief Task for conversion of HfRed3ProngsMl to version 001 +/// +/// \author Fabrizio Grosa , CERN + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +using namespace o2; +using namespace o2::framework; + +// Swaps covariance matrix elements if the data is known to be bogus (collision_000 is bogus) +struct HfConverterReduced3ProngsMl { + Produces ml3Prongs; + + void process(aod::HfRed3ProngsMl_000::iterator const& mlScoreTable) + { + ml3Prongs(mlScoreTable.mlScoreBkgMassHypo0(), mlScoreTable.mlScorePromptMassHypo0(), mlScoreTable.mlScoreNonpromptMassHypo0(), -1.f, -1.f, -1.f); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx index 11598709ffc..3a52b39387f 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx @@ -15,6 +15,7 @@ /// \author Alexandre Bigot , IPHC Strasbourg /// \author Antonio Palasciano , Università degli Studi di Bari /// \author Fabrizio Grosa , CERN +/// \author Fabio Catalano , CERN #include @@ -55,6 +56,13 @@ enum Event : uint8_t { enum DecayChannel : uint8_t { B0ToDminusPi = 0, BplusToD0barPi, + BsToDsminusPi +}; + +enum WrongCollisionType : uint8_t { + None = 0, + WrongAssociation, + SplitCollision, }; /// Creation of CharmHad-Pi pairs for Beauty hadrons @@ -75,6 +83,11 @@ struct HfDataCreatorCharmHadPiReduced { 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; @@ -86,6 +99,11 @@ struct HfDataCreatorCharmHadPiReduced { Produces rowHfD0PiMcCheckReduced; Produces rowHfBpMcGenReduced; + Produces rowCandidateConfigBs; + Produces rowHfDsPiMcRecReduced; + Produces rowHfDsPiMcCheckReduced; + Produces rowHfBsMcGenReduced; + // vertexing // Configurable bz{"bz", 5., "magnetic field"}; Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; @@ -102,6 +120,7 @@ struct HfDataCreatorCharmHadPiReduced { 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"}; @@ -136,30 +155,43 @@ struct HfDataCreatorCharmHadPiReduced { o2::vertexing::DCAFitterN<3> df3; o2::vertexing::DCAFitterN<2> df2; - using TracksPidPi = soa::Join; - using TracksPidWithSel = soa::Join; + 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 CandsD0Filtered = soa::Filtered>; - using CandsD0FilteredWithMl = 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; + std::shared_ptr hCandidatesD0, hCandidatesDPlus, hCandidatesDs; 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&) { - std::array doProcess = {doprocessDplusPiData, doprocessDplusPiDataWithMl, doprocessDplusPiMc, doprocessDplusPiMcWithMl, doprocessD0PiData, doprocessD0PiDataWithMl, doprocessD0PiMc, doprocessD0PiMcWithMl}; + std::array doProcess = {doprocessDplusPiData, doprocessDplusPiDataWithMl, doprocessDplusPiMc, doprocessDplusPiMcWithMl, + doprocessDsPiData, doprocessDsPiDataWithMl, doprocessDsPiMc, doprocessDsPiMcWithMl, + doprocessD0PiData, doprocessD0PiDataWithMl, doprocessD0PiMc, doprocessD0PiMcWithMl}; 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!"); } @@ -169,6 +201,9 @@ struct HfDataCreatorCharmHadPiReduced { if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { massC = MassDMinus; massB = MassB0; + } else if (doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiMc || doprocessDsPiMcWithMl) { + massC = MassDS; + massB = MassBS; } else if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiMc || doprocessD0PiMcWithMl) { massC = MassD0; massB = MassBPlus; @@ -177,7 +212,8 @@ struct HfDataCreatorCharmHadPiReduced { invMass2ChHadPiMax = (massB + invMassWindowCharmHadPi) * (massB + invMassWindowCharmHadPi); // Initialize fitter - if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { + if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl || + doprocessDsPiData || doprocessDsPiDataWithMl || doprocessDsPiMc || doprocessDsPiMcWithMl) { df3.setPropagateToPCA(propagateToPCA); df3.setMaxR(maxR); df3.setMaxDZIni(maxDZIni); @@ -215,36 +251,35 @@ struct HfDataCreatorCharmHadPiReduced { registry.get(HIST("hEvents"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } - std::string charmHadInvMassTitle = ""; - std::string charmHadTitle0 = ""; - std::string charmHadTitle1 = ""; - std::string histMassTitle0 = ""; - std::string histMassTitle1 = ""; + std::string charmHadTitle = ""; + std::string histMassTitle = ""; if (doprocessDplusPiData || doprocessDplusPiDataWithMl || doprocessDplusPiMc || doprocessDplusPiMcWithMl) { - charmHadTitle0 = "D^{#plus}"; - histMassTitle0 = "Dplus"; - charmHadInvMassTitle = "#it{M}(K#pi#pi)"; + 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) { + 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) { - charmHadTitle0 = "D^{0}"; - charmHadTitle1 = "#overline{D}^{0}"; - histMassTitle0 = "D0"; - histMassTitle1 = "D0bar"; - charmHadInvMassTitle = "#it{M}(K#pi)"; + 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(Form("hMass%s", histMassTitle0.data()), Form("%s candidates; %s (GeV/#it{c}^{2});entries", charmHadTitle0.data(), charmHadInvMassTitle.data()), {HistType::kTH1F, {{500, 0., 5.}}}); - if (doprocessD0PiData || doprocessD0PiDataWithMl || doprocessD0PiMc || doprocessD0PiMcWithMl) { - registry.add(Form("hMass%s", histMassTitle1.data()), Form("%s candidates; %s (GeV/#it{c}^{2});entries", charmHadTitle1.data(), charmHadInvMassTitle.data()), {HistType::kTH1F, {{500, 0., 5.}}}); - } - registry.add(Form("hPt%s", histMassTitle0.data()), Form("%s candidates candidates;%s candidate #it{p}_{T} (GeV/#it{c});entries", charmHadTitle0.data(), charmHadTitle0.data()), {HistType::kTH1F, {{100, 0., 10.}}}); + 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", histMassTitle0.data()), Form("%s candidates;%s cosine of pointing angle;entries", charmHadTitle0.data(), charmHadTitle0.data()), {HistType::kTH1F, {{110, -1.1, 1.1}}}); + 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}}}); /// candidate monitoring - hCandidatesD0 = registry.add("hCandidatesD0", "D candidate counter", {HistType::kTH1D, {axisCands}}); - hCandidatesDPlus = registry.add("hCandidatesDPlus", "B candidate counter", {HistType::kTH1D, {axisCands}}); + 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}}); setLabelHistoCands(hCandidatesD0); setLabelHistoCands(hCandidatesDPlus); + setLabelHistoCands(hCandidatesDs); } /// Pion selection (D Pi <-- B0) @@ -295,21 +330,62 @@ struct HfDataCreatorCharmHadPiReduced { 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. + 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; + } + + /// 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 (bachelor pion in last position) /// \param indexHfCandCharm is the index of the charm-hadron candidate /// \param selectedTracksPion is the map with the indices of selected bachelor pion tracks - template - void fillMcRecoInfo(const PParticles& particlesMc, + template + void fillMcRecoInfo(const CColl& collision, + const PParticles& particlesMc, const std::vector& vecDaughtersB, int& indexHfCandCharm, - std::map selectedTracksPion) + std::map selectedTracksPion, + const int64_t indexCollisionMaxNumContrib) { // we check the MC matching to be stored int8_t sign{0}; int8_t flag{0}; + int8_t flagWrongCollision{WrongCollisionType::None}; int8_t debug{0}; int pdgCodeBeautyMother{-1}; int pdgCodeCharmMother{-1}; @@ -337,6 +413,7 @@ struct HfDataCreatorCharmHadPiReduced { if (indexMother >= 0) { auto particleMother = particlesMc.rawIteratorAt(indexMother); motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); } } @@ -353,6 +430,17 @@ 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); + 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) { + flag = sign * BIT(hf_cand_b0::DecayTypeMc::BsToDsPiToKKPiPi); + } + } + } // 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) { @@ -363,7 +451,7 @@ struct HfDataCreatorCharmHadPiReduced { // b-hadron hypothesis std::array bHadronMotherHypos = {Pdg::kB0, Pdg::kBS, Pdg::kLambdaB0}; // c-hadron hypothesis - std::array cHadronMotherHypos = {Pdg::kDPlus, Pdg::kDS, Pdg::kDStar}; + std::array cHadronMotherHypos = {Pdg::kDPlus, Pdg::kDS, Pdg::kDStar, Pdg::kLambdaCPlus}; for (const auto& bHadronMotherHypo : bHadronMotherHypos) { int index0Mother = RecoDecay::getMother(particlesMc, particleProng0, bHadronMotherHypo, true); @@ -397,6 +485,7 @@ struct HfDataCreatorCharmHadPiReduced { // 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()); } } @@ -408,12 +497,132 @@ struct HfDataCreatorCharmHadPiReduced { } rowHfDPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); } - rowHfDPiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, debug, motherPt); + 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); + 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() == 2) { + 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::BsToDsPiToPhiPiPiToKKPiPi); + } 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::BsToDsPiToK0starKPiToKKPiPi); + } + } + } 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); + } + } + + // additional checks for correlated backgrounds + if (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); + 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() == 2) { + 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::B0ToDsPiToPhiPiPiToKKPiPi); + } 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::B0ToDsPiToK0starKPiToKKPiPi); + } + } + } + } + } + // 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::kDSStar, 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_bs::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 || 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); + 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 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; + } + } + } + } + rowHfDsPiMcCheckReduced(pdgCodeBeautyMother, pdgCodeCharmMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2, pdgCodeProng3); + } + 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); if (indexRec > -1) { - // Printf("Checking D0bar → K+ π-"); + // 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::DecayType::BplusToD0Pi); @@ -426,10 +635,9 @@ struct HfDataCreatorCharmHadPiReduced { if (indexMother >= 0) { auto particleMother = particlesMc.rawIteratorAt(indexMother); motherPt = particleMother.pt(); + checkWrongCollision(particleMother, collision, indexCollisionMaxNumContrib, flagWrongCollision); } } - rowHfD0PiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, debug, motherPt); - // additional checks for correlated backgrounds if (checkDecayTypeMc) { // Partly reconstructed decays, i.e. the 3 prongs have a common b-hadron ancestor @@ -462,6 +670,7 @@ struct HfDataCreatorCharmHadPiReduced { } rowHfD0PiMcCheckReduced(pdgCodeBeautyMother, pdgCodeProng0, pdgCodeProng1, pdgCodeProng2); } + rowHfD0PiMcRecReduced(indexHfCandCharm, selectedTracksPion[vecDaughtersB.back().globalIndex()], flag, flagWrongCollision, debug, motherPt); } } @@ -471,6 +680,7 @@ struct HfDataCreatorCharmHadPiReduced { aod::TrackAssoc const& trackIndices, TTracks const&, PParticles const& particlesMc, + uint64_t const& indexCollisionMaxNumContrib, aod::BCsWithTimestamps const&) { // helpers for ReducedTables filling @@ -509,6 +719,18 @@ struct HfDataCreatorCharmHadPiReduced { 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) { + invMassC0 = hfHelper.invMassDsToKKPi(candC); + registry.fill(HIST("hMassDsToKKPi"), invMassC0); + } + if (candC.isSelDsToPiKK() >= 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) { @@ -547,7 +769,7 @@ struct HfDataCreatorCharmHadPiReduced { } // third track, if it's a 3-prong - if constexpr (decChannel == DecayChannel::B0ToDminusPi) { + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { charmHadDauTracks.push_back(candC.template prong2_as()); trackParCov2 = getTrackParCov(charmHadDauTracks[2]); pVec2 = charmHadDauTracks[2].pVector(); @@ -562,19 +784,32 @@ struct HfDataCreatorCharmHadPiReduced { // reconstruct charm candidate secondary vertex o2::track::TrackParCov trackParCovCharmHad{}; std::array pVecCharm{}; - if constexpr (decChannel == DecayChannel::B0ToDminusPi) { // D∓ → π∓ K± π∓ + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ + + if constexpr (decChannel == DecayChannel::B0ToDminusPi) { + hCandidatesDPlus->Fill(SVFitting::BeforeFit); + } else { + hCandidatesDs->Fill(SVFitting::BeforeFit); + } - hCandidatesDPlus->Fill(SVFitting::BeforeFit); try { if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { continue; } } catch (const std::runtime_error& error) { LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; - hCandidatesDPlus->Fill(SVFitting::Fail); + if constexpr (decChannel == DecayChannel::B0ToDminusPi) { + hCandidatesDPlus->Fill(SVFitting::Fail); + } else { + hCandidatesDs->Fill(SVFitting::Fail); + } continue; } - hCandidatesDPlus->Fill(SVFitting::FitOk); + if constexpr (decChannel == DecayChannel::B0ToDminusPi) { + hCandidatesDPlus->Fill(SVFitting::FitOk); + } else { + hCandidatesDs->Fill(SVFitting::FitOk); + } auto secondaryVertexCharm = df3.getPCACandidate(); trackParCov0.propagateTo(secondaryVertexCharm[0], bz); @@ -610,6 +845,26 @@ struct HfDataCreatorCharmHadPiReduced { trackParCovCharmHad.setAbsCharge(0); // to be sure } + float ptDauMin = 1.e6, etaDauMin = 999.f, chi2TpcDauMax = -1.f; + int nItsClsDauMin = 8, nTpcCrossRowsDauMin = 200; + for (const auto& charmHadTrack : charmHadDauTracks) { + if (charmHadTrack.pt() < ptDauMin) { + ptDauMin = charmHadTrack.pt(); + } + if (std::abs(charmHadTrack.eta()) < etaDauMin) { + etaDauMin = std::abs(charmHadTrack.eta()); + } + if (charmHadTrack.itsNCls() < nItsClsDauMin) { + nItsClsDauMin = charmHadTrack.itsNCls(); + } + if (charmHadTrack.tpcNClsCrossedRows() < nTpcCrossRowsDauMin) { + nTpcCrossRowsDauMin = charmHadTrack.tpcNClsCrossedRows(); + } + if (charmHadTrack.tpcChi2NCl() > chi2TpcDauMax) { + chi2TpcDauMax = charmHadTrack.tpcChi2NCl(); + } + } + for (const auto& trackId : trackIndices) { auto trackPion = trackId.template track_as(); @@ -623,7 +878,7 @@ struct HfDataCreatorCharmHadPiReduced { } // reject pi D with same sign as D - if constexpr (decChannel == DecayChannel::B0ToDminusPi) { // D∓ → π∓ K± π∓ + if constexpr (decChannel == DecayChannel::B0ToDminusPi || decChannel == DecayChannel::BsToDsminusPi) { // D∓ → π∓ K± π∓ and Ds∓ → K∓ K± π∓ if (trackPion.sign() * charmHadDauTracks[0].sign() > 0) { continue; } @@ -651,7 +906,8 @@ struct HfDataCreatorCharmHadPiReduced { hfTrackPion(trackPion.globalIndex(), indexHfReducedCollision, trackParCovPion.getX(), trackParCovPion.getAlpha(), trackParCovPion.getY(), trackParCovPion.getZ(), trackParCovPion.getSnp(), - trackParCovPion.getTgl(), trackParCovPion.getQ2Pt()); + 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(), @@ -672,26 +928,41 @@ struct HfDataCreatorCharmHadPiReduced { beautyHadDauTracks.push_back(track); } beautyHadDauTracks.push_back(trackPion); - fillMcRecoInfo(particlesMc, beautyHadDauTracks, indexHfCandCharm, selectedTracksPion); + 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) { // D∓ → π∓ K± π∓ + 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); + 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()); if constexpr (withMl) { - hfCand3ProngMl(candC.mlProbDplusToPiKPi()[0], candC.mlProbDplusToPiKPi()[1], candC.mlProbDplusToPiKPi()[2]); + 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) { + std::copy(candC.mlProbDsToKKPi().begin(), candC.mlProbDsToKKPi().end(), mlScores.begin()); + } + if (candC.mlProbDsToPiKK().size() == 3) { + std::copy(candC.mlProbDsToPiKK().begin(), candC.mlProbDsToPiKK().end(), mlScores.begin() + 3); + } + 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(), @@ -699,23 +970,25 @@ struct HfDataCreatorCharmHadPiReduced { trackParCovCharmHad.getX(), trackParCovCharmHad.getAlpha(), trackParCovCharmHad.getY(), trackParCovCharmHad.getZ(), trackParCovCharmHad.getSnp(), trackParCovCharmHad.getTgl(), trackParCovCharmHad.getQ2Pt(), - candC.xSecondaryVertex(), candC.ySecondaryVertex(), candC.zSecondaryVertex(), invMassC0, invMassC1); + 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()); if constexpr (withMl) { - std::array bdtScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; + std::array mlScores = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f}; if (candC.mlProbD0().size() == 3) { - std::copy(candC.mlProbD0().begin(), candC.mlProbD0().end(), bdtScores.begin()); + std::copy(candC.mlProbD0().begin(), candC.mlProbD0().end(), mlScores.begin()); } if (candC.mlProbD0bar().size() == 3) { - std::copy(candC.mlProbD0bar().begin(), candC.mlProbD0bar().end(), bdtScores.begin() + 3); + std::copy(candC.mlProbD0bar().begin(), candC.mlProbD0bar().end(), mlScores.begin() + 3); } - - hfCand2ProngMl(bdtScores[0], bdtScores[1], bdtScores[2], bdtScores[3], bdtScores[4], bdtScores[5]); + hfCand2ProngMl(mlScores[0], mlScores[1], mlScores[2], mlScores[3], mlScores[4], mlScores[5]); } } fillHfReducedCollision = true; @@ -728,11 +1001,12 @@ struct HfDataCreatorCharmHadPiReduced { 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()); + hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); hfReducedCollExtra(collision.covXX(), collision.covXY(), collision.covYY(), - collision.covXZ(), collision.covYZ(), collision.covZZ(), - bz); + collision.covXZ(), collision.covYZ(), collision.covZZ()); } template @@ -775,9 +1049,84 @@ struct HfDataCreatorCharmHadPiReduced { rowHfB0McGenReduced(flag, ptParticle, yParticle, etaParticle, ptProngs[0], yProngs[0], etaProngs[0], ptProngs[1], yProngs[1], etaProngs[1]); + } else if constexpr (decayChannel == DecayChannel::BsToDsminusPi) { + // Bs → Ds- π+ + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBS, std::array{-static_cast(Pdg::kDS), +kPiPlus}, true)) { + // Match Ds- -> π- K+ π- + auto candCMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(particlesMc, candCMC, -static_cast(Pdg::kDS), std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2)) { + std::vector arrDaughDsIndex; + std::array arrPDGDaughDs; + RecoDecay::getDaughters(candCMC, &arrDaughDsIndex, std::array{0}, 1); + if (arrDaughDsIndex.size() == 2) { + for (auto jProng = 0u; jProng < arrDaughDsIndex.size(); ++jProng) { + auto daughJ = particlesMc.rawIteratorAt(arrDaughDsIndex[jProng]); + arrPDGDaughDs[jProng] = std::abs(daughJ.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::BsToDsPiToPhiPiPiToKKPiPi); + } 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::BsToDsPiToK0starKPiToKKPiPi); + } + } + } + } + + // additional checks for correlated backgrounds + if (checkDecayTypeMc) { + // B0 → Ds- π+ + if (!flag) { + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kB0, std::array{-static_cast(Pdg::kDS), +kPiPlus}, true)) { + // Match Ds- -> π- K+ π- + auto candCMC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); + if (RecoDecay::isMatchedMCGen(particlesMc, candCMC, -static_cast(Pdg::kDS), std::array{-kKPlus, +kKPlus, -kPiPlus}, true, &sign, 2)) { + std::vector arrDaughDsIndex; + std::array arrPDGDaughDs; + RecoDecay::getDaughters(candCMC, &arrDaughDsIndex, std::array{0}, 1); + if (arrDaughDsIndex.size() == 2) { + for (auto jProng = 0u; jProng < arrDaughDsIndex.size(); ++jProng) { + auto daughJ = particlesMc.rawIteratorAt(arrDaughDsIndex[jProng]); + arrPDGDaughDs[jProng] = std::abs(daughJ.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::B0ToDsPiToPhiPiPiToKKPiPi); + } 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::B0ToDsPiToK0starKPiToKKPiPi); + } + } + } + } + } + } + + // save information for Bs task + if (!TESTBIT(std::abs(flag), hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi) && !TESTBIT(std::abs(flag), hf_cand_bs::DecayTypeMc::BsToDsPiToK0starKPiToKKPiPi) && + !TESTBIT(std::abs(flag), hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi) && !TESTBIT(std::abs(flag), hf_cand_bs::DecayTypeMc::B0ToDsPiToK0starKPiToKKPiPi)) { + 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++; + } + rowHfBsMcGenReduced(flag, ptParticle, yParticle, etaParticle, + ptProngs[0], yProngs[0], etaProngs[0], + ptProngs[1], yProngs[1], etaProngs[1]); } else if constexpr (decayChannel == DecayChannel::BplusToD0barPi) { // B+ → D0bar π+ - if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBPlus, std::array{static_cast(Pdg::kD0), +kPiPlus}, true)) { + if (RecoDecay::isMatchedMCGen(particlesMc, particle, Pdg::kBPlus, std::array{-static_cast(Pdg::kD0), +kPiPlus}, true)) { // Match D0bar -> π- K+ auto candD0MC = particlesMc.rawIteratorAt(particle.daughtersIds().front()); // Printf("Checking D0bar -> π- K+"); @@ -833,12 +1182,12 @@ 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); + 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, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -863,18 +1212,78 @@ 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); + 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, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions 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, + CandsDsFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(selectionFlagDs.value, 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(candsDplusPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(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); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiData, "Process DsPi without MC info and without ML info", true); + + void processDsPiDataWithMl(soa::Join const& collisions, + CandsDsFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSel const& tracks, + aod::BCsWithTimestamps const& bcs) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(selectionFlagDs.value, 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(candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(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); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiDataWithMl, "Process DsPi without MC info and with ML info", false); + void processD0PiData(soa::Join const& collisions, CandsD0Filtered const& candsC, aod::TrackAssoc const& trackIndices, @@ -893,12 +1302,12 @@ 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); + 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, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -923,12 +1332,12 @@ 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); + 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, bcs); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, tracks, -1, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -938,12 +1347,13 @@ struct HfDataCreatorCharmHadPiReduced { //////////////////////////////////////////////////////////////////////////////////////////////////// // PROCESS FUNCTIONS FOR MC - void processDplusPiMc(soa::Join const& collisions, + void processDplusPiMc(CollisionsWMcLabels const& collisions, CandsDplusFiltered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + aod::BCsWithTimestamps const& bcs, + McCollisions const&) { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { @@ -957,12 +1367,14 @@ 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); + 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, particlesMc, bcs); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -970,12 +1382,13 @@ struct HfDataCreatorCharmHadPiReduced { } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiMc, "Process DplusPi with MC info and without ML info", false); - void processDplusPiMcWithMl(soa::Join const& collisions, + void processDplusPiMcWithMl(CollisionsWMcLabels const& collisions, CandsDplusFilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + aod::BCsWithTimestamps const& bcs, + McCollisions const&) { // store configurables needed for B0 workflow if (!isHfCandBhadConfigFilled) { @@ -989,12 +1402,14 @@ 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); + 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, particlesMc, bcs); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -1002,12 +1417,83 @@ struct HfDataCreatorCharmHadPiReduced { } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDplusPiMcWithMl, "Process DplusPi with MC info and with ML info", false); - void processD0PiMc(soa::Join const& collisions, + void processDsPiMc(CollisionsWMcLabels const& collisions, + CandsDsFiltered const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + aod::BCsWithTimestamps const& bcs, + McCollisions const&) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(selectionFlagDs.value, 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(candsDplusPerCollision, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + 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); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiMc, "Process DsPi with MC info and without ML info", false); + + void processDsPiMcWithMl(CollisionsWMcLabels const& collisions, + CandsDsFilteredWithMl const& candsC, + aod::TrackAssoc const& trackIndices, + TracksPidWithSelAndMc const& tracks, + aod::McParticles const& particlesMc, + aod::BCsWithTimestamps const& bcs, + McCollisions const&) + { + // store configurables needed for Bs workflow + if (!isHfCandBhadConfigFilled) { + rowCandidateConfigBs(selectionFlagDs.value, 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(candsDplusPerCollisionWithMl, thisCollId); + auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + 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); + } + PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processDsPiMcWithMl, "Process DsPi with MC info and with ML info", false); + + void processD0PiMc(CollisionsWMcLabels const& collisions, CandsD0Filtered const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + aod::BCsWithTimestamps const& bcs, + McCollisions const&) { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { @@ -1021,12 +1507,14 @@ 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); + 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, particlesMc, bcs); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -1034,12 +1522,13 @@ struct HfDataCreatorCharmHadPiReduced { } PROCESS_SWITCH(HfDataCreatorCharmHadPiReduced, processD0PiMc, "Process D0Pi with MC info and without ML info", false); - void processD0PiMcWithMl(soa::Join const& collisions, + void processD0PiMcWithMl(CollisionsWMcLabels const& collisions, CandsD0FilteredWithMl const& candsC, aod::TrackAssoc const& trackIndices, TracksPidWithSelAndMc const& tracks, aod::McParticles const& particlesMc, - aod::BCsWithTimestamps const& bcs) + aod::BCsWithTimestamps const& bcs, + McCollisions const&) { // store configurables needed for B+ workflow if (!isHfCandBhadConfigFilled) { @@ -1053,12 +1542,14 @@ 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); + 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, particlesMc, bcs); + auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); + int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + runDataCreation(collision, candsCThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx index db67cc88983..e39e9eab1ff 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx @@ -15,8 +15,11 @@ /// \author Luca Aglietta , UniTO Turin /// \author Fabrizio Grosa , CERN +#include #include #include +#include +#include #include "DetectorsBase/Propagator.h" #include "CommonConstants/PhysicsConstants.h" @@ -73,10 +76,29 @@ enum DType : uint8_t { Dstar }; +enum DecayTypeMc : uint8_t { + Ds1ToDStarK0ToD0PiK0s = 1, + Ds2StarToDplusK0sToPiKaPiPiPi, + Ds1ToDStarK0ToDPlusPi0K0s, + Ds1ToDStarK0ToD0PiK0sPart, + Ds1ToDStarK0ToD0NoPiK0sPart, + Ds1ToDStarK0ToD0PiK0sOneMu, + Ds2StarToDplusK0sOneMu +}; + +enum PartialMatchMc : uint8_t { + K0Matched = 0, + D0Matched, + DStarMatched, + DPlusMatched, + K0MuMatched, + DStarMuMatched +}; + /// Creation of D-V0 pairs struct HfDataCreatorCharmResoReduced { - // Produces AOD tables to store track information + // Produces AOD tables to store collision information 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 @@ -85,6 +107,9 @@ struct HfDataCreatorCharmResoReduced { Produces hfCandD; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h // ML optional Tables Produces hfCandDMl; // Defined in PWGHF/D2H/DataModel/ReducedDataModel.h + // MC Tables + Produces rowHfDV0McRecReduced; + Produces rowHfResoMcGenReduced; // CCDB configuration o2::ccdb::CcdbApi ccdbApi; @@ -92,6 +117,7 @@ struct HfDataCreatorCharmResoReduced { 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 @@ -104,15 +130,20 @@ struct HfDataCreatorCharmResoReduced { // selection V0 struct : ConfigurableGroup { std::string prefix = "v0s"; - Configurable minK0sLambdaCosinePa{"minK0sLambdaCosinePa", 0.97, "minimum cosp for K0S and Lambda"}; - Configurable minK0sLambdaRadius{"minK0sLambdaRadius", 0.5, "minimum radius for K0S and Lambda"}; - Configurable deltaMassK0s{"deltaMassK0s", 0.03, "delta mass cut for K0S"}; - Configurable deltaMassLambda{"deltaMassLambda", 0.015, "delta mass cut for Lambda"}; - Configurable minV0dauEta{"minV0dauEta", 1., "minimum eta for V0 daughters"}; - Configurable maxV0DCA{"maxV0DCA", 0.1, "maximum DCA for K0S and Lambda"}; - Configurable minV0dauDCA{"minV0dauDCA", 0.05, "minimum DCA for V0 daughters"}; - Configurable maxV0dauDCA{"maxV0dauDCA", 1., "maximum DCA for V0 daughters"}; - Configurable maxNsigmaPrForLambda{"maxNsigmaPrForLambda", 4., "maximum proton NSigma in TPC and TOF for Lambdas"}; + Configurable deltaMassK0s{"deltaMassK0s", 0.02, "delta mass cut for K0S"}; + Configurable deltaMassLambda{"deltaMassLambda", 0.01, "delta mass cut for Lambda"}; + Configurable etaMax{"etaMax", 0.8f, "maximum eta"}; + Configurable etaMaxDau{"etaMaxDau", 5.f, "maximum eta V0 daughters"}; + 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 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"}; + Configurable cosPa{"cosPa", 0.99f, "V0 CosPA"}; + Configurable radiusMin{"radiusMin", 0.9f, "Minimum v0 radius accepted"}; + Configurable nSigmaTpc{"nSigmaTpc", 4.f, "Nsigmatpc"}; + Configurable nSigmaTofPr{"nSigmaTofPr", 4.f, "N sigma TOF for protons only"}; } cfgV0Cuts; // selection single tracks @@ -134,14 +165,44 @@ struct HfDataCreatorCharmResoReduced { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; HfHelper hfHelper; o2::hf_evsel::HfEventSelection hfEvSel; + o2::vertexing::DCAFitterN<2> fitter; + double bz{0.}; + Service pdg; - bool isHfCandResoConfigFilled = false; + // bool isHfCandResoConfigFilled = false; + // Helper struct to pass V0 informations + struct { + std::array pos; + std::array mom; + std::array momPos; + std::array momNeg; + float pT; + float cosPA; + float dcaV0ToPv; + float dcaDau; + float alpha; + float eta; + float radius; + float mK0Short; + float mLambda; + uint8_t v0Type; + } candidateV0; + + struct { + float invMassD; + float ptD; + float invMassDdau; + float invMassKPiPiV0; + float ptReso; + } varUtils; using CandsDplusFiltered = soa::Filtered>; using CandsDplusFilteredWithMl = soa::Filtered>; using CandDstarFiltered = soa::Filtered>; using CandDstarFilteredWithMl = soa::Filtered>; - using TracksWithPID = soa::Join; + using TracksWithPID = soa::Join; + using TracksIUWithPID = soa::Join; + using TracksIUWithPIDAndMC = soa::Join; Filter filterSelectDplus = (aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= cfgDmesCuts.selectionFlagDplus); Filter filterSelectedCandDstar = (aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == cfgDmesCuts.selectionFlagDstarToD0Pi); @@ -150,7 +211,7 @@ struct HfDataCreatorCharmResoReduced { Preslice candsDplusPerCollisionWithMl = aod::hf_cand::collisionId; Preslice candsDstarPerCollision = aod::hf_cand::collisionId; Preslice candsDstarPerCollisionWithMl = aod::hf_cand::collisionId; - Preslice candsV0PerCollision = aod::v0data::collisionId; + Preslice candsV0PerCollision = aod::v0::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; HistogramRegistry registry{"registry"}; @@ -170,12 +231,13 @@ struct HfDataCreatorCharmResoReduced { } const AxisSpec axisPt{50, 0.f, 50.f, ""}; - const AxisSpec axisP{10, 0.f, 10.f, ""}; - const AxisSpec axisDeDx{500, 0.f, 2000.f, ""}; + const AxisSpec axisP{100, 0.f, 10.f, ""}; + 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}}); @@ -186,72 +248,228 @@ struct HfDataCreatorCharmResoReduced { 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, {{400, 0.49, 0.89}}}); - registry.add("hMassDsStar2", "Ds^{*}2 candidates; Ds^{*}2 - m_{D^{#plus}} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{400, 0.49, 0.89}}}); + 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("hV0Type", "V0 selection flag", {HistType::kTH1F, {{8, -0.5, 7.5}}}); 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}}); + } + + // Configure CCDB access ccdb->setURL(url.value); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); ccdbApi.init(url); + runNumber = 0; lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + + // Configure DCA fitter + fitter.setPropagateToPCA(true); + fitter.setMaxR(200.); + fitter.setMinParamChange(1e-3); + fitter.setMinRelChi2Change(0.9); + fitter.setMaxDZIni(1e9); + fitter.setMaxDXYIni(4); + fitter.setMaxChi2(1e9); + fitter.setUseAbsDCA(true); + fitter.setWeightedFinalPCA(false); } + /// Basic track quality selections for V0 daughters + /// \param Tr is a track + /// \param dDaughtersIds are the IDs of the D meson daughter tracks + template + bool selectV0Daughter(Tr const& track, const std::array& dDaughtersIds) + { + // acceptance selection + if (std::abs(track.eta()) > cfgV0Cuts.etaMaxDau) { + return false; + } + // Tpc Refit + if (!(track.hasTPC())) { + return false; + } + // track quality selection + if (track.itsNCls() < cfgV0Cuts.trackNclusItsCut || + track.tpcNClsFound() < cfgV0Cuts.trackNCrossedRowsTpc || + track.tpcNClsCrossedRows() < cfgV0Cuts.trackNCrossedRowsTpc || + track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsShared() > cfgV0Cuts.trackNsharedClusTpc) { + return false; + } + // rejection of tracks that share a daughter with the D meson + if (rejectPairsWithCommonDaughter && std::find(dDaughtersIds.begin(), dDaughtersIds.end(), track.globalIndex()) != dDaughtersIds.end()) { + return false; + } + return true; + } + + // Utility to find which v0 daughter carries the largest fraction of the mother longitudinal momentum + 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); + } + // Utility to find DCA of V0 to Primary vertex + 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)); + } /// Basic selection of V0 candidates - /// \param v0 is the v0 candidate /// \param collision is the current collision /// \param dauTracks are the v0 daughter tracks /// \param dDaughtersIds are the IDs of the D meson daughter tracks /// \return a bitmap with mass hypotesis if passes all cuts - template - uint8_t getSelectionMapV0(const V0& v0, const Coll& /*collision*/, const std::array& dauTracks, const std::array& dDaughtersIds) + template + bool buildAndSelectV0(const Coll& collision, const std::array& dDaughtersIds, const std::array& dauTracks) { - uint8_t selMap{BIT(K0s) | BIT(Lambda) | BIT(AntiLambda)}; - // reject VOs that share daughters with D - if (rejectPairsWithCommonDaughter && (std::find(dDaughtersIds.begin(), dDaughtersIds.end(), v0.posTrackId()) != dDaughtersIds.end() || std::find(dDaughtersIds.begin(), dDaughtersIds.end(), v0.negTrackId()) != dDaughtersIds.end())) { - return 0; + 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; + 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) { + return false; + } + // vertex reconstruction + auto trackPosCov = getTrackParCov(trackPos); + auto trackNegCov = getTrackParCov(trackNeg); + int nCand = 0; + try { + nCand = fitter.process(trackPosCov, trackNegCov); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return false; + } + if (nCand == 0) { + return false; + } + // compute candidate momentum from tracks propagated to decay vertex + auto& trackPosProp = fitter.getTrack(0); + 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.pT = std::hypot(candidateV0.mom[0], candidateV0.mom[1]); + // topological selections: + // v0 eta + candidateV0.eta = RecoDecay::eta(candidateV0.mom); + if (std::abs(candidateV0.eta) > cfgV0Cuts.etaMax) { + return false; + } + // daughters DCA + candidateV0.dcaDau = std::sqrt(fitter.getChi2AtPCACandidate()); + if (candidateV0.dcaDau > cfgV0Cuts.dcaDau) { + return false; } - // eta of daughters - if (std::fabs(v0.negativeeta()) > cfgV0Cuts.minV0dauEta || std::fabs(v0.positiveeta()) > cfgV0Cuts.minV0dauEta) { // cut all V0 daughters with |eta| > 1. - return 0; + // v0 radius + const auto& vtx = fitter.getPCACandidate(); + candidateV0.radius = std::hypot(vtx[0], vtx[1]); + if (candidateV0.radius < cfgV0Cuts.radiusMin) { + return false; } - // minimum v0radius - if (v0.v0radius() < cfgV0Cuts.minK0sLambdaRadius) { - return 0; + for (int i = 0; i < 3; i++) { + candidateV0.pos[i] = vtx[i]; } - // cosine of pointing angle - auto v0CosinePa = v0.v0cosPA(); - if (v0CosinePa < cfgV0Cuts.minK0sLambdaCosinePa) { - return 0; + // v0 DCA to primary vertex + candidateV0.dcaV0ToPv = calculateDCAStraightToPV( + vtx[0], vtx[1], vtx[2], + candidateV0.momPos[0] + candidateV0.momNeg[0], + candidateV0.momPos[1] + candidateV0.momNeg[1], + candidateV0.momPos[2] + candidateV0.momNeg[2], + collision.posX(), collision.posY(), collision.posZ()); + if (std::abs(candidateV0.dcaV0ToPv) > cfgV0Cuts.dcaPv) { + return false; } - // DCA V0 and V0 daughters to select for primary V0s - if (v0.dcav0topv() > cfgV0Cuts.maxV0DCA || v0.dcaV0daughters() > cfgV0Cuts.maxV0dauDCA || std::fabs(v0.dcapostopv()) < cfgV0Cuts.minV0dauDCA || std::fabs(v0.dcanegtopv()) < cfgV0Cuts.minV0dauDCA) { - return 0; + // v0 cosine of pointing angle + std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; + candidateV0.cosPA = RecoDecay::cpa(primVtx, vtx, candidateV0.mom); + if (candidateV0.cosPA < cfgV0Cuts.cosPa) { + return false; } + + // distinguish between K0s, and Lambda hypotesys + candidateV0.v0Type = {BIT(K0s) | BIT(Lambda) | BIT(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); + auto massPos = matter ? o2::constants::physics::MassProton : o2::constants::physics::MassPionCharged; + auto massNeg = matter ? o2::constants::physics::MassPionCharged : o2::constants::physics::MassProton; // mass hypotesis - if (std::fabs(v0.mK0Short() - MassK0) > cfgV0Cuts.deltaMassK0s) { - CLRBIT(selMap, K0s); + 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); } - if (std::fabs(v0.mLambda() - MassLambda0) > cfgV0Cuts.deltaMassLambda) { - CLRBIT(selMap, Lambda); + if (std::fabs(candidateV0.mLambda - MassLambda0) > cfgV0Cuts.deltaMassLambda) { + CLRBIT(candidateV0.v0Type, Lambda); + CLRBIT(candidateV0.v0Type, AntiLambda); } - if (std::fabs(v0.mAntiLambda() - MassLambda0) > cfgV0Cuts.deltaMassLambda) { - CLRBIT(selMap, AntiLambda); + // PID + if (TESTBIT(candidateV0.v0Type, K0s)) { + if ((trackPos.hasTPC() && std::fabs(trackPos.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc) || + (trackNeg.hasTPC() && std::fabs(trackNeg.tpcNSigmaPi()) > cfgV0Cuts.nSigmaTpc)) + CLRBIT(candidateV0.v0Type, K0s); } - // PID (Lambda/AntiLambda only) - float nSigmaPrTpc[2] = {dauTracks[0].tpcNSigmaPr(), dauTracks[1].tpcNSigmaPr()}; - float nSigmaPrTof[2] = {dauTracks[0].tofNSigmaPr(), dauTracks[1].tofNSigmaPr()}; - if (TESTBIT(selMap, Lambda) && ((dauTracks[0].hasTPC() && std::fabs(nSigmaPrTpc[0]) > cfgV0Cuts.maxNsigmaPrForLambda) || (dauTracks[0].hasTOF() && std::fabs(nSigmaPrTof[0]) > cfgV0Cuts.maxNsigmaPrForLambda))) { - CLRBIT(selMap, Lambda); + if (TESTBIT(candidateV0.v0Type, 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); } - if (TESTBIT(selMap, AntiLambda) && ((dauTracks[1].hasTPC() && std::fabs(nSigmaPrTpc[1]) > cfgV0Cuts.maxNsigmaPrForLambda) || (dauTracks[1].hasTOF() && std::fabs(nSigmaPrTof[1]) > cfgV0Cuts.maxNsigmaPrForLambda))) { - CLRBIT(selMap, AntiLambda); + if (TESTBIT(candidateV0.v0Type, 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); } - return selMap; + if (candidateV0.v0Type == 0) { + return false; + } + return true; } /// Basic selection of tracks @@ -262,7 +480,7 @@ struct HfDataCreatorCharmResoReduced { bool isTrackSelected(const Tr& track, const std::array& dDaughtersIds) { - if (rejectPairsWithCommonDaughter && std::find(dDaughtersIds.begin(), dDaughtersIds.end(), track.globalIndex())) { + if (rejectPairsWithCommonDaughter && std::find(dDaughtersIds.begin(), dDaughtersIds.end(), track.globalIndex()) != dDaughtersIds.end()) { return false; } @@ -288,7 +506,7 @@ struct HfDataCreatorCharmResoReduced { return false; } - if (std::abs(track.eta()) < cfgSingleTrackCuts.maxEta) { + if (std::abs(track.eta()) > cfgSingleTrackCuts.maxEta) { return false; } @@ -296,18 +514,233 @@ struct HfDataCreatorCharmResoReduced { return false; } - if (std::abs(track.tpcNSigmaPi()) < cfgSingleTrackCuts.maxNsigmaTpcPi && std::abs(track.tpcNSigmaKa()) < cfgSingleTrackCuts.maxNsigmaTpcKa && std::abs(track.tpcNSigmaPr()) < cfgSingleTrackCuts.maxNsigmaTpcPr) { // we keep the track if is it compatible with at least one of the PID hypotheses selected + 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; } - template + /// Function for filling MC reco information in the tables + /// \param particlesMc is the table with MC particles + /// \param vecDaughtersReso is the vector with all daughter tracks (bachelor pion in last position) + /// \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) + { + + // 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); + } + 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; + } + } + + // 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; + } + } + } + } + } 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; + } + } + } + } + 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(); + } + 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); + } + } + 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); + } + } + 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 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 (flag != 0) { + auto particleReso = particlesMc.iteratorAt(indexRecReso); + origin = RecoDecay::getCharmHadronOrigin(particlesMc, particleReso, false, &idxBhadMothers); + motherPt = particleReso.pt(); + } + 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); + } + } + 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); + } + } + 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); + } + } + } + } // 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 (indexRecDstar > -1) { + SETBIT(debug, PartialMatchMc::DStarMatched); + } + if (indexRecDplus > -1) { + SETBIT(debug, PartialMatchMc::DPlusMatched); + } + registry.fill(HIST("hMCRecDebug"), debug); + } + rowHfDV0McRecReduced(indexHfCandCharm, indexCandV0, flag, debug, origin, signD0, motherPt); + } + + template void runDataCreation(Coll const& collision, CCands const& candsD, BBach const& bachelors, - TracksWithPID const&, + Tr const&, + PParticles const& particlesMc, aod::BCsWithTimestamps const&) { // helpers for ReducedTables filling @@ -318,26 +751,32 @@ struct HfDataCreatorCharmResoReduced { std::map selectedTracks; bool fillHfReducedCollision = false; auto bc = collision.template bc_as(); - initCCDB(bc, runNumber, ccdb, ccdbPathGrpMag, lut, false); + if (runNumber != bc.runNumber()) { + LOG(info) << ">>>>>>>>>>>> Current run number: " << runNumber; + initCCDB(bc, runNumber, ccdb, ccdbPathGrpMag, lut, false); + bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << ">>>>>>>>>>>> Magnetic field: " << bz; + } + fitter.setBz(bz); // loop on D candidates for (const auto& candD : candsD) { // initialize variables depending on decay channel bool fillHfCandD = false; - float invMassD{0.f}, invMassDdau{0.f}; std::array pVecD; std::array pVecProng2; std::array secondaryVertexD; std::array prongIdsD; - uint8_t v0type; int8_t dtype; std::array bdtScores; + std::vector charmHadDauTracks{}; + varUtils.ptD = candD.pt(); if constexpr (DecayChannel == DecayChannel::DstarV0 || DecayChannel == DecayChannel::DstarTrack) { if (candD.signSoftPi() > 0) { - invMassD = candD.invMassDstar(); - invMassDdau = candD.invMassD0(); + varUtils.invMassD = candD.invMassDstar(); + varUtils.invMassDdau = candD.invMassD0(); } else { - invMassD = candD.invMassAntiDstar(); - invMassDdau = candD.invMassD0Bar(); + varUtils.invMassD = candD.invMassAntiDstar(); + varUtils.invMassDdau = candD.invMassD0Bar(); } pVecD = candD.pVector(); secondaryVertexD[0] = candD.xSecondaryVertexD0(); @@ -347,15 +786,17 @@ struct HfDataCreatorCharmResoReduced { 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; if constexpr (withMl) { std::copy(candD.mlProbDstarToD0Pi().begin(), candD.mlProbDstarToD0Pi().end(), bdtScores.begin()); } - registry.fill(HIST("hMassVsPtDstarAll"), candD.pt(), invMassD - invMassDdau); + registry.fill(HIST("hMassVsPtDstarAll"), candD.pt(), varUtils.invMassD - varUtils.invMassDdau); } else if constexpr (DecayChannel == DecayChannel::DplusV0) { - auto prong0 = candD.template prong0_as(); - invMassD = hfHelper.invMassDplusToPiKPi(candD); + auto prong0 = candD.template prong0_as
(); + varUtils.invMassD = hfHelper.invMassDplusToPiKPi(candD); pVecD = candD.pVector(); secondaryVertexD[0] = candD.xSecondaryVertex(); secondaryVertexD[1] = candD.ySecondaryVertex(); @@ -365,111 +806,159 @@ struct HfDataCreatorCharmResoReduced { 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
()); if constexpr (withMl) { - std::copy(candD.mlProbDplusToPiKPi().begin(), candD.mlProbDplusToPiKPi().end(), bdtScores.begin()); + registry.fill(HIST("hMassVsPtDplusAll"), candD.pt(), varUtils.invMassD); } - registry.fill(HIST("hMassVsPtDplusAll"), candD.pt(), invMassD); } // else if + // Get single track variables + float chi2TpcDauMax = -1.f; + int nItsClsDauMin = 8, nTpcCrossRowsDauMin = 200; + for (const auto& charmHadTrack : charmHadDauTracks) { + if (charmHadTrack.itsNCls() < nItsClsDauMin) { + nItsClsDauMin = charmHadTrack.itsNCls(); + } + if (charmHadTrack.tpcNClsCrossedRows() < nTpcCrossRowsDauMin) { + nTpcCrossRowsDauMin = charmHadTrack.tpcNClsCrossedRows(); + } + if (charmHadTrack.tpcChi2NCl() > chi2TpcDauMax) { + chi2TpcDauMax = charmHadTrack.tpcChi2NCl(); + } + } + if constexpr (DecayChannel == DecayChannel::DplusV0 || DecayChannel == DecayChannel::DstarV0) { // Loop on V0 candidates for (const auto& v0 : bachelors) { - auto posTrack = v0.template posTrack_as(); - auto negTrack = v0.template negTrack_as(); + auto trackPos = v0.template posTrack_as
(); + auto trackNeg = v0.template negTrack_as
(); // Apply selsection - v0type = getSelectionMapV0(v0, collision, std::array{posTrack, negTrack}, prongIdsD); - if (v0type == 0) { + auto v0DauTracks = std::array{trackPos, trackNeg}; + if (!buildAndSelectV0(collision, prongIdsD, v0DauTracks)) { continue; } + // Get single track variables + float chi2TpcDauV0Max = -1.f; + int nItsClsDauV0Min = 8, nTpcCrossRowsDauV0Min = 200; + for (const auto& v0Track : v0DauTracks) { + if (v0Track.itsNCls() < nItsClsDauV0Min) { + nItsClsDauV0Min = v0Track.itsNCls(); + } + if (v0Track.tpcNClsCrossedRows() < nTpcCrossRowsDauV0Min) { + nTpcCrossRowsDauV0Min = v0Track.tpcNClsCrossedRows(); + } + if (v0Track.tpcChi2NCl() > chi2TpcDauV0Max) { + chi2TpcDauV0Max = v0Track.tpcChi2NCl(); + } + } // propagate V0 to primary vertex (if enabled) - std::array pVecV0 = {v0.px(), v0.py(), v0.pz()}; if (propagateV0toPV) { - std::array pVecV0Orig = {v0.px(), v0.py(), v0.pz()}; - std::array posVecV0 = {v0.x(), v0.y(), v0.z()}; + std::array pVecV0Orig = {candidateV0.mom[0], candidateV0.mom[1], candidateV0.mom[2]}; gpu::gpustd::array dcaInfo; - auto trackParK0 = o2::track::TrackPar(posVecV0, pVecV0Orig, 0, true); + 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, pVecV0); + getPxPyPz(trackParK0, candidateV0.mom); } - float ptV0 = RecoDecay::pt(pVecV0); // fill histos - float invMassKPiPiV0{0.f}; - if (TESTBIT(v0type, K0s)) { + if (TESTBIT(candidateV0.v0Type, K0s)) { if constexpr (DecayChannel == DecayChannel::DplusV0) { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + 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) { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); } else { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); + varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassK0}); } } - - registry.fill(HIST("hMassVsPtK0s"), ptV0, v0.mK0Short()); + registry.fill(HIST("hMassVsPtK0s"), candidateV0.pT, candidateV0.mK0Short); if constexpr (DecayChannel == DecayChannel::DstarV0) { - registry.fill(HIST("hMassDs1"), invMassKPiPiV0 - invMassD); + registry.fill(HIST("hMassDs1"), varUtils.invMassKPiPiV0 - varUtils.invMassD); } else if constexpr (DecayChannel == DecayChannel::DplusV0) { - registry.fill(HIST("hMassDsStar2"), invMassKPiPiV0 - invMassD); + registry.fill(HIST("hMassDsStar2"), varUtils.invMassKPiPiV0 - varUtils.invMassD); } } - bool isLambda = TESTBIT(v0type, Lambda); - bool isAntiLambda = TESTBIT(v0type, AntiLambda); + bool isLambda = TESTBIT(candidateV0.v0Type, Lambda); + bool isAntiLambda = TESTBIT(candidateV0.v0Type, AntiLambda); if (isLambda || isAntiLambda) { if constexpr (DecayChannel == DecayChannel::DplusV0) { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVectorProng2(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); + 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) { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); + varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng0(), candD.pVectorProng1(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); } else { - invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), pVecV0}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); + varUtils.invMassKPiPiV0 = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), candidateV0.mom}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassLambda0}); } } - if (isLambda) { - registry.fill(HIST("hMassVsPtLambda"), ptV0, v0.mLambda()); - } - if (isAntiLambda) { - registry.fill(HIST("hMassVsPtLambda"), ptV0, v0.mAntiLambda()); + if (isLambda || isAntiLambda) { + registry.fill(HIST("hMassVsPtLambda"), candidateV0.pT, candidateV0.mLambda); } if constexpr (DecayChannel == DecayChannel::DplusV0) { - registry.fill(HIST("hMassXcRes"), invMassKPiPiV0 - invMassD); + registry.fill(HIST("hMassXcRes"), varUtils.invMassKPiPiV0 - varUtils.invMassD); } } // fill V0 table // if information on V0 already stored, go to next V0 if (!selectedV0s.count(v0.globalIndex())) { - hfCandV0(v0.posTrackId(), v0.negTrackId(), + hfCandV0(trackPos.globalIndex(), trackNeg.globalIndex(), indexHfReducedCollision, - v0.x(), v0.y(), v0.z(), - v0.pxpos(), v0.pypos(), v0.pzpos(), - v0.pxneg(), v0.pyneg(), v0.pzneg(), - v0.v0cosPA(), - v0.dcav0topv(), - v0type); + candidateV0.pos[0], candidateV0.pos[1], candidateV0.pos[2], + candidateV0.momPos[0], candidateV0.momPos[1], candidateV0.momPos[2], + candidateV0.momNeg[0], candidateV0.momNeg[1], candidateV0.momNeg[2], + candidateV0.cosPA, + candidateV0.dcaV0ToPv, + nItsClsDauV0Min, nTpcCrossRowsDauV0Min, chi2TpcDauV0Max, + candidateV0.v0Type); selectedV0s[v0.globalIndex()] = hfCandV0.lastIndex(); } fillHfCandD = true; + // Optional filling of MC Rec table + 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); + } } // V0 loop } else if constexpr (DecayChannel == DecayChannel::DstarTrack) { for (const auto& trackIndex : bachelors) { - auto track = trackIndex.template track_as(); + auto track = trackIndex.template track_as
(); 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 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(), track.pVector()}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + 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(), track.pVector()}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); + invMassKPiPiP = RecoDecay::m(std::array{candD.pVectorProng1(), candD.pVectorProng0(), candD.pVecSoftPi(), pVecTrack}, std::array{MassPiPlus, MassKPlus, MassPiPlus, MassProton}); } - registry.fill(HIST("hMassDstarProton"), invMassKPiPiP - invMassD); + registry.fill(HIST("hMassDstarProton"), invMassKPiPiP - varUtils.invMassD); if (!selectedTracks.count(track.globalIndex())) { hfTrackNoParam(indexHfReducedCollision, track.px(), track.py(), track.pz(), track.sign(), track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr(), - track.hasTOF()); + track.hasTOF(), track.hasTPC(), track.itsNCls(), track.tpcNClsCrossedRows(), track.tpcChi2NCl()); selectedTracks[track.globalIndex()] = hfTrackNoParam.lastIndex(); } fillHfCandD = true; @@ -483,15 +972,15 @@ struct HfDataCreatorCharmResoReduced { candD.pxProng0(), candD.pyProng0(), candD.pzProng0(), candD.pxProng1(), candD.pyProng1(), candD.pzProng1(), pVecProng2[0], pVecProng2[1], pVecProng2[2], - dtype); + nItsClsDauMin, nTpcCrossRowsDauMin, chi2TpcDauMax, dtype); if constexpr (withMl) { - hfCandDMl(bdtScores[0], bdtScores[1], bdtScores[2]); + hfCandDMl(bdtScores[0], bdtScores[1], bdtScores[2], -1., -1., -1.); } fillHfReducedCollision = true; - if constexpr (DecayChannel == DecayChannel::DstarV0) { - registry.fill(HIST("hMassVsPtDstarPaired"), candD.pt(), invMassD - invMassDdau); + if constexpr (DecayChannel == DecayChannel::DstarV0 || DecayChannel == DecayChannel::DstarTrack) { + registry.fill(HIST("hMassVsPtDstarPaired"), candD.pt(), varUtils.invMassD - varUtils.invMassDdau); } else if constexpr (DecayChannel == DecayChannel::DplusV0) { - registry.fill(HIST("hMassVsPtDplusPaired"), candD.pt(), invMassD); + registry.fill(HIST("hMassVsPtDplusPaired"), candD.pt(), varUtils.invMassD); } registry.fill(HIST("hDType"), dtype); } @@ -502,14 +991,149 @@ 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()); + hfReducedCollision(collision.posX(), collision.posY(), collision.posZ(), collision.numContrib(), hfRejMap, bz); } // run data creation + template + void runMcGen(aod::McParticles const& particlesMc) + { + // 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; + } + } 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); + } + } + // 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; + } + } + } 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; + } + } + } 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); + } + } + // 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++; + } + 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 + void processDplusV0(soa::Join const& collisions, CandsDplusFiltered const& candsDplus, - aod::V0Datas const& V0s, - TracksWithPID const& tracks, + aod::V0s const& V0s, + TracksIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -518,21 +1142,46 @@ 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); + 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, bcs); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, 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); + void processDplusV0MC(soa::Join const& collisions, + CandsDplusFiltered const& candsDplus, + aod::V0s const& V0s, + TracksIUWithPIDAndMC const& tracks, + aod::McParticles const& particlesMc, + 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 V0sThisColl = V0s.sliceBy(candsV0PerCollision, thisCollId); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, 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); + void processDplusV0WithMl(soa::Join const& collisions, CandsDplusFilteredWithMl const& candsDplus, - aod::V0Datas const& V0s, - TracksWithPID const& tracks, + aod::V0s const& V0s, + TracksIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -541,21 +1190,46 @@ 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); + 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, bcs); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, 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) + { + 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); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, particlesMc, 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::V0Datas const& V0s, - TracksWithPID const& tracks, + aod::V0s const& V0s, + TracksIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -564,21 +1238,46 @@ 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); + 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, bcs); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, 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); + void processDstarV0MC(soa::Join const& collisions, + CandDstarFiltered const& candsDstar, + aod::V0s const& V0s, + TracksIUWithPIDAndMC const& tracks, + aod::McParticles const& particlesMc, + 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, tracks, particlesMc, 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); + void processDstarV0WithMl(soa::Join const& collisions, CandDstarFilteredWithMl const& candsDstar, - aod::V0Datas const& V0s, - TracksWithPID const& tracks, + aod::V0s const& V0s, + TracksIUWithPID const& tracks, aod::BCsWithTimestamps const& bcs) { int zvtxColl{0}; @@ -587,18 +1286,43 @@ 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); + 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, bcs); + runDataCreation(collision, candsDThisColl, V0sThisColl, tracks, tracks, 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) + { + 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, tracks, particlesMc, 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); + void processDstarTrack(soa::Join const& collisions, CandDstarFiltered const& candsDstar, aod::TrackAssoc const& trackIndices, @@ -611,11 +1335,11 @@ 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); + 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, tracks, bcs); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, tracks, tracks, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); @@ -634,12 +1358,12 @@ 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); + 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, tracks, bcs); + runDataCreation(collision, candsDThisColl, trackIdsThisColl, tracks, tracks, bcs); } // handle normalization by the right number of collisions hfCollisionCounter(collisions.tableSize(), zvtxColl, sel8Coll, zvtxAndSel8Coll, zvtxAndSel8CollAndSoftTrig, allSelColl); diff --git a/PWGHF/D2H/Tasks/CMakeLists.txt b/PWGHF/D2H/Tasks/CMakeLists.txt index d9f203b5f2d..b2f78f68334 100644 --- a/PWGHF/D2H/Tasks/CMakeLists.txt +++ b/PWGHF/D2H/Tasks/CMakeLists.txt @@ -29,6 +29,11 @@ o2physics_add_dpl_workflow(task-bplus-reduced PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore 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 SOURCES taskBs.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -39,11 +44,21 @@ 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 + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-d0 SOURCES taskD0.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-directed-flow-charm-hadrons + SOURCES taskDirectedFlowCharmHadrons.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-dplus SOURCES taskDplus.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -61,7 +76,7 @@ o2physics_add_dpl_workflow(task-dstar-to-d0-pi o2physics_add_dpl_workflow(task-flow-charm-hadrons SOURCES taskFlowCharmHadrons.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(task-lb diff --git a/PWGHF/D2H/Tasks/taskB0Reduced.cxx b/PWGHF/D2H/Tasks/taskB0Reduced.cxx index 5e38055f589..d3f81aac980 100644 --- a/PWGHF/D2H/Tasks/taskB0Reduced.cxx +++ b/PWGHF/D2H/Tasks/taskB0Reduced.cxx @@ -36,65 +36,116 @@ namespace o2::aod { namespace hf_cand_b0_lite { -DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Transverse momentum of prong0 (GeV/c) -DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Transverse momentum of prong1 (GeV/c) -DECLARE_SOA_COLUMN(MProng0, mProng0, float); //! Invariant mass of prong0 (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(NSigTpcPi1, nSigTpcPi1, float); //! TPC Nsigma separation for prong1 with pion mass hypothesis -DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF Nsigma separation for prong1 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(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product 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(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(PtD, ptD, float); //! Transverse momentum of D-meson 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 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(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 +DECLARE_SOA_COLUMN(MD, mD, float); //! Invariant mass of D-meson 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(NSigTpcPiDmesProng0, nSigTpcPiDmesProng0, float); //! TPC Nsigma separation for D-meson prong0 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPiDmesProng0, nSigTofPiDmesProng0, float); //! TOF Nsigma separation for D-meson prong0 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofPiDmesProng0, nSigTpcTofPiDmesProng0, float); //! Combined TPC and TOF Nsigma separation for D-meson prong0 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcKaDmesProng1, nSigTpcKaDmesProng1, float); //! TPC Nsigma separation for D-meson prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTofKaDmesProng1, nSigTofKaDmesProng1, float); //! TOF Nsigma separation for D-meson prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofKaDmesProng1, nSigTpcTofKaDmesProng1, float); //! Combined TPC and TOF Nsigma separation for D-meson prong1 with kaon mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcPiDmesProng2, nSigTpcPiDmesProng2, float); //! TPC Nsigma separation for D-meson prong2 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPiDmesProng2, nSigTofPiDmesProng2, float); //! TOF Nsigma separation for D-meson prong2 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTpcTofPiDmesProng2, nSigTpcTofPiDmesProng2, float); //! Combined TPC and TOF Nsigma separation for D-meson 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(DecayLengthD, decayLengthD, float); //! Decay length of D-meson daughter candidate (cm) +DECLARE_SOA_COLUMN(DecayLengthXYD, decayLengthXYD, float); //! Transverse decay length of D-meson daughter candidate (cm) +DECLARE_SOA_COLUMN(ImpactParameterD, impactParameterD, float); //! Impact parameter product of D-meson 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_b0_lite DECLARE_SOA_TABLE(HfRedCandB0Lites, "AOD", "HFREDCANDB0LITE", //! Table with some B0 properties + // B meson features hf_cand_b0_lite::M, + hf_cand_b0_lite::M, + hf_cand_b0_lite::Pt, + hf_cand_b0_lite::Eta, + hf_cand_b0_lite::Phi, + hf_cand_b0_lite::Y, + hf_cand_b0_lite::Cpa, + hf_cand_b0_lite::CpaXY, hf_cand::Chi2PCA, hf_cand_b0_lite::DecayLength, hf_cand_b0_lite::DecayLengthXY, hf_cand_b0_lite::DecayLengthNormalised, hf_cand_b0_lite::DecayLengthXYNormalised, - hf_cand_b0_lite::MProng0, - hf_cand_b0_lite::PtProng0, - hf_cand_b0_lite::PtProng1, - hf_cand::ImpactParameter0, - hf_cand::ImpactParameter1, hf_cand_b0_lite::ImpactParameterProduct, - hf_cand_b0_lite::NSigTpcPi1, - hf_cand_b0_lite::NSigTofPi1, + hf_cand_b0_lite::MaxNormalisedDeltaIP, + hf_cand_b0_lite::MlScoreSig, + hf_sel_candidate_b0::IsSelB0ToDPi, + // D meson features + hf_cand_b0_lite::MD, + hf_cand_b0_lite::PtD, + hf_cand_b0_lite::DecayLengthD, + hf_cand_b0_lite::DecayLengthXYD, + hf_cand_b0_lite::ImpactParameterD, + hf_cand_b0_lite::PtDmesProngMin, + hf_cand_b0_lite::AbsEtaDmesProngMin, + hf_cand_b0_lite::ItsNClsDmesProngMin, + hf_cand_b0_lite::TpcNClsCrossedRowsDmesProngMin, + hf_cand_b0_lite::TpcChi2NClDmesProngMax, + hf_cand_b0_lite::NSigTpcPiDmesProng0, + hf_cand_b0_lite::NSigTofPiDmesProng0, + hf_cand_b0_lite::NSigTpcTofPiDmesProng0, + hf_cand_b0_lite::NSigTpcKaDmesProng1, + hf_cand_b0_lite::NSigTofKaDmesProng1, + hf_cand_b0_lite::NSigTpcTofKaDmesProng1, + hf_cand_b0_lite::NSigTpcPiDmesProng2, + hf_cand_b0_lite::NSigTofPiDmesProng2, + hf_cand_b0_lite::NSigTpcTofPiDmesProng2, hf_cand_b0_reduced::Prong0MlScoreBkg, hf_cand_b0_reduced::Prong0MlScorePrompt, hf_cand_b0_reduced::Prong0MlScoreNonprompt, - hf_cand_b0_lite::MlScoreSig, - hf_sel_candidate_b0::IsSelB0ToDPi, - hf_cand_b0_lite::M, - hf_cand_b0_lite::Pt, - hf_cand_b0_lite::Cpa, - hf_cand_b0_lite::CpaXY, - hf_cand_b0_lite::MaxNormalisedDeltaIP, - hf_cand_b0_lite::Eta, - hf_cand_b0_lite::Phi, - hf_cand_b0_lite::Y, + // pion features + hf_cand_b0_lite::PtBach, + hf_cand_b0_lite::AbsEtaBach, + hf_cand_b0_lite::ItsNClsBach, + hf_cand_b0_lite::TpcNClsCrossedRowsBach, + hf_cand_b0_lite::TpcChi2NClBach, + hf_cand_b0_lite::ImpactParameterBach, + hf_cand_b0_lite::NSigTpcPiBachelor, + hf_cand_b0_lite::NSigTofPiBachelor, + hf_cand_b0_lite::NSigTpcTofPiBachelor, + // MC truth hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, + hf_cand_b0_lite::FlagWrongCollision, hf_cand_b0_lite::PtGen); DECLARE_SOA_TABLE(HfRedB0McCheck, "AOD", "HFREDB0MCCHECK", //! Table with MC decay type check hf_cand_3prong::FlagMcMatchRec, - hf_cand_b0_lite::MProng0, - hf_cand_b0_lite::PtProng0, + hf_cand_b0_lite::FlagWrongCollision, + hf_cand_b0_lite::MD, + hf_cand_b0_lite::PtD, hf_cand_b0_lite::M, hf_cand_b0_lite::Pt, hf_cand_b0_lite::MlScoreSig, @@ -130,6 +181,7 @@ struct HfTaskB0Reduced { HistogramRegistry registry{"registry"}; using TracksPion = soa::Join; + using CandsDplus = soa::Join; void init(InitContext&) { @@ -137,16 +189,11 @@ struct HfTaskB0Reduced { 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, doprocessMcWithDmesMl, doprocessMcWithB0Ml, doprocessMcWithB0MlAndDecayTypeCheck}; + std::array processFuncMc{doprocessMc, doprocessMcWithDecayTypeCheck, doprocessMcWithDmesMl, doprocessMcWithDmesMlAndDecayTypeCheck, doprocessMcWithB0Ml, doprocessMcWithB0MlAndDecayTypeCheck}; if ((std::accumulate(processFuncMc.begin(), processFuncMc.end(), 0)) > 1) { LOGP(fatal, "Only one process function for MC can be enabled at a time."); } - if (((doprocessData || doprocessDataWithDmesMl) && fillTree && downSampleBkgFactor >= 1.) || - ((doprocessMc || doprocessMcWithDmesMl) && fillTree && fillBackground && downSampleBkgFactor >= 1.)) { - LOGP(fatal, "Set downSampleBkgFactor below unity when filling tree with background."); - } - const AxisSpec axisMlScore{100, 0.f, 1.f}; const AxisSpec axisMassB0{300, 4.5f, 6.0f}; const AxisSpec axisMassDminus{300, 1.75f, 2.05f}; @@ -203,7 +250,7 @@ struct HfTaskB0Reduced { } } - if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMl || doprocessMcWithB0Ml || doprocessMcWithB0MlAndDecayTypeCheck) { + if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck || doprocessMcWithB0Ml || doprocessMcWithB0MlAndDecayTypeCheck) { if (fillHistograms) { // gen histos registry.add("hEtaGen", "B^{0} particles (generated);#it{p}_{T}^{gen}(B^{0}) (GeV/#it{c});#it{#eta}^{gen}(B^{0});entries", {HistType::kTH2F, {axisPtB0, axisEta}}); @@ -258,7 +305,7 @@ struct HfTaskB0Reduced { registry.add("hCospXyDRecBg", "B^{0} candidates (unmatched);#it{p}_{T}(D^{#minus}) (GeV/#it{c});D^{#minus} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtDminus, axisCosp}}); } // MC checks - if (doprocessMcWithDecayTypeCheck || doprocessMcWithB0MlAndDecayTypeCheck) { + if (doprocessMcWithDecayTypeCheck || doprocessMcWithB0MlAndDecayTypeCheck || doprocessMcWithDmesMlAndDecayTypeCheck) { constexpr uint8_t kNBinsDecayTypeMc = hf_cand_b0::DecayTypeMc::NDecayTypeMc; TString labels[kNBinsDecayTypeMc]; labels[hf_cand_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi] = "B^{0} #rightarrow (D^{#minus} #rightarrow #pi^{#minus} K^{#plus} #pi^{#minus}) #pi^{#plus}"; @@ -272,7 +319,7 @@ struct HfTaskB0Reduced { } } // ML scores of D- daughter - if (doprocessMcWithDmesMl) { + if (doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck) { // signal registry.add("hMlScoreBkgDRecSig", "B^{0} candidates (matched);#it{p}_{T}(D^{#minus}) (GeV/#it{c});prong0, D^{#minus} ML background score;entries", {HistType::kTH2F, {axisPtDminus, axisMlScore}}); registry.add("hMlScorePromptDRecSig", "B^{0} candidates (matched);#it{p}_{T}(D^{#minus}) (GeV/#it{c});prong0, D^{#minus} ML prompt score;entries", {HistType::kTH2F, {axisPtDminus, axisMlScore}}); @@ -328,15 +375,15 @@ struct HfTaskB0Reduced { /// \param withB0Ml is the flag to enable the filling with ML scores for the B0 candidate /// \param candidate is the B0 candidate /// \param candidatesD is the table with D- candidates - template + template void fillCand(Cand const& candidate, - aod::HfRed3Prongs const&) + CandsDmes const&) { auto ptCandB0 = candidate.pt(); auto invMassB0 = hfHelper.invMassB0ToDPi(candidate); - auto candD = candidate.template prong0_as(); + auto candD = candidate.template prong0_as(); auto ptD = candidate.ptProng0(); - auto invMassD = candD.invMass(); + auto invMassD = candD.invMassHypo0(); std::array posPv{candidate.posX(), candidate.posY(), candidate.posZ()}; std::array posSvD{candD.xSecondaryVertex(), candD.ySecondaryVertex(), candD.zSecondaryVertex()}; std::array momD{candD.pVector()}; @@ -346,9 +393,11 @@ struct HfTaskB0Reduced { auto decLenXyD = RecoDecay::distanceXY(posPv, posSvD); 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_b0::DecayTypeMc::B0ToDplusPiToPiKPiPi); } @@ -474,7 +523,7 @@ struct HfTaskB0Reduced { } } if (fillTree) { - float pseudoRndm = ptD * 1000. - (int64_t)(ptD * 1000); + float pseudoRndm = ptD * 1000. - static_cast(ptD * 1000); if (flagMcMatchRec != 0 || (((doMc && fillBackground) || !doMc) && (ptCandB0 >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor))) { float prong0MlScoreBkg = -1.; float prong0MlScorePrompt = -1.; @@ -496,54 +545,78 @@ struct HfTaskB0Reduced { } hfRedCandB0Lite( + // B-meson features + invMassB0, + ptCandB0, + candidate.eta(), + candidate.phi(), + hfHelper.yB0(candidate), + candidate.cpa(), + candidate.cpaXY(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.decayLengthNormalised(), candidate.decayLengthXYNormalised(), + candidate.impactParameterProduct(), + candidate.maxNormalisedDeltaIP(), + candidateMlScoreSig, + candidate.isSelB0ToDPi(), + // D-meson features invMassD, ptD, - candidate.ptProng1(), + decLenD, + decLenXyD, candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameterProduct(), - prong1.tpcNSigmaPi(), - prong1.tofNSigmaPi(), + candD.ptProngMin(), + candD.absEtaProngMin(), + candD.itsNClsProngMin(), + candD.tpcNClsCrossedRowsProngMin(), + candD.tpcChi2NClProngMax(), + candD.tpcNSigmaPiProng0(), + candD.tofNSigmaPiProng0(), + candD.tpcTofNSigmaPiProng0(), + candD.tpcNSigmaKaProng1(), + candD.tofNSigmaKaProng1(), + candD.tpcTofNSigmaKaProng1(), + candD.tpcNSigmaPiProng2(), + candD.tofNSigmaPiProng2(), + candD.tpcTofNSigmaPiProng2(), prong0MlScoreBkg, prong0MlScorePrompt, prong0MlScoreNonprompt, - candidateMlScoreSig, - candidate.isSelB0ToDPi(), - invMassB0, - ptCandB0, - candidate.cpa(), - candidate.cpaXY(), - candidate.maxNormalisedDeltaIP(), - candidate.eta(), - candidate.phi(), - hfHelper.yB0(candidate), + // 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) { - float candidateMlScoreSig = -1; - if constexpr (withB0Ml) { - candidateMlScoreSig = candidate.mlProbB0ToDPi(); + + if constexpr (withDecayTypeCheck) { + hfRedB0McCheck( + flagMcMatchRec, + flagWrongCollision, + invMassD, + ptD, + invMassB0, + ptCandB0, + candidateMlScoreSig, + candidate.pdgCodeBeautyMother(), + candidate.pdgCodeCharmMother(), + candidate.pdgCodeProng0(), + candidate.pdgCodeProng1(), + candidate.pdgCodeProng2(), + candidate.pdgCodeProng3()); } - hfRedB0McCheck( - flagMcMatchRec, - invMassD, - ptD, - invMassB0, - ptCandB0, - candidateMlScoreSig, - candidate.pdgCodeBeautyMother(), - candidate.pdgCodeCharmMother(), - candidate.pdgCodeProng0(), - candidate.pdgCodeProng1(), - candidate.pdgCodeProng2(), - candidate.pdgCodeProng3()); } } } @@ -588,7 +661,7 @@ struct HfTaskB0Reduced { // Process functions void processData(soa::Filtered> const& candidates, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { for (const auto& candidate : candidates) { @@ -597,11 +670,11 @@ struct HfTaskB0Reduced { } fillCand(candidate, candidatesD); } // candidate loop - } // processData + } // processData PROCESS_SWITCH(HfTaskB0Reduced, processData, "Process data without ML scores for B0 and D daughter", true); void processDataWithDmesMl(soa::Filtered> const& candidates, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { for (const auto& candidate : candidates) { @@ -610,11 +683,11 @@ struct HfTaskB0Reduced { } fillCand(candidate, candidatesD); } // candidate loop - } // processDataWithDmesMl + } // processDataWithDmesMl PROCESS_SWITCH(HfTaskB0Reduced, processDataWithDmesMl, "Process data with(out) ML scores for D daughter (B0)", false); void processDataWithB0Ml(soa::Filtered> const& candidates, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { for (const auto& candidate : candidates) { @@ -623,12 +696,12 @@ struct HfTaskB0Reduced { } fillCand(candidate, candidatesD); } // candidate loop - } // processDataWithB0Ml + } // processDataWithB0Ml PROCESS_SWITCH(HfTaskB0Reduced, processDataWithB0Ml, "Process data with(out) ML scores for B0 (D daughter)", false); void processMc(soa::Filtered> const& candidates, aod::HfMcGenRedB0s const& mcParticles, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { // MC rec @@ -643,12 +716,12 @@ struct HfTaskB0Reduced { for (const auto& particle : mcParticles) { fillCandMcGen(particle); } // gen - } // processMc + } // processMc PROCESS_SWITCH(HfTaskB0Reduced, processMc, "Process MC without ML scores for B0 and D daughter", false); void processMcWithDecayTypeCheck(soa::Filtered> const& candidates, aod::HfMcGenRedB0s const& mcParticles, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { // MC rec @@ -663,12 +736,12 @@ struct HfTaskB0Reduced { for (const auto& particle : mcParticles) { fillCandMcGen(particle); } // gen - } // processMc + } // processMc PROCESS_SWITCH(HfTaskB0Reduced, processMcWithDecayTypeCheck, "Process MC with decay type check and without ML scores for B0 and D daughter", false); void processMcWithDmesMl(soa::Filtered> const& candidates, aod::HfMcGenRedB0s const& mcParticles, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { // MC rec @@ -683,12 +756,32 @@ struct HfTaskB0Reduced { for (const auto& particle : mcParticles) { fillCandMcGen(particle); } // gen - } // processMcWithDmesMl + } // processMcWithDmesMl PROCESS_SWITCH(HfTaskB0Reduced, processMcWithDmesMl, "Process MC with(out) ML scores for D daughter (B0)", false); + void processMcWithDmesMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedB0s const& mcParticles, + CandsDplus const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yB0(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskB0Reduced, processMcWithDmesMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for B0 (D daughter)", false); + void processMcWithB0Ml(soa::Filtered> const& candidates, aod::HfMcGenRedB0s const& mcParticles, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { // MC rec @@ -703,12 +796,12 @@ struct HfTaskB0Reduced { for (const auto& particle : mcParticles) { fillCandMcGen(particle); } // gen - } // processMcWithB0Ml + } // processMcWithB0Ml PROCESS_SWITCH(HfTaskB0Reduced, processMcWithB0Ml, "Process MC with(out) ML scores for B0 (D daughter)", false); void processMcWithB0MlAndDecayTypeCheck(soa::Filtered> const& candidates, aod::HfMcGenRedB0s const& mcParticles, - aod::HfRed3Prongs const& candidatesD, + CandsDplus const& candidatesD, TracksPion const&) { // MC rec @@ -723,7 +816,7 @@ struct HfTaskB0Reduced { for (const auto& particle : mcParticles) { fillCandMcGen(particle); } // gen - } // processMc + } // processMc PROCESS_SWITCH(HfTaskB0Reduced, processMcWithB0MlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for B0 (D daughter)", false); }; // struct diff --git a/PWGHF/D2H/Tasks/taskBplus.cxx b/PWGHF/D2H/Tasks/taskBplus.cxx index 9586ebaa424..b98a2930258 100644 --- a/PWGHF/D2H/Tasks/taskBplus.cxx +++ b/PWGHF/D2H/Tasks/taskBplus.cxx @@ -18,6 +18,8 @@ /// \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" @@ -263,7 +265,7 @@ struct HfTaskBplus { float ptProngs[2], yProngs[2], etaProngs[2]; int counter = 0; - for (const auto& daught : particle.daughters_as()) { + 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())); diff --git a/PWGHF/D2H/Tasks/taskBplusReduced.cxx b/PWGHF/D2H/Tasks/taskBplusReduced.cxx index 5b56d523944..af95d1c8179 100644 --- a/PWGHF/D2H/Tasks/taskBplusReduced.cxx +++ b/PWGHF/D2H/Tasks/taskBplusReduced.cxx @@ -57,6 +57,7 @@ DECLARE_SOA_COLUMN(Cpa, cpa, float); //! 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_bplus_lite DECLARE_SOA_TABLE(HfRedCandBpLites, "AOD", "HFREDCANDBPLITE", //! Table with some B+ properties @@ -88,10 +89,12 @@ DECLARE_SOA_TABLE(HfRedCandBpLites, "AOD", "HFREDCANDBPLITE", //! Table with som hf_cand_bplus_lite::Y, hf_cand_2prong::FlagMcMatchRec, hf_cand_2prong::OriginMcRec, + hf_cand_bplus_lite::FlagWrongCollision, hf_cand_bplus_lite::PtGen); DECLARE_SOA_TABLE(HfRedBpMcCheck, "AOD", "HFREDBPMCCHECK", //! Table with MC decay type check - hf_cand_3prong::FlagMcMatchRec, + hf_cand_2prong::FlagMcMatchRec, + hf_cand_bplus_lite::FlagWrongCollision, hf_cand_bplus_lite::MProng0, hf_cand_bplus_lite::PtProng0, hf_cand_bplus_lite::M, @@ -140,24 +143,20 @@ struct HfTaskBplusReduced { void init(InitContext&) { - std::array processFuncData{doprocessData, doprocessDataWithDmesMl}; + std::array processFuncData{doprocessData, doprocessDataWithDmesMl, 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, doprocessMcWithDmesMl}; + std::array processFuncMc{doprocessMc, doprocessMcWithDecayTypeCheck, doprocessMcWithDmesMl, doprocessMcWithDmesMlAndDecayTypeCheck, doprocessMcWithBplusMl, doprocessMcWithBplusMlAndDecayTypeCheck}; if ((std::accumulate(processFuncMc.begin(), processFuncMc.end(), 0)) > 1) { LOGP(fatal, "Only one process function for MC can be enabled at a time."); } - if (((doprocessData || doprocessDataWithDmesMl) && fillTree && downSampleBkgFactor >= 1.) || - ((doprocessMc || doprocessMcWithDmesMl) && fillTree && fillBackground && downSampleBkgFactor >= 1.)) { - LOGP(fatal, "Set downSampleBkgFactor below unity when filling tree with background."); - } - const AxisSpec axisMlScore{100, 0.f, 1.f}; const AxisSpec axisMassBplus{150, 4.5, 6.0}; const AxisSpec axisMassD0{300, 1.75f, 2.05f}; const AxisSpec axisCpa{120, -1.1, 1.1}; + const AxisSpec axisCpaD{101, 0.9, 1.01}; const AxisSpec axisPtProng{100, 0., 10.}; const AxisSpec axisD0Prong{200, -0.05, 0.05}; const AxisSpec axisImpParProd{200, -0.001, 0.001}; @@ -186,10 +185,10 @@ struct HfTaskBplusReduced { registry.add("hRapidity", bPlusCandTitle + "candidate #it{y};" + stringPt, {HistType::kTH2F, {axisRapidity, axisPtB}}); registry.add("hd0d0", bPlusCandTitle + "candidate product of DCAxy to prim. vertex (cm^{2});" + stringPt, {HistType::kTH2F, {axisImpParProd, axisPtB}}); registry.add("hInvMassD0", bPlusCandTitle + "prong0, D0 inv. mass (GeV/#it{c}^{2});" + stringPt, {HistType::kTH2F, {axisMassD0, axisPtD0}}); - registry.add("hDecLengthD", bPlusCandTitle + "#it{p}_{T}(D^{0}) (GeV/#it{c});D^{0} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtD0, axisDecLength}}); - registry.add("hDecLengthXyD", bPlusCandTitle + "#it{p}_{T}(D^{0}) (GeV/#it{c});decay length XY (cm);entries", {HistType::kTH2F, {axisPtD0, axisDecLength}}); - registry.add("hCpaD", bPlusCandTitle + "#it{p}_{T}(D^{0}) (GeV/#it{c});D^{0} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtD0, axisCpa}}); - registry.add("hCpaXyD", bPlusCandTitle + "#it{p}_{T}(D^{0}) (GeV/#it{c});D^{0} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtD0, axisCpa}}); + registry.add("hDecLengthD0", bPlusCandTitle + "D^{0} candidate decay length (cm);#it{p}_{T}(D^{0}) (GeV/#it{c});entries", {HistType::kTH2F, {axisDecLength, axisPtD0}}); + registry.add("hDecLengthXyD0", bPlusCandTitle + "decay length XY (cm);#it{p}_{T}(D^{0}) (GeV/#it{c});entries", {HistType::kTH2F, {axisDecLength, axisPtD0}}); + registry.add("hCpaD0", bPlusCandTitle + "D^{0} candidate cos(#vartheta_{P});#it{p}_{T}(D^{0}) (GeV/#it{c});entries", {HistType::kTH2F, {axisCpaD, axisPtD0}}); + registry.add("hCpaXyD0", bPlusCandTitle + "D^{0} candidate cos(#vartheta_{P}^{XY});#it{p}_{T}(D^{0}) (GeV/#it{c});entries", {HistType::kTH2F, {axisCpaD, axisPtD0}}); // ML scores of D0 daughter if (doprocessDataWithDmesMl) { @@ -213,7 +212,7 @@ struct HfTaskBplusReduced { } // histograms processMC - if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMl || doprocessMcWithBplusMl || doprocessMcWithBplusMlAndDecayTypeCheck) { + if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck || doprocessMcWithBplusMl || doprocessMcWithBplusMlAndDecayTypeCheck) { if (fillHistograms) { // Gen Level registry.add("hEtaGen", mcParticleMatched + "candidate #it{#eta}^{gen};" + stringPt, {HistType::kTH2F, {axisEta, axisPtB}}); @@ -270,7 +269,7 @@ struct HfTaskBplusReduced { registry.add("hDecLengthXyD0RecBg", bPlusCandUnmatch + "prong0 D^{0} decay length XY (cm);" + stringPtD + entries, {HistType::kTH2F, {{100, 0., 0.5}, {120, 0., 60.}}}); } // MC checks - if (doprocessMcWithDecayTypeCheck || doprocessMcWithBplusMlAndDecayTypeCheck) { + if (doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMlAndDecayTypeCheck || doprocessMcWithBplusMlAndDecayTypeCheck) { 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}"; @@ -283,7 +282,7 @@ struct HfTaskBplusReduced { } } // ML scores of D0 daughter - if (doprocessMcWithDmesMl) { + if (doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck) { // signal registry.add("hMlScoreBkgDRecSig", bPlusCandMatch + stringPtD + "prong0, D0 ML background score;entries", {HistType::kTH2F, {axisPtD0, axisMlScore}}); registry.add("hMlScorePromptDRecSig", bPlusCandMatch + stringPtD + "prong0, D0 ML prompt score;entries", {HistType::kTH2F, {axisPtD0, axisMlScore}}); @@ -340,14 +339,15 @@ struct HfTaskBplusReduced { /// \param candidatesD is the table with D0 candidates template void fillCand(Cand const& candidate, - aod::HfRed2Prongs const& /*candidatesD*/) + aod::HfRed2Prongs const& /*candidatesD*/, + TracksPion const&) { auto ptCandBplus = candidate.pt(); auto invMassBplus = hfHelper.invMassBplusToD0Pi(candidate); auto candD0 = candidate.template prong0_as(); - auto candPi = candidate.template prong1_as(); + auto candPi = candidate.template prong1_as(); auto ptD0 = candidate.ptProng0(); - auto invMassD0 = (candPi.signed1Pt() < 0) ? candD0.invMassD0() : candD0.invMassD0Bar(); + auto invMassD0 = (candPi.signed1Pt() < 0) ? candD0.invMassHypo0() : candD0.invMassHypo1(); std::array posPv{candidate.posX(), candidate.posY(), candidate.posZ()}; std::array posSvD{candD0.xSecondaryVertex(), candD0.ySecondaryVertex(), candD0.zSecondaryVertex()}; std::array momD{candD0.pVector()}; @@ -357,9 +357,11 @@ struct HfTaskBplusReduced { auto decLenXyD0 = RecoDecay::distanceXY(posPv, posSvD); 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_bplus::DecayTypeMc::BplusToD0PiToKPiPi); } @@ -537,6 +539,7 @@ struct HfTaskBplusReduced { hfHelper.yBplus(candidate), flagMcMatchRec, isSignal, + flagWrongCollision, ptMother); } if constexpr (withDecayTypeCheck) { @@ -546,6 +549,7 @@ struct HfTaskBplusReduced { } hfRedBpMcCheck( flagMcMatchRec, + flagWrongCollision, invMassD0, ptD0, invMassBplus, @@ -600,54 +604,54 @@ struct HfTaskBplusReduced { // Process functions void processData(soa::Filtered> const& candidates, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // candidate loop } // processData PROCESS_SWITCH(HfTaskBplusReduced, processData, "Process data without ML scores for D0 daughter", true); void processDataWithDmesMl(soa::Filtered> const& candidates, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // candidate loop } // processDataWithDmesMl PROCESS_SWITCH(HfTaskBplusReduced, processDataWithDmesMl, "Process data with ML scores for D0 daughter", false); void processDataWithBplusMl(soa::Filtered> const& candidates, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // candidate loop } // processDataWithBplusMl PROCESS_SWITCH(HfTaskBplusReduced, processDataWithBplusMl, "Process data with(out) ML scores for B+ (D0 daughter)", false); - void processMc(soa::Join const& candidates, + void processMc(soa::Filtered> const& candidates, aod::HfMcGenRedBps const& mcParticles, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { // MC rec for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // rec // MC gen. level @@ -660,14 +664,14 @@ struct HfTaskBplusReduced { void processMcWithDecayTypeCheck(soa::Filtered> const& candidates, aod::HfMcGenRedBps const& mcParticles, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { // MC rec for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // rec // MC gen. level @@ -677,17 +681,17 @@ struct HfTaskBplusReduced { } // processMc PROCESS_SWITCH(HfTaskBplusReduced, processMcWithDecayTypeCheck, "Process MC with decay type check and without ML scores for B+ and D daughter", false); - void processMcWithDmesMl(soa::Join const& candidates, + void processMcWithDmesMl(soa::Filtered> const& candidates, aod::HfMcGenRedBps const& mcParticles, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { // MC rec for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // rec // MC gen. level @@ -697,17 +701,37 @@ struct HfTaskBplusReduced { } // processMcWithDmesMl PROCESS_SWITCH(HfTaskBplusReduced, processMcWithDmesMl, "Process MC with(out) ML scores for D0 daughter (B+)", false); + void processMcWithDmesMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedBps const& mcParticles, + aod::HfRed2Prongs const& candidatesD, + TracksPion const& pionTracks) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD, pionTracks); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBplusReduced, processMcWithDmesMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for B+ (D0 daughter)", false); + void processMcWithBplusMl(soa::Filtered> const& candidates, aod::HfMcGenRedBps const& mcParticles, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { // MC rec for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // rec // MC gen. level @@ -720,14 +744,14 @@ struct HfTaskBplusReduced { void processMcWithBplusMlAndDecayTypeCheck(soa::Filtered> const& candidates, aod::HfMcGenRedBps const& mcParticles, aod::HfRed2Prongs const& candidatesD, - TracksPion const&) + TracksPion const& pionTracks) { // MC rec for (const auto& candidate : candidates) { if (yCandRecoMax >= 0. && std::abs(hfHelper.yBplus(candidate)) > yCandRecoMax) { continue; } - fillCand(candidate, candidatesD); + fillCand(candidate, candidatesD, pionTracks); } // rec // MC gen. level diff --git a/PWGHF/D2H/Tasks/taskBs.cxx b/PWGHF/D2H/Tasks/taskBs.cxx index 29c424f869b..e661c8d739b 100644 --- a/PWGHF/D2H/Tasks/taskBs.cxx +++ b/PWGHF/D2H/Tasks/taskBs.cxx @@ -128,8 +128,8 @@ struct HfTaskBs { if (checkDecayTypeMc) { constexpr uint8_t kNBinsDecayTypeMc = hf_cand_bs::DecayTypeMc::NDecayTypeMc + 1; TString labels[kNBinsDecayTypeMc]; - labels[hf_cand_bs::DecayTypeMc::BsToDsPiToKKPiPi] = "B^{0}_{s} #rightarrow (D^{#mp}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#mp}) #pi^{#pm}"; - labels[hf_cand_bs::DecayTypeMc::B0ToDsPiToKKPiPi] = "B^{0} #rightarrow (D^{#pm}_{s} #rightarrow K^{#minus} K^{#plus} #pi^{#pm}) #pi^{#mp}"; + 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, ""}; @@ -155,9 +155,6 @@ struct HfTaskBs { TracksWithSel const&) { for (const auto& candidate : candidates) { - if (!TESTBIT(candidate.hfflag(), hf_cand_bs::DecayType::BsToDsPi)) { - continue; - } if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { continue; } @@ -194,9 +191,6 @@ struct HfTaskBs { { // MC rec for (const auto& candidate : candidates) { - if (!TESTBIT(candidate.hfflag(), hf_cand_bs::DecayType::BsToDsPi)) { - continue; - } if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { continue; } @@ -206,7 +200,7 @@ struct HfTaskBs { auto invMassCandBs = hfHelper.invMassBsToDsPi(candidate); int flagMcMatchRecBs = std::abs(candidate.flagMcMatchRec()); - if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::BsToDsPiToKKPiPi)) { + if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kBS, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); @@ -230,7 +224,7 @@ struct HfTaskBs { registry.fill(HIST("hChi2PCARecSig"), candidate.chi2PCA(), ptCandBs); if (checkDecayTypeMc) { - registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::BsToDsPiToKKPiPi, invMassCandBs, ptCandBs); + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi, invMassCandBs, ptCandBs); } } else { registry.fill(HIST("hPtRecBg"), ptCandBs); @@ -252,8 +246,8 @@ struct HfTaskBs { registry.fill(HIST("hChi2PCARecBg"), candidate.chi2PCA(), ptCandBs); if (checkDecayTypeMc) { - if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::B0ToDsPiToKKPiPi)) { // B0(bar) → Ds± π∓ → (K- K+ π±) π∓ - registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::B0ToDsPiToKKPiPi, invMassCandBs, ptCandBs); + if (TESTBIT(flagMcMatchRecBs, hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi)) { // 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 registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::PartlyRecoDecay, invMassCandBs, ptCandBs); } else { @@ -265,7 +259,7 @@ struct HfTaskBs { // MC gen. level for (const auto& particle : mcParticles) { - if (TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_bs::DecayTypeMc::BsToDsPiToKKPiPi)) { + if (TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { auto ptParticle = particle.pt(); auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassBS); diff --git a/PWGHF/D2H/Tasks/taskBsReduced.cxx b/PWGHF/D2H/Tasks/taskBsReduced.cxx new file mode 100644 index 00000000000..cbe0ddc2fa4 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskBsReduced.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 taskBsReduced.cxx +/// \brief Bs → Ds- π+ → (K- K+ π-) π+ analysis task +/// +/// \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/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/D2H/DataModel/ReducedDataModel.h" + +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_bs_lite +{ +DECLARE_SOA_COLUMN(PtProng0, ptProng0, float); //! Transverse momentum of prong0 (GeV/c) +DECLARE_SOA_COLUMN(PtProng1, ptProng1, float); //! Transverse momentum of prong1 (GeV/c) +DECLARE_SOA_COLUMN(MProng0, mProng0, float); //! Invariant mass of prong0 (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(NSigTpcPi1, nSigTpcPi1, float); //! TPC Nsigma separation for prong1 with pion mass hypothesis +DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); //! TOF Nsigma separation for prong1 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(ImpactParameterProduct, impactParameterProduct, float); //! Impact parameter product 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(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_bs_lite + +DECLARE_SOA_TABLE(HfRedCandBsLites, "AOD", "HFREDCANDBSLITE", //! Table with some Bs properties + hf_cand::Chi2PCA, + hf_cand_bs_lite::DecayLength, + hf_cand_bs_lite::DecayLengthXY, + hf_cand_bs_lite::DecayLengthNormalised, + hf_cand_bs_lite::DecayLengthXYNormalised, + hf_cand_bs_lite::MProng0, + hf_cand_bs_lite::PtProng0, + hf_cand_bs_lite::PtProng1, + hf_cand::ImpactParameter0, + hf_cand::ImpactParameter1, + hf_cand_bs_lite::ImpactParameterProduct, + hf_cand_bs_lite::NSigTpcPi1, + hf_cand_bs_lite::NSigTofPi1, + hf_cand_bs_reduced::Prong0MlScoreBkg, + hf_cand_bs_reduced::Prong0MlScorePrompt, + hf_cand_bs_reduced::Prong0MlScoreNonprompt, + hf_cand_bs_lite::MlScoreSig, + hf_sel_candidate_bs::IsSelBsToDsPi, + hf_cand_bs_lite::M, + hf_cand_bs_lite::Pt, + hf_cand_bs_lite::Cpa, + hf_cand_bs_lite::CpaXY, + hf_cand_bs_lite::MaxNormalisedDeltaIP, + hf_cand_bs_lite::Eta, + hf_cand_bs_lite::Phi, + hf_cand_bs_lite::Y, + hf_cand_3prong::FlagMcMatchRec, + hf_cand_3prong::OriginMcRec, + hf_cand_bs_lite::FlagWrongCollision, + hf_cand_bs_lite::PtGen); + +DECLARE_SOA_TABLE(HfRedBsMcCheck, "AOD", "HFREDBSMCCHECK", //! Table with MC decay type check + hf_cand_3prong::FlagMcMatchRec, + hf_cand_bs_lite::FlagWrongCollision, + hf_cand_bs_lite::MProng0, + hf_cand_bs_lite::PtProng0, + hf_cand_bs_lite::M, + hf_cand_bs_lite::Pt, + hf_cand_bs_lite::MlScoreSig, + hf_bs_mc::PdgCodeBeautyMother, + hf_bs_mc::PdgCodeCharmMother, + hf_bs_mc::PdgCodeProng0, + hf_bs_mc::PdgCodeProng1, + hf_bs_mc::PdgCodeProng2, + hf_bs_mc::PdgCodeProng3); +} // namespace o2::aod + +/// Bs analysis task +struct HfTaskBsReduced { + 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 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_{s} candidates to keep for ML trainings"}; + Configurable ptMaxForDownSample{"ptMaxForDownSample", 10., "Maximum pt for the application of the downsampling factor"}; + + HfHelper hfHelper; + + 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}; + 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, doprocessMcWithDmesMl, doprocessMcWithDmesMlAndDecayTypeCheck, doprocessMcWithBsMl, doprocessMcWithBsMlAndDecayTypeCheck}; + 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 axisMassBs{300, 4.5f, 6.0f}; + const AxisSpec axisMassDs{300, 1.75f, 2.05f}; + 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 axisPtBs{100, 0.f, 50.f}; + const AxisSpec axisPtDs{100, 0.f, 50.f}; + const AxisSpec axisPtPi{100, 0.f, 10.f}; + + if (doprocessData || doprocessDataWithDmesMl || doprocessDataWithBsMl) { + if (fillHistograms) { + registry.add("hMass", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{M} (D_{s}#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtBs, axisMassBs}}); + registry.add("hDecLength", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hDecLengthXy", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hNormDecLengthXy", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisNormDecayLength}}); + registry.add("hDcaProng0", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 0 (D_{s}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hDcaProng1", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 1 (#pi) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hPtProng0", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(D_{s}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtDs}}); + registry.add("hPtProng1", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(#pi) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtPi}}); + registry.add("hCosp", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hCospXy", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hEta", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hRapidity", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{y};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hImpParProd", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtBs, axisImpParProd}}); + registry.add("hInvMassD", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtDs, axisMassDs}}); + registry.add("hDecLengthD", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hDecLengthXyD", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hCospD", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + registry.add("hCospXyD", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + + // ML scores of Ds- daughter + if (doprocessDataWithDmesMl) { + registry.add("hMlScoreBkgDs", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML background score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScorePromptDs", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML prompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScoreNonPromptDs", "B^{0}_{s} candidates;#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML nonprompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + } + + // ML scores of Bs candidate + if (doprocessDataWithBsMl) { + registry.add("hMlScoreSigBs", "B^{0}_{s} candidates;#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong0, B^{0}_{s} ML signal score;entries", {HistType::kTH2F, {axisPtBs, axisMlScore}}); + } + } + if (fillSparses) { + if (!(doprocessDataWithDmesMl || doprocessDataWithBsMl)) { + registry.add("hMassPtCutVars", "B^{0}_{s} candidates;#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);D_{s} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisDecayLength, axisCosp}}); + } else { + registry.add("hMassPtCutVars", "B^{0}_{s} candidates;#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate ML score bkg;D_{s} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisMlScore, axisMlScore}}); + } + } + } + + if (doprocessMc || doprocessMcWithDecayTypeCheck || doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck || doprocessMcWithBsMl || doprocessMcWithBsMlAndDecayTypeCheck) { + if (fillHistograms) { + // gen histos + registry.add("hEtaGen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{#eta}^{gen}(B^{0}_{s});entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hYGen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{y}^{gen}(B^{0}_{s});entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hYGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{y}^{gen}(B^{0}_{s});entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hPtProng0Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}^{gen}(D_{s}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtDs}}); + registry.add("hPtProng1Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}^{gen}(#pi) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtPi}}); + registry.add("hYProng0Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{y}^{gen}(D_{s});entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hYProng1Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{y}^{gen}(#pi);entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hEtaProng0Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{#eta}^{gen}(D_{s});entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hEtaProng1Gen", "B^{0}_{s} particles (generated);#it{p}_{T}^{gen}(B^{0}_{s}) (GeV/#it{c});#it{#eta}^{gen}(#pi);entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + + // reco histos + // signal + registry.add("hMassRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{M} (D_{s}#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtBs, axisMassBs}}); + registry.add("hDecLengthRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hDecLengthXyRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hNormDecLengthXyRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisNormDecayLength}}); + registry.add("hDcaProng0RecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 0 (D_{s}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hDcaProng1RecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 1 (#pi) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hPtProng0RecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(D_{s}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtDs}}); + registry.add("hPtProng1RecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(#pi) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtPi}}); + registry.add("hCospRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hCospXyRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hEtaRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hRapidityRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{y};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hImpParProdRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtBs, axisImpParProd}}); + registry.add("hInvMassDRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtDs, axisMassDs}}); + registry.add("hDecLengthDRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hDecLengthXyDRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hCospDRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + registry.add("hCospXyDRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + // background + if (fillBackground) { + registry.add("hMassRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{M} (D_{s}#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtBs, axisMassBs}}); + registry.add("hDecLengthRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hDecLengthXyRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisDecayLength}}); + registry.add("hNormDecLengthXyRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate norm. decay length XY (cm);entries", {HistType::kTH2F, {axisPtBs, axisNormDecayLength}}); + registry.add("hDcaProng0RecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 0 (D_{s}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hDcaProng1RecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong 1 (#pi) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisPtBs, axisDca}}); + registry.add("hPtProng0RecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(D_{s}) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtDs}}); + registry.add("hPtProng1RecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{p}_{T}(#pi) (GeV/#it{c});entries", {HistType::kTH2F, {axisPtBs, axisPtPi}}); + registry.add("hCospRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hCospXyRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtBs, axisCosp}}); + registry.add("hEtaRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{#eta};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hRapidityRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate #it{y};entries", {HistType::kTH2F, {axisPtBs, axisEta}}); + registry.add("hImpParProdRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate impact parameter product;entries", {HistType::kTH2F, {axisPtBs, axisImpParProd}}); + registry.add("hInvMassDRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, #it{M}(KK#pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {axisPtDs, axisMassDs}}); + registry.add("hDecLengthDRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hDecLengthXyDRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length XY (cm);entries", {HistType::kTH2F, {axisPtDs, axisDecayLength}}); + registry.add("hCospDRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + registry.add("hCospXyDRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate cos(#vartheta_{P}^{XY});entries", {HistType::kTH2F, {axisPtDs, axisCosp}}); + } + // MC checks + if (doprocessMcWithDecayTypeCheck || doprocessMcWithBsMlAndDecayTypeCheck || doprocessMcWithDmesMlAndDecayTypeCheck) { + constexpr uint8_t kNBinsDecayTypeMc = hf_cand_bs::DecayTypeMc::NDecayTypeMc; + TString labels[kNBinsDecayTypeMc]; + labels[hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi] = "B^{0}_{s} #rightarrow (D_{s} #rightarrow #Phi#pi #rightarrow KK#pi) #pi"; + 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::PartlyRecoDecay] = "Partly reconstructed decay channel"; + labels[hf_cand_bs::DecayTypeMc::OtherDecay] = "Other decays"; + static const AxisSpec axisDecayType = {kNBinsDecayTypeMc, 0.5, kNBinsDecayTypeMc + 0.5, ""}; + registry.add("hDecayTypeMc", "DecayType", {HistType::kTH3F, {axisDecayType, axisMassBs, axisPtBs}}); + for (uint8_t iBin = 0; iBin < kNBinsDecayTypeMc; ++iBin) { + registry.get(HIST("hDecayTypeMc"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin]); + } + } + // ML scores of Ds- daughter + if (doprocessMcWithDmesMl || doprocessMcWithDmesMlAndDecayTypeCheck) { + // signal + registry.add("hMlScoreBkgDsRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML background score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScorePromptDsRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML prompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScoreNonPromptDsRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML nonprompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + // background + registry.add("hMlScoreBkgDsRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML background score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScorePromptDsRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML prompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + registry.add("hMlScoreNonPromptDsRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(D_{s}) (GeV/#it{c});prong0, Ds ML nonprompt score;entries", {HistType::kTH2F, {axisPtDs, axisMlScore}}); + } + // ML scores of Bs candidate + if (doprocessMcWithBsMl || doprocessMcWithBsMlAndDecayTypeCheck) { + // signal + registry.add("hMlScoreSigBsRecSig", "B^{0}_{s} candidates (matched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong0, B^{0}_{s} ML signal score;entries", {HistType::kTH2F, {axisPtBs, axisMlScore}}); + // background + registry.add("hMlScoreSigBsRecBg", "B^{0}_{s} candidates (unmatched);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});prong0, B^{0}_{s} ML signal score;entries", {HistType::kTH2F, {axisPtBs, axisMlScore}}); + } + } + if (fillSparses) { + // gen sparses + registry.add("hPtYGenSig", "B^{0}_{s} particles (generated);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{y}(B^{0}_{s})", {HistType::kTHnSparseF, {axisPtBs, axisEta}}); + registry.add("hPtYWithProngsInAccepanceGenSig", "B^{0}_{s} particles (generated-daughters in acceptance);#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});#it{y}(B^{0}_{s})", {HistType::kTHnSparseF, {axisPtBs, axisEta}}); + + // reco sparses + if (!(doprocessDataWithDmesMl || doprocessDataWithBsMl)) { + registry.add("hMassPtCutVarsRecSig", "B^{0}_{s} candidates (matched);#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);D_{s} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisDecayLength, axisCosp}}); + if (fillBackground) { + registry.add("hMassPtCutVarsRecBg", "B^{0}_{s} candidates (unmatched);#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate decay length (cm);D_{s} candidate cos(#vartheta_{P})", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisDecayLength, axisCosp}}); + } + } else { + registry.add("hMassPtCutVarsRecSig", "B^{0}_{s} candidates (matched);#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate ML score bkg;D_{s} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisMlScore, axisMlScore}}); + if (fillBackground) { + registry.add("hMassPtCutVarsRecBg", "B^{0}_{s} candidates (unmatched);#it{M} (D_{s}#pi) (GeV/#it{c}^{2});#it{p}_{T}(B^{0}_{s}) (GeV/#it{c});B^{0}_{s} candidate decay length (cm);B^{0}_{s} candidate norm. decay length XY (cm);B^{0}_{s} candidate impact parameter product (cm);B^{0}_{s} candidate cos(#vartheta_{P});#it{M} (KK#pi) (GeV/#it{c}^{2});#it{p}_{T}(D_{s}) (GeV/#it{c});D_{s} candidate ML score bkg;D_{s} candidate ML score nonprompt", {HistType::kTHnSparseF, {axisMassBs, axisPtBs, axisDecayLength, axisNormDecayLength, axisImpParProd, axisCosp, axisMassDs, axisPtDs, axisMlScore, axisMlScore}}); + } + } + } + } + } + + /// 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; + } + + /// 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 withDmesMl is the flag to enable the filling with ML scores for the Ds- daughter + /// \param withBsMl is the flag to enable the filling with ML scores for the Bs candidate + /// \param candidate is the Bs candidate + /// \param candidatesD is the table with Ds- candidates + template + void fillCand(Cand const& candidate, + aod::HfRed3Prongs const&) + { + auto ptCandBs = candidate.pt(); + auto invMassBs = hfHelper.invMassBsToDsPi(candidate); + auto candDs = candidate.template prong0_as(); + auto ptDs = candidate.ptProng0(); + auto invMassDs = candDs.invMassHypo0() > 0 ? candDs.invMassHypo0() : candDs.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 posSvDs{candDs.xSecondaryVertex(), candDs.ySecondaryVertex(), candDs.zSecondaryVertex()}; + std::array momDs{candDs.pVector()}; + auto cospDs = RecoDecay::cpa(posPv, posSvDs, momDs); + auto cospXyDs = RecoDecay::cpaXY(posPv, posSvDs, momDs); + auto decLenDs = RecoDecay::distance(posPv, posSvDs); + auto decLenXyDs = RecoDecay::distanceXY(posPv, posSvDs); + + 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_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); + } + + if (fillHistograms) { + if constexpr (doMc) { + if (isSignal) { + registry.fill(HIST("hMassRecSig"), ptCandBs, invMassBs); + registry.fill(HIST("hPtProng0RecSig"), ptCandBs, candidate.ptProng0()); + registry.fill(HIST("hPtProng1RecSig"), ptCandBs, candidate.ptProng1()); + registry.fill(HIST("hImpParProdRecSig"), ptCandBs, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLengthRecSig"), ptCandBs, candidate.decayLength()); + registry.fill(HIST("hDecLengthXyRecSig"), ptCandBs, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXyRecSig"), ptCandBs, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0RecSig"), ptCandBs, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1RecSig"), ptCandBs, candidate.impactParameter1()); + registry.fill(HIST("hCospRecSig"), ptCandBs, candidate.cpa()); + registry.fill(HIST("hCospXyRecSig"), ptCandBs, candidate.cpaXY()); + registry.fill(HIST("hEtaRecSig"), ptCandBs, candidate.eta()); + registry.fill(HIST("hRapidityRecSig"), ptCandBs, hfHelper.yBs(candidate)); + registry.fill(HIST("hInvMassDRecSig"), ptDs, invMassDs); + registry.fill(HIST("hDecLengthDRecSig"), ptDs, decLenDs); + registry.fill(HIST("hDecLengthXyDRecSig"), ptDs, decLenXyDs); + registry.fill(HIST("hCospDRecSig"), ptDs, cospDs); + registry.fill(HIST("hCospXyDRecSig"), ptDs, cospXyDs); + if constexpr (withDecayTypeCheck) { + registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi, invMassBs, ptCandBs); + } + if constexpr (withDmesMl) { + registry.fill(HIST("hMlScoreBkgDsRecSig"), ptDs, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptDsRecSig"), ptDs, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptDsRecSig"), ptDs, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withBsMl) { + registry.fill(HIST("hMlScoreSigBsRecSig"), ptCandBs, candidate.mlProbBsToDsPi()[1]); + } + } else if (fillBackground) { + registry.fill(HIST("hMassRecBg"), ptCandBs, invMassBs); + registry.fill(HIST("hPtProng0RecBg"), ptCandBs, candidate.ptProng0()); + registry.fill(HIST("hPtProng1RecBg"), ptCandBs, candidate.ptProng1()); + registry.fill(HIST("hImpParProdRecBg"), ptCandBs, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLengthRecBg"), ptCandBs, candidate.decayLength()); + registry.fill(HIST("hDecLengthXyRecBg"), ptCandBs, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXyRecBg"), ptCandBs, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0RecBg"), ptCandBs, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1RecBg"), ptCandBs, candidate.impactParameter1()); + registry.fill(HIST("hCospRecBg"), ptCandBs, candidate.cpa()); + registry.fill(HIST("hCospXyRecBg"), ptCandBs, candidate.cpaXY()); + registry.fill(HIST("hEtaRecBg"), ptCandBs, candidate.eta()); + registry.fill(HIST("hRapidityRecBg"), ptCandBs, hfHelper.yBs(candidate)); + registry.fill(HIST("hInvMassDRecBg"), ptDs, invMassDs); + registry.fill(HIST("hDecLengthDRecBg"), ptDs, decLenDs); + registry.fill(HIST("hDecLengthXyDRecBg"), ptDs, decLenXyDs); + registry.fill(HIST("hCospDRecBg"), ptDs, cospDs); + registry.fill(HIST("hCospXyDRecBg"), ptDs, cospXyDs); + if constexpr (withDmesMl) { + registry.fill(HIST("hMlScoreBkgDsRecBg"), ptDs, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptDsRecBg"), ptDs, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptDsRecBg"), ptDs, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withBsMl) { + registry.fill(HIST("hMlScoreSigBsRecBg"), ptCandBs, candidate.mlProbBsToDsPi()[1]); + } + } else if constexpr (withDecayTypeCheck) { + for (uint8_t iFlag = 1; iFlag < hf_cand_bs::DecayTypeMc::NDecayTypeMc; ++iFlag) { + if (TESTBIT(flagMcMatchRec, iFlag)) { + registry.fill(HIST("hDecayTypeMc"), 1 + iFlag, invMassBs, ptCandBs); + } + } + } + } else { + registry.fill(HIST("hMass"), ptCandBs, invMassBs); + registry.fill(HIST("hPtProng0"), ptCandBs, candidate.ptProng0()); + registry.fill(HIST("hPtProng1"), ptCandBs, candidate.ptProng1()); + registry.fill(HIST("hImpParProd"), ptCandBs, candidate.impactParameterProduct()); + registry.fill(HIST("hDecLength"), ptCandBs, candidate.decayLength()); + registry.fill(HIST("hDecLengthXy"), ptCandBs, candidate.decayLengthXY()); + registry.fill(HIST("hNormDecLengthXy"), ptCandBs, candidate.decayLengthXY() / candidate.errorDecayLengthXY()); + registry.fill(HIST("hDcaProng0"), ptCandBs, candidate.impactParameter0()); + registry.fill(HIST("hDcaProng1"), ptCandBs, candidate.impactParameter1()); + registry.fill(HIST("hCosp"), ptCandBs, candidate.cpa()); + registry.fill(HIST("hCospXy"), ptCandBs, candidate.cpaXY()); + registry.fill(HIST("hEta"), ptCandBs, candidate.eta()); + registry.fill(HIST("hRapidity"), ptCandBs, hfHelper.yBs(candidate)); + registry.fill(HIST("hInvMassD"), ptDs, invMassDs); + registry.fill(HIST("hDecLengthD"), ptDs, decLenDs); + registry.fill(HIST("hDecLengthXyD"), ptDs, decLenXyDs); + registry.fill(HIST("hCospD"), ptDs, cospDs); + registry.fill(HIST("hCospXyD"), ptDs, cospXyDs); + + if constexpr (withDmesMl) { + registry.fill(HIST("hMlScoreBkgDs"), ptDs, candidate.prong0MlScoreBkg()); + registry.fill(HIST("hMlScorePromptDs"), ptDs, candidate.prong0MlScorePrompt()); + registry.fill(HIST("hMlScoreNonPromptDs"), ptDs, candidate.prong0MlScoreNonprompt()); + } + if constexpr (withBsMl) { + registry.fill(HIST("hMlScoreSigBs"), ptCandBs, candidate.mlProbBsToDsPi()[1]); + } + } + } + if (fillSparses) { + if constexpr (withDmesMl) { + 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()); + } else { + registry.fill(HIST("hMassPtCutVarsRecSig"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, decLenDs, cospDs); + } + } else if (fillBackground) { + if constexpr (withDmesMl) { + registry.fill(HIST("hMassPtCutVarsRecBg"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); + } else { + registry.fill(HIST("hMassPtCutVarsRecBg"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, decLenDs, cospDs); + } + } + } else { + if constexpr (withDmesMl) { + registry.fill(HIST("hMassPtCutVars"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, candidate.prong0MlScoreBkg(), candidate.prong0MlScoreNonprompt()); + } else { + registry.fill(HIST("hMassPtCutVars"), invMassBs, ptCandBs, candidate.decayLength(), candidate.decayLengthXY() / candidate.errorDecayLengthXY(), candidate.impactParameterProduct(), candidate.cpa(), invMassDs, ptDs, decLenDs, cospDs); + } + } + } + if (fillTree) { + float pseudoRndm = ptDs * 1000. - (int64_t)(ptDs * 1000); + if (flagMcMatchRec != 0 || (((doMc && fillBackground) || !doMc) && (ptCandBs >= ptMaxForDownSample || pseudoRndm < downSampleBkgFactor))) { + float prong0MlScoreBkg = -1.; + float prong0MlScorePrompt = -1.; + float prong0MlScoreNonprompt = -1.; + float candidateMlScoreSig = -1; + if constexpr (withDmesMl) { + prong0MlScoreBkg = candidate.prong0MlScoreBkg(); + prong0MlScorePrompt = candidate.prong0MlScorePrompt(); + prong0MlScoreNonprompt = candidate.prong0MlScoreNonprompt(); + } + if constexpr (withBsMl) { + candidateMlScoreSig = candidate.mlProbBsToDsPi()[1]; + } + auto prong1 = candidate.template prong1_as(); + + float ptMother = -1.; + if constexpr (doMc) { + ptMother = candidate.ptMother(); + } + + hfRedCandBsLite( + candidate.chi2PCA(), + candidate.decayLength(), + candidate.decayLengthXY(), + candidate.decayLengthNormalised(), + candidate.decayLengthXYNormalised(), + invMassDs, + ptDs, + candidate.ptProng1(), + candidate.impactParameter0(), + candidate.impactParameter1(), + candidate.impactParameterProduct(), + prong1.tpcNSigmaPi(), + prong1.tofNSigmaPi(), + prong0MlScoreBkg, + prong0MlScorePrompt, + prong0MlScoreNonprompt, + candidateMlScoreSig, + candidate.isSelBsToDsPi(), + invMassBs, + ptCandBs, + candidate.cpa(), + candidate.cpaXY(), + candidate.maxNormalisedDeltaIP(), + candidate.eta(), + candidate.phi(), + hfHelper.yBs(candidate), + flagMcMatchRec, + isSignal, + flagWrongCollision, + ptMother); + + if constexpr (withDecayTypeCheck) { + float candidateMlScoreSig = -1; + if constexpr (withBsMl) { + candidateMlScoreSig = candidate.mlProbBsToDsPi()[1]; + } + hfRedBsMcCheck( + flagMcMatchRec, + flagWrongCollision, + invMassDs, + ptDs, + invMassBs, + ptCandBs, + candidateMlScoreSig, + candidate.pdgCodeBeautyMother(), + candidate.pdgCodeCharmMother(), + candidate.pdgCodeProng0(), + candidate.pdgCodeProng1(), + candidate.pdgCodeProng2(), + candidate.pdgCodeProng3()); + } + } + } + } + + /// Fill particle histograms (gen MC truth) + void fillCandMcGen(aod::HfMcGenRedBss::iterator const& particle) + { + // keep only generated Bs with the analysis decay channel + if (!TESTBIT(std::abs(particle.flagMcMatchGen()), hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { + return; + } + 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 Bs 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, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // candidate loop + } // processData + PROCESS_SWITCH(HfTaskBsReduced, processData, "Process data without ML scores for Bs and D daughter", true); + + void processDataWithDmesMl(soa::Filtered> const& candidates, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // candidate loop + } // processDataWithDmesMl + PROCESS_SWITCH(HfTaskBsReduced, processDataWithDmesMl, "Process data with(out) ML scores for D daughter (Bs)", false); + + void processDataWithBsMl(soa::Filtered> const& candidates, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // candidate loop + } // processDataWithBsMl + PROCESS_SWITCH(HfTaskBsReduced, processDataWithBsMl, "Process data with(out) ML scores for Bs (D daughter)", false); + + void processMc(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBsReduced, processMc, "Process MC without ML scores for Bs and D daughter", false); + + void processMcWithDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBsReduced, processMcWithDecayTypeCheck, "Process MC with decay type check and without ML scores for Bs and D daughter", false); + + void processMcWithDmesMl(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithDmesMl + PROCESS_SWITCH(HfTaskBsReduced, processMcWithDmesMl, "Process MC with(out) ML scores for D daughter (Bs)", false); + + void processMcWithDmesMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBsReduced, processMcWithDmesMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for Bs (D daughter)", false); + + void processMcWithBsMl(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMcWithBsMl + PROCESS_SWITCH(HfTaskBsReduced, processMcWithBsMl, "Process MC with(out) ML scores for Bs (D daughter)", false); + + void processMcWithBsMlAndDecayTypeCheck(soa::Filtered> const& candidates, + aod::HfMcGenRedBss const& mcParticles, + aod::HfRed3Prongs const& candidatesD, + TracksPion const&) + { + // MC rec + for (const auto& candidate : candidates) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yBs(candidate)) > yCandRecoMax) { + continue; + } + fillCand(candidate, candidatesD); + } // rec + + // MC gen. level + for (const auto& particle : mcParticles) { + fillCandMcGen(particle); + } // gen + } // processMc + PROCESS_SWITCH(HfTaskBsReduced, processMcWithBsMlAndDecayTypeCheck, "Process MC with decay type check and with(out) ML scores for B0 (D daughter)", 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 105a3cdafa5..1594cc5e9cc 100644 --- a/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx +++ b/PWGHF/D2H/Tasks/taskCharmPolarisation.cxx @@ -16,6 +16,8 @@ /// \author S. Kundu (CERN) sourav.kundu@cern.ch /// \author M. Faggin (CERN) mattia.faggin@cern.ch +#include + #include "TRandom3.h" #include "Math/Vector3D.h" #include "Math/Vector4D.h" @@ -72,8 +74,11 @@ DECLARE_SOA_COLUMN(MassKPi, massKPi, float); DECLARE_SOA_COLUMN(MassKProton, massKProton, float); DECLARE_SOA_COLUMN(MassPiProton, massPiProton, float); DECLARE_SOA_COLUMN(BdtBkgScore, bdtBkgScore, float); -DECLARE_SOA_COLUMN(IsRealPKPi, isRealPKPi, bool); -DECLARE_SOA_COLUMN(IsReflected, isReflected, bool); +DECLARE_SOA_COLUMN(BdtNonPromptScore, bdtNonPromptScore, float); +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); } // namespace charm_polarisation @@ -90,8 +95,11 @@ DECLARE_SOA_TABLE(HfLcPolBkg, "AOD", "HFLCPOLBKG", charm_polarisation::MassKProton, charm_polarisation::MassPiProton, charm_polarisation::BdtBkgScore, + charm_polarisation::BdtNonPromptScore, charm_polarisation::IsRealPKPi, - charm_polarisation::IsReflected); + charm_polarisation::IsRealLcPKPi, + charm_polarisation::IsReflected, + charm_polarisation::Charge); } // namespace o2::aod @@ -125,12 +133,19 @@ struct TaskPolarisationCharmHadrons { // 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"}; /// activate rotational background Configurable nBkgRotations{"nBkgRotations", 0, "Number of rotated copies (background) per each original candidate"}; Configurable minRotAngleMultByPi{"minRotAngleMultByPi", 5. / 6, "Minimum angle rotation for track rotation, to be multiplied by pi"}; Configurable maxRotAngleMultByPi{"maxRotAngleMultByPi", 7. / 6, "Maximum angle rotation for track rotation, to be multiplied by pi"}; + // activate study of systematic uncertainties of tracking + Configurable activateTrackingSys{"activateTrackingSys", false, "Activate the study of systematic uncertainties of tracking"}; + /// output THnSparses Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", true, "Activate the THnSparse with cosThStar w.r.t. helicity axis"}; Configurable activateTHnSparseCosThStarProduction{"activateTHnSparseCosThStarProduction", true, "Activate the THnSparse with cosThStar w.r.t. production axis"}; @@ -140,14 +155,51 @@ struct TaskPolarisationCharmHadrons { float maxInvMass{1000.f}; /// table for Lc->pKpi background studies in MC - Configurable activateTableLcPKPiBkgMc{"activateTableLcPKPiBkgMc", false, "Activate the filling of the table to study Lc->PKPi background from MC"}; Configurable cosThStarAxisLcPKPiBkgMc{"cosThStarAxisLcPKPiBkgMc", 1, "cos(Theta*) axis for background studies (1 = helicity; 2 = production; 3 = beam; 4 = random)"}; + /// veto conditions for Lc->pKpi analysis + struct : ConfigurableGroup { + Configurable applyLcBkgVeto{"applyLcBkgVeto", false, "Flag to enable the veto on D+ and Ds+ background for Lc->pKpi analysis"}; + /// background from D+->K-pi+pi+ + Configurable enableLcBkgVetoDplusKPiPi{"enableLcBkgVetoDplusKPiPi", false, "Flag to enable the veto on D+->K-pi+pi+ for Lc->pKpi analysis"}; + Configurable massDplusKPiPiMinVeto{"massDplusKPiPiMinVeto", 1.85, "Min. value for D+->K-pi+pi+ veto"}; + Configurable massDplusKPiPiMaxVeto{"massDplusKPiPiMaxVeto", 1.90, "Max. value for D+->K-pi+pi+ veto"}; + /// background from D+->K+K-pi+ + Configurable enableLcBkgVetoDplusKKPi{"enableLcBkgVetoDplusKKPi", false, "Flag to enable the veto on D+->K+K-pi+ for Lc->pKpi analysis"}; + Configurable massDplusKKPiMinVeto{"massDplusKKPiMinVeto", 1.85, "Min. value for D+->K+K-pi+ veto"}; // one can use also massDplusKPiPiMinVeto, but this allows more flexibility in analysis + Configurable massDplusKKPiMaxVeto{"massDplusKKPiMaxVeto", 1.90, "Max. value for D+->K+K-pi+ veto"}; // one can use also massDplusKPiPiMaxVeto, but this allows more flexibility in analysis + /// background from Ds+->K+K-pi+ + Configurable enableLcBkgVetoDsKKPi{"enableLcBkgVetoDsKKPi", false, "Flag to enable the veto on Ds+->K+K-pi+ for Lc->pKpi analysis"}; + Configurable massDsKKPiMinVeto{"massDsKKPiMinVeto", 1.94, "Min. value for Ds+->K+K-pi+ veto"}; + Configurable massDsKKPiMaxVeto{"massDsKKPiMaxVeto", 2.00, "Max. value for Ds+->K+K-pi+ veto"}; + } lcBkgVeto; + 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 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})"}; + + /// veto conditions on Lc->pKpi signals + Configurable applyLcSignalVeto{"applyLcSignalVeto", false, "Flag to enable the veto on Lc->pKpi resonant channels"}; + Configurable mass2PPiLcMinVeto{"mass2PPiLcMinVeto", 1.f, "Min. value for Delta++(<-Lc) mass veto"}; + Configurable mass2PPiLcMaxVeto{"mass2PPiLcMaxVeto", 1.6f, "Max. value for Delta++(<-Lc) mass veto"}; + + } lcPKPiChannels; + + /// 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); using CollisionsWithMcLabels = soa::SmallGroups>; - using TracksWithMcLabels = soa::Join; + using TracksWithMcLabels = soa::Join; + using TracksWithExtra = soa::Join; using McParticlesDstarMatched = soa::Join; using McParticles3ProngMatched = soa::Join; @@ -182,7 +234,7 @@ struct TaskPolarisationCharmHadrons { void init(InitContext&) { /// check process functions - std::array processes = {doprocessDstar, doprocessDstarWithMl, doprocessLcToPKPi, doprocessLcToPKPiWithMl, doprocessDstarMc, doprocessDstarMcWithMl, doprocessLcToPKPiMc, doprocessLcToPKPiMcWithMl}; + std::array processes = {doprocessDstar, doprocessDstarWithMl, doprocessLcToPKPi, doprocessLcToPKPiWithMl, doprocessDstarMc, doprocessDstarMcWithMl, doprocessLcToPKPiMc, doprocessLcToPKPiMcWithMl, doprocessLcToPKPiBackgroundMcWithMl}; 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"); @@ -210,15 +262,10 @@ struct TaskPolarisationCharmHadrons { } // check bkg rotation for MC (not supported currently) - if (nBkgRotations > 0 && (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl)) { + if (nBkgRotations > 0 && (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl || doprocessLcToPKPiBackgroundMcWithMl)) { LOGP(fatal, "No background rotation supported for MC."); } - /// check configurations of the table for Lc->pKpi background studies - if (activateTableLcPKPiBkgMc && (cosThStarAxisLcPKPiBkgMc < 1 || cosThStarAxisLcPKPiBkgMc > 4)) { - LOGP(fatal, "cosThStarAxisLcPKPiBkgMc axis chosen is wrong. Fix it! (1 = helicity; 2 = production; 3 = beam; 4 = random)"); - } - massPi = o2::constants::physics::MassPiPlus; massProton = o2::constants::physics::MassProton; massKaon = o2::constants::physics::MassKaonCharged; @@ -242,6 +289,14 @@ struct TaskPolarisationCharmHadrons { const AxisSpec thnAxisPtB{configThnAxisPtB, "#it{p}_{T}(B mother) (GeV/#it{c})"}; const AxisSpec thnAxisDausAcc{2, -0.5f, 1.5f, "daughters in acceptance"}; const AxisSpec thnAxisResoChannelLc{4, -0.5, 3.5, "0: direct 1,2,3: resonant"}; // 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π± + const AxisSpec thnAxisAbsEtaTrackMin{configThnAxisAbsEtaTrackMin, "min |#it{#eta_{track}}|"}; + const AxisSpec thnAxisNumItsClsMin{configThnAxisNumItsClsMin, "min #it{N}_{cls ITS}"}; + const AxisSpec thnAxisNumTpcClsMin{configThnAxisNumTpcClsMin, "min #it{N}_{cls TPC}"}; + const AxisSpec thnAxisCharge{configThnAxisCharge, "charge"}; + const AxisSpec thnAxisInvMass2KPiLcMonitoring{lcPKPiChannels.configThnAxisInvMass2KPiLcMonitoring, "#it{M}^{2}(K#pi) from #Lambda_{c}^{+} (GeV/#it{c}^{2}"}; + 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"}; auto invMassBins = thnAxisInvMass.binEdges; minInvMass = invMassBins.front(); @@ -255,156 +310,203 @@ struct TaskPolarisationCharmHadrons { /// 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, thnAxisIsRotatedCandidate}); + 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, thnAxisIsRotatedCandidate}); + 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, thnAxisIsRotatedCandidate}); + 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 (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, thnAxisIsRotatedCandidate}); + 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 (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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, thnAxisPtB}); } } - } else if (doprocessLcToPKPiWithMl || doprocessLcToPKPiMcWithMl) { + } 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, thnAxisIsRotatedCandidate}); + 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 (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, thnAxisIsRotatedCandidate}); + 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}); + } } 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, thnAxisIsRotatedCandidate}); + 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 (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, thnAxisIsRotatedCandidate}); + 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}); } } 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}); - 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}); + 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) { - 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}); - 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}); + 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}); + } } 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}); - 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}); + 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}); + } } 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}); - 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}); + 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}); } } } 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, thnAxisIsRotatedCandidate}); + 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 (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarProduction, thnAxisIsRotatedCandidate}); + 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, thnAxisIsRotatedCandidate}); + 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 (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassD0, thnAxisCosThetaStarRandom, thnAxisIsRotatedCandidate}); + 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 (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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, 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}); - 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, thnAxisPtB}); + 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}); + 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, 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, thnAxisIsRotatedCandidate}); + 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 (activateTHnSparseCosThStarProduction) { - registry.add("hProduction", "THn for polarisation studies with cosThStar w.r.t. production axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarProduction, thnAxisIsRotatedCandidate}); + 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}); + } } if (activateTHnSparseCosThStarBeam) { - registry.add("hBeam", "THn for polarisation studies with cosThStar w.r.t. beam axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarBeam, thnAxisIsRotatedCandidate}); + 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 (activateTHnSparseCosThStarRandom) { - registry.add("hRandom", "THn for polarisation studies with cosThStar w.r.t. random axis", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisNumPvContributors, thnAxisY, thnAxisInvMassKPiLc, thnAxisCosThetaStarRandom, thnAxisIsRotatedCandidate}); + 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}); } } 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}); - 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}); + 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 (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}); - 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}); + 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}); + } } 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}); - 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}); + 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 (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}); - 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}); + 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}); } } } // MC Gen histos - if (doprocessDstarMc || doprocessDstarMcWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl) { + 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}); - 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}); + 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}); - 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}); + 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}); - 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}); + 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}); - 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}); + 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}); } } + /// control plots for Lc->pKPi + if ((doprocessLcToPKPi || doprocessLcToPKPiWithMl || doprocessLcToPKPiMc || doprocessLcToPKPiMcWithMl) && lcPKPiChannels.activateTHnLcChannelMonitor) { + registry.add("hMass2PairsLcPKPi", "THnSparse to monitor M2(Kpi), M2(pK), M2(ppi), pt correlation for Lc -> pKpi", HistType::kTHnSparseF, {thnAxisInvMass2KPiLcMonitoring, thnAxisInvMass2PKLcMonitoring, thnAxisInvMass2PPiLcMonitoring, thnAxisPt}); + } + // inv. mass hypothesis to loop over // e.g.: Lc->pKpi has the ambiguity pKpi vs. piKp if (doprocessLcToPKPi || doprocessLcToPKPiWithMl) { @@ -422,57 +524,80 @@ struct TaskPolarisationCharmHadrons { /// \param rapCharmHad is the rapidity of the candidate /// \param invMassD0 is the invariant-mass of the D0 daugher (only for D*+) /// \param invMassKPiLc is the invariant-mass of the K-pi pair (only for Lc+) + /// \param invMassPKLc is the invariant-mass of the p-K pair (only for Lc+) + /// \param invMassPPiLc is the invariant-mass of the p-pi pair (only for Lc+) /// \param cosThetaStar is the cosThetaStar of the candidate /// \param outputMl is the array with ML output scores /// \param isRotatedCandidate is a flag that keeps the info of the rotation of the candidate for bkg studies /// \param origin is the MC origin /// \param ptBhadMother is the pt of the b-hadron mother (only in case of non-prompt) /// \param resoChannelLc indicates the Lc decay channel (direct, resonant) + /// \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 template - void fillRecoHistos(float invMassCharmHad, float ptCharmHad, int numPvContributors, float rapCharmHad, float invMassD0, float invMassKPiLc, float cosThetaStar, std::array outputMl, int isRotatedCandidate, int8_t origin, float ptBhadMother, int8_t resoChannelLc) + 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) { 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, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + 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) { + registry.fill(HIST("hEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], charge); + } } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, charge); + } } } } else { // MC --> no distinction among channels, since rotational bkg not supported 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]); + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); } 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); + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } 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], ptBhadMother); + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, 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); + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } } 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); + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, ptBhadMother); + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, ptBhadMother); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoNonPromptHelicity"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiHelicity"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } } @@ -481,44 +606,62 @@ 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, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + 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) { + registry.fill(HIST("hEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], charge); + } } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hProduction"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, charge); + } } } } else { // MC --> no distinction among channels, since rotational bkg not supported 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]); + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); } 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); + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } 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], ptBhadMother); + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, 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); + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } } 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); + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, ptBhadMother); + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, ptBhadMother); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoNonPromptProduction"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiProduction"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } } @@ -527,44 +670,62 @@ 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, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + 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) { + registry.fill(HIST("hEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], charge); + } } } else { // without ML if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hBeam"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, charge); + } } } } else { // MC --> no distinction among channels, since rotational bkg not supported 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]); + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); } 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); + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } 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], ptBhadMother); + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, 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); + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, charge); + } } } } 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); + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecPromptEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } else { // non-prompt if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { // D*+ - registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, ptBhadMother); + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, ptBhadMother); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoNonPromptBeam"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); + if (activateTHnEulerPhiMonitor) { + registry.fill(HIST("hRecNonPromptEulerPhiBeam"), invMassCharmHad, ptCharmHad, invMassKPiLc, phiEuler, resoChannelLc, charge); + } } } } @@ -573,44 +734,44 @@ 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, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], isRotatedCandidate); + 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, rapCharmHad, invMassD0, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, isRotatedCandidate); + registry.fill(HIST("hRandom"), invMassCharmHad, ptCharmHad, numPvContributors, std::abs(rapCharmHad), invMassKPiLc, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, isRotatedCandidate, charge); } } } else { // MC --> no distinction among channels, since rotational bkg not supported 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]); + registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin); } 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); + 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], ptBhadMother); + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], absEtaMin, numItsClsMin, numTpcClsMin, 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); + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, outputMl[0], /*outputMl[1],*/ outputMl[2], resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } } } 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); + registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + 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, ptBhadMother); + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassD0, cosThetaStar, absEtaMin, numItsClsMin, numTpcClsMin, ptBhadMother); } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { // Lc+ - registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc); + registry.fill(HIST("hRecoNonPromptRandom"), invMassCharmHad, ptCharmHad, numPvContributors, rapCharmHad, invMassKPiLc, cosThetaStar, resoChannelLc, absEtaMin, numItsClsMin, numTpcClsMin, charge); } } } @@ -627,31 +788,31 @@ struct TaskPolarisationCharmHadrons { /// \param areDausInAcc is a flag indicating whether the daughters are in acceptance or not /// \param resoChannelLc indicates the Lc decay channel (direct, resonant) template - void fillGenHistos(float ptCharmHad, int numPvContributors, float rapCharmHad, float cosThetaStar, int8_t origin, float ptBhadMother, bool areDausInAcc, uint8_t resoChannelLc) + void fillGenHistos(float ptCharmHad, int numPvContributors, float rapCharmHad, float cosThetaStar, int8_t origin, float ptBhadMother, bool areDausInAcc, uint8_t resoChannelLc, int8_t charge) { if constexpr (cosThetaStarType == charm_polarisation::CosThetaStarType::Helicity) { // Helicity if (origin == RecoDecay::OriginType::Prompt) { // prompt - registry.fill(HIST("hGenPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc); + registry.fill(HIST("hGenPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); } else { // non-prompt - registry.fill(HIST("hGenNonPromptHelicity"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc); + registry.fill(HIST("hGenNonPromptHelicity"), 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); + registry.fill(HIST("hGenPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); } else { // non-prompt - registry.fill(HIST("hGenNonPromptProduction"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc); + registry.fill(HIST("hGenNonPromptProduction"), 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); + registry.fill(HIST("hGenPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); } else { // non-prompt - registry.fill(HIST("hGenNonPromptBeam"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc); + registry.fill(HIST("hGenNonPromptBeam"), 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); + registry.fill(HIST("hGenPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, areDausInAcc, resoChannelLc, charge); } else { // non-prompt - registry.fill(HIST("hGenNonPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc); + registry.fill(HIST("hGenNonPromptRandom"), ptCharmHad, numPvContributors, rapCharmHad, cosThetaStar, ptBhadMother, areDausInAcc, resoChannelLc, charge); } } } @@ -705,14 +866,17 @@ struct TaskPolarisationCharmHadrons { return true; } + /// \param prongTrack is the track we want to find the mother of + /// \param idMothers is the vector containing the mother IDs + /// \param particles are the MC particles template - void searchFirstLevelMother(Trk const& prongTrack, std::vector& idMothers, Part const&) + void searchFirstLevelMother(Trk const& prongTrack, std::vector& idMothers, Part const& /*particles*/) { /// particle associated to the prong track if (!prongTrack.has_mcParticle()) { return; } - auto prongParticle = prongTrack.mcParticle(); + auto prongParticle = prongTrack.template mcParticle_as(); /// leave the vector of mother indices empty if the currect paticle has no mothers if (!prongParticle.has_mothers()) { return; @@ -724,18 +888,45 @@ struct TaskPolarisationCharmHadrons { } }; + /// prongTracks is the vector of daughter tracks + /// etaMin is the minimum eta + /// nItsClsMin is the minumum number of clusters in ITS + /// nTpcClsMin is the minumum number of clusters in TPC + template + void getTrackingInfos(std::vector const& prongTracks, float& etaMin, int& nItsClsMin, int& nTpcClsMin) + { + etaMin = 10.f; + nItsClsMin = 10; + nTpcClsMin = 1000; + + for (const auto& track : prongTracks) { + if (std::abs(track.eta()) < etaMin) { + etaMin = std::abs(track.eta()); + } + if (track.itsNCls() < nItsClsMin) { + nItsClsMin = track.itsNCls(); + } + if (track.tpcNClsCrossedRows() < nTpcClsMin) { + nTpcClsMin = track.tpcNClsCrossedRows(); + } + } + } + /// \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, Part const& particles, int bkgRotationId, int numPvContributors, Trk const&) + template + bool runPolarisationAnalysis(Cand const& candidate, int bkgRotationId, int numPvContributors, Part const& particles, Trk const& /*tracks*/) { 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; 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 @@ -749,16 +940,31 @@ struct TaskPolarisationCharmHadrons { return isCandidateInSignalRegion; } } else if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { - if (!TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::LcToPKPi)) { // this candidate is not signal, skip - return isCandidateInSignalRegion; - } - origin = candidate.originMcRec(); - if (candidate.isCandidateSwapped()) { - massHypoMcTruth = charm_polarisation::MassHyposLcToPKPi::PiKP; - } else { - massHypoMcTruth = charm_polarisation::MassHyposLcToPKPi::PKPi; + 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 + return isCandidateInSignalRegion; + } + origin = candidate.originMcRec(); + if (candidate.isCandidateSwapped()) { + massHypoMcTruth = charm_polarisation::MassHyposLcToPKPi::PiKP; + } else { + massHypoMcTruth = charm_polarisation::MassHyposLcToPKPi::PKPi; + } + resoChannelLc = candidate.flagMcDecayChanRec(); /// 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π± } - resoChannelLc = candidate.flagMcDecayChanRec(); /// 0: direct; 1: Λc± → p± K*; 2: Λc± → Δ(1232)±± K∓; 3: Λc± → Λ(1520) π± + + /// Lc electric charge from MC truth + /// This is checked when the reconstructed 3-prong candidate is matched to MC with RecoDecay::getMatchedMCRec + int8_t flagMc = candidate.flagMcMatchRec(); + charge = std::abs(flagMc) > 0 ? flagMc / std::abs(flagMc) : 0; /// 0 should never happen, debug protection + } + } else { + /// data + if constexpr (channel == charm_polarisation::DecayChannel::LcToPKPi) { + /// Calculate the electric charge from reconstructed daughter tracks + /// Lc charge == first daughter charge + auto trackProng0 = candidate.template prong0_as(); + charge = static_cast(trackProng0.sign()); } } @@ -768,7 +974,7 @@ struct TaskPolarisationCharmHadrons { // variable definition float pxDau{-1000.f}, pyDau{-1000.f}, pzDau{-1000.f}; float pxCharmHad{-1000.f}, pyCharmHad{-1000.f}, pzCharmHad{-1000.f}; - float massDau{0.f}, invMassCharmHad{0.f}, invMassCharmHadForSparse{0.f}, invMassD0{0.f}, invMassKPiLc{0.f}; + float massDau{0.f}, invMassCharmHad{0.f}, invMassCharmHadForSparse{0.f}, invMassD0{0.f}, invMassKPiLc{0.f}, invMassPKLc{0.f}, invMassPPiLc{0.f}; float rapidity{-999.f}; std::array outputMl{-1.f, -1.f, -1.f}; int isRotatedCandidate = 0; // currently meaningful only for Lc->pKpi @@ -858,6 +1064,9 @@ struct TaskPolarisationCharmHadrons { rapidity = RecoDecay::y(candidate.pVector(), massLc); /// mass-hypothesis-dependent variables + float invMassPiKPi = 0.f; // bkg. from D+ -> K+pi-pi- + float invMassKKPi = 0.f; // bkg. from D+, Ds+ -> K+K-pi+ (1st mass hypothesis) + float invMassPiKK = 0.f; // bkg. from D+, Ds+ -> pi+K-K+ (2nd mass hypothesis) if (iMass == charm_polarisation::MassHyposLcToPKPi::PKPi && candidate.isSelLcToPKPi() >= selectionFlagLcToPKPi) { // reconstructed as pKpi pxDau = candidate.pxProng0(); @@ -884,6 +1093,14 @@ struct TaskPolarisationCharmHadrons { } // invariant mass of the KPi pair invMassKPiLc = hfHelper.invMassKPiPairLcToPKPi(candidate); + invMassPKLc = hfHelper.invMassPKPairLcToPKPi(candidate); + invMassPPiLc = hfHelper.invMassPPiPairLcToPKPi(candidate); + + // D+ and Ds+ invariant mass values, to put a veto on background sources + invMassPiKPi = hfHelper.invMassDplusToPiKPi(candidate); // bkg. from D+ -> K+pi-pi- + invMassKKPi = hfHelper.invMassDsToKKPi(candidate); // bkg. from D+, Ds+ -> K+K-pi+ (1st mass hypothesis) + invMassPiKK = hfHelper.invMassDsToPiKK(candidate); // bkg. from D+, Ds+ -> pi+K-K+ (2nd mass hypothesis) + } else if (iMass == charm_polarisation::MassHyposLcToPKPi::PiKP && candidate.isSelLcToPiKP() >= selectionFlagLcToPKPi) { // reconstructed as piKp pxDau = candidate.pxProng2(); @@ -910,6 +1127,14 @@ struct TaskPolarisationCharmHadrons { } // invariant mass of the KPi pair invMassKPiLc = hfHelper.invMassKPiPairLcToPiKP(candidate); + invMassPKLc = hfHelper.invMassPKPairLcToPiKP(candidate); + invMassPPiLc = hfHelper.invMassPPiPairLcToPiKP(candidate); + + // D+ and Ds+ invariant mass values, to put a veto on background sources + invMassPiKPi = hfHelper.invMassDplusToPiKPi(candidate); // bkg. from D+ -> K+pi-pi- + invMassKKPi = hfHelper.invMassDsToKKPi(candidate); // bkg. from D+, Ds+ -> K+K-pi+ (1st mass hypothesis) + invMassPiKK = hfHelper.invMassDsToPiKK(candidate); // bkg. from D+, Ds+ -> pi+K-K+ (2nd mass hypothesis) + } else { // NB: no need to check cases in which candidate.isSelLcToPKPi() and candidate.isSelLcToPiKP() are both false, because they are rejected already by the Filter // ... but we need to put this protections here! @@ -917,12 +1142,42 @@ struct TaskPolarisationCharmHadrons { continue; } + /// put veto on D+, Ds+ inv. masses, to reduce the background + if (lcBkgVeto.applyLcBkgVeto && ((lcBkgVeto.enableLcBkgVetoDplusKPiPi && lcBkgVeto.massDplusKPiPiMinVeto < invMassPiKPi && invMassPiKPi < lcBkgVeto.massDplusKPiPiMaxVeto) /*bkg. from D+ -> K+pi-pi-*/ || + (lcBkgVeto.enableLcBkgVetoDplusKKPi && lcBkgVeto.massDplusKKPiMinVeto < invMassKKPi && invMassKKPi < lcBkgVeto.massDplusKKPiMaxVeto) /*bkg. from D+ -> K+K-pi+ (1st mass hypothesis)*/ || + (lcBkgVeto.enableLcBkgVetoDplusKKPi && lcBkgVeto.massDplusKKPiMinVeto < invMassPiKK && invMassPiKK < lcBkgVeto.massDplusKKPiMaxVeto) /*bkg. from D+ -> K+K-pi+ (2nd mass hypothesis)*/ || + (lcBkgVeto.enableLcBkgVetoDsKKPi && lcBkgVeto.massDsKKPiMinVeto < invMassKKPi && invMassKKPi < lcBkgVeto.massDsKKPiMaxVeto) /*bkg. from Ds+ -> K+K-pi+ (1st mass hypothesis)*/ || + (lcBkgVeto.enableLcBkgVetoDsKKPi && lcBkgVeto.massDsKKPiMinVeto < invMassPiKK && invMassPiKK < lcBkgVeto.massDsKKPiMaxVeto)) /*bkg. from Ds+ -> K+K-pi+ (2nd mass hypothesis)*/) { + /// this candidate has D+ and/or Ds+ in the veto range, let's reject it + continue; + } + + /// control plots on pair masses + double invMass2KPiLc = invMassKPiLc * invMassKPiLc; + double invMass2PKLc = invMassPKLc * invMassPKLc; + double invMass2PPiLc = invMassPPiLc * invMassPPiLc; + if (lcPKPiChannels.activateTHnLcChannelMonitor && bkgRotationId == 0) { + /// fill Dalitz plot only for genuine candidates (i.e. non-rotated) + registry.fill(HIST("hMass2PairsLcPKPi"), invMass2KPiLc, invMass2PKLc, invMass2PPiLc, candidate.pt()); + } + + /// veto cut on pair masses + if (lcPKPiChannels.applyLcSignalVeto && lcPKPiChannels.mass2PPiLcMinVeto < invMass2PPiLc && invMass2PPiLc < lcPKPiChannels.mass2PPiLcMaxVeto) { + /// this candidate has a significant contribution from Lc+ -> Delta++ K-, let's reject it + continue; + } + } // Lc->pKpi if (invMassCharmHadForSparse < minInvMass || invMassCharmHadForSparse > maxInvMass) { continue; } + /// apply rapidity selection on the reconstructed candidate + if (std::abs(rapidity) > rapidityCut) { + continue; + } + float phiRandom = gRandom->Uniform(0.f, constants::math::TwoPI); float thetaRandom = gRandom->Uniform(0.f, constants::math::PI); ROOT::Math::PxPyPzMVector fourVecDau = ROOT::Math::PxPyPzMVector(pxDau, pyDau, pzDau, massDau); @@ -937,38 +1192,81 @@ struct TaskPolarisationCharmHadrons { isCandidateInSignalRegion = isInSignalRegion(invMassCharmHadForSparse); } + float absEtaTrackMin{-1.f}; + int numItsClsMin{-1}, numTpcClsMin{-1}; + + if (activateTrackingSys) { + auto trackProng0 = candidate.template prong0_as(); + auto trackProng1 = candidate.template prong1_as(); + if constexpr (channel == charm_polarisation::DecayChannel::DstarToDzeroPi) { + auto trackProng2 = candidate.template prongPi_as(); + getTrackingInfos(std::vector{trackProng0, trackProng1, trackProng2}, absEtaTrackMin, numItsClsMin, numTpcClsMin); + } else if (channel == charm_polarisation::DecayChannel::LcToPKPi) { + auto trackProng2 = candidate.template prong2_as(); + getTrackingInfos(std::vector{trackProng0, trackProng1, trackProng2}, absEtaTrackMin, numItsClsMin, numTpcClsMin); + } + } + + // helicity + ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); float cosThetaStarHelicity = -10.f; + float phiHelicity = -10.f; + // production + ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(pyCharmHad, -pxCharmHad, 0.f); float cosThetaStarProduction = -10.f; + float phiProduction = -10.f; + // beam + ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); float cosThetaStarBeam = -10.f; + float phiBeam = -10.f; + // random float cosThetaStarRandom = -10.f; + if (activateTHnSparseCosThStarHelicity) { - ROOT::Math::XYZVector helicityVec = fourVecMother.Vect(); + // helicity cosThetaStarHelicity = helicityVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(helicityVec.Mag2()); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarHelicity, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc); + 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); } if (activateTHnSparseCosThStarProduction) { - ROOT::Math::XYZVector normalVec = ROOT::Math::XYZVector(pyCharmHad, -pxCharmHad, 0.f); + // production cosThetaStarProduction = normalVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(normalVec.Mag2()); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarProduction, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc); + 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); } if (activateTHnSparseCosThStarBeam) { - ROOT::Math::XYZVector beamVec = ROOT::Math::XYZVector(0.f, 0.f, 1.f); + // beam cosThetaStarBeam = beamVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()); - fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarBeam, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc); + 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); } 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, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc); + fillRecoHistos(invMassCharmHadForSparse, ptCharmHad, numPvContributors, rapidity, invMassD0, invMassKPiLc, cosThetaStarRandom, -99.f, outputMl, isRotatedCandidate, origin, ptBhadMother, resoChannelLc, absEtaTrackMin, numItsClsMin, numTpcClsMin, charge); } /// Table for Lc->pKpi background studies /// Defined only in MC simulations, to study resonances and reflected signal if constexpr (doMc && channel == charm_polarisation::DecayChannel::LcToPKPi) { - if (activateTableLcPKPiBkgMc) { + if constexpr (studyLcPKPiBkgMc) { + /****************************************************************************************** + The code below can work only without grouping on "mcCollision". + In fact, grouping by "mcCollision" introduces the following inconsistencies: + + 1) the particle getters "track.template mcParticle_as()" retrieve the daughter particles quering the full particle table in the dataframe. + In other words, even if the 3-prong candidate is reconstructed in a completely wrong reco. collision due to the track-to-collision associator, + therefore this collision points to a "mcCollision" different from the current one and the daughter particles are associated to this different "mcCollision", + the getter "mcParticle_as" works anyway, because it works with unbound tables ignoring the fact that "particles" is grouped; + + 2) when we look for the mother index from the daughter particles of the previous point, but the daughter particles belong to a "mcCollision" different from the current one, + then also the mother particle belongs to this different "mcCollision". This means that the mother index ( - "particles.offset()") is outside the "particles.size()", + because the table "particles" is grouped w.r.t. the current "mcCollision". + *******************************************************************************************/ /// check if the tracks are associated to a pion + a kaon + a proton - bool isRealPKPi = false; /// true only if the triplet is formed by a MC pion + a MC kaon + a MC proton + int8_t isRealPKPi = 0; /// true only if the triplet is formed by a MC pion + a MC kaon + a MC proton bool isGenPKPi = false; bool isGenPiKP = false; auto trackProng0 = candidate.template prong0_as(); @@ -978,25 +1276,40 @@ struct TaskPolarisationCharmHadrons { int pdgProng1 = 0; int pdgProng2 = 0; if (trackProng0.has_mcParticle()) { - pdgProng0 = trackProng0.mcParticle().pdgCode(); + /// 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(); } if (trackProng1.has_mcParticle()) { - pdgProng1 = trackProng1.mcParticle().pdgCode(); + /// 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(); } if (trackProng2.has_mcParticle()) { - pdgProng2 = trackProng2.mcParticle().pdgCode(); + /// 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(); } 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; if (isGenPKPi || isGenPiKP) { - isRealPKPi = true; + isRealPKPi = 1; } /// check if the triplet is reflected or not /// i.e. generated as pKpi but reconstructed as piKp, or viceversa - bool isReflected = false; + int8_t isReflected = 0; if (isRealPKPi && ((iMass == charm_polarisation::MassHyposLcToPKPi::PKPi && candidate.isSelLcToPKPi() >= selectionFlagLcToPKPi && isGenPiKP) || (iMass == charm_polarisation::MassHyposLcToPKPi::PiKP && candidate.isSelLcToPiKP() >= selectionFlagLcToPKPi && isGenPKPi))) { - isReflected = true; + isReflected = 1; + } + + /// 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)) { + isRealLcPKPi = 1; } /// look for daughters' mothers (1st level only) @@ -1012,20 +1325,28 @@ struct TaskPolarisationCharmHadrons { int pdgMotherProng0 = -1; int pdgMotherProng1 = -1; int pdgMotherProng2 = -1; - if (idMothersProng0.size() > 0 && idMothersProng1.size() > 0 && idMothersProng0.at(0) == idMothersProng1.at(0)) { - auto mother = particles.rawIteratorAt(idMothersProng0.at(0) - particles.offset()); - pdgMotherProng0 = std::abs(mother.pdgCode()); // PDG code of the mother - pdgMotherProng1 = pdgMotherProng0; - } - if (idMothersProng1.size() > 0 && idMothersProng2.size() > 0 && idMothersProng1.at(0) == idMothersProng2.at(0)) { - auto mother = particles.rawIteratorAt(idMothersProng1.at(0) - particles.offset()); - pdgMotherProng1 = std::abs(mother.pdgCode()); // PDG code of the mother - pdgMotherProng2 = pdgMotherProng1; - } - if (idMothersProng0.size() > 0 && idMothersProng2.size() > 0 && idMothersProng0.at(0) == idMothersProng2.at(0)) { - auto mother = particles.rawIteratorAt(idMothersProng0.at(0) - particles.offset()); - pdgMotherProng0 = std::abs(mother.pdgCode()); // PDG code of the mother - pdgMotherProng2 = pdgMotherProng0; + bool atLeast2ProngsFromSameMother = (idMothersProng0.size() > 0 && idMothersProng1.size() > 0 && idMothersProng0.at(0) == idMothersProng1.at(0)) || + (idMothersProng1.size() > 0 && idMothersProng2.size() > 0 && idMothersProng1.at(0) == idMothersProng2.at(0)) || + (idMothersProng0.size() > 0 && idMothersProng2.size() > 0 && idMothersProng0.at(0) == idMothersProng2.at(0)); + if (atLeast2ProngsFromSameMother) { + if (idMothersProng0.size() > 0) { + /// BEWARE: in case of mcCollision grouping, the idMother can anyway point to a particle in another collision (*) + /// therefore the rawIteratorAt call might crash the code because one goes above the (grouped) particles table size + auto mother = particles.rawIteratorAt(idMothersProng0.at(0) - particles.offset()); + pdgMotherProng0 = std::abs(mother.pdgCode()); // PDG code of the mother + } + if (idMothersProng1.size() > 0) { + /// BEWARE: in case of mcCollision grouping, the idMother can anyway point to a particle in another collision (*) + /// therefore the rawIteratorAt call might crash the code because one goes above the (grouped) particles table size + auto mother = particles.rawIteratorAt(idMothersProng1.at(0) - particles.offset()); + pdgMotherProng1 = std::abs(mother.pdgCode()); // PDG code of the mother + } + if (idMothersProng2.size() > 0) { + /// BEWARE: in case of mcCollision grouping, the idMother can anyway point to a particle in another collision (*) + /// therefore the rawIteratorAt call might crash the code because one goes above the (grouped) particles table size + auto mother = particles.rawIteratorAt(idMothersProng2.at(0) - particles.offset()); + pdgMotherProng2 = std::abs(mother.pdgCode()); // PDG code of the mother + } } /// calculate inv. masses for pairs, depending on mass hypothesis @@ -1059,15 +1380,19 @@ struct TaskPolarisationCharmHadrons { case 4: cosThetaStarForTable = cosThetaStarRandom; break; + default: + LOG(fatal) << "cosThStarAxisLcPKPiBkgMc must be between 1 and 4 (1: helicity; 2: production; 3: beam; 4: random), but cosThStarAxisLcPKPiBkgMc = " << cosThStarAxisLcPKPiBkgMc << ". Fix it!"; + break; } rowCandLcBkg(invMassCharmHadForSparse, ptCharmHad, rapidity, cosThetaStarForTable, pdgMotherProng0, pdgMotherProng1, pdgMotherProng2, massKPi, massKProton, massPiProton, - outputMl.at(0), - isRealPKPi, isReflected); - } // end activateTableLcPKPiBkgMc - } // end table for Lc->pKpi background studies + outputMl.at(0), outputMl.at(2), + isRealPKPi, isRealLcPKPi, isReflected, + charge); + } // end studyLcPKPiBkgMc + } // end table for Lc->pKpi background studies } /// end loop over mass hypotheses @@ -1086,6 +1411,7 @@ struct TaskPolarisationCharmHadrons { float ptBhadMother{-1.f}; bool areDauInAcc{true}; int8_t resoChannelLc = -1; + int8_t charge = -99; 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 return; @@ -1115,6 +1441,10 @@ struct TaskPolarisationCharmHadrons { RecoDecay::getDaughters(mcParticle, &listDaughters, dauPdgs, 2); massDau = massProton; massCharmHad = massLc; + + /// electric charge from PDG code + int pdgCode = mcParticle.pdgCode(); + charge = static_cast(pdgCode / std::abs(pdgCode)); } float rapidity = mcParticle.y(); @@ -1172,22 +1502,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); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarHelicity, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); } 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); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarProduction, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); } 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); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarBeam, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); } 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); + fillGenHistos(ptCharmHad, numPvContributors, rapidity, cosThetaStarRandom, origin, ptBhadMother, areDauInAcc, resoChannelLc, charge); } } @@ -1197,7 +1527,8 @@ struct TaskPolarisationCharmHadrons { // Dstar with rectangular cuts void processDstar(aod::Collisions const& collisions, - FilteredCandDstarWSelFlag const& dstarCandidates) + FilteredCandDstarWSelFlag const& dstarCandidates, + TracksWithExtra const& tracks) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); @@ -1207,12 +1538,12 @@ struct TaskPolarisationCharmHadrons { for (const auto& dstarCandidate : groupedDstarCandidates) { nCands++; - if (runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } for (int iRotation{1}; iRotation <= nBkgRotations; ++iRotation) { - runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, iRotation, numPvContributors, -1 /*tracks*/); + runPolarisationAnalysis(dstarCandidate, iRotation, numPvContributors, -1 /*MC particles*/, tracks); } } fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); @@ -1222,7 +1553,8 @@ struct TaskPolarisationCharmHadrons { // Dstar with ML cuts void processDstarWithMl(aod::Collisions const& collisions, - FilteredCandDstarWSelFlagAndMl const& dstarCandidates) + FilteredCandDstarWSelFlagAndMl const& dstarCandidates, + TracksWithExtra const& tracks) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); @@ -1232,12 +1564,12 @@ struct TaskPolarisationCharmHadrons { for (const auto& dstarCandidate : groupedDstarCandidates) { nCands++; - if (runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } for (int iRotation{1}; iRotation <= nBkgRotations; ++iRotation) { - runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, iRotation, numPvContributors, -1 /*tracks*/); + runPolarisationAnalysis(dstarCandidate, iRotation, numPvContributors, -1 /*MC particles*/, tracks); } } fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); @@ -1249,7 +1581,8 @@ struct TaskPolarisationCharmHadrons { void processDstarMc(aod::McCollisions::iterator const&, McParticlesDstarMatched const& mcParticles, CollisionsWithMcLabels const& collisions, // this is grouped with SmallGroupsCollisionsWithMcLabels const& collisions, - FilteredCandDstarWSelFlagAndMc const& dstarCandidates) + FilteredCandDstarWSelFlagAndMc const& dstarCandidates, + TracksWithExtra const& tracks) { int numPvContributorsGen{0}; for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision @@ -1264,7 +1597,7 @@ struct TaskPolarisationCharmHadrons { for (const auto& dstarCandidate : groupedDstarCandidates) { nCands++; - if (runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } } @@ -1281,7 +1614,8 @@ struct TaskPolarisationCharmHadrons { void processDstarMcWithMl(aod::McCollisions::iterator const&, McParticlesDstarMatched const& mcParticles, CollisionsWithMcLabels const& collisions, // this is grouped with SmallGroupsCollisionsWithMcLabels const& collisions, - FilteredCandDstarWSelFlagAndMcAndMl const& dstarCandidates) + FilteredCandDstarWSelFlagAndMcAndMl const& dstarCandidates, + TracksWithExtra const& tracks) { int numPvContributorsGen{0}; for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision @@ -1296,7 +1630,7 @@ struct TaskPolarisationCharmHadrons { for (const auto& dstarCandidate : groupedDstarCandidates) { nCands++; - if (runPolarisationAnalysis(dstarCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(dstarCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } } @@ -1315,7 +1649,8 @@ struct TaskPolarisationCharmHadrons { // Lc->pKpi with rectangular cuts void processLcToPKPi(aod::Collisions const& collisions, - FilteredCandLcToPKPiWSelFlag const& lcCandidates) + FilteredCandLcToPKPiWSelFlag const& lcCandidates, + TracksWithExtra const& tracks) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); @@ -1325,13 +1660,13 @@ struct TaskPolarisationCharmHadrons { for (const auto& lcCandidate : groupedLcCandidates) { nCands++; - if (runPolarisationAnalysis(lcCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(lcCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } /// rotational background for (int iRotation{1}; iRotation <= nBkgRotations; ++iRotation) { - runPolarisationAnalysis(lcCandidate, -1 /*MC particles*/, iRotation, numPvContributors, -1 /*tracks*/); + runPolarisationAnalysis(lcCandidate, iRotation, numPvContributors, -1 /*MC particles*/, tracks); } } fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); @@ -1341,7 +1676,8 @@ struct TaskPolarisationCharmHadrons { // Lc->pKpi with ML cuts void processLcToPKPiWithMl(aod::Collisions const& collisions, - FilteredCandLcToPKPiWSelFlagAndMl const& lcCandidates) + FilteredCandLcToPKPiWSelFlagAndMl const& lcCandidates, + TracksWithExtra const& tracks) { for (const auto& collision : collisions) { auto thisCollId = collision.globalIndex(); @@ -1351,13 +1687,13 @@ struct TaskPolarisationCharmHadrons { for (const auto& lcCandidate : groupedLcCandidates) { nCands++; - if (runPolarisationAnalysis(lcCandidate, -1 /*MC particles*/, 0, numPvContributors, -1 /*tracks*/)) { + if (runPolarisationAnalysis(lcCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } /// rotational background for (int iRotation{1}; iRotation <= nBkgRotations; ++iRotation) { - runPolarisationAnalysis(lcCandidate, -1 /*MC particles*/, iRotation, numPvContributors, -1 /*tracks*/); + runPolarisationAnalysis(lcCandidate, iRotation, numPvContributors, -1 /*MC particles*/, tracks); } } fillMultHistos(numPvContributors, nCands, nCandsInSignalRegion); @@ -1370,7 +1706,7 @@ struct TaskPolarisationCharmHadrons { McParticles3ProngMatched const& mcParticles, CollisionsWithMcLabels const& collisions, // this is grouped with SmallGroupsCollisionsWithMcLabels const& collisions, FilteredCandLcToPKPiWSelFlagAndMc const& lcCandidates, - TracksWithMcLabels const& tracks) + TracksWithExtra const& tracks) { int numPvContributorsGen{0}; for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision @@ -1385,7 +1721,7 @@ struct TaskPolarisationCharmHadrons { for (const auto& lcCandidate : groupedLcCandidates) { nCands++; - if (runPolarisationAnalysis(lcCandidate, mcParticles, 0, numPvContributors, tracks)) { + if (runPolarisationAnalysis(lcCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } } @@ -1403,7 +1739,7 @@ struct TaskPolarisationCharmHadrons { McParticles3ProngMatched const& mcParticles, CollisionsWithMcLabels const& collisions, // this is grouped with SmallGroups FilteredCandLcToPKPiWSelFlagAndMcAndMl const& lcCandidates, - TracksWithMcLabels const& tracks) + TracksWithExtra const& tracks) { int numPvContributorsGen{0}; for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision @@ -1418,7 +1754,7 @@ struct TaskPolarisationCharmHadrons { for (const auto& lcCandidate : groupedLcCandidates) { nCands++; - if (runPolarisationAnalysis(lcCandidate, mcParticles, 0, numPvContributors, tracks)) { + if (runPolarisationAnalysis(lcCandidate, 0, numPvContributors, -1 /*MC particles*/, tracks)) { nCandsInSignalRegion++; } } @@ -1430,6 +1766,21 @@ struct TaskPolarisationCharmHadrons { } } PROCESS_SWITCH(TaskPolarisationCharmHadrons, 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, + FilteredCandLcToPKPiWSelFlagAndMcAndMl const& lcCandidates, + TracksWithMcLabels const& tracks) + { + for (const auto& lcCandidate : lcCandidates) { + runPolarisationAnalysis(lcCandidate, 0, /*numPvContributors*/ -1, mcParticles, tracks); + } + + for (const auto& mcParticle : mcParticles) { + runMcGenPolarisationAnalysis(mcParticle, mcParticles, /*numPvContributorsGen*/ -1); + } + } + PROCESS_SWITCH(TaskPolarisationCharmHadrons, processLcToPKPiBackgroundMcWithMl, "Process Lc candidates in MC with ML w/o mcCollision grouping", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/Tasks/taskCharmResoReduced.cxx b/PWGHF/D2H/Tasks/taskCharmResoReduced.cxx new file mode 100644 index 00000000000..7126e02258f --- /dev/null +++ b/PWGHF/D2H/Tasks/taskCharmResoReduced.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 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/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index e778ae64a9e..e5e12298f3f 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -55,6 +55,7 @@ struct HfTaskD0 { // 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"}; @@ -211,23 +212,28 @@ struct HfTaskD0 { registry.add("hDecLengthVsPtSig", "2-prong candidates;decay length (cm) vs #it{p}_{T} for signal;entries", {HistType::kTH2F, {{800, 0., 4.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("hDecLengthxyVsPtSig", "2-prong candidates;decay length xy (cm) vs #it{p}_{T} for signal;entries", {HistType::kTH2F, {{800, 0., 4.}, {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 thnAxisPtB{thnConfigAxisPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + const AxisSpec thnAxisY{thnConfigAxisY, "y"}; + const AxisSpec thnAxisOrigin{thnConfigAxisOrigin, "Origin"}; + const AxisSpec thnAxisCandType{thnConfigAxisCandType, "D0 type"}; + const AxisSpec thnAxisGenPtD{thnConfigAxisGenPtD, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisGenPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; + + registry.add("hSparseAcc", "Thn for generated D0 from charm and beauty", HistType::kTHnSparseD, {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin}); + registry.get(HIST("hSparseAcc"))->Sumw2(); + if (applyMl) { const AxisSpec thnAxisBkgScore{thnConfigAxisBkgScore, "BDT score bkg."}; const AxisSpec thnAxisNonPromptScore{thnConfigAxisNonPromptScore, "BDT score non-prompt."}; - const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (#pi K) (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 thnAxisCandType{thnConfigAxisCandType, "D0 type"}; - const AxisSpec thnAxisGenPtD{thnConfigAxisGenPtD, "#it{p}_{T} (GeV/#it{c})"}; - const AxisSpec thnAxisGenPtB{thnConfigAxisGenPtB, "#it{p}_{T}^{B} (GeV/#it{c})"}; - - registry.add("hSparseAcc", "Thn for generated D0 from charm and beauty", HistType::kTHnSparseD, {thnAxisGenPtD, thnAxisGenPtB, thnAxisY, thnAxisOrigin}); - registry.get(HIST("hSparseAcc"))->Sumw2(); - - registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates with BDT scores", HistType::kTHnSparseD, {thnAxisBkgScore, thnAxisNonPromptScore, thnAxisMass, thnAxisPt, thnAxisPtB, thnAxisY, thnAxisOrigin, thnAxisCandType}); + const AxisSpec thnAxisPromptScore{thnConfigAxisPromptScore, "BDT score prompt."}; + + registry.add("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates with BDT scores", HistType::kTHnSparseD, {thnAxisBkgScore, thnAxisNonPromptScore, thnAxisPromptScore, thnAxisMass, thnAxisPt, thnAxisPtB, thnAxisY, thnAxisOrigin, thnAxisCandType}); registry.get(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"))->Sumw2(); + } else { + registry.add("hMassVsPtVsPtBVsYVsOriginVsD0Type", "Thn for D0 candidates without BDT scores", HistType::kTHnSparseD, {thnAxisMass, thnAxisPt, thnAxisPtB, thnAxisY, thnAxisOrigin, thnAxisCandType}); + registry.get(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"))->Sumw2(); } } @@ -293,10 +299,17 @@ struct HfTaskD0 { if constexpr (applyMl) { if (candidate.isSelD0() >= selectionFlagD0) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0bar); + } + } else { + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0); } if (candidate.isSelD0bar() >= selectionFlagD0bar) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0bar); + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, -1, hfHelper.yD0(candidate), 0, SigD0bar); } } } @@ -463,7 +476,9 @@ 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], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0); } } else { registry.fill(HIST("hPtProng0Bkg"), ptProng0, rapidityCandidate); @@ -483,7 +498,9 @@ struct HfTaskD0 { if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassReflBkgD0"), massD0, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0()[0], candidate.mlProbD0()[1], candidate.mlProbD0()[2], massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0); } } } @@ -493,14 +510,18 @@ struct HfTaskD0 { if (candidate.flagMcMatchRec() == -(1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassSigD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0bar); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0bar); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), SigD0bar); } } else { registry.fill(HIST("hMassBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); if (candidate.flagMcMatchRec() == (1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { registry.fill(HIST("hMassReflBkgD0bar"), massD0bar, ptCandidate, rapidityCandidate); if constexpr (applyMl) { - registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0bar); + registry.fill(HIST("hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type"), candidate.mlProbD0bar()[0], candidate.mlProbD0bar()[1], candidate.mlProbD0bar()[2], massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0bar); + } else { + registry.fill(HIST("hMassVsPtVsPtBVsYVsOriginVsD0Type"), massD0bar, ptCandidate, candidate.ptBhadMotherPart(), rapidityCandidate, candidate.originMcRec(), ReflectedD0bar); } } } @@ -522,17 +543,13 @@ struct HfTaskD0 { registry.fill(HIST("hPtGenPrompt"), ptGen); registry.fill(HIST("hYGenPrompt"), yGen); registry.fill(HIST("hPtVsYGenPrompt"), ptGen, yGen); - if constexpr (applyMl) { - registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1); - } + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 1); } else { ptGenB = mcParticles.rawIteratorAt(particle.idxBhadMotherPart()).pt(); registry.fill(HIST("hPtGenNonPrompt"), ptGen); registry.fill(HIST("hYGenNonPrompt"), yGen); registry.fill(HIST("hPtVsYGenNonPrompt"), ptGen, yGen); - if constexpr (applyMl) { - registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2); - } + registry.fill(HIST("hSparseAcc"), ptGen, ptGenB, yGen, 2); } registry.fill(HIST("hEtaGen"), particle.eta()); } diff --git a/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx b/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx new file mode 100644 index 00000000000..a81e6acde41 --- /dev/null +++ b/PWGHF/D2H/Tasks/taskDirectedFlowCharmHadrons.cxx @@ -0,0 +1,324 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 taskDirectedFlowCharmHadrons.cxx +/// \brief Analysis task for charm hadron directed flow +/// +/// \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/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::hf_centrality; +using namespace o2::hf_evsel; + +enum DecayChannel { DplusToPiKPi = 0, + D0ToPiK, + D0ToKPi }; + +struct HfTaskDirectedFlowCharmHadrons { + Configurable centEstimator{"centEstimator", 2, "Centrality estimation (FT0A: 1, FT0C: 2, FT0M: 3, FV0A: 4)"}; + Configurable selectionFlag{"selectionFlag", 1, "Selection Flag for hadron (e.g. 1 for skimming, 3 for topo. and kine., 7 for PID)"}; + Configurable centralityMin{"centralityMin", 0., "Minimum centrality accepted in SP computation"}; + 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 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.}, ""}; + + using CandDplusDataWMl = soa::Filtered>; + using CandDplusData = soa::Filtered>; + using CandD0DataWMl = soa::Filtered>; + using CandD0Data = soa::Filtered>; + using CollsWithQvecs = soa::Join; + using TracksWithExtra = soa::Join; + + 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; + + Partition selectedD0ToPiK = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlag; + Partition selectedD0ToKPi = aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlag; + 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; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(InitContext&) + { + + /// check process functions + std::array processes = {doprocessDplusStd, doprocessDplusMl, doprocessD0Std, doprocessD0Ml}; + 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"); + } else if (nProcesses == 0) { + LOGP(fatal, "No process function enabled"); + } + + const AxisSpec thnAxisInvMass{thnConfigAxisInvMass, "Inv. mass (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisEta{thnConfigAxisEta, "#it{#eta}"}; + const AxisSpec thnAxisCent{thnConfigAxisCent, "Centrality"}; + const AxisSpec thnAxisScalarProd{thnConfigAxisScalarProd, "SP"}; + const AxisSpec thnAxisSign{thnConfigAxisSign, "Sign"}; + const AxisSpec thnAxisMlOne{thnConfigAxisMlOne, "Bkg score"}; + const AxisSpec thnAxisMlTwo{thnConfigAxisMlTwo, "FD score"}; + + std::vector axes = {thnAxisInvMass, thnAxisCent, thnAxisPt, thnAxisEta, thnAxisScalarProd, thnAxisSign}; + if (storeMl) { + axes.insert(axes.end(), {thnAxisMlOne, thnAxisMlTwo}); + } + + 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); + } else { + registry.add("hpQxtQxpvscent", "hpQxtQxpvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQytQypvscent", "hpQytQypvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQxtQypvscent", "hpQxtQypvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpQxpQytvscent", "hpQxpQytvscent", HistType::kTHnSparseF, {thnAxisCent, thnAxisScalarProd}, true); + registry.add("hpuxQxpvscentpteta", "hpuxQxpvscentpteta", HistType::kTHnSparseF, axes, true); + registry.add("hpuyQypvscentpteta", "hpuyQypvscentpteta", HistType::kTHnSparseF, axes, true); + registry.add("hpuxQxtvscentpteta", "hpuxQxtvscentpteta", HistType::kTHnSparseF, axes, true); + registry.add("hpuyQytvscentpteta", "hpuyQytvscentpteta", HistType::kTHnSparseF, axes, true); + } + + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + }; // end init + + /// Get the centrality + /// \param collision is the collision with the centrality information + double getCentrality(CollsWithQvecs::iterator const& collision) + { + double cent = -999.; + switch (centEstimator) { + case CentralityEstimator::FV0A: + cent = collision.centFV0A(); + break; + case CentralityEstimator::FT0M: + cent = collision.centFT0M(); + break; + case CentralityEstimator::FT0A: + cent = collision.centFT0A(); + break; + case CentralityEstimator::FT0C: + cent = collision.centFT0C(); + break; + default: + LOG(warning) << "Centrality estimator not valid. Possible values are V0A, T0M, T0A, T0C. Fallback to V0A"; + cent = collision.centFV0A(); + break; + } + return cent; + } + + /// Compute the scalar product + /// \param collision is the collision with the Q vector information and event plane + /// \param candidates are the selected candidates + template + void runFlowAnalysis(CollsWithQvecs::iterator const& collision, + T1 const& candidates, + Trk const& /*tracks*/) + { + double cent = getCentrality(collision); + if (cent < centralityMin || cent > centralityMax) { + return; + } + + if (!collision.triggereventsp()) { // for selecting only callibrated events + return; + } + + auto qxZDCA = collision.qxZDCA(); + auto qyZDCA = collision.qyZDCA(); + 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; + + // correlations in the denominators for SP calculation + if (direct) { + registry.fill(HIST("hpQxytpvscent"), cent, Qxytp); + } 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); + } + + for (const auto& candidate : candidates) { + double massCand = 0.; + std::vector outputMl = {-999., -999.}; + if constexpr (std::is_same_v || std::is_same_v) { + massCand = hfHelper.invMassDplusToPiKPi(candidate); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; + } + } else if constexpr (std::is_same_v || std::is_same_v) { + switch (channel) { + case DecayChannel::D0ToPiK: + massCand = hfHelper.invMassD0ToPiK(candidate); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbD0()[classMl->at(iclass)]; + } + break; + case DecayChannel::D0ToKPi: + massCand = hfHelper.invMassD0barToKPi(candidate); + if constexpr (std::is_same_v) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) + outputMl[iclass] = candidate.mlProbD0bar()[classMl->at(iclass)]; + } + break; + default: + break; + } + } + + auto trackprong0 = candidate.template prong0_as(); + double sign = trackprong0.sign(); // electric charge of the first daughter track to differentiate particle and antiparticle + + double ptCand = candidate.pt(); + double etaCand = candidate.eta(); + double phiCand = candidate.phi(); + double cosNPhi = std::cos(phiCand); + double sinNPhi = std::sin(phiCand); + + auto ux = cosNPhi; // real part of candidate q vector + auto uy = sinNPhi; // imaginary part of candidate q vector + auto uxQxp = ux * qxZDCA; + auto uyQyp = uy * qyZDCA; // correlations of particle and ZDC q vectors + auto uxyQxyp = uxQxp + uyQyp; + auto uxQxt = ux * qxZDCC; + auto uyQyt = uy * qyZDCC; + auto uxyQxyt = uxQxt + uyQyt; + auto oddv1 = ux * (qxZDCA - qxZDCC) + uy * (qyZDCA - qyZDCC); + auto evenv1 = ux * (qxZDCA + qxZDCC) + uy * (qyZDCA + qyZDCC); + + 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]); + } 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]); + registry.fill(HIST("hpuxQxtvscentpteta"), massCand, cent, ptCand, etaCand, uxQxt, sign, outputMl[0], outputMl[1]); + registry.fill(HIST("hpuyQytvscentpteta"), massCand, cent, ptCand, etaCand, uyQyt, sign, outputMl[0], outputMl[1]); + } + } 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); + } else { + registry.fill(HIST("hpuxQxpvscentpteta"), massCand, cent, ptCand, etaCand, uxQxp, sign); + registry.fill(HIST("hpuyQypvscentpteta"), massCand, cent, ptCand, etaCand, uyQyp, sign); + registry.fill(HIST("hpuxQxtvscentpteta"), massCand, cent, ptCand, etaCand, uxQxt, sign); + registry.fill(HIST("hpuyQytvscentpteta"), massCand, cent, ptCand, etaCand, uyQyt, sign); + } + } + } + } + // D0 with ML + void processD0Ml(CollsWithQvecs::iterator const& collision, + TracksWithExtra const& tracks) + { + auto candsD0ToPiKWMl = selectedD0ToPiKWMl->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + auto candsD0ToKPiWMl = selectedD0ToKPiWMl->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsD0ToPiKWMl, tracks); + runFlowAnalysis(collision, candsD0ToKPiWMl, tracks); + } + PROCESS_SWITCH(HfTaskDirectedFlowCharmHadrons, processD0Ml, "Process D0 candidates with ML", false); + + // D0 with rectangular cuts + void processD0Std(CollsWithQvecs::iterator const& collision, + TracksWithExtra const& tracks) + { + auto candsD0ToPiK = selectedD0ToPiK->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + auto candsD0ToKPi = selectedD0ToKPi->sliceByCached(aod::hf_cand::collisionId, collision.globalIndex(), cache); + runFlowAnalysis(collision, candsD0ToPiK, tracks); + runFlowAnalysis(collision, candsD0ToKPi, tracks); + } + PROCESS_SWITCH(HfTaskDirectedFlowCharmHadrons, processD0Std, "Process D0 candidates with rectangular cuts", false); + + // Dplus with ML + void processDplusMl(CollsWithQvecs::iterator const& collision, + CandDplusDataWMl const& candidatesDplus, + TracksWithExtra const& tracks) + { + runFlowAnalysis(collision, candidatesDplus, tracks); + } + PROCESS_SWITCH(HfTaskDirectedFlowCharmHadrons, processDplusMl, "Process Dplus candidates with ML", false); + + // Dplus with rectangular cuts + void processDplusStd(CollsWithQvecs::iterator const& collision, + CandDplusData const& candidatesDplus, + TracksWithExtra const& tracks) + { + runFlowAnalysis(collision, candidatesDplus, tracks); + } + PROCESS_SWITCH(HfTaskDirectedFlowCharmHadrons, processDplusStd, "Process Dplus candidates with rectangular cuts", true); + +}; // End struct HfTaskDirectedFlowCharmHadrons + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/D2H/Tasks/taskDs.cxx b/PWGHF/D2H/Tasks/taskDs.cxx index 2c45ba0d846..e9c49d9fc86 100644 --- a/PWGHF/D2H/Tasks/taskDs.cxx +++ b/PWGHF/D2H/Tasks/taskDs.cxx @@ -17,10 +17,18 @@ /// \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" @@ -32,6 +40,8 @@ using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +MetadataHelper metadataInfo; // Metadata helper + enum FinalState { KKPi = 0, PiKK }; @@ -41,13 +51,16 @@ enum DataType { Data = 0, McDplusPrompt, McDplusNonPrompt, McDplusBkg, + McLcBkg, McBkg, kDataTypes }; -enum SpeciesAndDecay { DsToKKPi = 0, - DplusToKKPi, - DplusToPiKPi, - kSpeciesAndDecay }; +template +concept hasDsMlInfo = requires(T candidate) +{ + candidate.mlProbDsToKKPi(); + candidate.mlProbDsToPiKK(); +}; /// Ds± analysis task struct HfTaskDs { @@ -56,61 +69,69 @@ struct HfTaskDs { 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."}; - Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; - Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"}; + Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; + Configurable massDsSignalMin{"massDsSignalMin", 1.934, "min mass for Ds signal"}; + Configurable massDsSignalMax{"massDsSignalMax", 1.994, "max mass for Ds signal"}; + Configurable massDplusSignalMin{"massDplusSignalMin", 1.866, "min mass for Dplus signal"}; + Configurable massDplusSignalMax{"massDplusSignalMax", 1.906, "max mass for Dplus signal"}; + Configurable fillPercentiles{"fillPercentiles", true, "Wheter to fill multiplicity axis with percentiles or raw information"}; + ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 8.f, 12.f, 24.f}, "axis for pT"}; + ConfigurableAxis axisNPvContributors{"axisNPvContributors", {200, -0.5f, 199.5f}, "axis for NPvContributors"}; 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"}; + + 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 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; HfHelper hfHelper; + Service ccdb; - using CentralityEstimator = o2::hf_centrality::CentralityEstimator; using TH1_ptr = std::shared_ptr; using TH2_ptr = std::shared_ptr; using THnSparse_ptr = std::shared_ptr; using histTypes = std::variant; + template + using MemberFunctionPointer = bool (HfTaskDs::*)(const CandDs&); + + using CollisionsWithFT0C = soa::Join; + using CollisionsWithFT0M = soa::Join; + using CollisionsWithNTracksPV = soa::Join; + + using CollisionsMc = soa::Join; + using CollisionsMcWithFT0C = soa::Join; + using CollisionsMcWithFT0M = soa::Join; + using CollisionsMcWithNTracksPV = soa::Join; - using CollisionsWithFT0C = soa::Join; - using CollisionsWithFT0M = soa::Join; - using CollisionsWithNTracksPV = soa::Join; using CandDsData = soa::Filtered>; using CandDsDataWithMl = soa::Filtered>; using CandDsMcReco = soa::Filtered>; using CandDsMcRecoWithMl = soa::Filtered>; using CandDsMcGen = soa::Join; + Preslice candDsPerCollision = aod::hf_cand::collisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + SliceCache cache; + 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; + TProfile* hVtxZFT0A; + TProfile* hVtxZFT0C; + TProfile* hVtxZNTracks; Filter filterDsFlag = (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi))) != static_cast(0); - // Data - Partition selectedDsToKKPiCandData = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs; - Partition selectedDsToKKPiCandWithMlData = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs; - Partition selectedDsToPiKKCandData = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - Partition selectedDsToPiKKCandWithMlData = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - - // MC - Partition selectedDsToKKPiCandMc = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs; - Partition selectedDsToKKPiCandWithMlMc = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs; - Partition selectedDsToPiKKCandMc = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - Partition selectedDsToPiKKCandWithMlMc = aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs; - - // Matched MC, no ML - Partition reconstructedCandDsSig = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && aod::hf_cand_3prong::flagMcDecayChanRec == decayChannel; - Partition reconstructedCandDplusSig = fillDplusMc && nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && aod::hf_cand_3prong::flagMcDecayChanRec == (decayChannel + offsetDplusDecayChannel); - Partition reconstructedCandDplusBkg = fillDplusMc && nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)); - Partition reconstructedCandBkg = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)); - - // Matched MC, with ML - Partition reconstructedCandDsSigWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && aod::hf_cand_3prong::flagMcDecayChanRec == decayChannel; - Partition reconstructedCandDplusSigWithMl = fillDplusMc && nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)) && aod::hf_cand_3prong::flagMcDecayChanRec == (decayChannel + offsetDplusDecayChannel); - Partition reconstructedCandDplusBkgWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)) && aod::hf_cand_3prong::flagMcDecayChanRec == decayChannel; - Partition reconstructedCandBkgWithMl = nabs(aod::hf_cand_3prong::flagMcMatchRec) != static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi)); - HistogramRegistry registry{"registry", {}}; - std::array folders = {"Data/", "MC/Ds/Prompt/", "MC/Ds/NonPrompt/", "MC/Dplus/Prompt/", "MC/Dplus/NonPrompt/", "MC/Dplus/Bkg/", "MC/Bkg/"}; + std::array folders = {"Data/", "MC/Ds/Prompt/", "MC/Ds/NonPrompt/", "MC/Dplus/Prompt/", "MC/Dplus/NonPrompt/", "MC/Dplus/Bkg/", "MC/Lc/", "MC/Bkg/"}; std::unordered_map dataHistograms = {}; std::unordered_map mcDsPromptHistograms = {}; @@ -118,9 +139,10 @@ struct HfTaskDs { std::unordered_map mcDplusPromptHistograms = {}; std::unordered_map mcDplusNonPromptHistograms = {}; std::unordered_map mcDplusBkgHistograms = {}; + std::unordered_map mcLcBkgHistograms = {}; std::unordered_map mcBkgHistograms = {}; - std::array, DataType::kDataTypes> histosPtr = {dataHistograms, mcDsPromptHistograms, mcDsNonPromptHistograms, mcDplusPromptHistograms, mcDplusNonPromptHistograms, mcDplusBkgHistograms, mcBkgHistograms}; + std::array, DataType::kDataTypes> histosPtr = {dataHistograms, mcDsPromptHistograms, mcDsNonPromptHistograms, mcDplusPromptHistograms, mcDplusNonPromptHistograms, mcDplusBkgHistograms, mcLcBkgHistograms, mcBkgHistograms}; void init(InitContext&) { @@ -138,18 +160,25 @@ struct HfTaskDs { AxisSpec massbins = {600, 1.67, 2.27, "inv. mass (KK#pi) (GeV/#it{c}^{2})"}; AxisSpec centralitybins = {100, 0., 100., "Centrality"}; + histosPtr[DataType::Data]["hNPvContribAll"] = registry.add((folders[DataType::Data] + "hNPvContribAll").c_str(), "3-prong candidates;NPvContributors;Centrality;Entries", HistType::kTH2F, {axisNPvContributors, {100, 0., 100}}); + for (auto i = 0; i < DataType::kDataTypes; ++i) { - if (doprocessDataWithCentFT0C || doprocessDataWithCentFT0M || doprocessDataWithCentNTracksPV || - doprocessMcWithCentFT0C || doprocessMcWithCentFT0M || doprocessMcWithCentNTracksPV) { - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins, centralitybins}); - } else if (doprocessDataWithMlAndCentFT0C || doprocessDataWithMlAndCentFT0M || doprocessDataWithMlAndCentNTracksPV || - doprocessMcWithMlAndCentFT0C || doprocessMcWithMlAndCentFT0M || doprocessMcWithMlAndCentNTracksPV) { - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins, centralitybins, axisMlScore0, axisMlScore1, axisMlScore2}); - } else if (doprocessData || doprocessMc) { - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins}); - } else if (doprocessDataWithMl || doprocessMcWithMl) { - histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins, axisMlScore0, axisMlScore1, axisMlScore2}); + 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, {massbins, ptbins, centralitybins}); + } else { + histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins, centralitybins, axisNPvContributors}); + } + } else if (doprocessDataWithMlAndCentFT0C || doprocessDataWithMlAndCentFT0M || doprocessDataWithMlAndCentNTracksPV || doprocessDataWithMl || doprocessMcWithMlAndCentFT0C || doprocessMcWithMlAndCentFT0M || doprocessMcWithMlAndCentNTracksPV || doprocessMcWithMl) { + 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, {massbins, ptbins, centralitybins, axisMlScore0, axisMlScore1, axisMlScore2}); + } else { + histosPtr[i]["hSparseMass"] = registry.add((folders[i] + "hSparseMass").c_str(), "THn for Ds", HistType::kTHnSparseF, {massbins, ptbins, centralitybins, axisMlScore0, axisMlScore1, axisMlScore2, axisNPvContributors}); + } } + histosPtr[i]["hNPvContribCands"] = registry.add((folders[i] + "hNPvContribCands").c_str(), "3-prong candidates;NPvContributors;Centrality;Entries", HistType::kTH2F, {axisNPvContributors, centralitybins}); + histosPtr[i]["hNPvContribCandsInSignalRegionDs"] = registry.add((folders[i] + "hNPvContribCandsInSignalRegionDs").c_str(), "3-prong candidates;NPvContributors;Centrality;Entries", HistType::kTH2F, {axisNPvContributors, centralitybins}); + histosPtr[i]["hNPvContribCandsInSignalRegionDplus"] = registry.add((folders[i] + "hNPvContribCandsInSignalRegionDplus").c_str(), "3-prong candidates;NPvContributors;Centrality;Entries", HistType::kTH2F, {axisNPvContributors, centralitybins}); histosPtr[i]["hPt"] = registry.add((folders[i] + "hPt").c_str(), "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); histosPtr[i]["hPtProng0"] = registry.add((folders[i] + "hPtProng0").c_str(), "3-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); histosPtr[i]["hPtProng1"] = registry.add((folders[i] + "hPtProng1").c_str(), "3-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}); @@ -181,35 +210,139 @@ struct HfTaskDs { doprocessMc || doprocessMcWithMl) { // processing MC for (auto i = 0; i < DataType::kDataTypes; ++i) { - if (i == DataType::McDsPrompt || i == DataType::McDsNonPrompt || i == DataType::McDplusPrompt || i == DataType::McDplusNonPrompt || i == DataType::McDplusBkg) { + if (i == DataType::McDsPrompt || i == DataType::McDsNonPrompt || i == DataType::McDplusPrompt || i == DataType::McDplusNonPrompt || i == DataType::McDplusBkg || i == DataType::McLcBkg) { histosPtr[i]["hEtaGen"] = registry.add((folders[i] + "hEtaGen").c_str(), "3-prong candidates (matched);#eta;entries", {HistType::kTH1F, {{100, -2., 2.}}}); - histosPtr[i]["hEtaRecSig"] = registry.add((folders[i] + "hEtaRecSig").c_str(), "3-prong candidates (matched);#eta;entries", {HistType::kTH1F, {{100, -2., 2.}}}); - histosPtr[i]["hCPARecSig"] = registry.add((folders[i] + "hCPARecSig").c_str(), "3-prong candidates (matched);cos. pointing angle;entries", {HistType::kTH1F, {{100, -1., 1.}}}); - histosPtr[i]["hPtRecSig"] = registry.add((folders[i] + "hPtRecSig").c_str(), "3-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {ptbins}}); - histosPtr[i]["hPtGenSig"] = registry.add((folders[i] + "hPtGenSig").c_str(), "MC particles (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {ptbins}}); histosPtr[i]["hPtGen"] = registry.add((folders[i] + "hPtGen").c_str(), "MC particles (unmatched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {ptbins}}); - histosPtr[i]["hPtVsYRecSigRecoPID"] = registry.add((folders[i] + "hPtVsYRecSigRecoPID").c_str(), "3-prong candidates (RecoPID - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); - histosPtr[i]["hPtVsYRecSigRecoTopol"] = registry.add((folders[i] + "hPtVsYRecSigRecoTopol").c_str(), "3-prong candidates (RecoTopol - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); - histosPtr[i]["hPtVsYRecSigRecoSkim"] = registry.add((folders[i] + "hPtVsYRecSigRecoSkim").c_str(), "3-prong candidates (RecoSkim - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); - histosPtr[i]["hPtVsYGen"] = registry.add((folders[i] + "hPtVsYGen").c_str(), "MC particles (unmatched);#it{p}_{T}^{gen.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); + histosPtr[i]["hPtVsYRecoPID"] = registry.add((folders[i] + "hPtVsYRecoPID").c_str(), "3-prong candidates (RecoPID - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); + histosPtr[i]["hPtVsYRecoTopol"] = registry.add((folders[i] + "hPtVsYRecoTopol").c_str(), "3-prong candidates (RecoTopol - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); + histosPtr[i]["hPtVsYRecoSkim"] = registry.add((folders[i] + "hPtVsYRecoSkim").c_str(), "3-prong candidates (RecoSkim - matched);#it{p}_{T}^{rec.}; #it{y}", {HistType::kTH2F, {ptbins, {ybins}}}); + histosPtr[i]["hPtYNPvContribGen"] = registry.add((folders[i] + "hPtYNPvContribGen").c_str(), "Thn for generated candidates", {HistType::kTHnSparseF, {ptbins, {ybins}, axisNPvContributors}}); } } } } - /// Evaluate multiplicity + 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; + } + + 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; + } + + 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; + } + + 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; + } + + template + bool isDplusBkg(const CandDs& candidate) + { + return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi)); + } + + template + bool isLcBkg(const CandDs& candidate) + { + return std::abs(candidate.flagMcMatchRec()) == static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi)); + } + + /// Checks whether the candidate is in the signal region of either the Ds or D+ decay + /// \param candidate is the candidate + /// \param isDs is true if we check for the Ds signal region, false for the D+ signal region + /// \return true if the candidate is in the signal region, false otherwise + template + bool isCandInSignalRegion(const CandDs& candidate, bool isDs) + { + bool isKKPi = candidate.isSelDsToKKPi() >= selectionFlagDs; + float invMass = isKKPi ? hfHelper.invMassDsToKKPi(candidate) : hfHelper.invMassDsToPiKK(candidate); + if (isDs && (invMass < massDsSignalMin || invMass > massDsSignalMax)) { + return false; + } + if (!isDs && (invMass < massDplusSignalMin || invMass > massDplusSignalMax)) { + return false; + } + return true; + } + + /// Evaluate centrality/multiplicity percentile using FT0M estimator /// \param candidate is candidate - /// \return multiplicity of the collision associated to the candidate - template - int evaluateCentrality(const T1& candidate) + /// \return centrality/multiplicity percentile of the collision + template + float getZEqMultColl(const Coll& collision, uint8_t nProngsContributorsPV) { - if constexpr (centDetector == CentralityEstimator::FT0C) - return candidate.template collision_as().centFT0C(); - else if constexpr (centDetector == CentralityEstimator::FT0M) - return candidate.template collision_as().centFT0M(); - else if constexpr (centDetector == CentralityEstimator::NTracksPV) - return candidate.template collision_as().centNTPV(); + auto multFT0A = collision.multFT0A() - nProngsContributorsPV; + auto multFT0C = collision.multFT0C() - nProngsContributorsPV; + float multZeqFT0A = hVtxZFT0A->Interpolate(0.0) * multFT0A / hVtxZFT0A->Interpolate(collision.posZ()); + float multZeqFT0C = hVtxZFT0C->Interpolate(0.0) * multFT0C / hVtxZFT0C->Interpolate(collision.posZ()); + return multZeqFT0A + multZeqFT0C; + } + + /// Evaluate centrality/multiplicity percentile using NTracksPV estimator + /// \param candidate is candidate + /// \return centrality/multiplicity percentile of the collision + template + float getZEqMultColl(const Coll& collision, uint8_t nProngsContributorsPV) + { + auto multNTracksPV = collision.multNTracksPV() - nProngsContributorsPV; + float multZeqNTracksPV = hVtxZNTracks->Interpolate(0.0) * multNTracksPV / hVtxZNTracks->Interpolate(collision.posZ()); + return multZeqNTracksPV; + } + + /// Default case if no centrality/multiplicity estimator is provided + /// \param candidate is candidate + /// \return dummy value for centrality/multiplicity percentile of the collision + template + float getZEqMultColl(const Coll&, uint8_t) + { + return -1.f; + } + + /// 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, const CandDs& candidate) + { + if (fillPercentiles) { + return o2::hf_centrality::getCentralityColl(collision); + } else { + return getZEqMultColl(collision, candidate.nProngsContributorsPV()); + } + } + + /// 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) + { + if (fillPercentiles) { + return o2::hf_centrality::getCentralityColl(collision); + } else { + return getZEqMultColl(collision, 0); + } + } + + /// Evaluate centrality/multiplicity percentile + /// \param candidate is candidate + /// \return centrality/multiplicity percentile of the collision associated to the candidate + template + float evaluateCentralityCand(const T1& candidate) + { + return evaluateCentralityColl(candidate.template collision_as(), candidate); } /// Fill histograms of quantities independent from the daugther-mass hypothesis @@ -245,30 +378,61 @@ struct HfTaskDs { return; } - /// Fill histograms of quantities for the KKPi daugther-mass hypothesis + /// Fill mass sparse if ML information is present /// \param candidate is candidate /// \param dataType is data class, as defined in DataType enum - template - void fillHistoKKPi(const T1& candidate, DataType dataType) + /// \param finalState is either KKPi or PiKK, as defined in FinalState enum + template + void fillSparse(const Cand& candidate, DataType dataType, FinalState finalState) { + auto mass = finalState == FinalState::KKPi ? hfHelper.invMassDsToKKPi(candidate) : hfHelper.invMassDsToPiKK(candidate); auto pt = candidate.pt(); - if constexpr (useMl) { - std::vector outputMl = {-999., -999., -999.}; - for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { // TODO: add checks for classMl size - outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl->at(iclass)]; - } - if constexpr (centDetector != CentralityEstimator::None) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToKKPi(candidate), pt, evaluateCentrality(candidate), outputMl[0], outputMl[1], outputMl[2]); - } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToKKPi(candidate), pt, outputMl[0], outputMl[1], outputMl[2]); - } - } else { - if constexpr (centDetector != CentralityEstimator::None) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToKKPi(candidate), pt, evaluateCentrality(candidate)); - } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToKKPi(candidate), pt); + auto mlScore = finalState == FinalState::KKPi ? candidate.mlProbDsToKKPi() : candidate.mlProbDsToPiKK(); + + std::vector outputMl = {-999., -999., -999.}; + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { // TODO: add checks for classMl size + if (mlScore.size() == 0) { + continue; } + outputMl[iclass] = mlScore[classMl->at(iclass)]; + } + + if (dataType == DataType::Data) { // If data do not fill PV contributors in sparse + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2]); + return; } + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), outputMl[0], outputMl[1], outputMl[2], candidate.template collision_as().numContrib()); + + return; + } + + /// Fill mass sparse if ML information is not present + /// \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 + void fillSparse(const Cand& candidate, DataType dataType, FinalState finalState) + { + auto mass = finalState == FinalState::KKPi ? hfHelper.invMassDsToKKPi(candidate) : hfHelper.invMassDsToPiKK(candidate); + auto pt = candidate.pt(); + + if (dataType == DataType::Data) { // If data do not fill PV contributors in sparse + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate)); + return; + } + std::get(histosPtr[dataType]["hSparseMass"])->Fill(mass, pt, evaluateCentralityCand(candidate), candidate.template collision_as().numContrib()); + + return; + } + + /// Fill histograms of quantities for the KKPi daugther-mass hypothesis + /// \param candidate is candidate + /// \param dataType is data class, as defined in DataType enum + template + void fillHistoKKPi(const T1& candidate, DataType dataType) + { + auto pt = candidate.pt(); + fillSparse(candidate, dataType, FinalState::KKPi); std::get(histosPtr[dataType]["hCos3PiK"])->Fill(hfHelper.cos3PiKDsToKKPi(candidate), pt); std::get(histosPtr[dataType]["hAbsCos3PiK"])->Fill(hfHelper.absCos3PiKDsToKKPi(candidate), pt); @@ -281,27 +445,11 @@ struct HfTaskDs { /// Fill histograms of quantities for the PiKK daugther-mass hypothesis /// \param candidate is candidate /// \param dataType is data class, as defined in DataType enum - template + template void fillHistoPiKK(const T1& candidate, DataType dataType) { auto pt = candidate.pt(); - if constexpr (useMl) { - std::vector outputMl = {-999., -999., -999.}; - for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { // TODO: add checks for classMl size - outputMl[iclass] = candidate.mlProbDsToPiKK()[classMl->at(iclass)]; - } - if constexpr (centDetector != CentralityEstimator::None) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToPiKK(candidate), pt, evaluateCentrality(candidate), outputMl[0], outputMl[1], outputMl[2]); - } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToPiKK(candidate), pt, outputMl[0], outputMl[1], outputMl[2]); - } - } else { - if constexpr (centDetector != CentralityEstimator::None) { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToPiKK(candidate), pt, evaluateCentrality(candidate)); - } else { - std::get(histosPtr[dataType]["hSparseMass"])->Fill(hfHelper.invMassDsToPiKK(candidate), pt); - } - } + fillSparse(candidate, dataType, FinalState::PiKK); std::get(histosPtr[dataType]["hCos3PiK"])->Fill(hfHelper.cos3PiKDsToPiKK(candidate), pt); std::get(histosPtr[dataType]["hAbsCos3PiK"])->Fill(hfHelper.absCos3PiKDsToPiKK(candidate), pt); @@ -315,229 +463,125 @@ struct HfTaskDs { /// \param candidate is candidate /// \param mcParticles are particles with MC information /// \param whichSpeciesDecay defines which histogram to fill - template - void fillHistoMCRec(const T1& candidate, const CandDsMcGen& mcParticles, SpeciesAndDecay whichSpeciesDecay) + template + void fillHistoMCRec(const T1& candidate, const CandDsMcGen& mcParticles, DataType dataType) { + + 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, candidate.template prong0_as().template mcParticle_as(), - whichSpeciesDecay == SpeciesAndDecay::DsToKKPi ? o2::constants::physics::Pdg::kDS : o2::constants::physics::Pdg::kDPlus, true); + id, true); if (indexMother != -1) { - if (yCandRecoMax >= 0. && std::abs(whichSpeciesDecay == SpeciesAndDecay::DsToKKPi ? hfHelper.yDs(candidate) : hfHelper.yDplus(candidate)) > yCandRecoMax) { + if (yCandRecoMax >= 0. && std::abs(yCand) > yCandRecoMax) { return; } - auto particleMother = mcParticles.iteratorAt(indexMother); - - int flag = candidate.isCandidateSwapped() ? candidate.isSelDsToPiKK() : candidate.isSelDsToKKPi(); // 0 corresponds to KKPi, 1 to PiKK - auto pt = candidate.pt(); // rec. level pT - // Ds - if (whichSpeciesDecay == SpeciesAndDecay::DsToKKPi) { - - double y = hfHelper.yDs(candidate); - - // prompt - if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { - fillHisto(candidate, DataType::McDsPrompt); - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDsPrompt); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDsPrompt); - - std::get(histosPtr[DataType::McDsPrompt]["hPtRecSig"])->Fill(pt); - std::get(histosPtr[DataType::McDsPrompt]["hPtGenSig"])->Fill(particleMother.pt()); // gen. level pT - std::get(histosPtr[DataType::McDsPrompt]["hPtVsYRecSigRecoSkim"])->Fill(pt, y); - std::get(histosPtr[DataType::McDsPrompt]["hCPARecSig"])->Fill(candidate.cpa()); - std::get(histosPtr[DataType::McDsPrompt]["hEtaRecSig"])->Fill(candidate.eta()); - if (TESTBIT(flag, aod::SelectionStep::RecoTopol)) { - std::get(histosPtr[DataType::McDsPrompt]["hPtVsYRecSigRecoTopol"])->Fill(pt, y); - } - if (TESTBIT(flag, aod::SelectionStep::RecoPID)) { - std::get(histosPtr[DataType::McDsPrompt]["hPtVsYRecSigRecoPID"])->Fill(pt, y); - } - } + if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi + fillHisto(candidate, dataType); + fillHistoKKPi(candidate, dataType); - // non-prompt - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - fillHisto(candidate, DataType::McDsNonPrompt); - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDsNonPrompt); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDsNonPrompt); - - std::get(histosPtr[DataType::McDsNonPrompt]["hPtRecSig"])->Fill(pt); - std::get(histosPtr[DataType::McDsNonPrompt]["hPtGenSig"])->Fill(particleMother.pt()); // gen. level pT - std::get(histosPtr[DataType::McDsNonPrompt]["hPtVsYRecSigRecoSkim"])->Fill(pt, y); - std::get(histosPtr[DataType::McDsNonPrompt]["hCPARecSig"])->Fill(candidate.cpa()); - std::get(histosPtr[DataType::McDsNonPrompt]["hEtaRecSig"])->Fill(candidate.eta()); - if (TESTBIT(flag, aod::SelectionStep::RecoTopol)) { - std::get(histosPtr[DataType::McDsNonPrompt]["hPtVsYRecSigRecoTopol"])->Fill(pt, y); - } - if (TESTBIT(flag, aod::SelectionStep::RecoPID)) { - std::get(histosPtr[DataType::McDsNonPrompt]["hPtVsYRecSigRecoPID"])->Fill(pt, y); - } + if (TESTBIT(candidate.isSelDsToKKPi(), aod::SelectionStep::RecoSkims)) { + std::get(histosPtr[dataType]["hPtVsYRecoSkim"])->Fill(pt, yCand); } - return; - } // end Ds - - // D+→ K± K∓ π± - if (whichSpeciesDecay == SpeciesAndDecay::DplusToKKPi) { - double y = hfHelper.yDplus(candidate); - - // prompt - if (candidate.originMcRec() == RecoDecay::OriginType::Prompt) { - fillHisto(candidate, DataType::McDplusPrompt); - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDplusPrompt); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDplusPrompt); - - std::get(histosPtr[DataType::McDplusPrompt]["hPtRecSig"])->Fill(pt); - std::get(histosPtr[DataType::McDplusPrompt]["hPtGenSig"])->Fill(particleMother.pt()); // gen. level pT - std::get(histosPtr[DataType::McDplusPrompt]["hPtVsYRecSigRecoSkim"])->Fill(pt, y); - std::get(histosPtr[DataType::McDplusPrompt]["hCPARecSig"])->Fill(candidate.cpa()); - std::get(histosPtr[DataType::McDplusPrompt]["hEtaRecSig"])->Fill(candidate.eta()); - if (TESTBIT(flag, aod::SelectionStep::RecoTopol)) { - std::get(histosPtr[DataType::McDplusPrompt]["hPtVsYRecSigRecoTopol"])->Fill(pt, y); - } - if (TESTBIT(flag, aod::SelectionStep::RecoPID)) { - std::get(histosPtr[DataType::McDplusPrompt]["hPtVsYRecSigRecoPID"])->Fill(pt, y); - } + if (TESTBIT(candidate.isSelDsToKKPi(), aod::SelectionStep::RecoTopol)) { + std::get(histosPtr[dataType]["hPtVsYRecoTopol"])->Fill(pt, yCand); } - - // non-prompt - if (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { - fillHisto(candidate, DataType::McDplusNonPrompt); - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDplusNonPrompt); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDplusNonPrompt); - - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtRecSig"])->Fill(pt); - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtGenSig"])->Fill(particleMother.pt()); // gen. level pT - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtVsYRecSigRecoSkim"])->Fill(pt, y); - std::get(histosPtr[DataType::McDplusNonPrompt]["hCPARecSig"])->Fill(candidate.cpa()); - std::get(histosPtr[DataType::McDplusNonPrompt]["hEtaRecSig"])->Fill(candidate.eta()); - if (TESTBIT(flag, aod::SelectionStep::RecoTopol)) { - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtVsYRecSigRecoTopol"])->Fill(pt, y); - } - if (TESTBIT(flag, aod::SelectionStep::RecoPID)) { - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtVsYRecSigRecoPID"])->Fill(pt, y); - } + if (TESTBIT(candidate.isSelDsToKKPi(), aod::SelectionStep::RecoPID)) { + std::get(histosPtr[dataType]["hPtVsYRecoPID"])->Fill(pt, yCand); } + } + if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK + fillHisto(candidate, dataType); + fillHistoPiKK(candidate, dataType); - return; - } // end D+→ K± K∓ π± - - // D+→ π± K∓ π± - if (whichSpeciesDecay == SpeciesAndDecay::DplusToPiKPi) { - double y = hfHelper.yDplus(candidate); - - // Fill whether it is prompt or non-prompt - fillHisto(candidate, DataType::McDplusBkg); - - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDplusBkg); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDplusBkg); - - std::get(histosPtr[DataType::McDplusBkg]["hPtRecSig"])->Fill(pt); - std::get(histosPtr[DataType::McDplusBkg]["hPtGenSig"])->Fill(particleMother.pt()); // gen. level pT - std::get(histosPtr[DataType::McDplusBkg]["hPtVsYRecSigRecoSkim"])->Fill(pt, y); - std::get(histosPtr[DataType::McDplusBkg]["hCPARecSig"])->Fill(candidate.cpa()); - std::get(histosPtr[DataType::McDplusBkg]["hEtaRecSig"])->Fill(candidate.eta()); - if (TESTBIT(flag, aod::SelectionStep::RecoTopol)) { - std::get(histosPtr[DataType::McDplusBkg]["hPtVsYRecSigRecoTopol"])->Fill(pt, y); + if (TESTBIT(candidate.isSelDsToPiKK(), aod::SelectionStep::RecoSkims)) { + std::get(histosPtr[dataType]["hPtVsYRecoSkim"])->Fill(pt, yCand); } - if (TESTBIT(flag, aod::SelectionStep::RecoPID)) { - std::get(histosPtr[DataType::McDplusBkg]["hPtVsYRecSigRecoPID"])->Fill(pt, y); + if (TESTBIT(candidate.isSelDsToPiKK(), aod::SelectionStep::RecoTopol)) { + std::get(histosPtr[dataType]["hPtVsYRecoTopol"])->Fill(pt, yCand); } - - return; - } // end D+→ π± K∓ π± + if (TESTBIT(candidate.isSelDsToPiKK(), aod::SelectionStep::RecoPID)) { + std::get(histosPtr[dataType]["hPtVsYRecoPID"])->Fill(pt, yCand); + } + } } + return; } - template - void runDataAnalysis(CandsDs const& candidates) + template + void runDataAnalysisPerCandidate(CandDs const& candidate) { - for (const auto& candidate : candidates) { - if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { - continue; - } + if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { + return; + } + + if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi fillHisto(candidate, DataType::Data); - if constexpr (decayChannel == FinalState::KKPi) { // KKPi - fillHistoKKPi(candidate, DataType::Data); - } else if constexpr (decayChannel == FinalState::PiKK) { // PiKK - fillHistoPiKK(candidate, DataType::Data); - } + fillHistoKKPi(candidate, DataType::Data); + } + if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK + fillHisto(candidate, DataType::Data); + fillHistoPiKK(candidate, DataType::Data); } } - template - void runMcAnalysis(CandsDs const& /*candidates*/, - CandDsMcGen const& mcParticles) + template + void runMcAnalysisPerCandidate(CandDs const& candidate, + CandDsMcGen const& mcParticles) { // MC rec. - // Ds± → K± K∓ π± - if constexpr (useMl) { - // Ds - for (const auto& candidate : reconstructedCandDsSigWithMl) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DsToKKPi); - // D+→ K± K∓ π± - for (const auto& candidate : reconstructedCandDplusSigWithMl) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DplusToKKPi); - // D+→ π± K∓ π± - for (const auto& candidate : reconstructedCandDplusBkgWithMl) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DplusToPiKPi); - // Bkg - for (const auto& candidate : reconstructedCandBkgWithMl) { - if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { - continue; - } + std::array, 6> isOfType = {// Contains the functions to check if the candidate is of a certain type + &HfTaskDs::isDsPrompt, + &HfTaskDs::isDsNonPrompt, + &HfTaskDs::isDplusPrompt, + &HfTaskDs::isDplusNonPrompt, + &HfTaskDs::isDplusBkg, + &HfTaskDs::isLcBkg}; + + bool isBkg = true; + for (int i = DataType::McDsPrompt; i <= DataType::McLcBkg; i++) { // Check what type of MC signal candidate it is, and fill the corresponding histograms + if ((this->*isOfType[i - DataType::McDsPrompt])(candidate)) { + isBkg = false; + fillHistoMCRec(candidate, mcParticles, static_cast(i)); + break; + } + } + if (isBkg) { + if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { + return; + } - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) + if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) { + if (candidate.isSelDsToKKPi() >= selectionFlagDs) { // KKPi fillHisto(candidate, DataType::McBkg); - } - } else { - // Ds - for (const auto& candidate : reconstructedCandDsSig) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DsToKKPi); - - // D+→ K± K∓ π± - for (const auto& candidate : reconstructedCandDplusSig) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DplusToKKPi); - - // D+→ π± K∓ π± - for (const auto& candidate : reconstructedCandDplusBkg) - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) - fillHistoMCRec(candidate, mcParticles, SpeciesAndDecay::DplusToPiKPi); - - // Bkg - for (const auto& candidate : reconstructedCandBkg) { - if (yCandRecoMax >= 0. && std::abs(hfHelper.yDs(candidate)) > yCandRecoMax) { - continue; + fillHistoKKPi(candidate, DataType::McBkg); } - - if (candidate.isSelDsToKKPi() >= selectionFlagDs || candidate.isSelDsToPiKK() >= selectionFlagDs) { + if (candidate.isSelDsToPiKK() >= selectionFlagDs) { // PiKK fillHisto(candidate, DataType::McBkg); - if (candidate.isSelDsToKKPi() >= selectionFlagDs) // KKPi - fillHistoKKPi(candidate, DataType::McDsPrompt); - if (candidate.isSelDsToPiKK() >= selectionFlagDs) // PiKK - fillHistoPiKK(candidate, DataType::McDsPrompt); + fillHistoPiKK(candidate, DataType::McBkg); } } } // TODO: add histograms for reflections + } + template + void fillMcGenHistos(CandDsMcGen const& mcParticles, + Coll const& recoCollisions) + { // MC gen. for (const auto& particle : mcParticles) { if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) { @@ -545,20 +589,27 @@ struct HfTaskDs { auto pt = particle.pt(); double y{0.f}; + unsigned maxNumContrib = 0; + const auto& recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); + for (const auto& recCol : recoCollsPerMcColl) { + maxNumContrib = recCol.numContrib() > maxNumContrib ? recCol.numContrib() : maxNumContrib; + } + if (particle.flagMcDecayChanGen() == decayChannel) { y = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDS); if (yCandGenMax >= 0. && std::abs(y) > yCandGenMax) { continue; } + if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { - std::get(histosPtr[DataType::McDsPrompt]["hPtGen"])->Fill(pt); // gen. level pT - std::get(histosPtr[DataType::McDsPrompt]["hPtVsYGen"])->Fill(pt, y); // gen. level pT - std::get(histosPtr[DataType::McDsPrompt]["hEtaGen"])->Fill(particle.eta()); // gen. level pT + std::get(histosPtr[DataType::McDsPrompt]["hPtGen"])->Fill(pt); // gen. level pT + std::get(histosPtr[DataType::McDsPrompt]["hEtaGen"])->Fill(particle.eta()); + std::get(histosPtr[DataType::McDsPrompt]["hPtYNPvContribGen"])->Fill(pt, y, maxNumContrib); // gen. level pT } if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { - std::get(histosPtr[DataType::McDsNonPrompt]["hPtGen"])->Fill(pt); // gen. level pT - std::get(histosPtr[DataType::McDsNonPrompt]["hPtVsYGen"])->Fill(pt, y); // gen. level pT - std::get(histosPtr[DataType::McDsNonPrompt]["hEtaGen"])->Fill(particle.eta()); // gen. level pT + std::get(histosPtr[DataType::McDsNonPrompt]["hPtGen"])->Fill(pt); // gen. level pT + std::get(histosPtr[DataType::McDsNonPrompt]["hEtaGen"])->Fill(particle.eta()); // gen. level pT + std::get(histosPtr[DataType::McDsNonPrompt]["hPtYNPvContribGen"])->Fill(pt, y, maxNumContrib); // gen. level pT } } else if (fillDplusMc) { y = RecoDecay::y(particle.pVector(), o2::constants::physics::MassDPlus); @@ -566,175 +617,365 @@ struct HfTaskDs { continue; } if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { - std::get(histosPtr[DataType::McDplusPrompt]["hPtGen"])->Fill(pt); // gen. level pT - std::get(histosPtr[DataType::McDplusPrompt]["hPtVsYGen"])->Fill(pt, y); // gen. level pT + std::get(histosPtr[DataType::McDplusPrompt]["hPtGen"])->Fill(pt); // gen. level pT std::get(histosPtr[DataType::McDplusPrompt]["hEtaGen"])->Fill(particle.eta()); + std::get(histosPtr[DataType::McDplusPrompt]["hPtYNPvContribGen"])->Fill(pt, y, maxNumContrib); // gen. level pT } if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { std::get(histosPtr[DataType::McDplusNonPrompt]["hPtGen"])->Fill(pt); // gen. level pT - std::get(histosPtr[DataType::McDplusNonPrompt]["hPtVsYGen"])->Fill(pt, y); std::get(histosPtr[DataType::McDplusNonPrompt]["hEtaGen"])->Fill(particle.eta()); + std::get(histosPtr[DataType::McDplusNonPrompt]["hPtYNPvContribGen"])->Fill(pt, y, maxNumContrib); // gen. level pT + } + } + } + } + } + } + + template + void fillNPvContribHisto(const Coll& collision, + std::array& nCandsPerType, + std::array& nCandsInSignalRegionDsPerType, + std::array& nCandsInSignalRegionDplusPerType) + { + int numPvContributors = collision.numContrib(); + float centrality = evaluateCentralityColl(collision); + std::get(histosPtr[DataType::Data]["hNPvContribAll"])->Fill(numPvContributors, centrality); + for (int i = 0; i < DataType::kDataTypes; i++) { + if (nCandsPerType[i]) { + std::get(histosPtr[i]["hNPvContribCands"])->Fill(numPvContributors, centrality); + } + if (nCandsInSignalRegionDsPerType[i]) { + std::get(histosPtr[i]["hNPvContribCandsInSignalRegionDs"])->Fill(numPvContributors, centrality); + } + if (nCandsInSignalRegionDplusPerType[i]) { + std::get(histosPtr[i]["hNPvContribCandsInSignalRegionDplus"])->Fill(numPvContributors, centrality); + } + } + } + + template + void runDataAnalysisPerCollision(const Coll& collisions, const CandsDs& candsDs) + { + for (const auto& collision : collisions) { + /* check the previous run number */ + const auto& bc = collision.bc(); + if (bc.runNumber() != mRunNumber) { + mRunNumber = bc.runNumber(); // mark this run as at least tried + if (ccdbConfig.reconstructionPass.value == "") { + lCalibObjects = ccdb->getForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, mRunNumber, metadata); + } + + if (lCalibObjects) { + LOG(info) << "CCDB objects loaded successfully"; + hVtxZFT0A = static_cast(lCalibObjects->FindObject("hVtxZFT0A")); + hVtxZFT0C = static_cast(lCalibObjects->FindObject("hVtxZFT0C")); + hVtxZNTracks = static_cast(lCalibObjects->FindObject("hVtxZNTracksPV")); + lCalibLoaded = true; + // Capture error + if (!hVtxZFT0A || !hVtxZFT0C || !hVtxZNTracks) { + LOGF(error, "Problem loading CCDB objects! Please check"); + lCalibLoaded = false; + } + } else { + LOGF(error, "Problem loading CCDB object! Please check"); + lCalibLoaded = false; + } + } + + auto thisCollId = collision.globalIndex(); + std::array nCandsPerType{0}; + std::array nCandsInSignalRegionDsPerType{0}; + std::array nCandsInSignalRegionDplusPerType{0}; + + auto groupedDsCandidates = candsDs.sliceBy(candDsPerCollision, thisCollId); + for (const auto& candidate : groupedDsCandidates) { + if (candidate.isSelDsToKKPi() < selectionFlagDs && candidate.isSelDsToPiKK() < selectionFlagDs) { + continue; + } + runDataAnalysisPerCandidate(candidate); + + ++nCandsPerType[DataType::Data]; + if (isCandInSignalRegion(candidate, true)) { + ++nCandsInSignalRegionDsPerType[DataType::Data]; + } + if (isCandInSignalRegion(candidate, false)) { + ++nCandsInSignalRegionDplusPerType[DataType::Data]; + } + } + fillNPvContribHisto(collision, nCandsPerType, nCandsInSignalRegionDsPerType, nCandsInSignalRegionDplusPerType); + } + } + + template + void runMcAnalysisPerCollision(const Coll& collisions, + const CandsDs& candsDs, + const CandDsMcGen& mcParticles) + { + for (const auto& collision : collisions) { + /* check the previous run number */ + const auto& bc = collision.bc(); + if (bc.runNumber() != mRunNumber) { + mRunNumber = bc.runNumber(); // mark this run as at least tried + if (ccdbConfig.reconstructionPass.value == "") { + lCalibObjects = ccdb->getForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, 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 = ccdb->getSpecificForRun(ccdbConfig.ccdbPath, mRunNumber, metadata); + } + + if (lCalibObjects) { + LOG(info) << "CCDB objects loaded successfully"; + hVtxZFT0A = static_cast(lCalibObjects->FindObject("hVtxZFT0A")); + hVtxZFT0C = static_cast(lCalibObjects->FindObject("hVtxZFT0C")); + hVtxZNTracks = static_cast(lCalibObjects->FindObject("hVtxZNTracksPV")); + lCalibLoaded = true; + // Capture error + if (!hVtxZFT0A || !hVtxZFT0C || !hVtxZNTracks) { + LOGF(error, "Problem loading CCDB objects! Please check"); + lCalibLoaded = false; + } + } else { + LOGF(error, "Problem loading CCDB object! Please check"); + lCalibLoaded = false; + } + } + + auto thisCollId = collision.globalIndex(); + std::array nCandsPerType{0}; + std::array nCandsInSignalRegionDsPerType{0}; + std::array nCandsInSignalRegionDplusPerType{0}; + + auto groupedDsCandidates = candsDs.sliceBy(candDsPerCollision, thisCollId); + for (const auto& candidate : groupedDsCandidates) { + if (candidate.isSelDsToKKPi() < selectionFlagDs && candidate.isSelDsToPiKK() < selectionFlagDs) { + continue; + } + runDataAnalysisPerCandidate(candidate); + runMcAnalysisPerCandidate(candidate, mcParticles); + + // Increase the number of candidates of the corresponding type to fill the NPvContrib histos + std::array, 4> isOfType = {// Contains the functions to check if the candidate is of a certain type + &HfTaskDs::isDsPrompt, + &HfTaskDs::isDsNonPrompt, + &HfTaskDs::isDplusPrompt, + &HfTaskDs::isDplusNonPrompt}; + bool isBkg = true; + for (int i = DataType::McDsPrompt; i <= DataType::McDplusNonPrompt; i++) { // Check what type of MC signal candidate it is, and fill the corresponding arrays + if ((this->*isOfType[i - DataType::McDsPrompt])(candidate)) { + isBkg = false; + ++nCandsPerType[i]; + if (isCandInSignalRegion(candidate, true)) { + ++nCandsInSignalRegionDsPerType[i]; + } + if (isCandInSignalRegion(candidate, false)) { + ++nCandsInSignalRegionDplusPerType[i]; } + break; } } + if (isBkg) { + ++nCandsPerType[DataType::McBkg]; + if (isCandInSignalRegion(candidate, true)) { + ++nCandsInSignalRegionDsPerType[DataType::McBkg]; + } + if (isCandInSignalRegion(candidate, false)) { + ++nCandsInSignalRegionDplusPerType[DataType::McBkg]; + } + } + + nCandsPerType[DataType::Data] = nCandsPerType[DataType::McDsPrompt] + nCandsPerType[DataType::McDsNonPrompt] + nCandsPerType[DataType::McDplusPrompt] + nCandsPerType[DataType::McDplusNonPrompt] + nCandsPerType[DataType::McBkg]; + + nCandsInSignalRegionDsPerType[DataType::Data] = nCandsInSignalRegionDsPerType[DataType::McDsPrompt] + nCandsInSignalRegionDsPerType[DataType::McDsNonPrompt] + nCandsInSignalRegionDsPerType[DataType::McDplusPrompt] + nCandsInSignalRegionDsPerType[DataType::McDplusNonPrompt] + nCandsInSignalRegionDsPerType[DataType::McBkg]; + + nCandsInSignalRegionDplusPerType[DataType::Data] = nCandsInSignalRegionDplusPerType[DataType::McDsPrompt] + nCandsInSignalRegionDplusPerType[DataType::McDsNonPrompt] + nCandsInSignalRegionDplusPerType[DataType::McDplusPrompt] + nCandsInSignalRegionDplusPerType[DataType::McDplusNonPrompt] + nCandsInSignalRegionDplusPerType[DataType::McBkg]; } + fillNPvContribHisto(collision, nCandsPerType, nCandsInSignalRegionDsPerType, nCandsInSignalRegionDplusPerType); } + fillMcGenHistos(mcParticles, collisions); } - void processDataWithCentFT0C(CollisionsWithFT0C const&, - CandDsData const&) + void processDataWithCentFT0C(CollisionsWithFT0C const& collisions, + CandDsData const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandData); - runDataAnalysis(selectedDsToPiKKCandData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithCentFT0C, "Process data w/o ML information on Ds, with information on centrality from FT0C", false); - void processDataWithCentFT0M(CollisionsWithFT0M const&, - CandDsData const&) + void processDataWithCentFT0M(CollisionsWithFT0M const& collisions, + CandDsData const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandData); - runDataAnalysis(selectedDsToPiKKCandData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithCentFT0M, "Process data w/o ML information on Ds, with information on centrality from FT0M", false); - void processDataWithCentNTracksPV(CollisionsWithNTracksPV const&, - CandDsData const&) + void processDataWithCentNTracksPV(CollisionsWithNTracksPV const& collisions, + CandDsData const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandData); - runDataAnalysis(selectedDsToPiKKCandData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithCentNTracksPV, "Process data w/o ML information on Ds, with information on centrality from NTracksPV", false); - void processData(aod::Collisions const&, - CandDsData const&) + void processData(soa::Join const& collisions, + CandDsData const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandData); - runDataAnalysis(selectedDsToPiKKCandData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processData, "Process data w/o ML information on Ds, w/o information on centrality", true); - void processDataWithMlAndCentFT0C(CollisionsWithFT0C const&, - CandDsDataWithMl const&) + void processDataWithMlAndCentFT0C(CollisionsWithFT0C const& collisions, + CandDsDataWithMl const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandWithMlData); - runDataAnalysis(selectedDsToPiKKCandWithMlData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithMlAndCentFT0C, "Process data with ML information on Ds, with information on centrality from FT0C", false); - void processDataWithMlAndCentFT0M(CollisionsWithFT0M const&, - CandDsDataWithMl const&) + void processDataWithMlAndCentFT0M(CollisionsWithFT0M const& collisions, + CandDsDataWithMl const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandWithMlData); - runDataAnalysis(selectedDsToPiKKCandWithMlData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithMlAndCentFT0M, "Process data with ML information on Ds, with information on centrality from FT0M", false); - void processDataWithMlAndCentNTracksPV(CollisionsWithNTracksPV const&, - CandDsDataWithMl const&) + void processDataWithMlAndCentNTracksPV(CollisionsWithNTracksPV const& collisions, + CandDsDataWithMl const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandWithMlData); - runDataAnalysis(selectedDsToPiKKCandWithMlData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithMlAndCentNTracksPV, "Process data with ML information on Ds, with information on centrality", false); - void processDataWithMl(aod::Collisions const&, - CandDsDataWithMl const&) + void processDataWithMl(soa::Join const& collisions, + CandDsDataWithMl const& candsDs, + aod::BCs const&, + aod::Tracks const&) { - runDataAnalysis(selectedDsToKKPiCandWithMlData); - runDataAnalysis(selectedDsToPiKKCandWithMlData); + runDataAnalysisPerCollision(collisions, candsDs); } PROCESS_SWITCH(HfTaskDs, processDataWithMl, "Process data with ML information on Ds, w/o information on centrality", false); - void processMcWithCentFT0C(CollisionsWithFT0C const&, - CandDsMcReco const& candidates, + void processMcWithCentFT0C(CollisionsMcWithFT0C const& collisions, + CandDsMcReco const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandMc); - runDataAnalysis(selectedDsToPiKKCandMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithCentFT0C, "Process MC w/o ML information on Ds, with information on centrality from FT0C", false); - void processMcWithCentFT0M(CollisionsWithFT0M const&, - CandDsMcReco const& candidates, + void processMcWithCentFT0M(CollisionsMcWithFT0M const& collisions, + CandDsMcReco const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandMc); - runDataAnalysis(selectedDsToPiKKCandMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithCentFT0M, "Process MC w/o ML information on Ds, with information on centrality from FT0M", false); - void processMcWithCentNTracksPV(CollisionsWithNTracksPV const&, - CandDsMcReco const& candidates, + void processMcWithCentNTracksPV(CollisionsMcWithNTracksPV const& collisions, + CandDsMcReco const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandMc); - runDataAnalysis(selectedDsToPiKKCandMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithCentNTracksPV, "Process MC w/o ML information on Ds, with information on centrality from NTracksPV", false); - void processMc(aod::Collisions const&, - CandDsMcReco const& candidates, + void processMc(CollisionsMc const& collisions, + CandDsMcReco const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandMc); - runDataAnalysis(selectedDsToPiKKCandMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMc, "Process MC w/o ML information on Ds, w/o information on centrality", false); - void processMcWithMlAndCentFT0C(CollisionsWithFT0C const&, - CandDsMcRecoWithMl const& candidates, + void processMcWithMlAndCentFT0C(CollisionsMcWithFT0C const& collisions, + CandDsMcRecoWithMl const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandWithMlMc); - runDataAnalysis(selectedDsToPiKKCandWithMlMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithMlAndCentFT0C, "Process MC with ML information on Ds, with information on centrality from FT0C", false); - void processMcWithMlAndCentFT0M(CollisionsWithFT0M const&, - CandDsMcRecoWithMl const& candidates, + void processMcWithMlAndCentFT0M(CollisionsMcWithFT0M const& collisions, + CandDsMcRecoWithMl const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandWithMlMc); - runDataAnalysis(selectedDsToPiKKCandWithMlMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithMlAndCentFT0M, "Process MC with ML information on Ds, with information on centrality from FT0M", false); - void processMcWithMlAndCentNTracksPV(CollisionsWithNTracksPV const&, - CandDsMcRecoWithMl const& candidates, + void processMcWithMlAndCentNTracksPV(CollisionsMcWithNTracksPV const& collisions, + CandDsMcRecoWithMl const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandWithMlMc); - runDataAnalysis(selectedDsToPiKKCandWithMlMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithMlAndCentNTracksPV, "Process MC with ML information on Ds, with information on centrality from NTracksPV", false); - void processMcWithMl(aod::Collisions const&, - CandDsMcRecoWithMl const& candidates, + void processMcWithMl(CollisionsMc const& collisions, + CandDsMcRecoWithMl const& candsDs, CandDsMcGen const& mcParticles, + aod::BCs const&, + aod::McCollisions const&, aod::TracksWMc const&) { - runMcAnalysis(candidates, mcParticles); - runDataAnalysis(selectedDsToKKPiCandWithMlMc); - runDataAnalysis(selectedDsToPiKKCandWithMlMc); + runMcAnalysisPerCollision(collisions, candsDs, mcParticles); } PROCESS_SWITCH(HfTaskDs, processMcWithMl, "Process MC with ML information on Ds, w/o information on centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { + // Parse the metadata + metadataInfo.initMetadata(cfgc); return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx b/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx index 07c5f63efa9..522be398df6 100644 --- a/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx +++ b/PWGHF/D2H/Tasks/taskDstarToD0Pi.cxx @@ -15,8 +15,13 @@ /// \author Deependra Sharma , IITB /// \author Fabrizio Grosa , CERN +#include +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" +#include "Framework/ASoAHelpers.h" #include "Framework/runDataProcessing.h" #include "PWGHF/Core/SelectorCuts.h" @@ -27,6 +32,7 @@ using namespace o2; using namespace o2::analysis; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::soa; /// Dstar analysis task struct HfTaskDstarToD0Pi { @@ -37,17 +43,31 @@ struct HfTaskDstarToD0Pi { Configurable> ptBins{"ptBins", std::vector{hf_cuts_dstar_to_d0_pi::vecBinsPt}, "pT bin limits for Dstar"}; using CandDstarWSelFlag = soa::Join; + using CandDstarWSelFlagWMl = soa::Join; /// @brief specially for MC data // full reconstructed Dstar candidate using CandDstarWSelFlagMcRec = soa::Join; using CandDstarMcGen = soa::Join; - Partition rowsSelectedCandDstar = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi; + using CollisionsWCent = soa::Join; + using CollisionsWCentMcLabel = soa::Join; + + Filter candFilter = aod::hf_sel_candidate_dstar::isSelDstarToD0Pi == selectionFlagDstarToD0Pi; + Preslice> preslicSelectedCandDstarPerCol = aod::hf_cand::collisionId; + Preslice> preslicSelectedCandDstarPerColWMl = aod::hf_cand::collisionId; + + PresliceUnsorted colsPerMcCollision = aod::mccollisionlabel::mcCollisionId; + SliceCache cache; + Partition rowsSelectedCandDstarMcRec = aod::hf_sel_candidate_dstar::isRecoD0Flag == selectionFlagHfD0ToPiK; ConfigurableAxis binningImpactParam{"binningImpactParam", {1000, 0.1, -0.1}, " Bins of Impact Parameter"}; ConfigurableAxis binningDecayLength{"binningDecayLength", {1000, 0.0, 0.7}, "Bins of Decay Length"}; ConfigurableAxis binningNormDecayLength{"binningNormDecayLength", {1000, 0.0, 40.0}, "Bins of Normalised Decay Length"}; + ConfigurableAxis binningCentrality{"binningCentrality", {VARIABLE_WIDTH, 0.0, 1.0, 10.0, 30.0, 50.0, 70.0, 100.0}, "centrality binning"}; + ConfigurableAxis binningDeltaInvMass{"binningDeltaInvMass", {100, 0.13, 0.16}, "Bins of Delta InvMass of Dstar"}; + ConfigurableAxis binningBkgBDTScore{"binningBkgBDTScore", {100, 0.0f, 1.0f}, "Bins for background BDT Score"}; + ConfigurableAxis binningSigBDTScore{"binningSigBDTScore", {100, 0.0f, 1.0f}, "Bins for Signal (Prompts + Non Prompt) BDT Score"}; HistogramRegistry registry{ "registry", @@ -57,7 +77,8 @@ struct HfTaskDstarToD0Pi { {"QA/hPtProng1D0", "Prong1 of D0 Candidates; Prong1 #it{p}_{T} (GeV/#it{c}); entries", {HistType::kTH1F, {{360, 0., 36.}}}}, {"QA/hPtProng0D0Bar", "Prong0 of D0Bar Candidates; Prong0 #it{p}_{T} (GeV/#it{c}); entries", {HistType::kTH1F, {{360, 0., 36.}}}}, {"QA/hPtProng1D0Bar", "Prong1 of D0Bar Candidates; Prong1 #it{p}_{T} (GeV/#it{c}); entries", {HistType::kTH1F, {{360, 0., 36.}}}}, - {"QA/hPtSoftPi", "Soft Pi ; Soft Pi #it{p}_{T} (GeV/#it{c}); entries", {HistType::kTH1F, {{100, 0., 1.}}}}}}; + {"QA/hPtSoftPi", "Soft Pi ; Soft Pi #it{p}_{T} (GeV/#it{c}); entries", {HistType::kTH1F, {{100, 0., 1.}}}}, + {"QA/hDeltaCentGen", "#{Delta}Cent % distribution of Collisions having same MC Collision;FT0M #{Delta}Cent %; Counts", {HistType::kTH1F, {{100, 0.0, 100.0}}}}}}; void init(InitContext&) { @@ -66,9 +87,15 @@ struct HfTaskDstarToD0Pi { AxisSpec axisImpactParam = {binningImpactParam, "impact parameter (cm)"}; AxisSpec axisDecayLength = {binningDecayLength, " decay length (cm)"}; AxisSpec axisNormDecayLength = {binningNormDecayLength, "normalised decay length (cm)"}; + AxisSpec axisCentrality = {binningCentrality, "centrality (%)"}; + AxisSpec axisDeltaInvMass = {binningDeltaInvMass, "#Delta #it{M}_{inv} D*"}; + AxisSpec axisBDTScorePrompt = {binningSigBDTScore, "BDT Score for Prompt Cand"}; + AxisSpec axisBDTScoreNonPrompt = {binningSigBDTScore, "BDT Score for Non-Prompt Cand"}; + AxisSpec axisBDTScoreBackground = {binningBkgBDTScore, "BDT Score for Background Cand"}; - registry.add("Yield/hDeltaInvMassDstar2D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {{100, 0.13, 0.16}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}, true); - registry.add("Yield/hDeltaInvMassDstar1D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2}); entries", {HistType::kTH1F, {{100, 0.13, 0.16}}}, true); + registry.add("Yield/hDeltaInvMassDstar3D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c}); FT0M centrality", {HistType::kTH3F, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true); + registry.add("Yield/hDeltaInvMassDstar2D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}, true); + registry.add("Yield/hDeltaInvMassDstar1D", "#Delta #it{M}_{inv} D* Candidate; inv. mass ((#pi #pi k) - (#pi k)) (GeV/#it{c}^{2}); entries", {HistType::kTH1F, {{axisDeltaInvMass}}}, true); registry.add("Yield/hInvMassDstar", "#Delta #it{M}_{inv} D* Candidate; inv. mass (#pi #pi k) (GeV/#it{c}^{2}); entries", {HistType::kTH1F, {{500, 0., 5.0}}}, true); registry.add("Yield/hInvMassD0", "#it{M}_{inv}D^{0} candidate;#it{M}_{inv} D^{0} (GeV/#it{c});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {{500, 0., 5.0}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}, true); // only QA @@ -94,11 +121,13 @@ struct HfTaskDstarToD0Pi { registry.add("QA/hEtaSkimD0RecSig", "MC Matched Skimed D* Candidates at Reconstruction Level; #it{#eta} of D0 Prong", {HistType::kTH1F, {{100, -2., 2.}}}); registry.add("QA/hEtaSkimDstarRecSig", "MC Matched Skimed D* Candidates at Reconstruction Level; #it{#eta} of D* Candidate", {HistType::kTH1F, {{100, -2., 2.}}}); // pt vs y - registry.add("QA/hPtSkimDstarGenSig", "MC Matched Skimed D* Reconstructed Candidates at Generator Level; #it{p}_{T} of D* at Generator Level (GeV/#it{c})", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("QA/hPtSkimDstarGenSig", "MC Matched Skimed D* Reconstructed Candidates at Generator Level; #it{p}_{T} of D* at Generator Level (GeV/#it{c})", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}, true); + registry.add("Efficiency/hPtVsCentSkimDstarGenSig", "MC Matched Skimed D* Reconstructed Candidates at Generator Level; #it{p}_{T} of D* at Generator Level (GeV/#it{c}); Centrality (%)", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true); registry.add("QA/hPtVsYSkimDstarRecSig", "MC Matched Skimed D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); registry.add("QA/hPtVsYRecoTopolDstarRecSig", "MC Matched RecoTopol D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); registry.add("QA/hPtVsYRecoPidDstarRecSig", "MC Matched RecoPid D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); registry.add("QA/hPtFullRecoDstarRecSig", "MC Matched FullReco D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c})", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("Efficiency/hPtVsCentFullRecoDstarRecSig", "MC Matched FullReco D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); Centrality (%)", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true); // Only Prompt RecSig registry.add("QA/hPtVsYSkimPromptDstarRecSig", "MC Matched Skimed Prompt D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}; #it{y})", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); registry.add("QA/hPtVsYRecoTopolPromptDstarRecSig", "MC Matched RecoTopol Prompt D* Candidates at Reconstruction Level; #it{p}_{T} of D* at Reconstruction Level (GeV/#it{c}); #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); @@ -118,6 +147,7 @@ struct HfTaskDstarToD0Pi { // MC Matching at Generator level Successful registry.add("QA/hEtaDstarGen", "MC Matched D* Candidates at Generator Level; #it{#eta}", {HistType::kTH1F, {{100, -2., 2.}}}); registry.add("QA/hPtDstarGen", "MC Matched D* Candidates at Generator Level; #it{p}_{T} of D*", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("Efficiency/hPtVsCentDstarGen", "MC Matched D* Candidates at Generator Level; #it{p}_{T} of D*;Centrality (%) ", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}}}, true); registry.add("QA/hPtVsYDstarGen", "MC Matched D* Candidates at Generator Level; #it{p}_{T} of D*; #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); // Prompt Gen registry.add("QA/hPtPromptDstarGen", "MC Matched Prompt D* Candidates at Generator Level; #it{p}_{T} of D*", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}); @@ -125,68 +155,129 @@ struct HfTaskDstarToD0Pi { // Non Prmpt Gen registry.add("QA/hPtNonPromptDstarGen", "MC Matched Non-Prompt D* Candidates at Generator Level; #it{p}_{T} of D*", {HistType::kTH1F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("QA/hPtVsYNonPromptDstarGen", "MC Matched Non-Prompt D* Candidates at Generator Level; #it{p}_{T} of D*; #it{y}", {HistType::kTH2F, {{vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}}); + + // Checking PV contributors from Data as well MC rec + registry.add("Efficiency/hNumPvContributorsAll", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true); + registry.add("Efficiency/hNumPvContributorsCand", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true); + registry.add("Efficiency/hNumPvContributorsCandInMass", "PV Contributors; PV Contributor; FT0M Centrality", {HistType::kTH2F, {{100, 0, 300}, {axisCentrality}}}, true); + + // BDT Score (axisBDTScoreBackground, axisBDTScorePrompt, axisBDTScoreNonPrompt) + registry.add("Yield/hDeltaInvMassVsPtVsCentVsBDTScore", "#Delta #it{M}_{inv} Vs Pt Vs Cent Vs BDTScore", {HistType::kTHnSparseL, {{axisDeltaInvMass}, {vecPtBins, "#it{p}_{T} (GeV/#it{c})"}, {axisCentrality}, {axisBDTScoreBackground}, {axisBDTScorePrompt}, {axisBDTScoreNonPrompt}}}); } - void process(CandDstarWSelFlag const&) + template + void runTaskDstar(CollisionsWCent const& cols, T1 selectedCands, T2 preslice) { - for (const auto& candDstar : rowsSelectedCandDstar) { - auto yDstar = candDstar.y(constants::physics::MassDStar); - if (yCandDstarRecoMax >= 0. && std::abs(yDstar) > yCandDstarRecoMax) { - continue; + for (const auto& col : cols) { + auto nPVContributors = col.numContrib(); + auto centrality = col.centFT0M(); + registry.fill(HIST("Efficiency/hNumPvContributorsAll"), nPVContributors, centrality); + + auto gIndexCol = col.globalIndex(); + auto selectedCandsCurrentCol = selectedCands.sliceBy(preslice, gIndexCol); + auto nCandsCurrentCol = selectedCandsCurrentCol.size(); + + if (nCandsCurrentCol > 0) { + LOGF(debug, "size of selectedCandsCurrentCol: %d", nCandsCurrentCol); + registry.fill(HIST("Efficiency/hNumPvContributorsCand"), nPVContributors, centrality); } - registry.fill(HIST("QA/hPtDstar"), candDstar.pt()); - registry.fill(HIST("QA/hPtD0"), candDstar.ptD0()); - registry.fill(HIST("QA/hPtSoftPi"), candDstar.ptSoftPi()); - registry.fill(HIST("QA/hEtaDstar"), candDstar.eta(), candDstar.pt()); - registry.fill(HIST("QA/hCtD0"), candDstar.ctD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthD0"), candDstar.decayLengthD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthXYD0"), candDstar.decayLengthXYD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthNormalisedD0"), candDstar.decayLengthNormalisedD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthXYNormalisedD0"), candDstar.decayLengthXYNormalisedD0(), candDstar.pt()); - registry.fill(HIST("QA/hCPAD0"), candDstar.cpaD0(), candDstar.pt()); - registry.fill(HIST("QA/hCPAxyD0"), candDstar.cpaXYD0(), candDstar.pt()); - registry.fill(HIST("QA/hImpactParameterXYD0"), candDstar.impactParameterXYD0(), candDstar.pt()); - registry.fill(HIST("QA/hDeltaIPMaxNormalisedD0"), candDstar.deltaIPNormalisedMaxD0(), candDstar.pt()); - registry.fill(HIST("QA/hSqSumProngsImpactParameterD0"), candDstar.impactParameterProngSqSumD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthErrorD0"), candDstar.errorDecayLengthD0(), candDstar.pt()); - registry.fill(HIST("QA/hDecayLengthXYErrorD0"), candDstar.errorDecayLengthXYD0(), candDstar.pt()); - registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpactParameter0(), candDstar.pt()); - registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpactParameter1(), candDstar.pt()); - registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpParamSoftPi(), candDstar.pt()); - registry.fill(HIST("QA/hd0Prong0"), candDstar.impactParameter0(), candDstar.pt()); - registry.fill(HIST("QA/hd0Prong1"), candDstar.impactParameter1(), candDstar.pt()); - registry.fill(HIST("QA/hd0ProngSoftPi"), candDstar.impParamSoftPi(), candDstar.pt()); - - auto invDstar = candDstar.invMassDstar(); - auto invAntiDstar = candDstar.invMassAntiDstar(); - auto invD0 = candDstar.invMassD0(); - auto invD0Bar = candDstar.invMassD0Bar(); - - auto signDstar = candDstar.signSoftPi(); - if (signDstar > 0) { - registry.fill(HIST("Yield/hDeltaInvMassDstar2D"), (invDstar - invD0), candDstar.pt()); - registry.fill(HIST("Yield/hInvMassD0"), invD0, candDstar.ptD0()); - registry.fill(HIST("Yield/hDeltaInvMassDstar1D"), (invDstar - invD0)); - registry.fill(HIST("Yield/hInvMassDstar"), invDstar); - // filling pt of two pronges of D0 - registry.fill(HIST("QA/hPtProng0D0"), candDstar.ptProng0()); - registry.fill(HIST("QA/hPtProng1D0"), candDstar.ptProng1()); - } else if (signDstar < 0) { - registry.fill(HIST("Yield/hDeltaInvMassDstar2D"), (invAntiDstar - invD0Bar), candDstar.pt()); - registry.fill(HIST("Yield/hInvMassD0"), invD0Bar, candDstar.ptD0()); - registry.fill(HIST("Yield/hDeltaInvMassDstar1D"), (invAntiDstar - invD0Bar)); - registry.fill(HIST("Yield/hInvMassDstar"), invAntiDstar); - // filling pt of two pronges of D0Bar - registry.fill(HIST("QA/hPtProng0D0Bar"), candDstar.ptProng0()); - registry.fill(HIST("QA/hPtProng1D0Bar"), candDstar.ptProng1()); + + int nCandsSignalRegion = 0; + for (const auto& candDstar : selectedCandsCurrentCol) { + auto yDstar = candDstar.y(constants::physics::MassDStar); + if (yCandDstarRecoMax >= 0. && std::abs(yDstar) > yCandDstarRecoMax) { + continue; + } + + registry.fill(HIST("QA/hPtDstar"), candDstar.pt()); + registry.fill(HIST("QA/hPtD0"), candDstar.ptD0()); + registry.fill(HIST("QA/hPtSoftPi"), candDstar.ptSoftPi()); + registry.fill(HIST("QA/hEtaDstar"), candDstar.eta(), candDstar.pt()); + registry.fill(HIST("QA/hCtD0"), candDstar.ctD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthD0"), candDstar.decayLengthD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthXYD0"), candDstar.decayLengthXYD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthNormalisedD0"), candDstar.decayLengthNormalisedD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthXYNormalisedD0"), candDstar.decayLengthXYNormalisedD0(), candDstar.pt()); + registry.fill(HIST("QA/hCPAD0"), candDstar.cpaD0(), candDstar.pt()); + registry.fill(HIST("QA/hCPAxyD0"), candDstar.cpaXYD0(), candDstar.pt()); + registry.fill(HIST("QA/hImpactParameterXYD0"), candDstar.impactParameterXYD0(), candDstar.pt()); + registry.fill(HIST("QA/hDeltaIPMaxNormalisedD0"), candDstar.deltaIPNormalisedMaxD0(), candDstar.pt()); + registry.fill(HIST("QA/hSqSumProngsImpactParameterD0"), candDstar.impactParameterProngSqSumD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthErrorD0"), candDstar.errorDecayLengthD0(), candDstar.pt()); + registry.fill(HIST("QA/hDecayLengthXYErrorD0"), candDstar.errorDecayLengthXYD0(), candDstar.pt()); + registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpactParameter0(), candDstar.pt()); + registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpactParameter1(), candDstar.pt()); + registry.fill(HIST("QA/hImpactParameterError"), candDstar.errorImpParamSoftPi(), candDstar.pt()); + registry.fill(HIST("QA/hd0Prong0"), candDstar.impactParameter0(), candDstar.pt()); + registry.fill(HIST("QA/hd0Prong1"), candDstar.impactParameter1(), candDstar.pt()); + registry.fill(HIST("QA/hd0ProngSoftPi"), candDstar.impParamSoftPi(), candDstar.pt()); + + auto invDstar = candDstar.invMassDstar(); + auto invAntiDstar = candDstar.invMassAntiDstar(); + auto invD0 = candDstar.invMassD0(); + auto invD0Bar = candDstar.invMassD0Bar(); + + auto signDstar = candDstar.signSoftPi(); + if (signDstar > 0) { + auto deltaMDstar = std::abs(invDstar - invD0); + if (0.142f < deltaMDstar && deltaMDstar < 0.15f) { + nCandsSignalRegion++; + } + + if constexpr (applyMl) { + auto mlBdtScore = candDstar.mlProbDstarToD0Pi(); + registry.fill(HIST("Yield/hDeltaInvMassVsPtVsCentVsBDTScore"), deltaMDstar, candDstar.pt(), centrality, mlBdtScore[0], mlBdtScore[1], mlBdtScore[2]); + } + + registry.fill(HIST("Yield/hDeltaInvMassDstar3D"), deltaMDstar, candDstar.pt(), centrality); + registry.fill(HIST("Yield/hDeltaInvMassDstar2D"), deltaMDstar, candDstar.pt()); + registry.fill(HIST("Yield/hInvMassD0"), invD0, candDstar.ptD0()); + registry.fill(HIST("Yield/hDeltaInvMassDstar1D"), deltaMDstar); + registry.fill(HIST("Yield/hInvMassDstar"), invDstar); + // filling pt of two pronges of D0 + registry.fill(HIST("QA/hPtProng0D0"), candDstar.ptProng0()); + registry.fill(HIST("QA/hPtProng1D0"), candDstar.ptProng1()); + } else if (signDstar < 0) { + auto deltaMAntiDstar = std::abs(invAntiDstar - invD0Bar); + if (0.142f < deltaMAntiDstar && deltaMAntiDstar < 0.15f) { + nCandsSignalRegion++; + } + 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()); + registry.fill(HIST("Yield/hDeltaInvMassDstar1D"), deltaMAntiDstar); + registry.fill(HIST("Yield/hInvMassDstar"), invAntiDstar); + // filling pt of two pronges of D0Bar + registry.fill(HIST("QA/hPtProng0D0Bar"), candDstar.ptProng0()); + registry.fill(HIST("QA/hPtProng1D0Bar"), candDstar.ptProng1()); + } + } // candidate loop for current collision ends + + if (nCandsSignalRegion > 0) { + registry.fill(HIST("Efficiency/hNumPvContributorsCandInMass"), nPVContributors, centrality); } - } + } // collision loop ends + } + + // process function without susing ML + void processWoML(CollisionsWCent const& cols, soa::Filtered const& selectedCands) + { + runTaskDstar, Preslice>>(cols, selectedCands, preslicSelectedCandDstarPerCol); } + PROCESS_SWITCH(HfTaskDstarToD0Pi, processWoML, "Process without ML", true); - void processMC(CandDstarWSelFlagMcRec const&, + // process function with susing ML, Here we store BDT score as well + void processWML(CollisionsWCent const& cols, soa::Filtered const& selectedCands) + { + runTaskDstar, Preslice>>(cols, selectedCands, preslicSelectedCandDstarPerColWMl); + } + PROCESS_SWITCH(HfTaskDstarToD0Pi, processWML, "Process with ML", false); + + void processMC(aod::McCollisions const&, CollisionsWCentMcLabel const& collisions, CandDstarWSelFlagMcRec const&, CandDstarMcGen const& rowsMcPartilces, aod::TracksWMc const&) { + rowsSelectedCandDstarMcRec.bindExternalIndices(&collisions); int8_t signDstar = 0; // MC at Reconstruction level @@ -196,11 +287,19 @@ struct HfTaskDstarToD0Pi { if (yCandDstarRecoMax >= 0. && std::abs(yDstarRecSig) > yCandDstarRecoMax) { continue; } + auto collision = candDstarMcRec.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 // get MC Mother particle auto indexMother = RecoDecay::getMother(rowsMcPartilces, candDstarMcRec.prong0_as().mcParticle_as(), o2::constants::physics::Pdg::kDStar, true, &signDstar, 2); auto particleMother = rowsMcPartilces.rawIteratorAt(indexMother); // What is difference between rawIterator() or iteratorAt() methods? registry.fill(HIST("QA/hPtSkimDstarGenSig"), particleMother.pt()); // generator level pt + registry.fill(HIST("Efficiency/hPtVsCentSkimDstarGenSig"), particleMother.pt(), centrality); + registry.fill(HIST("Efficiency/hPtVsCentFullRecoDstarRecSig"), ptDstarRecSig, centrality); + + // auto recCollision = candDstarMcRec.collision_as(); + // float centFT0M = recCollision.centFT0M(); + // LOGF(info, "centFT0M: %f", centFT0M); registry.fill(HIST("QA/hPtVsYSkimDstarRecSig"), ptDstarRecSig, yDstarRecSig); // Skimed at level of trackIndexSkimCreator if (candDstarMcRec.isRecoTopol()) { // if Topological selection are passed @@ -253,15 +352,48 @@ struct HfTaskDstarToD0Pi { // MC at Generator Level for (const auto& mcParticle : rowsMcPartilces) { if (TESTBIT(std::abs(mcParticle.flagMcMatchGen()), aod::hf_cand_dstar::DecayType::DstarToD0Pi)) { // MC Matching is successful at Generator Level + auto ptGen = mcParticle.pt(); // auto yGen = mcParticle.y(); // Can we use this definition? auto yGen = RecoDecay::y(mcParticle.pVector(), o2::constants::physics::MassDStar); if (yCandDstarGenMax >= 0. && std::abs(yGen) > yCandDstarGenMax) { continue; } + + auto mcCollision = mcParticle.mcCollision_as(); + auto recCollisions = collisions.sliceBy(colsPerMcCollision, mcCollision.globalIndex()); + // auto recCollisions = collisions.sliceByCached(aod::mccollisionlabel::mcCollisionId, mcCollision.globalIndex(), cache); + // auto recCollisions = collisions.sliceByCachedUnsorted(aod::mccollisionlabel::mcCollisionId, mcCollision.globalIndex(), cache); + + // looking if a generated collision reconstructed more than a times. + if (recCollisions.size() > 1) { + for (const auto& [c1, c2] : combinations(CombinationsStrictlyUpperIndexPolicy(recCollisions, recCollisions))) { + auto deltaCent = abs(c1.centFT0M() - c2.centFT0M()); + registry.fill(HIST("QA/hDeltaCentGen"), deltaCent); + } + } + + float centFT0MGen; + // assigning centrality to MC Collision using max FT0M amplitute from Reconstructed collisions + if (recCollisions.size()) { + std::vector::iterator, int>> tempRecCols; + + for (const auto& recCol : recCollisions) { + // if(recCollisions.size()>1) LOGF(info, "cuurent cent: %f",recCol.centFT0M()); + tempRecCols.push_back(std::make_pair(recCol, recCol.numContrib())); + } + std::sort(tempRecCols.begin(), tempRecCols.end(), compare); + centFT0MGen = tempRecCols.at(0).first.centFT0M(); + // if(recCollisions.size()>1) LOGF(info, "assigned cent: %f",centFT0MGen); + } else { + centFT0MGen = -999.; + } + registry.fill(HIST("QA/hEtaDstarGen"), mcParticle.eta()); registry.fill(HIST("QA/hPtDstarGen"), ptGen); registry.fill(HIST("QA/hPtVsYDstarGen"), ptGen, yGen); + registry.fill(HIST("Efficiency/hPtVsCentDstarGen"), ptGen, centFT0MGen); + // only promt Dstar candidate at Generator level if (mcParticle.originMcGen() == RecoDecay::OriginType::Prompt) { registry.fill(HIST("QA/hPtPromptDstarGen"), ptGen); @@ -274,6 +406,12 @@ struct HfTaskDstarToD0Pi { } } PROCESS_SWITCH(HfTaskDstarToD0Pi, processMC, "Process MC Data", false); + + // Comparator function to sort based on the second argument of a tuple + static bool compare(const std::pair::iterator, int>& a, const std::pair::iterator, int>& b) + { + return a.second > b.second; + } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx index 4b808f5dfb1..2d84a9afdf8 100644 --- a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx +++ b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx @@ -15,6 +15,10 @@ /// \author S. Politanò, INFN Torino, Italy /// \author Wu Chuntai, CUG, China +#include +#include + +#include "CCDB/BasicCCDBManager.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -26,12 +30,14 @@ #include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::hf_centrality; +using namespace o2::hf_evsel; enum DecayChannel { DplusToPiKPi = 0, DsToKKPi, @@ -46,16 +52,22 @@ enum QvecEstimator { FV0A = 0, FT0A, FT0C, TPCPos, - TPCNeg }; + TPCNeg, + TPCTot }; struct HfTaskFlowCharmHadrons { - Configurable zVtxMax{"zVtxMax", 10., "Max vertex coordinate z"}; 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)"}; + 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)"}; Configurable selectionFlag{"selectionFlag", 1, "Selection Flag for hadron (e.g. 1 for skimming, 3 for topo. and kine., 7 for PID)"}; + Configurable centralityMin{"centralityMin", 0., "Minimum centrality accepted in SP/EP computation (not applied in resolution process)"}; + 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 occEstimator{"occEstimator", 1, "Occupancy estimation (1: ITS, 2: FT0C)"}; + Configurable storeOccupancy{"storeOccupancy", false, "Flag to store TH2 occITS/occFT0C + HfEvSelBitMasks"}; 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}, ""}; @@ -66,6 +78,13 @@ struct HfTaskFlowCharmHadrons { 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 thnConfigAxisNumTracksInTimeRange{"thnConfigAxisNumTracksInTimeRange", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInTimeRangeNarrow{"thnConfigAxisNoCollInTimeRangeNarrow", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInTimeRangeStandard{"thnConfigAxisNoCollInTimeRangeStandard", {2, 0, 2}, ""}; + ConfigurableAxis thnConfigAxisNoCollInRofStandard{"thnConfigAxisNoCollInRofStandard", {2, 0, 2}, ""}; using CandDsDataWMl = soa::Filtered>; using CandDsData = soa::Filtered>; @@ -75,7 +94,7 @@ struct HfTaskFlowCharmHadrons { using CandLcDataWMl = soa::Filtered>; using CandD0DataWMl = soa::Filtered>; using CandD0Data = soa::Filtered>; - using CollsWithQvecs = soa::Join; + using CollsWithQvecs = soa::Join; Filter filterSelectDsCandidates = aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlag || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlag; Filter filterSelectDplusCandidates = aod::hf_sel_candidate_dplus::isSelDplusToPiKPi >= selectionFlag; @@ -98,6 +117,8 @@ struct HfTaskFlowCharmHadrons { SliceCache cache; HfHelper hfHelper; EventPlaneHelper epHelper; + HfEventSelection hfEvSel; // event selection and monitoring + o2::framework::Service ccdb; HistogramRegistry registry{"registry", {}}; @@ -111,40 +132,79 @@ struct HfTaskFlowCharmHadrons { const AxisSpec thnAxisScalarProd{thnConfigAxisScalarProd, "SP"}; const AxisSpec thnAxisMlOne{thnConfigAxisMlOne, "Bkg score"}; const AxisSpec thnAxisMlTwo{thnConfigAxisMlTwo, "FD score"}; - + const AxisSpec thnAxisOccupancyITS{thnConfigAxisOccupancyITS, "OccupancyITS"}; + const AxisSpec thnAxisOccupancyFT0C{thnConfigAxisOccupancyFT0C, "OccupancyFT0C"}; + const AxisSpec thnAxisNoSameBunchPileup{thnConfigAxisNoSameBunchPileup, "NoSameBunchPileup"}; + const AxisSpec thnAxisNumTracksInTimeRange{thnConfigAxisNumTracksInTimeRange, "NumTracksInTimeRange"}; + const AxisSpec thnAxisNoCollInTimeRangeNarrow{thnConfigAxisNoCollInTimeRangeNarrow, "NoCollInTimeRangeNarrow"}; + const AxisSpec thnAxisNoCollInTimeRangeStandard{thnConfigAxisNoCollInTimeRangeStandard, "NoCollInTimeRangeStandard"}; + const AxisSpec thnAxisNoCollInRofStandard{thnConfigAxisNoCollInRofStandard, "NoCollInRofStandard"}; + + std::vector axes = {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisScalarProd}; + if (storeEP) { + axes.insert(axes.end(), {thnAxisCosNPhi, thnAxisCosDeltaPhi}); + } if (storeMl) { - registry.add("hSparseFlowCharm", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisCosNPhi, thnAxisCosDeltaPhi, thnAxisScalarProd, thnAxisMlOne, thnAxisMlTwo}); - } else { - registry.add("hSparseFlowCharm", "THn for SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCent, thnAxisCosNPhi, thnAxisCosDeltaPhi, thnAxisScalarProd}); + axes.insert(axes.end(), {thnAxisMlOne, thnAxisMlTwo}); + } + if (storeOccupancy) { + if (occEstimator == 1) { + axes.insert(axes.end(), {thnAxisOccupancyITS, thnAxisNoSameBunchPileup, thnAxisNumTracksInTimeRange, + thnAxisNoCollInTimeRangeNarrow, thnAxisNoCollInTimeRangeStandard, thnAxisNoCollInRofStandard}); + } else { + axes.insert(axes.end(), {thnAxisOccupancyFT0C, thnAxisNoSameBunchPileup, thnAxisNumTracksInTimeRange, + thnAxisNoCollInTimeRangeNarrow, thnAxisNoCollInTimeRangeStandard, thnAxisNoCollInRofStandard}); + } } - 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}}); - registry.add("spReso/hSpResoFT0cTPCpos", "hSpResoFT0cTPCpos; centrality; Q_{FT0c} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0cTPCneg", "hSpResoFT0cTPCneg; centrality; Q_{FT0c} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0aFV0a", "hSpResoFT0aFV0a; centrality; Q_{FT0a} #bullet Q_{FV0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0aTPCpos", "hSpResoFT0aTPCpos; centrality; Q_{FT0a} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0aTPCneg", "hSpResoFT0aTPCneg; centrality; Q_{FT0a} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0mFV0a", "hSpResoFT0mFV0a; centrality; Q_{FT0m} #bullet Q_{FV0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0mTPCpos", "hSpResoFT0mTPCpos; centrality; Q_{FT0m} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFT0mTPCneg", "hSpResoFT0mTPCneg; centrality; Q_{FT0m} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFV0aTPCpos", "hSpResoFV0aTPCpos; centrality; Q_{FV0a} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoFV0aTPCneg", "hSpResoFV0aTPCneg; centrality; Q_{FV0a} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); - registry.add("spReso/hSpResoTPCposTPCneg", "hSpResoTPCposTPCneg; centrality; Q_{TPCpos} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("hSparseFlowCharm", "THn for SP", HistType::kTHnSparseF, axes); - if (saveEpResoHisto) { - registry.add("epReso/hEpResoFT0cFT0a", "hEpResoFT0cFT0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0cFV0a", "hEpResoFT0cFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0cTPCpos", "hEpResoFT0cTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0cTPCneg", "hEpResoFT0cTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0aFV0a", "hEpResoFT0aFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0aTPCpos", "hEpResoFT0aTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0aTPCneg", "hEpResoFT0aTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0mFV0a", "hEpResoFT0mFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0mTPCpos", "hEpResoFT0mTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFT0mTPCneg", "hEpResoFT0mTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFV0aTPCpos", "hEpResoFV0aTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoFV0aTPCneg", "hEpResoFV0aTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); - registry.add("epReso/hEpResoTPCposTPCneg", "hEpResoTPCposTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + if (storeOccupancy) { + registry.add("trackOccVsFT0COcc", "trackOccVsFT0COcc; trackOcc; FT0COcc", {HistType::kTH2F, {thnAxisOccupancyITS, thnAxisOccupancyFT0C}}); + } + + 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}}); + registry.add("spReso/hSpResoFT0cTPCpos", "hSpResoFT0cTPCpos; centrality; Q_{FT0c} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0cTPCneg", "hSpResoFT0cTPCneg; centrality; Q_{FT0c} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0cTPCtot", "hSpResoFT0cTPCtot; centrality; Q_{FT0c} #bullet Q_{TPCtot}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0aFV0a", "hSpResoFT0aFV0a; centrality; Q_{FT0a} #bullet Q_{FV0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0aTPCpos", "hSpResoFT0aTPCpos; centrality; Q_{FT0a} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0aTPCneg", "hSpResoFT0aTPCneg; centrality; Q_{FT0a} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0aTPCtot", "hSpResoFT0aTPCtot; centrality; Q_{FT0m} #bullet Q_{TPCtot}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0mFV0a", "hSpResoFT0mFV0a; centrality; Q_{FT0m} #bullet Q_{FV0a}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0mTPCpos", "hSpResoFT0mTPCpos; centrality; Q_{FT0m} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0mTPCneg", "hSpResoFT0mTPCneg; centrality; Q_{FT0m} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFT0mTPCtot", "hSpResoFT0mTPCtot; centrality; Q_{FV0a} #bullet Q_{TPCtot}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFV0aTPCpos", "hSpResoFV0aTPCpos; centrality; Q_{FV0a} #bullet Q_{TPCpos}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFV0aTPCneg", "hSpResoFV0aTPCneg; centrality; Q_{FV0a} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoFV0aTPCtot", "hSpResoFV0aTPCtot; centrality; Q_{FV0a} #bullet Q_{TPCtot}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + registry.add("spReso/hSpResoTPCposTPCneg", "hSpResoTPCposTPCneg; centrality; Q_{TPCpos} #bullet Q_{TPCneg}", {HistType::kTH2F, {thnAxisCent, thnAxisScalarProd}}); + + if (saveEpResoHisto) { + registry.add("epReso/hEpResoFT0cFT0a", "hEpResoFT0cFT0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0cFV0a", "hEpResoFT0cFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0cTPCpos", "hEpResoFT0cTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0cTPCneg", "hEpResoFT0cTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0cTPCtot", "hEpResoFT0cTPCtot; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0aFV0a", "hEpResoFT0aFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0aTPCpos", "hEpResoFT0aTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0aTPCneg", "hEpResoFT0aTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0aTPCtot", "hEpResoFT0aTPCtot; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0mFV0a", "hEpResoFT0mFV0a; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0mTPCpos", "hEpResoFT0mTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0mTPCneg", "hEpResoFT0mTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFT0mTPCtot", "hEpResoFT0mTPCtot; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFV0aTPCpos", "hEpResoFV0aTPCpos; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFV0aTPCneg", "hEpResoFV0aTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoFV0aTPCtot", "hEpResoFV0aTPCtot; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + registry.add("epReso/hEpResoTPCposTPCneg", "hEpResoTPCposTPCneg; centrality; #Delta#Psi_{sub}", {HistType::kTH2F, {thnAxisCent, thnAxisCosNPhi}}); + } + + hfEvSel.addHistograms(registry); // collision monitoring + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); } }; // end init @@ -208,21 +268,89 @@ struct HfTaskFlowCharmHadrons { /// \param cosDeltaPhi is the cosine of the n*(phi - evtPl) angle /// \param sp is the scalar product /// \param outputMl are the ML scores + /// \param occupancy is the occupancy of the collision using the track estimator + /// \param hfevselflag flag of the collision associated to utilsEvSelHf.h void fillThn(float& mass, float& pt, float& cent, float& cosNPhi, float& cosDeltaPhi, float& sp, - std::vector& outputMl) + std::vector& outputMl, + float& occupancy, + uint16_t& hfevselflag) { - if (storeMl) { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, cosNPhi, cosDeltaPhi, sp, outputMl[0], outputMl[1]); + if (storeOccupancy) { + 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::NumTracksInTimeRange), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + } 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::NumTracksInTimeRange), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + } + } 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::NumTracksInTimeRange), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + } else { + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, occupancy, + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NumTracksInTimeRange), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeNarrow), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInTimeRangeStandard), + TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoCollInRofStandard)); + } + } } else { - registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, cosNPhi, cosDeltaPhi, sp); + if (storeMl) { + if (storeEP) { + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp, cosNPhi, 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); + } else { + registry.fill(HIST("hSparseFlowCharm"), mass, pt, cent, sp); + } + } } } + /// Get the occupancy + /// \param collision is the collision with the occupancy information + float getOccupancy(CollsWithQvecs::iterator const& collision) + { + float occupancy = -999.; + switch (occEstimator) { + case 1: + occupancy = collision.trackOccupancyInTimeRange(); + break; + case 2: + occupancy = collision.ft0cOccupancyInTimeRange(); + break; + default: + LOG(warning) << "Occupancy estimator not valid. Possible values are ITS or FT0C. Fallback to ITS"; + occupancy = collision.trackOccupancyInTimeRange(); + break; + } + return occupancy; + } + /// Get the centrality /// \param collision is the collision with the centrality information float getCentrality(CollsWithQvecs::iterator const& collision) @@ -249,6 +377,22 @@ struct HfTaskFlowCharmHadrons { return cent; } + /// Check if the collision is selected + /// \param collision is the collision with the Q vector information + /// \param bc is the bunch crossing with timestamp information + /// \return true if the collision is selected, false otherwise + template + bool isCollSelected(CollsWithQvecs::iterator const& collision, + aod::BCsWithTimestamps const&) + { + float centrality{-1.f}; + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + + /// monitor the satisfied event selections + hfEvSel.fillHistograms(collision, rejectionMask, centrality); + return rejectionMask == 0; + } + /// Get the Q vector /// \param collision is the collision with the Q vector information std::vector getQvec(CollsWithQvecs::iterator const& collision) @@ -283,6 +427,11 @@ struct HfTaskFlowCharmHadrons { yQVec = collision.qvecBNegIm(); amplQVec = collision.nTrkBNeg(); break; + case QvecEstimator::TPCTot: + xQVec = collision.qvecBTotRe(); + yQVec = collision.qvecBTotIm(); + amplQVec = collision.nTrkBTot(); + 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(); @@ -299,12 +448,23 @@ struct HfTaskFlowCharmHadrons { void runFlowAnalysis(CollsWithQvecs::iterator const& collision, T1 const& candidates) { + float cent = getCentrality(collision); + if (cent < centralityMin || cent > centralityMax) { + return; + } + float occupancy = 0.; + uint16_t hfevflag; + if (storeOccupancy) { + occupancy = getOccupancy(collision); + registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); + hfevflag = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); + } + std::vector qVecs = getQvec(collision); float xQVec = qVecs[0]; float yQVec = qVecs[1]; float amplQVec = qVecs[2]; float evtPl = epHelper.GetEventPlane(xQVec, yQVec, harmonic); - float cent = getCentrality(collision); int nProngs = 3; for (const auto& candidate : candidates) { @@ -398,7 +558,7 @@ struct HfTaskFlowCharmHadrons { float scalprodCand = cosNPhi * xQVec + sinNPhi * yQVec; float cosDeltaPhi = std::cos(harmonic * (phiCand - evtPl)); - fillThn(massCand, ptCand, cent, cosNPhi, cosDeltaPhi, scalprodCand, outputMl); + fillThn(massCand, ptCand, cent, cosNPhi, cosDeltaPhi, scalprodCand, outputMl, occupancy, hfevflag); } } @@ -485,14 +645,15 @@ struct HfTaskFlowCharmHadrons { PROCESS_SWITCH(HfTaskFlowCharmHadrons, processLc, "Process Lc candidates", false); // Resolution - void processResolution(CollsWithQvecs::iterator const& collision) + void processResolution(CollsWithQvecs::iterator const& collision, + aod::BCsWithTimestamps const& bcs) { - - if (!collision.sel8() || std::abs(collision.posZ()) > zVtxMax) { + if (!isCollSelected(collision, bcs)) { + // no selection on the centrality is applied on purpose to allow for the resolution study in post-processing return; } - float centrality = getCentrality(collision); + float centrality = getCentrality(collision); // centrality not updated in the rejection mask function float xQVecFT0a = collision.qvecFT0ARe(); float yQVecFT0a = collision.qvecFT0AIm(); float xQVecFT0c = collision.qvecFT0CRe(); @@ -505,19 +666,25 @@ struct HfTaskFlowCharmHadrons { float yQVecBPos = collision.qvecBPosIm(); float xQVecBNeg = collision.qvecBNegRe(); float yQVecBNeg = collision.qvecBNegIm(); + float xQVecBTot = collision.qvecBTotRe(); + float yQVecBTot = collision.qvecBTotIm(); 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); registry.fill(HIST("spReso/hSpResoFT0cTPCneg"), centrality, xQVecFT0c * xQVecBNeg + yQVecFT0c * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0cTPCtot"), centrality, xQVecFT0c * xQVecBTot + yQVecFT0c * yQVecBTot); registry.fill(HIST("spReso/hSpResoFT0aFV0a"), centrality, xQVecFT0a * xQVecFV0a + yQVecFT0a * yQVecFV0a); registry.fill(HIST("spReso/hSpResoFT0aTPCpos"), centrality, xQVecFT0a * xQVecBPos + yQVecFT0a * yQVecBPos); registry.fill(HIST("spReso/hSpResoFT0aTPCneg"), centrality, xQVecFT0a * xQVecBNeg + yQVecFT0a * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0aTPCtot"), centrality, xQVecFT0a * xQVecBTot + yQVecFT0a * yQVecBTot); registry.fill(HIST("spReso/hSpResoFT0mFV0a"), centrality, xQVecFT0m * xQVecFV0a + yQVecFT0m * yQVecFV0a); registry.fill(HIST("spReso/hSpResoFT0mTPCpos"), centrality, xQVecFT0m * xQVecBPos + yQVecFT0m * yQVecBPos); registry.fill(HIST("spReso/hSpResoFT0mTPCneg"), centrality, xQVecFT0m * xQVecBNeg + yQVecFT0m * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFT0mTPCtot"), centrality, xQVecFT0m * xQVecBTot + yQVecFT0m * yQVecBTot); registry.fill(HIST("spReso/hSpResoFV0aTPCpos"), centrality, xQVecFV0a * xQVecBPos + yQVecFV0a * yQVecBPos); registry.fill(HIST("spReso/hSpResoFV0aTPCneg"), centrality, xQVecFV0a * xQVecBNeg + yQVecFV0a * yQVecBNeg); + registry.fill(HIST("spReso/hSpResoFV0aTPCtot"), centrality, xQVecFV0a * xQVecBTot + yQVecFV0a * yQVecBTot); registry.fill(HIST("spReso/hSpResoTPCposTPCneg"), centrality, xQVecBPos * xQVecBNeg + yQVecBPos * yQVecBNeg); if (saveEpResoHisto) { @@ -527,19 +694,24 @@ struct HfTaskFlowCharmHadrons { float epFV0a = epHelper.GetEventPlane(xQVecFV0a, yQVecFV0a, harmonic); float epBPoss = epHelper.GetEventPlane(xQVecBPos, yQVecBPos, harmonic); float epBNegs = epHelper.GetEventPlane(xQVecBNeg, yQVecBNeg, harmonic); + float epBTots = epHelper.GetEventPlane(xQVecBTot, yQVecBTot, harmonic); registry.fill(HIST("epReso/hEpResoFT0cFT0a"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epFT0a))); registry.fill(HIST("epReso/hEpResoFT0cFV0a"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epFV0a))); registry.fill(HIST("epReso/hEpResoFT0cTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBPoss))); registry.fill(HIST("epReso/hEpResoFT0cTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBNegs))); + registry.fill(HIST("epReso/hEpResoFT0cTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0c, epBTots))); registry.fill(HIST("epReso/hEpResoFT0aFV0a"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epFV0a))); registry.fill(HIST("epReso/hEpResoFT0aTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBPoss))); registry.fill(HIST("epReso/hEpResoFT0aTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBNegs))); + registry.fill(HIST("epReso/hEpResoFT0aTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0a, epBTots))); registry.fill(HIST("epReso/hEpResoFT0mFV0a"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0m, epFV0a))); registry.fill(HIST("epReso/hEpResoFT0mTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFT0m, epBPoss))); 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/hEpResoFV0aTPCpos"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFV0a, epBPoss))); registry.fill(HIST("epReso/hEpResoFV0aTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFV0a, epBNegs))); + registry.fill(HIST("epReso/hEpResoFV0aTPCtot"), centrality, std::cos(harmonic * getDeltaPsiInRange(epFV0a, epBTots))); registry.fill(HIST("epReso/hEpResoTPCposTPCneg"), centrality, std::cos(harmonic * getDeltaPsiInRange(epBPoss, epBNegs))); } } diff --git a/PWGHF/D2H/Tasks/taskLb.cxx b/PWGHF/D2H/Tasks/taskLb.cxx index a74b5ec7f11..025c525b35c 100644 --- a/PWGHF/D2H/Tasks/taskLb.cxx +++ b/PWGHF/D2H/Tasks/taskLb.cxx @@ -58,6 +58,9 @@ struct HfTaskLb { Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb); using TracksWExt = soa::Join; + using TracksWExtMc = soa::Join; + + PresliceUnsorted McPartID = aod::mctracklabel::mcParticleId; bool passesImpactParameterResolution(float pT, float d0Resolution) { @@ -294,7 +297,7 @@ struct HfTaskLb { void processMc(soa::Filtered> const& candidates, soa::Join const& mcParticles, - aod::TracksWMc const&, + TracksWExtMc const&, aod::HfCand3Prong const&) { // MC rec @@ -306,9 +309,10 @@ struct HfTaskLb { continue; } auto candLc = candidate.prong0_as(); + if (std::abs(candidate.flagMcMatchRec()) == 1 << hf_cand_lb::DecayType::LbToLcPi) { - auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kLambdaB0, true); + auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as().mcParticle_as>(), o2::constants::physics::Pdg::kLambdaB0, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); registry.fill(HIST("MC/hPtGenSig"), particleMother.pt()); registry.fill(HIST("MC/hPtRecSig"), candidate.pt()); @@ -362,7 +366,7 @@ struct HfTaskLb { float ptProngs[2], yProngs[2], etaProngs[2]; int counter = 0; - for (const auto& daught : particle.daughters_as()) { + 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())); diff --git a/PWGHF/D2H/Tasks/taskLc.cxx b/PWGHF/D2H/Tasks/taskLc.cxx index 842c4b18e11..2981f64c8c7 100644 --- a/PWGHF/D2H/Tasks/taskLc.cxx +++ b/PWGHF/D2H/Tasks/taskLc.cxx @@ -18,12 +18,15 @@ /// \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/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -39,11 +42,11 @@ struct HfTaskLc { Configurable yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"}; Configurable> binsPt{"binsPt", std::vector{hf_cuts_lc_to_p_k_pi::vecBinsPt}, "pT bin limits"}; // ThnSparse for ML outputScores and Vars - Configurable enableTHn{"enableTHn", false, "enable THn for Lc"}; + 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 thnConfigAxisMultiplicity{"thnConfigAxisMultiplicity", {100, 0, 1000}, ""}; + 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}, ""}; @@ -52,13 +55,24 @@ struct HfTaskLc { ConfigurableAxis thnConfigAxisCanType{"thnConfigAxisCanType", {5, 0., 5.}, ""}; HfHelper hfHelper; - Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc; + + using Collisions = soa::Join; + using CollisionsMc = soa::Join; + using CollisionsWithFT0C = soa::Join; + using CollisionsMcWithFT0C = soa::Join; + using CollisionsWithFT0M = soa::Join; + using CollisionsMcWithFT0M = soa::Join; using LcCandidates = soa::Filtered>; using LcCandidatesMl = soa::Filtered>; using LcCandidatesMc = soa::Filtered>; using LcCandidatesMlMc = soa::Filtered>; + using McParticles3ProngMatched = soa::Join; + Filter filterSelectCandidates = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLc || aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLc; + Preslice perMcCollision = aod::mcparticle::mcCollisionId; + Preslice candLcPerCollision = aod::hf_cand::collisionId; + SliceCache cache; HistogramRegistry registry{ "registry", @@ -88,7 +102,6 @@ struct HfTaskLc { {"MC/reconstructed/signal/hPtRecProng2Sig", "3-prong candidates (matched);prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, {"MC/reconstructed/prompt/hPtRecProng2SigPrompt", "3-prong candidates (matched, prompt);prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, {"MC/reconstructed/nonprompt/hPtRecProng2SigNonPrompt", "3-prong candidates (matched, non-prompt);prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, - {"Data/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, /// DCAxy to prim. vertex prongs {"Data/hd0Prong0", "3-prong candidates;prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}}, {"MC/reconstructed/signal/hd0RecProng0Sig", "3-prong candidates (matched);prong 0 DCAxy to prim. vertex (cm);entries", {HistType::kTH1F, {{600, -0.4, 0.4}}}}, @@ -154,14 +167,14 @@ struct HfTaskLc { void init(InitContext&) { - std::array doprocess{doprocessDataStd, doprocessDataWithMl, doprocessMcStd, doprocessMcWithMl}; + std::array doprocess{doprocessDataStd, doprocessDataStdWithFT0C, doprocessDataStdWithFT0M, doprocessDataWithMl, doprocessDataWithMlWithFT0C, doprocessDataWithMlWithFT0M, doprocessMcStd, doprocessMcStdWithFT0C, doprocessMcStdWithFT0M, doprocessMcWithMl, doprocessMcWithMlWithFT0C, doprocessMcWithMlWithFT0M}; if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) != 1) { LOGP(fatal, "no or more than one process function enabled! Please check your configuration!"); } auto vbins = (std::vector)binsPt; /// mass candidate - registry.add("Data/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/hMassVsPtVsNPvContributors", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}; Number of PV contributors", {HistType::kTH3F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}, {5000, 0., 10000.}}}); registry.add("Data/hMassVsPt", "3-prong candidates;inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("MC/reconstructed/signal/hMassVsPtRecSig", "3-prong candidates (matched);inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("MC/reconstructed/prompt/hMassVsPtRecSigPrompt", "3-prong candidates (matched, prompt);inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 1.98, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); @@ -259,13 +272,13 @@ struct HfTaskLc { registry.add("MC/reconstructed/prompt/hDecLenErrSigPrompt", "3-prong candidates (matched, prompt);decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("MC/reconstructed/nonprompt/hDecLenErrSigNonPrompt", "3-prong candidates (matched, non-prompt);decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - if (enableTHn) { + if (fillTHn) { const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T}(#Lambda_{c}^{+}) (GeV/#it{c})"}; const AxisSpec thnAxisPtProng0{thnConfigAxisPtProng, "#it{p}_{T}(prong0) (GeV/#it{c})"}; const AxisSpec thnAxisPtProng1{thnConfigAxisPtProng, "#it{p}_{T}(prong1) (GeV/#it{c})"}; const AxisSpec thnAxisPtProng2{thnConfigAxisPtProng, "#it{p}_{T}(prong2) (GeV/#it{c})"}; - const AxisSpec thnAxisMultiplicity{thnConfigAxisMultiplicity, "multiplicity"}; + const AxisSpec thnAxisCentrality{thnConfigAxisCentrality, "centrality (FT0C)"}; const AxisSpec thnAxisChi2PCA{thnConfigAxisChi2PCA, "Chi2PCA to sec. vertex (cm)"}; const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, "decay length (cm)"}; const AxisSpec thnAxisCPA{thnConfigAxisCPA, "cosine of pointing angle"}; @@ -274,157 +287,33 @@ struct HfTaskLc { const AxisSpec thnAxisBdtScoreLcNonPrompt{thnConfigAxisBdtScoreSignal, "BDT non-prompt score (Lc)"}; const AxisSpec thnAxisCanType{thnConfigAxisCanType, "candidates type"}; - if (doprocessDataWithMl || doprocessMcWithMl) { - registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisMultiplicity, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisCanType}); + if (doprocessDataWithMl || doprocessDataWithMlWithFT0C || doprocessDataWithMlWithFT0M || doprocessMcWithMl || doprocessMcWithMlWithFT0C || doprocessMcWithMlWithFT0M) { + registry.add("hnLcVarsWithBdt", "THn for Lambdac candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisBdtScoreLcBkg, thnAxisBdtScoreLcPrompt, thnAxisBdtScoreLcNonPrompt, thnAxisCanType}); } else { - registry.add("hnLcVars", "THn for Lambdac candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisMultiplicity, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisCanType}); + registry.add("hnLcVars", "THn for Lambdac candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisCentrality, thnAxisPtProng0, thnAxisPtProng1, thnAxisPtProng2, thnAxisChi2PCA, thnAxisDecLength, thnAxisCPA, thnAxisCanType}); } } } - template - void processData(aod::Collision const& collision, - CandType const& candidates, - aod::TracksWDca const& tracks) + /// 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) { - int nTracks = 0; - if (collision.numContrib() > 1) { - for (const auto& track : tracks) { - if (std::abs(track.eta()) > 4.0) { - continue; - } - if (std::abs(track.dcaXY()) > 0.0025 || std::abs(track.dcaZ()) > 0.0025) { - continue; - } - nTracks++; - } - } - registry.fill(HIST("Data/hMultiplicity"), nTracks); - - for (const auto& candidate : candidates) { - if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { - continue; - } - if (yCandRecoMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandRecoMax) { - continue; - } - auto pt = candidate.pt(); - 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(); - - if (candidate.isSelLcToPKPi() >= selectionFlagLc) { - registry.fill(HIST("Data/hMass"), hfHelper.invMassLcToPKPi(candidate)); - registry.fill(HIST("Data/hMassVsPtVsMult"), hfHelper.invMassLcToPKPi(candidate), pt, nTracks); - registry.fill(HIST("Data/hMassVsPt"), hfHelper.invMassLcToPKPi(candidate), pt); - } - if (candidate.isSelLcToPiKP() >= selectionFlagLc) { - registry.fill(HIST("Data/hMass"), hfHelper.invMassLcToPiKP(candidate)); - registry.fill(HIST("Data/hMassVsPtVsMult"), hfHelper.invMassLcToPiKP(candidate), pt, nTracks); - registry.fill(HIST("Data/hMassVsPt"), hfHelper.invMassLcToPiKP(candidate), pt); - } - registry.fill(HIST("Data/hPt"), pt); - registry.fill(HIST("Data/hPtProng0"), ptProng0); - registry.fill(HIST("Data/hPtProng1"), ptProng1); - registry.fill(HIST("Data/hPtProng2"), ptProng2); - registry.fill(HIST("Data/hd0Prong0"), candidate.impactParameter0()); - registry.fill(HIST("Data/hd0Prong1"), candidate.impactParameter1()); - registry.fill(HIST("Data/hd0Prong2"), candidate.impactParameter2()); - registry.fill(HIST("Data/hd0VsPtProng0"), candidate.impactParameter0(), pt); - registry.fill(HIST("Data/hd0VsPtProng1"), candidate.impactParameter1(), pt); - registry.fill(HIST("Data/hd0VsPtProng2"), candidate.impactParameter2(), pt); - registry.fill(HIST("Data/hDecLength"), decayLength); - registry.fill(HIST("Data/hDecLengthVsPt"), decayLength, pt); - registry.fill(HIST("Data/hDecLengthxy"), decayLengthXY); - registry.fill(HIST("Data/hDecLengthxyVsPt"), decayLengthXY, pt); - registry.fill(HIST("Data/hCt"), hfHelper.ctLc(candidate)); - registry.fill(HIST("Data/hCtVsPt"), hfHelper.ctLc(candidate), pt); - registry.fill(HIST("Data/hCPA"), cpa); - registry.fill(HIST("Data/hCPAVsPt"), cpa, pt); - registry.fill(HIST("Data/hCPAxy"), cpaXY); - registry.fill(HIST("Data/hCPAxyVsPt"), cpaXY, pt); - registry.fill(HIST("Data/hDca2"), chi2PCA); - registry.fill(HIST("Data/hDca2VsPt"), chi2PCA, pt); - registry.fill(HIST("Data/hEta"), candidate.eta()); - registry.fill(HIST("Data/hEtaVsPt"), candidate.eta(), pt); - registry.fill(HIST("Data/hPhi"), candidate.phi()); - registry.fill(HIST("Data/hPhiVsPt"), candidate.phi(), pt); - registry.fill(HIST("hSelectionStatus"), candidate.isSelLcToPKPi(), pt); - registry.fill(HIST("hSelectionStatus"), candidate.isSelLcToPiKP(), pt); - registry.fill(HIST("Data/hImpParErrProng0"), candidate.errorImpactParameter0(), pt); - registry.fill(HIST("Data/hImpParErrProng1"), candidate.errorImpactParameter1(), pt); - registry.fill(HIST("Data/hImpParErrProng2"), candidate.errorImpactParameter2(), pt); - registry.fill(HIST("Data/hDecLenErr"), candidate.errorDecayLength(), pt); - - if (enableTHn) { - double massLc(-1); - double outputBkg(-1), outputPrompt(-1), outputFD(-1); - if (candidate.isSelLcToPKPi() >= selectionFlagLc) { - massLc = hfHelper.invMassLcToPKPi(candidate); - - if constexpr (fillMl) { - - if (candidate.mlProbLcToPKPi().size() == 3) { - - outputBkg = candidate.mlProbLcToPKPi()[0]; /// bkg score - outputPrompt = candidate.mlProbLcToPKPi()[1]; /// prompt score - outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score - } - /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, nTracks, outputBkg, outputPrompt, outputFD, 0); - } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, nTracks, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0); - } - } - if (candidate.isSelLcToPiKP() >= selectionFlagLc) { - massLc = hfHelper.invMassLcToPiKP(candidate); - - if constexpr (fillMl) { - - if (candidate.mlProbLcToPiKP().size() == 3) { - - outputBkg = candidate.mlProbLcToPiKP()[0]; /// bkg score - outputPrompt = candidate.mlProbLcToPiKP()[1]; /// prompt score - outputFD = candidate.mlProbLcToPiKP()[2]; /// non-prompt score - } - /// Fill the ML outputScores and variables of candidate - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, nTracks, outputBkg, outputPrompt, outputFD, 0); - } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, nTracks, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0); - } - } - } - } + return o2::hf_centrality::getCentralityColl(collision); } - void processDataStd(aod::Collision const& collision, - LcCandidates const& selectedLcCandidates, - aod::TracksWDca const& tracks) + /// Fill MC histograms at reconstruction level + /// \tparam fillMl switch to fill ML histograms + template + void fillHistosMcRec(CollType const& collision, CandLcMcRec const& candidates, CandLcMcGen const& mcParticles) { - processData(collision, selectedLcCandidates, tracks); - } - PROCESS_SWITCH(HfTaskLc, processDataStd, "Process Data with the standard method", true); - void processDataWithMl(aod::Collision const& collision, - LcCandidatesMl const& selectedLcCandidatesMl, - aod::TracksWDca const& tracks) - { - processData(collision, selectedLcCandidatesMl, tracks); - } - PROCESS_SWITCH(HfTaskLc, processDataWithMl, "Process Data with the ML method", false); + auto thisCollId = collision.globalIndex(); + auto groupedLcCandidates = candidates.sliceBy(candLcPerCollision, thisCollId); - /// Fills MC histograms. - template - void processMc(CandType const& candidates, - soa::Join const& mcParticles, - aod::TracksWMc const&) - { - for (const auto& candidate : candidates) { + for (const auto& candidate : groupedLcCandidates) { /// Select Lc if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { continue; @@ -573,47 +462,50 @@ struct HfTaskLc { registry.fill(HIST("MC/reconstructed/nonprompt/hImpParErrProng2SigNonPrompt"), candidate.errorImpactParameter2(), pt); registry.fill(HIST("MC/reconstructed/nonprompt/hDecLenErrSigNonPrompt"), candidate.errorDecayLength(), pt); } - if (enableTHn) { + if (fillTHn) { + float cent = evaluateCentralityColl(collision); double massLc(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); if ((candidate.isSelLcToPKPi() >= selectionFlagLc) && pdgCodeProng0 == kProton) { massLc = hfHelper.invMassLcToPKPi(candidate); if constexpr (fillMl) { - if (candidate.mlProbLcToPKPi().size() == 3) { - outputBkg = candidate.mlProbLcToPKPi()[0]; /// bkg score outputPrompt = candidate.mlProbLcToPKPi()[1]; /// prompt score outputFD = candidate.mlProbLcToPKPi()[2]; /// non-prompt score } - /// Fill the ML outputScores and variables of candidate (todo: add multiplicity) - registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, 0, outputBkg, outputPrompt, outputFD, originType); + /// Fill the ML outputScores and variables of candidate + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, originType); } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, 0, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType); + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType); } } if ((candidate.isSelLcToPiKP() >= selectionFlagLc) && pdgCodeProng0 == kPiPlus) { massLc = hfHelper.invMassLcToPiKP(candidate); if constexpr (fillMl) { - if (candidate.mlProbLcToPiKP().size() == 3) { - outputBkg = candidate.mlProbLcToPiKP()[0]; /// bkg score outputPrompt = candidate.mlProbLcToPiKP()[1]; /// prompt score 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, 0, outputBkg, outputPrompt, outputFD, originType); + registry.get(HIST("hnLcVarsWithBdt"))->Fill(massLc, pt, cent, outputBkg, outputPrompt, outputFD, originType); } else { - registry.get(HIST("hnLcVars"))->Fill(massLc, pt, 0, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType); + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, originType); } } } } } + } + /// Fill MC histograms at generated level + /// \tparam fillMl switch to fill ML histograms + template + void fillHistosMcGen(CandLcMcGen const& mcParticles) + { // MC gen. for (const auto& particle : mcParticles) { if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { @@ -652,21 +544,247 @@ struct HfTaskLc { } } - void processMcStd(LcCandidatesMc const& selectedLcCandidatesMc, - soa::Join const& mcParticles, - aod::TracksWMc const& tracksWithMc) + /// Fill histograms for real data + /// \tparam fillMl switch to fill ML histograms + template + void fillHistosData(CollType const& collision, CandType const& candidates) + { + auto thisCollId = collision.globalIndex(); + auto groupedLcCandidates = candidates.sliceBy(candLcPerCollision, thisCollId); + auto numPvContributors = collision.numContrib(); + + for (const auto& candidate : groupedLcCandidates) { + if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { + continue; + } + if (yCandRecoMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandRecoMax) { + continue; + } + auto pt = candidate.pt(); + 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(); + + if (candidate.isSelLcToPKPi() >= selectionFlagLc) { + registry.fill(HIST("Data/hMass"), hfHelper.invMassLcToPKPi(candidate)); + registry.fill(HIST("Data/hMassVsPtVsNPvContributors"), hfHelper.invMassLcToPKPi(candidate), pt, numPvContributors); + registry.fill(HIST("Data/hMassVsPt"), hfHelper.invMassLcToPKPi(candidate), pt); + } + if (candidate.isSelLcToPiKP() >= selectionFlagLc) { + registry.fill(HIST("Data/hMass"), hfHelper.invMassLcToPiKP(candidate)); + registry.fill(HIST("Data/hMassVsPtVsNPvContributors"), hfHelper.invMassLcToPiKP(candidate), pt, numPvContributors); + registry.fill(HIST("Data/hMassVsPt"), hfHelper.invMassLcToPiKP(candidate), pt); + } + registry.fill(HIST("Data/hPt"), pt); + registry.fill(HIST("Data/hPtProng0"), ptProng0); + registry.fill(HIST("Data/hPtProng1"), ptProng1); + registry.fill(HIST("Data/hPtProng2"), ptProng2); + registry.fill(HIST("Data/hd0Prong0"), candidate.impactParameter0()); + registry.fill(HIST("Data/hd0Prong1"), candidate.impactParameter1()); + registry.fill(HIST("Data/hd0Prong2"), candidate.impactParameter2()); + registry.fill(HIST("Data/hd0VsPtProng0"), candidate.impactParameter0(), pt); + registry.fill(HIST("Data/hd0VsPtProng1"), candidate.impactParameter1(), pt); + registry.fill(HIST("Data/hd0VsPtProng2"), candidate.impactParameter2(), pt); + registry.fill(HIST("Data/hDecLength"), decayLength); + registry.fill(HIST("Data/hDecLengthVsPt"), decayLength, pt); + registry.fill(HIST("Data/hDecLengthxy"), decayLengthXY); + registry.fill(HIST("Data/hDecLengthxyVsPt"), decayLengthXY, pt); + registry.fill(HIST("Data/hCt"), hfHelper.ctLc(candidate)); + registry.fill(HIST("Data/hCtVsPt"), hfHelper.ctLc(candidate), pt); + registry.fill(HIST("Data/hCPA"), cpa); + registry.fill(HIST("Data/hCPAVsPt"), cpa, pt); + registry.fill(HIST("Data/hCPAxy"), cpaXY); + registry.fill(HIST("Data/hCPAxyVsPt"), cpaXY, pt); + registry.fill(HIST("Data/hDca2"), chi2PCA); + registry.fill(HIST("Data/hDca2VsPt"), chi2PCA, pt); + registry.fill(HIST("Data/hEta"), candidate.eta()); + registry.fill(HIST("Data/hEtaVsPt"), candidate.eta(), pt); + registry.fill(HIST("Data/hPhi"), candidate.phi()); + registry.fill(HIST("Data/hPhiVsPt"), candidate.phi(), pt); + registry.fill(HIST("hSelectionStatus"), candidate.isSelLcToPKPi(), pt); + registry.fill(HIST("hSelectionStatus"), candidate.isSelLcToPiKP(), pt); + registry.fill(HIST("Data/hImpParErrProng0"), candidate.errorImpactParameter0(), pt); + registry.fill(HIST("Data/hImpParErrProng1"), candidate.errorImpactParameter1(), pt); + registry.fill(HIST("Data/hImpParErrProng2"), candidate.errorImpactParameter2(), pt); + registry.fill(HIST("Data/hDecLenErr"), candidate.errorDecayLength(), pt); + + if (fillTHn) { + float cent = evaluateCentralityColl(collision); + double massLc(-1); + double outputBkg(-1), outputPrompt(-1), outputFD(-1); + if (candidate.isSelLcToPKPi() >= selectionFlagLc) { + massLc = hfHelper.invMassLcToPKPi(candidate); + + if constexpr (fillMl) { + if (candidate.mlProbLcToPKPi().size() == 3) { + outputBkg = candidate.mlProbLcToPKPi()[0]; /// bkg score + outputPrompt = candidate.mlProbLcToPKPi()[1]; /// prompt score + 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, 0); + } else { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0); + } + } + if (candidate.isSelLcToPiKP() >= selectionFlagLc) { + massLc = hfHelper.invMassLcToPiKP(candidate); + + if constexpr (fillMl) { + if (candidate.mlProbLcToPiKP().size() == 3) { + outputBkg = candidate.mlProbLcToPiKP()[0]; /// bkg score + outputPrompt = candidate.mlProbLcToPiKP()[1]; /// prompt score + 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, 0); + } else { + registry.get(HIST("hnLcVars"))->Fill(massLc, pt, cent, ptProng0, ptProng1, ptProng2, chi2PCA, decayLength, cpa, 0); + } + } + } + } + } + + /// Run the analysis on real data + /// \tparam fillMl switch to fill ML histograms + template + void runAnalysisPerCollisionData(CollType const& collisions, + CandType const& candidates) + { + + for (const auto& collision : collisions) { + fillHistosData(collision, candidates); + } + } + + /// Run the analysis on MC data + /// \tparam fillMl switch to fill ML histograms + template + void runAnalysisPerCollisionMc(CollType const& collisions, + CandType const& candidates, + CandLcMcGen const& mcParticles) + { + for (const auto& collision : collisions) { + // MC Rec. + fillHistosMcRec(collision, candidates, mcParticles); + } + // MC gen. + fillHistosMcGen(mcParticles); + } + + void processDataStd(Collisions const& collisions, + LcCandidates const& selectedLcCandidates, + aod::Tracks const&) + { + runAnalysisPerCollisionData(collisions, selectedLcCandidates); + } + PROCESS_SWITCH(HfTaskLc, processDataStd, "Process Data with the standard method", true); + + void processDataWithMl(Collisions const& collisions, + LcCandidatesMl const& selectedLcCandidatesMl, + aod::Tracks const&) + { + runAnalysisPerCollisionData(collisions, selectedLcCandidatesMl); + } + PROCESS_SWITCH(HfTaskLc, processDataWithMl, "Process real data with the ML method and without centrality", false); + + void processDataStdWithFT0C(CollisionsWithFT0C const& collisions, + LcCandidates const& selectedLcCandidates, + aod::Tracks const&) + { + runAnalysisPerCollisionData(collisions, selectedLcCandidates); + } + PROCESS_SWITCH(HfTaskLc, processDataStdWithFT0C, "Process real data with the standard method and with FT0C centrality", false); + + void processDataWithMlWithFT0C(CollisionsWithFT0C const& collisions, + LcCandidatesMl const& selectedLcCandidatesMl, + aod::Tracks const&) + { + runAnalysisPerCollisionData(collisions, selectedLcCandidatesMl); + } + PROCESS_SWITCH(HfTaskLc, processDataWithMlWithFT0C, "Process real data with the ML method and with FT0C centrality", false); + + void processDataStdWithFT0M(CollisionsWithFT0M const& collisions, + LcCandidates const& selectedLcCandidates, + aod::Tracks const&) + { + runAnalysisPerCollisionData(collisions, selectedLcCandidates); + } + PROCESS_SWITCH(HfTaskLc, processDataStdWithFT0M, "Process real data with the standard method and with FT0M centrality", false); + + void processDataWithMlWithFT0M(CollisionsWithFT0M const& collisions, + LcCandidatesMl const& selectedLcCandidatesMl, + aod::Tracks const&) { - processMc(selectedLcCandidatesMc, mcParticles, tracksWithMc); + runAnalysisPerCollisionData(collisions, selectedLcCandidatesMl); + } + PROCESS_SWITCH(HfTaskLc, processDataWithMlWithFT0M, "Process real data with the ML method and with FT0M centrality", false); + + void processMcStd(CollisionsMc const& collisions, + LcCandidatesMc const& selectedLcCandidatesMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) + { + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMc, mcParticles); } PROCESS_SWITCH(HfTaskLc, processMcStd, "Process MC with the standard method", false); - void processMcWithMl(LcCandidatesMlMc const& selectedLcCandidatesMlMc, - soa::Join const& mcParticles, - aod::TracksWMc const& tracksWithMc) + void processMcWithMl(CollisionsMc const& collisions, + LcCandidatesMlMc const& selectedLcCandidatesMlMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) + { + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMlMc, mcParticles); + } + PROCESS_SWITCH(HfTaskLc, processMcWithMl, "Process Mc with the ML method and without centrality", false); + + void processMcStdWithFT0C(CollisionsMcWithFT0C const& collisions, + LcCandidatesMc const& selectedLcCandidatesMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) + { + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMc, mcParticles); + } + PROCESS_SWITCH(HfTaskLc, processMcStdWithFT0C, "Process MC with the standard method with FT0C centrality", false); + + void processMcWithMlWithFT0C(CollisionsMcWithFT0C const& collisions, + LcCandidatesMlMc const& selectedLcCandidatesMlMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) + { + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMlMc, mcParticles); + } + PROCESS_SWITCH(HfTaskLc, processMcWithMlWithFT0C, "Process Mc with the ML method with FT0C centrality", false); + + void processMcStdWithFT0M(CollisionsMcWithFT0M const& collisions, + LcCandidatesMc const& selectedLcCandidatesMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) + { + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMc, mcParticles); + } + PROCESS_SWITCH(HfTaskLc, processMcStdWithFT0M, "Process MC with the standard method with FT0M centrality", false); + + void processMcWithMlWithFT0M(CollisionsMcWithFT0M const& collisions, + LcCandidatesMlMc const& selectedLcCandidatesMlMc, + McParticles3ProngMatched const& mcParticles, + aod::McCollisions const&, + aod::TracksWMc const&) { - processMc(selectedLcCandidatesMlMc, mcParticles, tracksWithMc); + runAnalysisPerCollisionMc(collisions, selectedLcCandidatesMlMc, mcParticles); } - PROCESS_SWITCH(HfTaskLc, processMcWithMl, "Process Mc with the ML method", false); + PROCESS_SWITCH(HfTaskLc, processMcWithMlWithFT0M, "Process Mc with the ML method with FT0M centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/Tasks/taskXic.cxx b/PWGHF/D2H/Tasks/taskXic.cxx index fa337ff6265..613112f3279 100644 --- a/PWGHF/D2H/Tasks/taskXic.cxx +++ b/PWGHF/D2H/Tasks/taskXic.cxx @@ -56,6 +56,7 @@ struct HfTaskXic { ConfigurableAxis thnConfigAxisCPA{"thnConfigAxisCPA", {20, 0.8, 1}, ""}; ConfigurableAxis thnConfigAxisBdtScoreBkg{"thnConfigAxisBdtScoreBkg", {100, 0., 1.}, ""}; ConfigurableAxis thnConfigAxisBdtScoreSignal{"thnConfigAxisBdtScoreSignal", {100, 0., 1.}, ""}; + ConfigurableAxis thnConfigAxisYMC{"thnConfigAxisYMC", {100, -2., 2.}, ""}; // Service pdg; HfHelper hfHelper; @@ -73,21 +74,28 @@ struct HfTaskXic { HistogramRegistry registry{ "registry", // histo not in pt bins { - {"Data/hPt", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, // pt Xic - {"Data/hEta", "3-prong candidates;candidate #it{eta};entries", {HistType::kTH1F, {{100, -5., 5.}}}}, // eta Xic - {"Data/hPhi", "3-prong candidates;candidate #varphi;entries", {HistType::kTH1F, {{72, 0., constants::math::TwoPI}}}}, // phi Xic - {"Data/hMass", "3-prong candidates; inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1F, {{600, 2.18, 2.58}}}}, // mass Xic - {"Data/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{1000, 0., 1000.}}}}, - - {"MC/reconstructed/signal/hPtRecSig", "3-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{360, 0., 36.}}}}, // pt Xic - {"MC/reconstructed/background/hPtRecBg", "3-prong candidates (unmatched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}}, - {"MC/generated/hPtGen", "MC particles (matched);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}}, - {"MC/generated/hPtGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance); #it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}}, - {"MC/generated/hEtaGen", "MC particles; #it{eta}^{gen} ;#it{p}_{T}^{gen.};entries", {HistType::kTH1F, {{100, -2., 2.}}}}, - {"MC/generated/hYGen", "MC particles; #it{y}^{gen} ;#it{p}_{T}^{gen.} ;entries", {HistType::kTH1F, {{100, -2., 2.}}}}, - // add generated in acceptance!! - - }}; + {"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/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/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.}}}}, + {"MC/generated/prompt/hPtGenPrompt", "MC particles (matched, prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, + {"MC/generated/nonprompt/hPtGenNonPrompt", "MC particles (matched, non-prompt);#it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, + {"MC/generated/signal/hEtaGen", "MC particles (matched);#it{#eta};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/generated/prompt/hEtaGenPrompt", "MC particles (matched, prompt);#it{#eta};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/generated/nonprompt/hEtaGenNonPrompt", "MC particles (matched, non-prompt);#it{#eta};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/generated/signal/hYGen", "MC particles (matched);#it{y};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/generated/prompt/hYGenPrompt", "MC particles (matched, prompt);#it{y};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/generated/nonprompt/hYGenNonPrompt", "MC particles (matched, non-prompt);#it{y};entries", {HistType::kTH1D, {{100, -2., 2.}}}}, + {"MC/reconstructed/signal/hMassRecSig", "3-prong candidates (matched);inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1D, {{600, 2.18, 2.58}}}}, + {"MC/reconstructed/prompt/hMassRecSigPrompt", "3-prong candidates (matched, prompt);inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1D, {{600, 2.18, 2.58}}}}, + {"MC/reconstructed/nonprompt/hMassRecSigNonPrompt", "3-prong candidates (matched, non-prompt);inv. mass (p K #pi) (GeV/#it{c}^{2})", {HistType::kTH1D, {{600, 2.18, 2.58}}}}, + {"MC/reconstructed/signal/hPtRecSig", "3-prong candidates (matched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, + {"MC/reconstructed/prompt/hPtRecSigPrompt", "3-prong candidates (matched, prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, + {"MC/reconstructed/nonprompt/hPtRecSigNonPrompt", "3-prong candidates (matched, non-prompt);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1D, {{360, 0., 36.}}}}, + {"MC/reconstructed/background/hPtRecBg", "3-prong candidates (unmatched);#it{p}_{T}^{rec.} (GeV/#it{c});entries", {HistType::kTH1D, {{100, 0., 10.}}}}}}; void init(InitContext&) { @@ -174,6 +182,22 @@ struct HfTaskXic { registry.add("MC/reconstructed/signal/hPtProng2RecSig", "3-prong candidates;prong 2 #it{p}_{T} (GeV/#it{c});;entries", {HistType::kTH2F, {{100, 0., 10.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("MC/reconstructed/signal/hChi2PCARecSig", "3-prong candidates;prong Chi2PCA to sec. vertex (cm);; entries", {HistType::kTH2F, {{100, 0, 120}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/reconstructed/signal/hMassVsPtRecSig", "3-prong candidates (matched);inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 2.18, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/reconstructed/prompt/hMassVsPtRecSigPrompt", "3-prong candidates (matched, prompt);inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 2.18, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/reconstructed/nonprompt/hMassVsPtRecSigNonPrompt", "3-prong candidates (matched, non-prompt);inv. mass (p K #pi) (GeV/#it{c}^{2}); p_{T}", {HistType::kTH2F, {{600, 2.18, 2.58}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + + registry.add("MC/reconstructed/signal/hEtaVsPtRecSig", "3-prong candidates (matched);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/reconstructed/prompt/hEtaVsPtRecSigPrompt", "3-prong candidates (matched, prompt);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/reconstructed/nonprompt/hEtaVsPtRecSigNonPrompt", "3-prong candidates (matched, non-prompt);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + + registry.add("MC/generated/signal/hEtaVsPtGenSig", "3-prong candidates (matched);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/generated/prompt/hEtaVsPtGenSigPrompt", "3-prong candidates (matched, prompt);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/generated/nonprompt/hEtaVsPtGenSigNonPrompt", "3-prong candidates (matched, non-prompt);candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + + registry.add("MC/generated/signal/hYVsPtGenSig", "3-prong candidates (matched);candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/generated/prompt/hYVsPtGenSigPrompt", "3-prong candidates (matched, prompt);candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + registry.add("MC/generated/nonprompt/hYVsPtGenSigNonPrompt", "3-prong candidates (matched, non-prompt);candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + // background registry.add("MC/reconstructed/background/hMassBg", "Invariant mass (unmatched);m (p K #pi) (GeV/#it{c}^{2});;entries", {HistType::kTH2F, {{500, 1.6, 3.1}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); registry.add("MC/reconstructed/background/hDecLengthRecBg", "3-prong candidates;decay length (cm);;entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); @@ -198,6 +222,8 @@ struct HfTaskXic { if (enableTHn) { const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass (p K #pi) (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T}(#Xi_{c}^{+}) (GeV/#it{c})"}; + const AxisSpec thnAxisPtMC{thnConfigAxisPt, "#it{p}_{T}(#Xi_{c}^{+} MC) (GeV/#it{c})"}; + const AxisSpec thnAxisYMC{thnConfigAxisYMC, "#it{y}_{MC}(#Xi_{c}^{+} MC)"}; const AxisSpec thnAxisChi2PCA{thnConfigAxisChi2PCA, "Chi2PCA to sec. vertex (cm)"}; const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, "decay length (cm)"}; const AxisSpec thnAxisDecLengthXY{thnConfigAxisDecLengthXY, "decay length (cm)"}; @@ -206,11 +232,12 @@ struct HfTaskXic { const AxisSpec thnAxisBdtScoreXicPrompt{thnConfigAxisBdtScoreSignal, "BDT prompt score (Xic)"}; const AxisSpec thnAxisBdtScoreXicNonPrompt{thnConfigAxisBdtScoreSignal, "BDT non-prompt score (Xic)"}; const AxisSpec thnAxisMcOrigin{3, -0.5, 2.5, "MC origin"}; + 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}); + registry.add("hnXicVarsWithBdt", "THn for Xic candidates with BDT scores", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisBdtScoreXicBkg, thnAxisBdtScoreXicPrompt, thnAxisBdtScoreXicNonPrompt, thnAxisMcOrigin, thnAxisPtMC, thnAxisYMC, thnAxisMCAllProngAccepted}); } else { - registry.add("hnXicVars", "THn for Xic candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisMcOrigin}); + registry.add("hnXicVars", "THn for Xic candidates", HistType::kTHnSparseF, {thnAxisMass, thnAxisPt, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA, thnAxisMcOrigin, thnAxisPtMC, thnAxisYMC, thnAxisMCAllProngAccepted}); } } } // end init @@ -334,9 +361,9 @@ struct HfTaskXic { 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); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, 0, 0.0, 0.0, false); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0, 0.0, 0.0, false); } } if (candidate.isSelXicToPiKP() >= selectionFlagXic) { @@ -348,9 +375,9 @@ struct HfTaskXic { 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); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, 0, 0.0, 0.0, false); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), 0, 0.0, 0.0, false); } } } // thn for Xic @@ -403,16 +430,20 @@ struct HfTaskXic { // 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 if (massXicToPKPi != 0.) { - registry.fill(HIST("MC/reconstructed/signal/hMassSig"), massXicToPKPi, ptCandidate); + registry.fill(HIST("MC/reconstructed/signal/hMassVsPtRecSig"), massXicToPKPi, ptCandidate); + registry.fill(HIST("MC/reconstructed/signal/hMassRecSig"), massXicToPKPi); } if (massXicToPiKP != 0.) { - registry.fill(HIST("MC/reconstructed/signal/hMassSig"), massXicToPiKP, ptCandidate); + registry.fill(HIST("MC/reconstructed/signal/hMassVsPtRecSig"), massXicToPiKP, ptCandidate); + registry.fill(HIST("MC/reconstructed/signal/hMassRecSig"), massXicToPiKP); } - registry.fill(HIST("MC/reconstructed/signal/hDecLengthRecSig"), candidate.decayLength(), ptCandidate); registry.fill(HIST("MC/reconstructed/signal/hDecLengthXYRecSig"), candidate.decayLengthXY(), ptCandidate); registry.fill(HIST("MC/reconstructed/signal/hNormalisedDecayLengthXYRecSig"), candidate.decayLengthXYNormalised(), ptCandidate); @@ -430,12 +461,46 @@ struct HfTaskXic { registry.fill(HIST("MC/reconstructed/signal/hImpParErrSig"), candidate.errorImpactParameter0(), ptCandidate); registry.fill(HIST("MC/reconstructed/signal/hDecLenErrSig"), candidate.errorDecayLength(), ptCandidate); registry.fill(HIST("MC/reconstructed/signal/hChi2PCARecSig"), candidate.chi2PCA(), ptCandidate); + registry.fill(HIST("MC/reconstructed/signal/hEtaVsPtRecSig"), candidate.eta(), ptCandidate); + + /// reconstructed signal prompt + if (candidate.originMcRec() == 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); + } + if ((candidate.isSelXicToPiKP() >= selectionFlagXic) && pdgCodeProng0 == kPiPlus) { + registry.fill(HIST("MC/reconstructed/prompt/hMassRecSigPrompt"), massXicToPiKP); + registry.fill(HIST("MC/reconstructed/prompt/hMassVsPtRecSigPrompt"), massXicToPiKP, ptCandidate); + } + registry.fill(HIST("MC/reconstructed/prompt/hEtaVsPtRecSigPrompt"), candidate.eta(), ptCandidate); + registry.fill(HIST("MC/reconstructed/prompt/hPtRecSigPrompt"), ptCandidate); + } else { + if ((candidate.isSelXicToPKPi() >= selectionFlagXic) && pdgCodeProng0 == kProton) { + registry.fill(HIST("MC/reconstructed/nonprompt/hMassRecSigNonPrompt"), massXicToPKPi); + registry.fill(HIST("MC/reconstructed/nonprompt/hMassVsPtRecSigNonPrompt"), massXicToPKPi, ptCandidate); + } + if ((candidate.isSelXicToPiKP() >= selectionFlagXic) && pdgCodeProng0 == kPiPlus) { + registry.fill(HIST("MC/reconstructed/nonprompt/hMassRecSigNonPrompt"), massXicToPiKP); + registry.fill(HIST("MC/reconstructed/nonprompt/hMassVsPtRecSigNonPrompt"), massXicToPiKP, ptCandidate); + } + registry.fill(HIST("MC/reconstructed/nonprompt/hEtaVsPtRecSigNonPrompt"), candidate.eta(), ptCandidate); + registry.fill(HIST("MC/reconstructed/nonprompt/hPtRecSigNonPrompt"), ptCandidate); + } if (enableTHn) { double massXic(-1); double outputBkg(-1), outputPrompt(-1), outputFD(-1); + bool allProngsInAcceptance = false; 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) { outputBkg = candidate.mlProbXicToPKPi()[0]; /// bkg score @@ -443,13 +508,20 @@ struct HfTaskXic { 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()); + registry.get(HIST("hnXicVarsWithBdt"))->Fill(massXic, ptCandidate, outputBkg, outputPrompt, outputFD, candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec()); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); } } 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) { outputBkg = candidate.mlProbXicToPiKP()[0]; /// bkg score @@ -457,9 +529,10 @@ struct HfTaskXic { outputFD = candidate.mlProbXicToPiKP()[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()); + // 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); } else { - registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec()); + registry.get(HIST("hnXicVars"))->Fill(massXic, ptCandidate, candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), candidate.originMcRec(), mcParticleProng0.pt(), yProng0, allProngsInAcceptance); } } } // enable THn @@ -497,36 +570,34 @@ struct HfTaskXic { // MC gen. for (const auto& particle : mcParticles) { if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::XicToPKPi) { - auto yParticle = RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus); - if (yCandGenMax >= 0. && std::abs(yParticle) > yCandGenMax) { + auto yGen = RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus); + if (yCandGenMax >= 0. && std::abs(yGen) > yCandGenMax) { continue; } - auto ptParticle = particle.pt(); - 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++; + auto ptGen = particle.pt(); + registry.fill(HIST("MC/generated/signal/hPtGen"), ptGen); + registry.fill(HIST("MC/generated/signal/hEtaGen"), particle.eta()); + registry.fill(HIST("MC/generated/signal/hYGen"), yGen); + registry.fill(HIST("MC/generated/signal/hEtaVsPtGenSig"), particle.eta(), ptGen); + registry.fill(HIST("MC/generated/signal/hYVsPtGenSig"), yGen, ptGen); + + if (particle.originMcGen() == RecoDecay::OriginType::Prompt) { + 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); + registry.fill(HIST("MC/generated/prompt/hEtaVsPtGenSigPrompt"), particle.eta(), ptGen); + registry.fill(HIST("MC/generated/prompt/hYVsPtGenSigPrompt"), yGen, ptGen); } - - registry.fill(HIST("MC/generated/hPtGen"), ptParticle); - registry.fill(HIST("MC/generated/hEtaGen"), particle.eta(), ptParticle); - registry.fill(HIST("MC/generated/hYGen"), yParticle, ptParticle); - // reject Xic daughters that are not in geometrical acceptance - if (!isProngInAcceptance(etaProngs[0], ptProngs[0]) || !isProngInAcceptance(etaProngs[1], ptProngs[1]) || !isProngInAcceptance(etaProngs[2], ptProngs[2])) { - continue; + if (particle.originMcGen() == RecoDecay::OriginType::NonPrompt) { + 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); + registry.fill(HIST("MC/generated/nonprompt/hEtaVsPtGenSigNonPrompt"), particle.eta(), ptGen); + registry.fill(HIST("MC/generated/nonprompt/hYVsPtGenSigNonPrompt"), yGen, ptGen); } - registry.fill(HIST("MC/generated/hPtGenWithProngsInAcceptance"), ptParticle); - registry.fill(HIST("MC/generated/hYGenWithProngsInAcceptance"), yParticle, ptParticle); - registry.fill(HIST("MC/generated/hEtaGenWithProngsInAcceptance"), particle.eta(), ptParticle); } } } - void processMcStd(soa::Filtered> const& selectedCandidatesMc, soa::Join const& mcParticles, aod::TracksWMc const& tracksWithMc) diff --git a/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx b/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx index 3a5acb6dd6e..726bf86d77d 100644 --- a/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx +++ b/PWGHF/D2H/Tasks/taskXicToXiPiPi.cxx @@ -13,7 +13,11 @@ /// \brief Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π± analysis task /// \note adapted from taskBs.cxx /// -/// \author Phil Stahlhut +/// \author Phil Lennart Stahlhut , Heidelberg University +/// \author Carolina Reetz , Heidelberg University +/// \author Jaeyoon Cho , Inha University + +#include #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" @@ -41,6 +45,24 @@ struct HfTaskXicToXiPiPi { Configurable> binsPt{"binsPt", std::vector{hf_cuts_xic_to_xi_pi_pi::vecBinsPt}, "pT bin limits"}; // MC checks Configurable checkDecayTypeMc{"checkDecayTypeMc", false, "Flag to enable DecayType histogram"}; + // THnSparese for ML selection check + Configurable enableTHn{"enableTHn", false, "Fill THnSparse for Xic"}; + ConfigurableAxis thnConfigAxisPt{"thnConfigAxisPt", {400, 0., 40.}, ""}; + ConfigurableAxis thnConfigAxisMass{"thnConfigAxisMass", {300, 1.8, 3.0}, ""}; + ConfigurableAxis thnConfigAxisPtProng{"thnConfigAxisPtProng", {300, 0., 30.}, ""}; + ConfigurableAxis thnConfigAxisChi2PCA{"thnConfigAxisChi2PCA", {200, 0., 20}, ""}; + ConfigurableAxis thnConfigAxisDecLength{"thnConfigAxisDecLength", {200, 0., 0.5}, ""}; + 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 binsDecLength{"binsDecLength", {200, 0., 0.5}, ""}; + ConfigurableAxis binsErrDecLength{"binsErrDecLength", {100, 0., 1.}, ""}; + ConfigurableAxis binsDCA{"binsDCA", {100, -0.05, 0.05}, ""}; + ConfigurableAxis binsImpParErr{"binsImpParErr", {200, -0.1, 0.1}, ""}; + ConfigurableAxis binsSV{"binsSV", {200, -5., 5.}, ""}; + ConfigurableAxis binsChi2{"binsChi2", {200, 0., 0.1}, ""}; Service pdg; @@ -55,32 +77,65 @@ struct HfTaskXicToXiPiPi { void init(InitContext const&) { + std::array doprocess{doprocessWithDCAFitter, doprocessWithKFParticle, doprocessWithDCAFitterAndML, doprocessWithKFParticleAndML, doprocessMcWithDCAFitter, doprocessMcWithKFParticle, doprocessMcWithDCAFitterAndML, doprocessMcWithKFParticleAndML}; + if ((std::accumulate(doprocess.begin(), doprocess.end(), 0)) == 0) { + LOGP(fatal, "No process function enabled. Please enable one."); + } + if ((doprocessWithDCAFitter || doprocessWithDCAFitterAndML || doprocessMcWithDCAFitter || doprocessMcWithDCAFitterAndML) && (doprocessWithKFParticle || doprocessWithKFParticleAndML || doprocessMcWithKFParticle || doprocessMcWithKFParticleAndML)) { + LOGP(fatal, "Cannot enable DCAFitter and KFParticle at the same time. Please choose one."); + } + if ((doprocessWithDCAFitter || doprocessWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticle) && (doprocessWithDCAFitterAndML || doprocessWithKFParticleAndML || doprocessMcWithDCAFitterAndML || doprocessMcWithKFParticleAndML)) { + LOGP(fatal, "Cannot enable process function with ML and process function without ML at the same time. Please choose one."); + } + static const AxisSpec axisMassXic = {300, 1.8, 3.0, "inv. mass (GeV/#it{c}^{2})"}; static const AxisSpec axisMassXiRes = {300, 1.0, 2.0, "inv. mass (GeV/#it{c}^{2})"}; static const AxisSpec axisPt = {(std::vector)binsPt, "#it{p}_{T} (GeV/#it{c})"}; + static const AxisSpec axisDecLength = {binsDecLength}; + static const AxisSpec axisErrDecLength = {binsErrDecLength}; + static const AxisSpec axisDCA = {binsDCA}; + static const AxisSpec axisImpParErr = {binsImpParErr}; + static const AxisSpec axisSV = {binsSV}; + static const AxisSpec axisChi2 = {binsChi2}; + // candidate + registry.add("hPt", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 20.}}}); registry.add("hEta", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hRapidity", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hCPA", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); registry.add("hCPAxy", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate cosine of pointing angle xy;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); registry.add("hMass", "#Xi^{#plus}_{c} candidates;inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm} (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisMassXic, axisPt}}); - registry.add("hDecLength", "#Xi^{#plus}_{c} candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 0.4}, axisPt}}); - registry.add("hErrDecLength", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, axisPt}}); - registry.add("hDecLengthXY", "#Xi^{#plus}_{c} candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 0.4}, axisPt}}); - registry.add("hErrDecLengthXY", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, axisPt}}); - registry.add("hd0Prong0", "#Xi^{#plus}_{c} candidates;prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong1", "#Xi^{#plus}_{c} candidates;prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong2", "#Xi^{#plus}_{c} candidates;prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{100, -0.05, 0.05}, axisPt}}); - registry.add("hImpParErr", "#Xi^{#plus}_{c} candidates;prongs impact parameter error (cm);entries", {HistType::kTH2F, {{200, -0.1, 0.1}, axisPt}}); - registry.add("hChi2PCA", "#Xi^{#plus}_{c} candidates (matched);sum of distances of the secondary vertex to its prongs;entries", {HistType::kTH2F, {{240, -0.01, 0.5}, axisPt}}); + registry.add("hDecLength", "#Xi^{#plus}_{c} candidates;decay length (cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hErrDecLength", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate decay length error (cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hDecLengthXY", "#Xi^{#plus}_{c} candidates;decay length xy (cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hErrDecLengthXY", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate decay length xy error (cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hSVx", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate secondary vertex position x (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVy", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate secondary vertex position y (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVz", "#Xi^{#plus}_{c} candidates;#Xi^{#plus}_{c} candidate secondary vertex position z (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + // daughters registry.add("hCPAXi", "#Xi^{#plus}_{c} candidates;#Xi^{#minus} candidate cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); registry.add("hCPAxyXi", "#Xi^{#plus}_{c} candidates;#Xi^{#minus} candidate cosine of pointing angle xy;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); registry.add("hCPALambda", "#Xi^{#plus}_{c} candidates;#Lambda candidate cosine of pointing angle;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); registry.add("hCPAxyLambda", "#Xi^{#plus}_{c} candidates;#Lambda candidate cosine of pointing angle xy;entries", {HistType::kTH2F, {{110, -1.1, 1.1}, axisPt}}); + registry.add("hPtProng0vsPt", "#Xi^{#plus}_{c} candidates;#Xi^{#mp} #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng1vsPt", "#Xi^{#plus}_{c} candidates;prong 1 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng2vsPt", "#Xi^{#plus}_{c} candidates;prong 2 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hd0Prong0", "#Xi^{#plus}_{c} candidates;prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong1", "#Xi^{#plus}_{c} candidates;prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong2", "#Xi^{#plus}_{c} candidates;prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hImpParErr", "#Xi^{#plus}_{c} candidates;prongs impact parameter error (cm);entries", {HistType::kTH2F, {axisImpParErr, axisPt}}); + registry.add("hChi2PCA", "#Xi^{#plus}_{c} candidates (matched);sum of distances of the secondary vertex to its prongs;entries", {HistType::kTH2F, {{240, -0.01, 0.5}, axisPt}}); registry.add("hMassXiPi1", "#Xi^{#plus}_{c} candidates;inv. mass #Xi^{#mp} #pi^{#pm} (prong 1) (GeV/#it{c}^{2});#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisMassXiRes, axisPt}}); 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}}); - if (doprocessMc) { + 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}}); + } + + if (doprocessMcWithKFParticle || doprocessMcWithDCAFitter || doprocessMcWithKFParticleAndML || doprocessMcWithDCAFitterAndML) { // MC reconstructed registry.add("hPtGenSig", "#Xi^{#plus}_{c} candidates (gen+rec);candidate #it{p}_{T}^{gen.} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 30.}}}); registry.add("hPtRecSig", "#Xi^{#plus}_{c} candidates (matched);candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 30.}}}); @@ -91,32 +146,44 @@ struct HfTaskXicToXiPiPi { registry.add("hPtProng1RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 1 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 20.}}}); registry.add("hPtProng2RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 2 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 20.}}}); registry.add("hPtProng2RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 2 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 20.}}}); + registry.add("hPtProng0vsPtRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#mp} #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng0vsPtRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#mp} #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng1vsPtRecSig", "#Xi^{#plus}_{c} candidates (matched);prong 1 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng1vsPtRecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 1 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng2vsPtRecSig", "#Xi^{#plus}_{c} candidates (matched);prong 2 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); + registry.add("hPtProng2vsPtRecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 2 (#pi^{#pm}) #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); registry.add("hEtaRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hEtaRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hRapidityRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hRapidityRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate #it{y};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); + registry.add("hSVxRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate secondary vertex position x (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVxRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate secondary vertex position x (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVyRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate secondary vertex position y (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVyRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate secondary vertex position y (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVzRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate secondary vertex position z (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVzRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate secondary vertex position z (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); registry.add("hCPARecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate cosine of pointing angle;entries", {HistType::kTH2F, {{220, -1.1, 1.1}, axisPt}}); registry.add("hCPARecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate cosine of pointing angle;entries", {HistType::kTH2F, {{220, -1.1, 1.1}, axisPt}}); registry.add("hCPAxyRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate CPAxy;entries", {HistType::kTH2F, {{220, -1.1, 1.1}, axisPt}}); registry.add("hCPAxyRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate CPAxy;entries", {HistType::kTH2F, {{220, -1.1, 1.1}, axisPt}}); registry.add("hMassRecSig", "#Xi^{#plus}_{c} candidates (matched);inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm} (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{300, 1.8, 3.0}, axisPt}}); registry.add("hMassRecBg", "#Xi^{#plus}_{c} candidates (unmatched);inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm} (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{300, 1.8, 3.0}, axisPt}}); - registry.add("hDecLengthRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hDecLengthRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hErrDecLengthRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hErrDecLengthRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hDecLengthXYRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length xy (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hDecLengthXYRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length xy(cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hErrDecLengthXYRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length xy (cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hErrDecLengthXYRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length xy(cm);entries", {HistType::kTH2F, {{100, 0., 0.5}, axisPt}}); - registry.add("hd0Prong0RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong0RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong1RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong1RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong2RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hd0Prong2RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {{200, -0.05, 0.05}, axisPt}}); - registry.add("hImpParErrRecSig", "#Xi^{#plus}_{c} candidates (matched);prongs impact parameter error (cm);entries", {HistType::kTH2F, {{100, -0.1, 0.1}, axisPt}}); - registry.add("hImpParErrRecBg", "#Xi^{#plus}_{c} candidates (unmatched);prongs impact parameter error (cm);entries", {HistType::kTH2F, {{100, -0.1, 0.1}, axisPt}}); + registry.add("hDecLengthRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hDecLengthRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hErrDecLengthRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hErrDecLengthRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length (cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hDecLengthXYRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length xy (cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hDecLengthXYRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length xy(cm);entries", {HistType::kTH2F, {axisDecLength, axisPt}}); + registry.add("hErrDecLengthXYRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#plus}_{c} candidate decay length xy (cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hErrDecLengthXYRecBg", "#Xi^{#plus}_{c} candidates (unmatched);#Xi^{#plus}_{c} candidate decay length xy(cm);entries", {HistType::kTH2F, {axisErrDecLength, axisPt}}); + registry.add("hd0Prong0RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong0RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 0 (#Xi^{#mp}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong1RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong1RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 1 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong2RecSig", "#Xi^{#plus}_{c} candidates (matched);prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hd0Prong2RecBg", "#Xi^{#plus}_{c} candidates (unmatched);prong 2 (#pi^{#pm}) DCAxy to prim. vertex (cm);entries", {HistType::kTH2F, {axisDCA, axisPt}}); + registry.add("hImpParErrRecSig", "#Xi^{#plus}_{c} candidates (matched);prongs impact parameter error (cm);entries", {HistType::kTH2F, {axisImpParErr, axisPt}}); + registry.add("hImpParErrRecBg", "#Xi^{#plus}_{c} candidates (unmatched);prongs impact parameter error (cm);entries", {HistType::kTH2F, {axisImpParErr, axisPt}}); registry.add("hChi2PCARecSig", "#Xi^{#plus}_{c} candidates (matched);sum of distances of the secondary vertex to its prongs;entries", {HistType::kTH2F, {{240, -0.01, 0.1}, axisPt}}); registry.add("hChi2PCARecBg", "#Xi^{#plus}_{c} candidates (unmatched);sum of distances of the secondary vertex to its prongs;entries", {HistType::kTH2F, {{240, -0.01, 0.1}, axisPt}}); registry.add("hCPAXiRecSig", "#Xi^{#plus}_{c} candidates (matched);#Xi^{#minus} cosine of pointing angle;entries", {HistType::kTH2F, {{220, -1.1, 1.1}, axisPt}}); @@ -131,6 +198,18 @@ struct HfTaskXicToXiPiPi { registry.add("hMassXiPi1RecBg", "#Xi^{#plus}_{c} candidates (unmatched);inv. mass #Xi^{#mp} #pi^{#pm} (prong 1) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{300, 1.0, 2.0}, axisPt}}); registry.add("hMassXiPi2RecSig", "#Xi^{#plus}_{c} candidates (matched);inv. mass #Xi^{#mp} #pi^{#pm} (prong 2) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{300, 1.0, 2.0}, axisPt}}); 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}}); + + if (doprocessMcWithKFParticle || doprocessMcWithDCAFitterAndML) { + 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}}); + } + // 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}}); registry.add("hPtProng1Gen", "MC particles (generated);prong 1 (#pi^{#pm}) #it{p}_{T}^{gen} (GeV/#it{c});entries", {HistType::kTH2F, {{200, 0., 20.}, axisPt}}); @@ -144,6 +223,9 @@ struct HfTaskXicToXiPiPi { registry.add("hPtGen", "MC particles (generated);candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 30.}}}); registry.add("hEtaGen", "MC particles (generated);#Xi^{#plus}_{c} candidate #it{#eta}^{gen};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hYGen", "MC particles (generated);#Xi^{#plus}_{c} candidate #it{y}^{gen};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); + registry.add("hSVxGen", "#Xi^{#plus}_{c} candidates (generated);#Xi^{#plus}_{c} candidate secondary vertex position x (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVyGen", "#Xi^{#plus}_{c} candidates (generated);#Xi^{#plus}_{c} candidate secondary vertex position y (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); + registry.add("hSVzGen", "#Xi^{#plus}_{c} candidates (generated);#Xi^{#plus}_{c} candidate secondary vertex position z (cm);entries", {HistType::kTH2F, {axisSV, axisPt}}); registry.add("hPtGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{300, 0., 30.}}}); registry.add("hEtaGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);#Xi^{#plus}_{c} candidate #it{#eta}^{gen};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); registry.add("hYGenWithProngsInAcceptance", "MC particles (generated-daughters in acceptance);#Xi^{#plus}_{c} candidate #it{y}^{gen};entries", {HistType::kTH2F, {{100, -2., 2.}, axisPt}}); @@ -161,6 +243,50 @@ struct HfTaskXicToXiPiPi { registry.get(HIST("hDecayTypeMc"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin]); } } + + if (enableTHn) { + const AxisSpec thnAxisPt{thnConfigAxisPt, "#it{p}_{T} (GeV/#it{c})"}; + const AxisSpec thnAxisMass{thnConfigAxisMass, "inv. mass #Xi^{#mp} #pi^{#pm} #pi^{#pm}"}; + const AxisSpec thnAxisChi2PCA{thnConfigAxisChi2PCA, "Chi2PCA to sec. vertex (cm)"}; + const AxisSpec thnAxisDecLength{thnConfigAxisDecLength, "decay length (cm)"}; + 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"}; + + 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}); + } else { + // without ML information + registry.add("hXicToXiPiPiVars", "THnSparse for Xic", HistType::kTHnSparseF, {thnAxisPt, thnAxisMass, thnAxisChi2PCA, thnAxisDecLength, thnAxisDecLengthXY, thnAxisCPA}); + } + } // enable THnSpare + + } // end init + + /// Fill THnSpare depending on whether ML selection is used + // \param candidate is candidate + template + void fillTHnSparse(const T1& candidate) + { + if (!enableTHn) { + return; + } + + if constexpr (useMl) { + // with ML information + double outputBkg = -99.; + double outputPrompt = -99.; + if (candidate.mlProbXicToXiPiPi().size() > 0) { + outputBkg = candidate.mlProbXicToXiPiPi()[0]; + outputPrompt = candidate.mlProbXicToXiPiPi()[1]; + } + registry.get(HIST("hXicToXiPiPiVarsWithML"))->Fill(candidate.pt(), candidate.invMassXic(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa(), outputBkg, outputPrompt); + } else { + // without ML information + registry.get(HIST("hXicToXiPiPiVars"))->Fill(candidate.pt(), candidate.invMassXic(), candidate.chi2PCA(), candidate.decayLength(), candidate.decayLengthXY(), candidate.cpa()); + } } /// Selection of Xic daughter in geometrical acceptance @@ -173,7 +299,9 @@ struct HfTaskXicToXiPiPi { return std::abs(etaProng) <= etaTrackMax && ptProng >= ptTrackMin; } - void process(soa::Filtered> const& candidates) + /// Function to fill histograms + template + void fillHistograms(TCanTable const& candidates) { for (const auto& candidate : candidates) { auto yCandXic = candidate.y(o2::constants::physics::MassXiCPlus); @@ -196,6 +324,12 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hErrDecLength"), candidate.errorDecayLength(), ptCandXic); registry.fill(HIST("hDecLengthXY"), candidate.decayLengthXY(), ptCandXic); registry.fill(HIST("hErrDecLengthXY"), candidate.errorDecayLengthXY(), ptCandXic); + registry.fill(HIST("hSVx"), candidate.xSecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVy"), candidate.ySecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVz"), candidate.zSecondaryVertex(), ptCandXic); + registry.fill(HIST("hPtProng0vsPt"), candidate.ptProng0(), ptCandXic); + registry.fill(HIST("hPtProng1vsPt"), candidate.ptProng1(), ptCandXic); + registry.fill(HIST("hPtProng2vsPt"), candidate.ptProng2(), ptCandXic); registry.fill(HIST("hd0Prong0"), candidate.impactParameter0(), ptCandXic); registry.fill(HIST("hd0Prong1"), candidate.impactParameter1(), ptCandXic); registry.fill(HIST("hd0Prong2"), candidate.impactParameter2(), ptCandXic); @@ -209,13 +343,31 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hCPAxyLambda"), candidate.cosPaLambda(), 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); + } + + // fill THnSparse + if (enableTHn) { + if constexpr (useMl) { + fillTHnSparse(candidate); + } else { + fillTHnSparse(candidate); + } + } } // candidate loop - } // process + } - /// MC analysis and fill histograms - void processMc(soa::Filtered> const& candidates, - soa::Join const& mcParticles, - aod::TracksWMc const&) + /// Function for MC analysis and histogram filling + template + void fillHistogramsMc(TCandTable const& candidates, + soa::Join const& mcParticles, + aod::TracksWMc const&) { std::vector arrDaughIndex; @@ -230,7 +382,7 @@ struct HfTaskXicToXiPiPi { int 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.pi0_as().mcParticle_as>(), o2::constants::physics::Pdg::kXiCPlus, true); + auto indexMother = RecoDecay::getMother(mcParticles, candidate.template pi0_as().template mcParticle_as>(), o2::constants::physics::Pdg::kXiCPlus, true); auto particleMother = mcParticles.rawIteratorAt(indexMother); registry.fill(HIST("hPtGenSig"), particleMother.pt()); @@ -238,8 +390,14 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hPtProng0RecSig"), candidate.ptProng0()); registry.fill(HIST("hPtProng1RecSig"), candidate.ptProng1()); registry.fill(HIST("hPtProng2RecSig"), candidate.ptProng2()); + registry.fill(HIST("hPtProng0vsPtRecSig"), candidate.ptProng0(), ptCandXic); + registry.fill(HIST("hPtProng1vsPtRecSig"), candidate.ptProng1(), ptCandXic); + registry.fill(HIST("hPtProng2vsPtRecSig"), candidate.ptProng2(), ptCandXic); registry.fill(HIST("hEtaRecSig"), candidate.eta(), ptCandXic); registry.fill(HIST("hRapidityRecSig"), yCandXic, ptCandXic); + registry.fill(HIST("hSVxRecSig"), candidate.xSecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVyRecSig"), candidate.ySecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVzRecSig"), candidate.zSecondaryVertex(), ptCandXic); registry.fill(HIST("hCPARecSig"), candidate.cpa(), ptCandXic); registry.fill(HIST("hCPAxyRecSig"), candidate.cpaXY(), ptCandXic); registry.fill(HIST("hMassRecSig"), candidate.invMassXic(), ptCandXic); @@ -258,13 +416,27 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hCPAxyXiRecSig"), candidate.cosPaXYXi(), ptCandXic); registry.fill(HIST("hCPALambdaRecSig"), candidate.cosPaLambda(), ptCandXic); registry.fill(HIST("hCPAxyLambdaRecSig"), candidate.cosPaLambda(), 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); + } } else { registry.fill(HIST("hPtRecBg"), ptCandXic); registry.fill(HIST("hPtProng0RecBg"), candidate.ptProng0()); registry.fill(HIST("hPtProng1RecBg"), candidate.ptProng1()); registry.fill(HIST("hPtProng2RecBg"), candidate.ptProng2()); + registry.fill(HIST("hPtProng0vsPtRecBg"), candidate.ptProng0(), ptCandXic); + registry.fill(HIST("hPtProng1vsPtRecBg"), candidate.ptProng1(), ptCandXic); + registry.fill(HIST("hPtProng2vsPtRecBg"), candidate.ptProng2(), ptCandXic); registry.fill(HIST("hEtaRecBg"), candidate.eta(), ptCandXic); registry.fill(HIST("hRapidityRecBg"), yCandXic, ptCandXic); + registry.fill(HIST("hSVxRecBg"), candidate.xSecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVyRecBg"), candidate.ySecondaryVertex(), ptCandXic); + registry.fill(HIST("hSVzRecBg"), candidate.zSecondaryVertex(), ptCandXic); registry.fill(HIST("hCPARecBg"), candidate.cpa(), ptCandXic); registry.fill(HIST("hCPAxyRecBg"), candidate.cpaXY(), ptCandXic); registry.fill(HIST("hMassRecBg"), candidate.invMassXic(), ptCandXic); @@ -283,6 +455,14 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hCPAxyXiRecBg"), candidate.cosPaXYXi(), ptCandXic); registry.fill(HIST("hCPALambdaRecBg"), candidate.cosPaLambda(), ptCandXic); registry.fill(HIST("hCPAxyLambdaRecBg"), candidate.cosPaLambda(), 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); + } } if (checkDecayTypeMc) { @@ -294,6 +474,15 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hDecayTypeMc"), 1 + hf_cand_xic_to_xi_pi_pi::DecayType::NDecayType, candidate.invMassXic(), ptCandXic); } } + // fill THnSparse + if (enableTHn) { + if constexpr (useMl) { + fillTHnSparse(candidate); + } else { + fillTHnSparse(candidate); + } + } + } // rec // MC gen. level @@ -311,6 +500,9 @@ struct HfTaskXicToXiPiPi { std::array ptProngs; std::array yProngs; std::array etaProngs; + std::array prodVtxXProngs; + std::array prodVtxYProngs; + std::array prodVtxZProngs; int counter = 0; RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2); for (auto iProng = 0u; iProng < arrDaughIndex.size(); ++iProng) { @@ -318,6 +510,9 @@ struct HfTaskXicToXiPiPi { ptProngs[counter] = daughI.pt(); etaProngs[counter] = daughI.eta(); yProngs[counter] = RecoDecay::y(daughI.pVector(), pdg->Mass(daughI.pdgCode())); + prodVtxXProngs[counter] = daughI.vx(); + prodVtxYProngs[counter] = daughI.vy(); + prodVtxZProngs[counter] = daughI.vz(); counter++; } @@ -333,6 +528,9 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hPtGen"), ptParticle); registry.fill(HIST("hYGen"), yParticle, ptParticle); registry.fill(HIST("hEtaGen"), particle.eta(), ptParticle); + registry.fill(HIST("hSVxGen"), prodVtxXProngs[0], ptParticle); + registry.fill(HIST("hSVyGen"), prodVtxYProngs[0], ptParticle); + registry.fill(HIST("hSVzGen"), prodVtxZProngs[0], ptParticle); // reject Xic daughters that are not in geometrical acceptance if (!isProngInAcceptance(etaProngs[0], ptProngs[0]) || !isProngInAcceptance(etaProngs[1], ptProngs[1]) || !isProngInAcceptance(etaProngs[2], ptProngs[2])) { @@ -343,8 +541,69 @@ struct HfTaskXicToXiPiPi { registry.fill(HIST("hYGenWithProngsInAcceptance"), yParticle, ptParticle); } } // gen - } // process - PROCESS_SWITCH(HfTaskXicToXiPiPi, processMc, "Process MC", false); + } + + /// Data analysis and fill histograms + void processWithDCAFitter(soa::Filtered> const& candidates) + { + fillHistograms(candidates); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithDCAFitter, "Process data with DCAFitter", true); + + void processWithKFParticle(soa::Filtered> const& candidates) + { + fillHistograms(candidates); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithKFParticle, "Process data with KFParticle", false); + + /// Data analysis and fill histograms with ML + void processWithDCAFitterAndML(soa::Filtered> const& candidates) + { + fillHistograms(candidates); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithDCAFitterAndML, "Process data with DCAFitter and ML approach", false); + + void processWithKFParticleAndML(soa::Filtered> const& candidates) + { + fillHistograms(candidates); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processWithKFParticleAndML, "Process data with KFParticle and ML approach", false); + + /// MC analysis and fill histograms + void processMcWithDCAFitter(soa::Filtered> const& candidates, + soa::Join const& mcParticles, + aod::TracksWMc const& tracksWMc) + { + fillHistogramsMc(candidates, mcParticles, tracksWMc); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithDCAFitter, "Process MC with DCAFitter", false); + + /// MC analysis and fill histograms with KFParticle + void processMcWithKFParticle(soa::Filtered> const& candidates, + soa::Join const& mcParticles, + aod::TracksWMc const& tracksWMc) + { + fillHistogramsMc(candidates, mcParticles, tracksWMc); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithKFParticle, "Process MC with KFParticle", false); + + // MC analysis and fill histograms with ML + void processMcWithDCAFitterAndML(soa::Filtered> const& candidates, + soa::Join const& mcParticles, + aod::TracksWMc const& tracksWMc) + { + fillHistogramsMc(candidates, mcParticles, tracksWMc); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithDCAFitterAndML, "Process MC with DCAFitter and ML approach", false); + + void processMcWithKFParticleAndML(soa::Filtered> const& candidates, + soa::Join const& mcParticles, + aod::TracksWMc const& tracksWMc) + { + fillHistogramsMc(candidates, mcParticles, tracksWMc); + } + PROCESS_SWITCH(HfTaskXicToXiPiPi, processMcWithKFParticleAndML, "Process MC with KFParticle and ML approach", false); + }; // struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/D2H/Utils/utilsRedDataFormat.h b/PWGHF/D2H/Utils/utilsRedDataFormat.h index 64d1931e06b..9740e55d372 100644 --- a/PWGHF/D2H/Utils/utilsRedDataFormat.h +++ b/PWGHF/D2H/Utils/utilsRedDataFormat.h @@ -10,12 +10,14 @@ // or submit itself to any jurisdiction. /// \file utilsRedDataFormat.h -/// \brief Event selection utilities for reduced data format analyses +/// \brief Utilities for reduced data format analyses /// \author Luca Aglietta , UniTO Turin #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" @@ -27,10 +29,10 @@ namespace o2::hf_evsel /// \tparam centEstimator centrality estimator /// \param collision collision to test against the selection criteria template -void checkEvSel(Coll const& collision, o2::hf_evsel::HfEventSelection& hfEvSel, int& zvtxColl, int& sel8Coll, int& zvtxAndSel8Coll, int& zvtxAndSel8CollAndSoftTrig, int& allSelColl, o2::framework::Service const& ccdb) +void checkEvSel(Coll const& collision, o2::hf_evsel::HfEventSelection& hfEvSel, int& zvtxColl, int& sel8Coll, int& zvtxAndSel8Coll, int& zvtxAndSel8CollAndSoftTrig, int& allSelColl, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry) { float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (!TESTBIT(rejectionMask, o2::hf_evsel::EventRejection::Trigger)) { sel8Coll++; } @@ -49,4 +51,31 @@ void checkEvSel(Coll const& collision, o2::hf_evsel::HfEventSelection& hfEvSel, } } // namespace o2::hf_evsel +namespace o2::pid_tpc_tof_utils +{ +/// Helper function to retrive PID information of bachelor pion from b-hadron decay +/// \param prong1 pion track from reduced data format, soa::Join +template +float getTpcTofNSigmaPi1(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.tpcNSigmaPi(); + float tofNSigma = prong1.tofNSigmaPi(); + return std::sqrt(.5f * tpcNSigma * tpcNSigma + .5f * tofNSigma * tofNSigma); + } + if (hasTpc) { + return std::abs(prong1.tpcNSigmaPi()); + } + if (hasTof) { + return std::abs(prong1.tofNSigmaPi()); + } + 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 fcddfbae215..5c206512490 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -34,6 +34,7 @@ #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/Utils/utilsPid.h" namespace o2::aod { @@ -338,11 +339,11 @@ DECLARE_SOA_TABLE(HfDstars_000, "AOD", "HFDSTAR", //! D* -> D0pi candidates (Run hf_track_index::Prong0Id, hf_track_index::ProngD0Id); -DECLARE_SOA_TABLE(HfDstars_001, "AOD", "HFDSTAR", //! D* -> D0pi candidates (Run 3 format) - o2::soa::Index<>, - hf_track_index::CollisionId, - hf_track_index::Prong0Id, - hf_track_index::ProngD0Id); +DECLARE_SOA_TABLE_VERSIONED(HfDstars_001, "AOD", "HFDSTAR", 1, //! D* -> D0pi candidates (Run 3 format) + o2::soa::Index<>, + hf_track_index::CollisionId, + hf_track_index::Prong0Id, + hf_track_index::ProngD0Id); using HfDstars = HfDstars_001; using HfDstar = HfDstars::iterator; @@ -482,7 +483,64 @@ 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(NProngsContributorsPV, nProngsContributorsPV, uint8_t); //! number of 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 + [](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); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPi2, tpcTofNSigmaPi2, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 2 + [](float tpcNSigmaPi2, float tofNSigmaPi2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi2, tofNSigmaPi2); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaKa0, tpcTofNSigmaKa0, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 0 + [](float tpcNSigmaKa0, float tofNSigmaKa0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa0, tofNSigmaKa0); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaKa1, tpcTofNSigmaKa1, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 1 + [](float tpcNSigmaKa1, float tofNSigmaKa1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa1, tofNSigmaKa1); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaKa2, tpcTofNSigmaKa2, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 2 + [](float tpcNSigmaKa2, float tofNSigmaKa2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa2, tofNSigmaKa2); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPr0, tpcTofNSigmaPr0, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 0 + [](float tpcNSigmaPr0, float tofNSigmaPr0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr0, tofNSigmaPr0); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPr1, tpcTofNSigmaPr1, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 1 + [](float tpcNSigmaPr1, float tofNSigmaPr1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr1, tofNSigmaPr1); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaPr2, tpcTofNSigmaPr2, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 2 + [](float tpcNSigmaPr2, float tofNSigmaPr2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr2, tofNSigmaPr2); }); +// tiny (binned) option +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyPi0, tpcTofNSigmaTinyPi0, //! 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(TpcTofNSigmaTinyPi1, tpcTofNSigmaTinyPi1, //! 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); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyPi2, tpcTofNSigmaTinyPi2, //! Combined NSigma separation with the TPC & TOF detectors for pion - prong 2 + [](float tpcNSigmaPi2, float tofNSigmaPi2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPi2, tofNSigmaPi2); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyKa0, tpcTofNSigmaTinyKa0, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 0 + [](float tpcNSigmaKa0, float tofNSigmaKa0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa0, tofNSigmaKa0); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyKa1, tpcTofNSigmaTinyKa1, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 1 + [](float tpcNSigmaKa1, float tofNSigmaKa1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa1, tofNSigmaKa1); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyKa2, tpcTofNSigmaTinyKa2, //! Combined NSigma separation with the TPC & TOF detectors for kaon - prong 2 + [](float tpcNSigmaKa2, float tofNSigmaKa2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaKa2, tofNSigmaKa2); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyPr0, tpcTofNSigmaTinyPr0, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 0 + [](float tpcNSigmaPr0, float tofNSigmaPr0) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr0, tofNSigmaPr0); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyPr1, tpcTofNSigmaTinyPr1, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 1 + [](float tpcNSigmaPr1, float tofNSigmaPr1) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr1, tofNSigmaPr1); }); +DECLARE_SOA_DYNAMIC_COLUMN(TpcTofNSigmaTinyPr2, tpcTofNSigmaTinyPr2, //! Combined NSigma separation with the TPC & TOF detectors for proton - prong 2 + [](float tpcNSigmaPr2, float tofNSigmaPr2) -> float { return pid_tpc_tof_utils::combineNSigma(tpcNSigmaPr2, tofNSigmaPr2); }); + // candidate properties DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! [](float px, float py) -> float { return RecoDecay::pt(px, py); }); @@ -633,7 +691,36 @@ DECLARE_SOA_TABLE(HfCand2ProngBase, "AOD", "HFCAND2PBASE", //! DECLARE_SOA_EXTENDED_TABLE_USER(HfCand2ProngExt, HfCand2ProngBase, "HFCAND2PEXT", //! hf_cand_2prong::Px, hf_cand_2prong::Py, hf_cand_2prong::Pz); +DECLARE_SOA_TABLE(HfProng0PidPi, "AOD", "HFP0PIDPI", //! + hf_cand::NSigTpcPi0, hf_cand::NSigTofPi0, + hf_cand::TpcTofNSigmaPi0); +DECLARE_SOA_TABLE(HfProng1PidPi, "AOD", "HFP1PIDPI", //! + hf_cand::NSigTpcPi1, hf_cand::NSigTofPi1, + hf_cand::TpcTofNSigmaPi1); +DECLARE_SOA_TABLE(HfProng2PidPi, "AOD", "HFP2PIDPI", //! + hf_cand::NSigTpcPi2, hf_cand::NSigTofPi2, + hf_cand::TpcTofNSigmaPi2); +DECLARE_SOA_TABLE(HfProng0PidKa, "AOD", "HFP0PIDKA", //! + hf_cand::NSigTpcKa0, hf_cand::NSigTofKa0, + hf_cand::TpcTofNSigmaKa0); +DECLARE_SOA_TABLE(HfProng1PidKa, "AOD", "HFP1PIDKA", //! + hf_cand::NSigTpcKa1, hf_cand::NSigTofKa1, + hf_cand::TpcTofNSigmaKa1); +DECLARE_SOA_TABLE(HfProng2PidKa, "AOD", "HFP2PIDKA", //! + hf_cand::NSigTpcKa2, hf_cand::NSigTofKa2, + hf_cand::TpcTofNSigmaKa2); +DECLARE_SOA_TABLE(HfProng0PidPr, "AOD", "HFP0PIDPR", //! + hf_cand::NSigTpcPr0, hf_cand::NSigTofPr0, + hf_cand::TpcTofNSigmaPr0); +DECLARE_SOA_TABLE(HfProng1PidPr, "AOD", "HFP1PIDPR", //! + hf_cand::NSigTpcPr1, hf_cand::NSigTofPr1, + hf_cand::TpcTofNSigmaPr1); +DECLARE_SOA_TABLE(HfProng2PidPr, "AOD", "HFP2PIDPR", //! + hf_cand::NSigTpcPr2, hf_cand::NSigTofPr2, + hf_cand::TpcTofNSigmaPr2); + using HfCand2Prong = HfCand2ProngExt; +using HfCand2ProngWPid = soa::Join; DECLARE_SOA_TABLE(HfCand2ProngKF, "AOD", "HFCAND2PKF", hf_cand::KfTopolChi2OverNdf, @@ -756,11 +843,12 @@ 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(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); // 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 enum DecayType { BplusToD0Pi = 0 }; @@ -1164,6 +1252,48 @@ DECLARE_SOA_COLUMN(DecLenV0, decLenV0, float); DECLARE_SOA_COLUMN(ErrorDecayLengthCharmBaryon, errorDecayLengthCharmBaryon, float); DECLARE_SOA_COLUMN(ErrorDecayLengthXYCharmBaryon, errorDecayLengthXYCharmBaryon, float); +// KFParticle results +DECLARE_SOA_COLUMN(KfDcaXYPiFromOmegac, kfDcaXYPiFromOmegac, float); +DECLARE_SOA_COLUMN(KfDcaXYCascToPv, kfDcaXYCascToPv, float); +DECLARE_SOA_COLUMN(Chi2GeoV0, chi2GeoV0, float); +DECLARE_SOA_COLUMN(Chi2GeoCasc, chi2GeoCasc, float); +DECLARE_SOA_COLUMN(Chi2GeoOmegac, chi2GeoOmegac, float); +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(Omegacldl, omegacldl, float); +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(Chi2TopoV0ToCasc, chi2TopoV0ToCasc, float); +DECLARE_SOA_COLUMN(Chi2TopoCascToOmegac, chi2TopoCascToOmegac, float); +DECLARE_SOA_COLUMN(DecayLenXYLambda, decayLenXYLambda, float); +DECLARE_SOA_COLUMN(DecayLenXYCasc, decayLenXYCasc, float); +DECLARE_SOA_COLUMN(DecayLenXYOmegac, decayLenXYOmegac, float); +DECLARE_SOA_COLUMN(CosPaV0ToCasc, cosPaV0ToCasc, float); +DECLARE_SOA_COLUMN(CosPaCascToOmegac, cosPaCascToOmegac, float); +DECLARE_SOA_COLUMN(CosPaXYV0ToCasc, cosPaXYV0ToCasc, float); +DECLARE_SOA_COLUMN(CosPaXYCascToOmegac, cosPaXYCascToOmegac, float); +DECLARE_SOA_COLUMN(KfMassV0, kfMassV0, float); +DECLARE_SOA_COLUMN(KfMassCasc, kfMassCasc, float); +DECLARE_SOA_COLUMN(KfMassOmegac, kfMassOmegac, float); +DECLARE_SOA_COLUMN(KfRapOmegac, kfRapOmegac, float); +DECLARE_SOA_COLUMN(KfptPiFromOmegac, kfptPiFromOmegac, float); +DECLARE_SOA_COLUMN(KfptOmegac, kfptOmegac, float); +DECLARE_SOA_COLUMN(CosThetaStarPiFromOmegac, cosThetaStarPiFromOmegac, float); +DECLARE_SOA_COLUMN(V0Ndf, v0Ndf, float); +DECLARE_SOA_COLUMN(CascNdf, cascNdf, float); +DECLARE_SOA_COLUMN(OmegacNdf, omegacNdf, float); +DECLARE_SOA_COLUMN(MassV0Ndf, massV0Ndf, float); +DECLARE_SOA_COLUMN(MassCascNdf, massCascNdf, float); +DECLARE_SOA_COLUMN(V0Chi2OverNdf, v0Chi2OverNdf, float); +DECLARE_SOA_COLUMN(CascChi2OverNdf, cascChi2OverNdf, float); +DECLARE_SOA_COLUMN(OmegacChi2OverNdf, omegacChi2OverNdf, float); +DECLARE_SOA_COLUMN(MassV0Chi2OverNdf, massV0Chi2OverNdf, float); +DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float); + // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, int8_t); // debug flag for mis-association reconstruction level @@ -1177,6 +1307,18 @@ DECLARE_SOA_COLUMN(OriginGen, originGen, int8_t); DECLARE_SOA_COLUMN(PtCharmBaryonGen, ptCharmBaryonGen, float); DECLARE_SOA_COLUMN(RapidityCharmBaryonGen, rapidityCharmBaryonGen, float); +// dynamic columns +DECLARE_SOA_DYNAMIC_COLUMN(PtCharmBaryon, ptCharmBaryon, + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtCasc, ptCasc, + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtLambda, ptLambda, + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtPiFromCharmBaryon, ptPiFromCharmBaryon, + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtKaFromCasc, ptKaFromCasc, + [](float px, float py) -> float { return RecoDecay::pt(px, py); }); + // mapping of decay types enum DecayType { XiczeroToXiPi = 0, OmegaczeroToXiPi, @@ -1229,6 +1371,13 @@ DECLARE_SOA_TABLE(HfCandToOmegaPi, "AOD", "HFCANDTOOMEGAPI", 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, + // dynamic + hf_cand_xic0_omegac0::PtCharmBaryon, + hf_cand_xic0_omegac0::PtCasc, + hf_cand_xic0_omegac0::PtPiFromCharmBaryon, + hf_cand_xic0_omegac0::PtLambda, + hf_cand_xic0_omegac0::PtKaFromCasc, + 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, @@ -1272,6 +1421,24 @@ DECLARE_SOA_TABLE(HfCandToOmegaK, "AOD", "HFCANDTOOMEGAK", 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, o2::soa::Marker<2>); +// table with results of KFParticle +DECLARE_SOA_TABLE(HfOmegacKf, "AOD", "HFOMEGACKF", //! + hf_cand_xic0_omegac0::KfDcaXYPiFromOmegac, hf_cand_xic0_omegac0::KfDcaXYCascToPv, + 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::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, + hf_cand_xic0_omegac0::KfRapOmegac, + hf_cand_xic0_omegac0::KfptPiFromOmegac, hf_cand_xic0_omegac0::KfptOmegac, + hf_cand_xic0_omegac0::CosThetaStarPiFromOmegac, + 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); + // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfXicToXiPiMCRec, "AOD", "HFXICXIPIMCREC", //! hf_cand_xic0_omegac0::FlagMcMatchRec, @@ -1346,9 +1513,16 @@ DECLARE_SOA_COLUMN(Sign, sign, float); DECLARE_SOA_COLUMN(InvMassXiPi0, invMassXiPi0, float); DECLARE_SOA_COLUMN(InvMassXiPi1, invMassXiPi1, 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(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); // MC matching result: DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // reconstruction level DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level @@ -1420,7 +1594,10 @@ using HfCandXic = HfCandXicExt; DECLARE_SOA_TABLE(HfCandXicKF, "AOD", "HFCANDXICKF", cascdata::KFCascadeChi2, cascdata::KFV0Chi2, - 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::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::DcaPi0Pi1, hf_cand_xic_to_xi_pi_pi::DcaPi0Xi, hf_cand_xic_to_xi_pi_pi::DcaPi1Xi, + cascdata::DCACascDaughters); // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandXicMcRec, "AOD", "HFCANDXICMCREC", //! @@ -1573,17 +1750,19 @@ 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(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); // 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 // mapping of decay types enum DecayType { B0ToDPi }; enum DecayTypeMc : uint8_t { B0ToDplusPiToPiKPiPi = 0, B0ToDsPiToKKPiPi, + BsToDsPiToKKPiPi, PartlyRecoDecay, OtherDecay, NDecayTypeMc }; @@ -1646,16 +1825,23 @@ 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(FlagMcMatchGen, flagMcMatchGen, int8_t); // generator level +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 // mapping of decay types enum DecayType { BsToDsPi }; -enum DecayTypeMc : uint8_t { BsToDsPiToKKPiPi = 0, // Bs(bar) → Ds∓ π± → (Phi π∓) π± → (K- K+ π∓) π± - B0ToDsPiToKKPiPi, // B0(bar) → Ds± π∓ → (Phi π±) π∓ → (K- K+ π±) π∓ - PartlyRecoDecay, // 4 final state particles have another common b-hadron ancestor - NDecayTypeMc }; // counter of differentiated MC decay types +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+ π±) π∓ + PartlyRecoDecay, // 4 final state particles have another common b-hadron ancestor + OtherDecay, + NDecayTypeMc }; // counter of differentiated MC decay types } // namespace hf_cand_bs @@ -1668,8 +1854,6 @@ DECLARE_SOA_TABLE(HfCandBsBase, "AOD", "HFCANDBSBASE", hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1, hf_cand::ImpactParameter0, hf_cand::ImpactParameter1, hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1, - hf_cand_bs::Prong0Id, hf_track_index::Prong1Id, - hf_track_index::HFflag, /* dynamic columns */ hf_cand_2prong::M, hf_cand_2prong::M2, @@ -1691,13 +1875,17 @@ DECLARE_SOA_TABLE(HfCandBsBase, "AOD", "HFCANDBSBASE", hf_cand::Phi, hf_cand::Y, hf_cand::E, - hf_cand::E2); + hf_cand::E2, + o2::soa::Marker<1>); // extended table with expression columns that can be used as arguments of dynamic columns DECLARE_SOA_EXTENDED_TABLE_USER(HfCandBsExt, HfCandBsBase, "HFCANDBSEXT", hf_cand_2prong::Px, hf_cand_2prong::Py, hf_cand_2prong::Pz); -using HfCandBs = HfCandBsExt; +DECLARE_SOA_TABLE(HfCandBsProngs, "AOD", "HFCANDBSPRONGS", + hf_cand_bs::Prong0Id, hf_track_index::Prong1Id); + +using HfCandBs = soa::Join; // table with results of reconstruction level MC matching DECLARE_SOA_TABLE(HfCandBsMcRec, "AOD", "HFCANDBSMCREC", diff --git a/PWGHF/DataModel/CandidateSelectionTables.h b/PWGHF/DataModel/CandidateSelectionTables.h index e5b38f39493..583c30a5de2 100644 --- a/PWGHF/DataModel/CandidateSelectionTables.h +++ b/PWGHF/DataModel/CandidateSelectionTables.h @@ -308,6 +308,7 @@ DECLARE_SOA_COLUMN(MlProbXicToPKPi, mlProbXicToPKPi, std::vector); //! 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); //! } // namespace hf_sel_candidate_xic DECLARE_SOA_TABLE(HfSelXicToPKPi, "AOD", "HFSELXIC", //! @@ -317,6 +318,8 @@ DECLARE_SOA_TABLE(HfMlXicToPKPi, "AOD", "HFMLXIC", //! // XicPlus to Xi Pi Pi DECLARE_SOA_TABLE(HfSelXicToXiPiPi, "AOD", "HFSELXICTOXI2PI", //! hf_sel_candidate_xic::IsSelXicToXiPiPi); +DECLARE_SOA_TABLE(HfMlXicToXiPiPi, "AOD", "HFMLXICTOXI2PI", //! + hf_sel_candidate_xic::MlProbXicToXiPiPi); namespace hf_sel_candidate_xicc { @@ -375,6 +378,9 @@ DECLARE_SOA_COLUMN(TofNSigmaPiFromLambda, tofNSigmaPiFromLambda, float); DECLARE_SOA_COLUMN(TofNSigmaPrFromLambda, tofNSigmaPrFromLambda, float); 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", @@ -384,6 +390,8 @@ 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(HfMlSelOmegacToOmegaPi, "AOD", "HFMLOMEGAC", //! + hf_sel_toomegapi::MlProbOmegac, hf_sel_toomegapi::MlProbOmegacBar); namespace hf_sel_toomegaka { DECLARE_SOA_COLUMN(StatusPidLambda, statusPidLambda, bool); diff --git a/PWGHF/DataModel/DerivedTables.h b/PWGHF/DataModel/DerivedTables.h index 9fb45596145..441d412ea2f 100644 --- a/PWGHF/DataModel/DerivedTables.h +++ b/PWGHF/DataModel/DerivedTables.h @@ -18,19 +18,32 @@ #include -#include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" #include "Common/Core/RecoDecay.h" +#include "PWGLF/DataModel/mcCentrality.h" + #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" namespace o2::aod { -constexpr uint MarkerD0 = 1; -constexpr uint Marker3P = 2; +// basic species: +// D0 -> K- + pi+ (done) +// Lc -> pi+ K- p (existing 3P table to be renamed Lc) +// D+ -> K- + pi+ + pi+ (3P table with adapted PID columns) +// Ds+ -> K- + K+ + pi+ (3P table with adapted PID columns) +// composite species +// B0 -> D- + pi+ +// B+ -> D0 + pi+ (in progress) +// D*+ -> D0 + pi+ +constexpr uint MarkerBase = 2; +constexpr uint MarkerD0 = 3; +constexpr uint Marker3P = 4; +constexpr uint MarkerBplus = 5; +constexpr uint MarkerB0 = 6; // ================ // Collision tables @@ -39,61 +52,86 @@ constexpr uint Marker3P = 2; // Basic collision properties namespace hf_coll_base { -DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int8_t); //! collision rejection flag -DECLARE_SOA_COLUMN(MultFT0M, multFT0M, float); //! FT0M multiplicity -DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); //! FT0A centrality percentile -DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); //! FT0C centrality percentile -DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); //! FT0M centrality percentile -DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); //! FT0A centrality percentile -DECLARE_SOA_COLUMN(CentFDDM, centFDDM, float); //! FDDM centrality percentile +DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int8_t); //! collision rejection flag +DECLARE_SOA_COLUMN(MultFT0M, multFT0M, float); //! FT0M multiplicity +DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); //! FT0A centrality percentile +DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); //! FT0C centrality percentile +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); //! FT0M centrality percentile +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); //! FV0A centrality percentile +DECLARE_SOA_COLUMN(CentFDDM, centFDDM, float); //! FDDM centrality percentile DECLARE_SOA_COLUMN(MultZeqNTracksPV, multZeqNTracksPV, float); //! z-equalised barrel multiplicity } // namespace hf_coll_base -// D0 - -DECLARE_SOA_TABLE(HfD0CollBases, "AOD", "HFD0COLLBASE", //! Table with basic collision info - o2::soa::Index<>, - collision::PosX, - collision::PosY, - collision::PosZ, - collision::NumContrib, - hf_coll_base::CentFT0A, - hf_coll_base::CentFT0C, - hf_coll_base::CentFT0M, - hf_coll_base::CentFV0A, - hf_coll_base::MultZeqNTracksPV, - // hf_coll_base::IsEventReject, - // bc::RunNumber, - soa::Marker); +// base + +DECLARE_SOA_TABLE_STAGED(HfCollBases, "HFCOLLBASE", //! Table with basic collision info + o2::soa::Index<>, + collision::PosX, + collision::PosY, + collision::PosZ, + collision::NumContrib, + hf_coll_base::CentFT0A, + hf_coll_base::CentFT0C, + hf_coll_base::CentFT0M, + hf_coll_base::CentFV0A, + hf_coll_base::MultZeqNTracksPV, + // hf_coll_base::IsEventReject, + // bc::RunNumber, + o2::soa::Marker); + +using HfCollBase = HfCollBases::iterator; + +DECLARE_SOA_TABLE_STAGED(HfCollIds, "HFCOLLID", //! Table with original global indices of collisions + hf_cand::CollisionId, + o2::soa::Marker); + +// D0 (to be replaced by base version) + +DECLARE_SOA_TABLE_STAGED(HfD0CollBases, "HFD0COLLBASE", //! Table with basic collision info + o2::soa::Index<>, + collision::PosX, + collision::PosY, + collision::PosZ, + collision::NumContrib, + hf_coll_base::CentFT0A, + hf_coll_base::CentFT0C, + hf_coll_base::CentFT0M, + hf_coll_base::CentFV0A, + hf_coll_base::MultZeqNTracksPV, + // hf_coll_base::IsEventReject, + // bc::RunNumber, + o2::soa::Marker); using HfD0CollBase = HfD0CollBases::iterator; - -DECLARE_SOA_TABLE(HfD0CollIds, "AOD", "HFD0COLLID", //! Table with original global indices of collisions - hf_cand::CollisionId, - soa::Marker); - -// 3-prong decays - -DECLARE_SOA_TABLE(Hf3PCollBases, "AOD", "HF3PCOLLBASE", //! Table with basic collision info - o2::soa::Index<>, - collision::PosX, - collision::PosY, - collision::PosZ, - collision::NumContrib, - hf_coll_base::CentFT0A, - hf_coll_base::CentFT0C, - hf_coll_base::CentFT0M, - hf_coll_base::CentFV0A, - hf_coll_base::MultZeqNTracksPV, - // hf_coll_base::IsEventReject, - // bc::RunNumber, - soa::Marker); +using StoredHfD0CollBase = StoredHfD0CollBases::iterator; + +DECLARE_SOA_TABLE_STAGED(HfD0CollIds, "HFD0COLLID", //! Table with original global indices of collisions + hf_cand::CollisionId, + o2::soa::Marker); + +// 3-prong decays (to be replaced by base version) + +DECLARE_SOA_TABLE_STAGED(Hf3PCollBases, "HF3PCOLLBASE", //! Table with basic collision info + o2::soa::Index<>, + collision::PosX, + collision::PosY, + collision::PosZ, + collision::NumContrib, + hf_coll_base::CentFT0A, + hf_coll_base::CentFT0C, + hf_coll_base::CentFT0M, + hf_coll_base::CentFV0A, + hf_coll_base::MultZeqNTracksPV, + // hf_coll_base::IsEventReject, + // bc::RunNumber, + o2::soa::Marker); using Hf3PCollBase = Hf3PCollBases::iterator; +using StoredHf3PCollBase = StoredHf3PCollBases::iterator; -DECLARE_SOA_TABLE(Hf3PCollIds, "AOD", "HF3PCOLLID", //! Table with original global indices of collisions - hf_cand::CollisionId, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PCollIds, "HF3PCOLLID", //! Table with original global indices of collisions + hf_cand::CollisionId, + o2::soa::Marker); // =================== // MC collision tables @@ -102,7 +140,8 @@ DECLARE_SOA_TABLE(Hf3PCollIds, "AOD", "HF3PCOLLID", //! Table with original glob // MC collision columns namespace hf_mc_coll { -DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! original global index of the MC collision +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! original global index of the MC collision +DECLARE_SOA_ARRAY_INDEX_COLUMN(HfCollBase, hfCollBases); //! collision index array pointing to the derived reconstructed collisions for D0 candidates namespace der_d0 { DECLARE_SOA_ARRAY_INDEX_COLUMN(HfD0CollBase, hfCollBases); //! collision index array pointing to the derived reconstructed collisions for D0 candidates @@ -113,41 +152,62 @@ DECLARE_SOA_ARRAY_INDEX_COLUMN(Hf3PCollBase, hfCollBases); //! collision index a } } // namespace hf_mc_coll -// DO +// base + +DECLARE_SOA_TABLE_STAGED(HfMcCollBases, "HFMCCOLLBASE", //! Table with basic MC collision info + o2::soa::Index<>, + mccollision::PosX, + mccollision::PosY, + mccollision::PosZ, + o2::soa::Marker); -DECLARE_SOA_TABLE(HfD0McCollBases, "AOD", "HFD0MCCOLLBASE", //! Table with basic MC collision info - o2::soa::Index<>, - mccollision::PosX, - mccollision::PosY, - mccollision::PosZ, - soa::Marker); +using HfMcCollBase = HfMcCollBases::iterator; + +DECLARE_SOA_TABLE_STAGED(HfMcCollIds, "HFMCCOLLID", //! Table with original global indices of MC collisions + hf_mc_coll::McCollisionId, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfMcRCollIds, "HFMCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table + hf_mc_coll::HfCollBaseIds); + +// D0 + +DECLARE_SOA_TABLE_STAGED(HfD0McCollBases, "HFD0MCCOLLBASE", //! Table with basic MC collision info + o2::soa::Index<>, + mccollision::PosX, + mccollision::PosY, + mccollision::PosZ, + o2::soa::Marker); using HfD0McCollBase = HfD0McCollBases::iterator; +using StoredHfD0McCollBase = StoredHfD0McCollBases::iterator; -DECLARE_SOA_TABLE(HfD0McCollIds, "AOD", "HFD0MCCOLLID", //! Table with original global indices of MC collisions - hf_mc_coll::McCollisionId, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(HfD0McCollIds, "HFD0MCCOLLID", //! Table with original global indices of MC collisions + hf_mc_coll::McCollisionId, + o2::soa::Marker); -DECLARE_SOA_TABLE(HfD0McRCollIds, "AOD", "HFD0MCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table - hf_mc_coll::der_d0::HfD0CollBaseIds); +DECLARE_SOA_TABLE_STAGED(HfD0McRCollIds, "HFD0MCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table + hf_mc_coll::der_d0::HfD0CollBaseIds); // 3-prong decays -DECLARE_SOA_TABLE(Hf3PMcCollBases, "AOD", "HF3PMCCOLLBASE", //! Table with basic MC collision info - o2::soa::Index<>, - mccollision::PosX, - mccollision::PosY, - mccollision::PosZ, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PMcCollBases, "HF3PMCCOLLBASE", //! Table with basic MC collision info + o2::soa::Index<>, + mccollision::PosX, + mccollision::PosY, + mccollision::PosZ, + cent::CentFT0M, + o2::soa::Marker); using Hf3PMcCollBase = Hf3PMcCollBases::iterator; +using StoredHf3PMcCollBase = StoredHf3PMcCollBases::iterator; -DECLARE_SOA_TABLE(Hf3PMcCollIds, "AOD", "HF3PMCCOLLID", //! Table with original global indices of MC collisions - hf_mc_coll::McCollisionId, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PMcCollIds, "HF3PMCCOLLID", //! Table with original global indices of MC collisions + hf_mc_coll::McCollisionId, + o2::soa::Marker); -DECLARE_SOA_TABLE(Hf3PMcRCollIds, "AOD", "HF3PMCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table - hf_mc_coll::der_3p::Hf3PCollBaseIds); +DECLARE_SOA_TABLE_STAGED(Hf3PMcRCollIds, "HF3PMCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table + hf_mc_coll::der_3p::Hf3PCollBaseIds); // ================ // Candidate tables @@ -160,6 +220,10 @@ namespace der_d0 { DECLARE_SOA_INDEX_COLUMN(HfD0CollBase, hfCollBase); //! collision index pointing to the derived collision table for D0 candidates } +namespace der_bplus +{ +DECLARE_SOA_INDEX_COLUMN(HfCollBase, hfCollBase); //! collision index pointing to the derived collision table for B+ candidates +} namespace der_3p { DECLARE_SOA_INDEX_COLUMN(Hf3PCollBase, hfCollBase); //! collision index pointing to the derived collision table for 3-prong candidates @@ -206,9 +270,13 @@ DECLARE_SOA_COLUMN(RSecondaryVertex, rSecondaryVertex, float); DECLARE_SOA_COLUMN(NSigTofKa0, nSigTofKa0, float); DECLARE_SOA_COLUMN(NSigTofKa1, nSigTofKa1, float); DECLARE_SOA_COLUMN(NSigTofKa2, nSigTofKa2, float); +DECLARE_SOA_COLUMN(NSigTofKaExpPi, nSigTofKaExpPi, float); +DECLARE_SOA_COLUMN(NSigTofKaExpKa, nSigTofKaExpKa, float); DECLARE_SOA_COLUMN(NSigTofPi0, nSigTofPi0, float); DECLARE_SOA_COLUMN(NSigTofPi1, nSigTofPi1, float); DECLARE_SOA_COLUMN(NSigTofPi2, nSigTofPi2, float); +DECLARE_SOA_COLUMN(NSigTofPiExpPi, nSigTofPiExpPi, float); +DECLARE_SOA_COLUMN(NSigTofPiExpKa, nSigTofPiExpKa, float); DECLARE_SOA_COLUMN(NSigTofPr0, nSigTofPr0, float); DECLARE_SOA_COLUMN(NSigTofPr1, nSigTofPr1, float); DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); @@ -216,9 +284,13 @@ DECLARE_SOA_COLUMN(NSigTofPr2, nSigTofPr2, float); DECLARE_SOA_COLUMN(NSigTpcKa0, nSigTpcKa0, float); DECLARE_SOA_COLUMN(NSigTpcKa1, nSigTpcKa1, float); DECLARE_SOA_COLUMN(NSigTpcKa2, nSigTpcKa2, float); +DECLARE_SOA_COLUMN(NSigTpcKaExpPi, nSigTpcKaExpPi, float); +DECLARE_SOA_COLUMN(NSigTpcKaExpKa, nSigTpcKaExpKa, float); DECLARE_SOA_COLUMN(NSigTpcPi0, nSigTpcPi0, float); DECLARE_SOA_COLUMN(NSigTpcPi1, nSigTpcPi1, float); DECLARE_SOA_COLUMN(NSigTpcPi2, nSigTpcPi2, float); +DECLARE_SOA_COLUMN(NSigTpcPiExpPi, nSigTpcPiExpPi, float); +DECLARE_SOA_COLUMN(NSigTpcPiExpKa, nSigTpcPiExpKa, float); DECLARE_SOA_COLUMN(NSigTpcPr0, nSigTpcPr0, float); DECLARE_SOA_COLUMN(NSigTpcPr1, nSigTpcPr1, float); DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); @@ -226,14 +298,89 @@ DECLARE_SOA_COLUMN(NSigTpcPr2, nSigTpcPr2, float); DECLARE_SOA_COLUMN(NSigTpcTofKa0, nSigTpcTofKa0, float); DECLARE_SOA_COLUMN(NSigTpcTofKa1, nSigTpcTofKa1, float); DECLARE_SOA_COLUMN(NSigTpcTofKa2, nSigTpcTofKa2, float); +DECLARE_SOA_COLUMN(NSigTpcTofKaExpPi, nSigTpcTofKaExpPi, float); +DECLARE_SOA_COLUMN(NSigTpcTofKaExpKa, nSigTpcTofKaExpKa, float); DECLARE_SOA_COLUMN(NSigTpcTofPi0, nSigTpcTofPi0, float); DECLARE_SOA_COLUMN(NSigTpcTofPi1, nSigTpcTofPi1, float); DECLARE_SOA_COLUMN(NSigTpcTofPi2, nSigTpcTofPi2, float); +DECLARE_SOA_COLUMN(NSigTpcTofPiExpPi, nSigTpcTofPiExpPi, float); +DECLARE_SOA_COLUMN(NSigTpcTofPiExpKa, nSigTpcTofPiExpKa, float); DECLARE_SOA_COLUMN(NSigTpcTofPr0, nSigTpcTofPr0, float); DECLARE_SOA_COLUMN(NSigTpcTofPr1, nSigTpcTofPr1, float); DECLARE_SOA_COLUMN(NSigTpcTofPr2, nSigTpcTofPr2, float); } // namespace hf_cand_par +// Candidate properties of the charm daughter candidate used for selection of the beauty candidate +// Copy of hf_cand_par with "Charm" suffix to make it joinable with the beauty candidate table. +// 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(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 +DECLARE_SOA_COLUMN(CtCharm, ctCharm, float); //! proper lifetime times c +DECLARE_SOA_COLUMN(DecayLengthCharm, decayLengthCharm, float); //! decay length +DECLARE_SOA_COLUMN(DecayLengthNormalisedCharm, decayLengthNormalisedCharm, float); //! decay length divided by its uncertainty +DECLARE_SOA_COLUMN(DecayLengthXYCharm, decayLengthXYCharm, float); //! decay length in the transverse plane +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(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(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 +DECLARE_SOA_COLUMN(PtProng0Charm, ptProng0Charm, float); //! transverse momentum of prong 0 +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 +// TOF +DECLARE_SOA_COLUMN(NSigTofKa0Charm, nSigTofKa0Charm, float); +DECLARE_SOA_COLUMN(NSigTofKa1Charm, nSigTofKa1Charm, float); +DECLARE_SOA_COLUMN(NSigTofKa2Charm, nSigTofKa2Charm, float); +DECLARE_SOA_COLUMN(NSigTofKaExpPiCharm, nSigTofKaExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTofKaExpKaCharm, nSigTofKaExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTofPi0Charm, nSigTofPi0Charm, float); +DECLARE_SOA_COLUMN(NSigTofPi1Charm, nSigTofPi1Charm, float); +DECLARE_SOA_COLUMN(NSigTofPi2Charm, nSigTofPi2Charm, float); +DECLARE_SOA_COLUMN(NSigTofPiExpPiCharm, nSigTofPiExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTofPiExpKaCharm, nSigTofPiExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTofPr0Charm, nSigTofPr0Charm, float); +DECLARE_SOA_COLUMN(NSigTofPr1Charm, nSigTofPr1Charm, float); +DECLARE_SOA_COLUMN(NSigTofPr2Charm, nSigTofPr2Charm, float); +// TPC +DECLARE_SOA_COLUMN(NSigTpcKa0Charm, nSigTpcKa0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcKa1Charm, nSigTpcKa1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcKa2Charm, nSigTpcKa2Charm, float); +DECLARE_SOA_COLUMN(NSigTpcKaExpPiCharm, nSigTpcKaExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTpcKaExpKaCharm, nSigTpcKaExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTpcPi0Charm, nSigTpcPi0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcPi1Charm, nSigTpcPi1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcPi2Charm, nSigTpcPi2Charm, float); +DECLARE_SOA_COLUMN(NSigTpcPiExpPiCharm, nSigTpcPiExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTpcPiExpKaCharm, nSigTpcPiExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTpcPr0Charm, nSigTpcPr0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcPr1Charm, nSigTpcPr1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcPr2Charm, nSigTpcPr2Charm, float); +// TPC+TOF +DECLARE_SOA_COLUMN(NSigTpcTofKa0Charm, nSigTpcTofKa0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofKa1Charm, nSigTpcTofKa1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofKa2Charm, nSigTpcTofKa2Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofKaExpPiCharm, nSigTpcTofKaExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTpcTofKaExpKaCharm, nSigTpcTofKaExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi0Charm, nSigTpcTofPi0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi1Charm, nSigTpcTofPi1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPi2Charm, nSigTpcTofPi2Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPiExpPiCharm, nSigTpcTofPiExpPiCharm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPiExpKaCharm, nSigTpcTofPiExpKaCharm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr0Charm, nSigTpcTofPr0Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr1Charm, nSigTpcTofPr1Charm, float); +DECLARE_SOA_COLUMN(NSigTpcTofPr2Charm, nSigTpcTofPr2Charm, float); +} // namespace hf_cand_par_charm + // Candidate selection flags namespace hf_cand_sel { @@ -247,203 +394,317 @@ DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); //! flag for DECLARE_SOA_COLUMN(OriginMcRec, originMcRec, int8_t); //! particle origin, reconstruction level DECLARE_SOA_COLUMN(IsCandidateSwapped, isCandidateSwapped, int8_t); //! swapping of the prongs order DECLARE_SOA_COLUMN(FlagMcDecayChanRec, flagMcDecayChanRec, int8_t); //! resonant decay channel flag, reconstruction level +DECLARE_SOA_COLUMN(MlScoreSig, mlScoreSig, float); //! ML score for signal class DECLARE_SOA_COLUMN(MlScoreBkg, mlScoreBkg, float); //! ML score for background class DECLARE_SOA_COLUMN(MlScorePrompt, mlScorePrompt, float); //! ML score for prompt class DECLARE_SOA_COLUMN(MlScoreNonPrompt, mlScoreNonPrompt, float); //! ML score for non-prompt class DECLARE_SOA_COLUMN(MlScores, mlScores, std::vector); //! vector of ML scores } // namespace hf_cand_mc +// Candidate MC columns of the charm daughter +namespace hf_cand_mc_charm +{ +DECLARE_SOA_COLUMN(FlagMcMatchRecCharm, flagMcMatchRecCharm, int8_t); //! flag for reconstruction level matching +DECLARE_SOA_COLUMN(OriginMcRecCharm, originMcRecCharm, int8_t); //! particle origin, reconstruction level +DECLARE_SOA_COLUMN(IsCandidateSwappedCharm, isCandidateSwappedCharm, int8_t); //! swapping of the prongs order +DECLARE_SOA_COLUMN(FlagMcDecayChanRecCharm, flagMcDecayChanRecCharm, int8_t); //! resonant decay channel flag, reconstruction level +DECLARE_SOA_COLUMN(MlScoreSigCharm, mlScoreSigCharm, float); //! ML score for signal class +DECLARE_SOA_COLUMN(MlScoreBkgCharm, mlScoreBkgCharm, float); //! ML score for background class +DECLARE_SOA_COLUMN(MlScorePromptCharm, mlScorePromptCharm, float); //! ML score for prompt class +DECLARE_SOA_COLUMN(MlScoreNonPromptCharm, mlScoreNonPromptCharm, float); //! ML score for non-prompt class +DECLARE_SOA_COLUMN(MlScoresCharm, mlScoresCharm, std::vector); //! vector of ML scores +} // namespace hf_cand_mc_charm + // D0 -DECLARE_SOA_TABLE(HfD0Bases, "AOD", "HFD0BASE", //! Table with basic candidate properties used in the analyses - o2::soa::Index<>, - hf_cand_base::der_d0::HfD0CollBaseId, - 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, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(HfD0Bases, "HFD0BASE", //! Table with basic candidate properties used in the analyses + o2::soa::Index<>, + hf_cand_base::der_d0::HfD0CollBaseId, + 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); // 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 -DECLARE_SOA_TABLE(HfD0Pars, "AOD", "HFD0PAR", //! 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::NSigTpcPi0, - hf_cand_par::NSigTpcKa0, - hf_cand_par::NSigTofPi0, - hf_cand_par::NSigTofKa0, - hf_cand_par::NSigTpcTofPi0, - hf_cand_par::NSigTpcTofKa0, - hf_cand_par::NSigTpcPi1, - hf_cand_par::NSigTpcKa1, - hf_cand_par::NSigTofPi1, - hf_cand_par::NSigTofKa1, - hf_cand_par::NSigTpcTofPi1, - hf_cand_par::NSigTpcTofKa1, - hf_cand_par::MaxNormalisedDeltaIP, - hf_cand_par::ImpactParameterProduct, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0ParEs, "AOD", "HFD0PARE", //! 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::KfTopolChi2OverNdf, - hf_cand_par::RSecondaryVertex, - hf_cand_par::PProng0, - hf_cand_par::PProng1, - hf_cand::PxProng0, - hf_cand::PyProng0, - hf_cand::PzProng0, - hf_cand::PxProng1, - hf_cand::PyProng1, - hf_cand::PzProng1, - hf_cand::ErrorImpactParameter0, - hf_cand::ErrorImpactParameter1, - hf_cand_par::CosThetaStar, - hf_cand_par::Ct, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0Sels, "AOD", "HFD0SEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0Mls, "AOD", "HFD0ML", //! Table with candidate selection ML scores - hf_cand_mc::MlScores, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0Ids, "AOD", "HFD0ID", //! Table with original global indices for candidates - hf_cand::CollisionId, - hf_track_index::Prong0Id, - hf_track_index::Prong1Id, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0Mcs, "AOD", "HFD0MC", //! Table with MC candidate info - hf_cand_mc::FlagMcMatchRec, - hf_cand_mc::OriginMcRec, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(HfD0Pars, "HFD0PAR", //! 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::NSigTpcPiExpKa, + hf_cand_par::NSigTofPiExpKa, + hf_cand_par::NSigTpcTofPiExpKa, + hf_cand_par::NSigTpcKaExpKa, + hf_cand_par::NSigTofKaExpKa, + hf_cand_par::NSigTpcTofKaExpKa, + hf_cand_par::MaxNormalisedDeltaIP, + hf_cand_par::ImpactParameterProduct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfD0ParEs, "HFD0PARE", //! 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::KfTopolChi2OverNdf, + hf_cand_par::RSecondaryVertex, + hf_cand_par::PProng0, + hf_cand_par::PProng1, + hf_cand::PxProng0, + hf_cand::PyProng0, + hf_cand::PzProng0, + hf_cand::PxProng1, + hf_cand::PyProng1, + hf_cand::PzProng1, + hf_cand::ErrorImpactParameter0, + hf_cand::ErrorImpactParameter1, + hf_cand_par::CosThetaStar, + hf_cand_par::Ct, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfD0Sels, "HFD0SEL", //! Table with candidate selection flags + hf_cand_sel::CandidateSelFlag, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfD0Mls, "HFD0ML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfD0Ids, "HFD0ID", //! Table with original global indices for candidates + hf_cand::CollisionId, + hf_track_index::Prong0Id, + hf_track_index::Prong1Id, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfD0Mcs, "HFD0MC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + o2::soa::Marker); + +// B+ + +DECLARE_SOA_TABLE_STAGED(HfBplusBases, "HFBPBASE", //! Table with basic candidate properties used in the analyses + o2::soa::Index<>, + hf_cand_base::der_bplus::HfCollBaseId, + 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); + +// 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 +DECLARE_SOA_TABLE_STAGED(HfBplusPars, "HFBPPAR", //! 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(HfBplusParD0s, "HFBPPARD0", //! Table with D0 candidate properties used for selection of B+ + hf_cand_par_charm::CpaCharm, + hf_cand_par_charm::DecayLengthCharm, + hf_cand_par_charm::ImpactParameter0Charm, + hf_cand_par_charm::ImpactParameter1Charm, + hf_cand_par_charm::ImpactParameterProductCharm, + hf_cand_par_charm::NSigTpcPiExpPiCharm, + hf_cand_par_charm::NSigTofPiExpPiCharm, + hf_cand_par_charm::NSigTpcTofPiExpPiCharm, + hf_cand_par_charm::NSigTpcKaExpPiCharm, + hf_cand_par_charm::NSigTofKaExpPiCharm, + hf_cand_par_charm::NSigTpcTofKaExpPiCharm, + hf_cand_par_charm::NSigTpcPiExpKaCharm, + hf_cand_par_charm::NSigTofPiExpKaCharm, + hf_cand_par_charm::NSigTpcTofPiExpKaCharm, + hf_cand_par_charm::NSigTpcKaExpKaCharm, + hf_cand_par_charm::NSigTofKaExpKaCharm, + hf_cand_par_charm::NSigTpcTofKaExpKaCharm); + +DECLARE_SOA_TABLE_STAGED(HfBplusParEs, "HFBPPARE", //! 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(HfBplusMls, "HFBPML", //! Table with candidate selection ML scores + hf_cand_mc::MlScoreSig, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfBplusMlD0s, "HFBPMLD0", //! Table with D0 candidate selection ML scores + hf_cand_mc_charm::MlScoresCharm, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfBplusIds, "HFBPID", //! Table with original global indices for candidates + hf_cand::CollisionId, + hf_track_index::Prong0Id, // D0 prong 0 + hf_track_index::Prong1Id, // D0 prong 1 + hf_track_index::Prong2Id, // bachelor pion + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(HfBplusMcs, "HFBPMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + o2::soa::Marker); // 3-prong decays -DECLARE_SOA_TABLE(Hf3PBases, "AOD", "HF3PBASE", //! Table with basic candidate properties used in the analyses - o2::soa::Index<>, - hf_cand_base::der_3p::Hf3PCollBaseId, - 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, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PBases, "HF3PBASE", //! Table with basic candidate properties used in the analyses + o2::soa::Index<>, + hf_cand_base::der_3p::Hf3PCollBaseId, + 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); // 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 -DECLARE_SOA_TABLE(Hf3PPars, "AOD", "HF3PPAR", //! 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::NSigTpcPr0, - hf_cand_par::NSigTofPi0, - hf_cand_par::NSigTofPr0, - hf_cand_par::NSigTpcTofPi0, - hf_cand_par::NSigTpcTofPr0, - hf_cand_par::NSigTpcKa1, - hf_cand_par::NSigTofKa1, - hf_cand_par::NSigTpcTofKa1, - hf_cand_par::NSigTpcPi2, - hf_cand_par::NSigTpcPr2, - hf_cand_par::NSigTofPi2, - hf_cand_par::NSigTofPr2, - hf_cand_par::NSigTpcTofPi2, - hf_cand_par::NSigTpcTofPr2, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PParEs, "AOD", "HF3PPARE", //! 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, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PSels, "AOD", "HF3PSEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PMls, "AOD", "HF3PML", //! Table with candidate selection ML scores - hf_cand_mc::MlScores, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PIds, "AOD", "HF3PID", //! Table with original global indices for candidates - hf_cand::CollisionId, - hf_track_index::Prong0Id, - hf_track_index::Prong1Id, - hf_track_index::Prong2Id, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PMcs, "AOD", "HF3PMC", //! Table with MC candidate info - hf_cand_mc::FlagMcMatchRec, - hf_cand_mc::OriginMcRec, - hf_cand_mc::IsCandidateSwapped, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PPars, "HF3PPAR", //! 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::NSigTpcPr0, + hf_cand_par::NSigTofPi0, + hf_cand_par::NSigTofPr0, + hf_cand_par::NSigTpcTofPi0, + hf_cand_par::NSigTpcTofPr0, + hf_cand_par::NSigTpcKa1, + hf_cand_par::NSigTofKa1, + hf_cand_par::NSigTpcTofKa1, + hf_cand_par::NSigTpcPi2, + hf_cand_par::NSigTpcPr2, + hf_cand_par::NSigTofPi2, + hf_cand_par::NSigTofPr2, + hf_cand_par::NSigTpcTofPi2, + hf_cand_par::NSigTpcTofPr2, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(Hf3PParEs, "HF3PPARE", //! 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(Hf3PSels, "HF3PSEL", //! Table with candidate selection flags + hf_cand_sel::CandidateSelFlag, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(Hf3PMls, "HF3PML", //! Table with candidate selection ML scores + hf_cand_mc::MlScores, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(Hf3PIds, "HF3PID", //! Table with original global indices for candidates + hf_cand::CollisionId, + hf_track_index::Prong0Id, + hf_track_index::Prong1Id, + hf_track_index::Prong2Id, + o2::soa::Marker); + +DECLARE_SOA_TABLE_STAGED(Hf3PMcs, "HF3PMC", //! Table with MC candidate info + hf_cand_mc::FlagMcMatchRec, + hf_cand_mc::OriginMcRec, + hf_cand_mc::IsCandidateSwapped, + o2::soa::Marker); // ================== // MC particle tables @@ -452,12 +713,16 @@ DECLARE_SOA_TABLE(Hf3PMcs, "AOD", "HF3PMC", //! Table with MC candidate info // MC particle columns namespace hf_mc_particle { -DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! MC collision of this particle -DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle +DECLARE_SOA_INDEX_COLUMN(McCollision, mcCollision); //! MC collision of this particle +DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle namespace der_d0 { DECLARE_SOA_INDEX_COLUMN(HfD0McCollBase, hfMcCollBase); //! collision index pointing to the derived MC collision table for D0 candidates } +namespace der_bplus +{ +DECLARE_SOA_INDEX_COLUMN(HfMcCollBase, hfMcCollBase); //! collision index pointing to the derived MC collision table for B+ candidates +} namespace der_3p { DECLARE_SOA_INDEX_COLUMN(Hf3PMcCollBase, hfMcCollBase); //! collision index pointing to the derived MC collision table for 3-prong candidates @@ -469,47 +734,69 @@ DECLARE_SOA_COLUMN(FlagMcDecayChanGen, flagMcDecayChanGen, int8_t); //! resonant // D0 -DECLARE_SOA_TABLE(HfD0PBases, "AOD", "HFD0PBASE", //! Table with MC particle info - o2::soa::Index<>, - hf_mc_particle::der_d0::HfD0McCollBaseId, - 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, - soa::Marker); - -DECLARE_SOA_TABLE(HfD0PIds, "AOD", "HFD0PID", //! Table with original global indices for MC particles - hf_mc_particle::McCollisionId, - hf_mc_particle::McParticleId, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(HfD0PBases, "HFD0PBASE", //! Table with MC particle info + o2::soa::Index<>, + hf_mc_particle::der_d0::HfD0McCollBaseId, + 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); + +DECLARE_SOA_TABLE_STAGED(HfD0PIds, "HFD0PID", //! Table with original global indices for MC particles + hf_mc_particle::McCollisionId, + hf_mc_particle::McParticleId, + o2::soa::Marker); + +// B+ + +DECLARE_SOA_TABLE_STAGED(HfBplusPBases, "HFBPPBASE", //! Table with MC particle info + o2::soa::Index<>, + hf_mc_particle::der_bplus::HfMcCollBaseId, + 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); + +DECLARE_SOA_TABLE_STAGED(HfBplusPIds, "HFBPPID", //! Table with original global indices for MC particles + hf_mc_particle::McCollisionId, + hf_mc_particle::McParticleId, + o2::soa::Marker); // 3-prong decays -DECLARE_SOA_TABLE(Hf3PPBases, "AOD", "HF3PPBASE", //! Table with MC particle info - o2::soa::Index<>, - hf_mc_particle::der_3p::Hf3PMcCollBaseId, - 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, - soa::Marker); - -DECLARE_SOA_TABLE(Hf3PPIds, "AOD", "HF3PPID", //! Table with original global indices for MC particles - hf_mc_particle::McCollisionId, - hf_mc_particle::McParticleId, - soa::Marker); +DECLARE_SOA_TABLE_STAGED(Hf3PPBases, "HF3PPBASE", //! Table with MC particle info + o2::soa::Index<>, + hf_mc_particle::der_3p::Hf3PMcCollBaseId, + 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); + +DECLARE_SOA_TABLE_STAGED(Hf3PPIds, "HF3PPID", //! Table with original global indices for MC particles + hf_mc_particle::McCollisionId, + hf_mc_particle::McParticleId, + o2::soa::Marker); } // namespace o2::aod #endif // PWGHF_DATAMODEL_DERIVEDTABLES_H_ diff --git a/PWGHF/DataModel/DerivedTablesStored.h b/PWGHF/DataModel/DerivedTablesStored.h deleted file mode 100644 index 95d5cc0438f..00000000000 --- a/PWGHF/DataModel/DerivedTablesStored.h +++ /dev/null @@ -1,371 +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 DerivedTablesStored.h -/// \brief Definitions of stored versions of derived tables produced by derived-data creators (defined in DerivedTables.h) -/// \author Vít Kučera , Inha University -/// \note Things to check when comparing with DerivedTables.h: -/// - Prefix "Stored" in table definitions -/// - Prefix "Stored" in names of index columns pointing to derived tables -/// - Suffix "Stored" in Marker name -/// - Prefix "der_stored_" in namespace names (if needed to avoid redefinitions in "der_") -/// - Origin AOD1 - -#ifndef PWGHF_DATAMODEL_DERIVEDTABLESSTORED_H_ -#define PWGHF_DATAMODEL_DERIVEDTABLESSTORED_H_ - -#include "PWGHF/DataModel/DerivedTables.h" - -namespace o2::aod -{ -constexpr uint MarkerD0Stored = 10; -constexpr uint Marker3PStored = 20; - -// ================ -// Collision tables -// ================ - -// D0 - -DECLARE_SOA_TABLE(StoredHfD0CollBases, "AOD1", "HFD0COLLBASE", //! Table with basic collision info - o2::soa::Index<>, - collision::PosX, - collision::PosY, - collision::PosZ, - collision::NumContrib, - hf_coll_base::CentFT0A, - hf_coll_base::CentFT0C, - hf_coll_base::CentFT0M, - hf_coll_base::CentFV0A, - hf_coll_base::MultZeqNTracksPV, - // hf_coll_base::IsEventReject, - // bc::RunNumber, - soa::Marker); - -using StoredHfD0CollBase = StoredHfD0CollBases::iterator; - -DECLARE_SOA_TABLE(StoredHfD0CollIds, "AOD1", "HFD0COLLID", //! Table with original global indices of collisions - hf_cand::CollisionId, - soa::Marker); - -// 3-prong decays - -DECLARE_SOA_TABLE(StoredHf3PCollBases, "AOD1", "HF3PCOLLBASE", //! Table with basic collision info - o2::soa::Index<>, - collision::PosX, - collision::PosY, - collision::PosZ, - collision::NumContrib, - hf_coll_base::CentFT0A, - hf_coll_base::CentFT0C, - hf_coll_base::CentFT0M, - hf_coll_base::CentFV0A, - hf_coll_base::MultZeqNTracksPV, - // hf_coll_base::IsEventReject, - // bc::RunNumber, - soa::Marker); - -using StoredHf3PCollBase = StoredHf3PCollBases::iterator; - -DECLARE_SOA_TABLE(StoredHf3PCollIds, "AOD1", "HF3PCOLLID", //! Table with original global indices of collisions - hf_cand::CollisionId, - soa::Marker); - -// =================== -// MC collision tables -// =================== - -// DO - -DECLARE_SOA_TABLE(StoredHfD0McCollBases, "AOD1", "HFD0MCCOLLBASE", //! Table with basic MC collision info - o2::soa::Index<>, - mccollision::PosX, - mccollision::PosY, - mccollision::PosZ, - soa::Marker); - -using StoredHfD0McCollBase = StoredHfD0McCollBases::iterator; - -DECLARE_SOA_TABLE(StoredHfD0McCollIds, "AOD1", "HFD0MCCOLLID", //! Table with original global indices of MC collisions - hf_mc_coll::McCollisionId, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0McRCollIds, "AOD1", "HFD0MCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table - hf_mc_coll::der_d0::HfD0CollBaseIds, - soa::Marker); - -// 3-prong decays - -DECLARE_SOA_TABLE(StoredHf3PMcCollBases, "AOD1", "HF3PMCCOLLBASE", //! Table with basic MC collision info - o2::soa::Index<>, - mccollision::PosX, - mccollision::PosY, - mccollision::PosZ, - soa::Marker); - -using StoredHf3PMcCollBase = StoredHf3PMcCollBases::iterator; - -DECLARE_SOA_TABLE(StoredHf3PMcCollIds, "AOD1", "HF3PMCCOLLID", //! Table with original global indices of MC collisions - hf_mc_coll::McCollisionId, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PMcRCollIds, "AOD1", "HF3PMCRCOLLID", //! Table with indices pointing to the derived reconstructed-collision table - hf_mc_coll::der_3p::Hf3PCollBaseIds, - soa::Marker); - -// ================ -// Candidate tables -// ================ - -// Basic candidate properties - -// D0 - -DECLARE_SOA_TABLE(StoredHfD0Bases, "AOD1", "HFD0BASE", //! Table with basic candidate properties used in the analyses - o2::soa::Index<>, - hf_cand_base::der_d0::HfD0CollBaseId, - 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, - 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 -DECLARE_SOA_TABLE(StoredHfD0Pars, "AOD1", "HFD0PAR", //! 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::NSigTpcPi0, - hf_cand_par::NSigTpcKa0, - hf_cand_par::NSigTofPi0, - hf_cand_par::NSigTofKa0, - hf_cand_par::NSigTpcTofPi0, - hf_cand_par::NSigTpcTofKa0, - hf_cand_par::NSigTpcPi1, - hf_cand_par::NSigTpcKa1, - hf_cand_par::NSigTofPi1, - hf_cand_par::NSigTofKa1, - hf_cand_par::NSigTpcTofPi1, - hf_cand_par::NSigTpcTofKa1, - hf_cand_par::MaxNormalisedDeltaIP, - hf_cand_par::ImpactParameterProduct, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0ParEs, "AOD1", "HFD0PARE", //! 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::KfTopolChi2OverNdf, - hf_cand_par::RSecondaryVertex, - hf_cand_par::PProng0, - hf_cand_par::PProng1, - hf_cand::PxProng0, - hf_cand::PyProng0, - hf_cand::PzProng0, - hf_cand::PxProng1, - hf_cand::PyProng1, - hf_cand::PzProng1, - hf_cand::ErrorImpactParameter0, - hf_cand::ErrorImpactParameter1, - hf_cand_par::CosThetaStar, - hf_cand_par::Ct, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0Sels, "AOD1", "HFD0SEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0Mls, "AOD1", "HFD0ML", //! Table with candidate selection ML scores - hf_cand_mc::MlScores, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0Ids, "AOD1", "HFD0ID", //! Table with original global indices for candidates - hf_cand::CollisionId, - hf_track_index::Prong0Id, - hf_track_index::Prong1Id, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0Mcs, "AOD1", "HFD0MC", //! Table with MC candidate info - hf_cand_mc::FlagMcMatchRec, - hf_cand_mc::OriginMcRec, - soa::Marker); - -// 3-prong decays - -DECLARE_SOA_TABLE(StoredHf3PBases, "AOD1", "HF3PBASE", //! Table with basic candidate properties used in the analyses - o2::soa::Index<>, - hf_cand_base::der_3p::Hf3PCollBaseId, - 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, - 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 -DECLARE_SOA_TABLE(StoredHf3PPars, "AOD1", "HF3PPAR", //! 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::NSigTpcPr0, - hf_cand_par::NSigTofPi0, - hf_cand_par::NSigTofPr0, - hf_cand_par::NSigTpcTofPi0, - hf_cand_par::NSigTpcTofPr0, - hf_cand_par::NSigTpcKa1, - hf_cand_par::NSigTofKa1, - hf_cand_par::NSigTpcTofKa1, - hf_cand_par::NSigTpcPi2, - hf_cand_par::NSigTpcPr2, - hf_cand_par::NSigTofPi2, - hf_cand_par::NSigTofPr2, - hf_cand_par::NSigTpcTofPi2, - hf_cand_par::NSigTpcTofPr2, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PParEs, "AOD1", "HF3PPARE", //! 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, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PSels, "AOD1", "HF3PSEL", //! Table with candidate selection flags - hf_cand_sel::CandidateSelFlag, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PMls, "AOD1", "HF3PML", //! Table with candidate selection ML scores - hf_cand_mc::MlScores, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PIds, "AOD1", "HF3PID", //! Table with original global indices for candidates - hf_cand::CollisionId, - hf_track_index::Prong0Id, - hf_track_index::Prong1Id, - hf_track_index::Prong2Id, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PMcs, "AOD1", "HF3PMC", //! Table with MC candidate info - hf_cand_mc::FlagMcMatchRec, - hf_cand_mc::OriginMcRec, - hf_cand_mc::IsCandidateSwapped, - soa::Marker); - -// ================== -// MC particle tables -// ================== - -// D0 - -DECLARE_SOA_TABLE(StoredHfD0PBases, "AOD1", "HFD0PBASE", //! Table with MC particle info - o2::soa::Index<>, - hf_mc_particle::der_d0::HfD0McCollBaseId, - 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, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHfD0PIds, "AOD1", "HFD0PID", //! Table with original global indices for MC particles - hf_mc_particle::McCollisionId, - hf_mc_particle::McParticleId, - soa::Marker); - -// 3-prong decays - -DECLARE_SOA_TABLE(StoredHf3PPBases, "AOD1", "HF3PPBASE", //! Table with MC particle info - o2::soa::Index<>, - hf_mc_particle::der_3p::Hf3PMcCollBaseId, - 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, - soa::Marker); - -DECLARE_SOA_TABLE(StoredHf3PPIds, "AOD1", "HF3PPID", //! Table with original global indices for MC particles - hf_mc_particle::McCollisionId, - hf_mc_particle::McParticleId, - soa::Marker); -} // namespace o2::aod - -#endif // PWGHF_DATAMODEL_DERIVEDTABLESSTORED_H_ diff --git a/PWGHF/HFC/DataModel/CorrelationTables.h b/PWGHF/HFC/DataModel/CorrelationTables.h index 0069d6b2161..4609b21df95 100644 --- a/PWGHF/HFC/DataModel/CorrelationTables.h +++ b/PWGHF/HFC/DataModel/CorrelationTables.h @@ -97,13 +97,14 @@ DECLARE_SOA_TABLE(DHadronRecoInfo, "AOD", "DHADRONRECOINFO", //! D0-Hadrons pair // 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(PtLc, ptLc, float); //! Transverse momentum of Lc -DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron -DECLARE_SOA_COLUMN(MLc, mLc, float); //! Invariant mass of Lc -DECLARE_SOA_COLUMN(SignalStatus, signalStatus, int); //! Tag for LcToPKPi/LcToPiKP -DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +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(PtLc, ptLc, float); //! Transverse momentum of Lc +DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron +DECLARE_SOA_COLUMN(MLc, mLc, float); //! Invariant mass of Lc +DECLARE_SOA_COLUMN(SignalStatus, signalStatus, int); //! Tag for LcToPKPi/LcToPiKP +DECLARE_SOA_COLUMN(PoolBin, poolBin, int); //! Pool Bin for the MixedEvent +DECLARE_SOA_COLUMN(IsAutoCorrelated, isAutoCorrelated, bool); //! Correlation Status } // namespace hf_correlation_lc_hadron DECLARE_SOA_TABLE(LcHadronPair, "AOD", "LCHPAIR", //! Lc-Hadrons pairs Informations @@ -111,7 +112,8 @@ DECLARE_SOA_TABLE(LcHadronPair, "AOD", "LCHPAIR", //! Lc-Hadrons pairs Informati aod::hf_correlation_lc_hadron::DeltaEta, aod::hf_correlation_lc_hadron::PtLc, aod::hf_correlation_lc_hadron::PtHadron, - aod::hf_correlation_lc_hadron::PoolBin); + aod::hf_correlation_lc_hadron::PoolBin, + aod::hf_correlation_lc_hadron::IsAutoCorrelated); DECLARE_SOA_TABLE(LcHadronRecoInfo, "AOD", "LCHRECOINFO", //! Lc-Hadrons pairs Reconstructed Informations aod::hf_correlation_lc_hadron::MLc, @@ -216,13 +218,23 @@ DECLARE_SOA_TABLE(Hadron, "AOD", "HADRON", //! Associated hadron properties // definition of columns and tables for Dplus-Hadron correlation pairs namespace hf_correlation_dplus_hadron { -DECLARE_SOA_COLUMN(DeltaPhi, deltaPhi, float); //! DeltaPhi between D+ and Hadrons -DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between D+ and Hadrons -DECLARE_SOA_COLUMN(PtD, ptD, float); //! Transverse momentum of D+ -DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron -DECLARE_SOA_COLUMN(MD, mD, float); //! Invariant mass of D+ -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(DeltaPhi, deltaPhi, float); //! DeltaPhi between D+ and Hadrons +DECLARE_SOA_COLUMN(DeltaEta, deltaEta, float); //! DeltaEta between D+ and Hadrons +DECLARE_SOA_COLUMN(PtD, ptD, float); //! Transverse momentum of D+ +DECLARE_SOA_COLUMN(PtHadron, ptHadron, float); //! Transverse momentum of Hadron +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(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 +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(TrackOrigin, trackOrigin, int); //! Number of crossed TPC Rows +DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); //! Used in MC-Rec, D+ Signal +DECLARE_SOA_COLUMN(IsDecayChan, isDecayChan, bool); //! Used in MC-Rec, D+ decay channel check +DECLARE_SOA_COLUMN(IsPrompt, isPrompt, bool); //! Used in MC-Rec, D+ Prompt or Non-Prompt +DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! Used in MC-Rec, primary associated particles } // namespace hf_correlation_dplus_hadron DECLARE_SOA_TABLE(DplusHadronPair, "AOD", "DPLUSHPAIR", //! D+-Hadrons pairs Informations @@ -236,6 +248,29 @@ DECLARE_SOA_TABLE(DplusHadronRecoInfo, "AOD", "DPLUSHRECOINFO", //! D+-Hadrons p aod::hf_correlation_dplus_hadron::MD, aod::hf_correlation_dplus_hadron::SignalStatus); +DECLARE_SOA_TABLE(DplusHadronGenInfo, "AOD", "DPLUSHGENINFO", //! Ds-Hadrons pairs Generated Information + aod::hf_correlation_dplus_hadron::IsPrompt, + aod::hf_correlation_dplus_hadron::IsPhysicalPrimary, + aod::hf_correlation_dplus_hadron::TrackOrigin); + +DECLARE_SOA_TABLE(DplusHadronMlInfo, "AOD", "DPLUSHMLINFO", //! D+-Hadrons pairs Machine Learning Information + aod::hf_correlation_dplus_hadron::MlScoreBkg, + aod::hf_correlation_dplus_hadron::MlScorePrompt); + +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); + +DECLARE_SOA_TABLE(DplusGenInfo, "AOD", "DPLUSGENOINFO", //! D+ candidates Generated Information + aod::hf_correlation_dplus_hadron::IsPrompt); + +DECLARE_SOA_TABLE(TrkRecInfoDplus, "AOD", "TRKRECINFODPLUS", //! Tracks Reconstructed Information + aod::hf_correlation_dplus_hadron::TrackDcaXY, + aod::hf_correlation_dplus_hadron::TrackDcaZ, + aod::hf_correlation_dplus_hadron::TrackTPCNClsCrossedRows); + // definition of columns and tables for Dstar-Hadron correlation pair namespace hf_correlation_dstar_hadron { @@ -314,6 +349,22 @@ DECLARE_SOA_COLUMN(DmesonSel, dmesonSel, bool); //! Selection flag for D meson i DECLARE_SOA_TABLE(DmesonSelection, "AOD", "DINCOLL", // Selection of D meson in collisions aod::hf_selection_dmeson_collision::DmesonSel); + +// Note: definition of columns and tables for Electron Hadron correlation pairs +namespace hf_correlation_electron_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 +} // 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); } // namespace o2::aod #endif // PWGHF_HFC_DATAMODEL_CORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h new file mode 100644 index 00000000000..f8350111bdc --- /dev/null +++ b/PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h @@ -0,0 +1,70 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 DerivedDataCorrelations.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" + +namespace o2::aod +{ +namespace hf_collisions_reduced +{ +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, float); //! Event multiplicity +DECLARE_SOA_COLUMN(PosZ, posZ, float); //! Primary vertex z position + +} // namespace hf_collisions_reduced +DECLARE_SOA_TABLE(HfcRedCollisions, "AOD", "HFCREDCOLLISION", //! Table with collision info + soa::Index<>, + aod::hf_collisions_reduced::Multiplicity, + aod::hf_collisions_reduced::PosZ); + +using HfcRedCollision = HfcRedCollisions::iterator; + +// DECLARE_SOA_TABLE(HfCandColCounts, "AOD", "HFCANDCOLCOUNT", //! Table with number of collisions which contain at least one candidate +// aod::hf_collisions_reduced::OriginalCollisionCount); + +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 +} // namespace hf_candidate_reduced +DECLARE_SOA_TABLE(DsCandReduced, "AOD", "DSCANDREDUCED", //! Table with Ds candidate info (rectangular selection) + 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); + +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 +} // namespace hf_assoc_track_reduced +DECLARE_SOA_TABLE(AssocTrackRed, "AOD", "ASSOCTRACKRED", //! Table with associated track info + soa::Index<>, + aod::hf_candidate_reduced::HfcRedCollisionId, + aod::hf_assoc_track_reduced::PhiAssocTrack, + aod::hf_assoc_track_reduced::EtaAssocTrack, + aod::hf_assoc_track_reduced::PtAssocTrack) +} // namespace o2::aod + +#endif // PWGHF_HFC_DATAMODEL_DERIVEDDATACORRELATIONTABLES_H_ diff --git a/PWGHF/HFC/Macros/DhCorrelationFitter.cxx b/PWGHF/HFC/Macros/DhCorrelationFitter.cxx index d203c6ee63f..7e5157bb752 100644 --- a/PWGHF/HFC/Macros/DhCorrelationFitter.cxx +++ b/PWGHF/HFC/Macros/DhCorrelationFitter.cxx @@ -14,6 +14,12 @@ /// \author Samuele Cattaruzzi /// \author Swapnesh Santosh Khade +#include "DhCorrelationFitter.h" + +#include +#include +#include + #include #include #include @@ -34,10 +40,10 @@ #include #include #include -#include #include #include -#include "DhCorrelationFitter.h" + +using namespace std; DhCorrelationFitter::DhCorrelationFitter() : // default constructor fIsReflected(kFALSE), diff --git a/PWGHF/HFC/TableProducer/CMakeLists.txt b/PWGHF/HFC/TableProducer/CMakeLists.txt index 1a888dfc1d7..2b01aad32c6 100644 --- a/PWGHF/HFC/TableProducer/CMakeLists.txt +++ b/PWGHF/HFC/TableProducer/CMakeLists.txt @@ -49,6 +49,11 @@ o2physics_add_dpl_workflow(correlator-dstar-hadrons PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(correlator-hfe-hadrons + SOURCES correlatorHfeHadrons.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(correlator-lc-hadrons SOURCES correlatorLcHadrons.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx b/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx index 3fc2a915496..9ec7e5fc7c2 100644 --- a/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorD0Hadrons.cxx @@ -15,6 +15,8 @@ /// \author Samrangy Sadhu , INFN Bari /// \author Swapnesh Santosh Khade , IIT Indore +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -30,12 +32,14 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" using namespace o2; using namespace o2::analysis; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::analysis::hf_correlations; /// /// Returns deltaPhi value in range [-pi/2., 3.*pi/2], typically used for correlation studies @@ -176,7 +180,7 @@ struct HfCorrelatorD0Hadrons { Configurable applyEfficiency{"efficiencyFlagD", 1, "Flag for applying D-meson efficiency weights"}; Configurable multMin{"multMin", 0., "minimum multiplicity accepted"}; Configurable multMax{"multMax", 10000., "maximum multiplicity accepted"}; - Configurable ptSoftPionMax{"ptSoftPionMax", 3 * 800. * pow(10., -6.), "max. pT cut for soft pion identification"}; + Configurable ptSoftPionMax{"ptSoftPionMax", 3.f * 800.f * std::pow(10.f, -6.f), "max. pT cut for soft pion identification"}; Configurable correlateD0WithLeadingParticle{"correlateD0WithLeadingParticle", false, "Switch for correlation of D0 mesons with leading particle only"}; Configurable storeAutoCorrelationFlag{"storeAutoCorrelationFlag", false, "Store flag that indicates if the track is paired to its D-meson mother instead of skipping it"}; Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; @@ -264,22 +268,6 @@ struct HfCorrelatorD0Hadrons { 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})"}}}); } - // Find Leading Particle - template - int findLeadingParticle(TTracks const& tracks) - { - auto leadingParticle = tracks.begin(); - for (auto const& track : tracks) { - if (std::abs(track.dcaXY()) >= 1. || std::abs(track.dcaZ()) >= 1.) { - continue; - } - if (track.pt() > leadingParticle.pt()) { - leadingParticle = track; - } - } - int leadingIndex = leadingParticle.globalIndex(); - return leadingIndex; - } // ======= Process starts for Data, Same event ============ /// D0-h correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) @@ -293,7 +281,7 @@ struct HfCorrelatorD0Hadrons { } // find leading particle if (correlateD0WithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks); + leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); } int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); @@ -437,7 +425,7 @@ struct HfCorrelatorD0Hadrons { } // find leading particle if (correlateD0WithLeadingParticle) { - leadingIndex = findLeadingParticle(tracks); + leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); } int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); int nTracks = 0; @@ -559,7 +547,7 @@ struct HfCorrelatorD0Hadrons { if (track.globalIndex() != leadingIndex) { continue; } - registry.fill(HIST("hTrackCounter"), 4); // fill no. of tracks have leading particle + registry.fill(HIST("hTrackCounterRec"), 4); // fill no. of tracks have leading particle } int signalStatus = 0; @@ -605,6 +593,10 @@ struct HfCorrelatorD0Hadrons { { 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) { @@ -647,11 +639,23 @@ struct HfCorrelatorD0Hadrons { 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); - if (std::abs(particle2.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) - continue; + bool correlationStatus = false; + if (std::abs(particle2.pdgCode()) == kPiPlus && indexMotherPi >= 0 && indexMotherD0 >= 0 && indexMotherPi == indexMotherD0) { + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } registry.fill(HIST("hTrackCounterGen"), 3); // fill after soft pion removal + if (correlateD0WithLeadingParticle) { + if (particle2.globalIndex() != leadingIndex) { + continue; + } + registry.fill(HIST("hTrackCounterGen"), 4); // fill no. of tracks have leading particle + } + auto getTracksSize = [&mcParticles](aod::McCollision const& /*collision*/) { int nTracks = 0; for (const auto& track : mcParticles) { @@ -664,8 +668,6 @@ struct HfCorrelatorD0Hadrons { 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))); - - bool correlationStatus = false; entryD0HadronPair(getDeltaPhi(particle2.phi(), particle1.phi()), particle2.eta() - particle1.eta(), particle1.pt(), diff --git a/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx b/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx index 63827f2b89c..45ad4877388 100644 --- a/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDMesonPairs.cxx @@ -14,6 +14,9 @@ /// /// \author Andrea Tavira García , IJCLab Orsay +#include +#include + #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -53,7 +56,7 @@ using McParticlesPlus2Prong = soa::Join perCol2Prong = aod::hf_cand::collisionId; + Preslice perCol2Prong = aod::hf_cand::collisionId; Produces entryD0Pair; Produces entryD0PairMcInfo; @@ -62,6 +65,7 @@ struct HfCorrelatorDMesonPairs { Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection Flag for D0"}; Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection Flag for D0bar"}; + Configurable selectionFlagHf{"selectionFlagHf", 1, "Selection Flag for HF flagged candidates"}; Configurable yCandMax{"yCandMax", 0.8, "maxmum |y| of D0 candidates"}; Configurable ptCandMin{"ptCandMin", -1., "minimum pT of D0 candidates"}; Configurable> binsPt{"binsPt", std::vector{o2::analysis::hf_cuts_d0_to_pi_k::vecBinsPt}, "pT bin limits for candidate mass plots"}; @@ -71,15 +75,17 @@ struct HfCorrelatorDMesonPairs { HfHelper hfHelper; - using TracksWPid = soa::Join; + // 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::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; + 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; HistogramConfigSpec hTH1Pt{HistType::kTH1F, {{180, 0., 36.}}}; HistogramConfigSpec hTH1Y{HistType::kTH1F, {{100, -5., 5.}}}; + HistogramConfigSpec hTH1NContrib{HistType::kTH1F, {{120, -0.5, 119.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}}}; HistogramRegistry registry{ "registry", @@ -95,6 +101,11 @@ struct HfCorrelatorDMesonPairs { {"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}, + // 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}, // 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}, @@ -201,6 +212,9 @@ struct HfCorrelatorDMesonPairs { registry.add("hInputCheckD0OrD0barMcGen", "Check on input D0 | D0bar meson candidates/event MC Gen", {HistType::kTH1F, {axisInputD0}}); registry.add("hMass", "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("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})"}}}); } /// Sets bits to select candidate type for D0 @@ -281,23 +295,21 @@ struct HfCorrelatorDMesonPairs { template void AnalysePid(const T& candidate) { - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); if (candidate.isSelD0() >= selectionFlagD0) { - registry.fill(HIST("PID/hTofNSigmaPi"), candidate.ptProng0(), prong0.tofNSigmaPi()); - registry.fill(HIST("PID/hTofNSigmaKa"), candidate.ptProng1(), prong1.tofNSigmaKa()); - registry.fill(HIST("PID/hTpcNSigmaPi"), candidate.ptProng0(), prong0.tpcNSigmaPi()); - registry.fill(HIST("PID/hTpcNSigmaKa"), candidate.ptProng1(), prong1.tpcNSigmaKa()); - registry.fill(HIST("PID/hTpcTofNSigmaPi"), candidate.ptProng0(), prong0.tpcTofNSigmaPi()); - registry.fill(HIST("PID/hTpcTofNSigmaKa"), candidate.ptProng1(), prong1.tpcTofNSigmaKa()); + registry.fill(HIST("PID/hTofNSigmaPi"), candidate.ptProng0(), candidate.nSigTofPi0()); + registry.fill(HIST("PID/hTofNSigmaKa"), candidate.ptProng1(), candidate.nSigTofKa1()); + registry.fill(HIST("PID/hTpcNSigmaPi"), candidate.ptProng0(), candidate.nSigTpcPi0()); + registry.fill(HIST("PID/hTpcNSigmaKa"), candidate.ptProng1(), candidate.nSigTpcKa1()); + registry.fill(HIST("PID/hTpcTofNSigmaPi"), candidate.ptProng0(), candidate.tpcTofNSigmaPi0()); + registry.fill(HIST("PID/hTpcTofNSigmaKa"), candidate.ptProng1(), candidate.tpcTofNSigmaKa1()); } if (candidate.isSelD0bar() >= selectionFlagD0bar) { - registry.fill(HIST("PID/hTofNSigmaPi"), candidate.ptProng1(), prong1.tofNSigmaPi()); - registry.fill(HIST("PID/hTofNSigmaKa"), candidate.ptProng0(), prong0.tofNSigmaKa()); - registry.fill(HIST("PID/hTpcNSigmaPi"), candidate.ptProng1(), prong1.tpcNSigmaPi()); - registry.fill(HIST("PID/hTpcNSigmaKa"), candidate.ptProng0(), prong0.tpcNSigmaKa()); - registry.fill(HIST("PID/hTpcTofNSigmaPi"), candidate.ptProng1(), prong1.tpcTofNSigmaPi()); - registry.fill(HIST("PID/hTpcTofNSigmaKa"), candidate.ptProng0(), prong0.tpcTofNSigmaKa()); + registry.fill(HIST("PID/hTofNSigmaPi"), candidate.ptProng1(), candidate.nSigTofPi1()); + registry.fill(HIST("PID/hTofNSigmaKa"), candidate.ptProng0(), candidate.nSigTofKa0()); + registry.fill(HIST("PID/hTpcNSigmaPi"), candidate.ptProng1(), candidate.nSigTpcPi1()); + registry.fill(HIST("PID/hTpcNSigmaKa"), candidate.ptProng0(), candidate.nSigTpcKa0()); + registry.fill(HIST("PID/hTpcTofNSigmaPi"), candidate.ptProng1(), candidate.tpcTofNSigmaPi1()); + registry.fill(HIST("PID/hTpcTofNSigmaKa"), candidate.ptProng0(), candidate.tpcTofNSigmaKa0()); } } @@ -328,7 +340,6 @@ struct HfCorrelatorDMesonPairs { registry.fill(HIST("hPhi"), candidate.phi()); registry.fill(HIST("hY"), candidate.y(MassD0)); registry.fill(HIST("hPtCandAfterCut"), candidate.pt()); - registry.fill(HIST("hMass"), hfHelper.invMassD0ToPiK(candidate), candidate.pt()); bool isDCand1 = isD(candidateType1); bool isDbarCand1 = isDbar(candidateType1); @@ -370,11 +381,9 @@ struct HfCorrelatorDMesonPairs { } /// Fill selection status histogram - /// \param candidate1 is the first candidate of the pair - /// \param candidate2 is the second candidate of the pair - template - void fillEntry(const T& candidate1, const T& candidate2, const bool& isDCand1, const bool& isDbarCand1, - const bool& isDCand2, const bool& isDbarCand2, const uint8_t& candidateType1, const uint8_t& candidateType2) + 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, + double ptCand1, double ptCand2, float massDCand1, float massDbarCand1, float massDCand2, float massDbarCand2) { /// Fill information on the D candidates @@ -399,12 +408,6 @@ struct HfCorrelatorDMesonPairs { /// Collect information on the D pairs uint8_t pairType(0); registry.fill(HIST("hSelectionStatus"), 1); - float yCand1 = hfHelper.yD0(candidate1); - float yCand2 = hfHelper.yD0(candidate2); - float massDCand1 = hfHelper.invMassD0ToPiK(candidate1); - float massDbarCand1 = hfHelper.invMassD0barToKPi(candidate1); - float massDCand2 = hfHelper.invMassD0ToPiK(candidate2); - float massDbarCand2 = hfHelper.invMassD0barToKPi(candidate2); if (isDCand1 && isDCand2) { SETBIT(pairType, DD); registry.fill(HIST("hSelectionStatus"), 14); @@ -434,12 +437,12 @@ struct HfCorrelatorDMesonPairs { } } - entryD0Pair(candidate1.pt(), candidate2.pt(), yCand1, yCand2, massDCand1, massDbarCand1, massDCand2, massDbarCand2, pairType, candidateType1, candidateType2); + entryD0Pair(ptCand1, ptCand2, yCand1, yCand2, massDCand1, massDbarCand1, massDCand2, massDbarCand2, pairType, candidateType1, candidateType2); } /// 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, TracksWPid const&) + soa::Join const& candidates, aod::Tracks const&) { for (const auto& candidate : candidates) { AnalysePid(candidate); @@ -457,8 +460,8 @@ struct HfCorrelatorDMesonPairs { if (ptCandMin >= 0. && candidate1.pt() < ptCandMin) { continue; } - auto prong0Cand1 = candidate1.template prong0_as(); - auto prong1Cand1 = candidate1.template prong1_as(); + auto prong0Cand1 = candidate1.template prong0_as(); + auto prong1Cand1 = candidate1.template prong1_as(); bool isSignalD0Cand1 = std::abs(hfHelper.invMassD0ToPiK(candidate1) - MassD0) < massCut; bool isSignalD0barCand1 = std::abs(hfHelper.invMassD0barToKPi(candidate1) - MassD0Bar) < massCut; @@ -470,6 +473,13 @@ struct HfCorrelatorDMesonPairs { bool isDCand1 = isD(candidateType1); bool isDbarCand1 = isDbar(candidateType1); + if (isDCand1) { + registry.fill(HIST("hMass"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + } + if (isDbarCand1) { + registry.fill(HIST("hMass"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); + } + for (auto candidate2 = candidate1 + 1; candidate2 != selectedD0CandidatesGrouped.end(); ++candidate2) { if (abs(hfHelper.yD0(candidate2)) > yCandMax) { continue; @@ -477,8 +487,8 @@ struct HfCorrelatorDMesonPairs { if (ptCandMin >= 0. && candidate2.pt() < ptCandMin) { continue; } - auto prong0Cand2 = candidate2.template prong0_as(); - auto prong1Cand2 = candidate2.template prong1_as(); + auto prong0Cand2 = candidate2.template prong0_as(); + auto prong1Cand2 = candidate2.template prong1_as(); if (daughterTracksCutFlag && ((prong0Cand1 == prong0Cand2) || (prong1Cand1 == prong1Cand2) || (prong0Cand1 == prong1Cand2) || (prong1Cand1 == prong0Cand2))) { continue; } @@ -493,14 +503,16 @@ struct HfCorrelatorDMesonPairs { bool isDCand2 = isD(candidateType2); bool isDbarCand2 = isDbar(candidateType2); - fillEntry(candidate1, candidate2, isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, 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)); } // end inner loop (Cand2) - } // end outer loop (Cand1) + } // end outer loop (Cand1) } PROCESS_SWITCH(HfCorrelatorDMesonPairs, processData, "Process data mode", true); - void processMcRec(aod::Collision const& collision, soa::Join const& candidates, TracksWPid const&) + void processMcRec(aod::Collision const& collision, soa::Join const& candidates, aod::Tracks const&) { for (const auto& candidate : candidates) { AnalysePid(candidate); @@ -512,20 +524,27 @@ struct HfCorrelatorDMesonPairs { return; } for (const auto& candidate1 : selectedD0CandidatesGroupedMc) { + auto ptCandidate1 = candidate1.pt(); + auto yCandidate1 = hfHelper.yD0(candidate1); + 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) { continue; } if (ptCandMin >= 0. && candidate1.pt() < ptCandMin) { continue; } - auto prong0Cand1 = candidate1.template prong0_as(); - auto prong1Cand1 = candidate1.template prong1_as(); - - bool isSignalD0Cand1 = std::abs(hfHelper.invMassD0ToPiK(candidate1) - MassD0) < massCut; - bool isSignalD0barCand1 = std::abs(hfHelper.invMassD0barToKPi(candidate1) - MassD0Bar) < massCut; + bool isSignalD0Cand1 = std::abs(massD0Cand1 - MassD0) < massCut; + bool isSignalD0barCand1 = std::abs(massD0barCand1 - MassD0Bar) < massCut; if (selectSignalRegionOnly && !(isSignalD0Cand1 || isSignalD0barCand1)) { continue; } + if (!(candidate1.isSelD0() >= selectionFlagD0 || candidate1.isSelD0bar() >= selectionFlagD0bar)) { + continue; + } auto candidateType1 = assignCandidateTypeD0(candidate1); // Candidate type attribution @@ -543,22 +562,58 @@ struct HfCorrelatorDMesonPairs { registry.fill(HIST("hStatusSinglePart"), 6); } + if (isDCand1) { + 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) { + registry.fill(HIST("hMassMcRecPrompt"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + } else if (originRec1 == 2) { + registry.fill(HIST("hMassMcRecNonPrompt"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + } + } else if (isTrueDbarCand1) { + registry.fill(HIST("hMassMcRecReflections"), hfHelper.invMassD0ToPiK(candidate1), candidate1.pt()); + } + } + if (isDbarCand1) { + 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) { + registry.fill(HIST("hMassMcRecPrompt"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); + } else if (originRec1 == 2) { + registry.fill(HIST("hMassMcRecNonPrompt"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); + } + } else if (isTrueDCand1) { + registry.fill(HIST("hMassMcRecReflections"), hfHelper.invMassD0barToKPi(candidate1), candidate1.pt()); + } + } + for (auto candidate2 = candidate1 + 1; candidate2 != selectedD0CandidatesGroupedMc.end(); ++candidate2) { + auto ptCandidate2 = candidate2.pt(); + auto yCandidate2 = hfHelper.yD0(candidate2); + 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) { continue; } if (ptCandMin >= 0. && candidate2.pt() < ptCandMin) { continue; } - auto prong0Cand2 = candidate2.template prong0_as(); - auto prong1Cand2 = candidate2.template prong1_as(); - if (daughterTracksCutFlag && ((prong0Cand1 == prong0Cand2) || (prong1Cand1 == prong1Cand2) || (prong0Cand1 == prong1Cand2) || (prong1Cand1 == prong0Cand2))) { + bool isSignalD0Cand2 = std::abs(massD0Cand2 - MassD0) < massCut; + bool isSignalD0barCand2 = std::abs(massD0barCand2 - MassD0Bar) < massCut; + if (selectSignalRegionOnly && !(isSignalD0Cand2 || isSignalD0barCand2)) { continue; } - - bool isSignalD0Cand2 = std::abs(hfHelper.invMassD0ToPiK(candidate2) - MassD0) < massCut; - bool isSignalD0barCand2 = std::abs(hfHelper.invMassD0barToKPi(candidate2) - MassD0Bar) < massCut; - if (selectSignalRegionOnly && !(isSignalD0Cand2 || isSignalD0barCand2)) { + if (!(candidate2.isSelD0() >= selectionFlagD0 || candidate2.isSelD0bar() >= selectionFlagD0bar)) { + continue; + } + if (daughterTracksCutFlag && ((prong0Cand1 == prong0Cand2) || (prong1Cand1 == prong1Cand2) || (prong0Cand1 == prong1Cand2) || (prong1Cand1 == prong0Cand2))) { continue; } auto candidateType2 = assignCandidateTypeD0(candidate2); // Candidate type attribution @@ -609,16 +664,25 @@ struct HfCorrelatorDMesonPairs { } else if (isTrueDbarCand1 && isTrueDCand2) { registry.fill(HIST("hSelectionStatus"), 25); } - fillEntry(candidate1, candidate2, isDCand1, isDbarCand1, isDCand2, isDbarCand2, candidateType1, candidateType2); + 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) + } // end outer loop (Cand1) } PROCESS_SWITCH(HfCorrelatorDMesonPairs, processMcRec, "Process Mc reco mode", false); - void processMcGen(aod::McCollision const&, McParticlesPlus2Prong const& mcParticles) + void processMcGen(aod::McCollision const&, soa::SmallGroups> const& collisions, McParticlesPlus2Prong const& mcParticles) { + int numPvContributorsGen{0}; + for (const auto& collision : collisions) { // loop over reco collisions associated to this gen collision + int numPvContributors = collision.numContrib(); + + if (numPvContributors > numPvContributorsGen) { // we take the associated reconstructed collision with higher number of PV contributors + numPvContributorsGen = numPvContributors; + } + } // Get counters per event int nDevent = 0, nDbarevent = 0, nDDbarevent = 0, nDorDbarevent = 0; for (const auto& particle : mcParticles) { @@ -702,6 +766,9 @@ struct HfCorrelatorDMesonPairs { registry.fill(HIST("hStatusSinglePartMcGen"), 4); } + registry.fill(HIST("hPtVsYVsNContribMcGen"), particle1.pt(), particle1.y(), numPvContributorsGen); + registry.fill(HIST("hNContribMcGen"), numPvContributorsGen); + for (auto particle2 = particle1 + 1; particle2 != mcParticles.end(); ++particle2) { // check if the particle is D0 or D0bar if (std::abs(particle2.pdgCode()) != Pdg::kD0) { @@ -784,7 +851,7 @@ struct HfCorrelatorDMesonPairs { entryD0PairMcGenInfo(originGen1, originGen2, matchedGen1, matchedGen2); } // end inner loop - } // end outer loop + } // end outer loop } PROCESS_SWITCH(HfCorrelatorDMesonPairs, processMcGen, "Process D0 Mc Gen mode", false); diff --git a/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx index a079552b749..166ebb7eab8 100644 --- a/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDplusHadrons.cxx @@ -31,6 +31,7 @@ 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; @@ -45,61 +46,68 @@ double getDeltaPhi(double phiD, double phiHadron) const int npTBinsMassAndEfficiency = o2::analysis::hf_cuts_dplus_to_pi_k_pi::nBinsPt; std::vector efficiencyDmeson(npTBinsMassAndEfficiency + 1); -// histogram binning definition -const int massAxisBins = 350; -const double massAxisMin = 1.7; -const double massAxisMax = 2.05; -const int phiAxisBins = 32; -const double phiAxisMin = -o2::constants::math::PIHalf; -const double phiAxisMax = 3. * o2::constants::math::PIHalf; -const int yAxisBins = 100; -const double yAxisMin = -2.; -const double yAxisMax = 2.; -const int ptDAxisBins = 180; -const double ptDAxisMin = 0.; -const double ptDAxisMax = 36.; - // definition of ME variables using BinningType = ColumnBinningPolicy>; +using BinningTypeMcGen = ColumnBinningPolicy; // Code to select a Dmeson in a collision struct HfCorrelatorDplusHadronsDplusSelection { Produces dplusSel; - Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for Dplus"}; // 7 corresponds to topo+PID cuts + 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 doSelDplusCollision{"doSelDplusCollision", true, "Select collisions with at least one D+"}; + Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for D+"}; Configurable yCandMax{"yCandMax", 0.8, "max. cand. rapidity"}; Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; HfHelper hfHelper; SliceCache cache; + using SelCollisions = soa::Join; using CandidatesDplusData = soa::Filtered>; using CandidatesDplusMcRec = soa::Filtered>; + using CandDplusMcGen = soa::Join; + // filter on selection of Dplus meson and decay channel Dplus->KPiPi 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; - void processDplusSelectionData(aod::Collision const& /*collision*/, + void processDplusSelectionData(SelCollisions::iterator const& collision, CandidatesDplusData const& candidates) { - bool isDplusFound = 0; - if (candidates.size() > 0) { + bool isSelColl = true; + bool isDplusFound = true; + bool isSel8 = true; + bool isNosameBunchPileUp = true; + if (doSelDplusCollision) { for (const auto& candidate : candidates) { - if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin) { + if (std::abs(hfHelper.yDplus(candidate)) > yCandMax || candidate.pt() < ptCandMin) { + isDplusFound = false; continue; } - isDplusFound = 1; + isDplusFound = true; break; } } - dplusSel(isDplusFound); + if (useSel8) { + isSel8 = collision.sel8(); + } + if (selNoSameBunchPileUpColl) { + isNosameBunchPileUp = static_cast(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + } + isSelColl = isDplusFound && isSel8 && isNosameBunchPileUp; + dplusSel(isSelColl); } PROCESS_SWITCH(HfCorrelatorDplusHadronsDplusSelection, processDplusSelectionData, "Process Dplus Selection Data", false); - void processDplusSelectionMcRec(aod::Collision const& /*collision*/, + void processDplusSelectionMcRec(SelCollisions::iterator const& collision, CandidatesDplusMcRec const& candidates) { - bool isDplusFound = 0; - if (candidates.size() > 0) { + bool isSelColl = true; + bool isDplusFound = false; + bool isSel8 = true; + bool isNosameBunchPileUp = true; + if (doSelDplusCollision) { for (const auto& candidate : candidates) { if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin) { continue; @@ -108,12 +116,20 @@ struct HfCorrelatorDplusHadronsDplusSelection { break; } } - dplusSel(isDplusFound); + if (useSel8) { + isSel8 = collision.sel8(); + } + if (selNoSameBunchPileUpColl) { + isNosameBunchPileUp = static_cast(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)); + } + isSelColl = isDplusFound && isSel8 && isNosameBunchPileUp; + dplusSel(isSelColl); } + PROCESS_SWITCH(HfCorrelatorDplusHadronsDplusSelection, processDplusSelectionMcRec, "Process Dplus Selection MCRec", false); void processDplusSelectionMcGen(aod::McCollision const&, - aod::McParticles const& mcParticles) + CandDplusMcGen const& mcParticles) { bool isDplusFound = 0; for (const auto& particle1 : mcParticles) { @@ -136,103 +152,155 @@ struct HfCorrelatorDplusHadronsDplusSelection { struct HfCorrelatorDplusHadrons { Produces entryDplusHadronPair; Produces entryDplusHadronRecoInfo; + Produces entryDplusHadronMlInfo; + Produces entryDplusCandRecoInfo; + Produces entryDplusHadronGenInfo; + Produces entryDplusCandGenInfo; + Produces entryTrackRecoInfo; Produces entryDplus; Produces entryHadron; Configurable selectionFlagDplus{"selectionFlagDplus", 7, "Selection Flag for Dplus"}; // 7 corresponds to topo+PID cuts - Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying D-meson efficiency weights"}; - 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"}; + Configurable numberEventsMixed{"numberEventsMixed", 5, "Number of events mixed in ME process"}; + Configurable applyEfficiency{"applyEfficiency", true, "Flag for applying D-meson efficiency weights"}; + Configurable removeDaughters{"removeDaughters", true, "Flag for removing D-meson daughters from correlations"}; 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. DCA_xy of tracks"}; Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCA_z 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", 100., "max. track pT"}; Configurable multMin{"multMin", 0., "minimum multiplicity accepted"}; Configurable multMax{"multMax", 10000., "maximum multiplicity accepted"}; - Configurable> binsPt{"binsPt", std::vector{o2::analysis::hf_cuts_dplus_to_pi_k_pi::vecBinsPt}, "pT bin limits for candidate mass plots and efficiency"}; + 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_dplus_to_pi_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_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>; - using TracksWithDca = soa::Filtered>; // track Selection applied - using CandidatesDplusData = soa::Filtered>; + using SelCollisionsWithDplus = soa::Filtered>; + using SelCollisionsWithDplusMc = soa::Filtered>; // collisionFilter applied + using CandidatesDplusData = soa::Filtered>; // Event Mixing for the MCRec Mode - using CandidatesDplusMcRec = soa::Filtered>; + using CandidatesDplusMcRec = soa::Filtered>; + using CandDplusMcGen = soa::Join; // flagDplusFilter applied // 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 Filter collisionFilter = aod::hf_selection_dmeson_collision::dmesonSel == true; // filter on selection of Dplus meson and decay channel Dplus->KPiPi 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); + // 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; - HistogramRegistry registry{ - "registry", - {{"hPtCand", "Dplus,Hadron candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng0", "Dplus,Hadron candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng1", "Dplus,Hadron candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng2", "Dplus,Hadron candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hSelectionStatus", "Dplus,Hadron candidates;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, - {"hEta", "Dplus,Hadron candidates;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hPhi", "Dplus,Hadron candidates;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisBins, phiAxisMin, phiAxisMax}}}}, - {"hY", "Dplus,Hadron candidates;candidate #it{#y};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hPtCandMCRec", "Dplus,Hadron candidates - MC reco;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng0MCRec", "Dplus,Hadron candidates - MC reco;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng1MCRec", "Dplus,Hadron candidates - MC reco;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hPtProng2MCRec", "Dplus,Hadron candidates - MC reco;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hSelectionStatusMCRec", "Dplus,Hadron candidates - MC reco;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}}, - {"hEtaMCRec", "Dplus,Hadron candidates - MC reco;candidate #it{#eta};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hPhiMCRec", "Dplus,Hadron candidates - MC reco;candidate #it{#varphi};entries", {HistType::kTH1F, {{phiAxisBins, phiAxisMin, phiAxisMax}}}}, - {"hYMCRec", "Dplus,Hadron candidates - MC reco;candidate #it{#y};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hMCEvtCount", "Event counter - MC gen;;entries", {HistType::kTH1F, {{1, -0.5, 0.5}}}}, - {"hPtCandMCGen", "Dplus,Hadron particles - MC gen;particle #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{ptDAxisBins, ptDAxisMin, ptDAxisMax}}}}, - {"hEtaMCGen", "Dplus,Hadron particles - MC gen;particle #it{#eta};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hPhiMCGen", "Dplus,Hadron particles - MC gen;particle #it{#varphi};entries", {HistType::kTH1F, {{phiAxisBins, phiAxisMin, phiAxisMax}}}}, - {"hYMCGen", "Dplus,Hadron candidates - MC gen;candidate #it{#y};entries", {HistType::kTH1F, {{yAxisBins, yAxisMin, yAxisMax}}}}, - {"hcountDplusHadronPerEvent", "Dplus,Hadron particles - MC gen;Number per event;entries", {HistType::kTH1F, {{20, 0., 20.}}}}, - {"hMultiplicityPreSelection", "multiplicity prior to selection;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hMultFT0M", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}}, - {"hZvtx", "z vertex;z vertex;entries", {HistType::kTH1F, {{200, -20., 20.}}}}, - {"hDplusBin", "Dplus 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&) { - auto vbins = (std::vector)binsPt; - registry.add("hMassDplus_2D", "Dplus candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("hMassDplusData", "Dplus candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{massAxisBins, massAxisMin, massAxisMax}}}); - registry.add("hMassDplusMCRec", "Dplus candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{massAxisBins, massAxisMin, massAxisMax}}}); - registry.add("hMassDplusMCRecSig", "Dplus 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("hMassDplusMCRecBkg", "Dplus 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("hcountDplustriggersMCGen", "Dplus trigger particles - MC gen;;N of trigger Dplus", {HistType::kTH2F, {{1, -0.5, 0.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); + AxisSpec axisMassD = {binsMassD, "inv. mass (pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; + 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})"}; + AxisSpec axisMultiplicity = {binsMultiplicity, "Multiplicity"}; + AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; + AxisSpec axisPosZ = {binsZVtx, "PosZ"}; + AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; + AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; + AxisSpec axisStatus = {15, 0.5, 15.5, "Selection status"}; + AxisSpec axisRapidity = {100, -2, 2, "Rapidity"}; + + registry.add("hPtCand", "Dplus,Hadron candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng0", "Dplus,Hadron candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng1", "Dplus,Hadron candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng2", "Dplus,Hadron candidates;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hSelectionStatus", "Dplus,Hadron candidates;selection status;entries", {HistType::kTH1F, {{10, -0.5, 9.5}}}); + registry.add("hEta", "Dplus,Hadron candidates;candidate #it{#eta};entries", {HistType::kTH1F, {axisEta}}); + registry.add("hPhi", "Dplus,Hadron candidates;candidate #it{#varphi};entries", {HistType::kTH1F, {axisPhi}}); + registry.add("hY", "Dplus,Hadron candidates;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hcountDplusHadronPerEvent", "Dplus,Hadron particles - MC gen;Number per event;entries", {HistType::kTH1F, {{20, 0., 20.}}}); + 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("hDplusBin", "Dplus 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("hMassDplus_2D", "Dplus candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDplusData", "Dplus candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{axisMassD}}}); + registry.add("hDplusPoolBin", "D+ candidates pool bin", {HistType::kTH1F, {axisPoolBin}}); + registry.add("hTracksPoolBin", "Particles associated pool bin", {HistType::kTH1F, {axisPoolBin}}); + // Histograms for MC Reco analysis + registry.add("hSelectionStatusMCRec", "Dplus,Hadron candidates - MC reco;selection status;entries", {HistType::kTH1F, {{4, -0.5, 3.5}}}); + registry.add("hMCEvtCount", "Event counter - MC gen;;entries", {HistType::kTH1F, {{1, -0.5, 0.5}}}); + registry.add("hPtProng0MCRec", "Dplus,Hadron candidates - MC reco;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng1MCRec", "Dplus,Hadron candidates - MC reco;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtProng2MCRec", "Dplus,Hadron candidates - MC reco;prong 2 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hMassDplusMcRec", "D+ candidates;inv. mass (K^{-}#pi^{+}#pi^{+}) (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{axisMassD}}}); + registry.add("hMassDplusVsPtMcRec", "D+ signal candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDplusMcRecSig", "D+ signal candidates - MC reco;inv. mass (#pi K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDplusMcRecBkg", "D+ background candidates - MC reco;inv. mass (#pi K #pi) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hPtCandMcRecSig", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecSigPrompt", "D+,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecSigNonPrompt", "D+,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecBkg", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hEtaMcRecSig", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcRecSig", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hYMCRecSig", "D+,Hadron candidates - MC reco;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hEtaMcRecBkg", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcRecBkg", "D+,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hYMCRecBkg", "Dplus,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}, {axisPtD}}}); + registry.add("hPtPrimaryParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); + registry.add("hPtVsMultiplicityMcRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + registry.add("hPtVsMultiplicityMcRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + // Histograms for MC Gen analysis + registry.add("hcountDplustriggersMCGen", "D+ trigger particles - MC gen;;N of trigger Dplus", {HistType::kTH2F, {{1, -0.5, 0.5}, {axisPtD}}}); + registry.add("hPtCandMCGen", "Dplus,Hadron particles - MC gen;particle #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {axisPtD}}); + registry.add("hYMCGen", "Dplus,Hadron candidates - MC gen;candidate #it{#y};entries", {HistType::kTH1F, {axisRapidity}}); + registry.add("hPtCandMcGenPrompt", "D+,Hadron particles - MC Gen Prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenNonPrompt", "D+,Hadron particles - MC Gen Non Prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hEtaMcGen", "D+,Hadron particles - MC Gen", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcGen", "D+,Hadron particles - MC Gen", {HistType::kTH1F, {axisPhi}}); + registry.add("hMultFT0AMcGen", "D+,Hadron multiplicity FT0A - MC Gen", {HistType::kTH1F, {axisMultiplicity}}); corrBinning = {{binsZVtx, binsMultiplicity}, true}; } /// Dplus-hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) void processData(SelCollisionsWithDplus::iterator const& collision, - TracksWithDca const& tracks, + TracksData const& tracks, CandidatesDplusData const& candidates, aod::BCsWithTimestamps const&) { auto bc = collision.bc_as(); int gCollisionId = collision.globalIndex(); int64_t timeStamp = bc.timestamp(); + + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); if (candidates.size() > 0) { - int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); int nTracks = 0; if (collision.numContrib() > 1) { for (const auto& track : tracks) { @@ -240,10 +308,8 @@ struct HfCorrelatorDplusHadrons { continue; } nTracks++; - registry.fill(HIST("hTracksBin"), poolBin); } } - registry.fill(HIST("hMultiplicityPreSelection"), nTracks); if (nTracks < multMin || nTracks > multMax) { return; @@ -251,18 +317,19 @@ struct HfCorrelatorDplusHadrons { registry.fill(HIST("hMultiplicity"), nTracks); int cntDplus = 0; + std::vector outputMl = {-1., -1., -1.}; for (const auto& candidate : candidates) { - if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin || candidate.pt() >= ptTrackMax) { + if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin || candidate.pt() >= ptCandMax) { continue; } int effBinD = o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()); - double efficiencyWeight = 1.; + double efficiencyWeightD = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / efficiencyD->at(effBinD); + efficiencyWeightD = 1. / efficiencyD->at(effBinD); } // fill invariant mass plots and generic info from all Dplus candidates - registry.fill(HIST("hMassDplus_2D"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeight); - registry.fill(HIST("hMassDplusData"), hfHelper.invMassDplusToPiKPi(candidate), efficiencyWeight); + registry.fill(HIST("hMassDplus_2D"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeightD); + registry.fill(HIST("hMassDplusData"), hfHelper.invMassDplusToPiKPi(candidate), efficiencyWeightD); registry.fill(HIST("hPtCand"), candidate.pt()); registry.fill(HIST("hPtProng0"), candidate.ptProng0()); registry.fill(HIST("hPtProng1"), candidate.ptProng1()); @@ -272,7 +339,12 @@ struct HfCorrelatorDplusHadrons { registry.fill(HIST("hY"), hfHelper.yDplus(candidate)); registry.fill(HIST("hSelectionStatus"), candidate.isSelDplusToPiKPi()); registry.fill(HIST("hDplusBin"), poolBin); + 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 entryDplus(candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDplusToPiKPi(candidate), poolBin, gCollisionId, timeStamp); + // Dplus-Hadron correlation dedicated section // if the candidate is a Dplus, search for Hadrons and evaluate correlations for (const auto& track : tracks) { @@ -281,16 +353,23 @@ struct HfCorrelatorDplusHadrons { continue; } // Removing Dplus daughters by checking track indices - if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { - continue; + if (removeDaughters) { + if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { + continue; + } } entryDplusHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), track.pt(), poolBin); - entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), 0); - if (cntDplus == 0) + entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), false); + entryDplusHadronGenInfo(false, false, 0); + entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); + if (cntDplus == 0) { entryHadron(track.phi(), track.eta(), track.pt(), poolBin, gCollisionId, timeStamp); + registry.fill(HIST("hTracksBin"), poolBin); + } } // Hadron Tracks loop cntDplus++; } // end outer Dplus loop @@ -302,11 +381,12 @@ struct HfCorrelatorDplusHadrons { /// Dplus-Hadron correlation pair builder - for MC reco-level analysis (candidates matched to true signal only, but also the various bkg sources are studied) void processMcRec(SelCollisionsWithDplus::iterator const& collision, - TracksWithDca const& tracks, - CandidatesDplusMcRec const& candidates) + TracksWithMc const& tracks, + CandidatesDplusMcRec const& candidates, + aod::McParticles const& mcParticles) { + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); if (candidates.size() > 0) { - int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); int nTracks = 0; if (collision.numContrib() > 1) { for (const auto& track : tracks) { @@ -314,7 +394,6 @@ struct HfCorrelatorDplusHadrons { continue; } nTracks++; - registry.fill(HIST("hTracksBin"), poolBin); } } registry.fill(HIST("hMultiplicityPreSelection"), nTracks); @@ -323,55 +402,105 @@ struct HfCorrelatorDplusHadrons { } registry.fill(HIST("hMultiplicity"), nTracks); + float multiplicityFT0M = collision.multFT0M(); + // MC reco level - bool flagDplusSignal = false; + bool isDplusPrompt = false; + bool isDplusNonPrompt = false; + bool isDplusSignal = false; for (const auto& candidate : candidates) { - if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin || candidate.pt() >= ptTrackMax) { + // rapidity and pT selections + if (std::abs(hfHelper.yDplus(candidate)) >= yCandMax || candidate.pt() <= ptCandMin || candidate.pt() >= ptCandMax) { continue; } + // efficiency weight determination int effBinD = o2::analysis::findBin(binsPtEfficiencyD, candidate.pt()); - double efficiencyWeight = 1.; + double efficiencyWeightD = 1.; if (applyEfficiency) { - efficiencyWeight = 1. / efficiencyD->at(effBinD); + efficiencyWeightD = 1. / efficiencyD->at(effBinD); } + // Dplus flag + isDplusSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::DplusToPiKPi); + // prompt and non-prompt division + isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + isDplusNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + + std::vector outputMl = {-1., -1., -1.}; + + // fill invariant mass plots from Dplus signal and background candidates + registry.fill(HIST("hMassDplusMcRec"), hfHelper.invMassDplusToPiKPi(candidate), efficiencyWeightD); + registry.fill(HIST("hDplusBin"), poolBin); - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) { + if (isDplusSignal) { // fill per-candidate distributions from Dplus true candidates - registry.fill(HIST("hPtCandMCRec"), candidate.pt()); registry.fill(HIST("hPtProng0MCRec"), candidate.ptProng0()); registry.fill(HIST("hPtProng1MCRec"), candidate.ptProng1()); registry.fill(HIST("hPtProng2MCRec"), candidate.ptProng2()); - registry.fill(HIST("hEtaMCRec"), candidate.eta()); - registry.fill(HIST("hPhiMCRec"), RecoDecay::constrainAngle(candidate.phi(), -o2::constants::math::PIHalf)); - registry.fill(HIST("hYMCRec"), hfHelper.yDplus(candidate)); + registry.fill(HIST("hMassDplusVsPtMcRec"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeightD); registry.fill(HIST("hSelectionStatusMCRec"), candidate.isSelDplusToPiKPi()); - } - // fill invariant mass plots from Dplus signal and background candidates - registry.fill(HIST("hMassDplusMCRec"), hfHelper.invMassDplusToPiKPi(candidate), efficiencyWeight); - if (std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi) { // also matched as Dplus - registry.fill(HIST("hMassDplusMCRecSig"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeight); + registry.fill(HIST("hPtCandMcRecSig"), candidate.pt()); + registry.fill(HIST("hEtaMcRecSig"), candidate.eta()); + registry.fill(HIST("hYMCRecSig"), hfHelper.yDplus(candidate)); + registry.fill(HIST("hPhiMcRecSig"), RecoDecay::constrainAngle(candidate.phi(), -PIHalf)); + + // prompt and non-prompt division + if (isDplusPrompt) { + registry.fill(HIST("hPtCandMcRecSigPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), candidate.pt(), multiplicityFT0M); + } else if (isDplusNonPrompt) { + registry.fill(HIST("hPtCandMcRecSigNonPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), candidate.pt(), multiplicityFT0M); + } + // Storing ML scores for signal reco candidates and charm/beauty origin + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + 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]); + entryDplusCandGenInfo(isDplusPrompt); } else { - registry.fill(HIST("hMassDplusMCRecBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeight); + registry.fill(HIST("hPtCandMcRecBkg"), candidate.pt()); + registry.fill(HIST("hEtaMcRecBkg"), candidate.eta()); + registry.fill(HIST("hPhiMcRecBkg"), RecoDecay::constrainAngle(candidate.phi(), -PIHalf)); + registry.fill(HIST("hMassDplusMcRecBkg"), hfHelper.invMassDplusToPiKPi(candidate), candidate.pt(), efficiencyWeightD); } - registry.fill(HIST("hDplusBin"), poolBin); + // Dplus-Hadron correlation dedicated section // if the candidate is selected as Dplus, search for Hadron and evaluate correlations - flagDplusSignal = candidate.flagMcMatchRec() == 1 << aod::hf_cand_3prong::DecayType::DplusToPiKPi; - for (const auto& track : tracks) { + bool isPhysicalPrimary = false; + int trackOrigin = -1; // apply track selection if (!track.isGlobalTrackWoDCA()) { continue; } // Removing Dplus daughters by checking track indices - if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { - continue; + if (removeDaughters) { + if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { + continue; + } } entryDplusHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), track.pt(), poolBin); - entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), flagDplusSignal); + entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), isDplusSignal); + entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + if (track.has_mcParticle()) { + auto mcParticle = track.template mcParticle_as(); + isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + entryDplusHadronGenInfo(isDplusPrompt, isPhysicalPrimary, trackOrigin); + } else { + entryDplusHadronGenInfo(isDplusPrompt, false, 0); + registry.fill(HIST("hFakeTracksMcRec"), track.pt()); + } + // for secondary particle fraction estimation + registry.fill(HIST("hPtParticleAssocVsCandMcRec"), track.pt(), candidate.pt()); + if (isPhysicalPrimary) { + registry.fill(HIST("hPtPrimaryParticleAssocVsCandMcRec"), track.pt(), candidate.pt()); + } + entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); } // end inner loop (Tracks) } // end outer Dplus loop @@ -382,81 +511,103 @@ struct HfCorrelatorDplusHadrons { PROCESS_SWITCH(HfCorrelatorDplusHadrons, processMcRec, "Process MC Reco mode", true); /// Dplus-Hadron correlation pair builder - for MC gen-level analysis (no filter/selection, only true signal) - void processMcGen(aod::McCollision const& mcCollision, - aod::McParticles const& mcParticles) + void processMcGen(SelCollisionsWithDplusMc::iterator const& mcCollision, + CandDplusMcGen const& mcParticles) { int counterDplusHadron = 0; registry.fill(HIST("hMCEvtCount"), 0); - auto getTracksSize = [&mcParticles](aod::McCollision const&) { - int nTracks = 0; - for (const auto& track : mcParticles) { - if (track.isPhysicalPrimary() && std::abs(track.eta()) < 1.0) { - nTracks++; - } - } - return nTracks; - }; - using BinningTypeMCGen = FlexibleBinningPolicy, aod::mccollision::PosZ, decltype(getTracksSize)>; - BinningTypeMCGen corrBinningMcGen{{getTracksSize}, {binsZVtx, binsMultiplicityMc}, true}; + BinningTypeMcGen corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true}; + int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); + registry.fill(HIST("hMultFT0AMcGen"), mcCollision.multMCFT0A()); + bool isDplusPrompt = false; + bool isDplusNonPrompt = false; // MC gen level for (const auto& particle1 : mcParticles) { // check if the particle is Dplus (for general plot filling and selection, so both cases are fine) - NOTE: decay channel is not probed! if (std::abs(particle1.pdgCode()) != Pdg::kDPlus) { continue; } + if (!TESTBIT(std::abs(particle1.flagMcMatchGen()), aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { + continue; + } double yD = RecoDecay::y(particle1.pVector(), MassDPlus); if (std::abs(yD) >= yCandMax || particle1.pt() <= ptCandMin) { continue; } + registry.fill(HIST("hDplusBin"), poolBin); registry.fill(HIST("hPtCandMCGen"), particle1.pt()); - registry.fill(HIST("hEtaMCGen"), particle1.eta()); - registry.fill(HIST("hPhiMCGen"), RecoDecay::constrainAngle(particle1.phi(), -o2::constants::math::PIHalf)); + registry.fill(HIST("hEtaMcGen"), particle1.eta()); + registry.fill(HIST("hPhiMcGen"), RecoDecay::constrainAngle(particle1.phi(), -PIHalf)); registry.fill(HIST("hYMCGen"), yD); + + // prompt and non-prompt division + isDplusPrompt = particle1.originMcGen() == RecoDecay::OriginType::Prompt; + isDplusNonPrompt = particle1.originMcGen() == RecoDecay::OriginType::NonPrompt; + if (isDplusPrompt) { + registry.fill(HIST("hPtCandMcGenPrompt"), particle1.pt()); + } else if (isDplusNonPrompt) { + registry.fill(HIST("hPtCandMcGenNonPrompt"), particle1.pt()); + } + + // prompt and non-prompt division + std::vector listDaughters{}; + std::array arrDaughDplusPDG = {+kPiPlus, -kKPlus, kPiPlus}; + std::array prongsId; + listDaughters.clear(); + RecoDecay::getDaughters(particle1, &listDaughters, arrDaughDplusPDG, 2); + int counterDaughters = 0; + if (listDaughters.size() == 3) { + for (const auto& dauIdx : listDaughters) { + auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); + counterDaughters += 1; + prongsId[counterDaughters - 1] = daughI.globalIndex(); + } + } counterDplusHadron++; // Dplus Hadron correlation dedicated section // if it's a Dplus particle, search for Hadron and evaluate correlations - if (std::abs(particle1.pdgCode()) != Pdg::kDPlus) { // just checking the particle PDG, not the decay channel (differently from Reco: you have a BR factor btw such levels!) - continue; - } registry.fill(HIST("hcountDplustriggersMCGen"), 0, particle1.pt()); // to count trigger Dplus for normalisation) - for (const auto& particle2 : mcParticles) { - - // Check Mother of particle 2 - bool flagMotherFound = false; - for (const auto& m : particle2.mothers_as()) { - if (m.globalIndex() == particle1.globalIndex()) { - flagMotherFound = true; - break; + for (const auto& particleAssoc : mcParticles) { + if (std::abs(particleAssoc.eta()) > etaTrackMax || particleAssoc.pt() < ptTrackMin || particleAssoc.pt() > ptTrackMax) { + continue; + } + if (removeDaughters) { + if (particleAssoc.globalIndex() == prongsId[0] || particleAssoc.globalIndex() == prongsId[1] || particleAssoc.globalIndex() == prongsId[2]) { + continue; } } - if (flagMotherFound || std::abs(particle2.eta()) >= etaTrackMax || particle2.pt() <= ptTrackMin) { + 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 ((std::abs(particle2.pdgCode()) != 11) && (std::abs(particle2.pdgCode()) != 13) && (std::abs(particle2.pdgCode()) != 211) && (std::abs(particle2.pdgCode()) != 321) && (std::abs(particle2.pdgCode()) != 2212)) { + if (!particleAssoc.isPhysicalPrimary()) { continue; } - int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), getTracksSize(mcCollision))); - entryDplusHadronPair(getDeltaPhi(particle2.phi(), particle1.phi()), - particle2.eta() - particle1.eta(), - particle1.pt(), - particle2.pt(), poolBin); - } // end inner loop - } // end outer loop + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); + entryDplusHadronPair(getDeltaPhi(particleAssoc.phi(), particle1.phi()), + particleAssoc.eta() - particle1.eta(), + particle1.pt(), + particleAssoc.pt(), + poolBin); + entryDplusHadronRecoInfo(MassDPlus, true); + entryDplusHadronGenInfo(isDplusPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); + } // end associated loop + } // end trigger registry.fill(HIST("hcountDplusHadronPerEvent"), counterDplusHadron); registry.fill(HIST("hZvtx"), mcCollision.posZ()); - registry.fill(HIST("hMultiplicity"), getTracksSize(mcCollision)); + // registry.fill(HIST("hMultiplicity"), getTracksSize(mcCollision)); } PROCESS_SWITCH(HfCorrelatorDplusHadrons, processMcGen, "Process MC Gen mode", false); void processDataMixedEvent(SelCollisionsWithDplus const& collisions, CandidatesDplusData const& candidates, - TracksWithDca const& tracks) + TracksData const& tracks) { auto tracksTuple = std::make_tuple(candidates, tracks); - Pair pairData{corrBinning, 5, -1, collisions, tracksTuple, &cache}; + Pair pairData{corrBinning, 5, -1, collisions, tracksTuple, &cache}; for (const auto& [c1, tracks1, c2, tracks2] : pairData) { // 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 @@ -475,61 +626,114 @@ struct HfCorrelatorDplusHadrons { void processMcRecMixedEvent(SelCollisionsWithDplus const& collisions, CandidatesDplusMcRec const& candidates, - TracksWithDca const& tracks) + TracksWithMc const& tracks, + aod::McParticles const& mcParticles) { + BinningType corrBinning{{binsZVtx, binsMultiplicityMc}, true}; + for (const auto& candidate : candidates) { + if (std::abs(hfHelper.yDplus(candidate)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { + continue; + } + // Dplus flag + bool isDplusSignal = TESTBIT(std::abs(candidate.flagMcMatchRec()), aod::hf_cand_3prong::DecayType::DplusToPiKPi); + // prompt and non-prompt division + bool isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + bool isDplusNonPrompt = candidate.originMcRec() == RecoDecay::OriginType::NonPrompt; + if (isDplusSignal) { + if (isDplusPrompt) { + registry.fill(HIST("hPtCandMcRecSigPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityMcRecPrompt"), candidate.pt(), 0); + } else if (isDplusNonPrompt) { + registry.fill(HIST("hPtCandMcRecSigNonPrompt"), candidate.pt()); + registry.fill(HIST("hPtVsMultiplicityMcRecNonPrompt"), candidate.pt(), 0); + } + } else { + registry.fill(HIST("hPtCandMcRecBkg"), candidate.pt()); + registry.fill(HIST("hEtaMcRecBkg"), candidate.eta()); + registry.fill(HIST("hPhiMcRecBkg"), RecoDecay::constrainAngle(candidate.phi(), -PIHalf)); + } + } auto tracksTuple = std::make_tuple(candidates, tracks); - Pair pairMcRec{corrBinning, 5, -1, collisions, tracksTuple, &cache}; + Pair pairMcRec{corrBinning, numberEventsMixed, -1, collisions, tracksTuple, &cache}; for (const auto& [c1, tracks1, c2, tracks2] : pairMcRec) { int poolBin = corrBinning.getBin(std::make_tuple(c2.posZ(), c2.multFT0M())); - for (const auto& [trigDplus, assocParticle] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - if (!assocParticle.isGlobalTrackWoDCA() || std::abs(hfHelper.yDplus(trigDplus)) >= yCandMax) { + int poolBinDplus = 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); // note that the selections here are not yet applied + registry.fill(HIST("hDplusPoolBin"), poolBinDplus); // note that the selections here are not yet applied + for (const auto& [candidate, pAssoc] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (std::abs(hfHelper.yDplus(candidate)) > yCandMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { continue; } - entryDplusHadronPair(getDeltaPhi(trigDplus.phi(), assocParticle.phi()), trigDplus.eta() - assocParticle.eta(), trigDplus.pt(), assocParticle.pt(), poolBin); - entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(trigDplus), 0); + if (!pAssoc.isGlobalTrackWoDCA()) { + continue; + } + 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; + // prompt and non-prompt division + bool isDplusPrompt = candidate.originMcRec() == RecoDecay::OriginType::Prompt; + if (pAssoc.has_mcParticle()) { + auto mcParticle = pAssoc.template mcParticle_as(); + isPhysicalPrimary = mcParticle.isPhysicalPrimary(); + trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); + } else { + registry.fill(HIST("hFakeTracksMcRec"), pAssoc.pt()); + } + entryDplusHadronPair(getDeltaPhi(pAssoc.phi(), candidate.phi()), + pAssoc.eta() - candidate.eta(), + candidate.pt(), + pAssoc.pt(), + poolBin); + entryDplusHadronRecoInfo(hfHelper.invMassDplusToPiKPi(candidate), isDplusSignal); + entryDplusHadronGenInfo(isDplusPrompt, isPhysicalPrimary, trackOrigin); + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)]; + } + entryDplusHadronMlInfo(outputMl[0], outputMl[1]); + entryTrackRecoInfo(pAssoc.dcaXY(), pAssoc.dcaZ(), pAssoc.tpcNClsCrossedRows()); } } } PROCESS_SWITCH(HfCorrelatorDplusHadrons, processMcRecMixedEvent, "Process Mixed Event MCRec", false); - void processMcGenMixedEvent(McCollisionsSel const& collisions, - McParticlesSel const& mcParticles) + void processMcGenMixedEvent(SelCollisionsWithDplusMc const& collisions, + CandDplusMcGen const& mcParticles) { - - auto getTracksSize = [&mcParticles, this](McCollisionsSel::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}, {binsZVtx, binsMultiplicityMc}, true}; - + BinningTypeMcGen corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true}; auto tracksTuple = std::make_tuple(mcParticles, mcParticles); - Pair pairMcGen{corrBinningMcGen, 5, -1, collisions, tracksTuple, &cache}; - + Pair pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache}; for (const auto& [c1, tracks1, c2, tracks2] : pairMcGen) { - for (const auto& [trigDplus, assocParticle] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - // Check track trigDplus is Dplus - if (std::abs(trigDplus.pdgCode()) != Pdg::kDPlus) { + 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.pdgCode()) != Pdg::kDPlus) { continue; } - - double yD = RecoDecay::y(trigDplus.pVector(), MassDPlus); - if (std::abs(yD) >= yCandMax || trigDplus.pt() <= ptCandMin || std::abs(assocParticle.eta()) >= etaTrackMax || assocParticle.pt() <= ptTrackMin) { + double yD = RecoDecay::y(candidate.pVector(), MassDPlus); + if (std::abs(yD) > 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; } - int poolBin = corrBinningMcGen.getBin(std::make_tuple(c2.posZ(), getTracksSize(c2))); - // LOGF(info, "Mixed event collisions: Index = (%d,%d), tracks Size: (%d,%d), Z Vertex: (%f), Pool Bin: (%d)", c1.globalIndex(), c2.globalIndex(), getTracksSize(c1), getTracksSize(c2), c2.posZ(), poolBin); // For debug - entryDplusHadronPair(getDeltaPhi(assocParticle.phi(), trigDplus.phi()), assocParticle.eta() - trigDplus.eta(), trigDplus.pt(), assocParticle.pt(), poolBin); + int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + bool isDplusPrompt = candidate.originMcGen() == RecoDecay::OriginType::Prompt; + entryDplusHadronPair(getDeltaPhi(particleAssoc.phi(), candidate.phi()), + particleAssoc.eta() - candidate.eta(), + candidate.pt(), + particleAssoc.pt(), + poolBin); + entryDplusHadronRecoInfo(MassDPlus, true); + entryDplusHadronGenInfo(isDplusPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); } } } diff --git a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx index 2800c2911fe..a0514f97a62 100644 --- a/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorDsHadrons.cxx @@ -14,6 +14,8 @@ /// \author Grazia Luparello /// \author Samuele Cattaruzzi +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -29,6 +31,7 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/DataModel/DerivedDataCorrelationTables.h" using namespace o2; using namespace o2::analysis; @@ -64,7 +67,6 @@ struct HfCorrelatorDsHadronsSelCollision { using SelCollisions = soa::Join; using CandDsData = soa::Filtered>; using CandDsMcReco = soa::Filtered>; - using CandDsMcGen = soa::Join; Filter dsFilter = ((o2::aod::hf_track_index::hfflag & static_cast(1 << aod::hf_cand_3prong::DecayType::DsToKKPi)) != static_cast(0)) && (aod::hf_sel_candidate_ds::isSelDsToKKPi >= selectionFlagDs || aod::hf_sel_candidate_ds::isSelDsToPiKK >= selectionFlagDs); @@ -97,15 +99,15 @@ struct HfCorrelatorDsHadronsSelCollision { } PROCESS_SWITCH(HfCorrelatorDsHadronsSelCollision, processDsSelCollisionsData, "Process Ds Collision Selection Data", true); - /// Code to select collisions with at least one Ds meson - for MC reco-level analysis - void processDsSelCollisionsMcRec(SelCollisions::iterator const& collision, - CandDsMcReco const& candidates) + /// Code to select collisions with at least one Ds meson - for MC-level analysis + void processDsSelCollisionsMc(SelCollisions::iterator const& collision, + CandDsMcReco const& candidates) { bool isSelColl = true; bool isDsFound = true; bool isSel8 = true; bool isNosameBunchPileUp = true; - if (doSelDsCollision) { + if (doSelDsCollision) { // to enable only for the MC reco part for (const auto& candidate : candidates) { if (std::abs(hfHelper.yDs(candidate)) > yCandMax || candidate.pt() < ptCandMin) { isDsFound = false; @@ -124,33 +126,7 @@ struct HfCorrelatorDsHadronsSelCollision { isSelColl = isDsFound && isSel8 && isNosameBunchPileUp; collisionsWithSelDs(isSelColl); } - PROCESS_SWITCH(HfCorrelatorDsHadronsSelCollision, processDsSelCollisionsMcRec, "Process Ds Collision Selection MCRec", false); - - /// Code to select collisions with at least one Ds meson - for MC gen-level analysis - void processDsSelCollisionsMcGen(aod::McCollision const&, - CandDsMcGen const& mcParticles) - { - bool isSelColl = true; - bool isDsFound = true; - if (doSelDsCollision) { - for (const auto& particle : mcParticles) { - if (std::abs(particle.pdgCode()) != Pdg::kDS) { - isDsFound = false; - continue; - } - double yD = RecoDecay::y(particle.pVector(), MassDS); - if (std::abs(yD) > yCandMax || particle.pt() < ptCandMin) { - isDsFound = false; - continue; - } - isDsFound = true; - break; - } - } - isSelColl = isDsFound; - collisionsWithSelDs(isSelColl); - } - PROCESS_SWITCH(HfCorrelatorDsHadronsSelCollision, processDsSelCollisionsMcGen, "Process Ds Collision Selection MCGen", false); + PROCESS_SWITCH(HfCorrelatorDsHadronsSelCollision, processDsSelCollisionsMc, "Process Ds Collision Selection MCRec", false); }; /// Ds-Hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth) @@ -162,16 +138,25 @@ struct HfCorrelatorDsHadrons { Produces entryDsCandRecoInfo; Produces entryDsCandGenInfo; Produces entryTrackRecoInfo; - - Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds"}; + Produces collReduced; + Produces candReduced; + Produces assocTrackReduced; + + 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 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 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"}; Configurable etaTrackMax{"etaTrackMax", 0.8, "max. eta of tracks"}; - Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCA_xy of tracks"}; - Configurable dcaZTrackMax{"dcaZTrackMax", 1., "max. DCA_z of tracks"}; + Configurable dcaXYTrackMax{"dcaXYTrackMax", 2., "max. DCA_xy of tracks"}; + Configurable dcaZTrackMax{"dcaZTrackMax", 2., "max. DCA_z of tracks"}; Configurable ptCandMin{"ptCandMin", 1., "min. cand. pT"}; Configurable ptCandMax{"ptCandMax", 50., "max. cand pT"}; Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT"}; @@ -189,14 +174,14 @@ struct HfCorrelatorDsHadrons { ConfigurableAxis binsMultiplicity{"binsMultiplicity", {200, 0., 800.}, "Multiplicity"}; ConfigurableAxis binsMultFT0M{"binsMultFT0M", {600, 0., 6000.}, "Multiplicity as FT0M signal amplitude"}; ConfigurableAxis binsPosZ{"binsPosZ", {100, -10., 10.}, "primary vertex z coordinate"}; - ConfigurableAxis binsBdtScore{"binsBdtScore", {100, 0., 1.}, "Bdt output scores"}; ConfigurableAxis binsPoolBin{"binsPoolBin", {9, 0., 9.}, "PoolBin"}; HfHelper hfHelper; SliceCache cache; - using SelCollisionsWithDs = soa::Filtered>; // collisionFilter applied - using SelCollisionsWithDsMc = soa::Filtered>; // collisionFilter applied + using SelCollisionsWithDs = soa::Filtered>; // collisionFilter applied + // using SelCollisionsWithDsWithMc = soa::Filtered>; // collisionFilter applied + using SelCollisionsMc = soa::Join; using CandDsData = soa::Filtered>; // flagDsFilter applied using CandDsMcReco = soa::Filtered>; // flagDsFilter applied using CandDsMcGen = soa::Join; // flagDsFilter applied @@ -219,57 +204,64 @@ struct HfCorrelatorDsHadrons { AxisSpec axisMultiplicity = {binsMultiplicity, "Multiplicity"}; AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; AxisSpec axisPosZ = {binsPosZ, "PosZ"}; - AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; AxisSpec axisPoolBin = {binsPoolBin, "PoolBin"}; AxisSpec axisStatus = {15, 0.5, 15.5, "Selection status"}; // Histograms for data analysis - registry.add("hPtCand", "Ds candidates pt", {HistType::kTH1F, {axisPtD}}); - registry.add("hSelectionStatusDsToKKPi", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); - registry.add("hSelectionStatusDsToPiKK", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); - registry.add("hCountSelectionStatusDsToKKPiAndToPiKK", "Ds candidates selection", {HistType::kTH1F, {{1, -0.5, 0.5}}}); - registry.add("hEta", "Ds candidates eta", {HistType::kTH1F, {axisEta}}); - registry.add("hEtaVsPtCand", "Ds candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtD}}}); - registry.add("hEtaVsPtPartAssoc", "Particles associated etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtHadron}}}); - registry.add("hPhi", "Ds candidates phi", {HistType::kTH1F, {axisPhi}}); - registry.add("hPhiVsPtCand", "Ds candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtD}}}); - registry.add("hPhiVsPtPartAssoc", "Particles associated phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtHadron}}}); - registry.add("hMultiplicity", "Multiplicity", {HistType::kTH1F, {axisMultiplicity}}); - registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH1F, {axisMultFT0M}}); - 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}}); - registry.add("hCorrelSystematics", "Ds-h correlations systematic error evaluation", {HistType::kTHnSparseD, {{axisPhi}, {axisEta}, {axisPtD}, {axisPtHadron}, {axisMassD}, {axisBdtScore}, {axisBdtScore}}}); + if (fillHistoData) { + registry.add("hPtCand", "Ds candidates pt", {HistType::kTH1F, {axisPtD}}); + registry.add("hSelectionStatusDsToKKPi", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); + registry.add("hSelectionStatusDsToPiKK", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); + registry.add("hCountSelectionStatusDsToKKPiAndToPiKK", "Ds candidates selection", {HistType::kTH1F, {{1, -0.5, 0.5}}}); + registry.add("hEta", "Ds candidates eta", {HistType::kTH1F, {axisEta}}); + registry.add("hEtaVsPtCand", "Ds candidates etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtD}}}); + registry.add("hEtaVsPtPartAssoc", "Particles associated etaVsPt", {HistType::kTH2F, {{axisEta}, {axisPtHadron}}}); + registry.add("hPhi", "Ds candidates phi", {HistType::kTH1F, {axisPhi}}); + registry.add("hPhiVsPtCand", "Ds candidates phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtD}}}); + registry.add("hPhiVsPtPartAssoc", "Particles associated phiVsPt", {HistType::kTH2F, {{axisPhi}, {axisPtHadron}}}); + registry.add("hMultiplicity", "Multiplicity", {HistType::kTH1F, {axisMultiplicity}}); + registry.add("hMultFT0M", "Multiplicity FT0M", {HistType::kTH1F, {axisMultFT0M}}); + 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}}); + } // Histograms for MC Reco analysis - registry.add("hPtCandMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcRecSigPrompt", "Ds,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcRecSigNonPrompt", "Ds,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtParticleAssocMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); - registry.add("hPtParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); - registry.add("hPtPrimaryParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); - registry.add("hEtaMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); - registry.add("hPhiMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); - registry.add("hEtaMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); - registry.add("hPhiMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); - registry.add("hPtVsMultiplicityMcRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); - registry.add("hPtVsMultiplicityMcRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); - registry.add("hMassDsMcRec", "Ds candidates", {HistType::kTH1F, {axisMassD}}); - registry.add("hMassDsVsPtMcRec", "Ds signal candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); - registry.add("hMassDsMcRecSig", "Ds signal candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); - registry.add("hMassDsMcRecBkg", "Ds background candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); - registry.add("hFakeTracksMcRec", "Fake tracks - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + if (fillHistoMcRec) { + registry.add("hPtCandMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecSigPrompt", "Ds,Hadron candidates Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecSigNonPrompt", "Ds,Hadron candidates Non Prompt - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPtD}}); + registry.add("hSelectionStatusDsToKKPiMcRec", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); + registry.add("hSelectionStatusDsToPiKKMcRec", "Ds candidates selection", {HistType::kTH1F, {axisStatus}}); + registry.add("hCountSelectionStatusDsToKKPiAndToPiKKMcRec", "Ds candidates selection", {HistType::kTH1F, {{1, -0.5, 0.5}}}); + registry.add("hPtParticleAssocMcRec", "Associated Particle - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + registry.add("hPtParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); + registry.add("hPtPrimaryParticleAssocVsCandMcRec", "Associated Particle - MC Rec", {HistType::kTH2F, {{axisPtHadron}, {axisPtD}}}); + registry.add("hEtaMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcRecSig", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hEtaMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisEta}}); + registry.add("hPhiMcRecBkg", "Ds,Hadron candidates - MC Reco", {HistType::kTH1F, {axisPhi}}); + registry.add("hPtVsMultiplicityMcRecPrompt", "Multiplicity FT0M - MC Rec Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + registry.add("hPtVsMultiplicityMcRecNonPrompt", "Multiplicity FT0M - MC Rec Non Prompt", {HistType::kTH2F, {{axisPtD}, {axisMultFT0M}}}); + registry.add("hMassDsMcRec", "Ds candidates", {HistType::kTH1F, {axisMassD}}); + registry.add("hMassDsVsPtMcRec", "Ds signal candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDsMcRecSig", "Ds signal candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDsMcRecBkg", "Ds background candidates - MC Reco", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hFakeTracksMcRec", "Fake tracks - MC Rec", {HistType::kTH1F, {axisPtHadron}}); + } // Histograms for MC Gen analysis - registry.add("hPtCandMcGen", "Ds,Hadron particles - MC Gen", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcGenPrompt", "Ds,Hadron particles - MC Gen Prompt", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtCandMcGenNonPrompt", "Ds,Hadron particles - MC Gen Non Prompt", {HistType::kTH1F, {axisPtD}}); - registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); - 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}}); + if (fillHistoMcGen) { + registry.add("hPtCandMcGen", "Ds,Hadron particles - MC Gen", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenPrompt", "Ds,Hadron particles - MC Gen Prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtCandMcGenNonPrompt", "Ds,Hadron particles - MC Gen Non Prompt", {HistType::kTH1F, {axisPtD}}); + registry.add("hPtParticleAssocMcGen", "Associated Particle - MC Gen", {HistType::kTH1F, {axisPtHadron}}); + 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}}); + } } /// Fill histograms of quantities independent from the daugther-mass hypothesis for data @@ -339,7 +331,7 @@ struct HfCorrelatorDsHadrons { /// Fill histograms of quantities for the Ds signal for MC reco-level /// \param particle is particle, Ds template - void fillHistoMcGen(const T1& particle) + void fillMcGenHisto(const T1& particle) { registry.fill(HIST("hPtCandMcGen"), particle.pt()); registry.fill(HIST("hEtaMcGen"), particle.eta()); @@ -447,6 +439,7 @@ struct HfCorrelatorDsHadrons { // MC reco level bool isDsPrompt = false; bool isDsSignal = false; + bool isCorrectInvMassHypo = false; bool isDecayChan = false; bool isAlreadyFilledEvent = false; float multiplicityFT0M = collision.multFT0M(); @@ -461,6 +454,9 @@ struct HfCorrelatorDsHadrons { continue; } + auto prong0McPart = candidate.template prong0_as().template mcParticle_as(); + isCorrectInvMassHypo = ((std::abs(prong0McPart.pdgCode()) == kKPlus) && (candidate.isSelDsToKKPi() >= selectionFlagDs)) || ((std::abs(prong0McPart.pdgCode()) == kPiPlus) && (candidate.isSelDsToPiKK() >= selectionFlagDs)); + double efficiencyWeightD = 1.; if (applyEfficiency) { efficiencyWeightD = 1. / efficiencyD->at(o2::analysis::findBin(binsPtEfficiencyD, candidate.pt())); @@ -468,7 +464,7 @@ struct HfCorrelatorDsHadrons { std::vector outputMl = {-1., -1., -1.}; - if (isDsSignal && isDecayChan) { + if (isDsSignal && isDecayChan && isCorrectInvMassHypo) { fillHistoMcRecSig(candidate, multiplicityFT0M); if (candidate.isSelDsToKKPi() >= selectionFlagDs) { for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { @@ -477,7 +473,7 @@ struct HfCorrelatorDsHadrons { registry.fill(HIST("hMassDsMcRec"), hfHelper.invMassDsToKKPi(candidate), efficiencyWeightD); registry.fill(HIST("hMassDsMcRecSig"), hfHelper.invMassDsToKKPi(candidate), candidate.pt(), efficiencyWeightD); registry.fill(HIST("hMassDsVsPtMcRec"), hfHelper.invMassDsToKKPi(candidate), candidate.pt(), efficiencyWeightD); - registry.fill(HIST("hSelectionStatusDsToKKPi"), candidate.isSelDsToKKPi()); + registry.fill(HIST("hSelectionStatusDsToKKPiMcRec"), candidate.isSelDsToKKPi()); entryDsCandRecoInfo(hfHelper.invMassDsToKKPi(candidate), candidate.pt(), outputMl[0], outputMl[2]); entryDsCandGenInfo(isDsPrompt); } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { @@ -487,7 +483,7 @@ struct HfCorrelatorDsHadrons { registry.fill(HIST("hMassDsMcRec"), hfHelper.invMassDsToPiKK(candidate), efficiencyWeightD); registry.fill(HIST("hMassDsMcRecSig"), hfHelper.invMassDsToPiKK(candidate), candidate.pt(), efficiencyWeightD); registry.fill(HIST("hMassDsVsPtMcRec"), hfHelper.invMassDsToPiKK(candidate), candidate.pt(), efficiencyWeightD); - registry.fill(HIST("hSelectionStatusDsToPiKK"), candidate.isSelDsToPiKK()); + registry.fill(HIST("hSelectionStatusDsToPiKKMcRec"), candidate.isSelDsToPiKK()); entryDsCandRecoInfo(hfHelper.invMassDsToPiKK(candidate), candidate.pt(), outputMl[0], outputMl[2]); entryDsCandGenInfo(isDsPrompt); } @@ -525,7 +521,7 @@ struct HfCorrelatorDsHadrons { bool isPhysicalPrimary = false; int trackOrigin = -1; // DsToKKPi and DsToPiKK division - if (candidate.isSelDsToKKPi() >= selectionFlagDs) { + if (isCorrectInvMassHypo && candidate.isSelDsToKKPi() >= selectionFlagDs) { entryDsHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), @@ -550,7 +546,7 @@ struct HfCorrelatorDsHadrons { } } entryTrackRecoInfo(track.dcaXY(), track.dcaZ(), track.tpcNClsCrossedRows()); - } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { + } else if (isCorrectInvMassHypo && candidate.isSelDsToPiKK() >= selectionFlagDs) { entryDsHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), @@ -582,73 +578,139 @@ struct HfCorrelatorDsHadrons { } PROCESS_SWITCH(HfCorrelatorDsHadrons, processMcRec, "Process MC Reco mode", false); + Preslice perCollisionCandMc = o2::aod::mcparticle::mcCollisionId; + PresliceUnsorted> collPerCollMc = o2::aod::mccollisionlabel::mcCollisionId; + /// Ds-Hadron correlation pair builder - for MC gen-level analysis (no filter/selection, only true signal) - void processMcGen(SelCollisionsWithDsMc::iterator const& mcCollision, + void processMcGen(SelCollisionsMc const& mcCollisions, + soa::Join const& collisions, CandDsMcGen const& mcParticles) { BinningTypeMcGen corrBinningMcGen{{zPoolBins, multPoolBins}, true}; - int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); - registry.fill(HIST("hCollisionPoolBin"), poolBin); - registry.fill(HIST("hMultFT0AMcGen"), mcCollision.multMCFT0A()); - bool isDsPrompt = false; - bool isDecayChan = false; - int trackOrigin = -1; - // MC gen level - for (const auto& particle : mcParticles) { - // check if the particle is Ds - if (std::abs(particle.pdgCode()) != Pdg::kDS) { + + for (const auto& mcCollision : mcCollisions) { + + // auto mcCollision = collision.template mcCollision_as>(); + + int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), mcCollision.multMCFT0A())); + registry.fill(HIST("hCollisionPoolBin"), poolBin); + registry.fill(HIST("hMultFT0AMcGen"), mcCollision.multMCFT0A()); + + const auto groupedMcParticles = mcParticles.sliceBy(perCollisionCandMc, mcCollision.globalIndex()); + const auto groupedCollisions = collisions.sliceBy(collPerCollMc, mcCollision.globalIndex()); + + if (groupedCollisions.size() < 1) { // Skipping MC events that have no reconstructed collisions continue; } - if ((std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (particle.flagMcDecayChanGen() == decayChannel)) { - double yD = RecoDecay::y(particle.pVector(), MassDS); - if (std::abs(yD) > yCandGenMax || particle.pt() < ptCandMin || particle.pt() > ptCandMax) { + if (groupedCollisions.size() > 1 && removeCollWSplitVtx) { // Skipping MC events that have more than one reconstructed collision + continue; + } + + /// loop over reconstructed collisions + for (const auto& collision : groupedCollisions) { + + // reco collision selection + if (useSel8 && !collision.sel8()) { continue; } - fillHistoMcGen(particle); - // prompt and non-prompt division - isDsPrompt = particle.originMcGen() == RecoDecay::OriginType::Prompt; - isDecayChan = particle.flagMcDecayChanGen() == 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) { - for (const auto& dauIdx : listDaughters) { - auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); - counterDaughters += 1; - prongsId[counterDaughters - 1] = daughI.globalIndex(); - } + if (std::abs(collision.posZ()) > 10.) { + continue; } - // Ds Hadron correlation dedicated section - for (const auto& particleAssoc : mcParticles) { - if (std::abs(particleAssoc.eta()) > etaTrackMax || particleAssoc.pt() < ptTrackMin || particleAssoc.pt() > ptTrackMax) { - continue; - } - if (particleAssoc.globalIndex() == prongsId[0] || particleAssoc.globalIndex() == prongsId[1] || particleAssoc.globalIndex() == prongsId[2]) { - 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 (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (!collision.has_mcCollision()) { + registry.fill(HIST("hFakeCollision"), 0.); + continue; + } + + bool isDsPrompt = false; + bool isDecayChan = false; + int trackOrigin = -1; + + // 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)) { + double yD = RecoDecay::y(particle.pVector(), MassDS); + if (std::abs(yD) > yCandGenMax || particle.pt() < ptCandMin || particle.pt() > ptCandMax) { + continue; + } + fillMcGenHisto(particle); + // prompt and non-prompt division + isDsPrompt = particle.originMcGen() == RecoDecay::OriginType::Prompt; + isDecayChan = particle.flagMcDecayChanGen() == 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) { + for (const auto& dauIdx : listDaughters) { + // auto daughI = mcParticles.rawIteratorAt(dauIdx - mcParticles.offset()); + auto daughI = groupedMcParticles.rawIteratorAt(dauIdx - groupedMcParticles.offset()); + counterDaughters += 1; + prongsId[counterDaughters - 1] = daughI.globalIndex(); + } + } + // Ds Hadron correlation dedicated section + for (const auto& particleAssoc : groupedMcParticles) { + if (std::abs(particleAssoc.eta()) > etaTrackMax || particleAssoc.pt() < ptTrackMin || particleAssoc.pt() > ptTrackMax) { + continue; + } + if (particleAssoc.globalIndex() == prongsId[0] || particleAssoc.globalIndex() == prongsId[1] || particleAssoc.globalIndex() == prongsId[2]) { + 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; + } + // trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); + trackOrigin = RecoDecay::getCharmHadronOrigin(groupedMcParticles, particleAssoc, true); + registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); + entryDsHadronPair(getDeltaPhi(particleAssoc.phi(), particle.phi()), + particleAssoc.eta() - particle.eta(), + particle.pt(), + particleAssoc.pt(), + poolBin); + entryDsHadronRecoInfo(MassDS, true, isDecayChan); + entryDsHadronGenInfo(isDsPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); + } } - trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, particleAssoc, true); - registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); - entryDsHadronPair(getDeltaPhi(particleAssoc.phi(), particle.phi()), - particleAssoc.eta() - particle.eta(), - particle.pt(), - particleAssoc.pt(), - poolBin); - entryDsHadronRecoInfo(MassDS, true, isDecayChan); - entryDsHadronGenInfo(isDsPrompt, particleAssoc.isPhysicalPrimary(), trackOrigin); } + } // end loop reconstructed collision + } // end loop generated collision + } + PROCESS_SWITCH(HfCorrelatorDsHadrons, processMcGen, "Process MC Gen mode", false); + + void processDerivedDataDs(SelCollisionsWithDs::iterator const& collision, + CandDsData const& candidates, + MyTracksData const& tracks) + { + collReduced(collision.multFT0M(), collision.posZ()); + + // Ds fill histograms and Ds candidates information stored + for (const auto& candidate : candidates) { + // candidate selected + if (candidate.isSelDsToKKPi() >= selectionFlagDs) { + candReduced(collReduced.lastIndex(), candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToKKPi(candidate)); + } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { + candReduced(collReduced.lastIndex(), candidate.phi(), candidate.eta(), candidate.pt(), hfHelper.invMassDsToPiKK(candidate)); + } + } + + // tracks information + for (const auto& track : tracks) { + if (!track.isGlobalTrackWoDCA()) { + continue; } + assocTrackReduced(collReduced.lastIndex(), track.phi(), track.eta(), track.pt()); } } - PROCESS_SWITCH(HfCorrelatorDsHadrons, processMcGen, "Process MC Gen mode", false); + PROCESS_SWITCH(HfCorrelatorDsHadrons, processDerivedDataDs, "Process derived data Ds", false); // Event Mixing void processDataME(SelCollisionsWithDs const& collisions, @@ -809,18 +871,15 @@ struct HfCorrelatorDsHadrons { } PROCESS_SWITCH(HfCorrelatorDsHadrons, processMcRecME, "Process Mixed Event MC Rec", false); - void processMcGenME(SelCollisionsWithDsMc const& collisions, + void processMcGenME(SelCollisionsMc const& collisions, CandDsMcGen const& mcParticles) { BinningTypeMcGen corrBinningMcGen{{zPoolBins, multPoolBins}, true}; auto tracksTuple = std::make_tuple(mcParticles, mcParticles); - Pair pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache}; + Pair pairMcGen{corrBinningMcGen, numberEventsMixed, -1, collisions, tracksTuple, &cache}; 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.pdgCode()) != Pdg::kDS) { - continue; - } if ((std::abs(candidate.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (candidate.flagMcDecayChanGen() == decayChannel)) { double yD = RecoDecay::y(candidate.pVector(), MassDS); if (std::abs(yD) > yCandGenMax || candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { diff --git a/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorHfeHadrons.cxx new file mode 100644 index 00000000000..2d9221f7190 --- /dev/null +++ b/PWGHF/HFC/TableProducer/correlatorHfeHadrons.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 correlatorHfeHadrons.cxx +/// \brief Heavy Flavour electron-Hadron correaltor task - data-like, MC-reco and MC-Kine analyses. +/// \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/PID/TPCPIDResponse.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" + +using namespace o2; +using namespace o2::framework; +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}; + +struct HfCorrelatorHfeHadrons { + SliceCache cache; + Produces entryElectronHadronPair; + // Configurables + // Event Selection + Configurable zPvPosMax{"zPvPosMax", 10., "Maximum z of the primary vertex (cm)"}; + Configurable isRun3{"isRun3", true, "Data is from Run3 or Run2"}; + + // 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"}; + Configurable etaTrackMin{"etaTrackMin", -0.8f, "Eta range for associated hadron tracks"}; + Configurable dcaXYTrackMax{"dcaXYTrackMax", 0.5f, "DCA XY cut"}; + Configurable dcaZTrackMax{"dcaZTrackMax", 1.0f, "DCA Z cut"}; + + // Electron hadron correlation condition + Configurable ptCondition{"ptCondition", true, "Electron pT should be greater than associate particle pT"}; + + using TableCollisions = o2::soa::Filtered>; + using TableCollision = TableCollisions::iterator; + using TableTracks = o2::soa::Join; + + 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; + 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}}}; + + 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(); + } + + // Associated Hadron Selection Cut + template + bool selAssoHadron(T const& track) + { + if (!track.isGlobalTrackWoDCA()) { + return false; + } + + if (std::abs(track.dcaXY()) > dcaXYTrackMax || std::abs(track.dcaZ()) > dcaZTrackMax) { + return false; + } + if (track.eta() < etaTrackMin || track.eta() > etaTrackMax) { + return false; + } + if (track.pt() < ptTrackMin) { + return false; + } + return true; + } + + // Electron-hadron Correlation + template + void fillCorrelation(CollisionType const& collision, ElectronType const& electron, TracksType const& tracks) + { + if (!(isRun3 ? collision.sel8() : (collision.sel7() && collision.alias_bit(kINT7)))) + return; + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFV0M())); + + // Construct Deta Phi between electrons and hadrons + + double ptElectron = -999; + double phiElectron = -999; + double etaElectron = -999; + + for (const auto& eTrack : electron) { + ptElectron = eTrack.ptTrack(); + phiElectron = eTrack.phiTrack(); + etaElectron = eTrack.etaTrack(); + + double deltaPhi = -999; + double deltaEta = -999; + double ptHadron = -999; + double etaHadron = -999; + double phiHadron = -999; + + if (!eTrack.isEmcal()) + continue; + + registry.fill(HIST("hptElectron"), ptElectron); + for (const auto& hTrack : tracks) { + if (hTrack.globalIndex() == eTrack.trackId()) + continue; + // Apply Hadron cut + if (!selAssoHadron(hTrack)) + continue; + ptHadron = hTrack.pt(); + phiHadron = hTrack.phi(); + etaHadron = hTrack.eta(); + + if (ptCondition && (ptElectron < ptHadron)) + continue; + 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); + } + } + } + + // mix event electron-hadron correlation + + template + void fillMixCorrelation(CollisionType1 const&, CollisionType2 const& c2, ElectronType const& tracks1, TracksType const& tracks2) + { + if (!(isRun3 ? c2.sel8() : (c2.sel7() && c2.alias_bit(kINT7)))) + return; + double ptElectronMix = -999; + double phiElectronMix = -999; + double etaElectronMix = -999; + double deltaPhiMix = -999; + double deltaEtaMix = -999; + double ptHadronMix = -999; + 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()) + continue; + ptHadronMix = t2.pt(); + ptElectronMix = t1.ptTrack(); + phiElectronMix = t1.phiTrack(); + phiHadronMix = t2.phi(); + etaElectronMix = t1.etaTrack(); + etaHadronMix = t2.eta(); + if (!selAssoHadron(t2)) + continue; + 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); + } + } + + // ======= Process starts for Data, Same event ============ + + void processData(TableCollision const& collision, + aod::HfSelEl const& electron, + TableTracks const& tracks) + { + fillCorrelation(collision, electron, tracks); + } + + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processData, "Process for Data", true); + + // ======= Process starts for McRec, Same event ============ + + void processMcRec(McTableCollision const& mcCollision, + aod::HfSelEl const& mcElectron, + McTableTracks const& mcTracks) + { + fillCorrelation(mcCollision, mcElectron, mcTracks); + } + + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRec, "Process MC Reco mode", false); + + // ====================== Implement Event mixing on Data =================================== + + void processDataMixedEvent(TableCollisions const& collision, aod::HfSelEl const& electron, TableTracks const& tracks) + { + auto tracksTuple = std::make_tuple(electron, tracks); + Pair pair{corrBinning, 5, -1, collision, tracksTuple, &cache}; + + // loop over the rows of the new table + for (auto& [c1, tracks1, c2, tracks2] : pair) { + + fillMixCorrelation(c1, c2, tracks1, tracks2); + } + } + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processDataMixedEvent, "Process Mixed Event Data", false); + + // ====================== Implement Event mixing on McRec =================================== + + void processMcRecMixedEvent(McTableCollisions const& mccollision, aod::HfSelEl const& electron, McTableTracks const& mcTracks) + { + auto tracksTuple = std::make_tuple(electron, mcTracks); + Pair pairMcRec{corrBinning, 5, -1, mccollision, tracksTuple, &cache}; + + // loop over the rows of the new table + for (auto& [c1, tracks1, c2, tracks2] : pairMcRec) { + + fillMixCorrelation(c1, c2, tracks1, tracks2); + } + } + PROCESS_SWITCH(HfCorrelatorHfeHadrons, processMcRecMixedEvent, "Process Mixed Event MC Reco mode", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx b/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx index 141ad2e9b4c..ecd5d7c0bc6 100644 --- a/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx +++ b/PWGHF/HFC/TableProducer/correlatorLcHadrons.cxx @@ -15,6 +15,8 @@ /// \author Marianna Mazzilli /// \author Zhen Zhang +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -30,12 +32,14 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" using namespace o2; using namespace o2::analysis; using namespace o2::constants::physics; 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 @@ -189,10 +193,14 @@ struct HfCorrelatorLcHadrons { 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 + Configurable storeAutoCorrelationFlag{"storeAutoCorrelationFlag", false, "Store flag that indicates if the track is paired to its D-meson mother instead of skipping it"}; + Configurable correlateLcWithLeadingParticle{"correlateLcWithLeadingParticle", false, "Switch for correlation of Lc baryons with leading particle only"}; HfHelper hfHelper; SliceCache cache; BinningType corrBinning{{binsZVtx, binsMultiplicity}, true}; + int leadingIndex = 0; + bool correlationStatus = false; // Filters for ME Filter collisionFilter = aod::hf_selection_lc_collision::lcSel >= filterFlagLc; @@ -263,6 +271,11 @@ struct HfCorrelatorLcHadrons { if (selectedLcCandidates.size() == 0) { return; } + // find leading particle + if (correlateLcWithLeadingParticle) { + leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + } + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); int nTracks = 0; if (collision.numContrib() > 1) { @@ -335,16 +348,27 @@ struct HfCorrelatorLcHadrons { if (std::abs(track.dcaXY()) >= dcaXYTrackMax || std::abs(track.dcaZ()) >= dcaZTrackMax) { continue; // Remove secondary tracks } + // Remove Lc daughters by checking track indices if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { - continue; + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; + } + + if (correlateLcWithLeadingParticle) { + if (track.globalIndex() != leadingIndex) { + continue; + } } if (candidate.isSelLcToPKPi() >= selectionFlagLc) { entryLcHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), track.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(candidate), false); } if (candidate.isSelLcToPiKP() >= selectionFlagLc) { @@ -352,7 +376,8 @@ struct HfCorrelatorLcHadrons { track.eta() - candidate.eta(), candidate.pt(), track.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(candidate), false); } } // Hadron Tracks loop @@ -370,6 +395,11 @@ struct HfCorrelatorLcHadrons { if (selectedLcCandidatesMc.size() == 0) { return; } + // find leading particle + if (correlateLcWithLeadingParticle) { + leadingIndex = findLeadingParticle(tracks, dcaXYTrackMax.value, dcaZTrackMax.value, etaTrackMax.value); + } + int poolBin = corrBinning.getBin(std::make_tuple(collision.posZ(), collision.multFT0M())); int nTracks = 0; if (collision.numContrib() > 1) { @@ -472,16 +502,25 @@ struct HfCorrelatorLcHadrons { } // Removing Lc daughters by checking track indices if ((candidate.prong0Id() == track.globalIndex()) || (candidate.prong1Id() == track.globalIndex()) || (candidate.prong2Id() == track.globalIndex())) { - continue; + if (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; } registry.fill(HIST("hPtParticleAssocMcRec"), track.pt()); + if (correlateLcWithLeadingParticle) { + if (track.globalIndex() != leadingIndex) { + continue; + } + } if (candidate.isSelLcToPKPi() >= selectionFlagLc) { entryLcHadronPair(getDeltaPhi(track.phi(), candidate.phi()), track.eta() - candidate.eta(), candidate.pt(), track.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(candidate), isLcSignal); } if (candidate.isSelLcToPiKP() >= selectionFlagLc) { @@ -489,9 +528,11 @@ struct HfCorrelatorLcHadrons { track.eta() - candidate.eta(), candidate.pt(), track.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(candidate), isLcSignal); } + } // end inner loop (Tracks) } // end outer Lc loop registry.fill(HIST("hZvtx"), collision.posZ()); @@ -506,6 +547,11 @@ struct HfCorrelatorLcHadrons { int counterLcHadron = 0; registry.fill(HIST("hMcEvtCount"), 0); + // find leading particle + if (correlateLcWithLeadingParticle) { + leadingIndex = findLeadingParticleMcGen(mcParticles, etaTrackMax.value, ptTrackMin.value); + } + auto getTracksSize = [&mcParticles](aod::McCollision const& /*collision*/) { int nTracks = 0; for (const auto& track : mcParticles) { @@ -556,15 +602,26 @@ struct HfCorrelatorLcHadrons { } 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 (!storeAutoCorrelationFlag) { + continue; + } + correlationStatus = true; } + + if (correlateLcWithLeadingParticle) { + if (particleAssoc.globalIndex() != leadingIndex) { + continue; + } + } + int poolBin = corrBinningMcGen.getBin(std::make_tuple(mcCollision.posZ(), getTracksSize(mcCollision))); registry.fill(HIST("hPtParticleAssocMcGen"), particleAssoc.pt()); entryLcHadronPair(getDeltaPhi(particleAssoc.phi(), particle.phi()), particleAssoc.eta() - particle.eta(), particle.pt(), particleAssoc.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(MassLambdaCPlus, true); } // end inner loop } @@ -600,7 +657,8 @@ struct HfCorrelatorLcHadrons { t1.eta() - t2.eta(), t1.pt(), t2.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(t1), false); } if (t1.isSelLcToPiKP() >= selectionFlagLc) { @@ -608,7 +666,8 @@ struct HfCorrelatorLcHadrons { t1.eta() - t2.eta(), t1.pt(), t2.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(t1), false); } } @@ -634,7 +693,8 @@ struct HfCorrelatorLcHadrons { t1.eta() - t2.eta(), t1.pt(), t2.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPKPi(t1), false); } if (t1.isSelLcToPiKP() >= selectionFlagLc) { @@ -642,7 +702,8 @@ struct HfCorrelatorLcHadrons { t1.eta() - t2.eta(), t1.pt(), t2.pt(), - poolBin); + poolBin, + correlationStatus); entryLcHadronRecoInfo(hfHelper.invMassLcToPiKP(t1), false); } } @@ -696,7 +757,8 @@ struct HfCorrelatorLcHadrons { t1.eta() - t2.eta(), t1.pt(), t2.pt(), - poolBin); + poolBin, + correlationStatus); } } } diff --git a/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx b/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx index 6335d32203f..7b493c9a733 100644 --- a/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx +++ b/PWGHF/HFC/TableProducer/femtoDreamProducer.cxx @@ -13,6 +13,8 @@ /// \brief Tasks that produces the track tables used for the pairing /// \author Ravindra Singh, GSI, ravindra.singh@cern.ch +#include +#include #include "CCDB/BasicCCDBManager.h" #include "Common/Core/trackUtilities.h" @@ -43,73 +45,81 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::analysis::femtoDream; -struct femtoDreamProducer { +struct HfFemtoDreamProducer { Produces outputCollision; + Produces rowMasks; Produces rowCandCharmHad; - Produces rowCandMCCharmHad; + Produces rowCandMcCharmHad; Produces rowCandCharmHadGen; Produces outputPartsIndex; - Produces outputMCCollision; - Produces outputCollsMCLabels; + Produces outputMcCollision; + Produces outputCollsMcLabels; Produces outputParts; - Produces outputPartsMC; + Produces outputPartsMc; Produces outputDebugParts; - Produces outputPartsMCLabels; - Produces outputDebugPartsMC; - Produces outputPartsExtMCLabels; + Produces outputPartsMcLabels; + Produces outputDebugPartsMc; + Produces outputPartsExtMcLabels; 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)"}; - Configurable isDebug{"isDebug", true, "Enable Debug tables"}; - Configurable isRun3{"isRun3", true, "Running on Run3 or pilot"}; - 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 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)"}; /// Event selection - Configurable doPvRefit{"doPvRefit", false, "do PV refit excluding the considered track"}; - Configurable evtZvtx{"evtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + // Configurable evtZvtx{"evtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + // Configurable evtTriggerCheck{"evtTriggerCheck", true, "Evt sel: check for trigger"}; + // Configurable evtTriggerSel{"evtTriggerSel", kINT7, "Evt sel: trigger"}; + // Configurable evtOfflineCheck{"evtOfflineCheck", false, "Evt sel: check for offline selection"}; + // Configurable evtAddOfflineCheck{"evtAddOfflineCheck", false, "Evt sel: additional checks for offline selection (not part of sel8 yet)"}; + + Configurable evtAddOfflineCheck{"evtAddOfflineCheck", false, "Evt sel: additional checks for offline selection (not part of sel8 yet)"}; + Configurable evtOfflineCheck{"evtOfflineCheck", false, "Evt sel: check for offline selection"}; Configurable evtTriggerCheck{"evtTriggerCheck", true, "Evt sel: check for trigger"}; Configurable evtTriggerSel{"evtTriggerSel", kINT7, "Evt sel: trigger"}; - Configurable evtOfflineCheck{"evtOfflineCheck", false, "Evt sel: check for offline selection"}; - Configurable evtAddOfflineCheck{"evtAddOfflineCheck", false, "Evt sel: additional checks for offline selection (not part of sel8 yet)"}; + Configurable evtZvtx{"evtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + + Configurable isDebug{"isDebug", true, "Enable Debug tables"}; + Configurable isRun3{"isRun3", true, "Running on Run3 or pilot"}; /// Lc table - Configurable useCent{"useCent", false, "Enable centrality for lc"}; Configurable selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc"}; + Configurable useCent{"useCent", false, "Enable centrality for lc"}; - Configurable trkRejectNotPropagated{"trkRejectNotPropagated", false, "True: reject not propagated tracks"}; Configurable trkPDGCode{"trkPDGCode", 2212, "PDG code of the selected track for Monte Carlo truth"}; Configurable> trkCharge{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kSign, "trk"), std::vector{-1, 1}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kSign, "Track selection: ")}; - Configurable> trkPtmin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMin, "trk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMin, "Track selection: ")}; - Configurable> trkPtmax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMax, "trk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMax, "Track selection: ")}; - Configurable> trkEta{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kEtaMax, "trk"), std::vector{0.8f, 0.7f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kEtaMax, "Track selection: ")}; - Configurable> trkTPCnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCnClsMin, "trk"), std::vector{80.f, 70.f, 60.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCnClsMin, "Track selection: ")}; - Configurable> trkTPCfCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCfClsMin, "trk"), std::vector{0.7f, 0.83f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCfClsMin, "Track selection: ")}; - Configurable> trkTPCcRowsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCcRowsMin, "trk"), std::vector{70.f, 60.f, 80.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCcRowsMin, "Track selection: ")}; - Configurable> trkTPCsCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCsClsMax, "trk"), std::vector{0.1f, 160.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCsClsMax, "Track selection: ")}; - Configurable> trkITSnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsMin, "trk"), std::vector{-1.f, 2.f, 4.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsMin, "Track selection: ")}; - Configurable> trkITSnclsIbMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kITSnClsIbMin, "trk"), std::vector{-1.f, 1.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kITSnClsIbMin, "Track selection: ")}; Configurable> trkDCAxyMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kDCAxyMax, "trk"), std::vector{0.1f, 3.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kDCAxyMax, "Track selection: ")}; Configurable> trkDCAzMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kDCAzMax, "trk"), std::vector{0.2f, 3.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kDCAzMax, "Track selection: ")}; + Configurable> trkEta{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kEtaMax, "trk"), std::vector{0.8f, 0.7f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kEtaMax, "Track selection: ")}; + Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton}, "Trk sel: Particles species for PID"}; Configurable> trkPIDnSigmaMax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kPIDnSigmaMax, "trk"), std::vector{3.5f, 3.f, 2.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kPIDnSigmaMax, "Track selection: ")}; Configurable trkPIDnSigmaOffsetTPC{"trkPIDnSigmaOffsetTPC", 0., "Offset for TPC nSigma because of bad calibration"}; Configurable trkPIDnSigmaOffsetTOF{"trkPIDnSigmaOffsetTOF", 0., "Offset for TOF nSigma because of bad calibration"}; - Configurable> trkPIDspecies{"trkPIDspecies", std::vector{o2::track::PID::Pion, o2::track::PID::Kaon, o2::track::PID::Proton}, "Trk sel: Particles species for PID"}; + Configurable> trkPtmax{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMax, "trk"), std::vector{5.4f, 5.6f, 5.5f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMax, "Track selection: ")}; + Configurable> trkPtmin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kpTMin, "trk"), std::vector{0.5f, 0.4f, 0.6f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kpTMin, "Track selection: ")}; + Configurable> trkTPCcRowsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCcRowsMin, "trk"), std::vector{70.f, 60.f, 80.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCcRowsMin, "Track selection: ")}; + Configurable> trkTPCfCls{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCfClsMin, "trk"), std::vector{0.7f, 0.83f, 0.9f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCfClsMin, "Track selection: ")}; + Configurable> trkTPCnclsMin{FemtoDreamTrackSelection::getSelectionName(femtoDreamTrackSelection::kTPCnClsMin, "trk"), std::vector{80.f, 70.f, 60.f}, FemtoDreamTrackSelection::getSelectionHelper(femtoDreamTrackSelection::kTPCnClsMin, "Track selection: ")}; + 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: ")}; using CandidateLc = soa::Join; - using CandidateLcMC = 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 FemtoFullCollisionMc = soa::Join::iterator; + using FemtoFullMcgenCollisions = soa::Join; + using FemtoFullMcgenCollision = FemtoFullMcgenCollisions::iterator; using FemtoHFTracks = soa::Join; using FemtoHFTrack = FemtoHFTracks::iterator; + using FemtoHFMcTracks = soa::Join; + using FemtoHFMcTrack = FemtoHFMcTracks::iterator; - using GeneratedMC = soa::Filtered>; + using GeneratedMc = soa::Filtered>; FemtoDreamCollisionSelection colCuts; FemtoDreamTrackSelection trackCuts; @@ -120,15 +130,17 @@ struct femtoDreamProducer { HistogramRegistry TrackRegistry{"Tracks", {}, OutputObjHandlingPolicy::AnalysisObject}; HfHelper hfHelper; - int runNumber; + 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 void init(InitContext&) { - std::array processes = {doprocessDataCharmHad, doprocessMCCharmHad, doprocessDataCharmHadWithML, doprocessMCCharmHadWithML, doprocessMCCharmHadGen}; + std::array processes = {doprocessDataCharmHad, doprocessMcCharmHad, doprocessDataCharmHadWithML, doprocessMcCharmHadWithML, doprocessMcCharmHadGen}; if (std::accumulate(processes.begin(), processes.end(), 0) != 1) { LOGP(fatal, "One and only one process function must be enabled at a time."); } @@ -170,41 +182,7 @@ struct femtoDreamProducer { /// Function to retrieve the nominal magnetic field in kG (0.1T) and convert it directly to T void getMagneticFieldTesla(aod::BCsWithTimestamps::iterator bc) { - // auto bc = col.bc_as(); initCCDB(bc, runNumber, ccdb, !isRun3 ? ccdbPathGrp : ccdbPathGrpMag, lut, !isRun3); - - // // TODO done only once (and not per run). Will be replaced by CCDBConfigurable - // // get magnetic field for run - // if (runNumber == bc.runNumber()) - // return; - // auto timestamp = bc.timestamp(); - // float output = -999; - // - // if (isRun3 && !isForceGRP) { - // 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()); - // } - // magField = output; - // runNumber = bc.runNumber(); } template @@ -221,77 +199,95 @@ struct femtoDreamProducer { particle.dcaXY(), particle.dcaZ(), particle.tpcSignal(), + -999., particle.tpcNSigmaPi(), particle.tpcNSigmaKa(), particle.tpcNSigmaPr(), + -999., + -999., + -999., + -999., particle.tofNSigmaPi(), particle.tofNSigmaKa(), particle.tofNSigmaPr(), - -999., -999., -999., -999., -999., -999., -999., -999., -999., -999.); + -999., + -999., + -999., + -999., -999., -999., -999., -999., -999.); } template - void fillMCParticle(CollisionType const& col, ParticleType const& particle, o2::aod::femtodreamparticle::ParticleType fdparttype) + 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(); + auto particleMc = particle.mcParticle(); + auto pdgCode = particleMc.pdgCode(); int particleOrigin = 99; int pdgCodeMother = -1; - // get list of mothers - // could be empty (for example in case of injected light nuclei) - auto motherparticlesMC = particleMC.template mothers_as(); + // 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 (std::abs(pdgCode) == abs(trkPDGCode.value)) { - if ((col.has_mcCollision() && (particleMC.mcCollisionId() != col.mcCollisionId())) || !col.has_mcCollision()) { + // if this fails, the particle is a fake + if (abs(pdgCode) == 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()) { particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kWrongCollision; - } else if (particleMC.isPhysicalPrimary()) { + // check if particle is primary + } else if (particleMc.isPhysicalPrimary()) { particleOrigin = aod::femtodreamMCparticle::ParticleOriginMCTruth::kPrimary; - } else if (particleMC.getGenStatusCode() == -1) { + // 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(); + 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; - } else if (!motherparticlesMC.empty()) { - // get direct mother of the particle - auto motherparticleMC = motherparticlesMC.front(); - pdgCodeMother = motherparticleMC.pdgCode(); - if (motherparticleMC.isPhysicalPrimary() && particleMC.getProcess() == 4) { - particleOrigin = checkDaughterType(fdparttype, motherparticleMC.pdgCode()); - } + // 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()); + outputPartsMc(particleOrigin, pdgCode, particleMc.pt(), particleMc.eta(), particleMc.phi()); + outputPartsMcLabels(outputPartsMc.lastIndex()); if (isDebug) { - outputPartsExtMCLabels(outputPartsMC.lastIndex()); - outputDebugPartsMC(pdgCodeMother); + outputPartsExtMcLabels(outputPartsMc.lastIndex()); + outputDebugPartsMc(pdgCodeMother); } } else { - outputPartsMCLabels(-1); + outputPartsMcLabels(-1); if (isDebug) { - outputPartsExtMCLabels(-1); + outputPartsExtMcLabels(-1); } } } template - void fillMCCollision(CollisionType const& col) + void fillMcCollision(CollisionType const& col) { if (col.has_mcCollision()) { - auto genMCcol = col.template mcCollision_as(); - outputMCCollision(genMCcol.multMCNParticlesEta08()); - outputCollsMCLabels(outputMCCollision.lastIndex()); + // auto genMCcol = col.template mcCollision_as(); + // outputMcCollision(genMCcol.multMCNParticlesEta08()); + outputCollsMcLabels(outputMcCollision.lastIndex()); } else { - outputCollsMCLabels(-1); + outputCollsMcLabels(-1); } } - template - bool fillTracksForCharmHadron(TrackType const& tracks, FemtoHFTrack const& prong0, FemtoHFTrack const& prong1, FemtoHFTrack const& prong2, int candSize) + template + bool fillTracksForCharmHadron(CollisionType const& col, TrackType const& tracks) { std::vector childIDs = {0, 0}; // these IDs are necessary to keep track of the children @@ -305,9 +301,6 @@ struct femtoDreamProducer { continue; } - if ((candSize == 1) && (track.globalIndex() == prong0.globalIndex() || track.globalIndex() == prong1.globalIndex() || track.globalIndex() == prong2.globalIndex())) - continue; - 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))); @@ -316,7 +309,7 @@ struct femtoDreamProducer { outputPartsIndex(track.globalIndex()); // now the table is filled - outputParts(outputCollision.lastIndex() + 1, + outputParts(outputCollision.lastIndex(), track.pt(), track.eta(), track.phi(), @@ -330,23 +323,18 @@ struct femtoDreamProducer { fillDebugParticle(track); } - if constexpr (isMC) { - fillMCParticle(track, o2::aod::femtodreamparticle::ParticleType::kTrack); - // if constexpr (isMC) { - // fillMCParticle(col, track, o2::aod::femtodreamparticle::ParticleType::kTrack); - // } + if constexpr (isMc) { + fillMcParticle(col, track, o2::aod::femtodreamparticle::ParticleType::kTrack); } } return fIsTrackFilled; } - template + template void fillCharmHadronTable(CollisionType const& col, TrackType const& tracks, CandType const& candidates) { const auto vtxZ = col.posZ(); const auto sizeCand = candidates.size(); - if (sizeCand == 0) - return; const auto spher = colCuts.computeSphericity(col, tracks); float mult = 0; @@ -374,6 +362,12 @@ struct femtoDreamProducer { if (colCuts.isEmptyCollision(col, tracks, trackCuts)) { return; } + + outputCollision(vtxZ, mult, multNtr, spher, magField); + if constexpr (isMc) { + fillMcCollision(col); + } + // Filling candidate properties rowCandCharmHad.reserve(sizeCand); bool isTrackFilled = false; @@ -394,9 +388,9 @@ struct femtoDreamProducer { outputMlPiKP.at(2) = candidate.mlProbLcToPiKP()[2]; /// non-prompt score } } - 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 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 fillTable = [&](int CandFlag, int FunctionSelection, @@ -404,19 +398,6 @@ struct femtoDreamProducer { float BDTScorePrompt, float BDTScoreFD) { if (FunctionSelection >= 1){ - // Fill tracks if it is not filled for Lc Candidate in an event - if (!isTrackFilled) { - isTrackFilled = fillTracksForCharmHadron(tracks, trackPos1, trackNeg, trackPos2, sizeCand); - - // If track filling was successful, fill the collision table - if (isTrackFilled) { - outputCollision(vtxZ, mult, multNtr, spher, magField); - } - } - - // fill collision table if track table is filled, i.e., there is at least one Lc-p pair - if (isTrackFilled) { - // Row for candidate charm hadron rowCandCharmHad( outputCollision.lastIndex(), trackPos1.sign() + trackNeg.sign() + trackPos2.sign(), @@ -437,18 +418,35 @@ struct femtoDreamProducer { BDTScorePrompt, BDTScoreFD); - // Row for MC candidate charm hadron (if constexpr isMC) - if constexpr (isMC) { - rowCandMCCharmHad( - candidate.flagMcMatchRec(), - candidate.originMcRec()); - } - } + // 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)); fillTable(1, candidate.isSelLcToPiKP(), outputMlPiKP.at(0), outputMlPiKP.at(1), outputMlPiKP.at(2)); } + + if (!isTrackFilled) { + isTrackFilled = fillTracksForCharmHadron(col, tracks); + // If track filling was successful, fill the collision table + } + + aod::femtodreamcollision::BitMaskType bitTrack = 0; + if (isTrackFilled) { + bitTrack |= 1 << 0; + } + + aod::femtodreamcollision::BitMaskType bitCand = 0; + if (sizeCand > 0) { + bitCand |= 1 << 0; + } + + rowMasks(static_cast(bitTrack), + static_cast(bitCand), + 0); } template @@ -476,7 +474,7 @@ struct femtoDreamProducer { fillCharmHadronTable(col, tracks, candidates); } - PROCESS_SWITCH(femtoDreamProducer, processDataCharmHad, + PROCESS_SWITCH(HfFemtoDreamProducer, processDataCharmHad, "Provide experimental data for charm hadron femto", false); void processDataCharmHadWithML(FemtoFullCollision const& col, @@ -491,47 +489,45 @@ struct femtoDreamProducer { fillCharmHadronTable(col, tracks, candidates); } - PROCESS_SWITCH(femtoDreamProducer, processDataCharmHadWithML, + PROCESS_SWITCH(HfFemtoDreamProducer, processDataCharmHadWithML, "Provide experimental data for charm hadron femto with ml", false); - void processMCCharmHad(FemtoFullCollisionMC const& col, + void processMcCharmHad(FemtoFullCollisionMc const& col, aod::BCsWithTimestamps const&, - soa::Join const& tracks, - soa::Filtered const& candidates, - GeneratedMC const& /*particles*/) + FemtoHFMcTracks const& tracks, + aod::McParticles const&, + CandidateLcMc const& candidates) { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); fillCharmHadronTable(col, tracks, candidates); } - PROCESS_SWITCH(femtoDreamProducer, processMCCharmHad, "Provide MC for charm hadron", false); + PROCESS_SWITCH(HfFemtoDreamProducer, processMcCharmHad, "Provide Mc for charm hadron", false); - void processMCCharmHadWithML(FemtoFullCollisionMC const& col, + void processMcCharmHadWithML(FemtoFullCollisionMc const& col, aod::BCsWithTimestamps const&, - soa::Join const& tracks, - soa::Filtered> const& candidates, - GeneratedMC const& /*particles*/) + FemtoHFMcTracks const& tracks, + aod::McParticles const&, + soa::Join const& candidates) { // get magnetic field for run getMagneticFieldTesla(col.bc_as()); fillCharmHadronTable(col, tracks, candidates); } - PROCESS_SWITCH(femtoDreamProducer, processMCCharmHadWithML, "Provide MC for charm hadron with ml", false); + PROCESS_SWITCH(HfFemtoDreamProducer, processMcCharmHadWithML, "Provide Mc for charm hadron with ml", false); - void processMCCharmHadGen(GeneratedMC const& particles) + void processMcCharmHadGen(GeneratedMc const& particles) { fillCharmHadMcGen(particles); } - PROCESS_SWITCH(femtoDreamProducer, processMCCharmHadGen, "Provide MC Generated charm hadron", false); + PROCESS_SWITCH(HfFemtoDreamProducer, processMcCharmHadGen, "Provide Mc Generated charm hadron", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGHF/HFC/Tasks/CMakeLists.txt b/PWGHF/HFC/Tasks/CMakeLists.txt index af150b89849..ec2e1779ebf 100644 --- a/PWGHF/HFC/Tasks/CMakeLists.txt +++ b/PWGHF/HFC/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(femtodream-pair-charm-hadrons - SOURCES femtoDreamPairTaskCharmHadrons.cxx +o2physics_add_dpl_workflow(task-charm-hadrons-femto-dream + SOURCES taskCharmHadronsFemtoDream.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) @@ -44,6 +44,11 @@ o2physics_add_dpl_workflow(task-correlation-dstar-hadrons PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-correlation-hfe-hadrons + SOURCES taskCorrelationHfeHadrons.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-correlation-lc-hadrons SOURCES taskCorrelationLcHadrons.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/PWGHF/HFC/Tasks/femtoDreamPairTaskCharmHadrons.cxx b/PWGHF/HFC/Tasks/femtoDreamPairTaskCharmHadrons.cxx deleted file mode 100644 index 7fe13bc00b3..00000000000 --- a/PWGHF/HFC/Tasks/femtoDreamPairTaskCharmHadrons.cxx +++ /dev/null @@ -1,365 +0,0 @@ -// 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 femtoDreamPairTaskCharmHadrons.cxx -/// \brief Tasks that reads the track tables used for the pairing and builds pairs of two tracks -/// \author Ravindra SIngh, GSI, ravindra.singh@cern.ch - -#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/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 femtoDreamPairTaskCharmHadrons { - - enum PairCharge { - positiveCharge = 1, - negativeCharge = -1 - }; - - /// General options - Configurable ConfOptCPRPlotPerRadii{"ConfOptCPRPlotPerRadii", false, "Plot CPR per radii"}; - Configurable ConfOptUseCPR{"ConfOptUseCPR", false, "Close Pair Rejection"}; - Configurable ConfOptCPRdeltaEtaMax{"ConfOptCPRdeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; - Configurable ConfOptCPRdeltaPhiMax{"ConfOptCPRdeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; - Configurable ConfOptExtendedPlots{"ConfOptExtendedPlots", false, "Enable additional three dimensional histogramms. High memory consumption. Use for debugging"}; - Configurable ConfOptHighkstarCut{"ConfOptHighkstarCut", 100000., "Set a cut for high k*, above which the pairs are rejected"}; - Configurable ConfOptisMc{"ConfOptisMc", false, "Enable additional Histogramms in the case of a MonteCarlo Run"}; - Configurable ConfOptsmearingByOrigin{"ConfOptsmearingByOrigin", false, "Obtain the smearing matrix differential in the MC origin of particle 1 and particle 2. High memory consumption. Use with care!"}; - Configurable ConfOptUse4D{"ConfOptUse4D", false, "Enable four dimensional histogramms (to be used only for analysis with high statistics): k* vs multiplicity vs multiplicity percentil vs mT"}; - ConfigurableAxis ConfOptDummy{"ConfOptDummy", {1, 0, 1}, "Dummy axis"}; - - /// Event selection - Configurable ConfEvent_maxMult{"ConfEvent_maxMult", 99999, "Maximum Multiplicity (MultNtr)"}; - Configurable ConfEvent_maxMultPercentile{"ConfEvent_maxMultPercentile", 100, "Maximum Multiplicity Percentile"}; - Configurable ConfEvent_minMult{"ConfEvent_minMult", 0, "Minimum Multiplicity (MultNtr)"}; - Configurable ConfEvent_minMultPercentile{"ConfEvent_minMultPercentile", 0, "Minimum Multiplicity Percentile"}; - - /// Particle 1 (track) - Configurable ConfTrk1_CutBit{"ConfTrk1_CutBit", 5542474, "Particle 1 (Track) - Selection bit from cutCulator"}; - Configurable ConfTrk1_PDGCode{"ConfTrk1_PDGCode", 2212, "PDG code of Particle 1 (Track)"}; - Configurable ConfTrk1_PIDThres{"ConfTrk1_PIDThres", 0.75, "Momentum threshold for PID selection for particle 1 (Track)"}; - Configurable ConfTrk1_TPCBit{"ConfTrk1_TPCBit", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; - Configurable ConfTrk1_TPCTOFBit{"ConfTrk1_TPCTOFBit", 2, "PID TPCTOF bit from cutCulator for particle 1 (Track)"}; - Configurable ConfTrk1_maxEta{"ConfTrk1_maxEta", 10., "Maximum eta of partricle 1 (Track)"}; - Configurable ConfTrk1_maxPt{"ConfTrk1_maxPt", 999., "Maximum pT of partricle 1 (Track)"}; - Configurable ConfTrk1_minEta{"ConfTrk1_minEta", -10., "Minimum eta of partricle 1 (Track)"}; - Configurable ConfTrk1_minPt{"ConfTrk1_minPt", 0., "Minimum pT of partricle 1 (Track)"}; - - /// Particle 2 (Charm Hadrons) - Configurable ConfHF_bkgBDT{"ConfHF_bkgBDT", 1., "Maximum background bdt score for Charm Hadron (particle 2)"}; - Configurable ConfHF_CandSel{"ConfHF_CandSel", 1, "candidate selection for charm hadron"}; - Configurable ConfHF_fdBDT{"ConfHF_fdBDT", 0., "Minimum feed-down bdt score Charm Hadron (particle 2)"}; - Configurable ConfHF_maxInvMass{"ConfHF_maxInvMass", 2.45, "Maximum invariant mass of Charm Hadron (particle 2)"}; - Configurable ConfHF_maxPt{"ConfHF_maxPt", 999., "Maximum pT of Charm Hadron (particle 2)"}; - Configurable ConfHF_minInvMass{"ConfHF_minInvMass", 2.15, "Minimum invariant mass of Charm Hadron (particle 2)"}; - Configurable ConfHF_minPt{"ConfHF_minPt", 0., "Minimum pT of Charm Hadron (particle 2)"}; - Configurable ConfHF_PDGCode{"ConfHF_PDGCode", 4122, "PDG code of particle 2 Charm Hadron"}; - Configurable ConfHF_promptBDT{"ConfHF_promptBDT", 0., "Minimum prompt bdt score Charm Hadron (particle 2)"}; - - /// Binning configurables - ConfigurableAxis ConfBin4Dkstar{"ConfBin4Dkstar", {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 ConfBin4DMult{"ConfBin4Dmult", {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 ConfBin4DmT{"ConfBin4DmT", {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 ConfBin4DmultPercentile{"ConfBin4DmultPercentile", {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)"}; - ConfigurableAxis ConfBinInvMass{"ConfBinInvMass", {300, 2.15, 2.45}, "InvMass binning"}; - ConfigurableAxis ConfBinTempFitVarHF{"ConfBinTempFitVarHF", {300, 0.9, 1}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis ConfBinTempFitVarHFChild{"ConfBinTempFitVarHFChild", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (V0 child)"}; - ConfigurableAxis ConfBinTempFitVarTrack{"ConfBinTempFitVarTrack", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Track)"}; - ConfigurableAxis ConfBinmT{"ConfBinmT", {225, 0., 7.5}, "binning mT"}; - ConfigurableAxis ConfBinmultTempFit{"ConfBinmultTempFit", {1, 0, 1}, "multiplicity Binning for the TempFitVar plot"}; - ConfigurableAxis ConfBinpT{"ConfBinpT", {20, 0.5, 4.05}, "pT binning"}; - ConfigurableAxis ConfBinpTHF{"ConfBinpTHF", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis ConfBinpTHFChild{"ConfBinpTHFChild", {20, 0.5, 4.05}, "pT binning of the pT vs. TempFitVar plot (V0)"}; - ConfigurableAxis ConfBinpTTrack{"ConfBinpTTrack", {50, 0.5, 10.05}, "pT binning of the pT vs. TempFitVar plot (Track)"}; - ConfigurableAxis ConfBinkT{"ConfBinkT", {150, 0., 9.}, "binning kT"}; - ConfigurableAxis ConfBinkstar{"ConfBinkstar", {1500, 0., 6.}, "binning kstar"}; - - // Mixing configurables - ConfigurableAxis ConfMixingBinMult{"ConfMixingBinMult", {VARIABLE_WIDTH, 0.0f, 200.0f}, "Mixing bins - multiplicity"}; - ConfigurableAxis ConfMixingBinMultPercentile{"ConfMixingBinMultPercentile", {VARIABLE_WIDTH, 0.0f, 100.f}, "Mixing bins - multiplicity percentile"}; - ConfigurableAxis ConfMixingBinVztx{"ConfMixingBinVztx", {VARIABLE_WIDTH, -10.0f, -4.f, 0.f, 4.f, 10.f}, "Mixing bins - z-vertex"}; - Configurable ConfMixingDepth{"ConfMixingDepth", 5, "Number of events for mixing"}; - Configurable ConfMixingPolicy{"ConfMixingBinPolicy", 0, "Binning policy for mixing - 0: multiplicity, 1: multipliciy percentile, 2: both"}; - - ColumnBinningPolicy colBinningMult{{ConfMixingBinVztx, ConfMixingBinMult}, true}; - ColumnBinningPolicy colBinningMultPercentile{{ConfMixingBinVztx, ConfMixingBinMultPercentile}, true}; - ColumnBinningPolicy colBinningMultMultPercentile{{ConfMixingBinVztx, ConfMixingBinMult, ConfMixingBinMultPercentile}, true}; - - FemtoDreamContainer sameEventCont; - FemtoDreamContainer mixedEventCont; - FemtoDreamPairCleaner pairCleaner; - FemtoDreamDetaDphiStar pairCloseRejection; - - Filter trackEtaFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta < ConfTrk1_maxEta, true); - Filter trackEtaFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta > ConfTrk1_minEta, true); - Filter trackPtFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt < ConfTrk1_maxPt, true); - Filter trackPtFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt > ConfTrk1_minPt, true); - Filter hfCandSelFilter = aod::fdhf::candidateSelFlag >= ConfHF_CandSel.value; - - using FilteredCharmCands = soa::Filtered; - using FilteredCharmCand = FilteredCharmCands::iterator; - - using FilteredCharmMCCands = soa::Filtered>; - using FilteredCharmMCCand = FilteredCharmMCCands::iterator; - - using FilteredColisions = FDCollisions; - using FilteredColision = FilteredColisions::iterator; - - using FilteredFDMCParts = soa::Filtered>; - using FilteredFDMCPart = FilteredFDMCParts::iterator; - - using FilteredFDParticles = soa::Filtered>; - using FilteredFDParticle = FilteredFDParticles::iterator; - - /// Histogramming for particle 1 - FemtoDreamParticleHisto trackHistoPartOne; - - /// Partition for particle 1 - - Partition PartitionTrk1 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)); - - Partition PartitionMCTrk1 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && - (ncheckbit(aod::femtodreamparticle::cut, ConfTrk1_CutBit)) && - ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfTrk1_PIDThres, ncheckbit(aod::femtodreamparticle::pidcut, ConfTrk1_TPCBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTrk1_TPCTOFBit)); - - /// Partition for particle 2 - Partition PartitionHF = aod::fdhf::bdtBkg < ConfHF_bkgBDT && aod::fdhf::bdtPrompt > ConfHF_promptBDT; - /// Histogramming for Event - FemtoDreamEventHisto eventHisto; - - /// Histogram output - HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry resultRegistry{"CorrelationsHF", {}, OutputObjHandlingPolicy::AnalysisObject}; - - float MassOne = o2::analysis::femtoDream::getMass(ConfTrk1_PDGCode); - float MassTwo = o2::analysis::femtoDream::getMass(ConfHF_PDGCode); - int8_t partSign = 0; - int64_t processType = 0; - - SliceCache cache; - Preslice perCol = aod::femtodreamparticle::fdCollisionId; - Produces fillFemtoResult; - - void init(InitContext& /*context*/) - { - eventHisto.init(&qaRegistry); - trackHistoPartOne.init(&qaRegistry, ConfBinmultTempFit, ConfOptDummy, ConfBinpTTrack, ConfOptDummy, ConfOptDummy, ConfBinTempFitVarTrack, ConfOptDummy, ConfOptDummy, ConfOptDummy, ConfOptDummy, ConfOptDummy, ConfOptisMc, ConfTrk1_PDGCode); - - sameEventCont.init(&resultRegistry, - ConfBinkstar, ConfBinpT, ConfBinkT, ConfBinmT, ConfMixingBinMult, ConfMixingBinMultPercentile, - ConfBin4Dkstar, ConfBin4DmT, ConfBin4DMult, ConfBin4DmultPercentile, - ConfOptisMc, ConfOptUse4D, ConfOptExtendedPlots, - ConfOptHighkstarCut, - ConfOptsmearingByOrigin, ConfBinInvMass); - - sameEventCont.setPDGCodes(ConfTrk1_PDGCode, ConfHF_PDGCode); - mixedEventCont.init(&resultRegistry, - ConfBinkstar, ConfBinpT, ConfBinkT, ConfBinmT, ConfMixingBinMult, ConfMixingBinMultPercentile, - ConfBin4Dkstar, ConfBin4DmT, ConfBin4DMult, ConfBin4DmultPercentile, - ConfOptisMc, ConfOptUse4D, ConfOptExtendedPlots, - ConfOptHighkstarCut, - ConfOptsmearingByOrigin, ConfBinInvMass); - - mixedEventCont.setPDGCodes(ConfTrk1_PDGCode, ConfHF_PDGCode); - pairCleaner.init(&qaRegistry); - if (ConfOptUseCPR.value) { - pairCloseRejection.init(&resultRegistry, &qaRegistry, ConfOptCPRdeltaPhiMax.value, ConfOptCPRdeltaEtaMax.value, ConfOptCPRPlotPerRadii.value); - } - } - - /// This function processes the same event and takes care of all the histogramming - template - void doSameEvent(PartitionType& SliceTrk1, CandType& SliceCharmHad, TableTracks const& parts, TableCandidates const& /*candidates*/, Collision const& col) - { - processType = 1; // for same event - /// Histogramming same event - for (auto const& part : SliceTrk1) { - - trackHistoPartOne.fillQA(part, aod::femtodreamparticle::kPt, col.multNtr(), col.multV0M()); - } - for (auto const& [p1, p2] : combinations(CombinationsFullIndexPolicy(SliceTrk1, SliceCharmHad))) { - // proton track charge - float chargeTrack = 0.; - if ((p1.cut() & 1) == 1) { - chargeTrack = positiveCharge; - } else { - chargeTrack = negativeCharge; - } - - if (chargeTrack != p2.charge()) - continue; - float kstar = FemtoDreamMath::getkstar(p1, MassOne, p2, MassTwo); - if (kstar > ConfOptHighkstarCut) - continue; - - if (chargeTrack == 1) { - partSign = 1; - } else { - partSign = 1 << 1; - } - - if (ConfOptUseCPR.value) { - if (pairCloseRejection.isClosePair(p1, p2, parts, col.magField())) { - continue; - } - } - - if (!pairCleaner.isCleanPair(p1, p2, parts)) { - continue; - } - float invMass; - if (p2.candidateSelFlag() == 1) { - invMass = p2.m(std::array{o2::constants::physics::MassProton, o2::constants::physics::MassKPlus, o2::constants::physics::MassPiPlus}); - } else { - invMass = p2.m(std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus, o2::constants::physics::MassProton}); - } - - if (invMass < ConfHF_minInvMass || invMass > ConfHF_maxInvMass) - continue; - if (p2.pt() < ConfHF_minPt || p2.pt() > ConfHF_maxPt) - continue; - - 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), - col.multNtr(), - col.multV0M(), - partSign, - processType); - - sameEventCont.setPair(p1, p2, col.multNtr(), col.multV0M(), ConfOptUse4D, ConfOptExtendedPlots, ConfOptsmearingByOrigin); - } - } - - void processSameEvent(FilteredColision const& col, FilteredFDParticles const& parts, FilteredCharmCands const& candidates) - { - eventHisto.fillQA(col); - auto SliceTrk1 = PartitionTrk1->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); - auto SliceCharmHad = PartitionHF->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); - doSameEvent(SliceTrk1, SliceCharmHad, parts, candidates, col); - } - PROCESS_SWITCH(femtoDreamPairTaskCharmHadrons, processSameEvent, "Enable processing same event", true); - - template - void doMixedEvent(CollisionType const& cols, PartType const& parts, PartitionType1& part1, PartitionType2& /*part2*/, BinningType policy) - { - processType = 1 << 1; // for mixed event - - for (auto const& [collision1, collision2] : soa::selfCombinations(policy, ConfMixingDepth.value, -1, cols, cols)) { - - auto SliceTrk1 = part1->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); - auto SliceCharmHad = PartitionHF->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); - for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(SliceTrk1, SliceCharmHad))) { - - float chargeTrack = 0.; - if ((p1.cut() & 1) == 1) { - chargeTrack = positiveCharge; - } else { - chargeTrack = negativeCharge; - } - - if (chargeTrack != p2.charge()) - continue; - float kstar = FemtoDreamMath::getkstar(p1, MassOne, p2, MassTwo); - if (kstar > ConfOptHighkstarCut) - 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}); - } else { - invMass = p2.m(std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus, o2::constants::physics::MassProton}); - } - 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(), - partSign, - processType); - - if (ConfOptUseCPR.value) { - if (pairCloseRejection.isClosePair(p1, p2, parts, collision1.magField())) { - continue; - } - } - if (!pairCleaner.isCleanPair(p1, p2, parts)) { - continue; - } - mixedEventCont.setPair(p1, p2, collision1.multNtr(), collision1.multV0M(), ConfOptUse4D, ConfOptExtendedPlots, ConfOptsmearingByOrigin); - } - } - } - - void processMixedEvent(FilteredColisions const& cols, FilteredFDParticles const& parts, FilteredCharmCands const& /*candidates*/) - { - switch (ConfMixingPolicy.value) { - case femtodreamcollision::kMult: - doMixedEvent(cols, parts, PartitionTrk1, PartitionHF, colBinningMult); - break; - case femtodreamcollision::kMultPercentile: - doMixedEvent(cols, parts, PartitionTrk1, PartitionHF, colBinningMultPercentile); - break; - case femtodreamcollision::kMultMultPercentile: - doMixedEvent(cols, parts, PartitionTrk1, PartitionHF, colBinningMultMultPercentile); - break; - default: - LOG(fatal) << "Invalid binning policiy specifed. Breaking..."; - } - } - PROCESS_SWITCH(femtoDreamPairTaskCharmHadrons, processMixedEvent, "Enable processing mixed events", true); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx b/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx new file mode 100644 index 00000000000..f7aad26d676 --- /dev/null +++ b/PWGHF/HFC/Tasks/taskCharmHadronsFemtoDream.cxx @@ -0,0 +1,513 @@ +// 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 taskCharmHadronsFemtoDream.cxx.cxx +/// \brief Tasks that reads the track tables used for the pairing and builds pairs of two tracks +/// \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/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 HfTaskCharmHadronsFemtoDream { + + enum TrackCharge { + PositiveCharge = 1, + 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)"}; + ConfigurableAxis bin4DmT{"bin4DmT", {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 bin4DmultPercentile{"bin4DmultPercentile", {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)"}; + ConfigurableAxis binInvMass{"binInvMass", {300, 2.15, 2.45}, "InvMass binning"}; + ConfigurableAxis binTempFitVarTrack{"binTempFitVarTrack", {300, -0.15, 0.15}, "binning of the TempFitVar in the pT vs. TempFitVar plot (Track)"}; + ConfigurableAxis binmT{"binmT", {225, 0., 7.5}, "binning mT"}; + ConfigurableAxis binmultTempFit{"binmultTempFit", {1, 0, 1}, "multiplicity Binning for the TempFitVar plot"}; + ConfigurableAxis binMulPercentile{"binMulPercentile", {10, 0.0f, 100.0f}, "multiplicity percentile Binning"}; + ConfigurableAxis binpT{"binpT", {20, 0.5, 4.05}, "pT binning"}; + ConfigurableAxis binpTTrack{"binpTTrack", {50, 0.5, 10.05}, "pT binning of the pT vs. TempFitVar plot (Track)"}; + ConfigurableAxis binEta{"binEta", {{200, -1.5, 1.5}}, "eta binning"}; + ConfigurableAxis binPhi{"binPhi", {{200, 0, TMath::TwoPi()}}, "phi binning"}; + ConfigurableAxis binkT{"binkT", {150, 0., 9.}, "binning kT"}; + ConfigurableAxis binkstar{"binkstar", {1500, 0., 6.}, "binning kstar"}; + ConfigurableAxis binNSigmaTPC{"binNSigmaTPC", {1600, -8, 8}, "Binning of Nsigma TPC plot"}; + ConfigurableAxis binNSigmaTOF{"binNSigmaTOF", {3000, -15, 15}, "Binning of the Nsigma TOF plot"}; + ConfigurableAxis binNSigmaTPCTOF{"binNSigmaTPCTOF", {3000, -15, 15}, "Binning of the Nsigma TPC+TOF plot"}; + ConfigurableAxis binTPCClusters{"binTPCClusters", {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"}; + + /// Particle 2 (Charm Hadrons) + Configurable charmHadBkgBDTmax{"charmHadBkgBDTmax", 1., "Maximum background bdt score for Charm Hadron (particle 2)"}; + Configurable charmHadCandSel{"charmHadCandSel", 1, "candidate selection for charm hadron"}; + Configurable charmHadMcSel{"charmHadMcSel", 2, "charm hadron selection for mc, partDplusToPiKPi (1), partLcToPKPi (2), partDsToKKPi (4), partXicToPKPi (8)"}; + Configurable charmHadFdBDTmin{"charmHadFdBDTmin", 0., "Minimum feed-down bdt score Charm Hadron (particle 2)"}; + Configurable charmHadFdBDTmax{"charmHadFdBDTmax", 1., "Maximum feed-down bdt score Charm Hadron (particle 2)"}; + Configurable charmHadMaxInvMass{"charmHadMaxInvMass", 2.45, "Maximum invariant mass of Charm Hadron (particle 2)"}; + Configurable charmHadMaxPt{"charmHadMaxPt", 999., "Maximum pT of Charm Hadron (particle 2)"}; + Configurable charmHadMinInvMass{"charmHadMinInvMass", 2.15, "Minimum invariant mass of Charm Hadron (particle 2)"}; + Configurable charmHadMinPt{"charmHadMinPt", 0., "Minimum pT of Charm Hadron (particle 2)"}; + Configurable charmHadPDGCode{"charmHadPDGCode", 4122, "PDG code of particle 2 Charm Hadron"}; + Configurable charmHadPromptBDTmin{"charmHadPromptBDTmin", 0., "Minimum prompt bdt score Charm Hadron (particle 2)"}; + Configurable charmHadPromptBDTmax{"charmHadPromptBDTmax", 1., "Maximum prompt bdt score Charm Hadron (particle 2)"}; + + /// General options + Configurable cprDeltaEtaMax{"cprDeltaEtaMax", 0.01, "Max. Delta Eta for Close Pair Rejection"}; + Configurable cprDeltaPhiMax{"cprDeltaPhiMax", 0.01, "Max. Delta Phi for Close Pair Rejection"}; + Configurable cprPlotPerRadii{"cprPlotPerRadii", false, "Plot CPR per radii"}; + Configurable extendedPlots{"extendedPlots", false, "Enable additional three dimensional histogramms. High memory consumption. Use for debugging"}; + Configurable highkstarCut{"highkstarCut", 100000., "Set a cut for high k*, above which the pairs are rejected"}; + Configurable isMc{"isMc", false, "Set true in the case of a MonteCarlo Run"}; + 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!"}; + 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 useCPR{"useCPR", false, "Close Pair Rejection"}; + ConfigurableAxis dummy{"dummy", {1, 0, 1}, "dummy axis"}; + + // Mixing configurables + ConfigurableAxis mixingBinMult{"mixingBinMult", {VARIABLE_WIDTH, 0.0f, 20.0f, 60.0f, 200.0f}, "Mixing bins - multiplicity"}; + ConfigurableAxis mixingBinMultPercentile{"mixingBinMultPercentile", {VARIABLE_WIDTH, 0.0f, 100.f}, "Mixing bins - multiplicity percentile"}; + ConfigurableAxis mixingBinVztx{"mixingBinVztx", {VARIABLE_WIDTH, -10.0f, -4.f, 0.f, 4.f, 10.f}, "Mixing bins - z-vertex"}; + Configurable mixingDepth{"mixingDepth", 5, "Number of events for mixing"}; + Configurable mixingBinPolicy{"mixingBinPolicy", 0, "Binning policy for mixing - 0: multiplicity, 1: multipliciy percentile, 2: both"}; + + /// Event selection + struct : ConfigurableGroup { + std::string prefix = "eventSel"; + Configurable multMin{"multMin", 0, "Minimum Multiplicity (MultNtr)"}; + Configurable multMax{"multMax", 99999, "Maximum Multiplicity (MultNtr)"}; + Configurable multPercentileMin{"multPercentileMin", 0, "Maximum Multiplicity Percentile"}; + Configurable multPercentileMax{"multPercentileMax", 100, "Minimum Multiplicity Percentile"}; + } eventSel; + + /// Particle 1 (track) + Configurable cutBitTrack1{"cutBitTrack1", 5542474, "Particle 1 (Track) - Selection bit from cutCulator"}; + Configurable pdgCodeTrack1{"pdgCodeTrack1", 2212, "PDG code of Particle 1 (Track)"}; + Configurable pidThresTrack1{"pidThresTrack1", 0.75, "Momentum threshold for PID selection for particle 1 (Track)"}; + Configurable tpcBitTrack1{"tpcBitTrack1", 4, "PID TPC bit from cutCulator for particle 1 (Track)"}; + Configurable tpcTofBitTrack1{"tpcTofBitTrack1", 2, "PID TPCTOF bit from cutCulator for particle 1 (Track)"}; + Configurable etaTrack1Max{"etaTrack1Max", 10., "Maximum eta of partricle 1 (Track)"}; + Configurable ptTrack1Max{"ptTrack1Max", 999., "Maximum pT of partricle 1 (Track)"}; + Configurable etaTrack1Min{"etaTrack1Min", -10., "Minimum eta of partricle 1 (Track)"}; + Configurable ptTrack1Min{"ptTrack1Min", 0., "Minimum pT of partricle 1 (Track)"}; + + ColumnBinningPolicy colBinningMult{{mixingBinVztx, mixingBinMult}, true}; + ColumnBinningPolicy colBinningMultPercentile{{mixingBinVztx, mixingBinMultPercentile}, true}; + ColumnBinningPolicy colBinningMultMultPercentile{{mixingBinVztx, mixingBinMult, mixingBinMultPercentile}, true}; + + FemtoDreamContainer sameEventCont; + FemtoDreamContainer mixedEventCont; + FemtoDreamPairCleaner pairCleaner; + FemtoDreamDetaDphiStar pairCloseRejectionSE; + FemtoDreamDetaDphiStar pairCloseRejectionME; + Filter eventMultiplicity = aod::femtodreamcollision::multNtr >= eventSel.multMin && aod::femtodreamcollision::multNtr <= eventSel.multMax; + Filter eventMultiplicityPercentile = aod::femtodreamcollision::multV0M >= eventSel.multPercentileMin && aod::femtodreamcollision::multV0M <= eventSel.multPercentileMax; + Filter hfCandSelFilter = aod::fdhf::candidateSelFlag >= charmHadCandSel.value; + Filter hfMcSelFilter = nabs(aod::fdhf::flagMc) == charmHadMcSel.value; + Filter trackEtaFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta < etaTrack1Max, true); + Filter trackEtaFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::eta > etaTrack1Min, true); + Filter trackPtFilterLow = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt < ptTrack1Max, true); + Filter trackPtFilterUp = ifnode(aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack), aod::femtodreamparticle::pt > ptTrack1Min, true); + + using FilteredCharmCands = soa::Filtered; + using FilteredCharmCand = FilteredCharmCands::iterator; + + using FilteredCharmMcCands = soa::Filtered>; + using FilteredCharmMcCand = FilteredCharmMcCands::iterator; + + using FilteredColisions = soa::Filtered>; + using FilteredColision = FilteredColisions::iterator; + + using FilteredMcColisions = soa::Filtered>; + using FilteredMcColision = FilteredMcColisions::iterator; + + using FilteredFDMcParts = soa::Filtered>; + using FilteredFDMcPart = FilteredFDMcParts::iterator; + + using FilteredFDParticles = soa::Filtered>; + using FilteredFDParticle = FilteredFDParticles::iterator; + + femtodreamcollision::BitMaskType BitMask = 1 << 0; + + /// Histogramming for particle 1 + FemtoDreamParticleHisto trackHistoPartOne; + /// Histogramming for Event + FemtoDreamEventHisto eventHisto; + /// Histogram output + HistogramRegistry registry{"CorrelationsAndQA", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry registryMixQa{"registryMixQa"}; + /// Partition for particle 1 + + Partition partitionTrk1 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && (ncheckbit(aod::femtodreamparticle::cut, cutBitTrack1)) && ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= pidThresTrack1, ncheckbit(aod::femtodreamparticle::pidcut, tpcBitTrack1), ncheckbit(aod::femtodreamparticle::pidcut, tpcTofBitTrack1)); + + Partition partitionMcTrk1 = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && + (ncheckbit(aod::femtodreamparticle::cut, cutBitTrack1)) && + ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= pidThresTrack1, ncheckbit(aod::femtodreamparticle::pidcut, tpcBitTrack1), ncheckbit(aod::femtodreamparticle::pidcut, tpcTofBitTrack1)); + + /// Partition for particle 2 + Partition partitionCharmHadron = aod::fdhf::bdtBkg < charmHadBkgBDTmax && aod::fdhf::bdtFD < charmHadFdBDTmax && aod::fdhf::bdtFD > charmHadFdBDTmin&& aod::fdhf::bdtPrompt charmHadPromptBDTmin; + Partition partitionMcCharmHadron = aod::fdhf::originMcRec == 1 || aod::fdhf::originMcRec == 2; + + float massOne = o2::analysis::femtoDream::getMass(pdgCodeTrack1); + float massTwo = o2::analysis::femtoDream::getMass(charmHadPDGCode); + int8_t partSign = 0; + int64_t processType = 0; + + SliceCache cache; + Preslice perCol = aod::femtodreamparticle::fdCollisionId; + Produces fillFemtoResult; + + void init(InitContext& /*context*/) + { + // setup columnpolicy for binning + colBinningMult = {{mixingBinVztx, mixingBinMult}, true}; + colBinningMultPercentile = {{mixingBinVztx, mixingBinMultPercentile}, true}; + colBinningMultMultPercentile = {{mixingBinVztx, mixingBinMult, mixingBinMultPercentile}, true}; + eventHisto.init(®istry); + trackHistoPartOne.init(®istry, binmultTempFit, binMulPercentile, binpTTrack, binEta, binPhi, binTempFitVarTrack, binNSigmaTPC, binNSigmaTOF, binNSigmaTPCTOF, binTPCClusters, dummy, isMc, pdgCodeTrack1, true); + + sameEventCont.init(®istry, + binkstar, binpT, binkT, binmT, mixingBinMult, mixingBinMultPercentile, + bin4Dkstar, bin4DmT, bin4DMult, bin4DmultPercentile, + isMc, use4D, extendedPlots, + highkstarCut, + smearingByOrigin, binInvMass); + + sameEventCont.setPDGCodes(pdgCodeTrack1, charmHadPDGCode); + mixedEventCont.init(®istry, + binkstar, binpT, binkT, binmT, mixingBinMult, mixingBinMultPercentile, + bin4Dkstar, bin4DmT, bin4DMult, bin4DmultPercentile, + isMc, use4D, extendedPlots, + highkstarCut, + smearingByOrigin, binInvMass); + + mixedEventCont.setPDGCodes(pdgCodeTrack1, charmHadPDGCode); + registryMixQa.add("MixingQA/hSECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + registryMixQa.add("MixingQA/hSECollisionPool", ";bin;Entries", kTH2F, {{100, -10, 10}, {2000, 0, 200}}); + registryMixQa.add("MixingQA/hMECollisionBins", ";bin;Entries", kTH1F, {{120, -0.5, 119.5}}); + pairCleaner.init(®istry); + if (useCPR.value) { + pairCloseRejectionSE.init(®istry, ®istry, cprDeltaPhiMax.value, cprDeltaEtaMax.value, cprPlotPerRadii.value, 1); + pairCloseRejectionME.init(®istry, ®istry, cprDeltaPhiMax.value, cprDeltaEtaMax.value, cprPlotPerRadii.value, 2); + } + } + + template + void fillCollision(CollisionType const& col) + { + registryMixQa.fill(HIST("MixingQA/hSECollisionBins"), colBinningMult.getBin({col.posZ(), col.multNtr()})); + registryMixQa.fill(HIST("MixingQA/hSECollisionPool"), col.posZ(), col.multNtr()); + } + + /// This function processes the same event and takes care of all the histogramming + template + void doSameEvent(PartitionType& sliceTrk1, CandType& sliceCharmHad, TableTracks const& parts, Collision const& col) + { + fillCollision(col); + + processType = 1; // for same event + /// Histogramming same event + for (auto const& part : sliceTrk1) { + + trackHistoPartOne.fillQA(part, static_cast(ConfTempFitVarMomentum.value), col.multNtr(), col.multV0M()); + } + + for (auto const& [p1, p2] : combinations(CombinationsFullIndexPolicy(sliceTrk1, sliceCharmHad))) { + + if (p1.trackId() == p2.prong0Id() || p1.trackId() == p2.prong1Id() || p1.trackId() == p2.prong2Id()) + continue; + + if (useCPR.value) { + if (pairCloseRejectionSE.isClosePair(p1, p2, parts, col.magField())) { + continue; + } + } + + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + continue; + } + + // proton track charge + 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; + } + + // 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}); + } else { + invMass = p2.m(std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus, o2::constants::physics::MassProton}); + } + + if (invMass < charmHadMinInvMass || invMass > charmHadMaxInvMass) { + continue; + } + + if (p2.pt() < charmHadMinPt || p2.pt() > charmHadMaxPt) { + 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), + col.multNtr(), + col.multV0M(), + p2.charge(), + pairSign, + processType, + charmHadMc, + originType); + + sameEventCont.setPair(p1, p2, col.multNtr(), col.multV0M(), use4D, extendedPlots, smearingByOrigin); + } + } + + template + void doMixedEvent(CollisionType const& cols, PartType const& parts, PartitionType1& part1, PartitionType2& part2, BinningType policy) + { + + // Mixed events that contain the pair of interest + processType = 2; // for mixed event + + Partition PartitionMaskedCol1 = (aod::femtodreamcollision::bitmaskTrackOne & BitMask) == BitMask; + PartitionMaskedCol1.bindTable(cols); + + Partition PartitionMaskedCol2 = (aod::femtodreamcollision::bitmaskTrackTwo & BitMask) == BitMask; + PartitionMaskedCol2.bindTable(cols); + + for (auto const& [collision1, collision2] : combinations(soa::CombinationsBlockFullIndexPolicy(policy, mixingDepth.value, -1, *PartitionMaskedCol1.mFiltered, *PartitionMaskedCol2.mFiltered))) { + // make sure that tracks in the same events are not mixed + if (collision1.globalIndex() == collision2.globalIndex()) { + continue; + } + + const int multiplicityCol = collision1.multNtr(); + registryMixQa.fill(HIST("MixingQA/hMECollisionBins"), colBinningMult.getBin({collision1.posZ(), multiplicityCol})); + + auto sliceTrk1 = part1->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision1.globalIndex(), cache); + auto sliceCharmHad = part2->sliceByCached(aod::femtodreamparticle::fdCollisionId, collision2.globalIndex(), cache); + for (auto& [p1, p2] : combinations(CombinationsFullIndexPolicy(sliceTrk1, sliceCharmHad))) { + + if (useCPR.value) { + if (pairCloseRejectionME.isClosePair(p1, p2, parts, collision1.magField())) { + continue; + } + } + if (!pairCleaner.isCleanPair(p1, p2, parts)) { + 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; + } + float invMass; + if (p2.candidateSelFlag() == 1) { + invMass = p2.m(std::array{o2::constants::physics::MassProton, o2::constants::physics::MassKPlus, o2::constants::physics::MassPiPlus}); + } else { + invMass = p2.m(std::array{o2::constants::physics::MassPiPlus, o2::constants::physics::MassKPlus, o2::constants::physics::MassProton}); + } + + 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); + } + } + } + + void processSameEvent(FilteredColision const& col, + FilteredFDParticles const& parts, + FilteredCharmCands const&) + { + if ((col.bitmaskTrackOne() & BitMask) != BitMask || (col.bitmaskTrackTwo() & BitMask) != BitMask) { + return; + } + eventHisto.fillQA(col); + auto sliceTrk1 = partitionTrk1->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + auto sliceCharmHad = partitionCharmHadron->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + doSameEvent(sliceTrk1, sliceCharmHad, parts, col); + } + PROCESS_SWITCH(HfTaskCharmHadronsFemtoDream, processSameEvent, "Enable processing same event", false); + + void processMixedEvent(FilteredColisions const& cols, + FilteredFDParticles const& parts, + FilteredCharmCands const&) + { + switch (mixingBinPolicy.value) { + case femtodreamcollision::kMult: + doMixedEvent(cols, parts, partitionTrk1, partitionCharmHadron, colBinningMult); + break; + case femtodreamcollision::kMultPercentile: + doMixedEvent(cols, parts, partitionTrk1, partitionCharmHadron, colBinningMultPercentile); + break; + case femtodreamcollision::kMultMultPercentile: + doMixedEvent(cols, parts, partitionTrk1, partitionCharmHadron, colBinningMultMultPercentile); + break; + default: + LOG(fatal) << "Invalid binning policiy specifed. Breaking..."; + } + } + PROCESS_SWITCH(HfTaskCharmHadronsFemtoDream, processMixedEvent, "Enable processing mixed events", 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(FilteredMcColision const& col, + FilteredFDMcParts const& parts, + o2::aod::FDMCParticles const&, + o2::aod::FDExtMCParticles const&, + FilteredCharmMcCands const&) + { + if ((col.bitmaskTrackOne() & BitMask) != BitMask || (col.bitmaskTrackTwo() & BitMask) != BitMask) { + return; + } + auto sliceMcTrk1 = partitionMcTrk1->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + auto sliceMcCharmHad = partitionMcCharmHadron->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); + + if (sliceMcTrk1.size() == 0 && sliceMcCharmHad.size() == 0) { + return; + } + doSameEvent(sliceMcTrk1, sliceMcCharmHad, parts, col); + } + PROCESS_SWITCH(HfTaskCharmHadronsFemtoDream, processSameEventMc, "Enable processing same event for Monte Carlo", 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(FilteredMcColisions const& cols, + FilteredFDMcParts const& parts, + o2::aod::FDMCParticles const&, + o2::aod::FDExtMCParticles const&, + FilteredCharmMcCands const&) + { + switch (mixingBinPolicy.value) { + case femtodreamcollision::kMult: + doMixedEvent(cols, parts, partitionMcTrk1, partitionMcCharmHadron, colBinningMult); + break; + case femtodreamcollision::kMultPercentile: + doMixedEvent(cols, parts, partitionMcTrk1, partitionMcCharmHadron, colBinningMultPercentile); + break; + case femtodreamcollision::kMultMultPercentile: + doMixedEvent(cols, parts, partitionMcTrk1, partitionMcCharmHadron, colBinningMultMultPercentile); + break; + default: + LOG(fatal) << "Invalid binning policiy specifed. Breaking..."; + } + } + PROCESS_SWITCH(HfTaskCharmHadronsFemtoDream, processMixedEventMc, "Enable processing mixed events MC", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx index 9ac7c6ae3de..416460e4689 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationD0Hadrons.cxx @@ -16,6 +16,8 @@ /// \author Samrangy Sadhu , INFN Bari /// \author Swapnesh Santosh Khade , IIT Indore +#include + #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -24,11 +26,13 @@ #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" using namespace o2; 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 { @@ -52,7 +56,7 @@ AxisSpec axisDeltaPhi = {64, -o2::constants::math::PIHalf, 3. * o2::constants::m AxisSpec axisPtD = {10, 0., 10., ""}; AxisSpec axisPtHadron = {11, 0., 11., ""}; AxisSpec axisPoolBin = {9, 0., 9., ""}; -AxisSpec axisCorrelationState = {2, 0., 1., ""}; +AxisSpec axisCorrelationState = {2, 0., 2., ""}; ConfigurableAxis axisMass{"axisMass", {250, 1.65f, 2.15f}, ""}; // definition of vectors for standard ptbin and invariant mass configurables @@ -94,13 +98,6 @@ struct HfTaskCorrelationD0Hadrons { Configurable leadingParticlePtMin{"leadingParticlePtMin", 0., "Min for leading particle pt"}; Configurable applyEfficiency{"efficiencyFlagD", 1, "Flag for applying efficiency weights"}; - enum Region { - Default = 0, // 默认值 - Toward, - Away, - Transverse - }; - HistogramRegistry registry{ "registry", {{"hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, @@ -180,7 +177,16 @@ struct HfTaskCorrelationD0Hadrons { // 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}}}}}}; + {"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}}}}}}; void init(InitContext&) { int nBinsPtAxis = binsCorrelations->size() - 1; @@ -225,16 +231,6 @@ struct HfTaskCorrelationD0Hadrons { registry.get(HIST("hCorrel2DVsPtGen"))->Sumw2(); } - Region getRegion(double deltaPhi) - { - if (std::abs(deltaPhi) < o2::constants::math::PI / 3.) { - return Toward; - } else if (deltaPhi > 2. * o2::constants::math::PI / 3. && deltaPhi < 4. * o2::constants::math::PI / 3.) { - return Away; - } else { - return Transverse; - } - } /// 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::DHadronPairFull const& pairEntries) @@ -275,35 +271,19 @@ struct HfTaskCorrelationD0Hadrons { continue; } Region region = getRegion(deltaPhi); - if (signalStatus == ParticleTypeData::D0Only || signalStatus == ParticleTypeData::D0D0barBoth) { - switch (region) { - case Toward: - registry.fill(HIST("hToward"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - case Away: - registry.fill(HIST("hAway"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - case Transverse: - registry.fill(HIST("hTransverse"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - default: - break; - } - } - if (signalStatus == ParticleTypeData::D0barOnly || signalStatus == ParticleTypeData::D0D0barBoth) { - switch (region) { - case Toward: - registry.fill(HIST("hToward"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - case Away: - registry.fill(HIST("hAway"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - case Transverse: - registry.fill(HIST("hTransverse"), massD, ptD, isAutoCorrelated, efficiencyWeight); - break; - default: - break; - } + + switch (region) { + case Toward: + registry.fill(HIST("hToward"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + case Away: + registry.fill(HIST("hAway"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + case Transverse: + registry.fill(HIST("hTransverse"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + default: + break; } } // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots @@ -395,12 +375,32 @@ struct HfTaskCorrelationD0Hadrons { int signalStatus = pairEntry.signalStatus(); int ptBinD = o2::analysis::findBin(binsCorrelations, ptD); int poolBin = pairEntry.poolBin(); + bool isAutoCorrelated = pairEntry.isAutoCorrelated(); double efficiencyWeight = 1.; if (applyEfficiency) { efficiencyWeight = 1. / (efficiencyDmeson->at(o2::analysis::findBin(binsEfficiency, ptD))); } - + if (isTowardTransverseAway) { + // Divide into three regions: toward, transverse, and away + if (ptHadron < leadingParticlePtMin) { + continue; + } + Region region = getRegion(deltaPhi); + switch (region) { + case Toward: + registry.fill(HIST("hTowardRec"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + case Away: + registry.fill(HIST("hAwayRec"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + case Transverse: + registry.fill(HIST("hTransverseRec"), massD, ptD, isAutoCorrelated, efficiencyWeight); + break; + default: + break; + } + } // fill correlation plots for signal/bagkground correlations if (pairEntry.signalStatus()) { registry.fill(HIST("hCorrel2DVsPtRecSig"), deltaPhi, deltaEta, ptD, ptHadron, efficiencyWeight); @@ -589,6 +589,8 @@ struct HfTaskCorrelationD0Hadrons { double ptD = pairEntry.ptD(); double ptHadron = pairEntry.ptHadron(); int poolBin = pairEntry.poolBin(); + double massD = pairEntry.mD(); + bool isAutoCorrelated = pairEntry.isAutoCorrelated(); // reject entries outside pT ranges of interest if (o2::analysis::findBin(binsCorrelations, ptD) < 0) { continue; @@ -596,7 +598,26 @@ struct HfTaskCorrelationD0Hadrons { if (ptHadron > ptHadronMax) { ptHadron = ptHadronMax + 0.5; } - + if (isTowardTransverseAway) { + // Divide into three regions: toward, transverse, and away + if (ptHadron < leadingParticlePtMin) { + continue; + } + Region region = getRegion(deltaPhi); + switch (region) { + case Toward: + registry.fill(HIST("hTowardGen"), massD, ptD, isAutoCorrelated); + break; + case Away: + registry.fill(HIST("hAwayGen"), massD, ptD, isAutoCorrelated); + break; + case Transverse: + registry.fill(HIST("hTransverseGen"), massD, ptD, isAutoCorrelated); + break; + default: + break; + } + } registry.fill(HIST("hCorrel2DVsPtGen"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); registry.fill(HIST("hCorrel2DPtIntGen"), deltaPhi, deltaEta); registry.fill(HIST("hDeltaEtaPtIntGen"), deltaEta); diff --git a/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx index f94c3d2d904..a196c6fb9a8 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx @@ -11,7 +11,10 @@ /// \file taskCorrelationDplusHadrons.cxx /// \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" @@ -28,11 +31,6 @@ using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; -namespace o2::aod -{ -using DplusHadronPairFull = 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});"; @@ -68,14 +66,24 @@ 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 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 fillHistoMcEff{"fillHistoMcEff", true, "Flag for filling histograms in efficiency processes"}; Configurable applyEfficiency{"applyEfficiency", 1, "Flag for applying efficiency weights"}; + Configurable loadAccXEffFromCCDB{"loadAccXEffFromCCDB", false, "Flag for loading efficiency distributions from CCDB"}; 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"}; // 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> 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"}; - Configurable> efficiencyD{"efficiencyD", {1., 1., 1., 1., 1., 1.}, "efficiency values for D+ meson"}; + Configurable> efficiencyD{"efficiencyD", {1., 1., 1., 1., 1., 1.}, "efficiency values for prompt D+ meson"}; + 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"}; @@ -84,6 +92,8 @@ struct HfTaskCorrelationDplusHadrons { 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 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"}; @@ -93,12 +103,28 @@ struct HfTaskCorrelationDplusHadrons { Configurable yCandGenMax{"yCandGenMax", 0.5, "max. gen. cand. rapidity"}; Configurable ptDaughterMin{"ptDaughterMin", 0.1, "min. daughter pT"}; Configurable activateQA{"activateQA", false, "Flag to enable debug histogram"}; - + Configurable nTpcCrossedRaws{"nTpcCrossedRaws", 70, "Number of crossed TPC Rows"}; + Configurable cutCollPosZMc{"cutCollPosZMc", 10., "max z-vertex position for collision acceptance"}; + // 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"}; + 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"}; + Service ccdb; + std::shared_ptr mEfficiencyPrompt = nullptr; + std::shared_ptr mEfficiencyFD = nullptr; + std::shared_ptr mEfficiencyAssociated = nullptr; + HfHelper hfHelper; enum CandidateStep { kCandidateStepMcGenAll = 0, @@ -109,16 +135,21 @@ struct HfTaskCorrelationDplusHadrons { kCandidateStepMcRecoInAcceptance, kCandidateNSteps }; - using CandDplusMcReco = soa::Filtered>; + using DplusHadronPair = soa::Join; + using DplusHadronPairFullWithMl = soa::Join; + using CandDplusMcReco = soa::Filtered>; using CandDplusMcGen = soa::Join; + using TracksWithMc = soa::Filtered>; // trackFilter applied 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); HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext&) { // Axis definition + AxisSpec axisMassD = {binsMassD, "inv. mass (#pi^{+}K^{-}#pi^{+}) (GeV/#it{c}^{2})"}; AxisSpec axisPtCorr = {(std::vector)binsPtCorrelations, "#it{p}_{T}^{D} (GeV/#it{c})"}; AxisSpec axisPtD = {(std::vector)binsPtEfficiencyD, "#it{p}_{T}^{D} (GeV/#it{c})"}; AxisSpec axisMultFT0M = {binsMultFT0M, "MultiplicityFT0M"}; @@ -127,31 +158,82 @@ struct HfTaskCorrelationDplusHadrons { AxisSpec axisPtHadron = {(std::vector)binsPtHadron, "#it{p}_{T}^{Hadron} (GeV/#it{c})"}; AxisSpec axisPoolBin = {binsPoolBin, "poolBin"}; AxisSpec axisDplusPrompt = {2, -0.5, 1.5, "Prompt D+"}; + AxisSpec axisBdtScore = {binsBdtScore, "Bdt score"}; + + // Histograms for data analysis + registry.add("hBdtScorePrompt", "D+ BDT prompt score", {HistType::kTH1F, {axisBdtScore}}); + registry.add("hBdtScoreBkg", "D+ BDT bkg score", {HistType::kTH1F, {axisBdtScore}}); + registry.add("hMassDplusVsPt", "D+ candidates massVsPt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassDplusVsPtWoEff", "D+ candidates massVsPt without efficiency", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + if (fillHistoData) { + registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandLeft", stringDHadron + "Left" + stringSideband + stringDeltaEta, {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandLeft", stringDHadron + "Left" + stringSideband + stringDeltaPhi, {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hDeltaEtaPtIntSidebandRight", stringDHadron + "Right" + stringSideband + stringDeltaEta, {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandRight", stringDHadron + "Right" + stringSideband + stringDeltaPhi, {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DVsPtSidebandLeft", stringDHadron + "Left" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSidebandRight", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); - registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); - registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); - registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); - registry.add("hCorrel2DVsPtSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); - registry.add("hDeltaEtaPtIntSidebands", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); - registry.add("hDeltaPhiPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); - registry.add("hCorrel2DPtIntSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); - registry.add("hCorrel2DVsPtSidebands", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.get(HIST("hCorrel2DVsPtSignalRegion"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebands"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandLeft"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandRight"))->Sumw2(); + } // Histograms for MC Reco analysis - registry.add("hDeltaEtaPtIntSignalRegionMCRec", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); - registry.add("hDeltaPhiPtIntSignalRegionMCRec", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); - registry.add("hDeltaEtaPtIntSidebandsMCRec", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); - registry.add("hCorrel2DPtIntSignalRegionMCRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); - registry.add("hCorrel2DVsPtSignalRegionMCRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); - registry.add("hCorrel2DVsPtSignalMCRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); - registry.add("hCorrel2DVsPtBkgMCRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); - registry.add("hDeltaPhiPtIntSidebandsMCRec", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); - registry.add("hCorrel2DPtIntSidebandsMCRec", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); - registry.add("hCorrel2DVsPtSidebandsMCRec", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + if (fillHistoMcRec) { + registry.add("hMassPromptDplusVsPt", "D+ prompt candidates mass Vs Pt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hMassNonPromptDplusVsPt", "D+ non prompt candidates mass Vs Pt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}}); + registry.add("hDeltaEtaPtIntSignalRegionMcRec", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSignalRegionMcRec", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hDeltaEtaPtIntSidebandsMcRec", stringDHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hCorrel2DPtIntSignalRegionMcRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSignalRegionMcRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisDplusPrompt}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSignalMcRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtBkgMcRec", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaPhiPtIntSidebandsMcRec", stringDHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntSidebandsMcRec", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtSidebandsMcRec", stringDHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtPhysicalPrimaryMcRec", stringDHadron + "(only true primary particles)" + stringSignal, {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisDplusPrompt}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandLeftMcRec", stringDHadron + "Left" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandLeftMcRec", stringDHadron + "Left" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DVsPtSidebandLeftMcRec", stringDHadron + "Left" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hDeltaEtaPtIntSidebandRightMcRec", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntSidebandRightMcRec", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DVsPtSidebandRightMcRec", stringDHadron + "Right" + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtD + stringPtHadron + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSignalRegionPromptDplusPromptHadronMcRec", stringDHadron + "signal region PromptD - Prompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec", stringDHadron + " signal region PromptD - NonPrompt Track MC reco", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + + registry.get(HIST("hCorrel2DVsPtSignalRegionMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandsMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtBkgMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandLeftMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSidebandRightMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtSignalRegionMcRec"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtPhysicalPrimaryMcRec"))->Sumw2(); + } // Histograms for MC Gen analysis - registry.add("hDeltaEtaPtIntMCGen", stringMCParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); - registry.add("hDeltaPhiPtIntMCGen", stringMCParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); - registry.add("hCorrel2DPtIntMCGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); - registry.add("hCorrel2DVsPtMCGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + stringPtD + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + if (fillHistoMcGen) { + registry.add("hDeltaEtaPtIntMcGen", stringMCParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}); + registry.add("hDeltaPhiPtIntMcGen", stringMCParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}); + registry.add("hCorrel2DPtIntMcGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}); + registry.add("hCorrel2DVsPtMcGen", stringMCParticles + stringDeltaPhi + stringDeltaEta + stringPtD + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtCorr}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtMcGenPrompt", stringDHadron + " Prompt MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtMcGenPromptDPromptHadron", stringDHadron + "prompt D prompt h MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtMcGenNonPromptDNonPromptHadron", stringDHadron + " non prompt D non prompt h MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + registry.add("hCorrel2DVsPtMcGenNonPrompt", stringDHadron + " NonPrompt MC Gen", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtD}, {axisPtHadron}, {axisPoolBin}}}); + + registry.get(HIST("hCorrel2DVsPtMcGen"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtMcGenPrompt"))->Sumw2(); + registry.get(HIST("hCorrel2DVsPtMcGenNonPrompt"))->Sumw2(); + } // Histograms for efficiencies registry.add("Efficiency/hPtCandMcRecPrompt", stringMCRecoDPrompt + stringPtD, {HistType::kTH1F, {axisPtD}}); registry.add("Efficiency/hPtCandMcGenPrompt", stringMCGenDPrompt + stringPtD, {HistType::kTH1F, {axisPtD}}); @@ -159,19 +241,37 @@ struct HfTaskCorrelationDplusHadrons { registry.add("Efficiency/hPtCandMcGenNonPrompt", stringMCGenDFd + stringPtD, {HistType::kTH1F, {axisPtD}}); registry.add("Efficiency/hPtCandMcGenDaughterInAcc", stringMCGenDFd + stringPtD, {HistType::kTH1F, {axisPtD}}); - registry.get(HIST("hCorrel2DVsPtSignalRegion"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSidebands"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalRegionMCRec"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSidebandsMCRec"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtSignalMCRec"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtBkgMCRec"))->Sumw2(); - registry.get(HIST("hCorrel2DVsPtMCGen"))->Sumw2(); - 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"); + // Loading efficiency histograms from CCDB + if (applyEfficiency && loadAccXEffFromCCDB) { + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(ccdbNoLaterThan.value); + + mEfficiencyPrompt = std::shared_ptr(ccdb->getForTimeStamp(promptEffCcdbPath, timestampCcdb)); + if (mEfficiencyPrompt == 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()); + + mEfficiencyFD = std::shared_ptr(ccdb->getForTimeStamp(fdEffCcdbPath, timestampCcdb)); + if (mEfficiencyFD == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", fdEffCcdbPath.value.c_str()); + } + LOGF(info, "Loaded feed-down D meson efficiency histogram from %s", fdEffCcdbPath.value.c_str()); + + mEfficiencyAssociated = std::shared_ptr(ccdb->getForTimeStamp(associatedEffCcdbPath, timestampCcdb)); + if (mEfficiencyAssociated == 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()); + } + if (activateQA) { const int regionLimits = 6; std::string labels[regionLimits] = {"SigReg Left", "SigReg Right", "Left SB Low", "Left SB Up", "Right SB Low", "Right SB Up"}; @@ -191,29 +291,69 @@ struct HfTaskCorrelationDplusHadrons { } } - void processData(aod::DplusHadronPairFull const& pairEntries) + void processData(DplusHadronPairFullWithMl const& pairEntries, aod::DplusRecoInfo const& candidates) { + for (const auto& candidate : candidates) { + float massD = candidate.mD(); + float ptD = candidate.ptD(); + float bdtScorePrompt = candidate.mlScorePrompt(); + float bdtScoreBkg = candidate.mlScoreBkg(); + int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); + + // reject entries outside pT ranges of interest + if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) { + continue; + } + + if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->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)); + } + } + registry.fill(HIST("hMassDplusVsPt"), massD, ptD, efficiencyWeightD); + registry.fill(HIST("hMassDplusVsPtWoEff"), massD, ptD); + registry.fill(HIST("hBdtScorePrompt"), bdtScorePrompt); + registry.fill(HIST("hBdtScoreBkg"), bdtScoreBkg); + } + for (const auto& pairEntry : pairEntries) { // define variables for widely used quantities - double deltaPhi = pairEntry.deltaPhi(); - double deltaEta = pairEntry.deltaEta(); - double ptD = pairEntry.ptD(); - double ptHadron = pairEntry.ptHadron(); + float deltaPhi = pairEntry.deltaPhi(); + float deltaEta = pairEntry.deltaEta(); + float ptD = pairEntry.ptD(); + float ptHadron = pairEntry.ptHadron(); + float bdtScorePrompt = pairEntry.mlScorePrompt(); + float bdtScoreBkg = pairEntry.mlScoreBkg(); + float trackDcaXY = pairEntry.trackDcaXY(); + float trackDcaZ = pairEntry.trackDcaZ(); + int trackTpcCrossedRows = pairEntry.trackTPCNClsCrossedRows(); int poolBin = pairEntry.poolBin(); double massD = pairEntry.mD(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); // reject entries outside pT ranges of interest - if (pTBinD < 0 || effBinD < 0) { + if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) { continue; } - if (ptHadron > 10.0) { - ptHadron = 10.5; + + if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + continue; + } + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { + continue; } double efficiencyWeight = 1.; 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))); + } } // 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)) { @@ -223,10 +363,21 @@ struct HfTaskCorrelationDplusHadrons { registry.fill(HIST("hDeltaEtaPtIntSignalRegion"), deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaPhiPtIntSignalRegion"), deltaPhi, efficiencyWeight); } - - if ((massD > sidebandLeftOuter->at(pTBinD) && massD < sidebandLeftInner->at(pTBinD)) || - (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD))) { - // in sideband region + // in sideband left region + if (massD > sidebandLeftOuter->at(pTBinD) && massD < sidebandLeftInner->at(pTBinD)) { + registry.fill(HIST("hCorrel2DVsPtSidebandLeft"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandLeft"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandLeft"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebands"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebands"), deltaPhi, efficiencyWeight); + } + // in sideband right region + if (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD)) { + registry.fill(HIST("hCorrel2DVsPtSidebandRight"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandRight"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandRight"), deltaPhi, efficiencyWeight); registry.fill(HIST("hCorrel2DVsPtSidebands"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); registry.fill(HIST("hCorrel2DPtIntSidebands"), deltaPhi, deltaEta, efficiencyWeight); registry.fill(HIST("hDeltaEtaPtIntSidebands"), deltaEta, efficiencyWeight); @@ -237,85 +388,176 @@ struct HfTaskCorrelationDplusHadrons { PROCESS_SWITCH(HfTaskCorrelationDplusHadrons, processData, "Process data", false); /// D-Hadron correlation pair filling task, from pair tables - for MC reco-level analysis (candidates matched to true signal only, but also bkg sources are studied) - void processMcRec(aod::DplusHadronPairFull const& pairEntries) + void processMcRec(DplusHadronPairFullWithMl const& pairEntries, + soa::Join const& candidates) { + for (const auto& candidate : candidates) { + float massD = candidate.mD(); + float ptD = candidate.ptD(); + float bdtScorePrompt = candidate.mlScorePrompt(); + float bdtScoreBkg = candidate.mlScoreBkg(); + int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); + bool isDplusPrompt = candidate.isPrompt(); + + // reject entries outside pT ranges of interest + if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) + continue; + + if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { + continue; + } + double efficiencyWeightD = 1.; + if (applyEfficiency) { + if (isDplusPrompt) { + efficiencyWeightD = 1. / efficiencyD->at(effBinD); + if (loadAccXEffFromCCDB) { + efficiencyWeightD = 1. / mEfficiencyPrompt->GetBinContent(mEfficiencyPrompt->FindBin(ptD)); + } + registry.fill(HIST("hMassDplusVsPt"), massD, ptD, efficiencyWeightD); + registry.fill(HIST("hMassDplusVsPtWoEff"), massD, ptD); + registry.fill(HIST("hMassPromptDplusVsPt"), massD, ptD, efficiencyWeightD); + registry.fill(HIST("hBdtScorePrompt"), bdtScorePrompt); + registry.fill(HIST("hBdtScoreBkg"), bdtScoreBkg); + } else { + efficiencyWeightD = 1. / efficiencyFdD->at(effBinD); + if (loadAccXEffFromCCDB) { + efficiencyWeightD = 1. / mEfficiencyFD->GetBinContent(mEfficiencyFD->FindBin(ptD)); + } + registry.fill(HIST("hMassDplusVsPt"), massD, ptD, efficiencyWeightD); + registry.fill(HIST("hMassDplusVsPtWoEff"), massD, ptD); + registry.fill(HIST("hMassNonPromptDplusVsPt"), massD, ptD, efficiencyWeightD); + registry.fill(HIST("hBdtScorePrompt"), bdtScorePrompt); + registry.fill(HIST("hBdtScoreBkg"), bdtScoreBkg); + } + } + } + for (const auto& pairEntry : pairEntries) { // define variables for widely used quantities - double deltaPhi = pairEntry.deltaPhi(); - double deltaEta = pairEntry.deltaEta(); - double ptD = pairEntry.ptD(); - double ptHadron = pairEntry.ptHadron(); + float deltaPhi = pairEntry.deltaPhi(); + float deltaEta = pairEntry.deltaEta(); + float ptD = pairEntry.ptD(); + float ptHadron = pairEntry.ptHadron(); + float massD = pairEntry.mD(); + float bdtScorePrompt = pairEntry.mlScorePrompt(); + 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(); int poolBin = pairEntry.poolBin(); - double massD = pairEntry.mD(); int effBinD = o2::analysis::findBin(binsPtEfficiencyD, ptD); int pTBinD = o2::analysis::findBin(binsPtCorrelations, ptD); - if (pTBinD < 0 || effBinD < 0) { + + // reject entries outside pT ranges of interest + if (ptD < binsPtEfficiencyD->front() || ptD > binsPtEfficiencyD->back()) + continue; + + if (bdtScorePrompt < mlOutputPrompt->at(effBinD) || bdtScoreBkg > mlOutputBkg->at(effBinD)) { continue; } - if (ptHadron > 10.0) { - ptHadron = 10.5; + if (trackDcaXY > dcaXYTrackMax || trackDcaZ > dcaZTrackMax || trackTpcCrossedRows < nTpcCrossedRaws) { + continue; } double efficiencyWeight = 1.; + if (applyEfficiency) { - efficiencyWeight = 1. / (efficiencyD->at(effBinD) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); + if (statusDplusPrompt) { + 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))); + } + } else { + efficiencyWeight = 1. / (efficiencyFdD->at(effBinD) * efficiencyHad->at(o2::analysis::findBin(binsPtEfficiencyHad, ptHadron))); + if (loadAccXEffFromCCDB) { + efficiencyWeight = 1. / (mEfficiencyFD->GetBinContent(mEfficiencyFD->FindBin(ptD)) * mEfficiencyAssociated->GetBinContent(mEfficiencyAssociated->FindBin(ptHadron))); + } + } } + // fill correlation plots for signal/bagkground correlations if (pairEntry.signalStatus()) { - registry.fill(HIST("hCorrel2DVsPtSignalMCRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); } else { - registry.fill(HIST("hCorrel2DVsPtBkgMCRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtBkgMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); } // reject entries outside pT ranges of interest // 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, poolBin, efficiencyWeight); - registry.fill(HIST("hCorrel2DPtIntSignalRegionMCRec"), deltaPhi, deltaEta, efficiencyWeight); - registry.fill(HIST("hDeltaEtaPtIntSignalRegionMCRec"), deltaEta, efficiencyWeight); - registry.fill(HIST("hDeltaPhiPtIntSignalRegionMCRec"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSignalRegionMcRec"), deltaPhi, deltaEta, ptD, ptHadron, statusDplusPrompt, 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("hCorrel2DVsPtSignalRegionPromptDplusPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } else if (statusDplusPrompt == 0 && statusPromptHadron == 2) { + registry.fill(HIST("hCorrel2DVsPtSignalRegionNonPromptDplusNonPromptHadronMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + } + } } - - if (((massD > sidebandLeftOuter->at(pTBinD)) && (massD < sidebandLeftInner->at(pTBinD))) || - ((massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD)))) { - // in sideband region - registry.fill(HIST("hCorrel2DVsPtSidebandsMCRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); - registry.fill(HIST("hCorrel2DPtIntSidebandsMCRec"), deltaPhi, deltaEta, efficiencyWeight); - registry.fill(HIST("hDeltaEtaPtIntSidebandsMCRec"), deltaEta, efficiencyWeight); - registry.fill(HIST("hDeltaPhiPtIntSidebandsMCRec"), deltaPhi, efficiencyWeight); + // in sideband left region + if (massD > sidebandLeftOuter->at(pTBinD) && massD < sidebandLeftInner->at(pTBinD)) { + registry.fill(HIST("hCorrel2DVsPtSidebandLeftMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandLeftMcRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandLeftMcRec"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSidebandsMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DPtIntSidebandsMcRec"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandsMcRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandsMcRec"), deltaPhi, efficiencyWeight); + } + // in sideband right region + if (massD > sidebandRightInner->at(pTBinD) && massD < sidebandRightOuter->at(pTBinD)) { + registry.fill(HIST("hCorrel2DVsPtSidebandRightMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandRightMcRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandRightMcRec"), deltaPhi, efficiencyWeight); + registry.fill(HIST("hCorrel2DVsPtSidebandsMcRec"), deltaPhi, deltaEta, ptD, ptHadron, poolBin, efficiencyWeight); + registry.fill(HIST("hCorrel2DPtIntSidebandsMcRec"), deltaPhi, deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaEtaPtIntSidebandsMcRec"), deltaEta, efficiencyWeight); + registry.fill(HIST("hDeltaPhiPtIntSidebandsMcRec"), deltaPhi, efficiencyWeight); } } // end loop } PROCESS_SWITCH(HfTaskCorrelationDplusHadrons, 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::DplusHadronPair const& pairEntries) + void processMcGen(DplusHadronPair 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 ptHadron = pairEntry.ptHadron(); + float deltaPhi = pairEntry.deltaPhi(); + float deltaEta = pairEntry.deltaEta(); + float ptD = pairEntry.ptD(); + float ptHadron = pairEntry.ptHadron(); int poolBin = pairEntry.poolBin(); - // reject entries outside pT ranges of interest - if (o2::analysis::findBin(binsPtCorrelations, ptD) < 0) { - continue; - } - if (ptHadron > 10.0) { - ptHadron = 10.5; - } + int statusPromptHadron = pairEntry.trackOrigin(); + bool isDplusPrompt = pairEntry.isPrompt(); - registry.fill(HIST("hCorrel2DVsPtMCGen"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); - registry.fill(HIST("hCorrel2DPtIntMCGen"), deltaPhi, deltaEta); - registry.fill(HIST("hDeltaEtaPtIntMCGen"), deltaEta); - registry.fill(HIST("hDeltaPhiPtIntMCGen"), deltaPhi); - } // end loop + registry.fill(HIST("hCorrel2DVsPtMcGen"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + registry.fill(HIST("hDeltaEtaPtIntMcGen"), deltaEta); + registry.fill(HIST("hDeltaPhiPtIntMcGen"), deltaPhi); + if (isDplusPrompt) { + registry.fill(HIST("hCorrel2DVsPtMcGenPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + if (statusPromptHadron == 1) { + registry.fill(HIST("hCorrel2DVsPtMcGenPromptDPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + } + } else { + registry.fill(HIST("hCorrel2DVsPtMcGenNonPrompt"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + if (statusPromptHadron == 2) { + registry.fill(HIST("hCorrel2DVsPtMcGenNonPromptDNonPromptHadron"), deltaPhi, deltaEta, ptD, ptHadron, poolBin); + } + } + } } PROCESS_SWITCH(HfTaskCorrelationDplusHadrons, processMcGen, "Process MC Gen mode", false); /// D-Hadron correlation - reconstruction and selection efficiency - void processMcCandEfficiency(soa::Join const&, + void processMcCandEfficiency(soa::Join const&, soa::Join const&, CandDplusMcGen const& mcParticles, CandDplusMcReco const& candidates, @@ -363,10 +605,20 @@ struct HfTaskCorrelationDplusHadrons { if (candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { continue; } + std::vector outputMl = {-1., -1., -1.}; if (candidate.isSelDplusToPiKPi() < selectionFlagDplus) { continue; } - auto collision = candidate.template collision_as>(); + 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()))) { + 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::DplusToPiKPi) { hCandidates->Fill(kCandidateStepMcReco, candidate.pt(), multiplicity, candidate.originMcRec()); diff --git a/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx index 0661847a2e1..89d8631652e 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationDsHadrons.cxx @@ -37,12 +37,13 @@ struct HfTaskCorrelationDsHadrons { Configurable fillHistoMcGen{"fillHistoMcGen", true, "Flag for filling histograms in MC Gen processes"}; Configurable fillHistoMcEff{"fillHistoMcEff", true, "Flag for filling histograms in efficiency processes"}; Configurable applyEfficiency{"applyEfficiency", false, "Flag for applying efficiency weights"}; - Configurable useSel8ForTrackEff{"useSel8ForTrackEff", true, "Flag for applying sel8 for collision selection"}; + 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 doMcCollisionCheck{"doMcCollisionCheck", false, "Flag for applying the collision check and selection based on MC collision info"}; - Configurable selectionFlagDs{"selectionFlagDs", 7, "Selection Flag for Ds"}; + Configurable removeCollWSplitVtx{"removeCollWSplitVtx", false, "Flag for rejecting the splitted collisions"}; + // 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 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 cutCollPosZMc{"cutCollPosZMc", 10., "max z-vertex position for collision acceptance"}; Configurable dcaXYTrackMax{"dcaXYTrackMax", 1., "max. DCA_xy of tracks"}; @@ -80,13 +81,14 @@ struct HfTaskCorrelationDsHadrons { HfHelper hfHelper; - enum CandidateStep { kCandidateStepMcGenAll = 0, - kCandidateStepMcGenDsToKKPi, - kCandidateStepMcCandInAcceptance, - kCandidateStepMcDaughtersInAcceptance, - kCandidateStepMcReco, - kCandidateStepMcRecoInAcceptance, - kCandidateNSteps }; + enum CandidateStep { + kCandidateStepMcGenDsToKKPi = 0, + kCandidateStepMcCandInAcceptance, + kCandidateStepMcDaughtersInAcceptance, + kCandidateStepMcReco, + kCandidateStepMcRecoInAcceptance, + kCandidateNSteps + }; enum AssocTrackStep { kAssocTrackStepMcGen = 0, kAssocTrackStepMcGenInAcceptance, @@ -94,8 +96,6 @@ struct HfTaskCorrelationDsHadrons { kAssocTrackStepRecoMcMatch, kAssocTrackStepRecoPrimaries, kAssocTrackStepRecoSpecies, - kAssocTrackStepRecoCollMatch, - kAssocTrackStepFake, kAssocTrackNSteps }; using DsHadronPairFull = soa::Join; @@ -188,7 +188,6 @@ struct HfTaskCorrelationDsHadrons { 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("hPtParticleAssocCollMatchMcRec", "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}}); @@ -204,6 +203,8 @@ struct HfTaskCorrelationDsHadrons { 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"}}}); 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})"); @@ -523,47 +524,163 @@ struct HfTaskCorrelationDsHadrons { } PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcRecME, "Process MC Reco ME", false); + SliceCache cache; + Preslice perCollisionCand = o2::aod::hf_cand::collisionId; + Preslice perCollisionCandMc = o2::aod::mcparticle::mcCollisionId; + PresliceUnsorted> collPerCollMc = o2::aod::mccollisionlabel::mcCollisionId; + /// Ds-Hadron correlation - for calculating candidate reconstruction efficiency using MC reco-level analysis - void processMcCandEfficiency(soa::Join const&, - soa::Join const&, + void processMcCandEfficiency(soa::Join const& collisions, + soa::Join const& mcCollisions, CandDsMcGen const& mcParticles, CandDsMcReco const& candidates, aod::TracksWMc const&) { auto hCandidates = registry.get(HIST("hCandidates")); + /// loop over generated collisions + for (const auto& mcCollision : mcCollisions) { + + const auto groupedCollisions = collisions.sliceBy(collPerCollMc, mcCollision.globalIndex()); + const auto groupedMcParticles = mcParticles.sliceBy(perCollisionCandMc, mcCollision.globalIndex()); + + if (groupedCollisions.size() < 1) { // Skipping MC events that have no reconstructed collisions + continue; + } + if (groupedCollisions.size() > 1 && removeCollWSplitVtx) { // Skipping MC events that have more than one reconstructed collision + continue; + } + + /// loop over reconstructed collisions + for (const auto& collision : groupedCollisions) { + + // reco collision selection + if (useSel8ForEff && !collision.sel8()) { + continue; + } + if (std::abs(collision.posZ()) > cutCollPosZMc) { + continue; + } + if (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { + continue; + } + if (!collision.has_mcCollision()) { + registry.fill(HIST("hFakeCollision"), 0.); + continue; + } + + float multiplicityReco = collision.multFT0M(); + float multiplicityGen = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C + + 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()); + 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 (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(), multiplicityGen, mcParticle.originMcGen()); + registry.fill(HIST("hPtCandMcGenDaughterInAcc"), mcParticle.pt()); + } + } + } + + // reconstructed candidate loop + for (const auto& candidate : groupedCandidates) { + if (candidate.pt() < ptCandMin || candidate.pt() > ptCandMax) { + continue; + } + std::vector outputMl = {-1., -1., -1.}; + if (candidate.isSelDsToKKPi() >= selectionFlagDs) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + outputMl[iclass] = candidate.mlProbDsToKKPi()[classMl->at(iclass)]; + } + } else if (candidate.isSelDsToPiKK() >= selectionFlagDs) { + for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) { + 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()))) { + continue; + } + + if ((std::abs(candidate.flagMcMatchRec()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (candidate.flagMcDecayChanRec() == 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 (candidate.originMcRec() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hPtCandMcRecNonPrompt"), candidate.pt()); + } + } + } + } + } + + } // end loop reconstructed collision + } // end loop generated collisions + } + PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcCandEfficiency, "Process MC for calculating candidate reconstruction efficiency", false); + + void processMcCandEfficiencyWoColl(soa::Join const&, + soa::Join const&, + CandDsMcGen const& mcParticles, + 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.pdgCode()) == Pdg::kDS) { + 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(kCandidateStepMcGenAll, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); - if ((std::abs(mcParticle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::DsToKKPi) && (mcParticle.flagMcDecayChanGen() == decayChannel)) { - hCandidates->Fill(kCandidateStepMcGenDsToKKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); - 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()); - } - if (mcParticle.originMcGen() == RecoDecay::OriginType::NonPrompt) { - registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt()); - } + hCandidates->Fill(kCandidateStepMcGenDsToKKPi, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); + 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()); } - 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 (mcParticle.originMcGen() == RecoDecay::OriginType::NonPrompt) { + registry.fill(HIST("hPtCandMcGenNonPrompt"), mcParticle.pt()); } - if (isDaughterInAcceptance) { - hCandidates->Fill(kCandidateStepMcDaughtersInAcceptance, mcParticle.pt(), multiplicity, mcParticle.originMcGen()); - registry.fill(HIST("hPtCandMcGenDaughterInAcc"), 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()); + } } } @@ -608,64 +725,37 @@ struct HfTaskCorrelationDsHadrons { } } } - PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcCandEfficiency, "Process MC for calculating candidate reconstruction efficiency", false); + PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcCandEfficiencyWoColl, "Process MC for calculating candidate reconstruction efficiency", false); + + Preslice perCollision = o2::aod::track::collisionId; + Preslice perCollisionMc = o2::aod::mcparticle::mcCollisionId; /// Ds-Hadron correlation - for calculating associated particle tracking efficiency using MC reco-level analysis - void processMcTrackEfficiency(soa::Join const&, - soa::Join const&, + void processMcTrackEfficiency(soa::Join const& collisions, + soa::Join const& mcCollisions, aod::McParticles const& mcParticles, TracksWithMc const& tracksData) { auto hAssocTracks = registry.get(HIST("hAssocTracks")); - /// Gen loop - float multiplicity = -1.; - float posZ = -20.; - for (const auto& mcParticle : mcParticles) { - // generated tracks - 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))) { - auto mcCollision = mcParticle.template mcCollision_as>(); - if (std::abs(mcCollision.posZ()) > cutCollPosZMc) { - continue; - } - multiplicity = mcCollision.multMCFT0A() + mcCollision.multMCFT0C(); // multFT0M = multFt0A + multFT0C - posZ = mcCollision.posZ(); - if (doMcCollisionCheck && eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { - continue; - } - hAssocTracks->Fill(kAssocTrackStepMcGen, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - if (mcParticle.pt() > ptTrackMin && std::abs(mcParticle.eta()) < etaTrackMax) { - hAssocTracks->Fill(kAssocTrackStepMcGenInAcceptance, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - 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()); - } - } + /// loop over generated collisions + for (const auto& mcCollision : mcCollisions) { + + const auto groupedCollisions = collisions.sliceBy(collPerCollMc, mcCollision.globalIndex()); + const auto groupedMcParticles = mcParticles.sliceBy(perCollisionMc, mcCollision.globalIndex()); + + if (groupedCollisions.size() < 1) { // Skipping MC events that have no reconstructed collisions + continue; + } + if (groupedCollisions.size() > 1 && removeCollWSplitVtx) { // Skipping MC events that have more than one reconstructed collision + continue; } - } - // recontructed tracks loop - for (const auto& track : tracksData) { - if (track.has_collision()) { - if (!track.isGlobalTrackWoDCA() || track.dcaXY() > dcaXYTrackMax || track.dcaZ() > dcaZTrackMax || track.tpcNClsCrossedRows() < nTpcCrossedRaws) { - continue; - } - auto collision = track.template collision_as>(); - if (useSel8ForTrackEff && !collision.sel8()) { + /// loop over reconstructed collisions + for (const auto& collision : groupedCollisions) { + + // reco collision selection + if (useSel8ForEff && !collision.sel8()) { continue; } if (std::abs(collision.posZ()) > cutCollPosZMc) { @@ -674,85 +764,92 @@ struct HfTaskCorrelationDsHadrons { if (selNoSameBunchPileUpColl && !(collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup))) { continue; } - multiplicity = collision.multFT0M(); - posZ = collision.posZ(); - hAssocTracks->Fill(kAssocTrackStepRecoAll, track.eta(), track.pt(), multiplicity, posZ); - if (track.has_mcParticle()) { - auto mcParticle = track.template mcParticle_as(); - if (doMcCollisionCheck) { - auto mcCollision = track.template mcParticle_as().template mcCollision_as>(); - if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { - continue; - } - hAssocTracks->Fill(kAssocTrackStepRecoMcMatch, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - if (mcParticle.isPhysicalPrimary()) { - hAssocTracks->Fill(kAssocTrackStepRecoPrimaries, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - 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, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - registry.fill(HIST("hPtParticleAssocSpecieMcRec"), track.pt()); - // check if mcParticle pt is equal to the one of the reconstructed track - registry.fill(HIST("hPtMcParticleAssocSpecieMcRec"), mcParticle.pt()); + if (!collision.has_mcCollision()) { + registry.fill(HIST("hFakeCollision"), 0.); + 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("hPtPrmPionMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmPionMcGen"), mcParticle.pt()); } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { - registry.fill(HIST("hPtPrmKaonMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmKaonMcGen"), mcParticle.pt()); } else if (std::abs(mcParticle.pdgCode()) == kProton) { - registry.fill(HIST("hPtPrmProtonMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmProtonMcGen"), mcParticle.pt()); } else if (std::abs(mcParticle.pdgCode()) == kElectron) { - registry.fill(HIST("hPtPrmElectronMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmElectronMcGen"), mcParticle.pt()); } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { - registry.fill(HIST("hPtPrmMuonMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmMuonMcGen"), mcParticle.pt()); } int trackOrigin = RecoDecay::getCharmHadronOrigin(mcParticles, mcParticle, true); if (trackOrigin == 1) { // charm orgin - registry.fill(HIST("hPtPrmPromptPartMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmPromptPartMcGen"), mcParticle.pt()); } else if (trackOrigin == 2) { // beauty origin - registry.fill(HIST("hPtPrmNonPromptPartMcRec"), mcParticle.pt()); - } - if (mcParticle.mcCollisionId() == track.collisionId()) { - hAssocTracks->Fill(kAssocTrackStepRecoCollMatch, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); - registry.fill(HIST("hPtParticleAssocCollMatchMcRec"), track.pt()); + registry.fill(HIST("hPtPrmNonPromptPartMcGen"), mcParticle.pt()); } } } - } else { - hAssocTracks->Fill(kAssocTrackStepRecoMcMatch, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); + } + } + + // reconstructed track loop + for (const auto& track : groupedTracks) { + if (!track.isGlobalTrackWoDCA()) { + 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, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); + 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, mcParticle.eta(), mcParticle.pt(), multiplicity, posZ); + hAssocTracks->Fill(kAssocTrackStepRecoSpecies, track.eta(), track.pt(), multiplicityReco, posZReco); registry.fill(HIST("hPtParticleAssocSpecieMcRec"), track.pt()); - // check if mcParticle pt is equal to the one of the reconstructed track + // check the pt spectra of mcParticle registry.fill(HIST("hPtMcParticleAssocSpecieMcRec"), mcParticle.pt()); if (std::abs(mcParticle.pdgCode()) == kPiPlus) { - registry.fill(HIST("hPtPrmPionMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmPionMcRec"), track.pt()); } else if (std::abs(mcParticle.pdgCode()) == kKPlus) { - registry.fill(HIST("hPtPrmKaonMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmKaonMcRec"), track.pt()); } else if (std::abs(mcParticle.pdgCode()) == kProton) { - registry.fill(HIST("hPtPrmProtonMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmProtonMcRec"), track.pt()); } else if (std::abs(mcParticle.pdgCode()) == kElectron) { - registry.fill(HIST("hPtPrmElectronMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmElectronMcRec"), track.pt()); } else if (std::abs(mcParticle.pdgCode()) == kMuonMinus) { - registry.fill(HIST("hPtPrmMuonMcRec"), mcParticle.pt()); + 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"), mcParticle.pt()); + registry.fill(HIST("hPtPrmPromptPartMcRec"), track.pt()); } else if (trackOrigin == 2) { // beauty origin - registry.fill(HIST("hPtPrmNonPromptPartMcRec"), mcParticle.pt()); + registry.fill(HIST("hPtPrmNonPromptPartMcRec"), track.pt()); } } } + } else { + // fake track + registry.fill(HIST("hFakeTracks"), 0.); } } - } else { - // fake track - hAssocTracks->Fill(kAssocTrackStepFake, track.eta(), track.pt(), multiplicity, posZ); - } - } + + } // end loop reconstructed collision + } // end loop generated collisions } PROCESS_SWITCH(HfTaskCorrelationDsHadrons, processMcTrackEfficiency, "Process MC for calculating associated particle tracking efficiency", false); }; diff --git a/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx new file mode 100644 index 00000000000..5f63948b769 --- /dev/null +++ b/PWGHF/HFC/Tasks/taskCorrelationHfeHadrons.cxx @@ -0,0 +1,68 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 taskCorrelationHfeHadrons.cxx +/// \brief HFE-Hadrons azimuthal correlations analysis task - data-like, MC-reco and MC-Gen analyses +/// \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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::aod::hf_correlation_electron_hadron; + +struct HfTaskCorrelationHfeHadrons { + // Configurables + // 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}}}; + + 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(); + } + + // correlation for electron hadron + void process(aod::HfEHadronPair const& pairEntries) + { + double deltaPhi = -999; + double deltaEta = -999; + double ptHadron = -999; + double ptElectron = -999; + + for (const auto& pairEntry : pairEntries) { + + deltaPhi = pairEntry.deltaPhi(); + deltaEta = pairEntry.deltaEta(); + ptElectron = pairEntry.ptElectron(); + ptHadron = pairEntry.ptHadron(); + + registry.fill(HIST("hInclusiveEHCorrel"), ptElectron, ptHadron, deltaPhi, deltaEta); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx b/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx index 889ded1486e..3acc221d30f 100644 --- a/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx +++ b/PWGHF/HFC/Tasks/taskCorrelationLcHadrons.cxx @@ -14,6 +14,8 @@ /// \author Marianna Mazzilli /// \author Zhen Zhang +#include + #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" #include "Framework/runDataProcessing.h" @@ -22,10 +24,12 @@ #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsAnalysis.h" #include "PWGHF/HFC/DataModel/CorrelationTables.h" +#include "PWGHF/HFC/Utils/utilsCorrelations.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::analysis::hf_correlations; /// /// Returns deltaPhi value in range [-pi/2., 3.*pi/2], typically used for correlation studies @@ -61,6 +65,8 @@ AxisSpec axisDeltaPhi = {64, -o2::constants::math::PIHalf, 3. * o2::constants::m AxisSpec axisPtLc = {10, 0., 10.}; AxisSpec axisPtHadron = {11, 0., 11.}; AxisSpec axisPoolBin = {9, 0., 9.}; +AxisSpec axisCorrelationState = {2, 0., 2., ""}; +ConfigurableAxis axisMass{"axisMass", {120, 1.98f, 2.58f}, ""}; // definition of vectors for standard ptbin and invariant mass configurables const int nPtBinsCorrelations = 8; @@ -96,35 +102,47 @@ struct HfTaskCorrelationLcHadrons { 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> efficiencyLc{"efficiencyLc", std::vector{vecEfficiencyLc}, "Efficiency values for Lc "}; + Configurable isTowardTransverseAway{"isTowardTransverseAway", false, "Divide into three regions: toward, transverse, and away"}; + Configurable leadingParticlePtMin{"leadingParticlePtMin", 0., "Min for leading particle pt"}; using LcHadronPairFull = soa::Join; HistogramRegistry registry{ "registry", - { - {"hDeltaEtaPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() - {"hDeltaEtaPtIntSidebands", stringLcHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebands", stringLcHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSidebands", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSidebands", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() - {"hDeltaEtaPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DVsPtSignalMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, - {"hCorrel2DVsPtBkgMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, - {"hDeltaEtaPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, - {"hDeltaEtaPtIntMcGen", stringMcParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, - {"hDeltaPhiPtIntMcGen", stringMcParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, - {"hCorrel2DPtIntMcGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, - {"hCorrel2DVsPtMcGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() - }}; + {{"hDeltaEtaPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, + {"hDeltaPhiPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, + {"hCorrel2DPtIntSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, + {"hCorrel2DVsPtSignalRegion", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() + {"hDeltaEtaPtIntSidebands", stringLcHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, + {"hDeltaPhiPtIntSidebands", stringLcHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, + {"hCorrel2DPtIntSidebands", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, + {"hCorrel2DVsPtSidebands", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() + {"hDeltaEtaPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, + {"hDeltaPhiPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, + {"hCorrel2DPtIntSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, + {"hCorrel2DVsPtSignalRegionMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, + {"hCorrel2DVsPtSignalMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, + {"hCorrel2DVsPtBkgMcRec", stringLcHadron + stringSignal + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, + {"hDeltaEtaPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, + {"hDeltaPhiPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, + {"hCorrel2DPtIntSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, + {"hCorrel2DVsPtSidebandsMcRec", stringLcHadron + stringSideband + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPtHadron + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, + {"hDeltaEtaPtIntMcGen", stringMcParticles + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}}}, + {"hDeltaPhiPtIntMcGen", stringMcParticles + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}}}, + {"hCorrel2DPtIntMcGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}}}, + {"hCorrel2DVsPtMcGen", stringMcParticles + stringDeltaPhi + stringDeltaEta + stringPtLc + stringPoolBin + "entries", {HistType::kTHnSparseD, {{axisDeltaPhi}, {axisDeltaEta}, {axisPtLc}, {axisPtHadron}, {axisPoolBin}}}}, // note: axes 3 and 4 (the Pt) are updated in the init() + // Toward Transverse Away + {"hToward", "Toward invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hTransverse", "Transverse invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hAway", "Away invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + // Toward Transverse Away for McRec + {"hTowardRec", "Toward invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hTransverseRec", "Transverse invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hAwayRec", "Away invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + // Toward Transverse Away for McGen + {"hTowardGen", "Toward invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hTransverseGen", "Transverse invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}, + {"hAwayGen", "Away invmass; ptLc; correlationState;entries", {HistType::kTH3F, {{axisMass}, {axisPtLc}, {axisCorrelationState}}}}}}; void init(InitContext&) { @@ -160,6 +178,7 @@ struct HfTaskCorrelationLcHadrons { int effBinLc = o2::analysis::findBin(binsPtEfficiency, ptLc); int ptBinLc = o2::analysis::findBin(binsPtCorrelations, ptLc); int poolBin = pairEntry.poolBin(); + bool isAutoCorrelated = pairEntry.isAutoCorrelated(); // reject entries outside Pt ranges of interest if (ptBinLc < 0 || effBinLc < 0) { continue; @@ -172,6 +191,28 @@ struct HfTaskCorrelationLcHadrons { if (applyEfficiency) { efficiencyWeight = 1. / (efficiencyLc->at(effBinLc) * efficiencyHadron); } + + // Divide into three regions: toward, transverse, and away + if (isTowardTransverseAway) { + if (ptHadron < leadingParticlePtMin) { + continue; + } + Region region = getRegion(deltaPhi); + switch (region) { + case Toward: + registry.fill(HIST("hToward"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + case Away: + registry.fill(HIST("hAway"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + case Transverse: + registry.fill(HIST("hTransverse"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + default: + break; + } + } + // check if correlation entry belongs to signal region, sidebands or is outside both, and fill correlation plots if (massLc > signalRegionInner->at(ptBinLc) && massLc < signalRegionOuter->at(ptBinLc)) { // in signal region @@ -208,6 +249,7 @@ struct HfTaskCorrelationLcHadrons { int effBinLc = o2::analysis::findBin(binsPtEfficiency, ptLc); int ptBinLc = o2::analysis::findBin(binsPtCorrelations, ptLc); int poolBin = pairEntry.poolBin(); + bool isAutoCorrelated = pairEntry.isAutoCorrelated(); if (ptBinLc < 0 || effBinLc < 0) { continue; } @@ -217,6 +259,28 @@ struct HfTaskCorrelationLcHadrons { if (applyEfficiency) { efficiencyWeight = 1. / (efficiencyLc->at(effBinLc) * efficiencyHadron); } + + // Divide into three regions: toward, transverse, and away + if (isTowardTransverseAway) { + if (ptHadron < leadingParticlePtMin) { + continue; + } + Region region = getRegion(deltaPhi); + switch (region) { + case Toward: + registry.fill(HIST("hTowardRec"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + case Away: + registry.fill(HIST("hAwayRec"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + case Transverse: + registry.fill(HIST("hTransverseRec"), massLc, ptLc, isAutoCorrelated, efficiencyWeight); + break; + default: + break; + } + } + // fill correlation plots for signal/bagkground correlations if (pairEntry.signalStatus()) { registry.fill(HIST("hCorrel2DVsPtSignalMcRec"), deltaPhi, deltaEta, ptLc, ptHadron, poolBin, efficiencyWeight); @@ -256,6 +320,7 @@ struct HfTaskCorrelationLcHadrons { double ptLc = pairEntry.ptLc(); double ptHadron = pairEntry.ptHadron(); int poolBin = pairEntry.poolBin(); + bool isAutoCorrelated = pairEntry.isAutoCorrelated(); // reject entries outside Pt ranges of interest if (o2::analysis::findBin(binsPtCorrelations, ptLc) < 0) { continue; @@ -264,6 +329,26 @@ struct HfTaskCorrelationLcHadrons { ptHadron = 10.5; } + if (isTowardTransverseAway) { + // Divide into three regions: toward, transverse, and away + if (ptHadron < leadingParticlePtMin) { + continue; + } + Region region = getRegion(deltaPhi); + switch (region) { + case Toward: + registry.fill(HIST("hTowardRec"), o2::constants::physics::MassLambdaCPlus, ptLc, isAutoCorrelated); + break; + case Away: + registry.fill(HIST("hAwayRec"), o2::constants::physics::MassLambdaCPlus, ptLc, isAutoCorrelated); + break; + case Transverse: + registry.fill(HIST("hTransverseRec"), o2::constants::physics::MassLambdaCPlus, ptLc, isAutoCorrelated); + break; + default: + break; + } + } registry.fill(HIST("hCorrel2DVsPtMcGen"), deltaPhi, deltaEta, ptLc, ptHadron, poolBin); registry.fill(HIST("hCorrel2DPtIntMcGen"), deltaPhi, deltaEta); registry.fill(HIST("hDeltaEtaPtIntMcGen"), deltaEta); diff --git a/PWGHF/HFC/Tasks/taskFlow.cxx b/PWGHF/HFC/Tasks/taskFlow.cxx index 2053295e740..023a5b02923 100644 --- a/PWGHF/HFC/Tasks/taskFlow.cxx +++ b/PWGHF/HFC/Tasks/taskFlow.cxx @@ -13,6 +13,9 @@ /// \author Katarina Krizkova Gajdosova , CERN /// \author Maja Kabus , CERN +#include +#include + #include #include #include @@ -23,6 +26,8 @@ #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" @@ -47,7 +52,9 @@ using namespace o2::framework; using namespace o2::framework::expressions; struct HfTaskFlow { + // configurables for processing options + 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"}; Configurable processMc{"processMc", false, "Flag to run on MC"}; @@ -60,28 +67,89 @@ struct HfTaskFlow { // configurables 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"}; 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 nClustersMftTrack{"nClustersMftTrack", 5, "Minimum number of clusters for the reconstruction of MFT tracks"}; + Service pdg; HfHelper hfHelper; SliceCache cache; + // ========================= + // using declarations : DATA + // ========================= + using FilteredCollisionsWSelMult = soa::Filtered>; + using HfCandidatesSelD0 = soa::Filtered>; + using HfCandidatesSelLc = soa::Filtered>; using TracksWDcaSel = soa::Filtered>; - using HfCandidatesSel = soa::Filtered>; + + // ========================= + // using declarations : MC + // ========================= + + // 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>; + + // ========================= + // Filters & partitions : DATA + // ========================= + + // 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 candidateFilterLc = aod::hf_sel_candidate_lc::isSelLcToPKPi >= selectionFlagLcToPKPi || + aod::hf_sel_candidate_lc::isSelLcToPiKP >= selectionFlagLcToPiKP; // Collision filters // FIXME: The filter is applied also on the candidates! Beware! Filter collisionVtxZFilter = nabs(aod::collision::posZ) < zVertexMax; - // Charged track filters + Filter trackFilter = (nabs(aod::track::eta) < etaTrackAssocMax) && (aod::track::pt > ptTrackAssocMin) && requireGlobalTrackWoPtEtaInFilter(); - // HF candidate filter - // TODO: use Partition instead of filter - Filter candidateFilter = aod::hf_sel_candidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_sel_candidate_d0::isSelD0bar >= selectionFlagD0bar; - Preslice perCol = aod::track::collisionId; + // ========================= + // Filters & partitions : MC + // ========================= + + // 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) + + // ========================= + // Preslice : DATA + // ========================= + + 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; // configurables for containers ConfigurableAxis axisVertex{"axisVertex", {14, -7, 7}, "vertex axis for histograms"}; @@ -100,19 +168,29 @@ struct HfTaskFlow { HistogramRegistry registry{"registry"}; - OutputObj sameTPCTPCCh{"sameEventTPCTPCChHadrons"}; - OutputObj sameTPCMFTCh{"sameEventTPCMFTChHadrons"}; - OutputObj sameHF{"sameEventHFHadrons"}; - OutputObj mixedTPCTPCCh{"mixedEventTPCTPCChHadrons"}; - OutputObj mixedHF{"mixedEventHFHadrons"}; - OutputObj mixedMFT{"mixedEventTPCMFTChHadrons"}; + // 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 + + // Correlation containers used for Monte-Carlo + OutputObj sameTPCTPCChChMC{"sameTPCTPCChChMC"}; + OutputObj mixedTPCTPCChChMC{"mixedTPCTPCChChMC"}; // ========================= // init() // ========================= void init(InitContext&) { - // EVENT HISTOGRAMS + // ========================= + // Event histograms + // TO-DO : do i have to separate event histograms between DATA and MC ? + // ========================= constexpr int kNBinsEvents = 3; registry.add("Data/hEventCounter", "hEventCounter", {HistType::kTH1F, {{kNBinsEvents, 0.5, 0.5 + kNBinsEvents}}}); // set axes of the event counter histogram @@ -120,70 +198,314 @@ struct HfTaskFlow { labels[0] = "all"; labels[1] = "after trigger selection (Run 2)"; labels[2] = "after Physics selection"; + + const int nBinsMix = axisMultiplicity->size() * 14; // 14 bins for z-vertex + for (int iBin = 0; iBin < kNBinsEvents; iBin++) { registry.get(HIST("Data/hEventCounter"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } - registry.add("Data/HadronHadron/SameEvent/hMultiplicity", "hMultiplicity", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/HadronHadron/SameEvent/hVtxZ", "hVtxZ", {HistType::kTH1F, {{400, -50, 50}}}); - registry.add("Data/HadronHadron/SameEvent/hNtracks", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); - - // histograms for event mixing - const int maxMixBin = axisMultiplicity->size() * 14; // 14 bins for z-vertex - registry.add("Data/HadronHadron/MixedEvent/hEventCountMixing", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); - registry.add("Data/HadronHf/MixedEvent/hEventCountHFMixing", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); - registry.add("Data/HadronHadron/SameEvent/hEventCountSame", "bin", {HistType::kTH1F, {{maxMixBin + 2, -2.5, -0.5 + maxMixBin, "bin"}}}); - registry.add("Data/HadronHadron/MixedEvent/hMultiplicityMixing", "hMultiplicityMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/HadronHadron/MixedEvent/hVtxZMixing", "hVtxZMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/HadronHadron/MixedEvent/hNtracksMixing", "hNtracksMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/HadronHf/MixedEvent/hMultiplicityHFMixing", "hMultiplicityHFMixing", {HistType::kTH1F, {{500, 0, 500}}}); - registry.add("Data/HadronHf/MixedEvent/hVtxZHFMixing", "hVtxZHFMixing", {HistType::kTH1F, {{100, -10, 10}}}); - registry.add("Data/HadronHf/MixedEvent/hNtracksHFMixing", "hNtracksHFMixing", {HistType::kTH1F, {{500, 0, 500}}}); - - // TRACK HISTOGRAMS - // histograms for associated particles - registry.add("Data/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/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/HadronHadron/SameEvent/hPt", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/HadronHadron/SameEvent/hEta", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/HadronHadron/SameEvent/hPhi", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - - // histograms for particles in event mixing - registry.add("Data/HadronHadron/MixedEvent/hPtMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/HadronHadron/MixedEvent/hEtaMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/HadronHadron/MixedEvent/hPhiMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - - // histograms for MFT tracks - registry.add("Data/HadronMft/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/HadronMft/hEtaMFT", "etaMFT", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/HadronMft/hPhiMFT", "phiMFT", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - - // histograms for candidates + + // ========================= + // DATA : histograms for TPC-TPC h-h case + // ========================= + + // 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/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}}}); + + // Katarina had this : + registry.add("Data/TpcTpc/HadronHadron/SameEvent/hVzEta", "eta vs. Vz", {HistType::kTH2F, {{100, -4, 4, "#eta"}, {20, -10, 10, "Vz"}}}); + + // 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/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 : histograms for TPC-TPC HF-h case for 3PRONG + // =================== + + 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, {{10000, 0., 10000.}}}); + 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})"}}}); + + // ========================= + // DATA : histograms for TPC-MFT h-h case + // ========================= + + // DATA : trigger particles (TPC tracks) histograms for TPC-MFT h-h same event + 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}}}); + + // 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, -2, 2, "#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}}}); + + // 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"}}}); + + // ========================= + // DATA : histograms for TPC-MFT HF-h case FOR 2PRONG + // ========================= + + // DATA : trigger particles (candidates) histograms for TPC-MFT HF-h same event + 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/hNtracksCandidate", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + + // 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})"}}}); + + // 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, -2, 2, "#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}}}); + + // 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"}}}); + + // ========================= + // DATA : histograms for TPC-MFT HF-h case FOR 3PRONG + // ========================= + + 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/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/hMultiplicity", "multiplicity;multiplicity;entries", {HistType::kTH1F, {{10000, 0., 10000.}}}); + 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})"}}}); + + // ========================= + // MC : histograms for TPC-TPC h-h case + // ========================= + + // 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/hEventCountSame", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + // Katarina had this : + registry.add("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {{500, 0, 500}}}); + // 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}}}); + // 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}}}); + + // 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/hEventCountSame", "hNtracks", {HistType::kTH1F, {{500, 0, 500}}}); + // Katarina had this : + registry.add("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicityPrimary", "hMultiplicityPrimary", {HistType::kTH1F, {{500, 0, 500}}}); + // 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}}}); + // 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}}}); + + // ========================= + // Declaration of correlation containers and their respective axis + // ========================= - registry.add("Data/HadronHf/hPtCand", "2-prong candidates;candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/HadronHf/hPtProng0", "2-prong candidates;prong 0 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/HadronHf/hPtProng1", "2-prong candidates;prong 1 #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0, 10.}}}); - registry.add("Data/HadronHf/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("Data/HadronHf/hDecLength", "2-prong candidates;decay length (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/hDecLengthXY", "2-prong candidates;decay length xy (cm);entries", {HistType::kTH2F, {{200, 0., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/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/HadronHf/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/HadronHf/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/HadronHf/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/HadronHf/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/HadronHf/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/HadronHf/hEtaCand", "2-prong candidates;candidate #it{#eta};entries", {HistType::kTH2F, {{100, -2., 2.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/hSelectionStatus", "2-prong candidates;selection status;entries", {HistType::kTH2F, {{5, -0.5, 4.5}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/hImpParErr", "2-prong candidates;impact parameter error (cm);entries", {HistType::kTH2F, {{100, -1., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/hDecLenErr", "2-prong candidates;decay length error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - registry.add("Data/HadronHf/hDecLenXYErr", "2-prong candidates;decay length xy error (cm);entries", {HistType::kTH2F, {{100, 0., 1.}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}}); - - // histograms for candidates in event mixing - registry.add("Data/HadronHf/MixedEvent/hPtHFMixing", "pT", {HistType::kTH1F, {{100, 0, 10, "p_{T}"}}}); - registry.add("Data/HadronHf/MixedEvent/hEtaHFMixing", "eta", {HistType::kTH1F, {{100, -4, 4, "#eta"}}}); - registry.add("Data/HadronHf/MixedEvent/hPhiHFMixing", "phi", {HistType::kTH1F, {{100, 0, TwoPI, "#varphi"}}}); - - // set axes of the correlation container std::vector corrAxis = {{axisDeltaEta, "#Delta#eta"}, {axisPtAssoc, "p_{T} (GeV/c)"}, {axisPtTrigger, "p_{T} (GeV/c)"}, @@ -195,107 +517,317 @@ struct HfTaskFlow { {axisVertexEfficiency, "z-vtx (cm)"}}; std::vector userAxis = {{axisMass, "m_{inv} (GeV/c^{2})"}}; - sameTPCTPCCh.setObject(new CorrelationContainer("sameEventTPCTPCChHadrons", "sameEventTPCTPCChHadrons", corrAxis, effAxis, {})); - sameTPCMFTCh.setObject(new CorrelationContainer("sameEventTPCMFTChHadrons", "sameEventTPCMFTChHadrons", corrAxis, effAxis, {})); - sameHF.setObject(new CorrelationContainer("sameEventHFHadrons", "sameEventHFHadrons", corrAxis, effAxis, userAxis)); - mixedTPCTPCCh.setObject(new CorrelationContainer("mixedEventTPCTPCChHadrons", "mixedEventTPCTPCChHadrons", corrAxis, effAxis, {})); - mixedHF.setObject(new CorrelationContainer("mixedEventHFHadrons", "mixedEventHFHadrons", corrAxis, effAxis, userAxis)); - mixedMFT.setObject(new CorrelationContainer("mixedEventTPCMFTChHadrons", "mixedEventTPCMFTChHadrons", corrAxis, effAxis, {})); - } - - // --------------- + // 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)); + + // initialization of correlation containes for monte-carlo + sameTPCTPCChChMC.setObject(new CorrelationContainer("sameTPCTPCChChMC", "sameTPCTPCChChMC", corrAxis, effAxis, {})); + mixedTPCTPCChChMC.setObject(new CorrelationContainer("mixedTPCTPCChChMC", "mixedTPCTPCChChMC", corrAxis, effAxis, {})); + } // End of init() function + + // ========================= // templates // FIXME: Some collisions are rejected here, what causes (part of) differences with the D0 task - // --------------- + // ========================= template bool isCollisionSelected(TCollision const& collision, bool fillHistograms = false) { - if (processRun2 == true) { - // Run 2: trigger selection for data case - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 1); - if (!processMc) { - if (!collision.alias_bit(kINT7)) { - return false; - } - } - // Run 2: further offline selection - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 2); - if (!collision.sel7()) { - return false; - } - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 3); - } else { - // Run 3: selection - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 1); + if (fillHistograms) + registry.fill(HIST("Data/hEventCounter"), 1); + + if (processMc == false) { if (!collision.sel8()) { return false; } - if (fillHistograms) - registry.fill(HIST("Data/hEventCounter"), 3); } + + if (fillHistograms) + registry.fill(HIST("Data/hEventCounter"), 3); + return true; } + // ========================= + // Quality Assesment plots + // ========================= + + // ---- DATA : TPC-TPC h-h Same Event QA ---- template - void fillQA(float multiplicity, TTracks const& tracks) + void fillTpcTpcChChSameEventQa(float multiplicity, TTracks const& tracks) { - int Ntracks = 0; + int nTracks = tracks.size(); for (const auto& track1 : tracks) { - Ntracks++; - registry.fill(HIST("Data/HadronHadron/SameEvent/hPt"), track1.pt()); - registry.fill(HIST("Data/HadronHadron/SameEvent/hEta"), track1.eta()); - registry.fill(HIST("Data/HadronHadron/SameEvent/hPhi"), track1.phi()); - registry.fill(HIST("Data/HadronHadron/SameEvent/hYields"), multiplicity, track1.pt(), track1.eta()); - registry.fill(HIST("Data/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track1.eta(), track1.phi()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hPt"), track1.pt()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hEta"), track1.eta()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hPhi"), track1.phi()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hYields"), multiplicity, track1.pt(), track1.eta()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hEtaPhi"), multiplicity, track1.eta(), track1.phi()); + } + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hNtracks"), nTracks); + } + + // ---- 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) + { + 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); + } 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("Data/HadronHadron/SameEvent/hNtracks"), Ntracks); + return nTracks; } + // ---- DATA : TPC-TPC h-h Mixed Event QA ---- template - void fillMixingQA(float multiplicity, float vz, TTracks const& tracks) + void fillTpcTpcChChMixedEventQa(float multiplicity, float vz, TTracks const& tracks) { - registry.fill(HIST("Data/HadronHadron/MixedEvent/hMultiplicityMixing"), multiplicity); - registry.fill(HIST("Data/HadronHadron/MixedEvent/hVtxZMixing"), vz); + registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hMultiplicityMixing"), multiplicity); + registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hVtxZMixing"), vz); - int Ntracks = 0; + int nTracks = tracks.size(); for (const auto& track1 : tracks) { - Ntracks++; - registry.fill(HIST("Data/HadronHadron/MixedEvent/hPtMixing"), track1.pt()); - registry.fill(HIST("Data/HadronHadron/MixedEvent/hEtaMixing"), track1.eta()); - registry.fill(HIST("Data/HadronHadron/MixedEvent/hPhiMixing"), track1.phi()); + 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/HadronHadron/MixedEvent/hNtracksMixing"), Ntracks); + registry.fill(HIST("Data/TpcTpc/HadronHadron/MixedEvent/hNtracksMixing"), nTracks); } + // ---- MC : TPC-TPC h-h Mixed Event QA ---- template - void fillHFMixingQA(float multiplicity, float vz, TTracks const& tracks) + void fillTpcTpcChChMixedEventQaMc(float multiplicity, float vz, TTracks const& tracks) { - registry.fill(HIST("Data/HadronHf/MixedEvent/hMultiplicityHFMixing"), multiplicity); - registry.fill(HIST("Data/HadronHf/MixedEvent/hVtxZHFMixing"), vz); + 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 = 0; + int nTracks = tracks.size(); for (const auto& track1 : tracks) { - Ntracks++; - registry.fill(HIST("Data/HadronHf/MixedEvent/hPtHFMixing"), track1.pt()); - registry.fill(HIST("Data/HadronHf/MixedEvent/hEtaHFMixing"), track1.eta()); - registry.fill(HIST("Data/HadronHf/MixedEvent/hPhiHFMixing"), track1.phi()); + 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); } - registry.fill(HIST("Data/HadronHf/MixedEvent/hNtracksHFMixing"), Ntracks); } + // ---- DATA : TPC-TPC HF-h Mixed Event QA ---- template - void fillMFTQA(float multiplicity, TTracks const& tracks) + 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) { - registry.fill(HIST("Data/HadronMft/hEtaMFT"), track1.eta()); - float phi = track1.phi(); - o2::math_utils::bringTo02Pi(phi); - registry.fill(HIST("Data/HadronMft/hPhiMFT"), phi); - registry.fill(HIST("Data/HadronMft/hEtaPhiMFT"), multiplicity, track1.eta(), phi); + + // 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 Same Event QA ---- + template + void fillTpcMftChChSameEventQa(float multiplicity, TTracks const& tracks) + { + int nTracks = tracks.size(); + bool isMFT = false; + for (const auto& track1 : tracks) { + if constexpr (std::is_same_v) { // if MFT tracks + + // apply cuts for MFT tracks + if (!isAcceptedMftTrack(track1)) { + continue; + } + + isMFT = true; + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hEtaMFT"), track1.eta()); + float phi = track1.phi(); + o2::math_utils::bringTo02Pi(phi); + + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hPhiMFT"), phi); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiMFT"), multiplicity, track1.eta(), phi); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hPtMFT"), track1.pt()); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hYieldsMFT"), multiplicity, track1.pt(), track1.eta()); + } else { // if TPC tracks + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hEtaTPC"), track1.eta()); + float phi = track1.phi(); + o2::math_utils::bringTo02Pi(phi); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hPhiTPC"), phi); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hEtaPhiTPC"), multiplicity, track1.eta(), phi); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hPtTPC"), track1.pt()); + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hYieldsTPC"), multiplicity, track1.pt(), track1.eta()); + } + if (isMFT) { + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hNtracksMFT"), nTracks); + } else { + registry.fill(HIST("Data/TpcMft/HadronHadron/SameEvent/hNtracksTPC"), nTracks); + } + } + } + + // ---- DATA : TPC-MFT HF-h Same Event QA ---- + template + void fillTpcMftHfChSameEventQa(float multiplicity, TTracks const& tracks) + { + // This is only called with MFT tracks, so no TPC case here + int nTracks = tracks.size(); + for (const auto& track1 : tracks) { + if constexpr (std::is_same_v) { // if MFT tracks + + // apply cuts for MFT tracks + if (!isAcceptedMftTrack(track1)) { + continue; + } + + float phi = track1.phi(); + o2::math_utils::bringTo02Pi(phi); + + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hEtaMFT"), track1.eta()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hPhiMFT"), phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hEtaPhiMFT"), multiplicity, track1.eta(), phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hPtMFT"), track1.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hYieldsMFT"), multiplicity, track1.pt(), track1.eta()); + } + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/hNtracksMFT"), 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); } } @@ -303,18 +835,68 @@ struct HfTaskFlow { template bool isAcceptedCandidate(TTrack const& candidate) { - if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + + if constexpr (std::is_same_v) { // For now, that means we do LambdaC + if (!(candidate.hfflag() & 1 << aod::hf_cand_3prong::DecayType::LcToPKPi)) { + return false; + } + if (yCandMax >= 0. && std::abs(hfHelper.yLc(candidate)) > yCandMax) { + return false; + } + return true; + } else { // For now, that means we do D0 + if (!(candidate.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) { + return false; + } + if (yCandMax >= 0. && std::abs(hfHelper.yD0(candidate)) > yCandMax) { + return false; + } + return true; + } + } + + // TODO: Check how to put this into a Filter + // I tried to put it as a filter, but filters for normal TPC tracks also apply to MFT tracks I think + // and it seems that they are not compatible + template + bool isAcceptedMftTrack(TTrack const& mftTrack) + { + // cut on the eta of MFT tracks + if (mftTrack.eta() > etaMftTrackMax || mftTrack.eta() < etaMftTrackMin) { return false; } - if (yCandMax >= 0. && std::abs(hfHelper.yD0(candidate)) > yCandMax) { + + // cut on the number of clusters of the reconstructed MFT track + if (mftTrack.nClusters() < nClustersMftTrack) { 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 isMcParticleSelected(TMcParticles& mcParticles) + { + // remove MC particles with charge = 0 + TParticlePDG* pdgparticle = pdg->GetParticle(mcParticles.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 true; } + // ---- 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 template - void fillCandidateQA(TTracks const& candidates) + void fillTpcTpcD0CandidateQa(TTracks const& candidates) { for (const auto& candidate : candidates) { if (!isAcceptedCandidate(candidate)) { @@ -322,33 +904,224 @@ struct HfTaskFlow { } if (candidate.isSelD0() >= selectionFlagD0) { - registry.fill(HIST("Data/HadronHf/hMass"), hfHelper.invMassD0ToPiK(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0ToPiK(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0ToPiK(candidate)); } if (candidate.isSelD0bar() >= selectionFlagD0bar) { - registry.fill(HIST("Data/HadronHf/hMass"), hfHelper.invMassD0barToKPi(candidate), candidate.pt()); - } - - registry.fill(HIST("Data/HadronHf/hPtCand"), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hPtProng0"), candidate.ptProng0()); - registry.fill(HIST("Data/HadronHf/hPtProng1"), candidate.ptProng1()); - registry.fill(HIST("Data/HadronHf/hDecLength"), candidate.decayLength(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hDecLengthXY"), candidate.decayLengthXY(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hd0Prong0"), candidate.impactParameter0(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hd0Prong1"), candidate.impactParameter1(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hd0d0"), candidate.impactParameterProduct(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hCTS"), hfHelper.cosThetaStarD0(candidate), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hCt"), hfHelper.ctD0(candidate), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hCPA"), candidate.cpa(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hEtaCand"), candidate.eta(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hSelectionStatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hImpParErr"), candidate.errorImpactParameter0(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hImpParErr"), candidate.errorImpactParameter1(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hDecLenErr"), candidate.errorDecayLength(), candidate.pt()); - registry.fill(HIST("Data/HadronHf/hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt()); - } - } - - template + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0barToKPi(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0barToKPi(candidate)); + } + + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hPtCandidate"), candidate.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(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLengthXY"), candidate.decayLengthXY(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong0"), candidate.impactParameter0(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0Prong1"), candidate.impactParameter1(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hd0d0"), candidate.impactParameterProduct(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCTS"), hfHelper.cosThetaStarD0(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCt"), hfHelper.ctD0(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hCPA"), candidate.cpa(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hEtaCandVsPt"), candidate.eta(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hSelectionStatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter0(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter1(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenErr"), candidate.errorDecayLength(), candidate.pt()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/2Prong/hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt()); + } + } + + // ---- 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 + template + void fillTpcTpcLcCandidateQa(TTracks const& candidates) + { + int nTracks = candidates.size(); + for (const auto& candidate : candidates) { + if (!isAcceptedCandidate(candidate)) { + continue; + } + + auto pt = candidate.pt(); + 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(); + + if (candidate.isSelLcToPKPi() >= selectionFlagLcToPKPi) { + 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, nTracks); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPKPi(candidate), pt); + } + if (candidate.isSelLcToPiKP() >= selectionFlagLcToPiKP) { + 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, nTracks); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMassVsPt"), hfHelper.invMassLcToPiKP(candidate), pt); + } + + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hMultiplicity"), nTracks); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPt"), pt); + 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/hPhi"), candidate.phi()); + registry.fill(HIST("Data/TpcTpc/HfHadron/SameEvent/3Prong/hPhiVsPt"), candidate.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 ---- + // 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 fillTpcMftD0CandidateQa(TTracks const& candidates, float multiplicity) + { + int nTracks = candidates.size(); + for (const auto& candidate : candidates) { + if (!isAcceptedCandidate(candidate)) { + continue; + } + + if (candidate.isSelD0() >= selectionFlagD0) { + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0ToPiK(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0ToPiK(candidate)); + } + if (candidate.isSelD0bar() >= selectionFlagD0bar) { + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMassVsPt"), hfHelper.invMassD0barToKPi(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hMass"), hfHelper.invMassD0barToKPi(candidate)); + } + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandidate"), candidate.eta()); + float phi = candidate.phi(); + o2::math_utils::bringTo02Pi(phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hPhiCandidate"), phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaPhiCandidate"), multiplicity, candidate.eta(), phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hYieldsCandidate"), multiplicity, candidate.pt(), candidate.eta()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hNtracksCandidate"), nTracks); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hPtCandidate"), candidate.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(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLengthXY"), candidate.decayLengthXY(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong0"), candidate.impactParameter0(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0Prong1"), candidate.impactParameter1(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hd0d0"), candidate.impactParameterProduct(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCTS"), hfHelper.cosThetaStarD0(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCt"), hfHelper.ctD0(candidate), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hCPA"), candidate.cpa(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hEtaCandVsPt"), candidate.eta(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hSelectionStatus"), candidate.isSelD0() + (candidate.isSelD0bar() * 2), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter0(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hImpParErr"), candidate.errorImpactParameter1(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenErr"), candidate.errorDecayLength(), candidate.pt()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/2Prong/hDecLenXYErr"), candidate.errorDecayLengthXY(), candidate.pt()); + } + } + + // ---- DATA : TPC-MFT 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 + template + void fillTpcMftLcCandidateQa(TTracks const& candidates, float multiplicity) + { + for (const auto& candidate : candidates) { + if (!isAcceptedCandidate(candidate)) { + continue; + } + + auto pt = candidate.pt(); + 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) { + 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) { + 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); + } + + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hYieldsCandidate"), multiplicity, candidate.pt(), candidate.eta()); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hEtaPhiCandidate"), multiplicity, candidate.eta(), phi); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hNtracksCandidate"), multiplicity); + registry.fill(HIST("Data/TpcMft/HfHadron/SameEvent/3Prong/hPt"), pt); + 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); + } + } + + // ========================= + // Correlation functions + // ========================= + + template void fillCorrelations(TTarget target, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, float multiplicity, float posZ) { auto triggerWeight = 1; @@ -365,26 +1138,51 @@ struct HfTaskFlow { // calculating inv. mass to be filled into the container below // Note: this is needed only in case of HF-hadron correlations + // TO DO ? Add one more if condition if its MC ? bool fillingHFcontainer = false; double invmass = 0; - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v || std::is_same_v) { // TODO: Check how to put this into a Filter if (!isAcceptedCandidate(track1)) { continue; } fillingHFcontainer = true; - invmass = hfHelper.invMassD0ToPiK(track1); + if constexpr (std::is_same_v) { // If D0 + invmass = hfHelper.invMassD0ToPiK(track1); + // Should add D0 bar ? + } else { // If Lc + invmass = hfHelper.invMassLcToPKPi(track1); + // Should add Lc bar ? (maybe not its the same mass right ?) + } + } + + // 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)) { + continue; + } + // TO-DO : add other if constexpr conditions when I will have more MC cases } // fill single-track distributions - if (!fillingHFcontainer) { - target->getTriggerHist()->Fill(CorrelationContainer::kCFStepReconstructed, pt1, multiplicity, posZ, triggerWeight); + if (!fillingHFcontainer) { // if not HF-h case + target->getTriggerHist()->Fill(step, pt1, multiplicity, posZ, triggerWeight); } else { - target->getTriggerHist()->Fill(CorrelationContainer::kCFStepReconstructed, pt1, multiplicity, posZ, invmass, triggerWeight); + target->getTriggerHist()->Fill(step, pt1, multiplicity, posZ, invmass, triggerWeight); } for (const auto& track2 : tracks2) { + // apply cuts for MFT tracks + if constexpr (std::is_same_v) { + if (!isAcceptedMftTrack(track2)) { + continue; + } + } + // case of h-h correlations where the two types of tracks are the same // this avoids autocorrelations and double counting of particle pairs if constexpr (std::is_same_v) { @@ -394,11 +1192,27 @@ struct HfTaskFlow { } // in case of HF-h correlations, remove candidate daughters from the pool of associated hadrons - // with which the candidate is being correlated - if constexpr (std::is_same_v) { - if ((track1.prong0Id() == track2.globalIndex()) || (track1.prong1Id() == track2.globalIndex())) { + // 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 ((track1.prong0Id() == track2.globalIndex()) || (track1.prong1Id() == track2.globalIndex())) { + continue; + } + } + if constexpr (std::is_same_v) { // Remove the 3 prong daughters + if ((track1.prong0Id() == track2.globalIndex()) || (track1.prong1Id() == track2.globalIndex()) || (track1.prong2Id() == track2.globalIndex())) { + continue; + } + } + } + + // 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)) { continue; } + // Note : no need for HF if condition as this will always be normal track, but maybe for MFT } float eta2 = track2.eta(); @@ -416,60 +1230,141 @@ struct HfTaskFlow { if (!fillingHFcontainer) { // fill pair correlations - target->getPairHist()->Fill(CorrelationContainer::kCFStepReconstructed, - eta1 - eta2, pt2, pt1, multiplicity, deltaPhi, posZ, + target->getPairHist()->Fill(step, eta1 - eta2, pt2, pt1, multiplicity, deltaPhi, posZ, triggerWeight * associatedWeight); } else { - - target->getPairHist()->Fill(CorrelationContainer::kCFStepReconstructed, - eta1 - eta2, pt2, pt1, multiplicity, deltaPhi, posZ, invmass, + target->getPairHist()->Fill(step, eta1 - eta2, pt2, pt1, multiplicity, deltaPhi, posZ, invmass, triggerWeight * associatedWeight); } } } } - template - void mixCollisions(FilteredCollisionsWSelMult const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) + // template + // void mixCollisions(FilteredCollisionsWSelMult const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) + template + void mixCollisions(TCollisions const& collisions, TTracksTrig const& tracks1, TTracksAssoc const& tracks2, TLambda getPartsSize, OutputObj& corrContainer) { - using BinningType = FlexibleBinningPolicy, aod::collision::PosZ, decltype(getPartsSize)>; - BinningType binningWithTracksSize{{getPartsSize}, {axisVertex, axisMultiplicity}, true}; + // 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}; auto tracksTuple = std::make_tuple(tracks1, tracks2); - Pair pair{binningWithTracksSize, nMixedEvents, -1, collisions, tracksTuple, &cache}; + Pair pair{binningWithTracksSize, nMixedEvents, -1, collisions, tracksTuple, &cache}; for (const auto& [collision1, tracks1, collision2, tracks2] : pair) { - if (!(isCollisionSelected(collision1, false))) { - continue; - } - if (!(isCollisionSelected(collision2, false))) { - continue; + if constexpr (!std::is_same_v) { // if NOT MC -> do collision cut + if (!(isCollisionSelected(collision1, false))) { + continue; + } + if (!(isCollisionSelected(collision2, false))) { + continue; + } } auto binningValues = binningWithTracksSize.getBinningValues(collision1, collisions); int bin = binningWithTracksSize.getBin(binningValues); - const auto multiplicity = tracks2.size(); // get multiplicity of charged hadrons, which is used for slicing in mixing + // 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) { - registry.fill(HIST("Data/HadronHf/MixedEvent/hEventCountHFMixing"), bin); - fillHFMixingQA(multiplicity, vz, tracks1); - } else { - registry.fill(HIST("Data/HadronHadron/MixedEvent/hEventCountMixing"), bin); - fillMixingQA(multiplicity, vz, tracks1); + 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 || 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 + 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 } - corrContainer->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCorrelations(corrContainer, tracks1, tracks2, multiplicity, collision1.posZ()); + corrContainer->fillEvent(multiplicityTracks2, CorrelationContainer::kCFStepReconstructed); + fillCorrelations(corrContainer, tracks1, tracks2, multiplicityTracks2, collision1.posZ()); + } + } + + // 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) + { + using BinningTypeMcTruth = FlexibleBinningPolicy, aod::mccollision::PosZ, decltype(getPartsSize)>; + + BinningTypeMcTruth binningWithTracksSize{{getPartsSize}, {axisVertex, axisMultiplicity}, true}; + auto tracksTuple = std::make_tuple(tracks1, tracks2); + Pair pair{binningWithTracksSize, nMixedEvents, -1, collisions, 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); + 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(); + + // 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()); } } // ===================================== - // process same event correlations: h-h case + // DATA : process same event correlations: TPC-TPC h-h case // ===================================== - void processSameTpcTpcHH(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks) + + void processSameTpcTpcChCh(FilteredCollisionsWSelMult::iterator const& collision, + TracksWDcaSel const& tracks) { if (!(isCollisionSelected(collision, true))) { return; @@ -481,63 +1376,229 @@ struct HfTaskFlow { // 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(); - registry.fill(HIST("Data/HadronHadron/SameEvent/hMultiplicity"), multiplicity); - registry.fill(HIST("Data/HadronHadron/SameEvent/hVtxZ"), collision.posZ()); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hVtxZ"), collision.posZ()); BinningPolicyBase<2> baseBinning{{axisVertex, axisMultiplicity}, true}; int bin = baseBinning.getBin(std::make_tuple(collision.posZ(), multiplicity)); - registry.fill(HIST("Data/HadronHadron/SameEvent/hEventCountSame"), bin); + registry.fill(HIST("Data/TpcTpc/HadronHadron/SameEvent/hEventCountSame"), bin); - sameTPCTPCCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameTPCTPCChCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillQA(multiplicity, tracks); - fillCorrelations(sameTPCTPCCh, tracks, tracks, multiplicity, collision.posZ()); + fillTpcTpcChChSameEventQa(multiplicity, tracks); + // TO-DO : add if condition for when we will implant corrected correlations (kCFStepReconstructed -> kCFStepCorrected) + fillCorrelations(sameTPCTPCChCh, tracks, tracks, multiplicity, collision.posZ()); } - PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcHH, "Process same-event correlations for h-h case", true); + PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChCh, "DATA : Process same-event correlations for TPC-TPC h-h case", false); // ===================================== - // process same event correlations: HF-h case + // DATA : process same event correlations: TPC-TPC HF-h case for D0 // ===================================== - void processSameHfHadrons(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks, - HfCandidatesSel const& candidates) + + void processSameTpcTpcD0Ch(FilteredCollisionsWSelMult::iterator const& collision, + TracksWDcaSel const& tracks, + HfCandidatesSelD0 const& candidates) { - if (!(isCollisionSelected(collision, true))) { + auto fillEventSelectionPlots = true; + + // When doing reference flow, two cases are used (HF-h, h-h) and thus eventSelectionPlots was filled twice + if (doReferenceFlow) + fillEventSelectionPlots = false; + + if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { return; } const auto multiplicity = tracks.size(); - sameHF->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + sameTPCTPCHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillCandidateQA(candidates); - fillCorrelations(sameHF, candidates, tracks, multiplicity, collision.posZ()); + fillTpcTpcD0CandidateQa(candidates); + fillCorrelations(sameTPCTPCHfCh, candidates, tracks, multiplicity, collision.posZ()); } - PROCESS_SWITCH(HfTaskFlow, processSameHfHadrons, "Process same-event correlations for HF-h case", true); + PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcD0Ch, "DATA : Process same-event correlations for TPC-TPC D0-h case", false); // ===================================== - // process same event correlations: h-MFT case + // DATA : process same event correlations: TPC-TPC HF-h case for Lc // ===================================== - void processSameTpcMftHH(FilteredCollisionsWSelMult::iterator const& collision, - TracksWDcaSel const& tracks, - aod::MFTTracks const& mfttracks) + + void processSameTpcTpcLcCh(FilteredCollisionsWSelMult::iterator const& collision, + TracksWDcaSel const& tracks, + HfCandidatesSelLc const& candidates) + { + auto fillEventSelectionPlots = true; + + // When doing reference flow, two cases are used (HF-h, h-h) and thus eventSelectionPlots was filled twice + if (doReferenceFlow) + fillEventSelectionPlots = false; + + if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + return; + } + const auto multiplicity = tracks.size(); + + sameTPCTPCHfCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); + + fillTpcTpcLcCandidateQa(candidates); + fillCorrelations(sameTPCTPCHfCh, candidates, tracks, multiplicity, collision.posZ()); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcLcCh, "DATA : Process same-event correlations for TPC-TPC Lc-h case", false); + + // ===================================== + // DATA : process same event correlations: TPC-MFT h-h case + // ===================================== + + void processSameTpcMftChCh(FilteredCollisionsWSelMult::iterator const& collision, + TracksWDcaSel const& tracks, + aod::MFTTracks const& mftTracks) { if (!(isCollisionSelected(collision, true))) { return; } - const auto multiplicity = tracks.size(); + const auto multiplicityTPC = tracks.size(); + const auto multiplicityMFT = mftTracks.size(); + + sameTPCMFTChCh->fillEvent(multiplicityTPC, CorrelationContainer::kCFStepReconstructed); + fillTpcMftChChSameEventQa(multiplicityTPC, tracks); + fillTpcMftChChSameEventQa(multiplicityMFT, mftTracks); + fillCorrelations(sameTPCMFTChCh, tracks, mftTracks, multiplicityTPC, collision.posZ()); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcMftChCh, "DATA : Process same-event correlations for TPC-MFT h-h case", false); + + // ===================================== + // DATA : process same event correlations: TPC-MFT HF-h case for D0 + // ===================================== + + void processSameTpcMftD0Ch(FilteredCollisionsWSelMult::iterator const& collision, + HfCandidatesSelD0 const& candidates, + aod::MFTTracks const& mftTracks) + { + auto fillEventSelectionPlots = true; + + // When doing reference flow, two cases are used (HF-h, h-h) and thus eventSelectionPlots was filled twice + if (doReferenceFlow) + fillEventSelectionPlots = false; + + if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + return; + } + + const auto multiplicityCandidates = candidates.size(); + const auto multiplicityMFT = mftTracks.size(); - sameTPCMFTCh->fillEvent(multiplicity, CorrelationContainer::kCFStepReconstructed); - fillMFTQA(multiplicity, mfttracks); - fillCorrelations(sameTPCMFTCh, tracks, mfttracks, multiplicity, collision.posZ()); + sameTPCMFTHfCh->fillEvent(multiplicityCandidates, CorrelationContainer::kCFStepReconstructed); + fillTpcMftD0CandidateQa(candidates, multiplicityCandidates); + fillTpcMftHfChSameEventQa(multiplicityMFT, mftTracks); + fillCorrelations(sameTPCMFTHfCh, candidates, mftTracks, multiplicityCandidates, collision.posZ()); } - PROCESS_SWITCH(HfTaskFlow, processSameTpcMftHH, "Process same-event correlations for h-MFT case", true); + PROCESS_SWITCH(HfTaskFlow, processSameTpcMftD0Ch, "DATA : Process same-event correlations for TPC-MFT D0-h case", false); // ===================================== - // process mixed event correlations: h-h case + // DATA : process same event correlations: TPC-MFT HF-h case for Lc // ===================================== - void processMixedTpcTpcHH(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks) + + void processSameTpcMftLcCh(FilteredCollisionsWSelMult::iterator const& collision, + HfCandidatesSelLc const& candidates, + aod::MFTTracks const& mftTracks) + { + auto fillEventSelectionPlots = true; + + // When doing reference flow, two cases are used (HF-h, h-h) and thus eventSelectionPlots was filled twice + if (doReferenceFlow) + fillEventSelectionPlots = false; + + if (!(isCollisionSelected(collision, fillEventSelectionPlots))) { + return; + } + + const auto multiplicityCandidates = candidates.size(); + const auto multiplicityMFT = mftTracks.size(); + + sameTPCMFTHfCh->fillEvent(multiplicityCandidates, CorrelationContainer::kCFStepReconstructed); + fillTpcMftLcCandidateQa(candidates, multiplicityCandidates); + fillTpcMftHfChSameEventQa(multiplicityMFT, mftTracks); + fillCorrelations(sameTPCMFTHfCh, candidates, mftTracks, multiplicityCandidates, collision.posZ()); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcMftLcCh, "DATA : Process same-event correlations for TPC-MFT Lc-h case", false); + + // ===================================== + // MONTE-CARLO : process same event correlations: TPC-TPC h-h case + // ===================================== + + void processSameTpcTpcChChmcREC(FilteredCollisionsWSelMultMC::iterator const& mcCollision, + TracksWDcaSelMC const& mcTracks) + { + + // NEED TO COMMENT THIS + // if (!(isCollisionSelected(mcCollision, true))) { + // return; + //} + + const auto multiplicity = mcTracks.size(); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); + registry.fill(HIST("MC/Rec/TpcTpc/HadronHadron/SameEvent/hVtxZ"), mcCollision.posZ()); + + 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); + + fillTpcTpcChChSameEventQaMc(multiplicity, mcTracks); + fillCorrelations(sameTPCTPCChChMC, mcTracks, mcTracks, multiplicity, mcCollision.posZ()); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChChmcREC, "MONTE-CARLO : Process same-event correlations for TPC-TPC h-h case", false); + + // Katarina's version = MC Truth + void processSameTpcTpcChChmcGEN(FilteredMcCollisions::iterator const& mcCollision, + FilteredMcParticles const& mcParticles) + { + + // if (!(isCollisionSelected(mcCollision, true))) { + // return; + // } + + // Not sure why to use this + // if (collisions.size() == 0) { + // return; + //} + + // if (!collision.has_mcCollision()) { + // LOGF(info, "No MC collision for this collision, skip..."); + // return; + // } + + const auto multiplicity = mcParticles.size(); // Note: these are all MC particles after selection (not only primary) + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hMultiplicity"), multiplicity); + registry.fill(HIST("MC/Gen/TpcTpc/HadronHadron/SameEvent/hVtxZ"), mcCollision.posZ()); + + // 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()); + + // 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()); + } + PROCESS_SWITCH(HfTaskFlow, processSameTpcTpcChChmcGEN, "MONTE-CARLO : Process same-event correlations for TPC-TPC h-h case", false); + + // ===================================== + // DATA : process mixed event correlations:TPC-TPC h-h case + // ===================================== + // TO BECOME DATA & MC REC ? + + void processMixedTpcTpcChCh(FilteredCollisionsWSelMult const& collisions, + TracksWDcaSel const& tracks) { // we want to group collisions based on charged-track multiplicity auto getTracksSize = [&tracks, this](FilteredCollisionsWSelMult::iterator const& col) { @@ -546,34 +1607,57 @@ struct HfTaskFlow { return size; }; - mixCollisions(collisions, tracks, tracks, getTracksSize, mixedTPCTPCCh); + mixCollisions(collisions, tracks, tracks, getTracksSize, mixedTPCTPCChCh); } - PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcHH, "Process mixed-event correlations for h-h case", true); + PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChCh, "DATA : Process mixed-event correlations for TPC-TPC h-h case", false); // ===================================== - // process mixed event correlations: h-HF case + // DATA : process mixed event correlations: TPC-TPC HF-h case for D0 // ===================================== - void processMixedHfHadrons(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks, - HfCandidatesSel const& candidates) + + void processMixedTpcTpcD0Ch(FilteredCollisionsWSelMult const& collisions, + TracksWDcaSel const& tracks, + HfCandidatesSelD0 const& candidates) { // 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 getTracksSize = [&candidates, this](FilteredCollisionsWSelMult::iterator const& col) { + // Still o2::aod::track::collisionId with HF ??? -> I don't think so + auto associatedTracks = candidates.sliceByCached(o2::aod::hf_cand::collisionId, col.globalIndex(), this->cache); + auto size = associatedTracks.size(); + return size; + }; + + mixCollisions(collisions, candidates, tracks, getTracksSize, mixedTPCTPCHfCh); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcD0Ch, "DATA : Process mixed-event correlations for TPC-TPC D0-h case", false); + + // ===================================== + // DATA : process mixed event correlations: TPC-TPC HF-h case for Lc + // ===================================== + + void processMixedTpcTpcLcCh(FilteredCollisionsWSelMult const& collisions, + TracksWDcaSel const& tracks, + HfCandidatesSelLc const& candidates) + { + // we want to group collisions based on charged-track multiplicity + auto getTracksSize = [&candidates, this](FilteredCollisionsWSelMult::iterator const& col) { + // Still o2::aod::track::collisionId with HF ??? -> I don't think so + auto associatedTracks = candidates.sliceByCached(o2::aod::hf_cand::collisionId, col.globalIndex(), this->cache); auto size = associatedTracks.size(); return size; }; - mixCollisions(collisions, candidates, tracks, getTracksSize, mixedHF); + mixCollisions(collisions, candidates, tracks, getTracksSize, mixedTPCTPCHfCh); } - PROCESS_SWITCH(HfTaskFlow, processMixedHfHadrons, "Process mixed-event correlations for HF-h case", true); + PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcLcCh, "DATA : Process mixed-event correlations for TPC-TPC Lc-h case", false); // ===================================== - // process mixed event correlations: h-MFT case + // DATA : process mixed event correlations: TPC-MFT h-h case // ===================================== - void processMixedTpcMftHH(FilteredCollisionsWSelMult const& collisions, - TracksWDcaSel const& tracks, - aod::MFTTracks const& mfttracks) + + void processMixedTpcMftChCh(FilteredCollisionsWSelMult const& collisions, + TracksWDcaSel const& tracks, + aod::MFTTracks const& mftTracks) { // we want to group collisions based on charged-track multiplicity auto getTracksSize = [&tracks, this](FilteredCollisionsWSelMult::iterator const& col) { @@ -582,9 +1666,90 @@ struct HfTaskFlow { return size; }; - mixCollisions(collisions, tracks, mfttracks, getTracksSize, mixedMFT); + mixCollisions(collisions, tracks, mftTracks, getTracksSize, mixedTPCMFTChCh); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftChCh, "DATA : Process mixed-event correlations for TPC-MFT h-h case", false); + + // ===================================== + // DATA : process mixed event correlations: TPC-MFT HF-h case for D0 + // ===================================== + + void processMixedTpcMftD0Ch(FilteredCollisionsWSelMult const& collisions, + HfCandidatesSelD0 const& candidates, + aod::MFTTracks const& mftTracks) + { + // we want to group collisions based on charged-track multiplicity + auto getTracksSize = [&candidates, this](FilteredCollisionsWSelMult::iterator const& col) { + // Still o2::aod::track::collisionId with HF ??? -> I don't think so + auto associatedTracks = candidates.sliceByCached(o2::aod::hf_cand::collisionId, col.globalIndex(), this->cache); + auto size = associatedTracks.size(); + return size; + }; + + mixCollisions(collisions, candidates, mftTracks, getTracksSize, mixedTPCMFTHfCh); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftD0Ch, "DATA : Process mixed-event correlations for TPC-MFT D0-h case", false); + + // ===================================== + // DATA : process mixed event correlations: TPC-MFT HF-h case + // ===================================== + + void processMixedTpcMftLcCh(FilteredCollisionsWSelMult const& collisions, + HfCandidatesSelLc const& candidates, + aod::MFTTracks const& mftTracks) + { + + // we want to group collisions based on charged-track multiplicity + auto getTracksSize = [&candidates, this](FilteredCollisionsWSelMult::iterator const& col) { + // Still o2::aod::track::collisionId with HF ??? -> I don't think so + auto associatedTracks = candidates.sliceByCached(o2::aod::hf_cand::collisionId, col.globalIndex(), this->cache); + auto size = associatedTracks.size(); + return size; + }; + + mixCollisions(collisions, candidates, mftTracks, getTracksSize, mixedTPCMFTHfCh); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftLcCh, "DATA : Process mixed-event correlations for TPC-MFT Lc-h case", false); + + // ===================================== + // MONTE-CARLO : process mixed event correlations: TPC-TPC h-h case + // ===================================== + + // MC rec + void processMixedTpcTpcChChmcREC(FilteredCollisionsWSelMultMC const& mcCollisions, + TracksWDcaSelMC const& mcTracks) + { + // 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; + }; + + mixCollisions(mcCollisions, mcTracks, mcTracks, getTracksSize, mixedTPCTPCChChMC); + } + PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChChmcREC, "MONTE-CARLO : Process mixed-event correlations for TPC-TPC h-h case", false); + + // MC gen + void processMixedTpcTpcChChmcGEN(FilteredMcCollisions const& mcCollisions, + FilteredMcParticles const& mcParticles) + { + // use normal index instead of globalIndex for MixedEvent ?? + + // 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; + }; + + mixCollisionsMcTruth(mcCollisions, mcParticles, mcParticles, getTracksSize, mixedTPCTPCChChMC); + + // TO-DO : mixed event for particles that have a reconstructed collision kCFStepVertex } - PROCESS_SWITCH(HfTaskFlow, processMixedTpcMftHH, "Process mixed-event correlations for h-MFT case", true); + PROCESS_SWITCH(HfTaskFlow, processMixedTpcTpcChChmcGEN, "MONTE-CARLO : Process mixed-event correlations for TPC-TPC h-h case", false); }; // End of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/HFC/Utils/utilsCorrelations.h b/PWGHF/HFC/Utils/utilsCorrelations.h new file mode 100644 index 00000000000..65f447a2b90 --- /dev/null +++ b/PWGHF/HFC/Utils/utilsCorrelations.h @@ -0,0 +1,86 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 utilsCorrelations.h +/// \brief Utilities for HFC analyses +/// \author Xu Wang + +#ifndef PWGHF_HFC_UTILS_UTILSCORRELATIONS_H_ +#define PWGHF_HFC_UTILS_UTILSCORRELATIONS_H_ + +#include +#include + +#include "CommonConstants/PhysicsConstants.h" + +namespace o2::analysis::hf_correlations +{ +enum Region { + Default = 0, + Toward, + Away, + Transverse +}; + +template +Region getRegion(T const deltaPhi) +{ + if (std::abs(deltaPhi) < o2::constants::math::PIThird) { + return Toward; + } else if (deltaPhi > 2. * o2::constants::math::PIThird && deltaPhi < 4. * o2::constants::math::PIThird) { + return Away; + } else { + return Transverse; + } +} + +// ========= Find Leading Particle ============== +template +int findLeadingParticle(TTracks const& tracks, T1 const dcaXYTrackMax, T2 const dcaZTrackMax, T3 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; + } + if (track.pt() > leadingParticle.pt()) { + leadingParticle = track; + } + } + return leadingParticle.globalIndex(); +} + +// ======= Find Leading Particle for McGen ============ +template +int findLeadingParticleMcGen(TMcParticles const& mcParticles, T1 const etaTrackMax, T2 const ptTrackMin) +{ + auto leadingParticle = mcParticles.begin(); + for (auto const& mcParticle : mcParticles) { + if (std::abs(mcParticle.eta()) > etaTrackMax) { + continue; + } + if (mcParticle.pt() < ptTrackMin) { + continue; + } + 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)) { + continue; + } + if (mcParticle.pt() > leadingParticle.pt()) { + leadingParticle = mcParticle; + } + } + return leadingParticle.globalIndex(); +} +} // namespace o2::analysis::hf_correlations +#endif // PWGHF_HFC_UTILS_UTILSCORRELATIONS_H_ diff --git a/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx b/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx index 3823a9e9859..cd583c3a83f 100644 --- a/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx +++ b/PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx @@ -40,11 +40,39 @@ 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.; struct HfElectronSelectionWithTpcEmcal { Produces electronSel; // Configurables // EMCal Cluster information + Configurable fillEmcClusterInfo{"fillEmcClusterInfo", true, "Fill histograms with EMCal cluster info before and after track match"}; // Event Selection @@ -69,8 +97,10 @@ struct HfElectronSelectionWithTpcEmcal { Configurable phiTrackEMCalMin{"phiTrackEMCalMin", 4.5355f, "phi range for electron tracks associated Emcal"}; // Track and EMCal Cluster matching cut - Configurable deltaEtaMatchMin{"deltaEtaMatchMin", 0.015f, "Eta distance of EMCAL cluster to its closest track"}; - Configurable deltaPhiMatchMin{"deltaPhiMatchMin", 0.025f, "Phi distance of EMCAL cluster to its closest track"}; + Configurable deltaEtaMatchMin{"deltaEtaMatchMin", -0.013f, "Min Eta distance of EMCAL cluster to its closest track"}; + Configurable deltaEtaMatchMax{"deltaEtaMatchMax", 0.0171f, "Max Eta distance of EMCAL cluster to its closest track"}; + Configurable deltaPhiMatchMin{"deltaPhiMatchMin", -0.022f, "Min Phi distance of EMCAL cluster to its closest track"}; + Configurable deltaPhiMatchMax{"deltaPhiMatchMax", 0.028f, "Max Phi distance of EMCAL cluster to its closest track"}; Configurable timeEmcClusterMax{"timeEmcClusterMax", 50.f, "EMCal Cluster time"}; // Inclusive electron selection cut @@ -84,8 +114,11 @@ struct HfElectronSelectionWithTpcEmcal { Configurable tpcNsigmaElectronMax{"tpcNsigmaElectronMax", 3.0f, "max Electron TPCnsigma"}; // Track and EMCal Cluster matching cut for Mc Reco - Configurable mcRecDeltaEtaMatchMin{"mcRecDeltaEtaMatchMin", 0.015f, "McReco Eta distance of EMCAL cluster to its closest track"}; - Configurable mcRecDeltaPhiMatchMin{"mcRecDeltaPhiMatchMin", 0.025f, "McReco Phi distance of EMCAL cluster to its closest track"}; + 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 @@ -108,34 +141,55 @@ struct HfElectronSelectionWithTpcEmcal { Filter CollisionFilter = nabs(aod::collision::posZ) < zPvPosMax && aod::collision::numContrib > (uint16_t)1; PresliceUnsorted perClusterMatchedTracks = o2::aod::emcalmatchedtrack::trackId; - HistogramConfigSpec hEmcClusterInfoSpec{HistType::kTHnSparseD, {{300, 0.0, 30.0}, {100, -0.9, 0.9}, {200, 0, 6.3}, {50, 0, 50}, {1800, -900, 900}}}; - HistogramConfigSpec hDeltaPhiDeltaEtaEmcClusterTrackSpecEnergy{HistType::kTHnSparseD, {{400, -0.2, 0.2}, {400, -0.2, 0.2}, {600, -300, 300}, {300, 0.0, 30.0}}}; - HistogramConfigSpec hPIDSpec{HistType::kTHnSparseD, {{60, 0, 3}, {500, 0.0, 50.0}, {500, 0., 50.}, {300, -15, 15}, {300, 0.0, 30.0}, {400, 0, 2}, {400, 0, 2}}}; - HistogramConfigSpec hTrackAllInfoSpec{HistType::kTHnSparseD, {{480, 0, 160}, {300, -15, 15}, {500, 0., 50.}, {500, 0., 50.}, {100, -1.5, 1.5}, {100, 0, 7}, {3, 0, 3}}}; - HistogramConfigSpec hTrackInfoSpec{HistType::kTHnSparseD, {{60, 0, 3}, {480, 0, 160}, {300, -15, 15}, {500, 0., 50.}, {500, 0., 50.}, {100, -1.5, 1.5}, {100, 0, 7}}}; + 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}}}; HistogramRegistry registry{ "registry", {{"hNevents", "No of events", {HistType::kTH1F, {{3, 1, 4}}}}, {"hZvertex", "z vertex", {HistType::kTH1F, {{100, -100, 100}}}}, - {"hTrackInformation", "Sparse TPC info; dE/dx;n#sigma;#it{p} (GeV#it{/c});#it{p}_{T} (GeV#it{/c});#eta;#varphi;passEMcal;", hTrackAllInfoSpec}, - {"hEmcClusterInformationBefore", "EMCal Cluster Info before match; Energy (GeV);#eta;#varphi", hEmcClusterInfoSpec}, - {"hEmcClusterInformationAfter", "EMCal Cluster Info after match; Energy (GeV);#eta;#varphi", hEmcClusterInfoSpec}, - {"hPIDafterMatch", "PID Info after match; E/P; dE/dx;n#sigma;#it{p} (GeV#it{/c});#it{p}_{T} (GeV#it{/c});#eta;#varphi;", hTrackInfoSpec}, - {"hEPRatioafterPID", "E/P Ratio after PID Cuts apply only trackwodca filter", {HistType::kTH2F, {{60, 0, 3}, {100, 0, 10}}}}, - {"hPIDafterPIDcuts", "PID Info after PID cuts; E/P; #it{p} (GeV#it{/c});#it{p}_{T} (GeV#it{/c});n_{#sigma}^{e};GeV;M02;M20", hPIDSpec}, - {"hEmcClsTrkEtaPhiDiffTimeEnergy", "EmcClsTrkEtaPhiDiffTimeEnergy;#Delta#eta;#Delta#varphi;Sec; Energy (GeV)", hDeltaPhiDeltaEtaEmcClusterTrackSpecEnergy}}}; - - void init(InitContext&) + {"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("hTrackInformation"))->Sumw2(); - registry.get(HIST("hEmcClusterInformationBefore"))->Sumw2(); - registry.get(HIST("hEmcClusterInformationAfter"))->Sumw2(); - registry.get(HIST("hPIDafterMatch"))->Sumw2(); - registry.get(HIST("hPIDafterPIDcuts"))->Sumw2(); - registry.get(HIST("hEmcClsTrkEtaPhiDiffTimeEnergy"))->Sumw2(); + registry.get(HIST("hAfterMatchSigmaVsEoP"))->Sumw2(); + registry.get(HIST("hPIDAfterPIDCuts"))->Sumw2(); } - // Track Selection Cut template bool selTracks(T const& track) @@ -173,7 +227,12 @@ struct HfElectronSelectionWithTpcEmcal { /////////////////////////////// if (fillEmcClusterInfo) { for (const auto& emcClusterBefore : emcClusters) { - registry.fill(HIST("hEmcClusterInformationBefore"), emcClusterBefore.energy(), emcClusterBefore.eta(), emcClusterBefore.phi(), emcClusterBefore.nCells(), emcClusterBefore.time()); + registry.fill(HIST("hEmcClusterEnergy"), emcClusterBefore.energy()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterEtaPhi"), emcClusterBefore.eta(), emcClusterBefore.phi()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterEnergyCell"), emcClusterBefore.energy(), emcClusterBefore.nCells()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterEnergyTime"), emcClusterBefore.energy(), emcClusterBefore.time()); // track etaphi infor after filter bit + registry.fill(HIST("hEmcClusterM02"), emcClusterBefore.m02()); + registry.fill(HIST("hEmcClusterM20"), emcClusterBefore.m20()); } } int passEMCal; @@ -184,9 +243,8 @@ 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(); pTrack = track.p(); @@ -194,7 +252,7 @@ struct HfElectronSelectionWithTpcEmcal { dcaxyTrack = track.dcaXY(); dcazTrack = track.dcaZ(); tpcNsigmaTrack = track.tpcNSigmaEl(); - + electronId = track.globalIndex(); // Apply Track Selection if (!selTracks(track)) { continue; @@ -206,7 +264,11 @@ struct HfElectronSelectionWithTpcEmcal { if ((phiTrack > phiTrackDCalMin && phiTrack < phiTrackDCalMax) && ((etaTrack > etaTrackDCalPositiveMin && etaTrack < etaTrackDCalPositiveMax) || (etaTrack > etaTrackDCalNegativeMin && etaTrack < etaTrackDCalNegativeMax))) passEMCal = 2; // Dcal acceptance passed - registry.fill(HIST("hTrackInformation"), track.tpcSignal(), tpcNsigmaTrack, pTrack, ptTrack, etaTrack, phiTrack, passEMCal); // track infor after filter bit + 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; @@ -256,24 +318,34 @@ struct HfElectronSelectionWithTpcEmcal { if (std::abs(timeEmcCluster) > timeEmcClusterMax) { continue; } - if (std::abs(deltaPhiMatch) > deltaPhiMatchMin || std::abs(deltaEtaMatch) > deltaEtaMatchMin) { + if (deltaPhiMatch < deltaPhiMatchMin || deltaPhiMatch > deltaPhiMatchMax || deltaEtaMatch < deltaEtaMatchMin || deltaEtaMatch > deltaEtaMatchMax) { continue; } } else { if (std::abs(timeEmcCluster) > mcRecTimeEmcClusterMax) { continue; } - if (std::abs(deltaPhiMatch) > mcRecDeltaPhiMatchMin || std::abs(deltaEtaMatch) > mcRecDeltaEtaMatchMin) { + if (deltaPhiMatch < mcRecDeltaPhiMatchMin || deltaPhiMatch > mcRecDeltaPhiMatchMax || deltaEtaMatch < mcRecDeltaEtaMatchMin || deltaEtaMatch > mcRecDeltaEtaMatchMax) { continue; } } - registry.fill(HIST("hEmcClsTrkEtaPhiDiffTimeEnergy"), deltaEtaMatch, deltaPhiMatch, timeEmcCluster, eMatchEmcCluster); + registry.fill(HIST("hEmcClsTrkEtaPhiDiffTimeEnergy"), deltaEtaMatch, deltaPhiMatch, timeEmcCluster); if (fillEmcClusterInfo) - registry.fill(HIST("hEmcClusterInformationAfter"), eMatchEmcCluster, etaMatchEmcCluster, phiMatchEmcCluster, cellEmcCluster, timeEmcCluster); + 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; - registry.fill(HIST("hPIDafterMatch"), eop, matchTrack.tpcSignal(), tpcNsigmaMatchTrack, pMatchTrack, ptMatchTrack, etaMatchTrack, phiMatchTrack); + + registry.fill(HIST("hAfterMatchSigmaVsEoP"), eop, ptMatchTrack, tpcNsigmaMatchTrack, m02MatchEmcCluster, m20MatchEmcCluster); + registry.fill(HIST("hAfterMatchEoPVsP"), eop, pMatchTrack); + registry.fill(HIST("hAfterMatchSigmaVsP"), tpcNsigmaMatchTrack, pMatchTrack); + 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) { @@ -286,14 +358,16 @@ struct HfElectronSelectionWithTpcEmcal { } } - registry.fill(HIST("hEPRatioafterPID"), eop, ptMatchTrack); + registry.fill(HIST("hPIDAfterPIDCuts"), eop, ptMatchTrack, tpcNsigmaMatchTrack, m02MatchEmcCluster, m20MatchEmcCluster); + registry.fill(HIST("hEPRatioAfterPID"), pMatchTrack, eMatchEmcCluster); + registry.fill(HIST("hAfterPIDEtaPhi"), etaMatchTrack, phiMatchTrack); if (eop < eopElectronMin || eop > eopElectronMax) { continue; } - registry.fill(HIST("hPIDafterPIDcuts"), eop, pMatchTrack, ptMatchTrack, tpcNsigmaMatchTrack, eMatchEmcCluster, m02MatchEmcCluster, m20MatchEmcCluster); isEMcal = true; - electronSel(matchTrack.collisionId(), matchTrack.globalIndex(), etaMatchTrack, phiMatchTrack, ptMatchTrack, pMatchTrack, trackRapidity, matchTrack.dcaXY(), matchTrack.dcaZ(), matchTrack.tpcNSigmaEl(), matchTrack.tofNSigmaEl(), + 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(), eMatchEmcCluster, etaMatchEmcCluster, phiMatchEmcCluster, m02MatchEmcCluster, m20MatchEmcCluster, cellEmcCluster, timeEmcCluster, deltaEtaMatch, deltaPhiMatch, isEMcal); } @@ -301,7 +375,7 @@ struct HfElectronSelectionWithTpcEmcal { if (isEMcal) { continue; } - electronSel(track.collisionId(), track.globalIndex(), etaTrack, phiTrack, ptTrack, pTrack, trackRapidity, dcaxyTrack, dcazTrack, track.tpcNSigmaEl(), track.tofNSigmaEl(), + electronSel(track.collisionId(), electronId, etaTrack, phiTrack, ptTrack, pTrack, trackRapidity, dcaxyTrack, dcazTrack, track.tpcNSigmaEl(), track.tofNSigmaEl(), eMatchEmcCluster, etaMatchEmcCluster, phiMatchEmcCluster, m02MatchEmcCluster, m20MatchEmcCluster, cellEmcCluster, timeEmcCluster, deltaEtaMatch, deltaPhiMatch, isEMcal); } } diff --git a/PWGHF/HFL/Tasks/CMakeLists.txt b/PWGHF/HFL/Tasks/CMakeLists.txt index 453a1b6b4eb..8a6c9ab4285 100644 --- a/PWGHF/HFL/Tasks/CMakeLists.txt +++ b/PWGHF/HFL/Tasks/CMakeLists.txt @@ -9,6 +9,11 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. +o2physics_add_dpl_workflow(task-electron-weak-boson + SOURCES taskElectronWeakBoson.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-muon-charm-beauty-separation SOURCES taskMuonCharmBeautySeparation.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -24,6 +29,11 @@ o2physics_add_dpl_workflow(task-single-muon-reader PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(task-single-muon-reader-assoc + SOURCES taskSingleMuonReaderAssoc.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGDQCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(task-single-muon-source SOURCES taskSingleMuonSource.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx b/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx new file mode 100644 index 00000000000..e86fe36813f --- /dev/null +++ b/PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx @@ -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 taskElectronWeakBoson.cxx +/// \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" + +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" + +#include "DataFormatsEMCAL/Cell.h" +#include "DataFormatsEMCAL/Constants.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/DataModel/PIDResponse.h" + +#include "PWGJE/DataModel/EMCALClusters.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct HfTaskElectronWeakBoson { + + // configurable parameters + Configurable nBinsPt{"nBinsPt", 100, "N bins in pt registry"}; + Configurable BinPtmax{"BinPtmax", 100.0, "maximum pt registry"}; + Configurable nBinsE{"nBinsE", 100, "N bins in E registry"}; + Configurable BinEmax{"BinEmax", 100.0, "maximum E registry"}; + + Configurable vtxZ{"vtxZ", 10.f, ""}; + + Configurable etaTrLow{"etaTrLow", -0.6f, "minimun track eta"}; + Configurable etaTrUp{"etaTrUp", 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 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 nsigTpcMin{"nsigTpcMin", -1.0, "tpc Nsig lower cut"}; + Configurable nsigTpcMax{"nsigTpcMax", 3.0, "tpc Nsig upper cut"}; + + Configurable phiEmcMin{"phiEmcMin", 1.39, "EMC phi acc min"}; + Configurable phiEmcMax{"phiEmcMax", 3.36, "EMC phi acc max"}; + Configurable clusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default"}; + Configurable timeEmcMin{"timeEmcMin", -25., "Minimum EMCcluster timing"}; + Configurable timeEmcMax{"timeEmcMax", +20., "Maximum EMCcluster timing"}; + Configurable m02Min{"m02Min", 0.1, "Minimum M02"}; + Configurable m02Max{"m02Max", 0.9, "Maximum M02"}; + Configurable rMatchMax{"rMatchMax", 0.1, "cluster - track matching cut"}; + + using SelectedClusters = o2::aod::EMCALClusters; + // PbPb + using TrackEle = o2::soa::Join; + + // pp + // using TrackEle = o2::soa::Filtered>; + + // Filter + 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 dcaxyfilter = (nabs(aod::track::dcaXY) < dcaxyMax); + Filter filter_globalTr = requireGlobalTrackInFilter(); + + Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == clusterDefinition) && (o2::aod::emcalcluster::time >= timeEmcMin) && (o2::aod::emcalcluster::time <= timeEmcMax) && (o2::aod::emcalcluster::m02 > m02Min) && (o2::aod::emcalcluster::m02 < m02Max); + + // Data Handling Objects + Preslice perCluster = o2::aod::emcalclustercell::emcalclusterId; + Preslice perClusterAmb = o2::aod::emcalclustercell::emcalambiguousclusterId; + PresliceUnsorted perClusterMatchedTracks = o2::aod::emcalmatchedtrack::trackId; + + // Histogram registry: an object to hold your registrygrams + HistogramRegistry registry{"registry"}; + + void init(InitContext const&) + { + + // define axes you want to use + const AxisSpec axisZvtx{400, -20, 20, "Zvtx"}; + const AxisSpec axisCounter{1, 0, 1, "events"}; + const AxisSpec axisEta{200, -1.0, 1.0, "#eta"}; + const AxisSpec axisPt{nBinsPt, 0, BinPtmax, "p_{T}"}; + const AxisSpec axisNsigma{100, -5, 5, "N#sigma"}; + 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 axisPhi{350, 0, 7, "Phi"}; + const AxisSpec axisEop{200, 0, 2, "Eop"}; + const AxisSpec axisChi2{500, 0.0, 50.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"}; + + // create registrygrams + registry.add("hZvtx", "Z vertex", kTH1F, {axisZvtx}); + registry.add("hEventCounter", "hEventCounter", kTH1F, {axisCounter}); + registry.add("hITSchi2", "ITS #chi^{2}", kTH1F, {axisChi2}); + registry.add("hTPCchi2", "TPC #chi^{2}", kTH1F, {axisChi2}); + registry.add("hTPCnCls", "TPC NCls", kTH1F, {axisCluster}); + registry.add("hITSnCls", "ITS NCls", kTH1F, {axisITSNCls}); + registry.add("hTPCnClsCrossedRows", "TPC NClsCrossedRows", kTH1F, {axisCluster}); + registry.add("hEta", "track eta", kTH1F, {axisEta}); + 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("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("hEopNsigTPC", "Eop vs. Nsigma", kTH2F, {{axisNsigma}, {axisEop}}); + registry.add("hEMCtime", "EMC timing", kTH1F, {axisEMCtime}); + } + + void process(soa::Filtered::iterator const& collision, + SelectedClusters const&, + TrackEle const& tracks, + o2::aod::EMCALMatchedTracks const& matchedtracks) + { + registry.fill(HIST("hEventCounter"), 0.5); + + // LOGF(info, "Collision index : %d", collision.index()); + // LOGF(info, "Number of tracks: %d", tracks.size()); + // LOGF(info, "Number of clusters: %d", clusters.size()); + + registry.fill(HIST("hZvtx"), collision.posZ()); + + for (const auto& track : tracks) { + + 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; + if (track.pt() < ptMin) + continue; + + registry.fill(HIST("hEta"), track.eta()); + registry.fill(HIST("hITSchi2"), track.itsChi2NCl()); + registry.fill(HIST("hTPCchi2"), track.tpcChi2NCl()); + registry.fill(HIST("hTPCnCls"), track.tpcNClsFound()); + registry.fill(HIST("hITSnCls"), track.itsNCls()); + registry.fill(HIST("hTPCnClsCrossedRows"), track.tpcNClsCrossedRows()); + registry.fill(HIST("hPt"), track.pt()); + registry.fill(HIST("hTPCNsigma"), track.p(), track.tpcNSigmaEl()); + + // track - match + + // continue; + if (track.phi() < phiEmcMin || track.phi() > phiEmcMax) + continue; + auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, track.globalIndex()); + + // LOGF(info, "Number of matched track: %d", tracksofcluster.size()); + + double rMin = 999.9; + double dPhiMin = 999.9; + double dEtaMin = 999.9; + + 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(); + double etaEmc = match.emcalcluster_as().eta(); + double timeEmc = match.emcalcluster_as().time(); + // 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; + dPhi = RecoDecay::constrainAngle(dPhi, -o2::constants::math::PI); + + registry.fill(HIST("hMatchPhi"), phiEmc, match.track_as().phi()); + registry.fill(HIST("hMatchEta"), etaEmc, match.track_as().eta()); + + double r = RecoDecay::sqrtSumOfSquares(dPhi, dEta); + if (r < rMin) { + rMin = r; + dPhiMin = dPhi; + dEtaMin = dEta; + } + registry.fill(HIST("hTrMatch"), dPhi, dEta); + registry.fill(HIST("hEMCtime"), timeEmc); + registry.fill(HIST("hEnergy"), energyEmc); + + if (r < rMatchMax) + continue; + + double eop = energyEmc / match.track_as().p(); + // 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.track_as().tpcNSigmaEl() > nsigTpcMin && match.track_as().tpcNSigmaEl() < nsigTpcMax) { + registry.fill(HIST("hEop"), match.track_as().pt(), eop); + } + } + + nMatch++; + } + } + + if (rMin < rMatchMax) { + // LOG(info) << "R mim = " << rMin; + registry.fill(HIST("hTrMatch_mim"), dPhiMin, dEtaMin); + } + + } // end of track loop + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/HFL/Tasks/taskSingleMuon.cxx b/PWGHF/HFL/Tasks/taskSingleMuon.cxx index fc70cfecc35..73445124ae9 100644 --- a/PWGHF/HFL/Tasks/taskSingleMuon.cxx +++ b/PWGHF/HFL/Tasks/taskSingleMuon.cxx @@ -56,8 +56,8 @@ struct HfTaskSingleMuonSelectionAmbiguousMftIndexBuilder { }; struct HfTaskSingleMuon { - Configurable trkType{"trkType", 0, "Muon track type, valid values are 0, 1, 2, 3 and 4"}; - Configurable mcMaskSelection{"mcMaskSelection", 0, "McMask for correct match, valid values are 0 and 128"}; + Configurable trkType{"trkType", 0u, "Muon track type, valid values are 0, 1, 2, 3 and 4"}; + Configurable mcMaskSelection{"mcMaskSelection", 0u, "McMask for correct match, valid values are 0 and 128"}; Configurable etaMin{"etaMin", -3.6, "eta minimum value"}; Configurable etaMax{"etaMax", -2.5, "eta maximum value"}; Configurable pDcaMin{"pDcaMin", 324., "p*DCA maximum value for small Rabs"}; diff --git a/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx b/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx new file mode 100644 index 00000000000..03fa6efb5a5 --- /dev/null +++ b/PWGHF/HFL/Tasks/taskSingleMuonReaderAssoc.cxx @@ -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. + +/// \file taskSingleMuonReaderAssoc.cxx +/// \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 "Common/Core/RecoDecay.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "PWGDQ/DataModel/ReducedInfoTables.h" + +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using MyCollisions = soa::Join; +using MyMuons = soa::Join; +using MyMcMuons = soa::Join; + +namespace o2::aod +{ +namespace single_muon +{ +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); +DECLARE_SOA_COLUMN(DeltaPt, deltaPt, float); +DECLARE_SOA_COLUMN(Chi2, chi2, float); +} // namespace single_muon +DECLARE_SOA_TABLE(HfSingleMuon, "AOD", "SINGLEMUON", single_muon::Pt, single_muon::DcaXY, single_muon::DeltaPt, single_muon::Chi2); +} // namespace o2::aod + +struct HfTaskSingleMuonReaderAssoc { + Produces singleMuon; + + Configurable trkType{"trkType", 0, "Muon track type, valid values are 0, 1, 2, 3 and 4"}; + Configurable etaMin{"etaMin", -3.6, "eta minimum value"}; + Configurable etaMax{"etaMax", -2.5, "eta maximum value"}; + Configurable pDcaMax{"pDcaMax", 594., "p*DCA maximum value"}; + Configurable rAbsMax{"rAbsMax", 89.5, "R at absorber end maximum value"}; + Configurable rAbsMin{"rAbsMin", 26.5, "R at absorber end minimum value"}; + Configurable fillMcHist{"fillMcHist", false, "fill MC-related histograms"}; + + HistogramRegistry registry{"registry"}; + + void init(InitContext&) + { + AxisSpec axisPt{200, 0., 100., "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisEta{100, -4., -2., "#it{#eta}"}; + AxisSpec axisDCA{2000, 0., 2., "#it{DCA}_{xy} (cm)"}; + AxisSpec axisChi2MatchMCHMFT{100, 0., 100., "MCH-MFT matching #chi^{2}"}; + AxisSpec axisSign{5, -2.5, 2.5, "Charge"}; + AxisSpec axisRabs{1000, 0, 100, "R at Absorber End (cm)"}; + AxisSpec axisDeltaPt{10000, -50, 50, "#Delta #it{p}_{T} (GeV/#it{c})"}; + AxisSpec axisVtxZ{80, -20., 20., "#it{z}_{vtx} (cm)"}; + + HistogramConfigSpec hTHnMu{HistType::kTHnSparseF, {axisPt, axisEta, axisDCA, axisRabs, axisSign, axisChi2MatchMCHMFT, axisDeltaPt}, 7}; + HistogramConfigSpec hVtxZ{HistType::kTH1F, {axisVtxZ}}; + + registry.add("hMuAfterCuts", "", hTHnMu); + if (fillMcHist) { + registry.add("hMuAfterCutsTrue", "", hTHnMu); + registry.add("hMuAfterCutsFake", "", hTHnMu); + } + registry.add("hVtxZ", "", hVtxZ); + } + + template + void runMuonSelAssoc(ReducedMuonsAssoc const& assocs, TCollisions const& collisions, TMuons const&) + { + for (const auto& collision : collisions) { + registry.fill(HIST("hVtxZ"), collision.posZ()); + } + for (const auto& assoc : assocs) { + auto muon = assoc.template reducedmuon_as(); + if (muon.trackType() != trkType) { + continue; + } + + const auto eta(muon.eta()), pDca(muon.pDca()); + const auto rAbs(muon.rAtAbsorberEnd()); + const auto dcaXY(RecoDecay::sqrtSumOfSquares(muon.fwdDcaX(), muon.fwdDcaY())); + const auto pt(muon.pt()); + const auto charge(muon.sign()); + const auto chi2(muon.chi2MatchMCHMFT()); + + if ((eta >= etaMax) || (eta < etaMin)) { + continue; + } + if ((rAbs >= rAbsMax) || (rAbs < rAbsMin)) { + continue; + } + if (pDca >= pDcaMax) { + continue; + } + + // histograms after acceptance cuts + if (muon.has_matchMCHTrack()) { + auto muonType3 = muon.template matchMCHTrack_as(); + auto Dpt = muonType3.pt() - pt; + + singleMuon(pt, dcaXY, Dpt, chi2); + registry.fill(HIST("hMuAfterCuts"), pt, eta, dcaXY, rAbs, charge, chi2, Dpt); + } + } + } + + template + void runMuonSelMcAssoc(ReducedMuonsAssoc const& assocs, TCollisions const& collisions, TMuons const&) + { + for (const auto& collision : collisions) { + registry.fill(HIST("hVtxZ"), collision.posZ()); + } + for (const auto& assoc : assocs) { + auto muon = assoc.template reducedmuon_as(); + if (muon.trackType() != trkType) { + continue; + } + + const auto eta(muon.eta()), pDca(muon.pDca()); + const auto rAbs(muon.rAtAbsorberEnd()); + const auto dcaXY(RecoDecay::sqrtSumOfSquares(muon.fwdDcaX(), muon.fwdDcaY())); + const auto pt(muon.pt()); + const auto charge(muon.sign()); + const auto chi2(muon.chi2MatchMCHMFT()); + + if ((eta >= etaMax) || (eta < etaMin)) { + continue; + } + if ((rAbs >= rAbsMax) || (rAbs < rAbsMin)) { + continue; + } + if (pDca >= pDcaMax) { + continue; + } + + // histograms after acceptance cuts + if (muon.has_matchMCHTrack()) { + auto muonType3 = muon.template matchMCHTrack_as(); + auto Dpt = muonType3.pt() - pt; + + singleMuon(pt, dcaXY, Dpt, chi2); + registry.fill(HIST("hMuAfterCuts"), pt, eta, dcaXY, rAbs, charge, chi2, Dpt); + if (muon.mcMask() == 0) { + registry.fill(HIST("hMuAfterCutsTrue"), pt, eta, dcaXY, rAbs, charge, chi2, Dpt); + } + if (muon.mcMask() == 128) { + registry.fill(HIST("hMuAfterCutsFake"), pt, eta, dcaXY, rAbs, charge, chi2, Dpt); + } + } + } + } + + void processMuon(ReducedMuonsAssoc const& assocs, MyCollisions const& collisions, MyMuons const& muons) + { + runMuonSelAssoc(assocs, collisions, muons); + } + PROCESS_SWITCH(HfTaskSingleMuonReaderAssoc, processMuon, "run muon selection with real data", true); + + void processMuonMc(ReducedMuonsAssoc const& assocs, MyCollisions const& collisions, MyMcMuons const& muons) + { + runMuonSelMcAssoc(assocs, collisions, muons); + } + PROCESS_SWITCH(HfTaskSingleMuonReaderAssoc, processMuonMc, "run muon selection with MC data", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/Macros/computeFonllPlusPythiaPredictions.C b/PWGHF/Macros/computeFonllPlusPythiaPredictions.C new file mode 100644 index 00000000000..bdd8f1ca7e2 --- /dev/null +++ b/PWGHF/Macros/computeFonllPlusPythiaPredictions.C @@ -0,0 +1,364 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +/// \brief macro for the calculation of FONLL+PYTHIA predictions for non-prompt charm hadrons +/// +/// \author Fabrizio Grosa , CERN + +#if !defined(__CINT__) || defined(__CLING__) + +#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 "Pythia8/Pythia.h" + +#endif + +enum Bhadrons { + Bplus = 0, + Bzero, + Bs, + Lb, + NBeautyHadrons +}; + +enum Chadrons { + Dplus = 0, + Dzero, + Ds, + Lc, + DstarPlus, + NCharmHadrons +}; + +enum BeautyFragFracOptions { + EpEm = 0, + PPbar, + LHCb, + LHCbMin, + LHCbMax, + NBeutyFragFracOptions +}; + +const std::array beautyFragFracEpEm = {0.408, 0.408, 0.100, 0.084}; +const std::array beautyFragFracPPbar = {0.344, 0.344, 0.115, 0.198}; +const std::array charmFragFracEpEm = {0.542, 0.225, 0.092, 0.057, 0.236}; // Values from e+e- ARXIV:1404.3888 (D0, D+, Ds, Lc, D*+) +const std::array beautyHadPdgs = {511, 521, 531, 5122}; +const std::array charmHadPdgs = {411, 421, 431, 4122, 413}; +const std::array beautyHadNames = {"Bzero", "Bplus", "Bs", "Lb"}; +const std::array charmHadNames = {"Dplus", "Dzero", "Ds", "Lc", "DstarPlus"}; +std::array namesFonll = {"Central", "Min", "Max"}; + +// FUNCTION PROTOTYPES +//__________________________________________________________________________________________________ +void computeFonllPlusPythiaPredictions(int nDecays = 10000000, + int seed = 42, + std::string inFileFonllBhad = "fonll_bhadron_5dot5teV_y1.txt", + int fragFracOpt = EpEm, + bool addPromptCharmHadrons = true, + std::string inFileFonllPromptDzero = "fonll_prompt_dzero_5dot5teV_y05.txt", + std::string inFileFonllPromptDplus = "fonll_prompt_dplus_5dot5teV_y05.txt", + std::string inFileFonllPromptDstarPlus = "fonll_prompt_dstar_5dot5teV_y05.txt", + std::string outFileName = "fonll_pythia_beautyFFee_charmhadrons_5dot5tev_y0dot5.root"); +std::vector splitString(const std::string& str, char delimiter); +std::array readFonll(std::string inFile, std::string histName = "hFonllBhadron"); + +// FUNCTION IMPLEMENTATIONS +//__________________________________________________________________________________________________ +std::vector splitString(const std::string& str, char delimiter) +{ + std::vector tokens; + std::stringstream ss(str); + std::string token; + + while (std::getline(ss, token, delimiter)) { + tokens.push_back(token); + } + tokens.erase(std::remove_if(tokens.begin(), tokens.end(), [](const std::string& str) { + return str.find_first_not_of(' ') == std::string::npos; // Check if the string contains only spaces + }), + tokens.end()); + + return tokens; +} + +//__________________________________________________________________________________________________ +std::array readFonll(std::string inFile, std::string histName) +{ + + std::array hFonll{nullptr, nullptr, nullptr}; + + std::ifstream inputFile(inFile); + + if (!inputFile) { + LOGP(fatal, "Error opening file {}", inFile); + return hFonll; + } + + std::string line; + + std::vector ptCent{}; + std::vector crossSecCent{}; + std::vector crossSecMin{}; + std::vector crossSecMax{}; + while (std::getline(inputFile, line)) { + if (line.find("#") != std::string::npos) { + continue; + } + std::vector elements = splitString(line, ' '); + ptCent.push_back(std::stof(elements[0])); + crossSecCent.push_back(std::stof(elements[1])); + crossSecMin.push_back(std::stof(elements[2])); + crossSecMax.push_back(std::stof(elements[3])); + } + inputFile.close(); + + if (ptCent.size() < 2) { + LOGP(fatal, "Only one pT value in FONLL file {}, cannot deduce binning.", inFile); + } + + float ptWidth = ptCent[1] - ptCent[0]; + float ptMin = ptCent.front() - ptWidth / 2; + float ptMax = ptCent.back() + ptWidth / 2; + + hFonll[0] = new TH1D(Form("%sCentral", histName.data()), ";#it{p}_{T} (GeV/#it{c});d#sigma/d#it{p}_{T} (#it{c}/GeV)", ptCent.size(), ptMin, ptMax); + hFonll[1] = new TH1D(Form("%sMin", histName.data()), ";#it{p}_{T} (GeV/#it{c});d#sigma/d#it{p}_{T} (#it{c}/GeV)", ptCent.size(), ptMin, ptMax); + hFonll[2] = new TH1D(Form("%sMax", histName.data()), ";#it{p}_{T} (GeV/#it{c});d#sigma/d#it{p}_{T} (#it{c}/GeV)", ptCent.size(), ptMin, ptMax); + for (auto iPt{0u}; iPt < ptCent.size(); ++iPt) { + hFonll[0]->SetBinContent(iPt + 1, crossSecCent[iPt]); + hFonll[1]->SetBinContent(iPt + 1, crossSecMin[iPt]); + hFonll[2]->SetBinContent(iPt + 1, crossSecMax[iPt]); + } + + return hFonll; +} + +//__________________________________________________________________________________________________ +void computeFonllPlusPythiaPredictions(int nDecays, int seed, std::string inFileFonllBhad, int fragFracOpt, bool addPromptCharmHadrons, std::string inFileFonllPromptDzero, std::string inFileFonllPromptDplus, std::string inFileFonllPromptDstarPlus, std::string outFileName) +{ + + gROOT->SetBatch(true); + gRandom->SetSeed(seed); + + if (fragFracOpt >= NBeutyFragFracOptions) { + LOGP(fatal, "Fragmentation fraction option not supported! Exit"); + } + + // init pythia object for the decayer + Pythia8::Pythia pythia; + pythia.readString("SoftQCD:inelastic = on"); + pythia.readString("Tune:pp = 14"); + pythia.readString("Random:setSeed = on"); + pythia.readString(Form("Random:seed %d", seed)); + pythia.init(); + + // get histograms from FONLL + auto hFonllBhad = readFonll(inFileFonllBhad); + if (!hFonllBhad[0]) { + return; + } + + std::map> hFonllPromptChad{}; + if (addPromptCharmHadrons) { + hFonllPromptChad[411] = readFonll(inFileFonllPromptDplus, "hFonllPromptDplus"); + hFonllPromptChad[421] = readFonll(inFileFonllPromptDzero, "hFonllPromptDzero"); + hFonllPromptChad[413] = readFonll(inFileFonllPromptDstarPlus, "hFonllPromptDstarPlus"); + // TODO: cook something for Ds and Lc + hFonllPromptChad[431] = {nullptr, nullptr, nullptr}; + hFonllPromptChad[4122] = {nullptr, nullptr, nullptr}; + for (auto iChad{0}; iChad < NCharmHadrons; ++iChad) { + if (charmHadPdgs[iChad] == 431 || charmHadPdgs[iChad] == 4122) { + continue; + } + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + hFonllPromptChad[charmHadPdgs[iChad]][iFonll]->Scale(charmFragFracEpEm[iChad]); + } + } + } + + // initialise histograms for non-prompt charm hadrons + std::map, NBeautyHadrons + 1>> hFonllPythiaNonPromptChad{}; + for (auto iChad{0}; iChad < NCharmHadrons; ++iChad) { + for (auto iBhad{0}; iBhad < NBeautyHadrons; ++iBhad) { + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][iBhad][iFonll] = new TH1D( + Form("hFonll%sFrom%s%s", charmHadNames[iChad].data(), beautyHadNames[iBhad].data(), namesFonll[iFonll].data()), + ";#it{p}_{T} (GeV/#it{c});d#sigma/d#it{p}_{T} (#it{c}/GeV)", 1000, 0., 100.); + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][iBhad][iFonll]->Sumw2(); + } + } + } + + // compute fractions for normalisation + std::array fragFracs{}; + std::array, NBeautyHadrons> fragFracFuncs{}; // used in case of LHCb due to the pT dependence + if (fragFracOpt == EpEm) { + fragFracs = beautyFragFracEpEm; + } else if (fragFracOpt == PPbar) { + fragFracs = beautyFragFracPPbar; + } else { // LHCb + for (int iPar{0}; iPar < 15; ++iPar) { + fragFracFuncs[0][iPar] = new TF1(Form("fracBz_%d", iPar), "1 / (2 * (([0] * ([1] + [2] * (x - [3]))) + ([4] * ([5] + exp([6] + [7] * x))) + 1) )", 0.f, 300.f); // B0 + fragFracFuncs[1][iPar] = new TF1(Form("fracBp_%d", iPar), "1 / (2 * (([0] * ([1] + [2] * (x - [3]))) + ([4] * ([5] + exp([6] + [7] * x))) + 1) )", 0.f, 300.f); // B+ + fragFracFuncs[2][iPar] = new TF1(Form("fracBs_%d", iPar), "([0] * ([1] + [2] * (x - [3]))) / (([0] * [1] + [2] * (x - [3])) + ([4] * ([5] + exp([6] + [7] * x))) + 1)", 0.f, 300.f); // Bs0 + fragFracFuncs[3][iPar] = new TF1(Form("fracLb_%d", iPar), "([4] * ([5] + exp([6] + [7] * x))) / (([0] * ([1] + [2] * (x - [3]))) + ([4] * ([5] + exp([6] + [7] * x))) + 1)", 0.f, 300.f); // Lb + + // parameters from https://arxiv.org/pdf/1902.06794.pdf + float sign = (iPar < 8) ? 1.f : -1.f; + float parLbA = 1.f + ((iPar == 1 || iPar == 8) ? sign * 0.061f : 0.f); + float parLbp1 = 0.0793f + ((iPar == 2 || iPar == 9) ? sign * 0.0141f : 0.f); + float parLbp2 = -1.022f + ((iPar == 3 || iPar == 10) ? sign * 0.0047f : 0.f); + float parLbp3 = -0.107f + ((iPar == 4 || iPar == 11) ? sign * 0.002f : 0.f); + float parBsA = 1.f + ((iPar == 5 || iPar == 12) ? sign * 0.043f : 0.f); + float parBsp1 = 0.119f + ((iPar == 6 || iPar == 13) ? sign * 0.001f : 0.f); + float parBsp2 = -0.00091f + ((iPar == 7 || iPar == 14) ? sign * 0.00025f : 0.f); + float parBsAvePt = 10.1f; + + for (int iBhad{0}; iBhad < NBeautyHadrons; ++iBhad) { + fragFracFuncs[iBhad][iPar]->SetParameters(parBsA, parBsp1, parBsp2, parBsAvePt, parLbA, parLbp1, parLbp2, parLbp3); + } + } + } + + std::array beautyHadMasses{}; + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + for (auto iBhad{0}; iBhad < NBeautyHadrons; ++iBhad) { + beautyHadMasses[iBhad] = TDatabasePDG::Instance()->GetParticle(beautyHadPdgs[iBhad])->Mass(); + for (auto iDecay{0}; iDecay < nDecays; ++iDecay) { + auto ptB = hFonllBhad[iFonll]->GetRandom(); + auto yB = gRandom->Uniform(-1., 1.); // we might consider to use more realistic shape from FONLL in the future + auto phiB = gRandom->Rndm() * o2::constants::math::TwoPI; + auto pxB = ptB * std::cos(phiB); + auto pyB = ptB * std::sin(phiB); + auto mtB = std::sqrt(beautyHadMasses[iBhad] * beautyHadMasses[iBhad] + ptB * ptB); + auto pzB = mtB * std::sinh(yB); + auto pB = std::sqrt(ptB * ptB + pzB * pzB); + auto eB = std::sqrt(beautyHadMasses[iBhad] * beautyHadMasses[iBhad] + pB * pB); + + Pythia8::Particle Bhad; + Bhad.id(beautyHadPdgs[iBhad]); + Bhad.status(81); + Bhad.m(beautyHadMasses[iBhad]); + Bhad.xProd(0.); + Bhad.yProd(0.); + Bhad.zProd(0.); + Bhad.tProd(0.); + Bhad.e(eB); + Bhad.px(pxB); + Bhad.py(pyB); + Bhad.pz(pzB); + + pythia.event.reset(); + pythia.event.append(Bhad); + auto idPart = pythia.event[1].id(); + pythia.particleData.mayDecay(idPart, true); + pythia.moreDecays(); + + auto fracB = fragFracs[iBhad]; + if (fragFracOpt == LHCb) { + fracB = fragFracFuncs[iBhad][0]->Eval(ptB > 5.f ? ptB : 5); + } else if (fragFracOpt == LHCbMin) { + fracB = 2.f; + for (int iPar{0}; iPar < 15; ++iPar) { + auto tmpFrac = fragFracFuncs[iBhad][iPar]->Eval(ptB > 5.f ? ptB : 5); + if (tmpFrac < fracB) { + fracB = tmpFrac; + } + } + } else if (fragFracOpt == LHCbMax) { + fracB = -1.f; + for (int iPar{0}; iPar < 15; ++iPar) { + auto tmpFrac = fragFracFuncs[iBhad][iPar]->Eval(ptB > 5.f ? ptB : 5); + if (tmpFrac > fracB) { + fracB = tmpFrac; + } + } + } + + for (int iPart{1}; iPart < pythia.event.size(); ++iPart) { + if (std::abs(pythia.event[iPart].y()) > 0.5) { + continue; + } + auto absPdg = std::abs(pythia.event[iPart].id()); + if (std::find(charmHadPdgs.begin(), charmHadPdgs.end(), absPdg) != charmHadPdgs.end()) { // we found a charm hadron, let's fill the corresponding histogram + hFonllPythiaNonPromptChad[absPdg][iBhad][iFonll]->Fill(pythia.event[iPart].pT(), fracB); + } + } + } + } + } + + std::array normCrossSec{}; + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + normCrossSec[iFonll] = hFonllBhad[iFonll]->Integral(); + for (auto iChad{0}; iChad < NCharmHadrons; ++iChad) { + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][NBeautyHadrons][iFonll] = reinterpret_cast(hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][0][iFonll]->Clone(Form("hFonllNonPrompt%s%s", charmHadNames[iChad].data(), namesFonll[iFonll].data()))); + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][NBeautyHadrons][iFonll]->Reset(); + for (auto iBhad{0}; iBhad < NBeautyHadrons; ++iBhad) { + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][iBhad][iFonll]->Scale(normCrossSec[iFonll] / nDecays); + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][NBeautyHadrons][iFonll]->Add(hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][iBhad][iFonll]); + } + } + } + + TFile outFile(outFileName.data(), "recreate"); + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + hFonllBhad[iFonll]->Write(); + } + auto dirNonPrompt = new TDirectoryFile("NonPrompt", "NonPrompt"); + dirNonPrompt->Write(); + for (auto iChad{0}; iChad < NCharmHadrons; ++iChad) { + dirNonPrompt->cd(); + auto dirCharmHad = new TDirectoryFile(charmHadNames[iChad].data(), charmHadNames[iChad].data()); + dirCharmHad->Write(); + dirCharmHad->cd(); + for (auto iBhad{0}; iBhad < NBeautyHadrons + 1; ++iBhad) { + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + hFonllPythiaNonPromptChad[charmHadPdgs[iChad]][iBhad][iFonll]->Write(); + } + } + } + if (addPromptCharmHadrons) { + outFile.cd(); + auto dirPrompt = new TDirectoryFile("Prompt", "Prompt"); + dirPrompt->Write(); + for (auto iChad{0}; iChad < NCharmHadrons; ++iChad) { + dirPrompt->cd(); + auto dirCharmHad = new TDirectoryFile(charmHadNames[iChad].data(), charmHadNames[iChad].data()); + dirCharmHad->Write(); + dirCharmHad->cd(); + for (auto iFonll{0}; iFonll < 3; ++iFonll) { + if (hFonllPromptChad[charmHadPdgs[iChad]][iFonll]) { + hFonllPromptChad[charmHadPdgs[iChad]][iFonll]->Write(); + } + } + } + } + outFile.Close(); +} diff --git a/PWGHF/TableProducer/CMakeLists.txt b/PWGHF/TableProducer/CMakeLists.txt index 32a1b8cadef..58f6d3280e4 100644 --- a/PWGHF/TableProducer/CMakeLists.txt +++ b/PWGHF/TableProducer/CMakeLists.txt @@ -28,6 +28,11 @@ o2physics_add_dpl_workflow(pid-creator PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(mc-pid-tof + SOURCES mcPidTof.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::TOFWorkflowUtils + COMPONENT_NAME Analysis) + # Candidate creators o2physics_add_dpl_workflow(candidate-creator-2prong @@ -82,7 +87,7 @@ o2physics_add_dpl_workflow(candidate-creator-sigmac0plusplus-cascade o2physics_add_dpl_workflow(candidate-creator-xic0-omegac0 SOURCES candidateCreatorXic0Omegac0.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::EventFilteringUtils + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::EventFilteringUtils KFParticle::KFParticle COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(candidate-creator-xic-to-xi-pi-pi @@ -231,7 +236,7 @@ o2physics_add_dpl_workflow(tree-creator-lc-to-p-k-pi o2physics_add_dpl_workflow(tree-creator-omegac-st SOURCES treeCreatorOmegacSt.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(tree-creator-omegac0-to-omega-ka @@ -271,6 +276,11 @@ o2physics_add_dpl_workflow(tree-creator-dstar-to-d0-pi # Derived-data creators +o2physics_add_dpl_workflow(derived-data-creator-bplus-to-d0-pi + SOURCES derivedDataCreatorBplusToD0Pi.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(derived-data-creator-d0-to-k-pi SOURCES derivedDataCreatorD0ToKPi.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -280,3 +290,10 @@ o2physics_add_dpl_workflow(derived-data-creator-lc-to-p-k-pi SOURCES derivedDataCreatorLcToPKPi.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) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 022173dddb4..6d27cfd9021 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -20,6 +20,10 @@ #define HomogeneousField #endif +#include +#include +#include + #include #include #include @@ -43,6 +47,7 @@ #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" using namespace o2; @@ -53,10 +58,15 @@ using namespace o2::aod::hf_cand_2prong; using namespace o2::hf_centrality; using namespace o2::constants::physics; using namespace o2::framework; +using namespace o2::aod::pid_tpc_tof_utils; /// Reconstruction of heavy-flavour 2-prong decay candidates struct HfCandidateCreator2Prong { Produces rowCandidateBase; + Produces rowProng0PidPi; + Produces rowProng0PidKa; + Produces rowProng1PidPi; + Produces rowProng1PidKa; Produces rowCandidateKF; // vertexing @@ -72,15 +82,14 @@ struct HfCandidateCreator2Prong { // 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)"}; HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter Service ccdb; - o2::base::MatLayerCylSet* lut; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + + using TracksWCovExtraPidPiKa = soa::Join; int runNumber{0}; float toMicrometers = 10000.; // from cm to µm @@ -160,7 +169,6 @@ struct HfCandidateCreator2Prong { ccdb->setURL(ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; /// candidate monitoring @@ -179,7 +187,7 @@ 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); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -196,7 +204,7 @@ struct HfCandidateCreator2Prong { 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); + 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 @@ -296,6 +304,12 @@ struct HfCandidateCreator2Prong { rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), nProngsContributorsPV, rowTrackIndexProng2.hfflag()); + // fill candidate prong PID rows + fillProngPid(track0, rowProng0PidPi); + fillProngPid(track0, rowProng0PidKa); + fillProngPid(track1, rowProng1PidPi); + fillProngPid(track1, rowProng1PidKa); + // fill histograms if (fillHistograms) { // calculate invariant masses @@ -320,7 +334,7 @@ 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); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -335,7 +349,7 @@ struct HfCandidateCreator2Prong { 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); + 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 @@ -440,6 +454,14 @@ struct HfCandidateCreator2Prong { 0.f, 0.f, rowTrackIndexProng2.prong0Id(), rowTrackIndexProng2.prong1Id(), nProngsContributorsPV, rowTrackIndexProng2.hfflag()); + + // fill candidate prong PID rows + fillProngPid(track0, rowProng0PidPi); + fillProngPid(track0, rowProng0PidKa); + fillProngPid(track1, rowProng1PidPi); + fillProngPid(track1, rowProng1PidKa); + + // fill KF info rowCandidateKF(topolChi2PerNdfD0, massD0, massD0bar); @@ -460,7 +482,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/ PV refit and w/o centrality selections void processPvRefitWithDCAFitterN(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -470,7 +492,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/o PV refit and w/o centrality selections void processNoPvRefitWithDCAFitterN(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -480,7 +502,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/ PV refit and w/o centrality selections void processPvRefitWithKFParticle(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -490,7 +512,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/o PV refit and w/o centrality selections void processNoPvRefitWithKFParticle(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -506,7 +528,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on FT0C void processPvRefitWithDCAFitterNCentFT0C(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -516,7 +538,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection FT0C void processNoPvRefitWithDCAFitterNCentFT0C(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -526,7 +548,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on FT0C void processPvRefitWithKFParticleCentFT0C(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -536,7 +558,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/o PV refit and w/o centrality selections void processNoPvRefitWithKFParticleCentFT0C(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -552,7 +574,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/ PV refit and w/ centrality selection on FT0M void processPvRefitWithDCAFitterNCentFT0M(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -562,7 +584,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using DCA fitter w/o PV refit and w/ centrality selection FT0M void processNoPvRefitWithDCAFitterNCentFT0M(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithDCAFitterN(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -572,7 +594,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/ PV refit and w/ centrality selection on FT0M void processPvRefitWithKFParticleCentFT0M(soa::Join const& collisions, soa::Join const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -582,7 +604,7 @@ struct HfCandidateCreator2Prong { /// @brief process function using KFParticle package w/o PV refit and w/o centrality selections void processNoPvRefitWithKFParticleCentFT0M(soa::Join const& collisions, aod::Hf2Prongs const& rowsTrackIndexProng2, - aod::TracksWCovExtra const& tracks, + TracksWCovExtraPidPiKa const& tracks, aod::BCsWithTimestamps const& bcWithTimeStamps) { runCreator2ProngWithKFParticle(collisions, rowsTrackIndexProng2, tracks, bcWithTimeStamps); @@ -603,10 +625,10 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -620,10 +642,10 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -637,10 +659,10 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -653,13 +675,30 @@ struct HfCandidateCreator2ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; + // Configuration + o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring + + using McCollisionsNoCents = soa::Join; + using McCollisionsFT0Cs = soa::Join; + using McCollisionsFT0Ms = soa::Join; + 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 void init(InitContext& initContext) { + std::array procCollisions = {doprocessMc, doprocessMcCentFT0C, doprocessMcCentFT0M}; + if (std::accumulate(procCollisions.begin(), procCollisions.end(), 0) > 1) { + LOGP(fatal, "At most one process function for collision study can be enabled at a time."); + } + const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-2prong") == 0) { @@ -671,10 +710,12 @@ struct HfCandidateCreator2ProngExpressions { } /// Performs MC matching. - void processMc(aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles, - aod::McCollisions const&, - BCsInfo const&) + template + void runCreator2ProngMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + CCs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const&) { rowCandidateProng2->bindExternalIndices(&tracks); @@ -689,6 +730,24 @@ struct HfCandidateCreator2ProngExpressions { flag = 0; origin = 0; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as()}; + + // Check whether the particle is from background events. If so, reject it. + if (rejectBackground) { + bool fromBkg{false}; + for (const auto& daughter : arrayDaughters) { + if (daughter.has_mcParticle()) { + auto mcParticle = daughter.mcParticle(); + if (mcParticle.fromBackgroundEvent()) { + fromBkg = true; + break; + } + } + } + if (fromBkg) { + rowMcMatchRec(flag, origin, -1.f, 0); + continue; + } + } std::vector idxBhadMothers{}; // D0(bar) → π± K∓ @@ -726,54 +785,104 @@ struct HfCandidateCreator2ProngExpressions { } } - // Match generated particles. - for (const auto& particle : mcParticles) { - flag = 0; - origin = 0; - std::vector idxBhadMothers{}; - - auto mcCollision = particle.mcCollision(); + for (const auto& mcCollision : mcCollisions) { - const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + // 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}; + 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()); + 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(rejectionMask); if (rejectionMask != 0) { - /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(flag, origin, -1); + // 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); + } continue; } - // D0(bar) → π± K∓ - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) { - flag = sign * (1 << DecayType::D0ToPiK); - } + // 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; + } - // J/ψ → e+ e− - if (flag == 0) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kElectron, -kElectron}, true)) { - flag = 1 << DecayType::JpsiToEE; + // D0(bar) → π± K∓ + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kD0, std::array{+kPiPlus, -kKPlus}, true, &sign)) { + flag = sign * (1 << DecayType::D0ToPiK); } - } - // J/ψ → μ+ μ− - if (flag == 0) { - if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kMuonPlus, -kMuonPlus}, true)) { - flag = 1 << DecayType::JpsiToMuMu; + // J/ψ → e+ e− + if (flag == 0) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kJPsi, std::array{+kElectron, -kElectron}, true)) { + flag = 1 << DecayType::JpsiToEE; + } } - } - // 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); + // 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); + } } } } - PROCESS_SWITCH(HfCandidateCreator2ProngExpressions, processMc, "Process MC", false); + void processMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator2ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator2ProngExpressions, processMc, "Process MC - no centrality", false); + + void processMcCentFT0C(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Cs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator2ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator2ProngExpressions, processMcCentFT0C, "Process MC - FT0c centrality", false); + + void processMcCentFT0M(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Ms const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator2ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator2ProngExpressions, processMcCentFT0M, "Process MC - FT0m centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 3a72c0b5c5e..a14df266590 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -15,6 +15,11 @@ /// /// \author Vít Kučera , CERN +#include +#include +#include +#include + #include #include "CommonConstants/PhysicsConstants.h" @@ -59,7 +64,6 @@ struct HfCandidateCreator3Prong { // 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)"}; // flags to enable creation for different particle species separately @@ -71,8 +75,6 @@ struct HfCandidateCreator3Prong { HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<3> df; // 3-prong vertex fitter Service ccdb; - o2::base::MatLayerCylSet* lut; - o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; int runNumber{0}; float toMicrometers = 10000.; // from cm to µm @@ -152,7 +154,6 @@ struct HfCandidateCreator3Prong { ccdb->setURL(ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); - lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; /// candidate monitoring @@ -171,7 +172,7 @@ 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); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -190,7 +191,7 @@ struct HfCandidateCreator3Prong { 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); + 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 @@ -403,10 +404,10 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -420,10 +421,10 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -437,10 +438,10 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -453,6 +454,9 @@ struct HfCandidateCreator3ProngExpressions { Produces rowMcMatchRec; Produces rowMcMatchGen; + // Configuration + o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + bool createDplus{false}; bool createDs{false}; bool createLc{false}; @@ -462,8 +466,20 @@ struct HfCandidateCreator3ProngExpressions { using BCsInfo = soa::Join; HistogramRegistry registry{"registry"}; + using McCollisionsNoCents = soa::Join; + using McCollisionsFT0Cs = soa::Join; + using McCollisionsFT0Ms = soa::Join; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + void init(InitContext& initContext) { + std::array procCollisions = {doprocessMc, doprocessMcCentFT0C, doprocessMcCentFT0M}; + if (std::accumulate(procCollisions.begin(), procCollisions.end(), 0) > 1) { + LOGP(fatal, "At most one process function for collision study can be enabled at a time."); + } // inspect for which particle species the candidates were created and which zPvPosMax cut was set for reconstructed const auto& workflows = initContext.services().get(); @@ -495,10 +511,12 @@ struct HfCandidateCreator3ProngExpressions { } /// Performs MC matching. - void processMc(aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles, - aod::McCollisions const&, - BCsInfo const&) + template + void runCreator3ProngMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + CCs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const&) { rowCandidateProng3->bindExternalIndices(&tracks); @@ -512,7 +530,7 @@ struct HfCandidateCreator3ProngExpressions { std::array arrPDGDaugh; std::array arrPDGResonant1 = {kProton, 313}; // Λc± → p± K* std::array arrPDGResonant2 = {2224, kKPlus}; // Λc± → Δ(1232)±± K∓ - std::array arrPDGResonant3 = {3124, kPiPlus}; // Λc± → Λ(1520) π± + 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± @@ -527,6 +545,24 @@ struct HfCandidateCreator3ProngExpressions { std::vector idxBhadMothers{}; auto arrayDaughters = std::array{candidate.prong0_as(), candidate.prong1_as(), candidate.prong2_as()}; + // Check whether the particle is from background events. If so, reject it. + if (rejectBackground) { + bool fromBkg{false}; + for (const auto& daughter : arrayDaughters) { + if (daughter.has_mcParticle()) { + auto mcParticle = daughter.mcParticle(); + if (mcParticle.fromBackgroundEvent()) { + fromBkg = true; + break; + } + } + } + if (fromBkg) { + rowMcMatchRec(flag, origin, swapping, channel, -1.f, 0); + continue; + } + } + // D± → π± K∓ π± if (createDplus) { indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2); @@ -613,103 +649,153 @@ struct HfCandidateCreator3ProngExpressions { } } - // Match generated particles. - for (const auto& particle : mcParticles) { - flag = 0; - origin = 0; - channel = 0; - arrDaughIndex.clear(); - std::vector idxBhadMothers{}; - - auto mcCollision = particle.mcCollision(); + for (const auto& mcCollision : mcCollisions) { - const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + // 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}; + 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()); + 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(rejectionMask); if (rejectionMask != 0) { - /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(flag, origin, channel, -1); + // at least one event selection not satisfied --> reject all gen particles from this collision + for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { + rowMcMatchGen(0, 0, 0, -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); + // 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; } - } - // 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; + // D± → π± K∓ π± + if (createDplus) { + if (RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kDPlus, std::array{+kPiPlus, -kKPlus, +kPiPlus}, true, &sign, 2)) { + flag = sign * (1 << DecayType::DplusToPiKPi); + } } - 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; + + // 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 && 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); + // Ξ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); + // 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); + } } } } - PROCESS_SWITCH(HfCandidateCreator3ProngExpressions, processMc, "Process MC", false); + void processMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator3ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator3ProngExpressions, processMc, "Process MC - no centrality", false); + + void processMcCentFT0C(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Cs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator3ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator3ProngExpressions, processMcCentFT0C, "Process MC - FT0c centrality", false); + + void processMcCentFT0M(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Ms const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreator3ProngMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreator3ProngExpressions, processMcCentFT0M, "Process MC - FT0m centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateCreatorBplus.cxx b/PWGHF/TableProducer/candidateCreatorBplus.cxx index b8845945df9..0d4753c6c98 100644 --- a/PWGHF/TableProducer/candidateCreatorBplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorBplus.cxx @@ -18,6 +18,10 @@ /// \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" @@ -79,9 +83,6 @@ struct HfCandidateCreatorBplus { o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; int runNumber; - double massPi{0.}; - double massD0{0.}; - double massBplus{0.}; double invMass2D0PiMin{0.}; double invMass2D0PiMax{0.}; double bz{0.}; @@ -110,11 +111,8 @@ struct HfCandidateCreatorBplus { void init(InitContext const&) { // invariant-mass window cut - massPi = MassPiPlus; - massD0 = MassD0; - massBplus = MassBPlus; - invMass2D0PiMin = (massBplus - invMassWindowBplus) * (massBplus - invMassWindowBplus); - invMass2D0PiMax = (massBplus + invMassWindowBplus) * (massBplus + invMassWindowBplus); + invMass2D0PiMin = (MassBPlus - invMassWindowBplus) * (MassBPlus - invMassWindowBplus); + invMass2D0PiMax = (MassBPlus + invMassWindowBplus) * (MassBPlus + invMassWindowBplus); // Initialise fitter for B vertex dfB.setPropagateToPCA(propagateToPCA); @@ -173,16 +171,8 @@ struct HfCandidateCreatorBplus { aod::BCsWithTimestamps const&) { - static int nCol = 0; - for (const auto& collision : collisions) { auto primaryVertex = getPrimaryVertex(collision); - - if (nCol % 10000 == 0) { - LOG(debug) << nCol << " collisions parsed"; - } - nCol++; - /// 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. @@ -294,7 +284,6 @@ struct HfCandidateCreatorBplus { auto trackParCovPi = getTrackParCov(trackPion); std::array pVecD0 = {0., 0., 0.}; std::array pVecBach = {0., 0., 0.}; - std::array pVecBCand = {0., 0., 0.}; // find the DCA between the D0 and the bachelor track, for B+ hCandidatesB->Fill(SVFitting::BeforeFit); @@ -318,8 +307,6 @@ struct HfCandidateCreatorBplus { auto covMatrixPCA = dfB.calcPCACovMatrixFlat(); hCovSVXX->Fill(covMatrixPCA[0]); // FIXME: Calculation of errorDecayLength(XY) gives wrong values without this line. - pVecBCand = RecoDecay::pVec(pVecD0, pVecBach); - // get track impact parameters // This modifies track momenta! auto covMatrixPV = primaryVertex.getCov(); @@ -336,7 +323,7 @@ struct HfCandidateCreatorBplus { auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.)); // compute invariant mass square and apply selection - auto invMass2D0Pi = RecoDecay::m2(std::array{pVecD0, pVecBach}, std::array{massD0, massPi}); + auto invMass2D0Pi = RecoDecay::m2(std::array{pVecD0, pVecBach}, std::array{MassD0, MassPiPlus}); if ((invMass2D0Pi < invMass2D0PiMin) || (invMass2D0Pi > invMass2D0PiMax)) { continue; } diff --git a/PWGHF/TableProducer/candidateCreatorBs.cxx b/PWGHF/TableProducer/candidateCreatorBs.cxx index 69fb0c3f178..e9aef03fd30 100644 --- a/PWGHF/TableProducer/candidateCreatorBs.cxx +++ b/PWGHF/TableProducer/candidateCreatorBs.cxx @@ -42,6 +42,7 @@ using namespace o2::hf_trkcandsel; /// Reconstruction of Bs candidates struct HfCandidateCreatorBs { Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateProngs; // table defined in CandidateReconstructionTables.h // vertexing Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; @@ -320,8 +321,6 @@ struct HfCandidateCreatorBs { 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 = BIT(hf_cand_bs::DecayType::BsToDsPi); - // fill output histograms for Bs candidates hMassDsToKKPi->Fill(hfHelper.invMassDsToKKPi(candDs), candDs.pt()); hCovSVXX->Fill(covMatrixPCA[0]); @@ -340,9 +339,9 @@ struct HfCandidateCreatorBs { pVecDs[0], pVecDs[1], pVecDs[2], pVecPion[0], pVecPion[1], pVecPion[2], dcaDs.getY(), dcaPion.getY(), - std::sqrt(dcaDs.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2()), - candDs.globalIndex(), trackPion.globalIndex(), - hfFlag); + std::sqrt(dcaDs.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2())); + + rowCandidateProngs(candDs.globalIndex(), trackPion.globalIndex()); } // pi loop } // Ds loop } // collision loop @@ -357,13 +356,11 @@ struct HfCandidateCreatorBsExpressions { void init(InitContext const&) {} - void processMc(aod::HfCand3Prong const& ds, - aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles) + void processMc(aod::HfCand3Prong const&, + aod::TracksWMc const&, + aod::McParticles const& mcParticles, + aod::HfCandBsProngs const& candsBs) { - rowCandidateBs->bindExternalIndices(&tracks); - rowCandidateBs->bindExternalIndices(&ds); - int indexRec = -1; int8_t sign = 0; int8_t flag = 0; @@ -372,8 +369,7 @@ struct HfCandidateCreatorBsExpressions { std::array arrPDGResonantDsPhiPi = {Pdg::kPhi, kPiPlus}; // Ds± → Phi π± // Match reconstructed candidates. - // Spawned table can be used directly - for (const auto& candidate : *rowCandidateBs) { + for (const auto& candidate : candsBs) { flag = 0; arrDaughDsIndex.clear(); auto candDs = candidate.prong0(); @@ -398,7 +394,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::BsToDsPiToKKPiPi); + flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); } } } @@ -418,7 +414,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::B0ToDsPiToKKPiPi); + flag = sign * BIT(hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi); } } } @@ -471,7 +467,7 @@ 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::BsToDsPiToKKPiPi); + flag = sign * BIT(hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi); } } } @@ -490,7 +486,7 @@ 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::B0ToDsPiToKKPiPi); + flag = sign * BIT(hf_cand_bs::DecayTypeMc::B0ToDsPiToPhiPiPiToKKPiPi); } } } @@ -499,7 +495,7 @@ struct HfCandidateCreatorBsExpressions { rowMcMatchGen(flag); } // gen - } // processMc + } // processMc PROCESS_SWITCH(HfCandidateCreatorBsExpressions, processMc, "Process MC", false); }; // struct diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 3f391842c93..b8846c23e19 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -25,6 +25,7 @@ #include "Framework/RunningWorkflowInfo.h" #include "ReconstructionDataFormats/DCA.h" #include "ReconstructionDataFormats/V0.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" #include "Common/Core/trackUtilities.h" @@ -136,22 +137,26 @@ struct HfCandidateCreatorCascade { setLabelHistoCands(hCandidates); } + using V0full = soa::Join; + using V0fCfull = soa::Join; + template void runCreatorCascade(Coll const&, aod::HfCascades const& rowsTrackIndexCasc, aod::V0sLinked const&, - aod::V0Datas const&, - aod::V0fCDatas const&, + V0full const&, + V0fCfull const&, aod::TracksWCov const&, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/) { + // loop over pairs of track indices for (const auto& casc : rowsTrackIndexCasc) { - /// reject candidates in collisions not satisfying the event selections auto collision = casc.template collision_as(); + /// reject candidates in collisions not satisfying the event selections float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -168,18 +173,14 @@ struct HfCandidateCreatorCascade { float v0x, v0y, v0z, v0px, v0py, v0pz; float v0PosPx, v0PosPy, v0PosPz, v0NegPx, v0NegPy, v0NegPz; float dcaV0dau, dcaPosToPV, dcaNegToPV, v0cosPA; - float posTrackX, negTrackX; - o2::track::TrackParCov trackParCovV0DaughPos; - o2::track::TrackParCov trackParCovV0DaughNeg; + std::array covV = {0.}; - auto v0index = casc.v0_as(); + auto v0index = casc.template v0_as(); if (v0index.has_v0Data()) { // this V0 passed both standard V0 and cascade V0 selections - auto v0row = v0index.v0Data(); + auto v0row = v0index.template v0Data_as(); const auto& trackV0DaughPos = v0row.posTrack_as(); const auto& trackV0DaughNeg = v0row.negTrack_as(); - trackParCovV0DaughPos = getTrackParCov(trackV0DaughPos); // check that aod::TracksWCov does not need TracksDCA! - trackParCovV0DaughNeg = getTrackParCov(trackV0DaughNeg); // check that aod::TracksWCov does not need TracksDCA! posGlobalIndex = trackV0DaughPos.globalIndex(); negGlobalIndex = trackV0DaughNeg.globalIndex(); v0x = v0row.x(); @@ -198,15 +199,17 @@ struct HfCandidateCreatorCascade { dcaPosToPV = v0row.dcapostopv(); dcaNegToPV = v0row.dcanegtopv(); v0cosPA = v0row.v0cosPA(); - posTrackX = v0row.posX(); - negTrackX = v0row.negX(); + + 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]] = v0row.momentumCovMat()[i]; + covV[i] = v0row.positionCovMat()[i]; + } } else if (v0index.has_v0fCData()) { // this V0 passes only V0-for-cascade selections, use that instead - auto v0row = v0index.v0fCData(); + auto v0row = v0index.template v0fCData_as(); const auto& trackV0DaughPos = v0row.posTrack_as(); const auto& trackV0DaughNeg = v0row.negTrack_as(); - trackParCovV0DaughPos = getTrackParCov(trackV0DaughPos); // check that aod::TracksWCov does not need TracksDCA! - trackParCovV0DaughNeg = getTrackParCov(trackV0DaughNeg); // check that aod::TracksWCov does not need TracksDCA! posGlobalIndex = trackV0DaughPos.globalIndex(); negGlobalIndex = trackV0DaughNeg.globalIndex(); v0x = v0row.x(); @@ -225,8 +228,12 @@ struct HfCandidateCreatorCascade { dcaPosToPV = v0row.dcapostopv(); dcaNegToPV = v0row.dcanegtopv(); v0cosPA = v0row.v0cosPA(); - posTrackX = v0row.posX(); - negTrackX = v0row.negX(); + + 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]] = v0row.momentumCovMat()[i]; + covV[i] = v0row.positionCovMat()[i]; + } } else { LOGF(warning, "V0Data/V0fCData not there for V0 %d in HF cascade %d. Skipping candidate.", casc.v0Id(), casc.globalIndex()); continue; // this was inadequately linked, should not happen @@ -243,24 +250,24 @@ struct HfCandidateCreatorCascade { } df.setBz(bz); - auto trackParCovBach = getTrackParCov(bach); - 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 + auto trackBach = getTrackParCov(bach); 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::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::track::TrackParCov(vertexV0, momentumV0, covV, 0, true); + trackV0.setAbsCharge(0); + trackV0.setPID(o2::track::PID::K0); // reconstruct the cascade secondary vertex hCandidates->Fill(SVFitting::BeforeFit); try { - if (df.process(trackV0, trackParCovBach) == 0) { + if (df.process(trackV0, trackBach) == 0) { continue; } else { - // LOG(info) << "Vertexing succeeded for Lc candidate"; + LOG(debug) << "Vertexing succeeded for Lc candidate"; } } catch (const std::runtime_error& error) { - LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + LOG(debug) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; hCandidates->Fill(SVFitting::Fail); continue; } @@ -308,7 +315,6 @@ struct HfCandidateCreatorCascade { std::sqrt(impactParameterBach.getSigmaY2()), std::sqrt(impactParameterV0.getSigmaY2()), casc.prong0Id(), casc.v0Id(), v0x, v0y, v0z, - // v0.posTrack(), v0.negTrack(), // why this was not fine? posGlobalIndex, negGlobalIndex, v0PosPx, v0PosPy, v0PosPz, v0NegPx, v0NegPy, v0NegPz, @@ -332,12 +338,12 @@ struct HfCandidateCreatorCascade { void processNoCent(soa::Join const& collisions, aod::HfCascades const& rowsTrackIndexCasc, aod::V0sLinked const& v0sLinked, - aod::V0Datas const& v0Data, - aod::V0fCDatas const& v0fCDatas, + V0full const& v0Full, + V0fCfull const& v0fcFull, aod::TracksWCov const& tracks, aod::BCsWithTimestamps const& bcs) { - runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Data, v0fCDatas, tracks, bcs); + runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Full, v0fcFull, tracks, bcs); } PROCESS_SWITCH(HfCandidateCreatorCascade, processNoCent, " Run candidate creator w/o centrality selections", true); @@ -345,12 +351,12 @@ struct HfCandidateCreatorCascade { void processCentFT0C(soa::Join const& collisions, aod::HfCascades const& rowsTrackIndexCasc, aod::V0sLinked const& v0sLinked, - aod::V0Datas const& v0Data, - aod::V0fCDatas const& v0fCDatas, + V0full const& v0Full, + V0fCfull const& v0fcFull, aod::TracksWCov const& tracks, aod::BCsWithTimestamps const& bcs) { - runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Data, v0fCDatas, tracks, bcs); + runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Full, v0fcFull, tracks, bcs); } PROCESS_SWITCH(HfCandidateCreatorCascade, processCentFT0C, " Run candidate creator w/ centrality selection on FT0C", false); @@ -358,12 +364,12 @@ struct HfCandidateCreatorCascade { void processCentFT0M(soa::Join const& collisions, aod::HfCascades const& rowsTrackIndexCasc, aod::V0sLinked const& v0sLinked, - aod::V0Datas const& v0Data, - aod::V0fCDatas const& v0fCDatas, + V0full const& v0Full, + V0fCfull const& v0fcFull, aod::TracksWCov const& tracks, aod::BCsWithTimestamps const& bcs) { - runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Data, v0fCDatas, tracks, bcs); + runCreatorCascade(collisions, rowsTrackIndexCasc, v0sLinked, v0Full, v0fcFull, tracks, bcs); } PROCESS_SWITCH(HfCandidateCreatorCascade, processCentFT0M, " Run candidate creator w/ centrality selection on FT0M", false); @@ -381,10 +387,10 @@ struct HfCandidateCreatorCascade { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -398,10 +404,10 @@ struct HfCandidateCreatorCascade { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -415,10 +421,10 @@ struct HfCandidateCreatorCascade { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -436,9 +442,25 @@ struct HfCandidateCreatorCascadeMc { 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; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) { + std::array procCollisions = {doprocessMc, doprocessMcCentFT0C, doprocessMcCentFT0M}; + if (std::accumulate(procCollisions.begin(), procCollisions.end(), 0) > 1) { + LOGP(fatal, "At most one process function for collision study can be enabled at a time."); + } + const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-cascade") == 0) { @@ -449,22 +471,21 @@ struct HfCandidateCreatorCascadeMc { hfEvSelMc.addHistograms(registry); // particles monitoring } - void processMc(MyTracksWMc const& tracks, - aod::McParticles const& mcParticles, - aod::McCollisions const&, - BCsInfo const&) + template + void runCreatorCascMc(MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + CCs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const&) { - int8_t sign = 0; - int8_t origin = 0; - int indexRec = -1; - std::vector arrDaughLcIndex; - std::array arrDaughLcPDG; - std::array arrDaughLcPDGRef = {+kProton, +kPiPlus, -kPiPlus}; - // Match reconstructed candidates. rowCandidateCasc->bindExternalIndices(&tracks); for (const auto& candidate : *rowCandidateCasc) { - origin = 0; + + int8_t sign = 0; + int8_t origin = 0; + int indexRec = -1; + std::vector idxBhadMothers{}; const auto& bach = candidate.prong0_as(); @@ -473,15 +494,32 @@ struct HfCandidateCreatorCascadeMc { auto arrayDaughtersV0 = std::array{trackV0DaughPos, trackV0DaughNeg}; auto arrayDaughtersLc = std::array{bach, trackV0DaughPos, trackV0DaughNeg}; + // Check whether the particle is from background events. If so, reject it. + if (rejectBackground) { + bool fromBkg{false}; + for (const auto& daughter : arrayDaughtersLc) { + if (daughter.has_mcParticle()) { + auto mcParticle = daughter.mcParticle(); + if (mcParticle.fromBackgroundEvent()) { + fromBkg = true; + break; + } + } + } + if (fromBkg) { + rowMcMatchRec(sign, origin, -1.f, 0); + continue; + } + } - RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, kK0Short, std::array{+kPiPlus, -kPiPlus}, false, &sign, 1); - if (sign != 0) { // we have already positively checked the K0s + int indexK0SRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersV0, kK0Short, std::array{+kPiPlus, -kPiPlus}, false, &sign, 1); + if (indexK0SRec >= 0) { // we have already positively checked the K0s // then we check the Lc - indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersLc, Pdg::kLambdaCPlus, std::array{+kProton, +kPiPlus, -kPiPlus}, true, &sign, 3); // 3-levels Lc --> p + K0 --> p + K0s --> p + pi+ pi- + indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersLc, Pdg::kLambdaCPlus, std::array{+kProton, +kPiPlus, -kPiPlus}, true, &sign, 3); // 3-levels Lc --> p + K0 --> p + K0s --> p + pi+ pi- } // Check whether the particle is non-prompt (from a b quark). - if (sign != 0) { + if (indexRec >= 0) { auto particle = mcParticles.rawIteratorAt(indexRec); origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); } @@ -492,58 +530,110 @@ struct HfCandidateCreatorCascadeMc { rowMcMatchRec(sign, origin, -1.f, 0); } } - //} - - // Match generated particles. - for (const auto& particle : mcParticles) { - origin = 0; - std::vector idxBhadMothers{}; - auto mcCollision = particle.mcCollision(); + for (const auto& mcCollision : mcCollisions) { - const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + // Slice the MC 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}; + 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()); + 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(rejectionMask); if (rejectionMask != 0) { - /// at least one event selection not satisfied --> reject the gen particle - rowMcMatchGen(sign, origin, -1); + // 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); + } continue; } - // checking if I have a Lc --> K0S + p - RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, +kK0Short}, false, &sign, 2); - if (sign == 0) { // now check for anti-Lc - RecoDecay::isMatchedMCGen(mcParticles, particle, -Pdg::kLambdaCPlus, std::array{-kProton, +kK0Short}, false, &sign, 2); - sign = -sign; - } - if (sign != 0) { - arrDaughLcIndex.clear(); - // checking that the final daughters (decay depth = 3) are p, pi+, pi- - RecoDecay::getDaughters(particle, &arrDaughLcIndex, arrDaughLcPDGRef, 3); // best would be to check the K0S daughters - if (arrDaughLcIndex.size() == 3) { - for (std::size_t iProng = 0; iProng < arrDaughLcIndex.size(); ++iProng) { - auto daughI = mcParticles.rawIteratorAt(arrDaughLcIndex[iProng]); - arrDaughLcPDG[iProng] = daughI.pdgCode(); - } - if (!(arrDaughLcPDG[0] == sign * arrDaughLcPDGRef[0] && arrDaughLcPDG[1] == arrDaughLcPDGRef[1] && arrDaughLcPDG[2] == arrDaughLcPDGRef[2])) { // this should be the condition, first bach, then v0 - sign = 0; - } else { - LOG(debug) << "Lc --> K0S+p found in MC table"; + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + + int8_t sign = 0; + int8_t origin = 0; + int8_t flag = 0; + + std::vector idxBhadMothers{}; + // Reject particles from background events + if (particle.fromBackgroundEvent() && rejectBackground) { + rowMcMatchGen(sign, origin, -1); + continue; + } + // checking if I have a Lc --> K0S + p + RecoDecay::isMatchedMCGen(mcParticles, particle, Pdg::kLambdaCPlus, std::array{+kProton, +kK0Short}, false, &sign, 2); + if (sign == 0) { // now check for anti-Lc + RecoDecay::isMatchedMCGen(mcParticles, particle, -Pdg::kLambdaCPlus, std::array{-kProton, +kK0Short}, false, &sign, 2); + sign = -sign; + } + if (sign != 0) { + // we check the K0S + for (const auto& daughterK0 : particle.daughters_as()) { + if (std::abs(daughterK0.pdgCode()) != kK0) { + continue; + } + for (const auto& daughterK0S : daughterK0.daughters_as()) { + if (daughterK0S.pdgCode() != kK0Short) { + continue; + } + if (RecoDecay::isMatchedMCGen(mcParticles, daughterK0S, kK0Short, std::array{+kPiPlus, -kPiPlus}, true)) { + flag = sign; + } + } } } - } - // Check whether the particle is non-prompt (from a b quark). - if (sign != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMcMatchGen(sign, origin, idxBhadMothers[0]); - } else { - rowMcMatchGen(sign, origin, -1); + // 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); + } } } } - PROCESS_SWITCH(HfCandidateCreatorCascadeMc, processMc, "Process MC data", false); + void processMc(MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorCascMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorCascadeMc, processMc, "Process MC - no centrality", false); + + void processMcCentFT0C(MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Cs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorCascMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorCascadeMc, processMcCentFT0C, "Process MC - FT0c centrality", false); + + void processMcCentFT0M(MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Ms const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorCascMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorCascadeMc, processMcCentFT0M, "Process MC - FT0m centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index e4a13157817..c343d8ce526 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -182,7 +182,7 @@ struct HfCandidateCreatorDstar { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexDstar.template collision_as(); float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -451,10 +451,10 @@ struct HfCandidateCreatorDstar { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -468,10 +468,10 @@ struct HfCandidateCreatorDstar { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -485,10 +485,10 @@ struct HfCandidateCreatorDstar { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -504,6 +504,17 @@ struct HfCandidateCreatorDstarExpressions { Produces rowsMcMatchRecDstar; Produces rowsMcMatchGenDstar; + // Configuration + o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + + using McCollisionsNoCents = soa::Join; + using McCollisionsFT0Cs = soa::Join; + using McCollisionsFT0Ms = soa::Join; + 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"}; @@ -511,6 +522,11 @@ struct HfCandidateCreatorDstarExpressions { // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) { + std::array procCollisions = {doprocessMc, doprocessMcCentFT0C, doprocessMcCentFT0M}; + if (std::accumulate(procCollisions.begin(), procCollisions.end(), 0) > 1) { + LOGP(fatal, "At most one process function for collision study can be enabled at a time."); + } + const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-dstar") == 0) { @@ -522,10 +538,12 @@ struct HfCandidateCreatorDstarExpressions { } /// Perform MC Matching. - void processMc(aod::TracksWMc const& tracks, - aod::McParticles const& mcParticles, - aod::McCollisions const&, - BCsInfo const&) + template + void runCreatorDstarMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + CCs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const&) { rowsCandidateD0->bindExternalIndices(&tracks); rowsCandidateDstar->bindExternalIndices(&tracks); @@ -550,6 +568,24 @@ struct HfCandidateCreatorDstarExpressions { auto arrayDaughtersDstar = std::array{candSoftPi, candD0.prong0_as(), candD0.prong1_as()}; auto arrayDaughtersofD0 = std::array{candD0.prong0_as(), candD0.prong1_as()}; + // Check whether the particle is from background events. If so, reject it. + if (rejectBackground) { + bool fromBkg{false}; + for (const auto& daughter : arrayDaughtersDstar) { + if (daughter.has_mcParticle()) { + auto mcParticle = daughter.mcParticle(); + if (mcParticle.fromBackgroundEvent()) { + fromBkg = true; + break; + } + } + } + if (fromBkg) { + rowsMcMatchRecDstar(flagDstar, originDstar, -1.f, 0); + continue; + } + } + // D*± → D0(bar) π± indexRecDstar = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughtersDstar, Pdg::kDStar, std::array{+kPiPlus, +kPiPlus, -kKPlus}, true, &signDstar, 2); // D0(bar) → π± K∓ @@ -580,51 +616,102 @@ struct HfCandidateCreatorDstarExpressions { rowsMcMatchRecD0(flagD0, originD0, -1.f, 0); } - // Match generated particles. - for (const auto& particle : mcParticles) { - flagDstar = 0; - flagD0 = 0; - originDstar = 0; - originD0 = 0; - std::vector idxBhadMothers{}; - - auto mcCollision = particle.mcCollision(); - - const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + for (const auto& mcCollision : mcCollisions) { + // Slice the MC 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}; + 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()); + 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(rejectionMask); if (rejectionMask != 0) { - /// at least one event selection not satisfied --> reject the gen particle - rowsMcMatchGenDstar(flagDstar, originDstar, -1); - rowsMcMatchGenD0(flagD0, originD0, -1); + // 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); + } 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)); - } - // 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)); - } + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + 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); + continue; + } - // check wether the particle is non-promt (from a B0 hadron) - if (flagDstar != 0) { - originDstar = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (flagD0 != 0) { - originD0 = RecoDecay::getCharmHadronOrigin(mcParticles, particle); - } + // 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)); + } + // 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 (originDstar == RecoDecay::OriginType::NonPrompt) { - rowsMcMatchGenDstar(flagDstar, originDstar, idxBhadMothers[0]); - } else { - rowsMcMatchGenDstar(flagDstar, originDstar, -1); + // check wether the particle is non-promt (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]); + } else { + rowsMcMatchGenDstar(flagDstar, originDstar, -1); + } + rowsMcMatchGenD0(flagD0, originD0, -1.); } - rowsMcMatchGenD0(flagD0, originD0, -1.); } } - PROCESS_SWITCH(HfCandidateCreatorDstarExpressions, processMc, "Process MC", false); + + void processMc(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsNoCents const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorDstarMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorDstarExpressions, processMc, "Process MC - no centrality", false); + + void processMcCentFT0C(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Cs const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorDstarMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorDstarExpressions, processMcCentFT0C, "Process MC - FT0c centrality", false); + + void processMcCentFT0M(aod::TracksWMc const& tracks, + aod::McParticles const& mcParticles, + McCollisionsFT0Ms const& collInfos, + aod::McCollisions const& mcCollisions, + BCsInfo const& BCsInfo) + { + runCreatorDstarMc(tracks, mcParticles, collInfos, mcCollisions, BCsInfo); + } + PROCESS_SWITCH(HfCandidateCreatorDstarExpressions, processMcCentFT0M, "Process MC - FT0m centrality", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/candidateCreatorLb.cxx b/PWGHF/TableProducer/candidateCreatorLb.cxx index 21ab291847c..a47c0bde898 100644 --- a/PWGHF/TableProducer/candidateCreatorLb.cxx +++ b/PWGHF/TableProducer/candidateCreatorLb.cxx @@ -255,7 +255,7 @@ struct HfCandidateCreatorLbExpressions { /// @brief dummy process function, to be run on data void process(aod::Tracks const&) {} - void processMc(aod::HfCand3Prong const&, + void processMc(aod::HfCand3Prong const& lcCandidates, aod::TracksWMc const& tracks, aod::McParticles const& mcParticles) { @@ -266,6 +266,7 @@ struct HfCandidateCreatorLbExpressions { int8_t debug = 0; rowCandidateLb->bindExternalIndices(&tracks); + rowCandidateLb->bindExternalIndices(&lcCandidates); // Match reconstructed candidates. for (const auto& candidate : *rowCandidateLb) { diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 164c01a6bcd..199dc5c7477 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -12,6 +12,23 @@ /// \file candidateCreatorXic0Omegac0.cxx /// \brief Reconstruction of Omegac0 and Xic0 decays candidates /// \author Federica Zanone , Heidelberg University +/// \author Yunfan Liu , China University of Geosciences + +#ifndef HomogeneousField +#define HomogeneousField +#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" @@ -32,6 +49,7 @@ #include "Common/Core/trackUtilities.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" +#include "Tools/KFparticle/KFUtilities.h" #include "PWGLF/DataModel/LFStrangenessTables.h" @@ -60,6 +78,7 @@ struct HfCandidateCreatorXic0Omegac0 { Produces rowCandToXiPi; Produces rowCandToOmegaPi; Produces rowCandToOmegaK; + Produces kfCandidateData; Configurable propagateToPCA{"propagateToPCA", false, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; @@ -80,6 +99,16 @@ struct HfCandidateCreatorXic0Omegac0 { 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)"}; + // KFParticle process setting + // V0 cuts + Configurable lambdaMassWindow{"lambdaMassWindow", 0.0075, "Distance from Lambda mass"}; + // cascade cuts + Configurable massToleranceCascade{"massToleranceCascade", 0.01, "Invariant mass tolerance for cascade"}; + // 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"}; + HfEventSelection hfEvSel; // event selection and monitoring o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter to build the omegac/xic vertex Service ccdb; @@ -88,26 +117,78 @@ struct HfCandidateCreatorXic0Omegac0 { int runNumber{-1}; double magneticField{0.}; - using MyCascTable = soa::Join; // to use strangeness tracking, use aod::TraCascDatas instead of aod::CascDatas + using MyCascTable = soa::Join; + using MyTraCascTable = soa::Join; // to use strangeness tracking using CascadesLinked = soa::Join; + using TraCascadesLinked = soa::Join; using MyV0Table = soa::Join; + using MyLFTracksWCov = soa::Join; + + using MyKfTracks = soa::Join; + using MyKfCascTable = soa::Join; + using KFCascadesLinked = soa::Join; std::shared_ptr hInvMassCharmBaryonToXiPi, hInvMassCharmBaryonToOmegaPi, hInvMassCharmBaryonToOmegaK, hFitterStatusToXiPi, hFitterStatusToOmegaPi, hFitterStatusToOmegaK, hCandidateCounterToXiPi, hCandidateCounterToOmegaPi, hCandidateCounterToOmegaK, hCascadesCounterToXiPi, hCascadesCounterToOmegaPi, hCascadesCounterToOmegaK; HistogramRegistry registry{"registry"}; - + // Helper struct to pass information + struct { + float chi2GeoV0; + float ldlV0; + float chi2TopoV0ToPv; + float chi2GeoCasc; + float ldlCasc; + float chi2TopoCascToPv; + float decayLenXYLambda; + float decayLenXYCasc; + float cosPaV0ToCasc; + float cosPaXYV0ToCasc; + float cosPaV0ToPv; + float cosPaXYV0ToPv; + float cosPaCascToOmegac; + float cosPaXYCascToOmegac; + float cosPaCascToPv; + float cosPaXYCascToPv; + float massV0; + float massCasc; + float ptPiFromOmegac; + float ptOmegac; + float rapOmegac; + float massOmegac; + float cosThetaStarPiFromOmegac; + float chi2TopoPiFromOmegacToPv; + float kfDcaXYPiFromOmegac; + float chi2TopoV0ToCasc; + float chi2TopoCascToOmegac; + float decayLenXYOmegac; + float chi2GeoOmegac; + float kfDcaV0Dau; + float kfDcaCascDau; + float kfDcaOmegacDau; + float kfDcaXYCascToPv; + float chi2TopoOmegacToPv; + float cosPaOmegacToPv; + float cosPaXYOmegacToPv; + float ldlOmegac; + float ctV0; + float ctCasc; + float ctOmegac; + float chi2MassV0; + float chi2MassCasc; + float etaOmegac; + } kfOmegac0Candidate; void init(InitContext const&) { - std::array allProcesses = {doprocessNoCentToXiPi, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessNoCentToOmegaPi, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessNoCentToOmegaK, doprocessCentFT0CToOmegaK, doprocessCentFT0MToOmegaK}; + std::array allProcesses = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi, doprocessNoCentToOmegaPi, doprocessOmegacToOmegaPiWithKFParticle, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessNoCentToOmegaK, doprocessCentFT0CToOmegaK, doprocessCentFT0MToOmegaK}; 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, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi}; + std::array processesToXiPi = {doprocessNoCentToXiPi, doprocessNoCentToXiPiTraCasc, doprocessCentFT0CToXiPi, doprocessCentFT0MToXiPi}; 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}; + std::array processesToOmegaPi = {doprocessNoCentToOmegaPi, doprocessCentFT0CToOmegaPi, doprocessCentFT0MToOmegaPi, doprocessOmegacToOmegaPiWithKFParticle}; if (std::accumulate(processesToOmegaPi.begin(), processesToOmegaPi.end(), 0) > 1) { LOGP(fatal, "One and only one process ToOmegaPi function must be enabled at a time."); } @@ -122,7 +203,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) || (doprocessNoCentToOmegaPi && !doprocessCollisions) || (doprocessNoCentToOmegaK && !doprocessCollisions)) { + if ((doprocessNoCentToXiPi && !doprocessCollisions) || (doprocessNoCentToXiPiTraCasc && !doprocessCollisions) || (doprocessNoCentToOmegaPi && !doprocessCollisions) || (doprocessNoCentToOmegaK && !doprocessCollisions) || (doprocessOmegacToOmegaPiWithKFParticle && !doprocessCollisions)) { LOGP(fatal, "Process function for collision monitoring not correctly enabled. Did you enable \"processCollisions\"?"); } if ((doprocessCentFT0CToXiPi && !doprocessCollisionsCentFT0C) || (doprocessCentFT0CToOmegaPi && !doprocessCollisionsCentFT0C) || (doprocessCentFT0CToOmegaK && !doprocessCollisionsCentFT0C)) { @@ -146,6 +227,19 @@ struct HfCandidateCreatorXic0Omegac0 { hCascadesCounterToOmegaPi = registry.add("hCascadesCounterToOmegaPi", "Cascades counter wrt derived data - #Omega #pi decay;status;entries", {HistType::kTH1F, {{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::kTH1F, {{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 + registry.add("hKFParticleV0TopoChi2", "hKFParticleV0TopoChi2", kTH1F, {{1000, -0.10f, 100.0f}}); + registry.add("hKFParticleCascTopoChi2", "hKFParticleCascTopoChi2", kTH1F, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleCascBachTopoChi2", "hKFParticleCascBachTopoChi2", kTH1F, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleDcaCharmBaryonDau", "hKFParticleDcaCharmBaryonDau", kTH1F, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleDcaXYV0DauToPv", "hKFParticleDcaXYV0DauToPv", kTH1F, {{1000, -0.1f, 100.0f}}); + registry.add("hKFParticleDcaXYCascBachToPv", "hKFParticleDcaXYCascBachToPv", kTH1F, {{1000, -0.1f, 100.0f}}); + registry.add("hKfLambda_ldl", "hKfLambda_ldl", kTH1F, {{1000, 0.0f, 1000.0f}}); + registry.add("hKfOmega_ldl", "hKfOmega_ldl", kTH1F, {{1000, 0.0f, 1000.0f}}); + registry.add("hKfOmegaC0_ldl", "hKfOmegaC0_ldl", kTH1F, {{1000, 0.0f, 1000.0f}}); + registry.add("hDcaXYCascadeToPVKf", "hDcaXYCascadeToPVKf", kTH1F, {{1000, 0.0f, 2.0f}}); + registry.add("hInvMassOmegaMinus", "hInvMassOmegaMinus", kTH1F, {{1000, 1.6f, 2.0f}}); + hfEvSel.addHistograms(registry); // collision monitoring df.setPropagateToPCA(propagateToPCA); @@ -166,11 +260,12 @@ struct HfCandidateCreatorXic0Omegac0 { runNumber = 0; } - template + template void runXic0Omegac0Creator(Coll const&, aod::BCsWithTimestamps const& /*bcWithTimeStamps*/, - TracksWCovDca const&, - MyCascTable const&, CascadesLinked const&, + MyLFTracksWCov const& lfTracks, + TracksWCovDca const& tracks, + TCascTable const&, TCascLinkTable const&, aod::HfCascLf2Prongs const& candidates, Hist& hInvMassCharmBaryon, Hist& hFitterStatus, @@ -204,7 +299,7 @@ struct HfCandidateCreatorXic0Omegac0 { auto collision = cand.collision_as(); float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectionMask != 0) { /// at least one event selection not satisfied --> reject the candidate continue; @@ -221,24 +316,49 @@ struct HfCandidateCreatorXic0Omegac0 { } df.setBz(magneticField); - auto trackCharmBachelor = cand.prong0_as(); + auto trackCharmBachelorId = cand.prong0Id(); + auto trackCharmBachelor = tracks.rawIteratorAt(trackCharmBachelorId); - auto cascAodElement = cand.cascade_as(); + auto cascAodElement = cand.template cascade_as(); hCascadesCounter->Fill(0); int v0index = cascAodElement.v0Id(); - if (!cascAodElement.has_cascData()) { + + // check if the cascade from AO2D has data + bool hasData = false; + if constexpr (requires { cascAodElement.cascDataId(); }) { // check if it's the CascDataLink + if (cascAodElement.has_cascData()) { + hasData = true; + } + } + if constexpr (requires { cascAodElement.traCascDataId(); }) { // check if it's the TraCascDataLink + if (cascAodElement.has_traCascData()) { + hasData = true; + } + } + if (!hasData) { continue; } - auto casc = cascAodElement.cascData_as(); + + typename TCascTable::iterator casc; + if constexpr (requires { cascAodElement.cascDataId(); }) { // check if it's the CascDataLink + casc = cascAodElement.template cascData_as(); + } + if constexpr (requires { cascAodElement.traCascDataId(); }) { // check if it's the TraCascDataLink + casc = cascAodElement.template traCascData_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(); // pion <- xi track + auto trackV0Dau0Id = casc.posTrackId(); // V0 positive daughter track + auto trackV0Dau1Id = casc.negTrackId(); // V0 negative daughter track + auto trackCascDauCharged = lfTracks.rawIteratorAt(trackCascDauChargedId); // pion <- xi track + auto trackV0Dau0 = lfTracks.rawIteratorAt(trackV0Dau0Id); // V0 positive daughter track + auto trackV0Dau1 = lfTracks.rawIteratorAt(trackV0Dau1Id); // V0 negative daughter track //-------------------------- V0 info--------------------------- // pseudorapidity - float pseudorapV0Dau0 = trackV0Dau0.eta(); - float pseudorapV0Dau1 = trackV0Dau1.eta(); + float pseudorapV0Dau0 = casc.positiveeta(); + float pseudorapV0Dau1 = casc.negativeeta(); // info from LF table std::array pVecV0 = {casc.pxlambda(), casc.pylambda(), casc.pzlambda()}; @@ -248,7 +368,7 @@ struct HfCandidateCreatorXic0Omegac0 { //-------------------reconstruct cascade track------------------ // pseudorapidity - float pseudorapCascBachelor = trackCascDauCharged.eta(); + float pseudorapCascBachelor = casc.bacheloreta(); // info from LF table std::array vertexCasc = {casc.x(), casc.y(), casc.z()}; @@ -312,20 +432,27 @@ struct HfCandidateCreatorXic0Omegac0 { // pseudorapidity float pseudorapCharmBachelor = trackCharmBachelor.eta(); - // DCAxy (computed with propagateToDCABxByBz method) - float dcaxyV0Dau0 = trackV0Dau0.dcaXY(); - float dcaxyV0Dau1 = trackV0Dau1.dcaXY(); - float dcaxyCascBachelor = trackCascDauCharged.dcaXY(); - - // DCAz (computed with propagateToDCABxByBz method) - float dcazV0Dau0 = trackV0Dau0.dcaZ(); - float dcazV0Dau1 = trackV0Dau1.dcaZ(); - float dcazCascBachelor = trackCascDauCharged.dcaZ(); - // primary vertex of the collision auto primaryVertex = getPrimaryVertex(collision); // get the associated covariance matrix with auto covMatrixPV = primaryVertex.getCov(); std::array pvCoord = {collision.posX(), collision.posY(), collision.posZ()}; + // DCAxy and DCAz (computed with propagateToDCABxByBz method) + o2::dataformats::DCA impactParameterV0Dau0; + o2::dataformats::DCA impactParameterV0Dau1; + o2::dataformats::DCA impactParameterCascDauCharged; + auto trackParVarV0Dau0 = getTrackParCov(trackV0Dau0); + auto trackParVarV0Dau1 = getTrackParCov(trackV0Dau1); + auto trackParVarCascDauCharged = getTrackParCov(trackCascDauCharged); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParVarV0Dau0, 2.f, matCorr, &impactParameterV0Dau0); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParVarV0Dau1, 2.f, matCorr, &impactParameterV0Dau1); + o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParVarCascDauCharged, 2.f, matCorr, &impactParameterCascDauCharged); + float dcaxyV0Dau0 = impactParameterV0Dau0.getY(); + float dcaxyV0Dau1 = impactParameterV0Dau1.getY(); + float dcaxyCascBachelor = impactParameterCascDauCharged.getY(); + float dcazV0Dau0 = impactParameterV0Dau0.getZ(); + float dcazV0Dau1 = impactParameterV0Dau1.getZ(); + float dcazCascBachelor = impactParameterCascDauCharged.getZ(); + // impact parameters o2::dataformats::DCA impactParameterCasc; o2::dataformats::DCA impactParameterCharmBachelor; @@ -404,7 +531,7 @@ struct HfCandidateCreatorXic0Omegac0 { trackCascDauCharged.sign(), covVtxCharmBaryon[0], covVtxCharmBaryon[1], covVtxCharmBaryon[2], covVtxCharmBaryon[3], covVtxCharmBaryon[4], covVtxCharmBaryon[5], pVecCharmBaryon[0], pVecCharmBaryon[1], pVecCharmBaryon[2], - pVecCasc[0], pVecCasc[1], pVecCasc[2], + pVecCascAsD[0], pVecCascAsD[1], pVecCascAsD[2], pVecCharmBachelorAsD[0], pVecCharmBachelorAsD[1], pVecCharmBachelorAsD[2], pVecV0[0], pVecV0[1], pVecV0[2], pVecCascBachelor[0], pVecCascBachelor[1], pVecCascBachelor[2], @@ -434,7 +561,7 @@ struct HfCandidateCreatorXic0Omegac0 { trackCascDauCharged.sign(), covVtxCharmBaryon[0], covVtxCharmBaryon[1], covVtxCharmBaryon[2], covVtxCharmBaryon[3], covVtxCharmBaryon[4], covVtxCharmBaryon[5], pVecCharmBaryon[0], pVecCharmBaryon[1], pVecCharmBaryon[2], - pVecCasc[0], pVecCasc[1], pVecCasc[2], + pVecCascAsD[0], pVecCascAsD[1], pVecCascAsD[2], pVecCharmBachelorAsD[0], pVecCharmBachelorAsD[1], pVecCharmBachelorAsD[2], pVecV0[0], pVecV0[1], pVecV0[2], pVecCascBachelor[0], pVecCascBachelor[1], pVecCascBachelor[2], @@ -464,7 +591,7 @@ struct HfCandidateCreatorXic0Omegac0 { trackCascDauCharged.sign(), covVtxCharmBaryon[0], covVtxCharmBaryon[1], covVtxCharmBaryon[2], covVtxCharmBaryon[3], covVtxCharmBaryon[4], covVtxCharmBaryon[5], pVecCharmBaryon[0], pVecCharmBaryon[1], pVecCharmBaryon[2], - pVecCasc[0], pVecCasc[1], pVecCasc[2], + pVecCascAsD[0], pVecCascAsD[1], pVecCascAsD[2], pVecCharmBachelorAsD[0], pVecCharmBachelorAsD[1], pVecCharmBachelorAsD[2], pVecV0[0], pVecV0[1], pVecV0[2], pVecCascBachelor[0], pVecCascBachelor[1], pVecCascBachelor[2], @@ -489,37 +616,488 @@ struct HfCandidateCreatorXic0Omegac0 { } // loop over LF Cascade-bachelor candidates } // end of run function + template + void runKfOmegac0CreatorWithKFParticle(Coll const&, + aod::BCsWithTimestamps const& /*bcWithTimeStamps*/, + MyKfTracks const&, + MyKfCascTable const&, KFCascadesLinked const&, + aod::HfCascLf2Prongs const& candidates, + Hist& hInvMassCharmBaryon, + Hist& hFitterStatus, + Hist& hCandidateCounter, + Hist& hCascadesCounter) + { + for (const auto& cand : candidates) { + hCandidateCounter->Fill(1); + + auto collision = cand.collision_as(); + + // 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(); + } + df.setBz(magneticField); + KFParticle::SetField(magneticField); + // bachelor from Omegac0 + auto trackCharmBachelor = cand.prong0_as(); + + auto cascAodElement = cand.cascade_as(); + hCascadesCounter->Fill(0); + int v0index = cascAodElement.v0Id(); + if (!cascAodElement.has_kfCascData()) { + continue; + } + 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 bachCharge = trackCascDauCharged.signed1Pt() > 0 ? +1 : -1; + + //// pion & p TrackParCov + auto trackParCovV0Dau0 = getTrackParCov(trackV0Dau0); + auto trackParCovV0Dau1 = getTrackParCov(trackV0Dau1); + // kaon <- casc TrackParCov + auto omegaDauChargedTrackParCov = getTrackParCov(trackCascDauCharged); + // convert tracks into KFParticle object + KFPTrack kfTrack0 = createKFPTrackFromTrack(trackV0Dau0); + KFPTrack kfTrack1 = createKFPTrackFromTrack(trackV0Dau1); + KFPTrack kfTrackBach = createKFPTrackFromTrack(trackCascDauCharged); + + KFParticle kfPosPr(kfTrack0, kProton); + KFParticle kfNegPi(kfTrack1, kPiMinus); + KFParticle kfNegKa(kfTrackBach, kKMinus); + KFParticle kfPosPi(kfTrack0, kPiPlus); + KFParticle kfNegPr(kfTrack1, kProton); + KFParticle kfPosKa(kfTrackBach, kKPlus); + + KFParticle kfBachKaon; + KFParticle kfPos; + KFParticle kfNeg; + if (bachCharge < 0) { + kfPos = kfPosPr; + kfNeg = kfNegPi; + kfBachKaon = kfNegKa; + } else { + kfPos = kfPosPi; + kfNeg = kfNegPr; + kfBachKaon = kfPosKa; + } + + //__________________________________________ + //*>~<* step 1 : construct V0 with KF + const KFParticle* v0Daughters[2] = {&kfPos, &kfNeg}; + // 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 (TMath::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 + if (kfUseV0MassConstraint) { + KFParticle kfV0 = kfV0MassConstrained; + } + kfV0.TransportToDecayVertex(); + + //__________________________________________ + //*>~<* step 2 : reconstruct cascade(Omega) with KF + const KFParticle* omegaDaugthers[2] = {&kfBachKaon, &kfV0}; + // construct cascade + KFParticle kfOmega; + kfOmega.SetConstructMethod(kfConstructMethod); + try { + kfOmega.Construct(omegaDaugthers, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct Omega from V0 and bachelor track: " << e.what(); + continue; + } + float massCasc, sigCasc; + kfOmega.GetMass(massCasc, sigCasc); + // 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(); + KFParticle kfOmegaMassConstrained = kfOmega; + kfOmegaMassConstrained.SetNonlinearMassConstraint(o2::constants::physics::MassOmegaMinus); // set mass constrain to OmegaMinus + if (kfUseCascadeMassConstraint) { + // set mass constraint if requested + KFParticle kfOmega = kfOmegaMassConstrained; + } + registry.fill(HIST("hInvMassOmegaMinus"), massCasc); + kfOmega.TransportToDecayVertex(); + + //__________________________________________ + //*>~<* step 3 : reconstruc Omegac0 with KF + // Create KF charm bach Pion from track + KFPTrack kfTrackBachPion = createKFPTrackFromTrack(trackCharmBachelor); + KFParticle kfBachPion(kfTrackBachPion, kPiPlus); + const KFParticle* omegaC0Daugthers[2] = {&kfBachPion, &kfOmega}; + + // construct OmegaC0 + KFParticle kfOmegaC0; + kfOmegaC0.SetConstructMethod(kfConstructMethod); + try { + kfOmegaC0.Construct(omegaC0Daugthers, 2); + } catch (std::runtime_error& e) { + LOG(debug) << "Failed to construct OmegaC0 from Cascade and bachelor pion track: " << e.what(); + continue; + } + float massOmegaC0, sigOmegaC0; + 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(); + // PV + KFPVertex kfVertex = createKFPVertexFromCollision(collision); + KFParticle kfPV(kfVertex); + + // set production vertex; + kfNeg.SetProductionVertex(kfV0); + kfPos.SetProductionVertex(kfV0); + + KFParticle kfBachKaonToOmega = kfBachKaon; + KFParticle kfV0ToCasc = kfV0; + kfBachKaonToOmega.SetProductionVertex(kfOmega); + kfV0ToCasc.SetProductionVertex(kfOmega); + + KFParticle kfOmegaToOmegaC = kfOmega; + KFParticle kfBachPionToOmegaC = kfBachPion; + kfBachPionToOmegaC.SetProductionVertex(kfOmegaC0); + kfOmegaToOmegaC.SetProductionVertex(kfOmegaC0); + + // KFParticle to PV + KFParticle kfV0ToPv = kfV0; + KFParticle kfOmegaToPv = kfOmega; + KFParticle kfOmegac0ToPv = kfOmegaC0; + KFParticle kfPiFromOmegacToPv = kfBachPion; + + kfV0ToPv.SetProductionVertex(kfPV); + kfOmegaToPv.SetProductionVertex(kfPV); + kfOmegac0ToPv.SetProductionVertex(kfPV); + kfPiFromOmegacToPv.SetProductionVertex(kfPV); + //------------get updated daughter tracks after vertex fit --------------- + auto trackParVarCharmBachelor = getTrackParCovFromKFP(kfBachPionToOmegaC, o2::track::PID::Pion, -bachCharge); // chrambaryon bach pion + trackParVarCharmBachelor.setAbsCharge(1); + + omegaDauChargedTrackParCov = getTrackParCovFromKFP(kfBachKaonToOmega, o2::track::PID::Kaon, bachCharge); // Cascade bach kaon + omegaDauChargedTrackParCov.setAbsCharge(1); + o2::track::TrackParCov trackCasc = getTrackParCovFromKFP(kfOmegaToOmegaC, kfOmegaToOmegaC.GetPDG(), bachCharge); + trackCasc.setAbsCharge(1); + + trackParCovV0Dau0 = getTrackParCovFromKFP(kfPos, kfPos.GetPDG(), 1); // V0 postive daughter + trackParCovV0Dau0.setAbsCharge(1); + trackParCovV0Dau1 = getTrackParCovFromKFP(kfNeg, kfNeg.GetPDG(), -1); // V0 negtive daughter + trackParCovV0Dau1.setAbsCharge(1); + + //-------------------------- V0 info--------------------------- + // pseudorapidity + float pseudorapV0Dau0 = kfPos.GetEta(); + float pseudorapV0Dau1 = kfNeg.GetEta(); + + // info from from KFParticle + std::array pVecV0 = {kfV0.GetPx(), kfV0.GetPy(), kfV0.GetPz()}; // pVec stands for vector containing the 3-momentum components + std::array vertexV0 = {kfV0.GetX(), kfV0.GetY(), kfV0.GetZ()}; + std::array pVecV0Dau0 = {kfPos.GetPx(), kfPos.GetPy(), kfPos.GetPz()}; + std::array pVecV0Dau1 = {kfNeg.GetPx(), kfNeg.GetPy(), kfNeg.GetPz()}; + + //-------------------reconstruct cascade track------------------ + // pseudorapidity + float pseudorapCascBachelor = kfBachKaonToOmega.GetEta(); + + // info from KFParticle + std::array vertexCasc = {kfOmega.GetX(), kfOmega.GetY(), kfOmega.GetZ()}; + std::array pVecCascBachelor = {kfBachKaonToOmega.GetPx(), kfBachKaonToOmega.GetPy(), kfBachKaonToOmega.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] = kfBachPionToOmegaC.GetPx(); + pVecCharmBachelorAsD[1] = kfBachPionToOmegaC.GetPy(); + pVecCharmBachelorAsD[2] = kfBachPionToOmegaC.GetPz(); + + std::array pVecCharmBaryon = {kfOmegaC0.GetPx(), kfOmegaC0.GetPy(), kfOmegaC0.GetPz()}; + std::array coordVtxCharmBaryon = {kfOmegaC0.GetX(), kfOmegaC0.GetY(), kfOmegaC0.GetZ()}; + auto covVtxCharmBaryon = kfOmegaC0.CovarianceMatrix(); + float covMatrixPV[6]; + kfVertex.GetCovarianceMatrix(covMatrixPV); + + // impact parameters + gpu::gpustd::array impactParameterV0Dau0; + gpu::gpustd::array impactParameterV0Dau1; + gpu::gpustd::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); + float dcaxyV0Dau0 = impactParameterV0Dau0[0]; + float dcaxyV0Dau1 = impactParameterV0Dau1[0]; + float dcaxyCascBachelor = impactParameterKaFromCasc[0]; + float dcazV0Dau0 = impactParameterV0Dau0[1]; + float dcazV0Dau1 = impactParameterV0Dau1[1]; + float dcazCascBachelor = impactParameterKaFromCasc[1]; + + // pseudorapidity + float pseudorapCharmBachelor = kfBachPionToOmegaC.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(massOmegaC0); + hCandidateCounter->Fill(3); + + //// KFParticle table information + // KF chi2 + auto v0NDF = kfV0.GetNDF(); + auto v0Chi2OverNdf = kfOmegac0Candidate.chi2GeoV0 / v0NDF; + + auto cascNDF = kfOmega.GetNDF(); + auto cascChi2OverNdf = kfOmegac0Candidate.chi2GeoCasc / cascNDF; + + kfOmegac0Candidate.chi2GeoOmegac = kfOmegaC0.GetChi2(); + auto charmbaryonNDF = kfOmegaC0.GetNDF(); + auto charmbaryonChi2OverNdf = kfOmegac0Candidate.chi2GeoOmegac / charmbaryonNDF; + + kfOmegac0Candidate.chi2MassV0 = kfV0MassConstrained.GetChi2(); + auto v0NDF_m = kfV0MassConstrained.GetNDF(); + auto v0Chi2OverNdf_m = kfOmegac0Candidate.chi2MassV0 / v0NDF_m; + + kfOmegac0Candidate.chi2MassCasc = kfOmegaMassConstrained.GetChi2(); + auto cascNDF_m = kfOmegaMassConstrained.GetNDF(); + auto cascChi2OverNdf_m = kfOmegac0Candidate.chi2MassCasc / cascNDF_m; + + // KF topo Chi2 + kfOmegac0Candidate.chi2TopoV0ToPv = kfV0ToPv.GetChi2(); + kfOmegac0Candidate.chi2TopoCascToPv = kfOmegaToPv.GetChi2(); + kfOmegac0Candidate.chi2TopoPiFromOmegacToPv = kfPiFromOmegacToPv.GetChi2(); + kfOmegac0Candidate.chi2TopoOmegacToPv = kfOmegac0ToPv.GetChi2(); + + auto cascBachTopoChi2 = kfBachKaonToOmega.GetChi2(); + kfOmegac0Candidate.chi2TopoV0ToCasc = kfV0ToCasc.GetChi2(); + kfOmegac0Candidate.chi2TopoCascToOmegac = kfOmegaToOmegaC.GetChi2(); + + // KF ldl + kfOmegac0Candidate.ldlV0 = ldlFromKF(kfV0, kfPV); + kfOmegac0Candidate.ldlCasc = ldlFromKF(kfOmega, kfPV); + kfOmegac0Candidate.ldlOmegac = ldlFromKF(kfOmegaC0, kfPV); + + // KF dca + kfOmegac0Candidate.kfDcaXYPiFromOmegac = kfBachPionToOmegaC.GetDistanceFromVertexXY(kfPV); + kfOmegac0Candidate.kfDcaV0Dau = kfNeg.GetDistanceFromParticle(kfPos); + kfOmegac0Candidate.kfDcaCascDau = kfBachKaonToOmega.GetDistanceFromParticle(kfV0ToCasc); + kfOmegac0Candidate.kfDcaXYCascToPv = kfOmegaToOmegaC.GetDistanceFromVertexXY(kfPV); + kfOmegac0Candidate.kfDcaOmegacDau = kfBachPionToOmegaC.GetDistanceFromParticle(kfOmegaToOmegaC); + + // KF decay length + float DecayLxy_Lam, err_DecayLxy_Lam; + kfV0ToCasc.GetDecayLengthXY(DecayLxy_Lam, err_DecayLxy_Lam); + kfOmegac0Candidate.decayLenXYLambda = DecayLxy_Lam; + + float DecayLxy_Casc, err_DecayLxy_Casc; + kfOmegaToOmegaC.GetDecayLengthXY(DecayLxy_Casc, err_DecayLxy_Casc); + kfOmegac0Candidate.decayLenXYCasc = DecayLxy_Casc; + + float DecayLxy_Omegac0, err_DecayLxy_Omegac0; + kfOmegac0ToPv.GetDecayLengthXY(DecayLxy_Omegac0, err_DecayLxy_Omegac0); + kfOmegac0Candidate.decayLenXYOmegac = DecayLxy_Omegac0; + + // KF cosPA + kfOmegac0Candidate.cosPaV0ToPv = cpaFromKF(kfV0, kfPV); + kfOmegac0Candidate.cosPaCascToPv = cpaFromKF(kfOmega, kfPV); + kfOmegac0Candidate.cosPaOmegacToPv = cpaFromKF(kfOmegaC0, kfPV); + kfOmegac0Candidate.cosPaXYV0ToPv = cpaXYFromKF(kfV0, kfPV); + kfOmegac0Candidate.cosPaXYCascToPv = cpaXYFromKF(kfOmega, kfPV); + kfOmegac0Candidate.cosPaXYOmegacToPv = cpaXYFromKF(kfOmegaC0, kfPV); + + kfOmegac0Candidate.cosPaV0ToCasc = cpaFromKF(kfV0, kfOmega); + kfOmegac0Candidate.cosPaCascToOmegac = cpaFromKF(kfOmega, kfOmegaC0); + kfOmegac0Candidate.cosPaXYV0ToCasc = cpaXYFromKF(kfV0, kfOmega); + kfOmegac0Candidate.cosPaXYCascToOmegac = cpaXYFromKF(kfOmega, kfOmegaC0); + // KF mass + kfOmegac0Candidate.massV0 = massLam; + kfOmegac0Candidate.massCasc = massCasc; + kfOmegac0Candidate.massOmegac = massOmegaC0; + + // KF pT + kfOmegac0Candidate.ptPiFromOmegac = kfBachPionToOmegaC.GetPt(); + kfOmegac0Candidate.ptOmegac = kfOmegaC0.GetPt(); + + // KF rapidity + kfOmegac0Candidate.rapOmegac = kfOmegaC0.GetRapidity(); + + // KF cosThetaStar + kfOmegac0Candidate.cosThetaStarPiFromOmegac = cosThetaStarFromKF(0, 4332, 211, 3312, kfBachPionToOmegaC, kfOmegaToOmegaC); + + // KF ct + kfOmegac0Candidate.ctV0 = kfV0.GetLifeTime(); + kfOmegac0Candidate.ctCasc = kfOmega.GetLifeTime(); + kfOmegac0Candidate.ctOmegac = kfOmegaC0.GetLifeTime(); + + // KF eta + 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("hKFParticleDcaCharmBaryonDau"), kfOmegac0Candidate.kfDcaOmegacDau); + registry.fill(HIST("hKFParticleDcaXYCascBachToPv"), dcaxyCascBachelor); + registry.fill(HIST("hKFParticleDcaXYV0DauToPv"), dcaxyV0Dau0); + 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); + + // fill the table + rowCandToOmegaPi(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(), + covVtxCharmBaryon[0], covVtxCharmBaryon[1], covVtxCharmBaryon[2], covVtxCharmBaryon[3], covVtxCharmBaryon[4], covVtxCharmBaryon[5], + pVecCharmBaryon[0], pVecCharmBaryon[1], pVecCharmBaryon[2], + kfOmegaToOmegaC.GetPx(), kfOmegaToOmegaC.GetPy(), kfOmegaToOmegaC.GetPz(), + pVecCharmBachelorAsD[0], pVecCharmBachelorAsD[1], pVecCharmBachelorAsD[2], + pVecV0[0], pVecV0[1], pVecV0[2], + 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(), + kfOmegac0Candidate.massV0, kfOmegac0Candidate.massCasc, kfOmegac0Candidate.massOmegac, + kfOmegac0Candidate.cosPaV0ToPv, kfOmegac0Candidate.cosPaOmegacToPv, kfOmegac0Candidate.cosPaCascToPv, kfOmegac0Candidate.cosPaXYV0ToPv, kfOmegac0Candidate.cosPaXYOmegacToPv, kfOmegac0Candidate.cosPaXYCascToPv, + kfOmegac0Candidate.ctOmegac, kfOmegac0Candidate.ctCasc, kfOmegac0Candidate.ctV0, + pseudorapV0Dau0, pseudorapV0Dau1, pseudorapCascBachelor, pseudorapCharmBachelor, + kfOmegac0Candidate.etaOmegac, kfOmega.GetEta(), kfV0.GetEta(), + dcaxyV0Dau0, dcaxyV0Dau1, dcaxyCascBachelor, + dcazV0Dau0, dcazV0Dau1, dcazCascBachelor, + kfOmegac0Candidate.kfDcaCascDau, kfOmegac0Candidate.kfDcaV0Dau, kfOmegac0Candidate.kfDcaOmegacDau, + decLenCharmBaryon, decLenCascade, decLenV0, errorDecayLengthCharmBaryon, errorDecayLengthXYCharmBaryon); + // 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.decayLenXYLambda, kfOmegac0Candidate.decayLenXYCasc, kfOmegac0Candidate.decayLenXYOmegac, + kfOmegac0Candidate.cosPaV0ToCasc, kfOmegac0Candidate.cosPaCascToOmegac, kfOmegac0Candidate.cosPaXYV0ToCasc, kfOmegac0Candidate.cosPaXYCascToOmegac, + kfOmegac0Candidate.rapOmegac, kfOmegac0Candidate.ptPiFromOmegac, kfOmegac0Candidate.ptOmegac, + kfOmegac0Candidate.cosThetaStarPiFromOmegac, + v0NDF, cascNDF, charmbaryonNDF, v0NDF_m, cascNDF_m, + v0Chi2OverNdf, cascChi2OverNdf, charmbaryonChi2OverNdf, v0Chi2OverNdf_m, cascChi2OverNdf_m); + + } // loop over LF Cascade-bachelor candidates + } // end of run function + /// @brief process function w/o centrality selections void processNoCentToXiPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentToXiPi, "Run candidate creator w/o centrality selections for xi pi decay channel", true); + void processNoCentToXiPiTraCasc(soa::Join const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, + MyTraCascTable const& traCascades, + TraCascadesLinked const& traCascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, traCascades, traCascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentToXiPiTraCasc, "Run candidate creator w/o centrality selections for xi pi decay channel with tracked cascades", false); + void processNoCentToOmegaPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentToOmegaPi, "Run candidate creator w/o centrality selections for omega pi decay channel", false); + void processOmegacToOmegaPiWithKFParticle(aod::Collisions const& collisions, + aod::BCsWithTimestamps const& bcWithTimeStamps, + MyKfTracks const& tracks, + MyKfCascTable const& cascades, + KFCascadesLinked const& cascadeLinks, + aod::HfCascLf2Prongs const& candidates) + { + runKfOmegac0CreatorWithKFParticle(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processOmegacToOmegaPiWithKFParticle, "Run candidate creator w/o centrality selections for Omegac0 To omega pi decay channel using KFParticle", false); + void processNoCentToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processNoCentToOmegaK, "Run candidate creator w/o centrality selections for omega K decay channel", false); @@ -527,33 +1105,36 @@ struct HfCandidateCreatorXic0Omegac0 { void processCentFT0CToXiPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0CToXiPi, "Run candidate creator w/ centrality selection on FT0C for xi pi channel", false); void processCentFT0CToOmegaPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0CToOmegaPi, "Run candidate creator w/ centrality selection on FT0C for omega pi channel", false); void processCentFT0CToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0CToOmegaK, "Run candidate creator w/ centrality selection on FT0C for omega K channel", false); @@ -561,33 +1142,36 @@ struct HfCandidateCreatorXic0Omegac0 { void processCentFT0MToXiPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToXiPi, hFitterStatusToXiPi, hCandidateCounterToXiPi, hCascadesCounterToXiPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MToXiPi, "Run candidate creator w/ centrality selection on FT0M for xi pi channel", false); void processCentFT0MToOmegaPi(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaPi, hFitterStatusToOmegaPi, hCandidateCounterToOmegaPi, hCascadesCounterToOmegaPi); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MToOmegaPi, "Run candidate creator w/ centrality selection on FT0M for omega pi channel", false); void processCentFT0MToOmegaK(soa::Join const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, TracksWCovDca const& tracks, + MyLFTracksWCov const& lfTracks, MyCascTable const& cascades, CascadesLinked const& cascadeLinks, aod::HfCascLf2Prongs const& candidates) { - runXic0Omegac0Creator(collisions, bcWithTimeStamps, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); + runXic0Omegac0Creator(collisions, bcWithTimeStamps, lfTracks, tracks, cascades, cascadeLinks, candidates, hInvMassCharmBaryonToOmegaK, hFitterStatusToOmegaK, hCandidateCounterToOmegaK, hCascadesCounterToOmegaK); } PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0, processCentFT0MToOmegaK, "Run candidate creator w/ centrality selection on FT0M for omega K channel", false); @@ -605,10 +1189,10 @@ struct HfCandidateCreatorXic0Omegac0 { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -622,10 +1206,10 @@ struct HfCandidateCreatorXic0Omegac0 { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -639,10 +1223,10 @@ struct HfCandidateCreatorXic0Omegac0 { /// bitmask with event. selection info float centrality{-1.f}; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); } /// end loop over collisions } @@ -661,13 +1245,45 @@ struct HfCandidateCreatorXic0Omegac0Mc { Produces rowMCMatchRecToOmegaK; Produces rowMCMatchGenToOmegaK; + // Configuration + o2::framework::Configurable rejectBackground{"rejectBackground", true, "Reject particles from background events"}; + + using MyTracksWMc = soa::Join; + using McCollisionsNoCents = soa::Join; + using McCollisionsFT0Cs = soa::Join; + using McCollisionsFT0Ms = soa::Join; + 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; + HistogramRegistry registry{"registry"}; // inspect for which zPvPosMax cut was set for reconstructed void init(InitContext& initContext) { + std::array procCollisionsXicToXiPi{doprocessMcXicToXiPi, doprocessMcXicToXiPiFT0m, doprocessMcXicToXiPiFT0c}; + 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."); + } + std::array procCollisionsOmegacToXiPi{doprocessMcOmegacToXiPi, doprocessMcOmegacToXiPiFT0m, doprocessMcOmegacToXiPiFT0c}; + if (std::accumulate(procCollisionsOmegacToXiPi.begin(), procCollisionsOmegacToXiPi.end(), 0) > 1) { + LOGP(fatal, "At most one process function for OmegacToXiPi collision study can be enabled at a time."); + } + std::array procCollisionsOmegacToOmegaPi{doprocessMcOmegacToOmegaPi, doprocessMcOmegacToOmegaPiFT0m, doprocessMcOmegacToOmegaPiFT0c}; + if (std::accumulate(procCollisionsOmegacToOmegaPi.begin(), procCollisionsOmegacToOmegaPi.end(), 0) > 1) { + LOGP(fatal, "At most one process function for OmegacToOmegaPi collision study can be enabled at a time."); + } + std::array procCollisionsOmegacToOmegaK{doprocessMcOmegacToOmegaK, doprocessMcOmegacToOmegaKFT0m, doprocessMcOmegacToOmegaKFT0c}; + if (std::accumulate(procCollisionsOmegacToOmegaK.begin(), procCollisionsOmegacToOmegaK.end(), 0) > 1) { + LOGP(fatal, "At most one process function for OmegacToOmegaK collision study can be enabled at a time."); + } + const auto& workflows = initContext.services().get(); for (const DeviceSpec& device : workflows.devices) { if (device.name.compare("hf-candidate-creator-xic0-omegac0") == 0) { @@ -676,14 +1292,26 @@ struct HfCandidateCreatorXic0Omegac0Mc { } } 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 + + hGenCharmBaryonPtRapidityTightOmegacToXiPi = registry.add("hGenCharmBaryonPtRapidityTightOmegacToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); + hGenCharmBaryonPtRapidityLooseOmegacToXiPi = registry.add("hGenCharmBaryonPtRapidityLooseOmegacToXiPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); + + hGenCharmBaryonPtRapidityTightOmegacToOmegaPi = registry.add("hGenCharmBaryonPtRapidityTightOmegacToOmegaPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); + hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi = registry.add("hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi", "Generated charm baryon #it{p}_{T};#it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1D, {{20, 0.0, 20.0}}}); + + 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}}}); } - template + template void runXic0Omegac0Mc(TMyRecoCand const& candidates, - aod::TracksWMc const&, + MyTracksWMc const&, aod::McParticles const& mcParticles, - aod::McCollisions const&, - aod::McCollisionLabels const&, + Colls const& collsWithMcLabels, + aod::McCollisions const& mcCollisions, BCsInfo const&) { float ptCharmBaryonGen = -999.; @@ -720,15 +1348,37 @@ struct HfCandidateCreatorXic0Omegac0Mc { collisionMatched = false; std::vector idxBhadMothers{}; - 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 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()}; + + // Check whether the particle is from background events. If so, reject it. + if (rejectBackground) { + bool fromBkg{false}; + for (const auto& daughter : arrayDaughters) { + if (daughter.has_mcParticle()) { + auto mcParticle = daughter.mcParticle(); + if (mcParticle.fromBackgroundEvent()) { + fromBkg = true; + break; + } + } + } + if (fromBkg) { + rowMCMatchRecXicToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); + rowMCMatchRecOmegacToXiPi(flag, debug, origin, collisionMatched, -1.f, 0); + rowMCMatchRecToOmegaPi(flag, debug, origin, collisionMatched, -1.f, 0); + rowMCMatchRecToOmegaK(flag, debug, origin, collisionMatched, -1.f, 0); + continue; + } + } + // Xic0 -> xi pi matching if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { // Xic → pi pi pi p @@ -751,7 +1401,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi); - collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); } } } @@ -790,7 +1440,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi); - collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); } } } @@ -829,7 +1479,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); - collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); } } } @@ -868,7 +1518,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { } if (indexRec > -1) { flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK); - collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRecCharmBaryon).mcCollisionId(); } } } @@ -889,181 +1539,237 @@ struct HfCandidateCreatorXic0Omegac0Mc { } } // close loop over candidates - // Match generated particles. - for (const auto& particle : mcParticles) { - ptCharmBaryonGen = -999.; - rapidityCharmBaryonGen = -999.; - flag = 0; - sign = -9; - debugGenCharmBar = 0; - debugGenCasc = 0; - debugGenLambda = 0; - origin = RecoDecay::OriginType::None; - std::vector idxBhadMothers{}; + for (const auto& mcCollision : mcCollisions) { - auto mcCollision = particle.mcCollision(); - const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision); + // 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}; + if constexpr (centEstimator == CentralityEstimator::FT0C) { + const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } else if constexpr (centEstimator == CentralityEstimator::FT0M) { + const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } else if constexpr (centEstimator == CentralityEstimator::None) { + const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + } hfEvSelMc.fillHistograms(rejectionMask); if (rejectionMask != 0) { - /// at least one event selection not satisfied --> reject the gen particle - if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + /// at least one event selection not satisfied --> reject all particles from this collision + for (unsigned int i = 0; i < mcParticlesPerMcColl.size(); ++i) { + if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { + rowMCMatchGenXicToXiPi(0, 0, 0, 0, -999., -999., RecoDecay::OriginType::None, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { + rowMCMatchGenOmegacToXiPi(0, 0, 0, 0, -999., -999., RecoDecay::OriginType::None, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { + rowMCMatchGenToOmegaPi(0, 0, 0, 0, -999., -999., RecoDecay::OriginType::None, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { + rowMCMatchGenToOmegaK(0, 0, 0, 0, -999., -999., RecoDecay::OriginType::None, -1); + } } continue; } - 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)) { - debugGenCharmBar = 1; - ptCharmBaryonGen = particle.pt(); - rapidityCharmBaryonGen = particle.y(); - for (const auto& daughterCharm : particle.daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { - continue; - } - // Xi -> Lambda pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { - debugGenCasc = 1; - for (const auto& daughterCascade : daughterCharm.daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { - continue; - } - // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { - debugGenLambda = 1; - flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi); + // Match generated particles. + for (const auto& particle : mcParticlesPerMcColl) { + ptCharmBaryonGen = -999.; + rapidityCharmBaryonGen = -999.; + flag = 0; + sign = -9; + debugGenCharmBar = 0; + debugGenCasc = 0; + debugGenLambda = 0; + origin = RecoDecay::OriginType::None; + std::vector idxBhadMothers{}; + + // Reject particles from background events + if (particle.fromBackgroundEvent() && rejectBackground) { + if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi) { + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi) { + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi) { + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } else if constexpr (decayChannel == aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK) { + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } + continue; + } + + 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)) { + debugGenCharmBar = 1; + ptCharmBaryonGen = particle.pt(); + rapidityCharmBaryonGen = particle.y(); + for (const auto& daughterCharm : particle.daughters_as()) { + if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { + continue; + } + // Xi -> Lambda pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { + debugGenCasc = 1; + for (const auto& daughterCascade : daughterCharm.daughters_as()) { + if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + continue; + } + // Lambda -> p pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + debugGenLambda = 1; + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::XiczeroToXiPi); + } } } } } - } - // Check whether the charm baryon is non-prompt (from a b quark) - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); - } else { - rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } - - } 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)) { - debugGenCharmBar = 1; - ptCharmBaryonGen = particle.pt(); - rapidityCharmBaryonGen = particle.y(); - for (const auto& daughterCharm : particle.daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { - continue; + // 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) { + hGenCharmBaryonPtRapidityTightXicToXiPi->SetBinContent(hGenCharmBaryonPtRapidityTightXicToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightXicToXiPi->GetBinContent(hGenCharmBaryonPtRapidityTightXicToXiPi->FindBin(ptCharmBaryonGen)) + 1); } - // Xi -> Lambda pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { - debugGenCasc = 1; - for (const auto& daughterCascade : daughterCharm.daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { - continue; - } - // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { - debugGenLambda = 1; - flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi); + if (std::abs(rapidityCharmBaryonGen) < 0.8) { + hGenCharmBaryonPtRapidityLooseXicToXiPi->SetBinContent(hGenCharmBaryonPtRapidityLooseXicToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseXicToXiPi->GetBinContent(hGenCharmBaryonPtRapidityLooseXicToXiPi->FindBin(ptCharmBaryonGen)) + 1); + } + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenXicToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } + + } 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)) { + debugGenCharmBar = 1; + ptCharmBaryonGen = particle.pt(); + rapidityCharmBaryonGen = particle.y(); + for (const auto& daughterCharm : particle.daughters_as()) { + if (std::abs(daughterCharm.pdgCode()) != pdgCodeXiMinus) { + continue; + } + // Xi -> Lambda pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeXiMinus, std::array{pdgCodeLambda, pdgCodePiMinus}, true)) { + debugGenCasc = 1; + for (const auto& daughterCascade : daughterCharm.daughters_as()) { + if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + continue; + } + // Lambda -> p pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + debugGenLambda = 1; + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToXiPi); + } } } } } - } - // Check whether the charm baryon is non-prompt (from a b quark) - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); - } else { - rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } - - } 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)) { - debugGenCharmBar = 1; - ptCharmBaryonGen = particle.pt(); - rapidityCharmBaryonGen = particle.y(); - for (const auto& daughterCharm : particle.daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { - continue; + // 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) { + hGenCharmBaryonPtRapidityTightOmegacToXiPi->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToXiPi->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToXiPi->FindBin(ptCharmBaryonGen)) + 1); } - // Omega -> Lambda K - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { - debugGenCasc = 1; - for (const auto& daughterCascade : daughterCharm.daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { - continue; - } - // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { - debugGenLambda = 1; - flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); + if (std::abs(rapidityCharmBaryonGen) < 0.8) { + hGenCharmBaryonPtRapidityLooseOmegacToXiPi->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToXiPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToXiPi->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToXiPi->FindBin(ptCharmBaryonGen)) + 1); + } + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenOmegacToXiPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } + + } 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)) { + debugGenCharmBar = 1; + ptCharmBaryonGen = particle.pt(); + rapidityCharmBaryonGen = particle.y(); + for (const auto& daughterCharm : particle.daughters_as()) { + if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { + continue; + } + // Omega -> Lambda K + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { + debugGenCasc = 1; + for (const auto& daughterCascade : daughterCharm.daughters_as()) { + if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + continue; + } + // Lambda -> p pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + debugGenLambda = 1; + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaPi); + } } } } } - } - // Check whether the charm baryon is non-prompt (from a b quark) - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); - } else { - rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } - - } 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)) { - debugGenCharmBar = 1; - ptCharmBaryonGen = particle.pt(); - rapidityCharmBaryonGen = particle.y(); - for (const auto& daughterCharm : particle.daughters_as()) { - if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { - continue; + // 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) { + hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaPi->FindBin(ptCharmBaryonGen)) + 1); } - // Omega -> Lambda K - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { - debugGenCasc = 1; - for (const auto& daughterCascade : daughterCharm.daughters_as()) { - if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { - continue; - } - // Lambda -> p pi - if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { - debugGenLambda = 1; - flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK); + if (std::abs(rapidityCharmBaryonGen) < 0.8) { + hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaPi->FindBin(ptCharmBaryonGen)) + 1); + } + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenToOmegaPi(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } + + } 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)) { + debugGenCharmBar = 1; + ptCharmBaryonGen = particle.pt(); + rapidityCharmBaryonGen = particle.y(); + for (const auto& daughterCharm : particle.daughters_as()) { + if (std::abs(daughterCharm.pdgCode()) != pdgCodeOmegaMinus) { + continue; + } + // Omega -> Lambda K + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCharm, pdgCodeOmegaMinus, std::array{pdgCodeLambda, pdgCodeKaonMinus}, true)) { + debugGenCasc = 1; + for (const auto& daughterCascade : daughterCharm.daughters_as()) { + if (std::abs(daughterCascade.pdgCode()) != pdgCodeLambda) { + continue; + } + // Lambda -> p pi + if (RecoDecay::isMatchedMCGen(mcParticles, daughterCascade, pdgCodeLambda, std::array{pdgCodeProton, pdgCodePiMinus}, true)) { + debugGenLambda = 1; + flag = sign * (1 << aod::hf_cand_xic0_omegac0::DecayType::OmegaczeroToOmegaK); + } } } } } + // 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) { + hGenCharmBaryonPtRapidityTightOmegacToOmegaK->SetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaK->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityTightOmegacToOmegaK->GetBinContent(hGenCharmBaryonPtRapidityTightOmegacToOmegaK->FindBin(ptCharmBaryonGen)) + 1); + } + if (std::abs(rapidityCharmBaryonGen) < 0.8) { + hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->SetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->FindBin(ptCharmBaryonGen), hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->GetBinContent(hGenCharmBaryonPtRapidityLooseOmegacToOmegaK->FindBin(ptCharmBaryonGen)) + 1); + } + } + if (origin == RecoDecay::OriginType::NonPrompt) { + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); + } else { + rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); + } } - // Check whether the charm baryon is non-prompt (from a b quark) - if (flag != 0) { - origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers); - } - if (origin == RecoDecay::OriginType::NonPrompt) { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, idxBhadMothers[0]); - } else { - rowMCMatchGenToOmegaK(flag, debugGenCharmBar, debugGenCasc, debugGenLambda, ptCharmBaryonGen, rapidityCharmBaryonGen, origin, -1); - } - } - } // close loop on MCParticles - } // close process + } // close loop on MCParticles + } // close loop on MCCollisions + } // close process void processDoNoMc(aod::Collisions::iterator const&) { @@ -1072,48 +1778,136 @@ struct HfCandidateCreatorXic0Omegac0Mc { PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processDoNoMc, "Do not run any MC process function", true); void processMcXicToXiPi(aod::HfCandToXiPi const& candidates, - aod::TracksWMc const& tracks, + MyTracksWMc const& tracks, aod::McParticles const& mcParticles, aod::McCollisions const& mcColls, - aod::McCollisionLabels const& mcLabels, + McCollisionsNoCents const& collsWithMcLabels, BCsInfo const& bcs) { - runXic0Omegac0Mc(candidates, tracks, mcParticles, mcColls, mcLabels, bcs); + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPi, "Run Xic0 to xi pi MC process function - no centrality", false); + + void processMcXicToXiPiFT0m(aod::HfCandToXiPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Ms const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPi, "Run Xic0 to xi pi MC process function", false); + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPiFT0m, "Run Xic0 to xi pi MC process function - FT0M", false); + + void processMcXicToXiPiFT0c(aod::HfCandToXiPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Cs const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcXicToXiPiFT0c, "Run Xic0 to xi pi MC process function - FT0C", false); void processMcOmegacToXiPi(aod::HfCandToXiPi const& candidates, - aod::TracksWMc const& tracks, + MyTracksWMc const& tracks, aod::McParticles const& mcParticles, aod::McCollisions const& mcColls, - aod::McCollisionLabels const& mcLabels, + McCollisionsNoCents const& collsWithMcLabels, BCsInfo const& bcs) { - runXic0Omegac0Mc(candidates, tracks, mcParticles, mcColls, mcLabels, bcs); + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToXiPi, "Run Omegac0 to xi pi MC process function - no centrality", false); + + void processMcOmegacToXiPiFT0m(aod::HfCandToXiPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Ms const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToXiPi, "Run Omegac0 to xi pi MC process function", false); + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToXiPiFT0m, "Run Omegac0 to xi pi MC process function - FT0M", false); + + void processMcOmegacToXiPiFT0c(aod::HfCandToXiPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Cs const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToXiPiFT0c, "Run Omegac0 to xi pi MC process function - FT0C", false); void processMcOmegacToOmegaPi(aod::HfCandToOmegaPi const& candidates, - aod::TracksWMc const& tracks, + MyTracksWMc const& tracks, aod::McParticles const& mcParticles, aod::McCollisions const& mcColls, - aod::McCollisionLabels const& mcLabels, + McCollisionsNoCents const& collsWithMcLabels, BCsInfo const& bcs) { - runXic0Omegac0Mc(candidates, tracks, mcParticles, mcColls, mcLabels, bcs); + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaPi, "Run Omegac0 to omega pi MC process function - no centrality", false); + + void processMcOmegacToOmegaPiFT0m(aod::HfCandToOmegaPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Ms const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaPiFT0m, "Run Omegac0 to omega pi MC process function - FT0M", false); + + void processMcOmegacToOmegaPiFT0c(aod::HfCandToOmegaPi const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Cs const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaPi, "Run Omegac0 to omega pi MC process function", false); + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaPiFT0c, "Run Omegac0 to omega pi MC process function - FT0C", false); void processMcOmegacToOmegaK(aod::HfCandToOmegaK const& candidates, - aod::TracksWMc const& tracks, + MyTracksWMc const& tracks, aod::McParticles const& mcParticles, aod::McCollisions const& mcColls, - aod::McCollisionLabels const& mcLabels, + McCollisionsNoCents const& collsWithMcLabels, BCsInfo const& bcs) { - runXic0Omegac0Mc(candidates, tracks, mcParticles, mcColls, mcLabels, bcs); + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaK, "Run Omegac0 to omega K MC process function - no centrality", false); + + void processMcOmegacToOmegaKFT0m(aod::HfCandToOmegaK const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Ms const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); + } + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaKFT0m, "Run Omegac0 to omega K MC process function - FT0M", false); + + void processMcOmegacToOmegaKFT0c(aod::HfCandToOmegaK const& candidates, + MyTracksWMc const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcColls, + McCollisionsFT0Cs const& collsWithMcLabels, + BCsInfo const& bcs) + { + runXic0Omegac0Mc(candidates, tracks, mcParticles, collsWithMcLabels, mcColls, bcs); } - PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaK, "Run Omegac0 to omega K MC process function", false); + PROCESS_SWITCH(HfCandidateCreatorXic0Omegac0Mc, processMcOmegacToOmegaKFT0c, "Run Omegac0 to omega K MC process function - FT0C", false); }; // close struct diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index f0752d56ed5..cea4a034559 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -13,12 +13,17 @@ /// \brief Reconstruction of Ξc± → (Ξ∓ → (Λ → p π∓) π∓) π± π± candidates /// /// \author Phil Lennart Stahlhut , Heidelberg University +/// \author Carolina Reetz , Heidelberg University /// \author Jinjoo Seo , Heidelberg University #ifndef HomogeneousField #define HomogeneousField #endif +#include +#include +#include + #include #include #include @@ -75,7 +80,8 @@ struct HfCandidateCreatorXicToXiPiPi { Configurable useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; // KFParticle Configurable constrainXicPlusToPv{"constrainXicPlusToPv", false, "Constrain XicPlus to PV"}; - Configurable kfConstructMethod{"kfConstructMethod", 0, "Construct method of XicPlus: 0 no mass constraint, 2 mass constraint"}; + 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)"}; Service ccdb; @@ -307,12 +313,12 @@ struct HfCandidateCreatorXicToXiPiPi { //---------------------------------fill candidate table rows------------------------------------------------------------------------------------------- rowCandidateBase(collision.globalIndex(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), - covMatrixPV[0], covMatrixPV[2], covMatrixPV[5], + 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], - covMatrixSV[0], covMatrixSV[2], covMatrixSV[5], + std::sqrt(covMatrixSV[0]), std::sqrt(covMatrixSV[2]), std::sqrt(covMatrixSV[5]), errorDecayLength, errorDecayLengthXY, chi2SV, massXiPiPi, signXic, pVecXi[0], pVecXi[1], pVecXi[2], @@ -410,28 +416,61 @@ struct HfCandidateCreatorXicToXiPiPi { continue; } - // topological constraint + // get geometrical chi2 of XicPlus + float chi2GeoXicPlus = kfXicPlus.GetChi2() / kfXicPlus.GetNDF(); + + // topological constraint of Xic to PV + float chi2topoXicPlusToPVBeforeConstraint = kfXicPlus.GetDeviationFromVertex(KFPV); + KFParticle kfXicPlusToPV = kfXicPlus; + kfXicPlusToPV.SetProductionVertex(KFPV); + float chi2topoXicPlusToPV = kfXicPlusToPV.GetChi2() / kfXicPlusToPV.GetNDF(); if (constrainXicPlusToPv) { - kfXicPlus.SetProductionVertex(KFPV); + 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; } - auto covMatrixXicPlus = kfXicPlus.CovarianceMatrix(); - // transport daughter particles to XicPlus decay vertex - kfCharmBachelor0.TransportToParticle(kfXicPlus); - kfCharmBachelor1.TransportToParticle(kfXicPlus); - kfXi.TransportToParticle(kfXicPlus); + // 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; - // get impact parameters of XicPlus daughters + // get updated daughter tracks after vertex fit + // after production vertex constraint the parameters of the particle are stored at the position of the production vertex + KFParticle kfCharmBachelor0Upd = kfCharmBachelor0; + KFParticle kfCharmBachelor1Upd = kfCharmBachelor1; + KFParticle kfXiUpd = kfXi; + kfCharmBachelor0Upd.SetProductionVertex(kfXicPlus); + kfCharmBachelor1Upd.SetProductionVertex(kfXicPlus); + kfXiUpd.SetProductionVertex(kfXicPlus); + + // get impact parameters of updated XicPlus daughters 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); + kfCharmBachelor0Upd.GetDistanceFromVertexXY(KFPV, impactParameterPi0XY, errImpactParameterPi0XY); + kfCharmBachelor1Upd.GetDistanceFromVertexXY(KFPV, impactParameterPi1XY, errImpactParameterPi1XY); + kfXiUpd.GetDistanceFromVertexXY(KFPV, impactParameterXiXY, errImpactParameterXiXY); // calculate cosine of pointing angle std::array pvCoord = {collision.posX(), collision.posY(), collision.posZ()}; @@ -441,36 +480,45 @@ struct HfCandidateCreatorXicToXiPiPi { double cpaXYXi = RecoDecay::cpaXY(pvCoord, vertexCasc, pVecCasc); // 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 dcaXYPi0Pi1 = kfCharmBachelor0Upd.GetDistanceFromParticleXY(kfCharmBachelor1Upd); + float dcaXYPi0Xi = kfCharmBachelor0Upd.GetDistanceFromParticleXY(kfXiUpd); + float dcaXYPi1Xi = kfCharmBachelor1Upd.GetDistanceFromParticleXY(kfXiUpd); + float dcaPi0Pi1 = kfCharmBachelor0Upd.GetDistanceFromParticle(kfCharmBachelor1Upd); + float dcaPi0Xi = kfCharmBachelor0Upd.GetDistanceFromParticle(kfXiUpd); + float dcaPi1Xi = kfCharmBachelor1Upd.GetDistanceFromParticle(kfXiUpd); // mass of Xi-Pi0 pair KFParticle kfXiPi0; + float errMassXiPi0; const KFParticle* kfXiResonanceDaughtersPi0[2] = {&kfXi, &kfCharmBachelor0}; kfXiPi0.SetConstructMethod(kfConstructMethod); try { kfXiPi0.Construct(kfXiResonanceDaughtersPi0, 2); - massXiPi0 = kfXiPi0.GetMass(); } catch (...) { LOG(info) << "Failed to construct Xi(1530) with Pi 0"; } + kfXiPi0.GetMass(massXiPi0, errMassXiPi0); // mass of Xi-Pi1 pair KFParticle kfXiPi1; + float errMassXiPi1; const KFParticle* kfXiResonanceDaughtersPi1[2] = {&kfXi, &kfCharmBachelor1}; kfXiPi1.SetConstructMethod(kfConstructMethod); try { kfXiPi1.Construct(kfXiResonanceDaughtersPi1, 2); - massXiPi1 = kfXiPi1.GetMass(); } catch (...) { LOG(info) << "Failed to construct Xi(1530) with Pi 1"; } + kfXiPi1.GetMass(massXiPi1, errMassXiPi1); + + // get invariant mass of Xic candidate + float errMassXiPiPi; + kfXicPlus.GetMass(massXiPiPi, errMassXiPiPi); //-------------------------------fill histograms-------------------------------------------- if (fillHistograms) { // invariant mass - registry.fill(HIST("hMass3"), kfXicPlus.GetMass()); + registry.fill(HIST("hMass3"), massXiPiPi); // covariance matrix elements of PV registry.fill(HIST("hCovPVXX"), covMatrixPV[0]); registry.fill(HIST("hCovPVYY"), covMatrixPV[2]); @@ -490,14 +538,14 @@ struct HfCandidateCreatorXicToXiPiPi { //------------------------------fill candidate table rows-------------------------------------- rowCandidateBase(collision.globalIndex(), KFPV.GetX(), KFPV.GetY(), KFPV.GetZ(), - covMatrixPV[0], covMatrixPV[2], covMatrixPV[5], + 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(), kfXicPlus.GetX(), kfXicPlus.GetY(), kfXicPlus.GetZ(), kfXicPlus.GetErrX(), kfXicPlus.GetErrY(), kfXicPlus.GetErrZ(), kfXicPlus.GetErrDecayLength(), kfXicPlus.GetErrDecayLengthXY(), - kfXicPlus.GetChi2(), kfXicPlus.GetMass(), signXic, + chi2GeoXicPlus, massXiPiPi, signXic, kfXi.GetPx(), kfXi.GetPy(), kfXi.GetPz(), kfCharmBachelor0.GetPx(), kfCharmBachelor0.GetPy(), kfCharmBachelor0.GetPz(), kfCharmBachelor1.GetPx(), kfCharmBachelor1.GetPy(), kfCharmBachelor1.GetPz(), @@ -509,7 +557,10 @@ struct HfCandidateCreatorXicToXiPiPi { cpaXi, cpaXYXi, cpaLambda, cpaXYLambda, massXiPi0, massXiPi1); rowCandidateKF(casc.kfCascadeChi2(), casc.kfV0Chi2(), - dcaXYPi0Pi1, dcaXYPi0Xi, dcaXYPi1Xi); + chi2topoXicPlusToPVBeforeConstraint, chi2topoXicPlusToPV, chi2topoXiToXicPlusBeforeConstraint, chi2topoXiToXicPlus, + dcaXYPi0Pi1, dcaXYPi0Xi, dcaXYPi1Xi, + dcaPi0Pi1, dcaPi0Xi, dcaPi1Xi, + casc.dcacascdaughters()); } // loop over track triplets } PROCESS_SWITCH(HfCandidateCreatorXicToXiPiPi, processXicplusWithKFParticle, "Run candidate creator with KFParticle using derived data from HfTrackIndexSkimCreatorLfCascades.", false); diff --git a/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx b/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx index 5c0c230c11f..9fc9fc8bdfc 100644 --- a/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorBsToDsPi.cxx @@ -15,6 +15,9 @@ /// /// \author Phil Stahlhut +#include +#include + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" #include "Framework/RunningWorkflowInfo.h" @@ -59,7 +62,7 @@ struct HfCandidateSelectorBsToDsPi { 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 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"}; @@ -116,7 +119,6 @@ struct HfCandidateSelectorBsToDsPi { hfMlResponse.setModelPathsLocal(onnxFileNames); } hfMlResponse.init(); - outputMl.assign(((std::vector)cutDirMl).size(), -1.f); // dummy value for ML output } int selectionFlagDs = -1; @@ -147,19 +149,9 @@ struct HfCandidateSelectorBsToDsPi { { for (const auto& hfCandBs : hfCandsBs) { int statusBsToDsPi = 0; + outputMl.clear(); auto ptCandBs = hfCandBs.pt(); - // check if flagged as Bs → Ds π - if (!TESTBIT(hfCandBs.hfflag(), hf_cand_bs::DecayType::BsToDsPi)) { - hfSelBsToDsPiCandidate(statusBsToDsPi); - if (applyMl) { - hfMlBsToDsPiCandidate(outputMl); - } - if (activateQA) { - registry.fill(HIST("hSelections"), 1, ptCandBs); - } - continue; - } SETBIT(statusBsToDsPi, SelectionStep::RecoSkims); // RecoSkims = 0 --> statusBsToDsPi = 1 if (activateQA) { registry.fill(HIST("hSelections"), 2 + SelectionStep::RecoSkims, ptCandBs); diff --git a/PWGHF/TableProducer/candidateSelectorD0.cxx b/PWGHF/TableProducer/candidateSelectorD0.cxx index 3254d513237..88a8fb017b3 100644 --- a/PWGHF/TableProducer/candidateSelectorD0.cxx +++ b/PWGHF/TableProducer/candidateSelectorD0.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" @@ -26,6 +29,7 @@ #include "PWGHF/Core/HfMlResponseD0ToKPi.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" using namespace o2; using namespace o2::analysis; @@ -63,7 +67,7 @@ struct HfCandidateSelectorD0 { 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 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 @@ -72,6 +76,8 @@ struct HfCandidateSelectorD0 { 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"}; + // Mass Cut for trigger analysis + Configurable useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrize pT differential mass cut for triggered data"}; o2::analysis::HfMlResponseD0ToKPi hfMlResponse; std::vector outputMlD0 = {}; @@ -80,6 +86,7 @@ struct HfCandidateSelectorD0 { TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; HfHelper hfHelper; + HfTrigger2ProngCuts hfTriggerCuts; using TracksSel = soa::Join; @@ -158,7 +165,9 @@ struct HfCandidateSelectorD0 { return false; } // candidate DCA - // if (candidate.chi2PCA() > cuts[pTBin][1]) return false; + if (std::abs(candidate.impactParameterXY()) > cuts->get(pTBin, "DCA")) { + return false; + } // candidate topological chi2 over ndf when using KFParticle, need to add this selection to the SelectorCuts.h // if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { @@ -209,10 +218,16 @@ struct HfCandidateSelectorD0 { if (std::abs(massD0 - o2::constants::physics::MassD0) > cuts->get(pTBin, "m")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(massD0, o2::constants::physics::MassD0, candidate.pt(), hfTriggerCuts)) { + return false; + } } else { if (std::abs(massD0bar - o2::constants::physics::MassD0) > cuts->get(pTBin, "m")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(massD0bar, o2::constants::physics::MassD0, candidate.pt(), hfTriggerCuts)) { + return false; + } } // cut on daughter pT @@ -317,20 +332,32 @@ struct HfCandidateSelectorD0 { int pidTrackNegPion = -1; if (usePidTpcOnly) { - pidTrackPosKaon = selectorKaon.statusTpc(trackPos); - pidTrackPosPion = selectorPion.statusTpc(trackPos); - pidTrackNegKaon = selectorKaon.statusTpc(trackNeg); - pidTrackNegPion = selectorPion.statusTpc(trackNeg); + /// kaon TPC PID positive daughter + pidTrackPosKaon = selectorKaon.statusTpc(trackPos, candidate.nSigTpcKa0()); + /// pion TPC PID positive daughter + pidTrackPosPion = selectorPion.statusTpc(trackPos, candidate.nSigTpcPi0()); + /// kaon TPC PID negative daughter + pidTrackNegKaon = selectorKaon.statusTpc(trackNeg, candidate.nSigTpcKa1()); + /// pion TPC PID negative daughter + pidTrackNegPion = selectorPion.statusTpc(trackNeg, candidate.nSigTpcPi1()); } else if (usePidTpcAndTof) { - pidTrackPosKaon = selectorKaon.statusTpcAndTof(trackPos); - pidTrackPosPion = selectorPion.statusTpcAndTof(trackPos); - pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg); - pidTrackNegPion = selectorPion.statusTpcAndTof(trackNeg); + /// kaon TPC, TOF PID positive daughter + pidTrackPosKaon = selectorKaon.statusTpcAndTof(trackPos, candidate.nSigTpcKa0(), candidate.nSigTofKa0()); + /// pion TPC, TOF PID positive daughter + pidTrackPosPion = selectorPion.statusTpcAndTof(trackPos, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + /// kaon TPC, TOF PID negative daughter + pidTrackNegKaon = selectorKaon.statusTpcAndTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + /// pion TPC, TOF PID negative daughter + pidTrackNegPion = selectorPion.statusTpcAndTof(trackNeg, candidate.nSigTpcPi1(), candidate.nSigTofPi1()); } else { - pidTrackPosKaon = selectorKaon.statusTpcOrTof(trackPos); - pidTrackPosPion = selectorPion.statusTpcOrTof(trackPos); - pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg); - pidTrackNegPion = selectorPion.statusTpcOrTof(trackNeg); + /// kaon TPC, TOF PID positive daughter + pidTrackPosKaon = selectorKaon.statusTpcOrTof(trackPos, candidate.nSigTpcKa0(), candidate.nSigTofKa0()); + /// pion TPC, TOF PID positive daughter + pidTrackPosPion = selectorPion.statusTpcOrTof(trackPos, candidate.nSigTpcPi0(), candidate.nSigTofPi0()); + /// kaon TPC, TOF PID negative daughter + pidTrackNegKaon = selectorKaon.statusTpcOrTof(trackNeg, candidate.nSigTpcKa1(), candidate.nSigTofKa1()); + /// pion TPC, TOF PID negative daughter + pidTrackNegPion = selectorPion.statusTpcOrTof(trackNeg, candidate.nSigTpcPi1(), candidate.nSigTofPi1()); } // int pidBayesTrackPos1Pion = selectorPion.statusBayes(trackPos); @@ -384,11 +411,11 @@ struct HfCandidateSelectorD0 { bool isSelectedMlD0bar = false; if (statusD0 > 0) { - std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::constants::physics::kD0); + std::vector inputFeaturesD0 = hfMlResponse.getInputFeatures(candidate, o2::constants::physics::kD0); isSelectedMlD0 = hfMlResponse.isSelectedMl(inputFeaturesD0, ptCand, outputMlD0); } if (statusD0bar > 0) { - std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate, trackPos, trackNeg, o2::constants::physics::kD0Bar); + std::vector inputFeaturesD0bar = hfMlResponse.getInputFeatures(candidate, o2::constants::physics::kD0Bar); isSelectedMlD0bar = hfMlResponse.isSelectedMl(inputFeaturesD0bar, ptCand, outputMlD0bar); } @@ -420,13 +447,13 @@ struct HfCandidateSelectorD0 { } } - void processWithDCAFitterN(aod::HfCand2Prong const& candidates, TracksSel const& tracks) + void processWithDCAFitterN(aod::HfCand2ProngWPid const& candidates, TracksSel const& tracks) { processSel(candidates, tracks); } PROCESS_SWITCH(HfCandidateSelectorD0, processWithDCAFitterN, "process candidates selection with DCAFitterN", true); - void processWithKFParticle(soa::Join const& candidates, TracksSel const& tracks) + void processWithKFParticle(soa::Join const& candidates, TracksSel const& tracks) { processSel(candidates, tracks); } diff --git a/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx b/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx index 326833bfa08..d6d607ba9c4 100644 --- a/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDplusToPiKPi.cxx @@ -15,6 +15,9 @@ /// \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" @@ -25,6 +28,7 @@ #include "PWGHF/Core/HfMlResponseDplusToPiKPi.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" using namespace o2; using namespace o2::analysis; @@ -59,12 +63,14 @@ struct HfCandidateSelectorDplusToPiKPi { 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", (int8_t)hf_cuts_ml::nCutScores, "Number of classes in ML model"}; + 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"}; @@ -72,14 +78,17 @@ struct HfCandidateSelectorDplusToPiKPi { Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_DPlusToKPiPi.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"}; + // Mass Cut for trigger analysis + Configurable useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrize pT differential mass cut for triggered data"}; - o2::analysis::HfMlResponseDplusToPiKPi hfMlResponse; + HfMlResponseDplusToPiKPi hfMlResponse; std::vector outputMlNotPreselected = {}; std::vector outputMl = {}; o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; HfHelper hfHelper; + HfTrigger3ProngCuts hfTriggerCuts; using TracksSel = soa::Join; @@ -132,13 +141,13 @@ struct HfCandidateSelectorDplusToPiKPi { template bool selection(const T1& candidate, const T2& trackPion1, const T2& trackKaon, const T2& trackPion2) { - auto candpT = candidate.pt(); - int pTBin = findBin(binsPt, candpT); + auto ptCand = candidate.pt(); + int pTBin = findBin(binsPt, ptCand); if (pTBin == -1) { return false; } // check that the candidate pT is within the analysis range - if (candpT < ptCandMin || candpT > ptCandMax) { + if (ptCand < ptCandMin || ptCand > ptCandMax) { return false; } // cut on daughter pT @@ -149,6 +158,9 @@ struct HfCandidateSelectorDplusToPiKPi { if (std::abs(hfHelper.invMassDplusToPiKPi(candidate) - o2::constants::physics::MassDPlus) > cuts->get(pTBin, "deltaM")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(hfHelper.invMassDplusToPiKPi(candidate), o2::constants::physics::MassDPlus, ptCand, hfTriggerCuts)) { + return false; + } if (candidate.decayLength() < cuts->get(pTBin, "decay length")) { return false; } @@ -216,7 +228,7 @@ struct HfCandidateSelectorDplusToPiKPi { auto ptCand = candidate.pt(); - if (!TESTBIT(candidate.hfflag(), aod::hf_cand_3prong::DecayType::DplusToPiKPi)) { + 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∓ π± hfSelDplusToPiKPiCandidate(statusDplusToPiKPi); if (applyMl) { hfMlDplusToPiKPiCandidate(outputMlNotPreselected); diff --git a/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx b/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx index c32ffdfd711..6d00e6daee9 100644 --- a/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDsToKKPi.cxx @@ -15,6 +15,9 @@ /// \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" @@ -25,6 +28,7 @@ #include "PWGHF/Core/HfMlResponseDsToKKPi.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsAnalysis.h" using namespace o2; using namespace o2::analysis; @@ -52,6 +56,8 @@ struct HfCandidateSelectorDsToKKPi { // 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 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"}; // pT bins for single-track cuts @@ -63,7 +69,7 @@ struct HfCandidateSelectorDsToKKPi { 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 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 +77,8 @@ struct HfCandidateSelectorDsToKKPi { Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_DsToKKPi.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"}; + // Mass cut for trigger analysis + Configurable useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrized pT differential mass cut for triggered data"}; HfHelper hfHelper; o2::analysis::HfMlResponseDsToKKPi hfMlResponse; @@ -79,6 +87,7 @@ struct HfCandidateSelectorDsToKKPi { o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorKa selectorKaon; + HfTrigger3ProngCuts hfTriggerCuts; using TracksSel = soa::Join; @@ -172,6 +181,9 @@ struct HfCandidateSelectorDsToKKPi { if (!isSelectedCandidateProngDca(candidate)) { return false; } + if (rejectCandsInDplusToPiKPiRegion && std::abs(hfHelper.invMassDplusToPiKPi(candidate) - o2::constants::physics::MassDPlus) < deltaMRegionDplusToPiKPi) { + return false; + } return true; } @@ -195,6 +207,9 @@ struct HfCandidateSelectorDsToKKPi { if (std::abs(hfHelper.invMassDsToKKPi(candidate) - o2::constants::physics::MassDS) > cuts->get(pTBin, "deltaM")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(hfHelper.invMassDsToKKPi(candidate), o2::constants::physics::MassDS, candidate.pt(), hfTriggerCuts)) { + return false; + } if (hfHelper.deltaMassPhiDsToKKPi(candidate) > cuts->get(pTBin, "deltaM Phi")) { return false; } @@ -224,6 +239,9 @@ struct HfCandidateSelectorDsToKKPi { if (std::abs(hfHelper.invMassDsToPiKK(candidate) - o2::constants::physics::MassDS) > cuts->get(pTBin, "deltaM")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(hfHelper.invMassDsToPiKK(candidate), o2::constants::physics::MassDS, candidate.pt(), hfTriggerCuts)) { + return false; + } if (hfHelper.deltaMassPhiDsToPiKK(candidate) > cuts->get(pTBin, "deltaM Phi")) { return false; } diff --git a/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx b/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx index 7f7f8501863..6445241d318 100644 --- a/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx +++ b/PWGHF/TableProducer/candidateSelectorDstarToD0Pi.cxx @@ -15,6 +15,10 @@ /// \author Deependra Sharma , IITB /// \author Fabrizio Grosa , CERN +#include +#include +#include + // O2 #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisDataModel.h" @@ -45,6 +49,8 @@ struct HfCandidateSelectorDstarToD0Pi { 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"}; + // Mass Cut for trigger analysis + Configurable useTriggerMassCut{"useTriggerMassCut", false, "Flag to enable parametrize pT differential mass cut for triggered data"}; // Configurable specific to Dstar Configurable ptDstarCandMin{"ptDstarCandMin", 0., "Minimum Dstar candidate pT"}; @@ -79,7 +85,7 @@ struct HfCandidateSelectorDstarToD0Pi { 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 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 @@ -108,6 +114,8 @@ struct HfCandidateSelectorDstarToD0Pi { AxisSpec axisSelStatus{2, -0.5f, 1.5f}; HistogramRegistry registry{"registry"}; + HfTrigger2ProngCuts hfTriggerCuts; + void init(InitContext&) { massPi = MassPiPlus; @@ -282,6 +290,9 @@ struct HfCandidateSelectorDstarToD0Pi { if (std::abs(mInvD0 - massD0) > cutsD0->get(binPt, "m")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(mInvD0, massD0, candidate.ptD0(), hfTriggerCuts)) { + return false; + } // cut on daughter pT auto d0prong0 = candidate.template prong0_as(); auto d0prong1 = candidate.template prong1_as(); @@ -307,6 +318,9 @@ struct HfCandidateSelectorDstarToD0Pi { if (std::abs(mInvD0Bar - massD0) > cutsD0->get(binPt, "m")) { return false; } + if (useTriggerMassCut && !isCandidateInMassRange(mInvD0Bar, massD0, candidate.ptD0(), hfTriggerCuts)) { + return false; + } // cut on daughter pT auto d0prong0 = candidate.template prong0_as(); auto d0prong1 = candidate.template prong1_as(); diff --git a/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx b/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx index 10f2873dd1e..d9b1872e83e 100644 --- a/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx @@ -18,6 +18,8 @@ #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" @@ -48,11 +50,14 @@ struct HfCandidateSelectorLbToLcPi { Configurable impactParameterMaximum{"impactParameterMaximum", 0.2, "Maximum impact parameter for single tracks"}; 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 selectionFlagLc{"selectionFlagLc", 1, "Selection Flag for Lc+"}; HfHelper hfHelper; + using TracksWExt = soa::Join; + bool passesImpactParameterResolution(float pT, float d0Resolution) { float expectedResolution(0.001 + 0.0052 * exp(-0.655 * pT)); @@ -138,12 +143,21 @@ struct HfCandidateSelectorLbToLcPi { return false; } + // distance between Lb and Lc decay + 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); + if (vertexDistance > maxVertexDistanceLbLc) { + return false; + } + return true; } void process(aod::HfCandLb const& hfCandLbs, soa::Join const&, - aod::Tracks const&) + TracksWExt const&) { for (const auto& hfCandLb : hfCandLbs) { // looping over Lb candidates @@ -159,12 +173,12 @@ struct HfCandidateSelectorLbToLcPi { // Lc is always index0 and pi is index1 by default // auto candLc = hfCandLb.prong0(); auto candLc = hfCandLb.prong0_as>(); - auto trackPi = hfCandLb.prong1(); + auto trackPi = hfCandLb.prong1_as(); // Check that the impact parameter resolution is not too far from the typical - auto track0 = candLc.prong0_as(); - auto track1 = candLc.prong1_as(); - auto track2 = candLc.prong2_as(); + auto track0 = candLc.prong0_as(); + auto track1 = candLc.prong1_as(); + auto track2 = candLc.prong2_as(); float reso0 = candLc.errorImpactParameter0(); float reso1 = candLc.errorImpactParameter1(); float reso2 = candLc.errorImpactParameter2(); @@ -186,6 +200,20 @@ struct HfCandidateSelectorLbToLcPi { continue; } + // PID selection for pion + if (trackPi.pt() > ptPidTpcMin && trackPi.pt() < ptPidTpcMax) { + if (std::abs(trackPi.tpcNSigmaPi()) > nSigmaTpcMax) { + hfSelLbToLcPiCandidate(statusLb); + continue; + } + } + if (trackPi.pt() > ptPidTofMin && trackPi.pt() < ptPidTofMax) { + if (std::abs(trackPi.tofNSigmaPi()) > nSigmaTofMax) { + hfSelLbToLcPiCandidate(statusLb); + continue; + } + } + hfSelLbToLcPiCandidate(1); // LOGF(debug, "Lb candidate selection successful, candidate should be selected"); } diff --git a/PWGHF/TableProducer/candidateSelectorLc.cxx b/PWGHF/TableProducer/candidateSelectorLc.cxx index afeba207356..818d65bb269 100644 --- a/PWGHF/TableProducer/candidateSelectorLc.cxx +++ b/PWGHF/TableProducer/candidateSelectorLc.cxx @@ -17,6 +17,9 @@ /// \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" @@ -77,7 +80,7 @@ struct HfCandidateSelectorLc { 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 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"}; @@ -201,6 +204,21 @@ struct HfCandidateSelectorLc { 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 impact parameter XY + if (std::abs(candidate.impactParameterXY()) > cuts->get(pTBin, "impParXY")) { + return false; + } + if (!isSelectedCandidateProngDca(candidate)) { return false; } @@ -432,11 +450,11 @@ struct HfCandidateSelectorLc { isSelectedMlLcToPiKP = false; if (pidLcToPKPi == 1 && pidBayesLcToPKPi == 1 && topolLcToPKPi) { - std::vector inputFeaturesLcToPKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2); + 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); + std::vector inputFeaturesLcToPiKP = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, false); isSelectedMlLcToPiKP = hfMlResponse.isSelectedMl(inputFeaturesLcToPiKP, candidate.pt(), outputMlLcToPiKP); } diff --git a/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx b/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx index 7e8d48085f0..c7b17972b8f 100644 --- a/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx +++ b/PWGHF/TableProducer/candidateSelectorLcToK0sP.cxx @@ -17,6 +17,9 @@ /// Daniel Samitz, , Vienna /// Elisa Meninno, , Vienna +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -62,7 +65,7 @@ struct HfCandidateSelectorLcToK0sP { 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 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"}; diff --git a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx index 12f2dddc6f6..b523f8bd7a4 100644 --- a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx +++ b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaKa.cxx @@ -129,6 +129,7 @@ struct HfCandidateSelectorToOmegaKa { TrackSelectorKa selectorKaon; using TracksSel = soa::Join; + using TracksSelLf = soa::Join; HistogramRegistry registry{"registry"}; // for QA of selections @@ -194,7 +195,8 @@ struct HfCandidateSelectorToOmegaKa { } void process(aod::HfCandToOmegaK const& candidates, - TracksSel const&) + TracksSel const& tracks, + TracksSelLf const& lfTracks) { // looping over charm baryon candidates @@ -202,10 +204,14 @@ struct HfCandidateSelectorToOmegaKa { bool resultSelections = true; // True if the candidate passes all the selections, False otherwise - auto trackV0PosDau = candidate.posTrack_as(); // positive V0 daughter - auto trackV0NegDau = candidate.negTrack_as(); // negative V0 daughter - auto trackKaFromCasc = candidate.bachelor_as(); // kaon <- cascade - auto trackKaFromCharm = candidate.bachelorFromCharmBaryon_as(); // kaon <- charm baryon + 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; @@ -302,7 +308,7 @@ struct HfCandidateSelectorToOmegaKa { } // dcaXY v0 daughters to PV cut - if (candidate.dcaXYToPvV0Dau0() < dcaPosToPvMin || candidate.dcaXYToPvV0Dau1() < dcaNegToPvMin) { + if (std::abs(candidate.dcaXYToPvV0Dau0()) < dcaPosToPvMin || std::abs(candidate.dcaXYToPvV0Dau1()) < dcaNegToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvV0Daughters"), 0); } else { @@ -310,7 +316,7 @@ struct HfCandidateSelectorToOmegaKa { } // dcaXY ka <-- cascade to PV cut - if (candidate.dcaXYToPvCascDau() < dcaBachToPvMin) { + if (std::abs(candidate.dcaXYToPvCascDau()) < dcaBachToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvKaFromCasc"), 0); } else { diff --git a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx index 2ecc7afc038..129887ed876 100644 --- a/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorOmegac0ToOmegaPi.cxx @@ -129,6 +129,7 @@ struct HfCandidateSelectorToOmegaPi { TrackSelectorKa selectorKaon; using TracksSel = soa::Join; + using TracksSelLf = soa::Join; HistogramRegistry registry{"registry"}; // for QA of selections @@ -194,17 +195,22 @@ struct HfCandidateSelectorToOmegaPi { } void process(aod::HfCandToOmegaPi const& candidates, - TracksSel const&) + TracksSel const& tracks, + TracksSelLf const& lfTracks) { // looping over charm baryon candidates for (const auto& candidate : candidates) { bool resultSelections = true; // True if the candidate passes all the selections, False otherwise - auto trackV0PosDau = candidate.posTrack_as(); // positive V0 daughter - auto trackV0NegDau = candidate.negTrack_as(); // negative V0 daughter - auto trackKaFromCasc = candidate.bachelor_as(); // kaon <- cascade - auto trackPiFromCharm = candidate.bachelorFromCharmBaryon_as(); // pion <- charm baryon + auto trackV0PosDauId = candidate.posTrackId(); // positive V0 daughter + auto trackV0NegDauId = candidate.negTrackId(); // negative V0 daughter + auto trackKaFromCascId = candidate.bachelorId(); // kaon <- cascade + auto trackPiFromCharmId = candidate.bachelorFromCharmBaryonId(); // pion <- charm baryon + auto trackV0PosDau = lfTracks.rawIteratorAt(trackV0PosDauId); + auto trackV0NegDau = lfTracks.rawIteratorAt(trackV0NegDauId); + auto trackKaFromCasc = lfTracks.rawIteratorAt(trackKaFromCascId); + auto trackPiFromCharm = tracks.rawIteratorAt(trackPiFromCharmId); auto trackPiFromLam = trackV0NegDau; auto trackPrFromLam = trackV0PosDau; @@ -301,7 +307,7 @@ struct HfCandidateSelectorToOmegaPi { } // dcaXY v0 daughters to PV cut - if (candidate.dcaXYToPvV0Dau0() < dcaPosToPvMin || candidate.dcaXYToPvV0Dau1() < dcaNegToPvMin) { + if (std::abs(candidate.dcaXYToPvV0Dau0()) < dcaPosToPvMin || std::abs(candidate.dcaXYToPvV0Dau1()) < dcaNegToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvV0Daughters"), 0); } else { @@ -309,7 +315,7 @@ struct HfCandidateSelectorToOmegaPi { } // dcaXY ka <-- cascade to PV cut - if (candidate.dcaXYToPvCascDau() < dcaBachToPvMin) { + if (std::abs(candidate.dcaXYToPvCascDau()) < dcaBachToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvKaFromCasc"), 0); } else { diff --git a/PWGHF/TableProducer/candidateSelectorToXiPi.cxx b/PWGHF/TableProducer/candidateSelectorToXiPi.cxx index eff8377e44a..20fb96ece0b 100644 --- a/PWGHF/TableProducer/candidateSelectorToXiPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorToXiPi.cxx @@ -118,6 +118,7 @@ struct HfCandidateSelectorToXiPi { TrackSelectorPr selectorProton; using TracksSel = soa::Join; + using TracksSelLf = soa::Join; HistogramRegistry registry{"registry"}; // for QA of selections @@ -176,7 +177,8 @@ struct HfCandidateSelectorToXiPi { } void process(aod::HfCandToXiPi const& candidates, - TracksSel const&) + TracksSel const& tracks, + TracksSelLf const& lfTracks) { double massLambdaFromPDG = o2::constants::physics::MassLambda0; @@ -187,10 +189,14 @@ struct HfCandidateSelectorToXiPi { bool resultSelections = true; // True if the candidate passes all the selections, False otherwise - auto trackV0PosDau = candidate.posTrack_as(); // positive V0 daughter - auto trackV0NegDau = candidate.negTrack_as(); // negative V0 daughter - auto trackPiFromCasc = candidate.bachelor_as(); // pion <- cascade - auto trackPiFromCharm = candidate.bachelorFromCharmBaryon_as(); // pion <- charm baryon + auto trackV0PosDauId = candidate.posTrackId(); // positive V0 daughter + auto trackV0NegDauId = candidate.negTrackId(); // negative V0 daughter + auto trackPiFromCascId = candidate.bachelorId(); // pion <- cascade + auto trackPiFromCharmId = candidate.bachelorFromCharmBaryonId(); // pion <- charm baryon + auto trackV0PosDau = lfTracks.rawIteratorAt(trackV0PosDauId); + auto trackV0NegDau = lfTracks.rawIteratorAt(trackV0NegDauId); + auto trackPiFromCasc = lfTracks.rawIteratorAt(trackPiFromCascId); + auto trackPiFromCharm = tracks.rawIteratorAt(trackPiFromCharmId); auto trackPiFromLam = trackV0NegDau; auto trackPrFromLam = trackV0PosDau; @@ -287,7 +293,7 @@ struct HfCandidateSelectorToXiPi { } // dcaXY v0 daughters to PV cut - if (candidate.dcaXYToPvV0Dau0() < dcaPosToPvMin || candidate.dcaXYToPvV0Dau1() < dcaNegToPvMin) { + if (std::abs(candidate.dcaXYToPvV0Dau0()) < dcaPosToPvMin || std::abs(candidate.dcaXYToPvV0Dau1()) < dcaNegToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvV0Daughters"), 0); } else { @@ -295,7 +301,7 @@ struct HfCandidateSelectorToXiPi { } // dcaXY pi <-- cascade to PV cut - if (candidate.dcaXYToPvCascDau() < dcaBachToPvMin) { + if (std::abs(candidate.dcaXYToPvCascDau()) < dcaBachToPvMin) { resultSelections = false; registry.fill(HIST("hSelDcaXYToPvPiFromCasc"), 0); } else { diff --git a/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx b/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx index 14e9bef0bd6..64ecd5cf65e 100644 --- a/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorXicToPKPi.cxx @@ -17,6 +17,9 @@ /// \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" @@ -60,7 +63,7 @@ struct HfCandidateSelectorXicToPKPi { 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 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"}; @@ -313,11 +316,11 @@ struct HfCandidateSelectorXicToPKPi { bool isSelectedMlXicToPiKP = false; if (topolXicToPKPi && pidXicToPKPi) { - std::vector inputFeaturesXicToPKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2); + std::vector inputFeaturesXicToPKPi = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, true); isSelectedMlXicToPKPi = hfMlResponse.isSelectedMl(inputFeaturesXicToPKPi, ptCand, outputMlXicToPKPi); } if (topolXicToPiKP && pidXicToPiKP) { - std::vector inputFeaturesXicToPiKP = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2); + std::vector inputFeaturesXicToPiKP = hfMlResponse.getInputFeatures(candidate, trackPos1, trackNeg, trackPos2, false); isSelectedMlXicToPiKP = hfMlResponse.isSelectedMl(inputFeaturesXicToPiKP, ptCand, outputMlXicToPiKP); } diff --git a/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx index 5e2d69d04bd..49b4b2df01b 100644 --- a/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateSelectorXicToXiPiPi.cxx @@ -12,13 +12,18 @@ /// \file candidateSelectorXicToXiPiPi.cxx /// \brief Ξc± → Ξ∓ π± π± candidate selector /// -/// \author Phil Lennart Stahlhut , CERN +/// \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" @@ -31,6 +36,7 @@ using namespace o2::analysis; struct HfCandidateSelectorXicToXiPiPi { Produces hfSelXicToXiPiPiCandidate; + Produces hfMlXicToXiPiPiCandidate; Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; Configurable ptCandMax{"ptCandMax", 36., "Upper bound of candidate pT"}; @@ -52,7 +58,23 @@ 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"}; - + // 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> 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/BDTXicToXiPiPi"}, "Paths of models on CCDB"}; + Configurable> onnxFileNames{"onnxFileNames", std::vector{"ModelHandler_onnx_XicToXiPiPi.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::HfMlResponseXicToXiPiPi hfMlResponse; + std::vector outputMlXicToXiPiPi = {}; + o2::ccdb::CcdbApi ccdbApi; TrackSelectorPi selectorPion; TrackSelectorPr selectorProton; @@ -93,6 +115,18 @@ struct HfCandidateSelectorXicToXiPiPi { registry.get(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data()); } } + + 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(); + } } /// Conjugate-independent topological cuts @@ -188,6 +222,9 @@ struct HfCandidateSelectorXicToXiPiPi { { for (const auto& hfCandXic : hfCandsXic) { int statusXicToXiPiPi = 0; + + outputMlXicToXiPiPi.clear(); + auto ptCandXic = hfCandXic.pt(); if (activateQA) { @@ -203,6 +240,9 @@ struct HfCandidateSelectorXicToXiPiPi { // topological cuts if (!selectionTopol(hfCandXic)) { hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); + if (applyMl) { + hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); + } continue; } SETBIT(statusXicToXiPiPi, SelectionStep::RecoTopol); // RecoTopol = 1 --> statusXicToXiPiPi = 3 @@ -233,6 +273,9 @@ struct HfCandidateSelectorXicToXiPiPi { if (!selectionPid(pidTrackPi0, pidTrackPi1, pidTrackPr, pidTrackPiLam, pidTrackPiXi, acceptPIDNotApplicable.value)) { hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); + if (applyMl) { + hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); + } continue; } SETBIT(statusXicToXiPiPi, SelectionStep::RecoPID); // RecoPID = 2 --> statusXicToXiPiPi = 7 @@ -241,6 +284,23 @@ struct HfCandidateSelectorXicToXiPiPi { } } + // ML selections + + if (applyMl) { + bool isSelectedMlXicToXiPiPi = false; + std::vector inputFeaturesXicToXiPiPi = hfMlResponse.getInputFeatures(hfCandXic); + + isSelectedMlXicToXiPiPi = hfMlResponse.isSelectedMl(inputFeaturesXicToXiPiPi, ptCandXic, outputMlXicToXiPiPi); + + hfMlXicToXiPiPiCandidate(outputMlXicToXiPiPi); + + if (!isSelectedMlXicToXiPiPi) { + hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); + continue; + } + SETBIT(statusXicToXiPiPi, aod::SelectionStep::RecoMl); + } + hfSelXicToXiPiPiCandidate(statusXicToXiPiPi); } } diff --git a/PWGHF/TableProducer/converterDstarIndices.cxx b/PWGHF/TableProducer/converterDstarIndices.cxx new file mode 100644 index 00000000000..9596a571498 --- /dev/null +++ b/PWGHF/TableProducer/converterDstarIndices.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. + +/// \file converterDstarIndices.cxx +/// \brief Task for conversion of HfDstars to version 001, using the collision index from the D0 daughter +/// +/// \author Fabrizio Grosa , CERN + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +#include "PWGHF/DataModel/CandidateReconstructionTables.h" + +using namespace o2; +using namespace o2::framework; + +struct HfConverterDstarIndices { + Produces dstarIndices; + + void process(aod::HfDstars_000::iterator const& candDstar, + aod::Hf2Prongs const&) + { + auto candDzero = candDstar.prongD0_as(); + dstarIndices(candDzero.collisionId(), candDstar.prong0Id(), candDstar.prongD0Id()); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx new file mode 100644 index 00000000000..6c0ada5de5b --- /dev/null +++ b/PWGHF/TableProducer/derivedDataCreatorBplusToD0Pi.cxx @@ -0,0 +1,557 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 derivedDataCreatorBplusToD0Pi.cxx +/// \brief Producer of derived tables of B+ candidates, collisions and MC particles +/// \note Based on derivedDataCreatorLcToPKPi.cxx +/// +/// \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 "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" + +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; + +/// Writes the full information in an output TTree +struct HfDerivedDataCreatorBplusToD0Pi { + // Candidates + Produces rowCandidateBase; + Produces rowCandidatePar; + Produces rowCandidateParD0; + Produces rowCandidateParE; + Produces rowCandidateMl; + Produces rowCandidateMlD0; + Produces rowCandidateId; + Produces rowCandidateMc; + // Collisions + Produces rowCollBase; + Produces rowCollId; + // MC collisions + Produces rowMcCollBase; + Produces rowMcCollId; + Produces rowMcRCollId; + // MC particles + Produces rowParticleBase; + Produces rowParticleId; + + // Switches for filling tables + Configurable fillCandidateBase{"fillCandidateBase", true, "Fill candidate base properties"}; + Configurable fillCandidatePar{"fillCandidatePar", true, "Fill candidate parameters"}; + Configurable fillCandidateParD0{"fillCandidateParD0", true, "Fill D0 candidate parameters"}; + Configurable fillCandidateParE{"fillCandidateParE", true, "Fill candidate extended parameters"}; + Configurable fillCandidateMl{"fillCandidateMl", true, "Fill candidate selection ML scores"}; + Configurable fillCandidateMlD0{"fillCandidateMlD0", true, "Fill D0 candidate selection ML scores"}; + Configurable fillCandidateId{"fillCandidateId", true, "Fill original indices from the candidate table"}; + Configurable fillCandidateMc{"fillCandidateMc", true, "Fill candidate MC info"}; + Configurable fillCollBase{"fillCollBase", true, "Fill collision base properties"}; + Configurable fillCollId{"fillCollId", true, "Fill original collision indices"}; + Configurable fillMcCollBase{"fillMcCollBase", true, "Fill MC collision base properties"}; + Configurable fillMcCollId{"fillMcCollId", true, "Fill original MC collision indices"}; + Configurable fillMcRCollId{"fillMcRCollId", true, "Fill indices of saved derived reconstructed collisions matched to saved derived MC collisions"}; + Configurable fillParticleBase{"fillParticleBase", true, "Fill MC particle properties"}; + Configurable fillParticleId{"fillParticleId", true, "Fill original MC indices"}; + // 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; + std::map> matchedCollisions; // indices of derived reconstructed collisions matched to the global indices of MC collisions + std::map hasMcParticles; // flags for MC collisions with HF particles + + 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 = aod::McCollisions; + using THfCandDaughters = aod::HfCand2ProngWPid; + 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)); + + 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_bplus::isSelBplusToD0Pi >= 0; + Partition candidatesMcAll = aod::hf_sel_candidate_bplus::isSelBplusToD0Pi >= 0; + 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)); + + void init(InitContext const&) + { + std::array doprocess{doprocessData, doprocessMcSig, doprocessMcBkg, doprocessMcAll, doprocessDataMl, doprocessMcMlSig, doprocessMcMlBkg, doprocessMcMlAll}; + if (std::accumulate(doprocess.begin(), doprocess.end(), 0) != 1) { + LOGP(fatal, "Only one process function can be enabled at a time."); + } + } + + template + // void fillTablesCollision(const T& collision, int isEventReject, int runNumber) + void fillTablesCollision(const T& collision) + { + if (fillCollBase) { + rowCollBase( + collision.posX(), + collision.posY(), + collision.posZ(), + collision.numContrib(), + collision.centFT0A(), + collision.centFT0C(), + collision.centFT0M(), + collision.centFV0A(), + collision.multZeqNTracksPV()); + // isEventReject, + // runNumber); + } + if (fillCollId) { + rowCollId( + collision.globalIndex()); + } + if constexpr (isMC) { + if (fillMcRCollId && collision.has_mcCollision()) { + // Save rowCollBase.lastIndex() at key collision.mcCollisionId() + LOGF(debug, "Rec. collision %d: Filling derived-collision index %d for MC collision %d", collision.globalIndex(), rowCollBase.lastIndex(), collision.mcCollisionId()); + matchedCollisions[collision.mcCollisionId()].push_back(rowCollBase.lastIndex()); // [] inserts an empty element if it does not exist + } + } + } + + template + void fillTablesMcCollision(const T& mcCollision) + { + if (fillMcCollBase) { + rowMcCollBase( + mcCollision.posX(), + mcCollision.posY(), + mcCollision.posZ()); + } + if (fillMcCollId) { + rowMcCollId( + mcCollision.globalIndex()); + } + if (fillMcRCollId) { + // Fill the table with the vector of indices of derived reconstructed collisions matched to mcCollision.globalIndex() + rowMcRCollId( + matchedCollisions[mcCollision.globalIndex()]); + } + } + + 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) + { + if (fillCandidateBase) { + rowCandidateBase( + rowCollBase.lastIndex(), + candidate.pt(), + candidate.eta(), + candidate.phi(), + 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 (fillCandidateParD0) { + std::array, 2>, 2> sigmas{}; // PID nSigma [Expected][Hypothesis][TPC/TOF/TPC+TOF] + if (candFlag == 0) { + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion], prongCharm, 0, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon], prongCharm, 0, Ka) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion], prongCharm, 1, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon], prongCharm, 1, Ka) + } else if (candFlag == 1) { + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion], prongCharm, 1, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon], prongCharm, 1, Ka) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion], prongCharm, 0, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon], prongCharm, 0, Ka) + } + rowCandidateParD0( + prongCharm.cpa(), + prongCharm.decayLength(), + prongCharm.impactParameter0(), + prongCharm.impactParameter1(), + prongCharm.impactParameterProduct(), + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][0], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][1], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][2], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][0], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][1], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][2], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][0], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][1], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][2], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][0], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][1], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][2]); + } + 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.cosThetaStarBplus(candidate), + ct); + } + if (fillCandidateMl) { + rowCandidateMl( + mlScore); + } + if (fillCandidateMlD0) { + rowCandidateMlD0( + mlScoresCharm); + } + if (fillCandidateId) { + rowCandidateId( + candidate.collisionId(), + prongCharm.prong0Id(), + prongCharm.prong1Id(), + candidate.prong1Id()); + } + if (fillCandidateMc) { + rowCandidateMc( + flagMc, + origin); + } + } + + template + void fillTablesParticle(const T& particle, U mass) + { + if (fillParticleBase) { + rowParticleBase( + rowMcCollBase.lastIndex(), + particle.pt(), + particle.eta(), + particle.phi(), + RecoDecayPtEtaPhi::y(particle.pt(), particle.eta(), mass), + particle.flagMcMatchGen(), + particle.originMcGen()); + } + if (fillParticleId) { + rowParticleId( + particle.mcCollisionId(), + particle.globalIndex()); + } + } + + template + void processCandidates(CollType const& collisions, + Partition& candidates, + CandCharmType const&, + TracksWPid const&, + aod::BCs const&) + { + // Fill collision properties + if constexpr (isMc) { + if (fillMcRCollId) { + matchedCollisions.clear(); + } + } + auto sizeTableColl = collisions.size(); + reserveTable(rowCollBase, fillCollBase, sizeTableColl); + reserveTable(rowCollId, fillCollId, 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 = fillMcRCollId && collision.has_mcCollision() && 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 && (!fillMcRCollId || !mcCollisionHasMcParticles)) { + LOGF(debug, "Skipping rec. collision %d", thisCollId); + continue; + } + LOGF(debug, "Filling rec. collision %d at derived index %d", thisCollId, rowCollBase.lastIndex() + 1); + // fillTablesCollision(collision, 0, collision.bc().runNumber()); + fillTablesCollision(collision); + + // Fill candidate properties + reserveTable(rowCandidateBase, fillCandidateBase, sizeTableCand); + reserveTable(rowCandidatePar, fillCandidatePar, sizeTableCand); + reserveTable(rowCandidateParD0, fillCandidateParD0, sizeTableCand); + reserveTable(rowCandidateParE, fillCandidateParE, sizeTableCand); + reserveTable(rowCandidateMl, fillCandidateMl, sizeTableCand); + reserveTable(rowCandidateMlD0, fillCandidateMlD0, 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 (isMc) { + flagMcRec = candidate.flagMcMatchRec(); + origin = candidate.originMcRec(); + if constexpr (onlyBkg) { + if (TESTBIT(std::abs(flagMcRec), aod::hf_cand_bplus::DecayType::BplusToD0Pi)) { + 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), aod::hf_cand_bplus::DecayType::BplusToD0Pi)) { + continue; + } + } + } + auto prongCharm = candidate.template prong0_as(); + auto prongBachelor = candidate.template prong1_as(); + double ct = hfHelper.ctBplus(candidate); + double y = hfHelper.yBplus(candidate); + float massBplusToD0Pi = hfHelper.invMassBplusToD0Pi(candidate); + float mlScoreBplusToD0Pi{-1.f}; + std::vector mlScoresD0; + bool isD0 = prongBachelor.sign() < 0; // D0 or D0bar + 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); + } + } + } + + template + void preProcessMcCollisions(CollisionType const& mcCollisions, + ParticleType const& mcParticles) + { + if (!fillMcRCollId) { + return; + } + hasMcParticles.clear(); + // Fill MC collision flags + for (const auto& mcCollision : mcCollisions) { + auto thisMcCollId = mcCollision.globalIndex(); + auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); + LOGF(debug, "MC collision %d has %d MC particles (preprocess)", thisMcCollId, particlesThisMcColl.size()); + hasMcParticles[thisMcCollId] = (particlesThisMcColl.size() > 0); + } + } + + template + void processMcParticles(CollisionType const& mcCollisions, + ParticleType const& mcParticles) + { + // Fill MC collision properties + auto sizeTableMcColl = mcCollisions.size(); + reserveTable(rowMcCollBase, fillMcCollBase, sizeTableMcColl); + reserveTable(rowMcCollId, fillMcCollId, sizeTableMcColl); + reserveTable(rowMcRCollId, fillMcRCollId, sizeTableMcColl); + for (const auto& mcCollision : mcCollisions) { + auto thisMcCollId = mcCollision.globalIndex(); + auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); + auto sizeTablePart = particlesThisMcColl.size(); + LOGF(debug, "MC collision %d has %d MC particles", thisMcCollId, sizeTablePart); + // Skip MC collisions without HF particles (and without HF candidates in matched reconstructed collisions if saving indices of reconstructed collisions matched to MC collisions) + LOGF(debug, "MC collision %d has %d saved derived rec. collisions", thisMcCollId, matchedCollisions[thisMcCollId].size()); + if (sizeTablePart == 0 && (!fillMcRCollId || matchedCollisions[thisMcCollId].empty())) { + LOGF(debug, "Skipping MC collision %d", thisMcCollId); + continue; + } + LOGF(debug, "Filling MC collision %d at derived index %d", thisMcCollId, rowMcCollBase.lastIndex() + 1); + fillTablesMcCollision(mcCollision); + + // Fill MC particle properties + reserveTable(rowParticleBase, fillParticleBase, sizeTablePart); + reserveTable(rowParticleId, fillParticleId, sizeTablePart); + for (const auto& particle : particlesThisMcColl) { + fillTablesParticle(particle, o2::constants::physics::MassBPlus); + } + } + } + + void processData(CollisionsWCentMult const& collisions, + SelectedCandidates const&, + THfCandDaughters const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + processCandidates(collisions, candidatesAll, candidatesDaughters, tracks, bcs); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processData, "Process data", true); + + void processMcSig(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughters const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcSig, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processMcSig, "Process MC only for signals", false); + + void processMcBkg(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughters const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcBkg, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processMcBkg, "Process MC only for background", false); + + void processMcAll(CollisionsWMcCentMult const& collisions, + SelectedCandidatesMc const&, + TypeMcCollisions const& mcCollisions, + MatchedGenCandidatesMc const& mcParticles, + THfCandDaughters const& candidatesDaughters, + TracksWPid const& tracks, + aod::BCs const& bcs) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcAll, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, 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(HfDerivedDataCreatorBplusToD0Pi, 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) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcMlSig, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, 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) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcMlBkg, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, 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) + { + preProcessMcCollisions(mcCollisions, mcParticles); + processCandidates(collisions, candidatesMcMlAll, candidatesDaughters, tracks, bcs); + processMcParticles(mcCollisions, mcParticles); + } + PROCESS_SWITCH(HfDerivedDataCreatorBplusToD0Pi, processMcMlAll, "Process MC with ML", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx index 694d773cf4f..de26dc1dff3 100644 --- a/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorD0ToKPi.cxx @@ -15,6 +15,10 @@ /// /// \author Vít Kučera , Inha University +#include +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -27,10 +31,14 @@ #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" 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; /// Writes the full information in an output TTree struct HfDerivedDataCreatorD0ToKPi { @@ -79,15 +87,15 @@ struct HfDerivedDataCreatorD0ToKPi { using CollisionsWCentMult = soa::Join; using CollisionsWMcCentMult = soa::Join; - using TracksWPid = soa::Join; - using SelectedCandidates = soa::Filtered>; - using SelectedCandidatesKf = soa::Filtered>; - using SelectedCandidatesMc = soa::Filtered>; - using SelectedCandidatesMcKf = soa::Filtered>; - using SelectedCandidatesMl = soa::Filtered>; - using SelectedCandidatesKfMl = soa::Filtered>; - using SelectedCandidatesMcMl = soa::Filtered>; - using SelectedCandidatesMcKfMl = soa::Filtered>; + // using TracksWPid = soa::Join; + using SelectedCandidates = soa::Filtered>; + using SelectedCandidatesKf = soa::Filtered>; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMcKf = soa::Filtered>; + using SelectedCandidatesMl = soa::Filtered>; + using SelectedCandidatesKfMl = soa::Filtered>; + using SelectedCandidatesMcMl = soa::Filtered>; + using SelectedCandidatesMcKfMl = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; using TypeMcCollisions = aod::McCollisions; @@ -132,14 +140,6 @@ struct HfDerivedDataCreatorD0ToKPi { } } - template - void reserveTable(T& table, const Configurable& enabled, const uint64_t size) - { - if (enabled.value) { - table.reserve(size); - } - }; - template // void fillTablesCollision(const T& collision, int isEventReject, int runNumber) void fillTablesCollision(const T& collision) @@ -191,8 +191,8 @@ struct HfDerivedDataCreatorD0ToKPi { } } - template - void fillTablesCandidate(const T& candidate, const U& prong0, const U& prong1, int candFlag, double invMass, double cosThetaStar, double topoChi2, + template + void fillTablesCandidate(const T& candidate, int candFlag, double invMass, double cosThetaStar, double topoChi2, double ct, double y, int8_t flagMc, int8_t origin, const std::vector& mlScores) { if (fillCandidateBase) { @@ -205,6 +205,18 @@ struct HfDerivedDataCreatorD0ToKPi { y); } if (fillCandidatePar) { + std::array, 2>, 2> sigmas{}; // PID nSigma [Expected][Hypothesis][TPC/TOF/TPC+TOF] + if (candFlag == 0) { + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion], candidate, 0, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon], candidate, 0, Ka) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion], candidate, 1, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon], candidate, 1, Ka) + } else if (candFlag == 1) { + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion], candidate, 1, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon], candidate, 1, Ka) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion], candidate, 0, Pi) + GET_N_SIGMA_PRONG(sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon], candidate, 0, Ka) + } rowCandidatePar( candidate.chi2PCA(), candidate.cpa(), @@ -219,18 +231,18 @@ struct HfDerivedDataCreatorD0ToKPi { candidate.impactParameter1(), candidate.impactParameterNormalised0(), candidate.impactParameterNormalised1(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.tpcTofNSigmaKa(), + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][0], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][1], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Pion][2], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][0], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][1], + sigmas[HfProngSpecies::Pion][HfProngSpecies::Kaon][2], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][0], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][1], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Pion][2], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][0], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][1], + sigmas[HfProngSpecies::Kaon][HfProngSpecies::Kaon][2], candidate.maxNormalisedDeltaIP(), candidate.impactParameterProduct()); } @@ -300,7 +312,7 @@ struct HfDerivedDataCreatorD0ToKPi { template void processCandidates(CollType const& collisions, Partition& candidates, - TracksWPid const&, + aod::Tracks const&, aod::BCs const&) { // Fill collision properties @@ -336,6 +348,7 @@ struct HfDerivedDataCreatorD0ToKPi { 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); @@ -350,7 +363,7 @@ struct HfDerivedDataCreatorD0ToKPi { 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; } @@ -361,9 +374,15 @@ struct HfDerivedDataCreatorD0ToKPi { 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(); + double ct = hfHelper.ctD0(candidate); double y = hfHelper.yD0(candidate); float massD0, massD0bar; @@ -382,10 +401,10 @@ struct HfDerivedDataCreatorD0ToKPi { std::copy(candidate.mlProbD0bar().begin(), candidate.mlProbD0bar().end(), std::back_inserter(mlScoresD0bar)); } if (candidate.isSelD0()) { - fillTablesCandidate(candidate, prong0, prong1, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ct, y, flagMcRec, origin, mlScoresD0); + fillTablesCandidate(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ct, y, flagMcRec, origin, mlScoresD0); } if (candidate.isSelD0bar()) { - fillTablesCandidate(candidate, prong0, prong1, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ct, y, flagMcRec, origin, mlScoresD0bar); + fillTablesCandidate(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ct, y, flagMcRec, origin, mlScoresD0bar); } } } @@ -415,6 +434,7 @@ struct HfDerivedDataCreatorD0ToKPi { // Fill MC collision properties auto sizeTableMcColl = mcCollisions.size(); reserveTable(rowMcCollBase, fillMcCollBase, sizeTableMcColl); + reserveTable(rowMcCollId, fillMcCollId, sizeTableMcColl); reserveTable(rowMcRCollId, fillMcRCollId, sizeTableMcColl); for (const auto& mcCollision : mcCollisions) { auto thisMcCollId = mcCollision.globalIndex(); @@ -441,7 +461,7 @@ struct HfDerivedDataCreatorD0ToKPi { void processDataWithDCAFitterN(CollisionsWCentMult const& collisions, SelectedCandidates const&, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processCandidates(collisions, candidatesAll, tracks, bcs); @@ -450,7 +470,7 @@ struct HfDerivedDataCreatorD0ToKPi { void processDataWithKFParticle(CollisionsWCentMult const& collisions, SelectedCandidatesKf const&, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processCandidates(collisions, candidatesKfAll, tracks, bcs); @@ -461,7 +481,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -474,7 +494,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -487,7 +507,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMc const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -500,7 +520,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKf const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -513,7 +533,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKf const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -526,7 +546,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKf const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -539,7 +559,7 @@ struct HfDerivedDataCreatorD0ToKPi { void processDataWithDCAFitterNMl(CollisionsWCentMult const& collisions, SelectedCandidatesMl const&, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processCandidates(collisions, candidatesMlAll, tracks, bcs); @@ -548,7 +568,7 @@ struct HfDerivedDataCreatorD0ToKPi { void processDataWithKFParticleMl(CollisionsWCentMult const& collisions, SelectedCandidatesKfMl const&, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processCandidates(collisions, candidatesKfMlAll, tracks, bcs); @@ -559,7 +579,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -572,7 +592,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -585,7 +605,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -598,7 +618,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKfMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -611,7 +631,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKfMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); @@ -624,7 +644,7 @@ struct HfDerivedDataCreatorD0ToKPi { SelectedCandidatesMcKfMl const&, TypeMcCollisions const& mcCollisions, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { preProcessMcCollisions(mcCollisions, mcParticles); diff --git a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx index 645deab1c39..e16c498cd11 100644 --- a/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/derivedDataCreatorLcToPKPi.cxx @@ -15,6 +15,10 @@ /// /// \author Vít Kučera , Inha University +#include +#include +#include + #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -23,14 +27,18 @@ #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" +#include "PWGLF/DataModel/mcCentrality.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" 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 HfDerivedDataCreatorLcToPKPi { @@ -85,7 +93,7 @@ struct HfDerivedDataCreatorLcToPKPi { using SelectedCandidatesMl = soa::Filtered>; using SelectedCandidatesMcMl = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; - using TypeMcCollisions = aod::McCollisions; + 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)); @@ -115,14 +123,6 @@ struct HfDerivedDataCreatorLcToPKPi { } } - template - void reserveTable(T& table, const Configurable& enabled, const uint64_t size) - { - if (enabled.value) { - table.reserve(size); - } - }; - template // void fillTablesCollision(const T& collision, int isEventReject, int runNumber) void fillTablesCollision(const T& collision) @@ -161,7 +161,8 @@ struct HfDerivedDataCreatorLcToPKPi { rowMcCollBase( mcCollision.posX(), mcCollision.posY(), - mcCollision.posZ()); + mcCollision.posZ(), + mcCollision.centFT0M()); } if (fillMcCollId) { rowMcCollId( @@ -329,6 +330,7 @@ struct HfDerivedDataCreatorLcToPKPi { 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); @@ -344,7 +346,7 @@ struct HfDerivedDataCreatorLcToPKPi { 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; } @@ -402,6 +404,7 @@ struct HfDerivedDataCreatorLcToPKPi { // Fill MC collision properties auto sizeTableMcColl = mcCollisions.size(); reserveTable(rowMcCollBase, fillMcCollBase, sizeTableMcColl); + reserveTable(rowMcCollId, fillMcCollId, sizeTableMcColl); reserveTable(rowMcRCollId, fillMcRCollId, sizeTableMcColl); for (const auto& mcCollision : mcCollisions) { auto thisMcCollId = mcCollision.globalIndex(); diff --git a/PWGHF/TableProducer/mcPidTof.cxx b/PWGHF/TableProducer/mcPidTof.cxx new file mode 100644 index 00000000000..ec4ff54b2e3 --- /dev/null +++ b/PWGHF/TableProducer/mcPidTof.cxx @@ -0,0 +1,1035 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 mcPidTof.cxx +/// \author Fabrizio Grosa fabrizio.grosa@cern.ch +/// \brief Task to produce PID tables for TOF split for pi, K, p, copied from https://github.com/AliceO2Group/O2Physics/blob/master/Common/TableProducer/PID/pidTofMerge.cxx +/// It works only for MC and adds the possibility to apply postcalibrations for MC. +/// + +#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/DataModel/EventSelection.h" +#include "Common/DataModel/FT0Corrected.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/TableProducer/PID/pidTOFBase.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::pid; +using namespace o2::framework::expressions; +using namespace o2::track; + +MetadataHelper metadataInfo; + +// Input data types +using Trks = o2::soa::Join; +using Cols = aod::Collisions; +using TrksWtof = soa::Join; +using TrksWtofWevTime = soa::Join; + +using EvTimeCollisions = soa::Join; +using EvTimeCollisionsFT0 = soa::Join; + +// Configuration common to all tasks +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; + mParamFileName = opt.cfgParamFileName.value; + mParametrizationPath = opt.cfgParametrizationPath.value; + mReconstructionPass = opt.cfgReconstructionPass.value; + mLoadResponseFromCCDB = opt.cfgLoadResponseFromCCDB.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, true)) { + 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", mTimeShiftCCDBPathPos, task); + getCfg(initContext, "paramFileName", mParamFileName, task); + getCfg(initContext, "parametrizationPath", mParametrizationPath, task); + getCfg(initContext, "reconstructionPass", mReconstructionPass, task); + getCfg(initContext, "loadResponseFromCCDB", mLoadResponseFromCCDB, 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 { + LOG(fatal) << "This task works only for MC"; + } + LOG(info) << "Passed autodetect mode for pass. Taking '" << mReconstructionPass << "'"; + } + LOG(info) << "Using parameter collection, starting from pass '" << mReconstructionPass << "'"; + + const std::string fname = mParamFileName; + if (!fname.empty()) { // Loading the parametrization from file + LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << mParametrizationPath; + if (1) { + o2::tof::ParameterCollection paramCollection; + paramCollection.loadParamFromFile(fname, mParametrizationPath); + LOG(info) << "+++ Loaded parameter collection from file +++"; + 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", mReconstructionPass.data()); + } + } else { + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass)); + mRespParamsV3.printMomentumChargeShiftParameters(); + } + } else { + mRespParamsV3.loadParamFromFile(fname.data(), mParametrizationPath); + } + } else if (mLoadResponseFromCCDB) { // Loading it from CCDB + LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << mParametrizationPath << " for timestamp " << mTimestamp; + o2::tof::ParameterCollection* paramCollection = ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp); + paramCollection->print(); + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass)) { // Attempt at loading the parameters with the pass defined + 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", mReconstructionPass.data()); + } + } else { // Pass is available, load non standard parameters + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); + mRespParamsV3.printMomentumChargeShiftParameters(); + } + } + // Calibration object is defined + mRespParamsV3.print(); + + // Loading additional calibration objects + if (mTimeShiftCCDBPathPos != "") { + if (mTimeShiftCCDBPathPos.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathPos, "ccdb_object", true); + } else { + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathPos, mTimestamp), true); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathPos, mTimestamp, metadata), true); + } + } + } + if (mTimeShiftCCDBPathNeg != "") { + if (mTimeShiftCCDBPathNeg.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathNeg, "ccdb_object", false); + } else { + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathNeg, mTimestamp), false); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathNeg, mTimestamp, metadata), false); + } + } + } + } + + 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; + } + mLastRunNumber = bc.runNumber(); + mTimestamp = bc.timestamp(); + + // Check the beam type + if (mCollisionSystem == -1) { + o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp(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(debug) << "Updating parametrization from path '" << mParametrizationPath << "' and timestamp " << mTimestamp; + if (!ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp)->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", mReconstructionPass.data()); + } + } + return; + } + + bool autoSetProcessFunctions() const { return mAutoSetProcessFunctions; } + int collisionSystem() const { return mCollisionSystem; } + + 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 mParamFileName; + std::string mParametrizationPath; + std::string mReconstructionPass; + bool mLoadResponseFromCCDB; + bool mFatalOnPassNotAvailable; + bool mEnableTimeDependentResponse; + int mCollisionSystem; + bool mAutoSetProcessFunctions; +}; + +// Part 1 TOF signal definition + +/// Selection criteria for tracks used for TOF event time +bool isTrackGoodMatchForTOFPID(const Trks::iterator& tr) +{ + if (!tr.hasTOF()) { + return false; + } + return true; +} + +/// Task to produce the TOF signal from the trackTime information +struct tofSignal { + // Tables to produce + o2::framework::Produces table; + o2::framework::Produces tableFlags; + // Running flags + bool enableTableTOFSignal = false; // Flag to check if the TOF signal table is requested or not + bool enableTablepidTOFFlags = false; // Flag to check if the TOF signal flags table is requested or not + // Output histograms + Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + // Detector response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + Service ccdb; + struct : ConfigurableGroup { + Configurable cfgUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; + Configurable cfgTimestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + Configurable cfgTimeShiftCCDBPathPos{"timeShiftCCDBPathPos", "", "Path of the TOF time shift vs eta for pos. tracks. If empty none is taken"}; + Configurable cfgTimeShiftCCDBPathNeg{"timeShiftCCDBPathNeg", "", "Path of the TOF time shift vs eta for neg. tracks. If empty none is taken"}; + Configurable cfgParamFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; + Configurable cfgParametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; + Configurable cfgReconstructionPass{"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."}}; + Configurable cfgLoadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; + Configurable cfgFatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; + Configurable cfgEnableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; + Configurable cfgCollisionSystem{"collisionSystem", -1, "Collision system: -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"}; + Configurable cfgAutoSetProcessFunctions{"autoSetProcessFunctions", true, "Flag to autodetect the process functions to use"}; + } cfg; // Configurables (only defined here and inherited from other tasks) + + TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration + + void init(o2::framework::InitContext& initContext) + { + mTOFCalibConfig.init(cfg); + // Checking that the table is requested in the workflow and enabling it + enableTableTOFSignal = isTableRequiredInWorkflow(initContext, "TOFSignal"); + if (enableTableTOFSignal) { + LOG(info) << "Table TOFSignal enabled!"; + } + enableTablepidTOFFlags = isTableRequiredInWorkflow(initContext, "pidTOFFlags"); + if (enableTablepidTOFFlags) { + LOG(info) << "Table pidTOFFlags enabled!"; + } + + // If the table is not requested, disable the task. Uless a process function is enabled from the workflow configuration + if (!enableTableTOFSignal && !enableTablepidTOFFlags) { + LOG(info) << "No table or process is enabled. Disabling task"; + return; + } + + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters + if (!enableQaHistograms) { + return; + } + histos.add("tofSignal", "tofSignal", kTH1D, {{1000, -1000, 1000000, "tofSignal (ps)"}}); + if (enableTablepidTOFFlags) { + histos.add("goodForPIDFlags", "goodForPIDFlags", kTH1D, {{3, 0, 3, "flags"}}); + } + } + + void process(Trks const& tracks) + { + if (!enableTableTOFSignal) { + return; + } + table.reserve(tracks.size()); + if (enableTablepidTOFFlags) { + tableFlags.reserve(tracks.size()); + } + for (auto& trk : tracks) { + const float& sig = o2::pid::tof::TOFSignal::GetTOFSignal(trk); + if (enableQaHistograms) { + histos.fill(HIST("tofSignal"), sig); + } + table(sig); + if (!enableTablepidTOFFlags) { + continue; + } + const auto& b = isTrackGoodMatchForTOFPID(trk); + if (enableQaHistograms) { + histos.fill(HIST("goodForPIDFlags"), sig); + } + tableFlags(b); + } + } +}; + +/// 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.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 +template typename response, + typename trackTypeContainer, + typename responseParametersType> +o2::tof::eventTimeContainer evTimeMakerForTracks(const trackTypeContainer& tracks, + const responseParametersType& responseParameters, + const float& diamond = 6.0) +{ + return o2::tof::evTimeMakerFromParam(tracks, responseParameters, diamond); +} + +// Part 2 event time definition + +/// Task to produce the TOF event time table +struct tofEventTime { + // Tables to produce + 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); + + bool enableTableTOFEvTime = false; + bool enableTableEvTimeTOFOnly = false; + // Detector response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + Service ccdb; + TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration + + // 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"}; + + void init(o2::framework::InitContext& initContext) + { + mTOFCalibConfig.inheritFromBaseTask(initContext); + // Checking that the table is requested in the workflow and enabling it + enableTableTOFEvTime = isTableRequiredInWorkflow(initContext, "TOFEvTime"); + + if (!enableTableTOFEvTime) { + LOG(info) << "Table for TOF Event time (TOFEvTime) is not required, disabling it"; + } + LOG(info) << "Table TOFEvTime enabled!"; + + enableTableEvTimeTOFOnly = isTableRequiredInWorkflow(initContext, "EvTimeTOFOnly"); + if (enableTableEvTimeTOFOnly) { + LOG(info) << "Table EvTimeTOFOnly enabled!"; + } + + if (!enableTableTOFEvTime && !enableTableEvTimeTOFOnly) { + LOG(info) << "No table is enabled. Disabling task"; + return; + } + + if (metadataInfo.isFullyDefined()) { + if (!metadataInfo.isRun3()) { + LOG(fatal) << "Metadata says it is Run2, but this task supports only Run3"; + } + } + + trackSampleMinMomentum = minMomentum; + trackSampleMaxMomentum = maxMomentum; + LOG(info) << "Configuring track sample for TOF ev. time: " << trackSampleMinMomentum << " < p < " << trackSampleMaxMomentum; + + 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 function to prepare the event for each track on Run 3 data without the FT0 + // Define slice per collision + Preslice perCollision = aod::track::collisionId; + template + using ResponseImplementationEvTime = o2::pid::tof::ExpTimes; + void process(TrksWtof& tracks, + aod::FT0s const&, + EvTimeCollisionsFT0 const&, + aod::BCsWithTimestamps const&) + { + if (!enableTableTOFEvTime) { + return; + } + LOG(debug) << "Processing data for TOF event time"; + + tableEvTime.reserve(tracks.size()); + tableFlags.reserve(tracks.size()); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly.reserve(tracks.size()); + } + bool calibUpdated = false; + for (auto const& track : tracks) { // Loop on all tracks + if (!track.has_collision()) { // Skipping tracks without collisions + continue; + } + const auto& coll = track.collision_as(); + if (!coll.has_bc()) { + continue; + } + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + calibUpdated = true; + break; + } + + // Autoset the processing mode for the event time computation + if (calibUpdated) { + 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; + } + } + } else { + LOG(warning) << "Calibration not updated on " << tracks.size() << " tracks !!"; + } + LOG(debug) << "Running on " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " mComputeEvTimeWithTOF " << mComputeEvTimeWithTOF.value << " mComputeEvTimeWithFT0 " << mComputeEvTimeWithFT0.value; + + 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 + tableFlags(0); + tableEvTime(0.f, 999.f); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + 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 + + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); + const auto& collision = t.collision_as(); + + // Compute the TOF event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + + 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 + + uint8_t flags = 0; + int nGoodTracksForTOF = 0; + float eventTime = 0.f; + float sumOfWeights = 0.f; + float weight = 0.f; + + for (auto const& trk : tracksInCollision) { // Loop on Tracks + // Reset the flag + flags = 0; + // Reset the event time + eventTime = 0.f; + sumOfWeights = 0.f; + weight = 0.f; + // Remove the bias on TOF ev. time + if constexpr (removeTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, t0TOF[0], t0TOF[1], 2); + } + if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || abs(t0TOF[0]) < maxEvTimeTOF)) { + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; + + 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; + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC; + } + + 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; + tableFlags(0); + } else { + tableFlags(flags); + } + tableEvTime(eventTime / sumOfWeights, sqrt(1. / sumOfWeights)); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), t0TOF[0], t0TOF[1], evTimeMakerTOF.mEventTimeMultiplicity); + } + } + } + } 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 + tableFlags(0); + tableEvTime(0.f, 999.f); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + 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 + + const auto& tracksInCollision = tracks.sliceBy(perCollision, lastCollisionId); + + // First make table for event time + const auto evTimeMakerTOF = evTimeMakerForTracks(tracksInCollision, mRespParamsV3, diamond); + int nGoodTracksForTOF = 0; + float et = evTimeMakerTOF.mEventTime; + float erret = evTimeMakerTOF.mEventTimeError; + + for (auto const& trk : tracksInCollision) { // Loop on Tracks + if constexpr (removeTOFEvTimeBias) { + evTimeMakerTOF.removeBias(trk, nGoodTracksForTOF, et, erret, 2); + } + uint8_t flags = 0; + if (erret < errDiamond && (maxEvTimeTOF <= 0.f || abs(et) < maxEvTimeTOF)) { + flags |= o2::aod::pidflags::enums::PIDFlags::EvTimeTOF; + } else { + et = 0.f; + erret = errDiamond; + } + tableFlags(flags); + tableEvTime(et, erret); + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)filterForTOFEventTime(trk), et, erret, evTimeMakerTOF.mEventTimeMultiplicity); + } + } + } + } else if (mComputeEvTimeWithTOF == 0 && mComputeEvTimeWithFT0 == 1) { + for (auto const& t : tracks) { // Loop on collisions + if (enableTableEvTimeTOFOnly) { + tableEvTimeTOFOnly((uint8_t)0, 0.f, 0.f, -1); + } + if (!t.has_collision()) { // Track was not assigned, cannot compute event time + tableFlags(0); + tableEvTime(0.f, 999.f); + continue; + } + const auto& collision = t.collision_as(); + + if (collision.has_foundFT0()) { // T0 measurement is available + // const auto& ft0 = collision.foundFT0(); + if (collision.t0ACValid()) { + tableFlags(o2::aod::pidflags::enums::PIDFlags::EvTimeT0AC); + tableEvTime(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + continue; + } + } + tableFlags(0); + tableEvTime(0.f, 999.f); + } + } else { + LOG(fatal) << "Invalid configuration for TOF event time computation"; + } + } +}; + +// Part 3 Nsigma computation + +static constexpr int idxPi = 2; +static constexpr int idxKa = 3; +static constexpr int idxPr = 4; + +/// Task to produce the response table +struct mcPidTof { + // Tables to produce + Produces tablePIDPi; + Produces tablePIDKa; + Produces tablePIDPr; + + // Tables to produce (full) + Produces tablePIDFullPi; + Produces tablePIDFullKa; + Produces tablePIDFullPr; + + // 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"}; + + // Histograms for QA + std::array, nSpecies> hnSigma; + std::array, nSpecies> hnSigmaFull; + + // postcalibrations to overcome MC FT0 timing issue + std::map gMcPostCalibMean{}; + std::map gMcPostCalibSigma{}; + int currentRun{0}; + struct : ConfigurableGroup { + std::string prefix = "mcRecalib"; + Configurable enable{"enable", false, "enable MC recalibration for Pi/Ka/Pr"}; + Configurable ccdbPath{"ccdbPath", "Users/f/fgrosa/RecalibmcPidTof/", "path for MC recalibration objects in CCDB"}; + } mcRecalib; + + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Running variables + std::vector mEnabledParticles; // Vector of enabled PID hypotheses to loop on when making tables + std::vector mEnabledParticlesFull; // Vector of enabled PID hypotheses to loop on when making full tables + void init(o2::framework::InitContext& initContext) + { + mTOFCalibConfig.inheritFromBaseTask(initContext); + // Checking the tables are requested in the workflow and enabling them (only pi, K, p) + std::array supportedSpecies = {idxPi, idxKa, idxPr}; + for (auto iSpecie{0u}; iSpecie < supportedSpecies.size(); ++iSpecie) { + // First checking tiny + int flag = -1; + enableFlagIfTableRequired(initContext, "pidTOF" + particleNames[supportedSpecies[iSpecie]], flag); + if (flag == 1) { + mEnabledParticles.push_back(supportedSpecies[iSpecie]); + } + + // Then check full + flag = -1; + enableFlagIfTableRequired(initContext, "pidTOFFull" + particleNames[supportedSpecies[iSpecie]], flag); + if (flag == 1) { + mEnabledParticlesFull.push_back(supportedSpecies[iSpecie]); + } + } + if (mEnabledParticlesFull.size() == 0 && mEnabledParticles.size() == 0) { + LOG(info) << "No PID tables are required, disabling process function"; + doprocessFillTables.value = false; + doprocessDummy.value = true; + return; + } + if (metadataInfo.isFullyDefined()) { + if (!metadataInfo.isRun3()) { + LOG(fatal) << "Metadata says it is Run2, but this task supports only Run3 data"; + } + } + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters + + // Printing enabled tables and enabling QA histograms if needed + LOG(info) << "++ Enabled tables:"; + const AxisSpec pAxis{100, 0, 5, "#it{p} (GeV/#it{c})"}; + const AxisSpec nSigmaAxis{100, -10, 10, "N_{#sigma}^{TOF}"}; + for (const int& iSpecie : mEnabledParticles) { + LOG(info) << "++ pidTOF" << particleNames[iSpecie] << " is enabled"; + if (!enableQaHistograms) { + continue; + } + hnSigma[iSpecie] = histos.add(Form("nSigma/%s", particleNames[iSpecie].c_str()), Form("N_{#sigma}^{TOF}(%s)", particleNames[iSpecie].c_str()), kTH2F, {pAxis, nSigmaAxis}); + } + for (const int& iSpecie : mEnabledParticlesFull) { + LOG(info) << "++ pidTOFFull" << particleNames[iSpecie] << " is enabled"; + if (!enableQaHistograms) { + continue; + } + hnSigmaFull[iSpecie] = histos.add(Form("nSigmaFull/%s", particleNames[iSpecie].c_str()), Form("N_{#sigma}^{TOF}(%s)", particleNames[iSpecie].c_str()), kTH2F, {pAxis, nSigmaAxis}); + } + } + + // 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 idxPi: { + if (fullTable) { + tablePIDFullPi.reserve(size); + } else { + tablePIDPi.reserve(size); + } + break; + } + case idxKa: { + if (fullTable) { + tablePIDFullKa.reserve(size); + } else { + tablePIDKa.reserve(size); + } + break; + } + case idxPr: { + if (fullTable) { + tablePIDFullPr.reserve(size); + } else { + tablePIDPr.reserve(size); + } + break; + } + default: + LOG(fatal) << "Wrong particle ID in reserveTable() for " << (fullTable ? "full" : "tiny") << " tables"; + break; + } + } + + // Makes the table empty for the given particle ID, filling it with dummy values + void makeTableEmpty(const int id, bool fullTable = false) + { + switch (id) { + case idxPi: + if (fullTable) { + tablePIDFullPi(-999.f, -999.f); + } else { + aod::pidutils::packInTable(-999.f, + tablePIDPi); + } + break; + case idxKa: + if (fullTable) { + tablePIDFullKa(-999.f, -999.f); + } else { + aod::pidutils::packInTable(-999.f, + tablePIDKa); + } + break; + case idxPr: + if (fullTable) { + tablePIDFullPr(-999.f, -999.f); + } else { + aod::pidutils::packInTable(-999.f, + tablePIDPr); + } + break; + default: + LOG(fatal) << "Wrong particle ID in makeTableEmpty() for " << (fullTable ? "full" : "tiny") << " tables"; + break; + } + } + + /// Retrieve MC postcalibration objects from CCDB + /// \param timestamp timestamp + void retrieveMcPostCalibFromCcdb(int64_t timestamp) + { + std::map metadata; + if (metadataInfo.isFullyDefined()) { + metadata["RecoPassName"] = metadataInfo.get("AnchorPassName"); + } else { + LOGP(error, "Impossible to read metadata! Using default calibrations (2022 apass7)"); + metadata["RecoPassName"] = ""; + } + auto calibList = ccdb->getSpecific(mcRecalib.ccdbPath, timestamp, metadata); + std::vector updatedSpecies{}; + for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses (tiny) + gMcPostCalibMean[pidId] = reinterpret_cast(calibList->FindObject(Form("Mean%s", particleNames[pidId].data()))); + gMcPostCalibSigma[pidId] = reinterpret_cast(calibList->FindObject(Form("Sigma%s", particleNames[pidId].data()))); + updatedSpecies.push_back(pidId); + } + for (auto const& pidId : mEnabledParticlesFull) { // Loop on enabled particle hypotheses (full) + if (std::find(updatedSpecies.begin(), updatedSpecies.end(), pidId) != updatedSpecies.end()) { + continue; + } + gMcPostCalibMean[pidId] = reinterpret_cast(calibList->FindObject(Form("Mean%s", particleNames[pidId].data()))); + gMcPostCalibSigma[pidId] = reinterpret_cast(calibList->FindObject(Form("Sigma%s", particleNames[pidId].data()))); + } + } + + /// Apply MC postcalibrations + /// \param pidId particle id + /// \param pt track pT + template + T applyMcRecalib(int pidId, T trackPt, T nSigma) + { + if (nSigma < -998) { + return nSigma; + } + + float shift{0.f}, scaleWidth{0.f}; + int nPoints = gMcPostCalibMean[pidId]->GetN(); + double ptMin = gMcPostCalibMean[pidId]->GetX()[0]; + double ptMax = gMcPostCalibMean[pidId]->GetX()[nPoints - 1]; + if (trackPt < ptMin) { + shift = gMcPostCalibMean[pidId]->Eval(ptMin); + scaleWidth = gMcPostCalibSigma[pidId]->Eval(ptMin); + } else if (trackPt > ptMax) { + shift = gMcPostCalibMean[pidId]->Eval(ptMax); + scaleWidth = gMcPostCalibSigma[pidId]->Eval(ptMax); + } else { + shift = gMcPostCalibMean[pidId]->Eval(trackPt); + scaleWidth = gMcPostCalibSigma[pidId]->Eval(trackPt); + } + + T nSigmaCorr = (nSigma - shift) / scaleWidth; + return nSigmaCorr; + } + + void processDummy(Trks const&) {} + PROCESS_SWITCH(mcPidTof, processDummy, "Dummy process function", false); + + template + using ResponseImplementation = o2::pid::tof::ExpTimes; + void processFillTables(TrksWtofWevTime const& tracks, + Cols const&, + aod::BCsWithTimestamps const&, + aod::McParticles const&) + { + constexpr auto responsePi = ResponseImplementation(); + constexpr auto responseKa = ResponseImplementation(); + constexpr auto responsePr = ResponseImplementation(); + + for (auto const& track : tracks) { // Loop on all tracks + if (!track.has_collision()) { // Skipping tracks without collisions + continue; + } + const auto& coll = track.collision(); + if (!coll.has_bc()) { + continue; + } + mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + if (mcRecalib.enable && mTOFCalibConfig.collisionSystem() != CollisionSystemType::kCollSyspp) { + LOGP(fatal, "MC recalibration only available for pp! Change the mcRecalib.enable configurable to 0 and rerun"); + } + break; + } + + for (auto const& pidId : mEnabledParticles) { + reserveTable(pidId, tracks.size(), false); + } + + for (auto const& pidId : mEnabledParticlesFull) { + reserveTable(pidId, tracks.size(), true); + } + + float resolution = 1.f; // Last resolution assigned + float nSigma = 0; + for (auto const& trk : tracks) { // Loop on all tracks + if (!trk.has_collision()) { // Track was not assigned, cannot compute NSigma (no event time) -> filling with empty table + for (auto const& pidId : mEnabledParticles) { + makeTableEmpty(pidId, false); + } + for (auto const& pidId : mEnabledParticlesFull) { + makeTableEmpty(pidId, true); + } + continue; + } + + if (mcRecalib.enable) { + auto runNumber = trk.collision().bc_as().runNumber(); + if (runNumber != currentRun) { + // update postcalibration files + auto timestamp = trk.collision().bc_as().timestamp(); + retrieveMcPostCalibFromCcdb(timestamp); + } + currentRun = runNumber; + } + + for (auto const& pidId : mEnabledParticles) { // Loop on enabled particle hypotheses + switch (pidId) { + case idxPi: { + nSigma = responsePi.GetSeparation(mRespParamsV3, trk); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kPiPlus) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + aod::pidutils::packInTable(nSigma, tablePIDPi); + break; + } + case idxKa: { + nSigma = responseKa.GetSeparation(mRespParamsV3, trk); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kKPlus) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + aod::pidutils::packInTable(nSigma, tablePIDKa); + break; + } + case idxPr: { + nSigma = responsePr.GetSeparation(mRespParamsV3, trk); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kProton) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + aod::pidutils::packInTable(nSigma, tablePIDPr); + break; + } + default: + LOG(fatal) << "Wrong particle ID for standard tables"; + break; + } + if (enableQaHistograms) { + hnSigma[pidId]->Fill(trk.p(), nSigma); + } + } + + for (auto const& pidId : mEnabledParticlesFull) { // Loop on enabled particle hypotheses with full tables + switch (pidId) { + case idxPi: { + resolution = responsePi.GetExpectedSigma(mRespParamsV3, trk); + nSigma = responsePi.GetSeparation(mRespParamsV3, trk); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kPiPlus) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + tablePIDFullPi(resolution, nSigma); + break; + } + case idxKa: { + resolution = responseKa.GetExpectedSigma(mRespParamsV3, trk); + nSigma = responseKa.GetSeparation(mRespParamsV3, trk, resolution); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kKPlus) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + tablePIDFullKa(resolution, nSigma); + break; + } + case idxPr: { + resolution = responsePr.GetExpectedSigma(mRespParamsV3, trk); + nSigma = responsePr.GetSeparation(mRespParamsV3, trk, resolution); + if (mcRecalib.enable && trk.has_mcParticle()) { + if (std::abs(trk.mcParticle().pdgCode()) == kProton) { // we rescale only true signal + nSigma = applyMcRecalib(pidId, trk.pt(), nSigma); + } + } + tablePIDFullPr(resolution, nSigma); + break; + } + default: + LOG(fatal) << "Wrong particle ID for full tables"; + break; + } + if (enableQaHistograms) { + hnSigmaFull[pidId]->Fill(trk.p(), nSigma); + } + } + } + } + PROCESS_SWITCH(mcPidTof, processFillTables, "Process with table filling", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + // Parse the metadata + metadataInfo.initMetadata(cfgc); + auto workflow = WorkflowSpec{adaptAnalysisTask(cfgc)}; + workflow.push_back(adaptAnalysisTask(cfgc)); + workflow.push_back(adaptAnalysisTask(cfgc)); + return workflow; +} diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 98815d42c67..fe77bb275d9 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -134,10 +134,10 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { void selectCollision(const Col& collision, const BCs&) { float centrality = -1.; - const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (fillHistograms) { - hfEvSel.fillHistograms(collision, rejectionMask); + hfEvSel.fillHistograms(collision, rejectionMask, centrality); // additional centrality histos if constexpr (centEstimator != o2::hf_centrality::None) { if (rejectionMask == 0) { @@ -2962,10 +2962,8 @@ struct HfTrackIndexSkimCreatorCascades { struct : ConfigurableGroup { Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; Configurable fillHistograms{"fillHistograms", true, "fill histograms"}; - // event selection - // Configurable triggerindex{"triggerindex", -1, "trigger index"}; // vertexing - // Configurable bz{"bz", 5., "magnetic field"}; + Configurable useDCAFitter{"useDCAFitter", true, "flag to optionally turn on/off the vertex reconstruction with the DCAFitter"}; Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; Configurable maxR{"maxR", 200., "reject PCA's above this radius"}; Configurable maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"}; @@ -2973,24 +2971,12 @@ struct HfTrackIndexSkimCreatorCascades { Configurable minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations if chi2/chi2old > this"}; Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; Configurable useWeightedFinalPCA{"useWeightedFinalPCA", true, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; - // quality cut - Configurable doCutQuality{"doCutQuality", true, "apply quality cuts"}; - // track cuts for bachelor - Configurable tpcRefitBach{"tpcRefitBach", true, "request TPC refit bachelor"}; - Configurable nCrossedRowsMinBach{"nCrossedRowsMinBach", 50, "min crossed rows bachelor"}; // track cuts for V0 daughters - Configurable tpcRefitV0Daugh{"tpcRefitV0Daugh", true, "request TPC refit V0 daughters"}; - Configurable nCrossedRowsMinV0Daugh{"nCrossedRowsMinV0Daugh", 50, "min crossed rows V0 daughters"}; Configurable etaMinV0Daugh{"etaMinV0Daugh", -99999., "min. pseudorapidity V0 daughters"}; Configurable etaMaxV0Daugh{"etaMaxV0Daugh", 1.1, "max. pseudorapidity V0 daughters"}; Configurable ptMinV0Daugh{"ptMinV0Daugh", 0.05, "min. pT V0 daughters"}; - // bachelor cuts - // Configurable dcabachtopv{"dcabachtopv", .1, "DCA Bach To PV"}; - // Configurable ptminbach{"ptminbach", -1., "min. track pT bachelor"}; // v0 cuts - Configurable cpaV0Min{"cpaV0Min", .995, "min. cos PA V0"}; // as in the task that create the V0s - Configurable dcaXYNegToPvMin{"dcaXYNegToPvMin", .1, "min. DCA_XY Neg To PV"}; // check: in HF Run 2, it was 0 at filtering - Configurable dcaXYPosToPvMin{"dcaXYPosToPvMin", .1, "min. DCA_XY Pos To PV"}; // check: in HF Run 2, it was 0 at filtering + Configurable cpaV0Min{"cpaV0Min", 0.95, "min. cos PA V0"}; // as in the task that create the V0s Configurable cutInvMassV0{"cutInvMassV0", 0.05, "V0 candidate invariant mass difference wrt PDG"}; // cascade cuts Configurable ptCascCandMin{"ptCascCandMin", -1., "min. pT of the cascade candidate"}; // PbPb 2018: use 1 @@ -3011,11 +2997,11 @@ struct HfTrackIndexSkimCreatorCascades { Service ccdb; o2::base::MatLayerCylSet* lut; o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; - int runNumber; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + int runNumber{0}; double massP{0.}; double massK0s{0.}; - double massPi{0.}; double massLc{0.}; using SelectedCollisions = soa::Filtered>; @@ -3042,23 +3028,22 @@ struct HfTrackIndexSkimCreatorCascades { massP = o2::constants::physics::MassProton; massK0s = o2::constants::physics::MassK0Short; - massPi = o2::constants::physics::MassPiPlus; massLc = o2::constants::physics::MassLambdaCPlus; - df2.setPropagateToPCA(config.propagateToPCA); - df2.setMaxR(config.maxR); - df2.setMinParamChange(config.minParamChange); - df2.setMinRelChi2Change(config.minRelChi2Change); - // df2.setMaxDZIni(1e9); // used in cascadeproducer.cxx, but not for the 2 prongs - // df2.setMaxChi2(1e9); // used in cascadeproducer.cxx, but not for the 2 prongs - df2.setUseAbsDCA(config.useAbsDCA); - df2.setWeightedFinalPCA(config.useWeightedFinalPCA); + if (config.useDCAFitter) { + df2.setPropagateToPCA(config.propagateToPCA); + df2.setMaxR(config.maxR); + df2.setMinParamChange(config.minParamChange); + df2.setMinRelChi2Change(config.minRelChi2Change); + df2.setMaxDZIni(config.maxDZIni); + df2.setUseAbsDCA(config.useAbsDCA); + df2.setWeightedFinalPCA(config.useWeightedFinalPCA); + } ccdb->setURL(config.ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(config.ccdbPathLut)); - runNumber = 0; if (config.fillHistograms) { registry.add("hVtx2ProngX", "2-prong candidates;#it{x}_{sec. vtx.} (cm);entries", {HistType::kTH1D, {{1000, -2., 2.}}}); @@ -3075,7 +3060,7 @@ struct HfTrackIndexSkimCreatorCascades { PROCESS_SWITCH(HfTrackIndexSkimCreatorCascades, processNoCascades, "Do not skim HF -> V0 cascades", true); void processCascades(SelectedCollisions const& collisions, - aod::V0Datas const& v0s, + soa::Join const& v0s, FilteredTrackAssocSel const& trackIndices, aod::TracksWCovDcaExtra const&, aod::BCsWithTimestamps const&) @@ -3084,67 +3069,52 @@ struct HfTrackIndexSkimCreatorCascades { for (const auto& collision : collisions) { auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); - df2.setBz(o2::base::Propagator::Instance()->getNominalBz()); - - // fist we loop over the bachelor candidate + if (config.useDCAFitter) { + df2.setBz(o2::base::Propagator::Instance()->getNominalBz()); + df2.setMatCorrType(matCorr); + } const auto thisCollId = collision.globalIndex(); auto groupedBachTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + auto groupedV0s = v0s.sliceBy(v0sPerCollision, thisCollId); - // for (const auto& bach : selectedTracks) { + // fist we loop over the bachelor candidate for (const auto& bachIdx : groupedBachTrackIndices) { auto bach = bachIdx.track_as(); - - // selections on the bachelor - - // pT cut - // FIXME: this should go in the tag-sel-tracks - if (config.tpcRefitBach) { - if (!(bach.trackType() & o2::aod::track::TPCrefit)) { - continue; - } - } - if (bach.tpcNClsCrossedRows() < config.nCrossedRowsMinBach) { - continue; - } - + 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()}; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackBach, 2.f, noMatCorr, &dcaInfoBach); + getPxPyPz(trackBach, pVecBach); + } - auto groupedV0s = v0s.sliceBy(v0sPerCollision, thisCollId); // now we loop over the V0s for (const auto& v0 : groupedV0s) { // selections on the V0 daughters - const auto& trackV0DaughPos = v0.posTrack_as(); - const auto& trackV0DaughNeg = v0.negTrack_as(); + const auto& trackV0DaughPos = v0.posTrack_as(); // only used for indices and track cuts (TPC clusters, TPC refit) + const auto& trackV0DaughNeg = v0.negTrack_as(); // only used for indices and track cuts (TPC clusters, TPC refit) // check not to take the same track twice (as bachelor and V0 daughter) if (trackV0DaughPos.globalIndex() == bach.globalIndex() || trackV0DaughNeg.globalIndex() == bach.globalIndex()) { continue; } - if (config.tpcRefitV0Daugh) { - if (!(trackV0DaughPos.trackType() & o2::aod::track::TPCrefit) || - !(trackV0DaughNeg.trackType() & o2::aod::track::TPCrefit)) { - continue; - } - } - if (trackV0DaughPos.tpcNClsCrossedRows() < config.nCrossedRowsMinV0Daugh || - trackV0DaughNeg.tpcNClsCrossedRows() < config.nCrossedRowsMinV0Daugh) { - continue; - } - // - // if (trackV0DaughPos.dcaXY() < dcaXYPosToPvMin || // to the filters? - // trackV0DaughNeg.dcaXY() < dcaXYNegToPvMin) { - // continue; - // } - // - if (trackV0DaughPos.pt() < config.ptMinV0Daugh || // to the filters? I can't for now, it is not in the tables - trackV0DaughNeg.pt() < config.ptMinV0Daugh) { + std::array pVecPos = {v0.pxpos(), v0.pypos(), v0.pzpos()}; + std::array pVecNeg = {v0.pxneg(), v0.pyneg(), v0.pzneg()}; + + float ptPos = RecoDecay::pt(pVecPos); + float ptNeg = RecoDecay::pt(pVecNeg); + if (ptPos < config.ptMinV0Daugh || // to the filters? I can't for now, it is not in the tables + ptNeg < config.ptMinV0Daugh) { continue; } - if ((trackV0DaughPos.eta() > config.etaMaxV0Daugh || trackV0DaughPos.eta() < config.etaMinV0Daugh) || // to the filters? I can't for now, it is not in the tables - (trackV0DaughNeg.eta() > config.etaMaxV0Daugh || trackV0DaughNeg.eta() < config.etaMinV0Daugh)) { + + float etaPos = RecoDecay::eta(pVecPos); + float etaNeg = RecoDecay::eta(pVecNeg); + if ((etaPos > config.etaMaxV0Daugh || etaPos < config.etaMinV0Daugh) || // to the filters? I can't for now, it is not in the tables + (etaNeg > config.etaMaxV0Daugh || etaNeg < config.etaMinV0Daugh)) { continue; } @@ -3158,40 +3128,44 @@ struct HfTrackIndexSkimCreatorCascades { continue; } - const std::array momentumV0 = {v0.px(), v0.py(), v0.pz()}; + std::array pVecV0 = {v0.px(), v0.py(), v0.pz()}; // invariant-mass cut: we do it here, before updating the momenta of bach and V0 during the fitting to save CPU // TODO: but one should better check that the value here and after the fitter do not change significantly!!! - double mass2K0sP = RecoDecay::m(std::array{bach.pVector(), momentumV0}, std::array{massP, massK0s}); + double mass2K0sP = RecoDecay::m(std::array{pVecBach, pVecV0}, std::array{massP, massK0s}); if ((config.cutInvMassCascLc >= 0.) && (std::abs(mass2K0sP - massLc) > config.cutInvMassCascLc)) { continue; } - auto trackParCovV0DaughPos = getTrackParCov(trackV0DaughPos); - trackParCovV0DaughPos.propagateTo(v0.posX(), o2::base::Propagator::Instance()->getNominalBz()); // propagate the track to the X closest to the V0 vertex - auto trackParCovV0DaughNeg = getTrackParCov(trackV0DaughNeg); - trackParCovV0DaughNeg.propagateTo(v0.negX(), o2::base::Propagator::Instance()->getNominalBz()); // propagate the track to the X closest to the V0 vertex - std::array pVecV0 = {0., 0., 0.}; - std::array pVecBach = {0., 0., 0.}; - - const std::array vertexV0 = {v0.x(), v0.y(), v0.z()}; - // 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 - // now we find the DCA between the V0 and the bachelor, for the cascade - int nCand2 = 0; - try { - nCand2 = df2.process(trackV0, trackBach); - } catch (...) { - continue; - } + if (config.useDCAFitter) { + + const std::array vertexV0 = {v0.x(), v0.y(), v0.z()}; + // 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, pVecV0, covV, 0, true); + trackV0.setAbsCharge(0); + trackV0.setPID(o2::track::PID::K0); - if (nCand2 == 0) { - continue; + int nCand2 = 0; + try { + nCand2 = df2.process(trackV0, trackBach); + } catch (...) { + continue; + } + + if (nCand2 == 0) { + continue; + } + df2.propagateTracksToVertex(); // propagate the bach and V0 to the Lc vertex + df2.getTrack(0).getPxPyPzGlo(pVecV0); // take the momentum at the Lc vertex + df2.getTrack(1).getPxPyPzGlo(pVecBach); } - df2.propagateTracksToVertex(); // propagate the bach and V0 to the Lc vertex - df2.getTrack(0).getPxPyPzGlo(pVecV0); // take the momentum at the Lc vertex - df2.getTrack(1).getPxPyPzGlo(pVecBach); // cascade candidate pT cut auto ptCascCand = RecoDecay::pt(pVecBach, pVecV0); @@ -3202,11 +3176,12 @@ struct HfTrackIndexSkimCreatorCascades { // invariant mass // re-calculate invariant masses with updated momenta, to fill the histogram mass2K0sP = RecoDecay::m(std::array{pVecBach, pVecV0}, std::array{massP, massK0s}); - std::array posCasc = {0., 0., 0.}; - const auto& cascVtx = df2.getPCACandidate(); - for (int i = 0; i < 3; i++) { - posCasc[i] = cascVtx[i]; + if (config.useDCAFitter) { + const auto& cascVtx = df2.getPCACandidate(); + for (int iCoord{0}; iCoord < 3; ++iCoord) { + posCasc[iCoord] = cascVtx[iCoord]; + } } // fill table row diff --git a/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx b/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx index aac534e265e..542ed264892 100644 --- a/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx +++ b/PWGHF/TableProducer/treeCreatorBsToDsPi.cxx @@ -172,8 +172,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::BsToDsPiToKKPiPi); - Partition recBg = nabs(aod::hf_cand_bs::flagMcMatchRec) != (int8_t)BIT(aod::hf_cand_bs::DecayTypeMc::BsToDsPiToKKPiPi); + 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); void init(InitContext const&) { @@ -351,7 +351,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::BsToDsPiToKKPiPi)) { + if (TESTBIT(std::abs(particle.flagMcMatchGen()), aod::hf_cand_bs::DecayTypeMc::BsToDsPiToPhiPiPiToKKPiPi)) { rowCandidateFullParticles( particle.mcCollision().bcId(), particle.pt(), diff --git a/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx b/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx index 3487f1615dd..2b2a7a84ef5 100644 --- a/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorD0ToKPi.cxx @@ -217,9 +217,9 @@ struct HfTreeCreatorD0ToKPi { HfHelper hfHelper; - using TracksWPid = soa::Join; - using SelectedCandidatesMc = soa::Filtered>; - using SelectedCandidatesMcKf = soa::Filtered>; + // using TracksWPid = soa::Join; + using SelectedCandidatesMc = soa::Filtered>; + using SelectedCandidatesMcKf = soa::Filtered>; using MatchedGenCandidatesMc = soa::Filtered>; Filter filterSelectCandidates = aod::hf_sel_candidate_d0::isSelD0 >= 1 || aod::hf_sel_candidate_d0::isSelD0bar >= 1; @@ -251,8 +251,8 @@ struct HfTreeCreatorD0ToKPi { runNumber); } - template - auto fillTable(const T& candidate, const U& prong0, const U& prong1, int candFlag, double invMass, double cosThetaStar, double topoChi2, + 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) { if (fillCandidateLiteTable) { @@ -268,18 +268,18 @@ struct HfTreeCreatorD0ToKPi { candidate.impactParameter1(), candidate.impactParameterNormalised0(), candidate.impactParameterNormalised1(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.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(), 1 << candFlag, invMass, candidate.pt(), @@ -326,18 +326,18 @@ struct HfTreeCreatorD0ToKPi { candidate.impactParameter1(), candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), - prong0.tpcNSigmaPi(), - prong0.tpcNSigmaKa(), - prong0.tofNSigmaPi(), - prong0.tofNSigmaKa(), - prong0.tpcTofNSigmaPi(), - prong0.tpcTofNSigmaKa(), - prong1.tpcNSigmaPi(), - prong1.tpcNSigmaKa(), - prong1.tofNSigmaPi(), - prong1.tofNSigmaKa(), - prong1.tpcTofNSigmaPi(), - prong1.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(), 1 << candFlag, invMass, candidate.maxNormalisedDeltaIP(), @@ -361,7 +361,7 @@ struct HfTreeCreatorD0ToKPi { template void processData(aod::Collisions const& collisions, CandType const& candidates, - TracksWPid const&, aod::BCs const&) + aod::Tracks const&, aod::BCs const&) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -382,8 +382,6 @@ struct HfTreeCreatorD0ToKPi { continue; } } - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); double yD = hfHelper.yD0(candidate); double eD = hfHelper.eD0(candidate); double ctD = hfHelper.ctD0(candidate); @@ -398,17 +396,17 @@ struct HfTreeCreatorD0ToKPi { massD0bar = hfHelper.invMassD0barToKPi(candidate); } if (candidate.isSelD0()) { - fillTable(candidate, prong0, prong1, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); + fillTable(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); } if (candidate.isSelD0bar()) { - fillTable(candidate, prong0, prong1, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); + fillTable(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, 0, 0); } } } void processDataWithDCAFitterN(aod::Collisions const& collisions, - soa::Filtered> const& candidates, - TracksWPid const& tracks, + soa::Filtered> const& candidates, + aod::Tracks const& tracks, aod::BCs const& bcs) { processData(collisions, candidates, tracks, bcs); @@ -416,8 +414,8 @@ struct HfTreeCreatorD0ToKPi { PROCESS_SWITCH(HfTreeCreatorD0ToKPi, processDataWithDCAFitterN, "Process data with DCAFitterN", true); void processDataWithKFParticle(aod::Collisions const& collisions, - soa::Filtered> const& candidates, - TracksWPid const& tracks, + soa::Filtered> const& candidates, + aod::Tracks const& tracks, aod::BCs const& bcs) { processData(collisions, candidates, tracks, bcs); @@ -429,7 +427,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const&, CandType const& candidates, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const&, + aod::Tracks const&, aod::BCs const&) { // Filling event properties @@ -461,8 +459,6 @@ struct HfTreeCreatorD0ToKPi { continue; } } - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); double yD = hfHelper.yD0(candidate); double eD = hfHelper.eD0(candidate); double ctD = hfHelper.ctD0(candidate); @@ -477,10 +473,10 @@ struct HfTreeCreatorD0ToKPi { massD0bar = hfHelper.invMassD0barToKPi(candidate); } if (candidate.isSelD0()) { - fillTable(candidate, prong0, prong1, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); + fillTable(candidate, 0, massD0, hfHelper.cosThetaStarD0(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); } if (candidate.isSelD0bar()) { - fillTable(candidate, prong0, prong1, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); + fillTable(candidate, 1, massD0bar, hfHelper.cosThetaStarD0bar(candidate), topolChi2PerNdf, ctD, yD, eD, candidate.flagMcMatchRec(), candidate.originMcRec()); } } @@ -505,7 +501,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMc const&, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, reconstructedCandSig, mcParticles, tracks, bcs); @@ -516,7 +512,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMc const&, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, reconstructedCandBkg, mcParticles, tracks, bcs); @@ -527,7 +523,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMc const& candidates, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); @@ -538,7 +534,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const&, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, reconstructedCandSigKF, mcParticles, tracks, bcs); @@ -549,7 +545,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const&, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, reconstructedCandBkgKF, mcParticles, tracks, bcs); @@ -560,7 +556,7 @@ struct HfTreeCreatorD0ToKPi { aod::McCollisions const& mcCollisions, SelectedCandidatesMcKf const& candidates, MatchedGenCandidatesMc const& mcParticles, - TracksWPid const& tracks, + aod::Tracks const& tracks, aod::BCs const& bcs) { processMc(collisions, mcCollisions, candidates, mcParticles, tracks, bcs); diff --git a/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx b/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx index b7e66144251..5933bda7118 100644 --- a/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorDplusToPiKPi.cxx @@ -124,7 +124,8 @@ DECLARE_SOA_TABLE(HfCandDpLites, "AOD", "HFCANDDPLITE", full::Phi, full::Y, hf_cand_3prong::FlagMcMatchRec, - hf_cand_3prong::OriginMcRec) + hf_cand_3prong::OriginMcRec, + hf_cand_3prong::FlagMcDecayChanRec) DECLARE_SOA_TABLE(HfCandDpFulls, "AOD", "HFCANDDPFULL", collision::BCId, @@ -204,7 +205,8 @@ DECLARE_SOA_TABLE(HfCandDpFulls, "AOD", "HFCANDDPFULL", full::Y, full::E, hf_cand_3prong::FlagMcMatchRec, - hf_cand_3prong::OriginMcRec); + hf_cand_3prong::OriginMcRec, + hf_cand_3prong::FlagMcDecayChanRec); DECLARE_SOA_TABLE(HfCandDpFullEvs, "AOD", "HFCANDDPFULLEV", collision::BCId, @@ -249,7 +251,7 @@ struct HfTreeCreatorDplusToPiKPi { 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)); - Partition reconstructedCandSig = 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(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)); void init(InitContext const&) @@ -274,9 +276,11 @@ struct HfTreeCreatorDplusToPiKPi { { int8_t flagMc = 0; int8_t originMc = 0; + int8_t channelMc = 0; if constexpr (doMc) { flagMc = candidate.flagMcMatchRec(); originMc = candidate.originMcRec(); + channelMc = candidate.flagMcDecayChanRec(); } auto prong0 = candidate.template prong0_as(); @@ -327,7 +331,8 @@ struct HfTreeCreatorDplusToPiKPi { candidate.phi(), hfHelper.yDplus(candidate), flagMc, - originMc); + originMc, + channelMc); } else { rowCandidateFull( candidate.collision().bcId(), @@ -407,7 +412,8 @@ struct HfTreeCreatorDplusToPiKPi { hfHelper.yDplus(candidate), hfHelper.eDplus(candidate), flagMc, - originMc); + originMc, + channelMc); } } diff --git a/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx b/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx index 4e7e3fb7471..99428bf1e42 100644 --- a/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorDsToKKPi.cxx @@ -22,6 +22,7 @@ #include "Framework/runDataProcessing.h" #include "PWGHF/Core/HfHelper.h" +#include "PWGHF/Core/CentralityEstimation.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" @@ -77,10 +78,11 @@ DECLARE_SOA_COLUMN(MaxNormalisedDeltaIP, maxNormalisedDeltaIP, float); //! DECLARE_SOA_COLUMN(ImpactParameterXY, impactParameterXY, float); //! Transverse impact parameter of candidate (cm) DECLARE_SOA_COLUMN(DeltaMassPhi, deltaMassPhi, float); //! Absolute mass difference between kaon-pair and phi-meson invariant mass (Gev/c2) DECLARE_SOA_COLUMN(AbsCos3PiK, absCos3PiK, float); //! Cube of absolute value of the cosine of pion-kaon angle in the phi rest frame +DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the candidate // Events DECLARE_SOA_COLUMN(IsEventReject, isEventReject, int); //! Event rejection flag DECLARE_SOA_COLUMN(RunNumber, runNumber, int); //! Run number -DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign +DECLARE_SOA_COLUMN(Centrality, centrality, float); //! Centrality (or multiplicity) percentile } // namespace full DECLARE_SOA_TABLE(HfCandDsLites, "AOD", "HFCANDDSLITE", @@ -126,9 +128,12 @@ DECLARE_SOA_TABLE(HfCandDsLites, "AOD", "HFCANDDSLITE", full::DeltaMassPhi, full::AbsCos3PiK, hf_cand::Chi2PCA, + full::Centrality, + collision::NumContrib, hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, hf_cand_3prong::FlagMcDecayChanRec, + hf_cand_3prong::IsCandidateSwapped, full::Sign); DECLARE_SOA_TABLE(HfCandDsFulls, "AOD", "HFCANDDSFULL", @@ -197,9 +202,11 @@ DECLARE_SOA_TABLE(HfCandDsFulls, "AOD", "HFCANDDSFULL", full::DeltaMassPhi, full::AbsCos3PiK, hf_cand::Chi2PCA, + full::Centrality, hf_cand_3prong::FlagMcMatchRec, hf_cand_3prong::OriginMcRec, hf_cand_3prong::FlagMcDecayChanRec, + hf_cand_3prong::IsCandidateSwapped, full::Sign); DECLARE_SOA_TABLE(HfCandDsFullEvs, "AOD", "HFCANDDSFULLEV", @@ -208,6 +215,7 @@ DECLARE_SOA_TABLE(HfCandDsFullEvs, "AOD", "HFCANDDSFULLEV", collision::PosX, collision::PosY, collision::PosZ, + full::Centrality, full::IsEventReject, full::RunNumber); @@ -245,6 +253,10 @@ struct HfTreeCreatorDsToKKPi { using CandDsMcGen = soa::Filtered>; using TracksWPid = soa::Join; + using CollisionsWithFT0C = soa::Join; + 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; @@ -269,6 +281,7 @@ struct HfTreeCreatorDsToKKPi { collision.posX(), collision.posY(), collision.posZ(), + o2::hf_centrality::getCentralityColl(collision), isEventReject, runNumber); } @@ -277,12 +290,13 @@ struct HfTreeCreatorDsToKKPi { /// \param doMc true to fill MC information /// \param massHypo mass hypothesis considered: 0 = KKPi, 1 = PiKK /// \param candidate is candidate - template + 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; @@ -290,6 +304,7 @@ struct HfTreeCreatorDsToKKPi { 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); @@ -314,6 +329,9 @@ struct HfTreeCreatorDsToKKPi { absCos3PiKDs = hfHelper.absCos3PiKDsToPiKK(candidate); } + auto const& collision = candidate.template collision_as(); + float centrality = o2::hf_centrality::getCentralityColl(collision); + auto prong0 = candidate.template prong0_as(); auto prong1 = candidate.template prong1_as(); auto prong2 = candidate.template prong2_as(); @@ -344,8 +362,8 @@ struct HfTreeCreatorDsToKKPi { prong2.tofNSigmaKa(), prong2.tpcTofNSigmaPi(), prong2.tpcTofNSigmaKa(), - candidate.isSelDsToKKPi(), - candidate.isSelDsToPiKK(), + massHypo == 0 ? candidate.isSelDsToKKPi() : -1, + massHypo == 1 ? candidate.isSelDsToPiKK() : -1, invMassDs, candidate.pt(), candidate.eta(), @@ -362,14 +380,17 @@ struct HfTreeCreatorDsToKKPi { deltaMassPhiKK, absCos3PiKDs, candidate.chi2PCA(), + centrality, + candidate.template collision_as().numContrib(), flagMc, originMc, channelMc, + isSwapped, prong0.sign() + prong1.sign() + prong2.sign()); } else { rowCandidateFull( - candidate.collision().bcId(), - candidate.collision().numContrib(), + candidate.template collision_as().bcId(), + candidate.template collision_as().numContrib(), candidate.posX(), candidate.posY(), candidate.posZ(), @@ -409,8 +430,8 @@ struct HfTreeCreatorDsToKKPi { prong2.tofNSigmaKa(), prong2.tpcTofNSigmaPi(), prong2.tpcTofNSigmaKa(), - candidate.isSelDsToKKPi(), - candidate.isSelDsToPiKK(), + massHypo == 0 ? candidate.isSelDsToKKPi() : -1, + massHypo == 1 ? candidate.isSelDsToPiKK() : -1, candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), @@ -433,16 +454,18 @@ struct HfTreeCreatorDsToKKPi { deltaMassPhiKK, absCos3PiKDs, candidate.chi2PCA(), + centrality, flagMc, originMc, channelMc, + isSwapped, prong0.sign() + prong1.sign() + prong2.sign()); } } - void processData(aod::Collisions const& collisions, - CandDsData const&, - TracksWPid const&) + template + void runData(Coll const& collisions, + CandDsData const&) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -464,7 +487,7 @@ struct HfTreeCreatorDsToKKPi { continue; } } - fillCandidateTable(candidate); + fillCandidateTable(candidate); } for (const auto& candidate : selectedDsToPiKKCand) { @@ -474,17 +497,15 @@ struct HfTreeCreatorDsToKKPi { continue; } } - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } - PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processData, "Process data", true); - - void processMc(aod::Collisions const& collisions, - aod::McCollisions const&, - CandDsMcReco const&, - CandDsMcGen const& mcParticles, - TracksWPid const&) + template + void runMc(Coll const& collisions, + aod::McCollisions const&, + CandDsMcReco const&, + CandDsMcGen const& mcParticles) { // Filling event properties rowCandidateFullEvents.reserve(collisions.size()); @@ -502,10 +523,10 @@ struct HfTreeCreatorDsToKKPi { for (const auto& candidate : reconstructedCandSig) { if (candidate.isCandidateSwapped() == 0) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } if (candidate.isCandidateSwapped() == 1) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } } else if (fillOnlyBackground) { @@ -524,10 +545,10 @@ struct HfTreeCreatorDsToKKPi { } // Bkg candidates are not matched to MC so rely on selections only if (candidate.isSelDsToKKPi() >= selectionFlagDs) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } if (candidate.isSelDsToPiKK() >= selectionFlagDs) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } } else { @@ -539,20 +560,20 @@ struct HfTreeCreatorDsToKKPi { for (const auto& candidate : reconstructedCandSig) { if (candidate.isCandidateSwapped() == 0) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } if (candidate.isCandidateSwapped() == 1) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } for (const auto& candidate : reconstructedCandBkg) { // Bkg candidates are not matched to MC so rely on selections only if (candidate.isSelDsToKKPi() >= selectionFlagDs) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } if (candidate.isSelDsToPiKK() >= selectionFlagDs) { - fillCandidateTable(candidate); + fillCandidateTable(candidate); } } } @@ -571,7 +592,77 @@ struct HfTreeCreatorDsToKKPi { } } - PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processMc, "Process MC", false); + void processDataWithFT0C(CollisionsWithFT0C const& collisions, + CandDsData const& candsDs, + TracksWPid const&) + { + runData(collisions, candsDs); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processDataWithFT0C, "Process data with centrality information from FT0C", false); + + void processDataWithFT0M(CollisionsWithFT0M const& collisions, + CandDsData const& candsDs, + TracksWPid const&) + { + runData(collisions, candsDs); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processDataWithFT0M, "Process data with centrality information from FT0M", false); + + void processDataWithNTracksPV(CollisionsWithNTracksPV const& collisions, + CandDsData const& candsDs, + TracksWPid const&) + { + runData(collisions, candsDs); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processDataWithNTracksPV, "Process data with centrality information from NTracksPV", false); + + void processData(soa::Join const& collisions, + CandDsData const& candsDs, + TracksWPid const&) + { + runData>(collisions, candsDs); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processData, "Process data without centrality information", true); + + void processMcWithFT0C(CollisionsWithFT0C const& collisions, + aod::McCollisions const& mcCollisions, + CandDsMcReco const& mcRecoCands, + CandDsMcGen const& mcParticles, + TracksWPid const&) + { + runMc(collisions, mcCollisions, mcRecoCands, mcParticles); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processMcWithFT0C, "Process MC with centrality information from FT0C", false); + + void processMcWithFT0M(CollisionsWithFT0M const& collisions, + aod::McCollisions const& mcCollisions, + CandDsMcReco const& mcRecoCands, + CandDsMcGen const& mcParticles, + TracksWPid const&) + { + runMc(collisions, mcCollisions, mcRecoCands, mcParticles); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processMcWithFT0M, "Process MC with centrality information from FT0M", false); + + void processMcWithNTracksPV(CollisionsWithNTracksPV const& collisions, + aod::McCollisions const& mcCollisions, + CandDsMcReco const& mcRecoCands, + CandDsMcGen const& mcParticles, + TracksWPid const&) + { + runMc(collisions, mcCollisions, mcRecoCands, mcParticles); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processMcWithNTracksPV, "Process MC with centrality information from NTracksPV", false); + + void processMc(soa::Join const& collisions, + aod::McCollisions const& mcCollisions, + CandDsMcReco const& mcRecoCands, + CandDsMcGen const& mcParticles, + TracksWPid const&) + { + runMc(collisions, mcCollisions, mcRecoCands, mcParticles); + } + PROCESS_SWITCH(HfTreeCreatorDsToKKPi, processMc, "Process MC without centrality information", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx b/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx index dd863781594..fd11fad78b1 100644 --- a/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx +++ b/PWGHF/TableProducer/treeCreatorDstarToD0Pi.cxx @@ -293,21 +293,50 @@ struct HfTreeCreatorDstarToD0Pi { originMc = candidate.originMcRec(); } - auto prong0 = candidate.template prong0_as(); - auto prong1 = candidate.template prong1_as(); + TracksWPid::iterator prong0; + TracksWPid::iterator prong1; auto prongSoftPi = candidate.template prongPi_as(); float massD0{-1.f}; float massDStar{-1.f}; float cosThetaD0{-1.f}; + float impParameterProng0{-999.}, impParameterProng1{-999.}; + // float errorImpParameterProng0{-999.}, errorImpParameterProng1{-999.}; + float impParameterNormalisedProng0{-999.}, impParameterNormalisedProng1{-999.}; + float ptProng0{-999.}, ptProng1{-999.}; + float pProng0{-999.}, pProng1{-999.}; if (candidate.signSoftPi() > 0) { massD0 = candidate.invMassD0(); massDStar = candidate.invMassDstar(); cosThetaD0 = candidate.cosThetaStarD0(); + prong0 = candidate.template prong0_as(); // pion + prong1 = candidate.template prong1_as(); // kaon + ptProng0 = candidate.ptProng0(); + ptProng1 = candidate.ptProng1(); + impParameterProng0 = candidate.impactParameter0(); + impParameterProng1 = candidate.impactParameter1(); + // errorImpParameterProng0 = candidate.errorImpactParameter0(); + // errorImpParameterProng1 = candidate.errorImpactParameter1(); + impParameterNormalisedProng0 = candidate.impactParameterNormalised0(); + impParameterNormalisedProng1 = candidate.impactParameterNormalised1(); + pProng0 = RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()); + pProng1 = RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()); } else { massD0 = candidate.invMassD0Bar(); massDStar = candidate.invMassAntiDstar(); cosThetaD0 = candidate.cosThetaStarD0Bar(); + prong0 = candidate.template prong1_as(); // pion + prong1 = candidate.template prong0_as(); // kaon + ptProng0 = candidate.ptProng1(); + ptProng1 = candidate.ptProng0(); + impParameterProng0 = candidate.impactParameter1(); + impParameterProng1 = candidate.impactParameter0(); + // errorImpParameterProng0 = candidate.errorImpactParameter1(); + // errorImpParameterProng1 = candidate.errorImpactParameter0(); + impParameterNormalisedProng0 = candidate.impactParameterNormalised1(); + impParameterNormalisedProng1 = candidate.impactParameterNormalised0(); + pProng0 = RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()); + pProng1 = RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()); } if (fillCandidateLiteTable) { @@ -322,14 +351,14 @@ struct HfTreeCreatorDstarToD0Pi { candidate.deltaIPNormalisedMaxD0(), candidate.impactParameterProductD0(), cosThetaD0, - candidate.ptProng0(), - candidate.ptProng1(), + ptProng0, + ptProng1, candidate.ptSoftPi(), - candidate.impactParameter0(), - candidate.impactParameter1(), + impParameterProng0, + impParameterProng1, candidate.impParamSoftPi(), - candidate.impactParameterNormalised0(), - candidate.impactParameterNormalised1(), + impParameterNormalisedProng0, + impParameterNormalisedProng1, candidate.normalisedImpParamSoftPi(), prong0.tpcNSigmaPi(), prong0.tpcNSigmaKa(), @@ -385,17 +414,17 @@ struct HfTreeCreatorDstarToD0Pi { candidate.deltaIPNormalisedMaxD0(), candidate.impactParameterProductD0(), cosThetaD0, - RecoDecay::p(candidate.pxProng0(), candidate.pyProng0(), candidate.pzProng0()), - RecoDecay::p(candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()), + pProng0, + pProng1, RecoDecay::p(candidate.pxSoftPi(), candidate.pySoftPi(), candidate.pzSoftPi()), - candidate.ptProng0(), - candidate.ptProng1(), + ptProng0, + ptProng1, candidate.ptSoftPi(), - candidate.impactParameter0(), - candidate.impactParameter1(), + impParameterProng0, + impParameterProng1, candidate.impParamSoftPi(), - candidate.impactParameterNormalised0(), - candidate.impactParameterNormalised1(), + impParameterNormalisedProng0, + impParameterNormalisedProng1, candidate.normalisedImpParamSoftPi(), candidate.errorImpactParameter0(), candidate.errorImpactParameter1(), @@ -457,7 +486,7 @@ struct HfTreeCreatorDstarToD0Pi { } 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; } @@ -498,7 +527,7 @@ struct HfTreeCreatorDstarToD0Pi { } 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/treeCreatorLcToK0sP.cxx b/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx index 4dfde61847f..14ae8ab647c 100644 --- a/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToK0sP.cxx @@ -27,6 +27,8 @@ using namespace o2; using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; namespace o2::aod { @@ -213,10 +215,17 @@ struct HfTreeCreatorLcToK0sP { Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; Configurable downSampleBkgFactor{"downSampleBkgFactor", 1., "Fraction of candidates to store in the tree"}; Configurable ptMaxForDownSample{"ptMaxForDownSample", 24., "Maximum pt for the application of the downsampling factor"}; + Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to fill derived tables with signal for ML trainings"}; + Configurable fillOnlyBackground{"fillOnlyBackground", false, "Flag to fill derived tables with background for ML trainings"}; HfHelper hfHelper; + Filter filterSelectCandidates = aod::hf_sel_candidate_lc_to_k0s_p::isSelLcToK0sP >= 1; using TracksWPid = soa::Join; + using SelectedCandidatesMc = soa::Filtered>; + + Partition recSig = nabs(aod::hf_cand_casc::flagMcMatchRec) != int8_t(0); + Partition recBkg = nabs(aod::hf_cand_casc::flagMcMatchRec) == int8_t(0); void init(InitContext const&) { @@ -349,7 +358,7 @@ struct HfTreeCreatorLcToK0sP { void processMc(aod::Collisions const& collisions, aod::McCollisions const&, - soa::Join const& candidates, + SelectedCandidatesMc const& candidates, soa::Join const& particles, TracksWPid const&) { @@ -360,21 +369,41 @@ struct HfTreeCreatorLcToK0sP { fillEvent(collision); } - // Filling candidate properties - if (fillCandidateLiteTable) { - rowCandidateLite.reserve(candidates.size()); - } else { - rowCandidateFull.reserve(candidates.size()); - } - for (const auto& candidate : candidates) { - auto bach = candidate.prong0_as(); // bachelor - if (downSampleBkgFactor < 1.) { - double pseudoRndm = bach.pt() * 1000. - (int16_t)(bach.pt() * 1000); - if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { - continue; + if (fillOnlySignal) { + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(recSig.size()); + } else { + rowCandidateFull.reserve(recSig.size()); + } + for (const auto& candidate : recSig) { + auto bach = candidate.prong0_as(); // bachelor + fillCandidate(candidate, bach, candidate.flagMcMatchRec(), candidate.originMcRec()); + } + } else if (fillOnlyBackground) { + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(recBkg.size()); + } else { + rowCandidateFull.reserve(recBkg.size()); + } + for (const auto& candidate : recBkg) { + if (downSampleBkgFactor < 1.) { + float pseudoRndm = candidate.ptProng0() * 1000. - (int64_t)(candidate.ptProng0() * 1000); + if (candidate.pt() < ptMaxForDownSample && pseudoRndm >= downSampleBkgFactor) { + continue; + } } + auto bach = candidate.prong0_as(); // bachelor + fillCandidate(candidate, bach, candidate.flagMcMatchRec(), candidate.originMcRec()); + } + } else { + // Filling candidate properties + if (fillCandidateLiteTable) { + rowCandidateLite.reserve(candidates.size()); + } else { + rowCandidateFull.reserve(candidates.size()); } - if (candidate.isSelLcToK0sP() >= 1) { + for (const auto& candidate : candidates) { + auto bach = candidate.prong0_as(); // bachelor fillCandidate(candidate, bach, candidate.flagMcMatchRec(), candidate.originMcRec()); } } diff --git a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx index d9efc0202a7..f0c1c1503c2 100644 --- a/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx +++ b/PWGHF/TableProducer/treeCreatorLcToPKPi.cxx @@ -244,15 +244,12 @@ DECLARE_SOA_TABLE(HfCandLcFullEvs, "AOD", "HFCANDLCFULLEV", full::MultZeqNTracksPV); DECLARE_SOA_TABLE(HfCandLcFullPs, "AOD", "HFCANDLCFULLP", - full::McCollisionId, full::Pt, full::Eta, full::Phi, full::Y, full::FlagMc, - full::OriginMcGen, - full::McParticleId); - + full::OriginMcGen); } // namespace o2::aod /// Writes the full information in an output TTree @@ -502,14 +499,12 @@ struct HfTreeCreatorLcToPKPi { for (const auto& particle : particles) { if (std::abs(particle.flagMcMatchGen()) == 1 << aod::hf_cand_3prong::DecayType::LcToPKPi) { rowCandidateFullParticles( - particle.mcCollisionId(), particle.pt(), particle.eta(), particle.phi(), RecoDecay::y(particle.pVector(), o2::constants::physics::MassLambdaCPlus), particle.flagMcMatchGen(), - particle.originMcGen(), - particle.globalIndex()); + particle.originMcGen()); } } } diff --git a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx index b91f65cb654..e2af6b5cff8 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx @@ -23,6 +23,8 @@ #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" @@ -127,6 +129,8 @@ DECLARE_SOA_COLUMN(Chi2TopologicalCharmedBaryon, chi2TopologicalCharmedBaryon, f DECLARE_SOA_COLUMN(Chi2TopologicalCasc, chi2TopologicalCasc, float); DECLARE_SOA_COLUMN(DecayLengthCharmedBaryon, decayLengthCharmedBaryon, float); DECLARE_SOA_COLUMN(DecayLengthXYCharmedBaryon, decayLengthXYCharmedBaryon, float); +DECLARE_SOA_COLUMN(DecayLengthCharmedBaryonUntracked, decayLengthCharmedBaryonUntracked, float); +DECLARE_SOA_COLUMN(DecayLengthXYCharmedBaryonUntracked, decayLengthXYCharmedBaryonUntracked, float); DECLARE_SOA_COLUMN(DecayLengthCasc, decayLengthCasc, float); DECLARE_SOA_COLUMN(DecayLengthXYCasc, decayLengthXYCasc, float); DECLARE_SOA_INDEX_COLUMN_FULL(MotherCasc, motherCasc, int, HfStChBarGens, "_Casc"); @@ -178,6 +182,8 @@ DECLARE_SOA_TABLE(HfStChBars, "AOD", "HFSTCHBAR", hf_st_charmed_baryon::Chi2TopologicalCasc, hf_st_charmed_baryon::DecayLengthCharmedBaryon, hf_st_charmed_baryon::DecayLengthXYCharmedBaryon, + hf_st_charmed_baryon::DecayLengthCharmedBaryonUntracked, + hf_st_charmed_baryon::DecayLengthXYCharmedBaryonUntracked, hf_st_charmed_baryon::DecayLengthCasc, hf_st_charmed_baryon::DecayLengthXYCasc, hf_st_charmed_baryon::MotherCascId, @@ -188,6 +194,9 @@ 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"}; @@ -195,6 +204,7 @@ struct HfTreeCreatorOmegacSt { 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 skimmedProcessing{"skimmedProcessing", false, "Put true if you are processing apass*_skimmed datasets"}; 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"}; @@ -362,6 +372,13 @@ struct HfTreeCreatorOmegacSt { for (const auto& collision : collisions) { const auto bc = collision.bc_as(); if (runNumber != bc.runNumber()) { + if (skimmedProcessing) { + if (runNumber == 0) { + zorroSummary.setObject(zorro.getZorroSummary()); + } + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fTrackedOmega"); + zorro.populateHistRegistry(registry, bc.runNumber()); + } runNumber = bc.runNumber(); auto timestamp = bc.timestamp(); @@ -376,6 +393,9 @@ struct HfTreeCreatorOmegacSt { } df2.setBz(bz); } + if (skimmedProcessing) { + zorro.isSelected(collision.bc().globalBC()); + } const auto primaryVertex = getPrimaryVertex(collision); const std::array primaryVertexPos = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; @@ -460,8 +480,9 @@ struct HfTreeCreatorOmegacSt { std::array, 2> momentaCascDaughters; trackParV0.getPxPyPzGlo(momentaCascDaughters[0]); trackParBachelor.getPxPyPzGlo(momentaCascDaughters[1]); + o2::track::TrackParCov trackParCovCascUntracked = df2.createParentTrackParCov(0); std::array pCasc; - df2.createParentTrackParCov().getPxPyPzGlo(pCasc); + trackParCovCascUntracked.getPxPyPzGlo(pCasc); const auto cpaCasc = RecoDecay::cpa(primaryVertexPos, df2.getPCACandidate(), pCasc); const auto cpaXYCasc = RecoDecay::cpaXY(primaryVertexPos, df2.getPCACandidate(), pCasc); @@ -538,6 +559,13 @@ struct HfTreeCreatorOmegacSt { hCandidatesCascPi->Fill(SVFitting::BeforeFit); try { + auto decayLengthUntracked = -1.; + auto decayLengthXYUntracked = -1.; + if (df2.process(trackParCovCascUntracked, trackParCovPion)) { + const auto& secondaryVertexUntracked = df2.getPCACandidate(); + decayLengthUntracked = RecoDecay::distance(secondaryVertexUntracked, primaryVertexPos); + decayLengthXYUntracked = RecoDecay::distanceXY(secondaryVertexUntracked, primaryVertexPos); + } if (df2.process(trackParCovCasc, trackParCovPion)) { const auto& secondaryVertex = df2.getPCACandidate(); const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); @@ -603,6 +631,8 @@ struct HfTreeCreatorOmegacSt { trackedCascade.topologyChi2(), decayLength, decayLengthXY, + decayLengthUntracked, + decayLengthXYUntracked, decayLengthCasc, decayLengthCascXY, trackCascMotherId, diff --git a/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx b/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx index 7014e64d0ef..42b40686a15 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegacToOmegaPi.cxx @@ -14,6 +14,7 @@ /// In this file are defined and filled the output tables /// /// \author Federica Zanone , Heidelberg University +/// \author Yunfan Liu , China University of Geosciences #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" @@ -99,6 +100,53 @@ DECLARE_SOA_COLUMN(TofNSigmaPiFromCharmBaryon, tofNSigmaPiFromCharmBaryon, float DECLARE_SOA_COLUMN(TofNSigmaKaFromCasc, tofNSigmaKaFromCasc, float); DECLARE_SOA_COLUMN(TofNSigmaPiFromLambda, tofNSigmaPiFromLambda, float); DECLARE_SOA_COLUMN(TofNSigmaPrFromLambda, tofNSigmaPrFromLambda, float); +// from creator KF +DECLARE_SOA_COLUMN(NSigmaTPCPiFromOmegac, nSigmaTPCPiFromOmegac, float); +DECLARE_SOA_COLUMN(NSigmaTOFPiFromOmegac, nSigmaTOFPiFromOmegac, float); +DECLARE_SOA_COLUMN(NSigmaTPCKaFromCasc, nSigmaTPCKaFromCasc, float); +DECLARE_SOA_COLUMN(NSigmaTOFKaFromCasc, nSigmaTOFKaFromCasc, float); +DECLARE_SOA_COLUMN(NSigmaTPCPiFromV0, nSigmaTPCPiFromV0, float); +DECLARE_SOA_COLUMN(NSigmaTPCPrFromV0, nSigmaTPCPrFromV0, float); +DECLARE_SOA_COLUMN(KfDcaXYPiFromOmegac, kfDcaXYPiFromOmegac, float); +DECLARE_SOA_COLUMN(KfDcaXYCascToPv, kfDcaXYCascToPv, float); +DECLARE_SOA_COLUMN(Chi2GeoV0, chi2GeoV0, float); +DECLARE_SOA_COLUMN(Chi2GeoCasc, chi2GeoCasc, float); +DECLARE_SOA_COLUMN(Chi2GeoOmegac, chi2GeoOmegac, float); +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(Omegacldl, omegacldl, float); +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(Chi2TopoV0ToCasc, chi2TopoV0ToCasc, float); +DECLARE_SOA_COLUMN(Chi2TopoCascToOmegac, chi2TopoCascToOmegac, float); +DECLARE_SOA_COLUMN(DecayLenXYLambda, decayLenXYLambda, float); +DECLARE_SOA_COLUMN(DecayLenXYCasc, decayLenXYCasc, float); +DECLARE_SOA_COLUMN(DecayLenXYOmegac, decayLenXYOmegac, float); +DECLARE_SOA_COLUMN(CosPaV0ToCasc, cosPaV0ToCasc, float); +DECLARE_SOA_COLUMN(CosPaV0ToPv, cosPaV0ToPv, float); +DECLARE_SOA_COLUMN(CosPaCascToOmegac, cosPaCascToOmegac, float); +DECLARE_SOA_COLUMN(CosPaCascToPv, cosPaCascToPv, float); +DECLARE_SOA_COLUMN(CosPaOmegacToPv, cosPaOmegacToPv, float); +DECLARE_SOA_COLUMN(KfRapOmegac, kfRapOmegac, float); +DECLARE_SOA_COLUMN(KfptPiFromOmegac, kfptPiFromOmegac, float); +DECLARE_SOA_COLUMN(KfptOmegac, kfptOmegac, float); +DECLARE_SOA_COLUMN(CosThetaStarPiFromOmegac, cosThetaStarPiFromOmegac, float); +DECLARE_SOA_COLUMN(CtOmegac, ctOmegac, float); +DECLARE_SOA_COLUMN(EtaOmegac, etaOmegac, float); +DECLARE_SOA_COLUMN(V0Ndf, v0Ndf, float); +DECLARE_SOA_COLUMN(CascNdf, cascNdf, float); +DECLARE_SOA_COLUMN(OmegacNdf, omegacNdf, float); +DECLARE_SOA_COLUMN(MassV0Ndf, massV0Ndf, float); +DECLARE_SOA_COLUMN(MassCascNdf, massCascNdf, float); +DECLARE_SOA_COLUMN(V0Chi2OverNdf, v0Chi2OverNdf, float); +DECLARE_SOA_COLUMN(CascChi2OverNdf, cascChi2OverNdf, float); +DECLARE_SOA_COLUMN(OmegacChi2OverNdf, omegacChi2OverNdf, float); +DECLARE_SOA_COLUMN(MassV0Chi2OverNdf, massV0Chi2OverNdf, float); +DECLARE_SOA_COLUMN(MassCascChi2OverNdf, massCascChi2OverNdf, float); } // namespace full @@ -129,12 +177,33 @@ DECLARE_SOA_TABLE(HfOmegac0ToOmegaPiLites, "AOD", "HFTOOMEPILITE", full::TofNSigmaPiFromCharmBaryon, full::TofNSigmaKaFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, full::FlagMcMatchRec, full::OriginRec, full::CollisionMatched); +DECLARE_SOA_TABLE(HfKfOmegacFulls, "AOD", "HFKFOMEGACFULL", + full::NSigmaTPCPiFromOmegac, full::NSigmaTOFPiFromOmegac, full::NSigmaTPCKaFromCasc, full::NSigmaTOFKaFromCasc, + full::NSigmaTPCPiFromV0, full::NSigmaTPCPrFromV0, + full::KfDcaXYPiFromOmegac, full::DcaCascDau, full::DcaCharmBaryonDau, full::KfDcaXYCascToPv, + full::DcaXYToPvV0Dau0, full::DcaXYToPvV0Dau1, full::DcaXYToPvCascDau, + 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::Chi2TopoV0ToCasc, full::Chi2TopoCascToOmegac, + full::DecayLenXYLambda, full::DecayLenXYCasc, full::DecayLenXYOmegac, + full::CosPaV0ToCasc, full::CosPaV0ToPv, full::CosPaCascToOmegac, full::CosPaCascToPv, full::CosPaOmegacToPv, + full::InvMassLambda, full::InvMassCascade, full::InvMassCharmBaryon, + full::KfRapOmegac, full::KfptPiFromOmegac, full::KfptOmegac, + full::CosThetaStarPiFromOmegac, full::CtOmegac, full::EtaOmegac, + 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); } // namespace o2::aod /// Writes the full information in an output TTree struct HfTreeCreatorOmegac0ToOmegaPi { Produces rowCandidateLite; + Produces rowKfCandidateFull; Produces rowEv; Configurable zPvCut{"zPvCut", 10., "Cut on absolute value of primary vertex z coordinate"}; @@ -226,6 +295,72 @@ struct HfTreeCreatorOmegac0ToOmegaPi { } } + template + void fillKfCandidate(const T& candidate, int8_t flagMc, int8_t originMc, bool collisionMatched) + { + if (candidate.resultSelections() && candidate.statusPidCharmBaryon() && candidate.statusInvMassLambda() && candidate.statusInvMassCascade() && candidate.statusInvMassCharmBaryon()) { + + rowKfCandidateFull( + candidate.tpcNSigmaPiFromCharmBaryon(), + candidate.tofNSigmaPiFromCharmBaryon(), + candidate.tpcNSigmaKaFromCasc(), + candidate.tofNSigmaKaFromCasc(), + candidate.tpcNSigmaPiFromLambda(), + candidate.tpcNSigmaPrFromLambda(), + candidate.kfDcaXYPiFromOmegac(), + candidate.dcaCascDau(), + candidate.dcaCharmBaryonDau(), + candidate.kfDcaXYCascToPv(), + candidate.dcaXYToPvV0Dau0(), + candidate.dcaXYToPvV0Dau1(), + candidate.dcaXYToPvCascDau(), + candidate.chi2GeoV0(), + candidate.chi2GeoCasc(), + candidate.chi2GeoOmegac(), + candidate.chi2MassV0(), + candidate.chi2MassCasc(), + candidate.v0ldl(), + candidate.cascldl(), + candidate.omegacldl(), + candidate.chi2TopoV0ToPv(), + candidate.chi2TopoCascToPv(), + candidate.chi2TopoPiFromOmegacToPv(), + candidate.chi2TopoOmegacToPv(), + candidate.chi2TopoV0ToCasc(), + candidate.chi2TopoCascToOmegac(), + candidate.decayLenXYLambda(), + candidate.decayLenXYCasc(), + candidate.decayLenXYOmegac(), + candidate.cosPaV0ToCasc(), + candidate.cosPAV0(), + candidate.cosPaCascToOmegac(), + candidate.cosPACasc(), + candidate.cosPACharmBaryon(), + candidate.invMassLambda(), + candidate.invMassCascade(), + candidate.invMassCharmBaryon(), + candidate.kfRapOmegac(), + candidate.kfptPiFromOmegac(), + candidate.kfptOmegac(), + candidate.cosThetaStarPiFromOmegac(), + candidate.ctauOmegac(), + candidate.etaCharmBaryon(), + candidate.v0Ndf(), + candidate.cascNdf(), + candidate.omegacNdf(), + candidate.massV0Ndf(), + candidate.massCascNdf(), + candidate.v0Chi2OverNdf(), + candidate.cascChi2OverNdf(), + candidate.omegacChi2OverNdf(), + candidate.massV0Chi2OverNdf(), + candidate.massCascChi2OverNdf(), + flagMc, + originMc, + collisionMatched); + } + } + void processDataLite(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) { @@ -243,6 +378,23 @@ struct HfTreeCreatorOmegac0ToOmegaPi { } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processDataLite, "Process data", true); + void processKfDataFull(MyEventTable 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 + rowKfCandidateFull.reserve(candidates.size()); + for (const auto& candidate : candidates) { + fillKfCandidate(candidate, -7, RecoDecay::OriginType::None, false); + } + } + PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKfDataFull, "Process KF data", false); + void processMcLite(MyEventTable const& collisions, MyTrackTable const&, soa::Join const& candidates) { @@ -260,6 +412,23 @@ struct HfTreeCreatorOmegac0ToOmegaPi { } PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processMcLite, "Process MC", false); + void processKFMcFull(MyEventTable 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) { + fillKfCandidate(candidate, candidate.flagMcMatchRec(), candidate.originRec(), candidate.collisionMatched()); + } + } + PROCESS_SWITCH(HfTreeCreatorOmegac0ToOmegaPi, processKFMcFull, "Process KF MC", false); + }; // end of struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/TableProducer/treeCreatorToXiPi.cxx b/PWGHF/TableProducer/treeCreatorToXiPi.cxx index facd45a4718..b875db47a41 100644 --- a/PWGHF/TableProducer/treeCreatorToXiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorToXiPi.cxx @@ -116,6 +116,10 @@ DECLARE_SOA_COLUMN(NormImpParPiFromCharmBar, normImpParPiFromCharmBar, double); DECLARE_SOA_COLUMN(NormDecayLenCharmBar, normDecayLenCharmBar, double); DECLARE_SOA_COLUMN(IsPionGlbTrkWoDca, isPionGlbTrkWoDca, bool); DECLARE_SOA_COLUMN(PionItsNCls, pionItsNCls, uint8_t); +DECLARE_SOA_COLUMN(NTpcRowsPion, nTpcRowsPion, int16_t); +DECLARE_SOA_COLUMN(NTpcRowsPiFromCasc, nTpcRowsPiFromCasc, int16_t); +DECLARE_SOA_COLUMN(NTpcRowsPosV0Dau, nTpcRowsPosV0Dau, int16_t); +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 @@ -172,6 +176,7 @@ DECLARE_SOA_TABLE(HfToXiPiFulls, "AOD", "HFTOXIPIFULL", full::DcaCascDau, full::DcaV0Dau, full::DcaCharmBaryonDau, full::DecLenCharmBaryon, full::DecLenCascade, full::DecLenV0, full::ErrorDecayLengthCharmBaryon, full::ErrorDecayLengthXYCharmBaryon, full::NormImpParCascade, full::NormImpParPiFromCharmBar, full::NormDecayLenCharmBar, full::IsPionGlbTrkWoDca, full::PionItsNCls, + full::NTpcRowsPion, full::NTpcRowsPiFromCasc, full::NTpcRowsPosV0Dau, full::NTpcRowsNegV0Dau, full::StatusPidLambda, full::StatusPidCascade, full::StatusPidCharmBaryon, full::StatusInvMassLambda, full::StatusInvMassCascade, full::StatusInvMassCharmBaryon, full::ResultSelections, full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaPiFromCharmBaryon, full::TpcNSigmaPiFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, @@ -197,6 +202,7 @@ DECLARE_SOA_TABLE(HfToXiPiLites, "AOD", "HFTOXIPILITE", full::DcaCascDau, full::DcaV0Dau, full::DcaCharmBaryonDau, full::ErrorDecayLengthCharmBaryon, full::NormImpParCascade, full::NormImpParPiFromCharmBar, full::IsPionGlbTrkWoDca, full::PionItsNCls, + full::NTpcRowsPion, full::NTpcRowsPiFromCasc, full::NTpcRowsPosV0Dau, full::NTpcRowsNegV0Dau, full::PidTpcInfoStored, full::PidTofInfoStored, full::TpcNSigmaPiFromCharmBaryon, full::TpcNSigmaPiFromCasc, full::TpcNSigmaPiFromLambda, full::TpcNSigmaPrFromLambda, full::TofNSigmaPiFromCharmBaryon, full::TofNSigmaPiFromCasc, full::TofNSigmaPiFromLambda, full::TofNSigmaPrFromLambda, @@ -317,6 +323,10 @@ struct HfTreeCreatorToXiPi { candidate.decLenCharmBaryon() / candidate.errorDecayLengthCharmBaryon(), candidate.template bachelorFromCharmBaryon_as().isGlobalTrackWoDCA(), candidate.template bachelorFromCharmBaryon_as().itsNCls(), + candidate.template bachelorFromCharmBaryon_as().tpcNClsCrossedRows(), + candidate.template bachelor_as().tpcNClsCrossedRows(), + candidate.template posTrack_as().tpcNClsCrossedRows(), + candidate.template negTrack_as().tpcNClsCrossedRows(), candidate.statusPidLambda(), candidate.statusPidCascade(), candidate.statusPidCharmBaryon(), @@ -398,6 +408,10 @@ struct HfTreeCreatorToXiPi { candidate.impactParBachFromCharmBaryonXY() / candidate.errImpactParBachFromCharmBaryonXY(), candidate.template bachelorFromCharmBaryon_as().isGlobalTrackWoDCA(), candidate.template bachelorFromCharmBaryon_as().itsNCls(), + candidate.template bachelorFromCharmBaryon_as().tpcNClsCrossedRows(), + candidate.template bachelor_as().tpcNClsCrossedRows(), + candidate.template posTrack_as().tpcNClsCrossedRows(), + candidate.template negTrack_as().tpcNClsCrossedRows(), candidate.pidTpcInfoStored(), candidate.pidTofInfoStored(), candidate.tpcNSigmaPiFromCharmBaryon(), diff --git a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx index c28709ffc75..488a9fee249 100644 --- a/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/treeCreatorXicToXiPiPi.cxx @@ -12,7 +12,10 @@ /// \file treeCreatorXicToXiPiPi.cxx /// \brief Writer of Ξc± → Ξ∓ π± π± candidates in the form of flat tables to be stored in TTrees. /// -/// \author Phil Lennart Stahlhut , CERN +/// \author Phil Lennart Stahlhut , Heidelberg University +/// \author Carolina Reetz , Heidelberg University + +#include #include "CommonConstants/PhysicsConstants.h" #include "Framework/AnalysisTask.h" @@ -24,16 +27,13 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::constants::physics; namespace o2::aod { namespace full { -// track indices DECLARE_SOA_COLUMN(CandidateSelFlag, candidateSelFlag, int); //! Selection flag of candidate (output of candidateSelector) -DECLARE_SOA_INDEX_COLUMN_FULL(Xi, xi, int, Tracks, "_pi0"); -DECLARE_SOA_INDEX_COLUMN_FULL(Pi0, pi0, int, Tracks, "_pi0"); -DECLARE_SOA_INDEX_COLUMN_FULL(Pi1, pi1, int, Tracks, "_pi1"); // vertices DECLARE_SOA_COLUMN(XPv, xPv, float); DECLARE_SOA_COLUMN(YPv, yPv, float); @@ -41,13 +41,19 @@ DECLARE_SOA_COLUMN(ZPv, zPv, float); DECLARE_SOA_COLUMN(XPvErr, xPvErr, float); DECLARE_SOA_COLUMN(YPvErr, yPvErr, float); DECLARE_SOA_COLUMN(ZPvErr, zPvErr, float); +DECLARE_SOA_COLUMN(XPvGen, xPvGen, float); +DECLARE_SOA_COLUMN(YPvGen, yPvGen, float); +DECLARE_SOA_COLUMN(ZPvGen, zPvGen, float); DECLARE_SOA_COLUMN(XSv, xSv, float); DECLARE_SOA_COLUMN(YSv, ySv, float); DECLARE_SOA_COLUMN(ZSv, zSv, float); -DECLARE_SOA_COLUMN(Chi2Sv, chi2Sv, 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(XSvGen, xSvGen, float); +DECLARE_SOA_COLUMN(YSvGen, ySvGen, float); +DECLARE_SOA_COLUMN(ZSvGen, zSvGen, float); DECLARE_SOA_COLUMN(XDecVtxXi, xDecVtxXi, float); DECLARE_SOA_COLUMN(YDecVtxXi, yDecVtxXi, float); DECLARE_SOA_COLUMN(ZDecVtxXi, zDecVtxXi, float); @@ -72,6 +78,10 @@ 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) @@ -87,115 +97,132 @@ 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(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(InvMassXiPi0, invMassXiPi0, float); DECLARE_SOA_COLUMN(InvMassXiPi1, invMassXiPi1, 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, full::CandidateSelFlag, - full::XPv, - full::YPv, - full::ZPv, - full::XSv, - full::YSv, - full::ZSv, - full::Chi2Sv, full::Sign, - full::E, - full::M, - full::P, - full::Pt, full::Y, full::Eta, full::Phi, + full::P, + full::Pt, + full::PtXi, + full::PtPi0, + full::PtPi1, + full::M, + full::InvMassXiPi0, + full::InvMassXiPi1, + full::Chi2Sv, full::Ct, full::DecayLength, + full::DecayLengthNormalised, full::DecayLengthXY, + full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::PtXi, - full::PtPi0, - full::PtPi1, - full::ImpactParameterXi, - full::ImpactParameterPi0, - full::ImpactParameterPi1, full::CpaXi, full::CpaXYXi, full::CpaLam, full::CpaXYLam, - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec); + full::ImpactParameterXi, + full::ImpactParameterNormalisedXi, + full::ImpactParameterPi0, + full::ImpactParameterNormalisedPi0, + full::ImpactParameterPi1, + full::ImpactParameterNormalisedPi1, + full::MaxNormalisedDeltaIP); DECLARE_SOA_TABLE(HfCandXicToXiPiPiLiteKfs, "AOD", "HFXICXI2PILITKF", + hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, full::CandidateSelFlag, - full::XPv, - full::YPv, - full::ZPv, - full::XSv, - full::YSv, - full::ZSv, - full::Chi2Sv, full::Sign, - full::E, - full::M, - full::P, - full::Pt, full::Y, full::Eta, full::Phi, + full::P, + full::Pt, + full::PtXi, + full::PtPi0, + full::PtPi1, + full::M, + full::InvMassXiPi0, + full::InvMassXiPi1, + full::Chi2Sv, full::Ct, full::DecayLength, + full::DecayLengthNormalised, full::DecayLengthXY, + full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::PtXi, - full::PtPi0, - full::PtPi1, - full::ImpactParameterXi, - full::ImpactParameterPi0, - full::ImpactParameterPi1, full::CpaXi, full::CpaXYXi, full::CpaLam, full::CpaXYLam, + full::ImpactParameterXi, + full::ImpactParameterNormalisedXi, + full::ImpactParameterPi0, + full::ImpactParameterNormalisedPi0, + full::ImpactParameterPi1, + full::ImpactParameterNormalisedPi1, + full::MaxNormalisedDeltaIP, + // 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, - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec); + full::DcaXiDaughters); DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", + hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, full::CandidateSelFlag, - full::XPv, - full::YPv, - full::ZPv, - full::XPvErr, - full::YPvErr, - full::ZPvErr, - full::XSv, - full::YSv, - full::ZSv, - full::Chi2Sv, - full::XSvErr, - full::YSvErr, - full::ZSvErr, - full::XDecVtxXi, - full::YDecVtxXi, - full::ZDecVtxXi, - full::XDecVtxLam, - full::YDecVtxLam, - full::ZDecVtxLam, full::Sign, - full::E, - full::M, - full::P, - full::Pt, full::Y, full::Eta, full::Phi, + full::P, + full::Pt, + full::PtXi, + full::PtPi0, + full::PtPi1, + full::M, + full::InvMassXiPi0, + full::InvMassXiPi1, + full::Chi2Sv, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -203,9 +230,10 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::PtXi, - full::PtPi0, - full::PtPi1, + full::CpaXi, + full::CpaXYXi, + full::CpaLam, + full::CpaXYLam, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -213,16 +241,8 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFulls, "AOD", "HFXICXI2PIFULL", full::ImpactParameterPi1, full::ImpactParameterNormalisedPi1, full::MaxNormalisedDeltaIP, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, - full::InvMassXiPi0, - full::InvMassXiPi1, - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec); - -DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", - full::CandidateSelFlag, + // additional columns only stored in the full candidate table + full::E, full::XPv, full::YPv, full::ZPv, @@ -232,7 +252,6 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::XSv, full::YSv, full::ZSv, - full::Chi2Sv, full::XSvErr, full::YSvErr, full::ZSvErr, @@ -241,15 +260,24 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::ZDecVtxXi, full::XDecVtxLam, full::YDecVtxLam, - full::ZDecVtxLam, + full::ZDecVtxLam); + +DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", + hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec, + full::CandidateSelFlag, full::Sign, - full::E, - full::M, - full::P, - full::Pt, full::Y, full::Eta, full::Phi, + full::P, + full::Pt, + full::PtXi, + full::PtPi0, + full::PtPi1, + full::M, + full::InvMassXiPi0, + full::InvMassXiPi1, + full::Chi2Sv, full::Ct, full::DecayLength, full::DecayLengthNormalised, @@ -257,9 +285,10 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::DecayLengthXYNormalised, full::Cpa, full::CpaXY, - full::PtXi, - full::PtPi0, - full::PtPi1, + full::CpaXi, + full::CpaXYXi, + full::CpaLam, + full::CpaXYLam, full::ImpactParameterXi, full::ImpactParameterNormalisedXi, full::ImpactParameterPi0, @@ -267,38 +296,69 @@ DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullKfs, "AOD", "HFXICXI2PIFULKF", full::ImpactParameterPi1, full::ImpactParameterNormalisedPi1, full::MaxNormalisedDeltaIP, - full::CpaXi, - full::CpaXYXi, - full::CpaLam, - full::CpaXYLam, - full::InvMassXiPi0, - full::InvMassXiPi1, + // additional columns only stored in the full candidate table + full::E, + full::XPv, + full::YPv, + full::ZPv, + full::XPvErr, + full::YPvErr, + full::ZPvErr, + full::XSv, + full::YSv, + full::ZSv, + full::XSvErr, + full::YSvErr, + full::ZSvErr, + full::XDecVtxXi, + full::YDecVtxXi, + full::ZDecVtxXi, + full::XDecVtxLam, + full::YDecVtxLam, + full::ZDecVtxLam, + // 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, - hf_cand_xic_to_xi_pi_pi::FlagMcMatchRec); - -DECLARE_SOA_TABLE(HfCandXicToXiPiPiDauInds, "AOD", "HFXICXI2PIDAUIN", - full::XiId, - full::Pi0Id, - full::Pi1Id); - -DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullEvs, "AOD", "HFXICXI2PIFULEV", - collision::BCId, - collision::NumContrib, - collision::PosX, - collision::PosY, - collision::PosZ); + full::DcaXiDaughters); DECLARE_SOA_TABLE(HfCandXicToXiPiPiFullPs, "AOD", "HFXICXI2PIFULLP", - collision::BCId, full::Pt, full::Eta, full::Phi, full::Y, + full::XPvGen, + full::YPvGen, + full::ZPvGen, + full::XSvGen, + full::YSvGen, + full::ZSvGen, hf_cand_xic_to_xi_pi_pi::FlagMcMatchGen); + +DECLARE_SOA_TABLE(HfCandXicToXiPiPiResiduals, "AOD", "HFXICXI2PIRESID", + 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 @@ -307,13 +367,12 @@ struct HfTreeCreatorXicToXiPiPi { Produces rowCandidateLiteKf; Produces rowCandidateFull; Produces rowCandidateFullKf; - Produces rowCandidateDauIndices; - Produces rowCandidateFullEvents; Produces rowCandidateFullParticles; + Produces rowCandidateResiduals; - Configurable selectionFlagXic{"selectionXic", 1, "Selection Flag for Xic"}; + Configurable selectionFlagXic{"selectionFlagXic", 1, "Selection Flag for Xic"}; Configurable fillCandidateLiteTable{"fillCandidateLiteTable", false, "Switch to fill lite table with candidate properties"}; - Configurable fillCandidateDauIndexTable{"fillCandidateDauIndexTable", false, "Switch to fill table with Xic daughters track indices"}; + Configurable fillGenParticleTable{"fillGenParticleTable", false, "Switch to fill table with MC truth for generated particles"}; // parameters for production of training samples Configurable fillOnlySignal{"fillOnlySignal", false, "Flag to fill derived tables with signal for ML trainings"}; Configurable fillOnlyBackground{"fillOnlyBackground", false, "Flag to fill derived tables with background for ML trainings"}; @@ -324,7 +383,6 @@ struct HfTreeCreatorXicToXiPiPi { using SelectedCandidatesKf = soa::Filtered>; using SelectedCandidatesMc = soa::Filtered>; using SelectedCandidatesKfMc = soa::Filtered>; - using TracksWPid = soa::Join; Filter filterSelectCandidates = aod::hf_sel_candidate_xic::isSelXicToXiPiPi >= selectionFlagXic; @@ -337,26 +395,6 @@ struct HfTreeCreatorXicToXiPiPi { { } - template - void fillEvent(const T& collision) - { - rowCandidateFullEvents( - collision.bcId(), - collision.numContrib(), - collision.posX(), - collision.posY(), - collision.posZ()); - } - - template - void fillIndexTable(const T& candidate) - { - rowCandidateDauIndices( - candidate.cascadeId(), - candidate.pi0Id(), - candidate.pi1Id()); - } - template void fillCandidateTable(const T& candidate) { @@ -367,41 +405,76 @@ struct HfTreeCreatorXicToXiPiPi { if constexpr (!doKf) { if (fillCandidateLiteTable) { rowCandidateLite( + flagMc, candidate.isSelXicToXiPiPi(), - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.xSecondaryVertex(), - candidate.ySecondaryVertex(), - candidate.zSecondaryVertex(), - candidate.chi2PCA(), candidate.sign(), - candidate.e(o2::constants::physics::MassXiCPlus), - candidate.invMassXic(), - candidate.p(), - candidate.pt(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), + candidate.p(), + candidate.pt(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.invMassXic(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.chi2PCA(), candidate.ct(o2::constants::physics::MassXiCPlus), candidate.decayLength(), + candidate.decayLengthNormalised(), candidate.decayLengthXY(), + candidate.decayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.ptProng0(), - candidate.ptProng1(), - candidate.ptProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), candidate.cosPaXi(), candidate.cosPaXYXi(), candidate.cosPaLambda(), candidate.cosPaXYLambda(), - flagMc); + candidate.impactParameter0(), + candidate.impactParameterNormalised0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised2(), + candidate.maxNormalisedDeltaIP()); } else { rowCandidateFull( + flagMc, 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.invMassXic(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.chi2PCA(), + candidate.ct(o2::constants::physics::MassXiCPlus), + candidate.decayLength(), + candidate.decayLengthNormalised(), + candidate.decayLengthXY(), + candidate.decayLengthXYNormalised(), + candidate.cpa(), + candidate.cpaXY(), + candidate.cosPaXi(), + candidate.cosPaXYXi(), + candidate.cosPaLambda(), + candidate.cosPaXYLambda(), + candidate.impactParameter0(), + candidate.impactParameterNormalised0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised2(), + candidate.maxNormalisedDeltaIP(), + // additional columns only stored in the full candidate table + candidate.e(o2::constants::physics::MassXiCPlus), candidate.posX(), candidate.posY(), candidate.posZ(), @@ -411,7 +484,6 @@ struct HfTreeCreatorXicToXiPiPi { candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), - candidate.chi2PCA(), candidate.xSvErr(), candidate.ySvErr(), candidate.zSvErr(), @@ -420,15 +492,26 @@ struct HfTreeCreatorXicToXiPiPi { candidate.zDecayVtxXi(), candidate.xDecayVtxLambda(), candidate.yDecayVtxLambda(), - candidate.zDecayVtxLambda(), + candidate.zDecayVtxLambda()); + } + } else { + if (fillCandidateLiteTable) { + rowCandidateLiteKf( + flagMc, + candidate.isSelXicToXiPiPi(), candidate.sign(), - candidate.e(o2::constants::physics::MassXiCPlus), - candidate.invMassXic(), - candidate.p(), - candidate.pt(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), + candidate.p(), + candidate.pt(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.invMassXic(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.chi2PCA(), candidate.ct(o2::constants::physics::MassXiCPlus), candidate.decayLength(), candidate.decayLengthNormalised(), @@ -436,9 +519,10 @@ struct HfTreeCreatorXicToXiPiPi { candidate.decayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.ptProng0(), - candidate.ptProng1(), - candidate.ptProng2(), + candidate.cosPaXi(), + candidate.cosPaXYXi(), + candidate.cosPaLambda(), + candidate.cosPaXYLambda(), candidate.impactParameter0(), candidate.impactParameterNormalised0(), candidate.impactParameter1(), @@ -446,57 +530,57 @@ struct HfTreeCreatorXicToXiPiPi { candidate.impactParameter2(), candidate.impactParameterNormalised2(), candidate.maxNormalisedDeltaIP(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), - candidate.invMassXiPi0(), - candidate.invMassXiPi1(), - flagMc); - } - } else { - if (fillCandidateLiteTable) { - rowCandidateLiteKf( + // KF-specific columns + candidate.kfCascadeChi2(), + candidate.kfV0Chi2(), + candidate.chi2TopoXicPlusToPVBeforeConstraint(), + candidate.chi2TopoXicPlusToPV(), + candidate.chi2TopoXiToXicPlusBeforeConstraint(), + candidate.chi2TopoXiToXicPlus(), + candidate.dcaXYPi0Pi1(), + candidate.dcaXYPi0Xi(), + candidate.dcaXYPi1Xi(), + candidate.dcaPi0Pi1(), + candidate.dcaPi0Xi(), + candidate.dcaPi1Xi(), + candidate.dcacascdaughters()); + } else { + rowCandidateFullKf( + flagMc, candidate.isSelXicToXiPiPi(), - candidate.posX(), - candidate.posY(), - candidate.posZ(), - candidate.xSecondaryVertex(), - candidate.ySecondaryVertex(), - candidate.zSecondaryVertex(), - candidate.chi2PCA(), candidate.sign(), - candidate.e(o2::constants::physics::MassXiCPlus), - candidate.invMassXic(), - candidate.p(), - candidate.pt(), candidate.y(o2::constants::physics::MassXiCPlus), candidate.eta(), candidate.phi(), + candidate.p(), + candidate.pt(), + candidate.ptProng0(), + candidate.ptProng1(), + candidate.ptProng2(), + candidate.invMassXic(), + candidate.invMassXiPi0(), + candidate.invMassXiPi1(), + candidate.chi2PCA(), candidate.ct(o2::constants::physics::MassXiCPlus), candidate.decayLength(), + candidate.decayLengthNormalised(), candidate.decayLengthXY(), + candidate.decayLengthXYNormalised(), candidate.cpa(), candidate.cpaXY(), - candidate.ptProng0(), - candidate.ptProng1(), - candidate.ptProng2(), - candidate.impactParameter0(), - candidate.impactParameter1(), - candidate.impactParameter2(), candidate.cosPaXi(), candidate.cosPaXYXi(), candidate.cosPaLambda(), candidate.cosPaXYLambda(), - candidate.kfCascadeChi2(), - candidate.kfV0Chi2(), - candidate.dcaPi0Pi1(), - candidate.dcaPi0Xi(), - candidate.dcaPi1Xi(), - flagMc); - } else { - rowCandidateFullKf( - candidate.isSelXicToXiPiPi(), + candidate.impactParameter0(), + candidate.impactParameterNormalised0(), + candidate.impactParameter1(), + candidate.impactParameterNormalised1(), + candidate.impactParameter2(), + candidate.impactParameterNormalised2(), + candidate.maxNormalisedDeltaIP(), + // additional columns only stored in the full candidate table + candidate.e(o2::constants::physics::MassXiCPlus), candidate.posX(), candidate.posY(), candidate.posZ(), @@ -506,7 +590,6 @@ struct HfTreeCreatorXicToXiPiPi { candidate.xSecondaryVertex(), candidate.ySecondaryVertex(), candidate.zSecondaryVertex(), - candidate.chi2PCA(), candidate.xSvErr(), candidate.ySvErr(), candidate.zSvErr(), @@ -516,61 +599,27 @@ struct HfTreeCreatorXicToXiPiPi { candidate.xDecayVtxLambda(), candidate.yDecayVtxLambda(), candidate.zDecayVtxLambda(), - candidate.sign(), - candidate.e(o2::constants::physics::MassXiCPlus), - candidate.invMassXic(), - candidate.p(), - candidate.pt(), - candidate.y(o2::constants::physics::MassXiCPlus), - candidate.eta(), - candidate.phi(), - candidate.ct(o2::constants::physics::MassXiCPlus), - candidate.decayLength(), - candidate.decayLengthNormalised(), - candidate.decayLengthXY(), - candidate.decayLengthXYNormalised(), - candidate.cpa(), - candidate.cpaXY(), - candidate.ptProng0(), - candidate.ptProng1(), - candidate.ptProng2(), - candidate.impactParameter0(), - candidate.impactParameterNormalised0(), - candidate.impactParameter1(), - candidate.impactParameterNormalised1(), - candidate.impactParameter2(), - candidate.impactParameterNormalised2(), - candidate.maxNormalisedDeltaIP(), - candidate.cosPaXi(), - candidate.cosPaXYXi(), - candidate.cosPaLambda(), - candidate.cosPaXYLambda(), - candidate.invMassXiPi0(), - candidate.invMassXiPi1(), + // KF-specific columns candidate.kfCascadeChi2(), candidate.kfV0Chi2(), + candidate.chi2TopoXicPlusToPVBeforeConstraint(), + candidate.chi2TopoXicPlusToPV(), + candidate.chi2TopoXiToXicPlusBeforeConstraint(), + candidate.chi2TopoXiToXicPlus(), + candidate.dcaXYPi0Pi1(), + candidate.dcaXYPi0Xi(), + candidate.dcaXYPi1Xi(), candidate.dcaPi0Pi1(), candidate.dcaPi0Xi(), candidate.dcaPi1Xi(), - flagMc); + candidate.dcacascdaughters()); } } } - void processData(aod::Collisions const& collisions, - SelectedCandidates const& candidates, - TracksWPid const&) + void processData(SelectedCandidates const& candidates) { - // Filling event properties - rowCandidateFullEvents.reserve(collisions.size()); - for (const auto& collision : collisions) { - fillEvent(collision); - } - // Filling candidate properties - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(candidates.size()); } else { @@ -578,33 +627,19 @@ struct HfTreeCreatorXicToXiPiPi { } 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; } } fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } - PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processData, "Process data", true); + PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processData, "Process data with DCAFitter reconstruction", true); - void processDataKf(aod::Collisions const& collisions, - SelectedCandidatesKf const& candidates, - TracksWPid const&) + void processDataKf(SelectedCandidatesKf const& candidates) { - // Filling event properties - rowCandidateFullEvents.reserve(collisions.size()); - for (const auto& collision : collisions) { - fillEvent(collision); - } - // Filling candidate properties - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(candidates.size()); } else { @@ -612,36 +647,23 @@ struct HfTreeCreatorXicToXiPiPi { } 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; } } fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } - PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processDataKf, "Process data with KF Particle reconstruction", false); + PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processDataKf, "Process data with KFParticle reconstruction", false); - void processMc(aod::Collisions const& collisions, - aod::McCollisions const&, - SelectedCandidatesMc const& candidates, - soa::Join const& particles, - TracksWPid const&) + void processMc(SelectedCandidatesMc const& candidates, + soa::Join const& particles) { - // Filling event properties - rowCandidateFullEvents.reserve(collisions.size()); - for (const auto& collision : collisions) { - fillEvent(collision); - } + std::vector arrDaughIndex; // Filling candidate properties if (fillOnlySignal) { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(recSig.size()); } else { @@ -649,33 +671,21 @@ struct HfTreeCreatorXicToXiPiPi { } for (const auto& candidate : recSig) { fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } else if (fillOnlyBackground) { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(recBg.size()); } else { rowCandidateFull.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; } fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } else { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(candidates.size()); } else { @@ -683,45 +693,43 @@ struct HfTreeCreatorXicToXiPiPi { } for (const auto& candidate : candidates) { fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } - // Filling particle properties - 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)) { - rowCandidateFullParticles( - particle.mcCollision().bcId(), - particle.pt(), - particle.eta(), - particle.phi(), - RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, o2::constants::physics::MassXiCPlus), - particle.flagMcMatchGen()); - } + 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)) { + arrDaughIndex.clear(); + RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2); + auto XicDaugh0 = particles.rawIteratorAt(arrDaughIndex[0]); + + rowCandidateFullParticles( + particle.pt(), + particle.eta(), + particle.phi(), + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus), + particle.vx(), + particle.vy(), + particle.vz(), + XicDaugh0.vx(), + XicDaugh0.vx(), + XicDaugh0.vz(), + particle.flagMcMatchGen()); + } + } // loop over generated particles } } - PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processMc, "Process MC", false); + PROCESS_SWITCH(HfTreeCreatorXicToXiPiPi, processMc, "Process MC with DCAFitter reconstruction", false); - void processMcKf(aod::Collisions const& collisions, - aod::McCollisions const&, - SelectedCandidatesKfMc const& candidates, - soa::Join const& particles, - TracksWPid const&) + void processMcKf(SelectedCandidatesKfMc const& candidates, + soa::Join const& particles) { - // Filling event properties - rowCandidateFullEvents.reserve(collisions.size()); - for (const auto& collision : collisions) { - fillEvent(collision); - } + std::vector arrDaughIndex; // Filling candidate properties if (fillOnlySignal) { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(recSigKf.size()); } else { @@ -729,33 +737,21 @@ struct HfTreeCreatorXicToXiPiPi { } for (const auto& candidate : recSigKf) { fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } else if (fillOnlyBackground) { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(recBgKf.size()); } else { rowCandidateFull.reserve(recBgKf.size()); } for (const auto& candidate : recBgKf) { - 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; } fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } else { - if (fillCandidateDauIndexTable) { - rowCandidateDauIndices.reserve(candidates.size()); - } if (fillCandidateLiteTable) { rowCandidateLite.reserve(candidates.size()); } else { @@ -763,27 +759,114 @@ struct HfTreeCreatorXicToXiPiPi { } for (const auto& candidate : candidates) { fillCandidateTable(candidate); - if (fillCandidateDauIndexTable) { - fillIndexTable(candidate); - } } } - // Filling particle properties - 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)) { - rowCandidateFullParticles( - particle.mcCollision().bcId(), - particle.pt(), - particle.eta(), - particle.phi(), - RecoDecay::y(std::array{particle.px(), particle.py(), particle.pz()}, o2::constants::physics::MassXiCPlus), - particle.flagMcMatchGen()); - } + 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)) { + arrDaughIndex.clear(); + RecoDecay::getDaughters(particle, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2); + auto XicDaugh0 = particles.rawIteratorAt(arrDaughIndex[0]); + + rowCandidateFullParticles( + particle.pt(), + particle.eta(), + particle.phi(), + RecoDecay::y(particle.pVector(), o2::constants::physics::MassXiCPlus), + particle.vx(), + particle.vy(), + particle.vz(), + XicDaugh0.vx(), + XicDaugh0.vx(), + XicDaugh0.vz(), + particle.flagMcMatchGen()); + } + } // loop over generated particles } } 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 indexRecXic; + int8_t sign; + std::array pvResiduals; + std::array svResiduals; + std::array pvPulls; + std::array svPulls; + + for (const auto& candidate : recSig) { + arrDaughIndex.clear(); + indexRecXic = -1; + sign = 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 Xic and daughters as MC particle + indexRecXic = RecoDecay::getMatchedMCRec(particles, arrayDaughters, Pdg::kXiCPlus, std::array{+kPiPlus, +kPiPlus, +kPiMinus, +kProton, +kPiMinus}, true, &sign, 4); + if (indexRecXic == -1) { + continue; + } + auto XicGen = particles.rawIteratorAt(indexRecXic); + RecoDecay::getDaughters(XicGen, &arrDaughIndex, std::array{+kXiMinus, +kPiPlus, +kPiPlus}, 2); + auto XicDaugh0 = particles.rawIteratorAt(arrDaughIndex[0]); + + // calculate residuals and pulls + float pResidual = candidate.p() - XicGen.p(); + float ptResidual = candidate.pt() - XicGen.pt(); + pvResiduals[0] = candidate.posX() - XicGen.vx(); + pvResiduals[1] = candidate.posY() - XicGen.vy(); + pvResiduals[2] = candidate.posZ() - XicGen.vz(); + svResiduals[0] = candidate.xSecondaryVertex() - XicDaugh0.vx(); + svResiduals[1] = candidate.ySecondaryVertex() - XicDaugh0.vy(); + svResiduals[2] = candidate.zSecondaryVertex() - XicDaugh0.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( + 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/Tasks/CMakeLists.txt b/PWGHF/Tasks/CMakeLists.txt index 60edb086f1e..00878e48a2c 100644 --- a/PWGHF/Tasks/CMakeLists.txt +++ b/PWGHF/Tasks/CMakeLists.txt @@ -36,7 +36,7 @@ o2physics_add_dpl_workflow(task-mc-gen-pt-rap-shapes o2physics_add_dpl_workflow(task-mc-validation SOURCES taskMcValidation.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) # o2physics_add_dpl_workflow(task-sel-optimisation diff --git a/PWGHF/Tasks/taskMcEfficiency.cxx b/PWGHF/Tasks/taskMcEfficiency.cxx index 024632dd7a1..abdbfcd2d59 100644 --- a/PWGHF/Tasks/taskMcEfficiency.cxx +++ b/PWGHF/Tasks/taskMcEfficiency.cxx @@ -39,7 +39,7 @@ struct HfTaskMcEfficiency { ConfigurableAxis axisPt{"axisPt", {10, 0, 10}, "pT axis"}; ConfigurableAxis axisMass{"axisMass", {120, 1.5848, 2.1848}, "m_inv axis"}; - ConfigurableAxis axisPdg{"axisPdg", {VARIABLE_WIDTH, -4122.5, -431.5, -421.5, -411.5, 0, 411.5, 421.5, 431.5, 4122.5}, "PDG code axis"}; + ConfigurableAxis axisPdg{"axisPdg", {VARIABLE_WIDTH, -4232.5, -4122.5, -431.5, -421.5, -411.5, 0, 411.5, 421.5, 431.5, 4122.5, 4232.5}, "PDG code axis"}; ConfigurableAxis axisCPA{"axisCPA", {102, -1.02, 1.02}, "Cosine of pointing angle axis"}; Configurable mcAcceptancePt{"mcAcceptancePt", 0.1, "MC Acceptance: lower pt limit"}; @@ -101,7 +101,7 @@ struct HfTaskMcEfficiency { return track.isGlobalTrackWoDCA(); } - template + template void candidate3ProngLoop(T1& candidates, T2& tracks, T3& mcParticles, std::vector pdgCodes) { using TracksType = std::decay_t; @@ -130,6 +130,11 @@ struct HfTaskMcEfficiency { pdgDaughters[0] = +kProton; pdgDaughters[1] = -kKPlus; pdgDaughters[2] = +kPiPlus; + } else if (pdgCode == Pdg::kXiCPlus) { + decayType = 1 << aod::hf_cand_3prong::DecayType::XicToPKPi; + pdgDaughters[0] = +kProton; + pdgDaughters[1] = -kKPlus; + pdgDaughters[2] = +kPiPlus; } else { LOGP(fatal, "Not implemented for PDG {}", pdgCode); } @@ -164,6 +169,12 @@ struct HfTaskMcEfficiency { isHypoMass2SelStep = candidate.isSelLcToPiKP(); } } + if constexpr (hasXicPlus) { + if (pdgCode == Pdg::kXiCPlus) { + isHypoMass1SelStep = candidate.isSelXicToPKPi(); + isHypoMass2SelStep = candidate.isSelXicToPiKP(); + } + } bool collisionMatched = false; int origin = RecoDecay::OriginType::None; @@ -194,6 +205,23 @@ struct HfTaskMcEfficiency { } } + if (pdgCode == Pdg::kXiCPlus) { + auto daughter = trackPos.mcParticle(); + if (std::abs(daughter.pdgCode()) == kProton) { + isHypoMass1TrackStep = true; + isHypoMass1SelStep = true; + isHypoMass2TrackStep = false; + isHypoMass2SelStep = false; + } else if (std::abs(daughter.pdgCode()) == kPiPlus) { + isHypoMass1TrackStep = false; + isHypoMass1SelStep = false; + isHypoMass2TrackStep = true; + isHypoMass2SelStep = true; + } else { + continue; + } + } + collisionMatched = candidate.template collision_as().mcCollisionId() == mcParticles.iteratorAt(indexRec).mcCollisionId(); } /// end info MC used @@ -207,6 +235,8 @@ struct HfTaskMcEfficiency { if (isHypoMass1TrackStep) { if (pdgCode == Pdg::kLambdaCPlus) { massHypo1 = hfHelper.invMassLcToPKPi(candidate); + } else if (pdgCode == Pdg::kXiCPlus) { + massHypo1 = hfHelper.invMassXicToPKPi(candidate); } else if (pdgCode == Pdg::kDPlus) { massHypo1 = hfHelper.invMassDplusToPiKPi(candidate); } else if (pdgCode == Pdg::kDS) { @@ -217,6 +247,8 @@ struct HfTaskMcEfficiency { if (isHypoMass2TrackStep) { if (pdgCode == Pdg::kLambdaCPlus) { massHypo2 = hfHelper.invMassLcToPiKP(candidate); + } else if (pdgCode == Pdg::kXiCPlus) { + massHypo2 = hfHelper.invMassXicToPiKP(candidate); } else if (pdgCode == Pdg::kDS) { massHypo2 = hfHelper.invMassDsToPiKK(candidate); } @@ -481,10 +513,10 @@ struct HfTaskMcEfficiency { /// 3-prong analyses - template + template void candidate3ProngMcLoop(C const& candidates, TracksWithSelectionMC const& tracks, aod::McParticles const& mcParticles, aod::McCollisionLabels const&, std::vector pdgCodes) { - candidate3ProngLoop(candidates, tracks, mcParticles, pdgCodes); + candidate3ProngLoop(candidates, tracks, mcParticles, pdgCodes); auto hCandidates = registry.get(HIST("hCandidates")); auto hTrackablePtEta = registry.get(HIST("hTrackablePtEta")); @@ -535,6 +567,10 @@ struct HfTaskMcEfficiency { pdgDaughters[0] = +kProton; pdgDaughters[1] = -kKPlus; pdgDaughters[2] = +kPiPlus; + } else if (pdgCode == Pdg::kXiCPlus) { + pdgDaughters[0] = +kProton; + pdgDaughters[1] = -kKPlus; + pdgDaughters[2] = +kPiPlus; } else { LOGP(fatal, "Not implemented for PDG {}", pdgCode); } @@ -661,7 +697,7 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDPlus}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDplus, "Process D+ data (no MC information needed)", false); @@ -669,7 +705,7 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDS}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDs, "Process Ds+ data (no MC information needed)", false); @@ -677,15 +713,23 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kLambdaCPlus}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataLc, "Process Lc data (no MC information needed)", false); + void processDataXic(soa::Join const& candidates, + TracksWithSelection const& tracks) + { + std::vector pdgCodes{Pdg::kXiCPlus}; + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + } + PROCESS_SWITCH(HfTaskMcEfficiency, processDataXic, "Process Xic data (no MC information needed)", false); + void processDataDplusDs(soa::Join const& candidates, TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kDS}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDplusDs, "Process D+ and Ds+ data (no MC information needed)", false); @@ -693,7 +737,7 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kDS, Pdg::kLambdaCPlus}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDplusDsLc, "Process D+, Ds+, and Lc data (no MC information needed)", false); @@ -701,7 +745,7 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kLambdaCPlus}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDplusLc, "Process D+ and Lc data (no MC information needed)", false); @@ -709,7 +753,7 @@ struct HfTaskMcEfficiency { TracksWithSelection const& tracks) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kDS, Pdg::kLambdaCPlus}; - candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); + candidate3ProngLoop(candidates, tracks, tracks, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processDataDsLc, "Process Ds+ and Lc data (no MC information needed)", false); @@ -730,7 +774,7 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDPlus}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDplus, "Process MC for D+ signal", false); @@ -740,7 +784,7 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDS}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDs, "Process MC for Ds+ signal", false); @@ -750,17 +794,27 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kLambdaCPlus}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcLc, "Process MC for Lc signal", false); + void processMcXic(soa::Join const& candidates, + TracksWithSelectionMC const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisionLabels const& colls) + { + std::vector pdgCodes{Pdg::kXiCPlus}; + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + } + PROCESS_SWITCH(HfTaskMcEfficiency, processMcXic, "Process MC for Xic signal", false); + void processMcDplusDs(soa::Join const& candidates, TracksWithSelectionMC const& tracks, aod::McParticles const& mcParticles, aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kDS}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDplusDs, "Process MC for D+ and Ds+ signals", false); @@ -770,7 +824,7 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kDS, Pdg::kLambdaCPlus}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDplusDsLc, "Process MC for D+, Ds+, and Lc signals", false); @@ -780,7 +834,7 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDPlus, Pdg::kLambdaCPlus}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDplusLc, "Process MC for D+ and Lc signals", false); @@ -790,7 +844,7 @@ struct HfTaskMcEfficiency { aod::McCollisionLabels const& colls) { std::vector pdgCodes{Pdg::kDS, Pdg::kLambdaCPlus}; - candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); + candidate3ProngMcLoop(candidates, tracks, mcParticles, colls, pdgCodes); } PROCESS_SWITCH(HfTaskMcEfficiency, processMcDsLc, "Process MC for Ds+ and Lc signals", false); }; diff --git a/PWGHF/Tasks/taskMcValidation.cxx b/PWGHF/Tasks/taskMcValidation.cxx index f8e18855dff..6c18108bce9 100644 --- a/PWGHF/Tasks/taskMcValidation.cxx +++ b/PWGHF/Tasks/taskMcValidation.cxx @@ -18,22 +18,32 @@ /// \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/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsEvSelHf.h" using namespace o2; using namespace o2::analysis; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_evsel; +using namespace o2::hf_centrality; namespace { @@ -43,6 +53,11 @@ enum DecayChannels { DzeroToKPi = 0, DplusToPhiPiToKKPi, // resonant channel with Phi, Dplus -> PhiPi -> KKPi DsToPhiPiToKKPi, // resonant channel with Phi, Ds -> PhiPi -> KKPi DsToK0starKToKKPi, // resonant channel with K0*, Ds -> K0*K -> KKPi + Ds1ToDStarK0s, + Ds2StarToDPlusK0s, + D10ToDStarPi, + D2Star0ToDPlusPi, + B0ToDminusPi, LcToPKPi, LcToPiK0s, XiCplusToPKPi, @@ -50,25 +65,35 @@ enum DecayChannels { DzeroToKPi = 0, XiCzeroToXiPi, OmegaCToOmegaPi, OmegaCToXiPi, - nChannels }; // always keep nChannels at the end - -static constexpr int nMesonChannels = 6; // number of meson channels -static constexpr int nOriginTypes = 2; // number of origin types (prompt, non-prompt) -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::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, 3, 3, 3, 5, 4, 4, 4}; -static constexpr std::array maxDepthForSearch = {1, 2, 2, 2, 2, 2, 2, 3, 2, 4, 3, 3, 3}; + nChannels +}; // 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 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::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}; // 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, -kPiPlus, -kPiPlus, +kProton}, {+kPiPlus, -kKPlus, -kPiPlus, +kProton}, {+kPiPlus, -kPiPlus, -kPiPlus, +kProton}}}; -static constexpr std::array, nChannels> arrPDGFinal5Prong = {{{}, {}, {}, {}, {}, {}, {}, {}, {}, {+kPiPlus, +kPiPlus, -kPiPlus, -kPiPlus, +kProton}, {}, {}, {}}}; +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::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", "#Lambda_{c}^{+} #rightarrow pK#pi", "#Lambda_{c}^{+} #rightarrow pK^{0}_{s}", "#Xi_{c}^{+} #rightarrow pK#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", + "#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", +static constexpr std::string_view particleNames[nChannels] = {"DzeroToKPi", "DstarToDzeroPi", "DplusToPiKPi", "DplusToPhiPiToKKPi", "DsToPhiPiToKKPi", "DsToK0starKToKKPi", "Ds1ToDStarK0s", "Ds2StarToDPlusK0s", "D10ToDStarPi", "D2Star0ToDPlusPi", "B0ToDminusPi", "LcToPKPi", "LcToPiK0s", "XiCplusToPKPi", "XiCplusToXiPiPi", "XiCzeroToXiPi", "OmegaCToOmegaPi", "OmegaCToXiPi"}; static constexpr std::string_view originNames[nOriginTypes] = {"Prompt", "NonPrompt"}; } // namespace @@ -79,26 +104,38 @@ static constexpr std::string_view originNames[nOriginTypes] = {"Prompt", "NonPro /// - Number of candidates per collision /// - Momentum Conservation for these particles struct HfTaskMcValidationGen { - Configurable xVertexMin{"xVertexMin", -100., "min. x of generated primary vertex [cm]"}; - Configurable xVertexMax{"xVertexMax", 100., "max. x of generated primary vertex [cm]"}; - Configurable yVertexMin{"yVertexMin", -100., "min. y of generated primary vertex [cm]"}; - Configurable yVertexMax{"yVertexMax", 100., "max. y of generated primary vertex [cm]"}; - Configurable zVertexMin{"zVertexMin", -100., "min. z of generated primary vertex [cm]"}; - Configurable zVertexMax{"zVertexMax", 100., "max. z of generated primary vertex [cm]"}; + + using BCsInfo = soa::Join; + using CollisionsNoCents = soa::Join; + using CollisionsFT0Cs = soa::Join; + using CollisionsFT0Ms = soa::Join; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0C = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted colPerMcCollisionFT0M = aod::mccollisionlabel::mcCollisionId; + Preslice mcParticlesPerMcCollision = aod::mcparticle::mcCollisionId; + 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 rejectParticlesFromBkgEvent{"rejectParticlesFromBkgEvent", true, "Reject particles"}; + Configurable storeOccupancy{"storeOccupancy", false, "Store collision occupancy for dedicated studies"}; + + HfEventSelectionMc hfEvSelMc; // mc event selection and monitoring - AxisSpec axisNhadrons{10, -0.5, 9.5}; + AxisSpec axisNhadrons{nChannels, -0.5, static_cast(nChannels) - 0.5}; AxisSpec axisNquarks{20, -0.5, 19.5}; AxisSpec axisResiduals{100, -0.01, 0.01}; AxisSpec axisPt{100, 0., 50.}; AxisSpec axisY{100, -5., 5.}; - AxisSpec axisMesonSpecies{nMesonChannels, -0.5, static_cast(nMesonChannels) - 0.5}; - AxisSpec axisBaryonSpecies{nChannels - nMesonChannels, -0.5, static_cast(nChannels - nMesonChannels) - 0.5}; + AxisSpec axisCent{110, 0., 110.}; + AxisSpec axisOcc{3000, 0., 15000.}; + AxisSpec axisCharmMesonSpecies{nCharmMesonChannels, -0.5, static_cast(nCharmMesonChannels) - 0.5}; + AxisSpec axisBeautySpecies{nBeautyChannels, -0.5, static_cast(nBeautyChannels) - 0.5}; + AxisSpec axisCharmBaryonSpecies{nCharmBaryonChannels, -0.5, static_cast(nCharmBaryonChannels) - 0.5}; AxisSpec axisDecLen{100, 0., 10000.}; HistogramRegistry registry{ "registry", - {{"hMomentumCheck", "Mom. Conservation (1 = true, 0 = false) (#it{#epsilon} = 1 MeV/#it{c}); Mom. Conservation result; entries", {HistType::kTH1F, {{2, -0.5, +1.5}}}}, + {{"hNevGen", "Generated events counter; Gen. events; entries", {HistType::kTH1F, {{1, -0.5, +0.5}}}}, + {"hMomentumCheck", "Mom. Conservation (1 = true, 0 = false) (#it{#epsilon} = 1 MeV/#it{c}); Mom. Conservation result; entries", {HistType::kTH1F, {{2, -0.5, +1.5}}}}, {"hPtDiffMotherDaughterGen", "Pt Difference Mother-Daughters; #Delta#it{p}_{T}^{gen} (GeV/#it{c}); entries", {HistType::kTH1F, {axisResiduals}}}, {"hPxDiffMotherDaughterGen", "Px Difference Mother-Daughters; #Delta#it{p}_{x}^{gen} (GeV/#it{c}); entries", {HistType::kTH1F, {axisResiduals}}}, {"hPyDiffMotherDaughterGen", "Py Difference Mother-Daughters; #Delta#it{p}_{y}^{gen} (GeV/#it{c}); entries", {HistType::kTH1F, {axisResiduals}}}, @@ -110,78 +147,145 @@ struct HfTaskMcValidationGen { {"Quarks/hCountBbar", "Event counter - Number of anti-beauty quarks; Events Per Collision; entries", {HistType::kTH1F, {axisNquarks}}}, {"Quarks/hPtVsYCharmQuark", "Y vs. Pt - charm quarks ; #it{p}_{T}^{gen} (GeV/#it{c}); #it{y}^{gen}", {HistType::kTH2F, {axisPt, axisY}}}, {"Quarks/hPtVsYBeautyQuark", "Y vs. Pt - beauty quarks ; #it{p}_{T}^{gen} (GeV/#it{c}); #it{y}^{gen}", {HistType::kTH2F, {axisPt, axisY}}}, - {"PromptCharmMesons/hPromptMesonsPtDistr", "Pt distribution vs prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisMesonSpecies, axisPt}}}, - {"PromptCharmMesons/hPromptMesonsYDistr", "Y distribution vs prompt charm meson; ; #it{y}^{gen}", {HistType::kTH2F, {axisMesonSpecies, axisY}}}, - {"PromptCharmMesons/hPromptMesonsDecLenDistr", "Decay length distribution vs prompt charm meson; ; decay length (#mum)", {HistType::kTH2F, {axisMesonSpecies, axisDecLen}}}, - {"NonPromptCharmMesons/hNonPromptMesonsPtDistr", "Pt distribution vs non-prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisMesonSpecies, axisPt}}}, - {"NonPromptCharmMesons/hNonPromptMesonsYDistr", "Y distribution vs non-prompt charm meson; ; #it{y}^{gen}", {HistType::kTH2F, {axisMesonSpecies, axisY}}}, - {"NonPromptCharmMesons/hNonPromptMesonsDecLenDistr", "Decay length distribution vs non-prompt charm meson; ; decay length (#mum)", {HistType::kTH2F, {axisMesonSpecies, axisDecLen}}}, - {"PromptCharmBaryons/hPromptBaryonsPtDistr", "Pt distribution vs prompt charm baryon in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisBaryonSpecies, axisPt}}}, - {"PromptCharmBaryons/hPromptBaryonsYDistr", "Y distribution vs prompt charm baryon; ; #it{y}^{gen}", {HistType::kTH2F, {axisBaryonSpecies, axisY}}}, - {"PromptCharmBaryons/hPromptBaryonsDecLenDistr", "Decay length distribution vs prompt charm baryon; ; decay length (#mum)", {HistType::kTH2F, {axisBaryonSpecies, axisDecLen}}}, - {"NonPromptCharmBaryons/hNonPromptBaryonsPtDistr", "Pt distribution vs non-prompt charm baryon in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisBaryonSpecies, axisPt}}}, - {"NonPromptCharmBaryons/hNonPromptBaryonsYDistr", "Y distribution vs non-prompt charm baryon; ; #it{y}^{gen}", {HistType::kTH2F, {axisBaryonSpecies, axisY}}}, - {"NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr", "Decay length distribution vs non-prompt charm baryon; ; decay length (#mum)", {HistType::kTH2F, {axisBaryonSpecies, axisDecLen}}}}}; + {"PromptCharmMesons/hPromptMesonsPtDistr", "Pt distribution vs prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisCharmMesonSpecies, axisPt}}}, + {"PromptCharmMesons/hPromptMesonsPtCentDistr", "Pt vs Cent distribution vs prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Centrality (%)", {HistType::kTH3F, {axisCharmMesonSpecies, axisPt, axisCent}}}, + {"PromptCharmMesons/hPromptMesonsPtOccDistr", "Pt vs Occ distribution vs prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Occupancy", {HistType::kTH3F, {axisCharmMesonSpecies, axisPt, axisOcc}}}, + {"PromptCharmMesons/hPromptMesonsYDistr", "Y distribution vs prompt charm meson; ; #it{y}^{gen}", {HistType::kTH2F, {axisCharmMesonSpecies, axisY}}}, + {"PromptCharmMesons/hPromptMesonsDecLenDistr", "Decay length distribution vs prompt charm meson; ; decay length (#mum)", {HistType::kTH2F, {axisCharmMesonSpecies, axisDecLen}}}, + {"NonPromptCharmMesons/hNonPromptMesonsPtDistr", "Pt distribution vs non-prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisCharmMesonSpecies, axisPt}}}, + {"NonPromptCharmMesons/hNonPromptMesonsPtCentDistr", "Pt vs Cent distribution vs non-prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Centrality (%)", {HistType::kTH3F, {axisCharmMesonSpecies, axisPt, axisCent}}}, + {"NonPromptCharmMesons/hNonPromptMesonsPtOccDistr", "Pt vs Occ distribution vs non-prompt charm meson in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Occupancy", {HistType::kTH3F, {axisCharmMesonSpecies, axisPt, axisOcc}}}, + {"NonPromptCharmMesons/hNonPromptMesonsYDistr", "Y distribution vs non-prompt charm meson; ; #it{y}^{gen}", {HistType::kTH2F, {axisCharmMesonSpecies, axisY}}}, + {"NonPromptCharmMesons/hNonPromptMesonsDecLenDistr", "Decay length distribution vs non-prompt charm meson; ; decay length (#mum)", {HistType::kTH2F, {axisCharmMesonSpecies, axisDecLen}}}, + {"Beauty/hPtDistr", "Pt distribution vs beauty hadron in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisBeautySpecies, axisPt}}}, + {"Beauty/hPtCentDistr", "Pt vs Cent distribution vs beauty hadron in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Centrality (%)", {HistType::kTH3F, {axisBeautySpecies, axisPt, axisCent}}}, + {"Beauty/hPtOccDistr", "Pt vs Occ distribution vs beauty hadron in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Occupancy", {HistType::kTH3F, {axisBeautySpecies, axisPt, axisOcc}}}, + {"Beauty/hYDistr", "Y distribution vs beauty hadron; ; #it{y}^{gen}", {HistType::kTH2F, {axisBeautySpecies, axisY}}}, + {"Beauty/hDecLenDistr", "Decay length distribution vs beauty hadron; ; decay length (#mum)", {HistType::kTH2F, {axisBeautySpecies, axisDecLen}}}, + {"PromptCharmBaryons/hPromptBaryonsPtDistr", "Pt distribution vs prompt charm baryon in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisCharmBaryonSpecies, axisPt}}}, + {"PromptCharmBaryons/hPromptBaryonsPtCentDistr", "Pt vs Cent distribution vs prompt charm baryons in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Centrality (%)", {HistType::kTH3F, {axisCharmBaryonSpecies, axisPt, axisCent}}}, + {"PromptCharmBaryons/hPromptBaryonsYDistr", "Y distribution vs prompt charm baryon; ; #it{y}^{gen}", {HistType::kTH2F, {axisCharmBaryonSpecies, axisY}}}, + {"PromptCharmBaryons/hPromptBaryonsPtOccDistr", "Pt vs Occ distribution vs prompt charm baryons in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Occupancy", {HistType::kTH3F, {axisCharmBaryonSpecies, axisPt, axisOcc}}}, + {"PromptCharmBaryons/hPromptBaryonsDecLenDistr", "Decay length distribution vs prompt charm baryon; ; decay length (#mum)", {HistType::kTH2F, {axisCharmBaryonSpecies, axisDecLen}}}, + {"NonPromptCharmBaryons/hNonPromptBaryonsPtDistr", "Pt distribution vs non-prompt charm baryon in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c})", {HistType::kTH2F, {axisCharmBaryonSpecies, axisPt}}}, + {"NonPromptCharmBaryons/hNonPromptBaryonsPtCentDistr", "Pt vs Cent distribution vs prompt charm baryons in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Centrality (%)", {HistType::kTH3F, {axisCharmBaryonSpecies, axisPt, axisCent}}}, + {"NonPromptCharmBaryons/hNonPromptBaryonsPtOccDistr", "Pt vs Occ distribution vs prompt charm baryons in |#it{y}^{gen}|<0.5; ; #it{p}_{T}^{gen} (GeV/#it{c}); Occupancy", {HistType::kTH3F, {axisCharmBaryonSpecies, axisPt, axisOcc}}}, + {"NonPromptCharmBaryons/hNonPromptBaryonsYDistr", "Y distribution vs non-prompt charm baryon; ; #it{y}^{gen}", {HistType::kTH2F, {axisCharmBaryonSpecies, axisY}}}, + {"NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr", "Decay length distribution vs non-prompt charm baryon; ; decay length (#mum)", {HistType::kTH2F, {axisCharmBaryonSpecies, axisDecLen}}}}}; - void init(InitContext&) + void init(InitContext& initContext) { + + std::array processes = {doprocessNoCentSel, doprocessCentFT0C, doprocessCentFT0M}; + if (std::accumulate(processes.begin(), processes.end(), 0) > 1) { + LOGP(fatal, "At most one process function for generated particles can be enabled at a time."); + } + // add per species histograms for (size_t iOrigin = 0; iOrigin < nOriginTypes; iOrigin++) { - for (int iChannel = 0; iChannel < nMesonChannels; iChannel++) { + for (int iChannel = 0; iChannel < nCharmMesonChannels; iChannel++) { // Charm mesons registry.add(Form("%sCharmMesons/hCount%s%s", originNames[iOrigin].data(), originNames[iOrigin].data(), particleNames[iChannel].data()), Form("Event counter - %s %s; Events Per Collision; entries", originNames[iOrigin].data(), labels[iChannel].data()), {HistType::kTH1F, {axisNhadrons}}); } - for (int iChannel = nMesonChannels; iChannel < nChannels; iChannel++) { + for (int iChannel = nCharmMesonChannels + nBeautyChannels; iChannel < nChannels; iChannel++) { // Charm baryons registry.add(Form("%sCharmBaryons/hCount%s%s", originNames[iOrigin].data(), originNames[iOrigin].data(), particleNames[iChannel].data()), Form("Event counter - %s %s; Events Per Collision; entries", originNames[iOrigin].data(), labels[iChannel].data()), {HistType::kTH1F, {axisNhadrons}}); } } + for (int iChannel = nCharmMesonChannels; iChannel < nCharmMesonChannels + nBeautyChannels; iChannel++) { // Beauty mesons + registry.add(Form("Beauty/hCount%s", particleNames[iChannel].data()), + Form("Event counter - %s; Events Per Collision; entries", labels[iChannel].data()), {HistType::kTH1F, {axisNhadrons}}); + } - for (auto iBin = 1; iBin <= nMesonChannels; ++iBin) { + for (auto iBin = 1; iBin <= nCharmMesonChannels; ++iBin) { registry.get(HIST("PromptCharmMesons/hPromptMesonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); + registry.get(HIST("PromptCharmMesons/hPromptMesonsPtCentDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); + registry.get(HIST("PromptCharmMesons/hPromptMesonsPtOccDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); registry.get(HIST("PromptCharmMesons/hPromptMesonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); registry.get(HIST("PromptCharmMesons/hPromptMesonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); registry.get(HIST("NonPromptCharmMesons/hNonPromptMesonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); + registry.get(HIST("NonPromptCharmMesons/hNonPromptMesonsPtCentDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); + registry.get(HIST("NonPromptCharmMesons/hNonPromptMesonsPtOccDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); registry.get(HIST("NonPromptCharmMesons/hNonPromptMesonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); registry.get(HIST("NonPromptCharmMesons/hNonPromptMesonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin - 1].data()); } - for (auto iBin = 1; iBin <= nChannels - nMesonChannels; ++iBin) { - registry.get(HIST("PromptCharmBaryons/hPromptBaryonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); - registry.get(HIST("PromptCharmBaryons/hPromptBaryonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); - registry.get(HIST("PromptCharmBaryons/hPromptBaryonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); - registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); - registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); - registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nMesonChannels - 1].data()); + for (auto iBin = 1; iBin <= nBeautyChannels; ++iBin) { + registry.get(HIST("Beauty/hPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels - 1].data()); + registry.get(HIST("Beauty/hPtCentDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels - 1].data()); + registry.get(HIST("Beauty/hPtOccDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels - 1].data()); + registry.get(HIST("Beauty/hYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels - 1].data()); + registry.get(HIST("Beauty/hDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels - 1].data()); } + for (auto iBin = 1; iBin <= nCharmBaryonChannels; ++iBin) { + registry.get(HIST("PromptCharmBaryons/hPromptBaryonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("PromptCharmBaryons/hPromptBaryonsPtCentDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("PromptCharmBaryons/hPromptBaryonsPtOccDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("PromptCharmBaryons/hPromptBaryonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("PromptCharmBaryons/hPromptBaryonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtCentDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtOccDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsYDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + registry.get(HIST("NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr"))->GetXaxis()->SetBinLabel(iBin, labels[iBin + nCharmMesonChannels + nBeautyChannels - 1].data()); + } + + // inspect for which particle species the candidates were created and which zPvPosMax cut was set for reconstructed + const auto& workflows = initContext.services().get(); + for (const DeviceSpec& device : workflows.devices) { + if (device.name.compare("hf-task-mc-validation-rec") == 0) { + hfEvSelMc.configureFromDevice(device); + break; + } + } + + hfEvSelMc.addHistograms(registry); // particles monitoring } - /// Primary-vertex selection - /// \param collision mcCollision table row - template - bool selectVertex(const Col& collision) + /// \brief Function to get MC collision occupancy + /// \param collSlice collection of reconstructed collisions + /// \return collision occupancy + template + int getOccupancyColl(CCs const& collSlice) { - // x position - if (collision.posX() < xVertexMin || collision.posX() > xVertexMax) { - return false; - } - // y position - if (collision.posY() < yVertexMin || collision.posY() > yVertexMax) { - return false; - } - // z position - if (collision.posZ() < zVertexMin || collision.posZ() > zVertexMax) { - return false; - } - return true; + float multiplicity{0.f}; + int occupancy = 0; + for (const auto& collision : collSlice) { + float collMult{0.f}; + collMult = collision.numContrib(); + + if (collMult > multiplicity) { + occupancy = collision.trackOccupancyInTimeRange(); + multiplicity = collMult; + } + } // end loop over collisions + + return occupancy; } - void process(aod::McCollision const& mcCollision, - aod::McParticles const& mcParticles) + template + void runCheckGenParticles(GenColl const& mcCollision, Particles const& mcParticles, RecoColls const& recoCollisions, BCsInfo const&, std::array& counterPrompt, std::array& counterNonPrompt) { if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { return; } - if (!selectVertex(mcCollision)) { + registry.fill(HIST("hNevGen"), 1); + + // Slice the collisions table to get the collision info for the current MC collision + float centrality{105.f}; + int occupancy = 0; + if (storeOccupancy) { + occupancy = getOccupancyColl(recoCollisions); + } + uint16_t rejectionMask{0}; + if constexpr (centEstimator == CentralityEstimator::FT0C) { + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, recoCollisions, centrality); + } else if constexpr (centEstimator == CentralityEstimator::FT0M) { + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, recoCollisions, centrality); + } else if constexpr (centEstimator == CentralityEstimator::None) { + rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, recoCollisions, centrality); + } + hfEvSelMc.fillHistograms(rejectionMask); + if (rejectionMask != 0) { return; } @@ -189,16 +293,20 @@ struct HfTaskMcValidationGen { int cBarPerCollision = 0; int bPerCollision = 0; int bBarPerCollision = 0; - std::array counterPrompt{0}, counterNonPrompt{0}; for (const auto& particle : mcParticles) { + + if (rejectParticlesFromBkgEvent && particle.fromBackgroundEvent()) { + continue; + } + if (!particle.has_mothers()) { continue; } int particlePdgCode = particle.pdgCode(); bool isDiffFromMothers = true; - for (const auto& mother : particle.mothers_as()) { + for (const auto& mother : particle.template mothers_as()) { if (particlePdgCode == mother.pdgCode()) { isDiffFromMothers = false; break; @@ -265,7 +373,21 @@ struct HfTaskMcValidationGen { } if (nDaughters[iD] == 4) { - if (!RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], arrPDGFinal4Prong[iD], true, nullptr, maxDepthForSearch[iD], &listDaughters)) { + if (iD != B0ToDminusPi) { + if (!RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], arrPDGFinal4Prong[iD], true, nullptr, maxDepthForSearch[iD], &listDaughters)) { + continue; + } + } else { // For B0 we consider flavour oscillations + if (!RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], arrPDGFinal4Prong[iD], true, nullptr, maxDepthForSearch[iD], &listDaughters)) { + continue; + } + } + if (iD == D10ToDStarPi && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+o2::constants::physics::Pdg::kDStar, -kPiPlus}, true)) { + continue; + } + if (iD == D2Star0ToDPlusPi && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+o2::constants::physics::Pdg::kDPlus, -kPiPlus}, true)) { continue; } if ((iD == XiCzeroToXiPi || iD == OmegaCToXiPi) && @@ -276,12 +398,26 @@ struct HfTaskMcValidationGen { !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+kOmegaMinus, +kPiPlus}, true)) { continue; } + if (iD == B0ToDminusPi && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{-o2::constants::physics::Pdg::kDPlus, +kPiPlus}, true)) { + continue; + } } if (nDaughters[iD] == 5) { if (!RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], arrPDGFinal5Prong[iD], true, nullptr, maxDepthForSearch[iD], &listDaughters)) { continue; } + if (iD == Ds1ToDStarK0s && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+kK0Short, +o2::constants::physics::Pdg::kDStar}, false, nullptr, 2) && + !RecoDecay::isMatchedMCGen(mcParticles, particle, -PDGArrayParticle[iD], std::array{+kK0Short, -o2::constants::physics::Pdg::kDStar}, false, nullptr, 2)) { + continue; + } + if (iD == Ds2StarToDPlusK0s && + !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+kK0Short, +o2::constants::physics::Pdg::kDPlus}, false, nullptr, 2) && + !RecoDecay::isMatchedMCGen(mcParticles, particle, -PDGArrayParticle[iD], std::array{+kK0Short, -o2::constants::physics::Pdg::kDPlus}, false, nullptr, 2)) { + continue; + } if (iD == XiCplusToXiPiPi && !RecoDecay::isMatchedMCGen(mcParticles, particle, PDGArrayParticle[iD], std::array{+kXiMinus, +kPiPlus, +kPiPlus}, true, nullptr, 2)) { continue; @@ -314,44 +450,70 @@ struct HfTaskMcValidationGen { registry.fill(HIST("hPDiffMotherDaughterGen"), pDiff); registry.fill(HIST("hPtDiffMotherDaughterGen"), ptDiff); - int origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); - if (origin == RecoDecay::OriginType::Prompt) { - counterPrompt[iD]++; - } else if (origin == RecoDecay::OriginType::NonPrompt) { - counterNonPrompt[iD]++; + int origin{0}; + if (iD < nCharmMesonChannels || iD >= nCharmMesonChannels + nBeautyChannels) { // Charm hadrons + origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle); + if (origin == RecoDecay::OriginType::Prompt) { + counterPrompt[iD]++; + } else if (origin == RecoDecay::OriginType::NonPrompt) { + counterNonPrompt[iD]++; + } } - auto daughter0 = particle.daughters_as().begin(); + auto daughter0 = particle.template daughters_as().begin(); double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; double vertexPrimary[3] = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; auto decayLength = RecoDecay::distance(vertexPrimary, vertexDau); - if (iD < nMesonChannels) { - if (origin == RecoDecay::OriginType::Prompt) { + if (iD < nCharmMesonChannels) { + if (origin == RecoDecay::OriginType::Prompt) { // Prompt charm mesons if (std::abs(particle.y()) < 0.5) { registry.fill(HIST("PromptCharmMesons/hPromptMesonsPtDistr"), iD, particle.pt()); + registry.fill(HIST("PromptCharmMesons/hPromptMesonsPtCentDistr"), iD, particle.pt(), centrality); + if (storeOccupancy) { + registry.fill(HIST("PromptCharmMesons/hPromptMesonsPtOccDistr"), iD, particle.pt(), occupancy); + } } registry.fill(HIST("PromptCharmMesons/hPromptMesonsYDistr"), iD, particle.y()); registry.fill(HIST("PromptCharmMesons/hPromptMesonsDecLenDistr"), iD, decayLength * 10000); } else if (origin == RecoDecay::OriginType::NonPrompt) { if (std::abs(particle.y()) < 0.5) { registry.fill(HIST("NonPromptCharmMesons/hNonPromptMesonsPtDistr"), iD, particle.pt()); + registry.fill(HIST("NonPromptCharmMesons/hNonPromptMesonsPtCentDistr"), iD, particle.pt(), centrality); + if (storeOccupancy) { + registry.fill(HIST("NonPromptCharmMesons/hNonPromptMesonsPtOccDistr"), iD, particle.pt(), occupancy); + } } registry.fill(HIST("NonPromptCharmMesons/hNonPromptMesonsYDistr"), iD, particle.y()); registry.fill(HIST("NonPromptCharmMesons/hNonPromptMesonsDecLenDistr"), iD, decayLength * 10000); } - } else { + } else if (iD < nCharmMesonChannels + nBeautyChannels) { // Beauty mesons + if (std::abs(particle.y()) < 0.5) { + registry.fill(HIST("Beauty/hPtDistr"), iD - nCharmMesonChannels, particle.pt()); + registry.fill(HIST("Beauty/hPtCentDistr"), iD - nCharmMesonChannels, particle.pt(), centrality); + } + registry.fill(HIST("Beauty/hYDistr"), iD - nCharmMesonChannels, particle.y()); + registry.fill(HIST("Beauty/hDecLenDistr"), iD - nCharmMesonChannels, decayLength * 10000); + } else { // Charm baryons if (origin == RecoDecay::OriginType::Prompt) { if (std::abs(particle.y()) < 0.5) { - registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsPtDistr"), iD - nMesonChannels, particle.pt()); + registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsPtDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt()); + registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsPtCentDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt(), centrality); + if (storeOccupancy) { + registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsPtOccDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt(), occupancy); + } } - registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsYDistr"), iD - nMesonChannels, particle.y()); - registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsDecLenDistr"), iD - nMesonChannels, decayLength * 10000); + registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsYDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.y()); + registry.fill(HIST("PromptCharmBaryons/hPromptBaryonsDecLenDistr"), iD - nCharmMesonChannels - nBeautyChannels, decayLength * 10000); } else if (origin == RecoDecay::OriginType::NonPrompt) { if (std::abs(particle.y()) < 0.5) { - registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtDistr"), iD - nMesonChannels, particle.pt()); + registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt()); + registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtCentDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt(), centrality); + if (storeOccupancy) { + registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsPtOccDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.pt(), occupancy); + } } - registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsYDistr"), iD - nMesonChannels, particle.y()); - registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr"), iD - nMesonChannels, decayLength * 10000); + registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsYDistr"), iD - nCharmMesonChannels - nBeautyChannels, particle.y()); + registry.fill(HIST("NonPromptCharmBaryons/hNonPromptBaryonsDecLenDistr"), iD - nCharmMesonChannels - nBeautyChannels, decayLength * 10000); } } } @@ -361,17 +523,91 @@ struct HfTaskMcValidationGen { registry.fill(HIST("Quarks/hCountB"), bPerCollision); registry.fill(HIST("Quarks/hCountCbar"), cBarPerCollision); registry.fill(HIST("Quarks/hCountBbar"), bBarPerCollision); - static_for<0, nMesonChannels - 1>([&](auto i) { - constexpr int index = i.value; - registry.fill(HIST("PromptCharmMesons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); - registry.fill(HIST("NonPromptCharmMesons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); - }); - static_for([&](auto i) { - constexpr int index = i.value; - registry.fill(HIST("PromptCharmBaryons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); - registry.fill(HIST("NonPromptCharmBaryons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); - }); - }; + } + + void processNoCentSel(aod::McCollisions const& mcCollisions, + aod::McParticles const& mcParticles, + CollisionsNoCents const& recoCollisions, + BCsInfo const& bcInfo) + { + for (const auto& mcCollision : mcCollisions) { + const auto recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + std::array counterPrompt{0}, counterNonPrompt{0}; + runCheckGenParticles(mcCollision, mcParticlesPerMcColl, recoCollsPerMcColl, bcInfo, counterPrompt, counterNonPrompt); + static_for<0, nCharmMesonChannels - 1>([&](auto i) { // Charm mesons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmMesons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmMesons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + static_for([&](auto i) { // Beauty hadrons + constexpr int index = i.value; + registry.fill(HIST("Beauty/hCount") + HIST(particleNames[index]), counterPrompt[index]); + }); + static_for([&](auto i) { // Charm baryons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmBaryons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmBaryons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + } + } // end processNoCentSel + PROCESS_SWITCH(HfTaskMcValidationGen, processNoCentSel, "Process generated collisions information without centrality selection", true); + + void processCentFT0C(aod::McCollisions const& mcCollisions, + aod::McParticles const& mcParticles, + CollisionsFT0Cs const& recoCollisions, + BCsInfo const& bcInfo) + { + for (const auto& mcCollision : mcCollisions) { + const auto recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + std::array counterPrompt{0}, counterNonPrompt{0}; + runCheckGenParticles(mcCollision, mcParticlesPerMcColl, recoCollsPerMcColl, bcInfo, counterPrompt, counterNonPrompt); + static_for<0, nCharmMesonChannels - 1>([&](auto i) { // Charm mesons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmMesons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmMesons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + static_for([&](auto i) { // Beauty + constexpr int index = i.value; + registry.fill(HIST("Beauty/hCount") + HIST(particleNames[index]), counterPrompt[index]); + }); + static_for([&](auto i) { // Charm baryons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmBaryons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmBaryons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + } + } // end processCentFT0C + PROCESS_SWITCH(HfTaskMcValidationGen, processCentFT0C, "Process generated collisions information with centrality selection using FT0C", false); + + void processCentFT0M(aod::McCollisions const& mcCollisions, + aod::McParticles const& mcParticles, + CollisionsFT0Ms const& recoCollisions, + BCsInfo const& bcInfo) + { + for (const auto& mcCollision : mcCollisions) { + const auto recoCollsPerMcColl = recoCollisions.sliceBy(colPerMcCollisionFT0M, mcCollision.globalIndex()); + const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); + std::array counterPrompt{0}, counterNonPrompt{0}; + runCheckGenParticles(mcCollision, mcParticlesPerMcColl, recoCollsPerMcColl, bcInfo, counterPrompt, counterNonPrompt); + static_for<0, nCharmMesonChannels - 1>([&](auto i) { // Charm mesons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmMesons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmMesons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + static_for([&](auto i) { // Beauty mesons + constexpr int index = i.value; + registry.fill(HIST("Beauty/hCount") + HIST(particleNames[index]), counterPrompt[index]); + }); + static_for([&](auto i) { // Charm baryons + constexpr int index = i.value; + registry.fill(HIST("PromptCharmBaryons/hCountPrompt") + HIST(particleNames[index]), counterPrompt[index]); + registry.fill(HIST("NonPromptCharmBaryons/hCountNonPrompt") + HIST(particleNames[index]), counterNonPrompt[index]); + }); + } + } // end processCentFT0M + PROCESS_SWITCH(HfTaskMcValidationGen, processCentFT0M, "Process generated collisions information with centrality selection using FT0M", false); }; /// Reconstruction Level Validation @@ -383,27 +619,40 @@ struct HfTaskMcValidationRec { Preslice perCol = aod::track::collisionId; 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 storeOccupancy{"storeOccupancy", false, "Store collision occupancy for dedicated studies"}; std::array, nChannels> histDeltaPt, histDeltaPx, histDeltaPy, histDeltaPz, histDeltaSecondaryVertexX, histDeltaSecondaryVertexY, histDeltaSecondaryVertexZ, histDeltaDecayLength; + std::array, 2>, nChannels> histPtCentReco; + std::array, 2>, nChannels> histPtOccReco; std::array, 5>, 2>, nChannels> histPtDau, histEtaDau, histImpactParameterDau; - std::array, 2>, nChannels> histPtReco; std::array, 4> histOriginTracks; std::shared_ptr histAmbiguousTracks, histTracks; std::shared_ptr histContributors; using HfCand2ProngWithMCRec = soa::Join; using HfCand3ProngWithMCRec = soa::Join; - using CollisionsWithMCLabels = soa::Join; + using CandMcGen = soa::Join; + using CollisionsWithMCLabels = soa::Join; + using CollisionsWithMCLabelsAndCentFT0C = soa::Join; + using CollisionsWithMCLabelsAndCentFT0M = soa::Join; using TracksWithSel = soa::Join; Partition tracksFilteredGlobalTrackWoDCA = requireGlobalTrackWoDCAInFilter(); Partition tracksInAcc = requireTrackCutInFilter(TrackSelectionFlags::kInAcceptanceTracks); + Preslice cand2ProngPerCollision = aod::hf_cand::collisionId; + Preslice cand3ProngPerCollision = aod::hf_cand::collisionId; + + Service ccdb; + HfEventSelection hfEvSel; // event selection and monitoring + AxisSpec axisDeltaMom{2000, -1., 1.}; AxisSpec axisOrigin{4, -1.5, 2.5}; AxisSpec axisEta{40, -1., 1.}; AxisSpec axisPt{50, 0., 10.}; AxisSpec axisPtD{100, 0., 50.}; + AxisSpec axisCent{110, 0., 110.}; + AxisSpec axisOcc{3000, 0., 15000.}; AxisSpec axisDeltaVtx{200, -1, 1.}; AxisSpec axisDecision{2, -0.5, 1.5}; AxisSpec axisITShits{8, -0.5, 7.5}; @@ -414,6 +663,7 @@ struct HfTaskMcValidationRec { HistogramRegistry registry{ "registry", {{"histNtracks", "Number of global tracks w/o DCA requirement;#it{N}_{tracks};entries", {HistType::kTH1F, {axisMult}}}, + {"hNevReco", "Reconstructed events counter; Reco. events; entries", {HistType::kTH1F, {{1, -0.5, +0.5}}}}, {"histXvtxReco", "Position of reco PV in #it{X};#it{X}^{reco} (cm);entries", {HistType::kTH1F, {axisDeltaVtx}}}, {"histYvtxReco", "Position of reco PV in #it{Y};#it{Y}^{reco} (cm);entries", {HistType::kTH1F, {axisDeltaVtx}}}, {"histZvtxReco", "Position of reco PV in #it{Z};#it{Z}^{reco} (cm);entries", {HistType::kTH1F, {{200, -20, 20.}}}}, @@ -422,6 +672,8 @@ struct HfTaskMcValidationRec { {"TrackToCollChecks/histAmbiguousTrackZvtxRMS", "RMS of #it{Z}^{reco} of collisions associated to a track;RMS(#it{Z}^{reco}) (cm);entries", {HistType::kTH1F, {{100, 0., 0.5}}}}, {"TrackToCollChecks/histFracGoodContributors", "Fraction of PV contributors originating from the correct collision;fraction;entries", {HistType::kTH1F, {{101, 0., 1.01}}}}, {"TrackToCollChecks/histCollisionsSameBC", "Collisions in same BC;number of contributors collision 1;number of contributors collision 2;#it{R}_{xy} collision 1 (cm);#it{R}_{xy} collision 2 (cm);number of contributors from beauty collision 1;number of contributors from beauty collision 2;", {HistType::kTHnSparseF, {axisMult, axisMult, axisR, axisR, axisSmallNum, axisSmallNum}}}}}; + HistogramRegistry registryMesons{"registryMesons"}; + HistogramRegistry registryBaryons{"registryBaryons"}; /// RMS calculation /// \param vec vector of values to compute RMS @@ -444,8 +696,10 @@ struct HfTaskMcValidationRec { /// \param mother is mother particle /// \param whichHad int indicating charm-hadron and decay channel, see enum DecayChannels /// \param whichOrigin int indicating origin: prompt or non-prompt + /// \param centrality is collision centrality + /// \param occupancy is collision occupancy template - void fillHisto(const T& candidate, const U& mother, int whichHad, int whichOrigin) + void fillHisto(const T& candidate, const U& mother, int whichHad, int whichOrigin, float centrality, int occupancy) { histDeltaPt[whichHad]->Fill(candidate.pt() - mother.pt()); histDeltaPx[whichHad]->Fill(candidate.px() - mother.px()); @@ -467,7 +721,10 @@ struct HfTaskMcValidationRec { std::array momDau1 = {candidate.pxProng1(), candidate.pyProng1(), candidate.pzProng1()}; - histPtReco[whichHad][whichOrigin]->Fill(candidate.pt()); + histPtCentReco[whichHad][whichOrigin]->Fill(candidate.pt(), centrality); + if (storeOccupancy) { + histPtOccReco[whichHad][whichOrigin]->Fill(candidate.pt(), occupancy); + } histPtDau[whichHad][whichOrigin][0]->Fill(RecoDecay::pt(momDau0)); histEtaDau[whichHad][whichOrigin][0]->Fill(RecoDecay::eta(momDau0)); histImpactParameterDau[whichHad][whichOrigin][0]->Fill(candidate.impactParameter0()); @@ -478,6 +735,16 @@ struct HfTaskMcValidationRec { void init(InitContext&) { + std::array procCollisions = {doprocessColl, doprocessCollWithCentFTOC, doprocessCollWithCentFTOM}; + if (std::accumulate(procCollisions.begin(), procCollisions.end(), 0) > 1) { + LOGP(fatal, "At most one process function for collision study can be enabled at a time."); + } + + std::array procCollAccoc = {doprocessCollAssoc, doprocessCollAssocWithCentFTOC, doprocessCollAssocWithCentFTOM}; + if (std::accumulate(procCollAccoc.begin(), procCollAccoc.end(), 0) > 1) { + LOGP(fatal, "At most one process for collision association study function can be enabled at a time."); + } + histOriginTracks[0] = registry.add("TrackToCollChecks/histOriginNonAssociatedTracks", ";origin;#it{p}_{T}^{reco} (GeV/#it{c});#it{#eta}^{reco};#it{Z}_{vtx}^{reco}#minus#it{Z}_{vtx}^{gen} (cm); is PV contributor; has TOF; number of ITS hits", HistType::kTHnSparseF, {axisOrigin, axisPt, axisEta, axisDeltaVtx, axisDecision, axisDecision, axisITShits}); // tracks not associated to any collision histOriginTracks[1] = registry.add("TrackToCollChecks/histOriginAssociatedTracks", ";origin;#it{p}_{T}^{reco} (GeV/#it{c});#it{#eta}^{reco};#it{Z}_{vtx}^{reco}#minus#it{Z}_{vtx}^{gen} (cm); is PV contributor; has TOF; number of ITS hits", HistType::kTHnSparseF, {axisOrigin, axisPt, axisEta, axisDeltaVtx, axisDecision, axisDecision, axisITShits}); // tracks associasted to a collision histOriginTracks[2] = registry.add("TrackToCollChecks/histOriginGoodAssociatedTracks", ";origin;#it{p}_{T}^{reco} (GeV/#it{c});#it{#eta}^{reco};#it{Z}_{vtx}^{reco}#minus#it{Z}_{vtx}^{gen} (cm); is PV contributor; has TOF; number of ITS hits", HistType::kTHnSparseF, {axisOrigin, axisPt, axisEta, axisDeltaVtx, axisDecision, axisDecision, axisITShits}); // tracks associated to the correct collision considering only first reco collision (based on the MC collision index) @@ -499,65 +766,109 @@ struct HfTaskMcValidationRec { histAmbiguousTracks->GetXaxis()->SetBinLabel(3, "charm"); histAmbiguousTracks->GetXaxis()->SetBinLabel(4, "beauty"); for (auto iHad = 0; iHad < nChannels; ++iHad) { - histDeltaPt[iHad] = registry.add(Form("%s/histDeltaPt", particleNames[iHad].data()), Form("Pt difference reco - MC %s; #it{p}_{T}^{reco} - #it{p}_{T}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); - histDeltaPx[iHad] = registry.add(Form("%s/histDeltaPx", particleNames[iHad].data()), Form("Px difference reco - MC %s; #it{p}_{x}^{reco} - #it{p}_{x}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); - histDeltaPy[iHad] = registry.add(Form("%s/histDeltaPy", particleNames[iHad].data()), Form("Py difference reco - MC %s; #it{p}_{y}^{reco} - #it{p}_{y}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); - histDeltaPz[iHad] = registry.add(Form("%s/histDeltaPz", particleNames[iHad].data()), Form("Pz difference reco - MC %s; #it{p}_{z}^{reco} - #it{p}_{z}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); - histDeltaSecondaryVertexX[iHad] = registry.add(Form("%s/histDeltaSecondaryVertexX", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta x (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); - histDeltaSecondaryVertexY[iHad] = registry.add(Form("%s/histDeltaSecondaryVertexY", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta y (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); - histDeltaSecondaryVertexZ[iHad] = registry.add(Form("%s/histDeltaSecondaryVertexZ", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta z (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); - histDeltaDecayLength[iHad] = registry.add(Form("%s/histDeltaDecayLength", particleNames[iHad].data()), Form("Decay length difference reco - MC (%s); #Delta L (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); - for (auto iOrigin = 0; iOrigin < 2; ++iOrigin) { - histPtReco[iHad][iOrigin] = registry.add(Form("%s/histPtReco%s", particleNames[iHad].data(), originNames[iOrigin].data()), Form("Pt reco %s %s; #it{p}_{T}^{reco} (GeV/#it{c}); entries", originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisPtD}); - for (unsigned int iDau = 0; iDau < nDaughters[iHad]; ++iDau) { - histPtDau[iHad][iOrigin][iDau] = registry.add(Form("%s/histPtDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Pt reco - %s %s; #it{p}_{T}^{dau, reco} (GeV/#it{c}); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisPt}); - histEtaDau[iHad][iOrigin][iDau] = registry.add(Form("%s/histEtaDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Eta reco - %s %s; #it{#eta}^{dau, reco}; entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {{100, -1., 1.}}); - histImpactParameterDau[iHad][iOrigin][iDau] = registry.add(Form("%s/histImpactParameterDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d DCAxy reco - %s %s; DCAxy (cm); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + if (iHad < nCharmMesonChannels) { + histDeltaPt[iHad] = registryMesons.add(Form("%s/histDeltaPt", particleNames[iHad].data()), Form("Pt difference reco - MC %s; #it{p}_{T}^{reco} - #it{p}_{T}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPx[iHad] = registryMesons.add(Form("%s/histDeltaPx", particleNames[iHad].data()), Form("Px difference reco - MC %s; #it{p}_{x}^{reco} - #it{p}_{x}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPy[iHad] = registryMesons.add(Form("%s/histDeltaPy", particleNames[iHad].data()), Form("Py difference reco - MC %s; #it{p}_{y}^{reco} - #it{p}_{y}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPz[iHad] = registryMesons.add(Form("%s/histDeltaPz", particleNames[iHad].data()), Form("Pz difference reco - MC %s; #it{p}_{z}^{reco} - #it{p}_{z}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaSecondaryVertexX[iHad] = registryMesons.add(Form("%s/histDeltaSecondaryVertexX", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta x (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaSecondaryVertexY[iHad] = registryMesons.add(Form("%s/histDeltaSecondaryVertexY", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta y (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaSecondaryVertexZ[iHad] = registryMesons.add(Form("%s/histDeltaSecondaryVertexZ", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta z (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaDecayLength[iHad] = registryMesons.add(Form("%s/histDeltaDecayLength", particleNames[iHad].data()), Form("Decay length difference reco - MC (%s); #Delta L (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + for (auto iOrigin = 0; iOrigin < 2; ++iOrigin) { + histPtCentReco[iHad][iOrigin] = registryMesons.add(Form("%s/histPtCentReco%s", particleNames[iHad].data(), originNames[iOrigin].data()), Form("Pt Cent reco %s %s; #it{p}_{T}^{reco} (GeV/#it{c}); Centrality (%%); entries", originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH2F, {axisPtD, axisCent}); + if (storeOccupancy) { + histPtOccReco[iHad][iOrigin] = registryMesons.add(Form("%s/histPtOccReco%s", particleNames[iHad].data(), originNames[iOrigin].data()), Form("Pt Cent reco %s %s; #it{p}_{T}^{reco} (GeV/#it{c}); Occupancy; entries", originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH2F, {axisPtD, axisOcc}); + } + for (unsigned int iDau = 0; iDau < nDaughters[iHad]; ++iDau) { + histPtDau[iHad][iOrigin][iDau] = registryMesons.add(Form("%s/histPtDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Pt reco - %s %s; #it{p}_{T}^{dau, reco} (GeV/#it{c}); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisPt}); + histEtaDau[iHad][iOrigin][iDau] = registryMesons.add(Form("%s/histEtaDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Eta reco - %s %s; #it{#eta}^{dau, reco}; entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {{100, -1., 1.}}); + histImpactParameterDau[iHad][iOrigin][iDau] = registryMesons.add(Form("%s/histImpactParameterDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d DCAxy reco - %s %s; DCAxy (cm); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + } + } + } else if (iHad >= nCharmMesonChannels + nBeautyChannels) { + histDeltaPt[iHad] = registryBaryons.add(Form("%s/histDeltaPt", particleNames[iHad].data()), Form("Pt difference reco - MC %s; #it{p}_{T}^{reco} - #it{p}_{T}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPx[iHad] = registryBaryons.add(Form("%s/histDeltaPx", particleNames[iHad].data()), Form("Px difference reco - MC %s; #it{p}_{x}^{reco} - #it{p}_{x}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPy[iHad] = registryBaryons.add(Form("%s/histDeltaPy", particleNames[iHad].data()), Form("Py difference reco - MC %s; #it{p}_{y}^{reco} - #it{p}_{y}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaPz[iHad] = registryBaryons.add(Form("%s/histDeltaPz", particleNames[iHad].data()), Form("Pz difference reco - MC %s; #it{p}_{z}^{reco} - #it{p}_{z}^{gen} (GeV/#it{c}); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaMom}); + histDeltaSecondaryVertexX[iHad] = registryBaryons.add(Form("%s/histDeltaSecondaryVertexX", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta x (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaSecondaryVertexY[iHad] = registryBaryons.add(Form("%s/histDeltaSecondaryVertexY", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta y (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaSecondaryVertexZ[iHad] = registryBaryons.add(Form("%s/histDeltaSecondaryVertexZ", particleNames[iHad].data()), Form("Sec. Vertex difference reco - MC (MC matched) - %s; #Delta z (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + histDeltaDecayLength[iHad] = registryBaryons.add(Form("%s/histDeltaDecayLength", particleNames[iHad].data()), Form("Decay length difference reco - MC (%s); #Delta L (cm); entries", labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + for (auto iOrigin = 0; iOrigin < 2; ++iOrigin) { + histPtCentReco[iHad][iOrigin] = registryBaryons.add(Form("%s/histPtCentReco%s", particleNames[iHad].data(), originNames[iOrigin].data()), Form("Pt Cent reco %s %s; #it{p}_{T}^{reco} (GeV/#it{c}); Centrality (%%); entries", originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH2F, {axisPtD, axisCent}); + if (storeOccupancy) { + histPtOccReco[iHad][iOrigin] = registryBaryons.add(Form("%s/histPtOccReco%s", particleNames[iHad].data(), originNames[iOrigin].data()), Form("Pt Cent reco %s %s; #it{p}_{T}^{reco} (GeV/#it{c}); Occupancy; entries", originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH2F, {axisPtD, axisOcc}); + } + for (unsigned int iDau = 0; iDau < nDaughters[iHad]; ++iDau) { + histPtDau[iHad][iOrigin][iDau] = registryBaryons.add(Form("%s/histPtDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Pt reco - %s %s; #it{p}_{T}^{dau, reco} (GeV/#it{c}); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisPt}); + histEtaDau[iHad][iOrigin][iDau] = registryBaryons.add(Form("%s/histEtaDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d Eta reco - %s %s; #it{#eta}^{dau, reco}; entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {{100, -1., 1.}}); + histImpactParameterDau[iHad][iOrigin][iDau] = registryBaryons.add(Form("%s/histImpactParameterDau%d%s", particleNames[iHad].data(), iDau, originNames[iOrigin].data()), Form("Daughter %d DCAxy reco - %s %s; DCAxy (cm); entries", iDau, originNames[iOrigin].data(), labels[iHad].data()), HistType::kTH1F, {axisDeltaVtx}); + } } } } histContributors = registry.add("TrackToCollChecks/histContributors", "PV contributors from correct/wrong MC collision;;entries", HistType::kTH1F, {axisDecision}); histContributors->GetXaxis()->SetBinLabel(1, "correct MC collision"); histContributors->GetXaxis()->SetBinLabel(2, "wrong MC collision"); + hfEvSel.addHistograms(registry); // collision monitoring + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); } - void process(CollisionsWithMCLabels::iterator const& collision, - aod::McCollisions const&) + template + void checkCollisions(Coll const& collision, + aod::McCollisions const&, + aod::BCsWithTimestamps const&) { - // check that collision is selected by hf-track-index-skim-creator-tag-sel-collisions - if (collision.whyRejectColl() != 0) { + // apply event selection + if (!collision.has_mcCollision()) { return; } - if (!collision.has_mcCollision()) { + + 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 return; } - auto mcCollision = collision.mcCollision_as(); + + auto mcCollision = collision.template mcCollision_as(); if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { return; } + registry.fill(HIST("hNevReco"), 1); registry.fill(HIST("histXvtxReco"), collision.posX()); registry.fill(HIST("histYvtxReco"), collision.posY()); registry.fill(HIST("histZvtxReco"), collision.posZ()); registry.fill(HIST("histDeltaZvtx"), collision.numContrib(), collision.posZ() - mcCollision.posZ()); - } // end process + } - void processCollAssoc(CollisionsWithMCLabels const& collisions, - TracksWithSel const&, - aod::McParticles const& mcParticles, - aod::McCollisions const&, - aod::BCs const&) + template + void checkCollisionAssociation(Colls const& collisions, + TracksWithSel const&, + aod::McParticles const& mcParticles, + aod::McCollisions const&, + aod::BCsWithTimestamps const&) { // loop over collisions - for (auto collision = collisions.begin(); collision != collisions.end(); ++collision) { + for (const auto& collision : collisions) { // check that collision is selected by hf-track-index-skim-creator-tag-sel-collisions - if (collision.whyRejectColl() != 0) { + + 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; } + if (!collision.has_mcCollision()) { continue; } - auto mcCollision = collision.mcCollision_as(); + auto mcCollision = collision.template mcCollision_as(); if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { continue; } @@ -678,118 +989,201 @@ struct HfTaskMcValidationRec { } } } + + void processColl(CollisionsWithMCLabels::iterator const& collision, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisions(collision, mcCollisions, bcs); + } // end process + PROCESS_SWITCH(HfTaskMcValidationRec, processColl, "Process collision information without centrality selection", true); + + void processCollWithCentFTOC(CollisionsWithMCLabelsAndCentFT0C::iterator const& collision, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisions(collision, mcCollisions, bcs); + } // end process + PROCESS_SWITCH(HfTaskMcValidationRec, processCollWithCentFTOC, "Process collision information with centrality selection with FT0C", false); + + void processCollWithCentFTOM(CollisionsWithMCLabelsAndCentFT0M::iterator const& collision, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisions(collision, mcCollisions, bcs); + } // end process + PROCESS_SWITCH(HfTaskMcValidationRec, processCollWithCentFTOM, "Process collision information with centrality selection with FT0M", false); + + void processCollAssoc(CollisionsWithMCLabels const& collisions, + TracksWithSel const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisionAssociation(collisions, tracks, mcParticles, mcCollisions, bcs); + } PROCESS_SWITCH(HfTaskMcValidationRec, processCollAssoc, "Process collision-association information, requires extra table from TrackToCollisionAssociation task (fillTableOfCollIdsPerTrack=true)", false); + void processCollAssocWithCentFTOC(CollisionsWithMCLabelsAndCentFT0C const& collisions, + TracksWithSel const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisionAssociation(collisions, tracks, mcParticles, mcCollisions, bcs); + } + PROCESS_SWITCH(HfTaskMcValidationRec, processCollAssocWithCentFTOC, "Process collision-association information with centrality selection with FT0C, requires extra table from TrackToCollisionAssociation task (fillTableOfCollIdsPerTrack=true)", false); + + void processCollAssocWithCentFTOM(CollisionsWithMCLabelsAndCentFT0M const& collisions, + TracksWithSel const& tracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs) + { + checkCollisionAssociation(collisions, tracks, mcParticles, mcCollisions, bcs); + } + PROCESS_SWITCH(HfTaskMcValidationRec, processCollAssocWithCentFTOM, "Process collision-association information with centrality selection with FT0M, requires extra table from TrackToCollisionAssociation task (fillTableOfCollIdsPerTrack=true)", false); + + template void processEff(HfCand2ProngWithMCRec const& cand2Prongs, HfCand3ProngWithMCRec const& cand3Prongs, aod::TracksWMc const&, aod::McParticles const& mcParticles, aod::McCollisions const&, - CollisionsWithMCLabels const& /*collisions*/) + aod::BCsWithTimestamps const&, + Coll const& collisions, + Preslice cand2ProngsPerCollision, + Preslice cand3ProngsPerCollision) { - // loop over 2-prong candidates - for (const auto& cand2Prong : cand2Prongs) { - - if (cand2Prong.collision_as().has_mcCollision()) { - auto mcCollision = cand2Prong.collision_as().mcCollision_as(); - if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { - continue; - } - } - - // determine which kind of candidate it is - bool isD0Sel = TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_2prong::DecayType::D0ToPiK); - if (!isD0Sel) { - continue; - } - int whichHad = -1; - if (isD0Sel && TESTBIT(std::abs(cand2Prong.flagMcMatchRec()), hf_cand_2prong::DecayType::D0ToPiK)) { - whichHad = DzeroToKPi; + // loop over collisions + for (const auto& collision : collisions) { + // apply event selection + float centrality{105.f}; + int occupancy = collision.trackOccupancyInTimeRange(); + hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); // only needed to update centrality, no bitmask selection applied + if (!collision.has_mcCollision()) { + return; } - int whichOrigin; - if (cand2Prong.originMcRec() == RecoDecay::OriginType::Prompt) { - whichOrigin = 0; - } else { - whichOrigin = 1; + auto mcCollision = collision.template mcCollision_as(); + if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { + return; } - if (whichHad >= 0) { - int indexParticle = -1; - if (cand2Prong.prong0_as().has_mcParticle()) { - indexParticle = RecoDecay::getMother(mcParticles, cand2Prong.prong0_as().mcParticle(), PDGArrayParticle[whichHad], true); - } - if (indexParticle < 0) { - continue; - } - auto mother = mcParticles.rawIteratorAt(indexParticle); - fillHisto(cand2Prong, mother, whichHad, whichOrigin); - } - } // end loop on 2-prong candidates + // group 2- and 3-prongs for collision + auto thisCollId = collision.globalIndex(); + auto grouped2ProngCandidates = cand2Prongs.sliceBy(cand2ProngsPerCollision, thisCollId); + auto grouped3ProngCandidates = cand3Prongs.sliceBy(cand3ProngsPerCollision, thisCollId); - // loop over 3-prong candidates - for (const auto& cand3Prong : cand3Prongs) { + // loop over 2-prong candidates + for (const auto& cand2Prong : grouped2ProngCandidates) { - if (cand3Prong.collision_as().has_mcCollision()) { - auto mcCollision = cand3Prong.collision_as().mcCollision_as(); - if (eventGeneratorType >= 0 && mcCollision.getSubGeneratorId() != eventGeneratorType) { + // determine which kind of candidate it is + bool isD0Sel = TESTBIT(cand2Prong.hfflag(), o2::aod::hf_cand_2prong::DecayType::D0ToPiK); + if (!isD0Sel) { continue; } - } - - // determine which kind of candidate it is - // FIXME: add D* and decays with cascades - bool isDPlusSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::DplusToPiKPi); - bool isDsSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::DsToKKPi); - bool isLcSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::LcToPKPi); - bool isXicSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::XicToPKPi); - if (!isDPlusSel && !isDsSel && !isLcSel && !isXicSel) { - continue; - } - int whichHad = -1; - if (isDPlusSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DplusToPiKPi)) { - whichHad = DplusToPiKPi; - } else if (isDsSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DsToKKPi)) { - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToPhiPi) { - whichHad = DsToPhiPiToKKPi; + int whichHad = -1; + if (isD0Sel && TESTBIT(std::abs(cand2Prong.flagMcMatchRec()), hf_cand_2prong::DecayType::D0ToPiK)) { + whichHad = DzeroToKPi; } - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToK0starK) { - whichHad = DsToK0starKToKKPi; - } - if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DplusToPhiPi) { - whichHad = DplusToPhiPiToKKPi; + int whichOrigin; + if (cand2Prong.originMcRec() == RecoDecay::OriginType::Prompt) { + whichOrigin = 0; + } else { + whichOrigin = 1; } - } else if (isLcSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::LcToPKPi)) { - whichHad = LcToPKPi; - } else if (isXicSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::XicToPKPi)) { - whichHad = XiCplusToPKPi; - } - int whichOrigin; - if (cand3Prong.originMcRec() == RecoDecay::OriginType::Prompt) { - whichOrigin = 0; - } else { - whichOrigin = 1; - } - if (whichHad >= 0) { - int indexParticle = -1; - if (cand3Prong.prong0_as().has_mcParticle()) { - indexParticle = RecoDecay::getMother(mcParticles, cand3Prong.prong0_as().mcParticle(), PDGArrayParticle[whichHad], true); + if (whichHad >= 0) { + int indexParticle = -1; + indexParticle = RecoDecay::getMother(mcParticles, cand2Prong.template prong0_as().template mcParticle_as(), PDGArrayParticle[whichHad], true); + if (indexParticle < 0) { + continue; + } + auto mother = mcParticles.rawIteratorAt(indexParticle); + fillHisto(cand2Prong, mother, whichHad, whichOrigin, centrality, occupancy); } - if (indexParticle < 0) { + } // end loop on 2-prong candidates + + // loop over 3-prong candidates + for (const auto& cand3Prong : grouped3ProngCandidates) { + + // determine which kind of candidate it is + // FIXME: add D* and decays with cascades + bool isDPlusSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::DplusToPiKPi); + bool isDsSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::DsToKKPi); + bool isLcSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::LcToPKPi); + bool isXicSel = TESTBIT(cand3Prong.hfflag(), hf_cand_3prong::DecayType::XicToPKPi); + if (!isDPlusSel && !isDsSel && !isLcSel && !isXicSel) { continue; } - auto mother = mcParticles.rawIteratorAt(indexParticle); - fillHisto(cand3Prong, mother, whichHad, whichOrigin); - std::array momDau2 = {cand3Prong.pxProng2(), - cand3Prong.pyProng2(), - cand3Prong.pzProng2()}; - histPtDau[whichHad][whichOrigin][2]->Fill(RecoDecay::pt(momDau2)); - histEtaDau[whichHad][whichOrigin][2]->Fill(RecoDecay::eta(momDau2)); - histImpactParameterDau[whichHad][whichOrigin][2]->Fill(cand3Prong.impactParameter2()); - } - } // end loop on 3-prong candidates + int whichHad = -1; + if (isDPlusSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DplusToPiKPi)) { + whichHad = DplusToPiKPi; + } else if (isDsSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::DsToKKPi)) { + if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToPhiPi) { + whichHad = DsToPhiPiToKKPi; + } + if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DsToK0starK) { + whichHad = DsToK0starKToKKPi; + } + if (cand3Prong.flagMcDecayChanRec() == hf_cand_3prong::DecayChannelDToKKPi::DplusToPhiPi) { + whichHad = DplusToPhiPiToKKPi; + } + } else if (isLcSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::LcToPKPi)) { + whichHad = LcToPKPi; + } else if (isXicSel && TESTBIT(std::abs(cand3Prong.flagMcMatchRec()), hf_cand_3prong::DecayType::XicToPKPi)) { + whichHad = XiCplusToPKPi; + } + int whichOrigin; + if (cand3Prong.originMcRec() == RecoDecay::OriginType::Prompt) { + whichOrigin = 0; + } else { + whichOrigin = 1; + } + + if (whichHad >= 0) { + int indexParticle = -1; + if (cand3Prong.template prong0_as().has_mcParticle()) { + indexParticle = RecoDecay::getMother(mcParticles, cand3Prong.template prong0_as().template mcParticle_as(), PDGArrayParticle[whichHad], true); + } + if (indexParticle < 0) { + continue; + } + auto mother = mcParticles.rawIteratorAt(indexParticle); + fillHisto(cand3Prong, mother, whichHad, whichOrigin, centrality, occupancy); + std::array momDau2 = {cand3Prong.pxProng2(), + cand3Prong.pyProng2(), + cand3Prong.pzProng2()}; + histPtDau[whichHad][whichOrigin][2]->Fill(RecoDecay::pt(momDau2)); + histEtaDau[whichHad][whichOrigin][2]->Fill(RecoDecay::eta(momDau2)); + histImpactParameterDau[whichHad][whichOrigin][2]->Fill(cand3Prong.impactParameter2()); + } + } // end loop on 3-prong candidates + } // end loop on collisions + } + void processEffNoCent(HfCand2ProngWithMCRec const& cand2Prongs, + HfCand3ProngWithMCRec const& cand3Prongs, + aod::TracksWMc const& mcTracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs, + CollisionsWithMCLabels const& collsWithLabels) + { + processEff(cand2Prongs, cand3Prongs, mcTracks, mcParticles, mcCollisions, bcs, collsWithLabels, cand2ProngPerCollision, cand3ProngPerCollision); + } + PROCESS_SWITCH(HfTaskMcValidationRec, processEffNoCent, "Compute charm-hadron efficiencies (not all of them are implemented), requires HF candidate creators w/o information on centrality", false); + + void processEffCentFT0C(HfCand2ProngWithMCRec const& cand2Prongs, + HfCand3ProngWithMCRec const& cand3Prongs, + aod::TracksWMc const& mcTracks, + aod::McParticles const& mcParticles, + aod::McCollisions const& mcCollisions, + aod::BCsWithTimestamps const& bcs, + CollisionsWithMCLabelsAndCentFT0C const& collsWithLabels) + { + processEff(cand2Prongs, cand3Prongs, mcTracks, mcParticles, mcCollisions, bcs, collsWithLabels, cand2ProngPerCollision, cand3ProngPerCollision); } - PROCESS_SWITCH(HfTaskMcValidationRec, processEff, "Compute charm-hadron efficiencies (not all of them are implemented), requires HF candidate creators", false); + PROCESS_SWITCH(HfTaskMcValidationRec, processEffCentFT0C, "Compute charm-hadron efficiencies (not all of them are implemented), requires HF candidate creators with information on centrality from FT0C", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGHF/Utils/utilsAnalysis.h b/PWGHF/Utils/utilsAnalysis.h index 0b4233bff15..b10a851072d 100644 --- a/PWGHF/Utils/utilsAnalysis.h +++ b/PWGHF/Utils/utilsAnalysis.h @@ -17,6 +17,7 @@ #include // std::upper_bound #include // std::distance +#include //std::string namespace o2::analysis { @@ -24,7 +25,7 @@ namespace o2::analysis /// \param bins array of pT bins /// \param value pT /// \return index of the pT bin -/// \note Accounts for the offset so that pt bin array can be used to also configure a histogram axis. +/// \note Accounts for the offset so that pT bin array can be used to also configure a histogram axis. template int findBin(T1 const& binsPt, T2 value) { @@ -108,6 +109,48 @@ bool isSelectedTrackTpcQuality(T const& track, const int tpcNClustersFoundMin, c return true; } +/// Mass selection of 2 or 3 prong canidates in triggered data analysis +/// \tparam nProngs switch between 2-prong and 3-prong selection +/// \param invMass is the invariant mass of the candidate +/// \param pdgMass is the pdg Mass of the candidate particle +/// \param pt is the pT of the candidate +/// \param cutConfig is the struct with the pt-dependent mass configurations +/// \return true if candidate passes selection +template +bool isCandidateInMassRange(const float& invMass, const double& pdgMass, const float& pt, Config const& cutConfig) +{ + float peakMean = (pt < cutConfig.ptDeltaMassMax.value) ? ((pdgMass + cutConfig.deltaMassPars->get("constant")) + cutConfig.deltaMassPars->get("linear") * pt) : pdgMass; + float peakWidth = cutConfig.sigmaPars->get("constant") + cutConfig.sigmaPars->get("linear") * pt; + + return (!(std::abs(invMass - peakMean) > cutConfig.nSigmaMax.value * peakWidth && pt < cutConfig.ptMassCutMax.value)); +} + +/// Configurable group to apply trigger specific cuts for 2-prong HF analysis +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}}; + 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"}; +}; + +/// 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}}; + 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"}; +}; + } // namespace o2::analysis #endif // PWGHF_UTILS_UTILSANALYSIS_H_ diff --git a/PWGHF/Utils/utilsDerivedData.h b/PWGHF/Utils/utilsDerivedData.h new file mode 100644 index 00000000000..ad3bf57e25e --- /dev/null +++ b/PWGHF/Utils/utilsDerivedData.h @@ -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. + +/// \file utilsDerivedData.h +/// \brief Utilities for derived-data creators +/// \author Vít Kučera , Inha University + +#ifndef PWGHF_UTILS_UTILSDERIVEDDATA_H_ +#define PWGHF_UTILS_UTILSDERIVEDDATA_H_ + +#include + +// Macro to store nSigma for prong _id_ with PID hypothesis _hyp_ in an array +#define GET_N_SIGMA_PRONG(_array_, _candidate_, _id_, _hyp_) \ + _array_[0] = _candidate_.nSigTpc##_hyp_##_id_(); \ + _array_[1] = _candidate_.nSigTof##_hyp_##_id_(); \ + _array_[2] = _candidate_.tpcTofNSigma##_hyp_##_id_(); + +namespace o2::analysis::hf_derived +{ +/// Reserve space in the filled table for all entries in the source table. +/// \param cursor cursor of the filled table +/// \param enabled switch for filling the table +/// \param size size of the source table +template +void reserveTable(T& cursor, const o2::framework::Configurable& enabled, const uint64_t size) +{ + if (enabled.value) { + cursor.reserve(size); + } +}; +} // namespace o2::analysis::hf_derived + +#endif // PWGHF_UTILS_UTILSDERIVEDDATA_H_ diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index 1b5b0531a25..71f0bd0559d 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -24,8 +24,11 @@ #include "Framework/Configurable.h" #include "Framework/HistogramRegistry.h" #include "Framework/HistogramSpec.h" +#include "Framework/OutputObjHeader.h" +#include "Common/CCDB/EventSelectionParams.h" #include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "PWGHF/Core/CentralityEstimation.h" namespace o2::hf_evsel @@ -33,6 +36,7 @@ namespace o2::hf_evsel // event rejection types enum EventRejection { None = 0, + SoftwareTrigger, Centrality, Trigger, TvxTrigger, @@ -44,7 +48,9 @@ enum EventRejection { NContrib, Chi2, PositionZ, - SoftwareTrigger, + NoCollInTimeRangeNarrow, + NoCollInTimeRangeStandard, + NoCollInRofStandard, NEventRejection }; @@ -52,11 +58,13 @@ o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +E /// \brief Function to put labels on monitoring histogram /// \param hRejection monitoring histogram +/// \param softwareTriggerLabel bin label for software trigger rejection template 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::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"); @@ -68,7 +76,9 @@ void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel hRejection->GetXaxis()->SetBinLabel(EventRejection::NContrib + 1, "# of PV contributors"); hRejection->GetXaxis()->SetBinLabel(EventRejection::Chi2 + 1, "PV #it{#chi}^{2}"); hRejection->GetXaxis()->SetBinLabel(EventRejection::PositionZ + 1, "PV #it{z}"); - hRejection->GetXaxis()->SetBinLabel(EventRejection::SoftwareTrigger + 1, softwareTriggerLabel.data()); + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeNarrow + 1, "No coll timerange narrow"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeStandard + 1, "No coll timerange strict"); + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInRofStandard + 1, "No coll in ROF std"); } struct HfEventSelection : o2::framework::ConfigurableGroup { @@ -84,26 +94,34 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { o2::framework::Configurable useIsGoodZvtxFT0vsPV{"useIsGoodZvtxFT0vsPV", false, "Check consistency between PVz from central barrel with that from FT0 timing"}; o2::framework::Configurable useNoSameBunchPileup{"useNoSameBunchPileup", false, "Exclude collisions in bunches with more than 1 reco. PV"}; // POTENTIALLY BAD FOR BEAUTY ANALYSES o2::framework::Configurable useNumTracksInTimeRange{"useNumTracksInTimeRange", false, "Apply occupancy selection (num. ITS tracks with at least 5 clusters in +-100us from current collision)"}; + o2::framework::Configurable useFT0cOccEstimator{"useFT0cOccEstimator", false, "Adopt FT0c amplitudes as occupancy estimator instead of ITS tracks"}; o2::framework::Configurable numTracksInTimeRangeMin{"numTracksInTimeRangeMin", 0, "Minimum occupancy"}; o2::framework::Configurable numTracksInTimeRangeMax{"numTracksInTimeRangeMax", 1000000, "Maximum occupancy"}; o2::framework::Configurable nPvContributorsMin{"nPvContributorsMin", 0, "Minimum number of PV contributors"}; o2::framework::Configurable chi2PvMax{"chi2PvMax", -1.f, "Maximum PV chi2"}; o2::framework::Configurable zPvPosMin{"zPvPosMin", -10.f, "Minimum PV posZ (cm)"}; o2::framework::Configurable zPvPosMax{"zPvPosMax", 10.f, "Maximum PV posZ (cm)"}; - o2::framework::Configurable softwareTrigger{"softwareTrigger", "", "Label of software trigger. Multiple triggers can be selected dividing them by a comma"}; + o2::framework::Configurable useNoCollInTimeRangeNarrow{"useNoCollInTimeRangeNarrow", false, "Reject collisions in time range narrow"}; + o2::framework::Configurable useNoCollInTimeRangeStandard{"useNoCollInTimeRangeStandard", false, "Reject collisions in time range strict"}; + o2::framework::Configurable useNoCollInRofStandard{"useNoCollInRofStandard", false, "Reject collisions in ROF standard"}; + o2::framework::Configurable softwareTrigger{"softwareTrigger", "", "Label of software trigger. Multiple triggers can be selected dividing them by a comma. Set None if you want bcs that are not selected by any trigger"}; + o2::framework::Configurable bcMarginForSoftwareTrigger{"bcMarginForSoftwareTrigger", 100, "Number of BCs of margin for software triggers"}; + o2::framework::Configurable ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "Users/m/mpuccio/EventFiltering/OTS/", "ccdb path for ZORRO objects"}; // 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"; - std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + std::shared_ptr hCollisions, hSelCollisionsCent, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; // util to retrieve trigger mask in case of software triggers Zorro zorro; + o2::framework::OutputObj zorroSummary{"zorroSummary"}; int currentRun{-1}; /// \brief Adds collision monitoring histograms in the histogram registry. @@ -111,12 +129,18 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { 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}}}); - setEventRejectionLabels(hCollisions); + setEventRejectionLabels(hCollisions, softwareTrigger); + + // we initialise the summary object + if (softwareTrigger.value != "") { + zorroSummary.setObject(zorro.getZorroSummary()); + } } /// \brief Applies event selection. @@ -125,9 +149,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \param collision collision to test against the selection criteria /// \param centrality collision centrality variable to be set in this function /// \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) + uint16_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 @@ -174,9 +199,27 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { if (useNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { SETBIT(rejectionMask, EventRejection::NoSameBunchPileup); } - /// occupancy estimator (ITS tracks with at least 5 clusters in +-10us from current collision) + /// No collisions in time range narrow + if (useNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeNarrow); + } + /// No collisions in time range strict + if (useNoCollInTimeRangeStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeStandard); + } + /// No collisions in ROF standard + if (useNoCollInRofStandard && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + SETBIT(rejectionMask, EventRejection::NoCollInRofStandard); + } if (useNumTracksInTimeRange) { - const int numTracksInTimeRange = collision.trackOccupancyInTimeRange(); + float numTracksInTimeRange; + if (useFT0cOccEstimator) { + /// occupancy estimator (FT0c signal amplitudes in +-10us from current collision) + numTracksInTimeRange = collision.ft0cOccupancyInTimeRange(); + } else { + /// occupancy estimator (ITS tracks with at least 5 clusters in +-10us from current collision) + numTracksInTimeRange = static_cast(collision.trackOccupancyInTimeRange()); + } if (numTracksInTimeRange < numTracksInTimeRangeMin || numTracksInTimeRange > numTracksInTimeRangeMax) { SETBIT(rejectionMask, EventRejection::NumTracksInTimeRange); } @@ -204,12 +247,21 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { int runNumber = bc.runNumber(); if (runNumber != currentRun) { // We might need to update Zorro from CCDB if the run number changes + zorro.setCCDBpath(ccdbPathSoftwareTrigger); + zorro.setBCtolerance(bcMarginForSoftwareTrigger); zorro.initCCDB(ccdb.service, runNumber, bc.timestamp(), softwareTrigger.value); currentRun = runNumber; } + zorro.populateHistRegistry(registry, runNumber); - if (!zorro.isSelected(bc.globalBC())) { /// Just let Zorro do the accounting - SETBIT(rejectionMask, EventRejection::SoftwareTrigger); + if (softwareTrigger.value != "None") { + if (!zorro.isSelected(bc.globalBC(), bcMarginForSoftwareTrigger)) { /// Just let Zorro do the accounting + SETBIT(rejectionMask, EventRejection::SoftwareTrigger); + } + } else { + if (!zorro.isNotSelectedByAny(bc.globalBC(), bcMarginForSoftwareTrigger)) { /// Just let Zorro do the accounting of not selected BCs + SETBIT(rejectionMask, EventRejection::SoftwareTrigger); + } } } @@ -220,7 +272,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \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) + void fillHistograms(Coll const& collision, const uint16_t rejectionMask, float& centrality) { hCollisions->Fill(EventRejection::None); const float posZ = collision.posZ(); @@ -237,6 +289,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { hPosYAfterEvSel->Fill(collision.posY()); hPosZAfterEvSel->Fill(posZ); hNumPvContributorsAfterSel->Fill(collision.numContrib()); + hSelCollisionsCent->Fill(centrality); } }; @@ -248,6 +301,8 @@ struct HfEventSelectionMc { 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 // histogram names static constexpr char nameHistParticles[] = "hParticles"; @@ -277,20 +332,53 @@ struct HfEventSelectionMc { zPvPosMin = option.defaultValue.get(); } else if (option.name.compare("hfEvSel.zPvPosMax") == 0) { zPvPosMax = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.centralityMin") == 0) { + centralityMin = option.defaultValue.get(); + } else if (option.name.compare("hfEvSel.centralityMax") == 0) { + centralityMax = option.defaultValue.get(); } } } /// \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) + template + uint16_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision, CCs const& collSlice, float& centrality) { uint16_t rejectionMask{0}; float zPv = mcCollision.posZ(); auto bc = mcCollision.template bc_as(); + if constexpr (centEstimator != o2::hf_centrality::CentralityEstimator::None) { + float multiplicity{0.f}; + for (const auto& collision : collSlice) { + float collCent{0.f}; + float collMult{0.f}; + if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0A) { + collCent = collision.centFT0A(); + } else if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0C) { + collCent = collision.centFT0C(); + } else if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0M) { + collCent = collision.centFT0M(); + } else if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FV0A) { + collCent = collision.centFV0A(); + } else { + LOGP(fatal, "Unsupported centrality estimator!"); + } + collMult = collision.numContrib(); + if (collMult > multiplicity) { + centrality = collCent; + multiplicity = collMult; + } + } + /// centrality selection + if (centrality < centralityMin || centrality > centralityMax) { + SETBIT(rejectionMask, EventRejection::Centrality); + } + } /// 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); diff --git a/PWGHF/Utils/utilsPid.h b/PWGHF/Utils/utilsPid.h new file mode 100644 index 00000000000..19325426cd6 --- /dev/null +++ b/PWGHF/Utils/utilsPid.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 utilsPid.h +/// \brief PID utilities for HF analyses +/// +/// \author Mattia Faggin , CERN + +#ifndef PWGHF_UTILS_UTILSPID_H_ +#define PWGHF_UTILS_UTILSPID_H_ + +namespace o2::aod::pid_tpc_tof_utils +{ +enum HfProngSpecies : uint8_t { Pion = 0, + Kaon, + Proton }; + +/// Function to combine TPC and TOF NSigma +/// \param tiny switch between full and tiny (binned) PID tables +/// \param tpcNSigma is the (binned) NSigma separation in TPC (if tiny = true) +/// \param tofNSigma is the (binned) NSigma separation in TOF (if tiny = true) +/// \return combined NSigma of TPC and TOF +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 + + 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 + return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma)); + } + if (tpcNSigma > defaultNSigma) { // only TPC + return std::abs(tpcNSigma); + } + if (tofNSigma > defaultNSigma) { // only TOF + return std::abs(tofNSigma); + } + return tofNSigma; // no TPC nor TOF +} + +/// @brief Function to fill tables with HF prong PID information +/// @tparam TRK datatype of the prong track +/// @tparam ROW datatype of the prong PID table to fill +/// @tparam specPid particle species +/// @param track prong track +/// @param rowPid cursor of the prong PID table to fill +template +void fillProngPid(TRK const& track, ROW& rowPid) +{ + + // get PID information for the daughter tracks + // TODO: add here the code for a possible PID post-calibrations in MC + float nSigTpc = -999.f; + float nSigTof = -999.f; + if constexpr (specPid == HfProngSpecies::Pion) { + // pion PID + if (track.hasTPC()) { + nSigTpc = track.tpcNSigmaPi(); + } + if (track.hasTOF()) { + nSigTof = track.tofNSigmaPi(); + } + } else if constexpr (specPid == HfProngSpecies::Kaon) { + // kaon PID + if (track.hasTPC()) { + nSigTpc = track.tpcNSigmaKa(); + } + if (track.hasTOF()) { + nSigTof = track.tofNSigmaKa(); + } + } else if constexpr (specPid == HfProngSpecies::Proton) { + // proton PID + if (track.hasTPC()) { + nSigTpc = track.tpcNSigmaPr(); + } + if (track.hasTOF()) { + nSigTof = track.tofNSigmaPr(); + } + } else { + LOG(fatal) << "Unsupported PID. Supported species in HF framework: HfProngSpecies::Pion, HfProngSpecies::Kaon, HfProngSpecies::Proton"; + } + + // fill candidate prong PID rows + rowPid(nSigTpc, nSigTof); +} +} // namespace o2::aod::pid_tpc_tof_utils + +#endif // PWGHF_UTILS_UTILSPID_H_ diff --git a/PWGJE/Core/JetCandidateUtilities.h b/PWGJE/Core/JetCandidateUtilities.h index 43e66f82d66..37e5e53d96b 100644 --- a/PWGJE/Core/JetCandidateUtilities.h +++ b/PWGJE/Core/JetCandidateUtilities.h @@ -38,7 +38,6 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/DerivedTables.h" -#include "PWGHF/DataModel/DerivedTablesStored.h" #include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" diff --git a/PWGJE/Core/JetDQUtilities.h b/PWGJE/Core/JetDQUtilities.h index fdd5ca9cbcd..e68a23494f6 100644 --- a/PWGJE/Core/JetDQUtilities.h +++ b/PWGJE/Core/JetDQUtilities.h @@ -52,7 +52,7 @@ namespace jetdqutilities template constexpr bool isDielectronCandidate() { - return std::is_same_v, CandidatesDielectronData::iterator> || std::is_same_v, CandidatesDielectronData::filtered_iterator> || std::is_same_v, CandidatesDielectronMCD::iterator> || std::is_same_v, CandidatesDielectronMCD::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesDielectronData::iterator> || std::is_same_v, o2::aod::CandidatesDielectronData::filtered_iterator> || std::is_same_v, o2::aod::CandidatesDielectronMCD::iterator> || std::is_same_v, o2::aod::CandidatesDielectronMCD::filtered_iterator>; } /** @@ -61,7 +61,7 @@ constexpr bool isDielectronCandidate() template constexpr bool isDielectronMcCandidate() { - return std::is_same_v, CandidatesDielectronMCP::iterator> || std::is_same_v, CandidatesDielectronMCP::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesDielectronMCP::iterator> || std::is_same_v, o2::aod::CandidatesDielectronMCP::filtered_iterator>; } /** diff --git a/PWGJE/Core/JetDerivedDataUtilities.h b/PWGJE/Core/JetDerivedDataUtilities.h index 389f2732b07..435a362e0db 100644 --- a/PWGJE/Core/JetDerivedDataUtilities.h +++ b/PWGJE/Core/JetDerivedDataUtilities.h @@ -17,6 +17,7 @@ #ifndef PWGJE_CORE_JETDERIVEDDATAUTILITIES_H_ #define PWGJE_CORE_JETDERIVEDDATAUTILITIES_H_ +#include #include #include "Common/CCDB/TriggerAliases.h" #include "Common/CCDB/EventSelectionParams.h" @@ -29,10 +30,14 @@ static constexpr float mPion = 0.139; // TDatabasePDG::Instance()->GetParticle(2 enum JCollisionSel { sel8 = 0, sel8Full = 1, - sel7 = 2, + sel8FullPbPb = 2, selMC = 3, - selUnanchoredMC = 4, - sel7KINT7 = 5 + selMCFull = 4, + selMCFullPbPb = 5, + selUnanchoredMC = 6, + selTVX = 7, + sel7 = 8, + sel7KINT7 = 9 }; template @@ -52,15 +57,27 @@ int initialiseEventSelection(std::string eventSelection) if (eventSelection == "sel8Full") { return JCollisionSel::sel8Full; } - if (eventSelection == "sel7") { - return JCollisionSel::sel7; + if (eventSelection == "sel8FullPbPb") { + return JCollisionSel::sel8FullPbPb; } if (eventSelection == "selMC") { return JCollisionSel::selMC; } + if (eventSelection == "selMCFull") { + return JCollisionSel::selMCFull; + } + if (eventSelection == "selMCFullPbPb") { + return JCollisionSel::selMCFullPbPb; + } if (eventSelection == "selUnanchoredMC") { return JCollisionSel::selUnanchoredMC; } + if (eventSelection == "selTVX") { + return JCollisionSel::selTVX; + } + if (eventSelection == "sel7") { + return JCollisionSel::sel7; + } if (eventSelection == "sel7KINT7") { return JCollisionSel::sel7KINT7; } @@ -68,13 +85,16 @@ int initialiseEventSelection(std::string eventSelection) } template -uint8_t setEventSelectionBit(T const& collision) +uint16_t setEventSelectionBit(T const& collision) { - uint8_t bit = 0; + 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()) { @@ -84,9 +104,16 @@ uint8_t setEventSelectionBit(T const& collision) } } 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); + } + } } } return bit; @@ -107,10 +134,154 @@ bool eventEMCAL(T const& collision) return found; } +inline const std::string JTriggerMasks = "fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"; + +enum JTrigSel { + noTrigSel = 0, + JetChLowPt = 1, + JetChHighPt = 2, + TrackLowPt = 3, + TrackHighPt = 4, + JetD0ChLowPt = 5, + JetD0ChHighPt = 6, + JetLcChLowPt = 7, + JetLcChHighPt = 8, + EMCALReadout = 9, + JetFullHighPt = 10, + JetFullLowPt = 11, + JetNeutralHighPt = 12, + JetNeutralLowPt = 13, + GammaVeryHighPtEMCAL = 14, + GammaVeryHighPtDCAL = 15, + GammaHighPtEMCAL = 16, + GammaHighPtDCAL = 17, + GammaLowPtEMCAL = 18, + GammaLowPtDCAL = 19, + GammaVeryLowPtEMCAL = 20, + GammaVeryLowPtDCAL = 21 +}; + +template +bool selectTrigger(T const& collision, std::vector triggerMaskBits) +{ + if (triggerMaskBits.size() == 0) { + return true; + } + for (auto triggerMaskBit : triggerMaskBits) { + if (collision.triggerSel() & (1 << triggerMaskBit)) { + return true; + } + } + return false; +} + +template +bool selectTrigger(T const& collision, int triggerMaskBit) +{ + if (triggerMaskBit == -1) { + return false; + } + return collision.triggerSel() & (1 << triggerMaskBit); +} + +bool triggerMasksContainTrigger(std::string triggerMasks, std::string trigger) +{ + size_t position = 0; + while ((position = triggerMasks.find(trigger, position)) != std::string::npos) { + bool validStart = (position == 0 || triggerMasks[position - 1] == ','); + bool validEnd = (position + trigger.length() == triggerMasks.length() || triggerMasks[position + trigger.length()] == ','); + if (validStart && validEnd) { + return true; + } + position += trigger.length(); + } + return false; +} + +std::vector initialiseTriggerMaskBits(std::string triggerMasks) +{ + std::vector triggerMaskBits; + if (triggerMasksContainTrigger(triggerMasks, "fJetChLowPt")) { + triggerMaskBits.push_back(JetChLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetChHighPt")) { + triggerMaskBits.push_back(JetChHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fTrackLowPt")) { + triggerMaskBits.push_back(TrackLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fTrackHighPt")) { + triggerMaskBits.push_back(TrackHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetD0ChLowPt")) { + triggerMaskBits.push_back(JetD0ChLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetD0ChHighPt")) { + triggerMaskBits.push_back(JetD0ChHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetLcChLowPt")) { + triggerMaskBits.push_back(JetLcChLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetLcChHighPt")) { + triggerMaskBits.push_back(JetLcChHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fEMCALReadout")) { + triggerMaskBits.push_back(EMCALReadout); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetFullHighPt")) { + triggerMaskBits.push_back(JetFullHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetFullLowPt")) { + triggerMaskBits.push_back(JetFullLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetNeutralHighPt")) { + triggerMaskBits.push_back(JetNeutralHighPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fJetNeutralLowPt")) { + triggerMaskBits.push_back(JetNeutralLowPt); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryHighPtEMCAL")) { + triggerMaskBits.push_back(GammaVeryHighPtEMCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryHighPtDCAL")) { + triggerMaskBits.push_back(GammaVeryHighPtDCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaHighPtEMCAL")) { + triggerMaskBits.push_back(GammaHighPtEMCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaHighPtDCAL")) { + triggerMaskBits.push_back(GammaHighPtDCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaLowPtEMCAL")) { + triggerMaskBits.push_back(GammaLowPtEMCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaLowPtDCAL")) { + triggerMaskBits.push_back(GammaLowPtDCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryLowPtEMCAL")) { + triggerMaskBits.push_back(GammaVeryLowPtEMCAL); + } + if (triggerMasksContainTrigger(triggerMasks, "fGammaVeryLowPtDCAL")) { + triggerMaskBits.push_back(GammaVeryLowPtDCAL); + } + return triggerMaskBits; +} + +uint64_t setTriggerSelectionBit(std::vector triggerDecisions) +{ + uint64_t bit = 0; + for (std::vector::size_type i = 0; i < triggerDecisions.size(); i++) { + if (triggerDecisions[i]) { + SETBIT(bit, i + 1); + } + } + return bit; +} + enum JTrigSelCh { noChargedTigger = 0, - chargedLow = 1, - chargedHigh = 2, + jetChLowPt = 1, + jetChHighPt = 2, trackLowPt = 3, trackHighPt = 4 }; @@ -126,11 +297,11 @@ bool selectChargedTrigger(T const& collision, int triggerSelection) int initialiseChargedTriggerSelection(std::string triggerSelection) { - if (triggerSelection == "chargedLow") { - return JTrigSelCh::chargedLow; + if (triggerSelection == "jetChLowPt") { + return JTrigSelCh::jetChLowPt; } - if (triggerSelection == "chargedHigh") { - return JTrigSelCh::chargedHigh; + if (triggerSelection == "jetChHighPt") { + return JTrigSelCh::jetChHighPt; } if (triggerSelection == "trackLowPt") { return JTrigSelCh::trackLowPt; @@ -148,10 +319,10 @@ uint8_t setChargedTriggerSelectionBit(T const& collision) uint8_t bit = 0; if (collision.hasJetChLowPt()) { - SETBIT(bit, JTrigSelCh::chargedLow); + SETBIT(bit, JTrigSelCh::jetChLowPt); } if (collision.hasJetChHighPt()) { - SETBIT(bit, JTrigSelCh::chargedHigh); + SETBIT(bit, JTrigSelCh::jetChHighPt); } if (collision.hasTrackLowPt()) { SETBIT(bit, JTrigSelCh::trackLowPt); @@ -165,18 +336,19 @@ uint8_t setChargedTriggerSelectionBit(T const& collision) enum JTrigSelFull { noFullTrigger = 0, - fullHigh = 1, - fullLow = 2, - neutralHigh = 3, - neutralLow = 4, - gammaVeryHighEMCAL = 5, - gammaHighEMCAL = 6, - gammaLowEMCAL = 7, - gammaVeryLowEMCAL = 8, - gammaVeryHighDCAL = 9, - gammaHighDCAL = 10, - gammaLowDCAL = 11, - gammaVeryLowDCAL = 12 + emcalReadout = 1, + jetFullHighPt = 2, + jetFullLowPt = 3, + jetNeutralHighPt = 4, + jetNeutralLowPt = 5, + gammaVeryHighPtEMCAL = 6, + gammaVeryHighPtDCAL = 7, + gammaHighPtEMCAL = 8, + gammaHighPtDCAL = 9, + gammaLowPtEMCAL = 10, + gammaLowPtDCAL = 11, + gammaVeryLowPtEMCAL = 12, + gammaVeryLowPtDCAL = 13 }; template @@ -190,30 +362,32 @@ bool selectFullTrigger(T const& collision, int triggerSelection) int initialiseFullTriggerSelection(std::string triggerSelection) { - if (triggerSelection == "fullHigh") { - return JTrigSelFull::fullHigh; - } else if (triggerSelection == "fullLow") { - return JTrigSelFull::fullLow; - } else if (triggerSelection == "neutralHigh") { - return JTrigSelFull::neutralHigh; - } else if (triggerSelection == "neutralLow") { - return JTrigSelFull::neutralLow; - } else if (triggerSelection == "gammaVeryHighEMCAL") { - return JTrigSelFull::gammaVeryHighEMCAL; - } else if (triggerSelection == "gammaHighEMCAL") { - return JTrigSelFull::gammaHighEMCAL; - } else if (triggerSelection == "gammaLowEMCAL") { - return JTrigSelFull::gammaLowEMCAL; - } else if (triggerSelection == "gammaVeryLowEMCAL") { - return JTrigSelFull::gammaVeryLowEMCAL; - } else if (triggerSelection == "gammaVeryHighDCAL") { - return JTrigSelFull::gammaVeryHighDCAL; - } else if (triggerSelection == "gammaHighDCAL") { - return JTrigSelFull::gammaHighDCAL; - } else if (triggerSelection == "gammaLowDCAL") { - return JTrigSelFull::gammaLowDCAL; - } else if (triggerSelection == "gammaVeryLowDCAL") { - return JTrigSelFull::gammaVeryLowDCAL; + if (triggerSelection == "emcalReadout") { + return JTrigSelFull::emcalReadout; + } else if (triggerSelection == "jetFullHighPt") { + return JTrigSelFull::jetFullHighPt; + } else if (triggerSelection == "jetFullLowPt") { + return JTrigSelFull::jetFullLowPt; + } else if (triggerSelection == "jetNeutralHighPt") { + return JTrigSelFull::jetNeutralHighPt; + } else if (triggerSelection == "jetNeutralLowPt") { + return JTrigSelFull::jetNeutralLowPt; + } else if (triggerSelection == "gammaVeryHighPtEMCAL") { + return JTrigSelFull::gammaVeryHighPtEMCAL; + } else if (triggerSelection == "gammaVeryHighPtDCAL") { + return JTrigSelFull::gammaVeryHighPtDCAL; + } else if (triggerSelection == "gammaHighPtEMCAL") { + return JTrigSelFull::gammaHighPtEMCAL; + } else if (triggerSelection == "gammaHighPtDCAL") { + return JTrigSelFull::gammaHighPtDCAL; + } else if (triggerSelection == "gammaLowPtEMCAL") { + return JTrigSelFull::gammaLowPtEMCAL; + } else if (triggerSelection == "gammaLowPtDCAL") { + return JTrigSelFull::gammaLowPtDCAL; + } else if (triggerSelection == "gammaVeryLowPtEMCAL") { + return JTrigSelFull::gammaVeryLowPtEMCAL; + } else if (triggerSelection == "gammaVeryLowPtDCAL") { + return JTrigSelFull::gammaVeryLowPtDCAL; } return -1; } @@ -222,51 +396,54 @@ template uint32_t setFullTriggerSelectionBit(T const& collision) { uint32_t bit = 0; + if (collision.hasEMCALinReadout()) { + SETBIT(bit, JTrigSelFull::emcalReadout); + } if (collision.hasJetFullHighPt()) { - SETBIT(bit, JTrigSelFull::fullHigh); + SETBIT(bit, JTrigSelFull::jetFullHighPt); } if (collision.hasJetFullLowPt()) { - SETBIT(bit, JTrigSelFull::fullLow); + SETBIT(bit, JTrigSelFull::jetFullLowPt); } if (collision.hasJetNeutralHighPt()) { - SETBIT(bit, JTrigSelFull::neutralHigh); + SETBIT(bit, JTrigSelFull::jetNeutralHighPt); } if (collision.hasJetNeutralLowPt()) { - SETBIT(bit, JTrigSelFull::neutralLow); + SETBIT(bit, JTrigSelFull::jetNeutralLowPt); } if (collision.hasGammaVeryHighPtEMCAL()) { - SETBIT(bit, JTrigSelFull::gammaVeryHighEMCAL); - } - if (collision.hasGammaHighPtEMCAL()) { - SETBIT(bit, JTrigSelFull::gammaHighEMCAL); - } - if (collision.hasGammaLowPtEMCAL()) { - SETBIT(bit, JTrigSelFull::gammaLowEMCAL); - } - if (collision.hasGammaVeryLowPtEMCAL()) { - SETBIT(bit, JTrigSelFull::gammaVeryLowEMCAL); + SETBIT(bit, JTrigSelFull::gammaVeryHighPtEMCAL); } if (collision.hasGammaVeryHighPtDCAL()) { - SETBIT(bit, JTrigSelFull::gammaVeryHighDCAL); + SETBIT(bit, JTrigSelFull::gammaVeryHighPtDCAL); + } + if (collision.hasGammaHighPtEMCAL()) { + SETBIT(bit, JTrigSelFull::gammaHighPtEMCAL); } if (collision.hasGammaHighPtDCAL()) { - SETBIT(bit, JTrigSelFull::gammaHighDCAL); + SETBIT(bit, JTrigSelFull::gammaHighPtDCAL); + } + if (collision.hasGammaLowPtEMCAL()) { + SETBIT(bit, JTrigSelFull::gammaLowPtEMCAL); } if (collision.hasGammaLowPtDCAL()) { - SETBIT(bit, JTrigSelFull::gammaLowDCAL); + SETBIT(bit, JTrigSelFull::gammaLowPtDCAL); + } + if (collision.hasGammaVeryLowPtEMCAL()) { + SETBIT(bit, JTrigSelFull::gammaVeryLowPtEMCAL); } if (collision.hasGammaVeryLowPtDCAL()) { - SETBIT(bit, JTrigSelFull::gammaVeryLowDCAL); + SETBIT(bit, JTrigSelFull::gammaVeryLowPtDCAL); } return bit; } enum JTrigSelChHF { noChargedHFTigger = 0, - chargedD0Low = 1, - chargedD0High = 2, - chargedLcLow = 3, - chargedLcHigh = 4 + jetD0ChLowPt = 1, + jetD0ChHighPt = 2, + jetLcChLowPt = 3, + jetLcChHighPt = 4 }; template @@ -280,17 +457,17 @@ bool selectChargedHFTrigger(T const& collision, int triggerSelection) int initialiseChargedHFTriggerSelection(std::string triggerSelection) { - if (triggerSelection == "chargedD0Low") { - return JTrigSelChHF::chargedD0Low; + if (triggerSelection == "jetD0ChLowPt") { + return JTrigSelChHF::jetD0ChLowPt; } - if (triggerSelection == "chargedD0High") { - return JTrigSelChHF::chargedD0High; + if (triggerSelection == "jetD0ChHighPt") { + return JTrigSelChHF::jetD0ChHighPt; } - if (triggerSelection == "chargedLcLow") { - return JTrigSelChHF::chargedLcLow; + if (triggerSelection == "jetLcChLowPt") { + return JTrigSelChHF::jetLcChLowPt; } - if (triggerSelection == "chargedLcHigh") { - return JTrigSelChHF::chargedLcHigh; + if (triggerSelection == "jetLcChHighPt") { + return JTrigSelChHF::jetLcChHighPt; } return -1; } @@ -301,16 +478,16 @@ uint8_t setChargedHFTriggerSelectionBit(T const& collision) uint8_t bit = 0; if (collision.hasJetD0ChLowPt()) { - SETBIT(bit, JTrigSelChHF::chargedD0Low); + SETBIT(bit, JTrigSelChHF::jetD0ChLowPt); } if (collision.hasJetD0ChHighPt()) { - SETBIT(bit, JTrigSelChHF::chargedD0High); + SETBIT(bit, JTrigSelChHF::jetD0ChHighPt); } if (collision.hasJetLcChLowPt()) { - SETBIT(bit, JTrigSelChHF::chargedLcLow); + SETBIT(bit, JTrigSelChHF::jetLcChLowPt); } if (collision.hasJetLcChHighPt()) { - SETBIT(bit, JTrigSelChHF::chargedLcHigh); + SETBIT(bit, JTrigSelChHF::jetLcChHighPt); } return bit; } @@ -319,9 +496,8 @@ enum JTrackSel { trackSign = 0, // warning : this number is hardcoded in the sign coloumn in the JTracks table so should not be changed without changing it there too globalTrack = 1, qualityTrack = 2, - hybridTrack = 3, - uniformTrack = 4, - uniformTrackWoDCA = 5 + qualityTrackWDCA = 3, + hybridTrack = 4 }; template @@ -348,18 +524,16 @@ int initialiseTrackSelection(std::string trackSelection) return JTrackSel::globalTrack; } else if (trackSelection == "QualityTracks") { return JTrackSel::qualityTrack; + } else if (trackSelection == "QualityTracksWDCA") { + return JTrackSel::qualityTrackWDCA; } else if (trackSelection == "hybridTracks") { return JTrackSel::hybridTrack; - } else if (trackSelection == "uniformTracks") { - return JTrackSel::uniformTrack; - } else if (trackSelection == "uniformTracksWoDCA") { - return JTrackSel::uniformTrackWoDCA; } return -1; } template -uint8_t setTrackSelectionBit(T const& track) +uint8_t setTrackSelectionBit(T const& track, float trackDCAZ, float maxDCAZ) { uint8_t bit = 0; @@ -372,20 +546,13 @@ uint8_t setTrackSelectionBit(T const& track) } if (track.isQualityTrack()) { SETBIT(bit, JTrackSel::qualityTrack); + if (std::abs(trackDCAZ) < maxDCAZ) { + SETBIT(bit, JTrackSel::qualityTrackWDCA); + } } if (track.trackCutFlagFb5()) { SETBIT(bit, JTrackSel::hybridTrack); } - if ((track.passedGoldenChi2() && track.passedDCAxy()) && - (track.passedITSNCls() && track.passedITSChi2NDF() && track.passedITSHits()) && - (!track.hasTPC() || (track.passedTPCNCls() && track.passedTPCChi2NDF() && track.passedTPCCrossedRowsOverNCls()))) { // removing track.passedDCAz() so aimeric can test. Needs to be added into the bracket with passedGoldenChi2 - SETBIT(bit, JTrackSel::uniformTrack); - } - if (track.passedGoldenChi2() && - (track.passedITSNCls() && track.passedITSChi2NDF() && track.passedITSHits()) && - (!track.hasTPC() || (track.passedTPCNCls() && track.passedTPCChi2NDF() && track.passedTPCCrossedRowsOverNCls()))) { - SETBIT(bit, JTrackSel::uniformTrackWoDCA); - } return bit; } diff --git a/PWGJE/Core/JetFinder.cxx b/PWGJE/Core/JetFinder.cxx index 940a201bb92..03583a9e622 100644 --- a/PWGJE/Core/JetFinder.cxx +++ b/PWGJE/Core/JetFinder.cxx @@ -37,7 +37,11 @@ void JetFinder::setParams() // selGhosts =fastjet::SelectorRapRange(ghostEtaMin,ghostEtaMax) && fastjet::SelectorPhiRange(phiMin,phiMax); // ghostAreaSpec=fastjet::GhostedAreaSpec(selGhosts,ghostRepeatN,ghostArea,gridScatter,ktScatter,ghostktMean); ghostAreaSpec = fastjet::GhostedAreaSpec(ghostEtaMax, ghostRepeatN, ghostArea, gridScatter, ktScatter, ghostktMean); // the first argument is rapidity not pseudorapidity, to be checked - jetDef = fastjet::JetDefinition(algorithm, jetR, recombScheme, strategy); + jetDef = fastjet::JetDefinition(fastjet::antikt_algorithm, jetR, recombScheme, strategy); + if (fastjetExtraParam > -98.0) { + jetDef.set_extra_param(fastjetExtraParam); + } + jetDef.set_jet_algorithm(algorithm); areaDef = fastjet::AreaDefinition(areaType, ghostAreaSpec); selJets = fastjet::SelectorPtRange(jetPtMin, jetPtMax) && fastjet::SelectorEtaRange(jetEtaMin, jetEtaMax) && fastjet::SelectorPhiRange(jetPhiMin, jetPhiMax); } diff --git a/PWGJE/Core/JetFinder.h b/PWGJE/Core/JetFinder.h index bdb03434b2a..26b4a3c5f0f 100644 --- a/PWGJE/Core/JetFinder.h +++ b/PWGJE/Core/JetFinder.h @@ -82,6 +82,7 @@ class JetFinder fastjet::AreaDefinition areaDef; fastjet::Selector selJets; fastjet::Selector selGhosts; + double fastjetExtraParam = -99.0; /// Sets the jet finding parameters void setParams(); diff --git a/PWGJE/Core/JetFindingUtilities.h b/PWGJE/Core/JetFindingUtilities.h index d76ceb94b71..8efd9733e6e 100644 --- a/PWGJE/Core/JetFindingUtilities.h +++ b/PWGJE/Core/JetFindingUtilities.h @@ -53,20 +53,38 @@ namespace jetfindingutilities { +/** + * returns true if the object is from the JDummys table + */ +template +constexpr bool isDummy() +{ + return std::is_same_v, o2::aod::JDummys::iterator> || std::is_same_v, o2::aod::JDummys::filtered_iterator>; +} + +/** + * returns true if the table is a JDummys table + */ +template +constexpr bool isDummyTable() +{ + return isDummy() || isDummy(); +} + /** * returns true if the cluster is from an EMCAL table */ template constexpr bool isEMCALCluster() { - return std::is_same_v, JetClusters::iterator> || std::is_same_v, JetClusters::filtered_iterator> || std::is_same_v, JetClustersMCD::iterator> || std::is_same_v, JetClustersMCD::filtered_iterator>; + return std::is_same_v, o2::aod::JetClusters::iterator> || std::is_same_v, o2::aod::JetClusters::filtered_iterator> || std::is_same_v, o2::aod::JetClustersMCD::iterator> || std::is_same_v, o2::aod::JetClustersMCD::filtered_iterator>; } /** * returns true if the table is an EMCAL table */ template -constexpr bool isEMCALTable() +constexpr bool isEMCALClusterTable() { return isEMCALCluster() || isEMCALCluster(); } @@ -163,7 +181,7 @@ template bool analyseCandidate(std::vector& inputParticles, T const& candidate, float candPtMin, float candPtMax, float candYMin, float candYMax) { auto candMass = jetcandidateutilities::getCandidatePDGMass(candidate); - if (isnan(candidate.y())) { + if (std::isnan(candidate.y())) { return false; } if (candidate.y() < candYMin || candidate.y() > candYMax) { @@ -227,7 +245,7 @@ bool analyseV0s(std::vector& inputParticles, T const& v0s, f } v0Y = v0.rapidity(v0Index); } - if (isnan(v0Y)) { + if (std::isnan(v0Y)) { continue; } if (v0Y < v0YMin || v0Y > v0YMax) { @@ -331,7 +349,7 @@ void analyseParticles(std::vector& inputParticles, std::stri } else if (particleSelection == "PhysicalPrimaryAndHepMCStatus" && (!particle.isPhysicalPrimary() || particle.getHepMCStatusCode() != 1)) { continue; } - if (isinf(particle.eta())) { + if (std::isinf(particle.eta())) { continue; } auto pdgParticle = pdgDatabase->GetParticle(particle.pdgCode()); diff --git a/PWGJE/Core/JetHFUtilities.h b/PWGJE/Core/JetHFUtilities.h index 3ede850f1fd..d76c8d19121 100644 --- a/PWGJE/Core/JetHFUtilities.h +++ b/PWGJE/Core/JetHFUtilities.h @@ -38,7 +38,6 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/DataModel/DerivedTables.h" -#include "PWGHF/DataModel/DerivedTablesStored.h" #include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" @@ -54,7 +53,7 @@ namespace jethfutilities template constexpr bool isD0Candidate() { - return std::is_same_v, CandidatesD0Data::iterator> || std::is_same_v, CandidatesD0Data::filtered_iterator> || std::is_same_v, CandidatesD0MCD::iterator> || std::is_same_v, CandidatesD0MCD::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesD0Data::iterator> || std::is_same_v, o2::aod::CandidatesD0Data::filtered_iterator> || std::is_same_v, o2::aod::CandidatesD0MCD::iterator> || std::is_same_v, o2::aod::CandidatesD0MCD::filtered_iterator>; } /** @@ -63,7 +62,7 @@ constexpr bool isD0Candidate() template constexpr bool isD0McCandidate() { - return std::is_same_v, CandidatesD0MCP::iterator> || std::is_same_v, CandidatesD0MCP::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesD0MCP::iterator> || std::is_same_v, o2::aod::CandidatesD0MCP::filtered_iterator>; } /** @@ -90,7 +89,7 @@ constexpr bool isD0McTable() template constexpr bool isLcCandidate() { - return std::is_same_v, CandidatesLcData::iterator> || std::is_same_v, CandidatesLcData::filtered_iterator> || std::is_same_v, CandidatesLcMCD::iterator> || std::is_same_v, CandidatesLcMCD::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesLcData::iterator> || std::is_same_v, o2::aod::CandidatesLcData::filtered_iterator> || std::is_same_v, o2::aod::CandidatesLcMCD::iterator> || std::is_same_v, o2::aod::CandidatesLcMCD::filtered_iterator>; } /** @@ -99,7 +98,7 @@ constexpr bool isLcCandidate() template constexpr bool isLcMcCandidate() { - return std::is_same_v, CandidatesLcMCP::iterator> || std::is_same_v, CandidatesLcMCP::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesLcMCP::iterator> || std::is_same_v, o2::aod::CandidatesLcMCP::filtered_iterator>; } /** @@ -126,7 +125,7 @@ constexpr bool isLcMcTable() template constexpr bool isBplusCandidate() { - return std::is_same_v, CandidatesBplusData::iterator> || std::is_same_v, CandidatesBplusData::filtered_iterator> || std::is_same_v, CandidatesBplusMCD::iterator> || std::is_same_v, CandidatesBplusMCD::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesBplusData::iterator> || std::is_same_v, o2::aod::CandidatesBplusData::filtered_iterator> || std::is_same_v, o2::aod::CandidatesBplusMCD::iterator> || std::is_same_v, o2::aod::CandidatesBplusMCD::filtered_iterator>; } /** @@ -135,7 +134,7 @@ constexpr bool isBplusCandidate() template constexpr bool isBplusMcCandidate() { - return std::is_same_v, CandidatesBplusMCP::iterator> || std::is_same_v, CandidatesBplusMCP::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesBplusMCP::iterator> || std::is_same_v, o2::aod::CandidatesBplusMCP::filtered_iterator>; } /** @@ -550,7 +549,7 @@ void fillD0McCollisionTable(T const& mcCollision, U& D0McCollisionTable, int32_t template void fillLcMcCollisionTable(T const& mcCollision, U& LcMcCollisionTable, int32_t& LcMcCollisionTableIndex) { - LcMcCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()); + LcMcCollisionTable(mcCollision.posX(), mcCollision.posY(), mcCollision.posZ(), mcCollision.centFT0M()); LcMcCollisionTableIndex = LcMcCollisionTable.lastIndex(); } @@ -584,18 +583,18 @@ void fillD0CandidateTable(T const& candidate, int32_t collisionIndex, U& D0BaseT candidate.impactParameter1(), candidate.impactParameterNormalised0(), candidate.impactParameterNormalised1(), - candidate.nSigTpcPi0(), - candidate.nSigTpcKa0(), - candidate.nSigTofPi0(), - candidate.nSigTofKa0(), - candidate.nSigTpcTofPi0(), - candidate.nSigTpcTofKa0(), - candidate.nSigTpcPi1(), - candidate.nSigTpcKa1(), - candidate.nSigTofPi1(), - candidate.nSigTofKa1(), - candidate.nSigTpcTofPi1(), - candidate.nSigTpcTofKa1(), + candidate.nSigTpcPiExpPi(), + candidate.nSigTofPiExpPi(), + candidate.nSigTpcTofPiExpPi(), + candidate.nSigTpcKaExpPi(), + candidate.nSigTofKaExpPi(), + candidate.nSigTpcTofKaExpPi(), + candidate.nSigTpcPiExpKa(), + candidate.nSigTofPiExpKa(), + candidate.nSigTpcTofPiExpKa(), + candidate.nSigTpcKaExpKa(), + candidate.nSigTofKaExpKa(), + candidate.nSigTpcTofKaExpKa(), candidate.maxNormalisedDeltaIP(), candidate.impactParameterProduct()); diff --git a/PWGJE/Core/JetMatchingUtilities.h b/PWGJE/Core/JetMatchingUtilities.h index b88ad32337c..90885ca737a 100644 --- a/PWGJE/Core/JetMatchingUtilities.h +++ b/PWGJE/Core/JetMatchingUtilities.h @@ -470,8 +470,10 @@ float getPtSum(T const& tracksBase, U const& clustersBase, V const& tracksTag, O template auto getConstituents(T const& jet, U const& /*constituents*/) { - if constexpr (jetfindingutilities::isEMCALTable
()) { + 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 + return nullptr; } else { return jet.template tracks_as(); } @@ -492,8 +494,8 @@ void MatchPt(T const& jetsBasePerCollision, U const& jetsTagPerCollision, std::v auto jetTagTracks = getConstituents(jetTag, tracksTag); auto jetTagClusters = getConstituents(jetTag, clustersTag); - ptSumBase = getPtSum < jetfindingutilities::isEMCALTable() || jetfindingutilities::isEMCALTable(), jetsBaseIsMc, jetsTagIsMc > (jetBaseTracks, jetBaseClusters, jetTagTracks, jetTagClusters); - ptSumTag = getPtSum < jetfindingutilities::isEMCALTable() || jetfindingutilities::isEMCALTable(), jetsTagIsMc, jetsBaseIsMc > (jetTagTracks, jetTagClusters, jetBaseTracks, jetBaseClusters); + ptSumBase = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), jetsBaseIsMc, jetsTagIsMc > (jetBaseTracks, jetBaseClusters, jetTagTracks, jetTagClusters); + ptSumTag = getPtSum < jetfindingutilities::isEMCALClusterTable() || jetfindingutilities::isEMCALClusterTable(), jetsTagIsMc, jetsBaseIsMc > (jetTagTracks, jetTagClusters, jetBaseTracks, jetBaseClusters); if (ptSumBase > jetBase.pt() * minPtFraction) { baseToTagMatchingPt[jetBase.globalIndex()].push_back(jetTag.globalIndex()); } diff --git a/PWGJE/Core/JetSubstructureUtilities.h b/PWGJE/Core/JetSubstructureUtilities.h index cf67d789ead..cb714c1c5bf 100644 --- a/PWGJE/Core/JetSubstructureUtilities.h +++ b/PWGJE/Core/JetSubstructureUtilities.h @@ -59,7 +59,7 @@ fastjet::ClusterSequenceArea jetToPseudoJet(T const& jet, U const& /*tracks*/, V for (auto& jetConstituent : jet.template tracks_as()) { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex()); } - if constexpr (std::is_same_v, JetClusters::iterator> || std::is_same_v, JetClusters::filtered_iterator>) { + 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()); } diff --git a/PWGJE/Core/JetTaggingUtilities.h b/PWGJE/Core/JetTaggingUtilities.h index 5e8793ed718..8f5c44362e1 100644 --- a/PWGJE/Core/JetTaggingUtilities.h +++ b/PWGJE/Core/JetTaggingUtilities.h @@ -46,6 +46,28 @@ namespace jettaggingutilities { const int cmTomum = 10000; // using cm -> #mum for impact parameter (dca) +//________________________________________________________________________ +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, + 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, + 5314, 5324, 5332, 5334, 5142, 5242, 5412, 5422, 5414, 5424, 5342, 5432, 5434, 5442, 5444, 5512, 5522, 5514, 5524, + 5532, 5534, 5542, 5544, 5554}; + + return (std::find(bPdG.begin(), bPdG.end(), std::abs(pc)) != bPdG.end()); +} +//________________________________________________________________________ +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}; + + return (std::find(bPdG.begin(), bPdG.end(), std::abs(pc)) != bPdG.end()); +} + /** * returns the globalIndex of the earliest mother of a particle in the shower. returns -1 if a suitable mother is not found * @@ -109,18 +131,19 @@ int getOriginalHFMotherIndex(const typename T::iterator& hfparticle) * @param hftrack track passed as reference which is then replaced by the first track that originated from an HF shower */ template -int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, typename U::iterator& hftrack) +int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, typename U::iterator& hftrack, bool searchUpToQuark) { bool hasMcParticle = false; int origin = -1; for (auto& 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; } hasMcParticle = true; auto const& particle = track.template mcParticle_as(); - origin = RecoDecay::getCharmHadronOrigin(particles, particle, true); + origin = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark); if (origin == 1 || origin == 2) { // 1=charm , 2=beauty hftrack = track; if (origin == 1) { @@ -131,6 +154,7 @@ int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, } } } + if (hasMcParticle) { return JetTaggingSpecies::lightflavour; } else { @@ -146,12 +170,13 @@ int jetTrackFromHFShower(T const& jet, U const& /*tracks*/, V const& particles, * @param hfparticle particle passed as reference which is then replaced by the first track that originated from an HF shower */ template -int jetParticleFromHFShower(T const& jet, U const& particles, typename U::iterator& hfparticle) +int jetParticleFromHFShower(T const& jet, U const& particles, typename U::iterator& hfparticle, bool searchUpToQuark) { int origin = -1; for (const auto& particle : jet.template tracks_as()) { - origin = RecoDecay::getCharmHadronOrigin(particles, particle, true); + 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 hfparticle = particle; if (origin == 1) { @@ -174,11 +199,11 @@ int jetParticleFromHFShower(T const& jet, U const& particles, typename U::iterat */ template -int mcdJetFromHFShower(T const& jet, U const& tracks, V const& particles, float dRMax = 0.25) +int mcdJetFromHFShower(T const& jet, U const& tracks, V const& particles, float dRMax = 0.25, bool searchUpToQuark = false) { typename U::iterator hftrack; - int origin = jetTrackFromHFShower(jet, tracks, particles, hftrack); + int origin = jetTrackFromHFShower(jet, tracks, particles, hftrack, searchUpToQuark); if (origin == JetTaggingSpecies::charm || origin == JetTaggingSpecies::beauty) { if (!hftrack.has_mcParticle()) { return JetTaggingSpecies::none; @@ -215,11 +240,11 @@ int mcdJetFromHFShower(T const& jet, U const& tracks, V const& particles, float */ template -int mcpJetFromHFShower(T const& jet, U const& particles, float dRMax = 0.25) +int mcpJetFromHFShower(T const& jet, U const& particles, float dRMax = 0.25, bool searchUpToQuark = false) { typename U::iterator hfparticle; - int origin = jetParticleFromHFShower(jet, particles, hfparticle); + int origin = jetParticleFromHFShower(jet, particles, hfparticle, searchUpToQuark); if (origin == JetTaggingSpecies::charm || origin == JetTaggingSpecies::beauty) { int originalHFMotherIndex = getOriginalHFMotherIndex(hfparticle); @@ -292,11 +317,7 @@ int jetOrigin(T const& jet, U const& particles, float dRMax = 0.25) template int16_t getJetFlavor(AnyJet const& jet, AllMCParticles const& mcparticles) { - const int arraySize = 99; - - std::array countpartcode; - int count = 0; - + bool charmQuark = false; for (auto& mcpart : mcparticles) { int pdgcode = mcpart.pdgCode(); if (TMath::Abs(pdgcode) == 21 || (TMath::Abs(pdgcode) >= 1 && TMath::Abs(pdgcode) <= 5)) { @@ -304,23 +325,105 @@ int16_t getJetFlavor(AnyJet const& jet, AllMCParticles const& mcparticles) if (dR < jet.r() / 100.f) { if (TMath::Abs(pdgcode) == 5) { - return 2; // Beauty jet - } else { - if (count > arraySize - 1) - return 0; - countpartcode[count] = pdgcode; - count++; + return JetTaggingSpecies::beauty; // Beauty jet + } else if (TMath::Abs(pdgcode) == 4) { + charmQuark = true; } } } } - for (int ij = 0; ij < count; ij++) { - if (TMath::Abs(countpartcode[ij]) == 4) - return 1; // Charm jet + if (charmQuark) { + return JetTaggingSpecies::charm; // Charm jet } - return 0; // Light flavor jet + return JetTaggingSpecies::lightflavour; // Light flavor jet +} + +/** + * return the jet flavor if it finds a HF hadron inside the jet: 0 for lf-jet, 1 for c-jet, 2 for b-jet + * + * @param AnyJet the jet that we need to study its flavor + * @param AllMCParticles a vector of all the mc particles stack + */ +template +int16_t getJetFlavorHadron(AnyJet const& jet, AllMCParticles const& mcparticles) +{ + bool charmHadron = false; + + for (auto& mcpart : mcparticles) { + int pdgcode = mcpart.pdgCode(); + if (isBHadron(pdgcode) || isCHadron(pdgcode)) { + double dR = jetutilities::deltaR(jet, mcpart); + + if (dR < jet.r() / 100.f) { + if (isBHadron(pdgcode)) { + return JetTaggingSpecies::beauty; // Beauty jet + } else if (isCHadron(pdgcode)) { + charmHadron = true; + } + } + } + } + + if (charmHadron) { + return JetTaggingSpecies::charm; // Charm jet + } + + return JetTaggingSpecies::lightflavour; // Light flavor jet +} + +/** + * return acceptance of track about DCA xy and z due to cut for QualityTracks + */ +template +bool trackAcceptanceWithDca(T const& track, float trackDcaXYMax, float trackDcaZMax) +{ + if (std::abs(track.dcaXY()) > trackDcaXYMax) + return false; + if (std::abs(track.dcaZ()) > trackDcaZMax) + return false; + return true; +} + +/** + * retrun acceptance of prong due to cut for high quality secondary vertex + */ +template +bool prongAcceptance(T const& prong, float prongChi2PCAMin, float prongChi2PCAMax, float prongsigmaLxyMax, float prongIPxyMin, float prongIPxyMax, bool doXYZ) +{ + if (prong.chi2PCA() < prongChi2PCAMin) + return false; + if (prong.chi2PCA() > prongChi2PCAMax) + 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; +} + +/** + * retrun acceptance of secondary vertex due to cut for high quality secondary vertex + */ +template +bool svAcceptance(T const& sv, float svDispersionMax) +{ + if (sv.dispersion() > svDispersionMax) + return false; + return true; } /** @@ -328,18 +431,13 @@ int16_t getJetFlavor(AnyJet const& jet, AllMCParticles const& mcparticles) * positive and negative value are expected from primary vertex * positive value is expected from secondary vertex * - * @param collision which is needed external table of collision due to postion X and Y * @param jet - * @param track which is needed each DCA_X and Y which is measured in jettaggerhfExtension.cxx + * @param jtrack which is needed aod::JTrackExtras */ -template -int getGeoSign(T const& collision, U const& jet, V const& track) +template +int getGeoSign(T const& jet, U const& jtrack) { - auto trackPar = getTrackPar(track); - auto xyz = trackPar.getXYZGlo(); - auto dcaX = xyz.X() - collision.posX(); - auto dcaY = xyz.Y() - collision.posY(); - auto sign = TMath::Sign(1, dcaX * jet.px() + dcaY * jet.py() + track.dcaZ() * jet.pz()); + auto sign = TMath::Sign(1, jtrack.dcaX() * jet.px() + jtrack.dcaY() * jet.py() + jtrack.dcaZ() * jet.pz()); if (sign < -1 || sign > 1) LOGF(info, Form("Sign is %d", sign)); return sign; @@ -349,14 +447,20 @@ int getGeoSign(T const& collision, U const& jet, V const& track) * Orders the tracks associated with a jet based on signed impact parameter significance and stores them * in a vector in descending order. */ -template > -void orderForIPJetTracks(T const& collision, U const& jet, V const& /*jtracks*/, W const& /*tracks*/, Vec& vecSignImpSig) +template > +void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float const& trackDcaXYMax, float const& trackDcaZMax, Vec& vecSignImpSig, bool useIPxyz) { - for (auto& jtrack : jet.template tracks_as()) { - auto track = jtrack.template track_as(); - auto geoSign = getGeoSign(collision, jet, track); - auto varSignImpXYSig = geoSign * TMath::Abs(track.dcaXY()) / TMath::Sqrt(track.sigmaDcaXY2()); - vecSignImpSig.push_back(varSignImpXYSig); + for (auto& jtrack : jet.template tracks_as()) { + if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + continue; + auto geoSign = getGeoSign(jet, jtrack); + float varSignImpSig; + if (!useIPxyz) { + varSignImpSig = geoSign * std::abs(jtrack.dcaXY()) / jtrack.sigmadcaXY(); + } else { + varSignImpSig = geoSign * std::abs(jtrack.dcaXYZ()) / jtrack.sigmadcaXYZ(); + } + vecSignImpSig.push_back(varSignImpSig); } std::sort(vecSignImpSig.begin(), vecSignImpSig.end(), std::greater()); } @@ -364,14 +468,14 @@ void orderForIPJetTracks(T const& collision, U const& jet, V const& /*jtracks*/, /** * Checks if a jet is greater than the given tagging working point based on the signed impact parameter significances */ -template -bool isGreaterThanTaggingPoint(T const& collision, U const& jet, V const& jtracks, W const& tracks, X const& taggingPoint = 1.0, Y const& cnt = 1) +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) { if (cnt == 0) { return true; // untagged } std::vector vecSignImpSig; - orderForIPJetTracks(collision, jet, jtracks, tracks, 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 @@ -420,7 +524,7 @@ template float getTrackProbability(T const& fResoFuncjet, U const& track, const float& minSignImpXYSig = -40) { float probTrack = 0; - auto varSignImpXYSig = TMath::Abs(track.dcaXY()) / TMath::Sqrt(track.sigmaDcaXY2()); + auto varSignImpXYSig = TMath::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); @@ -439,7 +543,6 @@ float getTrackProbability(T const& fResoFuncjet, U const& track, const float& mi * @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: The original tracks to transform from jtracks. * @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 @@ -447,24 +550,25 @@ float getTrackProbability(T const& fResoFuncjet, U const& track, const float& mi * specific flavor. Returns -1 if the jet contains fewer than two tracks with a positive * geometric sign. */ -template -float getJetProbability(T const& fResoFuncjet, U const& collision, V const& jet, W const& jtracks, X const& tracks, const int& cnt, const float& tagPoint = 1.0, const float& minSignImpXYSig = -10) +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) { - if (!(isGreaterThanTaggingPoint(collision, jet, jtracks, tracks, tagPoint, cnt))) + if (!(isGreaterThanTaggingPoint(jet, jtracks, trackDcaXYMax, trackDcaZMax, tagPoint, cnt, useIPxy))) return -1; std::vector jetTracksPt; float trackjetProb = 1.; - for (auto& jtrack : jet.template tracks_as()) { - auto track = jtrack.template track_as(); + for (auto& jtrack : jet.template tracks_as()) { + if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + continue; - float probTrack = getTrackProbability(fResoFuncjet, track, minSignImpXYSig); + float probTrack = getTrackProbability(fResoFuncjet, jtrack, minSignImpXYSig); - auto geoSign = getGeoSign(collision, jet, track); + auto geoSign = getGeoSign(jet, jtrack); if (geoSign > 0) { // only take positive sign track for JP calculation trackjetProb *= probTrack; - jetTracksPt.push_back(track.pt()); + jetTracksPt.push_back(jtrack.pt()); } } @@ -481,6 +585,50 @@ float getJetProbability(T const& fResoFuncjet, U const& collision, V const& jet, return JP; } +// 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) +{ + if (checkSv) + *checkSv = false; + float maxSxy = -1.0f; + typename ProngType::iterator bjetCand; + for (const auto& prong : jet.template secondaryVertices_as()) { + if (!prongAcceptance(prong, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, doXYZ)) + continue; + *checkSv = true; + float Sxy = -1.0f; + if (!doXYZ) { + Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); + } else { + Sxy = prong.decayLength() / prong.errorDecayLength(); + } + if (maxSxy < Sxy) { + bjetCand = prong; + } + } + return bjetCand; +} + +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 checkSv = false; + auto bjetCand = jetFromProngMaxDecayLength(jet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, doXYZ, &checkSv); + if (!(checkSv && svAcceptance(bjetCand, svDispersionMax))) + return false; + if (!doXYZ) { + auto maxSxy = bjetCand.decayLengthXY() / bjetCand.errorDecayLengthXY(); + if (maxSxy < tagPointForSV) + return false; + } else { + auto maxSxyz = bjetCand.decayLength() / bjetCand.errorDecayLength(); + if (maxSxyz < tagPointForSV) + return false; + } + return true; +} + }; // namespace jettaggingutilities #endif // PWGJE_CORE_JETTAGGINGUTILITIES_H_ diff --git a/PWGJE/Core/JetUtilities.h b/PWGJE/Core/JetUtilities.h index a681d76bf89..f1db864ef25 100644 --- a/PWGJE/Core/JetUtilities.h +++ b/PWGJE/Core/JetUtilities.h @@ -144,9 +144,17 @@ float deltaR(T const& A, U const& B) float dPhi = RecoDecay::constrainAngle(A.phi() - B.phi(), -M_PI); float dEta = A.eta() - B.eta(); - return TMath::Sqrt(dEta * dEta + dPhi * dPhi); + return std::sqrt(dEta * dEta + dPhi * dPhi); } +// same as deltaR but explicit specification of the eta and phi components +template +float deltaR(T const& eta1, U const& phi1, V const& eta2, W const& phi2) +{ + float dPhi = RecoDecay::constrainAngle(phi1 - phi2, -M_PI); + float dEta = eta1 - eta2; + return std::sqrt(dEta * dEta + dPhi * dPhi); +} }; // namespace jetutilities #endif // PWGJE_CORE_JETUTILITIES_H_ diff --git a/PWGJE/Core/JetV0Utilities.h b/PWGJE/Core/JetV0Utilities.h index 9e25fb13461..3d12cd5d0a3 100644 --- a/PWGJE/Core/JetV0Utilities.h +++ b/PWGJE/Core/JetV0Utilities.h @@ -54,7 +54,7 @@ namespace jetv0utilities template constexpr bool isV0Candidate() { - return std::is_same_v, CandidatesV0Data::iterator> || std::is_same_v, CandidatesV0Data::filtered_iterator> || std::is_same_v, CandidatesV0MCD::iterator> || std::is_same_v, CandidatesV0MCD::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesV0Data::iterator> || std::is_same_v, o2::aod::CandidatesV0Data::filtered_iterator> || std::is_same_v, o2::aod::CandidatesV0MCD::iterator> || std::is_same_v, o2::aod::CandidatesV0MCD::filtered_iterator>; } /** @@ -63,7 +63,7 @@ constexpr bool isV0Candidate() template constexpr bool isV0McCandidate() { - return std::is_same_v, CandidatesV0MCP::iterator> || std::is_same_v, CandidatesV0MCP::filtered_iterator>; + return std::is_same_v, o2::aod::CandidatesV0MCP::iterator> || std::is_same_v, o2::aod::CandidatesV0MCP::filtered_iterator>; } /** @@ -82,7 +82,7 @@ constexpr bool isV0Table() template constexpr bool isV0McTable() { - return std::is_same_v, CandidatesV0MCP> || std::is_same_v, o2::soa::Filtered>; // note not optimal way but needed for jetfindingutilities::analyseParticles() + return std::is_same_v, o2::aod::CandidatesV0MCP> || std::is_same_v, o2::soa::Filtered>; // note not optimal way but needed for jetfindingutilities::analyseParticles() } /** diff --git a/PWGJE/DataModel/EMCALClusters.h b/PWGJE/DataModel/EMCALClusters.h index c3aa23fac84..af97b559546 100644 --- a/PWGJE/DataModel/EMCALClusters.h +++ b/PWGJE/DataModel/EMCALClusters.h @@ -27,32 +27,43 @@ namespace emcalcluster { // define global cluster definitions -// the V1 algorithm is not yet implemented, but the V3 algorithm is // New definitions should be added here! -const EMCALClusterDefinition kV1Default(ClusterAlgorithm_t::kV1, 0, 1, "kV1Default", 0.5, 0.1, -10000, 10000, true, 0.03); // dummy -const EMCALClusterDefinition kV1Variation1(ClusterAlgorithm_t::kV3, 1, 1, "kV1Variation1", 0.3, 0.1, -10000, 10000, true, 0.03); // dummy -const EMCALClusterDefinition kV1Variation2(ClusterAlgorithm_t::kV3, 2, 1, "kV1Variation2", 0.2, 0.1, -10000, 10000, true, 0.03); // dummy +const EMCALClusterDefinition kV3NoSplit(ClusterAlgorithm_t::kV3, 0, 1, "kV3NoSplit", 0.5, 0.1, -10000, 10000, false, 0.); +const EMCALClusterDefinition kV3NoSplitLowSeed(ClusterAlgorithm_t::kV3, 1, 1, "kV3NoSplitLowSeed", 0.3, 0.1, -10000, 10000, false, 0.); +const EMCALClusterDefinition kV3NoSplitLowerSeed(ClusterAlgorithm_t::kV3, 2, 1, "kV3NoSplitLowerSeed", 0.2, 0.1, -10000, 10000, false, 0.); const EMCALClusterDefinition kV3Default(ClusterAlgorithm_t::kV3, 10, 1, "kV3Default", 0.5, 0.1, -10000, 10000, true, 0.03); -const EMCALClusterDefinition kV3Variation1(ClusterAlgorithm_t::kV3, 11, 1, "kV3Variation1", 0.5, 0.1, -10000, 10000, true, 0.); -const EMCALClusterDefinition kV3Variation2(ClusterAlgorithm_t::kV3, 12, 1, "kV3Variation2", 0.5, 0.1, -10000, 10000, false, 0.); +const EMCALClusterDefinition kV3MostSplit(ClusterAlgorithm_t::kV3, 11, 1, "kV3MostSplit", 0.5, 0.1, -10000, 10000, true, 0.); +const EMCALClusterDefinition kV3LowSeed(ClusterAlgorithm_t::kV3, 12, 1, "kV3LowSeed", 0.3, 0.1, -10000, 10000, true, 0.03); +const EMCALClusterDefinition kV3MostSplitLowSeed(ClusterAlgorithm_t::kV3, 13, 1, "kV3MostSplitLowSeed", 0.3, 0.1, -10000, 10000, true, 0.); +const EMCALClusterDefinition kV3StrictTime(ClusterAlgorithm_t::kV3, 20, 1, "kV3StrictTime", 0.5, 0.1, -500, 500, true, 0.03); +const EMCALClusterDefinition kV3StricterTime(ClusterAlgorithm_t::kV3, 21, 1, "kV3StricterTime", 0.5, 0.1, -100, 100, true, 0.03); +const EMCALClusterDefinition kV3MostStrictTime(ClusterAlgorithm_t::kV3, 22, 1, "kV3MostStrictTime", 0.5, 0.1, -50, 50, true, 0.03); /// \brief function returns EMCALClusterDefinition for the given name /// \param name name of the cluster definition /// \return EMCALClusterDefinition for the given name const EMCALClusterDefinition getClusterDefinitionFromString(const std::string& clusterDefinitionName) { - if (clusterDefinitionName == "kV1Default") { - return kV1Default; - } else if (clusterDefinitionName == "kV1Variation1") { - return kV1Variation1; - } else if (clusterDefinitionName == "kV1Variation2") { - return kV1Variation2; + if (clusterDefinitionName == "kV3NoSplit") { + return kV3NoSplit; + } else if (clusterDefinitionName == "kV3NoSplitLowSeed") { + return kV3NoSplitLowSeed; + } else if (clusterDefinitionName == "kV3NoSplitLowerSeed") { + return kV3NoSplitLowerSeed; } else if (clusterDefinitionName == "kV3Default") { return kV3Default; - } else if (clusterDefinitionName == "kV3Variation1") { - return kV3Variation1; - } else if (clusterDefinitionName == "kV3Variation2") { - return kV3Variation2; + } else if (clusterDefinitionName == "kV3MostSplit") { + return kV3MostSplit; + } else if (clusterDefinitionName == "kV3LowSeed") { + return kV3LowSeed; + } else if (clusterDefinitionName == "kV3MostSplitLowSeed") { + return kV3MostSplitLowSeed; + } else if (clusterDefinitionName == "kV3StrictTime") { + return kV3StrictTime; + } else if (clusterDefinitionName == "kV3StricterTime") { + return kV3StricterTime; + } else if (clusterDefinitionName == "kV3MostStrictTime") { + return kV3MostStrictTime; } else { throw std::invalid_argument("Cluster definition name not recognized"); } diff --git a/PWGJE/DataModel/GammaJetAnalysisTree.h b/PWGJE/DataModel/GammaJetAnalysisTree.h new file mode 100644 index 00000000000..beb927f381c --- /dev/null +++ b/PWGJE/DataModel/GammaJetAnalysisTree.h @@ -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. + +/// +/// \brief Table definitions for gamma-jet analyses +/// +/// \author Florian Jonas + +#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/Jet.h" + +namespace o2::aod +{ + +namespace gjevent +{ // TODO add rho //! event index +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, float); +DECLARE_SOA_COLUMN(Centrality, centrality, float); +DECLARE_SOA_COLUMN(Rho, rho, float); +DECLARE_SOA_COLUMN(EventSel, eventSel, uint8_t); +DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); +} // namespace gjevent +DECLARE_SOA_TABLE(GjEvents, "AOD", "GJEVENT", o2::soa::Index<>, gjevent::Multiplicity, gjevent::Centrality, gjevent::Rho, gjevent::EventSel, gjevent::Alias) + +using GjEvent = GjEvents::iterator; + +namespace gjgamma +{ +DECLARE_SOA_INDEX_COLUMN(GjEvent, gjevent); //! event index +DECLARE_SOA_COLUMN(Energy, energy, float); //! cluster energy (GeV) +DECLARE_SOA_COLUMN(Eta, eta, float); //! cluster pseudorapidity (calculated using vertex) +DECLARE_SOA_COLUMN(Phi, phi, float); //! cluster azimuthal angle (calculated using vertex) +DECLARE_SOA_COLUMN(M02, m02, float); //! shower shape long axis +DECLARE_SOA_COLUMN(M20, m20, float); //! shower shape short axis +DECLARE_SOA_COLUMN(NCells, nCells, ushort); //! number of cells in cluster +DECLARE_SOA_COLUMN(Time, time, float); //! cluster time (ns) +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(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 +DECLARE_SOA_COLUMN(TMtrackP, tmtrackp, float); //! track momentum of closest match, -1 if no match found +} // namespace gjgamma +DECLARE_SOA_TABLE(GjGammas, "AOD", "GJGAMMA", + gjgamma::GjEventId, gjgamma::Energy, 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 +{ +DECLARE_SOA_INDEX_COLUMN(GjEvent, gjevent); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Energy, energy, float); +DECLARE_SOA_COLUMN(Mass, mass, float); +DECLARE_SOA_COLUMN(Area, area, float); +DECLARE_SOA_COLUMN(NConstituents, nConstituents, ushort); +} // namespace gjchjet +DECLARE_SOA_TABLE(GjChargedJets, "AOD", "GJCHJET", gjchjet::GjEventId, gjchjet::Pt, gjchjet::Eta, gjchjet::Phi, gjchjet::Energy, gjchjet::Mass, gjchjet::Area, gjchjet::NConstituents) +} // namespace o2::aod + +#endif // PWGJE_DATAMODEL_GAMMAJETANALYSISTREE_H_ diff --git a/PWGJE/DataModel/Jet.h b/PWGJE/DataModel/Jet.h index 33b8fdb4320..b3356fcc4a4 100644 --- a/PWGJE/DataModel/Jet.h +++ b/PWGJE/DataModel/Jet.h @@ -61,7 +61,6 @@ DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //! DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! absolute p [](float pt, float eta) -> float { return pt * std::cosh(eta); }); } // namespace jet -} // namespace o2::aod // Defines the jet table definition #define DECLARE_JET_TABLE(_collision_name_, _jet_type_, _name_, _description_) \ @@ -176,8 +175,6 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, //! absolute p DECLARE_JETMATCHING_TABLE(_jet_type_##EventWiseSubtracted, _jet_type_##_duplicatenumber_##EventWiseSubtracted, _shortname_ "JETEWS2" STRINGIFY(_duplicatenumber_)) \ DECLARE_JETMATCHING_TABLE(_jet_type__duplicatenumber_##EventWiseSubtracted, _jet_type_##EventWiseSubtracted, _shortname_ "JET" STRINGIFY(_duplicatenumber_) "2EWS") -namespace o2::aod -{ 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"); @@ -190,51 +187,61 @@ DECLARE_JET_TABLES_LEVELS(DielectronCharged, JTrackSub, Dielectrons, JDielectron // duplicate jet tables (added as needed for analyses) DECLARE_JET_DUPLICATE_TABLES_LEVELS(Charged, JTrackSub, HfD0Bases, HfD0PBases, "C", 1); -} // namespace o2::aod +#undef DECLARE_JET_TABLE +#undef DECLARE_CONSTITUENTS_TABLE +#undef DECLARE_JET_TABLES +#undef DECLARE_JETMATCHING_TABLE +#undef DECLARE_MCEVENTWEIGHT_TABLE +#undef DECLARE_JET_TABLES_LEVELS +#undef STRINGIFY +#undef DECLARE_JET_DUPLICATE_TABLES_LEVELS -using JetCollisions = o2::aod::JCollisions; +using JetCollisions = JCollisions; using JetCollision = JetCollisions::iterator; -using JetCollisionsMCD = o2::soa::Join; -using JetTracks = o2::aod::JTracks; -using JetTracksMCD = o2::soa::Join; -using JetTracksSub = o2::aod::JTrackSubs; -using JetClusters = o2::aod::JClusters; -using JetClustersMCD = o2::soa::Join; - -using JetMcCollisions = o2::aod::JMcCollisions; +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 JetMcCollisions = JMcCollisions; using JetMcCollision = JetMcCollisions::iterator; -using JetParticles = o2::aod::JMcParticles; - -using CollisionsD0 = o2::soa::Join; -using CandidatesD0Data = o2::soa::Join; -using CandidatesD0MCD = o2::soa::Join; -using JetTracksSubD0 = o2::aod::JTrackD0Subs; -using McCollisionsD0 = o2::soa::Join; -using CandidatesD0MCP = o2::soa::Join; - -using CollisionsLc = o2::soa::Join; -using CandidatesLcData = o2::soa::Join; -using CandidatesLcMCD = o2::soa::Join; -using JetTracksSubLc = o2::aod::JTrackLcSubs; -using McCollisionsLc = o2::soa::Join; -using CandidatesLcMCP = o2::soa::Join; - -using CandidatesBplusData = o2::soa::Join; -using CandidatesBplusMCD = o2::soa::Join; -using JetTracksSubBplus = o2::aod::JTrackBplusSubs; -using CandidatesBplusMCP = o2::soa::Join; - -using CandidatesV0Data = o2::soa::Join; -using CandidatesV0MCD = o2::soa::Join; -// using V0Daughters = o2::aod::DauTrackExtras; -using McCollisionsV0 = o2::soa::Join; -using CandidatesV0MCP = o2::soa::Join; - -using CollisionsDielectron = o2::soa::Join; -using CandidatesDielectronData = o2::soa::Join; -using CandidatesDielectronMCD = o2::soa::Join; -using JetTracksSubDielectron = o2::aod::JTrackDielectronSubs; -using McCollisionsDielectron = o2::soa::Join; -using CandidatesDielectronMCP = o2::soa::Join; +using JetParticles = JMcParticles; + +using CollisionsD0 = o2::soa::Join; +using CandidatesD0Data = o2::soa::Join; +using CandidatesD0MCD = o2::soa::Join; +using JetTracksSubD0 = JTrackD0Subs; +using McCollisionsD0 = o2::soa::Join; +using CandidatesD0MCP = o2::soa::Join; + +using CollisionsLc = o2::soa::Join; +using CandidatesLcData = o2::soa::Join; +using CandidatesLcMCD = o2::soa::Join; +using JetTracksSubLc = JTrackLcSubs; +using McCollisionsLc = o2::soa::Join; +using CandidatesLcMCP = o2::soa::Join; + +using CandidatesBplusData = o2::soa::Join; +using CandidatesBplusMCD = o2::soa::Join; +using JetTracksSubBplus = JTrackBplusSubs; +using CandidatesBplusMCP = 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; + +using CollisionsDielectron = o2::soa::Join; +using CandidatesDielectronData = o2::soa::Join; +using CandidatesDielectronMCD = o2::soa::Join; +using JetTracksSubDielectron = JTrackDielectronSubs; +using McCollisionsDielectron = o2::soa::Join; +using CandidatesDielectronMCP = o2::soa::Join; + +} // namespace o2::aod #endif // PWGJE_DATAMODEL_JET_H_ diff --git a/PWGJE/DataModel/JetReducedData.h b/PWGJE/DataModel/JetReducedData.h index b5439774663..77aa55d9c29 100644 --- a/PWGJE/DataModel/JetReducedData.h +++ b/PWGJE/DataModel/JetReducedData.h @@ -32,31 +32,33 @@ DECLARE_SOA_INDEX_COLUMN(BC, bc); DECLARE_SOA_COLUMN(RunNumber, runNumber, int); DECLARE_SOA_COLUMN(GlobalBC, globalBC, uint64_t); DECLARE_SOA_COLUMN(Timestamp, timestamp, uint64_t); +DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); +DECLARE_SOA_BITMAP_COLUMN(Selection, selection, 64); +DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVX, readCountsWithTVX, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndNoTFB, readCountsWithTVXAndNoTFB, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndNoTFBAndNoITSROFB, readCountsWithTVXAndNoTFBAndNoITSROFB, std::vector); } // namespace jbc -DECLARE_SOA_TABLE(JBCs, "AOD", "JBC", - o2::soa::Index<>, - jbc::RunNumber, - jbc::GlobalBC, - jbc::Timestamp); +DECLARE_SOA_TABLE_STAGED(JBCs, "JBC", + o2::soa::Index<>, + jbc::RunNumber, + jbc::GlobalBC, + jbc::Timestamp, + jbc::Alias, + jbc::Selection); using JBC = JBCs::iterator; - -DECLARE_SOA_TABLE(StoredJBCs, "AOD1", "JBC", - o2::soa::Index<>, - jbc::RunNumber, - jbc::GlobalBC, - jbc::Timestamp, - o2::soa::Marker<1>); - using StoredJBC = StoredJBCs::iterator; -DECLARE_SOA_TABLE(JBCPIs, "AOD", "JBCPI", - jbc::BCId); +DECLARE_SOA_TABLE_STAGED(JBCPIs, "JBCPI", + jbc::BCId); -DECLARE_SOA_TABLE(StoredJBCPIs, "AOD1", "JBCPI", - jbc::BCId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(BCCounts, "BCCOUNT", + jbc::ReadCounts, + jbc::ReadCountsWithTVX, + jbc::ReadCountsWithTVXAndNoTFB, + jbc::ReadCountsWithTVXAndNoTFBAndNoITSROFB); namespace jcollision { @@ -67,86 +69,78 @@ 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(EventSel, eventSel, uint8_t); +DECLARE_SOA_COLUMN(EventSel, eventSel, uint16_t); DECLARE_SOA_BITMAP_COLUMN(Alias, alias, 32); +DECLARE_SOA_COLUMN(TrackOccupancyInTimeRange, trackOccupancyInTimeRange, int); +DECLARE_SOA_COLUMN(TriggerSel, triggerSel, uint64_t); DECLARE_SOA_COLUMN(ChargedTriggerSel, chargedTriggerSel, uint8_t); DECLARE_SOA_COLUMN(FullTriggerSel, fullTriggerSel, uint32_t); DECLARE_SOA_COLUMN(ChargedHFTriggerSel, chargedHFTriggerSel, uint8_t); DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); -DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector); -DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVX, readCountsWithTVX, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel8, readCountsWithTVXAndZVertexAndSel8, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel8Full, readCountsWithTVXAndZVertexAndSel8Full, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel8FullPbPb, readCountsWithTVXAndZVertexAndSel8FullPbPb, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelMC, readCountsWithTVXAndZVertexAndSelMC, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelMCFull, readCountsWithTVXAndZVertexAndSelMCFull, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelMCFullPbPb, readCountsWithTVXAndZVertexAndSelMCFullPbPb, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelUnanchoredMC, readCountsWithTVXAndZVertexAndSelUnanchoredMC, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSelTVX, readCountsWithTVXAndZVertexAndSelTVX, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel7, readCountsWithTVXAndZVertexAndSel7, std::vector); +DECLARE_SOA_COLUMN(ReadCountsWithTVXAndZVertexAndSel7KINT7, readCountsWithTVXAndZVertexAndSel7KINT7, std::vector); +DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); +DECLARE_SOA_COLUMN(IsEMCALReadout, isEmcalReadout, bool); } // namespace jcollision -DECLARE_SOA_TABLE(JCollisions, "AOD", "JCOLLISION", - o2::soa::Index<>, - jcollision::PosX, - jcollision::PosY, - jcollision::PosZ, - jcollision::Multiplicity, - jcollision::Centrality, - jcollision::EventSel, - jcollision::Alias); +DECLARE_SOA_TABLE_STAGED(JCollisions, "JCOLLISION", + o2::soa::Index<>, + jcollision::PosX, + jcollision::PosY, + jcollision::PosZ, + jcollision::Multiplicity, + jcollision::Centrality, + jcollision::TrackOccupancyInTimeRange, + jcollision::EventSel, + jcollision::Alias, + jcollision::TriggerSel); using JCollision = JCollisions::iterator; - -DECLARE_SOA_TABLE(StoredJCollisions, "AOD1", "JCOLLISION", - o2::soa::Index<>, - jcollision::PosX, - jcollision::PosY, - jcollision::PosZ, - jcollision::Multiplicity, - jcollision::Centrality, - jcollision::EventSel, - jcollision::Alias, - o2::soa::Marker<1>); - using StoredJCollision = StoredJCollisions::iterator; -DECLARE_SOA_TABLE(JCollisionPIs, "AOD", "JCOLLISIONPI", - jcollision::CollisionId); +DECLARE_SOA_TABLE_STAGED(JEMCCollisionLbs, "JEMCCOLLISIONLB", + jcollision::IsAmbiguous, + jcollision::IsEMCALReadout); +using JEMCCollisionLb = JEMCCollisionLbs::iterator; +using StoredJEMCCollisionLb = StoredJEMCCollisionLbs::iterator; + +DECLARE_SOA_TABLE_STAGED(JCollisionPIs, "JCOLLISIONPI", + jcollision::CollisionId); -DECLARE_SOA_TABLE(StoredJCollisionPIs, "AOD1", "JCOLLISIONPI", - jcollision::CollisionId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JCollisionBCs, "JCOLLISIONBC", + jcollision::JBCId); DECLARE_SOA_TABLE(JChTrigSels, "AOD", "JCHTRIGSEL", jcollision::ChargedTriggerSel); -DECLARE_SOA_TABLE(StoredJChTrigSels, "AOD1", "JCHTRIGSEL", - jcollision::ChargedTriggerSel, - o2::soa::Marker<1>); - DECLARE_SOA_TABLE(JFullTrigSels, "AOD", "JFULLTRIGSEL", jcollision::FullTriggerSel); -DECLARE_SOA_TABLE(StoredJFullTrigSels, "AOD1", "JFULLTRIGSEL", - jcollision::FullTriggerSel, - o2::soa::Marker<1>); - DECLARE_SOA_TABLE(JChHFTrigSels, "AOD", "JCHHFTRIGSEL", jcollision::ChargedHFTriggerSel); -DECLARE_SOA_TABLE(StoredJChHFTrigSels, "AOD1", "JCHHFTRIGSEL", - jcollision::ChargedHFTriggerSel, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JCollisionBCs, "AOD", "JCOLLISIONBC", - jcollision::JBCId); - -DECLARE_SOA_TABLE(StoredJCollisionBCs, "AOD1", "JCOLLISIONBC", - jcollision::JBCId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(CollisionCounts, "AOD", "COLLCOUNT", - jcollision::ReadCounts, - jcollision::ReadSelectedCounts, - jcollision::WrittenCounts); - -DECLARE_SOA_TABLE(StoredCollisionCounts, "AOD1", "COLLCOUNT", - jcollision::ReadCounts, - jcollision::ReadSelectedCounts, - jcollision::WrittenCounts, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(CollisionCounts, "COLLCOUNT", + jcollision::ReadCounts, + jcollision::ReadCountsWithTVX, + jcollision::ReadCountsWithTVXAndZVertexAndSel8, + jcollision::ReadCountsWithTVXAndZVertexAndSel8Full, + jcollision::ReadCountsWithTVXAndZVertexAndSel8FullPbPb, + jcollision::ReadCountsWithTVXAndZVertexAndSelMC, + jcollision::ReadCountsWithTVXAndZVertexAndSelMCFull, + jcollision::ReadCountsWithTVXAndZVertexAndSelMCFullPbPb, + jcollision::ReadCountsWithTVXAndZVertexAndSelUnanchoredMC, + jcollision::ReadCountsWithTVXAndZVertexAndSelTVX, + jcollision::ReadCountsWithTVXAndZVertexAndSel7, + jcollision::ReadCountsWithTVXAndZVertexAndSel7KINT7); namespace jmccollision { @@ -156,43 +150,26 @@ DECLARE_SOA_COLUMN(PosY, posY, float); DECLARE_SOA_COLUMN(PosZ, posZ, float); DECLARE_SOA_COLUMN(Weight, weight, float); } // namespace jmccollision -DECLARE_SOA_TABLE(JMcCollisions, "AOD", "JMCCOLLISION", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - jmccollision::Weight); +DECLARE_SOA_TABLE_STAGED(JMcCollisions, "JMCCOLLISION", + o2::soa::Index<>, + jmccollision::PosX, + jmccollision::PosY, + jmccollision::PosZ, + jmccollision::Weight); using JMcCollision = JMcCollisions::iterator; - -DECLARE_SOA_TABLE(StoredJMcCollisions, "AOD1", "JMCCOLLISION", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - jmccollision::Weight, - o2::soa::Marker<1>); - using StoredJMcCollision = StoredJMcCollisions::iterator; -DECLARE_SOA_TABLE(JMcCollisionPIs, "AOD", "JMCCOLLISIONPI", - jmccollision::McCollisionId); - -DECLARE_SOA_TABLE(StoredJMcCollisionPIs, "AOD1", "JMCCOLLISIONPI", - jmccollision::McCollisionId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JMcCollisionPIs, "JMCCOLLISIONPI", + jmccollision::McCollisionId); namespace jmccollisionlb { DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); } -DECLARE_SOA_TABLE(JMcCollisionLbs, "AOD", "JMCCOLLISIONLB", - jmccollisionlb::JMcCollisionId); - -DECLARE_SOA_TABLE(StoredJMcCollisionLbs, "AOD1", "JMCCOLLISIONLB", - jmccollisionlb::JMcCollisionId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JMcCollisionLbs, "JMCCOLLISIONLB", + jmccollisionlb::JMcCollisionId); namespace jtrack { @@ -201,8 +178,14 @@ DECLARE_SOA_INDEX_COLUMN(Track, track); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); -DECLARE_SOA_COLUMN(DCAXY, dcaXY, float); +DECLARE_SOA_COLUMN(DCAX, dcaX, float); +DECLARE_SOA_COLUMN(DCAY, dcaY, float); DECLARE_SOA_COLUMN(DCAZ, dcaZ, float); +DECLARE_SOA_COLUMN(DCAXY, dcaXY, float); +DECLARE_SOA_COLUMN(DCAXYZ, dcaXYZ, float); +DECLARE_SOA_COLUMN(SigmaDCAZ, sigmadcaZ, float); +DECLARE_SOA_COLUMN(SigmaDCAXY, sigmadcaXY, float); +DECLARE_SOA_COLUMN(SigmaDCAXYZ, sigmadcaXYZ, float); DECLARE_SOA_COLUMN(Sigma1Pt, sigma1Pt, float); DECLARE_SOA_COLUMN(TrackSel, trackSel, uint8_t); DECLARE_SOA_DYNAMIC_COLUMN(Px, px, @@ -219,56 +202,48 @@ DECLARE_SOA_DYNAMIC_COLUMN(Sign, sign, [](uint8_t trackSel) -> int { if (trackSel & (1 << jetderiveddatautilities::JTrackSel::trackSign)){ return 1;} else{return -1;} }); } // namespace jtrack -DECLARE_SOA_TABLE(JTracks, "AOD", "JTRACK", - o2::soa::Index<>, - jtrack::JCollisionId, - jtrack::Pt, - jtrack::Eta, - jtrack::Phi, - jtrack::TrackSel, - jtrack::Px, - jtrack::Py, - jtrack::Pz, - jtrack::P, - jtrack::Energy, - jtrack::Sign); +DECLARE_SOA_TABLE_STAGED(JTracks, "JTRACK", + o2::soa::Index<>, + jtrack::JCollisionId, + jtrack::Pt, + jtrack::Eta, + jtrack::Phi, + jtrack::TrackSel, + jtrack::Px, + jtrack::Py, + jtrack::Pz, + jtrack::P, + jtrack::Energy, + jtrack::Sign); using JTrack = JTracks::iterator; - -DECLARE_SOA_TABLE(StoredJTracks, "AOD1", "JTRACK", - o2::soa::Index<>, - jtrack::JCollisionId, - jtrack::Pt, - jtrack::Eta, - jtrack::Phi, - jtrack::TrackSel, - jtrack::Px, - jtrack::Py, - jtrack::Pz, - jtrack::P, - jtrack::Energy, - jtrack::Sign, - o2::soa::Marker<1>); - using StoredJTrack = StoredJTracks::iterator; -DECLARE_SOA_TABLE(JTrackExtras, "AOD", "JTRACKEXTRA", - jtrack::DCAXY, - jtrack::DCAZ, - jtrack::Sigma1Pt); - -DECLARE_SOA_TABLE(StoredJTrackExtras, "AOD1", "JTRACKEXTRA", - jtrack::DCAXY, - jtrack::DCAZ, - jtrack::Sigma1Pt, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JTrackPIs, "AOD", "JTRACKPI", - jtrack::TrackId); +DECLARE_SOA_TABLE_STAGED(JTrackExtras, "JTRACKEXTRA", + jtrack::DCAX, + jtrack::DCAY, + jtrack::DCAZ, + jtrack::DCAXY, + jtrack::DCAXYZ, + jtrack::SigmaDCAZ, + jtrack::SigmaDCAXY, + jtrack::SigmaDCAXYZ, + jtrack::Sigma1Pt); + +DECLARE_SOA_TABLE_STAGED(JTrackPIs, "JTRACKPI", + jtrack::TrackId); + +namespace jemctrack +{ +DECLARE_SOA_INDEX_COLUMN(JTrack, track); +DECLARE_SOA_COLUMN(EtaEMCAL, etaEmcal, float); +DECLARE_SOA_COLUMN(PhiEMCAL, phiEmcal, float); +} // namespace jemctrack -DECLARE_SOA_TABLE(StoredJTrackPIs, "AOD1", "JTRACKPI", - jtrack::TrackId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JEMCTracks, "JEMCTrack", + jemctrack::JTrackId, + jemctrack::EtaEMCAL, + jemctrack::PhiEMCAL); namespace jmcparticle { @@ -297,69 +272,39 @@ DECLARE_SOA_DYNAMIC_COLUMN(Energy, energy, [](float e) -> float { return e; }); } // namespace jmcparticle -DECLARE_SOA_TABLE(JMcParticles, "AOD", "JMCPARTICLE", - o2::soa::Index<>, - jmcparticle::JMcCollisionId, - jmcparticle::Pt, - jmcparticle::Eta, - jmcparticle::Phi, - jmcparticle::Y, - jmcparticle::E, - jmcparticle::PdgCode, - jmcparticle::GenStatusCode, - jmcparticle::HepMCStatusCode, - jmcparticle::IsPhysicalPrimary, - jmcparticle::MothersIds, - jmcparticle::DaughtersIdSlice, - jmcparticle::Px, - jmcparticle::Py, - jmcparticle::Pz, - jmcparticle::P, - jmcparticle::Energy); +DECLARE_SOA_TABLE_STAGED(JMcParticles, "JMCPARTICLE", + o2::soa::Index<>, + jmcparticle::JMcCollisionId, + jmcparticle::Pt, + jmcparticle::Eta, + jmcparticle::Phi, + jmcparticle::Y, + jmcparticle::E, + jmcparticle::PdgCode, + jmcparticle::GenStatusCode, + jmcparticle::HepMCStatusCode, + jmcparticle::IsPhysicalPrimary, + jmcparticle::MothersIds, + jmcparticle::DaughtersIdSlice, + jmcparticle::Px, + jmcparticle::Py, + jmcparticle::Pz, + jmcparticle::P, + jmcparticle::Energy); using JMcParticle = JMcParticles::iterator; - -DECLARE_SOA_TABLE(StoredJMcParticles, "AOD1", "JMCPARTICLE", - o2::soa::Index<>, - jmcparticle::JMcCollisionId, - jmcparticle::Pt, - jmcparticle::Eta, - jmcparticle::Phi, - jmcparticle::Y, - jmcparticle::E, - jmcparticle::PdgCode, - jmcparticle::GenStatusCode, - jmcparticle::HepMCStatusCode, - jmcparticle::IsPhysicalPrimary, - jmcparticle::MothersIds, - jmcparticle::DaughtersIdSlice, - jmcparticle::Px, - jmcparticle::Py, - jmcparticle::Pz, - jmcparticle::P, - jmcparticle::Energy, - o2::soa::Marker<1>); - using StoredJMcParticle = StoredJMcParticles::iterator; -DECLARE_SOA_TABLE(JMcParticlePIs, "AOD", "JMCPARTICLEPI", - jmcparticle::McParticleId); - -DECLARE_SOA_TABLE(StoredJMcParticlePIs, "AOD1", "JMCPARTICLEPI", - jmcparticle::McParticleId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JMcParticlePIs, "JMCPARTICLEPI", + jmcparticle::McParticleId); namespace jmctracklb { DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } -DECLARE_SOA_TABLE(JMcTrackLbs, "AOD", "JMCTRACKLB", //! Table joined to the track table containing the MC index - jmctracklb::JMcParticleId); - -DECLARE_SOA_TABLE(StoredJMcTrackLbs, "AOD1", "JMCTRACKLB", //! Table joined to the track table containing the MC index - jmctracklb::JMcParticleId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JMcTrackLbs, "JMCTRACKLB", //! Table joined to the track table containing the MC index + jmctracklb::JMcParticleId); namespace jcluster { @@ -387,38 +332,21 @@ DECLARE_SOA_COLUMN(SubleadingCellNumber, subleadingCellNumber, int); //! energ } // namespace jcluster -DECLARE_SOA_TABLE(JClusters, "AOD", "JCLUSTER", //! - o2::soa::Index<>, jcluster::JCollisionId, jcluster::ID, jcluster::Energy, - jcluster::CoreEnergy, jcluster::RawEnergy, jcluster::Eta, jcluster::Phi, - jcluster::M02, jcluster::M20, jcluster::NCells, jcluster::Time, - jcluster::IsExotic, jcluster::DistanceToBadChannel, jcluster::NLM, jcluster::Definition, - jcluster::LeadingCellEnergy, jcluster::SubleadingCellEnergy, jcluster::LeadingCellNumber, jcluster::SubleadingCellNumber); +DECLARE_SOA_TABLE_STAGED(JClusters, "JCLUSTER", //! + o2::soa::Index<>, jcluster::JCollisionId, jcluster::ID, jcluster::Energy, + jcluster::CoreEnergy, jcluster::RawEnergy, jcluster::Eta, jcluster::Phi, + jcluster::M02, jcluster::M20, jcluster::NCells, jcluster::Time, + jcluster::IsExotic, jcluster::DistanceToBadChannel, jcluster::NLM, jcluster::Definition, + jcluster::LeadingCellEnergy, jcluster::SubleadingCellEnergy, jcluster::LeadingCellNumber, jcluster::SubleadingCellNumber); using JCluster = JClusters::iterator; - -DECLARE_SOA_TABLE(StoredJClusters, "AOD1", "JCLUSTER", - o2::soa::Index<>, jcluster::JCollisionId, jcluster::ID, jcluster::Energy, - jcluster::CoreEnergy, jcluster::RawEnergy, jcluster::Eta, jcluster::Phi, - jcluster::M02, jcluster::M20, jcluster::NCells, jcluster::Time, - jcluster::IsExotic, jcluster::DistanceToBadChannel, jcluster::NLM, jcluster::Definition, - jcluster::LeadingCellEnergy, jcluster::SubleadingCellEnergy, jcluster::LeadingCellNumber, jcluster::SubleadingCellNumber, - o2::soa::Marker<1>); - using StoredJCluster = StoredJClusters::iterator; -DECLARE_SOA_TABLE(JClusterPIs, "AOD", "JCLUSTERPI", - jcluster::EMCALClusterId); - -DECLARE_SOA_TABLE(StoredJClusterPIs, "AOD1", "JCLUSTERPI", - jcluster::EMCALClusterId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JClusterPIs, "JCLUSTERPI", + jcluster::EMCALClusterId); -DECLARE_SOA_TABLE(JClusterTracks, "AOD", "JCLUSTERTRACK", //! - jcluster::JTrackIds); - -DECLARE_SOA_TABLE(StoredJClusterTracks, "AOD1", "JCLUSTERTRACK", //! - jcluster::JTrackIds, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JClusterTracks, "JCLUSTERTRACK", //! + jcluster::JTrackIds); namespace jmcclusterlb { @@ -426,12 +354,8 @@ DECLARE_SOA_ARRAY_INDEX_COLUMN(JMcParticle, mcParticle); DECLARE_SOA_COLUMN(AmplitudeA, amplitudeA, std::vector); } // namespace jmcclusterlb -DECLARE_SOA_TABLE(JMcClusterLbs, "AOD", "JMCCLUSTERLB", //! - jmcclusterlb::JMcParticleIds, jmcclusterlb::AmplitudeA); - -DECLARE_SOA_TABLE(StoredJMcClusterLbs, "AOD1", "JMCCLUSTERLB", //! - jmcclusterlb::JMcParticleIds, jmcclusterlb::AmplitudeA, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JMcClusterLbs, "JMCCLUSTERLB", //! + jmcclusterlb::JMcParticleIds, jmcclusterlb::AmplitudeA); namespace jdummy { @@ -439,14 +363,9 @@ namespace jdummy DECLARE_SOA_COLUMN(Dummy, dummy, bool); } // namespace jdummy -DECLARE_SOA_TABLE(JDummys, "AOD", "JDUMMY", - o2::soa::Index<>, - jdummy::Dummy); - -DECLARE_SOA_TABLE(StoredJDummys, "AOD1", "JDUMMY", - o2::soa::Index<>, - jdummy::Dummy, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JDummys, "JDUMMY", + o2::soa::Index<>, + jdummy::Dummy); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetReducedDataDQ.h b/PWGJE/DataModel/JetReducedDataDQ.h index b4f59554b40..8641b3d612e 100644 --- a/PWGJE/DataModel/JetReducedDataDQ.h +++ b/PWGJE/DataModel/JetReducedDataDQ.h @@ -26,68 +26,32 @@ namespace o2::aod { -DECLARE_SOA_TABLE(JDielectronMcCollisions, "AOD", "JDIELMCCOLL", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - o2::soa::Marker<3>); - -using JMcCollision = JMcCollisions::iterator; - -DECLARE_SOA_TABLE(StoredJDielectronMcCollisions, "AOD1", "JDIELMCCOLL", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - o2::soa::Marker<4>); +DECLARE_SOA_TABLE_STAGED(JDielectronMcCollisions, "JDIELMCCOLL", + o2::soa::Index<>, + jmccollision::PosX, + jmccollision::PosY, + jmccollision::PosZ); namespace jdielectronindices { DECLARE_SOA_INDEX_COLUMN(JCollision, collision); -DECLARE_SOA_INDEX_COLUMN(JDielectronMcCollision, dielectronmccollision); +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 -namespace dielectroncollisioncounter -{ -DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); -DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector); -DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector); -} // namespace dielectroncollisioncounter - -DECLARE_SOA_TABLE(JDielectronCollisionIds, "AOD", "JDIELCOLLID", - jdielectronindices::JCollisionId); +DECLARE_SOA_TABLE_STAGED(JDielectronCollisionIds, "JDIELCOLLID", + jdielectronindices::JCollisionId); -DECLARE_SOA_TABLE(StoredJDielectronCollisionIds, "AOD1", "JDIELCOLLID", - jdielectronindices::JCollisionId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JDielectronMcCollisionIds, "JDIELMCCOLLID", + jdielectronindices::JMcCollisionId); -DECLARE_SOA_TABLE(JDielectronMcCollisionIds, "AOD", "JDIELMCCOLLID", - jdielectronindices::JMcCollisionId); - -DECLARE_SOA_TABLE(StoredJDielectronMcCollisionIds, "AOD1", "JDIELMCCOLLID", - jdielectronindices::JMcCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JDielectronIds, "AOD", "JDIELID", - jdielectronindices::JCollisionId, - jdielectronindices::Prong0Id, - jdielectronindices::Prong1Id); - -DECLARE_SOA_TABLE(StoredJDielectronIds, "AOD1", "JDIELID", - jdielectronindices::JCollisionId, - jdielectronindices::Prong0Id, - jdielectronindices::Prong1Id, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(DielectronCollisionCounts, "AOD", "DIELCOLLCOUNT", - dielectroncollisioncounter::ReadCounts, - dielectroncollisioncounter::ReadSelectedCounts, - dielectroncollisioncounter::WrittenCounts); +DECLARE_SOA_TABLE_STAGED(JDielectronIds, "JDIELID", + jdielectronindices::JCollisionId, + jdielectronindices::Prong0Id, + jdielectronindices::Prong1Id); namespace jdielectronmc { @@ -115,63 +79,34 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); } // namespace jdielectronmc -DECLARE_SOA_TABLE(JDielectronMcs, "AOD", "JDIELMC", - o2::soa::Index<>, - jdielectronindices::JDielectronMcCollisionId, - jdielectronmc::Pt, - jdielectronmc::Eta, - jdielectronmc::Phi, - jdielectronmc::Y, - jdielectronmc::E, - jdielectronmc::M, - jdielectronmc::PdgCode, - jdielectronmc::GenStatusCode, - jdielectronmc::HepMCStatusCode, - jdielectronmc::IsPhysicalPrimary, - jdielectronmc::DecayFlag, - jdielectronmc::Origin, - jdielectronmc::Px, - jdielectronmc::Py, - jdielectronmc::Pz, - jdielectronmc::P); +DECLARE_SOA_TABLE_STAGED(JDielectronMcs, "JDIELMC", + o2::soa::Index<>, + jdielectronindices::JDielectronMcCollisionId, + jdielectronmc::Pt, + jdielectronmc::Eta, + jdielectronmc::Phi, + jdielectronmc::Y, + jdielectronmc::E, + jdielectronmc::M, + jdielectronmc::PdgCode, + jdielectronmc::GenStatusCode, + jdielectronmc::HepMCStatusCode, + jdielectronmc::IsPhysicalPrimary, + jdielectronmc::DecayFlag, + jdielectronmc::Origin, + jdielectronmc::Px, + jdielectronmc::Py, + jdielectronmc::Pz, + jdielectronmc::P); using JDielectronMc = JDielectronMcs::iterator; - -DECLARE_SOA_TABLE(StoredJDielectronMcs, "AOD1", "JDIELMC", - o2::soa::Index<>, - jdielectronindices::JDielectronMcCollisionId, - jdielectronmc::Pt, - jdielectronmc::Eta, - jdielectronmc::Phi, - jdielectronmc::Y, - jdielectronmc::E, - jdielectronmc::M, - jdielectronmc::PdgCode, - jdielectronmc::GenStatusCode, - jdielectronmc::HepMCStatusCode, - jdielectronmc::IsPhysicalPrimary, - jdielectronmc::DecayFlag, - jdielectronmc::Origin, - jdielectronmc::Px, - jdielectronmc::Py, - jdielectronmc::Pz, - jdielectronmc::P, - o2::soa::Marker<1>); - using StoredJDielectronMc = StoredJDielectronMcs::iterator; -DECLARE_SOA_TABLE(JDielectronMcIds, "AOD", "JDIELMCID", - jdielectronindices::JMcCollisionId, - jdielectronindices::JMcParticleId, - jdielectronmc::MothersIds, - jdielectronmc::DaughtersIdSlice); - -DECLARE_SOA_TABLE(StoredJDielectronMcIds, "AOD1", "JDIELMCID", - jdielectronindices::JMcCollisionId, - jdielectronindices::JMcParticleId, - jdielectronmc::MothersIds, - jdielectronmc::DaughtersIdSlice, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JDielectronMcIds, "JDIELMCID", + jdielectronindices::JMcCollisionId, + jdielectronindices::JMcParticleId, + jdielectronmc::MothersIds, + jdielectronmc::DaughtersIdSlice); namespace jdummydq { diff --git a/PWGJE/DataModel/JetReducedDataHF.h b/PWGJE/DataModel/JetReducedDataHF.h index 83118732cd1..1c196c173d9 100644 --- a/PWGJE/DataModel/JetReducedDataHF.h +++ b/PWGJE/DataModel/JetReducedDataHF.h @@ -35,51 +35,20 @@ DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jd0indices -namespace d0collisioncounter -{ -DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); -DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector); -DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector); -} // namespace d0collisioncounter - -DECLARE_SOA_TABLE(JD0CollisionIds, "AOD", "JD0COLLID", - jd0indices::JCollisionId); - -DECLARE_SOA_TABLE(StoredJD0CollisionIds, "AOD1", "JD0COLLID", - jd0indices::JCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JD0McCollisionIds, "AOD", "JD0MCCOLLID", - jd0indices::JMcCollisionId); - -DECLARE_SOA_TABLE(StoredJD0McCollisionIds, "AOD1", "JD0MCCOLLID", - jd0indices::JMcCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JD0Ids, "AOD", "JD0ID", - jd0indices::JCollisionId, - jd0indices::Prong0Id, - jd0indices::Prong1Id); - -DECLARE_SOA_TABLE(StoredJD0Ids, "AOD1", "JD0ID", - jd0indices::JCollisionId, - jd0indices::Prong0Id, - jd0indices::Prong1Id, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JD0PIds, "AOD", "JD0PID", - jd0indices::JMcCollisionId, - jd0indices::JMcParticleId); - -DECLARE_SOA_TABLE(StoredJD0PIds, "AOD1", "JD0PID", - jd0indices::JMcCollisionId, - jd0indices::JMcParticleId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(D0CollisionCounts, "AOD", "D0COLLCOUNT", - d0collisioncounter::ReadCounts, - d0collisioncounter::ReadSelectedCounts, - d0collisioncounter::WrittenCounts); +DECLARE_SOA_TABLE_STAGED(JD0CollisionIds, "JD0COLLID", + jd0indices::JCollisionId); + +DECLARE_SOA_TABLE_STAGED(JD0McCollisionIds, "JD0MCCOLLID", + jd0indices::JMcCollisionId); + +DECLARE_SOA_TABLE_STAGED(JD0Ids, "JD0ID", + jd0indices::JCollisionId, + jd0indices::Prong0Id, + jd0indices::Prong1Id); + +DECLARE_SOA_TABLE_STAGED(JD0PIds, "JD0PID", + jd0indices::JMcCollisionId, + jd0indices::JMcParticleId); namespace jlcindices { @@ -91,53 +60,21 @@ DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jlcindices -namespace lccollisioncounter -{ -DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); -DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector); -DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector); -} // namespace lccollisioncounter - -DECLARE_SOA_TABLE(JLcCollisionIds, "AOD", "JLCCOLLID", - jlcindices::JCollisionId); - -DECLARE_SOA_TABLE(StoredJLcCollisionIds, "AOD1", "JLCCOLLID", - jlcindices::JCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JLcMcCollisionIds, "AOD", "JLCMCCOLLID", - jlcindices::JMcCollisionId); - -DECLARE_SOA_TABLE(StoredJLcMcCollisionIds, "AOD1", "JLCMCCOLLID", - jlcindices::JMcCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JLcIds, "AOD", "JLCID", - jlcindices::JCollisionId, - jlcindices::Prong0Id, - jlcindices::Prong1Id, - jlcindices::Prong2Id); - -DECLARE_SOA_TABLE(StoredJLcIds, "AOD1", "JLCID", - jlcindices::JCollisionId, - jlcindices::Prong0Id, - jlcindices::Prong1Id, - jlcindices::Prong2Id, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JLcPIds, "AOD", "JLCPID", - jlcindices::JMcCollisionId, - jlcindices::JMcParticleId); - -DECLARE_SOA_TABLE(StoredJLcPIds, "AOD1", "JLCPID", - jlcindices::JMcCollisionId, - jlcindices::JMcParticleId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(LcCollisionCounts, "AOD", "LcCOLLCOUNT", - lccollisioncounter::ReadCounts, - lccollisioncounter::ReadSelectedCounts, - lccollisioncounter::WrittenCounts); +DECLARE_SOA_TABLE_STAGED(JLcCollisionIds, "JLCCOLLID", + jlcindices::JCollisionId); + +DECLARE_SOA_TABLE_STAGED(JLcMcCollisionIds, "JLCMCCOLLID", + jlcindices::JMcCollisionId); + +DECLARE_SOA_TABLE_STAGED(JLcIds, "JLCID", + jlcindices::JCollisionId, + jlcindices::Prong0Id, + jlcindices::Prong1Id, + jlcindices::Prong2Id); + +DECLARE_SOA_TABLE_STAGED(JLcPIds, "JLCPID", + jlcindices::JMcCollisionId, + jlcindices::JMcParticleId); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetReducedDataV0.h b/PWGJE/DataModel/JetReducedDataV0.h index 8458d739cb9..d904403b532 100644 --- a/PWGJE/DataModel/JetReducedDataV0.h +++ b/PWGJE/DataModel/JetReducedDataV0.h @@ -26,21 +26,12 @@ namespace o2::aod { -DECLARE_SOA_TABLE(JV0McCollisions, "AOD", "JV0MCCOLL", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - o2::soa::Marker<1>); - -using JMcCollision = JMcCollisions::iterator; - -DECLARE_SOA_TABLE(StoredJV0McCollisions, "AOD1", "JV0MCCOLL", - o2::soa::Index<>, - jmccollision::PosX, - jmccollision::PosY, - jmccollision::PosZ, - o2::soa::Marker<2>); +DECLARE_SOA_TABLE_STAGED(JV0McCollisions, "JV0MCCOLL", + o2::soa::Index<>, + jmccollision::PosX, + jmccollision::PosY, + jmccollision::PosZ, + o2::soa::Marker<3>); namespace jv0indices { @@ -52,43 +43,17 @@ DECLARE_SOA_INDEX_COLUMN(JMcCollision, mcCollision); DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle); } // namespace jv0indices -namespace v0collisioncounter -{ -DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector); -DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector); -DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector); -} // namespace v0collisioncounter - -DECLARE_SOA_TABLE(JV0CollisionIds, "AOD", "JV0COLLID", - jv0indices::JCollisionId); - -DECLARE_SOA_TABLE(StoredJV0CollisionIds, "AOD1", "JV0COLLID", - jv0indices::JCollisionId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(JV0McCollisionIds, "AOD", "JV0MCCOLLID", - jv0indices::JMcCollisionId); +DECLARE_SOA_TABLE_STAGED(JV0CollisionIds, "JV0COLLID", + jv0indices::JCollisionId); -DECLARE_SOA_TABLE(StoredJV0McCollisionIds, "AOD1", "JV0MCCOLLID", - jv0indices::JMcCollisionId, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JV0McCollisionIds, "JV0MCCOLLID", + jv0indices::JMcCollisionId); DECLARE_SOA_TABLE(JV0Ids, "AOD", "JV0ID", jv0indices::JCollisionId, jv0indices::PosTrackId, jv0indices::NegTrackId); -DECLARE_SOA_TABLE(StoredJV0Ids, "AOD1", "JV0ID", - jv0indices::JCollisionId, - jv0indices::PosTrackId, - jv0indices::NegTrackId, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE(V0CollisionCounts, "AOD", "V0COLLCOUNT", - v0collisioncounter::ReadCounts, - v0collisioncounter::ReadSelectedCounts, - v0collisioncounter::WrittenCounts); - namespace jv0mc { DECLARE_SOA_COLUMN(Pt, pt, float); @@ -114,61 +79,33 @@ DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float pt, float eta) -> float { return pt * std::cosh(eta); }); } // namespace jv0mc -DECLARE_SOA_TABLE(JV0Mcs, "AOD", "JV0MC", - o2::soa::Index<>, - jv0indices::JV0McCollisionId, - jv0mc::Pt, - jv0mc::Eta, - jv0mc::Phi, - jv0mc::Y, - jv0mc::E, - jv0mc::M, - jv0mc::PdgCode, - jv0mc::GenStatusCode, - jv0mc::HepMCStatusCode, - jv0mc::IsPhysicalPrimary, - jv0mc::DecayFlag, - jv0mc::Px, - jv0mc::Py, - jv0mc::Pz, - jv0mc::P); +DECLARE_SOA_TABLE_STAGED(JV0Mcs, "JV0MC", + o2::soa::Index<>, + jv0indices::JV0McCollisionId, + jv0mc::Pt, + jv0mc::Eta, + jv0mc::Phi, + jv0mc::Y, + jv0mc::E, + jv0mc::M, + jv0mc::PdgCode, + jv0mc::GenStatusCode, + jv0mc::HepMCStatusCode, + jv0mc::IsPhysicalPrimary, + jv0mc::DecayFlag, + jv0mc::Px, + jv0mc::Py, + jv0mc::Pz, + jv0mc::P); using JV0Mc = JV0Mcs::iterator; - -DECLARE_SOA_TABLE(StoredJV0Mcs, "AOD1", "JV0MC", - o2::soa::Index<>, - jv0indices::JV0McCollisionId, - jv0mc::Pt, - jv0mc::Eta, - jv0mc::Phi, - jv0mc::Y, - jv0mc::E, - jv0mc::M, - jv0mc::PdgCode, - jv0mc::GenStatusCode, - jv0mc::HepMCStatusCode, - jv0mc::IsPhysicalPrimary, - jv0mc::DecayFlag, - jv0mc::Px, - jv0mc::Py, - jv0mc::Pz, - jv0mc::P, - o2::soa::Marker<1>); - using StoredJV0Mc = StoredJV0Mcs::iterator; -DECLARE_SOA_TABLE(JV0McIds, "AOD", "JV0MCID", - jv0indices::JMcCollisionId, - jv0indices::JMcParticleId, - jv0mc::MothersIds, - jv0mc::DaughtersIdSlice); - -DECLARE_SOA_TABLE(StoredJV0McIds, "AOD1", "JV0MCID", - jv0indices::JMcCollisionId, - jv0indices::JMcParticleId, - jv0mc::MothersIds, - jv0mc::DaughtersIdSlice, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(JV0McIds, "JV0MCID", + jv0indices::JMcCollisionId, + jv0indices::JMcParticleId, + jv0mc::MothersIds, + jv0mc::DaughtersIdSlice); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetSubstructure.h b/PWGJE/DataModel/JetSubstructure.h index fb71550a942..2e5d03f46d0 100644 --- a/PWGJE/DataModel/JetSubstructure.h +++ b/PWGJE/DataModel/JetSubstructure.h @@ -32,6 +32,7 @@ namespace jetcollision 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 jetsubstructure @@ -46,6 +47,7 @@ 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); //! } // namespace jetsubstructure namespace jetoutput @@ -60,69 +62,69 @@ DECLARE_SOA_COLUMN(JetNConstituents, jetNConstituents, int); //! } // namespace jetoutput // Defines the jet substrcuture table definition -#define JETSUBSTRUCTURE_TABLE_DEF(_jet_type_, _cand_type_, _name_, _description_) \ - \ - namespace _name_##collisionoutput \ - { \ - DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ - } \ - \ - DECLARE_SOA_TABLE(_jet_type_##COs, "AOD", _description_ "CO", jetcollision::PosZ, jetcollision::Centrality, jetcollision::EventSel, _name_##collisionoutput::Dummy##_jet_type_<>); \ - using _jet_type_##CO = _jet_type_##COs::iterator; \ - \ - namespace _name_##jetoutput \ - { \ - DECLARE_SOA_INDEX_COLUMN(_jet_type_##CO, collision); \ - DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, _cand_type_, "_0"); \ - } \ - DECLARE_SOA_TABLE(_jet_type_##Os, "AOD", _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(_jet_type_##O, outputTable); \ - DECLARE_SOA_DYNAMIC_COLUMN(Dummy##_jet_type_, dummy##_jet_type_, []() -> int { return 0; }); \ - } \ - \ - DECLARE_SOA_TABLE(_jet_type_##SSs, "AOD", _description_ "SS", jetsubstructure::EnergyMother, jetsubstructure::PtLeading, jetsubstructure::PtSubLeading, jetsubstructure::Theta, jetsubstructure::NSub2DR, jetsubstructure::NSub1, jetsubstructure::NSub2, jetsubstructure::PairPt, jetsubstructure::PairEnergy, jetsubstructure::PairTheta, _name_##substructure::Dummy##_jet_type_<>); \ - DECLARE_SOA_TABLE(_jet_type_##SSOs, "AOD", _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); \ - \ - 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::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; \ using _jet_type_##SSO = _jet_type_##SSOs::iterator; // define the mathcing table definition -#define JETMATCHING_TABLE_DEF(_jet_type_, _matched_jet_type_, _name_, _description_) \ +#define JETMATCHING_TABLE_DEF(_jet_type_, _matched_jet_type_, _matched_jet_description_, _name_, _description_) \ namespace _name_##geomatched \ { \ - DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_matched_jet_type_, matchedJetGeo, int32_t, _matched_jet_type_##Os, "_geo"); \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_matched_jet_type_, matchedJetGeo, int32_t, _matched_jet_type_##Os, _matched_jet_description_ "OS", "_geo"); \ } \ \ namespace _name_##ptmatched \ { \ - DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_matched_jet_type_, matchedJetPt, int32_t, _matched_jet_type_##Os, "_pt"); \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_matched_jet_type_, matchedJetPt, int32_t, _matched_jet_type_##Os, _matched_jet_description_ "OS", "_pt"); \ } \ \ namespace _name_##candmatched \ { \ - DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_matched_jet_type_, matchedJetCand, int32_t, _matched_jet_type_##Os, "_hf"); \ + DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL_CUSTOM(_matched_jet_type_, matchedJetCand, int32_t, _matched_jet_type_##Os, _matched_jet_description_ "OS", "_hf"); \ } \ 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_, _cand_type_data_, _cand_type_ewsdata_, _cand_type_mcd_, _hfparticle_type_, _description_) \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##Jet, _cand_type_data_, _jet_type_##jet, _description_ "JET") \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##EWSJet, _cand_type_ewsdata_, _jet_type_##ewsjet, _description_ "EWSJET") \ - JETMATCHING_TABLE_DEF(_jet_type_##Jet, _jet_type_##EWSJet, _jet_type_##jet, _description_ "JET") \ - JETMATCHING_TABLE_DEF(_jet_type_##EWSJet, _jet_type_##Jet, _jet_type_##ewsjet, _description_ "EWSJET") \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCDJet, _cand_type_mcd_, _jet_type_##mcdjet, _description_ "MCDJET") \ - JETSUBSTRUCTURE_TABLE_DEF(_jet_type_##MCPJet, _hfparticle_type_, _jet_type_##mcpjet, _description_ "MCPJET") \ - JETMATCHING_TABLE_DEF(_jet_type_##MCDJet, _jet_type_##MCPJet, _jet_type_##mcdjet, _description_ "MCDJET") \ - JETMATCHING_TABLE_DEF(_jet_type_##MCPJet, _jet_type_##MCDJet, _jet_type_##mcpjet, _description_ "MCPJET") +#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, CJetCOs, CEWSJetCOs, CMCDJetCOs, CMCPJetCOs, "C"); -JETSUBSTRUCTURE_TABLES_DEF(D0C, HfD0Bases, HfD0Bases, HfD0Bases, HfD0PBases, "D0C"); -JETSUBSTRUCTURE_TABLES_DEF(LcC, Hf3PBases, Hf3PBases, Hf3PBases, Hf3PPBases, "LCC"); -JETSUBSTRUCTURE_TABLES_DEF(BplusC, HfD0Bases, HfD0Bases, HfD0Bases, HfD0PBases, "BPLUSC"); -JETSUBSTRUCTURE_TABLES_DEF(DielectronC, Dielectrons, Dielectrons, Dielectrons, JDielectronMcs, "DIELC"); +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", Hf3PBases, "HF3PBASE", Hf3PBases, "HF3PBASE", Hf3PBases, "HF3PBASE", Hf3PPBases, "HF3PPBASE"); +JETSUBSTRUCTURE_TABLES_DEF(BplusC, "BPLUSC", HfD0Bases, "HFD0BASE", HfD0Bases, "HFD0BASE", HfD0Bases, "HFD0BASE", HfD0PBases, "HFD0PBASE"); +JETSUBSTRUCTURE_TABLES_DEF(DielectronC, "DIELC", Dielectrons, "RTDIELECTRON", Dielectrons, "RTDIELECTRON", Dielectrons, "RTDIELECTRON", JDielectronMcs, "JDIELMC"); } // namespace o2::aod diff --git a/PWGJE/DataModel/JetSubtraction.h b/PWGJE/DataModel/JetSubtraction.h index 639049ea81a..f789d18637a 100644 --- a/PWGJE/DataModel/JetSubtraction.h +++ b/PWGJE/DataModel/JetSubtraction.h @@ -63,33 +63,32 @@ DECLARE_SOA_INDEX_COLUMN_FULL(Candidate, candidate, int, Dielectrons, "_0"); DECLARE_SOA_TABLE(BkgChargedRhos, "AOD", "BkgCRho", o2::soa::Index<>, - bkgcharged::JCollisionId, bkgrho::Rho, bkgrho::RhoM); DECLARE_SOA_TABLE(BkgD0Rhos, "AOD", "BkgD0Rho", o2::soa::Index<>, - bkgd0::CandidateId, bkgrho::Rho, - bkgrho::RhoM); + bkgrho::RhoM, + o2::soa::Marker<1>); DECLARE_SOA_TABLE(BkgLcRhos, "AOD", "BkgLcRho", o2::soa::Index<>, - bkglc::CandidateId, bkgrho::Rho, - bkgrho::RhoM); + bkgrho::RhoM, + o2::soa::Marker<2>); DECLARE_SOA_TABLE(BkgBplusRhos, "AOD", "BkgBPlRho", o2::soa::Index<>, - bkgbplus::CandidateId, bkgrho::Rho, - bkgrho::RhoM); + bkgrho::RhoM, + o2::soa::Marker<3>); DECLARE_SOA_TABLE(BkgDielectronRhos, "AOD", "BkgDIELRho", o2::soa::Index<>, - bkgdielectron::CandidateId, bkgrho::Rho, - bkgrho::RhoM); + bkgrho::RhoM, + o2::soa::Marker<4>); namespace jtracksub { diff --git a/PWGJE/DataModel/JetTagging.h b/PWGJE/DataModel/JetTagging.h index c5915396d07..cae674fd66f 100644 --- a/PWGJE/DataModel/JetTagging.h +++ b/PWGJE/DataModel/JetTagging.h @@ -52,6 +52,7 @@ DECLARE_SOA_COLUMN(Pz, pz, float); DECLARE_SOA_COLUMN(E, e, float); DECLARE_SOA_COLUMN(M, m, float); DECLARE_SOA_COLUMN(Chi2PCA, chi2PCA, float); +DECLARE_SOA_COLUMN(Dispersion, dispersion, float); DECLARE_SOA_COLUMN(ErrorDecayLength, errorDecayLength, float); DECLARE_SOA_COLUMN(ErrorDecayLengthXY, errorDecayLengthXY, float); DECLARE_SOA_DYNAMIC_COLUMN(RSecondaryVertex, rSecondaryVertex, [](float xVtxS, float yVtxS) -> float { return RecoDecay::sqrtSumOfSquares(xVtxS, yVtxS); }); @@ -89,6 +90,7 @@ DECLARE_SOA_DYNAMIC_COLUMN(ImpactParameterXY, impactParameterXY, [](float xVtxP, SecondaryVertexParams::E, \ SecondaryVertexParams::M, \ SecondaryVertexParams::Chi2PCA, \ + SecondaryVertexParams::Dispersion, \ SecondaryVertexParams::ErrorDecayLength, \ SecondaryVertexParams::ErrorDecayLengthXY, \ SecondaryVertexParams::RSecondaryVertex, \ @@ -118,15 +120,17 @@ 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(Algorithm2, algorithm2, int); \ - DECLARE_SOA_COLUMN(Algorithm3, algorithm3, int); \ - } \ - DECLARE_SOA_TABLE(_jet_type_##Tags, "AOD", _description_ "Tags", _name_##tagging::Origin, _name_##tagging::JetProb, _name_##tagging::Algorithm2, _name_##tagging::Algorithm3); +#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_) \ diff --git a/PWGJE/JetFinders/jetfinder.cxx b/PWGJE/JetFinders/jetfinder.cxx index b5795c56b86..61eb0fbacb4 100644 --- a/PWGJE/JetFinders/jetfinder.cxx +++ b/PWGJE/JetFinders/jetfinder.cxx @@ -36,6 +36,9 @@ struct JetFinderTask { Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; 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 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"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -46,7 +49,6 @@ struct JetFinderTask { 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 eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; // cluster level configurables @@ -77,6 +79,7 @@ struct JetFinderTask { Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; Configurable jetPtBinWidth{"jetPtBinWidth", 5, "used to define the width of the jetPt bins for the THnSparse"}; Configurable fillTHnSparse{"fillTHnSparse", false, "switch to fill the THnSparse"}; + Configurable jetExtraParam{"jetExtraParam", -99.0, "sets the _extra_param in fastjet"}; Service pdgDatabase; int trackSelection = -1; @@ -86,10 +89,13 @@ struct JetFinderTask { JetFinder jetFinder; std::vector inputParticles; + std::vector triggerMaskBits; + void init(InitContext const&) { - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); particleSelection = static_cast(particleSelections); jetFinder.etaMin = trackEtaMin; @@ -106,6 +112,7 @@ struct JetFinderTask { if (DoTriggering) { jetFinder.isTriggering = true; } + jetFinder.fastjetExtraParam = jetExtraParam; auto jetRadiiBins = (std::vector)jetRadius; if (jetRadiiBins.size() > 1) { @@ -122,95 +129,97 @@ struct JetFinderTask { double jetPtMinDouble = static_cast(jetPtMinInt); double jetPtMaxDouble = static_cast(jetPtMaxInt); - registry.add("hJet", "sparse for data or mcd jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); - registry.add("hJetEWS", "sparse for data or mcd event-wise subtracted jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); - registry.add("hJetMCP", "sparse for mcp jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); + if (fillTHnSparse) { + registry.add("hJet", "sparse for data or mcd jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); + registry.add("hJetEWS", "sparse for data or mcd event-wise subtracted jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); + registry.add("hJetMCP", "sparse for mcp jets", {HistType::kTHnC, {{jetRadiiBins, ""}, {jetPtBinNumber, jetPtMinDouble, jetPtMaxDouble}, {40, -1.0, 1.0}, {18, 0.0, 7.0}}}); + } } aod::EMCALClusterDefinition clusterDefinition = aod::emcalcluster::getClusterDefinitionFromString(clusterDefinitionS.value); - Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::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); // do we need eta cut both here and in globalselection? - Filter trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta > trackEtaMin && aod::jtracksub::eta < trackEtaMax && aod::jtracksub::phi >= trackPhiMin && aod::jtracksub::phi <= trackPhiMax); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + 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 trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta >= trackEtaMin && aod::jtracksub::eta <= trackEtaMax && aod::jtracksub::phi >= trackPhiMin && aod::jtracksub::phi <= trackPhiMax); - Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax && aod::jmcparticle::eta > trackEtaMin && aod::jmcparticle::eta < trackEtaMax); - 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)); + 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) + void processChargedJets(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJet")), fillTHnSparse); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); + jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJet")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processChargedJets, "Data and reco level jet finding for charged jets", false); - void processChargedEvtWiseSubJets(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks) + void processChargedEvtWiseSubJets(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); - jetfindingutilities::findJets(jetFinder, inputParticles, jetEWSPtMin, jetEWSPtMax, jetRadius, jetAreaFractionMin, collision, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, registry.get(HIST("hJetEWS")), fillTHnSparse); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); + jetfindingutilities::findJets(jetFinder, inputParticles, jetEWSPtMin, jetEWSPtMax, jetRadius, jetAreaFractionMin, collision, jetsEvtWiseSubTable, constituentsEvtWiseSubTable, fillTHnSparse ? registry.get(HIST("hJetEWS")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processChargedEvtWiseSubJets, "Data and reco level jet finding for charged jets with event-wise constituent subtraction", false); - void processNeutralJets(soa::Filtered::iterator const& collision, - soa::Filtered const& clusters) + void processNeutralJets(soa::Filtered::iterator const& collision, + soa::Filtered const& clusters) { - if (doEMCALEventSelection && !jetderiveddatautilities::eventEMCAL(collision)) { + if ((doEMCALEventSelection && !jetderiveddatautilities::eventEMCAL(collision)) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); jetfindingutilities::analyseClusters(inputParticles, &clusters); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJet")), fillTHnSparse); + jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJet")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processNeutralJets, "Data and reco level jet finding for neutral jets", false); - void processFullJets(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks, - soa::Filtered const& clusters) + void processFullJets(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks, + soa::Filtered const& clusters) { - if (doEMCALEventSelection && !jetderiveddatautilities::eventEMCAL(collision)) { + if ((doEMCALEventSelection && !jetderiveddatautilities::eventEMCAL(collision)) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); jetfindingutilities::analyseClusters(inputParticles, &clusters); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJet")), fillTHnSparse); + 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(JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelChargedJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); - jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse); + jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 1, particles, pdgDatabase); + jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJetMCP")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processParticleLevelChargedJets, "Particle level charged jet finding", false); - void processParticleLevelNeutralJets(JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelNeutralJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); - jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 2, particles, pdgDatabase); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse); + jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 2, particles, pdgDatabase); + jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJetMCP")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processParticleLevelNeutralJets, "Particle level neutral jet finding", false); - void processParticleLevelFullJets(JetMcCollision const& collision, soa::Filtered const& particles) + void processParticleLevelFullJets(aod::JetMcCollision const& collision, soa::Filtered const& particles) { // TODO: MC event selection? inputParticles.clear(); - jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 0, particles, pdgDatabase); - jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse); + jetfindingutilities::analyseParticles, soa::Filtered::iterator>(inputParticles, particleSelection, 0, particles, pdgDatabase); + jetfindingutilities::findJets(jetFinder, inputParticles, jetPtMin, jetPtMax, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, fillTHnSparse ? registry.get(HIST("hJetMCP")) : std::shared_ptr(nullptr), fillTHnSparse); } PROCESS_SWITCH(JetFinderTask, processParticleLevelFullJets, "Particle level full jet finding", false); diff --git a/PWGJE/JetFinders/jetfinderD0datacharged.cxx b/PWGJE/JetFinders/jetfinderD0datacharged.cxx index 7bdd6e87d9d..d26fb239ea3 100644 --- a/PWGJE/JetFinders/jetfinderD0datacharged.cxx +++ b/PWGJE/JetFinders/jetfinderD0datacharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderD0DataCharged = JetFinderHFTask; +using JetFinderD0DataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderD0mcdcharged.cxx b/PWGJE/JetFinders/jetfinderD0mcdcharged.cxx index 1471e00ffa3..afc97fad2b1 100644 --- a/PWGJE/JetFinders/jetfinderD0mcdcharged.cxx +++ b/PWGJE/JetFinders/jetfinderD0mcdcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderD0MCDetectorLevelCharged = JetFinderHFTask; +using JetFinderD0MCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderD0mcpcharged.cxx b/PWGJE/JetFinders/jetfinderD0mcpcharged.cxx index 27764256e04..a92690ebe2a 100644 --- a/PWGJE/JetFinders/jetfinderD0mcpcharged.cxx +++ b/PWGJE/JetFinders/jetfinderD0mcpcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderD0MCParticleLevelCharged = JetFinderHFTask; +using JetFinderD0MCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderDielectrondatacharged.cxx b/PWGJE/JetFinders/jetfinderDielectrondatacharged.cxx index 2e4e4070875..1703462a168 100644 --- a/PWGJE/JetFinders/jetfinderDielectrondatacharged.cxx +++ b/PWGJE/JetFinders/jetfinderDielectrondatacharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderDielectronDataCharged = JetFinderHFTask; +using JetFinderDielectronDataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderDielectronmcdcharged.cxx b/PWGJE/JetFinders/jetfinderDielectronmcdcharged.cxx index 69cca64919b..87b3a5b8013 100644 --- a/PWGJE/JetFinders/jetfinderDielectronmcdcharged.cxx +++ b/PWGJE/JetFinders/jetfinderDielectronmcdcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderDielectronMCDetectorLevelCharged = JetFinderHFTask; +using JetFinderDielectronMCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderDielectronmcpcharged.cxx b/PWGJE/JetFinders/jetfinderDielectronmcpcharged.cxx index 7a5da12fd87..b72e82ed53e 100644 --- a/PWGJE/JetFinders/jetfinderDielectronmcpcharged.cxx +++ b/PWGJE/JetFinders/jetfinderDielectronmcpcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderDielectronMCParticleLevelCharged = JetFinderHFTask; +using JetFinderDielectronMCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderLcdatacharged.cxx b/PWGJE/JetFinders/jetfinderLcdatacharged.cxx index 44af0addc98..bf522020db8 100644 --- a/PWGJE/JetFinders/jetfinderLcdatacharged.cxx +++ b/PWGJE/JetFinders/jetfinderLcdatacharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderLcDataCharged = JetFinderHFTask; +using JetFinderLcDataCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderLcmcdcharged.cxx b/PWGJE/JetFinders/jetfinderLcmcdcharged.cxx index fa5e0aa2d86..410d51695b1 100644 --- a/PWGJE/JetFinders/jetfinderLcmcdcharged.cxx +++ b/PWGJE/JetFinders/jetfinderLcmcdcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderLcMCDetectorLevelCharged = JetFinderHFTask; +using JetFinderLcMCDetectorLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderLcmcpcharged.cxx b/PWGJE/JetFinders/jetfinderLcmcpcharged.cxx index 4c018ce1cfe..9183edef828 100644 --- a/PWGJE/JetFinders/jetfinderLcmcpcharged.cxx +++ b/PWGJE/JetFinders/jetfinderLcmcpcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderhf.cxx" -using JetFinderLcMCParticleLevelCharged = JetFinderHFTask; +using JetFinderLcMCParticleLevelCharged = JetFinderHFTask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderV0datacharged.cxx b/PWGJE/JetFinders/jetfinderV0datacharged.cxx index 671535d635f..b080f135c6b 100644 --- a/PWGJE/JetFinders/jetfinderV0datacharged.cxx +++ b/PWGJE/JetFinders/jetfinderV0datacharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderv0.cxx" -using JetFinderV0DataCharged = JetFinderV0Task; +using JetFinderV0DataCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderV0mcdcharged.cxx b/PWGJE/JetFinders/jetfinderV0mcdcharged.cxx index 6c06d061aed..b46ddeb1b28 100644 --- a/PWGJE/JetFinders/jetfinderV0mcdcharged.cxx +++ b/PWGJE/JetFinders/jetfinderV0mcdcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderv0.cxx" -using JetFinderV0MCDetectorLevelCharged = JetFinderV0Task; +using JetFinderV0MCDetectorLevelCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderV0mcpcharged.cxx b/PWGJE/JetFinders/jetfinderV0mcpcharged.cxx index 53cc6f944f8..29f0fee1bd2 100644 --- a/PWGJE/JetFinders/jetfinderV0mcpcharged.cxx +++ b/PWGJE/JetFinders/jetfinderV0mcpcharged.cxx @@ -15,7 +15,7 @@ #include "PWGJE/JetFinders/jetfinderv0.cxx" -using JetFinderV0MCParticleLevelCharged = JetFinderV0Task; +using JetFinderV0MCParticleLevelCharged = JetFinderV0Task; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/JetFinders/jetfinderhf.cxx b/PWGJE/JetFinders/jetfinderhf.cxx index 3e685171fb8..db62faee40d 100644 --- a/PWGJE/JetFinders/jetfinderhf.cxx +++ b/PWGJE/JetFinders/jetfinderhf.cxx @@ -56,6 +56,9 @@ struct JetFinderHFTask { Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; 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 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"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -66,7 +69,6 @@ struct JetFinderHFTask { 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 eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; // cluster level configurables @@ -102,9 +104,11 @@ struct JetFinderHFTask { Configurable jetRecombScheme{"jetRecombScheme", 0, "jet recombination scheme. 0 = E-scheme, 1 = pT-scheme, 2 = pT2-scheme"}; Configurable jetGhostArea{"jetGhostArea", 0.005, "jet ghost area"}; Configurable ghostRepeat{"ghostRepeat", 1, "set to 0 to gain speed if you dont need area calculation"}; + Configurable DoTriggering{"DoTriggering", false, "used for the charged jet trigger to remove the eta constraint on the jet axis"}; Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; Configurable jetPtBinWidth{"jetPtBinWidth", 5, "used to define the width of the jetPt bins for the THnSparse"}; Configurable fillTHnSparse{"fillTHnSparse", false, "switch to fill the THnSparse"}; + Configurable jetExtraParam{"jetExtraParam", -99.0, "sets the _extra_param in fastjet"}; Service pdgDatabase; int trackSelection = -1; @@ -114,9 +118,12 @@ struct JetFinderHFTask { JetFinder jetFinder; std::vector inputParticles; + std::vector triggerMaskBits; + void init(InitContext const&) { trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); particleSelection = static_cast(particleSelections); @@ -133,6 +140,10 @@ struct JetFinderHFTask { jetFinder.recombScheme = static_cast(static_cast(jetRecombScheme)); jetFinder.ghostArea = jetGhostArea; jetFinder.ghostRepeatN = ghostRepeat; + if (DoTriggering) { + jetFinder.isTriggering = true; + } + jetFinder.fastjetExtraParam = jetExtraParam; auto jetRadiiBins = (std::vector)jetRadius; if (jetRadiiBins.size() > 1) { @@ -154,11 +165,11 @@ 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); - 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 trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta > trackEtaMin && aod::jtracksub::eta < trackEtaMax && aod::jtracksub::phi >= trackPhiMin && aod::jtracksub::phi <= trackPhiMax); - Filter partCuts = (aod::jmcparticle::pt >= trackPtMin && aod::jmcparticle::pt < trackPtMax); - 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)); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + 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 trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta >= trackEtaMin && aod::jtracksub::eta <= trackEtaMax && aod::jtracksub::phi >= trackPhiMin && aod::jtracksub::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)); // Filter candidateCuts = (aod::hfcand::pt >= candPtMin && aod::hfcand::pt < candPtMax && aod::hfcand::y >= candYMin && aod::hfcand::y < candYMax); PresliceOptional> perD0Candidate = aod::bkgd0::candidateId; @@ -170,7 +181,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)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); @@ -210,12 +221,12 @@ struct JetFinderHFTask { jetfindingutilities::findJets(jetFinder, inputParticles, minJetPt, maxJetPt, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse, true); } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetFinderHFTask, processDummy, "Dummy process function turned on by default", true); - void processChargedJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) + void processChargedJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) { for (typename CandidateTableData::iterator const& candidate : candidates) { // why can the type not be auto? try const auto analyseCharged(collision, tracks, candidate, jetsTable, constituentsTable, tracks, jetPtMin, jetPtMax); @@ -223,7 +234,7 @@ struct JetFinderHFTask { } PROCESS_SWITCH(JetFinderHFTask, processChargedJetsData, "charged hf jet finding on data", false); - void processChargedEvtWiseSubJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) + 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); @@ -231,7 +242,7 @@ struct JetFinderHFTask { } PROCESS_SWITCH(JetFinderHFTask, processChargedEvtWiseSubJetsData, "charged hf jet finding on data with event-wise constituent subtraction", false); - void processChargedJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) + void processChargedJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) { for (typename CandidateTableMCD::iterator const& candidate : candidates) { analyseCharged(collision, tracks, candidate, jetsTable, constituentsTable, tracks, jetPtMin, jetPtMax); @@ -239,7 +250,7 @@ struct JetFinderHFTask { } PROCESS_SWITCH(JetFinderHFTask, processChargedJetsMCD, "charged hf jet finding on MC detector level", false); - void processChargedEvtWiseSubJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) + 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); @@ -247,8 +258,8 @@ struct JetFinderHFTask { } PROCESS_SWITCH(JetFinderHFTask, processChargedEvtWiseSubJetsMCD, "charged hf jet finding on MC detector level with event-wise constituent subtraction", false); - void processChargedJetsMCP(JetMcCollision const& collision, - soa::Filtered const& particles, + void processChargedJetsMCP(aod::JetMcCollision const& collision, + soa::Filtered const& particles, CandidateTableMCP const& candidates) { for (typename CandidateTableMCP::iterator const& candidate : candidates) { diff --git a/PWGJE/JetFinders/jetfinderv0.cxx b/PWGJE/JetFinders/jetfinderv0.cxx index 17dc308ddb1..e36fb6235de 100644 --- a/PWGJE/JetFinders/jetfinderv0.cxx +++ b/PWGJE/JetFinders/jetfinderv0.cxx @@ -38,6 +38,9 @@ struct JetFinderV0Task { Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; 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 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"}; // track level configurables Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; @@ -48,7 +51,6 @@ struct JetFinderV0Task { 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 eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable particleSelections{"particleSelections", "PhysicalPrimary", "set particle selections"}; // V0 candidate level configurables @@ -69,9 +71,11 @@ struct JetFinderV0Task { Configurable jetRecombScheme{"jetRecombScheme", 0, "jet recombination scheme. 0 = E-scheme, 1 = pT-scheme, 2 = pT2-scheme"}; Configurable jetGhostArea{"jetGhostArea", 0.005, "jet ghost area"}; Configurable ghostRepeat{"ghostRepeat", 1, "set to 0 to gain speed if you dont need area calculation"}; + Configurable DoTriggering{"DoTriggering", false, "used for the charged jet trigger to remove the eta constraint on the jet axis"}; Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; 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"}; Service pdgDatabase; int trackSelection = -1; @@ -81,11 +85,14 @@ struct JetFinderV0Task { JetFinder jetFinder; std::vector inputParticles; + std::vector triggerMaskBits; + int candIndex; void init(InitContext const&) { trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); particleSelection = static_cast(particleSelections); @@ -102,6 +109,10 @@ struct JetFinderV0Task { jetFinder.recombScheme = static_cast(static_cast(jetRecombScheme)); jetFinder.ghostArea = jetGhostArea; jetFinder.ghostRepeatN = ghostRepeat; + if (DoTriggering) { + jetFinder.isTriggering = true; + } + jetFinder.fastjetExtraParam = jetExtraParam; if (candPDG == 310) { candIndex = 0; @@ -129,16 +140,16 @@ 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); - 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); + Filter collisionFilter = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax && aod::jcollision::trackOccupancyInTimeRange <= trackOccupancyInTimeRangeMax); + 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)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { return; } inputParticles.clear(); @@ -170,25 +181,25 @@ struct JetFinderV0Task { jetfindingutilities::findJets(jetFinder, inputParticles, minJetPt, maxJetPt, jetRadius, jetAreaFractionMin, collision, jetsTable, constituentsTable, registry.get(HIST("hJetMCP")), fillTHnSparse, true); } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetFinderV0Task, processDummy, "Dummy process function turned on by default", true); - void processChargedJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) + void processChargedJetsData(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableData const& candidates) { analyseCharged(collision, tracks, candidates, jetsTable, constituentsTable, jetPtMin, jetPtMax); } PROCESS_SWITCH(JetFinderV0Task, processChargedJetsData, "charged hf jet finding on data", false); - void processChargedJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) + void processChargedJetsMCD(soa::Filtered::iterator const& collision, soa::Filtered const& tracks, CandidateTableMCD const& candidates) { analyseCharged(collision, tracks, candidates, jetsTable, constituentsTable, jetPtMin, jetPtMax); } PROCESS_SWITCH(JetFinderV0Task, processChargedJetsMCD, "charged hf jet finding on MC detector level", false); - void processChargedJetsMCP(JetMcCollision const& collision, - soa::Filtered const& particles, + void processChargedJetsMCP(aod::JetMcCollision const& collision, + soa::Filtered const& particles, CandidateTableMCP const& candidates) { analyseMCP(collision, particles, candidates, 1, jetPtMin, jetPtMax); diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index cc3dfa1135e..12fa8359820 100644 --- a/PWGJE/TableProducer/CMakeLists.txt +++ b/PWGJE/TableProducer/CMakeLists.txt @@ -14,7 +14,7 @@ if(FastJet_FOUND) o2physics_add_dpl_workflow(jet-deriveddata-producer SOURCES jetderiveddataproducer.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-deriveddata-trigger-producer @@ -47,6 +47,16 @@ o2physics_add_dpl_workflow(jet-deriveddata-writer PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(jet-luminosity-producer + SOURCES luminosityproducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(jet-luminosity-calculator + SOURCES luminositycalculator.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-matching-mc SOURCES jetmatchingmc.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore diff --git a/PWGJE/TableProducer/emcalCorrectionTask.cxx b/PWGJE/TableProducer/emcalCorrectionTask.cxx index c0a63f1795a..111841890c8 100644 --- a/PWGJE/TableProducer/emcalCorrectionTask.cxx +++ b/PWGJE/TableProducer/emcalCorrectionTask.cxx @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include "CCDB/BasicCCDBManager.h" #include "Framework/runDataProcessing.h" @@ -75,7 +78,6 @@ struct EmcalCorrectionTask { Configurable selectedCellType{"selectedCellType", 1, "EMCAL Cell type"}; Configurable clusterDefinitions{"clusterDefinition", "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 hasPropagatedTracks{"hasPropagatedTracks", false, "temporary flag, only set to true when running over data which has the tracks propagated to EMCal/PHOS!"}; Configurable nonlinearityFunction{"nonlinearityFunction", "DATA_TestbeamFinal", "Nonlinearity correction at cluster level"}; Configurable disableNonLin{"disableNonLin", false, "Disable NonLin correction if set to true"}; Configurable hasShaperCorrection{"hasShaperCorrection", true, "Apply correction for shaper saturation"}; @@ -88,6 +90,7 @@ 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 applyCellTimeShift{"applyCellTimeShift", 0, "apply shift to the cell time for data and MC; For data: 0 = off; non-zero = log function extracted from data - For MC: 0 = off; 1 = const shift; 2 = eta-dependent shift"}; // Require EMCAL cells (CALO type 1) Filter emccellfilter = aod::calo::caloType == selectedCellType; @@ -109,6 +112,9 @@ struct EmcalCorrectionTask { // QA o2::framework::HistogramRegistry mHistManager{"EMCALCorrectionTaskQAHistograms"}; + // EMCal geometry + o2::emcal::Geometry* geometry; + void init(InitContext const&) { LOG(debug) << "Start init!"; @@ -125,7 +131,7 @@ struct EmcalCorrectionTask { mCcdbManager->get("GLO/Config/Geometry"); } LOG(debug) << "After load geometry!"; - o2::emcal::Geometry* geometry = o2::emcal::Geometry::GetInstanceFromRunNumber(223409); + geometry = o2::emcal::Geometry::GetInstanceFromRunNumber(223409); if (!geometry) { LOG(error) << "Failure accessing geometry"; } @@ -176,29 +182,32 @@ struct EmcalCorrectionTask { using o2HistType = o2::framework::HistType; using o2Axis = o2::framework::AxisSpec; o2Axis 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"}; mHistManager.add("hCellE", "hCellE", o2HistType::kTH1F, {energyAxis}); - mHistManager.add("hCellTowerID", "hCellTowerID", o2HistType::kTH1I, {{20000, 0, 20000}}); + mHistManager.add("hCellTowerID", "hCellTowerID", o2HistType::kTH1D, {{20000, 0, 20000}}); mHistManager.add("hCellEtaPhi", "hCellEtaPhi", o2HistType::kTH2F, {etaAxis, phiAxis}); // NOTE: Reversed column and row because it's more natural for presentation. - mHistManager.add("hCellRowCol", "hCellRowCol;Column;Row", o2HistType::kTH2I, {{97, 0, 97}, {600, 0, 600}}); + mHistManager.add("hCellRowCol", "hCellRowCol;Column;Row", o2HistType::kTH2D, {{97, 0, 97}, {600, 0, 600}}); mHistManager.add("hClusterE", "hClusterE", o2HistType::kTH1F, {energyAxis}); mHistManager.add("hClusterEtaPhi", "hClusterEtaPhi", o2HistType::kTH2F, {etaAxis, phiAxis}); + mHistManager.add("hClusterTime", "hClusterTime", o2HistType::kTH1F, {timeAxis}); mHistManager.add("hGlobalTrackEtaPhi", "hGlobalTrackEtaPhi", o2HistType::kTH2F, {etaAxis, phiAxis}); - mHistManager.add("hGlobalTrackMult", "hGlobalTrackMult", o2HistType::kTH1I, {{200, -0.5, 199.5, "N_{trk}"}}); - mHistManager.add("hCollisionType", "hCollisionType;;#it{count}", o2HistType::kTH1I, {{3, -0.5, 2.5}}); + 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}}); auto hCollisionType = mHistManager.get(HIST("hCollisionType")); hCollisionType->GetXaxis()->SetBinLabel(1, "no collision"); hCollisionType->GetXaxis()->SetBinLabel(2, "normal collision"); hCollisionType->GetXaxis()->SetBinLabel(3, "mult. collisions"); - mHistManager.add("hClusterType", "hClusterType;;#it{count}", o2HistType::kTH1I, {{3, -0.5, 2.5}}); + 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"); hClusterType->GetXaxis()->SetBinLabel(2, "normal collision"); hClusterType->GetXaxis()->SetBinLabel(3, "mult. collisions"); - mHistManager.add("hCollPerBC", "hCollPerBC;#it{N}_{coll.};#it{count}", o2HistType::kTH1I, {{100, -0.5, 99.5}}); - mHistManager.add("hBC", "hBC;;#it{count}", o2HistType::kTH1I, {{8, -0.5, 7.5}}); + mHistManager.add("hCollPerBC", "hCollPerBC;#it{N}_{coll.};#it{count}", o2HistType::kTH1D, {{100, -0.5, 99.5}}); + mHistManager.add("hBC", "hBC;;#it{count}", o2HistType::kTH1D, {{8, -0.5, 7.5}}); + mHistManager.add("hCollisionTimeReso", "hCollisionTimeReso;#Delta t_{coll};#it{count}", o2HistType::kTH1D, {{2000, 0, 2000}}); auto hBC = mHistManager.get(HIST("hBC")); hBC->GetXaxis()->SetBinLabel(1, "with EMCal cells"); hBC->GetXaxis()->SetBinLabel(2, "with EMCal cells but no collision"); @@ -258,7 +267,7 @@ struct EmcalCorrectionTask { } cellsBC.emplace_back(cell.cellNumber(), amplitude, - cell.time(), + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); } @@ -284,6 +293,7 @@ struct EmcalCorrectionTask { // dummy loop to get the first collision for (const auto& col : collisionsInFoundBC) { if (col.foundBCId() == bc.globalIndex()) { + mHistManager.fill(HIST("hCollisionTimeReso"), col.collisionTimeRes()); mHistManager.fill(HIST("hCollPerBC"), 1); mHistManager.fill(HIST("hCollisionType"), 1); math_utils::Point3D vertex_pos = {col.posX(), col.posY(), col.posZ()}; @@ -376,7 +386,7 @@ struct EmcalCorrectionTask { } cellsBC.emplace_back(cell.cellNumber(), amplitude, - cell.time(), + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); cellLabels.emplace_back(cell.mcParticleIds(), cell.amplitudeA()); @@ -478,7 +488,7 @@ struct EmcalCorrectionTask { for (auto& cell : cellsInBC) { cellsBC.emplace_back(cell.cellNumber(), cell.amplitude(), - cell.time(), + cell.time() + getCellTimeShift(cell.cellNumber(), cell.amplitude()), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); } @@ -617,6 +627,7 @@ struct EmcalCorrectionTask { } // end of cells of cluser loop // fill histograms mHistManager.fill(HIST("hClusterE"), cluster.E()); + mHistManager.fill(HIST("hClusterTime"), cluster.getClusterTime()); mHistManager.fill(HIST("hClusterEtaPhi"), pos.Eta(), TVector2::Phi_0_2pi(pos.Phi())); if (IndexMapPair && trackGlobalIndex) { for (unsigned int iTrack = 0; iTrack < std::get<0>(*IndexMapPair)[iCluster].size(); iTrack++) { @@ -669,7 +680,7 @@ struct EmcalCorrectionTask { clustercellsambiguous(clustersAmbiguous.lastIndex(), cellIndicesBC[cellindex]); } // end of cells of cluster loop - } // end of cluster loop + } // end of cluster loop } template @@ -719,18 +730,10 @@ struct EmcalCorrectionTask { continue; } NTrack++; - if (hasPropagatedTracks) { // only temporarily while not every data - // has the tracks propagated to EMCal/PHOS - trackPhi.emplace_back(TVector2::Phi_0_2pi(track.trackPhiEmcal())); - trackEta.emplace_back(track.trackEtaEmcal()); - mHistManager.fill(HIST("hGlobalTrackEtaPhi"), track.trackEtaEmcal(), - TVector2::Phi_0_2pi(track.trackPhiEmcal())); - } else { - trackPhi.emplace_back(TVector2::Phi_0_2pi(track.phi())); - trackEta.emplace_back(track.eta()); - mHistManager.fill(HIST("hGlobalTrackEtaPhi"), track.eta(), - TVector2::Phi_0_2pi(track.phi())); - } + trackPhi.emplace_back(TVector2::Phi_0_2pi(track.trackPhiEmcal())); + trackEta.emplace_back(track.trackEtaEmcal()); + mHistManager.fill(HIST("hGlobalTrackEtaPhi"), track.trackEtaEmcal(), + TVector2::Phi_0_2pi(track.trackPhiEmcal())); trackGlobalIndex.emplace_back(track.globalIndex()); } mHistManager.fill(HIST("hGlobalTrackMult"), NTrack); @@ -789,6 +792,40 @@ struct EmcalCorrectionTask { return 1.f; } } + + // 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) + { + if (isMC) { + if (applyCellTimeShift == 1) { // constant shift + LOG(debug) << "shift the cell time by 15ns"; + return -15.f; // roughly calculated by assuming particles travel with v=c (photons) and EMCal is 4.4m away from vertex + } else if (applyCellTimeShift == 2) { // 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 + // 0.2 is cell size in m (0.06) divided by the speed of light in m/ns (0.3) + // 47.5 is the "middle" of the EMCal (2*48 cells in one column) + float timeCol = 0.2f * (geometry->GlobalCol(cellID) - 47.5f); // calculate time to get to specific column + float time = -sqrt(215.f + timeCol * timeCol); // 215 is 14.67ns^2 (time it takes to get the cell at eta = 0) + LOG(debug) << "shift the cell time by " << time << " applyCellTimeShift " << applyCellTimeShift; + return time; + } else { + return 0.f; + } + } else { // data + if (applyCellTimeShift != 0) { + 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 + return 0.f; + else if (cellEnergy < 4.) // Low energy regime + return (0.57284 + 0.82194 * TMath::Log(1.30651 * cellEnergy)); // Parameters extracted from LHC22o (pp), but also usable for other periods + else // High energy regime + return (-0.05858 + 1.50593 * TMath::Log(0.97591 * cellEnergy)); // Parameters extracted from LHC22o (pp), but also usable for other periods + } else { // Dont apply cell time shift if applyCellTimeShift == 0 + return 0.f; + } + } + } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx b/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx index 6b0376a3e25..396888fe1a7 100644 --- a/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx +++ b/PWGJE/TableProducer/eventwiseConstituentSubtractor.cxx @@ -34,6 +34,7 @@ struct eventWiseConstituentSubtractorTask { Produces trackSubtractedD0Table; Produces trackSubtractedLcTable; Produces trackSubtractedBplusTable; + Produces trackSubtractedDielectronTable; Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; @@ -66,25 +67,16 @@ struct eventWiseConstituentSubtractorTask { 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); - Preslice perD0Candidate = aod::bkgd0::candidateId; - Preslice perLcCandidate = aod::bkglc::candidateId; - Preslice perBplusCandidate = aod::bkgbplus::candidateId; - Preslice perDielectronCandidate = aod::bkgdielectron::candidateId; - - template - void analyseHF(T const& tracks, U const& candidates, V const& bkgRhos, M& trackSubtractedTable) + template + void analyseHF(T const& tracks, U const& candidates, V& trackSubtractedTable) { for (auto& candidate : candidates) { - - auto const bkgRhosSliced = jetcandidateutilities::slicedPerCandidate(bkgRhos, candidate, perD0Candidate, perLcCandidate, perBplusCandidate, perDielectronCandidate); - auto const bkgRho = bkgRhosSliced.iteratorAt(0); - inputParticles.clear(); tracksSubtracted.clear(); jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); - tracksSubtracted = eventWiseConstituentSubtractor.JetBkgSubUtils::doEventConstSub(inputParticles, bkgRho.rho(), bkgRho.rhoM()); + tracksSubtracted = eventWiseConstituentSubtractor.JetBkgSubUtils::doEventConstSub(inputParticles, candidate.rho(), candidate.rhoM()); for (auto const& trackSubtracted : tracksSubtracted) { trackSubtractedTable(candidate.globalIndex(), trackSubtracted.pt(), trackSubtracted.eta(), trackSubtracted.phi(), trackSubtracted.E(), jetderiveddatautilities::setSingleTrackSelectionBit(trackSelection)); @@ -92,12 +84,12 @@ struct eventWiseConstituentSubtractorTask { } } - void processCollisions(soa::Join::iterator const& collision, soa::Filtered const& tracks) + void processCollisions(soa::Join::iterator const& collision, soa::Filtered const& tracks) { inputParticles.clear(); tracksSubtracted.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); tracksSubtracted = eventWiseConstituentSubtractor.JetBkgSubUtils::doEventConstSub(inputParticles, collision.rho(), collision.rhoM()); @@ -107,23 +99,29 @@ struct eventWiseConstituentSubtractorTask { } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processCollisions, "Fill table of subtracted tracks for collisions", true); - void processD0Collisions(JetCollision const&, aod::BkgD0Rhos const& bkgRhos, soa::Filtered const& tracks, CandidatesD0Data const& candidates) + void processD0Collisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) { - analyseHF(tracks, candidates, bkgRhos, trackSubtractedD0Table); + analyseHF(tracks, candidates, trackSubtractedD0Table); } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processD0Collisions, "Fill table of subtracted tracks for collisions with D0 candidates", false); - void processLcCollisions(JetCollision const&, aod::BkgLcRhos const& bkgRhos, soa::Filtered const& tracks, CandidatesLcData const& candidates) + void processLcCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) { - analyseHF(tracks, candidates, bkgRhos, trackSubtractedLcTable); + analyseHF(tracks, candidates, trackSubtractedLcTable); } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processLcCollisions, "Fill table of subtracted tracks for collisions with Lc candidates", false); - void processBplusCollisions(JetCollision const&, aod::BkgBplusRhos const& bkgRhos, soa::Filtered const& tracks, CandidatesBplusData const& candidates) + void processBplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) { - analyseHF(tracks, candidates, bkgRhos, trackSubtractedBplusTable); + analyseHF(tracks, candidates, trackSubtractedBplusTable); } PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processBplusCollisions, "Fill table of subtracted tracks for collisions with Bplus candidates", false); + + void processDielectronCollisions(aod::JetCollision const&, soa::Filtered const& tracks, soa::Join const& candidates) + { + analyseHF(tracks, candidates, trackSubtractedDielectronTable); + } + PROCESS_SWITCH(eventWiseConstituentSubtractorTask, processDielectronCollisions, "Fill table of subtracted tracks for collisions with Dielectron candidates", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"subtractor-eventwiseconstituent"})}; } diff --git a/PWGJE/TableProducer/jetderiveddataproducer.cxx b/PWGJE/TableProducer/jetderiveddataproducer.cxx index a7dc17a1688..e0fcdc959ea 100644 --- a/PWGJE/TableProducer/jetderiveddataproducer.cxx +++ b/PWGJE/TableProducer/jetderiveddataproducer.cxx @@ -23,28 +23,42 @@ #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 "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 "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" + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct JetDerivedDataProducerTask { + Produces bcCountsTable; Produces collisionCountsTable; Produces jDummysTable; Produces jBCsTable; @@ -52,11 +66,13 @@ struct JetDerivedDataProducerTask { 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; @@ -85,33 +101,80 @@ struct JetDerivedDataProducerTask { Produces jDielectronMcsTable; Produces jDielectronMcIdsTable; + 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)"}; + Configurable dcaZMax{"dcaZMax", 0.2, "maximum DCAZ selection for tracks - only applied for reassociation"}; + + 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"}; + Preslice perClusterCells = aod::emcalclustercell::emcalclusterId; Preslice perClusterTracks = aod::emcalclustercell::emcalclusterId; + Preslice perCollisionTrackIndices = aod::track_association::collisionId; + std::map, int32_t> trackCollisionMapping; + Service ccdb; + o2::base::MatLayerCylSet* lut; + o2::base::Propagator::MatCorrType noMatCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; Service pdgDatabase; + Zorro triggerDecider; + int runNumber; + bool withCollisionAssociator; void init(InitContext const&) { + if (doprocessTracksWithCollisionAssociator || includeTriggers) { + ccdb->setURL(ccdbUrl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + runNumber = 0; + if (doprocessTracksWithCollisionAssociator) { + withCollisionAssociator = true; + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); + } else { + withCollisionAssociator = false; + } + } + } + + void processClearMaps(aod::Collisions const&) + { + trackCollisionMapping.clear(); } + PROCESS_SWITCH(JetDerivedDataProducerTask, processClearMaps, "clears all maps", true); - void processBunchCrossings(soa::Join::iterator const& bc) + void processBunchCrossings(soa::Join::iterator const& bc) { - jBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp()); + jBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp(), bc.alias_raw(), bc.selection_raw()); jBCParentIndexTable(bc.globalIndex()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processBunchCrossings, "produces derived bunch crossing table", false); - void processCollisions(soa::Join::iterator const& collision) + void processCollisions(soa::Join::iterator const& collision, soa::Join const&) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFT0C(), collision.centFT0C(), jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw()); // note change multFT0C to multFT0M when problems with multFT0A are fixed + 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()); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisions, "produces derived collision tables", true); - void processCollisionsWithoutCentralityAndMultiplicity(soa::Join::iterator const& collision) + void processCollisionsWithoutCentralityAndMultiplicity(soa::Join::iterator const& collision, soa::Join const&) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw()); + 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(), -1.0, -1.0, -1, jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw(), triggerBit); jCollisionsParentIndexTable(collision.globalIndex()); jCollisionsBunchCrossingIndexTable(collision.bcId()); } @@ -119,7 +182,7 @@ struct JetDerivedDataProducerTask { void processCollisionsRun2(soa::Join::iterator const& collision) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multFT0C(), collision.centRun2V0M(), jetderiveddatautilities::setEventSelectionBit(collision), collision.alias_raw()); // note change multFT0C to multFT0M when problems with multFT0A are fixed + 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()); } @@ -127,12 +190,24 @@ struct JetDerivedDataProducerTask { void processCollisionsALICE3(aod::Collision const& collision) { - jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1.0, 0); + jCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), -1.0, -1.0, -1, -1.0, 0, 0); jCollisionsParentIndexTable(collision.globalIndex()); jCollisionsBunchCrossingIndexTable(-1); } PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisionsALICE3, "produces derived collision tables for ALICE 3 simulations", false); + void processWithoutEMCalCollisionLabels(aod::Collision const&) + { + 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()); + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processEMCalCollisionLabels, "produces derived collision labels for EMCal", false); + void processMcCollisionLabels(soa::Join::iterator const& collision) { @@ -151,14 +226,73 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcCollisions, "produces derived MC collision table", false); - void processTracks(soa::Join::iterator const& track) + void processTracks(soa::Join::iterator const& track, aod::Collisions const&) { - jTracksTable(track.collisionId(), track.pt(), track.eta(), track.phi(), jetderiveddatautilities::setTrackSelectionBit(track)); - jTracksExtraTable(track.dcaXY(), track.dcaZ(), track.sigma1Pt()); // these need to be recalculated when we add the track to collision associator + 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; + float dcaXYZ = getDcaXYZ(track, &sigmaDCAXYZ2); + float dcaX = -99.0; + float dcaY = -99.0; + if (track.collisionId() >= 0) { + auto const& collision = track.collision_as(); + dcaX = xyzTrack.X() - collision.posX(); + 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(); } 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) + { + 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()); + 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 + } else { + auto bc = collision.bc_as>(); + initCCDB(bc, runNumber, ccdb, doprocessCollisionsRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, doprocessCollisionsRun2); + o2::dataformats::DCA dcaCovInfo; + dcaCovInfo.set(-999., -999., -999., -999., -999.); + o2::dataformats::VertexBase collisionInfo; + 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()); + auto xyzTrack = trackParCov.getXYZGlo(); + float dcaXY = dcaCovInfo.getY(); + float dcaZ = dcaCovInfo.getZ(); + float dcaXYZ = std::sqrt(dcaXY * dcaXY + dcaZ * dcaZ); + float covYY = dcaCovInfo.getSigmaY2(); + float covZZ = dcaCovInfo.getSigmaZ2(); + float covYZ = dcaCovInfo.getSigmaYZ(); + float sigmaDCAXYZ; + if (dcaXYZ < o2::constants::math::Almost0) { + sigmaDCAXYZ = o2::constants::math::VeryBig; // Protection against division by zero + } 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())); + } + trackCollisionMapping[{track.globalIndex(), collision.globalIndex()}] = jTracksTable.lastIndex(); + } + } + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processTracksWithCollisionAssociator, "produces derived track table taking into account track-to-collision associations", false); + void processMcTrackLabels(soa::Join::iterator const& track) { if (track.has_mcParticle()) { @@ -169,9 +303,25 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processMcTrackLabels, "produces derived track labels table", false); + void processMcTrackLabelsWithCollisionAssociator(aod::Collisions const& collisions, soa::Join const&, aod::TrackAssoc const& assocCollisions) + { + for (auto const& collision : collisions) { + auto collisionTrackIndices = assocCollisions.sliceBy(perCollisionTrackIndices, collision.globalIndex()); + for (auto const& collisionTrackIndex : collisionTrackIndices) { + auto track = collisionTrackIndex.track_as>(); + if (track.collisionId() == collision.globalIndex() && track.has_mcParticle()) { + jMcTracksLabelTable(track.mcParticleId()); + } else { + jMcTracksLabelTable(-1); + } + } + } + } + PROCESS_SWITCH(JetDerivedDataProducerTask, processMcTrackLabelsWithCollisionAssociator, "produces derived track labels table taking into account track-to-collision associations", false); + void processParticles(aod::McParticle const& particle) { - std::vector mothersId; + std::vector mothersId; if (particle.has_mothers()) { auto mothersIdTemps = particle.mothersIds(); for (auto mothersIdTemp : mothersIdTemps) { @@ -194,7 +344,7 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processParticles, "produces derived parrticle table", false); - void processClusters(aod::Collision const&, aod::EMCALClusters const& clusters, aod::EMCALClusterCells const& cells, aod::Calos const&, aod::EMCALMatchedTracks const& matchedTracks, aod::Tracks const&) + void processClusters(aod::Collision const&, aod::EMCALClusters const& clusters, aod::EMCALClusterCells const& cells, aod::Calos const&, aod::EMCALMatchedTracks const& matchedTracks, soa::Join const&) { for (auto cluster : clusters) { @@ -224,9 +374,12 @@ struct JetDerivedDataProducerTask { jClustersParentIndexTable(cluster.globalIndex()); auto const clusterTracks = matchedTracks.sliceBy(perClusterTracks, cluster.globalIndex()); - std::vector clusterTrackIDs; + std::vector clusterTrackIDs; for (const auto& clusterTrack : clusterTracks) { - clusterTrackIDs.push_back(clusterTrack.trackId()); + 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()); } jClustersMatchedTracksTable(clusterTrackIDs); } @@ -235,7 +388,7 @@ struct JetDerivedDataProducerTask { void processMcClusterLabels(aod::EMCALMCCluster const& cluster) { - std::vector particleIds; + std::vector particleIds; for (auto particleId : cluster.mcParticleIds()) { particleIds.push_back(particleId); } @@ -258,9 +411,15 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0McCollisions, "produces derived index for D0 MC collisions", false); - void processD0(aod::HfD0Ids::iterator const& D0) + void processD0(aod::HfD0Ids::iterator const& D0, aod::Tracks const&) { - jD0IdsTable(D0.collisionId(), D0.prong0Id(), D0.prong1Id()); + auto JProng0ID = trackCollisionMapping.find({D0.prong0Id(), D0.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({D0.prong1Id(), D0.prong1_as().collisionId()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({D0.prong0Id(), D0.collisionId()}); + JProng1ID = trackCollisionMapping.find({D0.prong1Id(), D0.collisionId()}); + } + jD0IdsTable(D0.collisionId(), JProng0ID->second, JProng1ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processD0, "produces derived index for D0 candidates", false); @@ -282,9 +441,17 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processLcMcCollisions, "produces derived index for Lc MC collisions", false); - void processLc(aod::Hf3PIds::iterator const& Lc) + void processLc(aod::Hf3PIds::iterator const& Lc, aod::Tracks const&) { - jLcIdsTable(Lc.collisionId(), Lc.prong0Id(), Lc.prong1Id(), Lc.prong2Id()); + 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()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({Lc.prong0Id(), Lc.collisionId()}); + JProng1ID = trackCollisionMapping.find({Lc.prong1Id(), Lc.collisionId()}); + JProng2ID = trackCollisionMapping.find({Lc.prong2Id(), Lc.collisionId()}); + } + jLcIdsTable(Lc.collisionId(), JProng0ID->second, JProng1ID->second, JProng2ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processLc, "produces derived index for Lc candidates", false); @@ -294,9 +461,15 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processLcMC, "produces derived index for Lc particles", false); - void processV0(aod::V0Indices::iterator const& V0) + void processV0(aod::V0Indices::iterator const& V0, aod::Tracks const&) { - jV0IdsTable(V0.collisionId(), V0.posTrackId(), V0.negTrackId()); + auto JPosTrackID = trackCollisionMapping.find({V0.posTrackId(), V0.posTrack_as().collisionId()}); + auto JNegTrackID = trackCollisionMapping.find({V0.negTrackId(), V0.negTrack_as().collisionId()}); + if (withCollisionAssociator) { + JPosTrackID = trackCollisionMapping.find({V0.posTrackId(), V0.collisionId()}); + JNegTrackID = trackCollisionMapping.find({V0.negTrackId(), V0.collisionId()}); + } + jV0IdsTable(V0.collisionId(), JPosTrackID->second, JNegTrackID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processV0, "produces derived index for V0 candidates", false); @@ -310,7 +483,7 @@ struct JetDerivedDataProducerTask { jV0McCollisionIdsTable(mcCollision.globalIndex()); filledV0McCollisionTable = true; } - std::vector mothersId; + std::vector mothersId; if (particle.has_mothers()) { auto mothersIdTemps = particle.mothersIds(); for (auto mothersIdTemp : mothersIdTemps) { @@ -342,9 +515,15 @@ struct JetDerivedDataProducerTask { } PROCESS_SWITCH(JetDerivedDataProducerTask, processDielectronCollisions, "produces derived index for Dielectron collisions", false); - void processDielectron(aod::DielectronInfo const& Dielectron) + void processDielectron(aod::DielectronInfo const& Dielectron, aod::Tracks const&) { - jDielectronIdsTable(Dielectron.collisionId(), Dielectron.prong0Id(), Dielectron.prong1Id()); + auto JProng0ID = trackCollisionMapping.find({Dielectron.prong0Id(), Dielectron.prong0_as().collisionId()}); + auto JProng1ID = trackCollisionMapping.find({Dielectron.prong1Id(), Dielectron.prong1_as().collisionId()}); + if (withCollisionAssociator) { + JProng0ID = trackCollisionMapping.find({Dielectron.prong0Id(), Dielectron.collisionId()}); + JProng1ID = trackCollisionMapping.find({Dielectron.prong1Id(), Dielectron.collisionId()}); + } + jDielectronIdsTable(Dielectron.collisionId(), JProng0ID->second, JProng1ID->second); } PROCESS_SWITCH(JetDerivedDataProducerTask, processDielectron, "produces derived index for Dielectron candidates", false); @@ -358,7 +537,7 @@ struct JetDerivedDataProducerTask { jDielectronMcCollisionIdsTable(mcCollision.globalIndex()); filledDielectronMcCollisionTable = true; } - std::vector mothersId; + std::vector mothersId; if (particle.has_mothers()) { auto mothersIdTemps = particle.mothersIds(); for (auto mothersIdTemp : mothersIdTemps) { diff --git a/PWGJE/TableProducer/jetderiveddatatriggerproducer.cxx b/PWGJE/TableProducer/jetderiveddatatriggerproducer.cxx index 4d7dcccce96..a1a1636dd1b 100644 --- a/PWGJE/TableProducer/jetderiveddatatriggerproducer.cxx +++ b/PWGJE/TableProducer/jetderiveddatatriggerproducer.cxx @@ -47,35 +47,17 @@ struct JetDerivedDataTriggerProducerTask { } PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processChargedJetTriggers, "produces derived charged trigger table", false); - void processNoChargedJetTriggers(aod::Collision const&) - { - jChargedTriggerSelsTable(jetderiveddatautilities::JTrigSelCh::noChargedTigger); - } - PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processNoChargedJetTriggers, "produces derived charged trigger table when sample is not triggered", true); - void processFullJetTriggers(soa::Join::iterator const& collision) { jFullTriggerSelsTable(jetderiveddatautilities::setFullTriggerSelectionBit(collision)); } PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processFullJetTriggers, "produces derived full trigger table", false); - void processNoFullJetTriggers(aod::Collision const&) - { - jFullTriggerSelsTable(jetderiveddatautilities::JTrigSelFull::noFullTrigger); - } - PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processNoFullJetTriggers, "produces derived full trigger table table when sample is not triggered", true); - void processChargedHFJetTriggers(soa::Join::iterator const& collision) { jChargedHFTriggerSelsTable(jetderiveddatautilities::setChargedHFTriggerSelectionBit(collision)); } PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processChargedHFJetTriggers, "produces derived charged hf trigger table", false); - - void processNoChargedHFJetTriggers(aod::Collision const&) - { - jChargedHFTriggerSelsTable(jetderiveddatautilities::JTrigSelChHF::noChargedHFTigger); - } - PROCESS_SWITCH(JetDerivedDataTriggerProducerTask, processNoChargedHFJetTriggers, "produces derived charged hf trigger table when sample is not triggered", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/jetderiveddatawriter.cxx b/PWGJE/TableProducer/jetderiveddatawriter.cxx index c9c228a3601..eb5858184da 100644 --- a/PWGJE/TableProducer/jetderiveddatawriter.cxx +++ b/PWGJE/TableProducer/jetderiveddatawriter.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// \file jetderiveddatawriter.cxx -/// \brief Task to skim jet framework tables (JetCollisions, JetTracks, JetClusters, ...) +/// \brief Task to skim jet framework tables (aod::JetCollisions, aod::JetTracks, aod::JetClusters, ...) /// while adjusting indices accordingly /// /// \author Jochen Klein @@ -19,6 +19,8 @@ #include #include +#include + #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" #include "Framework/ASoA.h" @@ -36,49 +38,56 @@ using namespace o2::framework::expressions; struct JetDerivedDataWriter { struct : ConfigurableGroup { - Configurable chargedJetPtMin{"chargedJetPtMin", 0.0, "Minimum charged jet pt to accept event"}; - Configurable chargedEventWiseSubtractedJetPtMin{"chargedEventWiseSubtractedJetPtMin", 0.0, "Minimum charged event-wise subtracted jet pt to accept event"}; - Configurable chargedMCPJetPtMin{"chargedMCPJetPtMin", 0.0, "Minimum charged mcp jet pt to accept event"}; - Configurable neutralJetPtMin{"neutralJetPtMin", 0.0, "Minimum neutral jet pt to accept event"}; - Configurable neutralMCPJetPtMin{"neutralMCPJetPtMin", 0.0, "Minimum neutal mcp jet pt to accept event"}; - Configurable fullJetPtMin{"fullJetPtMin", 0.0, "Minimum full jet pt to accept event"}; - Configurable fullMCPJetPtMin{"fullMCPJetPtMin", 0.0, "Minimum full mcp jet pt to accept event"}; - Configurable chargedD0JetPtMin{"chargedD0JetPtMin", 0.0, "Minimum charged D0 jet pt to accept event"}; - Configurable chargedEventWiseSubtractedD0JetPtMin{"chargedEventWiseSubtractedD0JetPtMin", 0.0, "Minimum charged event-wise subtracted D0 jet pt to accept event"}; - Configurable chargedD0MCPJetPtMin{"chargedD0MCPJetPtMin", 0.0, "Minimum charged D0 mcp jet pt to accept event"}; - Configurable chargedLcJetPtMin{"chargedLcJetPtMin", 0.0, "Minimum charged Lc jet pt to accept event"}; - Configurable chargedEventWiseSubtractedLcJetPtMin{"chargedEventWiseSubtractedLcJetPtMin", 0.0, "Minimum charged event-wise subtracted Lc jet pt to accept event"}; - Configurable chargedLcMCPJetPtMin{"chargedLcMCPJetPtMin", 0.0, "Minimum charged Lc mcp jet pt to accept event"}; - Configurable chargedDielectronJetPtMin{"chargedDielectronJetPtMin", 0.0, "Minimum charged Dielectron jet pt to accept event"}; - Configurable chargedEventWiseSubtractedDielectronJetPtMin{"chargedEventWiseSubtractedDielectronJetPtMin", 0.0, "Minimum charged event-wise subtracted Dielectron jet pt to accept event"}; - Configurable chargedDielectronMCPJetPtMin{"chargedDielectronMCPJetPtMin", 0.0, "Minimum charged Dielectron mcp jet pt to accept event"}; - + 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 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", true, "save the clusters table to the output"}; + Configurable saveClustersTable{"saveClustersTable", false, "save the clusters table to the output"}; Configurable saveD0Table{"saveD0Table", false, "save the D0 table to the output"}; Configurable saveLcTable{"saveLcTable", false, "save the Lc table to the output"}; Configurable saveDielectronTable{"saveDielectronTable", false, "save the Dielectron table to the output"}; - Configurable eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"}; + 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; struct : ProducesGroup { - Produces storedCollisionCountsTable; Produces storedJDummysTable; Produces storedJBCsTable; Produces storedJBCParentIndexTable; Produces storedJCollisionsTable; Produces storedJCollisionsParentIndexTable; Produces storedJCollisionsBunchCrossingIndexTable; - Produces storedJChargedTriggerSelsTable; - Produces storedJFullTriggerSelsTable; - Produces storedJChargedHFTriggerSelsTable; + Produces storedJCollisionsEMCalLabelTable; Produces storedJMcCollisionsLabelTable; Produces storedJMcCollisionsTable; Produces storedJMcCollisionsParentIndexTable; Produces storedJTracksTable; Produces storedJTracksExtraTable; + Produces storedJTracksEMCalTable; Produces storedJTracksParentIndexTable; Produces storedJMcTracksLabelTable; Produces storedJMcParticlesTable; @@ -133,29 +142,33 @@ struct JetDerivedDataWriter { 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 DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; - Preslice D0CollisionsPerCollision = aod::jd0indices::collisionId; - Preslice LcCollisionsPerCollision = aod::jlcindices::collisionId; - Preslice DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; - Preslice D0sPerCollision = aod::jd0indices::collisionId; - Preslice LcsPerCollision = aod::jlcindices::collisionId; - Preslice DielectronsPerCollision = aod::jdielectronindices::collisionId; + Preslice> D0McCollisionsPerMcCollision = aod::jd0indices::mcCollisionId; + Preslice> LcMcCollisionsPerMcCollision = aod::jlcindices::mcCollisionId; + Preslice DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; + Preslice D0CollisionsPerCollision = aod::jd0indices::collisionId; + Preslice LcCollisionsPerCollision = aod::jlcindices::collisionId; + Preslice DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; + Preslice D0sPerCollision = aod::jd0indices::collisionId; + Preslice LcsPerCollision = aod::jlcindices::collisionId; + Preslice DielectronsPerCollision = aod::jdielectronindices::collisionId; + PresliceUnsorted EMCTrackPerTrack = aod::jemctrack::trackId; std::vector collisionFlag; std::vector McCollisionFlag; - std::vector bcIndicies; + std::vector bcIndicies; uint32_t precisionPositionMask; uint32_t precisionMomentumMask; - int eventSelection = -1; + 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 - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(config.eventSelectionForCounting)); + randomNumber.SetSeed(0); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(config.triggerMasks); } bool acceptCollision(aod::JCollision const&) @@ -163,148 +176,194 @@ struct JetDerivedDataWriter { return true; } - void processCollisions(aod::JCollisions const& collisions) + void processSetupCollisions(aod::JCollisions const& collisions) { collisionFlag.clear(); collisionFlag.resize(collisions.size()); std::fill(collisionFlag.begin(), collisionFlag.end(), false); } - void processMcCollisions(aod::JMcCollisions const& Mccollisions) + void processSetupMcCollisions(aod::JMcCollisions const& McCollisions) { McCollisionFlag.clear(); - McCollisionFlag.resize(Mccollisions.size()); + 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; + } + } + } + + void processSetupAllMcCollisionsWithDownscaling(aod::JMcCollisions const& McCollisions) + { + 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; + } + } + } + template - void processJets(T& jets) + 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) { - float jetPtMin = 0.0; + 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.centrality() < config.centralityMin || collision.centrality() >= 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>) { - jetPtMin = config.chargedJetPtMin; + selectionObjectPtMin = config.thresholdChargedJetPtMin; } else if constexpr (std::is_same_v, aod::ChargedEventWiseSubtractedJets> || std::is_same_v, aod::ChargedMCDetectorLevelEventWiseSubtractedJets>) { - jetPtMin = config.chargedEventWiseSubtractedJetPtMin; + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedJetPtMin; } else if constexpr (std::is_same_v, aod::ChargedMCParticleLevelJets>) { - jetPtMin = config.chargedMCPJetPtMin; + selectionObjectPtMin = config.thresholdChargedMCPJetPtMin; } else if constexpr (std::is_same_v, aod::NeutralJets> || std::is_same_v, aod::NeutralMCDetectorLevelJets>) { - jetPtMin = config.neutralJetPtMin; + selectionObjectPtMin = config.thresholdNeutralJetPtMin; } else if constexpr (std::is_same_v, aod::NeutralMCParticleLevelJets>) { - jetPtMin = config.neutralMCPJetPtMin; + selectionObjectPtMin = config.thresholdNeutralMCPJetPtMin; } else if constexpr (std::is_same_v, aod::FullJets> || std::is_same_v, aod::FullMCDetectorLevelJets>) { - jetPtMin = config.fullJetPtMin; + selectionObjectPtMin = config.thresholdFullJetPtMin; } else if constexpr (std::is_same_v, aod::FullMCParticleLevelJets>) { - jetPtMin = config.fullMCPJetPtMin; + selectionObjectPtMin = config.thresholdFullMCPJetPtMin; } else if constexpr (std::is_same_v, aod::D0ChargedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelJets>) { - jetPtMin = config.chargedD0JetPtMin; + selectionObjectPtMin = config.thresholdChargedD0JetPtMin; } else if constexpr (std::is_same_v, aod::D0ChargedEventWiseSubtractedJets> || std::is_same_v, aod::D0ChargedMCDetectorLevelEventWiseSubtractedJets>) { - jetPtMin = config.chargedEventWiseSubtractedD0JetPtMin; + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedD0JetPtMin; } else if constexpr (std::is_same_v, aod::D0ChargedMCParticleLevelJets>) { - jetPtMin = config.chargedD0MCPJetPtMin; + selectionObjectPtMin = config.thresholdChargedD0MCPJetPtMin; } else if constexpr (std::is_same_v, aod::LcChargedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelJets>) { - jetPtMin = config.chargedLcJetPtMin; + selectionObjectPtMin = config.thresholdChargedLcJetPtMin; } else if constexpr (std::is_same_v, aod::LcChargedEventWiseSubtractedJets> || std::is_same_v, aod::LcChargedMCDetectorLevelEventWiseSubtractedJets>) { - jetPtMin = config.chargedEventWiseSubtractedLcJetPtMin; + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedLcJetPtMin; } else if constexpr (std::is_same_v, aod::LcChargedMCParticleLevelJets>) { - jetPtMin = config.chargedLcMCPJetPtMin; + selectionObjectPtMin = config.thresholdChargedLcMCPJetPtMin; } else if constexpr (std::is_same_v, aod::DielectronChargedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelJets>) { - jetPtMin = config.chargedDielectronJetPtMin; + selectionObjectPtMin = config.thresholdChargedDielectronJetPtMin; } else if constexpr (std::is_same_v, aod::DielectronChargedEventWiseSubtractedJets> || std::is_same_v, aod::DielectronChargedMCDetectorLevelEventWiseSubtractedJets>) { - jetPtMin = config.chargedEventWiseSubtractedDielectronJetPtMin; + selectionObjectPtMin = config.thresholdChargedEventWiseSubtractedDielectronJetPtMin; } else if constexpr (std::is_same_v, aod::DielectronChargedMCParticleLevelJets>) { - jetPtMin = config.chargedDielectronMCPJetPtMin; + 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 { - jetPtMin = 0.0; + selectionObjectPtMin = 0.0; } - for (const auto& jet : jets) { - if (jet.pt() >= jetPtMin) { + 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 (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>) { - McCollisionFlag[jet.mcCollisionId()] = true; + if (selectionObject.mcCollisionId() >= 0) { + McCollisionFlag[selectionObject.mcCollisionId()] = true; + } } else { - collisionFlag[jet.collisionId()] = true; + if (selectionObject.collisionId() >= 0) { + collisionFlag[selectionObject.collisionId()] = true; + } } } } } // Todo : Check memory consumption of having so many Process Switches - PROCESS_SWITCH(JetDerivedDataWriter, processCollisions, "setup the writing for data and MCD", true); - PROCESS_SWITCH(JetDerivedDataWriter, processMcCollisions, "setup the writing for MCP", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processChargedJets, "process charged jets", true); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processChargedEventWiseSubtractedJets, "process charged event-wise subtracted jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processChargedMCDJets, "process charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processChargedMCDetectorLevelEventWiseSubtractedJets, "process charged event-wise subtracted mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processChargedMCPJets, "process charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processNeutralJets, "process neutral jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processNeutralMCDJets, "process neutral mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processNeutralMCPJets, "process neutral mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processFullJets, "process full jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processFullMCDJets, "process full mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processFullMCPJets, "process full mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processD0ChargedJets, "process D0 charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processD0ChargedEventWiseSubtractedJets, "process D0 event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processD0ChargedMCDJets, "process D0 charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processD0ChargedMCDetectorLevelEventWiseSubtractedJets, "process D0 event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processD0ChargedMCPJets, "process D0 charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processLcChargedJets, "process Lc charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processLcChargedEventWiseSubtractedJets, "process Lc event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processLcChargedMCDJets, "process Lc charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processLcChargedMCDetectorLevelEventWiseSubtractedJets, "process Lc event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processLcChargedMCPJets, "process Lc charged mcp jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processDielectronChargedJets, "process Dielectron charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processDielectronChargedEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processDielectronChargedMCDJets, "process Dielectron charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processDielectronChargedMCDetectorLevelEventWiseSubtractedJets, "process Dielectron event-wise subtracted charged mcd jets", false); - PROCESS_SWITCH_FULL(JetDerivedDataWriter, processJets, processDielectronChargedMCPJets, "process Dielectron charged mcp jets", false); - - void processDummyTable(aod::JDummys const&) + 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, 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&) { products.storedJDummysTable(1); } - PROCESS_SWITCH(JetDerivedDataWriter, processDummyTable, "write out dummy output table", true); + PROCESS_SWITCH(JetDerivedDataWriter, processStoreDummyTable, "write out dummy output table", true); - void processCollisionCounting(aod::JCollisions const& collisions, aod::CollisionCounts const& collisionCounts) - { - int readCollisionCounter = 0; - int readSelectedCollisionCounter = 0; - int writtenCollisionCounter = 0; - for (const auto& collision : collisions) { - readCollisionCounter++; - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { - readSelectedCollisionCounter++; - } - if (collisionFlag[collision.globalIndex()]) { - writtenCollisionCounter++; - } - } - std::vector previousReadCounts; - std::vector previousReadSelectedCounts; - std::vector previousWrittenCounts; - int iPreviousDataFrame = 0; - for (const auto& collisionCount : collisionCounts) { - auto readCollisionCounterSpan = collisionCount.readCounts(); - auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts(); - auto writtenCollisionCounterSpan = collisionCount.writtenCounts(); - if (iPreviousDataFrame == 0) { - std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts)); - std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts)); - std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts)); - } else { - for (unsigned int i = 0; i < previousReadCounts.size(); i++) { - previousReadCounts[i] += readCollisionCounterSpan[i]; - previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i]; - previousWrittenCounts[i] += writtenCollisionCounterSpan[i]; - } - } - iPreviousDataFrame++; - } - previousReadCounts.push_back(readCollisionCounter); - previousReadSelectedCounts.push_back(readSelectedCollisionCounter); - previousWrittenCounts.push_back(writtenCollisionCounter); - products.storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts); - } - PROCESS_SWITCH(JetDerivedDataWriter, processCollisionCounting, "write out collision counting output table", false); - - void processData(soa::Join::iterator const& collision, soa::Join const&, soa::Join const& tracks, soa::Join const& clusters, CollisionsD0 const& D0Collisions, CandidatesD0Data const& D0s, CollisionsLc const& LcCollisions, CandidatesLcData const& Lcs, CollisionsDielectron const& DielectronCollisions, CandidatesDielectronData const& Dielectrons) + 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::CollisionsDielectron const& DielectronCollisions, aod::CandidatesDielectronData const& Dielectrons) { std::map bcMapping; std::map trackMapping; @@ -313,14 +372,14 @@ struct JetDerivedDataWriter { 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()); + 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())); } } - products.storedJCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multiplicity(), collision.centrality(), collision.eventSel(), collision.alias_raw()); + 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; @@ -330,16 +389,19 @@ struct JetDerivedDataWriter { } products.storedJCollisionsBunchCrossingIndexTable(storedBCID); } - products.storedJChargedTriggerSelsTable(collision.chargedTriggerSel()); - products.storedJFullTriggerSelsTable(collision.fullTriggerSel()); - products.storedJChargedHFTriggerSelsTable(collision.chargedHFTriggerSel()); + if (config.saveClustersTable) { + products.storedJCollisionsEMCalLabelTable(collision.isAmbiguous(), collision.isEmcalReadout()); + } 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 + 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.dcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigma1Pt(), precisionMomentumMask)); + 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())); } @@ -350,11 +412,14 @@ struct JetDerivedDataWriter { cluster.nlm(), cluster.definition(), cluster.leadingCellEnergy(), cluster.subleadingCellEnergy(), cluster.leadingCellNumber(), cluster.subleadingCellNumber()); products.storedJClustersParentIndexTable(cluster.clusterId()); - std::vector clusterStoredJTrackIDs; + 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); @@ -440,9 +505,9 @@ struct JetDerivedDataWriter { } // process switch for output writing must be last // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processData, "write out data output tables", false); + PROCESS_SWITCH(JetDerivedDataWriter, processStoreData, "write out data output tables", false); - void processMC(soa::Join const& mcCollisions, soa::Join const& collisions, soa::Join const&, soa::Join const& tracks, soa::Join const& clusters, soa::Join const& particles, CollisionsD0 const& D0Collisions, CandidatesD0MCD const& D0s, soa::Join const& D0McCollisions, CandidatesD0MCP const& D0Particles, CollisionsLc const& LcCollisions, CandidatesLcMCD const& Lcs, soa::Join const& LcMcCollisions, CandidatesLcMCP const& LcParticles, CollisionsDielectron const& DielectronCollisions, CandidatesDielectronMCD const& Dielectrons, McCollisionsDielectron const& DielectronMcCollisions, CandidatesDielectronMCP const& DielectronParticles) + 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::CollisionsDielectron const& DielectronCollisions, aod::CandidatesDielectronMCD const& Dielectrons, aod::McCollisionsDielectron const& DielectronMcCollisions, aod::CandidatesDielectronMCP const& DielectronParticles) { std::map bcMapping; std::map paticleMapping; @@ -473,7 +538,7 @@ struct JetDerivedDataWriter { } for (auto particle : particlesPerMcCollision) { - std::vector mothersId; + std::vector mothersId; if (particle.has_mothers()) { auto mothersIdTemps = particle.mothersIds(); for (auto mothersIdTemp : mothersIdTemps) { @@ -554,7 +619,7 @@ struct JetDerivedDataWriter { if (JParticleIndex != paticleMapping.end()) { DielectronParticleId = JParticleIndex->second; } - std::vector DielectronMothersId; + std::vector DielectronMothersId; int DielectronDaughtersId[2]; if (DielectronParticle.has_mothers()) { for (auto const& DielectronMother : DielectronParticle.template mothers_as>()) { @@ -599,14 +664,14 @@ struct JetDerivedDataWriter { 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()); + 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())); } } - products.storedJCollisionsTable(collision.posX(), collision.posY(), collision.posZ(), collision.multiplicity(), collision.centrality(), collision.eventSel(), collision.alias_raw()); + 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()); auto JMcCollisionIndex = mcCollisionMapping.find(mcCollision.globalIndex()); @@ -621,17 +686,20 @@ struct JetDerivedDataWriter { } products.storedJCollisionsBunchCrossingIndexTable(storedBCID); } - products.storedJChargedTriggerSelsTable(collision.chargedTriggerSel()); - products.storedJFullTriggerSelsTable(collision.fullTriggerSel()); - products.storedJChargedHFTriggerSelsTable(collision.chargedHFTriggerSel()); + if (config.saveClustersTable) { + products.storedJCollisionsEMCalLabelTable(collision.isAmbiguous(), collision.isEmcalReadout()); + } 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.dcaXY(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.dcaZ(), precisionPositionMask), o2::math_utils::detail::truncateFloatFraction(track.sigma1Pt(), precisionMomentumMask)); + 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()) { @@ -654,16 +722,19 @@ struct JetDerivedDataWriter { cluster.nlm(), cluster.definition(), cluster.leadingCellEnergy(), cluster.subleadingCellEnergy(), cluster.leadingCellNumber(), cluster.subleadingCellNumber()); products.storedJClustersParentIndexTable(cluster.clusterId()); - std::vector clusterStoredJTrackIDs; + 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; + std::vector clusterStoredJParticleIDs; for (const auto& clusterParticleId : cluster.mcParticleIds()) { auto JParticleIndex = paticleMapping.find(clusterParticleId); if (JParticleIndex != paticleMapping.end()) { @@ -768,7 +839,7 @@ struct JetDerivedDataWriter { 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()) { + for (auto const& d0CollisionPerMcCollision : d0McCollisionPerMcCollision.template hfCollBases_as()) { auto d0CollisionIndex = D0CollisionMapping.find(d0CollisionPerMcCollision.globalIndex()); if (d0CollisionIndex != D0CollisionMapping.end()) { d0CollisionIDs.push_back(d0CollisionIndex->second); @@ -782,7 +853,7 @@ struct JetDerivedDataWriter { 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()) { + for (auto const& lcCollisionPerMcCollision : lcMcCollisionPerMcCollision.template hfCollBases_as()) { auto lcCollisionIndex = LcCollisionMapping.find(lcCollisionPerMcCollision.globalIndex()); if (lcCollisionIndex != LcCollisionMapping.end()) { lcCollisionIDs.push_back(lcCollisionIndex->second); @@ -796,9 +867,9 @@ struct JetDerivedDataWriter { } // process switch for output writing must be last // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processMC, "write out data output tables for mc", false); + PROCESS_SWITCH(JetDerivedDataWriter, processStoreMC, "write out data output tables for mc", false); - void processMCP(soa::Join const& mcCollisions, soa::Join const& particles, McCollisionsD0 const& D0McCollisions, CandidatesD0MCP const& D0Particles, McCollisionsLc const& LcMcCollisions, CandidatesLcMCP const& LcParticles, McCollisionsDielectron const& DielectronMcCollisions, CandidatesDielectronMCP const& DielectronParticles) + 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::McCollisionsDielectron const& DielectronMcCollisions, aod::CandidatesDielectronMCP const& DielectronParticles) { int particleTableIndex = 0; @@ -816,7 +887,7 @@ struct JetDerivedDataWriter { particleTableIndex++; } for (auto particle : particlesPerMcCollision) { - std::vector mothersId; + std::vector mothersId; int daughtersId[2]; if (particle.has_mothers()) { for (auto const& mother : particle.template mothers_as>()) { @@ -894,7 +965,7 @@ struct JetDerivedDataWriter { if (JParticleIndex != paticleMapping.end()) { DielectronParticleId = JParticleIndex->second; } - std::vector DielectronMothersId; + std::vector DielectronMothersId; int DielectronDaughtersId[2]; if (DielectronParticle.has_mothers()) { for (auto const& DielectronMother : DielectronParticle.template mothers_as>()) { @@ -925,7 +996,7 @@ struct JetDerivedDataWriter { } // process switch for output writing must be last // to run after all jet selections - PROCESS_SWITCH(JetDerivedDataWriter, processMCP, "write out data output tables for mcp", false); + PROCESS_SWITCH(JetDerivedDataWriter, processStoreMCP, "write out data output tables for mcp", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/TableProducer/jeteventweightmcd.cxx b/PWGJE/TableProducer/jeteventweightmcd.cxx index 2525c9cc0ea..40ce7053b8a 100644 --- a/PWGJE/TableProducer/jeteventweightmcd.cxx +++ b/PWGJE/TableProducer/jeteventweightmcd.cxx @@ -32,21 +32,21 @@ struct JetEventWeightMCDTask { Produces mcDetectorLevelWeightsTable; Produces mcDetectorLevelEventWiseSubtractedWeightsTable; - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetEventWeightMCDTask, processDummy, "Dummy process", true); - void processMCDetectorLevelEventWeight(MCDetectorLevelJetTable const& jet, soa::Join const&, JetMcCollisions const&) + void processMCDetectorLevelEventWeight(MCDetectorLevelJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { - auto collision = jet.template collision_as>(); + auto collision = jet.template collision_as>(); mcDetectorLevelWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWeight, "Fill event weight tables for detector level MC jets", false); - void processMCDetectorLevelEventWiseSubtractedEventWeight(MCDetectorLevelEventWiseSubtractedJetTable const& jet, soa::Join const&, JetMcCollisions const&) + void processMCDetectorLevelEventWiseSubtractedEventWeight(MCDetectorLevelEventWiseSubtractedJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { - auto collision = jet.template collision_as>(); + auto collision = jet.template collision_as>(); mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWiseSubtractedEventWeight, "Fill event weight tables for detector level MC jets", false); diff --git a/PWGJE/TableProducer/jeteventweightmcp.cxx b/PWGJE/TableProducer/jeteventweightmcp.cxx index 32083012d18..6a3a9742546 100644 --- a/PWGJE/TableProducer/jeteventweightmcp.cxx +++ b/PWGJE/TableProducer/jeteventweightmcp.cxx @@ -31,12 +31,12 @@ template mcParticleLevelWeightsTable; - void processDummy(JetMcCollisions const&) + void processDummy(aod::JetMcCollisions const&) { } PROCESS_SWITCH(JetEventWeightMCPTask, processDummy, "Dummy process", true); - void processMCParticleLevelEventWeight(MCParticleLevelJetTable const& jet, JetMcCollisions const&) + void processMCParticleLevelEventWeight(MCParticleLevelJetTable const& jet, aod::JetMcCollisions const&) { mcParticleLevelWeightsTable(jet.globalIndex(), jet.mcCollision().weight()); } diff --git a/PWGJE/TableProducer/jetmatchingduplicates.cxx b/PWGJE/TableProducer/jetmatchingduplicates.cxx index c56857475a8..3c6ef791d4f 100644 --- a/PWGJE/TableProducer/jetmatchingduplicates.cxx +++ b/PWGJE/TableProducer/jetmatchingduplicates.cxx @@ -53,12 +53,12 @@ struct JetMatchingDuplicates { { } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetMatchingDuplicates, processDummy, "Dummy process", true); - void processJets(JetCollisions const& collisions, + void processJets(aod::JetCollisions const& collisions, JetsBase const& jetsBase, JetsTag const& jetsTag, Tracks const& tracks, Candidates const& candidates) { diff --git a/PWGJE/TableProducer/jetmatchingmc.cxx b/PWGJE/TableProducer/jetmatchingmc.cxx index 434b93c3309..5ad292fcf8f 100644 --- a/PWGJE/TableProducer/jetmatchingmc.cxx +++ b/PWGJE/TableProducer/jetmatchingmc.cxx @@ -34,7 +34,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -template +template struct JetMatchingMc { Configurable doMatchingGeo{"doMatchingGeo", true, "Enable geometric matching"}; @@ -47,28 +47,28 @@ struct JetMatchingMc { Produces jetsTagtoBaseMatchingTable; // preslicing jet collections, only for Mc-based collection - static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex(); - static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex(); + static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex(); + static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex(); Preslice baseJetsPerCollision = jetsBaseIsMc ? aod::jet::mcCollisionId : aod::jet::collisionId; Preslice tagJetsPerCollision = jetsTagIsMc ? aod::jet::mcCollisionId : aod::jet::collisionId; - PresliceUnsorted CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; + PresliceUnsorted CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; void init(InitContext const&) { } - void processDummy(JetMcCollisions const&) + void processDummy(aod::JetMcCollisions const&) { } PROCESS_SWITCH(JetMatchingMc, processDummy, "Dummy process", true); - void processJets(JetMcCollisions const& mcCollisions, JetCollisionsMCD const& collisions, + void processJets(aod::JetMcCollisions const& mcCollisions, aod::JetCollisionsMCD const& collisions, JetsBase const& jetsBase, JetsTag const& jetsTag, - JetTracksMCD const& tracks, - JetClustersMCD const& clusters, - JetParticles const& particles, + aod::JetTracksMCD const& tracks, + ClustersBase const& clusters, + aod::JetParticles const& particles, CandidatesBase const& candidatesBase, CandidatesTag const& candidatesTag) { @@ -111,50 +111,58 @@ using ChargedJetMatching = JetMatchingMc; + aod::JMcCollisions, + aod::JDummys>; using FullJetMatching = JetMatchingMc, soa::Join, aod::FullMCDetectorLevelJetsMatchedToFullMCParticleLevelJets, aod::FullMCParticleLevelJetsMatchedToFullMCDetectorLevelJets, aod::JCollisions, - aod::JMcCollisions>; + aod::JMcCollisions, + aod::JetClustersMCD>; using NeutralJetMatching = JetMatchingMc, soa::Join, aod::NeutralMCDetectorLevelJetsMatchedToNeutralMCParticleLevelJets, aod::NeutralMCParticleLevelJetsMatchedToNeutralMCDetectorLevelJets, aod::JCollisions, - aod::JMcCollisions>; + aod::JMcCollisions, + aod::JetClustersMCD>; using D0ChargedJetMatching = JetMatchingMc, soa::Join, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCParticleLevelJets, aod::D0ChargedMCParticleLevelJetsMatchedToD0ChargedMCDetectorLevelJets, - CandidatesD0MCD, - CandidatesD0MCP>; + aod::CandidatesD0MCD, + aod::CandidatesD0MCP, + aod::JDummys>; using LcChargedJetMatching = JetMatchingMc, soa::Join, aod::LcChargedMCDetectorLevelJetsMatchedToLcChargedMCParticleLevelJets, aod::LcChargedMCParticleLevelJetsMatchedToLcChargedMCDetectorLevelJets, - CandidatesLcMCD, - CandidatesLcMCP>; + aod::CandidatesLcMCD, + aod::CandidatesLcMCP, + aod::JDummys>; /*using BplusChargedJetMatching = JetMatchingMc, soa::Join, aod::BplusChargedMCDetectorLevelJetsMatchedToBplusChargedMCParticleLevelJets, aod::BplusChargedMCParticleLevelJetsMatchedToBplusChargedMCDetectorLevelJets, - CandidatesBplusMCD, - CandidatesBplusMCP>;*/ + aod::CandidatesBplusMCD, + aod::CandidatesBplusMCP, + aod::JDummys>>;*/ using V0ChargedJetMatching = JetMatchingMc, soa::Join, aod::V0ChargedMCDetectorLevelJetsMatchedToV0ChargedMCParticleLevelJets, aod::V0ChargedMCParticleLevelJetsMatchedToV0ChargedMCDetectorLevelJets, - CandidatesV0MCD, - CandidatesV0MCP>; + aod::CandidatesV0MCD, + aod::CandidatesV0MCP, + aod::JDummys>; using DielectronChargedJetMatching = JetMatchingMc, soa::Join, aod::DielectronChargedMCDetectorLevelJetsMatchedToDielectronChargedMCParticleLevelJets, aod::DielectronChargedMCParticleLevelJetsMatchedToDielectronChargedMCDetectorLevelJets, - CandidatesDielectronMCD, - CandidatesDielectronMCP>; + aod::CandidatesDielectronMCD, + aod::CandidatesDielectronMCP, + aod::JDummys>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { std::vector tasks; diff --git a/PWGJE/TableProducer/jetmatchingmcsub.cxx b/PWGJE/TableProducer/jetmatchingmcsub.cxx index 81e2b6f41ce..819771a1088 100644 --- a/PWGJE/TableProducer/jetmatchingmcsub.cxx +++ b/PWGJE/TableProducer/jetmatchingmcsub.cxx @@ -53,15 +53,15 @@ struct JetMatchingMcSub { { } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetMatchingMcSub, processDummy, "Dummy process", true); - void processJets(JetCollisions const& collisions, + void processJets(aod::JetCollisions const& collisions, JetsBase const& jetsBase, JetsTag const& jetsTag, - JetTracks const& tracks, - JetTracksSub const& tracksSub, + aod::JetTracks const& tracks, + aod::JetTracksSub const& tracksSub, Candidates const& candidates) { @@ -103,22 +103,22 @@ using D0ChargedJetMatching = JetMatchingMcSub, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCDetectorLevelEventWiseSubtractedJets, aod::D0ChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToD0ChargedMCDetectorLevelJets, - CandidatesD0MCD>; + aod::CandidatesD0MCD>; using LcChargedJetMatching = JetMatchingMcSub, soa::Join, aod::LcChargedMCDetectorLevelJetsMatchedToLcChargedMCDetectorLevelEventWiseSubtractedJets, aod::LcChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToLcChargedMCDetectorLevelJets, - CandidatesLcMCD>; + aod::CandidatesLcMCD>; /*using BplusChargedJetMatching = JetMatchingMcSub, soa::Join, aod::BplusChargedMCDetectorLevelJetsMatchedToBplusChargedMCDetectorLevelEventWiseSubtractedJets, aod::BplusChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToBplusChargedMCDetectorLevelJets, - CandidatesBplusMCD>;*/ + aod::CandidatesBplusMCD>;*/ using DielectronChargedJetMatching = JetMatchingMcSub, soa::Join, aod::DielectronChargedMCDetectorLevelJetsMatchedToDielectronChargedMCDetectorLevelEventWiseSubtractedJets, aod::DielectronChargedMCDetectorLevelEventWiseSubtractedJetsMatchedToDielectronChargedMCDetectorLevelJets, - CandidatesDielectronMCD>; + aod::CandidatesDielectronMCD>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/TableProducer/jetmatchingsub.cxx b/PWGJE/TableProducer/jetmatchingsub.cxx index 6a8b106d89a..de8fce87bbd 100644 --- a/PWGJE/TableProducer/jetmatchingsub.cxx +++ b/PWGJE/TableProducer/jetmatchingsub.cxx @@ -53,14 +53,14 @@ struct JetMatchingSub { { } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetMatchingSub, processDummy, "Dummy process", true); - void processJets(JetCollisions const& collisions, + void processJets(aod::JetCollisions const& collisions, JetsBase const& jetsBase, JetsTag const& jetsTag, - JetTracks const& tracks, TracksTag const& tracksSub, Candidates const& candidates) + aod::JetTracks const& tracks, TracksTag const& tracksSub, Candidates const& candidates) { // initialise objects used to store the matching index arrays (array in case a mcCollision is split) before filling the matching tables @@ -103,25 +103,25 @@ using D0ChargedJetMatching = JetMatchingSub; + aod::CandidatesD0Data>; using LcChargedJetMatching = JetMatchingSub, soa::Join, aod::LcChargedJetsMatchedToLcChargedEventWiseSubtractedJets, aod::LcChargedEventWiseSubtractedJetsMatchedToLcChargedJets, aod::JTrackLcSubs, - CandidatesLcData>; + aod::CandidatesLcData>; /*using BplusChargedJetMatching = JetMatchingSub, soa::Join, aod::BplusChargedJetsMatchedToBplusChargedEventWiseSubtractedJets, aod::BplusChargedEventWiseSubtractedJetsMatchedToBplusChargedJets, aod::JTrackBplusSubs, - CandidatesBplusData>;*/ + aod::CandidatesBplusData>;*/ using DielectronChargedJetMatching = JetMatchingSub, soa::Join, aod::DielectronChargedJetsMatchedToDielectronChargedEventWiseSubtractedJets, aod::DielectronChargedEventWiseSubtractedJetsMatchedToDielectronChargedJets, aod::JTrackDielectronSubs, - CandidatesDielectronData>; + aod::CandidatesDielectronData>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { std::vector tasks; diff --git a/PWGJE/TableProducer/jettaggerhf.cxx b/PWGJE/TableProducer/jettaggerhf.cxx index 225f7919db6..02c1f7aad8d 100644 --- a/PWGJE/TableProducer/jettaggerhf.cxx +++ b/PWGJE/TableProducer/jettaggerhf.cxx @@ -33,17 +33,32 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -template +template struct JetTaggerHFTask { Produces taggingTableData; Produces taggingTableMCD; + Produces taggingTableMCP; + // configuration topological cut for track and sv + Configurable trackDcaXYMax{"trackDcaXYMax", 1, "minimum DCA xy acceptance for tracks [cm]"}; + Configurable trackDcaZMax{"trackDcaZMax", 2, "minimum DCA z acceptance for tracks [cm]"}; + 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 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 doSV{"doSV", false, "fill table for secondary vertex algorithm"}; 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))"}; @@ -52,15 +67,19 @@ struct JetTaggerHFTask { 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 tagPoint{"tagPoint", 2.5, "tagging working point"}; + Configurable minIPCount{"minIPCount", 2, "Select at least N signed impact parameter significance in jets"}; // default 2 + 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"}; + // 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; - using OriTracksData = soa::Join; - using OriTracksMCD = soa::Join; + using JetTagTracksData = soa::Join; + using JetTagTracksMCD = soa::Join; std::vector vecParamsData; std::vector vecParamsIncJetMC; @@ -77,6 +96,71 @@ struct JetTaggerHFTask { std::unique_ptr fSignImpXYSigBeautyJetMC = nullptr; std::unique_ptr fSignImpXYSigLfJetMC = nullptr; + template + void calculateJetProbability(int origin, T const& jet, U const& jtracks, std::vector& jetProb, bool const& isMC = true) + { + 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)); + } else { + if (useResoFuncFromIncJet) { + jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigIncJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, 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)); + } + if (origin == JetTaggingSpecies::lightflavour) { + jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigLfJetMC, jet, jtracks, trackDcaXYMax, trackDcaZMax, order, tagPointForIP, minSignImpXYSig)); + } + if (origin != JetTaggingSpecies::charm && origin != JetTaggingSpecies::beauty && origin != JetTaggingSpecies::lightflavour) { + jetProb.push_back(-1); + } + } + } + } + } + + template + void evaluateTrackProbQA(int origin, T const& jet, U const& /*jtracks*/, bool const& isMC = true) + { + for (auto& jtrack : jet.template tracks_as()) { + if (!jettaggingutilities::trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax)) + continue; + auto geoSign = jettaggingutilities::getGeoSign(jet, jtrack); + float probTrack = -1; + if (!isMC) { + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigData, jtrack, 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); + } else { + if (origin == JetTaggingSpecies::charm) { + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigCharmJetMC, jtrack, minSignImpXYSig); + } + if (origin == JetTaggingSpecies::beauty) { + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigBeautyJetMC, jtrack, minSignImpXYSig); + } + if (origin == JetTaggingSpecies::lightflavour) { + probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigLfJetMC, jtrack, minSignImpXYSig); + } + } + if (geoSign > 0) + registry.fill(HIST("h2_pos_track_probability_flavour"), probTrack, origin); + else + registry.fill(HIST("h2_neg_track_probability_flavour"), probTrack, origin); + } + } + } + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext const&) { @@ -87,14 +171,14 @@ struct JetTaggerHFTask { switch (resoFuncMatch) { case 0: vecParamsData = (std::vector)paramsResoFuncData; - vecParamsIncJetMC = (std::vector)paramsResoFuncIncJetMC; + vecParamsCharmJetMC = (std::vector)paramsResoFuncCharmJetMC; + vecParamsBeautyJetMC = (std::vector)paramsResoFuncBeautyJetMC; + vecParamsLfJetMC = (std::vector)paramsResoFuncLfJetMC; LOG(info) << "defined parameters of resolution function: custom"; break; case 1: vecParamsData = (std::vector)paramsResoFuncData; - vecParamsCharmJetMC = (std::vector)paramsResoFuncCharmJetMC; - vecParamsBeautyJetMC = (std::vector)paramsResoFuncBeautyJetMC; - vecParamsLfJetMC = (std::vector)paramsResoFuncLfJetMC; + vecParamsIncJetMC = (std::vector)paramsResoFuncIncJetMC; useResoFuncFromIncJet = true; LOG(info) << "defined parameters of resolution function: custom & use inclusive distribution"; break; @@ -113,15 +197,15 @@ struct JetTaggerHFTask { break; case 4: // TODO vecParamsData = (std::vector)paramsResoFuncData; - vecParamsCharmJetMC = {281446.003, -0.063, 0.894, 11.598, 0.943, 8.025, 0.130, 6.227, 0.027}; - vecParamsBeautyJetMC = {74839.065, -0.081, 0.875, 10.314, 0.939, 7.326, 0.101, 6.309, 0.024}; - vecParamsLfJetMC = {1531580.038, -0.062, -0.896, 13.267, 1.034, 5.866, 0.004, 7.836, 0.090}; - LOG(info) << "defined parameters of resolution function: PYTHIA8, JJ, LHC23d4"; + vecParamsCharmJetMC = {743719.121, -0.960, -0.240, 13.765, 1.314, 10.761, 0.293, 8.538, 0.052}; + vecParamsBeautyJetMC = {88888.418, 0.256, 1.003, 10.185, 0.740, 8.216, 0.147, 7.228, 0.040}; + vecParamsLfJetMC = {414860.372, -1.000, 0.285, 14.561, 1.464, 11.693, 0.339, 9.183, 0.052}; + LOG(info) << "defined parameters of resolution function: PYTHIA8, JJ, weighted, LHC24g4"; break; case 5: // TODO vecParamsData = (std::vector)paramsResoFuncData; - vecParamsIncJetMC = {1900387.527, -0.059, 0.895, 13.461, 1.004, 8.860, 0.098, 6.931, 0.011}; - LOG(info) << "defined parameters of resolution function: PYTHIA8, JJ, LHC23d4 & use inclusive distribution"; + vecParamsIncJetMC = {2211391.862, 0.360, 1.028, 13.019, 0.650, 11.151, 0.215, 9.462, 0.044}; + LOG(info) << "defined parameters of resolution function: PYTHIA8, JJ, weighted, LHC24g4 & use inclusive distribution"; useResoFuncFromIncJet = true; break; default: @@ -139,122 +223,165 @@ struct JetTaggerHFTask { if (trackProbQA) { AxisSpec trackProbabilityAxis = {binTrackProbability, "Track proability"}; AxisSpec jetFlavourAxis = {binJetFlavour, "Jet flavour"}; - 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 (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 (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}}}); + } } } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetTaggerHFTask, processDummy, "Dummy process", true); - void processData(JetCollision const& collision, JetTableData const& jets, JetTagTracksData const& jtracks, OriTracksData const& tracks) + void processData(aod::JetCollision const& /*collision*/, JetTableData const& jets, JetTagTracksData const& jtracks) { for (auto& jet : jets) { - int algorithm2 = 0; - int algorithm3 = 0; + bool flagtaggedjetIP = false; + bool flagtaggedjetIPxyz = false; + bool flagtaggedjetSV = false; + bool flagtaggedjetSVxyz = false; if (useJetProb) { - jetProb.clear(); - jetProb.reserve(maxOrder); - for (int order = 0; order < maxOrder; order++) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigData, collision, jet, jtracks, tracks, order, tagPoint, minSignImpXYSig)); + calculateJetProbability(0, jet, jtracks, jetProb, false); + if (trackProbQA) { + evaluateTrackProbQA(0, jet, jtracks, false); } } - // if (doSV) algorithm2 = jettaggingutilities::Algorithm2((mcdjet, tracks); - taggingTableData(0, jetProb, algorithm2, algorithm3); + 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); } } PROCESS_SWITCH(JetTaggerHFTask, processData, "Fill tagging decision for data jets", false); - void processMCD(JetCollision const& collision, JetTableMCD const& mcdjets, JetTagTracksMCD const& jtracks, OriTracksMCD const& tracks, JetParticles const& particles) + void processDataWithSV(aod::JetCollision const& /*collision*/, soa::Join const& jets, JetTagTracksData const& jtracks, aod::DataSecondaryVertex3Prongs const& prongs) + { + 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); + } + } + 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); + } + } + 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) { 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); + origin = jettaggingutilities::mcdJetFromHFShower(mcdjet, jtracks, particles, maxDeltaR, searchUpToQuark); else - origin = jettaggingutilities::jetTrackFromHFShower(mcdjet, jtracks, particles, hftrack); - int algorithm2 = 0; - int algorithm3 = 0; + origin = jettaggingutilities::jetTrackFromHFShower(mcdjet, jtracks, particles, hftrack, searchUpToQuark); if (useJetProb) { - jetProb.clear(); - jetProb.reserve(maxOrder); - for (int order = 0; order < maxOrder; order++) { - if (useResoFuncFromIncJet) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigIncJetMC, collision, mcdjet, jtracks, tracks, order, tagPoint, minSignImpXYSig)); - } else { - if (origin == JetTaggingSpecies::charm) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigCharmJetMC, collision, mcdjet, jtracks, tracks, order, tagPoint, minSignImpXYSig)); - } - if (origin == JetTaggingSpecies::beauty) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigBeautyJetMC, collision, mcdjet, jtracks, tracks, order, tagPoint, minSignImpXYSig)); - } - if (origin == JetTaggingSpecies::lightflavour) { - jetProb.push_back(jettaggingutilities::getJetProbability(fSignImpXYSigLfJetMC, collision, mcdjet, jtracks, tracks, order, tagPoint, minSignImpXYSig)); - } - } - } + calculateJetProbability(origin, mcdjet, jtracks, jetProb); if (trackProbQA) { - for (auto& jtrack : mcdjet.template tracks_as()) { - auto track = jtrack.template track_as(); - auto geoSign = jettaggingutilities::getGeoSign(collision, mcdjet, track); - float probTrack = -1; - if (useResoFuncFromIncJet) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigIncJetMC, track, minSignImpXYSig); - } else { - if (origin == JetTaggingSpecies::charm) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigCharmJetMC, track, minSignImpXYSig); - } - if (origin == JetTaggingSpecies::beauty) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigBeautyJetMC, track, minSignImpXYSig); - } - if (origin == JetTaggingSpecies::lightflavour) { - probTrack = jettaggingutilities::getTrackProbability(fSignImpXYSigLfJetMC, track, minSignImpXYSig); - } - } - if (geoSign > 0) { - registry.fill(HIST("h2_pos_track_probability_flavour"), probTrack, origin); - } else { - registry.fill(HIST("h2_neg_track_probability_flavour"), probTrack, origin); - } - } + evaluateTrackProbQA(origin, mcdjet, jtracks); } } - // if (doSV) algorithm2 = jettaggingutilities::Algorithm2((mcdjet, tracks); - taggingTableMCD(origin, jetProb, algorithm2, algorithm3); + 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 processTraining(JetCollision const& /*collision*/, JetTableMCD const& /*mcdjets*/, JetTagTracksMCD const& /*tracks*/) + void processMCDWithSV(aod::JetCollision const& /*collision*/, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::MCDSecondaryVertex3Prongs const& prongs, aod::JetParticles const& particles) { - // To create table for ML + 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, processTraining, "Fill tagging decision for mcd jets", false); -}; - -struct JetTaggerHFExtTask { + PROCESS_SWITCH(JetTaggerHFTask, processMCDWithSV, "Fill tagging decision for mcd jets with sv", false); - Produces jTracksTagTable; - - void init(InitContext const&) + void processMCP(aod::JetMcCollision const& /*collision*/, JetTableMCP const& mcpjets, aod::JetParticles const& particles) { + 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); + } } + PROCESS_SWITCH(JetTaggerHFTask, processMCP, "Fill tagging decision for mcp jets with sv", false); - void processTracks(soa::Join::iterator const& track) + void processTraining(aod::JetCollision const& /*collision*/, JetTableMCD const& /*mcdjets*/, JetTagTracksMCD const& /*tracks*/) { - float sigmaDcaXYZ2 = 0; - float dcaXYZ = getDcaXYZ(track, &sigmaDcaXYZ2); - - jTracksTagTable(dcaXYZ, sigmaDcaXYZ2); + // To create table for ML } - PROCESS_SWITCH(JetTaggerHFExtTask, processTracks, "produces derived track table for tagging", true); + PROCESS_SWITCH(JetTaggerHFTask, processTraining, "Fill tagging decision for mcd jets", false); }; -using JetTaggerChargedJets = JetTaggerHFTask, soa::Join, aod::ChargedJetTags, aod::ChargedMCDetectorLevelJetTags>; -using JetTaggerFullJets = JetTaggerHFTask, soa::Join, aod::FullJetTags, aod::FullMCDetectorLevelJetTags>; +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>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) @@ -262,10 +389,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) std::vector tasks; - tasks.emplace_back( - adaptAnalysisTask(cfgc, - SetDefaultProcesses{}, TaskName{"jet-taggerhf-extension"})); - tasks.emplace_back( adaptAnalysisTask(cfgc, SetDefaultProcesses{}, TaskName{"jet-taggerhf-charged"})); diff --git a/PWGJE/TableProducer/luminositycalculator.cxx b/PWGJE/TableProducer/luminositycalculator.cxx new file mode 100644 index 00000000000..c818ad6b3b2 --- /dev/null +++ b/PWGJE/TableProducer/luminositycalculator.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 luminositycalculator.cxx +/// \brief Task to calculate luminosity of measured data. The luminosity per TVX trigger can be obtained from the eventselectiontask (at the time of writing the variable csTVX) +/// +/// \author Nima Zardoshti + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/runDataProcessing.h" +#include "Framework/HistogramRegistry.h" + +#include "PWGJE/DataModel/JetReducedData.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct LuminosityCalculator { + + HistogramRegistry registry; + 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"}; + 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++) { + counter->GetXaxis()->SetBinLabel(iCounter + 1, histLabels[iCounter].data()); + } + } + + void processCalculateLuminosity(aod::StoredBCCounts const& bcCounts, aod::StoredCollisionCounts const& collisionCounts) + { + int readBC = 0; + int readBCWithTVXCounter = 0; + int readBCWithTVXAndNoTFBCounter = 0; + int readBCWithTVXAndNoTFBAndNoITSROFB = 0; + + for (const auto& bcCount : bcCounts) { + readBC += bcCount.readCounts().front(); + readBCWithTVXCounter += bcCount.readCountsWithTVX().front(); + readBCWithTVXAndNoTFBCounter += bcCount.readCountsWithTVXAndNoTFB().front(); + readBCWithTVXAndNoTFBAndNoITSROFB += bcCount.readCountsWithTVXAndNoTFBAndNoITSROFB().front(); + } + + int readCollision = 0; + int readCollisionWithTVXCounter = 0; + int readCollisionWithTVXAndZVertexAndSel8Counter = 0; + int readCollisionWithTVXAndZVertexAndSel8FullCounter = 0; + int readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCFullCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter = 0; + int readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter = 0; + int readCollisionWithTVXAndZVertexAndSelTVXCounter = 0; + int readCollisionWithTVXAndZVertexAndSel7Counter = 0; + int readCollisionWithTVXAndZVertexAndSel7KINT7Counter = 0; + + for (const auto& collisionCount : collisionCounts) { + readCollision += collisionCount.readCounts().front(); + readCollisionWithTVXCounter += collisionCount.readCountsWithTVX().front(); + readCollisionWithTVXAndZVertexAndSel8Counter += collisionCount.readCountsWithTVXAndZVertexAndSel8().front(); + readCollisionWithTVXAndZVertexAndSel8FullCounter += collisionCount.readCountsWithTVXAndZVertexAndSel8Full().front(); + readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter += collisionCount.readCountsWithTVXAndZVertexAndSel8FullPbPb().front(); + readCollisionWithTVXAndZVertexAndSelMCCounter += collisionCount.readCountsWithTVXAndZVertexAndSelMC().front(); + readCollisionWithTVXAndZVertexAndSelMCFullCounter += collisionCount.readCountsWithTVXAndZVertexAndSelMCFull().front(); + readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter += collisionCount.readCountsWithTVXAndZVertexAndSelMCFullPbPb().front(); + readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter += collisionCount.readCountsWithTVXAndZVertexAndSelUnanchoredMC().front(); + readCollisionWithTVXAndZVertexAndSelTVXCounter += collisionCount.readCountsWithTVXAndZVertexAndSelTVX().front(); + readCollisionWithTVXAndZVertexAndSel7Counter += collisionCount.readCountsWithTVXAndZVertexAndSel7().front(); + readCollisionWithTVXAndZVertexAndSel7KINT7Counter += collisionCount.readCountsWithTVXAndZVertexAndSel7KINT7().front(); + } + + registry.get(HIST("counter"))->SetBinContent(1, registry.get(HIST("counter"))->GetBinContent(1) + readBC); + registry.get(HIST("counter"))->SetBinContent(2, registry.get(HIST("counter"))->GetBinContent(2) + readBCWithTVXCounter); + registry.get(HIST("counter"))->SetBinContent(3, registry.get(HIST("counter"))->GetBinContent(3) + readBCWithTVXAndNoTFBCounter); + registry.get(HIST("counter"))->SetBinContent(4, registry.get(HIST("counter"))->GetBinContent(4) + readBCWithTVXAndNoTFBAndNoITSROFB); + registry.get(HIST("counter"))->SetBinContent(5, registry.get(HIST("counter"))->GetBinContent(5) + readCollision); + registry.get(HIST("counter"))->SetBinContent(6, registry.get(HIST("counter"))->GetBinContent(6) + readCollisionWithTVXCounter); + registry.get(HIST("counter"))->SetBinContent(7, registry.get(HIST("counter"))->GetBinContent(7) + readCollisionWithTVXAndZVertexAndSel8Counter); + registry.get(HIST("counter"))->SetBinContent(8, registry.get(HIST("counter"))->GetBinContent(8) + readCollisionWithTVXAndZVertexAndSel8FullCounter); + registry.get(HIST("counter"))->SetBinContent(9, registry.get(HIST("counter"))->GetBinContent(9) + readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter); + registry.get(HIST("counter"))->SetBinContent(10, registry.get(HIST("counter"))->GetBinContent(10) + readCollisionWithTVXAndZVertexAndSelMCCounter); + registry.get(HIST("counter"))->SetBinContent(11, registry.get(HIST("counter"))->GetBinContent(11) + readCollisionWithTVXAndZVertexAndSelMCFullCounter); + registry.get(HIST("counter"))->SetBinContent(12, registry.get(HIST("counter"))->GetBinContent(12) + readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter); + registry.get(HIST("counter"))->SetBinContent(13, registry.get(HIST("counter"))->GetBinContent(13) + readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter); + 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); + } + PROCESS_SWITCH(LuminosityCalculator, processCalculateLuminosity, "calculate ingredients for luminosity and fill a histogram", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-luminosity-calculator"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/luminosityproducer.cxx b/PWGJE/TableProducer/luminosityproducer.cxx new file mode 100644 index 00000000000..45592ba5d87 --- /dev/null +++ b/PWGJE/TableProducer/luminosityproducer.cxx @@ -0,0 +1,228 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 luminosityproducer.cxx +/// \brief Task to produce tables needed for normalisation and luminosity calculation +/// +/// \author Nima Zardoshti + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/runDataProcessing.h" + +#include "PWGJE/DataModel/JetReducedData.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct LuminosityProducer { + + Produces storedBCCountsTable; + Produces storedCollisionCountsTable; + + Configurable vertexZCutForCounting{"vertexZCutForCounting", 10.0, "choose z-vertex cut for collision counter"}; + + void init(InitContext&) + { + } + + void processStoreBCCounting(aod::JBCs const& bcs, aod::BCCounts const& bcCounts) + { + int readBCCounter = 0; + int readBCWithTVXCounter = 0; + int readBCWithTVXAndNoTFBCounter = 0; + int readBCWithTVXAndNoTFBAndNoITSROFBCounter = 0; + for (const auto& bc : bcs) { + readBCCounter++; + if (bc.selection_bit(aod::evsel::EventSelectionFlags::kIsTriggerTVX)) { + readBCWithTVXCounter++; + if (bc.selection_bit(aod::evsel::EventSelectionFlags::kNoTimeFrameBorder)) { + readBCWithTVXAndNoTFBCounter++; + if (bc.selection_bit(aod::evsel::EventSelectionFlags::kNoITSROFrameBorder)) { + readBCWithTVXAndNoTFBAndNoITSROFBCounter++; + } + } + } + } + std::vector previousReadCounts; + std::vector previousReadCountsWithTVX; + std::vector previousReadCountsWithTVXAndNoTFB; + std::vector previousReadCountsWithTVXAndNoTFBAndNoITSROFB; + int iPreviousDataFrame = 0; + for (const auto& bcCount : bcCounts) { + auto readBCCounterSpan = bcCount.readCounts(); + auto readBCWithTVXCounterSpan = bcCount.readCountsWithTVX(); + auto readBCWithTVXAndNoTFBCounterSpan = bcCount.readCountsWithTVXAndNoTFB(); + auto readBCWithTVXAndNoTFBAndNoITSROFBCounterSpan = bcCount.readCountsWithTVXAndNoTFBAndNoITSROFB(); + if (iPreviousDataFrame == 0) { + std::copy(readBCCounterSpan.begin(), readBCCounterSpan.end(), std::back_inserter(previousReadCounts)); + std::copy(readBCWithTVXCounterSpan.begin(), readBCWithTVXCounterSpan.end(), std::back_inserter(previousReadCountsWithTVX)); + std::copy(readBCWithTVXAndNoTFBCounterSpan.begin(), readBCWithTVXAndNoTFBCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndNoTFB)); + std::copy(readBCWithTVXAndNoTFBAndNoITSROFBCounterSpan.begin(), readBCWithTVXAndNoTFBAndNoITSROFBCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndNoTFBAndNoITSROFB)); + } 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 + previousReadCounts[i] += readBCCounterSpan[i]; + previousReadCountsWithTVX[i] += readBCWithTVXCounterSpan[i]; + previousReadCountsWithTVXAndNoTFB[i] += readBCWithTVXAndNoTFBCounterSpan[i]; + previousReadCountsWithTVXAndNoTFBAndNoITSROFB[i] += readBCWithTVXAndNoTFBAndNoITSROFBCounterSpan[i]; + } + } + iPreviousDataFrame++; + } + previousReadCounts.push_back(readBCCounter); + previousReadCountsWithTVX.push_back(readBCWithTVXCounter); + previousReadCountsWithTVXAndNoTFB.push_back(readBCWithTVXAndNoTFBCounter); + previousReadCountsWithTVXAndNoTFBAndNoITSROFB.push_back(readBCWithTVXAndNoTFBAndNoITSROFBCounter); + storedBCCountsTable(previousReadCounts, previousReadCountsWithTVX, previousReadCountsWithTVXAndNoTFB, previousReadCountsWithTVXAndNoTFBAndNoITSROFB); + } + PROCESS_SWITCH(LuminosityProducer, processStoreBCCounting, "write out bc counting output table", true); + + void processStoreCollisionCounting(aod::JCollisions const& collisions, aod::CollisionCounts const& collisionCounts) + { + int readCollisionCounter = 0; + int readCollisionWithTVXCounter = 0; + int readCollisionWithTVXAndZVertexAndSel8Counter = 0; + int readCollisionWithTVXAndZVertexAndSel8FullCounter = 0; + int readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCFullCounter = 0; + int readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter = 0; + int readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter = 0; + int readCollisionWithTVXAndZVertexAndSelTVXCounter = 0; // redundant but we keep it + int readCollisionWithTVXAndZVertexAndSel7Counter = 0; + int readCollisionWithTVXAndZVertexAndSel7KINT7Counter = 0; + for (const auto& collision : collisions) { + readCollisionCounter++; + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selTVX)) { // asuumes all selections include the TVX trigger + readCollisionWithTVXCounter++; + if (std::abs(collision.posZ()) > vertexZCutForCounting) { + continue; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) { + readCollisionWithTVXAndZVertexAndSel8Counter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8Full)) { + readCollisionWithTVXAndZVertexAndSel8FullCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8FullPbPb)) { + readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMC)) { + readCollisionWithTVXAndZVertexAndSelMCCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMCFull)) { + readCollisionWithTVXAndZVertexAndSelMCFullCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::selMCFullPbPb)) { + readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter++; + } + if (jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::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++; + } + } + } + std::vector previousReadCounts; + std::vector previousReadCountsWithTVX; + std::vector previousReadCountsWithTVXAndZVertexAndSel8; + std::vector previousReadCountsWithTVXAndZVertexAndSel8Full; + std::vector previousReadCountsWithTVXAndZVertexAndSel8FullPbPb; + std::vector previousReadCountsWithTVXAndZVertexAndSelMC; + std::vector previousReadCountsWithTVXAndZVertexAndSelMCFull; + std::vector previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb; + std::vector previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC; + std::vector previousReadCountsWithTVXAndZVertexAndSelTVX; + std::vector previousReadCountsWithTVXAndZVertexAndSel7; + std::vector previousReadCountsWithTVXAndZVertexAndSel7KINT7; + + int iPreviousDataFrame = 0; + for (const auto& collisionCount : collisionCounts) { + auto readCollisionCounterSpan = collisionCount.readCounts(); + auto readCollisionWithTVXCounterSpan = collisionCount.readCountsWithTVX(); + auto readCollisionWithTVXAndZVertexAndSel8CounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel8(); + auto readCollisionWithTVXAndZVertexAndSel8FullCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel8Full(); + auto readCollisionWithTVXAndZVertexAndSel8FullPbPbCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel8FullPbPb(); + auto readCollisionWithTVXAndZVertexAndSelMCCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelMC(); + auto readCollisionWithTVXAndZVertexAndSelMCFullCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelMCFull(); + auto readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelMCFullPbPb(); + auto readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelUnanchoredMC(); + auto readCollisionWithTVXAndZVertexAndSelTVXCounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSelTVX(); + auto readCollisionWithTVXAndZVertexAndSel7CounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel7(); + auto readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan = collisionCount.readCountsWithTVXAndZVertexAndSel7KINT7(); + + if (iPreviousDataFrame == 0) { + std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts)); + std::copy(readCollisionWithTVXCounterSpan.begin(), readCollisionWithTVXCounterSpan.end(), std::back_inserter(previousReadCountsWithTVX)); + std::copy(readCollisionWithTVXAndZVertexAndSel8CounterSpan.begin(), readCollisionWithTVXAndZVertexAndSel8CounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSel8)); + std::copy(readCollisionWithTVXAndZVertexAndSel8FullCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSel8FullCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSel8Full)); + std::copy(readCollisionWithTVXAndZVertexAndSel8FullPbPbCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSel8FullPbPbCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSel8FullPbPb)); + std::copy(readCollisionWithTVXAndZVertexAndSelMCCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSelMCCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSelMC)); + std::copy(readCollisionWithTVXAndZVertexAndSelMCFullCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSelMCFullCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSelMCFull)); + std::copy(readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb)); + std::copy(readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounterSpan.begin(), readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounterSpan.end(), std::back_inserter(previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC)); + 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)); + + } 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 + previousReadCounts[i] += readCollisionCounterSpan[i]; + previousReadCountsWithTVX[i] += readCollisionWithTVXCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSel8[i] += readCollisionWithTVXAndZVertexAndSel8CounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSel8Full[i] += readCollisionWithTVXAndZVertexAndSel8FullCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSel8FullPbPb[i] += readCollisionWithTVXAndZVertexAndSel8FullPbPbCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSelMC[i] += readCollisionWithTVXAndZVertexAndSelMCCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSelMCFull[i] += readCollisionWithTVXAndZVertexAndSelMCFullCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb[i] += readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC[i] += readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSelTVX[i] += readCollisionWithTVXAndZVertexAndSelTVXCounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSel7[i] += readCollisionWithTVXAndZVertexAndSel7CounterSpan[i]; + previousReadCountsWithTVXAndZVertexAndSel7KINT7[i] += readCollisionWithTVXAndZVertexAndSel7KINT7CounterSpan[i]; + } + } + iPreviousDataFrame++; + } + previousReadCounts.push_back(readCollisionCounter); + previousReadCountsWithTVX.push_back(readCollisionWithTVXCounter); + previousReadCountsWithTVXAndZVertexAndSel8.push_back(readCollisionWithTVXAndZVertexAndSel8Counter); + previousReadCountsWithTVXAndZVertexAndSel8Full.push_back(readCollisionWithTVXAndZVertexAndSel8FullCounter); + previousReadCountsWithTVXAndZVertexAndSel8FullPbPb.push_back(readCollisionWithTVXAndZVertexAndSel8FullPbPbCounter); + previousReadCountsWithTVXAndZVertexAndSelMC.push_back(readCollisionWithTVXAndZVertexAndSelMCCounter); + previousReadCountsWithTVXAndZVertexAndSelMCFull.push_back(readCollisionWithTVXAndZVertexAndSelMCFullCounter); + previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb.push_back(readCollisionWithTVXAndZVertexAndSelMCFullPbPbCounter); + previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC.push_back(readCollisionWithTVXAndZVertexAndSelUnanchoredMCCounter); + previousReadCountsWithTVXAndZVertexAndSelTVX.push_back(readCollisionWithTVXAndZVertexAndSelTVXCounter); + previousReadCountsWithTVXAndZVertexAndSel7.push_back(readCollisionWithTVXAndZVertexAndSel7Counter); + previousReadCountsWithTVXAndZVertexAndSel7KINT7.push_back(readCollisionWithTVXAndZVertexAndSel7KINT7Counter); + + storedCollisionCountsTable(previousReadCounts, previousReadCountsWithTVX, previousReadCountsWithTVXAndZVertexAndSel8, previousReadCountsWithTVXAndZVertexAndSel8Full, previousReadCountsWithTVXAndZVertexAndSel8FullPbPb, previousReadCountsWithTVXAndZVertexAndSelMC, previousReadCountsWithTVXAndZVertexAndSelMCFull, previousReadCountsWithTVXAndZVertexAndSelMCFullPbPb, previousReadCountsWithTVXAndZVertexAndSelUnanchoredMC, previousReadCountsWithTVXAndZVertexAndSelTVX, previousReadCountsWithTVXAndZVertexAndSel7, previousReadCountsWithTVXAndZVertexAndSel7KINT7); + } + PROCESS_SWITCH(LuminosityProducer, processStoreCollisionCounting, "write out collision counting output table", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + std::vector tasks; + + tasks.emplace_back(adaptAnalysisTask(cfgc, TaskName{"jet-luminosity-producer"})); + + return WorkflowSpec{tasks}; +} diff --git a/PWGJE/TableProducer/rhoEstimator.cxx b/PWGJE/TableProducer/rhoEstimator.cxx index a5a543125a3..8f7bd8afc0e 100644 --- a/PWGJE/TableProducer/rhoEstimator.cxx +++ b/PWGJE/TableProducer/rhoEstimator.cxx @@ -34,6 +34,7 @@ struct RhoEstimatorTask { Produces rhoD0Table; Produces rhoLcTable; Produces rhoBplusTable; + Produces rhoDielectronTable; Configurable trackPtMin{"trackPtMin", 0.15, "minimum track pT"}; Configurable trackPtMax{"trackPtMax", 1000.0, "maximum track pT"}; @@ -70,16 +71,16 @@ struct RhoEstimatorTask { 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); - void processChargedCollisions(JetCollision const& collision, soa::Filtered const& tracks) + void processChargedCollisions(aod::JetCollision const& /*collision*/, soa::Filtered const& tracks) { inputParticles.clear(); - jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); + jetfindingutilities::analyseTracks, soa::Filtered::iterator>(inputParticles, tracks, trackSelection, trackingEfficiency); auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoChargedTable(collision.globalIndex(), rho, rhoM); + rhoChargedTable(rho, rhoM); } PROCESS_SWITCH(RhoEstimatorTask, processChargedCollisions, "Fill rho tables for collisions using charged tracks", true); - void processD0Collisions(JetCollision const&, soa::Filtered const& tracks, CandidatesD0Data const& candidates) + void processD0Collisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesD0Data const& candidates) { inputParticles.clear(); for (auto& candidate : candidates) { @@ -87,12 +88,12 @@ struct RhoEstimatorTask { jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoD0Table(candidate.globalIndex(), rho, rhoM); + rhoD0Table(rho, rhoM); } } PROCESS_SWITCH(RhoEstimatorTask, processD0Collisions, "Fill rho tables for collisions with D0 candidates", false); - void processLcCollisions(JetCollision const&, soa::Filtered const& tracks, CandidatesLcData const& candidates) + void processLcCollisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesLcData const& candidates) { inputParticles.clear(); for (auto& candidate : candidates) { @@ -100,12 +101,12 @@ struct RhoEstimatorTask { jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoLcTable(candidate.globalIndex(), rho, rhoM); + rhoLcTable(rho, rhoM); } } PROCESS_SWITCH(RhoEstimatorTask, processLcCollisions, "Fill rho tables for collisions with Lc candidates", false); - void processBplusCollisions(JetCollision const&, soa::Filtered const& tracks, CandidatesBplusData const& candidates) + void processBplusCollisions(aod::JetCollision const&, soa::Filtered const& tracks, aod::CandidatesBplusData const& candidates) { inputParticles.clear(); for (auto& candidate : candidates) { @@ -113,10 +114,23 @@ struct RhoEstimatorTask { jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); - rhoBplusTable(candidate.globalIndex(), rho, rhoM); + rhoBplusTable(rho, rhoM); } } 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) + { + inputParticles.clear(); + for (auto& candidate : candidates) { + inputParticles.clear(); + jetfindingutilities::analyseTracks(inputParticles, tracks, trackSelection, trackingEfficiency, std::optional{candidate}); + + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(inputParticles, doSparse); + rhoDielectronTable(rho, rhoM); + } + } + PROCESS_SWITCH(RhoEstimatorTask, processDielectronCollisions, "Fill rho tables for collisions with Dielectron candidates", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"estimator-rho"})}; } diff --git a/PWGJE/TableProducer/secondaryVertexReconstruction.cxx b/PWGJE/TableProducer/secondaryVertexReconstruction.cxx index dc13c327a77..5ed4799a80f 100644 --- a/PWGJE/TableProducer/secondaryVertexReconstruction.cxx +++ b/PWGJE/TableProducer/secondaryVertexReconstruction.cxx @@ -62,6 +62,8 @@ struct SecondaryVertexReconstruction { 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 maxRsv{"maxRsv", 999., "max. radius of the reconstruced SV"}; + Configurable maxZsv{"maxZsv", 999., "max. Z coordinates of the reconstruced SV"}; 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 is chi2/chi2old > this"}; Configurable ptMinTrack{"ptMinTrack", -1., "min. track pT"}; @@ -94,6 +96,7 @@ struct SecondaryVertexReconstruction { registry.add("hFeNProngs", "n-prong Energy fraction carried by the SV from the jet;#it{f}_{E};nProngs;entries", {HistType::kTH2F, {{100, 0., 1.0}, nProngsBins}}); registry.add("hDcaXYNProngs", "DCAxy of n-prong candidate daughters;#it{p}_{T} (GeV/#it{c});#it{d}_{xy} (#mum);nProngs;entries", {HistType::kTH3F, {{100, 0., 20.}, {200, -500., 500.}, nProngsBins}}); registry.add("hDcaZNProngs", "DCAz of n-prong candidate daughters;#it{p}_{T} (GeV/#it{c});#it{d}_{z} (#mum);nProngs;entries", {HistType::kTH3F, {{100, 0., 20.}, {200, -500., 500.}, nProngsBins}}); + registry.add("hDispersion", "Vertex dispersion;#sigma_{vtx};nProngs;entries", {HistType::kTH2F, {{200, 0., 1.0}, nProngsBins}}); } df2.setPropagateToPCA(propagateToPCA); @@ -121,9 +124,9 @@ struct SecondaryVertexReconstruction { Filter trackCuts = (aod::jtrack::pt > ptMinTrack && aod::jtrack::eta > etaMinTrack && aod::jtrack::eta < etaMaxTrack); - using JetCollisionwPIs = soa::Join; - using JetTracksData = soa::Filtered>; - using JetTracksMCDwPIs = soa::Filtered>; + using JetCollisionwPIs = soa::Join; + using JetTracksData = soa::Filtered>; + using JetTracksMCDwPIs = soa::Filtered>; using OriginalTracks = soa::Join; template @@ -163,15 +166,36 @@ struct SecondaryVertexReconstruction { // Reconstruct the secondary vertex int processResult = 0; - std::apply([&df, &processResult](const auto&... elems) { processResult = df.process(elems...); }, trackParVars); + try { + std::apply([&df, &processResult](const auto&... elems) { processResult = df.process(elems...); }, trackParVars); + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + return; + } if (processResult == 0) { return; } - const auto& secondaryVertex = df.getPCACandidate(); + const auto& secondaryVertex = df.getPCACandidatePos(); + if (std::sqrt(secondaryVertex[0] * secondaryVertex[0] + secondaryVertex[1] * secondaryVertex[1]) > maxRsv || std::abs(secondaryVertex[2]) > maxZsv) { + return; + } + + float dispersion = 0.; + for (unsigned int inum = 0; inum < numProngs; ++inum) { + o2::dataformats::VertexBase sv(o2::math_utils::Point3D{secondaryVertex[0], secondaryVertex[1], secondaryVertex[2]}, std::array{0}); + o2::dataformats::DCA dcaSV; + auto& prong = df.getTrack(inum); + prong.propagateToDCA(sv, bz, &dcaSV); + dispersion += (dcaSV.getY() * dcaSV.getY() + dcaSV.getZ() * dcaSV.getZ()); + } + dispersion = std::sqrt(dispersion / numProngs); + 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); @@ -203,41 +227,41 @@ struct SecondaryVertexReconstruction { double massSV = RecoDecay::m(std::move(arrayMomenta), massArray); // fill candidate table rows - if (doprocessData3Prongs && numProngs == 3) { + if ((doprocessData3Prongs || doprocessData3ProngsExternalMagneticField) && numProngs == 3) { sv3prongTableData(analysisJet.globalIndex(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), secondaryVertex[0], secondaryVertex[1], secondaryVertex[2], arrayMomenta[0][0] + arrayMomenta[1][0] + arrayMomenta[2][0], arrayMomenta[0][1] + arrayMomenta[1][1] + arrayMomenta[2][1], arrayMomenta[0][2] + arrayMomenta[1][2] + arrayMomenta[2][2], - energySV, massSV, chi2PCA, errorDecayLength, errorDecayLengthXY); + energySV, massSV, chi2PCA, dispersion, errorDecayLength, errorDecayLengthXY); svIndices.push_back(sv3prongTableData.lastIndex()); - } else if (doprocessData2Prongs && numProngs == 2) { + } else if ((doprocessData2Prongs || doprocessData2ProngsExternalMagneticField) && numProngs == 2) { sv2prongTableData(analysisJet.globalIndex(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), secondaryVertex[0], secondaryVertex[1], secondaryVertex[2], arrayMomenta[0][0] + arrayMomenta[1][0], arrayMomenta[0][1] + arrayMomenta[1][1], arrayMomenta[0][2] + arrayMomenta[1][2], - energySV, massSV, chi2PCA, errorDecayLength, errorDecayLengthXY); + energySV, massSV, chi2PCA, dispersion, errorDecayLength, errorDecayLengthXY); svIndices.push_back(sv2prongTableData.lastIndex()); - } else if (doprocessMCD3Prongs && numProngs == 3) { + } else if ((doprocessMCD3Prongs || doprocessMCD3ProngsExternalMagneticField) && numProngs == 3) { sv3prongTableMCD(analysisJet.globalIndex(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), secondaryVertex[0], secondaryVertex[1], secondaryVertex[2], arrayMomenta[0][0] + arrayMomenta[1][0] + arrayMomenta[2][0], arrayMomenta[0][1] + arrayMomenta[1][1] + arrayMomenta[2][1], arrayMomenta[0][2] + arrayMomenta[1][2] + arrayMomenta[2][2], - energySV, massSV, chi2PCA, errorDecayLength, errorDecayLengthXY); + energySV, massSV, chi2PCA, dispersion, errorDecayLength, errorDecayLengthXY); svIndices.push_back(sv3prongTableMCD.lastIndex()); - } else if (doprocessMCD2Prongs && numProngs == 2) { + } else if ((doprocessMCD2Prongs || doprocessMCD2ProngsExternalMagneticField) && numProngs == 2) { sv2prongTableMCD(analysisJet.globalIndex(), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), secondaryVertex[0], secondaryVertex[1], secondaryVertex[2], arrayMomenta[0][0] + arrayMomenta[1][0], arrayMomenta[0][1] + arrayMomenta[1][1], arrayMomenta[0][2] + arrayMomenta[1][2], - energySV, massSV, chi2PCA, errorDecayLength, errorDecayLengthXY); + energySV, massSV, chi2PCA, dispersion, errorDecayLength, errorDecayLengthXY); svIndices.push_back(sv2prongTableMCD.lastIndex()); } else { LOG(error) << "No process specified\n"; diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 050decc2ba7..32f029a3b27 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -68,10 +68,18 @@ if(FastJet_FOUND) SOURCES v0jetspectra.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-v0qa + SOURCES v0qa.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-finder-charged-qa SOURCES jetfinderQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-charged-v2 + SOURCES jetchargedv2.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-finder-hf-qa SOURCES jetfinderhfQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore @@ -132,6 +140,10 @@ if(FastJet_FOUND) SOURCES phiInJets.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(nuclei-in-jets + SOURCES nucleiInJets.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-taggerhf-qa SOURCES jettaggerhfQA.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore @@ -156,5 +168,25 @@ if(FastJet_FOUND) SOURCES bjetTreeCreator.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(stat-prompt-photon + 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 + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(gamma-jet-tree-producer + SOURCES gammajettreeproducer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(bjet-tagging-ml + SOURCES bjetTaggingML.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore O2Physics::MLCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(jet-spectra-ese + SOURCES jetSpectraEseTask.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore + COMPONENT_NAME Analysis) endif() diff --git a/PWGJE/Tasks/ChJetTriggerQATask.cxx b/PWGJE/Tasks/ChJetTriggerQATask.cxx index c575736a8dd..19e4df451ff 100644 --- a/PWGJE/Tasks/ChJetTriggerQATask.cxx +++ b/PWGJE/Tasks/ChJetTriggerQATask.cxx @@ -44,6 +44,16 @@ 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; + +float DcaXYPtCut(float tracPt) +{ + return 0.0105f + 0.0350f / pow(tracPt, 1.1f); +} + // What this task should do // Event by event fill // 1) pT spectrum of tracks in TPC volume @@ -57,15 +67,10 @@ using namespace o2::framework::expressions; struct ChJetTriggerQATask { Configurable evSel{"evSel", "sel8", "choose event selection"}; - Configurable cfgVertexCut{"cfgVertexCut", 10.0, - "Accepted z-vertex range"}; - Configurable cfgTPCVolume{"cfgTPCVolume", 0.9, - "Full eta range"}; // eta range of TPC - Configurable cfgJetR{"cfgJetR", 0.4, - "jet resolution parameter"}; // jet cone radius - Configurable cfgJetPtMin{ - "cfgJetPtMin", 0.15, - "minimum jet pT constituent cut"}; // minimum jet constituent pT + Configurable cfgVertexCut{"cfgVertexCut", 10.0, "Accepted z-vertex range"}; + Configurable cfgTPCVolume{"cfgTPCVolume", 0.9, "Full eta range"}; // eta range of TPC + Configurable cfgJetR{"cfgJetR", 0.4, "jet resolution parameter"}; // jet cone radius + Configurable cfgJetPtMin{"cfgJetPtMin", 0.15, "minimum jet pT constituent cut"}; // minimum jet constituent pT Configurable cfgTrackPhiMinCut{"cfgTrackPhiMinCut", -999, "track min phi cut"}; Configurable cfgTrackPhiMaxCut{"cfgTrackPhiMaxCut", 999, "track max phi cut"}; @@ -75,16 +80,23 @@ 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 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"}; + + ConfigurableAxis dcaXY_Binning{"dcaXY_Binning", {100, -5., 5.}, ""}; + ConfigurableAxis dcaZ_Binning{"dcaZ_Binning", {100, -3., 3.}, ""}; + float fiducialVolume; // 0.9 - jetR HistogramRegistry spectra; int eventSelection = -1; int trackSelection = -1; - void init(o2::framework::InitContext&) + + void init(InitContext&) { fiducialVolume = static_cast(cfgTPCVolume) - static_cast(cfgJetR); eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); @@ -103,6 +115,20 @@ struct ChJetTriggerQATask { 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()}}}); + // Supplementary plots if (bAddSupplementHistosToOutput) { spectra.add("ptJetChInclFullVol", "inclusive charged jet pT in full volume", {HistType::kTH1F, {{200, 0., +200.}}}); @@ -127,14 +153,9 @@ struct ChJetTriggerQATask { Filter trackFilter = (nabs(aod::jtrack::eta) < static_cast(cfgTPCVolume)) && (aod::jtrack::phi > static_cast(cfgTrackPhiMinCut)) && (aod::jtrack::phi < static_cast(cfgTrackPhiMaxCut)) && (aod::jtrack::pt > static_cast(cfgJetPtMin)); // declare filters on jets - Filter jetRadiusSelection = (o2::aod::jet::r == nround(cfgJetR.node() * 100.0f)); - - using filteredJets = o2::soa::Filtered; + Filter jetRadiusSelection = (aod::jet::r == nround(cfgJetR.node() * 100.0f)); - void - process(soa::Filtered>::iterator const& collision, - soa::Filtered const& tracks, o2::soa::Filtered> const& jets) + void process(filteredColl const& collision, filteredJTracks const& tracks, filteredJets const& jets, joinedTracks const&) { if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { @@ -145,8 +166,8 @@ struct ChJetTriggerQATask { return; } - bool bLowPtJet = (bLowPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)); - bool bHighPtJet = (bHighPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)); + bool bLowPtJet = (bLowPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::jetChLowPt)); + bool bHighPtJet = (bHighPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::jetChHighPt)); bool bLowPtTrack = (bTrackLowPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::trackLowPt)); bool bHighPtTrack = (bTrackHighPtTrigger && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::trackHighPt)); bool bMinimumBias = ((!bLowPtTrigger) && (!bHighPtTrigger) && (!bTrackLowPtTrigger) && (!bTrackHighPtTrigger)); @@ -169,36 +190,68 @@ struct ChJetTriggerQATask { spectra.fill(HIST("vertexZ"), collision.posZ()); // Inclusive Track Cross TPC Rows - for (auto& trk : tracks) { // loop over filtered tracks in full TPC volume having pT > 100 MeV + for (auto const& track : tracks) { // loop over filtered tracks in full TPC volume having pT > 100 MeV + + auto const& originalTrack = track.track_as(); - if (!jetderiveddatautilities::selectTrack(trk, trackSelection)) { + spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts"), track.p(), track.p() - originalTrack.tpcInnerParam()); + + if (TMath::Abs(track.phi() - TMath::Pi()) < phiAngleRestriction) { + spectra.fill(HIST("globalP_tpcglobalPDiff_withoutcuts_phirestrict"), track.p(), track.p() - originalTrack.tpcInnerParam()); + } + + spectra.fill(HIST("ptphiAllTracks"), track.pt(), track.phi()); + + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; } + spectra.fill(HIST("ptphiQualityTracks"), track.pt(), track.phi()); + + 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()); + } + + spectra.fill(HIST("nITSClusters_TrackPt"), originalTrack.itsNCls(), track.phi(), track.pt()); + + 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 (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()); + } + } + spectra.fill( - HIST("ptphiTrackInclGood"), trk.pt(), - trk.phi()); // Inclusive Track pT vs phi spectrum in TPC volume + HIST("ptphiTrackInclGood"), track.pt(), + track.phi()); // Inclusive Track pT vs phi spectrum in TPC volume spectra.fill( - HIST("ptetaTrackInclGood"), trk.pt(), - trk.eta()); // Inclusive Track pT vs eta spectrum in TPC volume + HIST("ptetaTrackInclGood"), track.pt(), + track.eta()); // Inclusive Track pT vs eta spectrum in TPC volume if (bAddSupplementHistosToOutput) { spectra.fill( - HIST("phietaTrackAllInclGood"), trk.eta(), - trk.phi()); // Inclusive Track pT vs eta spectrum in TPC volume + HIST("phietaTrackAllInclGood"), track.eta(), + track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume - if (trk.pt() > 5.0) { + if (track.pt() > 5.0) { spectra.fill( - HIST("phietaTrackHighPtInclGood"), trk.eta(), - trk.phi()); // Inclusive Track pT vs eta spectrum in TPC volume + HIST("phietaTrackHighPtInclGood"), track.eta(), + track.phi()); // Inclusive Track pT vs eta spectrum in TPC volume } } - if (trk.pt() > + if (track.pt() > leadingTrackPt) { // Find leading track pT in full TPC volume - leadingTrackPt = trk.pt(); - leadingTrackEta = trk.eta(); - leadingTrackPhi = trk.phi(); + leadingTrackPt = track.pt(); + leadingTrackEta = track.eta(); + leadingTrackPhi = track.phi(); } } diff --git a/PWGJE/Tasks/FullJetTriggerQATask.cxx b/PWGJE/Tasks/FullJetTriggerQATask.cxx index 9dad8d604b5..99b76fcedb9 100644 --- a/PWGJE/Tasks/FullJetTriggerQATask.cxx +++ b/PWGJE/Tasks/FullJetTriggerQATask.cxx @@ -38,7 +38,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; struct JetTriggerQA { - using selectedClusters = o2::soa::Filtered; + using selectedClusters = o2::soa::Filtered; using fullJetInfos = soa::Join; using neutralJetInfos = soa::Join; using collisionWithTrigger = soa::Join::iterator; @@ -544,7 +544,7 @@ struct JetTriggerQA { } template - std::pair, std::vector> fillJetQA(const JetCollection& jets, JetTracks const& /*tracks*/, selectedClusters const& /*clusters*/, std::bitset /*hwtrg*/, const std::bitset& triggerstatus) + std::pair, std::vector> fillJetQA(const JetCollection& jets, aod::JetTracks const& /*tracks*/, selectedClusters const& /*clusters*/, std::bitset /*hwtrg*/, const std::bitset& triggerstatus) { auto isTrigger = [&triggerstatus](TriggerType_t triggertype) -> bool { return triggerstatus.test(triggertype); @@ -568,7 +568,7 @@ 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()) { + 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()); @@ -647,12 +647,12 @@ struct JetTriggerQA { return std::make_pair(vecMaxJet, vecMaxJetNoFiducial); } - using JetCollisionsTable = soa::Join; + using JetCollisionsTable = soa::Join; template void runQA(collisionWithTrigger const& collision, JetCollection const& jets, - JetTracks const& tracks, + aod::JetTracks const& tracks, selectedClusters const& clusters) { std::bitset triggerstatus; @@ -688,55 +688,51 @@ struct JetTriggerQA { setTrigger(TriggerType_t::kEmcalMB); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::fullHigh)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::jetFullHighPt)) { fillEventSelectionCounter(3); setTrigger(TriggerType_t::kEmcalJetFull); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::fullLow)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::jetFullLowPt)) { fillEventSelectionCounter(4); setTrigger(TriggerType_t::kEmcalJetFullLow); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::neutralHigh)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::jetNeutralHighPt)) { fillEventSelectionCounter(5); setTrigger(TriggerType_t::kEmcalJetNeutral); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::neutralLow)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::jetNeutralLowPt)) { fillEventSelectionCounter(6); setTrigger(TriggerType_t::kEmcalJetNeutralLow); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::neutralLow)) { - fillEventSelectionCounter(6); - setTrigger(TriggerType_t::kEmcalJetNeutralLow); - } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryHighEMCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryHighPtEMCAL)) { fillEventSelectionCounter(7); setTrigger(TriggerType_t::kEmcalGammaVeryHigh); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryHighDCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryHighPtDCAL)) { fillEventSelectionCounter(8); setTrigger(TriggerType_t::kDcalGammaVeryHigh); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaHighEMCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaHighPtEMCAL)) { fillEventSelectionCounter(9); setTrigger(TriggerType_t::kEmcalGammaHigh); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaHighDCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaHighPtDCAL)) { fillEventSelectionCounter(10); setTrigger(TriggerType_t::kDcalGammaHigh); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaLowEMCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaLowPtEMCAL)) { fillEventSelectionCounter(11); setTrigger(TriggerType_t::kEmcalGammaLow); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaLowDCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaLowPtDCAL)) { fillEventSelectionCounter(12); setTrigger(TriggerType_t::kDcalGammaLow); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryLowEMCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryLowPtEMCAL)) { fillEventSelectionCounter(13); setTrigger(TriggerType_t::kEmcalGammaVeryLow); } - if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryLowDCAL)) { + if (jetderiveddatautilities::selectFullTrigger(collision, jetderiveddatautilities::JTrigSelFull::gammaVeryLowPtDCAL)) { fillEventSelectionCounter(14); setTrigger(TriggerType_t::kDcalGammaVeryLow); } @@ -830,7 +826,7 @@ struct JetTriggerQA { void processFullJets(collisionWithTrigger const& collision, fullJetInfos const& jets, - JetTracks const& tracks, + aod::JetTracks const& tracks, selectedClusters const& clusters) { runQA(collision, jets, tracks, clusters); @@ -839,7 +835,7 @@ struct JetTriggerQA { void processNeutralJets(collisionWithTrigger const& collision, neutralJetInfos const& jets, - JetTracks const& tracks, + aod::JetTracks const& tracks, selectedClusters const& clusters) { runQA(collision, jets, tracks, clusters); diff --git a/PWGJE/Tasks/PhotonIsolationQA.cxx b/PWGJE/Tasks/PhotonIsolationQA.cxx index e25d9e11094..03b8e4f1fe6 100644 --- a/PWGJE/Tasks/PhotonIsolationQA.cxx +++ b/PWGJE/Tasks/PhotonIsolationQA.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -38,7 +40,6 @@ #include "DataFormatsEMCAL/Cell.h" #include "DataFormatsEMCAL/Constants.h" #include "DataFormatsEMCAL/AnalysisCluster.h" - #include "CommonDataFormat/InteractionRecord.h" // \struct PhotonIsolationQA @@ -56,8 +57,7 @@ using namespace o2::framework::expressions; using myGlobTracks = o2::soa::Join; using collisionEvSelIt = o2::soa::Join; -using mcCells = o2::soa::Join; -using filteredMCCells = o2::soa::Filtered; +using collisionEvSelItMC = o2::aod::McCollisions; using MCClusters = o2::soa::Join; struct PhotonIsolationQA { @@ -67,6 +67,8 @@ struct PhotonIsolationQA { using o2HistType = HistType; using o2Axis = AxisSpec; + o2::emcal::Geometry* mGeometry = nullptr; + Configurable maxPosZ{"maxPosZ", 10.0f, "maximum z position of collision in cm"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; @@ -78,16 +80,26 @@ struct PhotonIsolationQA { Configurable maxNLM{"maxNLM", 2, "Maximal amount of local maxima per cluster"}; Configurable ExoticContribution{"ExoticContribution", false, "Exotic cluster in the data"}; Configurable minDPhi{"minDPhi", 0.01, "Minimum dPhi between track and cluster"}; + Configurable Track_matching_Radius{"Track_matching_Radius", 0.05, "Radius for which a high energetic track is matched to a cluster"}; + Configurable isMC{"isMC", true, "should be set to true if the data set is monte carlo"}; Filter PosZFilter = nabs(aod::collision::posZ) < maxPosZ; + Filter PosZFilterMC = nabs(aod::mccollision::posZ) < maxPosZ; Filter clusterDefinitionSelection = (o2::aod::emcalcluster::definition == mClusterDefinition) && (o2::aod::emcalcluster::time >= minTime) && (o2::aod::emcalcluster::time <= maxTime) && (o2::aod::emcalcluster::energy > minClusterEnergy) && (o2::aod::emcalcluster::nCells >= minNCells) && (o2::aod::emcalcluster::nlm <= maxNLM) && (o2::aod::emcalcluster::isExotic == ExoticContribution); - Filter emccellfilter = aod::calo::caloType == 1; // mc emcal cell + Filter emccellfilter = aod::calo::caloType == 1; using selectedCollisions = soa::Filtered; + using selectedMcCollisions = soa::Filtered; using selectedClusters = soa::Filtered; using selectedMCClusters = soa::Filtered; + // Preslices + Preslice collisionsPerBC = aod::collision::bcId; + Preslice McCollisionsPerBC = aod::mccollision::bcId; + Preslice TracksPercollision = aod::track::collisionId; Preslice perClusterMatchedTracks = o2::aod::emcalclustercell::emcalclusterId; + Preslice ClustersPerCol = aod::emcalcluster::collisionId; + Preslice CellsPerCluster = aod::emcalclustercell::emcalclusterId; int eventSelection = -1; int trackSelection = -1; @@ -96,6 +108,9 @@ struct PhotonIsolationQA { eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + mGeometry = o2::emcal::Geometry::GetInstanceFromRunNumber(300000); + auto nCells = mGeometry->GetNCells(); + const o2Axis PosZ_Axis{100, -15, 15, "Z Positions (cm)"}; const o2Axis Num_Cluster_Axis{10, 0, 10, "N Clusters"}; const o2Axis Shower_Shape_Long_Axis{100, 0, 4, "#sigma^{2}_{long}"}; @@ -104,64 +119,72 @@ struct PhotonIsolationQA { const o2Axis Eta_Axis{100, -0.9, 0.9, "#eta"}; const o2Axis Energy_Axis{100, 0, 100, "E (GeV/c)"}; const o2Axis NCells_Axis{50, 0, 50, "N Cells"}; - const o2Axis Pt_Axis{100, 0, 100, "P_{T} (GeV/c)"}; - const o2Axis P_Axis{100, 0, 100, "P (GeV/c)"}; - const o2Axis RatioP_Axis{50, 0, 10, "E/P"}; - const o2Axis Num_Track_Axis{20, 0, 20, "N Tracks"}; + const o2Axis Num_Track_Axis{20, -0.5, 19.5, "N Tracks"}; const o2Axis PtIso_Axis{100, -10, 15, "P_{T, Iso} (GeV/c)"}; - const o2Axis Rho_Axis{100, 0, 100, "#rho (#frac{GeV/c}{A})"}; + const o2Axis Rho_Axis{200, 0, 200, "#rho (#frac{GeV/c}{A})"}; const o2Axis ABCD_Axis{5, 0, 5, "ABCD"}; - const o2Axis NLM_Axis{3, 0, 3, "NLM"}; - const o2Axis Fraction_Axis{50, 0, 2}; + const o2Axis NLM_Axis{50, -0.5, 49.5, "NLM"}; + const o2Axis PDG_Axis{20000, -10000.5, 9999.5, "PDG Code"}; + const o2Axis Status_Code_Axis{400, -200.5, 199.5, "Status Code"}; + const o2Axis BC_Axis{100, -0.5, 99.5, "Col per BC"}; + const o2Axis CellNumber_Axis{nCells, -0.5, nCells - 0.5, "Cell Number"}; + const o2Axis SM_Flag_Axis{2, -0.5, 1.5}; Data_Info.add("hPosZ", "Z Position of collision", o2HistType::kTH1F, {PosZ_Axis}); Data_Info.add("hNumClusters", "Number of cluster per collision", o2HistType::kTH1F, {Num_Cluster_Axis}); Data_Info.add("hClusterLocation", "Location of shower in eta phi plane", o2HistType::kTH2F, {{Eta_Axis}, {Phi_Axis}}); - Data_Info.add("hEnergy", "Energy of the cluster", o2HistType::kTH1F, {Energy_Axis}); Data_Info.add("hEnergy_ShowerShapeLong", "Energy vs Shower shape long axis", o2HistType::kTH2F, {{Energy_Axis}, {Shower_Shape_Long_Axis}}); Data_Info.add("hEnergy_ShowerShapeShort", "Energy vs Shower shape short axis", o2HistType::kTH2F, {{Energy_Axis}, {Shower_Shape_Short_Axis}}); - Data_Info.add("hEnergy_m02_m20", "Energy cluster Vs m02 vs m20", o2HistType::kTHnSparseL, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); + Data_Info.add("hEnergy_m02_m20", "Energy cluster Vs m02 vs m20", o2HistType::kTH3F, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); Data_Info.add("hEnergy_NCells", "Energy vs Number of cells in cluster", o2HistType::kTH2F, {{Energy_Axis}, {NCells_Axis}}); - Data_Info.add("hEvsNumTracks", "Energy of cluster vs matched tracks", o2HistType::kTH2F, {{Energy_Axis}, {Num_Track_Axis}}); - Data_Info.add("hTrackPt", "Pt of matched track", o2HistType::kTH1F, {Pt_Axis}); - Data_Info.add("hTrackEta", "Eta of matched track", o2HistType::kTH1F, {Eta_Axis}); - Data_Info.add("hTrackPhi", "Phi of matched track", o2HistType::kTH1F, {Phi_Axis}); - Data_Info.add("hRatioClusterETrackP", "Ratio between energy of cluster and P of tracks", o2HistType::kTH1F, {RatioP_Axis}); - Data_Info.add("hRatioClusterETrackPrackPt", "Ratio between E and P vs Pt of matched tracks", o2HistType::kTH2F, {{RatioP_Axis}, {Pt_Axis}}); Data_Info.add("hEvsPtIso", "Pt_Iso", o2HistType::kTH2F, {{Energy_Axis}, {PtIso_Axis}}); - Data_Info.add("hRho_Perpen_Cone", "Density of perpendicular cone", o2HistType::kTH1F, {Rho_Axis}); + Data_Info.add("hRho_Perpen_Cone", "Energy vs Density of perpendicular cone", o2HistType::kTH2F, {{Energy_Axis}, {Rho_Axis}}); Data_Info.add("hShowerShape", "Shower shape", o2HistType::kTH2F, {{Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); - Data_Info.add("hSigmaLongvsPtIso", "Long shower shape vs Pt_Iso", o2HistType::kTH2F, {{Shower_Shape_Long_Axis}, {PtIso_Axis}}); + Data_Info.add("hSigmaLongvsPtIso", "Long shower shape vs Pt_Iso", o2HistType::kTH3F, {{Shower_Shape_Long_Axis}, {PtIso_Axis}, {Energy_Axis}}); Data_Info.add("hABCDControlRegion", "Yield Control Regions", o2HistType::kTH2F, {{ABCD_Axis}, {Energy_Axis}}); - Data_Info.add("hE_M02_M20_NLM_NCells_PtIso", "Energy vs M02 vs M20 vs NLM vs NCells vs PtIso", o2HistType::kTHnSparseL, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}, {NLM_Axis}, {NCells_Axis}, {PtIso_Axis}}); + Data_Info.add("hCollperBC", "collisions per BC", o2HistType::kTH1F, {BC_Axis}); + Data_Info.add("hEnergy_NLM_Flag", "Energy vs NLM", o2HistType::kTH3F, {{Energy_Axis}, {NLM_Axis}, {SM_Flag_Axis}}); + Data_Info.add("hNCells_NLM_Flag", "Energy vs NLM", o2HistType::kTH3F, {{NCells_Axis}, {NLM_Axis}, {SM_Flag_Axis}}); MC_Info.add("hPosZ", "Z Position of collision", o2HistType::kTH1F, {PosZ_Axis}); + MC_Info.get(HIST("hPosZ"))->Sumw2(); MC_Info.add("hNumClusters", "Number of cluster per collision", o2HistType::kTH1F, {Num_Cluster_Axis}); + MC_Info.get(HIST("hNumClusters"))->Sumw2(); MC_Info.add("hClusterLocation", "Location of shower in eta phi plane", o2HistType::kTH2F, {{Eta_Axis}, {Phi_Axis}}); - MC_Info.add("hEnergy", "Energy of the cluster", o2HistType::kTH1F, {Energy_Axis}); MC_Info.add("hEnergy_ShowerShapeLong", "Energy vs Shower shape long axis", o2HistType::kTH2F, {{Energy_Axis}, {Shower_Shape_Long_Axis}}); + MC_Info.get(HIST("hEnergy_ShowerShapeLong"))->Sumw2(); MC_Info.add("hEnergy_ShowerShapeShort", "Energy vs Shower shape short axis", o2HistType::kTH2F, {{Energy_Axis}, {Shower_Shape_Short_Axis}}); - MC_Info.add("hEnergy_m02_m20", "Energy cluster Vs m02 vs m20", o2HistType::kTHnSparseL, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); + MC_Info.get(HIST("hEnergy_ShowerShapeShort"))->Sumw2(); + MC_Info.add("hEnergy_m02_m20", "Energy cluster Vs m02 vs m20", o2HistType::kTH3F, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); + MC_Info.get(HIST("hEnergy_m02_m20"))->Sumw2(); MC_Info.add("hEnergy_NCells", "Energy vs Number of cells in cluster", o2HistType::kTH2F, {{Energy_Axis}, {NCells_Axis}}); + MC_Info.get(HIST("hEnergy_NCells"))->Sumw2(); MC_Info.add("hEvsNumTracks", "Energy of cluster vs matched tracks", o2HistType::kTH2F, {{Energy_Axis}, {Num_Track_Axis}}); - MC_Info.add("hTrackPt", "Pt of matched track", o2HistType::kTH1F, {Pt_Axis}); - MC_Info.add("hTrackEta", "Eta of matched track", o2HistType::kTH1F, {Eta_Axis}); - MC_Info.add("hTrackPhi", "Phi of matched track", o2HistType::kTH1F, {Phi_Axis}); - MC_Info.add("hRatioClusterETrackP", "Ratio between energy of cluster and P of tracks", o2HistType::kTH1F, {RatioP_Axis}); - MC_Info.add("hRatioClusterETrackPrackPt", "Ratio between E and P vs Pt of matched tracks", o2HistType::kTH2F, {{RatioP_Axis}, {Pt_Axis}}); - MC_Info.add("hE_M02_M20_NLM_NCells_PtIso", "Energy vs M02 vs M20 vs NLM vs NCells vs PtIso", o2HistType::kTHnSparseL, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}, {NLM_Axis}, {NCells_Axis}, {PtIso_Axis}}); - + MC_Info.get(HIST("hEvsNumTracks"))->Sumw2(); MC_Info.add("hEvsPtIso", "Pt_Iso", o2HistType::kTH2F, {{Energy_Axis}, {PtIso_Axis}}); - MC_Info.add("hRho_Perpen_Cone", "Density of perpendicular cone", o2HistType::kTH1F, {Rho_Axis}); + MC_Info.get(HIST("hEvsPtIso"))->Sumw2(); + MC_Info.add("hRho_Perpen_Cone", "Energy vs Density of perpendicular cone", o2HistType::kTH2F, {{Energy_Axis}, {Rho_Axis}}); + MC_Info.get(HIST("hRho_Perpen_Cone"))->Sumw2(); MC_Info.add("hShowerShape", "Shower shape", o2HistType::kTH2F, {{Shower_Shape_Long_Axis}, {Shower_Shape_Short_Axis}}); - MC_Info.add("hSigmaLongvsPtIso", "Long shower shape vs Pt_Iso", o2HistType::kTH2F, {{Shower_Shape_Long_Axis}, {PtIso_Axis}}); + MC_Info.get(HIST("hShowerShape"))->Sumw2(); + MC_Info.add("hSigmaLongvsPtIso", "Long shower shape vs Pt_Iso", o2HistType::kTH3F, {{Shower_Shape_Long_Axis}, {PtIso_Axis}, {Energy_Axis}}); + MC_Info.get(HIST("hSigmaLongvsPtIso"))->Sumw2(); MC_Info.add("hABCDControlRegion", "Yield Control Regions", o2HistType::kTH2F, {{ABCD_Axis}, {Energy_Axis}}); - MC_Info.add("hMcParticlesToCluster", "Energy of particles linked to mc cluster", o2HistType::kTH1F, {{100, 0, 100}}); - MC_Info.add("hMcParticleStatusCode", "generator status code of mc particle linked to mc cluster", o2HistType::kTH1F, {{200, 0, 200}}); - MC_Info.add("hMcParticleProcessCode", "physical process code of mc particle linked to mc cluster", o2HistType::kTH1F, {{200, 0, 200}}); + MC_Info.get(HIST("hABCDControlRegion"))->Sumw2(); + MC_Info.add("hClusterEnergy_MCParticleEnergy", "Energy cluster vs energy particle of cluster", o2HistType::kTH2F, {{Energy_Axis}, {Energy_Axis}}); + MC_Info.get(HIST("hClusterEnergy_MCParticleEnergy"))->Sumw2(); + MC_Info.add("hMotherPDG", "PDG code of candidate photons mother", o2HistType::kTH1F, {{2000, -1000.5, 999.5}}); + MC_Info.add("hMotherStatusCode", "Statuscode of candidate photons mother", o2HistType::kTH1F, {{400, -200.5, 199.5}}); + MC_Info.add("hMotherStatusCodeVsPDG", "Statuscode of candidate photons mother", o2HistType::kTH2F, {{Status_Code_Axis}, {PDG_Axis}}); + MC_Info.add("hCollperBC", "collisions per BC", o2HistType::kTH1F, {BC_Axis}); + MC_Info.add("hEnergy_NLM_Flag", "Energy vs NLM", o2HistType::kTH3F, {{Energy_Axis}, {NLM_Axis}, {SM_Flag_Axis}}); + MC_Info.get(HIST("hEnergy_NLM_Flag"))->Sumw2(); + MC_Info.add("hNCells_NLM_Flag", "Energy vs NLM", o2HistType::kTH3F, {{NCells_Axis}, {NLM_Axis}, {SM_Flag_Axis}}); + MC_Info.get(HIST("hNCells_NLM_Flag"))->Sumw2(); + MC_Info.add("hPromtPhoton", "Energy vs m02 vs NCells, PtIso", o2HistType::kTHnSparseF, {{Energy_Axis}, {Shower_Shape_Long_Axis}, {NCells_Axis}, {PtIso_Axis}}); std::vector bin_names = {"A", "B", "C", "D", "True Bckgr A"}; for (size_t i = 0; i < bin_names.size(); i++) { @@ -174,9 +197,16 @@ struct PhotonIsolationQA { bool track_matching(const auto& cluster, o2::aod::EMCALMatchedTracks const& matched_tracks) { for (const auto& match : matched_tracks) { - double abs_pt = abs(match.track_as().pt()); - if ((cluster.energy() / abs_pt) < 1.75) { - return true; + double dphi = cluster.phi() - match.track_as().phi(); + if (abs(dphi) > M_PI) { + dphi = 2. * M_PI - abs(dphi); + } + double distance = sqrt(pow((cluster.eta() - match.track_as().eta()), 2) + pow(dphi, 2)); + if (distance < Track_matching_Radius) { + double abs_pt = abs(match.track_as().pt()); + if ((cluster.energy() / abs_pt) < 1.75) { + return true; + } } } return false; @@ -240,85 +270,188 @@ struct PhotonIsolationQA { return Pt_Iso; } - void fillclusterhistos(const auto cluster, HistogramRegistry registry) + void fillclusterhistos(const auto cluster, HistogramRegistry registry, double weight = 1.0) { registry.fill(HIST("hClusterLocation"), cluster.eta(), cluster.phi()); - registry.fill(HIST("hEnergy"), cluster.energy()); - registry.fill(HIST("hEnergy_ShowerShapeLong"), cluster.energy(), cluster.m02()); - registry.fill(HIST("hEnergy_ShowerShapeShort"), cluster.energy(), cluster.m20()); - registry.fill(HIST("hEnergy_NCells"), cluster.energy(), cluster.nCells()); - registry.fill(HIST("hEnergy_m02_m20"), cluster.energy(), cluster.m02(), cluster.m20()); + if (isMC == true) { + registry.fill(HIST("hEnergy_ShowerShapeLong"), cluster.energy(), cluster.m02(), weight); + registry.fill(HIST("hEnergy_ShowerShapeShort"), cluster.energy(), cluster.m20(), weight); + registry.fill(HIST("hEnergy_NCells"), cluster.energy(), cluster.nCells(), weight); + registry.fill(HIST("hEnergy_m02_m20"), cluster.energy(), cluster.m02(), cluster.m20(), weight); + registry.fill(HIST("hShowerShape"), cluster.m02(), cluster.m20(), weight); + } else { + registry.fill(HIST("hEnergy_ShowerShapeLong"), cluster.energy(), cluster.m02()); + registry.fill(HIST("hEnergy_ShowerShapeShort"), cluster.energy(), cluster.m20()); + registry.fill(HIST("hEnergy_NCells"), cluster.energy(), cluster.nCells()); + registry.fill(HIST("hEnergy_m02_m20"), cluster.energy(), cluster.m02(), cluster.m20()); + registry.fill(HIST("hShowerShape"), cluster.m02(), cluster.m20()); + } } - void fillABCDHisto(HistogramRegistry registry, const auto& cluster, double Pt_iso) + void fillABCDHisto(HistogramRegistry registry, const auto& cluster, double Pt_iso, double weight = 1.0) { - if ((Pt_iso < 1.5) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { - registry.fill(HIST("hABCDControlRegion"), 0.5, cluster.energy()); - } - if ((Pt_iso > 4.0) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { - registry.fill(HIST("hABCDControlRegion"), 1.5, cluster.energy()); - } - if ((Pt_iso < 1.5) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { - registry.fill(HIST("hABCDControlRegion"), 2.5, cluster.energy()); - } - if ((Pt_iso > 4.0) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { - registry.fill(HIST("hABCDControlRegion"), 3.5, cluster.energy()); + if (isMC == true) { + if ((Pt_iso < 1.5) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { + registry.fill(HIST("hABCDControlRegion"), 0.5, cluster.energy(), weight); + } + if ((Pt_iso > 4.0) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { + registry.fill(HIST("hABCDControlRegion"), 1.5, cluster.energy(), weight); + } + if ((Pt_iso < 1.5) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { + registry.fill(HIST("hABCDControlRegion"), 2.5, cluster.energy(), weight); + } + if ((Pt_iso > 4.0) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { + registry.fill(HIST("hABCDControlRegion"), 3.5, cluster.energy(), weight); + } + } else { + if ((Pt_iso < 1.5) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { + registry.fill(HIST("hABCDControlRegion"), 0.5, cluster.energy()); + } + if ((Pt_iso > 4.0) && (cluster.m02() < 0.3) && (cluster.m02() > 0.1)) { + registry.fill(HIST("hABCDControlRegion"), 1.5, cluster.energy()); + } + if ((Pt_iso < 1.5) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { + registry.fill(HIST("hABCDControlRegion"), 2.5, cluster.energy()); + } + if ((Pt_iso > 4.0) && (cluster.m02() < 2.0) && (cluster.m02() > 0.4)) { + registry.fill(HIST("hABCDControlRegion"), 3.5, cluster.energy()); + } } } - void fillMatchedTrackHistos(HistogramRegistry registry, const auto& cluster, o2::aod::EMCALMatchedTracks const& matched_tracks) + // iterates over all mothers to check if photon originated from hard scattering (statuscode = abs(23)) + template + int getOriginalMotherIndex(const typename T::iterator& particle) { - for (const auto& match : matched_tracks) { - registry.fill(HIST("hTrackPt"), match.track_as().pt()); - registry.fill(HIST("hTrackEta"), match.track_as().eta()); - registry.fill(HIST("hTrackPhi"), match.track_as().phi()); - registry.fill(HIST("hRatioClusterETrackP"), cluster.energy() / abs(match.track_as().p())); - registry.fill(HIST("hRatioClusterETrackPrackPt"), cluster.energy() / abs(match.track_as().p()), match.track_as().pt()); + if (abs(particle.getGenStatusCode()) == 23) { + return particle.getGenStatusCode(); + } + auto mother = particle; + + while (mother.has_mothers()) { + mother = mother.template mothers_first_as(); + + MC_Info.fill(HIST("hMotherPDG"), mother.pdgCode()); + MC_Info.fill(HIST("hMotherStatusCode"), mother.getGenStatusCode()); + MC_Info.fill(HIST("hMotherStatusCodeVsPDG"), mother.getGenStatusCode(), mother.pdgCode()); + + int motherStatusCode = mother.getGenStatusCode(); + int motherPDGCode = mother.pdgCode(); + + if (abs(motherStatusCode) == 23 && motherPDGCode == 22) { + return motherStatusCode; + } } + return -1.0; } - // process monte carlo data - void processMC(selectedCollisions::iterator const& theCollision, selectedMCClusters const& mcclusters, aod::StoredMcParticles_001 const&, myGlobTracks const& tracks, o2::aod::EMCALClusterCells const& /*emccluscells*/, o2::aod::EMCALMatchedTracks const& matchedtracks) + // Calculates the number of local maxima within a cluster + std::pair CalculateNLM(const auto& ClusterCells) { - MC_Info.fill(HIST("hPosZ"), theCollision.posZ()); - - if (mcclusters.size() > 0) { - MC_Info.fill(HIST("hNumClusters"), mcclusters.size()); + std::vector> Cell_Info(ClusterCells.size(), std::vector(3)); + std::vector supermodules; + + int idx = 0; + for (auto& Cell : ClusterCells) { + auto [supermodule, module, phiInModule, etaInModule] = mGeometry->GetCellIndex(Cell.calo().cellNumber()); + auto [row, col] = mGeometry->GetCellPhiEtaIndexInSModule(supermodule, module, phiInModule, etaInModule); + supermodules.push_back(supermodule); + Cell_Info[idx++] = {static_cast(row), static_cast(col), Cell.calo().amplitude()}; } - for (auto& mccluster : mcclusters) { - auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, mccluster.globalIndex()); - fillclusterhistos(mccluster, MC_Info); - fillMatchedTrackHistos(MC_Info, mccluster, tracksofcluster); - MC_Info.fill(HIST("hEvsNumTracks"), mccluster.energy(), tracksofcluster.size()); - - if (!track_matching(mccluster, tracksofcluster)) { // no track with significant momentum is matched to cluster - double Pt_Cone = sum_Pt_tracks_in_cone(mccluster, tracks); - double Rho_Perpen_Cone = Rho_Perpendicular_Cone(mccluster, tracks); - double Pt_iso = Pt_Iso(Pt_Cone, Rho_Perpen_Cone); - - MC_Info.fill(HIST("hEvsPtIso"), mccluster.energy(), Pt_iso); - MC_Info.fill(HIST("hRho_Perpen_Cone"), Rho_Perpen_Cone); - MC_Info.fill(HIST("hShowerShape"), mccluster.m02(), mccluster.m20()); - MC_Info.fill(HIST("hSigmaLongvsPtIso"), mccluster.m02(), Pt_iso); - MC_Info.fill(HIST("hE_M02_M20_NLM_NCells_PtIso"), mccluster.energy(), mccluster.m02(), mccluster.m20(), mccluster.nlm(), mccluster.nCells(), Pt_iso); - fillABCDHisto(MC_Info, mccluster, Pt_iso); - // acces mc true info - auto ClusterParticles = mccluster.mcParticle_as(); - bool background = true; - for (auto& clusterparticle : ClusterParticles) { - if (clusterparticle.pdgCode() == 22) { - MC_Info.fill(HIST("hMcParticlesToCluster"), clusterparticle.e()); - MC_Info.fill(HIST("hMcParticleProcessCode"), clusterparticle.getProcess()); - MC_Info.fill(HIST("hMcParticleStatusCode"), clusterparticle.getGenStatusCode()); - if ((clusterparticle.getProcess() >= 21) && (clusterparticle.getProcess() <= 29)) - background = false; // Particles from the hardest subprocess + std::vector> local_max_vector(ClusterCells.size(), std::vector(3)); + for (size_t i = 0; i < Cell_Info.size(); ++i) { + float row = Cell_Info[i][0]; + float col = Cell_Info[i][1]; + float amp = Cell_Info[i][2]; + + bool updated; + do { + updated = false; + for (const auto& cell : Cell_Info) { + float dr = cell[0] - row; + float dc = cell[1] - col; + if (std::abs(dr) <= 1 && std::abs(dc) <= 1 && cell[2] > amp) { + row += dr; + col += dc; + amp = cell[2]; + updated = true; } } + } while (updated); + + local_max_vector[i] = {row, col, amp}; + } + + std::set uniqueRows; + for (const auto& localMax : local_max_vector) { + uniqueRows.insert(localMax[0]); + } + + int NLM = uniqueRows.size(); - if (background) { - if ((Pt_iso < 1.5) && (mccluster.m02() < 0.3) && (mccluster.m02() > 0.1)) { - MC_Info.fill(HIST("hABCDControlRegion"), 4.5, mccluster.energy()); + // flag = 0 if cluster falls in 1 supermodule. flag = 1 if cluster falls in multiple supermodules and will have automatically more local maxima + int flag = (std::unordered_set(supermodules.begin(), supermodules.end()).size() > 1) ? 1 : 0; + return std::make_pair(NLM, flag); + } + + // process monte carlo data + void processMC(aod::BCs const& bcs, selectedMcCollisions const& Collisions, selectedMCClusters const& mcclusters, aod::McParticles const&, myGlobTracks const& tracks, o2::aod::EMCALMatchedTracks const& matchedtracks, aod::Calos const&, aod::EMCALClusterCells const& ClusterCells) + { + for (auto bc : bcs) { + auto collisionsInBC = Collisions.sliceBy(McCollisionsPerBC, bc.globalIndex()); + MC_Info.fill(HIST("hCollperBC"), collisionsInBC.size()); + if (collisionsInBC.size() == 1) { + for (const auto& Collision : collisionsInBC) { + MC_Info.fill(HIST("hPosZ"), Collision.posZ(), Collision.weight()); + auto ClustersInCol = mcclusters.sliceBy(ClustersPerCol, Collision.globalIndex()); + auto tracksInCol = tracks.sliceBy(TracksPercollision, Collision.globalIndex()); + + if (ClustersInCol.size() > 0) { + MC_Info.fill(HIST("hNumClusters"), ClustersInCol.size(), Collision.weight()); + } + + for (auto& mccluster : ClustersInCol) { + auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, mccluster.globalIndex()); + fillclusterhistos(mccluster, MC_Info, Collision.weight()); + MC_Info.fill(HIST("hEvsNumTracks"), mccluster.energy(), tracksofcluster.size(), Collision.weight()); + + auto CellsInCluster = ClusterCells.sliceBy(CellsPerCluster, mccluster.globalIndex()); + auto [NLM, flag] = CalculateNLM(CellsInCluster); + MC_Info.fill(HIST("hEnergy_NLM_Flag"), mccluster.energy(), NLM, flag, Collision.weight()); + MC_Info.fill(HIST("hNCells_NLM_Flag"), mccluster.nCells(), NLM, flag, Collision.weight()); + + if (!track_matching(mccluster, tracksofcluster)) { // no track with significant momentum is matched to cluster + if (NLM <= maxNLM) { + double Pt_Cone = sum_Pt_tracks_in_cone(mccluster, tracksInCol); + double Rho_Perpen_Cone = Rho_Perpendicular_Cone(mccluster, tracksInCol); + double Pt_iso = Pt_Iso(Pt_Cone, Rho_Perpen_Cone); + + MC_Info.fill(HIST("hEvsPtIso"), mccluster.energy(), Pt_iso, Collision.weight()); + MC_Info.fill(HIST("hRho_Perpen_Cone"), mccluster.energy(), Rho_Perpen_Cone, Collision.weight()); + MC_Info.fill(HIST("hSigmaLongvsPtIso"), mccluster.m02(), Pt_iso, mccluster.energy(), Collision.weight()); + fillABCDHisto(MC_Info, mccluster, Pt_iso, Collision.weight()); + + // acces mc true info + auto ClusterParticles = mccluster.mcParticle_as(); + bool background = true; + for (auto& clusterparticle : ClusterParticles) { + if (clusterparticle.pdgCode() == 22) { + MC_Info.fill(HIST("hClusterEnergy_MCParticleEnergy"), mccluster.energy(), clusterparticle.e(), Collision.weight()); + int first_mother_status_code = getOriginalMotherIndex(clusterparticle); + if (abs(first_mother_status_code) == 23) { + background = false; + MC_Info.fill(HIST("hPromtPhoton"), mccluster.energy(), mccluster.m02(), mccluster.nCells(), Pt_iso); + } + } + } + if (background) { + if ((Pt_iso < 1.5) && (mccluster.m02() < 0.3) && (mccluster.m02() > 0.1)) { + MC_Info.fill(HIST("hABCDControlRegion"), 4.5, mccluster.energy(), Collision.weight()); + } + } + } + } } } } @@ -327,30 +460,45 @@ struct PhotonIsolationQA { PROCESS_SWITCH(PhotonIsolationQA, processMC, "proces MC data", true); - void processData(selectedCollisions::iterator const& theCollision, selectedClusters const& clusters, o2::aod::EMCALClusterCells const& /*emccluscells*/, o2::aod::EMCALMatchedTracks const& matchedtracks, myGlobTracks const& alltracks) + void processData(aod::BCs const& bcs, selectedCollisions const& Collisions, selectedClusters const& clusters, o2::aod::EMCALMatchedTracks const& matchedtracks, myGlobTracks const& tracks, aod::Calos const&, aod::EMCALClusterCells const& ClusterCells) { - Data_Info.fill(HIST("hPosZ"), theCollision.posZ()); - - if (clusters.size() > 0) { - Data_Info.fill(HIST("hNumClusters"), clusters.size()); - } + for (auto bc : bcs) { + auto collisionsInBC = Collisions.sliceBy(collisionsPerBC, bc.globalIndex()); + Data_Info.fill(HIST("hCollperBC"), collisionsInBC.size()); + if (collisionsInBC.size() == 1) { + for (const auto& Collision : collisionsInBC) { + Data_Info.fill(HIST("hPosZ"), Collision.posZ()); + auto ClustersInCol = clusters.sliceBy(ClustersPerCol, Collision.globalIndex()); + auto tracksInCol = tracks.sliceBy(TracksPercollision, Collision.globalIndex()); + + if (ClustersInCol.size() > 0) { + Data_Info.fill(HIST("hNumClusters"), ClustersInCol.size()); + } - for (const auto& cluster : clusters) { - auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, cluster.globalIndex()); - fillclusterhistos(cluster, Data_Info); - fillMatchedTrackHistos(Data_Info, cluster, tracksofcluster); - Data_Info.fill(HIST("hEvsNumTracks"), cluster.energy(), tracksofcluster.size()); - - if (!track_matching(cluster, tracksofcluster)) { // no track with significant momentum is matched to cluster - double Pt_Cone = sum_Pt_tracks_in_cone(cluster, alltracks); - double Rho_Perpen_Cone = Rho_Perpendicular_Cone(cluster, alltracks); - double Pt_iso = Pt_Iso(Pt_Cone, Rho_Perpen_Cone); - Data_Info.fill(HIST("hEvsPtIso"), cluster.energy(), Pt_iso); - Data_Info.fill(HIST("hRho_Perpen_Cone"), Rho_Perpen_Cone); - Data_Info.fill(HIST("hShowerShape"), cluster.m02(), cluster.m20()); - Data_Info.fill(HIST("hSigmaLongvsPtIso"), cluster.m02(), Pt_iso); - Data_Info.fill(HIST("hE_M02_M20_NLM_NCells_PtIso"), cluster.energy(), cluster.m02(), cluster.m20(), cluster.nlm(), cluster.nCells(), Pt_iso); - fillABCDHisto(Data_Info, cluster, Pt_iso); + for (auto& cluster : ClustersInCol) { + auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, cluster.globalIndex()); + fillclusterhistos(cluster, Data_Info); + Data_Info.fill(HIST("hEvsNumTracks"), cluster.energy(), tracksofcluster.size()); + + auto CellsInCluster = ClusterCells.sliceBy(CellsPerCluster, cluster.globalIndex()); + auto [NLM, flag] = CalculateNLM(CellsInCluster); + Data_Info.fill(HIST("hEnergy_NLM_Flag"), cluster.energy(), NLM, flag); + Data_Info.fill(HIST("hNCells_NLM_Flag"), cluster.nCells(), NLM, flag); + + if (!track_matching(cluster, tracksofcluster)) { // no track with significant momentum is matched to cluster + if (NLM < maxNLM) { + double Pt_Cone = sum_Pt_tracks_in_cone(cluster, tracksInCol); + double Rho_Perpen_Cone = Rho_Perpendicular_Cone(cluster, tracksInCol); + double Pt_iso = Pt_Iso(Pt_Cone, Rho_Perpen_Cone); + + Data_Info.fill(HIST("hEvsPtIso"), cluster.energy(), Pt_iso); + Data_Info.fill(HIST("hRho_Perpen_Cone"), cluster.energy(), Rho_Perpen_Cone); + Data_Info.fill(HIST("hSigmaLongvsPtIso"), cluster.m02(), Pt_iso, cluster.energy()); + fillABCDHisto(Data_Info, cluster, Pt_iso); + } + } + } + } } } } diff --git a/PWGJE/Tasks/bjetTaggingML.cxx b/PWGJE/Tasks/bjetTaggingML.cxx new file mode 100644 index 00000000000..98b3542cc09 --- /dev/null +++ b/PWGJE/Tasks/bjetTaggingML.cxx @@ -0,0 +1,619 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 bjetTaggingML.cxx +/// \brief Task for tagging the beauty jets using ML algorithm (in onnx format) loaded from ccdb +/// +/// \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/DataModel/Jet.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" + +using namespace o2; +using namespace o2::framework; +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"}; + 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"}; + + // 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 nJetConst{"nJetConst", 10, "maximum number of jet consistuents to be used for ML evaluation"}; + + 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> 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 jetRadiiValues; + + void init(InitContext const&) + { + // Seed the random number generator using current time + std::srand(static_cast(std::time(nullptr))); + + jetRadiiValues = (std::vector)jetRadii; + + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + + 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_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}}}); + + registry.add("h2_SIPs2D_jetpT", "2D IP significance;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); + registry.add("h2_SIPs3D_jetpT", "3D IP significance;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); + registry.add("h2_LxyS_jetpT", "Decay length in XY;#it{p}_{T,jet} (GeV/#it{c});S#it{L}_{xy}", {HistType::kTH2F, {{200, 0., 200.}, {100, 0., 100.0}}}); + registry.add("h2_Dispersion_jetpT", "SV dispersion;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); + 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) { + + 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}}}); + 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}}}); + registry.add("h2_Dispersion_jetpT_bjet", "SV dispersion b-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); + 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_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}}}); + registry.add("h2_Dispersion_jetpT_cjet", "SV dispersion c-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); + 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_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}}}); + registry.add("h2_Dispersion_jetpT_lfjet", "SV dispersion lf-jet;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); + registry.add("h2_jetMass_jetpT_lfjet", "Jet mass lf-jet;#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_lfjet", "Secondary vertex mass lf-jet;#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("h_jetpT_detector_bjet", "Jet transverse momentum b-jets;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("h_jetpT_detector_cjet", "Jet transverse momentum c-jets;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("h_jetpT_detector_lfjet", "Jet transverse momentum lf-jet;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + + registry.add("h_jetpT_particle_DetColl", "Jet transverse momentum particle level inclusive jets (Detector-level collisions);#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("h_jetpT_particle_DetColl_bjet", "Jet transverse momentum particle level b-jets (Detector-level collisions);#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("h_jetpT_particle_DetColl_cjet", "Jet transverse momentum particle level c-jets (Detector-level collisions);#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + registry.add("h_jetpT_particle_DetColl_lfjet", "Jet transverse momentum particle level lf-jet (Detector-level collisions);#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + + registry.add("h_jetpT_particle_bjet", "Jet transverse momentum particle level b-jets;#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH1F, {{200, 0., 200.0}}}); + 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.}}}); + } + + 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 + 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 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 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; + } + + // 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) + { + 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()}); + } + + 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) { + 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) { + 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); + } else { + registry.fill(HIST("h2_LxyS_jetpT_lfjet"), myJet.pt(), candSV.decayLengthXY() / candSV.errorDecayLengthXY(), eventweight); + registry.fill(HIST("h2_Dispersion_jetpT_lfjet"), myJet.pt(), candSV.dispersion(), eventweight); + registry.fill(HIST("h2_SVMass_jetpT_lfjet"), myJet.pt(), massSV, eventweight); + } + } + } + } + + 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) + { + + for (auto& constituent : analysisJet.template tracks_as()) { + + if (constituent.pt() < trackPtMin) { + 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 = 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; + } + } + + 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) { + 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) { + 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 { + registry.fill(HIST("h2_SIPs2D_jetpT_lfjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); + registry.fill(HIST("h2_SIPs3D_jetpT_lfjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); + } + } + + 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}); + } + + auto compare = [](bjetTrackParams& tr1, bjetTrackParams& tr2) { + return (tr1.mSignedIP2D / tr1.mSignedIP2DSign) > (tr2.mSignedIP2D / tr2.mSignedIP2DSign); + }; + + // Sort the tracks based on their IP significance in descending order + std::sort(tracksParams.begin(), tracksParams.end(), compare); + } + + void processDummy(FilteredCollision::iterator const& /*collision*/) + { + } + PROCESS_SWITCH(BJetTaggingML, processDummy, "Dummy process function turned on by default", true); + + void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, aod::DataSecondaryVertex3Prongs const& allSVs) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + + registry.fill(HIST("h_vertexZ"), collision.posZ()); + + for (const auto& analysisJet : alljets) { + + bool jetIncluded = false; + for (auto jetR : jetRadiiValues) { + if (analysisJet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + 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()); + } + } + PROCESS_SWITCH(BJetTaggingML, processDataJets, "jet information in Data", false); + + using MCDJetTable = soa::Filtered>; + using MCPJetTable = soa::Filtered>; + using FilteredCollisionMCD = soa::Filtered>; + + 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)) { + return; + } + + registry.fill(HIST("h_vertexZ"), collision.posZ()); + + 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) { + if (analysisJet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + float eventWeight = useEventWeight ? analysisJet.eventWeight() : 1.0; + 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(); + + 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], 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()) { + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + if (jetFlavor == 2) { + registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_bjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); + } else if (jetFlavor == 1) { + 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); + } + } + } + + // For filling histograms used for the jet matching efficiency + for (const auto& mcpjet : mcPJetsPerColl) { + + bool jetIncluded = false; + for (auto jetR : jetRadiiValues) { + if (mcpjet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + float eventWeight = useEventWeight ? mcpjet.eventWeight() : 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + int8_t jetFlavor = 0; + + if (useQuarkDef) { + jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); + } else { + jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, mcParticlesPerColl); + } + + registry.fill(HIST("h_jetpT_particle_DetColl"), mcpjet.pt(), eventWeight); + + 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); + } + } + } + PROCESS_SWITCH(BJetTaggingML, 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 (auto jetR : jetRadiiValues) { + if (mcpjet.r() == static_cast(jetR * 100)) { + jetIncluded = true; + break; + } + } + + if (!jetIncluded) { + continue; + } + + float eventWeight = useEventWeight ? mcpjet.eventWeight() : 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + int8_t jetFlavor = 0; + + if (useQuarkDef) { + jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, MCParticles); + } else { + jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, MCParticles); + } + + 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); + } + } + } + PROCESS_SWITCH(BJetTaggingML, processMCTruthJets, "truth jet information", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"bjet-tagging-ml"})}; +} diff --git a/PWGJE/Tasks/bjetTreeCreator.cxx b/PWGJE/Tasks/bjetTreeCreator.cxx index 6f51e12d3cf..2d60344085a 100644 --- a/PWGJE/Tasks/bjetTreeCreator.cxx +++ b/PWGJE/Tasks/bjetTreeCreator.cxx @@ -111,11 +111,11 @@ DECLARE_SOA_COLUMN(SVfE, svfe, float); //! The SV energy frac DECLARE_SOA_COLUMN(IPXY, ipxy, float); //! The SV 2D IP DECLARE_SOA_COLUMN(CPA, cpa, float); //! Cosine pointing angle between the SV direction and momentum DECLARE_SOA_COLUMN(Chi2PCA, chi2pca, float); //! Sum of (non-weighted) distances of the secondary vertex to its prongsm +DECLARE_SOA_COLUMN(Dispersion, dispersion, float); //! The SV dispersion DECLARE_SOA_COLUMN(DecayLength2D, lxy, float); //! The decay length of the SV in XY DECLARE_SOA_COLUMN(DecayLength2DError, lxysigma, float); //! The decay length of the SV in XY significance DECLARE_SOA_COLUMN(DecayLength3D, lxyz, float); //! The decay length of the SV in 3D DECLARE_SOA_COLUMN(DecayLength3DError, lxyzsigma, float); //! The decay length of the SV in 3d significance -// DECLARE_SOA_COLUMN(SVDispersion, svdispersion, float); //! The SV dispersion, unfortunately it cannot be calculated in O2 } // namespace SVInfo DECLARE_SOA_TABLE(bjetSVParams, "AOD", "BJETSVPARAM", @@ -128,6 +128,7 @@ DECLARE_SOA_TABLE(bjetSVParams, "AOD", "BJETSVPARAM", SVInfo::IPXY, SVInfo::CPA, SVInfo::Chi2PCA, + SVInfo::Dispersion, SVInfo::DecayLength2D, SVInfo::DecayLength2DError, SVInfo::DecayLength3D, @@ -162,12 +163,21 @@ struct BJetTreeCreator { Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable> jetPtBins{"jetPtBins", std::vector{5, 1000}, "jet pT bins for reduction"}; + Configurable> jetReductionFactors{"jetReductionFactors", std::vector{0.0}, "jet reduction factors"}; + + 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 useQuarkDef{"useQuarkDef", true, "Flag whether to use quarks or hadrons for determining the jet flavor"}; + // track level configurables Configurable svPtMin{"svPtMin", 0.5, "minimum SV pT"}; @@ -177,6 +187,8 @@ struct BJetTreeCreator { Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; + Configurable maxConstSV{"maxConstSV", 999.0, "maximum number of SVs to be stored in the table"}; + Configurable svReductionFactor{"svReductionFactor", 1.0, "factor for how many SVs to keep"}; Configurable eventReductionFactor{"eventReductionFactor", 0.0, "Percentage of events to be removed"}; @@ -187,6 +199,8 @@ struct BJetTreeCreator { int eventSelection = -1; std::vector jetRadiiValues; + std::vector jetPtBinsReduction; + std::vector jetReductionFactorsPt; void init(InitContext const&) { @@ -194,6 +208,8 @@ struct BJetTreeCreator { std::srand(static_cast(std::time(nullptr))); jetRadiiValues = (std::vector)jetRadii; + jetPtBinsReduction = (std::vector)jetPtBins; + jetReductionFactorsPt = (std::vector)jetReductionFactors; eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); @@ -205,7 +221,7 @@ struct BJetTreeCreator { registry.add("h2_SIPs2D_jetpT", "2D IP significance;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_SIPs3D_jetpT", "3D IP significance;#it{p}_{T,jet} (GeV/#it{c});IPs", {HistType::kTH2F, {{200, 0., 200.}, {100, -50.0, 50.0}}}); registry.add("h2_LxyS_jetpT", "Decay length in XY;#it{p}_{T,jet} (GeV/#it{c});S#it{L}_{xy}", {HistType::kTH2F, {{200, 0., 200.}, {100, 0., 100.0}}}); - registry.add("h2_Dispersion_jetpT", "SV dispersion;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 50.0}}}); + registry.add("h2_Dispersion_jetpT", "SV dispersion;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); 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}}}); @@ -213,21 +229,21 @@ struct BJetTreeCreator { 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}}}); - registry.add("h2_Dispersion_jetpT_bjet", "SV dispersion b-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 50.0}}}); + registry.add("h2_Dispersion_jetpT_bjet", "SV dispersion b-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); 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_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}}}); - registry.add("h2_Dispersion_jetpT_cjet", "SV dispersion c-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 50.0}}}); + registry.add("h2_Dispersion_jetpT_cjet", "SV dispersion c-jets;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); 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_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}}}); - registry.add("h2_Dispersion_jetpT_lfjet", "SV dispersion lf-jet;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 50.0}}}); + registry.add("h2_Dispersion_jetpT_lfjet", "SV dispersion lf-jet;#it{p}_{T,jet} (GeV/#it{c});Dispersion", {HistType::kTH2F, {{200, 0., 200.}, {100, 0, 0.5}}}); registry.add("h2_jetMass_jetpT_lfjet", "Jet mass lf-jet;#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_lfjet", "Secondary vertex mass lf-jet;#it{p}_{T,jet} (GeV/#it{c});#it{m}_{SV} (GeV/#it{c}^{2})", {HistType::kTH2F, {{200, 0., 200.}, {50, 0, 10.0}}}); @@ -252,11 +268,29 @@ struct BJetTreeCreator { 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 JetTrackswID = soa::Filtered>; - using JetTracksMCDwID = soa::Filtered>; - using OriginalTracks = soa::Join; + using JetTrackswID = soa::Filtered>; + using JetTracksMCDwID = soa::Filtered>; using DataJets = soa::Filtered>; + // Function to get the reduction factor based on jet pT + double getReductionFactor(double jetPT) + { + // Loop through the jetPtBins vector + for (size_t ibin = 0; ibin < jetPtBinsReduction.size() - 1; ++ibin) { + if (jetPT >= jetPtBinsReduction[ibin] && jetPT < jetPtBinsReduction[ibin + 1]) { + return jetReductionFactorsPt[ibin]; + } + } + + // If jetPT is above the last bin, use the last reduction factor + if (jetPT >= jetPtBinsReduction.back()) { + return jetReductionFactorsPt.back(); + } + + // If jetPT is below the first bin, return the first reduction factor + return jetReductionFactorsPt.front(); + } + // 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& svIndices, int jetFlavor = 0, double eventweight = 1.0) @@ -284,9 +318,9 @@ struct BJetTreeCreator { double massSV = candSV.m(); double energySV = candSV.e(); - if (svIndices.size() < (svReductionFactor * myJet.template tracks_as().size())) { + if (svIndices.size() < (svReductionFactor * myJet.template tracks_as().size()) && svIndices.size() < maxConstSV) { if (produceTree) { - bjetSVParamsTable(bjetParamsTable.lastIndex() + 1, candSV.pt(), deltaRJetSV, massSV, energySV / myJet.energy(), candSV.impactParameterXY(), candSV.cpa(), candSV.chi2PCA(), candSV.decayLengthXY(), candSV.errorDecayLengthXY(), candSV.decayLength(), candSV.errorDecayLength()); + bjetSVParamsTable(bjetParamsTable.lastIndex() + 1, candSV.pt(), deltaRJetSV, massSV, energySV / myJet.energy(), candSV.impactParameterXY(), candSV.cpa(), candSV.chi2PCA(), candSV.dispersion(), candSV.decayLengthXY(), candSV.errorDecayLengthXY(), candSV.decayLength(), candSV.errorDecayLength()); } svIndices.push_back(bjetSVParamsTable.lastIndex()); } @@ -314,19 +348,18 @@ struct BJetTreeCreator { } template - void analyzeJetTrackInfo(AnyCollision const& collision, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, SecondaryVertices const& /*allSVs*/, std::vector& trackIndices, int jetFlavor = 0, double eventweight = 1.0) + 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& jconstituent : analysisJet.template tracks_as()) { + for (auto& constituent : analysisJet.template tracks_as()) { - if (jconstituent.pt() < trackPtMin) { + if (constituent.pt() < trackPtMin) { continue; } - auto constituent = jconstituent.template track_as(); 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 = jettaggingutilities::getGeoSign(collision, analysisJet, constituent); + int sign = jettaggingutilities::getGeoSign(analysisJet, constituent); float RClosestSV = 10.; for (const auto& candSV : analysisJet.template secondaryVertices_as()) { @@ -336,28 +369,24 @@ struct BJetTreeCreator { } } - float dcaXYZ(0.), sigmaDcaXYZ2(0.); - dcaXYZ = getDcaXYZ(constituent, &sigmaDcaXYZ2); - // jettaggingutilities::calculateDcaXYZ(dcaXYZ, sigmaDcaXYZ2, constituent.dcaXY(), constituent.dcaZ(), constituent.cYY(), constituent.cZY(), constituent.cZZ(), constituent.sigmaDcaXY2(), constituent.sigmaDcaZ2()); - - registry.fill(HIST("h2_SIPs2D_jetpT"), analysisJet.pt(), sign * TMath::Abs(constituent.dcaXY()) / TMath::Sqrt(constituent.sigmaDcaXY2()), eventweight); - registry.fill(HIST("h2_SIPs3D_jetpT"), analysisJet.pt(), sign * dcaXYZ / TMath::Sqrt(sigmaDcaXYZ2), eventweight); + 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) { - registry.fill(HIST("h2_SIPs2D_jetpT_bjet"), analysisJet.pt(), sign * TMath::Abs(constituent.dcaXY()) / TMath::Sqrt(constituent.sigmaDcaXY2()), eventweight); - registry.fill(HIST("h2_SIPs3D_jetpT_bjet"), analysisJet.pt(), sign * dcaXYZ / TMath::Sqrt(sigmaDcaXYZ2), eventweight); + 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) { - registry.fill(HIST("h2_SIPs2D_jetpT_cjet"), analysisJet.pt(), sign * TMath::Abs(constituent.dcaXY()) / TMath::Sqrt(constituent.sigmaDcaXY2()), eventweight); - registry.fill(HIST("h2_SIPs3D_jetpT_cjet"), analysisJet.pt(), sign * dcaXYZ / TMath::Sqrt(sigmaDcaXYZ2), eventweight); + 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 { - registry.fill(HIST("h2_SIPs2D_jetpT_lfjet"), analysisJet.pt(), sign * TMath::Abs(constituent.dcaXY()) / TMath::Sqrt(constituent.sigmaDcaXY2()), eventweight); - registry.fill(HIST("h2_SIPs3D_jetpT_lfjet"), analysisJet.pt(), sign * dcaXYZ / TMath::Sqrt(sigmaDcaXYZ2), eventweight); + registry.fill(HIST("h2_SIPs2D_jetpT_lfjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXY()) / constituent.sigmadcaXY(), eventweight); + registry.fill(HIST("h2_SIPs3D_jetpT_lfjet"), analysisJet.pt(), sign * std::abs(constituent.dcaXYZ()) / constituent.sigmadcaXYZ(), eventweight); } } if (produceTree) { - bjetTracksParamsTable(bjetParamsTable.lastIndex() + 1, constituent.pt(), constituent.eta(), dotProduct, dotProduct / analysisJet.p(), deltaRJetTrack, TMath::Abs(constituent.dcaXY()) * sign, TMath::Sqrt(constituent.sigmaDcaXY2()), dcaXYZ * sign, TMath::Sqrt(sigmaDcaXYZ2), 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.dcaXYZ()) * sign, constituent.sigmadcaXYZ(), constituent.p() / analysisJet.p(), RClosestSV); } trackIndices.push_back(bjetTracksParamsTable.lastIndex()); } @@ -368,7 +397,7 @@ struct BJetTreeCreator { } PROCESS_SWITCH(BJetTreeCreator, processDummy, "Dummy process function turned on by default", true); - void processDataJets(FilteredCollision::iterator const& collision, DataJets const& alljets, JetTrackswID const& allTracks, OriginalTracks const& /*allOrigTracks*/, aod::DataSecondaryVertex3Prongs const& allSVs) + 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)) { return; @@ -390,6 +419,10 @@ struct BJetTreeCreator { continue; } + if (static_cast(std::rand()) / RAND_MAX < getReductionFactor(analysisJet.pt())) { + continue; + } + std::vector tracksIndices; std::vector SVsIndices; @@ -398,12 +431,14 @@ struct BJetTreeCreator { 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_nSV_jetpT"), analysisJet.pt(), SVsIndices.size() < 250 ? SVsIndices.size() : 249); + 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(), SVsIndices.size(), analysisJet.mass(), 0, analysisJet.r()); + bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), nSVs, analysisJet.mass(), 0, analysisJet.r()); } } } @@ -416,7 +451,7 @@ struct BJetTreeCreator { 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, JetParticles const& MCParticles, aod::MCDSecondaryVertex3Prongs const& allSVs, OriginalTracks const& /*origTracks*/) + 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)) { return; @@ -441,10 +476,15 @@ struct BJetTreeCreator { continue; } + float eventWeight = analysisJet.eventWeight(); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (analysisJet.pt() > pTHatMaxMCD * pTHat) { + continue; + } + std::vector tracksIndices; std::vector SVsIndices; - float eventWeight = analysisJet.eventWeight(); int16_t jetFlavor = 0; // JetTracksMCDwID::iterator hftrack; @@ -452,16 +492,27 @@ struct BJetTreeCreator { // jetFlavor = jettaggingutilities::jetTrackFromHFShower(analysisJet, nonFilteredTracks, mcParticlesPerColl, hftrack); for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { - jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); - // jetFlavor = jettaggingutilities::mcpJetFromHFShower(mcpjet, mcParticlesPerColl, (float)(mcpjet.r() / 100.)); + if (useQuarkDef) { + jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, mcParticlesPerColl); + } else { + jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, mcParticlesPerColl); + // jetFlavor = jettaggingutilities::mcpJetFromHFShower(mcpjet, mcParticlesPerColl, (float)(mcpjet.r() / 100.)); + } + } + + if ((jetFlavor != JetTaggingSpecies::charm && jetFlavor != JetTaggingSpecies::beauty) && (static_cast(std::rand()) / RAND_MAX < getReductionFactor(analysisJet.pt()))) { + continue; } + analyzeJetSVInfo(analysisJet, allTracks, allSVs, SVsIndices, jetFlavor, eventWeight); analyzeJetTrackInfo(collision, analysisJet, allTracks, allSVs, tracksIndices, 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_nSV_jetpT"), analysisJet.pt(), SVsIndices.size() < 250 ? SVsIndices.size() : 249); + registry.fill(HIST("h2_nSV_jetpT"), analysisJet.pt(), nSVs < 250 ? nSVs : 249); if (jetFlavor == 2) { registry.fill(HIST("h2_jetMass_jetpT_bjet"), analysisJet.pt(), analysisJet.mass(), eventWeight); @@ -475,6 +526,11 @@ struct BJetTreeCreator { } for (auto& mcpjet : analysisJet.template matchedJetGeo_as()) { + + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + if (jetFlavor == 2) { registry.fill(HIST("h2_Response_DetjetpT_PartjetpT_bjet"), analysisJet.pt(), mcpjet.pt(), eventWeight); } else if (jetFlavor == 1) { @@ -486,7 +542,7 @@ struct BJetTreeCreator { if (produceTree) { bjetConstituentsTable(bjetParamsTable.lastIndex() + 1, tracksIndices, SVsIndices); - bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), SVsIndices.size(), analysisJet.mass(), jetFlavor, analysisJet.r()); + bjetParamsTable(analysisJet.pt(), analysisJet.eta(), analysisJet.phi(), tracksIndices.size(), nSVs, analysisJet.mass(), jetFlavor, analysisJet.r()); } } } @@ -495,7 +551,7 @@ struct BJetTreeCreator { Filter mccollisionFilter = nabs(aod::jmccollision::posZ) < vertexZCut; using FilteredCollisionMCP = soa::Filtered; - void processMCTruthJets(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTable const& MCPjets, JetParticles const& MCParticles) + void processMCTruthJets(FilteredCollisionMCP::iterator const& /*collision*/, MCPJetTable const& MCPjets, aod::JetParticles const& MCParticles) { for (const auto& mcpjet : MCPjets) { @@ -512,11 +568,19 @@ struct BJetTreeCreator { continue; } - int16_t jetFlavor = 0; - jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, MCParticles); - // jetFlavor = jettaggingutilities::mcpJetFromHFShower(mcpjet, mcParticlesPerColl, (float)(mcpjet.r() / 100.)); - float eventWeight = mcpjet.eventWeight(); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + + int16_t jetFlavor = 0; + if (useQuarkDef) { + jetFlavor = jettaggingutilities::getJetFlavor(mcpjet, MCParticles); + } else { + jetFlavor = jettaggingutilities::getJetFlavorHadron(mcpjet, MCParticles); + // jetFlavor = jettaggingutilities::mcpJetFromHFShower(mcpjet, MCParticles, (float)(mcpjet.r() / 100.)); + } if (jetFlavor == 2) { registry.fill(HIST("h_jetpT_particle_bjet"), mcpjet.pt(), eventWeight); diff --git a/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx b/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx index 2a298d0a44b..610e890cf20 100644 --- a/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx +++ b/PWGJE/Tasks/emcalPi0EnergyScaleCalib.cxx @@ -201,7 +201,7 @@ struct Pi0EnergyScaleCalibTask { Configurable mMinEnergyCut{"MinEnergyCut", 0.7, "apply min cluster energy cut"}; Configurable mMinNCellsCut{"MinNCellsCut", 1, "apply min cluster number of cell cut"}; Configurable mMinOpenAngleCut{"OpeningAngleCut", 0.0202, "apply min opening angle cut"}; - Configurable mClusterDefinition{"clusterDefinition", "kV3Default", "cluster definition to be selected, e.g. V3Default"}; + Configurable mClusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10 = kV3Default"}; Configurable mRequireBothPhotonsFromAcceptance{"RequireBothPhotonsFromAcceptance", 0, "Require both photons to be from the same acceptance category"}; Configurable mAcceptanceRestrictionType{"AcceptanceRestrictionType", 0, "0: No restriction, 1: Ignore behind TRD, 2: Only Behind TRD, 3: Only EMCal, 4: OnlyDCal, 5: Remove clusters on edges"}; @@ -213,8 +213,7 @@ struct Pi0EnergyScaleCalibTask { // define cluster filter. It selects only those clusters which are of the type // specified in the string mClusterDefinition,e.g. kV3Default, which is V3 clusterizer with default // clusterization parameters - o2::aod::EMCALClusterDefinition clusDef = o2::aod::emcalcluster::getClusterDefinitionFromString(mClusterDefinition.value); - Filter clusterDefinitionSelection = o2::aod::emcalcluster::definition == static_cast(clusDef); + Filter clusterDefinitionSelection = o2::aod::emcalcluster::definition == mClusterDefinition; // define container for photons std::vector mPhotons; diff --git a/PWGJE/Tasks/emcclustermonitor.cxx b/PWGJE/Tasks/emcclustermonitor.cxx index b922e4cf068..bbf29d344e7 100644 --- a/PWGJE/Tasks/emcclustermonitor.cxx +++ b/PWGJE/Tasks/emcclustermonitor.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -75,6 +76,7 @@ struct ClusterMonitor { std::vector mVetoBCIDs; std::vector mSelectBCIDs; + std::vector mCellTime; /// \brief Create output histograms and initialize geometry void init(InitContext const&) @@ -94,6 +96,8 @@ struct ClusterMonitor { const o2Axis supermoduleAxis{20, -0.5, 19.5, "Supermodule ID"}; o2Axis timeAxis{mClusterTimeBinning, "t_{cl} (ns)"}; o2Axis numberClustersAxis{mNumberClusterBinning, "Number of clusters / event"}; + const AxisSpec thAxisCellTimeDiff{3000, -1500, 1500, "#Delta#it{t}_{cell} (ns)"}; + 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}}); @@ -109,7 +113,6 @@ struct ClusterMonitor { 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) - int MaxMatched = 20; // maximum number of matched tracks, hardcoded in emcalCorrectionTask.cxx! mHistManager.add("clusterE", "Energy of cluster", o2HistType::kTH1F, {energyAxis}); mHistManager.add("clusterEMatched", "Energy of cluster (with match)", o2HistType::kTH1F, {energyAxis}); mHistManager.add("clusterESupermodule", "Energy of the cluster vs. supermoduleID", o2HistType::kTH2F, {energyAxis, supermoduleAxis}); @@ -122,33 +125,8 @@ struct ClusterMonitor { mHistManager.add("clusterDistanceToBadChannel", "Distance to bad channel", o2HistType::kTH1F, {{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("clusterTM_dEtadPhi", "cluster trackmatching dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH3F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dEta dPhi of only the Nth clostest track - mHistManager.add("clusterTM_dEtadPhi_ASide", "cluster trackmatching in A-Side dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest track in A-Aside - mHistManager.add("clusterTM_dEtadPhi_CSide", "cluster trackmatching in C-Side tracks dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest track in C-Side - mHistManager.add("clusterTM_PosdEtadPhi", "cluster trackmatching positive tracks dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest positive track - mHistManager.add("clusterTM_NegdEtadPhi", "cluster trackmatching negative tracks dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest negative track - mHistManager.add("clusterTM_PosdEtadPhi_Pl0_75", "cluster trackmatching positive tracks, p < 0.75 dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest positive track with p < 0.75 GeV/c - mHistManager.add("clusterTM_NegdEtadPhi_Pl0_75", "cluster trackmatching negative tracks, p < 0.75 dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest 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;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest 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;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest 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;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest positive track with p >= 1.25 GeV/c - mHistManager.add("clusterTM_NegdEtadPhi_Pgeq1_25", "cluster trackmatching negative tracks, p >= 1.25 dEta/dPhi;d#it{#eta};d#it{#varphi} (rad)", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, -0.4, 0.4}}); // dEta dPhi of only the clostest 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::kTH2F, {{100, -0.4, 0.4}, {100, 0.0, 50.}}); // dEta vs pT of only the clostest track - mHistManager.add("clusterTM_PosdPhiPt", "cluster trackmatching positive tracks dPhi/#it{p}_{T};d#it{#varphi} (rad);#it{p}_{T} (GeV/#it{c})", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, 0.0, 50.}}); // dPhi vs pT of only the clostest positive track - mHistManager.add("clusterTM_NegdPhiPt", "cluster trackmatching negative tracks dPh/#it{p}_{T}i;d#it{#varphi} (rad);#it{p}_{T} (GeV/#it{c})", o2HistType::kTH2F, {{100, -0.4, 0.4}, {100, 0.0, 50.}}); // dPhi vs pT of only the clostest negative track - mHistManager.add("clusterTM_dEtaTN", "cluster trackmatching dEta/TN;d#it{#eta};#it{N}_{matched tracks}", o2HistType::kTH2F, {{100, -0.4, 0.4}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // 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, {{100, -0.4, 0.4}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dPhi compared to the Nth closest track - mHistManager.add("clusterTM_dRTN", "cluster trackmatching dR/TN;d#it{R};#it{N}_{matched tracks}", o2HistType::kTH2F, {{100, 0.0, 0.4}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dR compared to the Nth closest track - mHistManager.add("clusterTM_NTrack", "cluster trackmatching NMatchedTracks", o2HistType::kTH1I, {{11, -0.5, 10.5}}); // how many tracks are matched - mHistManager.add("clusterTM_dEtaTNAli", "cluster trackmatching dEta/TN;d#it{#eta};#it{N}_{matched tracks}", o2HistType::kTH2F, {{100, -0.06, 0.06}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dEta compared to the Nth closest track with cuts from latest Pi0 Run2 analysis - mHistManager.add("clusterTM_dPhiTNAli", "cluster trackmatching dPhi/TN;d#it{#varphi} (rad);#it{N}_{matched tracks}", o2HistType::kTH2F, {{100, -0.1, 0.1}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dPhi compared to the Nth closest track with cuts from latest Pi0 Run2 analysis - mHistManager.add("clusterTM_dRTNAli", "cluster trackmatching dR/TN;d#it{R};#it{N}_{matched tracks}", o2HistType::kTH2F, {{100, 0.0, 0.1}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // dR compared to the Nth closest track with cuts from latest Pi0 Run2 analysis - mHistManager.add("clusterTM_NTrackAli", "cluster trackmatching NMatchedTracks", o2HistType::kTH1I, {{11, -0.5, 10.5}}); // how many tracks are matched with cuts from latest Pi0 Run2 analysis - mHistManager.add("clusterTM_EoverP_E", "cluster E/p (dEtadPhi<0.05);#it{E}_{cluster}/#it{p}_{track};#it{E}_{cluster} (GeV)", o2HistType::kTH3F, {{500, 0, 10}, {200, 0, 100}, {MaxMatched, 0.5, MaxMatched + 0.5}}); // E/p vs p vs # matched track - mHistManager.add("clusterTM_EvsP", "cluster E/track p (dEtadPhi<0.05);#it{E}_{cluster} (GeV);#it{p}_{track} (GeV/#it{c})", o2HistType::kTH2F, {{500, 0, 10}, {200, 0, 100}}); // E vs p for closest track with dEta,dPhi<0.05 - mHistManager.add("clusterTM_EoverP_electron", "cluster E/electron p (dEtadPhi<0.05);#it{E}_{cluster} (GeV);#it{p}_{e^{#pm}} (GeV/#it{c})", o2HistType::kTH2F, {{500, 0, 10}, {200, 0, 100}}); // E over p vs track pT for closest electron/positron track with dEta,dPhi<0.05 - mHistManager.add("clusterTM_EoverP_hadron", "cluster E/hadron p (dEtadPhi<0.05);#it{E}_{cluster} (GeV);#it{p}_{e^{#pm}} (GeV/#it{c})", o2HistType::kTH2F, {{500, 0, 10}, {200, 0, 100}}); // E over p vs track pT for closest hadron track with dEta,dPhi<0.05 - mHistManager.add("clusterTM_EoverP_Pt", "cluster E/track vs track pT (dEtadPhi<0.05);#it{E}_{cluster}/#it{p}_{track};#it{p}_{T,track} (GeV/#it{c})", o2HistType::kTH2F, {{500, 0, 10}, {200, 0, 100}}); // E vs p vs track pTfor closest track with dEta,dPhi<0.05 + mHistManager.add("clusterCellTimeDiff", "Cell time difference in clusters", o2HistType::kTH1D, {thAxisCellTimeDiff}); + mHistManager.add("clusterCellTimeMean", "Mean cell time per cluster", o2HistType::kTH1D, {thAxisCellTimeMean}); // add histograms per supermodule for (int ism = 0; ism < 20; ++ism) { @@ -266,12 +244,21 @@ struct ClusterMonitor { auto cellsofcluster = emccluscells.sliceBy(perCluster, cluster.globalIndex()); double maxamp = 0; double ampfraction = 0; + mCellTime.clear(); + mCellTime.reserve(cellsofcluster.size()); for (const auto& cell : cellsofcluster) { // example how to get any information of the cell associated with cluster LOG(debug) << "Cell ID:" << cell.calo().amplitude() << " Time " << cell.calo().time(); if (cell.calo().amplitude() > maxamp) { maxamp = cell.calo().amplitude(); } + mCellTime.push_back(cell.calo().time()); + } // end of loop over cells + mHistManager.fill(HIST("clusterCellTimeMean"), std::accumulate(mCellTime.begin(), mCellTime.end(), 0.0f) / mCellTime.size()); + for (int iCell1 = 0; iCell1 < mCellTime.size() - 1; iCell1++) { + for (int iCell2 = iCell1 + 1; iCell2 < mCellTime.size(); iCell2++) { + mHistManager.fill(HIST("clusterCellTimeDiff"), mCellTime[iCell1] - mCellTime[iCell2]); + } } ampfraction = maxamp / cluster.energy(); mHistManager.fill(HIST("clusterAmpFractionLeadingCell"), ampfraction); diff --git a/PWGJE/Tasks/emceventselectionqa.cxx b/PWGJE/Tasks/emceventselectionqa.cxx index b373371499f..de4228aa70e 100644 --- a/PWGJE/Tasks/emceventselectionqa.cxx +++ b/PWGJE/Tasks/emceventselectionqa.cxx @@ -41,7 +41,7 @@ struct EmcEventSelectionQA { using o2HistType = o2::framework::HistType; using o2Axis = o2::framework::AxisSpec; - o2Axis matchingAxis{3, -0.5, 2.5, "matchingStatus", "Matching status"}, // 0, no vertex,1 vertex found , 2 multiple vertices found + 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}); @@ -72,6 +72,7 @@ struct EmcEventSelectionQA { 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}); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatching")).get()); initCollisionHistogram(mHistManager.get(HIST("hCollisionMatchingReadout")).get()); @@ -162,10 +163,6 @@ struct EmcEventSelectionQA { } } - if (bc.selection_bit(aod::evsel::kIsTriggerTVX)) { - mHistManager.fill(HIST("hBCTVX"), bcID); - } - // lookup number of cells for global BC of this BC // avoid iteration over cell table for speed reason auto found = cellGlobalBCs.find(bc.globalBC()); @@ -185,6 +182,12 @@ struct EmcEventSelectionQA { } else { collisionStatus = 2; } + + if (bc.selection_bit(aod::evsel::kIsTriggerTVX)) { + mHistManager.fill(HIST("hBCTVX"), bcID); + mHistManager.fill(HIST("hBCCollisionCounter_TVX"), bcID, collisionStatus); + } + if (collisionStatus >= 0) { mHistManager.fill(HIST("hCollisionMatching"), collisionStatus); if (isEMCALreadout) { diff --git a/PWGJE/Tasks/emctmmonitor.cxx b/PWGJE/Tasks/emctmmonitor.cxx index 3b6773e7127..3a191cba635 100644 --- a/PWGJE/Tasks/emctmmonitor.cxx +++ b/PWGJE/Tasks/emctmmonitor.cxx @@ -349,7 +349,6 @@ struct TrackMatchingMonitor { mHistManager.fill(HIST("clusterTM_EoverP_E"), eOverP, cluster.energy(), t); mHistManager.fill(HIST("clusterTM_dEtadPhi"), dEta, dPhi, t); mHistManager.fill(HIST("clusterEMatched"), cluster.energy(), t); - mHistManager.fill(HIST("clusterTM_dEtaPt"), dEta, pT, 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); diff --git a/PWGJE/Tasks/emcvertexselectionqa.cxx b/PWGJE/Tasks/emcvertexselectionqa.cxx index 9d3a33a2443..4a803adc24f 100644 --- a/PWGJE/Tasks/emcvertexselectionqa.cxx +++ b/PWGJE/Tasks/emcvertexselectionqa.cxx @@ -37,6 +37,15 @@ using FullTracksIU = soa::Join; struct EmcVertexSelectionQA { o2::framework::HistogramRegistry mHistManager{"EMCALVertexSelectionQAHistograms"}; + Configurable cfgZvtxMax{"cfgZvtxMax", 20.f, "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 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"}; + void init(o2::framework::InitContext const&) { using o2HistType = o2::framework::HistType; @@ -66,6 +75,10 @@ struct EmcVertexSelectionQA { mHistManager.add("hVertexRelDiffRobustStdDevDCA", "Relative Difference of Robust StdDev DCA to StdDev DCA of Vertex vs its Quality", o2HistType::kTH2F, {{200, 0, 2}, qualityAxis}); mHistManager.add("hVertexRelDiffRobustStdDevTrackTime", "Relative Difference of Robust Standard Deviation to Standard Deviation of Tracks Contributing to the Vertex vs its Quality", o2HistType::kTH2F, {{200, 0, 2}, qualityAxis}); + // Z vertex positions of two vertices in the same BC (to look for two collisions in the same BC with similar z-vertex positions) + mHistManager.add("hDoubleZVertex", "Z Vertex Position Correlation of two Collions in the same BC", o2HistType::kTH2F, {{300, -15., 15.}, {300, -15., 15.}}); + mHistManager.add("hZVertexDiff", "Difference Z Vertex Position of two Collions in the same BC", o2HistType::kTH1F, {{40000, -20., 20., "Z_{vtx 1}-Z_{vtx 2} (cm)"}}); + // Set axis labels and bin titles initVertexHistogram(mHistManager.get(HIST("hCollisionMatching")).get()); initVertexHistogram(mHistManager.get(HIST("hCollisionMatchingReadout")).get()); @@ -84,6 +97,8 @@ struct EmcVertexSelectionQA { mHistManager.get(HIST("hnVertexContributors")).get()->GetXaxis()->SetTitle("N_{contr} to Vtx 1"); mHistManager.get(HIST("hnVertexContributors")).get()->GetYaxis()->SetTitle("N_{contr} to Vtx 2"); + mHistManager.get(HIST("hDoubleZVertex")).get()->GetXaxis()->SetTitle("Z_{vtx 1} (cm)"); + mHistManager.get(HIST("hDoubleZVertex")).get()->GetYaxis()->SetTitle("Z_{vtx 2} (cm)"); } Preslice perCollision = aod::track::collisionId; @@ -91,23 +106,32 @@ struct EmcVertexSelectionQA { void process(bcEvSels const& bcs, collEventSels const& collisions, FullTracksIU const& tracks) { for (const auto& bc : bcs) { - bool isEMCALreadout = false; + bool isEMCALreadout = (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.runNumber() > 300000) { - // 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)) { - isEMCALreadout = true; - } - } else { - // run1/2: rely on trigger cluster, runlist must contain only runs with EMCAL in readout - // Select min. bias trigger and EMCAL L0/L1 triggers - if (bc.alias_bit(kINT7) || bc.alias_bit(kEMC7) || bc.alias_bit(kEG1) || bc.alias_bit(kEG2) || bc.alias_bit(kEJ1) || bc.alias_bit(kEJ2)) { - isEMCALreadout = true; - } + auto colsinbc = collisions.sliceBy(perFoundBC, bc.globalIndex()); + + bool isBCAccepted = true; + for (auto& col : colsinbc) { + if (cfgRequireSel8 && !col.sel8()) + isBCAccepted = false; + if (cfgRequireFT0AND && !col.selection_bit(o2::aod::evsel::kIsTriggerTVX)) + isBCAccepted = false; + if (col.posZ() < -cfgZvtxMax || col.posZ() > cfgZvtxMax) + isBCAccepted = false; + if (cfgRequireNoTFB && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + isBCAccepted = false; + if (cfgRequireNoITSROFB && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + isBCAccepted = false; + if (cfgRequireNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + isBCAccepted = false; + if (cfgRequireVertexITSTPC && !col.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + isBCAccepted = false; + if (cfgRequireGoodZvtxFT0vsPV && !col.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + isBCAccepted = false; } + if (!isBCAccepted) + continue; - auto colsinbc = collisions.sliceBy(perFoundBC, bc.globalIndex()); int collisionStatus = -1; if (!colsinbc.size()) { collisionStatus = 0; @@ -127,6 +151,7 @@ struct EmcVertexSelectionQA { if (collisionStatus > 0) { int nVtx = 0; int nVtxwithTOForTRDcontr = 0; + std::vector zVertexPositions; std::vector nVtxContributors; for (auto& col : colsinbc) { // Loop over all collisions/vertices int ivtxquality = 0; // 0: TPC/ITS contributor, 1: TRD contributor , 2: TOF contributor @@ -184,12 +209,16 @@ struct EmcVertexSelectionQA { nVtxwithTOForTRDcontr++; } nVtxContributors.push_back(nPVContributorTracks); + zVertexPositions.push_back(col.posZ()); } mHistManager.fill(HIST("hnVerticeswithTOForTRDcontr"), nVtx, nVtxwithTOForTRDcontr); if (collisionStatus == 2) { mHistManager.fill(HIST("hnVertexContributors"), nVtxContributors.at(0), nVtxContributors.at(1)); + mHistManager.fill(HIST("hDoubleZVertex"), zVertexPositions.at(0), zVertexPositions.at(1)); + mHistManager.fill(HIST("hZVertexDiff"), zVertexPositions.at(0) - zVertexPositions.at(1)); } nVtxContributors.clear(); + zVertexPositions.clear(); } } } diff --git a/PWGJE/Tasks/fulljetspectrapp.cxx b/PWGJE/Tasks/fulljetspectrapp.cxx new file mode 100644 index 00000000000..b683a6ef98c --- /dev/null +++ b/PWGJE/Tasks/fulljetspectrapp.cxx @@ -0,0 +1,897 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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/gammajettreeproducer.cxx b/PWGJE/Tasks/gammajettreeproducer.cxx new file mode 100644 index 00000000000..273205ccb7c --- /dev/null +++ b/PWGJE/Tasks/gammajettreeproducer.cxx @@ -0,0 +1,295 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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/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/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 "DataFormatsEMCAL/Cell.h" +#include "DataFormatsEMCAL/Constants.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" +#include "TVector2.h" + +#include "CommonDataFormat/InteractionRecord.h" + +#include "EventFiltering/filterTables.h" + +// \struct GammaJetTreeProducer +/// \brief Task to produce a tree for gamma-jet analysis, including photons (and information of isolation) and charged and full jets +/// \author Florian Jonas , UC Berkeley/LBNL +/// \since 02.08.2024 +/// +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using selectedClusters = o2::soa::Filtered; + +#include "Framework/runDataProcessing.h" + +struct GammaJetTreeProducer { + // analysis tree + // charged jets + // photon candidates + Produces chargedJetsTable; + Produces eventsTable; + Produces gammasTable; + + HistogramRegistry mHistograms{"GammaJetTreeProducerHisto"}; + + // --------------- + // Configureables + // --------------- + + // event cuts + Configurable mVertexCut{"vertexCut", 10.0, "apply z-vertex cut with value in cm"}; + 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 + trackSelections{"trackSelections", "globalTracks", "set track selections"}; + Configurable trackMinPt{"trackMinPt", 0.15, "minimum track pT cut"}; + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + Configurable isoR{"isoR", 0.4, "isolation cone radius"}; + + // cluster cuts + Configurable mClusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default"}; + // Preslice perClusterMatchedTracks = o2::aod::jcluster::clusterId; + + int mRunNumber = 0; + int eventSelection = -1; + int trackSelection = -1; + + std::unordered_map collisionMapping; + std::vector triggerMaskBits; + + void init(InitContext const&) + { + using o2HistType = HistType; + using o2Axis = AxisSpec; + + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + + // create histograms + LOG(info) << "Creating histograms"; + + const o2Axis ptAxis{100, 0, 100, "p_{T} (GeV/c)"}; + const o2Axis energyAxis{100, 0, 100, "E (GeV)"}; + const o2Axis m02Axis{100, 0, 3, "m02"}; + + 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("chjetpt_vs_constpt", "pT of charged jet vs pT of constituents", o2HistType::kTH2F, {ptAxis, ptAxis}); + } + + // --------------------- + // Helper functions + // --------------------- + bool isTrackSelected(const auto& track) + { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + return false; + } + if (track.pt() < trackMinPt) { + return false; + } + + return true; + } + + bool isEventAccepted(const auto& collision) + { + + if (collision.posZ() > mVertexCut) { + return false; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return false; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return false; + } + if (!jetderiveddatautilities::eventEMCAL(collision)) { + return false; + } + return true; + } + + double ch_iso_in_cone(const auto& cluster, aod::JetTracks const& tracks, float radius = 0.4) + { + double iso = 0; + for (auto track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + // make dR function live somwhere else + float dR = jetutilities::deltaR(cluster, track); + if (dR < radius) { + iso += track.pt(); + } + } + return iso; + } + double ch_perp_cone_rho(const auto& cluster, aod::JetTracks const& tracks, float radius = 0.4) + { + double ptSumLeft = 0; + double ptSumRight = 0; + + double cPhi = TVector2::Phi_0_2pi(cluster.phi()); + + // rotate cone left by 90 degrees + float cPhiLeft = cPhi - TMath::Pi() / 2; + float cPhiRight = cPhi + TMath::Pi() / 2; + + // loop over tracks + float dRLeft, dRRight; + for (auto track : tracks) { + if (!isTrackSelected(track)) { + continue; + } + dRLeft = jetutilities::deltaR(cluster.eta(), cPhiLeft, track.eta(), track.phi()); + dRRight = jetutilities::deltaR(cluster.eta(), cPhiRight, track.eta(), track.phi()); + + if (dRLeft < radius) { + ptSumLeft += track.pt(); + } + if (dRRight < radius) { + ptSumRight += track.pt(); + } + } + + float rho = (ptSumLeft + ptSumRight) / (2 * TMath::Pi() * radius * radius); + return rho; + } + + // --------------------- + // Processing functions + // --------------------- + void processClearMaps(aod::JetCollisions const&) + { + collisionMapping.clear(); + } + PROCESS_SWITCH(GammaJetTreeProducer, processClearMaps, "process function that clears all the maps in each dataframe", true); + + // 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::jcluster::definition == mClusterDefinition); + // Process clusters + void processClusters(soa::Join::iterator const& collision, selectedClusters const& clusters, aod::JetTracks const& tracks) + { + if (!isEventAccepted(collision)) { + return; + } + + eventsTable(collision.multiplicity(), collision.centrality(), collision.rho(), collision.eventSel(), collision.alias_raw()); + collisionMapping[collision.globalIndex()] = eventsTable.lastIndex(); + + // loop over clusters + for (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); + + // find closest matched track + double dEta = 0; + double dPhi = 0; + // double dRMin = 100; + double p = -1; + + // auto tracksofcluster = matchedtracks.sliceBy(perClusterMatchedTracks, cluster.globalIndex()); + // for (const auto& match : tracksofcluster) { + // // ask the jtracks table for track with ID trackID + // double dR = deltaR(cluster.eta(), cluster.phi(), match.tracks_as().Eta(), match.tracks_as().Phi()); + // if (dR < dRMin) { + // dRMin = dR; + // dEta = cluster.eta() - match.tracks_as().eta(); + // dPhi = TVector2::Phi_0_2pi(cluster.phi()) - TVector2::Phi_0_2pi(match.tracks_as().phi()); + // if (abs(dPhi) > M_PI) { + // dPhi = 2 * M_PI - abs(dPhi); + // } + // p = match.tracks_as().p(); + // } + // } + + // // for compression reasons make dPhi and dEta 0 if no match is found + // if (p == -1) { + // dPhi = 0; + // dEta = 0; + // } + + gammasTable(eventsTable.lastIndex(), cluster.energy(), cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), cluster.nlm(), isoraw, perpconerho, dPhi, dEta, p); + } + + // dummy loop over tracks + for (auto track : tracks) { + mHistograms.fill(HIST("trackPt"), track.pt()); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processClusters, "Process EMCal clusters", true); + + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + // Process charged jets + void processChargedJets(soa::Join::iterator const& collision, soa::Filtered> const& chargedJets, aod::JetTracks const&) + { + // event selection + if (!isEventAccepted(collision)) { + return; + } + + // loop over charged jets + for (auto jet : chargedJets) { + if (jet.pt() < jetPtMin) + continue; + ushort nconst = 0; + // loop over constituents + for (auto& constituent : jet.template tracks_as()) { + mHistograms.fill(HIST("chjetpt_vs_constpt"), jet.pt(), constituent.pt()); + nconst++; + } + int32_t storedColIndex = -1; + if (auto foundCol = collisionMapping.find(collision.globalIndex()); foundCol != collisionMapping.end()) { + storedColIndex = foundCol->second; + } + chargedJetsTable(storedColIndex, jet.pt(), jet.eta(), jet.phi(), jet.energy(), jet.mass(), jet.area(), nconst); + // fill histograms + mHistograms.fill(HIST("chjetPt"), jet.pt()); + } + } + PROCESS_SWITCH(GammaJetTreeProducer, processChargedJets, "Process charged jets", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc, TaskName{"gamma-jet-tree-producer"})}; + return workflow; +} diff --git a/PWGJE/Tasks/hffragmentationfunction.cxx b/PWGJE/Tasks/hffragmentationfunction.cxx index b080485d2ea..9284c66e6c1 100644 --- a/PWGJE/Tasks/hffragmentationfunction.cxx +++ b/PWGJE/Tasks/hffragmentationfunction.cxx @@ -15,6 +15,9 @@ /// /// 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 "fastjet/PseudoJet.hh" @@ -41,6 +44,7 @@ #include "PWGJE/Core/JetFinder.h" #include "PWGJE/Core/FastJetUtilities.h" #include "PWGJE/Core/JetHFUtilities.h" +#include "PWGJE/Core/JetUtilities.h" using namespace o2; using namespace o2::framework; @@ -68,6 +72,7 @@ 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, float); DECLARE_SOA_COLUMN(HfPt, hfpt, float); DECLARE_SOA_COLUMN(HfEta, hfeta, float); DECLARE_SOA_COLUMN(HfPhi, hfphi, float); @@ -75,10 +80,16 @@ 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); @@ -91,16 +102,21 @@ DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", jet_distance::JetPt, jet_distance::JetEta, jet_distance::JetPhi, + jet_distance::JetNConst, jet_distance::HfPt, jet_distance::HfEta, jet_distance::HfPhi, jet_distance::HfMass, - jet_distance::HfY); + jet_distance::HfY, + jet_distance::HfMlScore0, + 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, @@ -112,18 +128,25 @@ DECLARE_SOA_TABLE(MCDJetDistanceTable, "AOD", "MCDJETDISTTABLE", jet_distance::JetPt, jet_distance::JetEta, jet_distance::JetPhi, + jet_distance::JetNConst, jet_distance::HfPt, jet_distance::HfEta, jet_distance::HfPhi, jet_distance::HfMass, jet_distance::HfY, jet_distance::HfPrompt, - jet_distance::HfMatch); + jet_distance::HfMatch, + jet_distance::HfMlScore0, + jet_distance::HfMlScore1, + jet_distance::HfMlScore2, + 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, @@ -133,12 +156,18 @@ DECLARE_SOA_TABLE(MatchJetDistanceTable, "AOD", "MATCHTABLE", jet_distance::JetPt, jet_distance::JetEta, jet_distance::JetPhi, + jet_distance::JetNConst, jet_distance::HfPt, jet_distance::HfEta, jet_distance::HfPhi, jet_distance::HfMass, jet_distance::HfY, - jet_distance::HfPrompt); + jet_distance::HfPrompt, + jet_distance::HfMlScore0, + jet_distance::HfMlScore1, + jet_distance::HfMlScore2, + jet_distance::HfMatchedFrom, + jet_distance::HfSelectedAs); } // namespace o2::aod struct HfFragmentationFunctionTask { @@ -153,21 +182,40 @@ struct HfFragmentationFunctionTask { using JetMCPTable = soa::Join; // slices for accessing proper HF mcdjets collision associated to mccollisions - PresliceUnsorted CollisionsPerMCCollision = aod::jmccollisionlb::mcCollisionId; + PresliceUnsorted CollisionsPerMCCollision = aod::jmccollisionlb::mcCollisionId; Preslice D0MCDJetsPerCollision = aod::jet::collisionId; Preslice D0MCPJetsPerMCCollision = aod::jet::mcCollisionId; // Histogram registry: an object to hold your histograms HistogramRegistry registry{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + + int eventSelection = -1; + void init(InitContext const&) { + // initialise event selection: + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); // create histograms // collision system histograms - registry.add("h_collision_counter", ";# collisions;", {HistType::kTH1F, {{2, 0., 1.}}}); + std::vector histLabels = {"mccollisions", "z_cut", "collisions", "sel8"}; + registry.add("h_collision_counter", ";# of collisions;", HistType::kTH1F, {{static_cast(histLabels.size()), 0.0, static_cast(histLabels.size())}}); + auto counter = registry.get(HIST("h_collision_counter")); + for (std::vector::size_type iCounter = 0; iCounter < histLabels.size(); iCounter++) { + counter->GetXaxis()->SetBinLabel(iCounter + 1, histLabels[iCounter].data()); + } + registry.add("h_jet_counter", ";# of jets;", {HistType::kTH1F, {{6, 0., 3.0}}}); + auto jetCounter = registry.get(HIST("h_jet_counter")); + jetCounter->GetXaxis()->SetBinLabel(1, "particle level"); + jetCounter->GetXaxis()->SetBinLabel(2, "detector level"); + jetCounter->GetXaxis()->SetBinLabel(3, "particle matched jets"); + jetCounter->GetXaxis()->SetBinLabel(4, "detector matched jets"); + jetCounter->GetXaxis()->SetBinLabel(5, "mcd matched to mcp loop"); + jetCounter->GetXaxis()->SetBinLabel(6, "mcp matched to mcd loop"); // D0 candidate histograms from data - registry.add("h_jet_counter", ";# jets;", {HistType::kTH1F, {{2, 0., 1.}}}); registry.add("h_d0_jet_projection", ";z^{D^{0},jet}_{||};dN/dz^{D^{0},jet}_{||}", {HistType::kTH1F, {{1000, 0., 10.}}}); registry.add("h_d0_jet_distance_vs_projection", ";#DeltaR_{D^{0},jet};z^{D^{0},jet}_{||}", {HistType::kTH2F, {{1000, 0., 10.}, {1000, 0., 10.}}}); registry.add("h_d0_jet_distance", ";#DeltaR_{D^{0},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 10.}}}); @@ -182,12 +230,16 @@ struct HfFragmentationFunctionTask { void processDummy(aod::TracksIU const&) {} PROCESS_SWITCH(HfFragmentationFunctionTask, processDummy, "Dummy process function turned on by default", true); - void processDataChargedSubstructure(JetCollision const&, + void processDataChargedSubstructure(aod::JetCollision const& collision, soa::Join const& jets, - CandidatesD0Data const&) + aod::CandidatesD0Data const&) { - - double axisDistance = 0; + // 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)) { + return; + } + registry.fill(HIST("h_collision_counter"), 3.0); for (auto& jet : jets) { // fill jet counter histogram @@ -195,15 +247,16 @@ struct HfFragmentationFunctionTask { // obtaining jet 3-vector TVector3 jetVector(jet.px(), jet.py(), jet.pz()); - for (auto& d0Candidate : jet.candidates_as()) { + for (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); // calculating angular distance in eta-phi plane - axisDistance = RecoDecay::sqrtSumOfSquares(jet.eta() - d0Candidate.eta(), deltaPhi(jet.phi(), d0Candidate.phi())); + double axisDistance = jetutilities::deltaR(jet, d0Candidate); // filling histograms registry.fill(HIST("h_d0_jet_projection"), z_parallel); @@ -218,41 +271,76 @@ struct HfFragmentationFunctionTask { // filling table distJetTable(axisDistance, - jet.pt(), jet.eta(), jet.phi(), - d0Candidate.pt(), d0Candidate.eta(), d0Candidate.phi(), d0Candidate.m(), d0Candidate.y()); + jet.pt(), jet.eta(), jet.phi(), jet.tracks_as().size(), + d0Candidate.pt(), d0Candidate.eta(), d0Candidate.phi(), d0Candidate.m(), d0Candidate.y(), d0Candidate.mlScores()[0], d0Candidate.mlScores()[1], d0Candidate.mlScores()[2]); break; // get out of candidates' loop after first HF particle is found in jet - } // end of D0 candidates loop + } // end of D0 candidates loop } // end of jets loop } // end of process function PROCESS_SWITCH(HfFragmentationFunctionTask, processDataChargedSubstructure, "charged HF jet substructure", false); - void processMcEfficiency(JetMcCollisions const& mccollisions, - JetCollisionsMCD const& collisions, + void processMcEfficiency(aod::JetMcCollisions const& mccollisions, + aod::JetCollisionsMCD const& collisions, JetMCDTable const& mcdjets, JetMCPTable const& mcpjets, - CandidatesD0MCD const&, - CandidatesD0MCP const&) + aod::CandidatesD0MCD const&, + aod::CandidatesD0MCP const&, + aod::JetTracks const&, + aod::JetParticles const&) { for (const auto& mccollision : mccollisions) { + registry.fill(HIST("h_collision_counter"), 0.0); + // skip collisions outside of |z| < vertexZCut + if (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()); for (const auto& collision : collisionsPerMCCollision) { + + registry.fill(HIST("h_collision_counter"), 2.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(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()); for (const auto& mcdjet : d0mcdJetsPerCollision) { + registry.fill(HIST("h_jet_counter"), 0.5); + // obtain leading HF candidate in jet - auto mcdd0cand = mcdjet.candidates_first_as(); + auto mcdd0cand = mcdjet.candidates_first_as(); + + if (mcdjet.has_matchedJetCand()) { + registry.fill(HIST("h_jet_counter"), 1.5); + } + + // reflection information for storage: +1 = D0, -1 = D0bar, 0 = neither + int matchedFrom = 0; + int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; + + if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level + matchedFrom = 1; + } else if (mcdd0cand.flagMcMatchRec() == -decayChannel) { // matched to D0bar on truth level + matchedFrom = -1; + } else { // matched to another kind of particle on truth level + matchedFrom = 0; + } // store data in MC detector level table - mcddistJetTable(RecoDecay::sqrtSumOfSquares(mcdjet.eta() - mcdd0cand.eta(), deltaPhi(mcdjet.phi(), mcdd0cand.phi())), - mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), // detector level jet + mcddistJetTable(jetutilities::deltaR(mcdjet, mcdd0cand), + mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.tracks_as().size(), // detector level jet mcdd0cand.pt(), mcdd0cand.eta(), mcdd0cand.phi(), mcdd0cand.m(), mcdd0cand.y(), (mcdd0cand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level D0 candidate - mcdjet.has_matchedJetCand()); + mcdjet.has_matchedJetCand(), mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2], // ML scores for bkg, prompt and non-prompt + matchedFrom, mcdd0cand.candidateSelFlag()); // check whether detector level candidate is a reflection, CandidateSelFlag == 0 -> selected as D0, CandidateSelFlag == 1 -> selected as D0bar } } @@ -260,12 +348,18 @@ struct HfFragmentationFunctionTask { const auto d0mcpJetsPerMCCollision = mcpjets.sliceBy(D0MCPJetsPerMCCollision, mccollision.globalIndex()); for (const auto& mcpjet : d0mcpJetsPerMCCollision) { + registry.fill(HIST("h_jet_counter"), 0.0); + // obtain leading HF particle in jet - auto mcpd0cand = mcpjet.candidates_first_as(); + auto mcpd0cand = mcpjet.candidates_first_as(); + + if (mcpjet.has_matchedJetCand()) { + registry.fill(HIST("h_jet_counter"), 1.0); + } // store data in MC detector level table (calculate angular distance in eta-phi plane on the fly) - mcpdistJetTable(RecoDecay::sqrtSumOfSquares(mcpjet.eta() - mcpd0cand.eta(), deltaPhi(mcpjet.phi(), mcpd0cand.phi())), - mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), // particle level jet + mcpdistJetTable(jetutilities::deltaR(mcpjet, mcpd0cand), + mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), mcpjet.tracks_as().size(), // particle level jet mcpd0cand.pt(), mcpd0cand.eta(), mcpd0cand.phi(), mcpd0cand.y(), (mcpd0cand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level D0 mcpjet.has_matchedJetCand()); } @@ -273,32 +367,77 @@ struct HfFragmentationFunctionTask { } PROCESS_SWITCH(HfFragmentationFunctionTask, processMcEfficiency, "non-matched and matched MC HF and jets", false); - void processMcChargedMatched(JetMcCollision const&, - JetMCDTable const&, - JetMCPTable const& mcpjets, - CandidatesD0MCD const&, - CandidatesD0MCP const&) + void processMcChargedMatched(aod::JetMcCollisions const& mccollisions, + aod::JetCollisionsMCD const& collisions, + JetMCDTable const& mcdjets, + JetMCPTable const&, + aod::CandidatesD0MCD const&, + aod::CandidatesD0MCP const&, + aod::JetTracks const&, + aod::JetParticles const&) { - // fill jet counter histogram - registry.fill(HIST("h_collision_counter"), 0.5); + for (const auto& mccollision : mccollisions) { - // d0 particle level jets associated to same mccollision - for (const auto& mcpjet : mcpjets) { + registry.fill(HIST("h_collision_counter"), 0.0); - // obtain leading HF particle in jet - auto mcpd0cand = mcpjet.candidates_first_as(); + // skip collisions outside of |z| < vertexZCut + if (abs(mccollision.posZ()) > vertexZCut) { + continue; + } + registry.fill(HIST("h_collision_counter"), 1.0); - // loop through detector level matched to current particle level - for (auto& mcdjet : mcpjet.matchedJetCand_as()) { + // reconstructed collisions associated to same mccollision + const auto collisionsPerMCCollision = collisions.sliceBy(CollisionsPerMCCollision, mccollision.globalIndex()); + for (const auto& collision : collisionsPerMCCollision) { - // obtain leading HF candidate in jet - auto mcdd0cand = mcdjet.candidates_first_as(); + registry.fill(HIST("h_collision_counter"), 2.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !(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()); + for (const auto& mcdjet : d0mcdJetsPerCollision) { - // store matched particle and detector level data in one single table (calculate angular distance in eta-phi plane on the fly) - matchJetTable(RecoDecay::sqrtSumOfSquares(mcpjet.eta() - mcpd0cand.eta(), deltaPhi(mcpjet.phi(), mcpd0cand.phi())), mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), // particle level jet - mcpd0cand.pt(), mcpd0cand.eta(), mcpd0cand.phi(), mcpd0cand.y(), (mcpd0cand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level D0 - RecoDecay::sqrtSumOfSquares(mcdjet.eta() - mcdd0cand.eta(), deltaPhi(mcdjet.phi(), mcdd0cand.phi())), mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), // detector level jet - mcdd0cand.pt(), mcdd0cand.eta(), mcdd0cand.phi(), mcdd0cand.m(), mcdd0cand.y(), (mcdd0cand.originMcRec() == RecoDecay::OriginType::Prompt)); // detector level D0 + registry.fill(HIST("h_jet_counter"), 0.5); + + // comparison with fill on bin on 2.5 for sanity check + if (mcdjet.has_matchedJetCand()) { + registry.fill(HIST("h_jet_counter"), 1.5); + } + + // obtain leading HF candidate in jet + auto mcdd0cand = mcdjet.candidates_first_as(); + + // reflection information for storage: +1 = D0, -1 = D0bar, 0 = neither + int matchedFrom = 0; + int decayChannel = 1 << aod::hf_cand_2prong::DecayType::D0ToPiK; + + if (mcdd0cand.flagMcMatchRec() == decayChannel) { // matched to D0 on truth level + matchedFrom = 1; + } else if (mcdd0cand.flagMcMatchRec() == -decayChannel) { // matched to D0bar on truth level + matchedFrom = -1; + } else { // matched to another kind of particle on truth level + matchedFrom = 0; + } + + // loop through detector level matched to current particle level + for (auto& mcpjet : mcdjet.matchedJetCand_as()) { + + registry.fill(HIST("h_jet_counter"), 2.5); + + // obtain leading HF candidate in jet + auto mcpd0cand = mcpjet.candidates_first_as(); + + // store matched particle and detector level data in one single table (calculate angular distance in eta-phi plane on the fly) + matchJetTable(jetutilities::deltaR(mcpjet, mcpd0cand), mcpjet.pt(), mcpjet.eta(), mcpjet.phi(), mcpjet.tracks_as().size(), // particle level jet + mcpd0cand.pt(), mcpd0cand.eta(), mcpd0cand.phi(), mcpd0cand.y(), (mcpd0cand.originMcGen() == RecoDecay::OriginType::Prompt), // particle level D0 + jetutilities::deltaR(mcdjet, mcdd0cand), mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), mcdjet.tracks_as().size(), // detector level jet + mcdd0cand.pt(), mcdd0cand.eta(), mcdd0cand.phi(), mcdd0cand.m(), mcdd0cand.y(), (mcdd0cand.originMcRec() == RecoDecay::OriginType::Prompt), // detector level D0 + mcdd0cand.mlScores()[0], mcdd0cand.mlScores()[1], mcdd0cand.mlScores()[2], + matchedFrom, mcdd0cand.candidateSelFlag()); // check whether detector level candidate is a reflection, CandidateSelFlag == 0 -> selected as D0, CandidateSelFlag == 1 -> selected as D0bar + } + } } } } diff --git a/PWGJE/Tasks/jetChCorr.cxx b/PWGJE/Tasks/jetChCorr.cxx index 8d3cffd5346..43486b4567c 100644 --- a/PWGJE/Tasks/jetChCorr.cxx +++ b/PWGJE/Tasks/jetChCorr.cxx @@ -394,36 +394,36 @@ struct JetChCorr { } } - void processDummy(JetTracks const&) + void processDummy(aod::JetTracks const&) { } PROCESS_SWITCH(JetChCorr, processDummy, "Dummy process function turned on by default", true); - void processChargedJetsData(soa::Join::iterator const& jet, JetTracks const& tracks) + void processChargedJetsData(soa::Join::iterator const& jet, aod::JetTracks const& tracks) { analyseCharged(jet, tracks); } PROCESS_SWITCH(JetChCorr, processChargedJetsData, "charged jet substructure", false); void processChargedJetsEventWiseSubData(soa::Join::iterator const& jet, - JetTracksSub const& tracks) + aod::JetTracksSub const& tracks) { analyseCharged(jet, tracks); } PROCESS_SWITCH(JetChCorr, processChargedJetsEventWiseSubData, "eventwise-constituent subtracted charged jet substructure", false); void processChargedJetsMCD(typename soa::Join::iterator const& jet, - JetTracks const& tracks) + aod::JetTracks const& tracks) { analyseCharged(jet, tracks); } PROCESS_SWITCH(JetChCorr, processChargedJetsMCD, "charged jet substructure", false); void processChargedJetsMCP(typename soa::Join::iterator const& jet, - JetParticles const&) + aod::JetParticles const&) { jetConstituents.clear(); - for (auto& jetConstituent : jet.template tracks_as()) { + for (auto& jetConstituent : jet.template tracks_as()) { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex(), static_cast(JetConstituentStatus::track), pdg->Mass(jetConstituent.pdgCode())); } jetReclustering(jet); diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 99a7a9cf3b1..df4569a415e 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -14,6 +14,7 @@ // Authors: Daniel Jones #include +#include #include "TRandom3.h" @@ -62,6 +63,7 @@ struct hJetAnalysis { 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 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"}; Preslice> PartJetsPerCollision = aod::jet::mcCollisionId; @@ -69,10 +71,11 @@ struct hJetAnalysis { 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 eventCuts = nabs(aod::jcollision::posZ) < vertexZCut; + Filter eventTrackLevelCuts = nabs(aod::jcollision::posZ) < vertexZCut; HistogramRegistry registry{"registry", {{"hNtrig", "number of triggers;trigger type;entries", {HistType::kTH1F, {{2, 0, 2}}}}, + {"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}}}}, @@ -101,9 +104,9 @@ struct hJetAnalysis { {"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}}}}, - {"hDeltaRPartSignal", "Particle #DeltaR;#DeltaR;#frac{1}{N_{jets}}#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}}}}, - {"hDeltaRpTPartSignal", "Particle 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, 2 * o2::constants::math::PI}, {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, 2 * o2::constants::math::PI}, {50, 0.0, 0.15}}}}, {"hDeltaRReference", "#DeltaR;#DeltaR;#frac{dN_{jets}}{d#DeltaR}", {HistType::kTH1F, {{50, 0.0, 0.15}}}}, @@ -122,19 +125,23 @@ struct hJetAnalysis { int eventSelection = -1; int trackSelection = -1; + std::vector triggerMaskBits; + + Service pdg; void init(InitContext const&) { eventSelection = jetderiveddatautilities::initialiseEventSelection(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 eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut); + Filter eventTrackLevelCuts = nabs(aod::jcollision::posZ) < vertexZCut; } template - void fillHistograms(T const& jets, W const& /*jetsWTA*/, U const& tracks) + void fillHistograms(T const& jets, W const& /*jetsWTA*/, U const& tracks, float weight = 1.0) { bool is_sig_col; std::vector phi_TT_ar; @@ -142,6 +149,7 @@ struct hJetAnalysis { int trig_number = 0; int n_TT = 0; double leadingPT = 0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); float dice = rand->Rndm(); if (dice < frac_sig) @@ -161,36 +169,39 @@ struct hJetAnalysis { phi_TT_ar.push_back(track.phi()); n_TT++; } - registry.fill(HIST("hPtTrack"), track.pt()); - registry.fill(HIST("hEtaTrack"), track.eta()); - registry.fill(HIST("hPhiTrack"), track.phi()); + registry.fill(HIST("hPtTrack"), track.pt(), weight); + registry.fill(HIST("hEtaTrack"), track.eta(), weight); + registry.fill(HIST("hPhiTrack"), track.phi(), weight); } if (n_TT > 0) { trig_number = rand->Integer(n_TT); phi_TT = phi_TT_ar[trig_number]; if (is_sig_col) { - registry.fill(HIST("hNtrig"), 1.5); - registry.fill(HIST("hJetSignalMultiplicity"), jets.size()); - registry.fill(HIST("hSigEventTriggers"), n_TT); + registry.fill(HIST("hNtrig"), 1.5, weight); + registry.fill(HIST("hJetSignalMultiplicity"), jets.size(), weight); + registry.fill(HIST("hSigEventTriggers"), n_TT, weight); } if (!is_sig_col) { - registry.fill(HIST("hNtrig"), 0.5); - registry.fill(HIST("hJetReferenceMultiplicity"), jets.size()); - registry.fill(HIST("hRefEventTriggers"), n_TT); + registry.fill(HIST("hNtrig"), 0.5, weight); + registry.fill(HIST("hJetReferenceMultiplicity"), jets.size(), weight); + registry.fill(HIST("hRefEventTriggers"), n_TT, weight); } } for (auto& jet : jets) { - registry.fill(HIST("hJetPt"), jet.pt()); - registry.fill(HIST("hJetEta"), jet.eta()); - registry.fill(HIST("hJetPhi"), jet.phi()); + if (jet.pt() > pTHatMaxMCD * pTHat) { + continue; + } + registry.fill(HIST("hJetPt"), jet.pt(), weight); + registry.fill(HIST("hJetEta"), jet.eta(), weight); + registry.fill(HIST("hJetPhi"), jet.phi(), weight); for (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); - registry.fill(HIST("hDeltaRpT"), jet.pt(), dR); + registry.fill(HIST("hDeltaR"), dR, weight); + registry.fill(HIST("hDeltaRpT"), jet.pt(), dR, weight); } if (n_TT > 0) { float dphi = RecoDecay::constrainAngle(jet.phi() - phi_TT); @@ -200,23 +211,23 @@ struct hJetAnalysis { 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); - registry.fill(HIST("hDeltaRSignal"), dR); + registry.fill(HIST("hDeltaRpTSignal"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRSignal"), dR, weight); } - registry.fill(HIST("hDeltaRpTDPhiSignal"), jet.pt(), dphi, dR); + registry.fill(HIST("hDeltaRpTDPhiSignal"), jet.pt(), dphi, dR, weight); } - registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt()); + registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hSignalPt"), jet.pt()); + registry.fill(HIST("hSignalPt"), jet.pt(), weight); } - registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size()); + registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); for (auto& constituent : jet.template tracks_as()) { if (constituent.pt() > leadingPT) { leadingPT = constituent.pt(); } - registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt()); + registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); } - registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT); + registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } if (!is_sig_col) { for (auto& jetWTA : jet.template matchedJetGeo_as>()) { @@ -224,30 +235,30 @@ struct hJetAnalysis { 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); - registry.fill(HIST("hDeltaRReference"), dR); + registry.fill(HIST("hDeltaRpTReference"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRReference"), dR, weight); } - registry.fill(HIST("hDeltaRpTDPhiReference"), jet.pt(), dphi, dR); + registry.fill(HIST("hDeltaRpTDPhiReference"), jet.pt(), dphi, dR, weight); } - registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt()); + registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hReferencePt"), jet.pt()); + registry.fill(HIST("hReferencePt"), jet.pt(), weight); } - registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size()); + registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); for (auto& constituent : jet.template tracks_as()) { if (constituent.pt() > leadingPT) { leadingPT = constituent.pt(); } - registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt()); + registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); } - registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT); + registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } } } } - template - void fillMCPHistograms(T const& jets, U const& particles) + template + void fillMCPHistograms(T const& jets, W const& /*jetsWTA*/, U const& particles, float weight = 1.0) { bool is_sig_col; std::vector phi_TT_ar; @@ -255,6 +266,7 @@ struct hJetAnalysis { int trig_number = 0; int n_TT = 0; double leadingPT = 0; + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); float dice = rand->Rndm(); if (dice < frac_sig) @@ -263,6 +275,13 @@ struct hJetAnalysis { is_sig_col = false; for (auto& particle : particles) { + auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (!pdgParticle) { + continue; + } + if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) { + continue; + } if (is_sig_col && particle.pt() < pt_TTsig_max && particle.pt() > pt_TTsig_min) { phi_TT_ar.push_back(particle.phi()); n_TT++; @@ -271,59 +290,89 @@ struct hJetAnalysis { phi_TT_ar.push_back(particle.phi()); n_TT++; } - registry.fill(HIST("hPtPart"), particle.pt()); - registry.fill(HIST("hEtaPart"), particle.eta()); - registry.fill(HIST("hPhiPart"), particle.phi()); + registry.fill(HIST("hPtPart"), particle.pt(), weight); + registry.fill(HIST("hEtaPart"), particle.eta(), weight); + registry.fill(HIST("hPhiPart"), particle.phi(), weight); } if (n_TT > 0) { trig_number = rand->Integer(n_TT); phi_TT = phi_TT_ar[trig_number]; if (is_sig_col) { - registry.fill(HIST("hNtrig"), 1.5); - registry.fill(HIST("hJetSignalMultiplicity"), jets.size()); - registry.fill(HIST("hSigEventTriggers"), n_TT); + registry.fill(HIST("hNtrig"), 1.5, weight); + registry.fill(HIST("hJetSignalMultiplicity"), jets.size(), weight); + registry.fill(HIST("hSigEventTriggers"), n_TT, weight); } if (!is_sig_col) { - registry.fill(HIST("hNtrig"), 0.5); - registry.fill(HIST("hJetReferenceMultiplicity"), jets.size()); - registry.fill(HIST("hRefEventTriggers"), n_TT); + registry.fill(HIST("hNtrig"), 0.5, weight); + registry.fill(HIST("hJetReferenceMultiplicity"), jets.size(), weight); + registry.fill(HIST("hRefEventTriggers"), n_TT, weight); } } for (auto& jet : jets) { - registry.fill(HIST("hJetPt"), jet.pt()); - registry.fill(HIST("hJetEta"), jet.eta()); - registry.fill(HIST("hJetPhi"), jet.phi()); + if (jet.pt() > pTHatMaxMCP * pTHat) { + continue; + } + registry.fill(HIST("hJetPt"), jet.pt(), weight); + registry.fill(HIST("hJetEta"), jet.eta(), weight); + registry.fill(HIST("hJetPhi"), jet.phi(), weight); + for (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); + } if (n_TT > 0) { float dphi = RecoDecay::constrainAngle(jet.phi() - phi_TT); if (is_sig_col) { - registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt()); + for (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); + } + registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hSignalPt"), jet.pt()); + registry.fill(HIST("hSignalPt"), jet.pt(), weight); } - registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size()); + registry.fill(HIST("hJetSignalConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); for (auto& constituent : jet.template tracks_as()) { if (constituent.pt() > leadingPT) { leadingPT = constituent.pt(); } - registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt()); + registry.fill(HIST("hJetSignalConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); } - registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT); + registry.fill(HIST("hSignalLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } if (!is_sig_col) { - registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt()); + for (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); + } + registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight); if (std::abs(dphi - o2::constants::math::PI) < 0.6) { - registry.fill(HIST("hReferencePt"), jet.pt()); + registry.fill(HIST("hReferencePt"), jet.pt(), weight); } - registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size()); + registry.fill(HIST("hJetReferenceConstituentMultiplicity"), jet.pt(), dphi, jet.tracksIds().size(), weight); for (auto& constituent : jet.template tracks_as()) { if (constituent.pt() > leadingPT) { leadingPT = constituent.pt(); } - registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt()); + registry.fill(HIST("hJetReferenceConstituentPt"), jet.pt(), dphi, constituent.pt(), weight); } - registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT); + registry.fill(HIST("hReferenceLeadingTrack"), jet.pt(), dphi, leadingPT, weight); } } } @@ -342,6 +391,9 @@ struct hJetAnalysis { 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.pt() > pTHatMaxMCD * pTHat) { + continue; + } if (djet < 0.6 * jetR) { dR = djet; break; @@ -355,6 +407,9 @@ struct hJetAnalysis { } 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.pt() > pTHatMaxMCP * pTHat) { + continue; + } if (djetp < 0.6 * jetR) { dRp = djetp; break; @@ -364,84 +419,197 @@ struct hJetAnalysis { 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); - if (jetBase.pt() > 5 || jetTag.pt() > 5) { - 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("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); } } } - void processData(soa::Filtered::iterator const& collision, + void processData(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, - soa::Filtered const& tracks) + soa::Filtered const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); fillHistograms(jets, jetsWTA, tracks); } PROCESS_SWITCH(hJetAnalysis, processData, "process data", true); - void processMCD(soa::Filtered::iterator const& collision, + void processMCD(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, soa::Filtered> const& jetsWTA, - soa::Filtered const& tracks) + soa::Filtered const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); fillHistograms(jets, jetsWTA, tracks); } PROCESS_SWITCH(hJetAnalysis, processMCD, "process MC detector level", false); - void processMCP(JetMcCollision const& /*collision*/, - soa::Filtered> const& jets, - JetParticles const& particles) + void processMCDWeighted(soa::Filtered>::iterator const& collision, + aod::JMcCollisions const&, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + soa::Filtered const& tracks) { - fillMCPHistograms(jets, particles); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight()); + fillHistograms(jets, jetsWTA, tracks, collision.mcCollision().weight()); + } + PROCESS_SWITCH(hJetAnalysis, processMCDWeighted, "process MC detector level with event weights", false); + + void processMCP(aod::JetMcCollision const& collision, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + aod::JetParticles const& particles) + { + if (std::abs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + fillMCPHistograms(jets, jetsWTA, particles); } PROCESS_SWITCH(hJetAnalysis, processMCP, "process MC particle level", false); - void processJetsMCPMCDMatched(soa::Filtered::iterator const& collision, + void processMCPWeighted(aod::JetMcCollision const& collision, + soa::Filtered> const& jets, + soa::Filtered> const& jetsWTA, + aod::JetParticles const& particles) + { + if (std::abs(collision.posZ()) > vertexZCut) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.weight()); + fillMCPHistograms(jets, jetsWTA, particles, collision.weight()); + } + PROCESS_SWITCH(hJetAnalysis, processMCPWeighted, "process MC particle level with event weights", false); + + void processJetsMCPMCDMatched(soa::Filtered::iterator const& collision, soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - JetTracks const&, - JetParticles const&, - JetMcCollisions const&, + aod::JetTracks const&, + aod::JetParticles const&, + aod::JetMcCollisions const&, soa::Filtered> const& mcpjets) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + 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); } } - PROCESS_SWITCH(hJetAnalysis, processJetsMCPMCDMatched, "process MC matched", false); + PROCESS_SWITCH(hJetAnalysis, processJetsMCPMCDMatched, "process MC matched (inc jets)", false); - void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, + void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, soa::Filtered> const& mcdjets, soa::Filtered> const& mcdjetsWTA, soa::Filtered> const& mcpjetsWTA, - JetTracks const&, - JetParticles const&, - JetMcCollisions const&, + aod::JetTracks const&, + aod::JetParticles const&, + aod::JetMcCollisions const&, soa::Filtered> const& mcpjets) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + 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()); } } - PROCESS_SWITCH(hJetAnalysis, processJetsMCPMCDMatchedWeighted, "process MC matched with event weights", false); + PROCESS_SWITCH(hJetAnalysis, processJetsMCPMCDMatchedWeighted, "process MC matched with event weights (inc jets)", 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&, + aod::JetMcCollisions const&, + soa::Filtered> const& mcpjets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(PartJetsPerCollision, collision.mcCollisionId()); + bool ishJetEvent = false; + for (auto& track : tracks) { + if (track.pt() < pt_TTsig_max && track.pt() > pt_TTsig_min) { + ishJetEvent = true; + break; + } + } + if (ishJetEvent) { + for (const auto& mcdjet : mcdjets) { + fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets); + } + } + } + PROCESS_SWITCH(hJetAnalysis, processRecoilJetsMCPMCDMatched, "process MC matched (recoil jets)", false); + + 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&, + aod::JetMcCollisions const&, + soa::Filtered> const& mcpjets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + if (!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ()); + const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(PartJetsPerCollision, collision.mcCollisionId()); + bool ishJetEvent = false; + for (auto& track : tracks) { + if (track.pt() < pt_TTsig_max && track.pt() > pt_TTsig_min) { + ishJetEvent = true; + break; + } + } + if (ishJetEvent) { + for (const auto& mcdjet : mcdjets) { + fillMatchedHistograms(mcdjet, mcdjetsWTA, mcpjetsWTACut, mcpjets, mcdjet.eventWeight()); + } + } + } + PROCESS_SWITCH(hJetAnalysis, processRecoilJetsMCPMCDMatchedWeighted, "process MC matched with event weights (recoil jets)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"hJetAnalysis"})}; } diff --git a/PWGJE/Tasks/jetLundReclustering.cxx b/PWGJE/Tasks/jetLundReclustering.cxx index ef01fad490d..4b43b0ad2a2 100644 --- a/PWGJE/Tasks/jetLundReclustering.cxx +++ b/PWGJE/Tasks/jetLundReclustering.cxx @@ -112,15 +112,15 @@ struct JetLundReclustering { } // Dummy process - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetLundReclustering, processDummy, "Dummy process function, turned on by default", true); // Process function for charged jets - void processChargedJets(soa::Filtered::iterator const& collision, + void processChargedJets(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, - JetTracks const&) + aod::JetTracks const&) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -128,7 +128,7 @@ struct JetLundReclustering { for (const auto& jet : jets) { registry.fill(HIST("jet_PtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); jetConstituents.clear(); - for (auto& jetConstituent : jet.tracks_as()) { + for (auto& jetConstituent : jet.tracks_as()) { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex()); } // Perform jet reclustering diff --git a/PWGJE/Tasks/jetSpectraEseTask.cxx b/PWGJE/Tasks/jetSpectraEseTask.cxx new file mode 100644 index 00000000000..96ecaba87b9 --- /dev/null +++ b/PWGJE/Tasks/jetSpectraEseTask.cxx @@ -0,0 +1,279 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 jetSpectraEseTask.cxx +/// \brief jet spectra analysis framework with ESE (19/08/2024) +/// +/// \author Joachim C. K. B. Hansen, Lund University + +#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/DataModel/Jet.h" + +#include "Common/DataModel/EseTable.h" +#include "Common/DataModel/Qvectors.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +#include "Framework/runDataProcessing.h" + +struct JetSpectraEseTask { + ConfigurableAxis binJetPt{"binJetPt", {200, 0., 200.}, ""}; + ConfigurableAxis bindPhi{"bindPhi", {100, -TMath::Pi() - 1, TMath::Pi() + 1}, ""}; + ConfigurableAxis binESE{"binESE", {100, 0, 100}, ""}; + ConfigurableAxis binCos{"binCos", {100, -1.05, 1.05}, ""}; + + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.2, "jet resolution parameter"}; + Configurable vertexZCut{"vertexZCut", 10.0, "vertex z cut"}; + Configurable> CentRange{"CentRange", {30, 50}, "centrality region of interest"}; + Configurable leadingJetPtCut{"fLeadingJetPtCut", 5.0, "leading jet pT cut"}; + + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + Configurable fColSwitch{"fColSwitch", 0, "collision switch"}; + + AxisSpec jetPtAxis = {binJetPt, "#it{p}_{T,jet}"}; + AxisSpec dPhiAxis = {bindPhi, "#Delta#phi"}; + AxisSpec eseAxis = {binESE, "#it{q}_{2}"}; + + AxisSpec cosAxis = {binCos, ""}; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, false, false}; + + int eventSelection = -1; + int trackSelection = -1; + + void init(o2::framework::InitContext&) + { + eventSelection = jetderiveddatautilities::initialiseEventSelection(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("hJetPtdPhiq2", "", {HistType::kTH3F, {{jetPtAxis}, {dPhiAxis}, {eseAxis}}}); + registry.add("hPsi2FT0C", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); + registry.add("hPsi2FT0A", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); + registry.add("hPsi2FV0A", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); + registry.add("hPsi2TPCpos", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); + registry.add("hPsi2TPCneg", ";Centrality; #Psi_{2}", {HistType::kTH2F, {{100, 0, 100}, {150, -2.5, 2.5}}}); + registry.add("hCosPsi2FT0CmFT0A", ";Centrality;cos(2(#Psi_{2}^{FT0C}-#Psi_{2}^{FT0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2FT0CmFV0A", ";Centrality;cos(2(#Psi_{2}^{FT0C}-#Psi_{2}^{FV0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2FV0AmFT0A", ";Centrality;cos(2(#Psi_{2}^{FT0C}-#Psi_{2}^{FV0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2FT0AmFT0C", ";Centrality;cos(2(#Psi_{2}^{FT0A}-#Psi_{2}^{FT0C}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2FT0AmFV0A", ";Centrality;cos(2(#Psi_{2}^{FT0C}-#Psi_{2}^{FV0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2FV0AmFT0C", ";Centrality;cos(2(#Psi_{2}^{FV0A}-#Psi_{2}^{FT0C}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2TPCposmTPCneg", ";Centrality;cos(2(#Psi_{2}^{TPCpos}-#Psi_{2}^{TPCneg}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2TPCposmFV0A", ";Centrality;cos(2(#Psi_{2}^{TPCpos}-#Psi_{2}^{FV0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + registry.add("hCosPsi2TPCnegmFV0A", ";Centrality;cos(2(#Psi_{2}^{TPCneg}-#Psi_{2}^{FV0A}));#it{q}_{2}", {HistType::kTH3F, {{100, 0, 100}, {cosAxis}, {eseAxis}}}); + + break; + case 1: + LOGF(info, "JetSpectraEseTask::init() - using MC"); + registry.add("h_mc_collisions", "event status;event status;entries", {HistType::kTH1F, {{10, 0.0, 10.0}}}); + registry.add("h_part_jet_pt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + registry.add("h_part_jet_eta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_part_jet_phi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); + registry.add("h_part_jet_pt_match", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + registry.add("h_part_jet_eta_match", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_part_jet_phi_match", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); + registry.add("h_detector_jet_pt", "detector level jet pT;#it{p}_{T,jet det} (GeV/#it{c});entries", {HistType::kTH1F, {{jetPtAxis}}}); + registry.add("h_detector_jet_eta", "detector level jet #eta;#eta_{jet det};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_detector_jet_phi", "detector level jet #phi;#phi_{jet det};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); + registry.add("h_matched_jets_pt_delta", "#it{p}_{T,jet part}; det - part", {HistType::kTH2F, {{jetPtAxis}, {200, -20., 20.0}}}); + registry.add("h_matched_jets_eta_delta", "#eta_{jet part}; det - part", {HistType::kTH2F, {{100, -1.0, 1.0}, {200, -20.0, 20.0}}}); + registry.add("h_matched_jets_phi_delta", "#phi_{jet part}; det - part", {HistType::kTH2F, {{80, -1.0, 7.}, {200, -20.0, 20.}}}); + registry.add("h_response_mat_match", "#it{p}_{T, jet det}; #it{p}_{T, jet part}", HistType::kTH2F, {jetPtAxis, jetPtAxis}); + break; + } + } + + 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::Join const&, + soa::Filtered const& jets, + aod::JetTracks const& tracks) + { + float counter{0.5f}; + registry.fill(HIST("hEventCounter"), counter++); + const auto originalCollision = collision.collision_as>(); + registry.fill(HIST("hEventCounter"), counter++); + if (originalCollision.centFT0C() < CentRange->at(0) || originalCollision.centFT0C() > CentRange->at(1)) + return; + registry.fill(HIST("hEventCounter"), counter++); + + const auto vPsi2 = procEP(originalCollision); + const auto qPerc = originalCollision.qPERCFT0C(); + if (qPerc[0] < 0) + return; + registry.fill(HIST("hEventCounter"), counter++); + + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) + return; + + registry.fill(HIST("hEventCounter"), counter++); + + if (!isAcceptedLeadTrack(tracks)) + return; + + registry.fill(HIST("hEventCounter"), counter++); + registry.fill(HIST("hRho"), collision.rho()); + for (auto const& jet : jets) { + float jetpT_bkgsub = jet.pt() - (collision.rho() * jet.area()); + registry.fill(HIST("hJetPt"), jet.pt()); + registry.fill(HIST("hJetPt_bkgsub"), jetpT_bkgsub); + 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("hJetPtdPhiq2"), jetpT_bkgsub, dPhi, qPerc[0]); /* check the dphi */ + } + registry.fill(HIST("hEventCounter"), counter++); + } + PROCESS_SWITCH(JetSpectraEseTask, processESEDataCharged, "process ese collisions", true); + + void processMCParticleLevel(soa::Filtered::iterator const& jet) + { + registry.fill(HIST("h_part_jet_pt"), jet.pt()); + registry.fill(HIST("h_part_jet_eta"), jet.eta()); + registry.fill(HIST("h_part_jet_phi"), jet.phi()); + } + PROCESS_SWITCH(JetSpectraEseTask, processMCParticleLevel, "jets on particle level MC", false); + + using JetMCPTable = soa::Filtered>; + void processMCChargedMatched(soa::Filtered::iterator const& collision, + soa::Filtered> const& mcdjets, + JetMCPTable const&, + aod::JetTracks const&, + aod::JetParticles const&) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) + return; + + float counter{0.5f}; + registry.fill(HIST("h_mc_collisions"), counter++); + for (const auto& mcdjet : mcdjets) { + + registry.fill(HIST("h_detector_jet_pt"), mcdjet.pt()); + registry.fill(HIST("h_detector_jet_eta"), mcdjet.eta()); + registry.fill(HIST("h_detector_jet_phi"), mcdjet.phi()); + for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + + registry.fill(HIST("h_part_jet_pt_match"), mcpjet.pt()); + registry.fill(HIST("h_part_jet_eta_match"), mcpjet.eta()); + registry.fill(HIST("h_part_jet_phi_match"), mcpjet.phi()); + + registry.fill(HIST("h_matched_jets_pt_delta"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); + registry.fill(HIST("h_matched_jets_phi_delta"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); + registry.fill(HIST("h_matched_jets_eta_delta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); + + registry.fill(HIST("h_response_mat_match"), mcdjet.pt(), mcpjet.pt()); + } + } + registry.fill(HIST("h_mc_collisions"), counter++); + } + PROCESS_SWITCH(JetSpectraEseTask, processMCChargedMatched, "jet matched mcp and mcd", false); + + 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(); + } + } + } + if (leadingTrackpT == 0.0) + return false; + else + return true; + } + + template + float procEP(qVectors const& vec) + { + const auto epFT0A = 1 / 2.0 * TMath::ATan2(vec.qvecFT0AImVec()[0], vec.qvecFT0AReVec()[0]); + const auto epFV0A = 1 / 2.0 * std::atan2(vec.qvecFV0AImVec()[0], vec.qvecFV0AReVec()[0]); + const auto epFT0C = 1 / 2.0 * std::atan2(vec.qvecFT0CImVec()[0], vec.qvecFT0CReVec()[0]); + const auto epTPCpos = 1 / 2.0 * std::atan2(vec.qvecTPCposImVec()[0], vec.qvecTPCposReVec()[0]); + const auto epTPCneg = 1 / 2.0 * std::atan2(vec.qvecTPCnegImVec()[0], vec.qvecTPCnegReVec()[0]); + + registry.fill(HIST("hPsi2FT0C"), vec.centFT0C(), epFT0C); + registry.fill(HIST("hPsi2FT0A"), vec.centFT0C(), epFT0A); + registry.fill(HIST("hPsi2FV0A"), vec.centFT0C(), epFV0A); + registry.fill(HIST("hPsi2TPCpos"), vec.centFT0C(), epTPCpos); + registry.fill(HIST("hPsi2TPCneg"), vec.centFT0C(), epTPCneg); + + const auto cosPsi2FT0CmFT0A = cosPsiXY(epFT0C, epFT0A); + const auto cosPsi2FT0CmFV0A = cosPsiXY(epFT0C, epFV0A); + const auto cosPsi2FV0AmFT0A = cosPsiXY(epFV0A, epFT0A); + const auto cosPsi2FT0AmFT0C = cosPsiXY(epFT0A, epFT0C); + const auto cosPsi2FT0AmFV0A = cosPsiXY(epFT0A, epFV0A); + const auto cosPsi2FV0AmFT0C = cosPsiXY(epFV0A, epFT0C); + const auto cosPsi2TPCposmTPCneg = cosPsiXY(epTPCpos, epTPCneg); + const auto cosPsi2TPCposmFV0A = cosPsiXY(epTPCpos, epFV0A); + const auto cosPsi2TPCnegmFV0A = cosPsiXY(epTPCneg, epFV0A); + + registry.fill(HIST("hCosPsi2FT0CmFT0A"), vec.centFT0C(), cosPsi2FT0CmFT0A, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2FT0CmFV0A"), vec.centFT0C(), cosPsi2FT0CmFV0A, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2FV0AmFT0A"), vec.centFT0C(), cosPsi2FV0AmFT0A, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2FT0AmFT0C"), vec.centFT0C(), cosPsi2FT0AmFT0C, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2FT0AmFV0A"), vec.centFT0C(), cosPsi2FT0AmFV0A, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2FV0AmFT0C"), vec.centFT0C(), cosPsi2FV0AmFT0C, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2TPCposmTPCneg"), vec.centFT0C(), cosPsi2TPCposmTPCneg, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2TPCposmFV0A"), vec.centFT0C(), cosPsi2TPCposmFV0A, vec.qPERCFT0C()[0]); + registry.fill(HIST("hCosPsi2TPCnegmFV0A"), vec.centFT0C(), cosPsi2TPCnegmFV0A, vec.qPERCFT0C()[0]); + + return epFT0A; + } + + template + float cosPsiXY(Psi const& psiX, Psi const& psiY) + { + return std::cos(2.0 * (psiX - psiY)); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGJE/Tasks/jetTutorial.cxx b/PWGJE/Tasks/jetTutorial.cxx index 0065726bae2..230aaa53aaa 100644 --- a/PWGJE/Tasks/jetTutorial.cxx +++ b/PWGJE/Tasks/jetTutorial.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// jet tutorial task for hands on tutorial session (09/11/2023) +// jet tutorial task for hands on tutorial session (16/11/2024) // /// \author Nima Zardoshti // @@ -26,6 +26,7 @@ #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" @@ -45,12 +46,14 @@ struct JetTutorialTask { {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_jet_pt_bkgsub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_pt_rhosub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_pt_constsub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_part_jet_pt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_part_jet_eta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_part_jet_phi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, {"h_jet_ntracks", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{40, -0.5, 39.5}}}}, {"h_jet_angularity", "jet angularity ;#lambda_{1};entries", {HistType::kTH1F, {{5, 0.0, 0.5}}}}, + {"h_jet_angularity_constsub", "jet angularity bkg sub;#lambda_{1};entries", {HistType::kTH1F, {{5, 0.0, 0.5}}}}, {"h_full_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_full_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_full_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, @@ -66,24 +69,37 @@ struct JetTutorialTask { {"h_matched_jets_eta", "#eta_{jet part}; #eta_{jet det}", {HistType::kTH2F, {{100, -1.0, 1.0}, {100, -1.0, 1.0}}}}, {"h_matched_jets_phi", "#phi_{jet part}; #phi_{jet det}", {HistType::kTH2F, {{80, -1.0, 7.}, {80, -1.0, 7.}}}}}}; + 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 kappa{"kappa", 1.0, "angularity kappa"}; + Configurable alpha{"alpha", 1.0, "angularity alpha"}; + + 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; int trackSelection = -1; + std::vector triggerMaskBits; void init(o2::framework::InitContext&) { eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); } 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 processCollisions(JetCollision const& collision, JetTracks const& tracks) + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) { registry.fill(HIST("h_collisions"), 0.5); @@ -100,9 +116,9 @@ struct JetTutorialTask { registry.fill(HIST("h_track_phi"), track.phi()); } } - PROCESS_SWITCH(JetTutorialTask, processCollisions, "process self contained collisions", true); + PROCESS_SWITCH(JetTutorialTask, processCollisions, "process JE collisions", false); - void processCollisionsWithExternalTracks(JetCollision const& collision, soa::Join const& tracks, soa::Join const&) + void processCollisionsWithExternalTracks(soa::Filtered::iterator const& collision, soa::Join const& tracks, soa::Join const&) { registry.fill(HIST("h_collisions"), 0.5); @@ -121,126 +137,167 @@ struct JetTutorialTask { registry.fill(HIST("h_track_chi2PerCluster"), originalTrack.tpcChi2NCl()); } } - PROCESS_SWITCH(JetTutorialTask, processCollisionsWithExternalTracks, "process non self contained collisions", true); + PROCESS_SWITCH(JetTutorialTask, processCollisionsWithExternalTracks, "process JE collisions with access to the original track table", false); - void processDataCharged(soa::Filtered::iterator const& jet) + void processDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } } - PROCESS_SWITCH(JetTutorialTask, processDataCharged, "jets data", true); + PROCESS_SWITCH(JetTutorialTask, processDataCharged, "charged jets in data", false); - void processMCDetectorLevelCharged(soa::Filtered::iterator const& jet) + void processMCDetectorLevelCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } } - PROCESS_SWITCH(JetTutorialTask, processMCDetectorLevelCharged, "jets on detector level MC", false); + PROCESS_SWITCH(JetTutorialTask, processMCDetectorLevelCharged, "charged jets in detector level MC", false); - void processMCParticleLevel(soa::Filtered::iterator const& jet) + void processMCDetectorLevelWeightedCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const&, soa::Filtered const& jets) { - registry.fill(HIST("h_part_jet_pt"), jet.pt()); - registry.fill(HIST("h_part_jet_eta"), jet.eta()); - registry.fill(HIST("h_part_jet_phi"), jet.phi()); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt(), collision.mcCollision().weight()); + registry.fill(HIST("h_jet_eta"), jet.eta(), collision.mcCollision().weight()); + registry.fill(HIST("h_jet_phi"), jet.phi(), collision.mcCollision().weight()); + } } - PROCESS_SWITCH(JetTutorialTask, processMCParticleLevel, "jets on particle level MC", false); + PROCESS_SWITCH(JetTutorialTask, processMCDetectorLevelWeightedCharged, "charged jets in weighted detector level MC", false); - void processMCCharged(JetCollision const&, soa::Filtered const& mcdjets, soa::Filtered const& mcpjets) + void processMCParticleLevelCharged(soa::Filtered::iterator const& mcCollision, soa::Filtered const& jets) { + for (auto& jet : jets) { + registry.fill(HIST("h_part_jet_pt"), jet.pt(), mcCollision.weight()); + registry.fill(HIST("h_part_jet_eta"), jet.eta(), mcCollision.weight()); + registry.fill(HIST("h_part_jet_phi"), jet.phi(), mcCollision.weight()); + } + } + PROCESS_SWITCH(JetTutorialTask, processMCParticleLevelCharged, "charged jets in particle level MC", false); + + void processMCCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const&, soa::Filtered const& mcdjets, soa::Filtered const& mcpjets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } for (auto& mcdjet : mcdjets) { - registry.fill(HIST("h_jet_pt"), mcdjet.pt()); - registry.fill(HIST("h_jet_eta"), mcdjet.eta()); - registry.fill(HIST("h_jet_phi"), mcdjet.phi()); + registry.fill(HIST("h_jet_pt"), mcdjet.pt(), collision.mcCollision().weight()); + registry.fill(HIST("h_jet_eta"), mcdjet.eta(), collision.mcCollision().weight()); + registry.fill(HIST("h_jet_phi"), mcdjet.phi(), collision.mcCollision().weight()); } - for (auto& mcpjet : mcpjets) { - registry.fill(HIST("h_part_jet_pt"), mcpjet.pt()); - registry.fill(HIST("h_part_jet_eta"), mcpjet.eta()); - registry.fill(HIST("h_part_jet_phi"), mcpjet.phi()); + auto mcpjetsPerCollision = mcpjets.sliceBy(perMcCollisionJets, collision.mcCollisionId()); + for (auto& mcpjet : mcpjetsPerCollision) { + registry.fill(HIST("h_part_jet_pt"), mcpjet.pt(), collision.mcCollision().weight()); + registry.fill(HIST("h_part_jet_eta"), mcpjet.eta(), collision.mcCollision().weight()); + registry.fill(HIST("h_part_jet_phi"), mcpjet.phi(), collision.mcCollision().weight()); } } - PROCESS_SWITCH(JetTutorialTask, processMCCharged, "jets on detector and particle level MC", false); + PROCESS_SWITCH(JetTutorialTask, processMCCharged, "charged jets in detector and particle level MC", false); using JetMCPTable = soa::Filtered>; - void processMCChargedMatched(JetCollision const&, + void processMCMatchedCharged(soa::Filtered::iterator const& collision, soa::Filtered> const& mcdjets, JetMCPTable const&, - JetTracks const&, - JetParticles const&) + aod::JetTracks const&, + aod::JetParticles const&) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } for (const auto& mcdjet : mcdjets) { - for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - // for (auto& mcpjet : mcdjet.template matchedJetPt_as()) { - - registry.fill(HIST("h_matched_jets_pt"), mcpjet.pt(), mcdjet.pt()); - registry.fill(HIST("h_matched_jets_pt"), mcpjet.phi(), mcdjet.phi()); - registry.fill(HIST("h_matched_jets_pt"), mcpjet.eta(), mcdjet.eta()); + registry.fill(HIST("h_matched_jets_pt"), mcpjet.pt(), mcdjet.pt(), collision.mcCollision().weight()); + registry.fill(HIST("h_matched_jets_pt"), mcpjet.phi(), mcdjet.phi(), collision.mcCollision().weight()); + registry.fill(HIST("h_matched_jets_pt"), mcpjet.eta(), mcdjet.eta(), collision.mcCollision().weight()); } } } - PROCESS_SWITCH(JetTutorialTask, processMCChargedMatched, "jet finder QA matched mcp and mcd", false); + PROCESS_SWITCH(JetTutorialTask, processMCMatchedCharged, "matched detector and particle level charged jets", false); - void processDataChargedSubstructure(soa::Filtered>::iterator const& jet, JetTracks const&) + void processDataSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, aod::JetTracks const&) { - // add aditional selection on jet eta - 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("h_jet_ntracks"), jet.tracksIds().size()); - double angularity = 0.0; - for (auto& jetConstituent : jet.tracks_as()) { - angularity += jetConstituent.pt() * TMath::Sqrt(TMath::Power(jet.phi() - jetConstituent.phi(), 2.0) + TMath::Power(jet.eta() - jetConstituent.eta(), 2.0)); - } - registry.fill(HIST("h_jet_angularity"), angularity / (jet.pt() * round(jet.r() / 100.0f))); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto& jet : jets) { + 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("h_jet_ntracks"), jet.tracksIds().size()); + double angularity = 0.0; + for (auto& jetConstituent : jet.tracks_as()) { + angularity += std::pow(jetConstituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, jetConstituent), alpha); + } + angularity /= (jet.pt() * (jet.r() / 100.f)); + registry.fill(HIST("h_jet_angularity"), angularity); + } } - PROCESS_SWITCH(JetTutorialTask, processDataChargedSubstructure, "jet substructure charged jets", false); + PROCESS_SWITCH(JetTutorialTask, processDataSubstructureCharged, "charged jet substructure", false); - void processMCParticleSubstructure(soa::Filtered>::iterator const& jet, JetParticles const&) + void processDataFull(soa::Filtered::iterator const&, soa::Filtered const& jets) { - double angularity = 0.0; - for (auto& jetConstituents : jet.tracks_as()) { - angularity += jetConstituents.pt() * TMath::Sqrt(TMath::Power(jet.phi() - jetConstituents.phi(), 2.0) + TMath::Power(jet.eta() - jetConstituents.eta(), 2.0)); + for (auto& jet : jets) { + 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("h_part_jet_angularity"), angularity / (jet.pt() * round(jet.r() / 100.0f))); } - PROCESS_SWITCH(JetTutorialTask, processMCParticleSubstructure, "jet substructure particle level full jets", false); + PROCESS_SWITCH(JetTutorialTask, processDataFull, "full jets in data", false); - void processDataFull(soa::Filtered::iterator const& jet) + void processDataSubstructureFull(soa::Filtered::iterator const&, soa::Filtered> const& jets, aod::JetTracks const&, aod::JetClusters const&) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); - } - PROCESS_SWITCH(JetTutorialTask, processDataFull, "jets data", true); + for (auto& jet : jets) { + registry.fill(HIST("h_full_jet_pt"), jet.pt()); + registry.fill(HIST("h_full_jet_eta"), jet.eta()); + registry.fill(HIST("h_full_jet_phi"), jet.phi()); + registry.fill(HIST("h_full_jet_ntracks"), jet.tracksIds().size()); + registry.fill(HIST("h_full_jet_nclusters"), jet.clustersIds().size()); + double angularity = 0.0; + for (auto& jetConstituent : jet.tracks_as()) { + angularity += std::pow(jetConstituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, jetConstituent), alpha); + } - void processDataFullSubstructure(soa::Filtered>::iterator const& jet, JetTracks const&, JetClusters const&) - { - // add aditional selection on jet eta - registry.fill(HIST("h_full_jet_pt"), jet.pt()); - registry.fill(HIST("h_full_jet_eta"), jet.eta()); - registry.fill(HIST("h_full_jet_phi"), jet.phi()); - registry.fill(HIST("h_full_jet_ntracks"), jet.tracksIds().size()); - registry.fill(HIST("h_full_jet_nclusters"), jet.clustersIds().size()); - double angularity = 0.0; - for (auto& jetTrack : jet.tracks_as()) { - angularity += jetTrack.pt() * TMath::Sqrt(TMath::Power(jet.phi() - jetTrack.phi(), 2.0) + TMath::Power(jet.eta() - jetTrack.eta(), 2.0)); - } + for (auto& jetCluster : jet.tracks_as()) { + angularity += std::pow(jetCluster.energy(), kappa) * std::pow(jetutilities::deltaR(jet, jetCluster), alpha); + } - for (auto& jetCluster : jet.clusters_as()) { - angularity += jetCluster.energy() * TMath::Sqrt(TMath::Power(jet.phi() - jetCluster.phi(), 2.0) + TMath::Power(jet.eta() - jetCluster.eta(), 2.0)); + registry.fill(HIST("h_full_jet_angularity"), angularity / (jet.pt() * round(jet.r() * 100.0f))); } + } + PROCESS_SWITCH(JetTutorialTask, processDataSubstructureFull, "full jet substructure", false); - registry.fill(HIST("h_full_jet_angularity"), angularity / (jet.pt() * round(jet.r() * 100.0f))); + void processMCParticleLevelSubstructureFull(soa::Filtered::iterator const& mcCollision, soa::Filtered> const& jets, aod::JetParticles const&) + { + for (auto& jet : jets) { + double angularity = 0.0; + for (auto& jetConstituent : jet.tracks_as()) { + angularity += std::pow(jetConstituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, jetConstituent), alpha); + } + angularity /= (jet.pt() * (jet.r() / 100.f)); + registry.fill(HIST("h_part_jet_angularity"), angularity, mcCollision.weight()); + } } - PROCESS_SWITCH(JetTutorialTask, processDataFullSubstructure, "jet substructure full jets", false); + PROCESS_SWITCH(JetTutorialTask, processMCParticleLevelSubstructureFull, "full particle level jet substructure", false); - void processDataRecoil(JetCollision const& collision, soa::Filtered const& jets, JetTracks const& tracks) + void processRecoilDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets, aod::JetTracks const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + bool selectedEvent = false; double leadingTrackpT = 0.0; double leadingTrackPhi = 0.0; for (auto& track : tracks) { @@ -248,13 +305,15 @@ struct JetTutorialTask { if (track.pt() > leadingTrackpT) { leadingTrackpT = track.pt(); leadingTrackPhi = track.phi(); + selectedEvent = true; } } } - if (leadingTrackpT == 0.0) + if (!selectedEvent) { 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)) { + if (std::abs(RecoDecay::constrainAngle(jet.phi() - leadingTrackPhi, -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()); @@ -262,18 +321,67 @@ struct JetTutorialTask { } } } - PROCESS_SWITCH(JetTutorialTask, processDataRecoil, "hadron-recoil jets", false); + PROCESS_SWITCH(JetTutorialTask, processRecoilDataCharged, "hadron-recoil charged jets", false); + + void processDataRhoAreaSubtractedCharged(soa::Filtered>::iterator const& collision, soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_pt_rhosub"), jet.pt() - (collision.rho() * jet.area())); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + } + PROCESS_SWITCH(JetTutorialTask, processDataRhoAreaSubtractedCharged, "charged rho-area subtracted jets", false); + + void processDataConstituentSubtractedCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto jet : jets) { + registry.fill(HIST("h_jet_pt_constsub"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + } + PROCESS_SWITCH(JetTutorialTask, processDataConstituentSubtractedCharged, "charged constituent subtracted jets", false); - /*void processDataBackgroundSubtracted(soa::Join::iterator const& collision, soa::Filtered const& jets) + void processDataConstituentSubtractedSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered> const& jets, aod::JetTracksSub const&) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } for (auto jet : jets) { + registry.fill(HIST("h_jet_pt_constsub"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + registry.fill(HIST("h_jet_ntracks"), jet.tracksIds().size()); + double angularity = 0.0; + for (auto& jetConstituent : jet.tracks_as()) { + angularity += std::pow(jetConstituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, jetConstituent), alpha); + } + angularity /= (jet.pt() * (jet.r() / 100.f)); + registry.fill(HIST("h_jet_angularity_constsub"), angularity); + } + } + PROCESS_SWITCH(JetTutorialTask, processDataConstituentSubtractedSubstructureCharged, "charged constituent subtracted jet substructure", false); + + void processDataTriggered(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) { + return; + } + for (auto& jet : jets) { registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_pt_bkgsub"), jet.pt() - (collision.rho() * jet.area())); registry.fill(HIST("h_jet_eta"), jet.eta()); registry.fill(HIST("h_jet_phi"), jet.phi()); } } - PROCESS_SWITCH(JetTutorialTask, processDataBackgroundSubtracted, "baackground subtracted jets", false);*/ + PROCESS_SWITCH(JetTutorialTask, processDataTriggered, "jets triggered", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-tutorial"})}; } diff --git a/PWGJE/Tasks/jetTutorialSkeleton.cxx b/PWGJE/Tasks/jetTutorialSkeleton.cxx index ba5310ef535..70fc22ec736 100644 --- a/PWGJE/Tasks/jetTutorialSkeleton.cxx +++ b/PWGJE/Tasks/jetTutorialSkeleton.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// jet tutorial skeleton task for hands on tutorial session (09/11/2023) +// jet tutorial task for hands on tutorial session (16/11/2024) // /// \author Nima Zardoshti // @@ -26,6 +26,7 @@ #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" @@ -45,12 +46,14 @@ struct JetTutorialSkeletonTask { {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_jet_pt_bkgsub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_pt_rhosub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_pt_constsub", "jet pT bkg sub;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_part_jet_pt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_part_jet_eta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_part_jet_phi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, {"h_jet_ntracks", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{40, -0.5, 39.5}}}}, {"h_jet_angularity", "jet angularity ;#lambda_{1};entries", {HistType::kTH1F, {{5, 0.0, 0.5}}}}, + {"h_jet_angularity_constsub", "jet angularity bkg sub;#lambda_{1};entries", {HistType::kTH1F, {{5, 0.0, 0.5}}}}, {"h_full_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, {"h_full_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, {"h_full_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, @@ -66,92 +69,153 @@ struct JetTutorialSkeletonTask { {"h_matched_jets_eta", "#eta_{jet part}; #eta_{jet det}", {HistType::kTH2F, {{100, -1.0, 1.0}, {100, -1.0, 1.0}}}}, {"h_matched_jets_phi", "#phi_{jet part}; #phi_{jet det}", {HistType::kTH2F, {{80, -1.0, 7.}, {80, -1.0, 7.}}}}}}; + 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 kappa{"kappa", 1.0, "angularity kappa"}; + Configurable alpha{"alpha", 1.0, "angularity alpha"}; + + 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; int trackSelection = -1; + std::vector triggerMaskBits; void init(o2::framework::InitContext&) { eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(triggerMasks); } 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; - void processCollisions(aod::JCollision const&, aod::JTracks const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processCollisions, "process self contained collisions", true); + Preslice> perMcCollisionJets = aod::jet::mcCollisionId; - void processCollisionsWithExternalTracks(aod::JCollision const&, soa::Join const&, soa::Join const&) + void processDummy(aod::JDummys const&) { } - PROCESS_SWITCH(JetTutorialSkeletonTask, processCollisionsWithExternalTracks, "process non self contained collisions", true); + PROCESS_SWITCH(JetTutorialSkeletonTask, processDummy, "dummy process", false); - void processDataCharged(soa::Filtered::iterator const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataCharged, "jets data", true); + /* + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) + { - void processMCDetectorLevelCharged(soa::Filtered::iterator const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processMCDetectorLevelCharged, "jets on detector level MC", false); + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processCollisions, "process JE collisions", false); - void processMCParticleLevel(soa::Filtered::iterator const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processMCParticleLevel, "jets on particle level MC", false); + void processCollisionsWithExternalTracks(soa::Filtered::iterator const& collision, soa::Join const& tracks, soa::Join const&) + { - void processMCCharged(aod::JCollisions const&, soa::Filtered const&, soa::Filtered const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processMCCharged, "jets on detector and particle level MC", false); - - using JetMCPTable = soa::Filtered>; - void processMCChargedMatched(aod::JCollision const&, - soa::Filtered> const&, - JetMCPTable const&, - aod::JTracks const&, - aod::JMcParticles const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processMCChargedMatched, "jet finder QA matched mcp and mcd", false); + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processCollisionsWithExternalTracks, "process JE collisions with access to the original track table", false); - void processDataChargedSubstructure(soa::Filtered>::iterator const&, aod::JTracks const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataChargedSubstructure, "jet substructure charged jets", false); + void processDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { - void processMCParticleSubstructure(soa::Filtered>::iterator const&, aod::JMcParticles const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processMCParticleSubstructure, "jet substructure particle level full jets", false); + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataCharged, "charged jets in data", false); - void processDataFull(soa::Filtered::iterator const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataFull, "jets data", true); + void processMCDetectorLevelCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { - void processDataFullSubstructure(soa::Filtered>::iterator const&, aod::JTracks const&, aod::JClusters const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataFullSubstructure, "jet substructure full jets", false); + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCDetectorLevelCharged, "charged jets in detector level MC", false); - void processDataRecoil(aod::JCollision const&, soa::Filtered const&, aod::JTracks const&) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataRecoil, "hadron-recoil jets", false); + void processMCDetectorLevelWeightedCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const& ,soa::Filtered const& jets) + { - /*void processDataBackgroundSubtracted(soa::Join::iterator const& collision, soa::Filtered const& jets) - { - } - PROCESS_SWITCH(JetTutorialSkeletonTask, processDataBackgroundSubtracted, "baackground subtracted jets", false);*/ + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCDetectorLevelWeightedCharged, "charged jets in weighted detector level MC", false); + + void processMCParticleLevelCharged(soa::Filtered::iterator const& mcCollision, soa::Filtered const& jets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCParticleLevelCharged, "charged jets in particle level MC", false); + + void processMCCharged(soa::Filtered::iterator const& collision, aod::JetMcCollisions const& , soa::Filtered const& mcdjets, soa::Filtered const& mcpjets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCCharged, "charged jets in detector and particle level MC", false); + + + using JetMCPTable = soa::Filtered>; + void processMCMatchedCharged(soa::Filtered::iterator const& collision, + soa::Filtered> const& mcdjets, + JetMCPTable const&, + aod::JetTracks const&, + aod::JetParticles const&) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCMatchedCharged, "matched detector and particle level charged jets", false); + + void processDataSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered>const& jets, aod::JetTracks const&) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataSubstructureCharged, "charged jet substructure", false); + + void processDataFull(soa::Filtered::iterator const& , soa::Filtered const& jets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataFull, "full jets in data", false); + + void processDataSubstructureFull(soa::Filtered::iterator const& , soa::Filtered> const& jets, aod::JetTracks const&, aod::JetClusters const&) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataSubstructureFull, "full jet substructure", false); + + + void processMCParticleLevelSubstructureFull(soa::Filtered::iterator const& mcCollision, soa::Filtered> const& jets, aod::JetParticles const&) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processMCParticleLevelSubstructureFull, "full particle level jet substructure", false); + + + void processRecoilDataCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets, aod::JetTracks const& tracks) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processRecoilDataCharged, "hadron-recoil charged jets", false); + + void processDataRhoAreaSubtractedCharged(soa::Filtered>::iterator const& collision, soa::Filtered const& jets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataRhoAreaSubtractedCharged, "charged rho-area subtracted jets", false); + + void processDataConstituentSubtractedCharged(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataConstituentSubtractedCharged, "charged constituent subtracted jets", false); + + + void processDataConstituentSubtractedSubstructureCharged(soa::Filtered::iterator const& collision, soa::Filtered>const& jets, aod::JetTracksSub const&) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataConstituentSubtractedSubstructureCharged, "charged constituent subtracted jet substructure", false); + + void processDataTriggered(soa::Filtered::iterator const& collision, soa::Filtered const& jets) + { + + } + PROCESS_SWITCH(JetTutorialSkeletonTask, processDataTriggered, "jets triggered", false); + */ }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-tutorial-skeleton"})}; } diff --git a/PWGJE/Tasks/jetchargedv2.cxx b/PWGJE/Tasks/jetchargedv2.cxx new file mode 100644 index 00000000000..01184740f28 --- /dev/null +++ b/PWGJE/Tasks/jetchargedv2.cxx @@ -0,0 +1,556 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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" + +//< evt pln .h >// +#include "Framework/ASoAHelpers.h" +#include "Framework/RunningWorkflowInfo.h" +#include "Framework/StaticFor.h" + +#include "Common/DataModel/Qvectors.h" +#include "Common/Core/EventPlaneHelper.h" +//< evt pln .h | end >// + +// o2 includes. +#include "DetectorsCommonDataFormats/AlignParam.h" + +#include "Framework/ASoA.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 "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 "EventFiltering/filterTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +//=====================< evt pln >=====================// +using MyCollisions = soa::Join; +//=====================< evt pln | end >=====================// + +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 centralityMin{"centralityMin", -999.0, "minimum centrality"}; + Configurable centralityMax{"centralityMax", 999.0, "maximum centrality"}; + Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; + Configurable trackPtMax{"trackPtMax", 1000., "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 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 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 jetRadius{"jetRadius", 0.2, "jet resolution parameters"}; + + Configurable randomConeR{"randomConeR", 0.4, "size of random Cone for estimating background fluctuations"}; + + //=====================< evt pln >=====================// + Configurable cfgAddEvtSel{"cfgAddEvtSel", true, "event selection"}; + Configurable> cfgnMods{"cfgnMods", {2}, "Modulation of interest"}; + Configurable cfgnTotalSystem{"cfgnTotalSystem", 7, "total qvector number"}; + Configurable cfgDetName{"cfgDetName", "FT0M", "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"}; + + ConfigurableAxis cfgaxisQvecF{"cfgaxisQvecF", {300, -1, 1}, ""}; + ConfigurableAxis cfgaxisQvec{"cfgaxisQvec", {100, -3, 3}, ""}; + ConfigurableAxis cfgaxisCent{"cfgaxisCent", {90, 0, 90}, ""}; + + EventPlaneHelper helperEP; + 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; + } + } + //=====================< evt pln | end >=====================// + + Configurable selectedJetsRadius{"selectedJetsRadius", 0.4, "resolution parameter for histograms without radius"}; + + std::vector jetPtBins; + std::vector jetPtBinsRhoAreaSub; + + int eventSelection = -1; + int trackSelection = -1; + double evtnum = 1; // evt sum for local rho test + + void init(o2::framework::InitContext&) + { + 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; + } + + auto jetPtTemp = 0.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + while (jetPtTemp < jetPtMax) { + if (jetPtTemp < 100.0) { + jetPtTemp += 1.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } else if (jetPtTemp < 200.0) { + jetPtTemp += 5.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + + } else { + jetPtTemp += 10.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } + } + 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 >// + + 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)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + + //< \sigma p_T at local rho test plot > + registry.add("h_ptsum_collnum", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{40, 0.0, 40}}}); + registry.add("h_ptsum_sumpt", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, 0., TMath::TwoPi()}}}); + registry.add("h2_phi_track_eta", "phi vs track eta; #varphi; #eta (GeV/#it{c})", {HistType::kTH2F, {{100, -1.0, 1.0}, {160, 0., TMath::TwoPi()}}}); + registry.add("h2_phi_track_pt", "phi vs track pT; #varphi; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {160, 0., TMath::TwoPi()}}}); + registry.add("h2_centrality_phi_w_pt", "centrality vs jet #varphi; #varphi_{jet}; 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()}}}); + + //< \sigma p_T at local rho test plot | end > + 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.}}}); + + 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}}}); + + 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_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 >// + + 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}}); + 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 >// + + //=====================< evt pln plot >=====================// + AxisSpec axisCent{cfgaxisCent, "centrality"}; + AxisSpec axisQvec{cfgaxisQvec, "Q"}; + AxisSpec axisQvecF{cfgaxisQvecF, "Q"}; + + AxisSpec axisEvtPl{360, -constants::math::PI, constants::math::PI}; + + histosQA.add("histCentFull", "Centrality distribution for valid events", HistType::kTH1F, {axisCent}); + for (std::size_t 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}}); + } + //=====================< evt pln plot | end >=====================// + } + + Preslice JetsPerJCollision = aod::jet::collisionId; + Preslice tracksPerJCollision = o2::aod::jtrack::collisionId; + + Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); + Filter trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta > trackEtaMin && aod::jtracksub::eta < trackEtaMax); + Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); + + 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; + } + + //=====================< q-vector & evtpln check >=====================// + template + void fillHistosQvec(const T& vec, 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 (vec.qvecAmp()[DetId] > 1e-8) { + histosQA.fill(HIST("histQvecUncorV2"), vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], vec.cent()); + histosQA.fill(HIST("histQvecRectrV2"), vec.qvecRe()[DetInd + 1], vec.qvecIm()[DetInd + 1], vec.cent()); + histosQA.fill(HIST("histQvecTwistV2"), vec.qvecRe()[DetInd + 2], vec.qvecIm()[DetInd + 2], vec.cent()); + histosQA.fill(HIST("histQvecFinalV2"), vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], vec.cent()); + histosQA.fill(HIST("histEvtPlUncorV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd], vec.qvecIm()[DetInd], nmode), vec.cent()); + histosQA.fill(HIST("histEvtPlRectrV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 1], vec.qvecIm()[DetInd + 1], nmode), vec.cent()); + histosQA.fill(HIST("histEvtPlTwistV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 2], vec.qvecIm()[DetInd + 2], nmode), vec.cent()); + histosQA.fill(HIST("histEvtPlFinalV2"), helperEP.GetEventPlane(vec.qvecRe()[DetInd + 3], vec.qvecIm()[DetInd + 3], nmode), vec.cent()); + } + } + } + //=====================< q-vector & evtpln check | end >=====================// + void fillLeadingJetQA(double leadingJetPt, double leadingJetPhi, double leadingJetEta) + { + registry.fill(HIST("leadJetPt"), leadingJetPt); + registry.fill(HIST("leadJetPhi"), leadingJetPhi); + registry.fill(HIST("leadJetEta"), leadingJetEta); + } // end of fillLeadingJetQA template + + void processjetQA(soa::Filtered::iterator const& collision, + soa::Join const& jets, aod::JetTracks const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + 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 (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); + + void processSigmaPt(soa::Filtered> const& collisions, + soa::Join const& jets, + aod::JetTracks const& tracks) + { + // double collnum = 1; + 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(); + } + } + fillLeadingJetQA(leadingJetPt, leadingJetPhi, leadingJetEta); + + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + + //=====================< evt pln [n=2->\Psi_2, n=3->\Psi_3] >=====================// + for (std::size_t 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()); + } + //< Psi_EP,2, JetPtCorr = Jet_pT-*A in-plane and out-of-plane >// + auto collJets = jets.sliceBy(JetsPerJCollision, collision.globalIndex()); // select the jet in collisions + if (nmode == 2) { + Double_t phiMinusPsi2; + if (collision.qvecAmp()[DetId] < 1e-8) { + continue; + } + float evtPl2 = helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode); + for (auto const& jet : collJets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + phiMinusPsi2 = jet.phi() - evtPl2; + // Double_t jetPtCorr = 0.0; + // jetPtCorr = jet.pt() - collision.rho() * jet.area(); + + if ((phiMinusPsi2 < TMath::Pi() / 4) || (phiMinusPsi2 >= 7 * TMath::Pi() / 4) || (phiMinusPsi2 >= 3 * TMath::Pi() / 4 && phiMinusPsi2 < 5 * TMath::Pi() / 4)) { + 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); + } 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); + } + } + //< 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); + for (auto const& jet : collJets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + phiMinusPsi3 = jet.phi() - evtPl3; + // Double_t jetPtCorr = 0.0; + // jetPtCorr = jet.pt() - collision.rho() * jet.area(); + + if ((phiMinusPsi3 < TMath::Pi() / 4) || (phiMinusPsi3 >= 7 * TMath::Pi() / 4) || (phiMinusPsi3 >= 3 * TMath::Pi() / 4 && phiMinusPsi3 < 5 * TMath::Pi() / 4)) { + 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); + } + } + } + } + //=====================< evt pln | end >=====================// + auto collTracks = tracks.sliceBy(tracksPerJCollision, collision.globalIndex()); + if (jets.size() > 0) { + for (auto const& track : collTracks) { + if (jetderiveddatautilities::selectTrack(track, trackSelection) && (fabs(track.eta() - leadingJetEta) > jetRadius) && track.pt() >= 0.2 && track.pt() <= 5.) { + 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 + 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()); + } + } + } + registry.fill(HIST("h_ptsum_collnum"), 0.5); + evtnum += 1; + } + } + PROCESS_SWITCH(Jetchargedv2Task, processSigmaPt, "QA for charged tracks", true); + + void processRandomConeDataV2(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + soa::Filtered const& tracks) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + + for (std::size_t 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 randomConePt = 0; + + int nmode = cfgnMods->at(i); + int DetInd = DetId * 4 + cfgnTotalSystem * 4 * (nmode - 2); + + Double_t RcPhiPsi2; + float evtPl2 = helperEP.GetEventPlane(collision.qvecRe()[DetInd], collision.qvecIm()[DetInd], nmode); + RcPhiPsi2 = randomConePhi - evtPl2; + + 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; + 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(); + } + } + } + } + } + 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); + + void processTracksQA(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) + { + registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + 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()); + } + } + PROCESS_SWITCH(Jetchargedv2Task, processTracksQA, "QA for charged tracks", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-charged-v2"})}; +} diff --git a/PWGJE/Tasks/jetfinderQA.cxx b/PWGJE/Tasks/jetfinderQA.cxx index fd29e0dbeb5..efb303fbea8 100644 --- a/PWGJE/Tasks/jetfinderQA.cxx +++ b/PWGJE/Tasks/jetfinderQA.cxx @@ -60,12 +60,18 @@ 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 jetPtMax{"jetPtMax", 200., "set jet pT bin max"}; Configurable jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; + Configurable nBinsEta{"nBinsEta", 200, "number of bins for eta axes"}; 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 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 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)"}; std::vector filledJetR_Both; std::vector filledJetR_Low; @@ -75,6 +81,9 @@ struct JetFinderQATask { int eventSelection = -1; int trackSelection = -1; + std::vector jetPtBins; + std::vector jetPtBinsRhoAreaSub; + void init(o2::framework::InitContext&) { eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); @@ -93,70 +102,101 @@ struct JetFinderQATask { 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) { + jetPtTemp += 1.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } else if (jetPtTemp < 200.0) { + jetPtTemp += 5.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } else { + jetPtTemp += 10.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } + } + std::sort(jetPtBinsRhoAreaSub.begin(), jetPtBinsRhoAreaSub.end()); + + AxisSpec jetPtAxis = {jetPtBins, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec jetPtAxisRhoAreaSub = {jetPtBinsRhoAreaSub, "#it{p}_{T} (GeV/#it{c})"}; + + AxisSpec jetEtaAxis = {nBinsEta, jetEtaMin, jetEtaMax, "#eta"}; + AxisSpec trackEtaAxis = {nBinsEta, trackEtaMin, trackEtaMax, "#eta"}; + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { - registry.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + 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.}}}); registry.add("h_jet_ntracks", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxis}}); + registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetEtaAxis}}); registry.add("h2_centrality_jet_phi", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {300, 0., 3.}}}); - registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_leadingtrack_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,leading track} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200.0}, {200, 0.0, 200.0}}}); - registry.add("h_jet_phat", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); - registry.add("h_jet_ptcut", "p_{T} cut;p_{T,jet} (GeV/#it{c});N;entries", {HistType::kTH2F, {{200, 0, 200}, {20, 0, 5}}}); - registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); - } - - if (doprocessJetsRhoAreaSubData) { - - registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{400, -200., 200.}}}); - registry.add("h_jet_eta_rhoareasubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetEtaAxis}}); + registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {300, 0., 3.}}}); + registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta", "#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", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_leadingtrack_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c}); #it{p}_{T,leading track} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0.0, 200.0}}}); + registry.add("h_jet_phat", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + 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}}); + } + + if (doprocessJetsRhoAreaSubData || doprocessJetsRhoAreaSubMCD) { + + registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_eta_rhoareasubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {jetEtaAxis}}); registry.add("h_jet_phi_rhoareasubtracted", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_rhoareasubtracted", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt_rhoareasubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {400, -200., 200.}}}); - registry.add("h2_centrality_jet_eta_rhoareasubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt_rhoareasubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_centrality_jet_eta_rhoareasubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetEtaAxis}}); registry.add("h2_centrality_jet_phi_rhoareasubtracted", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks_rhoareasubtracted", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi_rhoareasubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area_rhoareasubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {300, 0., 3.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); - 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, ""}, {400, -200., 200.}, {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, ""}, {200, 0., 200.}, {400, -200., 200.}}}); - } - - if (doprocessEvtWiseConstSubJetsData) { - registry.add("h_jet_pt_eventwiseconstituentsubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta_eventwiseconstituentsubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_centrality_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, jetEtaAxis}}); + registry.add("h3_jet_r_jet_pt_jet_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi_rhoareasubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area_rhoareasubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {300, 0., 3.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, trackEtaAxis}}); + 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}}); + } + + if (doprocessEvtWiseConstSubJetsData || doprocessEvtWiseConstSubJetsMCD) { + registry.add("h_jet_pt_eventwiseconstituentsubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_eventwiseconstituentsubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {jetEtaAxis}}); registry.add("h_jet_phi_eventwiseconstituentsubtracted", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_eventwiseconstituentsubtracted", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt_eventwiseconstituentsubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_jet_eta_eventwiseconstituentsubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt_eventwiseconstituentsubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxis}}); + registry.add("h2_centrality_jet_eta_eventwiseconstituentsubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetEtaAxis}}); registry.add("h2_centrality_jet_phi_eventwiseconstituentsubtracted", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks_eventwiseconstituentsubtracted", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area_eventwiseconstituentsubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {300, 0., 3.}}}); - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - 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, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - 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, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_centrality_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetEtaAxis}}); + registry.add("h3_jet_r_jet_pt_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area_eventwiseconstituentsubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {300, 0., 3.}}}); + 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.}}}); } if (doprocessRho) { @@ -167,114 +207,116 @@ struct JetFinderQATask { registry.add("h2_centrality_rhom", ";centrality; #it{rho}_{m} (GeV/area)", {HistType::kTH2F, {{1100, 0., 110.}, {100, 0., 100.0}}}); } - if (doprocessRandomCone) { + if (doprocessRandomConeData || doprocessRandomConeMCD) { 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}}}); } if (doprocessJetsMCP || doprocessJetsMCPWeighted) { - registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {jetEtaAxis}}); registry.add("h_jet_phi_part", "jet #varphi;#varphi_{jet}^{part};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_part", "jet N tracks;N_{jet tracks}^{part};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h_jet_phat_part", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); - registry.add("h_jet_ptcut_part", "p_{T} cut;p_{T,jet}^{part} (GeV/#it{c});N;entries", {HistType::kTH2F, {{200, 0, 200}, {20, 0, 5}}}); - registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, jetEtaAxis}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, trackEtaAxis}}); + registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h_jet_phat_part", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); + registry.add("h_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 (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted || doprocessJetsSubMatched) { - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeo", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {300, 0., 300.}, {300, 0., 300.}}}); + registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeo", "#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_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, ""}, {200, 0.0, 200}, {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}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedpt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + 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_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_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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + 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_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_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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {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_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_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.}}}); } if (doprocessTriggeredData) { registry.add("h_collision_trigger_events", "event status;event status;entries", {HistType::kTH1F, {{6, 0.0, 6.0}}}); registry.add("h_track_pt_MB", "track pT for MB events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_MB", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_MB", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {trackEtaAxis}}); registry.add("h_track_phi_MB", "track #varphi for MB events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_Low", "track pT for low #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_Low", "track #eta for low #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_Low", "track #eta for low #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {trackEtaAxis}}); registry.add("h_track_phi_Triggered_Low", "track #varphi for low #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_High", "track pT for high #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_High", "track #eta for high #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_High", "track #eta for high #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {trackEtaAxis}}); registry.add("h_track_phi_Triggered_High", "track #varphi for high #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_Both", "track pT for both #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_Both", "track #eta for both #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_Both", "track #eta for both #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {trackEtaAxis}}); registry.add("h_track_phi_Triggered_Both", "track #varphi for both #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {4, -0.5, 3.5}}}); - registry.add("h3_jet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {4, -0.5, 3.5}}}); + registry.add("h3_jet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {4, -0.5, 3.5}}}); + registry.add("h3_jet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, jetEtaAxis, {4, -0.5, 3.5}}}); registry.add("h3_jet_r_jet_phi_collision", "#it{R}_{jet};#varphi_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {4, -0.5, 3.5}}}); - registry.add("h2_jet_r_jet_pT_triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h2_jet_r_jet_pT_triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h3_jet_r_jet_pt_track_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_MB", "#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_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Low", "#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_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_High", "#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_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Both", "#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_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); } if (doprocessTracks || doprocessTracksWeighted) { 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, {{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.}}}); - registry.add("h2_centrality_track_energy", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, 0.0, 100.0}}}); + registry.add("h3_centrality_track_pt_track_phi", "centrality vs track pT vs track #varphi; centrality; #it{p}_{T,track} (GeV/#it{c}); #varphi_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_centrality_track_pt_track_eta", "centrality vs track pT vs track #eta; centrality; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, trackEtaAxis}}); + registry.add("h3_centrality_track_pt_track_dcaxy", "centrality vs track pT vs track DCA_{xy}; centrality; #it{p}_{T,track} (GeV/#it{c}); track DCA_{xy}", {HistType::kTH3F, {{120, -10.0, 110.0}, {20, 0., 100.}, {200, -0.15, 0.15}}}); + registry.add("h3_track_pt_track_eta_track_phi", "track pT vs track #eta vs track #varphi; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}; #varphi_{track}", {HistType::kTH3F, {{200, 0., 200.}, trackEtaAxis, {160, -1.0, 7.}}}); if (doprocessTracksWeighted) { registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); } } if (doprocessTracksSub) { - - registry.add("h2_centrality_track_pt_eventwiseconstituentsubtracted", "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_eventwiseconstituentsubtracted", "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_eventwiseconstituentsubtracted", "centrality vs track #varphi; centrality; #varphi_{track}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); - registry.add("h2_centrality_track_energy_eventwiseconstituentsubtracted", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, 0.0, 100.0}}}); + registry.add("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted", "centrality vs track pT vs track #varphi; centrality; #it{p}_{T,track} (GeV/#it{c}); #varphi_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted", "centrality vs track pT vs track #eta; centrality; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, trackEtaAxis}}); + registry.add("h3_track_pt_track_eta_track_phi_eventwiseconstituentsubtracted", "track pT vs track #eta vs track #varphi; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}; #varphi_{track}", {HistType::kTH3F, {{200, 0., 200.}, trackEtaAxis, {160, -1.0, 7.}}}); } if (doprocessMCCollisionsWeighted) { @@ -286,7 +328,7 @@ struct JetFinderQATask { Filter trackCuts = (aod::jtrack::pt >= trackPtMin && aod::jtrack::pt < trackPtMax && aod::jtrack::eta > trackEtaMin && aod::jtrack::eta < trackEtaMax); Filter trackSubCuts = (aod::jtracksub::pt >= trackPtMin && aod::jtracksub::pt < trackPtMax && aod::jtracksub::eta > trackEtaMin && aod::jtracksub::eta < trackEtaMax); Filter eventCuts = (nabs(aod::jcollision::posZ) < vertexZCut && aod::jcollision::centrality >= centralityMin && aod::jcollision::centrality < centralityMax); - PresliceUnsorted> CollisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; + PresliceUnsorted> CollisionsPerMCPCollision = aod::jmccollisionlb::mcCollisionId; template bool isAcceptedJet(U const& jet) @@ -297,23 +339,46 @@ struct JetFinderQATask { return false; } } - if (leadingConstituentPtMin > -98.0) { - bool isMinleadingConstituent = false; - for (auto& constituent : jet.template tracks_as()) { - if (constituent.pt() >= leadingConstituentPtMin) { - isMinleadingConstituent = true; - break; + 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; } } - if (!isMinleadingConstituent) { - return false; - } + return isMinLeadingConstituent && isMaxLeadingConstituent; } + return true; } + template + bool trackIsInJet(T const& track, U const& jet) + { + for (auto const& constituentId : jet.tracksIds()) { + if (constituentId == track.globalIndex()) { + return true; + } + } + return false; + } + template - void fillHistograms(T const& jet, float centrality, float weight = 1.0) + void fillHistograms(T const& jet, float centrality, float occupancy, float weight = 1.0) { float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); @@ -332,6 +397,7 @@ struct JetFinderQATask { 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_centrality_jet_ntracks"), centrality, jet.tracksIds().size(), weight); + registry.fill(HIST("h3_centrality_occupancy_jet_pt"), centrality, occupancy, jet.pt(), weight); } registry.fill(HIST("h3_jet_r_jet_pt_centrality"), jet.r() / 100.0, jet.pt(), centrality, weight); @@ -341,7 +407,7 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_ntracks"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_area"), jet.r() / 100.0, jet.pt(), jet.area(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); @@ -350,7 +416,7 @@ struct JetFinderQATask { } template - void fillRhoAreaSubtractedHistograms(T const& jet, float centrality, float rho, float weight = 1.0) + void fillRhoAreaSubtractedHistograms(T const& jet, float centrality, float occupancy, float rho, float weight = 1.0) { if (jet.r() == round(selectedJetsRadius * 100.0f)) { registry.fill(HIST("h_jet_pt_rhoareasubtracted"), jet.pt() - (rho * jet.area()), weight); @@ -358,6 +424,7 @@ struct JetFinderQATask { registry.fill(HIST("h_jet_phi_rhoareasubtracted"), jet.phi(), weight); registry.fill(HIST("h_jet_ntracks_rhoareasubtracted"), jet.tracksIds().size(), weight); registry.fill(HIST("h2_centrality_jet_pt_rhoareasubtracted"), centrality, jet.pt() - (rho * jet.area()), weight); + registry.fill(HIST("h3_centrality_occupancy_jet_pt_rhoareasubtracted"), centrality, occupancy, jet.pt() - (rho * jet.area()), weight); if (jet.pt() - (rho * jet.area()) > 0) { registry.fill(HIST("h2_centrality_jet_eta_rhoareasubtracted"), centrality, jet.eta(), weight); registry.fill(HIST("h2_centrality_jet_phi_rhoareasubtracted"), centrality, jet.phi(), weight); @@ -373,7 +440,7 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_area_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), jet.area(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_pt_rhoareasubtracted"), jet.r() / 100.0, jet.pt(), jet.pt() - (rho * jet.area()), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), constituent.eta(), weight); @@ -402,7 +469,7 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_ntracks_eventwiseconstituentsubtracted"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_area_eventwiseconstituentsubtracted"), jet.r() / 100.0, jet.pt(), jet.area(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_eventwiseconstituentsubtracted"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_eventwiseconstituentsubtracted"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); @@ -433,7 +500,7 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_part_jet_eta_part_jet_phi_part"), jet.r() / 100.0, jet.eta(), jet.phi(), weight); registry.fill(HIST("h3_jet_r_part_jet_pt_part_jet_ntracks_part"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_part_jet_pt_part_track_pt_part"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_part_jet_pt_part_track_eta_part"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); @@ -462,6 +529,12 @@ struct JetFinderQATask { 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); + for (int N = 1; N < 21; N++) { + if (jetBase.pt() < N * 0.25 * pTHat && jetTag.pt() < N * 0.25 * pTHat) { + registry.fill(HIST("h3_ptcut_jet_pt_tag_jet_pt_base_matchedgeo"), N * 0.25, jetTag.pt(), jetBase.pt(), weight); + } + } + if (jetBase.r() == round(selectedJetsRadius * 100.0f)) { 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); @@ -523,50 +596,165 @@ struct JetFinderQATask { 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("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_track_pt_track_eta_track_phi"), track.pt(), track.eta(), track.phi(), weight); + } + } + + template + void randomCone(T const& collision, U const& jets, V 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); + float randomConePt = 0; + 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("h2_centrality_rhorandomcone"), collision.centrality(), 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; + 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) { + randomConePt += track.pt(); + } + } + } + registry.fill(HIST("h2_centrality_rhorandomconerandomtrackdirection"), collision.centrality(), 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 + float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-M_PI)); + float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + + bool jetWasInCone = false; + while ((randomConeLeadJetDeltaR <= 0 && (TMath::Sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < jets.iteratorAt(0).r() / 100.0 + randomConeR)) || (randomConeLeadJetDeltaR > 0 && (TMath::Sqrt(dEtaLeadingJet * dEtaLeadingJet + dPhiLeadingJet * dPhiLeadingJet) < randomConeLeadJetDeltaR))) { + 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; + 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(); + } + } + } + } + } + + registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), 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(); + } + } + } + } } + 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()); } - void processJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTracks const&) + void processJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { + 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)) { + if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange()); } } PROCESS_SWITCH(JetFinderQATask, processJetsData, "jet finder QA data", false); - void processJetsRhoAreaSubData(soa::Filtered>::iterator const& collision, + void processJetsRhoAreaSubData(soa::Filtered>::iterator const& collision, soa::Join const& jets, - JetTracks const&) + aod::JetTracks const&) { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } for (auto jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), collision.rho()); + fillRhoAreaSubtractedHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), collision.rho()); } } PROCESS_SWITCH(JetFinderQATask, processJetsRhoAreaSubData, "jet finder QA for rho-area subtracted jets", false); - void processEvtWiseConstSubJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTracksSub const&) + void processJetsRhoAreaSubMCD(soa::Filtered>::iterator const& collision, + soa::Join const& jets, + aod::JetTracks const&) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillRhoAreaSubtractedHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), collision.rho()); + } + } + PROCESS_SWITCH(JetFinderQATask, processJetsRhoAreaSubMCD, "jet finder QA for rho-area subtracted mcd jets", false); + + void processEvtWiseConstSubJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracksSub const&) { + 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)) { + if (!isAcceptedJet(jet)) { continue; } fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); @@ -574,16 +762,36 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processEvtWiseConstSubJetsData, "jet finder QA for eventwise constituent-subtracted jets data", false); - void processJetsSubMatched(soa::Filtered::iterator const&, + void processEvtWiseConstSubJetsMCD(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracksSub const&) + { + 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; + } + fillEventWiseConstituentSubtractedHistograms(jet, collision.centrality()); + } + } + PROCESS_SWITCH(JetFinderQATask, processEvtWiseConstSubJetsMCD, "jet finder QA for eventwise constituent-subtracted mcd jets", false); + + void processJetsSubMatched(soa::Filtered::iterator const& collision, soa::Join const& jets, soa::Join const&, - JetTracks const&, JetTracksSub const&) + aod::JetTracks const&, aod::JetTracksSub const&) { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } for (const auto& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillMatchedHistograms::iterator, soa::Join>(jet); @@ -591,51 +799,57 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processJetsSubMatched, "jet finder QA matched unsubtracted and constituent subtracted jets", false); - void processJetsMCD(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTracks const&) + void processJetsMCD(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { + 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)) { + if (!isAcceptedJet(jet)) { continue; } - fillHistograms(jet, collision.centrality()); + fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange()); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCD, "jet finder QA mcd", false); - void processJetsMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTracks const&) + void processJetsMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::JetTracks const&) { + 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)) { + if (!isAcceptedJet(jet)) { continue; } - double pTHat = 10. / (std::pow(jet.eventWeight(), 1.0 / 6.0)); + double pTHat = 10. / (std::pow(jet.eventWeight(), 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("h_jet_ptcut"), jet.pt(), N * 0.25, jet.eventWeight()); } } - fillHistograms(jet, collision.centrality(), jet.eventWeight()); + fillHistograms(jet, collision.centrality(), collision.trackOccupancyInTimeRange(), jet.eventWeight()); } } PROCESS_SWITCH(JetFinderQATask, processJetsMCDWeighted, "jet finder QA mcd with weighted events", false); - void processJetsMCP(soa::Join::iterator const& jet, JetParticles const&, JetMcCollisions const&, soa::Filtered const& collisions) + void processJetsMCP(soa::Join::iterator const& jet, aod::JetParticles const&, aod::JetMcCollisions const&, soa::Filtered const& collisions) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } if (checkMcCollisionIsMatched) { auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, jet.mcCollisionId()); - if (collisionspermcpjet.size() >= 1) { + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { fillMCPHistograms(jet); } } else { @@ -644,15 +858,15 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processJetsMCP, "jet finder QA mcp", false); - void processJetsMCPWeighted(soa::Join::iterator const& jet, JetParticles const&, JetMcCollisions const&, soa::Filtered const& collisions) + void processJetsMCPWeighted(soa::Join::iterator const& jet, aod::JetParticles const&, aod::JetMcCollisions const&, soa::Filtered const& collisions) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } - double pTHat = 10. / (std::pow(jet.eventWeight(), 1.0 / 6.0)); + double pTHat = 10. / (std::pow(jet.eventWeight(), 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("h_jet_ptcut_part"), jet.pt(), N * 0.25, jet.eventWeight()); @@ -669,16 +883,19 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processJetsMCPWeighted, "jet finder QA mcp with weighted events", false); - void processJetsMCPMCDMatched(soa::Filtered::iterator const&, + void processJetsMCPMCDMatched(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, soa::Join const&, - JetTracks const&, JetParticles const&) + aod::JetTracks const&, aod::JetParticles const&) { + 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)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms::iterator, soa::Join>(mcdjet); @@ -686,16 +903,19 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processJetsMCPMCDMatched, "jet finder QA matched mcp and mcd", false); - void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const&, + void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, soa::Join const&, - JetTracks const&, JetParticles const&) + aod::JetTracks const&, aod::JetParticles const&) { + 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)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms::iterator, soa::Join>(mcdjet, mcdjet.eventWeight()); @@ -703,15 +923,15 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processJetsMCPMCDMatchedWeighted, "jet finder QA matched mcp and mcd with weighted events", false); - void processMCCollisionsWeighted(JetMcCollision const& collision) + void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); - void processTriggeredData(soa::Join::iterator const& collision, + void processTriggeredData(soa::Join::iterator const& collision, soa::Join const& jets, - soa::Filtered const& tracks) + soa::Filtered const& tracks) { registry.fill(HIST("h_collision_trigger_events"), 0.5); // all events if (collision.posZ() > vertexZCut) { @@ -722,13 +942,13 @@ struct JetFinderQATask { return; } registry.fill(HIST("h_collision_trigger_events"), 2.5); // events with sel8() - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h_collision_trigger_events"), 3.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_collision_trigger_events"), 4.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_collision_trigger_events"), 5.5); // events with high pT triggered jets } @@ -740,19 +960,19 @@ struct JetFinderQATask { for (auto& jet : jets) { for (std::size_t iJetRadius = 0; iJetRadius < jetRadiiValues.size(); iJetRadius++) { if (jet.r() == round(jetRadiiValues[iJetRadius] * 100.0f)) { - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && !filledJetR_Low[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && !filledJetR_Low[iJetRadius]) { filledJetR_Low[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_Low"), jet.r() / 100.0, pt); } } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh) && !filledJetR_High[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt) && !filledJetR_High[iJetRadius]) { filledJetR_High[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_High"), jet.r() / 100.0, pt); } } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh) && !filledJetR_Both[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt) && !filledJetR_Both[iJetRadius]) { filledJetR_Both[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_Both"), jet.r() / 100.0, pt); @@ -769,38 +989,38 @@ struct JetFinderQATask { registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 0.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 0.0); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 1.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 1.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 1.0); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 2.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 2.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 2.0); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 3.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 3.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 3.0); } - for (auto& constituent : jet.template tracks_as>()) { + for (auto& constituent : jet.template tracks_as>()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_MB"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_MB"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_MB"), jet.r() / 100.0, jet.pt(), constituent.phi()); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.phi()); @@ -816,17 +1036,17 @@ struct JetFinderQATask { registry.fill(HIST("h_track_eta_MB"), track.eta()); registry.fill(HIST("h_track_phi_MB"), track.phi()); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h_track_pt_Triggered_Low"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_Low"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_Low"), track.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_track_pt_Triggered_High"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_High"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_High"), track.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_track_pt_Triggered_Both"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_Both"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_Both"), track.phi()); @@ -835,8 +1055,8 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processTriggeredData, "QA for charged jet trigger", false); - void processTracks(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks) + void processTracks(soa::Filtered::iterator const& collision, + soa::Filtered> const& tracks) { registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); @@ -845,13 +1065,18 @@ struct JetFinderQATask { } registry.fill(HIST("h_collisions"), 1.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 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); } PROCESS_SWITCH(JetFinderQATask, processTracks, "QA for charged tracks", false); - void processTracksWeighted(soa::Join::iterator const& collision, - JetMcCollisions const&, - soa::Filtered const& tracks) + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JetMcCollisions const&, + soa::Filtered> const& tracks) { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); @@ -861,30 +1086,40 @@ struct JetFinderQATask { } registry.fill(HIST("h_collisions"), 1.5); registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + registry.fill(HIST("h_collisions_weighted"), 2.5, eventWeight); fillTrackHistograms(collision, tracks, eventWeight); } PROCESS_SWITCH(JetFinderQATask, processTracksWeighted, "QA for charged tracks weighted", false); - void processTracksSub(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks) + void processTracksSub(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } for (auto const& track : tracks) { - registry.fill(HIST("h2_centrality_track_pt_eventwiseconstituentsubtracted"), collision.centrality(), track.pt()); - registry.fill(HIST("h2_centrality_track_eta_eventwiseconstituentsubtracted"), collision.centrality(), track.eta()); - registry.fill(HIST("h2_centrality_track_phi_eventwiseconstituentsubtracted"), collision.centrality(), track.phi()); - registry.fill(HIST("h2_centrality_track_energy_eventwiseconstituentsubtracted"), collision.centrality(), track.energy()); + 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_track_pt_track_eta_track_phi_eventwiseconstituentsubtracted"), track.pt(), track.eta(), track.phi()); } } PROCESS_SWITCH(JetFinderQATask, processTracksSub, "QA for charged event-wise embedded subtracted tracks", false); - void processRho(soa::Filtered>::iterator const& collision, soa::Filtered const& tracks) + void processRho(soa::Filtered>::iterator const& collision, soa::Filtered const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } int nTracks = 0; for (auto const& track : tracks) { if (jetderiveddatautilities::selectTrack(track, trackSelection)) { @@ -899,56 +1134,17 @@ struct JetFinderQATask { } PROCESS_SWITCH(JetFinderQATask, processRho, "QA for rho-area subtracted jets", false); - void processRandomCone(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) + void processRandomConeData(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; - } - TRandom3 randomNumber(0); - float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); - float randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); - float randomConePt = 0; - 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("h2_centrality_rhorandomcone"), collision.centrality(), 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 - 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; - 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(); - } - } - } - } - } + randomCone(collision, jets, tracks); + } + PROCESS_SWITCH(JetFinderQATask, processRandomConeData, "QA for random cone estimation of background fluctuations in data", false); - registry.fill(HIST("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * collision.rho()); + void processRandomConeMCD(soa::Filtered>::iterator const& collision, soa::Join const& jets, soa::Filtered const& tracks) + { + randomCone(collision, jets, tracks); } - PROCESS_SWITCH(JetFinderQATask, processRandomCone, "QA for random cone estimation of background fluctuations", false); + PROCESS_SWITCH(JetFinderQATask, processRandomConeMCD, "QA for random cone estimation of background fluctuations in mcd", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-finder-charged-qa"})}; } diff --git a/PWGJE/Tasks/jetfinderfullQA.cxx b/PWGJE/Tasks/jetfinderfullQA.cxx index 13e42669e02..3899a335d4b 100644 --- a/PWGJE/Tasks/jetfinderfullQA.cxx +++ b/PWGJE/Tasks/jetfinderfullQA.cxx @@ -54,6 +54,7 @@ struct JetFinderFullQATask { Configurable trackPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + 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"}; Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; @@ -79,6 +80,8 @@ struct JetFinderFullQATask { int trackSelection = -1; + std::vector jetPtBins; + Service pdgDatabase; void init(o2::framework::InitContext&) @@ -97,107 +100,125 @@ struct JetFinderFullQATask { jetRadiiBins.push_back(jetRadiiBins[jetRadiiBins.size() - 1] + 0.1); } + auto jetPtTemp = 0.0; + jetPtBins.push_back(jetPtTemp); + while (jetPtTemp < jetPtMax) { + if (jetPtTemp < 100.0) { + jetPtTemp += 1.0; + jetPtBins.push_back(jetPtTemp); + } else if (jetPtTemp < 200.0) { + jetPtTemp += 5.0; + jetPtBins.push_back(jetPtTemp); + + } else { + jetPtTemp += 10.0; + jetPtBins.push_back(jetPtTemp); + } + } + + AxisSpec jetPtAxis = {jetPtBins, "#it{p}_{T} (GeV/#it{c})"}; + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { - registry.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + 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, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); registry.add("h_jet_nclusters", "jet N clusters;N_{jet clusters};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxis}}); + registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {500, -5.0, 5.0}}}); registry.add("h2_centrality_jet_phi", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); registry.add("h2_centrality_jet_nclusters", "centrality vs N_{jet clusters}; centrality; N_{jet clusters}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_nclusters", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet clusters}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_neutralenergyfraction", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});E_{neutral}/E_{total}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {120, 0.0, 1.2}}}); - registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {300, 0., 3.}}}); - registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_cluster_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,cluster} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_cluster_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{cluster}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_cluster_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{cluster}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_cluster_energy", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});E_{cluster} (GeV)", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.0}}}); + registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_nclusters", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet clusters}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_neutralenergyfraction", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});E_{neutral}/E_{total}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {120, 0.0, 1.2}}}); + registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {300, 0., 3.}}}); + registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_cluster_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,cluster} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_cluster_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{cluster}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_cluster_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{cluster}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_cluster_energy", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});E_{cluster} (GeV)", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); } if (doprocessJetsMCP || doprocessJetsMCPWeighted) { - registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi_part", "jet #varphi;#varphi_{jet}^{part};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_part", "jet N tracks;N_{jet tracks}^{part};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_neutralenergyfraction_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});E_{neutral}^{part}/E_{total}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {120, 0.0, 1.2}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_neutralenergyfraction_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});E_{neutral}^{part}/E_{total}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {120, 0.0, 1.2}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); } if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted) { - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeo", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#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_matchedgeo", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_cluster_pt_tag_cluster_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,cluster}^{tag} (GeV/#it{c});#it{p}_{T,cluster}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedgeo", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_cluster_pt_tag_cluster_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,cluster}^{tag} (GeV/#it{c});#it{p}_{T,cluster}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedgeo", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_cluster_phi_tag_cluster_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{cluster}^{tag};#varphi_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedgeo", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.0}}}); - 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, ""}, {200, 0.0, 200}, {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}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedpt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedgeo", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); + 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, 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}) / #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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_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, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_cluster_pt_tag_cluster_pt_base_matchedpt", "#it{R}_{jet};#it{p}_{T,cluster}^{tag} (GeV/#it{c});#it{p}_{T,cluster}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedpt", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedpt", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_cluster_phi_tag_cluster_phi_base_matchedpt", "#it{R}_{jet};#varphi_{cluster}^{tag};#varphi_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedpt", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.0}}}); - 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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedpt", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); + 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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_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, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_cluster_pt_tag_cluster_pt_base_matchedgeopt", "#it{R}_{jet};#it{p}_{T,cluster}^{tag} (GeV/#it{c});#it{p}_{T,cluster}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_cluster_eta_tag_cluster_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{cluster}^{tag};#eta_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_cluster_phi_tag_cluster_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{cluster}^{tag};#varphi_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedgeopt", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.0}}}); - 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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_cluster_energy_tag_cluster_energy_base_matchedgeopt", "#it{R}_{jet};#E_{cluster}^{tag};#E_{cluster}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); + 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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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}}}); } if (doprocessTracks || doprocessTracksWeighted) { registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h_centrality_collisions", "centrality vs collisions; centrality, collisions", {HistType::kTH2F, {{1200, -10.0, 110.0}, {4, 0.0, 4.0}}}); registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_energy", "track energy;Energy GeV ;entries", {HistType::kTH1F, {{100, 0.0, 100.0}}}); 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.0, 1.0}}}); + registry.add("h_cluster_eta", "cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_cluster_phi", "cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_cluster_energy", "cluster E;E_{cluster} (GeV);entries", {HistType::kTH1F, {{200, 0., 200.}}}); if (doprocessTracksWeighted) { @@ -283,14 +304,14 @@ struct JetFinderFullQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_nclusters"), jet.r() / 100.0, jet.pt(), jet.clustersIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_area"), jet.r() / 100.0, jet.pt(), jet.area(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_phi"), jet.r() / 100.0, jet.pt(), constituent.phi(), weight); } - for (auto& cluster : jet.template clusters_as()) { + for (auto& cluster : jet.template clusters_as()) { double clusterpt = cluster.energy() / std::cosh(cluster.eta()); neutralEnergy += cluster.energy(); registry.fill(HIST("h3_jet_r_jet_pt_cluster_pt"), jet.r() / 100.0, jet.pt(), clusterpt, weight); @@ -324,7 +345,7 @@ struct JetFinderFullQATask { registry.fill(HIST("h3_jet_r_part_jet_eta_part_jet_phi_part"), jet.r() / 100.0, jet.eta(), jet.phi(), weight); registry.fill(HIST("h3_jet_r_part_jet_pt_part_jet_ntracks_part"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { auto pdgParticle = pdgDatabase->GetParticle(constituent.pdgCode()); if (pdgParticle->Charge() == 0) { neutralEnergy += constituent.e(); @@ -432,18 +453,18 @@ struct JetFinderFullQATask { } } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetFinderFullQATask, processDummy, "dummy task", true); - void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, JetTracks const&, JetClusters const&) + void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -451,13 +472,13 @@ struct JetFinderFullQATask { } PROCESS_SWITCH(JetFinderFullQATask, processJetsData, "jet finder HF QA data", false); - void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, JetTracks const&, JetClusters const&) + void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -465,13 +486,13 @@ struct JetFinderFullQATask { } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCD, "jet finder HF QA mcd", false); - void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, JetTracks const&, JetClusters const&) + void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, aod::JetTracks const&, aod::JetClusters const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality(), jet.eventWeight()); @@ -479,43 +500,43 @@ struct JetFinderFullQATask { } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); - void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, JetParticles const&) + void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, aod::JetParticles const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } fillMCPHistograms(jet); } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCP, "jet finder HF QA mcp", false); - void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, JetParticles const&) + void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, aod::JetParticles const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } fillMCPHistograms(jet, jet.eventWeight()); } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCPWeighted, "jet finder HF QA mcp on weighted events", false); - void processJetsMCPMCDMatched(JetCollision const&, + void processJetsMCPMCDMatched(aod::JetCollision const&, JetTableMCDMatchedJoined const& mcdjets, JetTableMCPMatchedJoined const&, - JetTracks const&, - JetClusters const&, - JetParticles const&) + aod::JetTracks const&, + aod::JetClusters const&, + aod::JetParticles const&) { for (const auto& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(mcdjet)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms(mcdjet); @@ -523,19 +544,19 @@ struct JetFinderFullQATask { } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCPMCDMatched, "jet finder HF QA matched mcp and mcd", false); - void processJetsMCPMCDMatchedWeighted(JetCollision const&, + void processJetsMCPMCDMatchedWeighted(aod::JetCollision const&, JetTableMCDMatchedWeightedJoined const& mcdjets, JetTableMCPMatchedWeightedJoined const&, - JetTracks const&, - JetClusters const&, - JetParticles const&) + aod::JetTracks const&, + aod::JetClusters const&, + aod::JetParticles const&) { for (const auto& mcdjet : mcdjets) { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(mcdjet)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms(mcdjet, mcdjet.eventWeight()); @@ -543,16 +564,16 @@ struct JetFinderFullQATask { } PROCESS_SWITCH(JetFinderFullQATask, processJetsMCPMCDMatchedWeighted, "jet finder HF QA matched mcp and mcd on weighted events", false); - void processMCCollisionsWeighted(JetMcCollision const& collision) + void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderFullQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); - void processTracks(JetCollision const& collision, - soa::Filtered const& tracks, - soa::Filtered const& clusters) + void processTracks(aod::JetCollision const& collision, + soa::Filtered const& tracks, + soa::Filtered const& clusters) { registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h_centrality_collisions"), collision.centrality(), 0.5); @@ -567,8 +588,8 @@ struct JetFinderFullQATask { void processTracksWeighted(soa::Join::iterator const& collision, aod::JMcCollisions const&, - soa::Filtered const& tracks, - soa::Filtered const& clusters) + soa::Filtered const& tracks, + soa::Filtered const& clusters) { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); diff --git a/PWGJE/Tasks/jetfinderhfQA.cxx b/PWGJE/Tasks/jetfinderhfQA.cxx index 8963fb5d513..9ac052bdebe 100644 --- a/PWGJE/Tasks/jetfinderhfQA.cxx +++ b/PWGJE/Tasks/jetfinderhfQA.cxx @@ -60,6 +60,7 @@ struct JetFinderHFQATask { Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; Configurable trackPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + 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"}; Configurable jetAreaFractionMin{"jetAreaFractionMin", -99.0, "used to make a cut on the jet areas"}; @@ -81,6 +82,9 @@ struct JetFinderHFQATask { int eventSelection = -1; int trackSelection = -1; + std::vector jetPtBins; + std::vector jetPtBinsRhoAreaSub; + void init(o2::framework::InitContext&) { eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); @@ -103,81 +107,108 @@ struct JetFinderHFQATask { 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) { + jetPtTemp += 1.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } else if (jetPtTemp < 200.0) { + jetPtTemp += 5.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + + } else { + jetPtTemp += 10.0; + jetPtBins.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(jetPtTemp); + jetPtBinsRhoAreaSub.push_back(-jetPtTemp); + } + } + std::sort(jetPtBinsRhoAreaSub.begin(), jetPtBinsRhoAreaSub.end()); + + AxisSpec jetPtAxis = {jetPtBins, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec jetPtAxisRhoAreaSub = {jetPtBinsRhoAreaSub, "#it{p}_{T} (GeV/#it{c})"}; + if (doprocessJetsData || doprocessJetsMCD || doprocessJetsMCDWeighted) { - registry.add("h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + 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, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxis}}); + registry.add("h2_centrality_jet_eta", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {500, -5.0, 5.0}}}); registry.add("h2_centrality_jet_phi", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {300, 0., 3.}}}); - registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_candidate_invmass_jet_pt_candidate_pt", ";#it{m}_{inv, candidate} (GeV/#it{c}^{2}); #it{p}_{T,jet} (GeV/#it{c}) ;#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{500, 0.0, 5.0}, {200, 0.0, 200.0}, {200, 0.0, 200.0}}}); - registry.add("h3_candidatebar_invmass_jet_pt_candidate_pt", ";#it{m}_{inv, candidate bar} (GeV/#it{c}^{2}); #it{p}_{T,jet} (GeV/#it{c}) ;#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{500, 0.0, 5.0}, {200, 0.0, 200.0}, {200, 0.0, 200.0}}}); + registry.add("h3_jet_r_jet_pt_centrality", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_jet_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {300, 0., 3.}}}); + registry.add("h3_jet_r_jet_pt_track_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_candidate_invmass_jet_pt_candidate_pt", ";#it{m}_{inv, candidate} (GeV/#it{c}^{2}); #it{p}_{T,jet} (GeV/#it{c}) ;#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{500, 0.0, 5.0}, jetPtAxis, {200, 0.0, 200.0}}}); + registry.add("h3_candidatebar_invmass_jet_pt_candidate_pt", ";#it{m}_{inv, candidate bar} (GeV/#it{c}^{2}); #it{p}_{T,jet} (GeV/#it{c}) ;#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{500, 0.0, 5.0}, jetPtAxis, {200, 0.0, 200.0}}}); registry.add("h_jet_phat_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); } - if (doprocessJetsRhoAreaSubData) { + if (doprocessJetsRhoAreaSubData || doprocessJetsRhoAreaSubMCD) { - registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{400, -200., 200.}}}); - registry.add("h_jet_eta_rhoareasubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_jet_pt_rhoareasubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxisRhoAreaSub}}); + registry.add("h_jet_eta_rhoareasubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi_rhoareasubtracted", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_rhoareasubtracted", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt_rhoareasubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {400, -200., 200.}}}); - registry.add("h2_centrality_jet_eta_rhoareasubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt_rhoareasubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxisRhoAreaSub}}); + registry.add("h2_centrality_jet_eta_rhoareasubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {500, -5.0, 5.0}}}); registry.add("h2_centrality_jet_phi_rhoareasubtracted", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks_rhoareasubtracted", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi_rhoareasubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area_rhoareasubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {300, 0., 3.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); - 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, ""}, {400, -200., 200.}, {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, ""}, {200, 0., 200.}, {400, -200., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {400, -200., 200.}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_centrality_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_jet_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi_rhoareasubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area_rhoareasubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {300, 0., 3.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {500, -5.0, 5.0}}}); + 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_jet_r_jet_pt_candidate_pt_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_rhoareasubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxisRhoAreaSub, {500, -5.0, 5.0}}}); } if (doprocessEvtWiseConstSubJetsData) { - registry.add("h_jet_pt_eventwiseconstituentsubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta_eventwiseconstituentsubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_jet_pt_eventwiseconstituentsubtracted", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_eventwiseconstituentsubtracted", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi_eventwiseconstituentsubtracted", "jet #varphi;#varphi_{jet};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_eventwiseconstituentsubtracted", "jet N tracks;N_{jet tracks};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h2_centrality_jet_pt_eventwiseconstituentsubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, 0., 200.}}}); - registry.add("h2_centrality_jet_eta_eventwiseconstituentsubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, -1.0, 1.0}}}); + registry.add("h2_centrality_jet_pt_eventwiseconstituentsubtracted", "centrality vs #it{p}_{T,jet}; centrality; #it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{1200, -10.0, 110.0}, jetPtAxis}}); + registry.add("h2_centrality_jet_eta_eventwiseconstituentsubtracted", "centrality vs #eta_{jet}; centrality; #eta_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {500, -5.0, 5.0}}}); registry.add("h2_centrality_jet_phi_eventwiseconstituentsubtracted", "centrality vs #varphi_{jet}; centrality; #varphi_{jet}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); registry.add("h2_centrality_jet_ntracks_eventwiseconstituentsubtracted", "centrality vs N_{jet tracks}; centrality; N_{jet tracks}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_centrality_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {1200, -10.0, 110.0}}}); - registry.add("h3_jet_r_jet_pt_jet_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_eta_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_jet_ntracks_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_jet_pt_jet_area_eventwiseconstituentsubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {300, 0., 3.}}}); - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - 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, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - 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, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_centrality_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});centrality", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {1200, -10.0, 110.0}}}); + registry.add("h3_jet_r_jet_pt_jet_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_eta_jet_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#eta_{jet};#varphi_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_jet_ntracks_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});N_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_jet_area_eventwiseconstituentsubtracted", "#it{R}_{jet}; #it{p}_{T,jet} (GeV/#it{c}); #it{area}_{jet}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {300, 0., 3.}}}); + 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, {200, 0., 200.}}}); + 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, {500, -5.0, 5.0}}}); + 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("h3_jet_r_jet_pt_candidate_pt_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_eventwiseconstituentsubtracted", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); } if (doprocessRho) { @@ -188,239 +219,236 @@ struct JetFinderHFQATask { registry.add("h2_centrality_rhom", ";centrality; #it{rho}_{m} (GeV/area)", {HistType::kTH2F, {{1100, 0., 110.}, {100, 0., 100.0}}}); } - if (doprocessRandomCone) { + if (doprocessRandomConeData || doprocessRandomConeMCD) { 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_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}}}); } if (doprocessJetsMCP || doprocessJetsMCPWeighted) { - registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); - registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_jet_pt_part", "jet pT;#it{p}_{T,jet}^{part}(GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); + registry.add("h_jet_eta_part", "jet #eta;#eta_{jet}^{part};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_jet_phi_part", "jet #varphi;#varphi_{jet}^{part};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_jet_ntracks_part", "jet N tracks;N_{jet tracks}^{part};entries", {HistType::kTH1F, {{200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, -0.5, 199.5}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_pt_part_candidate_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,candidate}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_part_jet_pt_part_candidate_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_part_jet_pt_part_candidate_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_part_jet_pt_part_candidate_y_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});y_{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{350, 0, 350}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_eta_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_phi_part", ";#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_eta_part_jet_phi_part", ";#it{R}_{jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_pt_part_jet_ntracks_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});N_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,jet tracks}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_part_jet_pt_part_track_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi_{jet tracks}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_pt_part_candidate_pt_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,candidate}^{part} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_part_jet_pt_part_candidate_eta_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#eta_{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_part_jet_pt_part_candidate_phi_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});#varphi{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_part_jet_pt_part_candidate_y_part", "#it{R}_{jet}^{part};#it{p}_{T,jet}^{part} (GeV/#it{c});y_{candidate}^{part}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h_jet_phat_part_weighted", "jet #hat{p};#hat{p} (GeV/#it{c});entries", {HistType::kTH1F, {{1000, 0, 1000}}}); } if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWeighted || doprocessJetsSubMatched) { - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeo", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeo", "#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_matchedgeo", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_candidate_pt_tag_candidate_pt_base_matchedgeo", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeo", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeo", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedgeo", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - 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, ""}, {200, 0.0, 200}, {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}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedpt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + 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, 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}) / #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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_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, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_candidate_pt_tag_candidate_pt_base_matchedpt", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedpt", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedpt", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedpt", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - 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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - 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, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + 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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_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, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_candidate_pt_tag_candidate_pt_base_matchedgeopt", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeopt", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedgeopt", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - 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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.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, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - 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, {{200, 0.0, 200}, {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, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedhf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedhf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedhf", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + 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_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, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + 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_r_jet_pt_tag_jet_pt_base_matchedhf", "#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_matchedhf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedhf", "#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_matchedhf", "#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_candidate_pt_tag_candidate_pt_base_matchedhf", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedhf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedhf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedhf", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedhf", "#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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedhf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedhf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedhf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedhf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedhf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeohf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeohf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeohf", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedhf", "#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_matchedhf", "#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_matchedhf", "#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_pt_tag_jet_eta_tag_jet_eta_base_matchedhf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedhf", ";#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_matchedhf", ";#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_r_jet_pt_tag_jet_pt_base_matchedgeohf", "#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_matchedgeohf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeohf", "#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_matchedgeohf", "#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_candidate_pt_tag_candidate_pt_base_matchedgeohf", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeohf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeohf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedgeohf", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeohf", "#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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeohf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeohf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeohf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeohf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeohf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedpthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedpthf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpthf", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeohf", "#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_matchedgeohf", "#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_matchedgeohf", "#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_pt_tag_jet_eta_tag_jet_eta_base_matchedgeohf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeohf", ";#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_matchedgeohf", ";#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_r_jet_pt_tag_jet_pt_base_matchedpthf", "#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_matchedpthf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedpthf", "#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_matchedpthf", "#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_candidate_pt_tag_candidate_pt_base_matchedpthf", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedpthf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedpthf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedpthf", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedpthf", "#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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedpthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedpthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedpthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedpthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedpthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); - - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_matchedgeopthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c});#it{p}_{T,jet}^{base} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_eta_tag_jet_eta_base_matchedgeopthf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopthf", "#it{R}_{jet};#varphi_{jet}^{tag};#varphi_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedpthf", "#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_matchedpthf", "#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_matchedpthf", "#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_pt_tag_jet_eta_tag_jet_eta_base_matchedpthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedpthf", ";#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_matchedpthf", ";#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_r_jet_pt_tag_jet_pt_base_matchedgeopthf", "#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_matchedgeopthf", "#it{R}_{jet};#eta_{jet}^{tag};#eta_{jet}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_phi_tag_jet_phi_base_matchedgeopthf", "#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_matchedgeopthf", "#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_candidate_pt_tag_candidate_pt_base_matchedgeopthf", "#it{R}_{jet};#it{p}_{T,candidate}^{tag} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeopthf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_candidate_eta_tag_candidate_eta_base_matchedgeopthf", "#it{R}_{jet};#eta_{candidate}^{tag};#eta_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); registry.add("h3_jet_r_candidate_phi_tag_candidate_phi_base_matchedgeopthf", "#it{R}_{jet};#varphi_{candidate}^{tag};#varphi_{candidate}^{base}", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeopthf", "#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, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_eta_base_diff_matchedgeopthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#eta_{jet}^{tag} - #eta_{jet}^{base}) / #eta_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_r_jet_pt_tag_jet_phi_base_diff_matchedgeopthf", "#it{R}_{jet};#it{p}_{T,jet}^{tag} (GeV/#it{c}); (#varphi_{jet}^{tag} - #varphi_{jet}^{base}) / #varphi_{jet}^{tag}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0.0, 200}, {1000, -5.0, 5.0}}}); - registry.add("h3_jet_pt_tag_jet_eta_tag_jet_eta_base_matchedgeopthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {100, -1.0, 1.0}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeopthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #varphi_{jet}^{tag}; #varphi_{jet}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {160, -1.0, 7.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_pt_tag_jet_ntracks_tag_jet_ntracks_base_matchedgeopthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); N_{jet tracks}^{tag}; N_{jet tracks}^{base}", {HistType::kTH3F, {{200, 0.0, 200}, {200, -0.5, 199.5}, {200, -0.5, 199.5}}}); + registry.add("h3_jet_r_jet_pt_tag_jet_pt_base_diff_matchedgeopthf", "#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_matchedgeopthf", "#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_matchedgeopthf", "#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_pt_tag_jet_eta_tag_jet_eta_base_matchedgeopthf", ";#it{p}_{T,jet}^{tag} (GeV/#it{c}); #eta_{jet}^{tag}; #eta_{jet}^{base}", {HistType::kTH3F, {jetPtAxis, {500, -5.0, 5.0}, {500, -5.0, 5.0}}}); + registry.add("h3_jet_pt_tag_jet_phi_tag_jet_phi_base_matchedgeopthf", ";#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_matchedgeopthf", ";#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}}}); } if (doprocessTriggeredData) { registry.add("h_collision_trigger_events", "event status;event status;entries", {HistType::kTH1F, {{6, 0.0, 6.0}}}); registry.add("h_track_pt_MB", "track pT for MB events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_MB", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_MB", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_MB", "track #varphi for MB events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_Low", "track pT for low #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_Low", "track #eta for low #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_Low", "track #eta for low #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_Triggered_Low", "track #varphi for low #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_High", "track pT for high #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_High", "track #eta for high #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_High", "track #eta for high #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_Triggered_High", "track #varphi for high #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_Triggered_Both", "track pT for both #it{p}_{T} Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_Triggered_Both", "track #eta for both #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_Triggered_Both", "track #eta for both #it{p}_{T} Triggered events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_Triggered_Both", "track #varphi for both #it{p}_{T} Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {4, -0.5, 3.5}}}); - registry.add("h3_jet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {4, -0.5, 3.5}}}); + registry.add("h3_jet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {4, -0.5, 3.5}}}); + registry.add("h3_jet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {4, -0.5, 3.5}}}); registry.add("h3_jet_r_jet_phi_collision", "#it{R}_{jet};#varphi_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {4, -0.5, 3.5}}}); - registry.add("h2_jet_r_jet_pT_triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); + registry.add("h2_jet_r_jet_pT_triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h3_jet_r_jet_pt_track_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_track_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,jet tracks} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_MB", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_Low", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_High", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); } if (doprocessHFTriggeredData) { registry.add("h_collision_hftrigger_events", "event status;event status;entries", {HistType::kTH1F, {{115, 0.0, 15.0}}}); registry.add("h_track_pt_all", "track pT for MB events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_all", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_all", "track #eta for MB events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_all", "track #varphi for MB events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_triggered_HFlow", "track pT for low #it{p}_{T} HF Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_triggered_HFlow", "track #eta for low #it{p}_{T} HF Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_triggered_HFlow", "track #eta for low #it{p}_{T} HF Triggered events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_triggered_HFlow", "track #varphi for low #it{p}_{T} HF Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_track_pt_triggered_HFhigh", "track pT for high #it{p}_{T} HF Triggered events;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_track_eta_triggered_HFhigh", "track #eta for high #it{p}_{T} HF Triggered events;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_track_eta_triggered_HFhigh", "track #eta for high #it{p}_{T} HF Triggered events;#eta_{track};entries", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h_track_phi_triggered_HFhigh", "track #varphi for high #it{p}_{T} HF Triggered events;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); - registry.add("h2_jet_r_jet_pT_triggered_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_Lcall", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_Lclow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_pT_triggered_Lchigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, {200, 0., 200.}}}); - registry.add("h2_jet_r_jet_eta_triggered_HFall", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}}}); - registry.add("h2_jet_r_jet_eta_triggered_HFlow", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}}}); - registry.add("h2_jet_r_jet_eta_triggered_HFhigh", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}}}); - - registry.add("h3_hfjet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {4, -0.5, 3.5}}}); - registry.add("h3_hfjet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {100, -1.0, 1.0}, {4, -0.5, 3.5}}}); + registry.add("h2_jet_r_jet_pT_triggered_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_Lcall", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_Lclow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_pT_triggered_Lchigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c})", {HistType::kTH2F, {{jetRadiiBins, ""}, jetPtAxis}}); + registry.add("h2_jet_r_jet_eta_triggered_HFall", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}}}); + registry.add("h2_jet_r_jet_eta_triggered_HFlow", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}}}); + registry.add("h2_jet_r_jet_eta_triggered_HFhigh", "#it{R}_{jet};#eta_{jet}", {HistType::kTH2F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}}}); + + registry.add("h3_hfjet_r_jet_pt_collision", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {4, -0.5, 3.5}}}); + registry.add("h3_hfjet_r_jet_eta_collision", "#it{R}_{jet};#eta_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {500, -5.0, 5.0}, {4, -0.5, 3.5}}}); registry.add("h3_hfjet_r_jet_phi_collision", "#it{R}_{jet};#varphi_{jet};collision trigger status", {HistType::kTH3F, {{jetRadiiBins, ""}, {160, -1.0, 7.}, {4, -0.5, 3.5}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_pt_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {200, 0., 200.}}}); - registry.add("h3_jet_r_jet_pt_candidate_eta_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); - registry.add("h3_jet_r_jet_pt_candidate_phi_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); - registry.add("h3_jet_r_jet_pt_candidate_y_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_all", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_triggered_HFlow", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_pt_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#it{p}_{T,candidate} (GeV/#it{c})", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {200, 0., 200.}}}); + registry.add("h3_jet_r_jet_pt_candidate_eta_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); + registry.add("h3_jet_r_jet_pt_candidate_phi_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {160, -1.0, 7.}}}); + registry.add("h3_jet_r_jet_pt_candidate_y_triggered_HFhigh", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, jetPtAxis, {500, -5.0, 5.0}}}); } if (doprocessTracks || doprocessTracksWeighted) { 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, {{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.}}}); - registry.add("h2_centrality_track_energy", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, 0.0, 100.0}}}); + registry.add("h3_centrality_track_pt_track_phi", "centrality vs track pT vs track #varphi; centrality; #it{p}_{T,track} (GeV/#it{c}); #varphi_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_centrality_track_pt_track_eta", "centrality vs track pT vs track #eta; centrality; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {500, -5.0, 5.0}}}); + registry.add("h3_track_pt_track_eta_track_phi", "track pT vs track #eta vs track #varphi; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}; #varphi_{track}", {HistType::kTH3F, {{200, 0., 200.}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); if (doprocessTracksWeighted) { registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); } } if (doprocessTracksSub) { - - registry.add("h2_centrality_track_pt_eventwiseconstituentsubtracted", "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_eventwiseconstituentsubtracted", "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_eventwiseconstituentsubtracted", "centrality vs track #varphi; centrality; #varphi_{track}", {HistType::kTH2F, {{1200, -10.0, 110.0}, {160, -1.0, 7.}}}); - registry.add("h2_centrality_track_energy_eventwiseconstituentsubtracted", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, 0.0, 100.0}}}); + registry.add("h3_centrality_track_pt_track_phi_eventwiseconstituentsubtracted", "centrality vs track pT vs track #varphi; centrality; #it{p}_{T,track} (GeV/#it{c}); #varphi_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {160, -1.0, 7.}}}); + registry.add("h3_centrality_track_pt_track_eta_eventwiseconstituentsubtracted", "centrality vs track pT vs track #eta; centrality; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}", {HistType::kTH3F, {{1200, -10.0, 110.0}, {200, 0., 200.}, {500, -5.0, 5.0}}}); + registry.add("h3_track_pt_track_eta_track_phi_eventwiseconstituentsubtracted", "track pT vs track #eta vs track #varphi; #it{p}_{T,track} (GeV/#it{c}); #eta_{track}; #varphi_{track}", {HistType::kTH3F, {{200, 0., 200.}, {500, -5.0, 5.0}, {160, -1.0, 7.}}}); } if (doprocessMCCollisionsWeighted) { @@ -431,7 +459,7 @@ struct JetFinderHFQATask { if (doprocessCandidates) { registry.add("h_candidate_invmass", ";#it{m}_{inv, candidate} (GeV/#it{c}^{2});counts", {HistType::kTH1F, {{500, 0.0, 5.0}}}); registry.add("h_candidate_pt", ";#it{p}_{T,candidate} (GeV/#it{c});counts", {HistType::kTH1F, {{200, 0.0, 200.0}}}); - registry.add("h_candidate_y", ";y_{candidate};counts", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + registry.add("h_candidate_y", ";y_{candidate};counts", {HistType::kTH1F, {{500, -5.0, 5.0}}}); registry.add("h2_centrality_ncandidates", "centrality vs N_{candidates};centrality;N_{candidates};", {HistType::kTH2F, {{1200, -10.0, 110.0}, {100, 0.0, 100.0}}}); } } @@ -464,11 +492,6 @@ struct JetFinderHFQATask { PresliceOptional> perBplusCandidateTracks = aod::bkgbplus::candidateId; PresliceOptional> perDielectronCandidateTracks = aod::bkgdielectron::candidateId; - PresliceOptional perD0CandidateRhos = aod::bkgd0::candidateId; - PresliceOptional perLcCandidateRhos = aod::bkglc::candidateId; - PresliceOptional perBplusCandidateRhos = aod::bkgbplus::candidateId; - PresliceOptional perDielectronCandidateRhos = aod::bkgdielectron::candidateId; - template bool isAcceptedJet(V const& jet) { @@ -527,7 +550,7 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_ntracks"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size() + jet.candidatesIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_area"), jet.r() / 100.0, jet.pt(), jet.area(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); @@ -577,7 +600,7 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_area_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), jet.area(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_pt_rhoareasubtracted"), jet.r() / 100.0, jet.pt(), jet.pt() - (rho * jet.area()), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_rhoareasubtracted"), jet.r() / 100.0, jet.pt() - (rho * jet.area()), constituent.eta(), weight); @@ -911,25 +934,78 @@ struct JetFinderHFQATask { 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("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_track_pt_track_eta_track_phi"), track.pt(), track.eta(), track.phi(), weight); + } + } + + template + void randomCone(T const& collision, U const& jets, V const& candidates, M const& tracks) + { + + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return; + } + for (auto const& candidate : candidates) { + TRandom3 randomNumber(0); + float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); + float randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); + float randomConePt = 0; + 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("h2_centrality_rhorandomcone"), collision.centrality(), 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 + 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; + 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("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), 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 } } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetFinderHFQATask, processDummy, "dummy task", true); - void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, JetTracks const&) + void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -937,27 +1013,43 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsData, "jet finder HF QA data", false); - void processJetsRhoAreaSubData(soa::Filtered::iterator const& collision, - BkgRhoTable const& bkgRhos, + void processJetsRhoAreaSubData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, - CandidateTableData const&, - JetTracks const&) + soa::Join const&, + aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } - auto const jetCandidate = jet.template candidates_first_as(); - auto bkgRho = jetcandidateutilities::slicedPerCandidate(bkgRhos, jetCandidate, perD0CandidateRhos, perLcCandidateRhos, perBplusCandidateRhos, perDielectronCandidateRhos).iteratorAt(0); - fillRhoAreaSubtractedHistograms(jet, collision.centrality(), bkgRho.rho()); + auto const candidate = jet.template candidates_first_as>(); + fillRhoAreaSubtractedHistograms(jet, collision.centrality(), candidate.rho()); } } PROCESS_SWITCH(JetFinderHFQATask, processJetsRhoAreaSubData, "jet finder HF QA for rho-area subtracted jets", false); - void processEvtWiseConstSubJetsData(soa::Filtered::iterator const& collision, JetTableDataSubJoined const& jets, CandidateTableData const&, JetTracksDataSub const&) + void processJetsRhoAreaSubMCD(soa::Filtered::iterator const& collision, + JetTableMCDJoined const& jets, + soa::Join const&, + aod::JetTracks const&) + { + for (auto const& jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + auto const candidate = jet.template candidates_first_as>(); + fillRhoAreaSubtractedHistograms(jet, collision.centrality(), candidate.rho()); + } + } + PROCESS_SWITCH(JetFinderHFQATask, processJetsRhoAreaSubMCD, "jet finder HF QA for rho-area subtracted mcd jets", false); + + void processEvtWiseConstSubJetsData(soa::Filtered::iterator const& collision, JetTableDataSubJoined const& jets, CandidateTableData const&, JetTracksDataSub const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { @@ -971,16 +1063,16 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processEvtWiseConstSubJetsData, "jet finder HF QA for eventwise constituent-subtracted jets data", false); - void processJetsSubMatched(soa::Filtered::iterator const&, + void processJetsSubMatched(soa::Filtered::iterator const&, JetTableDataMatchedJoined const& jets, JetTableDataSubMatchedJoined const&, - JetTracks const&, JetTracksDataSub const&, CandidateTableData const&) + aod::JetTracks const&, JetTracksDataSub const&, CandidateTableData const&) { for (const auto& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillMatchedHistograms(jet); @@ -988,13 +1080,13 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsSubMatched, "jet finder HF QA matched unsubtracted and constituent subtracted jets", false); - void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, CandidateTableMCD const&, JetTracks const&) + void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, CandidateTableMCD const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -1002,13 +1094,13 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCD, "jet finder HF QA mcd", false); - void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, CandidateTableMCD const&, JetTracks const&) + void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, CandidateTableMCD const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality(), jet.eventWeight()); @@ -1016,35 +1108,35 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); - void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, JetParticles const&, CandidateTableMCP const&) + void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, aod::JetParticles const&, CandidateTableMCP const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } - fillMCPHistograms(jet); + fillMCPHistograms(jet); } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCP, "jet finder HF QA mcp", false); - void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, JetParticles const&, CandidateTableMCP const&) + void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, aod::JetParticles const&, CandidateTableMCP const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } - fillMCPHistograms(jet, jet.eventWeight()); + fillMCPHistograms(jet, jet.eventWeight()); } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCPWeighted, "jet finder HF QA mcp on weighted events", false); - void processJetsMCPMCDMatched(soa::Filtered::iterator const&, + void processJetsMCPMCDMatched(soa::Filtered::iterator const&, JetTableMCDMatchedJoined const& mcdjets, JetTableMCPMatchedJoined const&, CandidateTableMCD const&, - JetTracks const&, JetParticles const&, + aod::JetTracks const&, aod::JetParticles const&, CandidateTableMCP const&) { @@ -1052,7 +1144,7 @@ struct JetFinderHFQATask { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(mcdjet)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms(mcdjet); @@ -1060,11 +1152,11 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCPMCDMatched, "jet finder HF QA matched mcp and mcd", false); - void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const&, + void processJetsMCPMCDMatchedWeighted(soa::Filtered::iterator const&, JetTableMCDMatchedWeightedJoined const& mcdjets, JetTableMCPMatchedWeightedJoined const&, CandidateTableMCD const&, - JetTracks const&, JetParticles const&, + aod::JetTracks const&, aod::JetParticles const&, CandidateTableMCP const&) { @@ -1072,7 +1164,7 @@ struct JetFinderHFQATask { if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(mcdjet)) { + if (!isAcceptedJet(mcdjet)) { continue; } fillMatchedHistograms(mcdjet, mcdjet.eventWeight()); @@ -1080,16 +1172,16 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processJetsMCPMCDMatchedWeighted, "jet finder HF QA matched mcp and mcd on weighted events", false); - void processMCCollisionsWeighted(JetMcCollision const& collision) + void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderHFQATask, processMCCollisionsWeighted, "collision QA for weighted events", false); - void processTriggeredData(soa::Join::iterator const& collision, + void processTriggeredData(soa::Join::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, - soa::Filtered const& tracks) + soa::Filtered const& tracks) { registry.fill(HIST("h_collision_trigger_events"), 0.5); // all events if (collision.posZ() > vertexZCut) { @@ -1100,13 +1192,13 @@ struct JetFinderHFQATask { return; } registry.fill(HIST("h_collision_trigger_events"), 2.5); // events with sel8() - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h_collision_trigger_events"), 3.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_collision_trigger_events"), 4.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_collision_trigger_events"), 5.5); // events with high pT triggered jets } @@ -1118,19 +1210,19 @@ struct JetFinderHFQATask { for (auto& jet : jets) { for (std::size_t iJetRadius = 0; iJetRadius < jetRadiiValues.size(); iJetRadius++) { if (jet.r() == round(jetRadiiValues[iJetRadius] * 100.0f)) { - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && !filledJetR_Low[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && !filledJetR_Low[iJetRadius]) { filledJetR_Low[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_Low"), jet.r() / 100.0, pt); } } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh) && !filledJetR_High[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt) && !filledJetR_High[iJetRadius]) { filledJetR_High[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_High"), jet.r() / 100.0, pt); } } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh) && !filledJetR_Both[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt) && !filledJetR_Both[iJetRadius]) { filledJetR_Both[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_Both"), jet.r() / 100.0, pt); @@ -1147,38 +1239,38 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 0.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 0.0); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 1.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 1.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 1.0); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 2.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 2.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 2.0); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 3.0); registry.fill(HIST("h3_jet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 3.0); registry.fill(HIST("h3_jet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 3.0); } - for (auto& constituent : jet.template tracks_as>()) { + for (auto& constituent : jet.template tracks_as>()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_MB"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_MB"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_MB"), jet.r() / 100.0, jet.pt(), constituent.phi()); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_Low"), jet.r() / 100.0, jet.pt(), constituent.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_High"), jet.r() / 100.0, jet.pt(), constituent.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.pt()); registry.fill(HIST("h3_jet_r_jet_pt_track_eta_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.eta()); registry.fill(HIST("h3_jet_r_jet_pt_track_phi_Triggered_Both"), jet.r() / 100.0, jet.pt(), constituent.phi()); @@ -1191,19 +1283,19 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_MB"), jet.r() / 100.0, jet.pt(), candidate.phi()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_MB"), jet.r() / 100.0, jet.pt(), candidate.y()); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered_Low"), jet.r() / 100.0, jet.pt(), candidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered_Low"), jet.r() / 100.0, jet.pt(), candidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_Triggered_Low"), jet.r() / 100.0, jet.pt(), candidate.phi()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered_Low"), jet.r() / 100.0, jet.pt(), candidate.y()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered_High"), jet.r() / 100.0, jet.pt(), candidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered_High"), jet.r() / 100.0, jet.pt(), candidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_Triggered_High"), jet.r() / 100.0, jet.pt(), candidate.phi()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_Triggered_High"), jet.r() / 100.0, jet.pt(), candidate.y()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_Triggered_Both"), jet.r() / 100.0, jet.pt(), candidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_Triggered_Both"), jet.r() / 100.0, jet.pt(), candidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_Triggered_Both"), jet.r() / 100.0, jet.pt(), candidate.phi()); @@ -1220,17 +1312,17 @@ struct JetFinderHFQATask { registry.fill(HIST("h_track_eta_MB"), track.eta()); registry.fill(HIST("h_track_phi_MB"), track.phi()); - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt)) { registry.fill(HIST("h_track_pt_Triggered_Low"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_Low"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_Low"), track.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_track_pt_Triggered_High"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_High"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_High"), track.phi()); } - if (jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedLow) && jetderiveddatautilities::selectChargedTrigger(collision, jetderiveddatautilities::JTrigSelCh::chargedHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetChHighPt)) { registry.fill(HIST("h_track_pt_Triggered_Both"), track.pt()); registry.fill(HIST("h_track_eta_Triggered_Both"), track.eta()); registry.fill(HIST("h_track_phi_Triggered_Both"), track.phi()); @@ -1240,21 +1332,21 @@ struct JetFinderHFQATask { PROCESS_SWITCH(JetFinderHFQATask, processTriggeredData, "QA for charged jet trigger", false); - void processHFTriggeredData(soa::Join::iterator const& collision, + void processHFTriggeredData(soa::Join::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, - soa::Filtered const&) + soa::Filtered const&) { int hfLowTrigger = -2; int hfHighTrigger = -2; if constexpr (jethfutilities::isD0Table()) { - hfLowTrigger = jetderiveddatautilities::JTrigSelChHF::chargedD0Low; - hfHighTrigger = jetderiveddatautilities::JTrigSelChHF::chargedD0High; + hfLowTrigger = jetderiveddatautilities::JTrigSel::JetD0ChLowPt; + hfHighTrigger = jetderiveddatautilities::JTrigSel::JetD0ChHighPt; } if constexpr (jethfutilities::isLcTable()) { - hfLowTrigger = jetderiveddatautilities::JTrigSelChHF::chargedLcLow; - hfHighTrigger = jetderiveddatautilities::JTrigSelChHF::chargedLcHigh; + hfLowTrigger = jetderiveddatautilities::JTrigSel::JetLcChLowPt; + hfHighTrigger = jetderiveddatautilities::JTrigSel::JetLcChHighPt; } registry.fill(HIST("h_collision_hftrigger_events"), 0.5); // all events @@ -1266,28 +1358,28 @@ struct JetFinderHFQATask { return; } registry.fill(HIST("h_collision_hftrigger_events"), 2.5); // events with sel8() - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0Low)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChLowPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 3.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0High)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChHighPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 4.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0Low) && jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0High)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChHighPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 5.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChLowPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 6.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChHighPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 7.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcLow) && jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChHighPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 8.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0Low) && jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcLow)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChLowPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChLowPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 9.5); // events with high pT triggered jets } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedD0High) && jetderiveddatautilities::selectChargedHFTrigger(collision, jetderiveddatautilities::JTrigSelChHF::chargedLcHigh)) { + if (jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetD0ChHighPt) && jetderiveddatautilities::selectTrigger(collision, jetderiveddatautilities::JTrigSel::JetLcChHighPt)) { registry.fill(HIST("h_collision_hftrigger_events"), 10.5); // events with high pT triggered jets } @@ -1299,13 +1391,13 @@ struct JetFinderHFQATask { for (auto& jet : jets) { for (std::size_t iJetRadius = 0; iJetRadius < jetRadiiValues.size(); iJetRadius++) { if (jet.r() == round(jetRadiiValues[iJetRadius] * 100.0f)) { - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfLowTrigger) && !filledJetHFR_Low[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, hfLowTrigger) && !filledJetHFR_Low[iJetRadius]) { filledJetHFR_Low[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_HFlow"), jet.r() / 100.0, pt); } } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfHighTrigger) && !filledJetHFR_High[iJetRadius]) { + if (jetderiveddatautilities::selectTrigger(collision, hfHighTrigger) && !filledJetHFR_High[iJetRadius]) { filledJetHFR_High[iJetRadius] = true; for (double pt = 0.0; pt <= jet.pt(); pt += 1.0) { registry.fill(HIST("h2_jet_r_jet_pT_triggered_HFhigh"), jet.r() / 100.0, pt); @@ -1328,17 +1420,17 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_hfjet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 0.0); registry.fill(HIST("h3_hfjet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 0.0); - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfLowTrigger)) { + if (jetderiveddatautilities::selectTrigger(collision, hfLowTrigger)) { registry.fill(HIST("h3_hfjet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 1.0); registry.fill(HIST("h3_hfjet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 1.0); registry.fill(HIST("h3_hfjet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 1.0); } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfHighTrigger)) { + if (jetderiveddatautilities::selectTrigger(collision, hfHighTrigger)) { registry.fill(HIST("h3_hfjet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 2.0); registry.fill(HIST("h3_hfjet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 2.0); registry.fill(HIST("h3_hfjet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 2.0); } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfLowTrigger) && jetderiveddatautilities::selectChargedHFTrigger(collision, hfHighTrigger)) { + if (jetderiveddatautilities::selectTrigger(collision, hfLowTrigger) && jetderiveddatautilities::selectTrigger(collision, hfHighTrigger)) { registry.fill(HIST("h3_hfjet_r_jet_pt_collision"), jet.r() / 100.0, jet.pt(), 3.0); registry.fill(HIST("h3_hfjet_r_jet_eta_collision"), jet.r() / 100.0, jet.eta(), 3.0); registry.fill(HIST("h3_hfjet_r_jet_phi_collision"), jet.r() / 100.0, jet.phi(), 3.0); @@ -1351,13 +1443,13 @@ struct JetFinderHFQATask { registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_all"), jet.r() / 100.0, jet.pt(), candidate.phi()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_all"), jet.r() / 100.0, jet.pt(), candidate.y()); - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfLowTrigger)) { + if (jetderiveddatautilities::selectTrigger(collision, hfLowTrigger)) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_triggered_HFlow"), jet.r() / 100.0, jet.pt(), candidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_triggered_HFlow"), jet.r() / 100.0, jet.pt(), candidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_triggered_HFlow"), jet.r() / 100.0, jet.pt(), candidate.phi()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_y_triggered_HFlow"), jet.r() / 100.0, jet.pt(), candidate.y()); } - if (jetderiveddatautilities::selectChargedHFTrigger(collision, hfHighTrigger)) { + if (jetderiveddatautilities::selectTrigger(collision, hfHighTrigger)) { registry.fill(HIST("h3_jet_r_jet_pt_candidate_pt_triggered_HFhigh"), jet.r() / 100.0, jet.pt(), candidate.pt()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_eta_triggered_HFhigh"), jet.r() / 100.0, jet.pt(), candidate.eta()); registry.fill(HIST("h3_jet_r_jet_pt_candidate_phi_triggered_HFhigh"), jet.r() / 100.0, jet.pt(), candidate.phi()); @@ -1369,8 +1461,8 @@ struct JetFinderHFQATask { PROCESS_SWITCH(JetFinderHFQATask, processHFTriggeredData, "QA for charged hf jet trigger", false); - void processTracks(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks) + void processTracks(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) { registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); @@ -1383,9 +1475,9 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processTracks, "QA for charged tracks", false); - void processTracksWeighted(soa::Join::iterator const& collision, - JetMcCollisions const&, - soa::Filtered const& tracks) + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JetMcCollisions const&, + soa::Filtered const& tracks) { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); @@ -1399,7 +1491,7 @@ struct JetFinderHFQATask { } PROCESS_SWITCH(JetFinderHFQATask, processTracksWeighted, "QA for charged tracks weighted", false); - void processTracksSub(soa::Filtered::iterator const& collision, + void processTracksSub(soa::Filtered::iterator const& collision, CandidateTableData const& candidates, soa::Filtered const& tracks) { @@ -1409,23 +1501,21 @@ struct JetFinderHFQATask { for (auto const& candidate : candidates) { for (auto const& track : jetcandidateutilities::slicedPerCandidate(tracks, candidate, perD0CandidateTracks, perLcCandidateTracks, perBplusCandidateTracks, perDielectronCandidateTracks)) { - registry.fill(HIST("h2_centrality_track_pt_eventwiseconstituentsubtracted"), collision.centrality(), track.pt()); - registry.fill(HIST("h2_centrality_track_eta_eventwiseconstituentsubtracted"), collision.centrality(), track.eta()); - registry.fill(HIST("h2_centrality_track_phi_eventwiseconstituentsubtracted"), collision.centrality(), track.phi()); - registry.fill(HIST("h2_centrality_track_energy_eventwiseconstituentsubtracted"), collision.centrality(), track.energy()); + 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_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) } } PROCESS_SWITCH(JetFinderHFQATask, processTracksSub, "QA for charged event-wise embedded subtracted tracks", false); - void processRho(JetCollision const& collision, CandidateTableData const& candidates, BkgRhoTable const& bkgRhos, soa::Filtered const& tracks) + void processRho(aod::JetCollision const& collision, soa::Join const& candidates, soa::Filtered const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; } for (auto const& candidate : candidates) { - auto bkgRho = jetcandidateutilities::slicedPerCandidate(bkgRhos, candidate, perD0CandidateRhos, perLcCandidateRhos, perBplusCandidateRhos, perDielectronCandidateRhos).iteratorAt(0); int nTracks = 0; for (auto const& track : tracks) { if (jetderiveddatautilities::selectTrack(track, trackSelection)) { @@ -1433,70 +1523,28 @@ struct JetFinderHFQATask { } } registry.fill(HIST("h2_centrality_ntracks"), collision.centrality(), nTracks); - registry.fill(HIST("h2_ntracks_rho"), nTracks, bkgRho.rho()); - registry.fill(HIST("h2_ntracks_rhom"), nTracks, bkgRho.rhoM()); - registry.fill(HIST("h2_centrality_rho"), collision.centrality(), bkgRho.rho()); - registry.fill(HIST("h2_centrality_rhom"), collision.centrality(), bkgRho.rhoM()); + 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()); break; // currently only fills it for the first candidate in the event (not pT ordered) } } PROCESS_SWITCH(JetFinderHFQATask, processRho, "QA for rho-area subtracted jets", false); - void processRandomCone(soa::Filtered::iterator const& collision, JetTableDataSubJoined const& jets, CandidateTableData const& candidates, BkgRhoTable const& bkgRhos, soa::Filtered const& tracks) + void processRandomConeData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, soa::Join const& candidates, soa::Filtered const& tracks) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { - return; - } - for (auto const& candidate : candidates) { - auto bkgRho = jetcandidateutilities::slicedPerCandidate(bkgRhos, candidate, perD0CandidateRhos, perLcCandidateRhos, perBplusCandidateRhos, perDielectronCandidateRhos).iteratorAt(0); - TRandom3 randomNumber(0); - float randomConeEta = randomNumber.Uniform(trackEtaMin + randomConeR, trackEtaMax - randomConeR); - float randomConePhi = randomNumber.Uniform(0.0, 2 * M_PI); - float randomConePt = 0; - 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("h2_centrality_rhorandomcone"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * bkgRho.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 - float dPhiLeadingJet = RecoDecay::constrainAngle(jets.iteratorAt(0).phi() - randomConePhi, static_cast(-M_PI)); - float dEtaLeadingJet = jets.iteratorAt(0).eta() - randomConeEta; + randomCone(collision, jets, candidates, tracks); + } + PROCESS_SWITCH(JetFinderHFQATask, processRandomConeData, "QA for random cone estimation of background fluctuations in data", false); - 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; - 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("h2_centrality_rhorandomconewithoutleadingjet"), collision.centrality(), randomConePt - M_PI * randomConeR * randomConeR * bkgRho.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 - } + void processRandomConeMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, soa::Join const& candidates, soa::Filtered const& tracks) + { + randomCone(collision, jets, candidates, tracks); } - PROCESS_SWITCH(JetFinderHFQATask, processRandomCone, "QA for random cone estimation of background fluctuations", false); + PROCESS_SWITCH(JetFinderHFQATask, processRandomConeMCD, "QA for random cone estimation of background fluctuations in mcd", false); - void processCandidates(soa::Filtered::iterator const& collision, CandidateTableData const& candidates) + void processCandidates(soa::Filtered::iterator const& collision, CandidateTableData const& candidates) { for (auto const& candidate : candidates) { @@ -1509,10 +1557,10 @@ struct JetFinderHFQATask { PROCESS_SWITCH(JetFinderHFQATask, processCandidates, "HF candidate QA", false); }; -using JetFinderD0QATask = JetFinderHFQATask; -using JetFinderLcQATask = JetFinderHFQATask; -// using JetFinderBplusQATask = JetFinderHFQATask; -using JetFinderDielectronQATask = JetFinderHFQATask; +using JetFinderD0QATask = JetFinderHFQATask; +using JetFinderLcQATask = JetFinderHFQATask; +// using JetFinderBplusQATask = JetFinderHFQATask; +using JetFinderDielectronQATask = JetFinderHFQATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetfinderv0QA.cxx b/PWGJE/Tasks/jetfinderv0QA.cxx index 8f0152db0ee..b901db5d61d 100644 --- a/PWGJE/Tasks/jetfinderv0QA.cxx +++ b/PWGJE/Tasks/jetfinderv0QA.cxx @@ -224,7 +224,7 @@ struct JetFinderV0QATask { registry.fill(HIST("h3_jet_r_jet_pt_jet_ntracks"), jet.r() / 100.0, jet.pt(), jet.tracksIds().size() + jet.candidatesIds().size(), weight); registry.fill(HIST("h3_jet_r_jet_pt_jet_area"), jet.r() / 100.0, jet.pt(), jet.area(), weight); - for (auto& constituent : jet.template tracks_as()) { + for (auto& constituent : jet.template tracks_as()) { registry.fill(HIST("h3_jet_r_jet_pt_track_pt"), jet.r() / 100.0, jet.pt(), constituent.pt(), weight); registry.fill(HIST("h3_jet_r_jet_pt_track_eta"), jet.r() / 100.0, jet.pt(), constituent.eta(), weight); @@ -305,18 +305,18 @@ struct JetFinderV0QATask { } } - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(JetFinderV0QATask, processDummy, "dummy task", true); - void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, JetTracks const&) + void processJetsData(soa::Filtered::iterator const& collision, JetTableDataJoined const& jets, CandidateTableData const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -324,13 +324,13 @@ struct JetFinderV0QATask { } PROCESS_SWITCH(JetFinderV0QATask, processJetsData, "jet finder HF QA data", false); - void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, CandidateTableMCD const&, JetTracks const&) + void processJetsMCD(soa::Filtered::iterator const& collision, JetTableMCDJoined const& jets, CandidateTableMCD const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality()); @@ -338,13 +338,13 @@ struct JetFinderV0QATask { } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCD, "jet finder HF QA mcd", false); - void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, CandidateTableMCD const&, JetTracks const&) + void processJetsMCDWeighted(soa::Filtered::iterator const& collision, JetTableMCDWeightedJoined const& jets, CandidateTableMCD const&, aod::JetTracks const&) { for (auto const& jet : jets) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { continue; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { continue; } fillHistograms(jet, collision.centrality(), jet.eventWeight()); @@ -352,38 +352,38 @@ struct JetFinderV0QATask { } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCDWeighted, "jet finder HF QA mcd on weighted events", false); - void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, JetParticles const&, CandidateTableMCP const&) + void processJetsMCP(typename JetTableMCPJoined::iterator const& jet, aod::JetParticles const&, CandidateTableMCP const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } - fillMCPHistograms(jet); + fillMCPHistograms(jet); } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCP, "jet finder HF QA mcp", false); - void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, JetParticles const&, CandidateTableMCP const&) + void processJetsMCPWeighted(typename JetTableMCPWeightedJoined::iterator const& jet, aod::JetParticles const&, CandidateTableMCP const&) { if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { return; } - if (!isAcceptedJet(jet)) { + if (!isAcceptedJet(jet)) { return; } - fillMCPHistograms(jet, jet.eventWeight()); + fillMCPHistograms(jet, jet.eventWeight()); } PROCESS_SWITCH(JetFinderV0QATask, processJetsMCPWeighted, "jet finder HF QA mcp on weighted events", false); - void processMCCollisionsWeighted(JetMcCollision const& collision) + void processMCCollisionsWeighted(aod::JetMcCollision const& collision) { registry.fill(HIST("h_collision_eventweight_part"), collision.weight()); } PROCESS_SWITCH(JetFinderV0QATask, processMCCollisionsWeighted, "collision QA for weighted events", false); - void processTracks(soa::Filtered::iterator const& collision, - soa::Filtered const& tracks) + void processTracks(soa::Filtered::iterator const& collision, + soa::Filtered const& tracks) { registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); @@ -396,9 +396,9 @@ struct JetFinderV0QATask { } PROCESS_SWITCH(JetFinderV0QATask, processTracks, "QA for charged tracks", false); - void processTracksWeighted(soa::Join::iterator const& collision, - JetMcCollisions const&, - soa::Filtered const& tracks) + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JetMcCollisions const&, + soa::Filtered const& tracks) { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); @@ -412,7 +412,7 @@ struct JetFinderV0QATask { } PROCESS_SWITCH(JetFinderV0QATask, processTracksWeighted, "QA for charged tracks weighted", false); - void processCandidates(soa::Filtered::iterator const& collision, CandidateTableData const& candidates) + void processCandidates(soa::Filtered::iterator const& collision, CandidateTableData const& candidates) { for (auto const& candidate : candidates) { @@ -427,7 +427,7 @@ struct JetFinderV0QATask { PROCESS_SWITCH(JetFinderV0QATask, processCandidates, "HF candidate QA", false); }; -using JetFinderV0QA = JetFinderV0QATask; +using JetFinderV0QA = JetFinderV0QATask; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetfragmentation.cxx b/PWGJE/Tasks/jetfragmentation.cxx index d08a3935431..8f939d75f46 100644 --- a/PWGJE/Tasks/jetfragmentation.cxx +++ b/PWGJE/Tasks/jetfragmentation.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// jet V0 fragmentation +/// \brief Task for jet fragmentation into V0s // /// \author Gijs van Weelden // @@ -63,7 +63,7 @@ using MatchedMCPV0Jets = soa::Join; struct JetFragmentation { - HistogramRegistry registry{"registry"}; + HistogramRegistry registry{"registry"}; // CallSumw2 = false? Configurable evSel{"evSel", "sel8WithoutTimeFrameBorderCut", "choose event selection"}; Configurable vertexZCut{"vertexZCut", 10.f, "vertex z cut"}; @@ -115,6 +115,7 @@ struct JetFragmentation { ConfigurableAxis jetCount{"jetCount", {20, -.5f, 19.5f}, ""}; ConfigurableAxis trackCount{"trackCount", {1000, -.5f, 999.5f}, ""}; ConfigurableAxis v0Count{"v0Count", {50, -.5f, 49.5f}, ""}; + ConfigurableAxis v0Weight{"v0Weight", {50, 0.f, 10.0f}, ""}; ConfigurableAxis binV0Pt{"binV0Pt", {120, 0.0f, 60.0f}, ""}; ConfigurableAxis binV0Eta{"binV0Eta", {20, -1.f, 1.f}, ""}; @@ -128,6 +129,7 @@ struct JetFragmentation { ConfigurableAxis binV0DCAd{"binV0DCAd", {100, 0.0f, 10.0f}, ""}; 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 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)"}; @@ -155,7 +157,7 @@ struct JetFragmentation { Preslice V0sPerCollision = aod::v0data::collisionId; Preslice> McV0sPerCollision = aod::v0data::collisionId; Preslice PartJetsPerCollision = aod::jet::mcCollisionId; - Preslice JetParticlesPerCollision = aod::jmcparticle::mcCollisionId; + Preslice JetParticlesPerCollision = aod::jmcparticle::mcCollisionId; Preslice ParticlesPerCollision = aod::mcparticle::mcCollisionId; int eventSelection = -1; @@ -217,6 +219,7 @@ struct JetFragmentation { 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)"}; @@ -239,7 +242,7 @@ struct JetFragmentation { 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) { + if (doprocessDataRun3 || doprocessDataV0Frag || doprocessDataV0JetsFrag || doprocessDataV0JetsFragWithWeights) { registry.add("data/jets/jetPtEtaPhi", "Jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); } if (doprocessDataRun3 || doprocessDataV0Frag) { @@ -253,13 +256,17 @@ struct JetFragmentation { registry.add("data/jets/jetPtZTheta", "Jet #it{p}_{T}, z, #theta", HistType::kTH3D, {jetPtAxis, zAxis, thetaAxis}); } // doprocessDataRun3 || doprocessDataV0Frag - if (doprocessDataV0 || doprocessDataV0Frag || doprocessDataV0JetsFrag) { + if (doprocessDataV0 || doprocessDataV0Frag || doprocessDataV0JetsFrag || doprocessDataV0JetsFragWithWeights || doprocessDataV0PerpCone) { 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}); @@ -295,13 +302,14 @@ struct JetFragmentation { registry.add("data/jets/V0/jetCorrectedPtV0TrackProj", "jetCorrectedPtV0TrackProj", HistType::kTH2D, {jetPtAxis, zAxis}); } - if (doprocessDataV0Frag || doprocessDataV0JetsFrag) { + 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}); @@ -309,6 +317,7 @@ struct JetFragmentation { 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}); @@ -371,6 +380,53 @@ struct JetFragmentation { 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}); + // 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}); + // 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}); + } + if (doprocessMcP || doprocessMcMatchedV0JetsFrag) { registry.add("particle-level/jets/partJetPtEtaPhi", "Particle level jet #it{p}_{T}, #eta, #phi", HistType::kTH3D, {partJetPtAxis, partEtaAxis, partPhiAxis}); } @@ -486,8 +542,10 @@ struct JetFragmentation { registry.add("matching/jets/missPartJetPtZTheta", "Misses", HistType::kTH3D, {partJetPtAxis, partZAxis, partThetaAxis}); } // doprocessMcMatched - if (doprocessMcMatchedV0 || doprocessMcMatchedV0Frag || doprocessMcMatchedV0JetsFrag) { + if (doprocessMcMatchedV0 || doprocessMcMatchedV0Frag || doprocessMcMatchedV0JetsFrag || doprocessMcV0MatchedPerpCone) { 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) { @@ -729,14 +787,260 @@ struct JetFragmentation { } // 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}); + } // 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/nV0sConePtEta", "nV0sConePtEta", HistType::kTH3D, {v0Count, jetPtAxis, etaAxis}); + registry.add("data/PC/ConePtEtaPhi", "ConePtEtaPhi", HistType::kTH3D, {jetPtAxis, etaAxis, phiAxis}); + registry.add("data/PC/JetPtEtaConePt", "JetPtEtaConePt", HistType::kTH3D, {jetPtAxis, etaAxis, jetPtAxis}); + } // 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}); + } // 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) + { + // 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; + } + 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 + std::vector convertState(uint32_t state, int nParticles, int nClasses = 4) + { + std::vector v(nParticles, nClasses); + int nStates = pow(nClasses, nParticles); + int nBitsPerParticle = round(log2(nClasses)); + int nBitsPerInt = sizeof(uint32_t) * 8; + + // Check if the input configuration is parseable + 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; + } + if (nStates <= 0) { + LOGF(warning, "Illegal number of states (%d)! %s", nStates, (nStates == 0) ? "" : "Max = 2^31"); + return v; + } + 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) { + LOGF(warning, "Illegal state! State %d >= %d", state, nStates); + return v; + } + + for (int ip = 0; ip < nParticles; ip++) { + double value = 0; + int startBit = ip * nBitsPerParticle; + for (int ib = 0; ib < nBitsPerParticle; ib++) { + int bit = startBit + ib; + int bitVal = ((state & (1 << bit)) > 0); + value += bitVal * TMath::Power(2, ib); + } + v[ip] = value; + } + return v; + } // convertState + // Returns the corrected values for z and ptjet for a given state + std::vector correctedValues(std::vector state, std::vector values) + { + // Assumes values = (z1, z2, ..., zn, ptjet) + std::vector v(values); + double r = 0; + int nParticles = state.size(); + + if (values.size() != (uint32_t)(nParticles + 1)) { + LOGF(warning, "Number of values (%d) must be equal to the number of particles (%d) + 1!", values.size(), nParticles); + return v; + } + for (int ip = 0; ip < nParticles; ip++) { + if (state[ip] == 0) { + r += values[ip]; + } + } + for (int ip = 0; ip < nParticles; ip++) { + if (state[ip] == 0) { + v[ip] = values[ip] / (1 - r); + } + } + v[nParticles] = values[nParticles] * (1 - r); + return v; + } + double stateWeight(std::vector state, std::vector> weights) + { + double w = 1.; + for (int ip = 0; (uint32_t)ip < state.size(); ip++) { + w *= weights[ip][state[ip]]; + } + return w; + } + template bool JetContainsV0s(JetType const& jet) { @@ -745,6 +1049,8 @@ struct JetFragmentation { template 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 auto negId = v0.template negTrack_as().mcParticleId(); auto posId = v0.template posTrack_as().mcParticleId(); auto daughters = particle.daughtersIds(); @@ -877,7 +1183,7 @@ struct JetFragmentation { } // TODO: Can probably be made simpler/shorter by using V0MCLabels - template + template // Not used for V0 jets void fillMcMatchedV0Histograms(CollisionType const& collision, V0Type const& v0, trackType const&, particleType const&, double weight = 1.) { auto negTrack = v0.template negTrack_as(); @@ -899,18 +1205,18 @@ struct JetFragmentation { if (particleMotherOfNeg.isPhysicalPrimary() && particleMotherOfNeg == particleMotherOfPos) { double ptPartV0 = particleMotherOfNeg.pt(); int pdg = particleMotherOfNeg.pdgCode(); - registry.fill(HIST("matching/V0/V0PartPtDetPt"), ptPartV0, v0.pt()); - registry.fill(HIST("matching/V0/V0PartPtRatioPtRelDiffPt"), ptPartV0, v0.pt() / ptPartV0, (v0.pt() - ptPartV0) / ptPartV0); + 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 (pdg == 310) { // K0S - registry.fill(HIST("matching/V0/K0SPtEtaPhi"), ptPartV0, v0.pt(), v0.eta(), v0.phi()); + 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()); + 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); @@ -921,7 +1227,7 @@ struct JetFragmentation { 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()); + 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); @@ -933,38 +1239,42 @@ struct JetFragmentation { 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 + } // for mothers of pos + } // for mothers of neg } template - void fillDataJetHistograms(T const& jet) + void fillDataJetHistograms(T const& jet, double weight = 1.) { - registry.fill(HIST("data/jets/jetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi()); + registry.fill(HIST("data/jets/jetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); } - template - void fillDataFragHistograms(T const& jet) + void fillDataJetHistogramsWithWeights(double jetpt, double jeteta, double jetphi, double weight = 1.) { - for (const auto& track : jet.template tracks_as()) { + registry.fill(HIST("data/jets/weighted/jetPtEtaPhi"), jetpt, jeteta, jetphi, weight); + } + template // Not used for V0 jets + void fillDataFragHistograms(T const& jet, double weight = 1.) + { + 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()); - registry.fill(HIST("data/jets/jetTrackPtEtaPhi"), track.pt(), track.eta(), track.phi()); - registry.fill(HIST("data/jets/jetPtFrag"), jet.pt(), chargeFrag); - registry.fill(HIST("data/jets/jetPtTrackProj"), jet.pt(), trackProj); - registry.fill(HIST("data/jets/jetPtXi"), jet.pt(), xi); - registry.fill(HIST("data/jets/jetPtTheta"), jet.pt(), theta); - registry.fill(HIST("data/jets/jetPtXiTheta"), jet.pt(), xi, theta); - registry.fill(HIST("data/jets/jetPtZTheta"), jet.pt(), trackProj, theta); + 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); } } template - void fillDataV0Histograms(CollisionType const& collision, V0Type const& V0s) + void fillDataV0Histograms(CollisionType const& collision, V0Type const& V0s, double weight = 1.) { for (const auto& v0 : V0s) { double ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; @@ -975,44 +1285,45 @@ struct JetFragmentation { 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/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/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()); + 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()); - registry.fill(HIST("data/V0/LambdaPtCtauMass"), v0.pt(), ctauLambda, v0.mLambda()); - 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/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); } if (IsAntiLambdaCandidate(collision, v0)) { - registry.fill(HIST("data/V0/antiLambdaPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); - registry.fill(HIST("data/V0/antiLambdaPtCtauMass"), v0.pt(), ctauAntiLambda, v0.mAntiLambda()); - 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/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 (IsK0SCandidate(collision, v0)) { - registry.fill(HIST("data/V0/K0SPtEtaPhi"), v0.pt(), v0.eta(), v0.phi()); - registry.fill(HIST("data/V0/K0SPtCtauMass"), v0.pt(), ctauK0s, v0.mK0Short()); - 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/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); } } // for v0 } template - void fillDataV0FragHistograms(CollisionType const& collision, JetType const& jet, V0Type const& v0) + void fillDataV0FragHistograms(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; @@ -1023,76 +1334,133 @@ struct JetFragmentation { 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/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/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()); + 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); - 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/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/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); - 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/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/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); - 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/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/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); + } + } + template + void fillDataV0FragHistogramsWithWeights(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()) { + 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; + + switch (state[ip]) { + case 0: // Background + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjCtau"), jetpt, z, ctauK0s, ctauLambda, ctauAntiLambda, weight); + registry.fill(HIST("data/jets/weighted/V0/jetPtBkgTrackProjMass"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), weight); + 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); + break; + case 1: // K0S + 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); + break; + case 2: // Lambda + 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/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); + break; + case 3: // AntiLambda + 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/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); + 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/jetPtV0TrackProjMassWide"), jetpt, z, v0.mK0Short(), v0.mLambda(), v0.mAntiLambda(), 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); } } @@ -1116,7 +1484,7 @@ struct JetFragmentation { registry.fill(HIST("matching/jets/matchPartJetPtRelDiffPt"), partJet.pt(), (detJet.pt() - partJet.pt()) / partJet.pt(), weight); } - template + template // Not used for V0 jets void fillMatchingHistogramsConstituent(DetJet const& detJet, PartJet const& partJet, Track const& track, Particle const& particle, double weight = 1.) { double detChargeFrag = -1., detTrackProj = -1., detTheta = -1., detXi = -1.; @@ -1174,7 +1542,7 @@ struct JetFragmentation { registry.fill(HIST("matching/jets/matchDetJetPtZThetaPartJetPtZTheta"), detJet.pt(), detTrackProj, detTheta, partJet.pt(), partTrackProj, partTheta, weight); } - template + template // Not used for V0 jets void fillMatchingFakeOrMiss(Jet const& jet, Constituent const& constituent, bool isFake, double weight = 1.) { double chargeFrag = -1., trackProj = -1., theta = -1., xi = -1.; @@ -1207,7 +1575,7 @@ struct JetFragmentation { 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 (v0.pdgCode() == 310) { // K0S + 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 @@ -1303,6 +1671,174 @@ struct JetFragmentation { } } + // 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(); + + auto posMom = posPart.template mothers_first_as(); + auto negMom = negPart.template mothers_first_as(); + + bool posDecayed = false; + bool negDecayed = false; + + // 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; + } + + 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; + } + } + + // 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(); + + 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); + } + } + } + // Check if V0 was missed because daughter decayed + template + void fillMatchingV0DecayedHistograms(V const& partJet, W const& detJet, X 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(); + + auto posMom = posPart.template mothers_first_as(); + auto negMom = negPart.template mothers_first_as(); + + bool posDecayed = false; + bool negDecayed = false; + + double zv0 = TrackProj(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; + } + + 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; + } + } + + // 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(); + + 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; + } + } + + 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); + } + } + } + } + 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 void fillMatchingV0Histograms(CollisionType const& collision, V0Type const& v0, particleType const& particle, double weight = 1.) { @@ -1310,18 +1846,18 @@ struct JetFragmentation { 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; - registry.fill(HIST("matching/V0/V0PartPtDetPt"), particle.pt(), v0.pt()); - registry.fill(HIST("matching/V0/V0PartPtRatioPtRelDiffPt"), particle.pt(), v0.pt() / particle.pt(), (v0.pt() - particle.pt()) / particle.pt()); + 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 - registry.fill(HIST("matching/V0/K0SPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi()); + 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 - registry.fill(HIST("matching/V0/LambdaPtEtaPhi"), particle.pt(), v0.pt(), v0.eta(), v0.phi()); + 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); registry.fill(HIST("matching/V0/LambdaPtDCAposneg"), particle.pt(), v0.pt(), v0.dcapostopv(), v0.dcanegtopv(), weight); @@ -1332,7 +1868,7 @@ struct JetFragmentation { 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()); + 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); @@ -1344,9 +1880,9 @@ struct JetFragmentation { registry.fill(HIST("matching/V0/antiLambda0Reflection"), 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& /*particle*/, double weight = 1.) + void fillMatchingV0DauHistograms(V0Type const& v0, ParticleType const& /* pv0 */, double weight = 1.) { auto negTrack = v0.template negTrack_as(); auto posTrack = v0.template posTrack_as(); @@ -1355,6 +1891,7 @@ struct JetFragmentation { 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); } + // 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.) { @@ -1362,10 +1899,10 @@ struct JetFragmentation { 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(), posTrack.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(), negTrack.pt(), negTrack.pt() / negPart.pt(), (negTrack.pt() - negPart.pt()) / negPart.pt(), weight); + 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); } - + // Reconstructed signal for in-jet V0s template void fillMatchingV0FragHistograms(CollisionType const& collision, DetJetType const& detJet, PartJetType const& partJet, V0Type const& v0, ParticleType const& particle, double weight = 1.) { @@ -1403,7 +1940,7 @@ struct JetFragmentation { 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 (particle.pdgCode() == 310) { // K0S + if (TMath::Abs(particle.pdgCode()) == 310) { // K0S registry.fill(HIST("matching/jets/V0/matchDetJetPtK0STrackProjPartJetPtK0STrackProj"), detJet.pt(), detTrackProj, partJet.pt(), partTrackProj, weight); registry.fill(HIST("matching/jets/V0/partJetPtK0SPtDetJetPtK0SPt"), partJet.pt(), particle.pt(), detJet.pt(), v0.pt(), weight); @@ -1502,10 +2039,10 @@ struct JetFragmentation { { registry.fill(HIST("detector-level/jets/detJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); } - template + template // Not used for V0 jets void fillMCDFragHistograms(Jet const& jet, double weight = 1.) { - for (const auto& track : jet.template tracks_as()) { + 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); @@ -1528,10 +2065,10 @@ struct JetFragmentation { { registry.fill(HIST("particle-level/jets/partJetPtEtaPhi"), jet.pt(), jet.eta(), jet.phi(), weight); } - template + template // Not used for V0 jets void fillMCPFragHistograms(Jet const& jet, double weight = 1.) { - for (const auto& track : jet.template tracks_as()) { + 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); @@ -1549,13 +2086,236 @@ struct JetFragmentation { } } - void processDummy(JetTracks const&) {} + template + void fillDataPerpConeHists(T const& coll, U const& jet, V const& v0s, 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; + } + + 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); + } + } + // 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); + } + } + + // Version for MCD jets + template + void fillMcPerpConeHists(T const& coll, U const& mcdjet, V const& v0s, W const& /* V0 particles */, 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("mcd/PC/jetPtEtaFakeV0Pt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + + 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); + + 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); + + 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); + + 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); + } + } + // 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.) + { + 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); + + 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/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); + } + } + + void processDummy(aod::JetTracks const&) {} PROCESS_SWITCH(JetFragmentation, processDummy, "Dummy process function turned on by default", true); - void processMcD(soa::Filtered::iterator const& collision, - JetMcCollisions const&, + void processMcD(soa::Filtered::iterator const& collision, + aod::JetMcCollisions const&, MCDJetsWithConstituents const&, - JetTracks const& tracks) + aod::JetTracks const& tracks) { if (!collision.has_mcCollision()) { return; @@ -1580,9 +2340,9 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processMcD, "Monte Carlo detector level", false); - void processMcP(JetMcCollision const& mcCollision, + void processMcP(aod::JetMcCollision const& mcCollision, MCPJetsWithConstituents const& jets, - JetParticles const& particles) + aod::JetParticles const& particles) { double nJets = 0, nTracks = 0; double weight = mcCollision.weight(); @@ -1601,9 +2361,9 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processMcP, "Monte Carlo particle level", false); - void processDataRun3(soa::Filtered::iterator const& collision, + void processDataRun3(soa::Filtered::iterator const& collision, ChargedJetsWithConstituents const& jets, - JetTracks const& tracks) + aod::JetTracks const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -1628,12 +2388,12 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processDataRun3, "Run 3 Data", false); - void processMcMatched(soa::Filtered::iterator const& collision, + void processMcMatched(soa::Filtered::iterator const& collision, MatchedMCDJetsWithConstituents const&, - JetTracksMCD const&, - JetMcCollisions const&, + aod::JetTracksMCD const&, + aod::JetMcCollisions const&, MatchedMCPJetsWithConstituents const& allMcPartJets, - JetParticles const&) + aod::JetParticles const&) { if (!collision.has_mcCollision()) { return; @@ -1648,52 +2408,52 @@ struct JetFragmentation { for (auto& partJet : detJet.template matchedJetGeo_as()) { fillMatchingHistogramsJet(detJet, partJet, weight); - for (const auto& track : detJet.tracks_as()) { + 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()) { + 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 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 + } // for detJet tracks } 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()) { + for (const auto& track : detJet.tracks_as()) { fillMatchingFakeOrMiss(detJet, track, isFake, weight); } } // if detJet does not have a match - } // for det jet + } // 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()) { + 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()) { + for (const auto& particle : partJet.tracks_as()) { bool isParticleMatched = false; - for (const auto& track : detJet.tracks_as()) { + for (const auto& track : detJet.tracks_as()) { if (!track.has_mcParticle()) { continue; } - if (particle.globalIndex() == track.template mcParticle_as().globalIndex()) { + if (particle.globalIndex() == track.template mcParticle_as().globalIndex()) { isParticleMatched = true; } } @@ -1703,15 +2463,15 @@ struct JetFragmentation { fillMatchingFakeOrMiss(partJet, particle, isFake, weight); } } // for particle - } // for matched det jet + } // 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()) { + for (const auto& particle : partJet.tracks_as()) { fillMatchingFakeOrMiss(partJet, particle, isFake, weight); } } // if no matched jet - } // for part jet + } // for part jet } PROCESS_SWITCH(JetFragmentation, processMcMatched, "Monte Carlo particle and detector level", false); @@ -1738,13 +2498,13 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processMcMatchedV0, "Monte Carlo V0", false); - void processMcMatchedV0Frag(soa::Filtered>::iterator const& jcoll, + void processMcMatchedV0Frag(soa::Filtered>::iterator const& jcoll, MatchedMCDJetsWithConstituents const&, - JetTracksMCD const&, + aod::JetTracksMCD const&, soa::Join const& allV0s, - JetMcCollisions const&, + aod::JetMcCollisions const&, MatchedMCPJetsWithConstituents const& allMcPartJets, - JetParticles const&, + aod::JetParticles const&, aod::McCollisions const&, aod::McParticles const& allMcParticles, aod::Collisions const&) @@ -1756,7 +2516,7 @@ struct JetFragmentation { return; } double weight = jcoll.mcCollision().weight(); - // This is necessary, because jets are linked to JetCollisions, but V0s are linked to Collisions + // 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()); @@ -1768,6 +2528,7 @@ struct JetFragmentation { 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]; @@ -1829,8 +2590,8 @@ struct JetFragmentation { isV0Used[iv0] = true; fillMatchingV0Fake(collision, detJet, v0, weight); } // v0 loop - } // if no matched jet - } // det jet loop + } // if no matched jet + } // det jet loop for (const auto& partJet : mcPartJets) { int iparticle = -1; for (const auto& particle : mcParticles) { @@ -1877,13 +2638,13 @@ struct JetFragmentation { } } } // v0 loop - } // detJet loop + } // detJet loop if (!isParticleUsed[iparticle]) { isParticleUsed[iparticle] = true; fillMatchingV0Miss(partJet, particle, weight); } } // particle loop - } // part jet loop + } // part jet loop } PROCESS_SWITCH(JetFragmentation, processMcMatchedV0Frag, "Monte Carlo V0 fragmentation", false); @@ -1898,16 +2659,16 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processDataV0, "Data V0", false); - void processDataV0Frag(soa::Filtered>::iterator const& jcoll, + void processDataV0Frag(soa::Filtered>::iterator const& jcoll, ChargedJetsWithConstituents const& jets, - JetTracks const&, + aod::JetTracks const&, aod::Collisions const&, aod::V0Datas const& allV0s) { if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { return; } - // This is necessary, because jets are linked to JetCollisions, but V0s are linked to Collisions + // 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()); @@ -1978,8 +2739,10 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processDataV0Frag, "Data V0 fragmentation", false); + // + // // ---------------- V0 jets ---------------- - void processDataV0JetsFrag(soa::Filtered::iterator const& jcoll, soa::Join const& v0jets, CandidatesV0Data const& v0s) + void processDataV0JetsFrag(soa::Filtered::iterator const& jcoll, soa::Join const& v0jets, aod::CandidatesV0Data const& v0s) { if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { return; @@ -1998,7 +2761,7 @@ struct JetFragmentation { fillDataJetHistograms(jet); int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; - for (const auto& v0 : jet.candidates_as()) { + for (const auto& v0 : jet.candidates_as()) { nV0inJet++; fillDataV0FragHistograms(jcoll, jet, v0); if (IsK0SCandidate(jcoll, v0)) { @@ -2016,7 +2779,74 @@ struct JetFragmentation { } PROCESS_SWITCH(JetFragmentation, processDataV0JetsFrag, "Data V0 jets fragmentation", false); - void processMcMatchedV0JetsFrag(soa::Filtered::iterator const& jcoll, JetMcCollisions const&, MatchedMCDV0JetsWithConstituents const& v0jetsMCD, MatchedMCPV0JetsWithConstituents const& v0jetsMCP, soa::Join const& v0s, CandidatesV0MCP const& pv0s, JetTracksMCD const& jTracks, JetParticles const&) + 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); + + 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); + + 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()); + + int nStates = TMath::Power(nClasses, nParticles); + for (int M = 0; M < nStates; M++) { + std::vector state = convertState(M, nParticles, nClasses); + std::vector 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); + } + // TODO: Fill nV0 hist + // TODO: Fill weighted nV0 hist? + } + } + PROCESS_SWITCH(JetFragmentation, processDataV0JetsFragWithWeights, "Data V0 jets fragmentation with weights", false); + + void processDataV0PerpCone(soa::Filtered::iterator const& jcoll, aod::V0ChargedJets const& v0jets, aod::CandidatesV0Data const& v0s) + { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + return; + } + if (v0s.size() == 0) { + 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; + } + fillDataPerpConeHists(jcoll, jet, v0s); + } + } + 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&) { if (!jcoll.has_mcCollision()) { return; @@ -2026,13 +2856,19 @@ struct JetFragmentation { } 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 for (const auto& v0 : v0s) { + if (!v0.has_mcParticle()) { + fillMatchingV0FakeHistograms(jcoll, v0, weight); + fillMatchingFakeV0DauHistograms(v0, weight); + continue; + } for (const auto& pv0 : pv0s) { if (V0sAreMatched(v0, pv0, jTracks)) { fillMatchingV0Histograms(jcoll, v0, pv0, weight); - fillMatchingV0DauHistograms(v0, pv0, weight); + fillMatchingV0DauHistograms(v0, pv0, weight); } } } @@ -2049,7 +2885,7 @@ struct JetFragmentation { int nV0inJet = 0, nLambdainJet = 0, nAntiLambdainJet = 0, nK0SinJet = 0; if (!detJet.has_matchedJetGeo()) { - for (const auto& detV0 : detJet.candidates_as>()) { + for (const auto& detV0 : detJet.candidates_as>()) { fillMatchingV0Fake(jcoll, detJet, detV0, weight); } continue; @@ -2057,18 +2893,19 @@ struct JetFragmentation { 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); continue; } bool isV0Matched = false; - for (const auto& partV0 : partJet.template candidates_as()) { + for (const auto& partV0 : partJet.template candidates_as()) { if (V0sAreMatched(detV0, partV0, jTracks)) { isV0Matched = true; nV0inJet++; fillMatchingV0FragHistograms(jcoll, detJet, partJet, detV0, partV0, weight); - fillMatchingV0DauJetHistograms(detJet, partJet, detV0, partV0, weight); + fillMatchingV0DauJetHistograms(detJet, partJet, detV0, partV0, weight); if (TMath::Abs(partV0.pdgCode()) == 310) { nK0SinJet++; @@ -2079,7 +2916,7 @@ struct JetFragmentation { } break; } // if matched - } // partV0 loop + } // partV0 loop if (!isV0Matched) { fillMatchingV0Fake(jcoll, detJet, detV0, weight); @@ -2087,7 +2924,7 @@ struct JetFragmentation { } // detV0 loop registry.fill(HIST("matching/jets/V0/jetPtnV0MatchednK0SnLambdanAntiLambda"), partJet.pt(), nV0inJet, nK0SinJet, nLambdainJet, nAntiLambdainJet, weight); } // Matched partJet loop - } // detJet loop + } // detJet loop for (const auto& partJet : v0jetsMCP) { if (!JetContainsV0s(partJet)) { @@ -2096,7 +2933,7 @@ struct JetFragmentation { fillMCPJetHistograms(partJet, weight); if (!partJet.has_matchedJetGeo()) { - for (const auto& partV0 : partJet.candidates_as()) { + for (const auto& partV0 : partJet.candidates_as()) { fillMatchingV0Miss(partJet, partV0, weight); } continue; @@ -2108,9 +2945,9 @@ struct JetFragmentation { continue; } isJetMatched = true; - for (const auto& partV0 : partJet.candidates_as()) { + for (const auto& partV0 : partJet.candidates_as()) { bool isV0Matched = false; - for (const auto& detV0 : detJet.candidates_as>()) { + for (const auto& detV0 : detJet.candidates_as>()) { if (V0sAreMatched(detV0, partV0, jTracks)) { isV0Matched = true; break; @@ -2120,17 +2957,62 @@ struct JetFragmentation { fillMatchingV0Miss(partJet, partV0, weight); } } // partV0 loop - } // detJet loop + } // detJet loop // To account for matched jets where the detector level jet is outside of the eta range (cut applied within this task) if (!isJetMatched) { - for (const auto& partV0 : partJet.candidates_as()) { + for (const auto& partV0 : partJet.candidates_as()) { fillMatchingV0Miss(partJet, partV0, weight); } } } // partJet loop } 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) + { + if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + return; + } + if (v0s.size() == 0) { + return; + } + double weight = jcoll.mcCollision().weight(); + registry.fill(HIST("mcd/V0/nV0sEvent"), v0s.size()); + registry.fill(HIST("mcd/V0/nV0sEventWeighted"), v0s.size(), weight); + + for (const auto& mcdjet : v0jets) { + 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); + + for (const auto& mcdjet : v0jets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, -99., -99., v0EtaMin, v0EtaMax)) { + continue; + } + 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); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGJE/Tasks/jetmatchingqa.cxx b/PWGJE/Tasks/jetmatchingqa.cxx index 3dc888f0933..e752b47e2a5 100644 --- a/PWGJE/Tasks/jetmatchingqa.cxx +++ b/PWGJE/Tasks/jetmatchingqa.cxx @@ -42,6 +42,7 @@ struct JetMatchingQA { {"h_jet_match_geo_pt_zoom", "geo-matched jets", {HistType::kTH2F, {{1000, 0.0f, 10.0f, "#it{p}_{T} (particle level, GeV/#it{c})"}, {1000, 0.0f, 10.0f, "#it{p}_{T} (detector level, GeV/#it{c})"}}}}, {"h_jet_match_geo_dpt", "geo-matched jets", {HistType::kTH1F, {{100, -10.0f, 10.0f, "#Delta#it{p}_{T} (particle level vs detector level, GeV/#it{c})"}}}}, + {"h2_jet_pt_jet_match_geo_dptoverpt", "geo-matched jets", {HistType::kTH2F, {{2000, 0.0f, 200.0f, "#it{p}_{T} (detector level, GeV/#it{c})"}, {700, -5.0f, 2.0f, "(#it{p}_{T, part}-#it{p}_{T, det})/#it{p}_{T,part} (particle level vs detector level, GeV/#it{c})"}}}}, {"h_jet_match_geo_PtLeadingPart", "geo-matched jets", {HistType::kTH2F, {{1000, 0.0f, 10.0f, "#it{p}_{T}^{leading} (particle level, GeV/#it{c})"}, {1000, 0.0f, 10.0f, "#it{p}_{T}^{leading} (detector level, GeV/#it{c})"}}}}, {"h_jet_match_geo_phi", "geo-matched jets", {HistType::kTH2F, {{80, -1.0f, 7.0f, "#phi_{jet} (particle level, rad)"}, {80, -1.0f, 7.0f, "#phi_{jet} (detector level, rad)"}}}}, {"h_jet_match_geo_eta", "geo-matched jets", {HistType::kTH2F, {{70, -0.7f, 0.7f, "#it{p}_{T}^{particle level} (GeV/#it{c})"}, {70, -0.7f, 0.7f, "#it{p}_{T} (detector level, GeV/#it{c})"}}}}, @@ -76,12 +77,12 @@ struct JetMatchingQA { { } - void processDummy(JetMcCollisions const&) + void processDummy(aod::JetMcCollisions const&) { } PROCESS_SWITCH(JetMatchingQA, processDummy, "Dummy process", true); - void processMCD(JetCollision const&, JetParticles const&, JetTracksMCD const&, + void processMCD(aod::JetCollision const&, aod::JetParticles const&, aod::JetTracksMCD const&, BaseJetCollection const& djets, TagJetCollection const&) { for (const auto& djet : djets) { @@ -105,13 +106,13 @@ struct JetMatchingQA { registry.fill(HIST("h_jet_match_hf_Nconst"), pjet.tracksIds().size(), djet.tracksIds().size()); double pjet_pt_lead = 0.; - for (auto& mcparticle : pjet.template tracks_as()) { + for (auto& mcparticle : pjet.template tracks_as()) { if (mcparticle.pt() > pjet_pt_lead) { pjet_pt_lead = mcparticle.pt(); } } double djet_pt_lead = 0.; - for (auto& track : djet.template tracks_as()) { + for (auto& track : djet.template tracks_as()) { if (track.pt() > djet_pt_lead) { djet_pt_lead = track.pt(); } @@ -127,18 +128,19 @@ struct JetMatchingQA { registry.fill(HIST("h_jet_match_geo_pt_zoom"), pjet.pt(), djet.pt()); registry.fill(HIST("h_jet_match_geo_dpt"), pjet.pt() - djet.pt()); + registry.fill(HIST("h2_jet_pt_jet_match_geo_dptoverpt"), pjet.pt(), (pjet.pt() - djet.pt()) * 1. / pjet.pt()); registry.fill(HIST("h_jet_match_geo_phi"), pjet.phi(), djet.phi()); registry.fill(HIST("h_jet_match_geo_eta"), pjet.eta(), djet.eta()); registry.fill(HIST("h_jet_match_geo_Nconst"), pjet.tracksIds().size(), djet.tracksIds().size()); double pjet_pt_lead = 0.; - for (auto& mcparticle : pjet.template tracks_as()) { + for (auto& mcparticle : pjet.template tracks_as()) { if (mcparticle.pt() > pjet_pt_lead) { pjet_pt_lead = mcparticle.pt(); } } double djet_pt_lead = 0.; - for (auto& track : djet.template tracks_as()) { + for (auto& track : djet.template tracks_as()) { if (track.pt() > djet_pt_lead) { djet_pt_lead = track.pt(); } @@ -159,13 +161,13 @@ struct JetMatchingQA { registry.fill(HIST("h_jet_match_pt_Nconst"), pjet.tracksIds().size(), djet.tracksIds().size()); double pjet_pt_lead = 0.; - for (auto& mcparticle : pjet.template tracks_as()) { + for (auto& mcparticle : pjet.template tracks_as()) { if (mcparticle.pt() > pjet_pt_lead) { pjet_pt_lead = mcparticle.pt(); } } double djet_pt_lead = 0.; - for (auto& track : djet.template tracks_as()) { + for (auto& track : djet.template tracks_as()) { if (track.pt() > djet_pt_lead) { djet_pt_lead = track.pt(); } @@ -176,7 +178,7 @@ struct JetMatchingQA { } PROCESS_SWITCH(JetMatchingQA, processMCD, "QA on detector-level jets", false); - void processMCP(JetMcCollision const&, + void processMCP(aod::JetMcCollision const&, TagJetCollection const& pjets, BaseJetCollection const&) { for (const auto& pjet : pjets) { diff --git a/PWGJE/Tasks/jetplanarflow.cxx b/PWGJE/Tasks/jetplanarflow.cxx index a4c5527ac64..9c2769978ca 100644 --- a/PWGJE/Tasks/jetplanarflow.cxx +++ b/PWGJE/Tasks/jetplanarflow.cxx @@ -228,7 +228,7 @@ struct JetPlanarFlowTask { if (particleSelection == "PhysicalPrimary" && !track.isPhysicalPrimary()) { continue; } - if (isinf(track.eta())) { + if (std::isinf(track.eta())) { continue; } } else { @@ -273,14 +273,14 @@ struct JetPlanarFlowTask { } } - void processDummy(JetTracks const&) + void processDummy(aod::JetTracks const&) { } PROCESS_SWITCH(JetPlanarFlowTask, processDummy, "Dummy process function turned on by default", true); - void processChargedJetsData(soa::Filtered::iterator const& collision, + void processChargedJetsData(soa::Filtered::iterator const& collision, soa::Join const& jets, - JetTracks const& tracks) + aod::JetTracks const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -296,9 +296,9 @@ struct JetPlanarFlowTask { } PROCESS_SWITCH(JetPlanarFlowTask, processChargedJetsData, "charged jet analysis", false); - void processChargedRhoAreaSubtractedJetsData(soa::Filtered>::iterator const& collision, + void processChargedRhoAreaSubtractedJetsData(soa::Filtered>::iterator const& collision, soa::Join const& jets, - JetTracks const& tracks) + aod::JetTracks const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -314,9 +314,9 @@ struct JetPlanarFlowTask { } PROCESS_SWITCH(JetPlanarFlowTask, processChargedRhoAreaSubtractedJetsData, "charged rho-area subtracted jet analysis", false); - void processChargedJetsEventWiseSubData(soa::Filtered::iterator const& collision, + void processChargedJetsEventWiseSubData(soa::Filtered::iterator const& collision, soa::Join const& jets, - JetTracksSub const& tracks) + aod::JetTracksSub const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -332,9 +332,9 @@ struct JetPlanarFlowTask { } PROCESS_SWITCH(JetPlanarFlowTask, processChargedJetsEventWiseSubData, "charged event-wise subtracted jet analysis", false); - void processChargedJetsMCD(soa::Filtered::iterator const& collision, + void processChargedJetsMCD(soa::Filtered::iterator const& collision, soa::Join const& jets, - JetTracks const& tracks) + aod::JetTracks const& tracks) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { return; @@ -350,9 +350,9 @@ struct JetPlanarFlowTask { } PROCESS_SWITCH(JetPlanarFlowTask, processChargedJetsMCD, "charged detector level jet analysis", false); - void processChargedJetsMCP(JetMcCollisions const& collision, + void processChargedJetsMCP(aod::JetMcCollisions const& collision, soa::Join const& jets, - JetParticles const& particles) + aod::JetParticles const& particles) { for (auto const& jet : jets) { diff --git a/PWGJE/Tasks/jetsubstructure.cxx b/PWGJE/Tasks/jetsubstructure.cxx index c4398703437..b99d2b6ed33 100644 --- a/PWGJE/Tasks/jetsubstructure.cxx +++ b/PWGJE/Tasks/jetsubstructure.cxx @@ -49,6 +49,9 @@ struct JetSubstructureTask { 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 pairConstituentPtMin{"pairConstituentPtMin", 1.0, "pt cut off for constituents going into pairs"}; Service pdg; std::vector jetConstituents; @@ -63,6 +66,7 @@ struct JetSubstructureTask { std::vector pairPtVec; std::vector pairEnergyVec; std::vector pairThetaVec; + float angularity; HistogramRegistry registry; @@ -154,11 +158,13 @@ struct JetSubstructureTask { pairThetaVec.clear(); std::vector tracksVec; for (auto const& constituent : jet.template tracks_as()) { - tracksVec.push_back(constituent); + if (constituent.pt() >= pairConstituentPtMin) { + tracksVec.push_back(constituent); + } } - if (tracksVec.size() >= 2) { - for (typename std::vector::size_type track1Index = 0; track1Index < tracksVec.size() - 1; track1Index++) { - for (typename std::vector::size_type track2Index = track1Index + 1; track2Index < tracksVec.size(); track2Index++) { + 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))); @@ -167,6 +173,16 @@ struct JetSubstructureTask { } } + template + void jetSubstructureSimple(T const& jet, U const& /*tracks*/) + { + angularity = 0.0; + for (auto& constituent : jet.template tracks_as()) { + 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) { @@ -177,46 +193,48 @@ struct JetSubstructureTask { nSub = jetsubstructureutilities::getNSubjettiness(jet, tracks, tracks, tracks, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); jetReclustering(jet); jetPairing(jet, tracks); - outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec); + jetSubstructureSimple(jet, tracks); + outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); } - void processDummy(JetTracks const&) + void processDummy(aod::JetTracks const&) { } PROCESS_SWITCH(JetSubstructureTask, processDummy, "Dummy process function turned on by default", true); void processChargedJetsData(soa::Join::iterator const& jet, - JetTracks const& tracks) + aod::JetTracks const& tracks) { analyseCharged(jet, tracks, jetSubstructureDataTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsData, "charged jet substructure", false); void processChargedJetsEventWiseSubData(soa::Join::iterator const& jet, - JetTracksSub const& tracks) + aod::JetTracksSub const& tracks) { analyseCharged(jet, tracks, jetSubstructureDataSubTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsEventWiseSubData, "eventwise-constituent subtracted charged jet substructure", false); void processChargedJetsMCD(typename soa::Join::iterator const& jet, - JetTracks const& tracks) + aod::JetTracks const& tracks) { analyseCharged(jet, tracks, jetSubstructureMCDTable); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsMCD, "charged jet substructure", false); void processChargedJetsMCP(typename soa::Join::iterator const& jet, - JetParticles const& particles) + aod::JetParticles const& particles) { jetConstituents.clear(); - for (auto& jetConstituent : jet.template tracks_as()) { + for (auto& jetConstituent : jet.template tracks_as()) { 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); - jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec); + jetSubstructureSimple(jet, particles); + jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); } PROCESS_SWITCH(JetSubstructureTask, processChargedJetsMCP, "charged jet substructure on MC particle level", false); }; diff --git a/PWGJE/Tasks/jetsubstructurehf.cxx b/PWGJE/Tasks/jetsubstructurehf.cxx index 9cdb933c20a..c20515e9618 100644 --- a/PWGJE/Tasks/jetsubstructurehf.cxx +++ b/PWGJE/Tasks/jetsubstructurehf.cxx @@ -53,6 +53,9 @@ struct JetSubstructureHFTask { // 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 pairConstituentPtMin{"pairConstituentPtMin", 1.0, "pt cut off for constituents going into pairs"}; Service pdg; float candMass; @@ -69,6 +72,7 @@ struct JetSubstructureHFTask { std::vector pairPtVec; std::vector pairEnergyVec; std::vector pairThetaVec; + float angularity; HistogramRegistry registry; void init(InitContext const&) @@ -168,23 +172,25 @@ struct JetSubstructureHFTask { std::vector> tracksVec; std::vector> candidatesVec; for (auto& constituent : jet.template tracks_as()) { - tracksVec.push_back(constituent); + if (constituent.pt() >= pairConstituentPtMin) { + tracksVec.push_back(constituent); + } } for (auto& candidate : jet.template candidates_as()) { candidatesVec.push_back(candidate); } - if (tracksVec.size() >= 2) { - for (typename std::vector>::size_type track1Index = 0; track1Index < tracksVec.size() - 1; track1Index++) { - for (typename std::vector>::size_type track2Index = track1Index + 1; track2Index < tracksVec.size(); track2Index++) { + 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))); } } } - if (candidatesVec.size() >= 2) { - for (typename std::vector>::size_type candidate1Index = 0; candidate1Index < candidatesVec.size() - 1; candidate1Index++) { - for (typename std::vector>::size_type candidate2Index = candidate1Index + 1; candidate2Index < candidatesVec.size(); candidate2Index++) { + 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()); 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)); @@ -205,6 +211,19 @@ struct JetSubstructureHFTask { } } + template + void jetSubstructureSimple(T const& jet, U const& /*tracks*/, V const& /*candidates*/) + { + angularity = 0.0; + for (auto& candidate : jet.template candidates_as()) { + angularity += std::pow(candidate.pt(), kappa) * std::pow(jetutilities::deltaR(jet, candidate), alpha); + } + for (auto& constituent : jet.template tracks_as()) { + 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) { @@ -218,17 +237,18 @@ struct JetSubstructureHFTask { nSub = jetsubstructureutilities::getNSubjettiness(jet, tracks, tracks, candidates, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); jetReclustering(jet); jetPairing(jet, tracks, candidates); - outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec); + jetSubstructureSimple(jet, tracks, candidates); + outputTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); } - void processDummy(JetTracks const&) + void processDummy(aod::JetTracks const&) { } PROCESS_SWITCH(JetSubstructureHFTask, processDummy, "Dummy process function turned on by default", true); void processChargedJetsData(typename JetTableData::iterator const& jet, CandidateTable const& candidates, - JetTracks const& tracks) + aod::JetTracks const& tracks) { analyseCharged(jet, tracks, candidates, jetSubstructureDataTable); } @@ -244,18 +264,18 @@ struct JetSubstructureHFTask { void processChargedJetsMCD(typename JetTableMCD::iterator const& jet, CandidateTable const& candidates, - JetTracks const& tracks) + aod::JetTracks const& tracks) { analyseCharged(jet, tracks, candidates, jetSubstructureMCDTable); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsMCD, "HF jet substructure on data", false); void processChargedJetsMCP(typename JetTableMCP::iterator const& jet, - JetParticles const& particles, + aod::JetParticles const& particles, CandidateTableMCP const& candidates) { jetConstituents.clear(); - for (auto& jetConstituent : jet.template tracks_as()) { + for (auto& jetConstituent : jet.template tracks_as()) { fastjetutilities::fillTracks(jetConstituent, jetConstituents, jetConstituent.globalIndex(), static_cast(JetConstituentStatus::track), pdg->Mass(jetConstituent.pdgCode())); } for (auto& jetHFCandidate : jet.template candidates_as()) { @@ -264,14 +284,15 @@ struct JetSubstructureHFTask { nSub = jetsubstructureutilities::getNSubjettiness(jet, particles, particles, candidates, 2, fastjet::contrib::CA_Axes(), true, zCut, beta); jetReclustering(jet); jetPairing(jet, particles, candidates); - jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec); + jetSubstructureSimple(jet, particles, candidates); + jetSubstructureMCPTable(energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, nSub[0], nSub[1], nSub[2], pairPtVec, pairEnergyVec, pairThetaVec, angularity); } PROCESS_SWITCH(JetSubstructureHFTask, processChargedJetsMCP, "HF jet substructure on MC particle level", false); }; -using JetSubstructureD0 = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, CandidatesD0Data, CandidatesD0MCP, aod::D0CJetSSs, aod::D0CMCDJetSSs, aod::D0CMCPJetSSs, aod::D0CEWSJetSSs, aod::JTrackD0Subs>; -using JetSubstructureLc = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, CandidatesLcData, CandidatesLcMCP, aod::LcCJetSSs, aod::LcCMCDJetSSs, aod::LcCMCPJetSSs, aod::LcCEWSJetSSs, aod::JTrackLcSubs>; -// using JetSubstructureBplus = JetSubstructureHFTask,soa::Join,soa::Join,soa::Join, CandidatesBplusData, CandidatesBplusMCP, aod::BplusCJetSSs,aod::BplusCMCDJetSSs,aod::BplusCMCPJetSSs, aod::BplusCEWSJetSSs, aod::JTrackBplusSubs>; -using JetSubstructureDielectron = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, CandidatesDielectronData, CandidatesDielectronMCP, aod::DielectronCJetSSs, aod::DielectronCMCDJetSSs, aod::DielectronCMCPJetSSs, aod::DielectronCEWSJetSSs, aod::JTrackDielectronSubs>; +using JetSubstructureD0 = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesD0Data, aod::CandidatesD0MCP, aod::D0CJetSSs, aod::D0CMCDJetSSs, aod::D0CMCPJetSSs, aod::D0CEWSJetSSs, aod::JTrackD0Subs>; +using JetSubstructureLc = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesLcData, aod::CandidatesLcMCP, aod::LcCJetSSs, aod::LcCMCDJetSSs, aod::LcCMCPJetSSs, aod::LcCEWSJetSSs, aod::JTrackLcSubs>; +// using JetSubstructureBplus = JetSubstructureHFTask,soa::Join,soa::Join,soa::Join, aod::CandidatesBplusData, aod::CandidatesBplusMCP, aod::BplusCJetSSs,aod::BplusCMCDJetSSs,aod::BplusCMCPJetSSs, aod::BplusCEWSJetSSs, aod::JTrackBplusSubs>; +using JetSubstructureDielectron = JetSubstructureHFTask, soa::Join, soa::Join, soa::Join, aod::CandidatesDielectronData, aod::CandidatesDielectronMCP, aod::DielectronCJetSSs, aod::DielectronCMCDJetSSs, aod::DielectronCMCPJetSSs, aod::DielectronCEWSJetSSs, aod::JTrackDielectronSubs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetsubstructurehfoutput.cxx b/PWGJE/Tasks/jetsubstructurehfoutput.cxx index dafa4d7bf1f..a822d22b4f7 100644 --- a/PWGJE/Tasks/jetsubstructurehfoutput.cxx +++ b/PWGJE/Tasks/jetsubstructurehfoutput.cxx @@ -22,7 +22,6 @@ #include "Common/Core/TrackSelection.h" #include "Common/Core/TrackSelectionDefaults.h" -#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" @@ -41,9 +40,9 @@ using namespace o2::framework::expressions; // NB: runDataProcessing.h must be included after customize! #include "Framework/runDataProcessing.h" -template +template struct JetSubstructureHFOutputTask { - Produces storedCollisionCountsTable; + Produces collisionOutputTableData; Produces jetOutputTableData; Produces jetSubstructureOutputTableData; @@ -82,7 +81,7 @@ struct JetSubstructureHFOutputTask { Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"}; - Configurable eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"}; + // need to add selection on pThat to post processing std::map jetMappingData; std::map jetMappingDataSub; @@ -98,19 +97,17 @@ struct JetSubstructureHFOutputTask { std::vector collisionFlag; std::vector mcCollisionFlag; - PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; - PresliceOptional D0CollisionsPerCollision = aod::jd0indices::collisionId; - PresliceOptional LcCollisionsPerCollision = aod::jlcindices::collisionId; - PresliceOptional DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; - PresliceOptional> D0McCollisionsPerMcCollision = aod::jd0indices::mcCollisionId; - PresliceOptional> LcMcCollisionsPerMcCollision = aod::jlcindices::mcCollisionId; - PresliceOptional DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; + PresliceUnsorted> CollisionsPerMcCollision = aod::jmccollisionlb::mcCollisionId; + PresliceOptional D0CollisionsPerCollision = aod::jd0indices::collisionId; + PresliceOptional LcCollisionsPerCollision = aod::jlcindices::collisionId; + PresliceOptional DielectronCollisionsPerCollision = aod::jdielectronindices::collisionId; + PresliceOptional> D0McCollisionsPerMcCollision = aod::jd0indices::mcCollisionId; + PresliceOptional> LcMcCollisionsPerMcCollision = aod::jlcindices::mcCollisionId; + PresliceOptional DielectronMcCollisionsPerMcCollision = aod::jdielectronindices::mcCollisionId; - int eventSelection = -1; void init(InitContext const&) { jetRadiiValues = (std::vector)jetRadii; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelectionForCounting)); } template @@ -138,12 +135,12 @@ struct JetSubstructureHFOutputTask { 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); + jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairPtVec, pairEnergyVec, pairThetaVec, jet.angularity()); 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) + 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) { int nJetInCollision = 0; @@ -165,7 +162,7 @@ struct JetSubstructureHFOutputTask { } if constexpr (!isMCP) { if (nJetInCollision == 0) { - collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel()); + collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel(), eventWeight); collisionIndex = collisionOutputTable.lastIndex(); } nJetInCollision++; @@ -364,7 +361,7 @@ struct JetSubstructureHFOutputTask { } } - void processClearMaps(JetCollisions const&) + void processClearMaps(aod::JetCollisions const&) { candidateMapping.clear(); candidateCollisionMapping.clear(); @@ -378,46 +375,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processClearMaps, "process function that clears all the maps in each dataframe", true); - void processCountCollisions(JetCollisions const& collisions, aod::CollisionCounts const& collisionCounts) - { - int readCollisionCounter = 0; - int readSelectedCollisionCounter = 0; - int writtenCollisionCounter = -1; - for (auto const& collision : collisions) { - readCollisionCounter++; - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { - readSelectedCollisionCounter++; - } - } - std::vector previousReadCounts; - std::vector previousReadSelectedCounts; - std::vector previousWrittenCounts; - int iPreviousDataFrame = 0; - for (const auto& collisionCount : collisionCounts) { - auto readCollisionCounterSpan = collisionCount.readCounts(); - auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts(); - auto writtenCollisionCounterSpan = collisionCount.writtenCounts(); - if (iPreviousDataFrame == 0) { - std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts)); - std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts)); - std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts)); - } else { - for (unsigned int i = 0; i < previousReadCounts.size(); i++) { - previousReadCounts[i] += readCollisionCounterSpan[i]; - previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i]; - previousWrittenCounts[i] += writtenCollisionCounterSpan[i]; - } - } - iPreviousDataFrame++; - } - previousReadCounts.push_back(readCollisionCounter); - previousReadSelectedCounts.push_back(readSelectedCollisionCounter); - previousWrittenCounts.push_back(writtenCollisionCounter); - storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts); - } - PROCESS_SWITCH(JetSubstructureHFOutputTask, processCountCollisions, "process function that counts read in collisions", false); - - void processOutputCollisionsData(JetCollisions const& collisions, + void processOutputCollisionsData(aod::JetCollisions const& collisions, JetTableData const& jets, CandidateCollisionTable const& canidateCollisions, CandidateTable const& candidates) @@ -426,7 +384,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsData, "hf collision output data", false); - void processOutputCollisionsDataSub(JetCollisions const& collisions, + void processOutputCollisionsDataSub(aod::JetCollisions const& collisions, JetTableDataSub const& jets, CandidateCollisionTable const& canidateCollisions, CandidateTable const& candidates) @@ -435,8 +393,8 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsDataSub, "hf collision output data eventwise constituent subtracted", false); - void processOutputCollisionsMc(soa::Join const& collisions, - JetMcCollisions const& mcCollisions, + void processOutputCollisionsMc(soa::Join const& collisions, + aod::JetMcCollisions const& mcCollisions, JetTableMCD const& jetsMCD, JetTableMCP const& jetsMCP, CandidateCollisionTable const& canidateCollisions, @@ -448,7 +406,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsMc, "hf collision output MC", false); - void processOutputCollisionsMCPOnly(JetMcCollisions const& mcCollisions, + void processOutputCollisionsMCPOnly(aod::JetMcCollisions const& mcCollisions, JetTableMCP const& jetsMCP, CandidateMcCollisionTable const& canidateMcCollisions, CandidateTableMCP const& candidatesMCP) @@ -457,7 +415,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCollisionsMCPOnly, "hf collision output MCP only", false); - void processOutputCandidatesData(JetCollision const&, + void processOutputCandidatesData(aod::JetCollision const&, JetTableData const& jets, CandidateTable const& candidates) { @@ -465,7 +423,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesData, "hf candidate output data", false); - void processOutputCandidatesDataSub(JetCollision const&, + void processOutputCandidatesDataSub(aod::JetCollision const&, JetTableDataSub const& jets, CandidateTable const& candidates) { @@ -473,7 +431,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesDataSub, "hf candidate output data eventwise constituent subtracted", false); - void processOutputCandidatesMCD(JetCollision const&, + void processOutputCandidatesMCD(aod::JetCollision const&, JetTableMCD const& jets, CandidateTableMCD const& candidates) { @@ -482,7 +440,7 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesMCD, "hf candidate output MCD", false); - void processOutputCandidatesMCP(JetMcCollision const&, + void processOutputCandidatesMCP(aod::JetMcCollision const&, JetTableMCP const& jets, CandidateTableMCP const& candidates) { @@ -490,19 +448,19 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputCandidatesMCP, "hf candidate output MCP", false); - void processOutputJetsData(JetCollision const& collision, + void processOutputJetsData(aod::JetCollision const& collision, JetTableData const& jets, CandidateTable const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, candidateMapping, jetPtMinData); + analyseCharged(collision, jets, candidates, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, candidateMapping, jetPtMinData, 1.0); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsData, "hf jet substructure output Data", false); - void processOutputJetsDataSub(JetCollision const& collision, + void processOutputJetsDataSub(aod::JetCollision const& collision, JetTableDataSub const& jets, CandidateTable const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, candidateMapping, jetPtMinDataSub); + analyseCharged(collision, jets, candidates, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, candidateMapping, jetPtMinDataSub, 1.0); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsDataSub, "hf jet substructure output event-wise subtracted Data", false); @@ -514,19 +472,20 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputMatchingData, "jet matching output Data", false); - void processOutputJetsMCD(JetCollision const& collision, + void processOutputJetsMCD(aod::JetCollisionMCD const& collision, + aod::JetMcCollisions const&, JetTableMCD const& jets, CandidateTableMCD const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, candidateMapping, jetPtMinMCD); + analyseCharged(collision, jets, candidates, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, candidateMapping, jetPtMinMCD, collision.mcCollision().weight()); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsMCD, "hf jet substructure output MCD", false); - void processOutputJetsMCP(JetMcCollision const& collision, + void processOutputJetsMCP(aod::JetMcCollision const& collision, JetTableMCP const& jets, CandidateTableMCP const& candidates) { - analyseCharged(collision, jets, candidates, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, candidateMappingMCP, jetPtMinMCP); + analyseCharged(collision, jets, candidates, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, candidateMappingMCP, jetPtMinMCP, collision.weight()); } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputJetsMCP, "hf jet substructure output MCP", false); @@ -538,10 +497,10 @@ struct JetSubstructureHFOutputTask { } PROCESS_SWITCH(JetSubstructureHFOutputTask, processOutputMatchingMC, "jet matching output MC", false); }; -using JetSubstructureOutputD0 = JetSubstructureHFOutputTask, CandidatesD0Data, CandidatesD0MCD, 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::StoredHfD0Sels, aod::StoredHfD0Mls, aod::StoredHfD0Mcs, aod::StoredHfD0McCollBases, aod::StoredHfD0McRCollIds, aod::StoredHfD0PBases, aod::D0CollisionCounts>; -using JetSubstructureOutputLc = JetSubstructureHFOutputTask, CandidatesLcData, CandidatesLcMCD, 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::StoredHf3PCollBase, aod::StoredHf3PBases, aod::StoredHf3PPars, aod::StoredHf3PParEs, aod::StoredHf3PSels, aod::StoredHf3PMls, aod::StoredHf3PMcs, aod::StoredHf3PMcCollBases, aod::StoredHf3PMcRCollIds, aod::StoredHf3PPBases, aod::LcCollisionCounts>; -// using JetSubstructureOutputBplus = JetSubstructureHFOutputTask, CandidatesBplusData, CandidatesBplusMCD, 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::StoredHfBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMcs, aod::StoredHfBplusPBases, aod::BplusCollisionCounts>; -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::StoredJDielectronMcCollisions, aod::JDielectron6Dummys, aod::StoredJDielectronMcs, aod::DielectronCollisionCounts>; +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::StoredHfD0Sels, aod::StoredHfD0Mls, aod::StoredHfD0Mcs, aod::StoredHfD0McCollBases, aod::StoredHfD0McRCollIds, aod::StoredHfD0PBases>; +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::StoredHf3PCollBase, aod::StoredHf3PBases, aod::StoredHf3PPars, aod::StoredHf3PParEs, aod::StoredHf3PSels, aod::StoredHf3PMls, aod::StoredHf3PMcs, aod::StoredHf3PMcCollBases, aod::StoredHf3PMcRCollIds, aod::StoredHf3PPBases>; +// 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::StoredHfBplusSels, aod::StoredHfBplusMls, aod::StoredHfBplusMcs, aod::StoredHfBplusPBases>; +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::StoredJDielectronMcCollisions, aod::JDielectron6Dummys, aod::StoredJDielectronMcs>; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetsubstructureoutput.cxx b/PWGJE/Tasks/jetsubstructureoutput.cxx index fed22a1b826..695afef9e35 100644 --- a/PWGJE/Tasks/jetsubstructureoutput.cxx +++ b/PWGJE/Tasks/jetsubstructureoutput.cxx @@ -23,6 +23,7 @@ #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" @@ -40,7 +41,6 @@ using namespace o2::framework::expressions; struct JetSubstructureOutputTask { - Produces storedCollisionCountsTable; Produces collisionOutputTableData; Produces jetOutputTableData; Produces jetSubstructureOutputTableData; @@ -69,8 +69,6 @@ struct JetSubstructureOutputTask { Configurable trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"}; Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"}; - Configurable eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"}; - std::map jetMappingData; std::map jetMappingDataSub; std::map jetMappingMCD; @@ -78,11 +76,9 @@ struct JetSubstructureOutputTask { std::vector jetRadiiValues; - int eventSelection = -1; void init(InitContext const&) { jetRadiiValues = (std::vector)jetRadii; - eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelectionForCounting)); } template @@ -110,12 +106,12 @@ struct JetSubstructureOutputTask { 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); + jetSubstructureOutputTable(jetOutputTable.lastIndex(), energyMotherVec, ptLeadingVec, ptSubLeadingVec, thetaVec, jet.nSub2DR(), jet.nSub1(), jet.nSub2(), pairPtVec, pairEnergyVec, pairThetaVec, jet.angularity()); 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) + void analyseCharged(T const& collision, U const& jets, V& collisionOutputTable, M& jetOutputTable, N& jetSubstructureOutputTable, std::map& jetMapping, float jetPtMin, float eventWeight) { int nJetInCollision = 0; int32_t collisionIndex = -1; @@ -130,7 +126,7 @@ struct JetSubstructureOutputTask { if (jet.r() == round(jetRadiiValue * 100.0f)) { if constexpr (!isMc) { if (nJetInCollision == 0) { - collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel()); + collisionOutputTable(collision.posZ(), collision.centrality(), collision.eventSel(), eventWeight); collisionIndex = collisionOutputTable.lastIndex(); } nJetInCollision++; @@ -183,7 +179,7 @@ struct JetSubstructureOutputTask { } } - void processClearMaps(JetCollisions const&) + void processClearMaps(aod::JetCollisions const&) { jetMappingData.clear(); jetMappingDataSub.clear(); @@ -192,56 +188,17 @@ struct JetSubstructureOutputTask { } PROCESS_SWITCH(JetSubstructureOutputTask, processClearMaps, "process function that clears all the maps in each dataframe", true); - void processCountCollisions(JetCollisions const& collisions, aod::CollisionCounts const& collisionCounts) - { - int readCollisionCounter = 0; - int readSelectedCollisionCounter = 0; - int writtenCollisionCounter = -1; - for (auto const& collision : collisions) { - readCollisionCounter++; - if (jetderiveddatautilities::selectCollision(collision, eventSelection)) { - readSelectedCollisionCounter++; - } - } - std::vector previousReadCounts; - std::vector previousReadSelectedCounts; - std::vector previousWrittenCounts; - int iPreviousDataFrame = 0; - for (const auto& collisionCount : collisionCounts) { - auto readCollisionCounterSpan = collisionCount.readCounts(); - auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts(); - auto writtenCollisionCounterSpan = collisionCount.writtenCounts(); - if (iPreviousDataFrame == 0) { - std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts)); - std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts)); - std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts)); - } else { - for (unsigned int i = 0; i < previousReadCounts.size(); i++) { - previousReadCounts[i] += readCollisionCounterSpan[i]; - previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i]; - previousWrittenCounts[i] += writtenCollisionCounterSpan[i]; - } - } - iPreviousDataFrame++; - } - previousReadCounts.push_back(readCollisionCounter); - previousReadSelectedCounts.push_back(readSelectedCollisionCounter); - previousWrittenCounts.push_back(writtenCollisionCounter); - storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts); - } - PROCESS_SWITCH(JetSubstructureOutputTask, processCountCollisions, "process function that counts read in collisions", false); - - void processOutputData(JetCollision const& collision, + void processOutputData(aod::JetCollision const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, jetPtMinData); + analyseCharged(collision, jets, collisionOutputTableData, jetOutputTableData, jetSubstructureOutputTableData, jetMappingData, jetPtMinData, 1.0); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputData, "jet substructure output Data", false); - void processOutputDataSub(JetCollision const& collision, + void processOutputDataSub(aod::JetCollision const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, jetPtMinDataSub); + analyseCharged(collision, jets, collisionOutputTableDataSub, jetOutputTableDataSub, jetSubstructureOutputTableDataSub, jetMappingDataSub, jetPtMinDataSub, 1.0); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputDataSub, "jet substructure output event-wise subtracted Data", false); @@ -253,17 +210,17 @@ struct JetSubstructureOutputTask { } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMatchingData, "jet matching output Data", false); - void processOutputMCD(JetCollision const& collision, + void processOutputMCD(aod::JetCollisionMCD const& collision, aod::JetMcCollisions const&, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, jetPtMinMCD); + analyseCharged(collision, jets, collisionOutputTableMCD, jetOutputTableMCD, jetSubstructureOutputTableMCD, jetMappingMCD, jetPtMinMCD, collision.mcCollision().weight()); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMCD, "jet substructure output MCD", false); - void processOutputMCP(JetMcCollision const& collision, + void processOutputMCP(aod::JetMcCollision const& collision, soa::Join const& jets) { - analyseCharged(collision, jets, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, jetPtMinMCP); + analyseCharged(collision, jets, collisionOutputTableMCP, jetOutputTableMCP, jetSubstructureOutputTableMCP, jetMappingMCP, jetPtMinMCP, collision.weight()); } PROCESS_SWITCH(JetSubstructureOutputTask, processOutputMCP, "jet substructure output MCP", false); diff --git a/PWGJE/Tasks/jettaggerhfQA.cxx b/PWGJE/Tasks/jettaggerhfQA.cxx index c12115ff89e..d3bc15e3d5b 100644 --- a/PWGJE/Tasks/jettaggerhfQA.cxx +++ b/PWGJE/Tasks/jettaggerhfQA.cxx @@ -36,7 +36,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -template +template struct JetTaggerHFQA { // task on/off configuration @@ -44,6 +44,7 @@ struct JetTaggerHFQA { Configurable fillIPz{"fillIPz", false, "process of z plane of dca"}; Configurable fillIPxyz{"fillIPxyz", false, "process of xyz plane of dca"}; Configurable fillTrackCounting{"fillTrackCounting", false, "process of track counting method"}; + Configurable fillGeneralSVQA{"fillGeneralSVQA", true, "process of general QA for sv"}; // Cut configuration Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; @@ -51,19 +52,30 @@ struct JetTaggerHFQA { Configurable trackEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks"}; Configurable trackPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks"}; 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 jetEtaMin{"jetEtaMin", -99.0, "minimum jet pseudorapidity"}; Configurable jetEtaMax{"jetEtaMax", 99.0, "maximum jet pseudorapidity"}; - Configurable prong2sigmaLxyMax{"prong2simgaLxyMax", 0.03, "maximum sigma of decay length of 2-prong on xy plane"}; - Configurable prong2SxyMin{"prong2SxyMin", 7, "minimum decay length significance of 2-prong on xy plane"}; - Configurable prong2sigmaLxyzMax{"prong2sigmaLxyzMax", 0.03, "maximum sigma of decay length of 2-prong on xyz plane"}; - Configurable prong2SxyzMin{"prong2SxyzMin", 7, "minimum decay length significance of 2-prong on xyz plane"}; - Configurable prong3sigmaLxyMax{"prong3sigmaLxyMax", 0.03, "maximum sigma of decay length of 3-prong on xy plane"}; - Configurable prong3SxyMin{"prong3SxyMin", 7, "minimum decay length significance of 3-prong on xy plane"}; - Configurable prong3sigmaLxyzMax{"prong3sigmaLxyzMax", 0.03, "maximum sigma of decay length of 3-prong on xyz plane"}; - Configurable prong3SxyzMin{"prong3SxyzMin", 7, "minimum decay length significance of 3-prong on xyz plane"}; + Configurable prongChi2PCAMin{"prongChi2PCAMin", 1, "minimum Chi2 PCA of decay length of prongs"}; + Configurable prongChi2PCAMax{"prongChi2PCAMax", 100, "maximum Chi2 PCA of decay length of prongs"}; + 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"}; + Configurable prongIPxyMax{"prongIPxyMax", 1, "minimum impact parmeter of prongs on xy plane"}; + Configurable svDispersionMax{"svDispersionMax", 1, "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"}; + 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 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 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 eventSelections{"eventSelections", "sel8", "choose event selection"}; Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; // Binning ConfigurableAxis binJetFlavour{"binJetFlavour", {6, -0.5, 5.5}, ""}; @@ -72,39 +84,37 @@ struct JetTaggerHFQA { ConfigurableAxis binPhi{"binPhi", {18 * 8, 0.f, 2. * TMath::Pi()}, ""}; ConfigurableAxis binNtracks{"binNtracks", {100, 0., 100.}, ""}; ConfigurableAxis binTrackPt{"binTrackPt", {200, 0.f, 100.f}, ""}; - ConfigurableAxis binImpactParameterXY{"binImpactParameterXY", {800, -400.5f, 400.5f}, ""}; + ConfigurableAxis binImpactParameterXY{"binImpactParameterXY", {801, -400.5f, 400.5f}, ""}; ConfigurableAxis binSigmaImpactParameterXY{"binImpactSigmaParameterXY", {800, 0.f, 100.f}, ""}; - ConfigurableAxis binImpactParameterXYSignificance{"binImpactParameterXYSignificance", {800, -40.5f, 40.5f}, ""}; - ConfigurableAxis binImpactParameterZ{"binImpactParameterZ", {800, -400.5f, 400.5f}, ""}; - ConfigurableAxis binImpactParameterZSignificance{"binImpactParameterZSignificance", {800, -40.5f, 40.5f}, ""}; - ConfigurableAxis binImpactParameterXYZ{"binImpactParameterXYZ", {2000, -1000.5f, 1000.5f}, ""}; - ConfigurableAxis binImpactParameterXYZSignificance{"binImpactParameterXYZSignificance", {2000, -100.5f, 100.5f}, ""}; + ConfigurableAxis binImpactParameterXYSignificance{"binImpactParameterXYSignificance", {801, -40.5f, 40.5f}, ""}; + ConfigurableAxis binImpactParameterZ{"binImpactParameterZ", {801, -400.5f, 400.5f}, ""}; + ConfigurableAxis binImpactParameterZSignificance{"binImpactParameterZSignificance", {801, -40.5f, 40.5f}, ""}; + ConfigurableAxis binImpactParameterXYZ{"binImpactParameterXYZ", {2001, -1000.5f, 1000.5f}, ""}; + ConfigurableAxis binImpactParameterXYZSignificance{"binImpactParameterXYZSignificance", {2001, -100.5f, 100.5f}, ""}; ConfigurableAxis binNumOrder{"binNumOrder", {6, 0.5, 6.5}, ""}; ConfigurableAxis binJetProbability{"binJetProbability", {100, 0.f, 1.f}, ""}; ConfigurableAxis binJetProbabilityLog{"binJetProbabilityLog", {100, 0.f, 10.f}, ""}; ConfigurableAxis binNprongs{"binNprongs", {100, 0., 100.}, ""}; ConfigurableAxis binLxy{"binLxy", {200, 0, 20.f}, ""}; - ConfigurableAxis binSxy{"binSxy", {200, 0, 200.f}, ""}; + ConfigurableAxis binSxy{"binSxy", {1000, 0, 1000.f}, ""}; ConfigurableAxis binLxyz{"binLxyz", {200, 0, 20.f}, ""}; - ConfigurableAxis binSxyz{"binSxyz", {200, 0, 200.f}, ""}; + ConfigurableAxis binSxyz{"binSxyz", {1000, 0, 1000.f}, ""}; + ConfigurableAxis binMass{"binMass", {50, 0, 10.f}, ""}; ConfigurableAxis binSigmaLxy{"binSigmaLxy", {100, 0., 0.1}, ""}; ConfigurableAxis binSigmaLxyz{"binSigmaLxyz", {100, 0., 0.1}, ""}; int numberOfJetFlavourSpecies = 6; + int eventSelection = -1; int trackSelection = -1; - float maxSigmaLxy2Prong = 0.; - float minSxy2Prong = 0.; - float maxSigmaLxyz2Prong = 0.; - float minSxyz2Prong = 0.; - float maxSigmaLxy3Prong = 0.; - float minSxy3Prong = 0.; - float maxSigmaLxyz3Prong = 0.; - float minSxyz3Prong = 0.; HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; void init(InitContext const&) { + numberOfJetFlavourSpecies = static_cast(numFlavourSpecies); + + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); // Axis AxisSpec jetFlavourAxis = {binJetFlavour, "Jet flavour"}; AxisSpec jetPtAxis = {binJetPt, "#it{p}_{T, jet}"}; @@ -114,6 +124,7 @@ struct JetTaggerHFQA { 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}"}; @@ -127,20 +138,10 @@ struct JetTaggerHFQA { 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]"}; - numberOfJetFlavourSpecies = static_cast(numFlavourSpecies); - maxSigmaLxy2Prong = static_cast(prong2sigmaLxyMax); - minSxy2Prong = static_cast(prong2SxyMin); - maxSigmaLxyz2Prong = static_cast(prong2sigmaLxyzMax); - minSxyz2Prong = static_cast(prong2SxyzMin); - maxSigmaLxy3Prong = static_cast(prong3sigmaLxyMax); - minSxy3Prong = static_cast(prong3SxyMin); - maxSigmaLxyz3Prong = static_cast(prong3sigmaLxyzMax); - minSxyz3Prong = static_cast(prong3SxyzMin); - - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); if (doprocessTracksDca) { registry.add("h_impact_parameter_xy", "", {HistType::kTH1F, {{impactParameterXYAxis}}}); registry.add("h_impact_parameter_xy_significance", "", {HistType::kTH1F, {{impactParameterXYSignificanceAxis}}}); @@ -179,7 +180,7 @@ struct JetTaggerHFQA { registry.add("h3_track_pt_sign_impact_parameter_xyz_significance_tc", "", {HistType::kTH3F, {{trackPtAxis}, {impactParameterXYZSignificanceAxis}, {numOrderAxis}}}); } } - if (doprocessIPsMCD) { + 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}}}); @@ -232,6 +233,37 @@ struct JetTaggerHFQA { registry.add("h3_sign_impact_parameter_xyz_significance_tc_flavour", "", {HistType::kTH3F, {{impactParameterXYZSignificanceAxis}, {numOrderAxis}, {jetFlavourAxis}}}); } } + 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}}}); + } + + 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}}}); + } + } + 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}}}); @@ -242,7 +274,7 @@ struct JetTaggerHFQA { 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) { + 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}}}); @@ -252,435 +284,595 @@ struct JetTaggerHFQA { 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 (doprocessSV2ProngData) { - 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_Sxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_2prong_Lxyz", "", {HistType::kTH2F, {{jetPtAxis}, {LxyzAxis}}}); - registry.add("h2_jet_pt_2prong_Sxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); + 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_2prong_Sxy_sigmaLxy", "", {HistType::kTH2F, {{SxyAxis}, {sigmaLxyAxis}}}); - registry.add("h2_2prong_Sxyz_sigmaLxyz", "", {HistType::kTH2F, {{SxyzAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_2prong_sigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyAxis}}}); - registry.add("h2_jet_pt_2prong_sigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_2prong_Sxy_cutSxyAndsigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_2prong_Sxyz_cutSxyzAndsigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_jet_pt_2prong_Sxy_N1_cutSxyAndsigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_2prong_Sxyz_N1_cutSxyzAndsigmaLxyz", "", {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}}}); } if (doprocessSV3ProngData) { - 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_Sxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_3prong_Lxyz", "", {HistType::kTH2F, {{jetPtAxis}, {LxyzAxis}}}); - registry.add("h2_jet_pt_3prong_Sxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); + 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_3prong_Sxy_sigmaLxy", "", {HistType::kTH2F, {{SxyAxis}, {sigmaLxyAxis}}}); - registry.add("h2_3prong_Sxyz_sigmaLxyz", "", {HistType::kTH2F, {{SxyzAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_3prong_sigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyAxis}}}); - registry.add("h2_jet_pt_3prong_sigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {sigmaLxyzAxis}}}); - registry.add("h2_jet_pt_3prong_Sxy_cutSxyAndsigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_3prong_Sxyz_cutSxyzAndsigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - registry.add("h2_jet_pt_3prong_Sxy_N1_cutSxyAndsigmaLxy", "", {HistType::kTH2F, {{jetPtAxis}, {SxyAxis}}}); - registry.add("h2_jet_pt_3prong_Sxyz_N1_cutSxyzAndsigmaLxyz", "", {HistType::kTH2F, {{jetPtAxis}, {SxyzAxis}}}); - } - if (doprocessSV2ProngMCD) { - 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_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_Sxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); + 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_2prong_Sxy_sigmaLxy_flavour", "", {HistType::kTH3F, {{SxyAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_2prong_Sxyz_sigmaLxyz_flavour", "", {HistType::kTH3F, {{SxyzAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxy_flavour_cutSxyAndsigmaLxy", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_flavour_cutSxyzAndsigmaLxyz", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxy_N1_flavour_cutSxyAndsigmaLxy", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_2prong_Sxyz_N1_flavour_cutSxyzAndsigmaLxyz", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - } - if (doprocessSV3ProngMCD) { - 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_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_Sxyz_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) { + 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_3prong_Sxy_sigmaLxy_flavour", "", {HistType::kTH3F, {{SxyAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_3prong_Sxyz_sigmaLxyz_flavour", "", {HistType::kTH3F, {{SxyzAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxy_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_sigmaLxyz_flavour", "", {HistType::kTH3F, {{jetPtAxis}, {sigmaLxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxy_flavour_cutSxyAndsigmaLxy", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_flavour_cutSxyzAndsigmaLxyz", "", {HistType::kTH3F, {{jetPtAxis}, {SxyzAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxy_N1_flavour_cutSxyAndsigmaLxy", "", {HistType::kTH3F, {{jetPtAxis}, {SxyAxis}, {jetFlavourAxis}}}); - registry.add("h3_jet_pt_3prong_Sxyz_N1_flavour_cutSxyzAndsigmaLxyz", "", {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) { + 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}}}); } } // 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; + Preslice particlesPerCollision = aod::jmcparticle::mcCollisionId; - using JetTagTracksData = soa::Join; - using JetTagTracksMCD = soa::Join; - using OriTracksData = soa::Join; - using OriTracksMCD = soa::Join; + using JetTagTracksData = soa::Join; + using JetTagTracksMCD = soa::Join; std::function&, const std::vector&)> sortImp = [](const std::vector& a, const std::vector& b) { return a[0] > b[0]; }; - template - bool trackAcceptance(T const& track) + template + bool isAcceptedJet(U const& jet) { - if (track.pt() < trackPtMin || track.pt() > trackPtMax) - return false; + 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; } - bool prongAcceptance(float sigmaDecayLength, float decayLengthSig, float maxSigmaDecayLength, float minDecayLengthSig) + template + bool trackAcceptance(T const& track) { - if ((sigmaDecayLength < maxSigmaDecayLength) && (decayLengthSig > minDecayLengthSig)) - return true; + if (track.pt() < trackPtMin || track.pt() > trackPtMax) + return false; - return false; + return true; } - template - std::tuple getMaxSxyForJet(const JetType& mcdjet) + template + void fillHistogramIPsData(T const& jet, U const& /*jtracks*/) { - float maxSxy = 0; - float correspondingErrorDecayLengthXY = 0; - - for (const auto& prong : mcdjet.template secondaryVertices_as()) { - float Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY(); - if (maxSxy < Sxy) { - maxSxy = Sxy; - correspondingErrorDecayLengthXY = prong.errorDecayLengthXY(); + float eventWeight = 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat) { + return; + } + std::vector> vecSignImpXYSig, vecSignImpZSig, vecSignImpXYZSig; + for (auto& track : jet.template tracks_as()) { + if (!trackAcceptance(track)) + continue; + if (!jettaggingutilities::trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) + continue; + // General parameters + registry.fill(HIST("h3_jet_pt_track_pt_track_eta"), jet.pt(), track.pt(), track.eta()); + registry.fill(HIST("h3_jet_pt_track_pt_track_phi"), jet.pt(), track.pt(), track.phi()); + int geoSign = jettaggingutilities::getGeoSign(jet, track); + if (fillIPxy) { + float varImpXY, varSignImpXY, varImpXYSig, varSignImpXYSig; + varImpXY = 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("h2_jet_pt_impact_parameter_xy"), jet.pt(), varImpXY); + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xy"), jet.pt(), varSignImpXY); + registry.fill(HIST("h2_jet_pt_impact_parameter_xy_significance"), jet.pt(), varImpXYSig); + registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_xy_significance"), jet.pt(), track.pt(), varSignImpXYSig); + vecSignImpXYSig.push_back({varSignImpXYSig, track.pt()}); + } + if (fillIPz) { + float varImpZ, varSignImpZ, varImpZSig, varSignImpZSig; + varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; + varSignImpZ = geoSign * std::abs(track.dcaZ()) * jettaggingutilities::cmTomum; + varImpZSig = track.dcaZ() / track.sigmadcaZ(); + varSignImpZSig = geoSign * std::abs(track.dcaZ()) / track.sigmadcaZ(); + registry.fill(HIST("h2_jet_pt_impact_parameter_z"), jet.pt(), varImpZ); + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_z"), jet.pt(), varSignImpZ); + registry.fill(HIST("h2_jet_pt_impact_parameter_z_significance"), jet.pt(), varImpZSig); + registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_z_significance"), jet.pt(), track.pt(), varSignImpZSig); + vecSignImpZSig.push_back({varSignImpZSig, track.pt()}); + } + if (fillIPxyz) { + float varImpXYZ, varSignImpXYZ, varImpXYZSig, varSignImpXYZSig; + varImpXYZ = track.dcaXYZ() * jettaggingutilities::cmTomum; + varSignImpXYZ = geoSign * std::abs(track.dcaXYZ()) * jettaggingutilities::cmTomum; + varImpXYZSig = track.dcaXYZ() / track.sigmadcaXYZ(); + varSignImpXYZSig = geoSign * std::abs(track.dcaXYZ()) / track.sigmadcaXYZ(); + registry.fill(HIST("h2_jet_pt_impact_parameter_xyz"), jet.pt(), varImpXYZ); + registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xyz"), jet.pt(), varSignImpXYZ); + registry.fill(HIST("h2_jet_pt_impact_parameter_xyz_significance"), jet.pt(), varImpXYZSig); + registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_xyz_significance"), jet.pt(), track.pt(), varSignImpXYZSig); + vecSignImpXYZSig.push_back({varSignImpXYZSig, track.pt()}); } } - return std::make_tuple(maxSxy, correspondingErrorDecayLengthXY); - } - template - std::tuple getMaxSxyzForJet(const JetType& mcdjet) - { - float maxSxyz = 0; - float correspondingErrorDecayLength = 0; - - for (const auto& prong : mcdjet.template secondaryVertices_as()) { - float Sxyz = prong.decayLength() / prong.errorDecayLength(); - if (maxSxyz < Sxyz) { - maxSxyz = Sxyz; - correspondingErrorDecayLength = prong.errorDecayLength(); + if (!fillTrackCounting) + return; + if (fillIPxy) + std::sort(vecSignImpXYSig.begin(), vecSignImpXYSig.end(), sortImp); + if (fillIPz) + std::sort(vecSignImpZSig.begin(), vecSignImpZSig.end(), sortImp); + if (fillIPxyz) + std::sort(vecSignImpXYZSig.begin(), vecSignImpXYZSig.end(), sortImp); + 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()) { + 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()) { + 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); } } - return std::make_tuple(maxSxyz, correspondingErrorDecayLength); } - template - void fillHistogramIPsData(T const& collision, U const& jets, V const& /*jtracks*/, W const& /*tracks*/) + template + void fillHistogramIPsMCD(T const& mcdjet, U const& /*jtracks*/, float eventWeight = 1.0) { - for (auto& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + 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]; + std::vector vecImpZ[numberOfJetFlavourSpecies], vecSignImpZ[numberOfJetFlavourSpecies], vecImpZSig[numberOfJetFlavourSpecies], vecSignImpZSig[numberOfJetFlavourSpecies]; + std::vector vecImpXYZ[numberOfJetFlavourSpecies], vecSignImpXYZ[numberOfJetFlavourSpecies], vecImpXYZSig[numberOfJetFlavourSpecies], vecSignImpXYZSig[numberOfJetFlavourSpecies]; + std::vector> vecSignImpXYSigTC, vecSignImpZSigTC, vecSignImpXYZSigTC; + int jetflavour = mcdjet.origin(); + if (jetflavour == JetTaggingSpecies::none) { + LOGF(debug, "NOT DEFINE JET FLAVOR"); + } + 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()) { + if (!trackAcceptance(track)) + continue; + if (!jettaggingutilities::trackAcceptanceWithDca(track, trackDcaXYMax, trackDcaZMax)) continue; + + // General parameters + registry.fill(HIST("h3_jet_pt_track_pt_flavour"), mcdjet.pt(), track.pt(), jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_track_eta_flavour"), mcdjet.pt(), track.eta(), jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_track_phi_flavour"), mcdjet.pt(), track.phi(), jetflavour, eventWeight); + 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"), mcdjet.pt(), varImpXY, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sigma_impact_parameter_xy_flavour"), mcdjet.pt(), varSigmaImpXY, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_flavour"), mcdjet.pt(), varSignImpXY, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_impact_parameter_xy_significance_flavour"), mcdjet.pt(), varImpXYSig, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour"), mcdjet.pt(), varSignImpXYSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_xy_flavour"), track.pt(), varImpXY, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_flavour"), track.pt(), varSignImpXY, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_xy_significance_flavour"), track.pt(), varImpXYSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_significance_flavour"), track.pt(), varSignImpXYSig, jetflavour, eventWeight); + vecImpXY[jetflavour].push_back(varImpXY); + vecSignImpXY[jetflavour].push_back(varSignImpXY); + vecImpXYSig[jetflavour].push_back(varImpXYSig); + vecSignImpXYSig[jetflavour].push_back(varSignImpXYSig); + vecSignImpXYSigTC.push_back({varSignImpXYSig, track.pt()}); } - std::vector> vecSignImpXYSig, vecSignImpZSig, vecSignImpXYZSig; - for (auto& jtrack : jet.template tracks_as()) { - auto track = jtrack.template track_as(); - if (!trackAcceptance(track)) - continue; - - // General parameters - registry.fill(HIST("h3_jet_pt_track_pt_track_eta"), jet.pt(), track.pt(), track.eta()); - registry.fill(HIST("h3_jet_pt_track_pt_track_phi"), jet.pt(), track.pt(), track.phi()); - int geoSign = jettaggingutilities::getGeoSign(collision, jet, track); - if (fillIPxy) { - float varImpXY, varSignImpXY, varImpXYSig, varSignImpXYSig; - varImpXY = track.dcaXY() * jettaggingutilities::cmTomum; - varSignImpXY = geoSign * std::abs(track.dcaXY()) * jettaggingutilities::cmTomum; - varImpXYSig = track.dcaXY() / std::sqrt(track.sigmaDcaXY2()); - varSignImpXYSig = geoSign * std::abs(track.dcaXY()) / std::sqrt(track.sigmaDcaXY2()); - registry.fill(HIST("h2_jet_pt_impact_parameter_xy"), jet.pt(), varImpXY); - registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xy"), jet.pt(), varSignImpXY); - registry.fill(HIST("h2_jet_pt_impact_parameter_xy_significance"), jet.pt(), varImpXYSig); - registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_xy_significance"), jet.pt(), track.pt(), varSignImpXYSig); - vecSignImpXYSig.push_back({varSignImpXYSig, track.pt()}); - } - if (fillIPz) { - float varImpZ, varSignImpZ, varImpZSig, varSignImpZSig; - varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; - varSignImpZ = geoSign * std::abs(track.dcaZ()) * jettaggingutilities::cmTomum; - varImpZSig = track.dcaZ() / std::sqrt(track.sigmaDcaZ2()); - varSignImpZSig = geoSign * std::abs(track.dcaZ()) / std::sqrt(track.sigmaDcaZ2()); - registry.fill(HIST("h2_jet_pt_impact_parameter_z"), jet.pt(), varImpZ); - registry.fill(HIST("h2_jet_pt_sign_impact_parameter_z"), jet.pt(), varSignImpZ); - registry.fill(HIST("h2_jet_pt_impact_parameter_z_significance"), jet.pt(), varImpZSig); - registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_z_significance"), jet.pt(), track.pt(), varSignImpZSig); - vecSignImpZSig.push_back({varSignImpZSig, track.pt()}); - } - if (fillIPxyz) { - float varImpXYZ, varSignImpXYZ, varImpXYZSig, varSignImpXYZSig; - float dcaXYZ = jtrack.dcaXYZ(); - float sigmaDcaXYZ2 = jtrack.sigmaDcaXYZ2(); - varImpXYZ = dcaXYZ * jettaggingutilities::cmTomum; - varSignImpXYZ = geoSign * std::abs(dcaXYZ) * jettaggingutilities::cmTomum; - varImpXYZSig = dcaXYZ / std::sqrt(sigmaDcaXYZ2); - varSignImpXYZSig = geoSign * std::abs(dcaXYZ) / std::sqrt(sigmaDcaXYZ2); - registry.fill(HIST("h2_jet_pt_impact_parameter_xyz"), jet.pt(), varImpXYZ); - registry.fill(HIST("h2_jet_pt_sign_impact_parameter_xyz"), jet.pt(), varSignImpXYZ); - registry.fill(HIST("h2_jet_pt_impact_parameter_xyz_significance"), jet.pt(), varImpXYZSig); - registry.fill(HIST("h3_jet_pt_track_pt_sign_impact_parameter_xyz_significance"), jet.pt(), track.pt(), varSignImpXYZSig); - vecSignImpXYZSig.push_back({varSignImpXYZSig, track.pt()}); - } + if (fillIPz) { + float varImpZ, varSignImpZ, varImpZSig, varSignImpZSig; + varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; + varSignImpZ = geoSign * std::abs(track.dcaZ()) * jettaggingutilities::cmTomum; + varImpZSig = track.dcaZ() / track.sigmadcaZ(); + varSignImpZSig = geoSign * std::abs(track.dcaZ()) / track.sigmadcaZ(); + registry.fill(HIST("h3_jet_pt_impact_parameter_z_flavour"), mcdjet.pt(), varImpZ, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_flavour"), mcdjet.pt(), varSignImpZ, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_impact_parameter_z_significance_flavour"), mcdjet.pt(), varImpZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour"), mcdjet.pt(), varSignImpZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_z_flavour"), track.pt(), varImpZ, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_z_flavour"), track.pt(), varSignImpZ, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_z_significance_flavour"), track.pt(), varImpZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_z_significance_flavour"), track.pt(), varSignImpZSig, jetflavour, eventWeight); + vecImpZ[jetflavour].push_back(varImpZ); + vecSignImpZ[jetflavour].push_back(varSignImpZ); + vecImpZSig[jetflavour].push_back(varImpZSig); + vecSignImpZSig[jetflavour].push_back(varSignImpZSig); + vecSignImpZSigTC.push_back({varSignImpZSig, track.pt()}); + } + if (fillIPxyz) { + float varImpXYZ, varSignImpXYZ, varImpXYZSig, varSignImpXYZSig; + float dcaXYZ = track.dcaXYZ(); + float sigmadcaXYZ = track.sigmadcaXYZ(); + varImpXYZ = dcaXYZ * jettaggingutilities::cmTomum; + varSignImpXYZ = geoSign * std::abs(dcaXYZ) * jettaggingutilities::cmTomum; + varImpXYZSig = dcaXYZ / sigmadcaXYZ; + varSignImpXYZSig = geoSign * std::abs(dcaXYZ) / sigmadcaXYZ; + registry.fill(HIST("h3_jet_pt_impact_parameter_xyz_flavour"), mcdjet.pt(), varImpXYZ, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_flavour"), mcdjet.pt(), varSignImpXYZ, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_impact_parameter_xyz_significance_flavour"), mcdjet.pt(), varImpXYZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour"), mcdjet.pt(), varSignImpXYZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_xyz_flavour"), track.pt(), varImpXYZ, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_xyz_flavour"), track.pt(), varSignImpXYZ, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_impact_parameter_xyz_significance_flavour"), track.pt(), varImpXYZSig, jetflavour, eventWeight); + registry.fill(HIST("h3_track_pt_sign_impact_parameter_xyz_significance_flavour"), track.pt(), varSignImpXYZSig, jetflavour, eventWeight); + vecImpXYZ[jetflavour].push_back(varImpXYZ); + vecSignImpXYZ[jetflavour].push_back(varSignImpXYZ); + vecImpXYZSig[jetflavour].push_back(varImpXYZSig); + vecSignImpXYZSig[jetflavour].push_back(varSignImpXYZSig); + vecSignImpXYZSigTC.push_back({varSignImpXYZSig, track.pt()}); } + } - if (!fillTrackCounting) - continue; + 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 if (fillIPxy) - std::sort(vecSignImpXYSig.begin(), vecSignImpXYSig.end(), sortImp); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N1"), mcdjet.pt(), vecSignImpXYSig[jetflavour][0], jetflavour, eventWeight); if (fillIPz) - std::sort(vecSignImpZSig.begin(), vecSignImpZSig.end(), sortImp); + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N1"), mcdjet.pt(), vecSignImpZSig[jetflavour][0], jetflavour, eventWeight); if (fillIPxyz) - std::sort(vecSignImpXYZSig.begin(), vecSignImpXYZSig.end(), sortImp); - if (fillIPxy && vecSignImpXYSig.empty()) - continue; - if (fillIPz && vecSignImpZSig.empty()) - continue; - if (fillIPxyz && vecSignImpXYZSig.empty()) - continue; - 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()) { - 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()) { - 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); - } - } + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N1"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][0], jetflavour, eventWeight); + } + if (vecImpXY[jetflavour].size() > 1) { // N2 + if (fillIPxy) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N2"), mcdjet.pt(), vecSignImpXYSig[jetflavour][1], jetflavour, eventWeight); + if (fillIPz) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N2"), mcdjet.pt(), vecSignImpZSig[jetflavour][1], jetflavour, eventWeight); + if (fillIPxyz) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N2"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][1], jetflavour, eventWeight); + } + if (vecImpXY[jetflavour].size() > 2) { // N3 + if (fillIPxy) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N3"), mcdjet.pt(), vecSignImpXYSig[jetflavour][2], jetflavour, eventWeight); + if (fillIPz) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N3"), mcdjet.pt(), vecSignImpZSig[jetflavour][2], jetflavour, eventWeight); + if (fillIPxyz) + registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N3"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][2], jetflavour, eventWeight); } - } - template - void fillHistogramIPsMCD(T const& collision, U const& mcdjets, V const& /*jtracks*/, W const& /*tracks*/) - { - for (auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - std::vector vecImpXY[numberOfJetFlavourSpecies], vecSignImpXY[numberOfJetFlavourSpecies], vecImpXYSig[numberOfJetFlavourSpecies], vecSignImpXYSig[numberOfJetFlavourSpecies]; - std::vector vecImpZ[numberOfJetFlavourSpecies], vecSignImpZ[numberOfJetFlavourSpecies], vecImpZSig[numberOfJetFlavourSpecies], vecSignImpZSig[numberOfJetFlavourSpecies]; - std::vector vecImpXYZ[numberOfJetFlavourSpecies], vecSignImpXYZ[numberOfJetFlavourSpecies], vecImpXYZSig[numberOfJetFlavourSpecies], vecSignImpXYZSig[numberOfJetFlavourSpecies]; - std::vector> vecSignImpXYSigTC, vecSignImpZSigTC, vecSignImpXYZSigTC; - int jetflavour = mcdjet.origin(); - if (jetflavour == JetTaggingSpecies::none) { - LOGF(debug, "NOT DEFINE JET FLAVOR"); - } - registry.fill(HIST("h2_jet_pt_flavour"), mcdjet.pt(), jetflavour); - registry.fill(HIST("h2_jet_eta_flavour"), mcdjet.eta(), jetflavour); - registry.fill(HIST("h2_jet_phi_flavour"), mcdjet.phi(), jetflavour); - for (auto& jtrack : mcdjet.template tracks_as()) { - auto track = jtrack.template track_as(); - if (!trackAcceptance(track)) - continue; - // General parameters - registry.fill(HIST("h3_jet_pt_track_pt_flavour"), mcdjet.pt(), track.pt(), jetflavour); - registry.fill(HIST("h3_jet_pt_track_eta_flavour"), mcdjet.pt(), track.eta(), jetflavour); - registry.fill(HIST("h3_jet_pt_track_phi_flavour"), mcdjet.pt(), track.phi(), jetflavour); - int geoSign = jettaggingutilities::getGeoSign(collision, 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 = std::abs(track.dcaXY()) / std::sqrt(track.sigmaDcaXY2()); - varSignImpXYSig = geoSign * std::abs(track.dcaXY()) / std::sqrt(track.sigmaDcaXY2()); - registry.fill(HIST("h3_jet_pt_impact_parameter_xy_flavour"), mcdjet.pt(), varImpXY, jetflavour); - registry.fill(HIST("h3_jet_pt_sigma_impact_parameter_xy_flavour"), mcdjet.pt(), varSigmaImpXY, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_flavour"), mcdjet.pt(), varSignImpXY, jetflavour); - registry.fill(HIST("h3_jet_pt_impact_parameter_xy_significance_flavour"), mcdjet.pt(), varImpXYSig, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour"), mcdjet.pt(), varSignImpXYSig, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_xy_flavour"), jtrack.pt(), varImpXY, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_flavour"), jtrack.pt(), varSignImpXY, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_xy_significance_flavour"), jtrack.pt(), varImpXYSig, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xy_significance_flavour"), jtrack.pt(), varSignImpXYSig, jetflavour); - vecImpXY[jetflavour].push_back(varImpXY); - vecSignImpXY[jetflavour].push_back(varSignImpXY); - vecImpXYSig[jetflavour].push_back(varImpXYSig); - vecSignImpXYSig[jetflavour].push_back(varSignImpXYSig); - vecSignImpXYSigTC.push_back({varSignImpXYSig, jtrack.pt()}); - } - if (fillIPz) { - float varImpZ, varSignImpZ, varImpZSig, varSignImpZSig; - varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; - varSignImpZ = geoSign * std::abs(track.dcaZ()) * jettaggingutilities::cmTomum; - varImpZSig = track.dcaZ() / std::sqrt(track.sigmaDcaZ2()); - varSignImpZSig = geoSign * std::abs(track.dcaZ()) / std::sqrt(track.sigmaDcaZ2()); - registry.fill(HIST("h3_jet_pt_impact_parameter_z_flavour"), mcdjet.pt(), varImpZ, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_flavour"), mcdjet.pt(), varSignImpZ, jetflavour); - registry.fill(HIST("h3_jet_pt_impact_parameter_z_significance_flavour"), mcdjet.pt(), varImpZSig, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour"), mcdjet.pt(), varSignImpZSig, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_z_flavour"), jtrack.pt(), varImpZ, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_z_flavour"), jtrack.pt(), varSignImpZ, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_z_significance_flavour"), jtrack.pt(), varImpZSig, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_z_significance_flavour"), jtrack.pt(), varSignImpZSig, jetflavour); - vecImpZ[jetflavour].push_back(varImpZ); - vecSignImpZ[jetflavour].push_back(varSignImpZ); - vecImpZSig[jetflavour].push_back(varImpZSig); - vecSignImpZSig[jetflavour].push_back(varSignImpZSig); - vecSignImpZSigTC.push_back({varSignImpZSig, jtrack.pt()}); - } - if (fillIPxyz) { - float varImpXYZ, varSignImpXYZ, varImpXYZSig, varSignImpXYZSig; - float dcaXYZ = jtrack.dcaXYZ(); - float sigmaDcaXYZ2 = jtrack.sigmaDcaXYZ2(); - varImpXYZ = dcaXYZ * jettaggingutilities::cmTomum; - varSignImpXYZ = geoSign * std::abs(dcaXYZ) * jettaggingutilities::cmTomum; - varImpXYZSig = dcaXYZ / std::sqrt(sigmaDcaXYZ2); - varSignImpXYZSig = geoSign * std::abs(dcaXYZ) / std::sqrt(sigmaDcaXYZ2); - registry.fill(HIST("h3_jet_pt_impact_parameter_xyz_flavour"), mcdjet.pt(), varImpXYZ, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_flavour"), mcdjet.pt(), varSignImpXYZ, jetflavour); - registry.fill(HIST("h3_jet_pt_impact_parameter_xyz_significance_flavour"), mcdjet.pt(), varImpXYZSig, jetflavour); - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour"), mcdjet.pt(), varSignImpXYZSig, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_xyz_flavour"), jtrack.pt(), varImpXYZ, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xyz_flavour"), jtrack.pt(), varSignImpXYZ, jetflavour); - registry.fill(HIST("h3_track_pt_impact_parameter_xyz_significance_flavour"), jtrack.pt(), varImpXYZSig, jetflavour); - registry.fill(HIST("h3_track_pt_sign_impact_parameter_xyz_significance_flavour"), jtrack.pt(), varSignImpXYZSig, jetflavour); - vecImpXYZ[jetflavour].push_back(varImpXYZ); - vecSignImpXYZ[jetflavour].push_back(varSignImpXYZ); - vecImpXYZSig[jetflavour].push_back(varImpXYZSig); - vecSignImpXYZSig[jetflavour].push_back(varSignImpXYZSig); - vecSignImpXYZSigTC.push_back({varSignImpXYZSig, jtrack.pt()}); - } - } + std::sort(vecSignImpXYSigTC.begin(), vecSignImpXYSigTC.end(), sortImp); + std::sort(vecSignImpZSigTC.begin(), vecSignImpZSigTC.end(), sortImp); + std::sort(vecSignImpXYZSigTC.begin(), vecSignImpXYZSigTC.end(), sortImp); - if (!fillTrackCounting) - continue; - 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 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N1"), mcdjet.pt(), vecSignImpXYSig[jetflavour][0], jetflavour); - if (fillIPz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N1"), mcdjet.pt(), vecSignImpZSig[jetflavour][0], jetflavour); - if (fillIPxyz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N1"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][0], jetflavour); - } - if (vecImpXY[jetflavour].size() > 1) { // N2 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N2"), mcdjet.pt(), vecSignImpXYSig[jetflavour][1], jetflavour); - if (fillIPz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N2"), mcdjet.pt(), vecSignImpZSig[jetflavour][1], jetflavour); - if (fillIPxyz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N2"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][1], jetflavour); - } - if (vecImpXY[jetflavour].size() > 2) { // N3 - if (fillIPxy) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xy_significance_flavour_N3"), mcdjet.pt(), vecSignImpXYSig[jetflavour][2], jetflavour); - if (fillIPz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_z_significance_flavour_N3"), mcdjet.pt(), vecSignImpZSig[jetflavour][2], jetflavour); - if (fillIPxyz) - registry.fill(HIST("h3_jet_pt_sign_impact_parameter_xyz_significance_flavour_N3"), mcdjet.pt(), vecSignImpXYZSig[jetflavour][2], jetflavour); - } - - std::sort(vecSignImpXYSigTC.begin(), vecSignImpXYSigTC.end(), sortImp); - std::sort(vecSignImpZSigTC.begin(), vecSignImpZSigTC.end(), sortImp); - std::sort(vecSignImpXYZSigTC.begin(), vecSignImpXYZSigTC.end(), sortImp); - - if (vecSignImpXYSigTC.empty()) - continue; - for (int order = 1; order <= numOrder; order++) { - if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYSigTC.size()) { - registry.fill(HIST("h3_sign_impact_parameter_xy_significance_tc_flavour"), vecSignImpXYSigTC[order - 1][0], order, jetflavour); - } + if (vecSignImpXYSigTC.empty()) + return; + for (int order = 1; order <= numOrder; order++) { + if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYSigTC.size()) { + registry.fill(HIST("h3_sign_impact_parameter_xy_significance_tc_flavour"), vecSignImpXYSigTC[order - 1][0], order, jetflavour, eventWeight); } - if (vecSignImpZSigTC.empty()) - continue; - for (int order = 1; order <= numOrder; order++) { - if (fillIPxy && static_cast>::size_type>(order) < vecSignImpZSigTC.size()) { - registry.fill(HIST("h3_sign_impact_parameter_z_significance_tc_flavour"), vecSignImpZSigTC[order - 1][0], order, jetflavour); - } + } + if (vecSignImpZSigTC.empty()) + return; + for (int order = 1; order <= numOrder; order++) { + if (fillIPxy && static_cast>::size_type>(order) < vecSignImpZSigTC.size()) { + registry.fill(HIST("h3_sign_impact_parameter_z_significance_tc_flavour"), vecSignImpZSigTC[order - 1][0], order, jetflavour, eventWeight); } + } - if (vecSignImpXYZSigTC.empty()) - continue; - for (int order = 1; order <= numOrder; order++) { - if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYZSigTC.size()) { - registry.fill(HIST("h3_sign_impact_parameter_xyz_significance_tc_flavour"), vecSignImpXYZSigTC[order - 1][0], order, jetflavour); - } + if (vecSignImpXYZSigTC.empty()) + return; + for (int order = 1; order <= numOrder; order++) { + if (fillIPxy && static_cast>::size_type>(order) < vecSignImpXYZSigTC.size()) { + registry.fill(HIST("h3_sign_impact_parameter_xyz_significance_tc_flavour"), vecSignImpXYZSigTC[order - 1][0], order, jetflavour, eventWeight); } } } - template - void fillHistogramJPData(T const& /*collision*/, U const& jets) + template + void fillHistogramIPsMCP(T const& mcpjet, float eventWeight = 1.0) { - for (auto& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - 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])); + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcpjet.pt() > pTHatMaxMCD * pTHat) { + return; } + int jetflavour = mcpjet.origin(); + if (jetflavour == JetTaggingSpecies::none) { + LOGF(debug, "NOT DEFINE JET FLAVOR"); + } + registry.fill(HIST("h2_jet_pt_part_flavour"), mcpjet.pt(), jetflavour, eventWeight); + registry.fill(HIST("h2_jet_eta_part_flavour"), mcpjet.eta(), jetflavour, eventWeight); + registry.fill(HIST("h2_jet_phi_part_flavour"), mcpjet.phi(), jetflavour, eventWeight); } - template - void fillHistogramJPMCD(T const& /*collision*/, U const& mcdjets) + template + void fillHistogramIPsMatched(T const& mcdjet, U const&, V const&, W const& particlesPerColl, float eventWeight = 1.0) { - for (auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; + 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); } - registry.fill(HIST("h3_jet_pt_JP_flavour"), mcdjet.pt(), mcdjet.jetProb()[0], mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_neg_log_JP_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[0]), mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_JP_N1_flavour"), mcdjet.pt(), mcdjet.jetProb()[1], mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N1_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[1]), mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_JP_N2_flavour"), mcdjet.pt(), mcdjet.jetProb()[2], mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N2_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[2]), mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_JP_N3_flavour"), mcdjet.pt(), mcdjet.jetProb()[3], mcdjet.origin()); - registry.fill(HIST("h3_jet_pt_neg_log_JP_N3_flavour"), mcdjet.pt(), -1 * TMath::Log(mcdjet.jetProb()[3]), mcdjet.origin()); } + 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) + { + float eventWeight = 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + 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])); + } + + template + void fillHistogramJPMCD(T const& mcdjet, float eventWeight = 1.0) + { + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + 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 fillHistogramSV2ProngData(T const& /*collision*/, U const& jets, V const& /*prongs*/) + void fillHistogramJPMatched(T const& mcdjet, U const&, V const& particlesPerColl, float eventWeight = 1.0) { - for (const auto& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - auto [maxSxy, sigmaLxy] = getMaxSxyForJet(jet); - auto [maxSxyz, sigmaLxyz] = getMaxSxyzForJet(jet); - registry.fill(HIST("h_2prong_nprongs"), jet.template secondaryVertices_as().size()); - for (const auto& prong : jet.template secondaryVertices_as()) { + 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); + } + + template + void fillHistogramSV2ProngData(T const& jet, U const& /*prongs*/) + { + float eventWeight = 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat) { + return; + } + if (jet.template secondaryVertices_as().size() < 1) + return; + 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(); @@ -689,39 +881,48 @@ struct JetTaggerHFQA { 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_2prong_Sxy_sigmaLxy"), Sxy, prong.errorDecayLengthXY()); - registry.fill(HIST("h2_2prong_Sxyz_sigmaLxyz"), Sxyz, 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()); - if (prongAcceptance(prong.errorDecayLengthXY(), Sxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h2_jet_pt_2prong_Sxy_cutSxyAndsigmaLxy"), jet.pt(), Sxy); - } - if (prongAcceptance(prong.errorDecayLength(), Sxyz, maxSigmaLxyz2Prong, minSxyz2Prong)) { - registry.fill(HIST("h2_jet_pt_2prong_Sxyz_cutSxyzAndsigmaLxyz"), jet.pt(), Sxyz); - } } + } + bool checkSv = false; + auto bjetCand = jettaggingutilities::jetFromProngMaxDecayLength(jet, 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("h2_jet_pt_2prong_Sxy_N1"), jet.pt(), maxSxy); - registry.fill(HIST("h2_jet_pt_2prong_Sxyz_N1"), jet.pt(), maxSxyz); - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h2_jet_pt_2prong_Sxy_N1_cutSxyAndsigmaLxy"), jet.pt(), maxSxy); + registry.fill(HIST("h2_jet_pt_2prong_mass_N1"), jet.pt(), massSV); + if (jet.flagtaggedjetSV()) { + registry.fill(HIST("h2_taggedjet_pt_2prong_Sxy_N1"), jet.pt(), maxSxy); + registry.fill(HIST("h2_taggedjet_pt_2prong_mass_N1"), jet.pt(), massSV); } - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h2_jet_pt_2prong_Sxyz_N1_cutSxyzAndsigmaLxyz"), jet.pt(), maxSxyz); + } + auto bjetCandXYZ = jettaggingutilities::jetFromProngMaxDecayLength(jet, 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("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()) { + 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); } } } - template - void fillHistogramSV3ProngData(T const& /*collision*/, U const& jets, V const& /*prongs*/) + template + void fillHistogramSV3ProngData(T const& jet, U const& /*prongs*/) { - for (const auto& jet : jets) { - if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - auto [maxSxy, sigmaLxy] = getMaxSxyForJet(jet); - auto [maxSxyz, sigmaLxyz] = getMaxSxyzForJet(jet); - registry.fill(HIST("h_3prong_nprongs"), jet.template secondaryVertices_as().size()); - for (const auto& prong : jet.template secondaryVertices_as()) { + float eventWeight = 1.0; + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (jet.pt() > pTHatMaxMCD * pTHat) { + return; + } + if (jet.template secondaryVertices_as().size() < 1) + return; + 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(); @@ -730,108 +931,238 @@ struct JetTaggerHFQA { 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_3prong_Sxy_sigmaLxy"), Sxy, prong.errorDecayLengthXY()); - registry.fill(HIST("h2_3prong_Sxyz_sigmaLxyz"), Sxyz, 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()); - if (prongAcceptance(prong.errorDecayLengthXY(), Sxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h2_jet_pt_3prong_Sxy_cutSxyAndsigmaLxy"), jet.pt(), Sxy); - } - if (prongAcceptance(prong.errorDecayLength(), Sxyz, maxSigmaLxyz3Prong, minSxyz3Prong)) { - registry.fill(HIST("h2_jet_pt_3prong_Sxyz_cutSxyzAndsigmaLxyz"), jet.pt(), Sxyz); - } } + } + bool checkSv = false; + auto bjetCand = jettaggingutilities::jetFromProngMaxDecayLength(jet, 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("h2_jet_pt_3prong_Sxy_N1"), jet.pt(), maxSxy); + registry.fill(HIST("h2_jet_pt_3prong_mass_N1"), jet.pt(), massSV); + if (jet.flagtaggedjetSV()) { + registry.fill(HIST("h2_taggedjet_pt_3prong_Sxy_N1"), jet.pt(), maxSxy); + registry.fill(HIST("h2_taggedjet_pt_3prong_mass_N1"), jet.pt(), massSV); + } + } + auto bjetCandXYZ = jettaggingutilities::jetFromProngMaxDecayLength(jet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, prongIPxyMin, prongIPxyMax, true, &checkSv); + if (checkSv && jettaggingutilities::svAcceptance(bjetCandXYZ, svDispersionMax)) { + auto maxSxyz = bjetCandXYZ.decayLength() / bjetCandXYZ.errorDecayLength(); + auto massSV = bjetCandXYZ.m(); registry.fill(HIST("h2_jet_pt_3prong_Sxyz_N1"), jet.pt(), maxSxyz); - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h2_jet_pt_3prong_Sxy_N1_cutSxyAndsigmaLxy"), jet.pt(), maxSxy); + registry.fill(HIST("h2_jet_pt_3prong_mass_xyz_N1"), jet.pt(), massSV); + if (jet.flagtaggedjetSVxyz()) { + 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); } - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h2_jet_pt_3prong_Sxyz_N1_cutSxyzAndsigmaLxyz"), jet.pt(), maxSxyz); + } + } + + template + void fillHistogramSV2ProngMCD(T const& mcdjet, U const& /*prongs*/, float eventWeight = 1.0) + { + float pTHat = 10. / (std::pow(eventWeight, 1.0 / pTHatExponent)); + if (mcdjet.pt() > pTHatMaxMCD * pTHat) { + return; + } + auto origin = mcdjet.origin(); + if (mcdjet.template secondaryVertices_as().size() < 1) + return; + 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_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin, 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"), mcdjet.pt(), maxSxy, origin, eventWeight); + registry.fill(HIST("h3_jet_pt_2prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); + if (mcdjet.flagtaggedjetSV()) { + 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); + } + } + auto bjetCandXYZ = jettaggingutilities::jetFromProngMaxDecayLength(mcdjet, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyzMax, prongIPxyMin, prongIPxyMax, true, &checkSv); + if (checkSv && jettaggingutilities::svAcceptance(bjetCandXYZ, svDispersionMax)) { + auto maxSxyz = bjetCandXYZ.decayLength() / bjetCandXYZ.errorDecayLength(); + 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()) { + 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 fillHistogramSV2ProngMCD(T const& /*collision*/, U const& mcdjets, V const& /*prongs*/) + template + void fillHistogramSV2ProngMCPMCDMatched(T const& mcdjet, U const& /*mcpjets*/, V const& /*prongs*/, W const& particlesPerColl, float eventWeight = 1.0) { - for (const auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; + 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 origin = mcdjet.origin(); - auto [maxSxy, sigmaLxy] = getMaxSxyForJet(mcdjet); - auto [maxSxyz, sigmaLxyz] = getMaxSxyzForJet(mcdjet); - registry.fill(HIST("h2_2prong_nprongs_flavour"), mcdjet.template secondaryVertices_as().size(), origin); - for (const auto& prong : mcdjet.template secondaryVertices_as()) { + } + 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; + } + auto origin = mcdjet.origin(); + if (mcdjet.template secondaryVertices_as().size() < 1) + return; + 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_2prong_Lxy_flavour"), mcdjet.pt(), Lxy, origin); - registry.fill(HIST("h3_jet_pt_2prong_Sxy_flavour"), mcdjet.pt(), Sxy, origin); - registry.fill(HIST("h3_jet_pt_2prong_Lxyz_flavour"), mcdjet.pt(), Lxyz, origin); - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_flavour"), mcdjet.pt(), Sxyz, origin); - registry.fill(HIST("h3_2prong_Sxy_sigmaLxy_flavour"), Sxy, prong.errorDecayLengthXY(), origin); - registry.fill(HIST("h3_2prong_Sxyz_sigmaLxyz_flavour"), Sxyz, prong.errorDecayLength(), origin); - registry.fill(HIST("h3_jet_pt_2prong_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin); - registry.fill(HIST("h3_jet_pt_2prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin); - if (prongAcceptance(prong.errorDecayLengthXY(), Sxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h3_jet_pt_2prong_Sxy_flavour_cutSxyAndsigmaLxy"), mcdjet.pt(), Sxy, origin); - } - if (prongAcceptance(prong.errorDecayLength(), Sxyz, maxSigmaLxyz2Prong, minSxyz2Prong)) { - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_flavour_cutSxyzAndsigmaLxyz"), mcdjet.pt(), Sxyz, origin); - } + 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_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin, eventWeight); } - registry.fill(HIST("h3_jet_pt_2prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin); - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin); - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h3_jet_pt_2prong_Sxy_N1_flavour_cutSxyAndsigmaLxy"), mcdjet.pt(), maxSxy, origin); + } + 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"), mcdjet.pt(), maxSxy, origin, eventWeight); + registry.fill(HIST("h3_jet_pt_3prong_mass_N1_flavour"), mcdjet.pt(), massSV, origin, eventWeight); + if (mcdjet.flagtaggedjetSV()) { + 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); } - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy2Prong, minSxy2Prong)) { - registry.fill(HIST("h3_jet_pt_2prong_Sxyz_N1_flavour_cutSxyzAndsigmaLxyz"), mcdjet.pt(), maxSxyz, origin); + } + 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_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()) { + 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 fillHistogramSV3ProngMCD(T const& /*collision*/, U const& mcdjets, V const& /*prongs*/) + template + void fillHistogramSV3ProngMCPMCDMatched(T const& mcdjet, U const& /*mcpjets*/, V const& /*prongs*/, W const& particlesPerColl, float eventWeight = 1.0) { - for (const auto& mcdjet : mcdjets) { - if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { - continue; - } - auto origin = mcdjet.origin(); - auto [maxSxy, sigmaLxy] = getMaxSxyForJet(mcdjet); - auto [maxSxyz, sigmaLxyz] = getMaxSxyzForJet(mcdjet); - registry.fill(HIST("h2_3prong_nprongs_flavour"), mcdjet.template secondaryVertices_as().size(), origin); + 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"), mcdjet.pt(), Lxy, origin); - registry.fill(HIST("h3_jet_pt_3prong_Sxy_flavour"), mcdjet.pt(), Sxy, origin); - registry.fill(HIST("h3_jet_pt_3prong_Lxyz_flavour"), mcdjet.pt(), Lxyz, origin); - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_flavour"), mcdjet.pt(), Sxyz, origin); - registry.fill(HIST("h3_3prong_Sxy_sigmaLxy_flavour"), Sxy, prong.errorDecayLengthXY(), origin); - registry.fill(HIST("h3_3prong_Sxyz_sigmaLxyz_flavour"), Sxyz, prong.errorDecayLength(), origin); - registry.fill(HIST("h3_jet_pt_3prong_sigmaLxy_flavour"), mcdjet.pt(), prong.errorDecayLengthXY(), origin); - registry.fill(HIST("h3_jet_pt_3prong_sigmaLxyz_flavour"), mcdjet.pt(), prong.errorDecayLength(), origin); - if (prongAcceptance(prong.errorDecayLengthXY(), Sxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h3_jet_pt_3prong_Sxy_flavour_cutSxyAndsigmaLxy"), mcdjet.pt(), Sxy, origin); - } - if (prongAcceptance(prong.errorDecayLength(), Sxyz, maxSigmaLxyz3Prong, minSxyz3Prong)) { - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_flavour_cutSxyzAndsigmaLxyz"), mcdjet.pt(), Sxyz, origin); - } + 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); } - registry.fill(HIST("h3_jet_pt_3prong_Sxy_N1_flavour"), mcdjet.pt(), maxSxy, origin); - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_N1_flavour"), mcdjet.pt(), maxSxyz, origin); - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h3_jet_pt_3prong_Sxy_N1_flavour_cutSxyAndsigmaLxy"), mcdjet.pt(), maxSxy, origin); + } + 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); } - if (prongAcceptance(sigmaLxy, maxSxy, maxSigmaLxy3Prong, minSxy3Prong)) { - registry.fill(HIST("h3_jet_pt_3prong_Sxyz_N1_flavour_cutSxyzAndsigmaLxyz"), mcdjet.pt(), maxSxyz, origin); + } + 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); } } } @@ -841,23 +1172,21 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processDummy, "Dummy process", true); - void processTracksDca(JetTagTracksData& jtracks, OriTracksData const&) + void processTracksDca(JetTagTracksData& jtracks) { for (auto const& jtrack : jtracks) { if (!jetderiveddatautilities::selectTrack(jtrack, trackSelection)) { continue; } - auto track = jtrack.track_as(); - float varImpXY, varImpXYSig, varImpZ, varImpZSig, varImpXYZ, varImpXYZSig; - varImpXY = track.dcaXY() * jettaggingutilities::cmTomum; - varImpXYSig = track.dcaXY() / std::sqrt(track.sigmaDcaXY2()); - varImpZ = track.dcaZ() * jettaggingutilities::cmTomum; - varImpZSig = track.dcaZ() / std::sqrt(track.sigmaDcaZ2()); + 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 sigmaDcaXYZ2 = jtrack.sigmaDcaXYZ2(); + float sigmadcaXYZ = jtrack.sigmadcaXYZ(); varImpXYZ = dcaXYZ * jettaggingutilities::cmTomum; - varImpXYZSig = dcaXYZ / std::sqrt(sigmaDcaXYZ2); + varImpXYZSig = dcaXYZ / sigmadcaXYZ; registry.fill(HIST("h_impact_parameter_xy"), varImpXY); registry.fill(HIST("h_impact_parameter_xy_significance"), varImpXYSig); @@ -869,60 +1198,399 @@ struct JetTaggerHFQA { } PROCESS_SWITCH(JetTaggerHFQA, processTracksDca, "Fill inclusive tracks' imformation for data", false); - void processIPsData(soa::Filtered::iterator const& jcollision, JetTagTableData const& jets, JetTagTracksData const& jtracks, OriTracksData const& tracks) + void processIPsData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTagTracksData const& jtracks) { - fillHistogramIPsData(jcollision, jets, jtracks, tracks); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillHistogramIPsData(jet, jtracks); + } } PROCESS_SWITCH(JetTaggerHFQA, processIPsData, "Fill impact parameter imformation for data jets", false); - void processIPsMCD(soa::Filtered::iterator const& jcollision, JetTagTableMCD const& mcdjets, JetTagTracksMCD const& jtracks, OriTracksMCD const& tracks, JetParticles&) + void processIPsMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::JetParticles&) { - fillHistogramIPsMCD(jcollision, mcdjets, jtracks, tracks); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramIPsMCD(mcdjet, jtracks); + } } PROCESS_SWITCH(JetTaggerHFQA, processIPsMCD, "Fill impact parameter imformation for mcd jets", false); - void processJPData(soa::Filtered::iterator const& jcollision, JetTagTableData const& jets, JetTagTracksData const&) + void processIPsMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const& jtracks, aod::JetParticles&) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + fillHistogramIPsMCD(mcdjet, jtracks, 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) + { + for (auto mcpjet : mcpjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcpjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcpjet)) { + return; + } + if (checkMcCollisionIsMatched) { + auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, mcpjet.mcCollisionId()); + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { + fillHistogramIPsMCP(mcpjet); + } + } else { + fillHistogramIPsMCP(mcpjet); + } + } + } + PROCESS_SWITCH(JetTaggerHFQA, processIPsMCP, "Fill impact parameter imformation for mcp jets", false); + + void processIPsMCPWeighted(soa::Filtered const& collisions, soa::Join const& mcpjets, aod::JetParticles&) + { + for (auto mcpjet : mcpjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcpjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcpjet)) { + return; + } + if (checkMcCollisionIsMatched) { + auto collisionspermcpjet = collisions.sliceBy(CollisionsPerMCPCollision, mcpjet.mcCollisionId()); + if (collisionspermcpjet.size() >= 1 && jetderiveddatautilities::selectCollision(collisionspermcpjet.begin(), eventSelection)) { + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto& mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramIPsMatched(mcdjet, mcpjets, jtracks, particlesPerColl); + } + } + 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) { - fillHistogramJPData(jcollision, jets); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto& mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramIPsMatched(mcdjet, mcpjets, jtracks, particlesPerColl, mcdjet.eventWeight()); + } + } + PROCESS_SWITCH(JetTaggerHFQA, processIPsMCPMCDMatchedWeighted, "Fill impact parameter imformation for mcp mcd matched jets", false); + + void processJPData(soa::Filtered::iterator const& collision, soa::Join const& jets, JetTagTracksData const&) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillHistogramJPData(jet); + } } PROCESS_SWITCH(JetTaggerHFQA, processJPData, "Fill jet probability imformation for data jets", false); - void processJPMCD(soa::Filtered::iterator const& jcollision, JetTagTableMCD const& mcdjets, JetTagTracksMCD const&) + void processJPMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const&) { - fillHistogramJPMCD(jcollision, mcdjets); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramJPMCD(mcdjet); + } } PROCESS_SWITCH(JetTaggerHFQA, processJPMCD, "Fill jet probability imformation for mcd jets", false); - void processSV2ProngData(soa::Filtered::iterator const& jcollision, soa::Join const& jets, aod::DataSecondaryVertex2Prongs const& prongs) + void processJPMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, JetTagTracksMCD const&) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramJPMCD(mcdjet, mcdjet.eventWeight()); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramJPMatched(mcdjet, mcpjets, particlesPerColl); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramJPMatched(mcdjet, mcpjets, particlesPerColl, mcdjet.eventWeight()); + } + } + PROCESS_SWITCH(JetTaggerHFQA, processJPMCPMCDMatchedWeighted, "Fill jet probability imformation for mcd jets", false); + + void processSV2ProngData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::DataSecondaryVertex2Prongs const& prongs) { - fillHistogramSV2ProngData(jcollision, jets, prongs); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillHistogramSV2ProngData(jet, prongs); + } } PROCESS_SWITCH(JetTaggerHFQA, processSV2ProngData, "Fill 2prong imformation for data jets", false); - void processSV3ProngData(soa::Filtered::iterator const& jcollision, soa::Join const& jets, aod::DataSecondaryVertex3Prongs const& prongs) + void processSV3ProngData(soa::Filtered::iterator const& collision, soa::Join const& jets, aod::DataSecondaryVertex3Prongs const& prongs) { - fillHistogramSV3ProngData(jcollision, jets, prongs); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto jet : jets) { + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(jet)) { + continue; + } + fillHistogramSV3ProngData(jet, prongs); + } } PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngData, "Fill 2prong imformation for data jets", false); - void processSV2ProngMCD(soa::Filtered::iterator const& jcollision, soa::Join const& mcdjets, aod::MCDSecondaryVertex2Prongs const& prongs) + void processSV2ProngMCD(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, aod::MCDSecondaryVertex2Prongs const& prongs) { - fillHistogramSV2ProngMCD(jcollision, mcdjets, prongs); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV2ProngMCD(mcdjet, prongs); + } } PROCESS_SWITCH(JetTaggerHFQA, processSV2ProngMCD, "Fill 2prong imformation for mcd jets", false); - void processSV3ProngMCD(soa::Filtered::iterator const& jcollision, soa::Join const& mcdjets, aod::MCDSecondaryVertex3Prongs const& prongs) + void processSV2ProngMCDWeighted(soa::Filtered::iterator const& collision, soa::Join const& mcdjets, aod::MCDSecondaryVertex2Prongs const& prongs) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV2ProngMCD(mcdjet, prongs, mcdjet.eventWeight()); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV2ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV2ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl, 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) { - fillHistogramSV3ProngMCD(jcollision, mcdjets, prongs); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV3ProngMCD(mcdjet, prongs); + } } PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngMCD, "Fill 3prong imformation for mcd jets", false); + + void processSV3ProngMCDWeighted(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) { + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV3ProngMCD(mcdjet, prongs, mcdjet.eventWeight()); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV3ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl); + } + } + 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) + { + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + for (auto mcdjet : mcdjets) { + auto const particlesPerColl = particles.sliceBy(particlesPerCollision, collision.mcCollisionId()); + if (!jetfindingutilities::isInEtaAcceptance(mcdjet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { + continue; + } + if (!isAcceptedJet(mcdjet)) { + continue; + } + fillHistogramSV3ProngMCPMCDMatched(mcdjet, mcpjets, prongs, particlesPerColl, mcdjet.eventWeight()); + } + } + PROCESS_SWITCH(JetTaggerHFQA, processSV3ProngMCPMCDMatchedWeighted, "Fill 3prong imformation for mcd jets", false); }; -using JetTaggerQAChargedDataJets = soa::Join; -using JetTaggerQAChargedMCDJets = soa::Join; +using JetTaggerQAChargedDataJets = soa::Join; +using JetTaggerQAChargedMCDJets = soa::Join; using JetTaggerQAChargedMCPJets = soa::Join; -using JetTaggerQACharged = JetTaggerHFQA; +using JetTaggerQACharged = JetTaggerHFQA; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGJE/Tasks/jetvalidationqa.cxx b/PWGJE/Tasks/jetvalidationqa.cxx index 1ef731bad09..c608c9c256c 100644 --- a/PWGJE/Tasks/jetvalidationqa.cxx +++ b/PWGJE/Tasks/jetvalidationqa.cxx @@ -169,9 +169,9 @@ struct jetTrackCollisionQa { Filter etafilter = (aod::jtrack::eta <= etaup) && (aod::jtrack::eta >= etalow); Filter ptfilter = (aod::jtrack::pt <= ptUp) && (aod::jtrack::pt >= ptLow); using Tracks = soa::Join; - using TracksJE = soa::Filtered>; + using TracksJE = soa::Filtered>; - void processESD(JetCollision const& collision, soa::Join const& jets, TracksJE const& tracks, Tracks const&) + void processESD(aod::JetCollision const& collision, soa::Join const& jets, TracksJE const& tracks, Tracks const&) { mHistManager.fill(HIST("controlCollisionVtxZ"), collision.posZ()); if (evSel == true) { @@ -239,7 +239,7 @@ struct jetTrackCollisionQa { PROCESS_SWITCH(jetTrackCollisionQa, processESD, "validate jet-finder output on run2 ESD", true); // process for run3 AOD's - void processRun3AOD(JetCollision const& collision, soa::Join const& jets, TracksJE const& tracks, Tracks const&) + 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) { @@ -304,7 +304,7 @@ struct jetTrackCollisionQa { PROCESS_SWITCH(jetTrackCollisionQa, processRun3AOD, "validate jet-finder output on run3 AOD", false); // dummy process to run jetfinder validation code on ESD, but MC validation for run3 on hyperloop - void processDummy(JetCollisions const&) + void processDummy(aod::JetCollisions const&) { } PROCESS_SWITCH(jetTrackCollisionQa, processDummy, "Dummy process function turned on by default", false); @@ -473,12 +473,12 @@ struct mcJetTrackCollisionQa { Filter etafilter = (aod::jtrack::eta < etaup) && (aod::jtrack::eta > etalow); Filter ptfilter = (aod::jtrack::pt < ptUp) && (aod::jtrack::pt > ptLow); - using MCTracksJE = soa::Filtered; + using MCTracksJE = soa::Filtered; - void processMcRun2(JetCollisionsMCD::iterator const& collision, + void processMcRun2(aod::JetCollisionsMCD::iterator const& collision, soa::Join const& mcPartJets, soa::Join const& mcDetJets, - JetParticles const&, JetMcCollisions const&, + aod::JetParticles const&, aod::JetMcCollisions const&, MCTracksJE const& tracks) { if (fabs(collision.posZ()) > 10) { @@ -491,7 +491,7 @@ struct mcJetTrackCollisionQa { for (const auto& genJet : mcPartJets) { if (genJet.mcCollisionId() == collision.globalIndex()) { fillMcPartJets(genJet); - for (auto& mcParticle : genJet.tracks_as()) { + for (auto& mcParticle : genJet.tracks_as()) { fillMcPartJetConstituents(mcParticle); } } @@ -509,10 +509,10 @@ struct mcJetTrackCollisionQa { } // end processMcRun2 PROCESS_SWITCH(mcJetTrackCollisionQa, processMcRun2, "validate jet-finder output on converted run2 mc AOD's", false); - void processMcRun3(JetCollisionsMCD::iterator const& collision, + void processMcRun3(aod::JetCollisionsMCD::iterator const& collision, soa::Join const& mcPartJets, soa::Join const& mcDetJets, - JetParticles const&, JetMcCollisions const&, + aod::JetParticles const&, aod::JetMcCollisions const&, MCTracksJE const& tracks) { if (fabs(collision.posZ()) > 10) { @@ -525,7 +525,7 @@ struct mcJetTrackCollisionQa { for (const auto& genJet : mcPartJets) { if (genJet.mcCollisionId() == collision.globalIndex()) { fillMcPartJets(genJet); - for (auto& mcParticle : genJet.tracks_as()) { + for (auto& mcParticle : genJet.tracks_as()) { fillMcPartJetConstituents(mcParticle); } } @@ -544,7 +544,7 @@ struct mcJetTrackCollisionQa { PROCESS_SWITCH(mcJetTrackCollisionQa, processMcRun3, "validate jet-finder output on run3 mc AOD's", false); // dummy process to run jetfinder validation code on AO2D's, but MC validation for run3 on hyperloop - void processDummy(JetMcCollisions const&) + void processDummy(aod::JetMcCollisions const&) { } PROCESS_SWITCH(mcJetTrackCollisionQa, processDummy, "Dummy process function turned off by default", true); diff --git a/PWGJE/Tasks/mcgeneratorstudies.cxx b/PWGJE/Tasks/mcgeneratorstudies.cxx index 4df20c893ce..98ec04f3341 100644 --- a/PWGJE/Tasks/mcgeneratorstudies.cxx +++ b/PWGJE/Tasks/mcgeneratorstudies.cxx @@ -21,6 +21,9 @@ #include "PWGJE/DataModel/EMCALMatchedCollisions.h" +#include "DetectorsBase/GeometryManager.h" +#include "EMCALBase/Geometry.h" + #include "Common/DataModel/TrackSelectionTables.h" #include "Common/DataModel/EventSelection.h" @@ -28,57 +31,248 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using MyMCCollisions = soa::Join; +using MyMCCollisions = soa::Join; +using MyBCs = o2::soa::Join; struct MCGeneratorStudies { HistogramRegistry mHistManager{"MCGeneratorStudyHistograms"}; 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"}; - - Filter collisionFilter = (aod::collision::posZ > -mVertexCut) && (aod::collision::posZ < mVertexCut); - Filter mcParticleFilter = (aod::mcparticle::pdgCode == mSelectedParticleCode) && (aod::mcparticle::y > -mRapidityCut) && (aod::mcparticle::y < mRapidityCut); + Configurable mSelectedParticleCode{"particlePDGCode", 111, "PDG code of the particle to be investigated (0 for all)"}; + 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"}; void init(InitContext const&) { AxisSpec pTAxis{250, 0., 25., "#it{p}_{T} (GeV/#it{c})"}; - mHistManager.add("hCollisionCounter", "Number of collisions after event cuts", HistType::kTH1F, {{5, 0.5, 5.5}}); - mHistManager.add("hpT_all", "All collisions", HistType::kTH1F, {pTAxis}); - mHistManager.add("hpT_T0Triggered", "T0 triggered collisions", HistType::kTH1F, {pTAxis}); - mHistManager.add("hpT_T0Triggered_EMCReadout", "T0 triggered and EMC readout collisions", HistType::kTH1F, {pTAxis}); - mHistManager.add("hpT_T0Triggered_EMCReadout_Unique", "Unique T0 triggered and EMC readout collisions", HistType::kTH1F, {pTAxis}); + auto hCollisionCounter = mHistManager.add("hCollisionCounter", "Number of collisions after event cuts", HistType::kTH1F, {{7, 0.5, 7.5}}); + hCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hCollisionCounter->GetXaxis()->SetBinLabel(2, "+TVX"); // TVX + hCollisionCounter->GetXaxis()->SetBinLabel(3, "+|z|<10cm"); // TVX with z < 10cm + hCollisionCounter->GetXaxis()->SetBinLabel(4, "+Sel8"); // TVX with z < 10cm and Sel8 + hCollisionCounter->GetXaxis()->SetBinLabel(5, "+Good z vtx"); // TVX with z < 10cm and Sel8 and good z xertex + hCollisionCounter->GetXaxis()->SetBinLabel(6, "+unique"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC) + hCollisionCounter->GetXaxis()->SetBinLabel(7, "+EMC readout"); // TVX with z < 10cm and Sel8 and good z xertex and unique (only collision in the BC) and kTVXinEMC + + auto hBCCounter = mHistManager.add("hBCCounter", "Number of BCs after BC cuts", HistType::kTH1F, {{3, 0.5, 3.5}}); + hBCCounter->GetXaxis()->SetBinLabel(1, "all"); + hBCCounter->GetXaxis()->SetBinLabel(2, "+TVX"); + hBCCounter->GetXaxis()->SetBinLabel(3, "+Collision"); + + TString mesonLatexString = (TString)mSelectedParticleCode; + switch (mSelectedParticleCode) { + case 0: + mesonLatexString = "particles"; + break; + case 111: + mesonLatexString = "#pi^{0}"; + break; + case 221: + mesonLatexString = "#eta"; + break; + } + mHistManager.add("Yield", Form("Generated %s in all collisions", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_Accepted", Form("Accepted %s in all collisions", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_T", Form("Generated %s in TVX triggered collisions", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZ", Form("Generated %s in TVX collisions with z < 10cm", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZS", Form("Generated %s in TVX collisions with z < 10cm and Sel8", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZSG", Form("Generated %s in collisions with good z < 10cm and Sel8", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZSGU", Form("Generated %s in unique collisions with good z < 10cm and Sel8", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZSGUE", Form("Generated %s in unique TVXinEMC collisions with good z < 10cm and Sel8", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_TZSGUE_Accepted", Form("Accepted %s in unique TVXinEMC collisions with good z < 10cm and Sel8", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + + mHistManager.add("Yield_BC_T", Form("Generated %s in TVX triggered BCs", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("Yield_BC_TC", Form("Generated %s in TVX triggered BCs that have at least one collision", mesonLatexString.Data()), HistType::kTH1F, {pTAxis}); + mHistManager.add("NCollisionsMCCollisions", "Number of (MC)Collisions in the BC;#it{N}_(Collisions);#it{N}_(MC Collisions)", kTH2F, {{4, -0.5, 3.5}, {4, -0.5, 3.5}}); + mHistManager.add("NTVXCollisionsMCCollisions", "Number of (MC)Collisions in the TVX triggered BC;#it{N}_(Collisions);#it{N}_(MC Collisions)", kTH2F, {{4, -0.5, 3.5}, {4, -0.5, 3.5}}); + + auto hEMCollisionCounter = mHistManager.add("hEMCollisionCounter", "collision counter;;Number of events", kTH1F, {{13, 0.5, 13.5}}, false); + hEMCollisionCounter->GetXaxis()->SetBinLabel(1, "all"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(2, "No TF border"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(3, "No ITS ROF border"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(4, "No Same Bunch Pileup"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(5, "Is Vertex ITSTPC"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(6, "Is Good Zvtx FT0vsPV"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(7, "FT0AND"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(8, "sel8"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(9, "|Z_{vtx}| < 10 cm"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(10, "EMC MB Readout"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(11, "EMC L0 Triggered"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(12, "EMC Cell Content"); + hEMCollisionCounter->GetXaxis()->SetBinLabel(13, "accepted"); + + o2::emcal::Geometry::GetInstanceFromRunNumber(300000); } - PresliceUnsorted perMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted perFoundBC = aod::evsel::foundBCId; + Preslice MCCollperBC = aod::mccollision::bcId; + Preslice perMcCollision = aod::mcparticle::mcCollisionId; - void process(soa::Filtered::iterator const& collision, soa::Filtered const& mcParticles) + void process(MyBCs const& bcs, MyMCCollisions const& collisions, aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { - bool isT0Triggered = collision.sel8(); - bool isEMCReadout = collision.isemcreadout(); - bool isUniqueCollision = !collision.ambiguous(); - - mHistManager.fill(HIST("hCollisionCounter"), 1); - if (isT0Triggered) { - mHistManager.fill(HIST("hCollisionCounter"), 2); - // mHistManager.fill(HIST("hpT_T0Triggered"), mcParticles, aod::evsel::sel8 == true); - if (isEMCReadout) { - mHistManager.fill(HIST("hCollisionCounter"), 3); - if (isUniqueCollision) { - mHistManager.fill(HIST("hCollisionCounter"), 4); + + for (const auto& bc : bcs) { + + auto collisionsInFoundBC = collisions.sliceBy(perFoundBC, bc.globalIndex()); + auto MCCollisionsBC = mcCollisions.sliceBy(MCCollperBC, bc.globalIndex()); + + 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 + + mHistManager.fill(HIST("NTVXCollisionsMCCollisions"), collisionsInFoundBC.size(), mcCollisions.size()); + + mHistManager.fill(HIST("hBCCounter"), 2); + + bool bcHasCollision = collisionsInFoundBC.size() > 0; + + if (bcHasCollision) + mHistManager.fill(HIST("hBCCounter"), 3); + + for (auto& mcCollision : MCCollisionsBC) { + + auto mcParticles_inColl = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); + + for (auto& mcParticle : mcParticles_inColl) { + if (mcParticle.pdgCode() != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + continue; + if (fabs(mcParticle.y()) > mRapidityCut) + continue; + if (!mcParticle.isPhysicalPrimary() && !mcParticle.producedByGenerator()) + continue; + if (mRequireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) + continue; + + mHistManager.fill(HIST("Yield_BC_T"), mcParticle.pt()); + + if (bcHasCollision) + mHistManager.fill(HIST("Yield_BC_TC"), mcParticle.pt()); + } } } } - auto mcParticles_inColl = mcParticles.sliceBy(perMcCollision, collision.globalIndex()); - for (auto& mcParticle : mcParticles_inColl) { - mHistManager.fill(HIST("hpT_all"), mcParticle.pt()); - if (isT0Triggered) { - mHistManager.fill(HIST("hpT_T0Triggered"), mcParticle.pt()); - if (isEMCReadout) { - mHistManager.fill(HIST("hpT_T0Triggered_EMCReadout"), mcParticle.pt()); - if (isUniqueCollision) { - mHistManager.fill(HIST("hpT_T0Triggered_EMCReadout_Unique"), mcParticle.pt()); + + for (auto& collision : collisions) { + fillEventHistogram(&mHistManager, collision); + + auto mcCollision = collision.mcCollision(); + auto mcParticles_inColl = mcParticles.sliceBy(perMcCollision, mcCollision.globalIndex()); + + for (auto& mcParticle : mcParticles_inColl) { + if (mcParticle.pdgCode() != 0 && mcParticle.pdgCode() != mSelectedParticleCode) + continue; + if (fabs(mcParticle.y()) > mRapidityCut) + continue; + if (!mcParticle.isPhysicalPrimary() && !mcParticle.producedByGenerator()) + continue; + if (mRequireGammaGammaDecay && !isGammaGammaDecay(mcParticle, mcParticles)) + continue; + + 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)) { + mHistManager.fill(HIST("Yield_T"), mcParticle.pt()); + if (abs(collision.posZ()) < mVertexCut) { + mHistManager.fill(HIST("Yield_TZ"), mcParticle.pt()); + if (collision.sel8()) { + mHistManager.fill(HIST("Yield_TZS"), mcParticle.pt()); + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + mHistManager.fill(HIST("Yield_TZSG"), mcParticle.pt()); + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + mHistManager.fill(HIST("Yield_TZSGU"), mcParticle.pt()); + if (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()); + } + } + } + } + } + } + } + } + } + + 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; + } + + template + bool isAccepted(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; + 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 fillEventHistogram(HistogramRegistry* fRegistry, MyMCCollisions::iterator const& collision) + { + fRegistry->fill(HIST("hEMCollisionCounter"), 1.0); + if (collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + fRegistry->fill(HIST("hEMCollisionCounter"), 2.0); + if (collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + fRegistry->fill(HIST("hEMCollisionCounter"), 3.0); + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + fRegistry->fill(HIST("hEMCollisionCounter"), 4.0); + if (collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) + fRegistry->fill(HIST("hEMCollisionCounter"), 5.0); + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) + fRegistry->fill(HIST("hEMCollisionCounter"), 6.0); + if (collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) + fRegistry->fill(HIST("hEMCollisionCounter"), 7.0); + if (collision.sel8()) + fRegistry->fill(HIST("hEMCollisionCounter"), 8.0); + if (abs(collision.posZ()) < 10.0) + fRegistry->fill(HIST("hEMCollisionCounter"), 9.0); + if (collision.alias_bit(kTVXinEMC)) + fRegistry->fill(HIST("hEMCollisionCounter"), 10.0); + if (collision.alias_bit(kEMC7) || collision.alias_bit(kDMC7)) + fRegistry->fill(HIST("hEMCollisionCounter"), 11.0); + if (collision.isemcreadout()) + fRegistry->fill(HIST("hEMCollisionCounter"), 12.0); + fRegistry->fill(HIST("hEMCollisionCounter"), 13.0); + + fRegistry->fill(HIST("hCollisionCounter"), 1); + if (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()) { + fRegistry->fill(HIST("hCollisionCounter"), 4); + if (collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + fRegistry->fill(HIST("hCollisionCounter"), 5); + if (collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + fRegistry->fill(HIST("hCollisionCounter"), 6); + if (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 b1a695bd9f7..1eabf7c6c50 100644 --- a/PWGJE/Tasks/nSubjettiness.cxx +++ b/PWGJE/Tasks/nSubjettiness.cxx @@ -227,7 +227,7 @@ struct NSubjettinessTask { table(jet.pt(), jet.eta(), jet.phi(), nSub_Kt_results[1], nSub_Kt_results[2], nSub_Kt_results[0], nSub_CA_results[1], nSub_CA_results[2], nSub_CA_results[0], nSub_CASD_results[1], nSub_CASD_results[2], nSub_CASD_results[0]); } - void processJetsData(soa::Filtered::iterator const&, soa::Filtered> const& jets, JetTracks const& tracks) + void processJetsData(soa::Filtered::iterator const&, soa::Filtered> const& jets, aod::JetTracks const& tracks) { for (auto& jet : jets) { processJet(jet, tracks); @@ -236,7 +236,7 @@ struct NSubjettinessTask { } PROCESS_SWITCH(NSubjettinessTask, processJetsData, "Process function for inclusive jets in data", true); - void processJetsDataEWS(soa::Filtered::iterator const&, soa::Filtered> const& jets, JetTracksSub const& tracks) + void processJetsDataEWS(soa::Filtered::iterator const&, soa::Filtered> const& jets, aod::JetTracksSub const& tracks) { for (auto& jet : jets) { processJet(jet, tracks); @@ -245,7 +245,7 @@ struct NSubjettinessTask { } PROCESS_SWITCH(NSubjettinessTask, processJetsDataEWS, "Process function for inclusive jets with eventwise subtraction in data", false); - void processJetsMCD(soa::Filtered::iterator const&, soa::Filtered> const& jets, JetTracks const& tracks) + void processJetsMCD(soa::Filtered::iterator const&, soa::Filtered> const& jets, aod::JetTracks const& tracks) { for (auto& jet : jets) { processJet(jet, tracks); @@ -254,7 +254,7 @@ struct NSubjettinessTask { } PROCESS_SWITCH(NSubjettinessTask, processJetsMCD, "Process function for inclusive jets in mcd", false); - void processJetsMCDWeighted(soa::Filtered::iterator const&, soa::Filtered> const& jets, JetTracks const& tracks) + void processJetsMCDWeighted(soa::Filtered::iterator const&, soa::Filtered> const& jets, aod::JetTracks const& tracks) { for (auto& jet : jets) { processJet(jet, tracks, jet.eventWeight()); @@ -263,7 +263,7 @@ struct NSubjettinessTask { } PROCESS_SWITCH(NSubjettinessTask, processJetsMCDWeighted, "Process function for inclusive jets in weighted mcd", false); - void processJetsMCP(JetMcCollision const&, soa::Filtered> const& jets, JetParticles const& particles) + void processJetsMCP(aod::JetMcCollision const&, soa::Filtered> const& jets, aod::JetParticles const& particles) { for (auto& jet : jets) { processJet(jet, particles); @@ -272,7 +272,7 @@ struct NSubjettinessTask { } PROCESS_SWITCH(NSubjettinessTask, processJetsMCP, "Process function for inclusive jets in mcp", false); - void processJetsMCPWeighted(JetMcCollision const&, soa::Filtered> const& jets, JetParticles const& particles) + void processJetsMCPWeighted(aod::JetMcCollision const&, soa::Filtered> const& jets, aod::JetParticles const& particles) { for (auto& jet : jets) { processJet(jet, particles, jet.eventWeight()); diff --git a/PWGJE/Tasks/nucleiInJets.cxx b/PWGJE/Tasks/nucleiInJets.cxx new file mode 100644 index 00000000000..212c167fced --- /dev/null +++ b/PWGJE/Tasks/nucleiInJets.cxx @@ -0,0 +1,1312 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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: Arvind Khuntia (arvind.khuntia@cern.ch) INFN Bologna, Italy + +#include +#include +#include +#include + +#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 "PWGLF/DataModel/LFParticleIdentification.h" + +#include "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +struct nucleiInJets { + + enum Particle { + kPion = 1, // π+ + kKaon = 2, // K+ + kProton = 3, // p + kDeuteron = 4, // d + kTriton = 5, // Tr + kHelium = 6 // He + }; + + int mapPDGToValue(int pdgCode) + { + switch (pdgCode) { + case 211: // π+ + return Particle::kPion; + case -211: // π- + return -Particle::kPion; + + case 321: // k+ + return Particle::kKaon; + case -321: // k- + return -Particle::kKaon; + + case 2212: // p + return Particle::kProton; + case -2212: // antip + return -Particle::kProton; + + case 1000010020: // Deuteron + return Particle::kDeuteron; + case -1000010020: // AntiDeuteron + return -Particle::kDeuteron; + + case 1000010030: // Triton + return Particle::kTriton; + case -1000010030: // AntiTriton + return -Particle::kTriton; + + case 1000020030: // Helium + return Particle::kHelium; + case -1000020030: // AntiHelium + return -Particle::kHelium; + default: + return 0; // Default case for unknown or unmapped PDG codes + } + } + + 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 cfgtrkMinPt{"cfgtrkMinPt", 0.15, "set track min pT"}; + Configurable cfgtrkMaxEta{"cfgtrkMaxEta", 0.8, "set track max Eta"}; + Configurable cfgtrkMaxRap{"cfgtrkMaxRap", 0.5, "set track max y"}; + Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.12, "Track DCAr cut to PV Maximum"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 1.0, "Track DCAz cut to PV Maximum"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; + Configurable cfgConnectedToPV{"cfgConnectedToPV", true, "PV contributor track selection"}; // PV Contriuibutor + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) + Configurable cfgnFindableTPCClusters{"cfgnFindableTPCClusters", 120, "nFindable TPC Clusters"}; + Configurable cfgnTPCCrossedRows{"cfgnTPCCrossedRows", 70, "nCrossed TPC Rows"}; + Configurable cfgnTPCChi2{"cfgnTPChi2", 4.0, "nTPC Chi2 per Cluster"}; + Configurable cfgnITSChi2{"cfgnITShi2", 36.0, "nITS Chi2 per Cluster"}; + + Configurable cfgjetPtMin{"cfgjetPtMin", 5.0, "minimum jet pT cut"}; + Configurable cfgjetR{"cfgjetR", 0.4, "jet resolution parameter"}; + Configurable cDebugLevel{"cDebugLevel", 0, "print debug msg"}; + Configurable cMaxPt{"cMaxPt", 10, "max pt for Hist"}; + + Configurable cfgnTPCPIDPr{"cfgnTPCPIDPr", 3, "nTPC PID Pr"}; + Configurable cfgnTPCPIDDe{"cfgnTPCPIDDe", 3, "nTPC PID De"}; + Configurable cfgnTPCPIDHe{"cfgnTPCPIDHe", 3, "nTPC PID He"}; + Configurable cfgnTPCPIDTr{"cfgnTPCPIDTr", 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 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}, ""}; + + ConfigurableAxis binsMassPr{"binsMassPr", {100, -1., 1.f}, ""}; + ConfigurableAxis binsMassDe{"binsMassDe", {180, -1.8, 1.8f}, ""}; + ConfigurableAxis binsMassTr{"binsMassTr", {250, -2.5, 2.5f}, ""}; + ConfigurableAxis binsMassHe{"binsMassHe", {300, -3., 3.f}, ""}; + + 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; + + using EventCandidates = soa::Join; // , aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs + using TrackCandidates = soa::Join; + using TrackCandidatesLfPid = soa::Join; + using TrackCandidatesMC = soa::Join; + + Filter jetCuts = aod::jet::pt > cfgjetPtMin&& aod::jet::r == nround(cfgjetR.node() * 100.0f); + + using chargedJetstrack = soa::Filtered>; + using JetMCPartTable = soa::Filtered>; + using JetMCDetTable = soa::Filtered>; + + SliceCache cache; + HistogramRegistry jetHist{"jetHist", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + const AxisSpec PtAxis = {100, 0, 10.0}; + const AxisSpec PtJetAxis = {300, 0, 30.0}; + const AxisSpec MultAxis = {100, 0, 100}; + const AxisSpec dRAxis = {100, 0, 3.6}; + 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 betaAxis{binsBeta, "TOF #beta"}; + const AxisSpec ptZHeAxis{binsPtZHe, "#it{p}_{T}"}; + + const AxisSpec massPrAxis{binsMassPr, ""}; + const AxisSpec massDeAxis{binsMassDe, ""}; + const AxisSpec massTrAxis{binsMassTr, ""}; + const AxisSpec massHeAxis{binsMassHe, ""}; + + // jet property + jetHist.add("jet/h1JetPt", "jet_{p_{T}}", kTH1F, {PtJetAxis}); + jetHist.add("jet/h1JetEvents", "NumbeOfJetEvents", kTH1F, {{1, 0, 1}}); + jetHist.add("jet/h1JetEta", "jet_{#eta}", kTH1F, {{100, -1.0, 1.0}}); + jetHist.add("jet/h1JetPhi", "jet_{#phi}", kTH1F, {{80, -1.0, 7.}}); + 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}}); + //////////////////////////// + // MC + //////////////////////////// + jetHist.add("mcpJet/eventStat", "vertexZ (All)", kTH1F, {{5, .0, 5.0}}); + auto h = jetHist.get(HIST("mcpJet/eventStat")); + h->GetXaxis()->SetBinLabel(1, "All"); + h->GetXaxis()->SetBinLabel(2, "Sel8-goodRecJet"); + 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("mcdJet/eventStat", "vertexZ (All)", kTH1F, {{5, .0, 5.0}}); + auto h1 = jetHist.get(HIST("mcdJet/eventStat")); + h1->GetXaxis()->SetBinLabel(1, "All"); + h1->GetXaxis()->SetBinLabel(2, "Sel8-goodRecJet"); + 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}}); + + ////////////////////////////////////////////// + // inside jet + ////////////////////////////////////////////// + if (addpik) { + jetHist.add("tracks/pion/h3PtVsPionNSigmaTPCVsPtJet_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/antiPion/h3PtVsPionNSigmaTPCVsPtJet_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/kaon/h3PtVsKaonNSigmaTPCVsPtJet_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/antiKaon/h3PtVsKaonNSigmaTPCVsPtJet_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/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/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}}); + jetHist.add("tracks/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet", "pT(d) vs NSigmaTPC (d) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet", "pT(#bar{d}) vs NSigmaTPC (#bar{d}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet", "pT(He) vs NSigmaTPC (He) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet", "pT(#bar{He}) vs NSigmaTPC (#bar{He}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet", "pT(Tr) vs NSigmaTPC (Tr) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet", "pT(#bar{Tr}) vs NSigmaTPC (#bar{Tr}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + + if (cEnableProtonQA) { + jetHist.add("tracks/proton/dca/after/hDCAxyVsPtProton_jet", "DCAxy vs Pt (p)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiProton/dca/after/hDCAxyVsPtantiProton_jet", "DCAxy vs Pt (#bar{p})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/proton/dca/after/hDCAzVsPtProton_jet", "DCAz vs Pt (p)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiProton/dca/after/hDCAzVsPtantiProton_jet", "DCAz vs Pt (#bar{p})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableDeuteronQA) { + jetHist.add("tracks/deuteron/dca/after/hDCAxyVsPtDeuteron_jet", "DCAxy vs Pt (d)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiDeuteron/dca/after/hDCAxyVsPtantiDeuteron_jet", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/deuteron/dca/after/hDCAzVsPtDeuteron_jet", "DCAz vs Pt (d)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiDeuteron/dca/after/hDCAzVsPtantiDeuteron_jet", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableTritonQA) { + jetHist.add("tracks/triton/dca/after/hDCAxyVsPtTriton_jet", "DCAxy vs Pt (t)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/after/hDCAxyVsPtantiTriton_jet", "DCAxy vs Pt (#bar{t})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/triton/dca/after/hDCAzVsPtTriton_jet", "DCAz vs Pt (t)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/after/hDCAzVsPtantiTriton_jet", "DCAz vs Pt (#bar{t})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + if (cEnableHeliumQA) { + jetHist.add("tracks/helium/dca/after/hDCAxyVsPtHelium_jet", "DCAxy vs Pt (He)", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/after/hDCAxyVsPtantiHelium_jet", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/helium/dca/after/hDCAzVsPtHelium_jet", "DCAz vs Pt (He)", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/after/hDCAzVsPtantiHelium_jet", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + } + + jetHist.add("tracks/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z;#it{p}/Z (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); + jetHist.add("tracks/h2TPCsignVsTPCmomentum_Jet", "TPC <-dE/dX> vs #it{p}/Z;#it{p}/Z (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); + jetHist.add("tracks/h2TPCsignVsTPCmomentum_OutJet", "TPC <-dE/dX> vs #it{p}/Z;#it{p}/Z (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); + jetHist.add("tracks/perpCone/h2TPCsignVsTPCmomentum", "TPC <-dE/dX> vs #it{p}/Z;#it{p}/Z (GeV/#it{c}); TPC <-dE/dx> (a.u.)", HistType::kTH2F, {{500, -5.f, 5.f}, {dedxAxis}}); + + jetHist.add("tracks/h2TOFbetaVsP_Jet", "TOF #beta vs #it{p}/Z; #it{p}/Z (GeV/#it{c}); TOF #beta", HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + jetHist.add("tracks/h2TOFbetaVsP_OutJet", "TOF #beta vs #it{p}/Z; #it{p}/Z (GeV/#it{c}); TOF #beta", HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + jetHist.add("tracks/h2TOFbetaVsP", "TOF #beta vs #it{p}/Z; #it{p}/Z (GeV/#it{c}); TOF #beta", HistType::kTH2F, {{250, -5.f, 5.f}, {betaAxis}}); + + // TOF hist + jetHist.add("tracks/proton/h2TOFmassProtonVsPt_jet", "h2TOFmassProtonVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiProton/h2TOFmassantiProtonVsPt_jet", "h2TOFmassantiProtonVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/proton/h2TOFmass2ProtonVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massPrAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiProton/h2TOFmass2antiProtonVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massPrAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/deuteron/h2TOFmassDeuteronVsPt_jet", "h2TOFmassDeuteronVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt_jet", "h2TOFmassantiDeuteronVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massDeAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massDeAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/triton/h2TOFmassTritonVsPt_jet", "h2TOFmassTritonVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiTriton/h2TOFmassantiTritonVsPt_jet", "h2TOFmassantiTritonVsPt_jet; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/triton/h2TOFmass2TritonVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massTrAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiTriton/h2TOFmass2antiTritonVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massTrAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/helium/h2TOFmassHeliumVsPt_jet", "h2TOFmassHeliumVsPt_jet; TOFmass; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {ptZHeAxis}}); + jetHist.add("tracks/antiHelium/h2TOFmassantiHeliumVsPt_jet", "h2TOFmassantiHeliumVsPt_jet; TOFmass; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {ptZHeAxis}}); + jetHist.add("tracks/helium/h2TOFmass2HeliumVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}t; TOFmass2; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{massHeAxis}, {ptZHeAxis}}); + jetHist.add("tracks/antiHelium/h2TOFmass2antiHeliumVsPt_jet", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{massHeAxis}, {ptZHeAxis}}); + + // TOF hist nSigma + if (addpik) { + jetHist.add("tracks/pion/h2TofNsigmaPionVsPt_jet", "h2TofNsigmaPionVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiPion/h2TofNsigmaantiPionVsPt_jet", "h2TofNsigmaantiPionVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/kaon/h2TofNsigmaKaonVsPt_jet", "h2TofNsigmaKaonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiKaon/h2TofNsigmaantiKaonVsPt_jet", "h2TofNsigmaantiKaonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + } + jetHist.add("tracks/proton/h2TofNsigmaProtonVsPt_jet", "h2TofNsigmaProtonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiProton/h2TofNsigmaantiProtonVsPt_jet", "h2TofNsigmaantiProtonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/deuteron/h2TofNsigmaDeuteronVsPt_jet", "h2TofNsigmaDeuteronVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt_jet", "h2TofNsigmaantiDeuteronVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/triton/h2TofNsigmaTritonVsPt_jet", "h2TofNsigmaTritonVsPt_jet; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + 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.}}); + ///////////// + // perp cone + ///////////// + jetHist.add("tracks/perpCone/proton/h2TofNsigmaProtonVsPt", "h2TofNsigmaProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/antiProton/h2TofNsigmaantiProtonVsPt", "h2TofNsigmaantiProtonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/deuteron/h2TofNsigmaDeuteronVsPt", "h2TofNsigmaDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/antiDeuteron/h2TofNsigmaantiDeuteronVsPt", "h2TofNsigmaantiDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/triton/h2TofNsigmaTritonVsPt", "h2TofNsigmaTritonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/antiTriton/h2TofNsigmaantiTritonVsPt", "h2TofNsigmaantiTritonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/helium/h2TofNsigmaHeliumVsPt", "h2TofNsigmaHeliumVsPt; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/perpCone/antiHelium/h2TofNsigmaantiHeliumVsPt", "h2TofNsigmaantiHeliumVsPt; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + ////////////////////////////////////////////// + // outside jet + ////////////////////////////////////////////// + jetHist.add("tracks/proton/h3PtVsProtonNSigmaTPC", "pT(p) vs NSigmaTPC (p); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/antiProton/h3PtVsantiProtonNSigmaTPC", "pT(#bar{p}) vs NSigmaTPC (#bar{p}); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/deuteron/h3PtVsDeuteronNSigmaTPC", "pT(d) vs NSigmaTPC (d); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/antiDeuteron/h3PtVsantiDeuteronNSigmaTPC", "pT(#bar{d}) vs NSigmaTPC (#bar{d}); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/helium/h3PtVsHeliumNSigmaTPC", "pT(He) vs NSigmaTPC (He); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/antiHelium/h3PtVsantiHeliumNSigmaTPC", "pT(#bar{He}) vs NSigmaTPC (#bar{He}); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/triton/h3PtVsTritonNSigmaTPC", "pT(Tr) vs NSigmaTPC(Tr); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + jetHist.add("tracks/antiTriton/h3PtVsantiTritonNSigmaTPC", "pT(#barTr}) vs NSigmaTPC (#bar{Tr}); #it{p}_{T} (GeV/#it{c}; NSigmaTPC;", HistType::kTH2F, {{PtAxis}, {200, -10, 10}}); + + jetHist.add("tracks/perpCone/proton/h3PtVsProtonNSigmaTPCVsPtJet", "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/perpCone/antiProton/h3PtVsantiProtonNSigmaTPCVsPtJet", "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}}); + jetHist.add("tracks/perpCone/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet", "pT(d) vs NSigmaTPC (d) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/perpCone/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet", "pT(#bar{d}) vs NSigmaTPC (#bar{d}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/perpCone/helium/h3PtVsHeliumNSigmaTPCVsPtJet", "pT(He) vs NSigmaTPC (He) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/perpCone/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet", "pT(#bar{He}) vs NSigmaTPC (#bar{He}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/perpCone/triton/h3PtVsTritonNSigmaTPCVsPtJet", "pT(Tr) vs NSigmaTPC (Tr) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/perpCone/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet", "pT(#bar{Tr}) vs NSigmaTPC (#bar{Tr}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + + if (cEnableProtonQA) { + jetHist.add("tracks/proton/dca/after/hDCAxyVsPtProton", "DCAxy vs Pt (p)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + 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("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("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("tracks/antiDeuteron/dca/after/hDCAzVsPtantiDeuteron", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + if (cEnableTritonQA) { + jetHist.add("tracks/triton/dca/after/hDCAxyVsPtTriton", "DCAxy vs Pt (t)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/after/hDCAxyVsPtantiTriton", "DCAxy vs Pt (#bar{t})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/triton/dca/after/hDCAzVsPtTriton", "DCAz vs Pt (t)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/after/hDCAzVsPtantiTriton", "DCAz vs Pt (#bar{t})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + if (cEnableHeliumQA) { + jetHist.add("tracks/helium/dca/after/hDCAxyVsPtHelium", "DCAxy vs Pt (He)", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/after/hDCAxyVsPtantiHelium", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/helium/dca/after/hDCAzVsPtHelium", "DCAz vs Pt (He)", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/after/hDCAzVsPtantiHelium", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + } + + // TOF hist #DeltaMass2 + jetHist.add("tracks/proton/h2TOFmassProtonVsPt", "h2TOFmassProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiProton/h2TOFmassantiProtonVsPt", "h2TOFmassantiProtonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/proton/h2TOFmass2ProtonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massPrAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiProton/h2TOFmass2antiProtonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massPrAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/deuteron/h2TOFmassDeuteronVsPt", "h2TOFmassDeuteronVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TOFmassantiDeuteronVsPt", "h2TOFmassantiDeuteronVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/deuteron/h2TOFmass2DeuteronVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massDeAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TOFmass2antiDeuteronVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massDeAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/triton/h2TOFmassTritonVsPt", "h2TOFmassTritonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/antiTriton/h2TOFmassantiTritonVsPt", "h2TOFmassantiTritonVsPt; TOFmass; #it{p}_{T} (GeV)", HistType::kTH2F, {{80, 0.4, 4.}, {50, 0., 5.}}); + jetHist.add("tracks/triton/h2TOFmass2TritonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massTrAxis}, {250, 0., 5.}}); + jetHist.add("tracks/antiTriton/h2TOFmass2antiTritonVsPt", "#Delta M^{2} (t) vs #it{p}_{T}; TOFmass2; #it{p}_{T} (GeV)", HistType::kTH2F, {{massTrAxis}, {250, 0., 5.}}); + + jetHist.add("tracks/helium/h2TOFmassHeliumVsPt", "h2TOFmassHeliumVsPt; TOFmass; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {ptZHeAxis}}); + jetHist.add("tracks/antiHelium/h2TOFmassantiHeliumVsPt", "h2TOFmassantiHeliumVsPt; TOFmass; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{180, 0.4, 4.}, {ptZHeAxis}}); + 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}}); + + // 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.}}); + jetHist.add("tracks/deuteron/h2TofNsigmaDeuteronVsPt", "h2TofNsigmaDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiDeuteron/h2TofNsigmaantiDeuteronVsPt", "h2TofNsigmaantiDeuteronVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/triton/h2TofNsigmaTritonVsPt", "h2TofNsigmaTritonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiTriton/h2TofNsigmaantiTritonVsPt", "h2TofNsigmaantiTritonVsPt; TofNsigma; #it{p}_{T} (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/helium/h2TofNsigmaHeliumVsPt", "h2TofNsigmaHeliumVsPt; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + jetHist.add("tracks/antiHelium/h2TofNsigmaantiHeliumVsPt", "h2TofNsigmaantiHeliumVsPt; TofNsigma; #it{p}_{T}/z (GeV)", HistType::kTH2F, {{100, -5, 5}, {50, 0., 5.}}); + + if (isMC) { + // 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}}); + jetHist.add("tracks/mc/deuteron/h3PtVsDeuteronNSigmaTPCVsPtJet_jet", "pT(d) vs NSigmaTPC (d) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/mc/antiDeuteron/h3PtVsantiDeuteronNSigmaTPCVsPtJet_jet", "pT(#bar{d}) vs NSigmaTPC (#bar{d}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/mc/helium/h3PtVsHeliumNSigmaTPCVsPtJet_jet", "pT(He) vs NSigmaTPC (He) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/mc/antiHelium/h3PtVsantiHeliumNSigmaTPCVsPtJet_jet", "pT(#bar{He}) vs NSigmaTPC (#bar{He}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/mc/triton/h3PtVsTritonNSigmaTPCVsPtJet_jet", "pT(Tr) vs NSigmaTPC (Tr) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + jetHist.add("tracks/mc/antiTriton/h3PtVsantiTritonNSigmaTPCVsPtJet_jet", "pT(#bar{Tr}) vs NSigmaTPC (#bar{Tr}) vs jet pT; #it{p}_{T} (GeV/#it{c}; NSigmaTPC; p^{jet}_{T}", HistType::kTH3F, {{PtAxis}, {200, -10, 10}, {PtJetAxis}}); + + if (cEnableProtonQA) { + jetHist.add("tracks/proton/dca/before/hDCAxyVsPtProton_jet", "DCAxy vs Pt (p)", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/antiProton/dca/before/hDCAxyVsPtantiProton_jet", "DCAxy vs Pt (#bar{p})", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/proton/dca/before/hDCAzVsPtProton_jet", "DCAz vs Pt (p)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiProton/dca/before/hDCAzVsPtantiProton_jet", "DCAz vs Pt (#bar{p})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableDeuteronQA) { + jetHist.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteron_jet", "DCAxy vs Pt (d)", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/antiDeuteron/dca/before/hDCAxyVsPtantiDeuteron_jet", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteron_jet", "DCAz vs Pt (d)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiDeuteron/dca/before/hDCAzVsPtantiDeuteron_jet", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableTritonQA) { + jetHist.add("tracks/triton/dca/before/hDCAxyVsPtTriton_jet", "DCAxy vs Pt (t)", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/antiTriton/dca/before/hDCAxyVsPtantiTriton_jet", "DCAxy vs Pt (#bar{t})", HistType::kTH2F, {{PtAxis}, {dcaxyAxis}}); + jetHist.add("tracks/triton/dca/before/hDCAzVsPtTriton_jet", "DCAz vs Pt (t)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/before/hDCAzVsPtantiTriton_jet", "DCAz vs Pt (#bar{t})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableHeliumQA) { + jetHist.add("tracks/helium/dca/before/hDCAxyVsPtHelium_jet", "DCAxy vs Pt (He)", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/before/hDCAxyVsPtantiHelium_jet", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{dcaxyAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/helium/dca/before/hDCAzVsPtHelium_jet", "DCAz vs Pt (He)", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/before/hDCAzVsPtantiHelium_jet", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + } + + // outside jet + if (cEnableProtonQA) { + jetHist.add("tracks/proton/dca/before/hDCAxyVsPtProton", "DCAxy vs Pt (p)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiProton/dca/before/hDCAxyVsPtantiProton", "DCAxy vs Pt (#bar{p})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/proton/dca/before/hDCAzVsPtProton", "DCAz vs Pt (p)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiProton/dca/before/hDCAzVsPtantiProton", "DCAz vs Pt (#bar{p})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableDeuteronQA) { + jetHist.add("tracks/deuteron/dca/before/hDCAxyVsPtDeuteron", "DCAxy vs Pt (d)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiDeuteron/dca/before/hDCAxyVsPtantiDeuteron", "DCAxy vs Pt (#bar{d})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/deuteron/dca/before/hDCAzVsPtDeuteron", "DCAz vs Pt (d)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiDeuteron/dca/before/hDCAzVsPtantiDeuteron", "DCAz vs Pt (#bar{d})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableTritonQA) { + jetHist.add("tracks/triton/dca/before/hDCAxyVsPtTriton", "DCAxy vs Pt (t)", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/before/hDCAxyVsPtantiTriton", "DCAxy vs Pt (#bar{t})", HistType::kTH2F, {{dcaxyAxis}, {PtAxis}}); + jetHist.add("tracks/triton/dca/before/hDCAzVsPtTriton", "DCAz vs Pt (t)", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + jetHist.add("tracks/antiTriton/dca/before/hDCAzVsPtantiTriton", "DCAz vs Pt (#bar{t})", HistType::kTH2F, {{dcazAxis}, {PtAxis}}); + } + + if (cEnableHeliumQA) { + jetHist.add("tracks/helium/dca/before/hDCAxyVsPtHelium", "DCAxy vs Pt (He)", HistType::kTH2F, {{450, 0.5f, 5.f}, {dcaxyAxis}}); + jetHist.add("tracks/antiHelium/dca/before/hDCAxyVsPtantiHelium", "DCAxy vs Pt (#bar{He})", HistType::kTH2F, {{450, 0.5f, 5.f}, {dcaxyAxis}}); + jetHist.add("tracks/helium/dca/before/hDCAzVsPtHelium", "DCAz vs Pt (He)", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + jetHist.add("tracks/antiHelium/dca/before/hDCAzVsPtantiHelium", "DCAz vs Pt (#bar{He})", HistType::kTH2F, {{dcazAxis}, {450, 0.5f, 5.f}}); + } + + // PartilceJet-constituents + jetHist.add("mcpJet/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + // detectorJet-constituents + jetHist.add("mcdJet/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + jetHist.add("mcdJet/pt/perpCone/PtParticleType", "Pt (p) vs particletype", HistType::kTH2D, {{100, 0.f, 10.f}, {14, -7, 7}}); + + jetHist.add("mcpJet/hJetPt", "Pt (jet)", HistType::kTH1F, {{100, 0.f, 50.f}}); + jetHist.add("mcpJet/hJetEta", "Eta (jet)", HistType::kTH1F, {{100, 1.5, 1.5}}); + jetHist.add("mcpJet/hJetPhi", "Phi (jet)", HistType::kTH1F, {{70, 0.f, 7.f}}); + + jetHist.add("mcdJet/hJetPt", "Pt (jet)", HistType::kTH1F, {{100, 0.f, 50.f}}); + jetHist.add("mcdJet/hJetEta", "Eta (jet)", HistType::kTH1F, {{100, 1.5, 1.5}}); + jetHist.add("mcdJet/hJetPhi", "Phi (jet)", HistType::kTH1F, {{70, 0.f, 7.f}}); + + // 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/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/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}}); + + // 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/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/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/pt/PtParticleType", "Pt (p) vs jetflag vs particletype", HistType::kTH3D, {{100, 0.f, 10.f}, {2, 0, 2}, {14, -7, 7}}); + } + } + + 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 + return PerpendicularConeAxisPhi; + } + + template + bool isTrackSelected(const TrackType track) + { + // standard track selection + 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 (track.tpcNClsFindable() < cfgnFindableTPCClusters) + return false; + if (track.tpcNClsCrossedRows() < cfgnTPCCrossedRows) + return false; + if (track.tpcChi2NCl() > cfgnTPCChi2) + return false; + if (track.itsChi2NCl() > cfgnITSChi2) + return false; + if (cfgConnectedToPV && !track.isPVContributor()) + return false; + return true; + } + + int nEvents = 0; + template + void fillTrackInfo(const TracksType& trk, const JetType& jets, std::vector& leadingJetPtEtaPhi) + { + if (!isTrackSelected(trk)) + return; + if (trk.pt() > cMaxPt) + return; + jetHist.fill(HIST("tracks/h2TPCsignVsTPCmomentum"), trk.tpcInnerParam() / (1.f * trk.sign()), trk.tpcSignal()); + bool jetFlag = false; + bool jetFlagPerpCone = false; + float jetPt = -999.; + + 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)); + if (R < cfgjetR) + jetFlag = true; + jetPt = leadingJetPtEtaPhi[0]; + // Get perpCone + 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)); + 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)); + if (R < cfgjetR) + jetFlag = true; + jetPt = jet.pt(); + break; + } + } + // 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); + } + + if (addTOFplots && trk.hasTOF()) { + jetHist.fill(HIST("tracks/h2TOFbetaVsP"), trk.p() / (1.f * trk.sign()), trk.beta()); + } + if (jetFlag) { + jetHist.fill(HIST("tracks/h2TPCsignVsTPCmomentum_Jet"), trk.tpcInnerParam() / (1.f * trk.sign()), trk.tpcSignal()); + if (addTOFplots && trk.hasTOF()) { + jetHist.fill(HIST("tracks/h2TOFbetaVsP_Jet"), trk.p() / (1.f * trk.sign()), trk.beta()); + } + if (trk.sign() > 0) { // particle info + if (addpik) { + 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 (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracks/proton/dca/after/hDCAxyVsPtProton_jet"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/proton/dca/after/hDCAzVsPtProton_jet"), trk.dcaZ(), trk.pt()); + } + if (cEnableDeuteronQA && std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + 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) { + 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()); + } + if (cEnableHeliumQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + jetHist.fill(HIST("tracks/helium/dca/after/hDCAxyVsPtHelium_jet"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/helium/dca/after/hDCAzVsPtHelium_jet"), trk.dcaZ(), trk.pt()); + } + + 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/deuteron/h2TOFmassDeuteronVsPt_jet"), massTOF, trk.pt()); + jetHist.fill(HIST("tracks/deuteron/h2TOFmass2DeuteronVsPt_jet"), massTOF * massTOF - gMassDeuteron * gMassDeuteron, 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/helium/h2TOFmassHeliumVsPt_jet"), massTOF, trk.pt()); + jetHist.fill(HIST("tracks/helium/h2TOFmass2HeliumVsPt_jet"), massTOF * massTOF - gMassHelium * gMassHelium, 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()); + + } else { + if (trk.tpcNSigmaPr() < 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/h2TofNsigmaProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); + } + + if (trk.tpcNSigmaDe() < useTPCpreSel) { + 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/h2TofNsigmaDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); + } + if (trk.tpcNSigmaTr() < useTPCpreSel) { + 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()); + } + if (trk.tpcNSigmaHe() < useTPCpreSel) { + 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()); + } + } + // nSigma + if (addpik) { + jetHist.fill(HIST("tracks/pion/h2TofNsigmaPionVsPt_jet"), trk.tofNSigmaPi(), trk.pt()); + jetHist.fill(HIST("tracks/kaon/h2TofNsigmaKaonVsPt_jet"), trk.tofNSigmaKa(), trk.pt()); + } + + } // tof info + + } else { // anti-particle info + if (addpik) { + 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 (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracks/antiProton/dca/after/hDCAxyVsPtantiProton_jet"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/antiProton/dca/after/hDCAzVsPtantiProton_jet"), trk.dcaZ(), trk.pt()); + } + if (cEnableDeuteronQA && std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + 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) { + 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()); + } + if (cEnableTritonQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + jetHist.fill(HIST("tracks/antiHelium/dca/after/hDCAxyVsPtantiHelium_jet"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/antiHelium/dca/after/hDCAzVsPtantiHelium_jet"), trk.dcaZ(), trk.pt()); + } + + 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/h2TofNsigmaantiProtonVsPt_jet"), 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/h2TofNsigmaantiDeuteronVsPt_jet"), 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/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/h2TofNsigmaantiHeliumVsPt_jet"), trk.tofNSigmaHe(), trk.pt()); + } else { + if (trk.tpcNSigmaPr() < 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/h2TofNsigmaantiProtonVsPt_jet"), trk.tofNSigmaPr(), trk.pt()); + } + if (trk.tpcNSigmaDe() < useTPCpreSel) { + 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/h2TofNsigmaantiDeuteronVsPt_jet"), trk.tofNSigmaDe(), trk.pt()); + } + if (trk.tpcNSigmaTr() < useTPCpreSel) { + 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/h2TofNsigmaantiTritonVsPt_jet"), trk.tofNSigmaTr(), trk.pt()); + } + if (trk.tpcNSigmaHe() < useTPCpreSel) { + 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/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) { + jetHist.fill(HIST("tracks/antiPion/h2TofNsigmaantiPionVsPt_jet"), trk.tofNSigmaPi(), trk.pt()); + } + if (trk.tpcNSigmaKa() < useTPCpreSel) { + jetHist.fill(HIST("tracks/antiKaon/h2TofNsigmaantiKaonVsPt_jet"), trk.tofNSigmaKa(), trk.pt()); + } + } + } // pikEnd + } + } // anti-particle + //////////////////////////////////////// + // within jet end + ////////////////////////////////////////// + } else { + jetHist.fill(HIST("tracks/h2TPCsignVsTPCmomentum_OutJet"), trk.tpcInnerParam() / (1.f * trk.sign()), trk.tpcSignal()); + if (jetFlagPerpCone && isWithLeadingJet) { + jetHist.fill(HIST("tracks/perpCone/h2TPCsignVsTPCmomentum"), trk.tpcInnerParam() / (1.f * trk.sign()), trk.tpcSignal()); + } + if (addTOFplots && trk.hasTOF()) { + jetHist.fill(HIST("tracks/h2TOFbetaVsP_OutJet"), trk.p() / (1.f * trk.sign()), trk.beta()); + } + if (trk.sign() > 0) { + jetHist.fill(HIST("tracks/proton/h3PtVsProtonNSigmaTPC"), trk.pt(), trk.tpcNSigmaPr()); // Pr + jetHist.fill(HIST("tracks/deuteron/h3PtVsDeuteronNSigmaTPC"), trk.pt(), trk.tpcNSigmaDe()); // De + jetHist.fill(HIST("tracks/helium/h3PtVsHeliumNSigmaTPC"), trk.pt(), trk.tpcNSigmaHe()); // He + 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 (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracks/proton/dca/after/hDCAxyVsPtProton"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/proton/dca/after/hDCAzVsPtProton"), trk.dcaZ(), trk.pt()); + } + if (cEnableDeuteronQA && std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + 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) { + jetHist.fill(HIST("tracks/triton/dca/after/hDCAxyVsPtTriton"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/triton/dca/after/hDCAzVsPtTriton"), trk.dcaZ(), trk.pt()); + } + if (cEnableHeliumQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + jetHist.fill(HIST("tracks/helium/dca/after/hDCAxyVsPtHelium"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/helium/dca/after/hDCAzVsPtHelium"), trk.dcaZ(), trk.pt()); + } + 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/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/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/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/triton/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + } else { + if (trk.tpcNSigmaPr() < 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/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/proton/h2TofNsigmaProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); + } + if (trk.tpcNSigmaDe() < useTPCpreSel) { + 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/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/deuteron/h2TofNsigmaDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); + } + if (trk.tpcNSigmaTr() < useTPCpreSel) { + 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/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/triton/h2TofNsigmaTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + } + if (trk.tpcNSigmaHe() < useTPCpreSel) { + 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/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 (cEnableProtonQA && std::abs(trk.tpcNSigmaPr()) < cfgnTPCPIDPr) { + jetHist.fill(HIST("tracks/antiProton/dca/after/hDCAxyVsPtantiProton"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/antiProton/dca/after/hDCAzVsPtantiProton"), trk.dcaZ(), trk.pt()); + } + if (cEnableDeuteronQA && std::abs(trk.tpcNSigmaDe()) < cfgnTPCPIDDe) { + jetHist.fill(HIST("tracks/antiDeuteron/dca/after/hDCAxyVsPtantiDeuteron"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/antiDeuteron/dca/after/hDCAzVsPtantiDeuteron"), trk.dcaZ(), trk.pt()); + } + if (cEnableHeliumQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + jetHist.fill(HIST("tracks/antiTriton/dca/after/hDCAxyVsPtantiTriton"), trk.dcaXY(), trk.pt()); + jetHist.fill(HIST("tracks/antiTriton/dca/after/hDCAzVsPtantiTriton"), trk.dcaZ(), trk.pt()); + } + if (cEnableTritonQA && std::abs(trk.tpcNSigmaHe()) < cfgnTPCPIDHe) { + 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/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/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/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/antiTriton/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + } else { + if (trk.tpcNSigmaPr() < 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/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/antiProton/h2TofNsigmaantiProtonVsPt"), trk.tofNSigmaPr(), trk.pt()); + } + if (trk.tpcNSigmaDe() < useTPCpreSel) { + 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/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/antiDeuteron/h2TofNsigmaantiDeuteronVsPt"), trk.tofNSigmaDe(), trk.pt()); + } + if (trk.tpcNSigmaTr() < useTPCpreSel) { + 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/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/antiTriton/h2TofNsigmaantiTritonVsPt"), trk.tofNSigmaTr(), trk.pt()); + } + if (trk.tpcNSigmaHe() < useTPCpreSel) { + 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/h2TofNsigmaantiHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); + if (jetFlagPerpCone && isWithLeadingJet) + jetHist.fill(HIST("tracks/perpCone/antiHelium/h2TofNsigmaantiHeliumVsPt"), trk.tofNSigmaHe(), trk.pt()); + } + } + } + } + + } //////////////////////////////////////// + // outside jet end + //////////////////////////////////////// + } + + void processJetTracksData(aod::JCollision const& collision, chargedJetstrack const& chargedjets, soa::Join const& tracks, TrackCandidates const&) + { + + if (fabs(collision.posZ()) > 10) + return; + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + return; + + 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()); + else + jetHist.fill(HIST("jetOut/vertexZ"), collision.posZ()); + + if (isWithJetEvents && nJets == 0) + return; + jetHist.fill(HIST("jet/h1JetEvents"), 0.5); + + 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 processMCGen(o2::aod::JMcCollision const& collision, /*soa::SmallGroups> const& recoColls,*/ aod::JMcParticles 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 + return; + + jetHist.fill(HIST("mcpJet/eventStat"), 2.5); + + jetHist.fill(HIST("mcpJet/vertexZ"), collision.posZ()); + + bool INELgt0 = false; + for (const auto& mcParticle : mcParticles) { + if (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) { + jetHist.fill(HIST("mcpJet/hJetPt"), mcpjet.pt()); + jetHist.fill(HIST("mcpJet/hJetEta"), mcpjet.eta()); + jetHist.fill(HIST("mcpJet/hJetPhi"), mcpjet.phi()); + nJets++; + } + jetHist.fill(HIST("mcpJet/nJetsPerEvent"), nJets); + + for (const auto& mcParticle : mcParticles) { + + if (!mcParticle.isPhysicalPrimary()) + continue; + if (fabs(mcParticle.eta()) > cfgtrkMaxEta) + continue; + if (fabs(mcParticle.y()) > cfgtrkMaxRap) + continue; + + bool jetFlag = false; + // float jetPt = -999.; + for (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)); + if (R < cfgjetR) + jetFlag = true; + // jetPt = mcpjet.pt(); + break; + } // jet + 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, + 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)) + return; + // bool jetFlag = kFALSE; + + jetHist.fill(HIST("mcdJet/eventStat"), 1.5); + + if (fabs(collisionJet.posZ()) > 10) + return; + + jetHist.fill(HIST("mcdJet/eventStat"), 2.5); + bool INELgt0 = false; + for (const auto& track : tracks) { + if (fabs(track.eta()) < cfgtrkMaxEta) { + INELgt0 = true; + break; + } + } + if (!INELgt0) + return; + jetHist.fill(HIST("mcdJet/eventStat"), 3.5); + int nJets = 0; + std::vector leadingJetWithPtEtaPhi(3); + float leadingJetPt = -1.0f; + for (auto& mcdjet : mcdjets) { + jetHist.fill(HIST("mcdJet/hJetPt"), mcdjet.pt()); + jetHist.fill(HIST("mcdJet/hJetEta"), mcdjet.eta()); + jetHist.fill(HIST("mcdJet/hJetPhi"), mcdjet.phi()); + if (mcdjet.pt() > leadingJetPt) { + leadingJetWithPtEtaPhi[0] = mcdjet.pt(); + leadingJetWithPtEtaPhi[1] = mcdjet.eta(); + leadingJetWithPtEtaPhi[2] = mcdjet.phi(); + } + nJets++; + } + + jetHist.fill(HIST("mcdJet/vertexZ"), collisionJet.posZ()); + jetHist.fill(HIST("mcdJet/nJetsPerEvent"), nJets); + + if (isWithJetEvents && nJets == 0) + return; + + for (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) + 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)); + 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)); + if (RPerpCone1 < cfgjetR || RPerpCone2 < cfgjetR) + jetFlagPerpCone = true; + } else { + for (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)); + 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&) + { + if (fabs(collision.posZ()) > 10) + return; + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) + return; + + jetHist.fill(HIST("recmatched/vertexZ"), collision.posZ()); + bool INELgt0 = false; + for (const auto& track : tracks) { + if (fabs(track.eta()) < cfgtrkMaxEta) { + INELgt0 = true; + break; + } + } + if (!INELgt0) + return; + + std::vector mcdJetPt{}; + std::vector mcdJetPhi{}; + std::vector mcdJetEta{}; + std::vector mcpJetPt{}; + std::vector mcpJetPhi{}; + std::vector mcpJetEta{}; + + for (auto& mcdjet : mcdjets) { + + if (!mcdjet.has_matchedJetGeo()) + continue; + for (auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + if (!mcpjet.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("recmatched/hRecMatchedJetPt"), mcpjet.pt(), mcpjet.pt() - mcdjet.pt()); + 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/hRecJetPt"), mcdjet.pt()); + jetHist.fill(HIST("recmatched/hGenJetPt"), mcpjet.pt()); + jetHist.fill(HIST("recmatched/h2ResponseMatrix"), mcpjet.pt(), mcdjet.pt()); + + } // mcpJet + + } // mcdJet + + for (const auto& track : tracks) { + auto completeTrack = track.track_as(); + if (fabs(completeTrack.eta()) > cfgtrkMaxEta) + continue; + if (!isTrackSelected(completeTrack)) + continue; + if (!track.has_mcParticle()) + continue; + auto mcTrack = track.mcParticle_as(); + // add pid later + + 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)); + + if (R < cfgjetR) { + jetFlag = true; + break; + } + } + + if (mapPDGToValue(mcTrack.pdgCode()) != 0) { + jetHist.fill(HIST("recmatched/pt/PtParticleType"), mcTrack.pt(), jetFlag, mapPDGToValue(mcTrack.pdgCode())); + } + } // tracks + } // process + + int nprocessSimJEEvents = 0; + void processGenMatched(aod::JMcCollision const& collision, + /*soa::SmallGroups> const& recocolls,*/ + JetMCDetTable const&, JetMCPartTable const& mcpjets, aod::JMcParticles const& mcParticles) + { + + if (cDebugLevel > 0) { + nprocessSimJEEvents++; + if ((nprocessSimJEEvents + 1) % 100000 == 0) + LOG(debug) << "Jet Events: " << nprocessSimJEEvents; + } + if (fabs(collision.posZ()) > 10) + return; + + jetHist.fill(HIST("genmatched/vertexZ"), collision.posZ()); + + bool INELgt0 = false; + for (const auto& mcParticle : mcParticles) { + if (fabs(mcParticle.eta()) < cfgtrkMaxEta) { + INELgt0 = true; + break; + } + } + if (!INELgt0) + return; + + std::vector mcdJetPt{}; + std::vector mcdJetPhi{}; + std::vector mcdJetEta{}; + std::vector mcpJetPt{}; + std::vector mcpJetPhi{}; + std::vector mcpJetEta{}; + + for (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()); + + } // mcdJet + } // mcpJet + + for (const auto& mcParticle : mcParticles) { + if (fabs(mcParticle.eta()) > cfgtrkMaxEta) + continue; + // add pid later + + bool jetFlag = false; + 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)); + + if (R < cfgjetR) { + jetFlag = true; + break; + } + } // DetJet + if (mapPDGToValue(mcParticle.pdgCode()) != 0) { + jetHist.fill(HIST("genmatched/pt/PtParticleType"), mcParticle.pt(), jetFlag, mapPDGToValue(mcParticle.pdgCode())); + } + } // jet constituents + + } // process + + PROCESS_SWITCH(nucleiInJets, processJetTracksData, "nuclei in Jets data", true); + PROCESS_SWITCH(nucleiInJets, processMCRec, "nuclei in Jets for detectorlevel Jets", true); + 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); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"nuclei-in-jets"})}; +}; diff --git a/PWGJE/Tasks/phiInJets.cxx b/PWGJE/Tasks/phiInJets.cxx index 7b3f5374d01..09206a3cf4b 100644 --- a/PWGJE/Tasks/phiInJets.cxx +++ b/PWGJE/Tasks/phiInJets.cxx @@ -49,20 +49,6 @@ struct phiInJets { SliceCache cache; HistogramRegistry JEhistos{"JEhistos", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry registry{"registry", - {{"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{4000, 0., 200.}}}}, - {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_matched_REC_jet_pt", "matched_REC level jet pT;#it{p}_{T,jet part} (GeV/#it{c});Delta", {HistType::kTH2F, {{200, 0., 200.}, {400, -20., 20.}}}}, - {"h_matched_REC_jet_eta", "matched_REC level jet #eta;#eta_{jet part};Delta", {HistType::kTH2F, {{100, -1.0, 1.0}, {400, -20., 20.}}}}, - {"h_matched_REC_jet_phi", "matched_REC level jet #phi;#phi_{jet part};Delta", {HistType::kTH2F, {{80, -1.0, 7.}, {400, -20., 20.}}}}, - {"h_matched_GEN_jet_pt", "matched_GEN level jet pT;#it{p}_{T,jet part} (GeV/#it{c});Delta", {HistType::kTH2F, {{200, 0., 200.}, {400, -20., 20.}}}}, - {"h_matched_GEN_jet_eta", "matched_GEN level jet #eta;#eta_{jet part};Delta", {HistType::kTH2F, {{100, -1.0, 1.0}, {400, -20., 20.}}}}, - {"h_matched_GEN_jet_phi", "matched_GEN level jet #phi;#phi_{jet part};Delta", {HistType::kTH2F, {{80, -1.0, 7.}, {400, -20., 20.}}}}, - {"h_part_jet_pt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{4000, 0., 200.}}}}, - {"h_part_jet_eta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_part_jet_phi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}}}; - Configurable cfgeventSelections{"cfgeventSelections", "sel8", "choose event selection"}; Configurable cfgtrackSelections{"cfgtrackSelections", "globalTracks", "set track selections"}; @@ -86,6 +72,14 @@ struct phiInJets { Configurable cDebugLevel{"cDebugLevel", 0, "Resolution of Debug"}; Configurable cfgBR{"cfgBR", false, "Forces Gen. Charged BR Only"}; Configurable cfgSimPID{"cfgSimPID", false, "Enforces PID on the Gen. Rec level"}; + Configurable cfgSingleJet{"cfgSingleJet", false, "Enforces strict phi-jet correspondance"}; + Configurable cfgIsKstar{"cfgIsKstar", false, "Swaps Phi for Kstar analysis"}; + Configurable cfgDataHists{"cfgDataHists", false, "Enables DataHists"}; + Configurable cfgMCRecHists{"cfgMCRecHists", false, "Enables MCRecHists"}; + Configurable cfgMCGenHists{"cfgMCGenHists", false, "Enables MCGenHists"}; + Configurable cfgMCGenMATCHEDHists{"cfgMCGenMATCHEDHists", false, "Enables MCGenMATCHEDHists"}; + Configurable cfgMCRecMATCHEDHists{"cfgMCRecMATCHEDHists", false, "Enables MCRecMATCHEDHists"}; + // CONFIG DONE ///////////////////////////////////////// //INIT @@ -97,135 +91,184 @@ 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 = {400, 0.95, 1.35}; + const AxisSpec MinvAxis = {500, 0.75, 1.25}; const AxisSpec PtAxis = {200, 0, 20.0}; const AxisSpec MultAxis = {100, 0, 100}; - const AxisSpec dRAxis = {100, 0, 3.6}; - - 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("Resp_Matrix", "Resp_Matrix", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) - JEhistos.add("Resp_Matrix_MATCHED", "Resp_Matrix_MATCHED", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) - - JEhistos.add("ptGeneratedPion", "ptGeneratedPion", kTH1F, {PtAxis}); - JEhistos.add("ptGeneratedKaon", "ptGeneratedKaon", kTH1F, {PtAxis}); - JEhistos.add("ptGeneratedProton", "ptGeneratedProton", kTH1F, {PtAxis}); - JEhistos.add("ptGeneratedPhi", "ptGeneratedPhi", kTH1F, {PtAxis}); - JEhistos.add("ptGeneratedPhi_ALLBR", "ptGeneratedPhi_ALLBR", kTH1F, {PtAxis}); - - JEhistos.add("ptGeneratedPhi_JetTrigger", "ptGeneratedPhi_JetTrigger", kTH1F, {PtAxis}); - - JEhistos.add("mGeneratedPhi", "mGeneratedPhi", kTH1F, {MinvAxis}); - - JEhistos.add("etaHistogram", "etaHistogram", kTH1F, {axisEta}); - JEhistos.add("phiHistogram", "phiHistogram", kTH1F, {axisPhi}); - JEhistos.add("FJetaHistogram", "FJetaHistogram", kTH1F, {axisEta}); - JEhistos.add("FJphiHistogram", "FJphiHistogram", kTH1F, {axisPhi}); - JEhistos.add("FJptHistogram", "FJptHistogram", kTH1F, {axisPt}); - 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("FJnchHistogram", "FJnchHistogram", kTH1F, {MultAxis}); - JEhistos.add("nEvents", "nEvents", kTH1F, {{4, 0.0, 4.0}}); - JEhistos.add("nEvents_MCRec", "nEvents_MCRec", kTH1F, {{4, 0.0, 4.0}}); - JEhistos.add("nEvents_MCGen", "nEvents_MCGen", kTH1F, {{4, 0.0, 4.0}}); - JEhistos.add("nEvents_MCRec_MATCHED", "nEvents_MCRec_MATCHED", kTH1F, {{4, 0.0, 4.0}}); - JEhistos.add("nEvents_MCGen_MATCHED", "nEvents_MCGen_MATCHED", kTH1F, {{4, 0.0, 4.0}}); - - JEhistos.add("hMCTrue_nonmatch_hUSS_Kangle_v_pt", "hMCTrue_nonmatch_hUSS_Kangle_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("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("JetVsPhi_REC", "JetVsPhi_REC", kTH2F, {{4000, 0., 200.}, {200, 0, 20.0}}); - JEhistos.add("nJetsPerEvent", "nJetsPerEvent", kTH1F, {{10, 0.0, 10.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}}); - 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("hUSS", "hUSS", kTH3F, {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_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_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_1D", "hLSS_INSIDE_1D", kTH1F, {MinvAxis}); - JEhistos.add("hLSS_INSIDE_1D_2_3", "hLSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); - 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_INSIDE", "hMCTrue_hUSS_INSIDE", kTH3F, {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}); - 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_INSIDE", "hMCTrue_nonmatch_hUSS_INSIDE", kTH3F, {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}); - 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_INSIDE", "hMCRec_hUSS_INSIDE", kTH3F, {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("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_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}); - 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}); + const AxisSpec dRAxis = {100, 0, 100}; + + // Now we define histograms. Due to saving space, we only reserve histogram memory for histograms we will be filling. + + 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}}); + 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("hNResoPerEvent", "hNResoPerEvent", kTH1F, {{10, 0, 10}}); + JEhistos.add("hNResoPerEventWJet", "hNResoPerEventWJet", kTH1F, {{10, 0, 10}}); + JEhistos.add("hNResoPerEventInJet", "hNResoPerEventInJet", kTH1F, {{10, 0, 10}}); + + JEhistos.add("FJetaHistogram", "FJetaHistogram", kTH1F, {axisEta}); + JEhistos.add("FJphiHistogram", "FJphiHistogram", kTH1F, {axisPhi}); + 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_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_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_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_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}}); + + 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}); + } + + if (cfgMCGenHists) { + JEhistos.add("nEvents_MCGen", "nEvents_MCGen", kTH1F, {{4, 0.0, 4.0}}); + + JEhistos.add("h_part_jet_pt", "particle level jet pT;#it{p}_{T,jet part} (GeV/#it{c});entries", {HistType::kTH1F, {{4000, 0., 200.}}}); + JEhistos.add("h_part_jet_eta", "particle level jet #eta;#eta_{jet part};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); + JEhistos.add("h_part_jet_phi", "particle level jet #phi;#phi_{jet part};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}); + + JEhistos.add("ptGeneratedPion", "ptGeneratedPion", kTH1F, {PtAxis}); + JEhistos.add("ptGeneratedKaon", "ptGeneratedKaon", kTH1F, {PtAxis}); + JEhistos.add("ptGeneratedProton", "ptGeneratedProton", kTH1F, {PtAxis}); + JEhistos.add("ptGeneratedPhi", "ptGeneratedPhi", kTH1F, {PtAxis}); + JEhistos.add("ptGeneratedPhi_ALLBR", "ptGeneratedPhi_ALLBR", kTH1F, {PtAxis}); + + JEhistos.add("ptGeneratedPhi_JetTrigger", "ptGeneratedPhi_JetTrigger", kTH1F, {PtAxis}); + JEhistos.add("mGeneratedPhi", "mGeneratedPhi", kTH1F, {MinvAxis}); + + JEhistos.add("hMCTrue_nonmatch_hUSS_Kangle_v_pt", "hMCTrue_nonmatch_hUSS_Kangle_v_pt", kTH2F, {axisEta, PtAxis}); + 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_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}); + } + + if (cfgMCGenMATCHEDHists) { + JEhistos.add("nEvents_MCGen_MATCHED", "nEvents_MCGen_MATCHED", kTH1F, {{4, 0.0, 4.0}}); + + JEhistos.add("h_matched_GEN_jet_pt", "matched_GEN level jet pT;#it{p}_{T,jet part} (GeV/#it{c});Delta", {HistType::kTH2F, {{200, 0., 200.}, {400, -20., 20.}}}); + JEhistos.add("h_matched_GEN_jet_eta", "matched_GEN level jet #eta;#eta_{jet part};Delta", {HistType::kTH2F, {{100, -1.0, 1.0}, {400, -20., 20.}}}); + JEhistos.add("h_matched_GEN_jet_phi", "matched_GEN level jet #phi;#phi_{jet part};Delta", {HistType::kTH2F, {{80, -1.0, 7.}, {400, -20., 20.}}}); + JEhistos.add("2DGenToRec", "2DGenToRec", kTH2F, {PtAxis, axisPt}); + JEhistos.add("2DGenToRec_constrained", "2DGenToRec_constrained", kTH2F, {PtAxis, axisPt}); + + JEhistos.add("RespGen_Matrix_MATCHED", "RespGen_Matrix_MATCHED", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) + 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_1D", "hMCTrue_hUSS_INSIDE_1D", kTH1F, {MinvAxis}); + JEhistos.add("hMCTrue_hUSS_INSIDE_1D_2_3", "hMCTrue_hUSS_INSIDE_1D_2_3", kTH1F, {MinvAxis}); + } + + if (cfgMCRecMATCHEDHists) { + JEhistos.add("nEvents_MCRec_MATCHED", "nEvents_MCRec_MATCHED", kTH1F, {{4, 0.0, 4.0}}); + + JEhistos.add("h_matched_REC_jet_pt", "matched_REC level jet pT;#it{p}_{T,jet part} (GeV/#it{c});Delta", {HistType::kTH2F, {{200, 0., 200.}, {400, -20., 20.}}}); + JEhistos.add("h_matched_REC_jet_eta", "matched_REC level jet #eta;#eta_{jet part};Delta", {HistType::kTH2F, {{100, -1.0, 1.0}, {400, -20., 20.}}}); + JEhistos.add("h_matched_REC_jet_phi", "matched_REC level jet #phi;#phi_{jet part};Delta", {HistType::kTH2F, {{80, -1.0, 7.}, {400, -20., 20.}}}); + + JEhistos.add("Resp_Matrix_MATCHED", "Resp_Matrix_MATCHED", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) + JEhistos.add("Resp_Matrix_MATCHED_rand0", "Resp_Matrix_MATCHED_rand0", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) + JEhistos.add("Resp_Matrix_MATCHED_rand1", "Resp_Matrix_MATCHED_rand1", HistType::kTHnSparseD, {PtAxis, axisPt, PtAxis, axisPt}); // REC(Phi,Jet), GEN(Phi,Jet) + + 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_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)); @@ -233,10 +276,11 @@ struct phiInJets { } // end of init double massKa = o2::constants::physics::MassKPlus; + double massPi = o2::constants::physics::MassPiMinus; using EventCandidates = soa::Join; // , aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs using TrackCandidates = soa::Join; + aod::pidTPCKa, aod::pidTOFKa, aod::pidTPCPi, aod::pidTOFPi>; Filter jetCuts = aod::jet::pt > cfgjetPtMin&& aod::jet::r == nround(cfgjetR.node() * 100.0f); // Function for track quality cuts @@ -285,7 +329,24 @@ struct phiInJets { ///////////////////////////////////////////////////////////////////////////// template - bool trackPID(const T& candidate) + bool trackPID(const T& candidate, bool FT) + { + bool pid = false; + + if (!cfgIsKstar) { + pid = trackPIDKaon(candidate); + + } else { + if (!FT) + pid = trackPIDPion(candidate); + else + pid = trackPIDKaon(candidate); + } + return pid; + } + + template + bool trackPIDKaon(const T& candidate) { bool tpcPIDPassed{false}, tofPIDPassed{false}; if (std::abs(candidate.tpcNSigmaKa()) < cfgnTPCPID) @@ -303,46 +364,115 @@ struct phiInJets { } return false; } + + 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 + double DistinguishJets(const JetType& jets, const TLorentzVector lResonance) + { + if (cDebugLevel > 0) + std::cout << "oof, multiple jets fit to the same phi. Time to find the best phi-jet link" << std::endl; + + double best_R = 0; + double best_jetpt = 0; + for (auto const& jet : jets) { + double phidiff = TVector2::Phi_mpi_pi(jet.phi() - lResonance.Phi()); + double etadiff = jet.eta() - lResonance.Eta(); + double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); + if (R < cfgjetR && best_R == 0) { + best_R = R; + best_jetpt = jet.pt(); + } else if (R < best_R) { + best_R = R; + best_jetpt = jet.pt(); + } + } // jetloop + return best_jetpt; + } + + template + double DistinguishJetsMC(const Jet_pt& jet_pt, const Jet_phi& jet_phi, const Jet_eta& jet_eta, const TLorentzVector lResonance) + { + if (cDebugLevel > 0) + std::cout << "oof, multiple jets fit to the same phi. Time to find the best phi-jet link" << std::endl; + + double best_R = 0; + double best_jetpt = 0; + for (std::vector::size_type i = 0; i < jet_pt.size(); i++) { + double phidiff = TVector2::Phi_mpi_pi(jet_phi[i] - lResonance.Phi()); + double etadiff = jet_eta[i] - lResonance.Eta(); + double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); + if (R < cfgjetR && best_R == 0) { + best_R = R; + best_jetpt = jet_pt[i]; + } else if (R < best_R) { + best_R = R; + best_jetpt = jet_pt[i]; + } + } // jetloop + return best_jetpt; + } + + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// template - void minvReconstruction(double mult, const TracksType& trk1, const TracksType& trk2, const JetType& jets) + int minvReconstruction(double mult, const TracksType& trk1, const TracksType& trk2, const JetType& jets) { TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; if (!trackSelection(trk1) || !trackSelection(trk2)) - return; + return -1; - if (!trackPID(trk1) || !trackPID(trk2)) - return; + if (!trackPID(trk1, true) || !trackPID(trk2, false)) + return -1; - if (trk1.index() >= trk2.index()) - return; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. + if (!cfgIsKstar) { + if (trk1.globalIndex() >= trk2.globalIndex()) + return -1; // For Phi, we only need to iterate each pair once + } else { + if (trk1.globalIndex() == trk2.globalIndex()) + return -1; // For Kstar, we need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. + } lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massKa); - lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + if (!cfgIsKstar) + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + else + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); + lResonance = lDecayDaughter1 + lDecayDaughter2; if (std::abs(lResonance.Eta()) > cfgtrkMaxEta) - return; + return -1; ///////////////////////////////////////////////////////////////////////////// // Fill Global Event Minv if (trk1.sign() * trk2.sign() < 0) { - if (!IsMC) { - JEhistos.fill(HIST("hUSS_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hUSS_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hUSS"), mult, lResonance.Pt(), lResonance.M()); - } - - if (IsMC) { - JEhistos.fill(HIST("hMCRec_hUSS_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_hUSS_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCRec_hUSS"), mult, lResonance.Pt(), lResonance.M()); - } + JEhistos.fill(HIST("hUSS_1D"), lResonance.M()); + if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) + JEhistos.fill(HIST("hUSS_1D_2_3"), lResonance.M()); + JEhistos.fill(HIST("hUSS"), mult, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() * trk2.sign() > 0) { @@ -354,70 +484,90 @@ struct phiInJets { ///////////////////////////////////////////////////////////////////////////// bool jetFlag = false; + int goodjets = 0; + double jetpt = 0; for (auto const& jet : jets) { - double phidiff = TVector2::Phi_mpi_pi(jet.phi() - lResonance.Phi()); double etadiff = jet.eta() - lResonance.Eta(); double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); - if (R < cfgjetR) + if (R < cfgjetR) { jetFlag = true; + jetpt = jet.pt(); + goodjets++; + } } + if (cfgSingleJet) + if (goodjets > 1) + jetpt = DistinguishJets(jets, lResonance); + ///////////////////////////////////////////////////////////////////////////// // Fill inside Jet if (jetFlag) { if (trk1.sign() * trk2.sign() < 0) { - if (!IsMC) { - JEhistos.fill(HIST("hUSS_INSIDE_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hUSS_INSIDE"), mult, lResonance.Pt(), lResonance.M()); - } - - if (IsMC) { - JEhistos.fill(HIST("hMCRec_hUSS_INSIDE_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCRec_hUSS_INSIDE"), mult, lResonance.Pt(), lResonance.M()); - } + JEhistos.fill(HIST("hUSS_INSIDE_1D"), lResonance.M()); + if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) + JEhistos.fill(HIST("hUSS_INSIDE_1D_2_3"), lResonance.M()); + JEhistos.fill(HIST("hUSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() * trk2.sign() > 0) { JEhistos.fill(HIST("hLSS_INSIDE_1D"), lResonance.M()); if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) JEhistos.fill(HIST("hLSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hLSS_INSIDE"), mult, lResonance.Pt(), lResonance.M()); + JEhistos.fill(HIST("hLSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); } } // 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"), mult, 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"), mult, 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"), mult, lResonance.Pt(), lResonance.M()); - } - } //! jetflag + // 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) + return 3; + if (goodjets > 0) + return 2; + return 1; + } else { + return -1; + } + } else { + if (lResonance.M() > 0.85 && lResonance.M() < 0.95) { + if (jetFlag) + return 3; + if (goodjets > 0) + return 2; + return 1; + } else { + return -1; + } + } } // MinvReconstruction ///////////////////////////////////////////////////////////////////////////// @@ -427,8 +577,12 @@ struct phiInJets { { if (cDebugLevel > 0) { nEvents++; - if ((nEvents + 1) % 10000 == 0) + 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); @@ -437,17 +591,30 @@ struct phiInJets { if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) return; + int nReso = 0; + int nResoWTrig = 0; + int nResoInTrig = 0; for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { - auto trk1 = track1.track_as>(); - auto trk2 = track2.track_as>(); - minvReconstruction(1.0, trk1, trk2, chargedjets); + auto trk1 = track1.track_as>(); + auto trk2 = track2.track_as>(); + int Reso = minvReconstruction(1.0, trk1, trk2, chargedjets); + if (Reso > 0) + nReso++; + if (Reso > 1) + nResoWTrig++; + if (Reso > 2) + nResoInTrig++; } + // Here we have to fill the number of reso candidates per event + JEhistos.fill(HIST("hNResoPerEvent"), nReso); + JEhistos.fill(HIST("hNResoPerEventWJet"), nResoWTrig); + JEhistos.fill(HIST("hNResoPerEventInJet"), nResoInTrig); + int nJets = 0; for (auto chargedjet : chargedjets) { JEhistos.fill(HIST("FJetaHistogram"), chargedjet.eta()); JEhistos.fill(HIST("FJphiHistogram"), chargedjet.phi()); JEhistos.fill(HIST("FJptHistogram"), chargedjet.pt()); - // JEhistos.fill(HIST("FJnchHistogram"), chargedjet.tracks().size()); nJets++; } @@ -457,7 +624,7 @@ struct phiInJets { // return; for (auto& trackC : tracks) { - auto originalTrack = trackC.track_as>(); + auto originalTrack = trackC.track_as>(); JEhistos.fill(HIST("hDCArToPv"), originalTrack.dcaXY()); JEhistos.fill(HIST("hDCAzToPv"), originalTrack.dcaZ()); JEhistos.fill(HIST("rawpT"), originalTrack.pt()); @@ -487,7 +654,7 @@ struct phiInJets { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - using myCompleteTracks = soa::Join; + using myCompleteTracks = soa::Join; using myCompleteJetTracks = soa::Join; int nJEEvents = 0; int nprocessRecEvents = 0; @@ -495,8 +662,11 @@ struct phiInJets { { if (cDebugLevel > 0) { nprocessRecEvents++; - if ((nprocessRecEvents + 1) % 10000 == 0) + if ((nprocessRecEvents + 1) % 10000 == 0) { + double histmem = JEhistos.getSize(); + std::cout << histmem << std::endl; std::cout << "processRec: " << nprocessRecEvents << std::endl; + } } JEhistos.fill(HIST("nEvents_MCRec"), 0.5); @@ -527,20 +697,24 @@ struct phiInJets { mcd_pt.push_back(mcdjet.pt()); mcd_eta.push_back(mcdjet.eta()); mcd_phi.push_back(mcdjet.phi()); - registry.fill(HIST("h_jet_pt"), mcdjet.pt()); - registry.fill(HIST("h_jet_eta"), mcdjet.eta()); - registry.fill(HIST("h_jet_phi"), 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 (hasJets) JEhistos.fill(HIST("nEvents_MCRec"), 2.5); + double PhiCand = 0; + double RealPhiCand = 0; + double RealPhiCandWithJet = 0; + double RealPhiCandInJet = 0; // Track Eff for (const auto& track : tracks) { auto originalTrack = track.track_as(); if (!trackSelection(originalTrack)) continue; if (cfgSimPID) - if (!trackPID(originalTrack)) + if (!trackPID(originalTrack, true)) continue; if (track.has_mcParticle()) { @@ -560,24 +734,46 @@ struct phiInJets { if (!trackSelection(originalTrack2)) continue; if (cfgSimPID) - if (!trackPID(originalTrack2)) + if (!trackPID(originalTrack2, false)) continue; - - if (originalTrack.index() >= originalTrack2.index()) + if (!cfgIsKstar) { + if (originalTrack.globalIndex() >= originalTrack2.globalIndex()) + continue; + } else { + if (originalTrack.globalIndex() == originalTrack2.globalIndex()) + continue; + } + if (fabs(originalTrack.eta()) > cfgtrkMaxEta || fabs(originalTrack2.eta()) > cfgtrkMaxEta) continue; - if (fabs(originalTrack.eta()) > cfgtrkMaxEta || fabs(originalTrack2.eta()) > cfgtrkMaxEta) + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + lDecayDaughter1.SetXYZM(originalTrack.px(), originalTrack.py(), originalTrack.pz(), massKa); + if (!cfgIsKstar) + lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massKa); + else + lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massPi); + lResonance = lDecayDaughter1 + lDecayDaughter2; + + if (fabs(lResonance.Eta()) > cfgtrkMaxEta) continue; - // check PID + if (lResonance.M() > 1.005 && lResonance.M() < 1.035) + PhiCand++; + // check PID if (track.has_mcParticle() && track2.has_mcParticle()) { auto part1 = track.mcParticle(); auto part2 = track2.mcParticle(); if (fabs(part1.pdgCode()) != 321) continue; // Not Kaon - if (fabs(part2.pdgCode()) != 321) - continue; // Not Kaon + if (!cfgIsKstar) { + if (fabs(part2.pdgCode()) != 321) + continue; // Not Kaon + } else { + if (fabs(part2.pdgCode()) != 211) + continue; // Not Kaon + } + if (!part1.has_mothers()) continue; // Not decaying Kaon if (!part2.has_mothers()) @@ -597,23 +793,40 @@ struct phiInJets { mothers2PDG.push_back(part2_mom.pdgCode()); } - if (mothers1PDG[0] != 333) - continue; // mother not phi - if (mothers2PDG[0] != 333) - continue; // mother not phi + if (!cfgIsKstar) { + if (mothers1PDG[0] != 333) + continue; // mother not phi + if (mothers2PDG[0] != 333) + continue; // mother not phi + } else { + if (mothers1PDG[0] != 313) + continue; // mother not phi + if (mothers2PDG[0] != 313) + continue; // mother not phi + } if (mothers1[0] != mothers2[0]) continue; // Kaons not from the same phi - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; - lDecayDaughter1.SetXYZM(originalTrack.px(), originalTrack.py(), originalTrack.pz(), massKa); - lDecayDaughter2.SetXYZM(originalTrack2.px(), originalTrack2.py(), originalTrack2.pz(), massKa); - lResonance = lDecayDaughter1 + lDecayDaughter2; - if (fabs(lResonance.Eta()) > cfgtrkMaxEta) - continue; + 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++; + + // Now we do jets bool jetFlag = false; - for (std::vector::size_type i = 0; i < mcd_pt.size(); i++) { + int goodjets = 0; + double jetpt = 0; + + for (std::size_t i = 0; i < mcd_pt.size(); i++) { + 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)); @@ -628,33 +841,26 @@ struct phiInJets { 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) + if (R < cfgjetR) { jetFlag = true; - } + jetpt = mcd_pt[i]; + goodjets++; + } + } // 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"), 1.0, lResonance.Pt(), lResonance.M()); - - } else if (!jetFlag && mcd_pt.size() > 0) { - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D"), lResonance.M()); - - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG_1D_2_3"), lResonance.M()); - - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE_TRIG"), 1.0, lResonance.Pt(), lResonance.M()); - - } else if (!jetFlag) { - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE_1D"), lResonance.M()); - - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE_1D_2_3"), lResonance.M()); - - JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_OUTSIDE"), 1.0, lResonance.Pt(), lResonance.M()); - } //! jetflag + JEhistos.fill(HIST("hMCRec_nonmatch_hUSS_INSIDE"), jetpt, lResonance.Pt(), lResonance.M()); + } if (hasJets) { JEhistos.fill(HIST("ptJEHistogramPhi_JetTrigger"), lResonance.Pt()); @@ -666,6 +872,10 @@ struct phiInJets { } // mcpart check } // tracks2 } // tracks1 + 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); @@ -678,8 +888,11 @@ struct phiInJets { { if (cDebugLevel > 0) { nprocessSimEvents++; - if ((nprocessSimEvents + 1) % 10000 == 0) + if ((nprocessSimEvents + 1) % 10000 == 0) { + double histmem = JEhistos.getSize(); + std::cout << histmem << std::endl; std::cout << "processSim: " << nprocessSimEvents << std::endl; + } } JEhistos.fill(HIST("nEvents_MCGen"), 0.5); @@ -717,9 +930,9 @@ struct phiInJets { mcp_eta.push_back(mcpjet.eta()); mcp_phi.push_back(mcpjet.phi()); - registry.fill(HIST("h_part_jet_pt"), mcpjet.pt()); - registry.fill(HIST("h_part_jet_eta"), mcpjet.eta()); - registry.fill(HIST("h_part_jet_phi"), mcpjet.phi()); + JEhistos.fill(HIST("h_part_jet_pt"), mcpjet.pt()); + JEhistos.fill(HIST("h_part_jet_eta"), mcpjet.eta()); + JEhistos.fill(HIST("h_part_jet_phi"), mcpjet.phi()); } if (hasJets) JEhistos.fill(HIST("nEvents_MCGen"), 2.5); @@ -737,15 +950,31 @@ struct phiInJets { if (fabs(mcParticle.eta()) <= cfgtrkMaxEta) { // watch out for context!!! TLorentzVector lResonance; lResonance.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); - if (abs(mcParticle.pdgCode()) == 333) { + + int GenPID = 0; + if (!cfgIsKstar) + GenPID = 333; + else + GenPID = 313; + + if (abs(mcParticle.pdgCode()) == GenPID) { JEhistos.fill(HIST("ptGeneratedPhi_ALLBR"), mcParticle.pt()); bool skip = false; + // First we check for Forced BR - if (mcParticle.has_daughters()) - for (auto& dgth : mcParticle.daughters_as()) - if (fabs(dgth.pdgCode()) != 321) - skip = true; + // if we check for Phi + if (!cfgIsKstar) { + if (mcParticle.has_daughters()) + for (auto& dgth : mcParticle.daughters_as()) + if (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) + skip = true; + } if (skip && cfgBR) continue; @@ -754,6 +983,8 @@ struct phiInJets { ////////////////////////////Implementation of phi finding + int goodjets = 0; + double jetpt = 0; TLorentzVector lResonance; lResonance.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); bool jetFlag = false; @@ -770,34 +1001,40 @@ struct phiInJets { JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_Kangle_v_pt"), R_K, lResonance.Pt()); } } - if (R < cfgjetR) + if (R < cfgjetR) { jetFlag = true; + jetpt = mcp_pt[i]; + goodjets++; + } } + if (cfgSingleJet) + if (goodjets > 1) + jetpt = DistinguishJetsMC(mcp_pt, mcp_phi, mcp_eta, lResonance); if (jetFlag) { JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE_pt_v_eta"), lResonance.Pt(), lResonance.Eta()); JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE_1D"), lResonance.M()); if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_INSIDE"), 1.0, lResonance.Pt(), 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()); - } 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()); - 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()); - JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_TRIG"), 1.0, lResonance.Pt(), lResonance.M()); + // } else if (!jetFlag) { + // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE_1D"), 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()); - 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"), 1.0, lResonance.Pt(), lResonance.M()); + // JEhistos.fill(HIST("hMCTrue_nonmatch_hUSS_OUTSIDE"), jetpt, lResonance.Pt(), lResonance.M()); - } //! jetflag + // } //! jetflag ////////////////////////////Phi found if (hasJets) { @@ -819,19 +1056,24 @@ struct phiInJets { using JetMCPTable = soa::Filtered>; using JetMCDTable = soa::Filtered>; - // void processMatchedGen(o2::aod::JMcCollision const& collision, aod::JMcParticles const& mcParticles, soa::Filtered const& mcpjets) int nprocessSimJEEvents = 0; void processMatchedGen(aod::JMcCollision const& collision, soa::SmallGroups> const& recocolls, JetMCDTable const& /*mcdjets*/, JetMCPTable const& mcpjets, - aod::JMcParticles const& mcParticles) + myCompleteJetTracks const& tracks, + myCompleteTracks const&, + aod::JMcParticles const& mcParticles, + aod::McParticles const&) { if (cDebugLevel > 0) { nprocessSimJEEvents++; - if ((nprocessSimJEEvents + 1) % 10000 == 0) - std::cout << "JEvents: " << nprocessSimJEEvents << std::endl; + if ((nprocessSimJEEvents + 1) % 10000 == 0) { + double histmem = JEhistos.getSize(); + std::cout << histmem << std::endl; + std::cout << "processMatchedGen Events: " << nprocessSimJEEvents << std::endl; + } } JEhistos.fill(HIST("nEvents_MCGen_MATCHED"), 0.5); @@ -875,9 +1117,9 @@ struct phiInJets { if (!mcdjet.has_matchedJetGeo()) continue; hasJets = kTRUE; - registry.fill(HIST("h_matched_GEN_jet_pt"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); - registry.fill(HIST("h_matched_GEN_jet_phi"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); - registry.fill(HIST("h_matched_GEN_jet_eta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); + JEhistos.fill(HIST("h_matched_GEN_jet_pt"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); + JEhistos.fill(HIST("h_matched_GEN_jet_phi"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); + JEhistos.fill(HIST("h_matched_GEN_jet_eta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); mcd_pt.push_back(mcdjet.pt()); mcd_eta.push_back(mcdjet.eta()); @@ -896,50 +1138,157 @@ struct phiInJets { if (fabs(mcParticle.eta()) > cfgtrkMaxEta) continue; - if (fabs(mcParticle.pdgCode()) == 333) { + int GenPID = 0; + + if (!cfgIsKstar) + GenPID = 333; + else + GenPID = 313; + + if (fabs(mcParticle.pdgCode()) == GenPID) { bool skip = false; + double phi_dgth_px[2] = {0}; + double phi_dgth_py[2] = {0}; + double phi_dgth_pz[2] = {0}; + double TEMP_phi_dgth_px[2] = {0}; + double TEMP_phi_dgth_py[2] = {0}; + double TEMP_phi_dgth_pz[2] = {0}; + + bool good_daughter[2] = {false}; + int dgth_index = 0; // First we check for Forced BR - if (mcParticle.has_daughters()) - for (auto& dgth : mcParticle.daughters_as()) - if (fabs(dgth.pdgCode()) != 321) - skip = true; + // if we check for Phi + if (!cfgIsKstar) { + if (mcParticle.has_daughters()) { + for (auto& dgth : mcParticle.daughters_as()) { + if (fabs(dgth.pdgCode()) != 321) { + skip = true; + break; + } + for (const auto& track : tracks) { + auto trk = track.track_as(); + if (!trackSelection(trk)) + continue; + if (fabs(trk.eta()) > cfgtrkMaxEta) + continue; + if (cfgSimPID) { + if (!trackPID(trk, true)) + continue; + } + if (!trk.has_mcParticle()) + continue; + auto part = trk.mcParticle(); + if (part.globalIndex() == dgth.globalIndex()) { + TEMP_phi_dgth_px[dgth_index] = track.px(); + TEMP_phi_dgth_py[dgth_index] = track.py(); + TEMP_phi_dgth_pz[dgth_index] = track.pz(); + good_daughter[dgth_index] = true; + dgth_index++; + if (dgth_index == 2) { + phi_dgth_px[0] = TEMP_phi_dgth_px[0]; + phi_dgth_py[0] = TEMP_phi_dgth_py[0]; + phi_dgth_pz[0] = TEMP_phi_dgth_pz[0]; + phi_dgth_px[1] = TEMP_phi_dgth_px[1]; + phi_dgth_py[1] = TEMP_phi_dgth_py[1]; + phi_dgth_pz[1] = TEMP_phi_dgth_pz[1]; + break; + } + } // index check + } // 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) + skip = true; + } if (skip && cfgBR) continue; + + int goodjets = 0; + double jetpt_mcd = 0; + double jetpt_mcp = 0; TLorentzVector lResonance; + TLorentzVector lResonance_REC; + TLorentzVector lDecayDaughter1_REC; + TLorentzVector lDecayDaughter2_REC; lResonance.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); + 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++) { double phidiff = TVector2::Phi_mpi_pi(mcp_phi[i] - lResonance.Phi()); double etadiff = mcp_eta[i] - lResonance.Eta(); double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); - if (R < cfgjetR) + if (R < cfgjetR) { jetFlag = true; + jetpt_mcp = mcp_pt[i]; + jetpt_mcd = mcd_pt[i]; + goodjets++; + } + } + if (cfgSingleJet) { + if (goodjets > 1) { + jetpt_mcp = DistinguishJetsMC(mcp_pt, mcp_phi, mcp_eta, lResonance); + jetpt_mcd = DistinguishJetsMC(mcd_pt, mcd_phi, mcd_eta, lResonance_REC); + } } if (jetFlag) { + if (cDebugLevel > 0) { + std::cout << "******************************************" << std::endl; + std::cout << "GEN TO REC LEVEL: " << std::endl; + std::cout << "Rec. Phi Pt: " << lResonance_REC.Pt() << std::endl; + std::cout << "Rec. Phi Eta: " << lResonance_REC.Eta() << std::endl; + std::cout << "Rec. Jet Pt: " << jetpt_mcd << std::endl; + std::cout << "Gen. Phi Pt: " << lResonance.Pt() << std::endl; + std::cout << "Gen. Phi Eta: " << lResonance.Eta() << std::endl; + std::cout << "Gen. Jet Pt: " << jetpt_mcp << std::endl; + std::cout << "******************************************" << std::endl; + } + + JEhistos.fill(HIST("RespGen_Matrix_MATCHED"), lResonance_REC.Pt(), jetpt_mcd, lResonance.Pt(), jetpt_mcp); + unsigned int seed = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + int dice = rand_r(&seed) % 2; + if (dice > 0) + JEhistos.fill(HIST("RespGen_Matrix_MATCHED_rand0"), lResonance_REC.Pt(), jetpt_mcd, lResonance.Pt(), jetpt_mcp); + else + JEhistos.fill(HIST("RespGen_Matrix_MATCHED_rand1"), lResonance_REC.Pt(), jetpt_mcd, lResonance.Pt(), jetpt_mcp); + + JEhistos.fill(HIST("2DGenToRec"), lResonance.Pt(), jetpt_mcp); + // //check constrained eff + if (good_daughter[0] && good_daughter[1] && lResonance_REC.Pt() > 0 && lResonance_REC.Pt() < 20.0 && jetpt_mcd > 8 && jetpt_mcd < 200) + JEhistos.fill(HIST("2DGenToRec_constrained"), lResonance.Pt(), jetpt_mcp); + JEhistos.fill(HIST("hMCTrue_hUSS_INSIDE_1D"), lResonance.M()); if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) JEhistos.fill(HIST("hMCTrue_hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCTrue_hUSS_INSIDE"), 1.0, lResonance.Pt(), lResonance.M()); - - } else if (!jetFlag && mcp_pt.size() > 0) { - JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE_TRIG_1D"), 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()); + // 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"), 1.0, lResonance.Pt(), 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()); + // } 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()); + // 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"), 1.0, lResonance.Pt(), lResonance.M()); + // JEhistos.fill(HIST("hMCTrue_hUSS_OUTSIDE"), jetpt_mcp, lResonance.Pt(), lResonance.M()); - } //! jetflag + // } //! jetflag } // chech for phi } // MC Particles } // main fcn @@ -959,8 +1308,11 @@ struct phiInJets { if (cDebugLevel > 0) { nprocessRecJEEvents++; - if ((nprocessRecJEEvents + 1) % 10000 == 0) - std::cout << "JEvents: " << nprocessRecJEEvents << std::endl; + if ((nprocessRecJEEvents + 1) % 10000 == 0) { + double histmem = JEhistos.getSize(); + std::cout << histmem << std::endl; + std::cout << "processMatched Rec Events: " << nprocessRecJEEvents << std::endl; + } } JEhistos.fill(HIST("nEvents_MCRec_MATCHED"), 0.5); @@ -996,9 +1348,9 @@ struct phiInJets { if (!mcpjet.has_matchedJetGeo()) continue; hasJets = kTRUE; - registry.fill(HIST("h_matched_REC_jet_pt"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); - registry.fill(HIST("h_matched_REC_jet_phi"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); - registry.fill(HIST("h_matched_REC_jet_eta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); + JEhistos.fill(HIST("h_matched_REC_jet_pt"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); + JEhistos.fill(HIST("h_matched_REC_jet_phi"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); + JEhistos.fill(HIST("h_matched_REC_jet_eta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); mcd_pt.push_back(mcdjet.pt()); mcd_eta.push_back(mcdjet.eta()); @@ -1016,17 +1368,22 @@ struct phiInJets { auto trk1 = track1.track_as(); for (const auto& track2 : tracks) { auto trk2 = track2.track_as(); - if (trk1.index() >= trk2.index()) - continue; + if (!cfgIsKstar) { + if (trk1.globalIndex() >= trk2.globalIndex()) + continue; + } else { + if (trk1.globalIndex() == trk2.globalIndex()) + continue; + } if (fabs(trk1.eta()) > cfgtrkMaxEta || fabs(trk2.eta()) > cfgtrkMaxEta) continue; if ((trk1.sign() * trk2.sign()) > 0) continue; // Not K+K- if (trackSelection(trk1) && trackSelection(trk2)) { if (cfgSimPID) { - if (!trackPID(trk1)) + if (!trackPID(trk1, true)) continue; - if (!trackPID(trk2)) + if (!trackPID(trk2, false)) continue; } if (track1.has_mcParticle() && track2.has_mcParticle()) { @@ -1034,8 +1391,13 @@ struct phiInJets { auto part2 = track2.mcParticle(); if (fabs(part1.pdgCode()) != 321) continue; // Not Kaon - if (fabs(part2.pdgCode()) != 321) - continue; // Not Kaon + if (!cfgIsKstar) { + if (fabs(part2.pdgCode()) != 321) + continue; // Not Kaon + } else { + if (fabs(part2.pdgCode()) != 211) + continue; // Not Kaon + } if (!part1.has_mothers()) continue; // Not decaying Kaon if (!part2.has_mothers()) @@ -1058,65 +1420,101 @@ struct phiInJets { mothers2PDG.push_back(part2_mom.pdgCode()); mothers2Pt.push_back(part2_mom.pt()); } - if (mothers1PDG[0] != 333) - continue; // mother not phi - if (mothers2PDG[0] != 333) - continue; // mother not phi + if (!cfgIsKstar) { + if (mothers1PDG[0] != 333) + continue; // mother not phi + if (mothers2PDG[0] != 333) + continue; // mother not phi + } else { + if (mothers1PDG[0] != 313) + continue; // mother not phi + if (mothers2PDG[0] != 313) + continue; // mother not phi + } if (mothers1[0] != mothers2[0]) continue; // Kaons not from the same phi TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massKa); - lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); - lResonance = lDecayDaughter1 + lDecayDaughter2; + if (!cfgIsKstar) + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + else + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massPi); + lResonance = lDecayDaughter1 + lDecayDaughter2; if (fabs(lResonance.Eta()) > cfgtrkMaxEta) continue; bool jetFlag = false; + int goodjets = 0; + double jetpt_mcp = 0; + double jetpt_mcd = 0; for (std::vector::size_type i = 0; i < mcd_pt.size(); i++) { 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 (R < cfgjetR) + if (R < cfgjetR) { + jetpt_mcd = mcd_pt[i]; + jetpt_mcp = mcp_pt[i]; + goodjets++; jetFlag = true; + } + } - if (jetFlag) { // Fill Resp. Matrix - if (cDebugLevel > 0) { - std::cout << "******************************************" << std::endl; - std::cout << "Rec. Phi Pt: " << lResonance.Pt() << std::endl; - std::cout << "Rec. Jet Pt: " << mcd_pt[i] << std::endl; - std::cout << "Gen. Phi Pt: " << mothers1Pt[0] << std::endl; - std::cout << "Gen. Jet Pt: " << mcp_pt[i] << std::endl; - std::cout << "******************************************" << std::endl; - } - JEhistos.fill(HIST("Resp_Matrix_MATCHED"), lResonance.Pt(), mcd_pt[i], mothers1Pt[0], mcp_pt[i]); + if (cfgSingleJet) { + if (goodjets > 1) { + jetpt_mcd = DistinguishJetsMC(mcd_pt, mcd_phi, mcd_eta, lResonance); + jetpt_mcp = DistinguishJetsMC(mcp_pt, mcp_phi, mcp_eta, lResonance); } } + if (jetFlag) { // Fill Resp. Matrix + if (cDebugLevel > 0) { + std::cout << "******************************************" << std::endl; + std::cout << "REC TO GEN LEVEL: " << std::endl; + std::cout << "Rec. Phi Pt: " << lResonance.Pt() << std::endl; + std::cout << "Rec. Jet Pt: " << jetpt_mcd << std::endl; + std::cout << "Gen. Phi Pt: " << mothers1Pt[0] << std::endl; + std::cout << "Gen. Jet Pt: " << jetpt_mcp << std::endl; + std::cout << "******************************************" << std::endl; + } + JEhistos.fill(HIST("Resp_Matrix_MATCHED"), lResonance.Pt(), jetpt_mcd, mothers1Pt[0], jetpt_mcp); + unsigned int seed = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + int dice = rand_r(&seed) % 2; + if (dice > 0) + JEhistos.fill(HIST("Resp_Matrix_MATCHED_rand0"), lResonance.Pt(), jetpt_mcd, mothers1Pt[0], jetpt_mcp); + else + JEhistos.fill(HIST("Resp_Matrix_MATCHED_rand1"), lResonance.Pt(), jetpt_mcd, mothers1Pt[0], jetpt_mcp); + + JEhistos.fill(HIST("2DRecToGen"), lResonance.Pt(), jetpt_mcd); + // check constrained eff + if (mothers1Pt[0] > 0 && mothers1Pt[0] < 20.0 && jetpt_mcp > 8 && jetpt_mcp < 200) + JEhistos.fill(HIST("2DRecToGen_constrained"), lResonance.Pt(), jetpt_mcd); + } + // Fill 3D Invariant mass distributions if (jetFlag) { JEhistos.fill(HIST("hMCRec_hUSS_INSIDE_1D"), lResonance.M()); if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) JEhistos.fill(HIST("hMCRec_hUSS_INSIDE_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCRec_hUSS_INSIDE"), 1.0, lResonance.Pt(), lResonance.M()); - - } else if (!jetFlag && mcd_pt.size() > 0) { - JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG_1D"), lResonance.M()); + JEhistos.fill(HIST("hMCRec_hUSS_INSIDE"), jetpt_mcd, lResonance.Pt(), lResonance.M()); + } + // else if (!jetFlag && mcd_pt.size() > 0) { + // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG_1D"), lResonance.M()); - if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) - JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG_1D_2_3"), lResonance.M()); + // if (lResonance.Pt() > 2.0 && lResonance.Pt() < 3) + // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG_1D_2_3"), lResonance.M()); - JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG"), 1.0, lResonance.Pt(), lResonance.M()); + // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_TRIG"), jetpt_mcd, lResonance.Pt(), lResonance.M()); - } else if (!jetFlag) { - JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE_1D"), lResonance.M()); + // } else if (!jetFlag) { + // 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()); + // 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"), 1.0, lResonance.Pt(), lResonance.M()); + // JEhistos.fill(HIST("hMCRec_hUSS_OUTSIDE"), jetpt_mcd, lResonance.Pt(), lResonance.M()); - } //! jetflag + // } //! jetflag } // pass track cut } // has mc particle diff --git a/PWGJE/Tasks/statPromptPhoton.cxx b/PWGJE/Tasks/statPromptPhoton.cxx new file mode 100644 index 00000000000..b3d1aaaffa9 --- /dev/null +++ b/PWGJE/Tasks/statPromptPhoton.cxx @@ -0,0 +1,631 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 statPromptPhoton.cxx +/// \brief Reconstruction of Phi yield through track-track Minv correlations for resonance hadrochemistry analysis. +/// +/// +/// \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 "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 "PWGJE/Core/FastJetUtilities.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/EMCALClusters.h" +#include "EMCALBase/Geometry.h" +#include "EMCALCalib/BadChannelMap.h" + +#include "DataFormatsEMCAL/Cell.h" +#include "DataFormatsEMCAL/Constants.h" +#include "DataFormatsEMCAL/AnalysisCluster.h" + +#include "CommonDataFormat/InteractionRecord.h" + +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"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; + Configurable cfgConnectedToPV{"cfgConnectedToPV", true, "PV contributor track selection"}; + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; + 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 cfgClusterDefinition{"clusterDefinition", 10, "cluster definition to be selected, e.g. 10=kV3Default, 0 = kV1Default"}; + Configurable cfgMinTime{"MinTime", -30., "Minimum cluster time for time cut"}; + Configurable cfgMaxTime{"MaxTime", +35., "Maximum cluster time for time cut"}; + Configurable cfgMinClusterEnergy{"MinClusterEnergy", 0.7f, "Minimal cluster energy"}; + Configurable cfgMinNCells{"MinNCelss", 2, "Minimal amount of cells per cluster"}; + Configurable cfgMaxNLM{"MaxNLM", 2, "Maximal amount of local Maxima per cluster"}; + Configurable cfgExoticContribution{"ExoticContribution", false, "Exotic cluster in the data"}; + Configurable cfgtrkMinPt{"cfgtrkMinPt", 0.15, "set track min pT"}; + Configurable cfgtrkMaxEta{"cfgtrkMaxEta", 0.6, "set track max Eta"}; + Configurable cfgMinR{"MinR", 0.1, "Min. Radii of Delta R cone around photon trigger"}; + Configurable cfgMaxR{"MaxR", 0.4, "Max. Radii of Delta R cone around photon trigger"}; + 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"}; + + // INIT + void init(InitContext const&) + { + 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()}}); + + } // 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; + + using MCCells = o2::soa::Join; + + using MCClusters = o2::soa::Join; + using selectedCollisions = soa::Join; + using selectedMCCollisions = aod::McCollisions; + + using TrackCandidates = soa::Join; + + using filteredMCCells = o2::soa::Filtered; + using filteredMCClusters = soa::Filtered; + using filteredCollisions = soa::Filtered; + using filteredMCCollisions = soa::Filtered; + + Preslice perClusterMatchedTracks = o2::aod::emcalclustercell::emcalclusterId; + + // Helper functions + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + template + + double GetPtHadSum(const Tracks& tracks, const Trigger& trigger, double MinR, double MaxR, bool IsStern, bool IsParticle, bool DodR) + { + double eta_trigger, phi_trigger; + if constexpr (requires { trigger.eta(); }) { + eta_trigger = trigger.eta(); + phi_trigger = trigger.phi(); + } else if constexpr (requires { trigger.Eta(); }) { + eta_trigger = trigger.Eta(); + phi_trigger = trigger.Phi(); + } + double pthadsum = 0; + + for (auto& track : tracks) { + double phi_track = track.phi(); + double eta_track = track.eta(); + double pt_track = track.pt(); + + if (!IsParticle) { + if constexpr (requires { track.trackId(); }) { + 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; + } // reject track + } // done checking for JTrack + } else { + if constexpr (requires { track.isPhysicalPrimary(); }) { + if (track.pt() < 0.15) { + continue; + } + if (std::abs(track.eta()) > cfgtrkMaxEta) { + continue; + } + if (track.getGenStatusCode() < 20) { + continue; + } + if (!track.isPhysicalPrimary()) { + continue; + } + int pdg = std::abs(track.pdgCode()); + if (pdg != 211 && pdg != 321 && pdg != 2212) { + continue; + } + } + } + if (IsStern || IsParticle) { + if constexpr (requires { trigger.globalIndex(); }) { + if (trigger.globalIndex() == track.globalIndex()) + continue; + } + } + double phidiff = TVector2::Phi_mpi_pi(phi_track - phi_trigger); + double etadiff = std::abs(eta_track - eta_trigger); + double dR = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); + + 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); + } + } else { + if (IsStern) { + histos.fill(HIST("GEN_dR_Stern"), dR); + } + if (!IsStern) { + histos.fill(HIST("GEN_dR_Photon"), dR); + } + } + } + } + if (dR > MinR && dR < MaxR) { + pthadsum += pt_track; + } + + } // end of track loop + return pthadsum; + } // end of GetPtHadSum + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + 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; + }; // end of track selection + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////// + // PROCESS + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// + int nEventsGenMC = 0; + + void processMCGen(filteredMCCollisions::iterator const& collision, soa::SmallGroups> const& recocolls, aod::McParticles const& mcParticles, filteredMCClusters const&) + { + nEventsGenMC++; + 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) + return; + + if (recocolls.size() <= 0) // not reconstructed + return; + for (auto& recocoll : recocolls) { // poorly reconstructed + if (!recocoll.sel8()) + return; + if (fabs(recocoll.posZ()) > cfgVtxCut) + + return; + histos.fill(HIST("GEN_nEvents"), 1.5); + if (!recocoll.alias_bit(kTVXinEMC)) + return; + histos.fill(HIST("GEN_nEvents"), 2.5); + } + + for (auto& mcPhoton : mcParticles) { + bool photontrigger = false; + if (mcPhoton.pt() < 0.15) + continue; + if (std::abs(mcPhoton.eta()) > cfgtrkMaxEta) + continue; + if (mcPhoton.getGenStatusCode() < 20) + continue; + + // first we check for pthadsums for all charged particles a la sternheimer + if (mcPhoton.isPhysicalPrimary()) { + int pdg = std::abs(mcPhoton.pdgCode()); + if (pdg == 211 || pdg == 321 || pdg == 2212) { + bool sterntrigger = false; + double sternPt = 0.0; + if (mcPhoton.pt() > cfgMinTrig && mcPhoton.pt() < cfgMaxTrig) { + if (fabs(mcPhoton.eta()) <= cfgtrkMaxEta) { + sterntrigger = true; + sternPt = mcPhoton.pt(); + } + } + // stern trigger + if (sterntrigger) { + bool doStern = true; + double sterncount = 1.0; + while (doStern) { + TLorentzVector lParticleTrigger; + lParticleTrigger.SetPxPyPzE(mcPhoton.px(), mcPhoton.py(), mcPhoton.pz(), mcPhoton.e()); + double pthadsum = GetPtHadSum(mcParticles, lParticleTrigger, cfgMinR, cfgMaxR, true, true, true); + histos.fill(HIST("GEN_Trigger_V_PtHadSum_Stern"), sterncount, pthadsum, 2.0 / sternPt); + if (sterncount < sternPt) { + sterncount++; + } else { + doStern = false; + } + } // While sternin' + } // stern trigger loop + } // check if charged pikp + } // check for primary particles + + // now we do all photons + if (mcPhoton.pdgCode() == 22) { + histos.fill(HIST("GEN_True_Photon_Energy"), mcPhoton.e()); + if (mcPhoton.pt() > cfgMinTrig && mcPhoton.pt() < cfgMaxTrig) { + if (fabs(mcPhoton.eta()) <= cfgtrkMaxEta) { + photontrigger = true; + } + } // check for photon trigger + if (photontrigger) { + TLorentzVector lRealPhoton; + lRealPhoton.SetPxPyPzE(mcPhoton.px(), mcPhoton.py(), mcPhoton.pz(), mcPhoton.e()); + 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) { + if (mcPhoton.isPhysicalPrimary()) { + histos.fill(HIST("GEN_True_Prompt_Photon_Energy"), mcPhoton.e()); + if (photontrigger) { + TLorentzVector lRealPromptPhoton; + lRealPromptPhoton.SetPxPyPzE(mcPhoton.px(), mcPhoton.py(), mcPhoton.pz(), mcPhoton.e()); + double truepthadsum = GetPtHadSum(mcParticles, lRealPromptPhoton, cfgMinR, cfgMaxR, false, true, true); + histos.fill(HIST("GEN_TrueTrigger_V_PtHadSum_Photon"), mcPhoton.e(), truepthadsum); + } // photontrigger + } // check for primary photons + } // prompt photon check + + } // photon check + + } // loop over mc particles + + } // end of process + + 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; + + 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&) + { + + nEventsRecMC_JE++; + if ((nEventsRecMC_JE + 1) % 10000 == 0) { + std::cout << "Processed JE Rec MC Events: " << nEventsRecMC_JE << std::endl; + } + + histos.fill(HIST("REC_nEvents"), 0.5); + + if (fabs(collision.posZ()) > cfgVtxCut) + return; + if (!collision.sel8()) + return; + + histos.fill(HIST("REC_nEvents"), 1.5); + + if (!collision.isEmcalReadout()) + return; + + histos.fill(HIST("REC_nEvents"), 2.5); + + // now we do clusters + bool clustertrigger = false; + for (auto& mccluster : mcclusters) { + histos.fill(HIST("REC_M02_BC"), mccluster.energy()); + if (mccluster.m02() < 0.1) + continue; + histos.fill(HIST("REC_Cluster_QA"), 0.5); + histos.fill(HIST("REC_M02_AC"), mccluster.energy()); + 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; + double truephotonPt = 0.0; + auto tracksofcluster = mccluster.matchedTracks_as>(); + + // 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()) { + 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; + } + + // veto is required + if (vetotrigger) { + for (auto& ctrack : tracksofcluster) { + auto ogtrack = ctrack.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + + double etaT = ctrack.eta(); + double etaC = mccluster.eta(); + double phiT = ctrack.phi(); + double phiC = mccluster.phi(); + double ptT = ctrack.pt(); + + if (fabs(etaT - etaC) < (0.010 + pow(ptT + 4.07, -2.5))) { + chargetrigger = true; + } + if (fabs(TVector2::Phi_mpi_pi(phiT - phiC)) < (0.015 + pow(ptT + 3.65, -2.0))) { + chargetrigger = true; + } + if (chargetrigger) { + histos.fill(HIST("REC_Cluster_QA"), 3.5); + break; + } + } // tracks + } // veto + + // check if cluster is good + if (!chargetrigger) { + for (auto& ctrack : tracksofcluster) { + auto ogtrack = ctrack.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (!ogtrack.isGlobalTrack()) { + continue; + } + + double ptT = ctrack.pt(); + sumptTAC += 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_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); + } + + 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()); + } + + // now we check the realness of our prompt photons + auto ClusterParticles = mccluster.mcParticle_as(); + bool goodgentrigger = true; + for (auto& clusterparticle : ClusterParticles) { + if (clusterparticle.pdgCode() == 211 || clusterparticle.pdgCode() == 321 || clusterparticle.pdgCode() == 2212) { + goodgentrigger = false; + } + + double phidiff = TVector2::Phi_mpi_pi(mccluster.phi() - clusterparticle.phi()); + double etadiff = mccluster.eta() - clusterparticle.eta(); + histos.fill(HIST("REC_True_v_Cluster_Phi"), phidiff); + histos.fill(HIST("REC_True_v_Cluster_Eta"), etadiff); + + if (!photontrigger) { + continue; + } + 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()); + 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); + } + } // photon check + } // clusterparticle loop + if (goodgentrigger && photontrigger) { + histos.fill(HIST("REC_Trigger_Purity"), 0.5); + histos.fill(HIST("REC_Trigger_Energy_GOOD"), mccluster.energy()); + } + if (goodgentrigger && !photontrigger) { + histos.fill(HIST("REC_Trigger_Purity"), 1.5); + histos.fill(HIST("REC_Trigger_Energy_MISS"), mccluster.energy()); + } + if (!goodgentrigger && photontrigger) { + histos.fill(HIST("REC_Trigger_Purity"), 2.5); + histos.fill(HIST("REC_Trigger_Energy_FAKE"), mccluster.energy()); + } + } // cluster loop + + // clusters done, now we do the sternheimer tracks + for (auto& track : tracks) { + bool sterntrigger = false; + double sternPt = 0.0; + auto ogtrack = track.track_as(); + if (!trackSelection(ogtrack)) { + continue; + } + if (clustertrigger) { + histos.fill(HIST("REC_TrackPhi_photontrigger"), track.phi()); + histos.fill(HIST("REC_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; + 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); + 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); + +}; // end of main struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +}; diff --git a/PWGJE/Tasks/trackEfficiency.cxx b/PWGJE/Tasks/trackEfficiency.cxx index 815128bc1e7..47d5ce4ea17 100644 --- a/PWGJE/Tasks/trackEfficiency.cxx +++ b/PWGJE/Tasks/trackEfficiency.cxx @@ -44,7 +44,7 @@ using namespace o2::framework::expressions; struct TrackEfficiencyJets { Service pdg; - using JetParticlesWithOriginal = soa::Join; + using JetParticlesWithOriginal = soa::Join; HistogramRegistry registry; @@ -60,12 +60,15 @@ struct TrackEfficiencyJets { Configurable centralityMax{"centralityMax", 999, ""}; 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 nBinsLowPt{"nBinsLowPt", 200, "number of pt bins for low pt (below 10GeV) efficiency histograms"}; // Track QA process function configurables: - Configurable trackQAEtaMin{"trackEtaMin", -0.9, "minimum eta acceptance for tracks in the processTracks QA"}; - Configurable trackQAEtaMax{"trackEtaMax", 0.9, "maximum eta acceptance for tracks in the processTracks QA"}; - Configurable trackQAPtMin{"trackPtMin", 0.15, "minimum pT acceptance for tracks in the processTracks QA"}; - Configurable trackQAPtMax{"trackPtMax", 100.0, "maximum pT acceptance for tracks in the processTracks QA"}; + Configurable trackQAEtaMin{"trackQAEtaMin", -0.9, "minimum eta acceptance for tracks in the processTracks QA"}; + Configurable trackQAEtaMax{"trackQAEtaMax", 0.9, "maximum eta acceptance for tracks in the processTracks QA"}; + Configurable trackQAPtMin{"trackQAPtMin", 0.15, "minimum pT acceptance for tracks in the processTracks QA"}; + Configurable trackQAPtMax{"trackQAPtMax", 100.0, "maximum pT acceptance for tracks in the processTracks QA"}; + 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; int trackSelection = -1; @@ -91,8 +94,21 @@ struct TrackEfficiencyJets { 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("h3_centrality_track_pt_track_sigma1overpt"), collision.centrality(), track.pt(), track.sigma1Pt(), weight); - registry.fill(HIST("h3_centrality_track_pt_track_sigmapt"), collision.centrality(), track.pt(), track.sigma1Pt() * track.pt(), 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); + } + } + + template + void fillParticlesHistograms(T const& collision, U const& mcparticles, 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); } } @@ -113,8 +129,8 @@ struct TrackEfficiencyJets { registry.add("hMcPartCutsCounts", "McPart cuts count checks", {HistType::kTH1F, {{10, 0., 10.}}}); registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(1, "allPartsInSelMcColl"); - registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(2, "isPrimary"); - registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(3, "isCharged"); + registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(2, "isCharged"); + registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(3, "isPrimary"); registry.get(HIST("hMcPartCutsCounts"))->GetXaxis()->SetBinLabel(4, "etaAccept"); // not actually applied here but it will give an idea of what will be done in the post processing registry.add("hTrackCutsCounts", "Track cuts count checks", {HistType::kTH1F, {{10, 0., 10.}}}); @@ -124,50 +140,93 @@ struct TrackEfficiencyJets { 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 = {500, 0., 10., "#it{p}_{T} (GeV/#it{c})"}; - AxisSpec etaAxis = {100, -1.0, 1.0, "#eta"}; - AxisSpec phiAxis = {200, -1.0, 7., "#phi"}; + 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"}; + + // 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_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_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_mcpartofinterest", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis, etaAxis, phiAxis}}); + 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("h3_track_pt_track_eta_track_phi_nonassociatedtrack", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis, etaAxis, phiAxis}}); - 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, etaAxis, phiAxis}}); - 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, etaAxis, phiAxis}}); - registry.add("h3_track_pt_track_eta_track_phi_associatedtrack_split", "#it{p}_{T, track} (GeV/#it{c}); #eta_{track}; #phi_{track}", {HistType::kTH3F, {ptAxis, etaAxis, phiAxis}}); + // 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_particle_eta_particle_phi_associatedtrack_primary", "#it{p}_{T, mcpart} (GeV/#it{c}); #eta_{mcpart}; #phi_{mcpart}", {HistType::kTH3F, {ptAxis, etaAxis, phiAxis}}); - 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, etaAxis, phiAxis}}); - 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, etaAxis, phiAxis}}); - 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, etaAxis, phiAxis}}); + 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("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, {200, -1., 1.}}}); + 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("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.}}}); } if (doprocessTracks || doprocessTracksWeighted) { - AxisSpec centAxis = {101, 0., 101., "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}}}); + AxisSpec centAxis = {121, -10., 111., "centrality (%)"}; 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.}}}); registry.add("h2_centrality_track_energy", "centrality vs track energy; centrality; Energy GeV", {HistType::kTH2F, {centAxis, {100, 0.0, 100.0}}}); - registry.add("h3_centrality_track_pt_track_sigmapt", "#it{p}_{T,track} (GeV/#it{c}); #sigma(#it{p}_{T})", {HistType::kTH3F, {centAxis, {100, 0., 100.}, {200, 0.0, 2.0}}}); - registry.add("h3_centrality_track_pt_track_sigma1overpt", "#it{p}_{T,track} (GeV/#it{c}); #sigma(#it{p}_{T})/#it{p}_{T}", {HistType::kTH3F, {centAxis, {1000, 0., 100.}, {200, 0.0, 2.0}}}); - if (doprocessTracksWeighted) { - registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); - } + registry.add("h2_track_pt_track_sigmapt", "#sigma(#it{p}_{T})/#it{p}_{T}; #it{p}_{T,track} (GeV/#it{c})", {HistType::kTH2F, {{100, 0., 10.}, {100000, 0.0, 100.0}}}); + 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}}}); + } + + 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}}}); + } + + if (doprocessTracks || doprocessTracksWeighted) { + AxisSpec centAxis = {121, -10., 111., "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 (%)"}; + 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}}}); + } + if (doprocessTracksWeighted) { + registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + } + if (doprocessParticlesWeighted) { + registry.add("h_mccollisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); } } - Preslice tracksPerJCollision = o2::aod::jtrack::collisionId; + Preslice tracksPerJCollision = o2::aod::jtrack::collisionId; // 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); - void processEFficiencyPurity(JetMcCollision const& mcCollision, - 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, + void processEFficiencyPurity(aod::JetMcCollision const& mcCollision, + 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: @@ -225,18 +284,22 @@ struct TrackEfficiencyJets { for (auto& jMcParticle : jMcParticles) { registry.fill(HIST("hMcPartCutsCounts"), 0.5); // allPartsInSelMcColl - if (checkPrimaryPart && !jMcParticle.isPhysicalPrimary()) { // global tracks should be mostly primaries + if (!isChargedParticle(jMcParticle.pdgCode())) { continue; } - registry.fill(HIST("hMcPartCutsCounts"), 1.5); // isPrimary + registry.fill(HIST("hMcPartCutsCounts"), 1.5); // isCharged - if (!isChargedParticle(jMcParticle.pdgCode())) { + registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_mcpart_nonprimary"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi()); + + if (checkPrimaryPart && !jMcParticle.isPhysicalPrimary()) { // global tracks should be mostly primaries continue; } - registry.fill(HIST("hMcPartCutsCounts"), 2.5); // isCharged + registry.fill(HIST("hMcPartCutsCounts"), 2.5); // isPrimary registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_mcpartofinterest"), jMcParticle.pt(), jMcParticle.eta(), jMcParticle.phi()); + 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 } @@ -266,6 +329,8 @@ struct TrackEfficiencyJets { if (!track.has_mcParticle()) { registry.fill(HIST("h3_track_pt_track_eta_track_phi_nonassociatedtrack"), track.pt(), track.eta(), track.phi()); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_nonassociatedtrack"), track.pt(), track.eta(), track.phi()); continue; } registry.fill(HIST("hTrackCutsCounts"), 2.5); @@ -275,8 +340,15 @@ struct TrackEfficiencyJets { registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_nonprimary"), track.pt(), track.eta(), track.phi()); registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_nonprimary"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); + 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()); registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_nonprimary"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_nonprimary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); } else { seenMcParticlesVector.push_back(jMcParticleFromTrack.globalIndex()); } @@ -290,9 +362,16 @@ struct TrackEfficiencyJets { registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); registry.fill(HIST("h2_particle_pt_track_pt_residual_associatedtrack_primary"), jMcParticleFromTrack.pt(), (jMcParticleFromTrack.pt() - track.pt()) / jMcParticleFromTrack.pt()); + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_primary"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); + registry.fill(HIST("h2_particle_pt_high_track_pt_high_residual_associatedtrack_primary"), jMcParticleFromTrack.pt(), (jMcParticleFromTrack.pt() - track.pt()) / jMcParticleFromTrack.pt()); + if (std::find(seenMcParticlesVector.begin(), seenMcParticlesVector.end(), jMcParticleFromTrack.globalIndex()) != seenMcParticlesVector.end()) { - registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_split"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("h3_track_pt_track_eta_track_phi_associatedtrack_split_primary"), track.pt(), track.eta(), track.phi()); registry.fill(HIST("h3_particle_pt_particle_eta_particle_phi_associatedtrack_split_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); + + registry.fill(HIST("h3_track_pt_high_track_eta_track_phi_associatedtrack_split_primary"), track.pt(), track.eta(), track.phi()); + registry.fill(HIST("h3_particle_pt_high_particle_eta_particle_phi_associatedtrack_split_primary"), jMcParticleFromTrack.pt(), jMcParticleFromTrack.eta(), jMcParticleFromTrack.phi()); } else { seenMcParticlesVector.push_back(jMcParticleFromTrack.globalIndex()); } @@ -305,8 +384,8 @@ struct TrackEfficiencyJets { } PROCESS_SWITCH(TrackEfficiencyJets, processEFficiencyPurity, "Histograms for efficiency and purity quantities", true); - void processTracks(soa::Filtered::iterator const& collision, - soa::Filtered> const& tracks) + void processTracks(soa::Filtered::iterator const& collision, + soa::Filtered> const& tracks) { registry.fill(HIST("h_collisions"), 0.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 0.5); @@ -315,13 +394,18 @@ struct TrackEfficiencyJets { } registry.fill(HIST("h_collisions"), 1.5); registry.fill(HIST("h2_centrality_collisions"), collision.centrality(), 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); } PROCESS_SWITCH(TrackEfficiencyJets, processTracks, "QA for charged tracks", false); - void processTracksWeighted(soa::Join::iterator const& collision, - JetMcCollisions const&, - soa::Filtered> const& tracks) + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JetMcCollisions const&, + soa::Filtered> const& tracks) { float eventWeight = collision.mcCollision().weight(); registry.fill(HIST("h_collisions"), 0.5); @@ -331,9 +415,113 @@ struct TrackEfficiencyJets { } registry.fill(HIST("h_collisions"), 1.5); registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + if (collision.trackOccupancyInTimeRange() < trackOccupancyInTimeRangeMin || trackOccupancyInTimeRangeMax < collision.trackOccupancyInTimeRange()) { + return; + } + registry.fill(HIST("h_collisions"), 2.5); + registry.fill(HIST("h_collisions_weighted"), 2.5, eventWeight); fillTrackHistograms(collision, tracks, eventWeight); } PROCESS_SWITCH(TrackEfficiencyJets, processTracksWeighted, "QA for charged tracks weighted", false); + + void processParticles(aod::JetMcCollision const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered const& mcparticles) + { + registry.fill(HIST("h_mccollisions"), 0.5); + registry.fill(HIST("h2_centrality_mccollisions"), collisions.begin().centrality(), 0.5); + + if (!(abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (acceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + + 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 + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collisions.begin().centrality()) && (collisions.begin().centrality() < 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 + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collision.centrality()) && (collision.centrality() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } + } + if (!hasSel8Coll) { + return; + } + 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); + } + PROCESS_SWITCH(TrackEfficiencyJets, processParticles, "QA for charged particles", false); + + void processParticlesWeighted(aod::JetMcCollision const& mcCollision, + soa::SmallGroups const& collisions, + soa::Filtered const& mcparticles) + { + float eventWeight = mcCollision.weight(); + registry.fill(HIST("h_mccollisions"), 0.5); + registry.fill(HIST("h_mccollisions_weighted"), 0.5, eventWeight); + + if (!(abs(mcCollision.posZ()) < vertexZCut)) { + return; + } + if (collisions.size() < 1) { + return; + } + if (acceptSplitCollisions == 0 && collisions.size() > 1) { + return; + } + + 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 + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collisions.begin().centrality()) && (collisions.begin().centrality() < 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 + hasSel8Coll = true; + } + if (!checkCentrality || ((centralityMin < collision.centrality()) && (collision.centrality() < centralityMax))) { // effect unclear if mcColl is split + centralityCheck = true; + } + } + } + if (!hasSel8Coll) { + return; + } + if (!centralityCheck) { + return; + } + + registry.fill(HIST("h_mccollisions"), 1.5); + registry.fill(HIST("h_mccollisions_weighted"), 1.5, eventWeight); + fillParticlesHistograms(collisions.begin(), mcparticles, eventWeight); + } + PROCESS_SWITCH(TrackEfficiencyJets, processParticlesWeighted, "QA for charged particles weighted", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"track-efficiency"})}; } diff --git a/PWGJE/Tasks/triggerCorrelations.cxx b/PWGJE/Tasks/triggerCorrelations.cxx index e215bae706e..bb2d43e1f95 100644 --- a/PWGJE/Tasks/triggerCorrelations.cxx +++ b/PWGJE/Tasks/triggerCorrelations.cxx @@ -44,79 +44,31 @@ struct TriggerCorrelationsTask { HistogramRegistry registry; - int nChTrigs; - int nFullTrigs; - int nChHFTrigs; - int nAllTrigs; - - int chTrigOffset; - int fullTrigOffset; - int chHFTrigOffset; - + std::vector triggerMaskBits; void init(o2::framework::InitContext&) { - std::vector trigSelChLabels = {"chargedLow", "chargedHigh", "trackLowPt", "trackHighPt"}; - std::vector trigSelFullLabels = {"fullHigh", "fullLow", "neutralHigh", "neutralLow", "gammaVeryHighEMCAL", "gammaHighEMCAL", "gammaLowEMCAL", "gammaVeryLowEMCAL", "gammaVeryHighDCAL", "gammaHighDCAL", "gammaLowDCAL", "gammaVeryLowDCAL"}; - std::vector trigSelChHFLabels = {"chargedD0Low", "chargedD0High", "chargedLcLow", "chargedLcHigh"}; - nChTrigs = trigSelChLabels.size(); - nFullTrigs = trigSelFullLabels.size(); - nChHFTrigs = trigSelChHFLabels.size(); - nAllTrigs = nChTrigs + nFullTrigs + nChHFTrigs; - chTrigOffset = 0; - fullTrigOffset = chTrigOffset + nChTrigs; - chHFTrigOffset = fullTrigOffset + nFullTrigs; - registry.add("triggerCorrelations", "Correlation between jet triggers", HistType::kTH2D, {{nAllTrigs, -0.5, static_cast(nAllTrigs) - 0.5, "primary trigger"}, {nAllTrigs, -0.5, static_cast(nAllTrigs) - 0.5, "secondary trigger"}}); + triggerMaskBits = jetderiveddatautilities::initialiseTriggerMaskBits(jetderiveddatautilities::JTriggerMasks); + + std::vector trigSelLabels = {"JetChLowPt", "JetChHighPt", "TrackLowPt", "TrackHighPt", "JetD0ChLowPt", "JetD0ChHighPt", "JetLcChLowPt", "JetLcChHighPt", "EMCALReadout", "JetFullHighPt", "JetFullLowPt", "JetNeutralHighPt", "JetNeutralLowPt", "GammaVeryHighPtEMCAL", "GammaVeryHighPtDCAL", "GammaHighPtEMCAL", "GammaHighPtDCAL", "GammaLowPtEMCAL", "GammaLowPtDCAL", "GammaVeryLowPtEMCAL", "GammaVeryLowPtDCAL"}; + registry.add("triggerCorrelations", "Correlation between jet triggers", HistType::kTH2D, {{static_cast(trigSelLabels.size()), -0.5, static_cast(trigSelLabels.size()) - 0.5, "primary trigger"}, {static_cast(trigSelLabels.size()), -0.5, static_cast(trigSelLabels.size()) - 0.5, "secondary trigger"}}); auto triggerCorrelation = registry.get(HIST("triggerCorrelations")); - for (auto iChTrigs = 0; iChTrigs < nChTrigs; iChTrigs++) { - triggerCorrelation->GetXaxis()->SetBinLabel(iChTrigs + chTrigOffset + 1, trigSelChLabels[iChTrigs].data()); - triggerCorrelation->GetYaxis()->SetBinLabel(iChTrigs + chTrigOffset + 1, trigSelChLabels[iChTrigs].data()); - } - for (auto iFullTrigs = 0; iFullTrigs < nFullTrigs; iFullTrigs++) { - triggerCorrelation->GetXaxis()->SetBinLabel(iFullTrigs + fullTrigOffset + 1, trigSelFullLabels[iFullTrigs].data()); - triggerCorrelation->GetYaxis()->SetBinLabel(iFullTrigs + fullTrigOffset + 1, trigSelFullLabels[iFullTrigs].data()); - } - for (auto iChHFTrigs = 0; iChHFTrigs < nChHFTrigs; iChHFTrigs++) { - triggerCorrelation->GetXaxis()->SetBinLabel(iChHFTrigs + chHFTrigOffset + 1, trigSelChHFLabels[iChHFTrigs].data()); - triggerCorrelation->GetYaxis()->SetBinLabel(iChHFTrigs + chHFTrigOffset + 1, trigSelChHFLabels[iChHFTrigs].data()); + for (std::vector::size_type iTrigs = 0; iTrigs < trigSelLabels.size(); iTrigs++) { + triggerCorrelation->GetXaxis()->SetBinLabel(iTrigs + 1, trigSelLabels[iTrigs].data()); + triggerCorrelation->GetYaxis()->SetBinLabel(iTrigs + 1, trigSelLabels[iTrigs].data()); } } template - void fillCorrelationsHistogram(T const& collision, bool fill = false, int iTrig = -1) + void fillCorrelationsHistogram(T const& collision, bool fill = false, int iCurrentTrig = -1) { - - for (auto iChTrigs = 0; iChTrigs < nChTrigs; iChTrigs++) { - if (fill) { - if (jetderiveddatautilities::selectChargedTrigger(collision, iChTrigs + 1)) { - registry.fill(HIST("triggerCorrelations"), iTrig, iChTrigs + chTrigOffset); - } - } else { - if (jetderiveddatautilities::selectChargedTrigger(collision, iChTrigs + 1)) { - fillCorrelationsHistogram(collision, true, iChTrigs + chTrigOffset); - } - } - } - - for (auto iFullTrigs = 0; iFullTrigs < nFullTrigs; iFullTrigs++) { - if (fill) { - if (jetderiveddatautilities::selectFullTrigger(collision, iFullTrigs + 1)) { - registry.fill(HIST("triggerCorrelations"), iTrig, iFullTrigs + fullTrigOffset); - } - } else { - if (jetderiveddatautilities::selectFullTrigger(collision, iFullTrigs + 1)) { - fillCorrelationsHistogram(collision, true, iFullTrigs + fullTrigOffset); - } - } - } - - for (auto iChHFTrigs = 0; iChHFTrigs < nFullTrigs; iChHFTrigs++) { + for (std::vector::size_type iTrig = 0; iTrig < triggerMaskBits.size(); iTrig++) { if (fill) { - if (jetderiveddatautilities::selectChargedHFTrigger(collision, iChHFTrigs + 1)) { - registry.fill(HIST("triggerCorrelations"), iTrig, iChHFTrigs + chHFTrigOffset); + if (jetderiveddatautilities::selectTrigger(collision, triggerMaskBits[iTrig])) { + registry.fill(HIST("triggerCorrelations"), iCurrentTrig, iTrig); } } else { - if (jetderiveddatautilities::selectChargedHFTrigger(collision, iChHFTrigs + 1)) { - fillCorrelationsHistogram(collision, true, iChHFTrigs + chHFTrigOffset); + if (jetderiveddatautilities::selectTrigger(collision, triggerMaskBits[iTrig])) { + fillCorrelationsHistogram(collision, true, iTrig); } } } diff --git a/PWGJE/Tasks/v0jetspectra.cxx b/PWGJE/Tasks/v0jetspectra.cxx index dad55b12e52..cbf39c5b057 100644 --- a/PWGJE/Tasks/v0jetspectra.cxx +++ b/PWGJE/Tasks/v0jetspectra.cxx @@ -9,8 +9,8 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// jet spectra for v0 fragmentation study -// +/// \brief Jet spectra for ch+V0 jets +/// /// \author Gijs van Weelden // @@ -89,7 +89,7 @@ struct V0JetSpectra { } } - void processData(soa::Filtered::iterator const& jcoll, aod::ChargedJets const& chjets, aod::V0ChargedJets const& v0jets) + void processData(soa::Filtered::iterator const& jcoll, aod::ChargedJets const& chjets, aod::V0ChargedJets const& v0jets) { if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { return; @@ -100,7 +100,7 @@ struct V0JetSpectra { } PROCESS_SWITCH(V0JetSpectra, processData, "Jet spectra for V0 jets or Ch jets if no V0s in data", false); - void processMCD(soa::Filtered::iterator const& jcoll, JetMcCollisions const&, MCDJets const& chjets, MCDV0Jets const& v0jets) + void processMCD(soa::Filtered::iterator const& jcoll, aod::JetMcCollisions const&, MCDJets const& chjets, MCDV0Jets const& v0jets) { if (!jcoll.has_mcCollision()) { return; @@ -115,7 +115,7 @@ struct V0JetSpectra { } PROCESS_SWITCH(V0JetSpectra, processMCD, "Jet spectra for V0 jets or Ch jets if no V0s", false); - void processMCP(JetMcCollision const& jcoll, MCPJets const& chjets, MCPV0Jets const& v0jets) + void processMCP(aod::JetMcCollision const& jcoll, MCPJets const& chjets, MCPV0Jets const& v0jets) { double weight = jcoll.weight(); if (v0jets.size() == 0) { @@ -124,7 +124,7 @@ struct V0JetSpectra { } PROCESS_SWITCH(V0JetSpectra, processMCP, "Jet spectra for V0 jets or Ch jets if no V0s", false); - void processMcMatched(soa::Filtered::iterator const& jcoll, JetMcCollisions const&, MatchedMCDJets const& chjetsMCD, MatchedMCPJets const& chjetsMCP, MatchedMCDV0Jets const& v0jetsMCD, MatchedMCPV0Jets const& v0jetsMCP) + 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)) { return; diff --git a/PWGJE/Tasks/v0qa.cxx b/PWGJE/Tasks/v0qa.cxx new file mode 100644 index 00000000000..e4de0088ccf --- /dev/null +++ b/PWGJE/Tasks/v0qa.cxx @@ -0,0 +1,1280 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 V0s in the jets framework, based on the LF v0cascadesqa task +// +/// \author Gijs van Weelden +// + +#include "TH1F.h" +#include "TTree.h" + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/RunningWorkflowInfo.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" + +#include "CommonConstants/PhysicsConstants.h" + +#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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// V0 jets +using MCDV0Jets = aod::V0ChargedMCDetectorLevelJets; +using MCDV0JetsWithConstituents = soa::Join; +using MatchedMCDV0Jets = soa::Join; +using MatchedMCDV0JetsWithConstituents = 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? + + 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 binEta{"binEta", {100, -1.0f, 1.0f}, ""}; + ConfigurableAxis binPhi{"binPhi", {static_cast(TMath::Pi()) * 10 / 2, 0.0f, 2. * static_cast(TMath::Pi())}, ""}; + + 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 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 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}, ""}; + + int eventSelection = -1; + + void init(InitContext&) + { + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(evSel)); + + const AxisSpec axisJetPt{binPtJet, "Jet Pt (GeV/c)"}; + const AxisSpec axisV0Pt{binPtV0, "V0 Pt (GeV/c)"}; + const AxisSpec axisEta{binEta, "Eta"}; + const AxisSpec axisPhi{binPhi, "Phi"}; + const AxisSpec axisV0Radius{binV0Radius, "V0 Radius (cm)"}; + const AxisSpec axisV0CosPA{binV0CosPA, "V0 CosPA"}; + const AxisSpec axisK0SM{binInvMassK0S, "M(#pi^{+} #pi^{-}) (GeV/c^{2})"}; + const AxisSpec axisLambdaM{binInvMassLambda, "M(p #pi^{-}) (GeV/c^{2})"}; + const AxisSpec axisAntiLambdaM{binInvMassLambda, "M(#bar{p} #pi^{+}) (GeV/c^{2})"}; + + const AxisSpec axisPtDiff{binPtDiff, "Pt difference (GeV/c)"}; + const AxisSpec axisDcaXY{binsDcaXY, "DCA_{xy} (cm)"}; + const AxisSpec axisDcaZ{binsDcaZ, "DCA_{z} (cm)"}; + const AxisSpec axisITSNCl{binITSNCl, "# clusters ITS"}; + const AxisSpec axisITSChi2NCl{binITSChi2NCl, "Chi2 / cluster ITS"}; + + const AxisSpec axisNClFindable{binTPCNCl, "# findable clusters TPC"}; + const AxisSpec axisNClFound{binTPCNCl, "# found clusters TPC"}; + const AxisSpec axisNClShared{binTPCNCl, "# shared clusters TPC"}; + const AxisSpec axisNClCrossedRows{binTPCNCl, "# crossed rows TPC"}; + const AxisSpec axisTPCChi2NCl{binTPCChi2NCl, "Chi2 / cluster TPC"}; + const AxisSpec axisSharedFraction{binTPCNClSharedFraction, "Fraction shared clusters TPC"}; + 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}}); + } + if (doprocessMcD) { + registry.add("inclusive/hEvents", "Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("inclusive/K0SPtEtaMass", "K0S Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisK0SM}); + registry.add("inclusive/InvMassK0STrue", "Invariant mass of K0S", HistType::kTH3D, {axisV0Pt, axisV0Radius, axisK0SM}); + registry.add("inclusive/InvMassLambdaTrue", "Invariant mass of Lambda", HistType::kTH3D, {axisV0Pt, axisV0Radius, axisLambdaM}); + registry.add("inclusive/LambdaPtEtaMass", "Lambda Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisLambdaM}); + registry.add("inclusive/InvMassAntiLambdaTrue", "Invariant mass of AntiLambda", HistType::kTH3D, {axisV0Pt, axisV0Radius, axisAntiLambdaM}); + registry.add("inclusive/AntiLambdaPtEtaMass", "AntiLambda Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisAntiLambdaM}); + } + if (doprocessMcP) { + registry.add("inclusive/hMcEvents", "MC Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("inclusive/GeneratedK0S", "Generated K0S", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Radius}); + registry.add("inclusive/GeneratedLambda", "Generated Lambda", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Radius}); + registry.add("inclusive/GeneratedAntiLambda", "Generated AntiLambda", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Radius}); + } + if (doprocessMcDJets) { + registry.add("jets/hJetEvents", "Jet Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("jets/JetPtEtaK0SPt", "Jet Pt, Eta, K0S Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetK0STrue", "Invariant mass of K0S in jets", HistType::kTH3D, {axisJetPt, axisV0Pt, axisK0SM}); + registry.add("jets/JetPtEtaLambdaPt", "Jet Pt, Eta, Lambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetLambdaTrue", "Invariant mass of Lambda in jets", HistType::kTH3D, {axisJetPt, axisV0Pt, axisLambdaM}); + registry.add("jets/JetPtEtaAntiLambdaPt", "Jet Pt, Eta, AntiLambda Pt", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetAntiLambdaTrue", "Invariant mass of AntiLambda in jets", HistType::kTH3D, {axisJetPt, axisV0Pt, axisAntiLambdaM}); + } + if (doprocessMcDMatchedJets) { + registry.add("jets/hMatchedJetEvents", "Matched Jet Events", {HistType::kTH1D, {{2, 0.0f, 2.0f}}}); + registry.add("jets/JetsPtEtaK0SPt", "Matched Jet Pt, Eta, K0S Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetsK0STrue", "Invariant mass of K0S in matched jets", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisV0Pt, axisK0SM}); + registry.add("jets/JetsPtEtaLambdaPt", "Matched Jet Pt, Eta, Lambda Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetsLambdaTrue", "Invariant mass of Lambda in matched jets", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisV0Pt, axisLambdaM}); + registry.add("jets/JetsPtEtaAntiLambdaPt", "Matched Jet Pt, Eta, AntiLambda Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/InvMassJetsAntiLambdaTrue", "Invariant mass of AntiLambda in matched jets", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisV0Pt, axisAntiLambdaM}); + } + 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/GeneratedJetLambda", "Generated Jet Lambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + registry.add("jets/GeneratedJetAntiLambda", "Generated Jet AntiLambda", HistType::kTH3D, {axisJetPt, axisEta, axisV0Pt}); + } + if (doprocessCollisionAssociation) { + registry.add("collisions/V0PtEta", "V0 Pt, Eta", HistType::kTH2D, {axisV0Pt, axisEta}); + registry.add("collisions/V0PtEtaWrongColl", "V0 Pt, Eta, wrong collision", HistType::kTH2D, {axisV0Pt, axisEta}); + registry.add("collisions/K0SPtEtaMass", "K0S Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisK0SM}); + registry.add("collisions/K0SPtEtaMassWrongColl", "K0S Pt, Eta, Mass, wrong collision", HistType::kTH3D, {axisV0Pt, axisEta, axisK0SM}); + registry.add("collisions/LambdaPtEtaMass", "Lambda Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisLambdaM}); + registry.add("collisions/LambdaPtEtaMassWrongColl", "Lambda Pt, Eta, Mass, wrong collision", HistType::kTH3D, {axisV0Pt, axisEta, axisLambdaM}); + registry.add("collisions/AntiLambdaPtEtaMass", "AntiLambda Pt, Eta, Mass", HistType::kTH3D, {axisV0Pt, axisEta, axisAntiLambdaM}); + registry.add("collisions/AntiLambdaPtEtaMassWrongColl", "AntiLambda Pt, Eta, Mass, wrong collision", HistType::kTH3D, {axisV0Pt, axisEta, axisAntiLambdaM}); + + registry.add("collisions/XiMinusPtYLambdaPt", "#Xi^{-} Pt, Y, #Lambda Pt", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + registry.add("collisions/XiMinusPtYLambdaPtWrongColl", "#Xi^{-} Pt, Y, #Lambda Pt, wrong collision", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + registry.add("collisions/XiPlusPtYAntiLambdaPt", "#Xi^{+} Pt, Y, #bar{#Lambda} Pt", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + registry.add("collisions/XiPlusPtYAntiLambdaPtWrongColl", "#Xi^{+} Pt, Y, #bar{#Lambda} Pt, wrong collision", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + } + if (doprocessCollisionAssociationJets) { + 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/JetPtEtaK0SPtMassWrongColl", "Jet Pt, Eta, K0S Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisK0SM}); + registry.add("collisions/JetPtEtaLambdaPtMass", "Jet Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetPtEtaLambdaPtMassWrongColl", "Jet Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetPtEtaAntiLambdaPtMass", "Jet Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetPtEtaAntiLambdaPtMassWrongColl", "Jet Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, 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}); + registry.add("collisions/JetPtEtaXiPlusPtAntiLambdaPt", "Jet Pt, #Xi^{+} Pt, #bar{#Lambda} Pt", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisV0Pt}); + registry.add("collisions/JetPtEtaXiPlusPtAntiLambdaPtWrongColl", "Jet Pt, #Xi^{+} Pt, #bar{#Lambda} Pt", HistType::kTHnSparseD, {axisJetPt, axisEta, axisV0Pt, axisV0Pt}); + } + if (doprocessCollisionAssociationMatchedJets) { + 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/JetsPtEtaLambdaPtMass", "Jets Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetsPtEtaLambdaPtMassWrongColl", "Jets Pt, Eta, Lambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisLambdaM}); + registry.add("collisions/JetsPtEtaAntiLambdaPtMass", "Jets Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisAntiLambdaM}); + registry.add("collisions/JetsPtEtaAntiLambdaPtMassWrongColl", "Jets Pt, Eta, AntiLambda Pt Mass", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, 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}); + registry.add("collisions/JetsPtEtaXiPlusPtAntiLambdaPt", "Jets Pt, Eta, #Xi^{+} Pt, #bar{#Lambda} Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisV0Pt}); + registry.add("collisions/JetsPtEtaXiPlusPtAntiLambdaPtWrongColl", "Jets Pt, Eta, #Xi^{+} Pt, #bar{#Lambda} Pt", HistType::kTHnSparseD, {axisJetPt, axisJetPt, axisEta, axisV0Pt, axisV0Pt}); + } + if (doprocessFeeddown) { + registry.add("feeddown/XiMinusPtYLambdaPt", "#Xi^{-} Pt, Y, #Lambda Pt", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + registry.add("feeddown/XiPlusPtYAntiLambdaPt", "#Xi^{-} Pt, Y, #Lambda Pt", HistType::kTH3D, {axisV0Pt, axisEta, axisV0Pt}); + } + if (doprocessFeeddownJets) { + registry.add("feeddown/JetPtXiMinusPtLambdaPt", "Jets Pt, #Xi^{-} Pt, #Lambda Pt", HistType::kTH3D, {axisJetPt, axisJetPt, axisV0Pt}); + registry.add("feeddown/JetPtXiPlusPtAntiLambdaPt", "Jets Pt, #Xi^{+} Pt, #Lambda Pt", HistType::kTH3D, {axisJetPt, axisJetPt, axisV0Pt}); + } + if (doprocessFeeddownMatchedJets) { + 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 (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/PtMass", "pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); + registry.add("tracks/PtDiffMass", "ptdiff mass", HistType::kTHnSparseD, {axisV0Pt, axisPtDiff, axisK0SM, axisLambdaM, axisAntiLambdaM}); + + registry.add("tracks/DCAxy", "dcaxy", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaXY, axisDcaXY, axisPtDiff}); + registry.add("tracks/DCAxyMassK0S", "dcaxy mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaXY, axisDcaXY, axisK0SM}); + registry.add("tracks/DCAxyMassLambda0", "dcaxy mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaXY, axisDcaXY, axisLambdaM}); + registry.add("tracks/DCAxyMassAntiLambda0", "dcaxy mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaXY, axisDcaXY, axisAntiLambdaM}); + + registry.add("tracks/DCAz", "dcaz", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaZ, axisDcaZ, axisPtDiff}); + registry.add("tracks/DCAzMassK0S", "dcaz mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaZ, axisDcaZ, axisK0SM}); + registry.add("tracks/DCAzMassLambda0", "dcaz mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaZ, axisDcaZ, axisLambdaM}); + registry.add("tracks/DCAzMassAntiLambda0", "dcaz mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisDcaZ, axisDcaZ, axisAntiLambdaM}); + + registry.add("tracks/V0Radius", "v0 radius", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0Radius, axisPtDiff}); + registry.add("tracks/V0RadiusMassK0S", "v0 radius mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0Radius, axisK0SM}); + registry.add("tracks/V0RadiusMassLambda0", "v0 radius mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0Radius, axisLambdaM}); + registry.add("tracks/V0RadiusMassAntiLambda0", "v0 radius mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0Radius, axisAntiLambdaM}); + + registry.add("tracks/V0CosPa", "v0 cos pa", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0CosPA, axisPtDiff}); + registry.add("tracks/V0CosPaMassK0S", "v0 cos pa mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0CosPA, axisK0SM}); + registry.add("tracks/V0CosPaMassLambda0", "v0 cos pa mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0CosPA, axisLambdaM}); + registry.add("tracks/V0CosPaMassAntiLambda0", "v0 cos pa mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisV0CosPA, axisAntiLambdaM}); + + // TRD + registry.add("tracks/posTRDPt", "pos trd pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/posTRDPtMass", "pos trd pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); + registry.add("tracks/posNoTRDPt", "pos no trd pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/posNoTRDPtMass", "pos no trd pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); + + registry.add("tracks/negTRDPt", "neg trd pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/negTRDPtMass", "neg trd pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); + registry.add("tracks/negNoTRDPt", "neg no trd pt", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/negNoTRDPtMass", "neg no trd pt mass", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM, axisLambdaM, axisAntiLambdaM}); + + // ITS: positive track + registry.add("tracks/ITS/posLayer1", "pos layer 1", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer1MassK0S", "pos layer 1 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer1MassLambda0", "pos layer 1 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer1MassAntiLambda0", "pos layer 1 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer2", "pos layer 2", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer2MassK0S", "pos layer 2 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer2MassLambda0", "pos layer 2 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer2MassAntiLambda0", "pos layer 2 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer3", "pos layer 3", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer3MassK0S", "pos layer 3 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer3MassLambda0", "pos layer 3 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer3MassAntiLambda0", "pos layer 3 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer4", "pos layer 4", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer4MassK0S", "pos layer 4 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer4MassLambda0", "pos layer 4 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer4MassAntiLambda0", "pos layer 4 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer5", "pos layer 5", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer5MassK0S", "pos layer 5 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer5MassLambda0", "pos layer 5 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer5MassAntiLambda0", "pos layer 5 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer6", "pos layer 6", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer6MassK0S", "pos layer 6 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer6MassLambda0", "pos layer 6 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer6MassAntiLambda0", "pos layer 6 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer7", "pos layer 7", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer7MassK0S", "pos layer 7 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer7MassLambda0", "pos layer 7 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer7MassAntiLambda0", "pos layer 7 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer56", "pos layer 56", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer56MassK0S", "pos layer 56 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer56MassLambda0", "pos layer 56 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer56MassAntiLambda0", "pos layer 56 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer67", "pos layer 67", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer67MassK0S", "pos layer 67 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer67MassLambda0", "pos layer 67 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer67MassAntiLambda0", "pos layer 67 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer57", "pos layer 57", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer57MassK0S", "pos layer 57 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer57MassLambda0", "pos layer 57 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer57MassAntiLambda0", "pos layer 57 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posLayer567", "pos layer 567", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/posLayer567MassK0S", "pos layer 567 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/posLayer567MassLambda0", "pos layer 567 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/posLayer567MassAntiLambda0", "pos layer 567 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/posNCl", "pos ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisITSNCl}); + registry.add("tracks/ITS/posChi2NCl", "pos chi2ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisITSChi2NCl}); + + // ITS: Negative track + registry.add("tracks/ITS/negLayer1", "neg layer 1", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer1MassK0S", "neg layer 1 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer1MassLambda0", "neg layer 1 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer1MassAntiLambda0", "neg layer 1 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer2", "neg layer 2", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer2MassK0S", "neg layer 2 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer2MassLambda0", "neg layer 2 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer2MassAntiLambda0", "neg layer 2 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer3", "neg layer 3", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer3MassK0S", "neg layer 3 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer3MassLambda0", "neg layer 3 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer3MassAntiLambda0", "neg layer 3 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer4", "neg layer 4", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer4MassK0S", "neg layer 4 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer4MassLambda0", "neg layer 4 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer4MassAntiLambda0", "neg layer 4 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer5", "neg layer 5", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer5MassK0S", "neg layer 5 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer5MassLambda0", "neg layer 5 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer5MassAntiLambda0", "neg layer 5 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer6", "neg layer 6", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer6MassK0S", "neg layer 6 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer6MassLambda0", "neg layer 6 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer6MassAntiLambda0", "neg layer 6 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer7", "neg layer 7", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer7MassK0S", "neg layer 7 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer7MassLambda0", "neg layer 7 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer7MassAntiLambda0", "neg layer 7 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer56", "neg layer 56", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer56MassK0S", "neg layer 56 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer56MassLambda0", "neg layer 56 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer56MassAntiLambda0", "neg layer 56 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer67", "neg layer 67", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer67MassK0S", "neg layer 67 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer67MassLambda0", "neg layer 67 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer67MassAntiLambda0", "neg layer 67 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer57", "neg layer 57", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer57MassK0S", "neg layer 57 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer57MassLambda0", "neg layer 57 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer57MassAntiLambda0", "neg layer 57 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negLayer567", "neg layer 567", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisPtDiff}); + registry.add("tracks/ITS/negLayer567MassK0S", "neg layer 567 mass K0S", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisK0SM}); + registry.add("tracks/ITS/negLayer567MassLambda0", "neg layer 567 mass Lambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisLambdaM}); + registry.add("tracks/ITS/negLayer567MassAntiLambda0", "neg layer 567 mass AntiLambda0", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisAntiLambdaM}); + + registry.add("tracks/ITS/negNCl", "neg ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisITSNCl}); + registry.add("tracks/ITS/negChi2NCl", "neg chi2ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisITSChi2NCl}); + + // TPC information + registry.add("tracks/TPC/posNClFindable", "pos ncl findable", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClFindable}); + registry.add("tracks/TPC/posNClsFound", "pos ncl found", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClFound}); + registry.add("tracks/TPC/posNClsShared", "pos ncl shared", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClShared}); + registry.add("tracks/TPC/posNClsCrossedRows", "pos ncl crossed rows", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClCrossedRows}); + registry.add("tracks/TPC/posNClsCrossedRowsOverFindableCls", "pos ncl crossed rows over findable cls", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisCrossedRowsOverFindable}); + registry.add("tracks/TPC/posFractionSharedCls", "pos fraction shared cls", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisSharedFraction}); + registry.add("tracks/TPC/posChi2NCl", "pos chi2ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisTPCChi2NCl}); + + registry.add("tracks/TPC/negNClFindable", "neg ncl findable", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClFindable}); + registry.add("tracks/TPC/negNClsFound", "neg ncl found", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClFound}); + registry.add("tracks/TPC/negNClsShared", "neg ncl shared", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClShared}); + registry.add("tracks/TPC/negNClsCrossedRows", "neg ncl crossed rows", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisNClCrossedRows}); + registry.add("tracks/TPC/negNClsCrossedRowsOverFindableCls", "neg ncl crossed rows over findable cls", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisCrossedRowsOverFindable}); + registry.add("tracks/TPC/negFractionSharedCls", "neg fraction shared cls", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisSharedFraction}); + registry.add("tracks/TPC/negChi2NCl", "neg chi2ncl", HistType::kTHnSparseD, {axisV0Pt, axisV0Pt, axisV0Pt, axisTPCChi2NCl}); + } // doprocessV0TrackQA + } // init + + template + bool isCollisionReconstructed(T const& collision, U const& eventSelection) + { + if (!collision.has_mcCollision()) { + return false; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) { + return false; + } + return true; + } + template + 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(); + 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 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) + { + int ibit = layer - 1; + return (track.itsClusterMap() & (1 << ibit)); + } + + template + void fillTrackQa(V const& v0) + { + auto posTrack = v0.template posTrack_as().template track_as(); + auto negTrack = v0.template negTrack_as().template track_as(); + + double mK = v0.mK0Short(); + double mL = v0.mLambda(); + double mAL = v0.mAntiLambda(); + + double vPt = v0.pt(); + double pPt = posTrack.pt(); + double nPt = negTrack.pt(); + double dPt = posTrack.pt() - negTrack.pt(); + + 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/PtMass"), vPt, pPt, nPt, mK, mL, mAL); + registry.fill(HIST("tracks/PtDiffMass"), vPt, dPt, mK, mL, mAL); + + registry.fill(HIST("tracks/DCAxy"), vPt, pPt, nPt, posTrack.dcaXY(), negTrack.dcaXY(), dPt); + registry.fill(HIST("tracks/DCAxyMassK0S"), vPt, pPt, nPt, posTrack.dcaXY(), negTrack.dcaXY(), mK); + registry.fill(HIST("tracks/DCAxyMassLambda0"), vPt, pPt, nPt, posTrack.dcaXY(), negTrack.dcaXY(), mL); + registry.fill(HIST("tracks/DCAxyMassAntiLambda0"), vPt, pPt, nPt, posTrack.dcaXY(), negTrack.dcaXY(), mAL); + + registry.fill(HIST("tracks/DCAz"), vPt, pPt, nPt, posTrack.dcaZ(), negTrack.dcaZ(), dPt); + registry.fill(HIST("tracks/DCAzMassK0S"), vPt, pPt, nPt, posTrack.dcaZ(), negTrack.dcaZ(), mK); + registry.fill(HIST("tracks/DCAzMassLambda0"), vPt, pPt, nPt, posTrack.dcaZ(), negTrack.dcaZ(), mL); + registry.fill(HIST("tracks/DCAzMassAntiLambda0"), vPt, pPt, nPt, posTrack.dcaZ(), negTrack.dcaZ(), mAL); + + registry.fill(HIST("tracks/V0Radius"), vPt, pPt, nPt, v0.v0radius(), dPt); + registry.fill(HIST("tracks/V0RadiusMassK0S"), vPt, pPt, nPt, v0.v0radius(), mK); + registry.fill(HIST("tracks/V0RadiusMassLambda0"), vPt, pPt, nPt, v0.v0radius(), mL); + registry.fill(HIST("tracks/V0RadiusMassAntiLambda0"), vPt, pPt, nPt, v0.v0radius(), mAL); + + registry.fill(HIST("tracks/V0CosPa"), vPt, pPt, nPt, v0.v0cosPA(), dPt); + registry.fill(HIST("tracks/V0CosPaMassK0S"), vPt, pPt, nPt, v0.v0cosPA(), mK); + registry.fill(HIST("tracks/V0CosPaMassLambda0"), vPt, pPt, nPt, v0.v0cosPA(), mL); + registry.fill(HIST("tracks/V0CosPaMassAntiLambda0"), vPt, pPt, nPt, v0.v0cosPA(), mAL); + + // Has TRD or not + if (posTrack.hasTRD()) { + registry.fill(HIST("tracks/posTRDPt"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/posTRDPtMass"), vPt, pPt, nPt, mK, mL, mAL); + } else { + registry.fill(HIST("tracks/posNoTRDPt"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/posNoTRDPtMass"), vPt, pPt, nPt, mK, mL, mAL); + } + if (negTrack.hasTRD()) { + registry.fill(HIST("tracks/negTRDPt"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/negTRDPtMass"), vPt, pPt, nPt, mK, mL, mAL); + } else { + registry.fill(HIST("tracks/negNoTRDPt"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/negNoTRDPtMass"), vPt, pPt, nPt, mK, mL, mAL); + } + + // ITS information + if (hasITSHit(posTrack, 1)) { + registry.fill(HIST("tracks/ITS/posLayer1"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer1MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer1MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer1MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 2)) { + registry.fill(HIST("tracks/ITS/posLayer2"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer2MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer2MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer2MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 3)) { + registry.fill(HIST("tracks/ITS/posLayer3"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer3MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer3MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer3MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 4)) { + registry.fill(HIST("tracks/ITS/posLayer4"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer4MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer4MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer4MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 5)) { + registry.fill(HIST("tracks/ITS/posLayer5"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer5MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer5MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer5MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 6)) { + registry.fill(HIST("tracks/ITS/posLayer6"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer6MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer6MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer6MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 7)) { + registry.fill(HIST("tracks/ITS/posLayer7"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer7MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer7MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer7MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 5) && hasITSHit(posTrack, 6)) { + registry.fill(HIST("tracks/ITS/posLayer56"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer56MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer56MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer56MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 6) && hasITSHit(posTrack, 7)) { + registry.fill(HIST("tracks/ITS/posLayer67"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer67MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer67MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer67MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 5) && hasITSHit(posTrack, 7)) { + registry.fill(HIST("tracks/ITS/posLayer57"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer57MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer57MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer57MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(posTrack, 5) && hasITSHit(posTrack, 6) && hasITSHit(posTrack, 7)) { + registry.fill(HIST("tracks/ITS/posLayer567"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/posLayer567MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/posLayer567MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/posLayer567MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + registry.fill(HIST("tracks/ITS/posNCl"), vPt, pPt, nPt, posTrack.itsNCls()); + registry.fill(HIST("tracks/ITS/posChi2NCl"), vPt, pPt, nPt, posTrack.itsChi2NCl()); + + if (hasITSHit(negTrack, 1)) { + registry.fill(HIST("tracks/ITS/negLayer1"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer1MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer1MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer1MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 2)) { + registry.fill(HIST("tracks/ITS/negLayer2"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer2MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer2MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer2MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 3)) { + registry.fill(HIST("tracks/ITS/negLayer3"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer3MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer3MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer3MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 4)) { + registry.fill(HIST("tracks/ITS/negLayer4"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer4MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer4MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer4MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 5)) { + registry.fill(HIST("tracks/ITS/negLayer5"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer5MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer5MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer5MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 6)) { + registry.fill(HIST("tracks/ITS/negLayer6"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer6MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer6MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer6MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 7)) { + registry.fill(HIST("tracks/ITS/negLayer7"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer7MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer7MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer7MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 5) && hasITSHit(negTrack, 6)) { + registry.fill(HIST("tracks/ITS/negLayer56"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer56MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer56MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer56MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 6) && hasITSHit(negTrack, 7)) { + registry.fill(HIST("tracks/ITS/negLayer67"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer67MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer67MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer67MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 5) && hasITSHit(negTrack, 7)) { + registry.fill(HIST("tracks/ITS/negLayer57"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer57MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer57MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer57MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + if (hasITSHit(negTrack, 5) && hasITSHit(negTrack, 6) && hasITSHit(negTrack, 7)) { + registry.fill(HIST("tracks/ITS/negLayer567"), vPt, pPt, nPt, dPt); + registry.fill(HIST("tracks/ITS/negLayer567MassK0S"), vPt, pPt, nPt, mK); + registry.fill(HIST("tracks/ITS/negLayer567MassLambda0"), vPt, pPt, nPt, mL); + registry.fill(HIST("tracks/ITS/negLayer567MassAntiLambda0"), vPt, pPt, nPt, mAL); + } + registry.fill(HIST("tracks/ITS/negNCl"), vPt, pPt, nPt, negTrack.itsNCls()); + registry.fill(HIST("tracks/ITS/negChi2NCl"), vPt, pPt, nPt, negTrack.itsChi2NCl()); + + // TPC information + registry.fill(HIST("tracks/TPC/posNClFindable"), vPt, pPt, nPt, posTrack.tpcNClsFindable()); + registry.fill(HIST("tracks/TPC/posNClsFound"), vPt, pPt, nPt, posTrack.tpcNClsFound()); + registry.fill(HIST("tracks/TPC/posChi2NCl"), vPt, pPt, nPt, posTrack.tpcChi2NCl()); + registry.fill(HIST("tracks/TPC/posNClsShared"), vPt, pPt, nPt, posTrack.tpcNClsShared()); + registry.fill(HIST("tracks/TPC/posFractionSharedCls"), vPt, pPt, nPt, posTrack.tpcFractionSharedCls()); + registry.fill(HIST("tracks/TPC/posNClsCrossedRows"), vPt, pPt, nPt, posTrack.tpcNClsCrossedRows()); + registry.fill(HIST("tracks/TPC/posNClsCrossedRowsOverFindableCls"), vPt, pPt, nPt, posTrack.tpcCrossedRowsOverFindableCls()); + + registry.fill(HIST("tracks/TPC/negNClFindable"), vPt, pPt, nPt, negTrack.tpcNClsFindable()); + registry.fill(HIST("tracks/TPC/negNClsFound"), vPt, pPt, nPt, negTrack.tpcNClsFound()); + registry.fill(HIST("tracks/TPC/negChi2NCl"), vPt, pPt, nPt, negTrack.tpcChi2NCl()); + registry.fill(HIST("tracks/TPC/negNClsShared"), vPt, pPt, nPt, negTrack.tpcNClsShared()); + registry.fill(HIST("tracks/TPC/negFractionSharedCls"), vPt, pPt, nPt, negTrack.tpcFractionSharedCls()); + registry.fill(HIST("tracks/TPC/negNClsCrossedRows"), vPt, pPt, nPt, negTrack.tpcNClsCrossedRows()); + 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); + + void processFlags(soa::Join::iterator const& v0) + { + int isK0S = static_cast(v0.isK0SCandidate()); + int isLambda = static_cast((v0.isLambdaCandidate())); + 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); + } + 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)) { + return; + } + registry.fill(HIST("inclusive/hEvents"), 1.5); + double weight = jcoll.mcCollision().weight(); + + for (const auto& v0 : v0s) { + if (!v0.has_mcParticle()) { + continue; + } + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + + // K0S + if (TMath::Abs(pdg) == 310) { + 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) { + 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) { + registry.fill(HIST("inclusive/AntiLambdaPtEtaMass"), v0.pt(), v0.eta(), v0.mAntiLambda(), weight); + registry.fill(HIST("inclusive/InvMassAntiLambdaTrue"), v0.pt(), v0.v0radius(), v0.mAntiLambda(), weight); + } + } + } + PROCESS_SWITCH(V0QA, processMcD, "Reconstructed true V0s", false); + + void processMcP(aod::JetMcCollision const& mccoll, aod::CandidatesV0MCP const& pv0s, soa::SmallGroups const& collisions) + { + registry.fill(HIST("inclusive/hMcEvents"), 0.5); + bool isReconstructed = false; + + for (auto collision : collisions) { + if (!isCollisionReconstructed(collision, eventSelection)) { + continue; + } + if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) { + continue; + } + isReconstructed = true; + break; + } + if (!isReconstructed) { + return; + } + + registry.fill(HIST("inclusive/hMcEvents"), 1.5); + double weight = mccoll.weight(); + + for (auto& pv0 : pv0s) { + if (!pv0.has_daughters()) + continue; + if (!pv0.isPhysicalPrimary()) + continue; + if (TMath::Abs(pv0.y() > yPartMax)) + continue; + + // Can calculate this from aod::CandidatesV0MCD (contains decay vertex) + double R_Decay = 1.0; + + if (pv0.pdgCode() == 310) { + registry.fill(HIST("inclusive/GeneratedK0S"), pv0.pt(), pv0.eta(), R_Decay, weight); + } + if (pv0.pdgCode() == 3122) { + registry.fill(HIST("inclusive/GeneratedLambda"), pv0.pt(), pv0.eta(), R_Decay, weight); + } + if (pv0.pdgCode() == -3122) { + registry.fill(HIST("inclusive/GeneratedAntiLambda"), pv0.pt(), pv0.eta(), R_Decay, weight); + } + } + } + PROCESS_SWITCH(V0QA, processMcP, "Particle level V0s", false); + + 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)) { + 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()) { + continue; + } + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + + // K0S + if (TMath::Abs(pdg) == 310) { + 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) { + 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) { + registry.fill(HIST("jets/JetPtEtaAntiLambdaPt"), mcdjet.pt(), mcdjet.eta(), v0.pt(), weight); + registry.fill(HIST("jets/InvMassJetAntiLambdaTrue"), mcdjet.pt(), v0.pt(), v0.mAntiLambda(), weight); + } + } + } + } + PROCESS_SWITCH(V0QA, processMcDJets, "Reconstructed true V0s in jets", false); + + 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)) { + return; + } + registry.fill(HIST("jets/hMatchedJetEvents"), 1.5); + double weight = jcoll.mcCollision().weight(); + + for (const auto& mcdjet : mcdjets) { + // if (!jetfindingutilities::isInEtaAcceptance(mcdjet, -99., -99., v0EtaMin, v0EtaMax)) + for (const auto& mcpjet : mcdjet.template matchedJetGeo_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)) + continue; + int pdg = pv0.pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + + // K0S + if (TMath::Abs(pdg) == 310) { + 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) { + 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) { + 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); + } + } + } + } + } + } + PROCESS_SWITCH(V0QA, processMcDMatchedJets, "Reconstructed true V0s in jets", false); + + void processMcPJets(aod::JetMcCollision const& mccoll, soa::SmallGroups const& collisions, MCPV0JetsWithConstituents const& jets, aod::CandidatesV0MCP const&) + { + registry.fill(HIST("jets/hMcJetEvents"), 0.5); + bool isReconstructed = false; + + for (auto collision : collisions) { + if (!isCollisionReconstructed(collision, eventSelection)) { + continue; + } + if (collision.mcCollision().globalIndex() != mccoll.globalIndex()) { + continue; + } + isReconstructed = true; + break; + } + 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& 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) { + registry.fill(HIST("jets/GeneratedJetK0S"), jet.pt(), jet.eta(), pv0.pt(), weight); + } + if (pv0.pdgCode() == 3122) { + registry.fill(HIST("jets/GeneratedJetLambda"), jet.pt(), jet.eta(), pv0.pt(), weight); + } + if (pv0.pdgCode() == -3122) { + registry.fill(HIST("jets/GeneratedJetAntiLambda"), jet.pt(), jet.eta(), pv0.pt(), weight); + } + } + } + } + PROCESS_SWITCH(V0QA, processMcPJets, "Particle level V0s in jets", false); + + 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()) { + return; + } + auto mcColl = jcoll.template mcCollision_as>(); + double weight = mcColl.weight(); + + for (const auto& v0 : v0s) { + if (!v0.has_mcParticle()) { + continue; + } + + auto pv0 = v0.mcParticle(); + bool correctCollision = (mcColl.mcCollisionId() == v0.mcParticle().mcCollisionId()); + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + + registry.fill(HIST("collisions/V0PtEta"), pv0.pt(), pv0.eta(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/V0PtEtaWrongColl"), pv0.pt(), pv0.eta(), weight); + } + if (TMath::Abs(pdg) == 310) { + 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) { + 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) { + 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()) { + continue; + } + auto mother = v0.mcMotherParticle(); + pdg = mother.pdgCode(); + correctCollision = (mcColl.mcCollisionId() == mother.mcCollisionId()); + + if (pdg == 3312) { // Xi- + 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+ + 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); + } + } + } + } + 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&) + { + if (!jcoll.has_mcCollision()) { + 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()) { + continue; + } + + auto pv0 = v0.mcParticle(); + bool correctCollision = (mcColl.mcCollisionId() == pv0.mcCollisionId()); + int pdg = pv0.pdgCode(); + + // Check V0 decay kinematics + if (!isV0Reconstructed(jcoll, v0, pdg)) + continue; + + registry.fill(HIST("collisions/JetPtEtaV0Pt"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaV0PtWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + } + if (TMath::Abs(pdg) == 310) { + registry.fill(HIST("collisions/JetPtEtaK0SPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaK0SPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + } + } + if (pdg == 3122) { + registry.fill(HIST("collisions/JetPtEtaLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + } + } + if (pdg == -3122) { + registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMass"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaAntiLambdaPtMassWrongColl"), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + } + } + + 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 (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaXiMinusPtLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + } + } + if (pdg == -3312) { // Xi+ + registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPt"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + } + } + } // for v0s + } // for mcdjets + } + 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) + { + 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>()) { + if (!v0.has_mcParticle()) + continue; + + for (const auto& pv0 : mcpjet.template candidates_as()) { + if (!V0sAreMatched(v0, pv0, jTracks)) + continue; + int pdg = pv0.pdgCode(); + bool correctCollision = (mcColl.mcCollisionId() == pv0.mcCollisionId()); + + // Check V0 decay kinematics + if (!isV0Reconstructed(jcoll, v0, pdg)) + continue; + + registry.fill(HIST("collisions/JetsPtEtaV0Pt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaV0PtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), weight); + } + if (TMath::Abs(pdg) == 310) { + registry.fill(HIST("collisions/JetsPtEtaK0SPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaK0SPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mK0Short(), weight); + } + } + if (pdg == 3122) { + registry.fill(HIST("collisions/JetsPtEtaLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mLambda(), weight); + } + } + if (pdg == -3122) { + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMass"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaAntiLambdaPtMassWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), pv0.pt(), v0.mAntiLambda(), weight); + } + } + + 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 (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaXiMinusPtLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + } + } + if (pdg == -3312) { // Xi+ + registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + if (!correctCollision) { + registry.fill(HIST("collisions/JetsPtEtaXiPlusPtAntiLambdaPtWrongColl"), mcpjet.pt(), mcdjet.pt(), mcdjet.eta(), mother.pt(), pv0.pt(), weight); + } + } + } // for pv0 + } // for v0 + } // for mcpjet + } // for mcdjet + } + PROCESS_SWITCH(V0QA, processCollisionAssociationMatchedJets, "V0 in matched jets collision association", false); + + 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()) { + return; + } + auto mcColl = jcoll.template mcCollision_as>(); + double weight = mcColl.weight(); + + for (const auto& v0 : v0s) { + if (!v0.has_mcParticle()) { + continue; + } + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + // Feed-down from Xi + if (!v0.has_mcMotherParticle()) + continue; + + auto pv0 = v0.mcParticle(); + auto mother = v0.mcMotherParticle(); + pdg = mother.pdgCode(); + + if (pdg == 3312) { // Xi- + registry.fill(HIST("feeddown/XiMinusPtYLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); + } + if (pdg == -3312) { // Xi+ + registry.fill(HIST("feeddown/XiPlusPtYAntiLambdaPt"), mother.pt(), mother.y(), pv0.pt(), weight); + } + } + } + PROCESS_SWITCH(V0QA, processFeeddown, "Inclusive feeddown", false); + + 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()) { + 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()) { + continue; + } + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + // Feed-down from Xi + if (!v0.has_mcMotherParticle()) + continue; + + auto pv0 = v0.mcParticle(); + auto mother = v0.mcMotherParticle(); + pdg = mother.pdgCode(); + + if (pdg == 3312) { // Xi- + registry.fill(HIST("feeddown/JetPtXiMinusPtLambdaPt"), mcdjet.pt(), mother.pt(), pv0.pt(), weight); + } + if (pdg == -3312) { // Xi+ + registry.fill(HIST("feeddown/JetPtXiPlusPtAntiLambdaPt"), mcdjet.pt(), mother.pt(), pv0.pt(), weight); + } + } + } + } + PROCESS_SWITCH(V0QA, processFeeddownJets, "Jets feeddown", false); + + 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()) { + 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()) { + if (!v0.has_mcParticle()) + continue; + if (!v0.has_mcMotherParticle()) + continue; + + for (const auto& pv0 : mcpjet.template candidates_as()) { + if (!V0sAreMatched(v0, pv0, jTracks)) + continue; + + int pdg = v0.mcParticle().pdgCode(); + + // Check V0 decay kinematics + if (v0.isRejectedCandidate()) + continue; + + auto mother = v0.mcMotherParticle(); + pdg = mother.pdgCode(); + if (pdg == 3312) { // Xi- + registry.fill(HIST("feeddown/JetsPtXiMinusPtLambdaPt"), mcpjet.pt(), mcdjet.pt(), mother.pt(), pv0.pt(), weight); + } + if (pdg == -3312) { // Xi+ + registry.fill(HIST("feeddown/JetsPtXiPlusPtAntiLambdaPt"), mcpjet.pt(), mcdjet.pt(), mother.pt(), pv0.pt(), weight); + } + } + } + } + } + } + PROCESS_SWITCH(V0QA, processFeeddownMatchedJets, "Jets feeddown", false); + + using DaughterJTracks = soa::Join; + using DaughterTracks = soa::Join; + void processV0TrackQA(aod::JetCollision const& /*jcoll*/, soa::Join const& v0s, DaughterJTracks const&, DaughterTracks const&) + { + // if (!jetderiveddatautilities::selectCollision(jcoll, eventSelection)) { + // return; + // } + for (const auto& v0 : v0s) { + if (v0.isRejectedCandidate()) { + continue; + } + fillTrackQa(v0); + } + } + PROCESS_SWITCH(V0QA, processV0TrackQA, "V0 track QA", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"jet-v0qa"})}; +} diff --git a/PWGLF/DataModel/LFClusterStudiesTable.h b/PWGLF/DataModel/LFClusterStudiesTable.h new file mode 100644 index 00000000000..88ca35a85d3 --- /dev/null +++ b/PWGLF/DataModel/LFClusterStudiesTable.h @@ -0,0 +1,122 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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: Giorgio Alberto Lucia + +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#ifndef PWGLF_DATAMODEL_LFCLUSTERSTUDIESTABLE_H_ +#define PWGLF_DATAMODEL_LFCLUSTERSTUDIESTABLE_H_ + +namespace o2::aod +{ + +namespace LFClusterStudiesTables +{ +DECLARE_SOA_COLUMN(PMother, pMother, float); +DECLARE_SOA_COLUMN(PtMother, ptMother, float); +DECLARE_SOA_COLUMN(EtaMother, etaMother, float); +DECLARE_SOA_COLUMN(PhiMother, phiMother, float); +DECLARE_SOA_COLUMN(MassMother, massMother, float); +DECLARE_SOA_COLUMN(PdgCodeMother, pdgCodeMother, int); +DECLARE_SOA_COLUMN(RadiusMother, radiusMother, float); +DECLARE_SOA_COLUMN(DcaMotherPV, dcaMotherPV, float); +DECLARE_SOA_COLUMN(CosPAMother, cosPAMother, float); +DECLARE_SOA_COLUMN(AlphaAPMother, alphaAPMother, float); +DECLARE_SOA_COLUMN(QtAPMother, qtAPMother, float); +DECLARE_SOA_COLUMN(McPdgCodeMother, mcPdgCodeMother, int); + +/** + * PartID: + * 0: e + * 1: #pi + * 2: K + * 3: p + * 4: d + * 5: ^{3}He + */ +DECLARE_SOA_COLUMN(PartID, partID, uint8_t); +DECLARE_SOA_COLUMN(PartIDMc, partIDMc, int); +DECLARE_SOA_COLUMN(IsPositive, isPositive, bool); + +DECLARE_SOA_COLUMN(P, p, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(PTPC, pTPC, float); +DECLARE_SOA_COLUMN(PIDinTrk, pidInTrk, uint32_t); +DECLARE_SOA_COLUMN(PDGCode, pdgCode, int); +DECLARE_SOA_COLUMN(DcaToPV, dcaToPV, float); +DECLARE_SOA_COLUMN(ItsClusterSize, itsClusterSize, uint32_t); +DECLARE_SOA_COLUMN(TpcSignal, tpcSignal, float); +DECLARE_SOA_COLUMN(TpcNcls, tpcNcls, uint8_t); +DECLARE_SOA_COLUMN(TpcNSigma, tpcNSigma, float); +DECLARE_SOA_COLUMN(TofNSigma, tofNSigma, float); +DECLARE_SOA_COLUMN(TofMass, tofMass, float); +DECLARE_SOA_COLUMN(Chi2its, chi2its, float); +DECLARE_SOA_COLUMN(Chi2tpc, chi2tpc, float); +DECLARE_SOA_COLUMN(HasTPC, hasTPC, bool); +DECLARE_SOA_COLUMN(McPdgCode, mcPdgCode, int); + +} // namespace LFClusterStudiesTables + +DECLARE_SOA_TABLE( + ClStTable, "AOD", "CLSTTABLE", + LFClusterStudiesTables::P, + LFClusterStudiesTables::Eta, + LFClusterStudiesTables::Phi, + LFClusterStudiesTables::ItsClusterSize, + LFClusterStudiesTables::PartID); + +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, + LFClusterStudiesTables::TofNSigma, + LFClusterStudiesTables::TofMass, + LFClusterStudiesTables::CosPAMother, + LFClusterStudiesTables::MassMother); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFCLUSTERSTUDIESTABLE_H_ diff --git a/PWGLF/DataModel/LFDoubleCascTables.h b/PWGLF/DataModel/LFDoubleCascTables.h new file mode 100644 index 00000000000..49e3b6604de --- /dev/null +++ b/PWGLF/DataModel/LFDoubleCascTables.h @@ -0,0 +1,73 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#ifndef PWGLF_DATAMODEL_LFDOUBLECASCTABLES_H_ +#define PWGLF_DATAMODEL_LFDOUBLECASCTABLES_H_ + +namespace o2::aod +{ + +namespace DoubleCascTables +{ +DECLARE_SOA_COLUMN(PtCasc1, ptCasc1, float); // signed pt of the cascade +DECLARE_SOA_COLUMN(EtaCasc1, etaCasc1, float); +DECLARE_SOA_COLUMN(PhiCasc1, phiCasc1, float); +DECLARE_SOA_COLUMN(CascDecLength1, cascDecLength1, float); +DECLARE_SOA_COLUMN(OmegaMassCasc1, omegaMassCasc1, float); +DECLARE_SOA_COLUMN(XiMassCasc1, xiMassCasc1, float); +DECLARE_SOA_COLUMN(CosPACasc1, cosPACasc1, float); +DECLARE_SOA_COLUMN(DcaBachPVCasc1, dcaBachPVCasc1, float); +DECLARE_SOA_COLUMN(DcaV0BachCasc1, dcaV0BachCasc1, float); +DECLARE_SOA_COLUMN(NSigmaKBach1, nSigmaKBach1, float); + +DECLARE_SOA_COLUMN(PtCasc2, ptCasc2, float); +DECLARE_SOA_COLUMN(EtaCasc2, etaCasc2, float); +DECLARE_SOA_COLUMN(PhiCasc2, phiCasc2, float); +DECLARE_SOA_COLUMN(CascDecLength2, cascDecLength2, float); +DECLARE_SOA_COLUMN(OmegaMassCasc2, omegaMassCasc2, float); +DECLARE_SOA_COLUMN(XiMassCasc2, xiMassCasc2, float); +DECLARE_SOA_COLUMN(CosPACasc2, cosPACasc2, float); +DECLARE_SOA_COLUMN(DcaBachPVCasc2, dcaBachPVCasc2, float); +DECLARE_SOA_COLUMN(DcaV0BachCasc2, dcaV0BachCasc2, float); +DECLARE_SOA_COLUMN(NSigmaKBach2, nSigmaKBach2, float); + +DECLARE_SOA_COLUMN(DoubleOmegaMass, doubleOmegaMass, float); +} // namespace DoubleCascTables + +DECLARE_SOA_TABLE(DoubleCascTable, "AOD", "DOUBLECASCTABLE", + DoubleCascTables::PtCasc1, + DoubleCascTables::EtaCasc1, + DoubleCascTables::PhiCasc1, + DoubleCascTables::CascDecLength1, + DoubleCascTables::OmegaMassCasc1, + DoubleCascTables::XiMassCasc1, + DoubleCascTables::CosPACasc1, + DoubleCascTables::DcaBachPVCasc1, + DoubleCascTables::DcaV0BachCasc1, + DoubleCascTables::NSigmaKBach1, + DoubleCascTables::PtCasc2, + DoubleCascTables::EtaCasc2, + DoubleCascTables::PhiCasc2, + DoubleCascTables::CascDecLength2, + DoubleCascTables::OmegaMassCasc2, + DoubleCascTables::XiMassCasc2, + DoubleCascTables::CosPACasc2, + DoubleCascTables::DcaBachPVCasc2, + DoubleCascTables::DcaV0BachCasc2, + DoubleCascTables::NSigmaKBach2, + DoubleCascTables::DoubleOmegaMass); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFDOUBLECASCTABLES_H_ diff --git a/PWGLF/DataModel/LFEbyeTables.h b/PWGLF/DataModel/LFEbyeTables.h index 00f6c732d44..d7ff437ece4 100644 --- a/PWGLF/DataModel/LFEbyeTables.h +++ b/PWGLF/DataModel/LFEbyeTables.h @@ -22,6 +22,10 @@ namespace LFEbyeCollTable { 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); } // namespace LFEbyeCollTable DECLARE_SOA_TABLE(CollEbyeTables, "AOD", "COLLEBYETABLE", @@ -30,9 +34,18 @@ DECLARE_SOA_TABLE(CollEbyeTables, "AOD", "COLLEBYETABLE", LFEbyeCollTable::Zvtx); using CollEbyeTable = CollEbyeTables::iterator; +DECLARE_SOA_TABLE(MiniCollTables, "AOD", "MINICOLLTABLE", + o2::soa::Index<>, + LFEbyeCollTable::ZvtxMask, + LFEbyeCollTable::TriggerMask, + LFEbyeCollTable::Ntracklets, + LFEbyeCollTable::V0Multiplicity); +using MiniCollTable = MiniCollTables::iterator; + namespace LFEbyeTable { DECLARE_SOA_INDEX_COLUMN(CollEbyeTable, collEbyeTable); +DECLARE_SOA_INDEX_COLUMN(MiniCollTable, miniCollTable); DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Mass, mass, float); @@ -53,6 +66,10 @@ DECLARE_SOA_COLUMN(GenPt, genPt, float); DECLARE_SOA_COLUMN(GenEta, genEta, float); DECLARE_SOA_COLUMN(PdgCode, pdgCode, int); DECLARE_SOA_COLUMN(IsReco, isReco, bool); +DECLARE_SOA_COLUMN(EtaMask, etaMask, int8_t); +DECLARE_SOA_COLUMN(SelMask, selMask, int); +DECLARE_SOA_COLUMN(OuterPID, outerPID, float); +DECLARE_SOA_COLUMN(GenEtaMask, genEtaMask, int8_t); } // namespace LFEbyeTable DECLARE_SOA_TABLE(NucleiEbyeTables, "AOD", "NUCLEBYETABLE", @@ -120,6 +137,27 @@ DECLARE_SOA_TABLE(McLambdaEbyeTables, "AOD", "MCLAMBEBYETABLE", LFEbyeTable::PdgCode, LFEbyeTable::IsReco); using McLambdaEbyeTable = McLambdaEbyeTables::iterator; + +DECLARE_SOA_TABLE(MiniTrkTables, "AOD", "MINITRKTABLE", + o2::soa::Index<>, + LFEbyeTable::MiniCollTableId, + LFEbyeTable::Pt, + LFEbyeTable::EtaMask, + LFEbyeTable::SelMask, + LFEbyeTable::OuterPID); +using MiniTrkTable = MiniTrkTables::iterator; + +DECLARE_SOA_TABLE(McMiniTrkTables, "AOD", "MCMINITRKTABLE", + o2::soa::Index<>, + LFEbyeTable::MiniCollTableId, + LFEbyeTable::Pt, + LFEbyeTable::EtaMask, + LFEbyeTable::SelMask, + LFEbyeTable::OuterPID, + LFEbyeTable::GenPt, + LFEbyeTable::GenEtaMask, + LFEbyeTable::IsReco); +using McMiniTrkTable = McMiniTrkTables::iterator; } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFEBYETABLES_H_ diff --git a/PWGLF/DataModel/LFHStrangeCorrelationTables.h b/PWGLF/DataModel/LFHStrangeCorrelationTables.h index 53cf20bc7eb..1b31239f406 100644 --- a/PWGLF/DataModel/LFHStrangeCorrelationTables.h +++ b/PWGLF/DataModel/LFHStrangeCorrelationTables.h @@ -22,10 +22,13 @@ #ifndef PWGLF_DATAMODEL_LFHSTRANGECORRELATIONTABLES_H_ #define PWGLF_DATAMODEL_LFHSTRANGECORRELATIONTABLES_H_ +#include #include "Framework/AnalysisDataModel.h" #include "Common/Core/RecoDecay.h" #include "CommonConstants/PhysicsConstants.h" -#include + +// Simple checker +#define bitcheck(var, nbit) ((var) & (1 << (nbit))) namespace o2::aod { @@ -34,9 +37,11 @@ namespace o2::aod namespace triggerTracks { 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, "_Trigger"); //! +DECLARE_SOA_COLUMN(MCOriginalPt, mcOriginalPt, float); // true generated pt } // namespace triggerTracks -DECLARE_SOA_TABLE(TriggerTracks, "AOD", "TRIGGERTRACKS", o2::soa::Index<>, triggerTracks::CollisionId, triggerTracks::TrackId); +DECLARE_SOA_TABLE(TriggerTracks, "AOD", "TRIGGERTRACKS", o2::soa::Index<>, triggerTracks::CollisionId, triggerTracks::MCPhysicalPrimary, triggerTracks::TrackId, triggerTracks::MCOriginalPt); /// _________________________________________ /// Table for storing assoc track indices namespace assocPions @@ -51,44 +56,38 @@ namespace assocV0s { DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! DECLARE_SOA_INDEX_COLUMN(V0Core, v0Core); //! -DECLARE_SOA_COLUMN(CompatibleK0Short, compatibleK0Short, bool); // compatible with K0Short -DECLARE_SOA_COLUMN(CompatibleLambda, compatibleLambda, bool); // compatible with Lambda -DECLARE_SOA_COLUMN(CompatibleAntiLambda, compatibleAntiLambda, bool); // compatible with AntiLambda + +// dEdx compatibility is done via encoded integer: 0: passes loose; 1: passes normal, 2: passes tight; definition of loose/normal/tight is in hStrangeCorrelationFilter +DECLARE_SOA_COLUMN(CompatibleK0Short, compatibleK0Short, int); // compatible with K0Short dEdx, encoded syst checks +DECLARE_SOA_COLUMN(CompatibleLambda, compatibleLambda, int); // compatible with Lambda dEdx, encoded syst checks +DECLARE_SOA_COLUMN(CompatibleAntiLambda, compatibleAntiLambda, int); // compatible with AntiLambda dEdx, encoded syst checks + DECLARE_SOA_COLUMN(MCTrueK0Short, mcTrueK0Short, bool); // true K0Short in MC DECLARE_SOA_COLUMN(MCTrueLambda, mcTrueLambda, bool); // true Lambda in MC DECLARE_SOA_COLUMN(MCTrueAntiLambda, mcTrueAntiLambda, bool); // true AntiLambda in MC -DECLARE_SOA_COLUMN(MassRegionK0Short, massRegionK0Short, int); // -DECLARE_SOA_COLUMN(MassRegionLambda, massRegionLambda, int); // -DECLARE_SOA_COLUMN(MassRegionAntiLambda, massRegionAntiLambda, int); // +DECLARE_SOA_COLUMN(MCPhysicalPrimary, mcPhysicalPrimary, bool); // true physical primary flag +DECLARE_SOA_COLUMN(NSigmaMassK0Short, nSigmaMassK0Short, float); // +DECLARE_SOA_COLUMN(NSigmaMassLambda, nSigmaMassLambda, float); // +DECLARE_SOA_COLUMN(NSigmaMassAntiLambda, nSigmaMassAntiLambda, float); // DECLARE_SOA_DYNAMIC_COLUMN(Compatible, compatible, //! check compatibility with a hypothesis of a certain number (0 - K0, 1 - L, 2 - Lbar) - [](bool cK0Short, bool cLambda, bool cAntiLambda, int value) -> bool { - if (value == 0 && cK0Short) - return true; - if (value == 1 && cLambda) - return true; - if (value == 2 && cAntiLambda) - return true; - return false; - }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassRegionCheck, invMassRegionCheck, - [](int rK0Short, int rLambda, int rAntiLambda, int value, int region) -> bool { - if (value == 0 && rK0Short == region) + [](int cK0Short, int cLambda, int cAntiLambda, int value, int compatibilityLevel) -> bool { + if (value == 0 && bitcheck(cK0Short, compatibilityLevel)) return true; - if (value == 1 && rLambda == region) + if (value == 1 && bitcheck(cLambda, compatibilityLevel)) return true; - if (value == 2 && rAntiLambda == region) + if (value == 2 && bitcheck(cAntiLambda, compatibilityLevel)) return true; return false; }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassRegion, invMassRegion, - [](int rK0Short, int rLambda, int rAntiLambda, int value) -> int { +DECLARE_SOA_DYNAMIC_COLUMN(InvMassNSigma, invMassNSigma, + [](float rK0Short, float rLambda, float rAntiLambda, int value) -> float { if (value == 0) return rK0Short; if (value == 1) return rLambda; if (value == 2) return rAntiLambda; - return -1; + return 1000.0f; }); DECLARE_SOA_DYNAMIC_COLUMN(MCTrue, mcTrue, [](int mcTrueK0Short, int mcTrueLambda, int mcTrueAntiLambda, int value) -> bool { @@ -109,12 +108,12 @@ DECLARE_SOA_TABLE(AssocV0s, "AOD", "ASSOCV0S", o2::soa::Index<>, assocV0s::MCTrueK0Short, assocV0s::MCTrueLambda, assocV0s::MCTrueAntiLambda, - assocV0s::MassRegionK0Short, - assocV0s::MassRegionLambda, - assocV0s::MassRegionAntiLambda, + assocV0s::MCPhysicalPrimary, + assocV0s::NSigmaMassK0Short, + assocV0s::NSigmaMassLambda, + assocV0s::NSigmaMassAntiLambda, + assocV0s::InvMassNSigma, assocV0s::Compatible, - assocV0s::InvMassRegionCheck, - assocV0s::InvMassRegion, assocV0s::MCTrue); /// _________________________________________ /// Table for storing associated casc indices @@ -122,47 +121,39 @@ namespace assocCascades { DECLARE_SOA_INDEX_COLUMN(Collision, collision); //! DECLARE_SOA_INDEX_COLUMN(CascData, cascData); //! -DECLARE_SOA_COLUMN(CompatibleXiMinus, compatibleXiMinus, bool); // compatible with XiMinus -DECLARE_SOA_COLUMN(CompatibleXiPlus, compatibleXiPlus, bool); // compatible with XiPlus -DECLARE_SOA_COLUMN(CompatibleOmegaMinus, compatibleOmegaMinus, bool); // compatible with OmegaMinus -DECLARE_SOA_COLUMN(CompatibleOmegaPlus, compatibleOmegaPlus, bool); // compatible with OmegaPlus + +// dEdx compatibility is done via encoded integer: 0: passes loose; 1: passes normal, 2: passes tight; definition of loose/normal/tight is in hStrangeCorrelationFilter +DECLARE_SOA_COLUMN(CompatibleXiMinus, compatibleXiMinus, int); // compatible with XiMinus +DECLARE_SOA_COLUMN(CompatibleXiPlus, compatibleXiPlus, int); // compatible with XiPlus +DECLARE_SOA_COLUMN(CompatibleOmegaMinus, compatibleOmegaMinus, int); // compatible with OmegaMinus +DECLARE_SOA_COLUMN(CompatibleOmegaPlus, compatibleOmegaPlus, int); // compatible with OmegaPlus + DECLARE_SOA_COLUMN(MCTrueXiMinus, mcTrueXiMinus, bool); // true XiMinus in mc DECLARE_SOA_COLUMN(MCTrueXiPlus, mcTrueXiPlus, bool); // true XiPlus in mc DECLARE_SOA_COLUMN(MCTrueOmegaMinus, mcTrueOmegaMinus, bool); // true OmegaMinus in mc DECLARE_SOA_COLUMN(MCTrueOmegaPlus, mcTrueOmegaPlus, bool); // true OmegaPlus in mc -DECLARE_SOA_COLUMN(MassRegionXi, massRegionXi, int); // -DECLARE_SOA_COLUMN(MassRegionOmega, massRegionOmega, int); // +DECLARE_SOA_COLUMN(MCPhysicalPrimary, mcPhysicalPrimary, bool); // physical primary in MC +DECLARE_SOA_COLUMN(NSigmaMassXi, nSigmaMassXi, float); // +DECLARE_SOA_COLUMN(NSigmaMassOmega, nSigmaMassOmega, float); // DECLARE_SOA_DYNAMIC_COLUMN(Compatible, compatible, //! check compatibility with a hypothesis of a certain number (0 - K0, 1 - L, 2 - Lbar) - [](bool cXiMinus, bool cXiPlus, bool cOmegaMinus, bool cOmegaPlus, int value) -> bool { - if (value == 0 && cXiMinus) - return true; - if (value == 1 && cXiPlus) - return true; - if (value == 2 && cOmegaMinus) - return true; - if (value == 3 && cOmegaPlus) - return true; - return false; - }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassRegionCheck, invMassRegionCheck, - [](int rXi, int rOmega, int value, int region) -> bool { - if (value == 0 && rXi == region) + [](int cXiMinus, int cXiPlus, int cOmegaMinus, int cOmegaPlus, int value, int compatibilityLevel) -> bool { + if (value == 0 && bitcheck(cXiMinus, compatibilityLevel)) return true; - if (value == 1 && rXi == region) + if (value == 1 && bitcheck(cXiPlus, compatibilityLevel)) return true; - if (value == 2 && rOmega == region) + if (value == 2 && bitcheck(cOmegaMinus, compatibilityLevel)) return true; - if (value == 3 && rOmega == region) + if (value == 3 && bitcheck(cOmegaPlus, compatibilityLevel)) return true; return false; }); -DECLARE_SOA_DYNAMIC_COLUMN(InvMassRegion, invMassRegion, - [](int rXi, int rOmega, int value) -> int { +DECLARE_SOA_DYNAMIC_COLUMN(InvMassNSigma, invMassNSigma, + [](float rXi, float rOmega, int value) -> float { if (value == 0 || value == 1) return rXi; if (value == 2 || value == 3) return rOmega; - return -1; + return 1000.0f; }); DECLARE_SOA_DYNAMIC_COLUMN(MCTrue, mcTrue, [](int mcTrueXiMinus, int mcTrueXiPlus, int mcTrueOmegaMinus, int mcTrueOmegaPlus, int value) -> bool { @@ -186,11 +177,11 @@ DECLARE_SOA_TABLE(AssocCascades, "AOD", "ASSOCCASCADES", o2::soa::Index<>, assoc assocCascades::MCTrueXiPlus, assocCascades::MCTrueOmegaMinus, assocCascades::MCTrueOmegaPlus, - assocCascades::MassRegionXi, - assocCascades::MassRegionOmega, + assocCascades::MCPhysicalPrimary, + assocCascades::NSigmaMassXi, + assocCascades::NSigmaMassOmega, + assocCascades::InvMassNSigma, assocCascades::Compatible, - assocCascades::InvMassRegionCheck, - assocCascades::InvMassRegion, assocCascades::MCTrue); } // namespace o2::aod diff --git a/PWGLF/DataModel/LFHypernucleiTables.h b/PWGLF/DataModel/LFHypernucleiTables.h index ba81c59b502..e86ae9e42c7 100644 --- a/PWGLF/DataModel/LFHypernucleiTables.h +++ b/PWGLF/DataModel/LFHypernucleiTables.h @@ -34,47 +34,50 @@ DECLARE_SOA_COLUMN(MultFT0C, multFT0C, float); // Multiplicity with DECLARE_SOA_COLUMN(PsiTPC, psiTPC, float); // Psi with TPC estimator DECLARE_SOA_COLUMN(MultTPC, multTPC, float); // Multiplicity with TPC estimator -DECLARE_SOA_COLUMN(IsMatter, isMatter, bool); // bool: true for matter -DECLARE_SOA_COLUMN(PtHe3, ptHe3, float); // Pt of the He daughter -DECLARE_SOA_COLUMN(PhiHe3, phiHe3, float); // Phi of the He daughter -DECLARE_SOA_COLUMN(EtaHe3, etaHe3, float); // Eta of the He daughter -DECLARE_SOA_COLUMN(PtPi, ptPi, float); // Pt of the Pi daughter -DECLARE_SOA_COLUMN(PhiPi, phiPi, float); // Phi of the Pi daughter -DECLARE_SOA_COLUMN(EtaPi, etaPi, float); // Eta of the Pi daughter -DECLARE_SOA_COLUMN(XPrimVtx, xPrimVtx, float); // Decay vertex of the candidate (x direction) -DECLARE_SOA_COLUMN(YPrimVtx, yPrimVtx, float); // Decay vertex of the candidate (y direction) -DECLARE_SOA_COLUMN(ZPrimVtx, zPrimVtx, float); // Decay vertex of the candidate (z direction) -DECLARE_SOA_COLUMN(XDecVtx, xDecVtx, float); // Decay vertex of the candidate (x direction) -DECLARE_SOA_COLUMN(YDecVtx, yDecVtx, float); // Decay vertex of the candidate (y direction) -DECLARE_SOA_COLUMN(ZDecVtx, zDecVtx, float); // Decay vertex of the candidate (z direction) -DECLARE_SOA_COLUMN(MassH3L, massH3L, float); // Squared mass w/ hypertriton mass hypo -DECLARE_SOA_COLUMN(MassH4L, massH4L, float); // Squared mass w/ H4L mass hypo -DECLARE_SOA_COLUMN(DcaV0Daug, dcaV0Daug, float); // DCA between daughters -DECLARE_SOA_COLUMN(CosPA, cosPA, double); // Cosine of the pointing angle -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(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(Tracked, tracked, bool); // bool: true for tracked candidates -DECLARE_SOA_COLUMN(Flags, flags, uint8_t); // Flags for PID in tracking (bits [0, 3] for negative daughter, [4,7] for positive daughter) -DECLARE_SOA_COLUMN(TPCmomHe, tpcMomHe, float); // TPC momentum of the He daughter -DECLARE_SOA_COLUMN(TPCmomPi, tpcMomPi, float); // TPC momentum of the Pi daughter -DECLARE_SOA_COLUMN(ITSclusterSizesHe, itsClusterSizesHe, uint32_t); // ITS cluster size of the He daughter -DECLARE_SOA_COLUMN(ITSclusterSizesPi, itsClusterSizesPi, uint32_t); // ITS cluster size of the Pi daughter -DECLARE_SOA_COLUMN(DcaHe, dcaHe, float); // DCA between He daughter and V0 -DECLARE_SOA_COLUMN(DcaPi, dcaPi, float); // DCA between pi daughter and V0 -DECLARE_SOA_COLUMN(GenPt, genPt, float); // Pt 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(GenPtHe3, genPtHe3, float); // Pt of the He daughter (to be used for the recalibration) -DECLARE_SOA_COLUMN(GenXDecVtx, genXDecVtx, float); // Decay vertex of the candidate (x direction) -DECLARE_SOA_COLUMN(GenYDecVtx, genYDecVtx, float); // Decay vertex of the candidate (y direction) -DECLARE_SOA_COLUMN(GenZDecVtx, genZDecVtx, float); // Decay vertex of the candidate (z direction) -DECLARE_SOA_COLUMN(IsReco, isReco, bool); // bool: true for reco -DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); // bool: true for signal -DECLARE_SOA_COLUMN(IsRecoMCCollision, isRecoMCCollision, bool); // bool: true for reco MC collision -DECLARE_SOA_COLUMN(IsSurvEvSel, isSurvEvSel, bool); // bool: true for survived event selection +DECLARE_SOA_COLUMN(IsMatter, isMatter, bool); // bool: true for matter +DECLARE_SOA_COLUMN(PtHe3, ptHe3, float); // Pt of the He daughter +DECLARE_SOA_COLUMN(PhiHe3, phiHe3, float); // Phi of the He daughter +DECLARE_SOA_COLUMN(EtaHe3, etaHe3, float); // Eta of the He daughter +DECLARE_SOA_COLUMN(PtPi, ptPi, float); // Pt of the Pi daughter +DECLARE_SOA_COLUMN(PhiPi, phiPi, float); // Phi of the Pi daughter +DECLARE_SOA_COLUMN(EtaPi, etaPi, float); // Eta of the Pi daughter +DECLARE_SOA_COLUMN(XPrimVtx, xPrimVtx, float); // Decay vertex of the candidate (x direction) +DECLARE_SOA_COLUMN(YPrimVtx, yPrimVtx, float); // Decay vertex of the candidate (y direction) +DECLARE_SOA_COLUMN(ZPrimVtx, zPrimVtx, float); // Decay vertex of the candidate (z direction) +DECLARE_SOA_COLUMN(XDecVtx, xDecVtx, float); // Decay vertex of the candidate (x direction) +DECLARE_SOA_COLUMN(YDecVtx, yDecVtx, float); // Decay vertex of the candidate (y direction) +DECLARE_SOA_COLUMN(ZDecVtx, zDecVtx, float); // Decay vertex of the candidate (z direction) +DECLARE_SOA_COLUMN(MassH3L, massH3L, float); // Squared mass w/ hypertriton mass hypo +DECLARE_SOA_COLUMN(MassH4L, massH4L, float); // Squared mass w/ H4L mass hypo +DECLARE_SOA_COLUMN(DcaV0Daug, dcaV0Daug, float); // DCA between daughters +DECLARE_SOA_COLUMN(CosPA, cosPA, double); // Cosine of the pointing angle +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(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 +DECLARE_SOA_COLUMN(TrackedClSize, trackedClSize, int); // int: zero for non-tracked candidates +DECLARE_SOA_COLUMN(Flags, flags, uint8_t); // Flags for PID in tracking (bits [0, 3] for negative daughter, [4,7] for positive daughter) +DECLARE_SOA_COLUMN(TPCmomHe, tpcMomHe, float); // TPC momentum of the He daughter +DECLARE_SOA_COLUMN(TPCmomPi, tpcMomPi, float); // TPC momentum of the Pi daughter +DECLARE_SOA_COLUMN(TOFMass, tofMass, float); // TOF mass of the candidate +DECLARE_SOA_COLUMN(ITSclusterSizesHe, itsClusterSizesHe, uint32_t); // ITS cluster size of the He daughter +DECLARE_SOA_COLUMN(ITSclusterSizesPi, itsClusterSizesPi, uint32_t); // ITS cluster size of the Pi daughter +DECLARE_SOA_COLUMN(ITSclusterSizesHyp, itsClusterSizesHyp, uint32_t); // ITS cluster size of the Pi daughter +DECLARE_SOA_COLUMN(DcaHe, dcaHe, float); // DCA between He daughter and V0 +DECLARE_SOA_COLUMN(DcaPi, dcaPi, float); // DCA between pi daughter and V0 +DECLARE_SOA_COLUMN(GenPt, genPt, float); // Pt 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(GenPtHe3, genPtHe3, float); // Pt of the He daughter (to be used for the recalibration) +DECLARE_SOA_COLUMN(GenXDecVtx, genXDecVtx, float); // Decay vertex of the candidate (x direction) +DECLARE_SOA_COLUMN(GenYDecVtx, genYDecVtx, float); // Decay vertex of the candidate (y direction) +DECLARE_SOA_COLUMN(GenZDecVtx, genZDecVtx, float); // Decay vertex of the candidate (z direction) +DECLARE_SOA_COLUMN(IsReco, isReco, bool); // bool: true for reco +DECLARE_SOA_COLUMN(IsSignal, isSignal, bool); // bool: true for signal +DECLARE_SOA_COLUMN(IsRecoMCCollision, isRecoMCCollision, bool); // bool: true for reco MC collision +DECLARE_SOA_COLUMN(IsSurvEvSel, isSurvEvSel, bool); // bool: true for survived event selection } // namespace hyperrec DECLARE_SOA_TABLE(DataHypCands, "AOD", "HYPCANDS", @@ -88,9 +91,10 @@ DECLARE_SOA_TABLE(DataHypCands, "AOD", "HYPCANDS", hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, - hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, + hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, + hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, - hyperrec::Flags, hyperrec::Tracked); + hyperrec::Flags, hyperrec::TrackedClSize); DECLARE_SOA_TABLE(DataHypCandsFlow, "AOD", "HYPCANDSFLOW", o2::soa::Index<>, @@ -106,9 +110,10 @@ DECLARE_SOA_TABLE(DataHypCandsFlow, "AOD", "HYPCANDSFLOW", hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, - hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, + hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, + hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, - hyperrec::Flags, hyperrec::Tracked); + hyperrec::Flags, hyperrec::TrackedClSize); DECLARE_SOA_TABLE(MCHypCands, "AOD", "MCHYPCANDS", o2::soa::Index<>, @@ -121,9 +126,10 @@ DECLARE_SOA_TABLE(MCHypCands, "AOD", "MCHYPCANDS", hyperrec::XDecVtx, hyperrec::YDecVtx, hyperrec::ZDecVtx, hyperrec::DcaV0Daug, hyperrec::DcaHe, hyperrec::DcaPi, hyperrec::NSigmaHe, hyperrec::NTPCclusHe, hyperrec::NTPCclusPi, - hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, + hyperrec::TPCmomHe, hyperrec::TPCmomPi, hyperrec::TPCsignalHe, hyperrec::TPCsignalPi, hyperrec::TPCChi2He, + hyperrec::TOFMass, hyperrec::ITSclusterSizesHe, hyperrec::ITSclusterSizesPi, - hyperrec::Flags, hyperrec::Tracked, + hyperrec::Flags, hyperrec::TrackedClSize, hyperrec::GenPt, hyperrec::GenPhi, hyperrec::GenEta, diff --git a/PWGLF/DataModel/LFLithium4Tables.h b/PWGLF/DataModel/LFLithium4Tables.h index 50c5acb5cca..486e44575ee 100644 --- a/PWGLF/DataModel/LFLithium4Tables.h +++ b/PWGLF/DataModel/LFLithium4Tables.h @@ -44,6 +44,8 @@ DECLARE_SOA_COLUMN(InnerParamTPCPr, innerParamTPCPr, float); DECLARE_SOA_COLUMN(NClsTPCHe3, nClsTPCHe3, uint8_t); DECLARE_SOA_COLUMN(NSigmaTPCHe3, nSigmaTPCHe3, float); DECLARE_SOA_COLUMN(NSigmaTPCPr, nSigmaTOFPr, float); +DECLARE_SOA_COLUMN(Chi2TPCHe3, chi2TPCHe3, float); +DECLARE_SOA_COLUMN(Chi2TPCPr, chi2TPCPr, float); DECLARE_SOA_COLUMN(MassTOFHe3, massTOFHe3, float); DECLARE_SOA_COLUMN(MassTOFPr, massTOFPr, float); DECLARE_SOA_COLUMN(PIDtrkHe3, pidTrkHe3, uint32_t); @@ -59,10 +61,18 @@ DECLARE_SOA_COLUMN(IsBkgLS, isBkgLS, bool); DECLARE_SOA_COLUMN(IsBkgEM, isBkgEM, bool); DECLARE_SOA_COLUMN(PtMCHe3, ptMCHe3, float); +DECLARE_SOA_COLUMN(EtaMCHe3, etaMCHe3, float); +DECLARE_SOA_COLUMN(PhiMCHe3, phiMCHe3, float); DECLARE_SOA_COLUMN(PtMCPr, ptMCPr, float); +DECLARE_SOA_COLUMN(EtaMCPr, etaMCPr, float); +DECLARE_SOA_COLUMN(PhiMCPr, phiMCPr, float); DECLARE_SOA_COLUMN(SignedPtMC, signedPtMC, float); DECLARE_SOA_COLUMN(MassMC, massMC, float); +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); +DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); + } // namespace Lithium4TablesNS DECLARE_SOA_TABLE(Lithium4Table, "AOD", "LITHIUM4TABLE", @@ -83,6 +93,8 @@ DECLARE_SOA_TABLE(Lithium4Table, "AOD", "LITHIUM4TABLE", Lithium4TablesNS::NClsTPCHe3, Lithium4TablesNS::NSigmaTPCHe3, Lithium4TablesNS::NSigmaTPCPr, + Lithium4TablesNS::Chi2TPCHe3, + Lithium4TablesNS::Chi2TPCPr, Lithium4TablesNS::MassTOFHe3, Lithium4TablesNS::MassTOFPr, Lithium4TablesNS::PIDtrkHe3, @@ -94,37 +106,18 @@ DECLARE_SOA_TABLE(Lithium4Table, "AOD", "LITHIUM4TABLE", Lithium4TablesNS::IsBkgLS, Lithium4TablesNS::IsBkgEM) DECLARE_SOA_TABLE(Lithium4TableMC, "AOD", "LITHIUM4TABLEMC", - Lithium4TablesNS::PtHe3, - Lithium4TablesNS::EtaHe3, - Lithium4TablesNS::PhiHe3, - Lithium4TablesNS::PtPr, - Lithium4TablesNS::EtaPr, - Lithium4TablesNS::PhiPr, - Lithium4TablesNS::DCAxyHe3, - Lithium4TablesNS::DCAzHe3, - Lithium4TablesNS::DCAxyPr, - Lithium4TablesNS::DCAzPr, - Lithium4TablesNS::SignalTPCHe3, - Lithium4TablesNS::InnerParamTPCHe3, - Lithium4TablesNS::SignalTPCPr, - Lithium4TablesNS::InnerParamTPCPr, - Lithium4TablesNS::NClsTPCHe3, - Lithium4TablesNS::NSigmaTPCHe3, - Lithium4TablesNS::NSigmaTPCPr, - Lithium4TablesNS::MassTOFHe3, - Lithium4TablesNS::MassTOFPr, - Lithium4TablesNS::PIDtrkHe3, - Lithium4TablesNS::PIDtrkPr, - Lithium4TablesNS::ItsClusterSizeHe3, - Lithium4TablesNS::ItsClusterSizePr, - Lithium4TablesNS::SharedClustersHe3, - Lithium4TablesNS::SharedClustersPr, - Lithium4TablesNS::IsBkgLS, - Lithium4TablesNS::IsBkgEM, Lithium4TablesNS::PtMCHe3, + Lithium4TablesNS::EtaMCHe3, + Lithium4TablesNS::PhiMCHe3, Lithium4TablesNS::PtMCPr, + Lithium4TablesNS::EtaMCPr, + Lithium4TablesNS::PhiMCPr, Lithium4TablesNS::SignedPtMC, Lithium4TablesNS::MassMC) +DECLARE_SOA_TABLE(Lithium4Mult, "AOD", "LITHIUM4MULT", + Lithium4TablesNS::Multiplicity, + Lithium4TablesNS::CentralityFT0C, + Lithium4TablesNS::MultiplicityFT0C) } // namespace o2::aod diff --git a/PWGLF/DataModel/LFLnnTables.h b/PWGLF/DataModel/LFLnnTables.h index 2ee0fa22839..f9ab7fe3989 100644 --- a/PWGLF/DataModel/LFLnnTables.h +++ b/PWGLF/DataModel/LFLnnTables.h @@ -58,6 +58,8 @@ DECLARE_SOA_COLUMN(TPCsignalPi, tpcSignalPi, uint16_t); // TPC DECLARE_SOA_COLUMN(Flags, flags, uint8_t); // Flags for PID in tracking (bits [0, 3] for negative daughter, [4,7] for positive daughter) DECLARE_SOA_COLUMN(TPCmom3H, tpcMom3H, float); // TPC momentum of the 3H daughter DECLARE_SOA_COLUMN(TPCmomPi, tpcMomPi, float); // TPC momentum of the Pi daughter +DECLARE_SOA_COLUMN(MassTrTOF, mass2TrTOF, float); // TOF 3H mass +DECLARE_SOA_COLUMN(TPCchi3H, tpcChi3H, float); // tpcChi3H DECLARE_SOA_COLUMN(ITSclusterSizes3H, itsClusterSizes3H, uint32_t); // ITS cluster size of the 3H daughter DECLARE_SOA_COLUMN(ITSclusterSizesPi, itsClusterSizesPi, uint32_t); // ITS cluster size of the Pi daughter DECLARE_SOA_COLUMN(Dca3H, dca3H, float); // DCA between 3H daughter and V0 @@ -87,6 +89,7 @@ DECLARE_SOA_TABLE(DataLnnCands, "AOD", "LNNCANDS", lnnrec::DcaV0Daug, lnnrec::Dca3H, lnnrec::DcaPi, lnnrec::NSigma3H, lnnrec::NTPCclus3H, lnnrec::NTPCclusPi, lnnrec::TPCmom3H, lnnrec::TPCmomPi, lnnrec::TPCsignal3H, lnnrec::TPCsignalPi, + lnnrec::MassTrTOF, lnnrec::TPCchi3H, lnnrec::ITSclusterSizes3H, lnnrec::ITSclusterSizesPi, lnnrec::Flags); @@ -102,6 +105,7 @@ DECLARE_SOA_TABLE(MCLnnCands, "AOD", "MCLNNCANDS", lnnrec::DcaV0Daug, lnnrec::Dca3H, lnnrec::DcaPi, lnnrec::NSigma3H, lnnrec::NTPCclus3H, lnnrec::NTPCclusPi, lnnrec::TPCmom3H, lnnrec::TPCmomPi, lnnrec::TPCsignal3H, lnnrec::TPCsignalPi, + lnnrec::MassTrTOF, lnnrec::TPCchi3H, lnnrec::ITSclusterSizes3H, lnnrec::ITSclusterSizesPi, lnnrec::Flags, lnnrec::GenPt, @@ -119,4 +123,4 @@ using DataLnnCand = DataLnnCands::iterator; using MCLnnCand = MCLnnCands::iterator; } // namespace o2::aod -#endif // PWGLF_DATAMODEL_LFLNNTABLES_H_ \ No newline at end of file +#endif // PWGLF_DATAMODEL_LFLNNTABLES_H_ diff --git a/PWGLF/DataModel/LFNonPromptCascadeTables.h b/PWGLF/DataModel/LFNonPromptCascadeTables.h index 92e5b4085ca..0208c7c027c 100644 --- a/PWGLF/DataModel/LFNonPromptCascadeTables.h +++ b/PWGLF/DataModel/LFNonPromptCascadeTables.h @@ -24,6 +24,15 @@ namespace o2::aod { namespace NPCascadeTable { +DECLARE_SOA_COLUMN(MatchingChi2, matchingChi2, float); +DECLARE_SOA_COLUMN(ITSClusSize, itsClusSize, float); +DECLARE_SOA_COLUMN(IsGoodMatch, isGoodMatch, bool); +DECLARE_SOA_COLUMN(IsGoodCascade, isGoodCascade, bool); +DECLARE_SOA_COLUMN(PdgCodeMom, pdgCodeMom, int); +DECLARE_SOA_COLUMN(PdgCodeITStrack, pdgCodeITStrack, int); +DECLARE_SOA_COLUMN(IsFromBeauty, isFromBeauty, bool); +DECLARE_SOA_COLUMN(IsFromCharm, isFromCharm, bool); + DECLARE_SOA_COLUMN(PvX, pvX, float); DECLARE_SOA_COLUMN(PvY, pvY, float); DECLARE_SOA_COLUMN(PvZ, pvZ, float); @@ -91,9 +100,15 @@ 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(DCAxMC, dcaXmc, float); +DECLARE_SOA_COLUMN(DCAyMC, dcaYmc, float); +DECLARE_SOA_COLUMN(DCAzMC, dcaZmc, float); +DECLARE_SOA_COLUMN(MCcollisionMatch, mcCollisionMatch, bool); } // namespace NPCascadeTable DECLARE_SOA_TABLE(NPCascTable, "AOD", "NPCASCTABLE", + NPCascadeTable::MatchingChi2, + NPCascadeTable::ITSClusSize, NPCascadeTable::PvX, NPCascadeTable::PvY, NPCascadeTable::PvZ, @@ -146,6 +161,14 @@ DECLARE_SOA_TABLE(NPCascTable, "AOD", "NPCASCTABLE", NPCascadeTable::BachPionTOFNSigma) DECLARE_SOA_TABLE(NPCascTableMC, "AOD", "NPCASCTABLEMC", + NPCascadeTable::MatchingChi2, + NPCascadeTable::ITSClusSize, + NPCascadeTable::IsGoodMatch, + NPCascadeTable::IsGoodCascade, + NPCascadeTable::PdgCodeMom, + NPCascadeTable::PdgCodeITStrack, + NPCascadeTable::IsFromBeauty, + NPCascadeTable::IsFromCharm, NPCascadeTable::PvX, NPCascadeTable::PvY, NPCascadeTable::PvZ, @@ -199,7 +222,23 @@ DECLARE_SOA_TABLE(NPCascTableMC, "AOD", "NPCASCTABLEMC", NPCascadeTable::gPt, NPCascadeTable::gEta, NPCascadeTable::gPhi, - NPCascadeTable::PDGcode) + NPCascadeTable::PDGcode, + NPCascadeTable::DCAxMC, + NPCascadeTable::DCAyMC, + NPCascadeTable::DCAzMC, + NPCascadeTable::MCcollisionMatch) + +DECLARE_SOA_TABLE(NPCascTableGen, "AOD", "NPCASCTABLEGen", + NPCascadeTable::gPt, + NPCascadeTable::gEta, + NPCascadeTable::gPhi, + NPCascadeTable::PDGcode, + NPCascadeTable::PdgCodeMom, + NPCascadeTable::DCAxMC, + NPCascadeTable::DCAyMC, + NPCascadeTable::DCAzMC, + NPCascadeTable::IsFromBeauty, + NPCascadeTable::IsFromCharm) } // namespace o2::aod diff --git a/PWGLF/DataModel/LFNucleiTables.h b/PWGLF/DataModel/LFNucleiTables.h index dd7b72abb67..2fcd940d070 100644 --- a/PWGLF/DataModel/LFNucleiTables.h +++ b/PWGLF/DataModel/LFNucleiTables.h @@ -185,44 +185,44 @@ DECLARE_SOA_TABLE(LfCandNucleus, "AOD", "LFNUCL", track::TPCNClsCrossedRows, track::TPCCrossedRowsOverFindableCls, track::TPCFoundOverFindableCls); -DECLARE_SOA_TABLE_FULL(LfCandNucleusDummy, "LfCandNucleus", "AOD", "LFNUCL", - o2::soa::Index<>, - full::LfNuclEventId, - full::DcaXY, full::DcaZ, - full::TPCNSigmaDe, full::TPCNSigmaHe, - full::TOFNSigmaDe, full::TOFNSigmaHe, - full::IsEvTimeTOF, - full::IsEvTimeT0AC, - full::HasTOF, - full::HasTRD, - full::TPCInnerParam, - full::Beta, - full::TPCSignal, - full::Pt, - full::Eta, - full::Phi, - full::Sign, - full::ITSNCls, - track::TPCNClsFindable, - track::TPCNClsFindableMinusFound, - track::TPCNClsFindableMinusCrossedRows, - full::TPCChi2Ncl, - full::ITSChi2NCl, - track::ITSClusterMap, - full::IsPVContributor, - full::P, - dummy::TPCNSigmaPi, dummy::TPCNSigmaKa, dummy::TPCNSigmaPr, - dummy::TPCNSigmaTr, dummy::TPCNSigmaAl, - dummy::TOFNSigmaPi, dummy::TOFNSigmaKa, dummy::TOFNSigmaPr, - dummy::TOFNSigmaTr, dummy::TOFNSigmaAl, - dummy::TPCExpSignalDiffPr, dummy::TPCExpSignalDiffDe, dummy::TPCExpSignalDiffHe, - dummy::TOFExpSignalDiffPr, dummy::TOFExpSignalDiffDe, dummy::TOFExpSignalDiffHe, - dummy::TOFExpMom, - full::Rapidity, - track::TPCNClsFound, - track::TPCNClsCrossedRows, - track::TPCCrossedRowsOverFindableCls, - track::TPCFoundOverFindableCls); +DECLARE_SOA_TABLE_VERSIONED(LfCandNucleusDummy, "AOD", "LFNUCL", 1, + o2::soa::Index<>, + full::LfNuclEventId, + full::DcaXY, full::DcaZ, + full::TPCNSigmaDe, full::TPCNSigmaHe, + full::TOFNSigmaDe, full::TOFNSigmaHe, + full::IsEvTimeTOF, + full::IsEvTimeT0AC, + full::HasTOF, + full::HasTRD, + full::TPCInnerParam, + full::Beta, + full::TPCSignal, + full::Pt, + full::Eta, + full::Phi, + full::Sign, + full::ITSNCls, + track::TPCNClsFindable, + track::TPCNClsFindableMinusFound, + track::TPCNClsFindableMinusCrossedRows, + full::TPCChi2Ncl, + full::ITSChi2NCl, + track::ITSClusterMap, + full::IsPVContributor, + full::P, + dummy::TPCNSigmaPi, dummy::TPCNSigmaKa, dummy::TPCNSigmaPr, + dummy::TPCNSigmaTr, dummy::TPCNSigmaAl, + dummy::TOFNSigmaPi, dummy::TOFNSigmaKa, dummy::TOFNSigmaPr, + dummy::TOFNSigmaTr, dummy::TOFNSigmaAl, + dummy::TPCExpSignalDiffPr, dummy::TPCExpSignalDiffDe, dummy::TPCExpSignalDiffHe, + dummy::TOFExpSignalDiffPr, dummy::TOFExpSignalDiffDe, dummy::TOFExpSignalDiffHe, + dummy::TOFExpMom, + full::Rapidity, + track::TPCNClsFound, + track::TPCNClsCrossedRows, + track::TPCCrossedRowsOverFindableCls, + track::TPCFoundOverFindableCls); DECLARE_SOA_TABLE(LfCandNucleusExtra, "AOD", "LFNUCLEXTRA", full::TPCNSigmaPi, full::TPCNSigmaKa, full::TPCNSigmaPr, diff --git a/PWGLF/DataModel/LFResonanceTables.h b/PWGLF/DataModel/LFResonanceTables.h index ca0e5fca08e..2c74b52a1b6 100644 --- a/PWGLF/DataModel/LFResonanceTables.h +++ b/PWGLF/DataModel/LFResonanceTables.h @@ -66,6 +66,7 @@ DECLARE_SOA_COLUMN(IsINELgt0, isINELgt0, bool); //! INEL>0 DECLARE_SOA_COLUMN(IsTriggerTVX, isTriggerTVX, bool); //! TriggerTVX DECLARE_SOA_COLUMN(IsInSel8, isInSel8, bool); //! InSel8 DECLARE_SOA_COLUMN(IsInAfterAllCuts, isInAfterAllCuts, bool); //! InAfterAllCuts +DECLARE_SOA_COLUMN(ImpactParameter, impactParameter, float); //! ImpactParameter } // namespace resocollision DECLARE_SOA_TABLE(ResoCollisions, "AOD", "RESOCOLLISION", @@ -81,7 +82,8 @@ DECLARE_SOA_TABLE(ResoCollisions, "AOD", "RESOCOLLISION", resocollision::EvtPlResAC, resocollision::EvtPlResBC, resocollision::BMagField, - timestamp::Timestamp); + timestamp::Timestamp, + evsel::NumTracksInTimeRange); using ResoCollision = ResoCollisions::iterator; DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", @@ -89,7 +91,8 @@ DECLARE_SOA_TABLE(ResoMCCollisions, "AOD", "RESOMCCOL", resocollision::IsINELgt0, resocollision::IsTriggerTVX, resocollision::IsInSel8, - resocollision::IsInAfterAllCuts); + resocollision::IsInAfterAllCuts, + resocollision::ImpactParameter); using ResoMCCollision = ResoMCCollisions::iterator; // Resonance Daughters @@ -120,19 +123,37 @@ 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(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 // For MC DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! Index of the corresponding MC particle DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); @@ -197,6 +218,18 @@ DECLARE_SOA_TABLE(ResoV0s, "AOD", "RESOV0S", 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::V0CosPA, resodaughter::DaughDCA, v0data::DCAPosToPV, @@ -221,6 +254,24 @@ DECLARE_SOA_TABLE(ResoCascades, "AOD", "RESOCASCADES", 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::V0CosPA, resodaughter::CascCosPA, resodaughter::DaughDCA, @@ -288,7 +339,9 @@ DECLARE_SOA_TABLE(ResoMCParents, "AOD", "RESOMCPARENTS", resodaughter::Pz, resodaughter::Eta, resodaughter::Phi, - mcparticle::Y); + mcparticle::Y, + mcparticle::E, + mcparticle::StatusCode); using ResoMCParent = ResoMCParents::iterator; using Reso2TracksExt = soa::Join; // without Extra diff --git a/PWGLF/DataModel/LFResonanceTablesMergeDF.h b/PWGLF/DataModel/LFResonanceTablesMergeDF.h index bceb237faff..00ec4741956 100644 --- a/PWGLF/DataModel/LFResonanceTablesMergeDF.h +++ b/PWGLF/DataModel/LFResonanceTablesMergeDF.h @@ -44,6 +44,7 @@ DECLARE_SOA_COLUMN(BMagField, bMagField, float); //! Magnetic field } // namespace resocollisiondf DECLARE_SOA_TABLE(ResoCollisionDFs, "AOD", "RESOCOLLISIONDF", o2::soa::Index<>, + o2::aod::mult::MultNTracksPV, collision::PosX, collision::PosY, collision::PosZ, @@ -54,7 +55,8 @@ DECLARE_SOA_TABLE(ResoCollisionDFs, "AOD", "RESOCOLLISIONDF", resocollisiondf::EvtPlResAC, resocollisiondf::EvtPlResBC, resocollisiondf::BMagField, - timestamp::Timestamp); + timestamp::Timestamp, + evsel::NumTracksInTimeRange); using ResoCollisionDF = ResoCollisionDFs::iterator; // Resonance Daughters diff --git a/PWGLF/DataModel/LFSigmaTables.h b/PWGLF/DataModel/LFSigmaTables.h index b5a909733c7..01ef1354162 100644 --- a/PWGLF/DataModel/LFSigmaTables.h +++ b/PWGLF/DataModel/LFSigmaTables.h @@ -31,36 +31,38 @@ DECLARE_SOA_TABLE(Sigma0Collisions, "AOD", "SIGMA0COLLISION", //! basic collisio using Sigma0Collision = Sigma0Collisions::iterator; -namespace v0SigmaCandidate +namespace sigma0Core { //______________________________________________________ // REGULAR COLUMNS FOR INDEXING // FOR DERIVED DECLARE_SOA_INDEX_COLUMN(Sigma0Collision, sigma0Collision); //! -} // namespace v0SigmaCandidate +} // namespace sigma0Core // for real data -namespace v0SigmaCandidate +namespace sigma0Core { DECLARE_SOA_COLUMN(SigmapT, sigmapT, float); DECLARE_SOA_COLUMN(SigmaMass, sigmaMass, float); DECLARE_SOA_COLUMN(SigmaRapidity, sigmaRapidity, float); -// DECLARE_SOA_COLUMN(SigmaDCAz, sigmaDCAz, float); -// DECLARE_SOA_COLUMN(SigmaDCAxy, sigmaDCAxy, float); -// DECLARE_SOA_COLUMN(SigmaDCADau, sigmaDCADau, float); - -} // namespace v0SigmaCandidate - -DECLARE_SOA_TABLE(V0SigmaCandidates, "AOD", "V0SIGMAS", - v0SigmaCandidate::SigmapT, - v0SigmaCandidate::SigmaMass, - v0SigmaCandidate::SigmaRapidity); - -DECLARE_SOA_TABLE(V0Sigma0CollRefs, "AOD", "V0SIGMA0COLLREF", //! optional table to refer back to a collision - o2::soa::Index<>, v0SigmaCandidate::Sigma0CollisionId); +DECLARE_SOA_COLUMN(SigmaOPAngle, sigmaOPAngle, float); +DECLARE_SOA_COLUMN(SigmaDeltaEta, sigmaDeltaEta, float); +DECLARE_SOA_COLUMN(SigmaDeltaPhi, sigmaDeltaPhi, float); +} // namespace sigma0Core + +DECLARE_SOA_TABLE(Sigma0Cores, "AOD", "SIGMA0CORES", + sigma0Core::SigmapT, + sigma0Core::SigmaMass, + sigma0Core::SigmaRapidity, + sigma0Core::SigmaOPAngle, + sigma0Core::SigmaDeltaEta, + sigma0Core::SigmaDeltaPhi); + +DECLARE_SOA_TABLE(Sigma0CollRefs, "AOD", "SIGMA0COLLREF", //! optional table to refer back to a collision + o2::soa::Index<>, sigma0Core::Sigma0CollisionId); // For Photon extra info -namespace v0SigmaPhotonExtras +namespace sigmaPhotonExtra { DECLARE_SOA_COLUMN(PhotonPt, photonPt, float); DECLARE_SOA_COLUMN(PhotonMass, photonMass, float); @@ -74,6 +76,7 @@ DECLARE_SOA_COLUMN(PhotonDCAPosPV, photonDCAPosPV, float); 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(PhotonPosTPCCrossedRows, photonPosTPCCrossedRows, uint8_t); @@ -92,44 +95,46 @@ DECLARE_SOA_COLUMN(PhotonNegITSClSize, photonNegITSClSize, uint32_t); DECLARE_SOA_COLUMN(PhotonV0Type, photonV0Type, uint8_t); DECLARE_SOA_COLUMN(GammaBDTScore, gammaBDTScore, float); -} // namespace v0SigmaPhotonExtras - -DECLARE_SOA_TABLE(V0SigmaPhotonExtras, "AOD", "V0SIGMAPHOTON", - v0SigmaPhotonExtras::PhotonMass, - v0SigmaPhotonExtras::PhotonPt, - v0SigmaPhotonExtras::PhotonQt, - v0SigmaPhotonExtras::PhotonAlpha, - v0SigmaPhotonExtras::PhotonRadius, - v0SigmaPhotonExtras::PhotonCosPA, - v0SigmaPhotonExtras::PhotonDCADau, - v0SigmaPhotonExtras::PhotonDCANegPV, - v0SigmaPhotonExtras::PhotonDCAPosPV, - v0SigmaPhotonExtras::PhotonZconv, - v0SigmaPhotonExtras::PhotonEta, - v0SigmaPhotonExtras::PhotonY, - v0SigmaPhotonExtras::PhotonPosTPCNSigma, - v0SigmaPhotonExtras::PhotonNegTPCNSigma, - v0SigmaPhotonExtras::PhotonPosTPCCrossedRows, - v0SigmaPhotonExtras::PhotonNegTPCCrossedRows, - v0SigmaPhotonExtras::PhotonPosPt, - v0SigmaPhotonExtras::PhotonNegPt, - v0SigmaPhotonExtras::PhotonPosEta, - v0SigmaPhotonExtras::PhotonNegEta, - v0SigmaPhotonExtras::PhotonPosY, - v0SigmaPhotonExtras::PhotonNegY, - v0SigmaPhotonExtras::PhotonPsiPair, - v0SigmaPhotonExtras::PhotonPosITSCls, - v0SigmaPhotonExtras::PhotonNegITSCls, - v0SigmaPhotonExtras::PhotonPosITSClSize, - v0SigmaPhotonExtras::PhotonNegITSClSize, - v0SigmaPhotonExtras::PhotonV0Type, - v0SigmaPhotonExtras::GammaBDTScore); +} // namespace sigmaPhotonExtra + +DECLARE_SOA_TABLE(SigmaPhotonExtras, "AOD", "SIGMA0PHOTON", + sigmaPhotonExtra::PhotonPt, + sigmaPhotonExtra::PhotonMass, + sigmaPhotonExtra::PhotonQt, + sigmaPhotonExtra::PhotonAlpha, + sigmaPhotonExtra::PhotonRadius, + sigmaPhotonExtra::PhotonCosPA, + sigmaPhotonExtra::PhotonDCADau, + sigmaPhotonExtra::PhotonDCANegPV, + sigmaPhotonExtra::PhotonDCAPosPV, + sigmaPhotonExtra::PhotonZconv, + sigmaPhotonExtra::PhotonEta, + sigmaPhotonExtra::PhotonY, + sigmaPhotonExtra::PhotonPhi, + sigmaPhotonExtra::PhotonPosTPCNSigma, + sigmaPhotonExtra::PhotonNegTPCNSigma, + sigmaPhotonExtra::PhotonPosTPCCrossedRows, + sigmaPhotonExtra::PhotonNegTPCCrossedRows, + sigmaPhotonExtra::PhotonPosPt, + sigmaPhotonExtra::PhotonNegPt, + sigmaPhotonExtra::PhotonPosEta, + sigmaPhotonExtra::PhotonNegEta, + sigmaPhotonExtra::PhotonPosY, + sigmaPhotonExtra::PhotonNegY, + sigmaPhotonExtra::PhotonPsiPair, + sigmaPhotonExtra::PhotonPosITSCls, + sigmaPhotonExtra::PhotonNegITSCls, + sigmaPhotonExtra::PhotonPosITSClSize, + sigmaPhotonExtra::PhotonNegITSClSize, + sigmaPhotonExtra::PhotonV0Type, + sigmaPhotonExtra::GammaBDTScore); // For Lambda extra info -namespace v0SigmaLambdaExtras +namespace sigmaLambdaExtra { DECLARE_SOA_COLUMN(LambdaPt, lambdaPt, float); 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(LambdaRadius, lambdaRadius, float); @@ -139,10 +144,15 @@ DECLARE_SOA_COLUMN(LambdaDCANegPV, lambdaDCANegPV, float); DECLARE_SOA_COLUMN(LambdaDCAPosPV, lambdaDCAPosPV, float); DECLARE_SOA_COLUMN(LambdaEta, lambdaEta, float); DECLARE_SOA_COLUMN(LambdaY, lambdaY, float); +DECLARE_SOA_COLUMN(LambdaPhi, lambdaPhi, float); DECLARE_SOA_COLUMN(LambdaPosPrTPCNSigma, lambdaPosPrTPCNSigma, float); DECLARE_SOA_COLUMN(LambdaPosPiTPCNSigma, lambdaPosPiTPCNSigma, float); DECLARE_SOA_COLUMN(LambdaNegPrTPCNSigma, lambdaNegPrTPCNSigma, float); DECLARE_SOA_COLUMN(LambdaNegPiTPCNSigma, lambdaNegPiTPCNSigma, float); +DECLARE_SOA_COLUMN(LambdaPrTOFNSigma, lambdaPrTOFNSigma, float); +DECLARE_SOA_COLUMN(LambdaPiTOFNSigma, lambdaPiTOFNSigma, float); +DECLARE_SOA_COLUMN(ALambdaPrTOFNSigma, aLambdaPrTOFNSigma, float); +DECLARE_SOA_COLUMN(ALambdaPiTOFNSigma, aLambdaPiTOFNSigma, float); DECLARE_SOA_COLUMN(LambdaPosTPCCrossedRows, lambdaPosTPCCrossedRows, uint8_t); DECLARE_SOA_COLUMN(LambdaNegTPCCrossedRows, lambdaNegTPCCrossedRows, uint8_t); DECLARE_SOA_COLUMN(LambdaPosPt, lambdaPosPt, float); @@ -161,51 +171,71 @@ DECLARE_SOA_COLUMN(LambdaV0Type, lambdaV0Type, uint8_t); DECLARE_SOA_COLUMN(LambdaBDTScore, lambdaBDTScore, float); DECLARE_SOA_COLUMN(AntiLambdaBDTScore, antilambdaBDTScore, float); -} // namespace v0SigmaLambdaExtras - -DECLARE_SOA_TABLE(V0SigmaLambdaExtras, "AOD", "V0SIGMALAMBDA", - v0SigmaLambdaExtras::LambdaPt, - v0SigmaLambdaExtras::LambdaMass, - v0SigmaLambdaExtras::LambdaQt, - v0SigmaLambdaExtras::LambdaAlpha, - v0SigmaLambdaExtras::LambdaRadius, - v0SigmaLambdaExtras::LambdaCosPA, - v0SigmaLambdaExtras::LambdaDCADau, - v0SigmaLambdaExtras::LambdaDCANegPV, - v0SigmaLambdaExtras::LambdaDCAPosPV, - v0SigmaLambdaExtras::LambdaEta, - v0SigmaLambdaExtras::LambdaY, - v0SigmaLambdaExtras::LambdaPosPrTPCNSigma, - v0SigmaLambdaExtras::LambdaPosPiTPCNSigma, - v0SigmaLambdaExtras::LambdaNegPrTPCNSigma, - v0SigmaLambdaExtras::LambdaNegPiTPCNSigma, - v0SigmaLambdaExtras::LambdaPosTPCCrossedRows, - v0SigmaLambdaExtras::LambdaNegTPCCrossedRows, - v0SigmaLambdaExtras::LambdaPosPt, - v0SigmaLambdaExtras::LambdaNegPt, - v0SigmaLambdaExtras::LambdaPosEta, - v0SigmaLambdaExtras::LambdaNegEta, - v0SigmaLambdaExtras::LambdaPosPrY, - v0SigmaLambdaExtras::LambdaPosPiY, - v0SigmaLambdaExtras::LambdaNegPrY, - v0SigmaLambdaExtras::LambdaNegPiY, - v0SigmaLambdaExtras::LambdaPosITSCls, - v0SigmaLambdaExtras::LambdaNegITSCls, - v0SigmaLambdaExtras::LambdaPosITSClSize, - v0SigmaLambdaExtras::LambdaNegITSClSize, - v0SigmaLambdaExtras::LambdaV0Type, - v0SigmaLambdaExtras::LambdaBDTScore, - v0SigmaLambdaExtras::AntiLambdaBDTScore); +} // namespace sigmaLambdaExtra + +DECLARE_SOA_TABLE(SigmaLambdaExtras, "AOD", "SIGMA0LAMBDA", + sigmaLambdaExtra::LambdaPt, + sigmaLambdaExtra::LambdaMass, + sigmaLambdaExtra::AntiLambdaMass, + sigmaLambdaExtra::LambdaQt, + sigmaLambdaExtra::LambdaAlpha, + sigmaLambdaExtra::LambdaRadius, + sigmaLambdaExtra::LambdaCosPA, + sigmaLambdaExtra::LambdaDCADau, + sigmaLambdaExtra::LambdaDCANegPV, + sigmaLambdaExtra::LambdaDCAPosPV, + sigmaLambdaExtra::LambdaEta, + sigmaLambdaExtra::LambdaY, + sigmaLambdaExtra::LambdaPhi, + sigmaLambdaExtra::LambdaPosPrTPCNSigma, + sigmaLambdaExtra::LambdaPosPiTPCNSigma, + sigmaLambdaExtra::LambdaNegPrTPCNSigma, + sigmaLambdaExtra::LambdaNegPiTPCNSigma, + sigmaLambdaExtra::LambdaPrTOFNSigma, + sigmaLambdaExtra::LambdaPiTOFNSigma, + sigmaLambdaExtra::ALambdaPrTOFNSigma, + sigmaLambdaExtra::ALambdaPiTOFNSigma, + sigmaLambdaExtra::LambdaPosTPCCrossedRows, + sigmaLambdaExtra::LambdaNegTPCCrossedRows, + sigmaLambdaExtra::LambdaPosPt, + sigmaLambdaExtra::LambdaNegPt, + sigmaLambdaExtra::LambdaPosEta, + sigmaLambdaExtra::LambdaNegEta, + sigmaLambdaExtra::LambdaPosPrY, + sigmaLambdaExtra::LambdaPosPiY, + sigmaLambdaExtra::LambdaNegPrY, + sigmaLambdaExtra::LambdaNegPiY, + sigmaLambdaExtra::LambdaPosITSCls, + sigmaLambdaExtra::LambdaNegITSCls, + sigmaLambdaExtra::LambdaPosITSClSize, + sigmaLambdaExtra::LambdaNegITSClSize, + sigmaLambdaExtra::LambdaV0Type, + sigmaLambdaExtra::LambdaBDTScore, + sigmaLambdaExtra::AntiLambdaBDTScore); // for MC data -namespace v0SigmaMCCandidate +namespace sigmaMCCore { -DECLARE_SOA_COLUMN(IsSigma, isSigma, bool); - -} // namespace v0SigmaMCCandidate - -DECLARE_SOA_TABLE(V0SigmaMCCandidates, "AOD", "V0MCSIGMAS", - v0SigmaMCCandidate::IsSigma); +DECLARE_SOA_COLUMN(IsSigma, isSigma, bool); // TODO: include PDG + IsPhysicalPrimary +DECLARE_SOA_COLUMN(IsAntiSigma, isAntiSigma, bool); +DECLARE_SOA_COLUMN(PhotonCandPDGCode, photonCandPDGCode, int); +DECLARE_SOA_COLUMN(PhotonCandPDGCodeMother, photonCandPDGCodeMother, int); +DECLARE_SOA_COLUMN(IsPhotonCandPrimary, isPhotonCandPrimary, bool); +DECLARE_SOA_COLUMN(LambdaCandPDGCode, lambdaCandPDGCode, int); +DECLARE_SOA_COLUMN(LambdaCandPDGCodeMother, lambdaCandPDGCodeMother, int); +DECLARE_SOA_COLUMN(IsLambdaCandPrimary, isLambdaCandPrimary, bool); + +} // namespace sigmaMCCore + +DECLARE_SOA_TABLE(SigmaMCCores, "AOD", "SIGMA0MCCORES", + sigmaMCCore::IsSigma, + sigmaMCCore::IsAntiSigma, + sigmaMCCore::PhotonCandPDGCode, + sigmaMCCore::PhotonCandPDGCodeMother, + sigmaMCCore::IsPhotonCandPrimary, + sigmaMCCore::LambdaCandPDGCode, + sigmaMCCore::LambdaCandPDGCodeMother, + sigmaMCCore::IsLambdaCandPrimary); } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFSIGMATABLES_H_ diff --git a/PWGLF/DataModel/LFSlimNucleiTables.h b/PWGLF/DataModel/LFSlimNucleiTables.h index c61c1b25a7b..19c42ed12f9 100644 --- a/PWGLF/DataModel/LFSlimNucleiTables.h +++ b/PWGLF/DataModel/LFSlimNucleiTables.h @@ -36,11 +36,13 @@ DECLARE_SOA_COLUMN(DCAz, dcaz, float); DECLARE_SOA_COLUMN(TPCsignal, tpcSignal, float); DECLARE_SOA_COLUMN(ITSchi2, itsChi2, float); DECLARE_SOA_COLUMN(TPCchi2, tpcChi2, float); +DECLARE_SOA_COLUMN(TOFchi2, tofChi2, float); DECLARE_SOA_COLUMN(Flags, flags, uint16_t); DECLARE_SOA_COLUMN(TPCfindableCls, tpcFindableCls, uint8_t); DECLARE_SOA_COLUMN(TPCcrossedRows, tpcCrossedRows, uint8_t); 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(gPt, genPt, float); DECLARE_SOA_COLUMN(gEta, genEta, float); @@ -78,11 +80,13 @@ DECLARE_SOA_TABLE(NucleiTable, "AOD", "NUCLEITABLE", NucleiTableNS::TPCsignal, NucleiTableNS::ITSchi2, NucleiTableNS::TPCchi2, + NucleiTableNS::TOFchi2, NucleiTableNS::Flags, NucleiTableNS::TPCfindableCls, NucleiTableNS::TPCcrossedRows, NucleiTableNS::ITSclsMap, NucleiTableNS::TPCnCls, + NucleiTableNS::TPCnClsShared, NucleiTableNS::ITSclusterSizes); DECLARE_SOA_TABLE(NucleiTableFlow, "AOD", "NUCLEITABLEFLOW", @@ -111,11 +115,13 @@ DECLARE_SOA_TABLE(NucleiTableMC, "AOD", "NUCLEITABLEMC", NucleiTableNS::TPCsignal, NucleiTableNS::ITSchi2, NucleiTableNS::TPCchi2, + NucleiTableNS::TOFchi2, NucleiTableNS::Flags, NucleiTableNS::TPCfindableCls, NucleiTableNS::TPCcrossedRows, NucleiTableNS::ITSclsMap, NucleiTableNS::TPCnCls, + NucleiTableNS::TPCnClsShared, NucleiTableNS::ITSclusterSizes, NucleiTableNS::gPt, NucleiTableNS::gEta, diff --git a/PWGLF/DataModel/LFSlimStrangeTables.h b/PWGLF/DataModel/LFSlimStrangeTables.h index 95505bef0f5..423a412bb6d 100644 --- a/PWGLF/DataModel/LFSlimStrangeTables.h +++ b/PWGLF/DataModel/LFSlimStrangeTables.h @@ -41,16 +41,25 @@ DECLARE_SOA_COLUMN(PzPos, pzPos, float); DECLARE_SOA_COLUMN(PxNeg, pxNeg, float); DECLARE_SOA_COLUMN(PyNeg, pyNeg, float); DECLARE_SOA_COLUMN(PzNeg, pzNeg, float); +DECLARE_SOA_COLUMN(PxPosMC, pxPosMC, float); +DECLARE_SOA_COLUMN(PyPosMC, pyPosMC, float); +DECLARE_SOA_COLUMN(PzPosMC, pzPosMC, float); +DECLARE_SOA_COLUMN(PxNegMC, pxNegMC, float); +DECLARE_SOA_COLUMN(PyNegMC, pyNegMC, float); +DECLARE_SOA_COLUMN(PzNegMC, pzNegMC, float); DECLARE_SOA_COLUMN(GenPt, gentPt, float); DECLARE_SOA_COLUMN(GenEta, genEta, float); DECLARE_SOA_COLUMN(GenCt, genCt, float); DECLARE_SOA_COLUMN(GenLen, genLen, float); DECLARE_SOA_COLUMN(PDGCodeDauPos, pdgCodeDauPos, int); +DECLARE_SOA_COLUMN(PDGCodeMotherDauPos, pdgCodeMotherDauPos, int); DECLARE_SOA_COLUMN(PDGCodeDauNeg, pdgCodeDauNeg, int); +DECLARE_SOA_COLUMN(PDGCodeMotherDauNeg, pdgCodeMotherDauNeg, int); DECLARE_SOA_COLUMN(PDGCode, pdgCode, int); DECLARE_SOA_COLUMN(PDGCodeMother, pdgCodeMother, int); DECLARE_SOA_COLUMN(IsReco, isReco, bool); DECLARE_SOA_COLUMN(IsFD, isFD, uint8_t); +DECLARE_SOA_COLUMN(PDGMatchMotherSecondMother, pdgMatchMotherSecondMother, int); } // namespace SlimLambdaTables DECLARE_SOA_TABLE(LambdaTableML, "AOD", "LAMBDATABLEML", @@ -89,10 +98,13 @@ DECLARE_SOA_TABLE(McLambdaTableML, "AOD", "MCLAMBDATABLEML", SlimLambdaTables::GenEta, SlimLambdaTables::GenCt, SlimLambdaTables::PDGCodeDauPos, + SlimLambdaTables::PDGCodeMotherDauPos, SlimLambdaTables::PDGCodeDauNeg, + SlimLambdaTables::PDGCodeMotherDauNeg, SlimLambdaTables::PDGCode, SlimLambdaTables::PDGCodeMother, - SlimLambdaTables::IsReco); + SlimLambdaTables::IsReco, + SlimLambdaTables::PDGMatchMotherSecondMother); DECLARE_SOA_TABLE(V0TableAP, "AOD", "V0TABLEAP", SlimLambdaTables::Eta, @@ -119,6 +131,12 @@ DECLARE_SOA_TABLE(McV0TableAP, "AOD", "MCV0TABLEAP", SlimLambdaTables::PxNeg, SlimLambdaTables::PyNeg, SlimLambdaTables::PzNeg, + SlimLambdaTables::PxPosMC, + SlimLambdaTables::PyPosMC, + SlimLambdaTables::PzPosMC, + SlimLambdaTables::PxNegMC, + SlimLambdaTables::PyNegMC, + SlimLambdaTables::PzNegMC, SlimLambdaTables::Radius, SlimLambdaTables::DcaV0PV, SlimLambdaTables::DcaPosPV, diff --git a/PWGLF/DataModel/LFStrangenessMLTables.h b/PWGLF/DataModel/LFStrangenessMLTables.h index fdb97e1ca1b..abae8814856 100644 --- a/PWGLF/DataModel/LFStrangenessMLTables.h +++ b/PWGLF/DataModel/LFStrangenessMLTables.h @@ -235,6 +235,18 @@ DECLARE_SOA_TABLE(CascMLCandidates, "AOD", "CAMLCANDIDATES", cascmlcandidates::IsXiPlus, cascmlcandidates::IsOmegaMinus, cascmlcandidates::IsOmegaPlus); + +namespace CascMLSelection +{ +DECLARE_SOA_COLUMN(XiBDTScore, xiBDTScore, float); +DECLARE_SOA_COLUMN(OmegaBDTScore, omegaBDTScore, float); +} // namespace CascMLSelection + +DECLARE_SOA_TABLE(CascXiMLScores, "AOD", "CASCXIMLSCORES", + CascMLSelection::XiBDTScore); +DECLARE_SOA_TABLE(CascOmMLScores, "AOD", "CASCOMMLSCORES", + CascMLSelection::OmegaBDTScore); + } // namespace o2::aod #endif // PWGLF_DATAMODEL_LFSTRANGENESSMLTABLES_H_ diff --git a/PWGLF/DataModel/LFStrangenessPIDTables.h b/PWGLF/DataModel/LFStrangenessPIDTables.h index 36a345b87ad..e689dc28141 100644 --- a/PWGLF/DataModel/LFStrangenessPIDTables.h +++ b/PWGLF/DataModel/LFStrangenessPIDTables.h @@ -137,15 +137,15 @@ DECLARE_SOA_COLUMN(BachTOFEventTime, bachTOFEventTime, float); //! bachelor tr // delta-times DECLARE_SOA_COLUMN(PosTOFDeltaTXiPi, posTOFDeltaTXiPi, float); //! positive track TOFDeltaT from pion <- lambda <- xi expectation -DECLARE_SOA_COLUMN(PosTOFDeltaTXiPr, posTOFDeltaTXiPr, float); //! positive track TOFDeltaT from pion <- lambda <- xi expectation +DECLARE_SOA_COLUMN(PosTOFDeltaTXiPr, posTOFDeltaTXiPr, float); //! positive track TOFDeltaT from proton <- lambda <- xi expectation DECLARE_SOA_COLUMN(NegTOFDeltaTXiPi, negTOFDeltaTXiPi, float); //! negative track TOFDeltaT from pion <- lambda <- xi expectation -DECLARE_SOA_COLUMN(NegTOFDeltaTXiPr, negTOFDeltaTXiPr, float); //! negative track TOFDeltaT from pion <- lambda <- xi expectation +DECLARE_SOA_COLUMN(NegTOFDeltaTXiPr, negTOFDeltaTXiPr, float); //! negative track TOFDeltaT from proton <- lambda <- xi expectation DECLARE_SOA_COLUMN(BachTOFDeltaTXiPi, bachTOFDeltaTXiPi, float); //! bachelor track TOFDeltaT from pion <- xi expectation DECLARE_SOA_COLUMN(PosTOFDeltaTOmPi, posTOFDeltaTOmPi, float); //! positive track TOFDeltaT from pion <- lambda <- omega expectation -DECLARE_SOA_COLUMN(PosTOFDeltaTOmPr, posTOFDeltaTOmPr, float); //! positive track TOFDeltaT from pion <- lambda <- omega expectation +DECLARE_SOA_COLUMN(PosTOFDeltaTOmPr, posTOFDeltaTOmPr, float); //! positive track TOFDeltaT from proton <- lambda <- omega expectation DECLARE_SOA_COLUMN(NegTOFDeltaTOmPi, negTOFDeltaTOmPi, float); //! negative track TOFDeltaT from pion <- lambda <- omega expectation -DECLARE_SOA_COLUMN(NegTOFDeltaTOmPr, negTOFDeltaTOmPr, float); //! negative track TOFDeltaT from pion <- lambda <- omega expectation -DECLARE_SOA_COLUMN(BachTOFDeltaTOmPi, bachTOFDeltaTOmPi, float); //! bachelor track TOFDeltaT from pion <- omega expectation +DECLARE_SOA_COLUMN(NegTOFDeltaTOmPr, negTOFDeltaTOmPr, float); //! negative track TOFDeltaT from proton <- lambda <- omega expectation +DECLARE_SOA_COLUMN(BachTOFDeltaTOmKa, bachTOFDeltaTOmKa, float); //! bachelor track TOFDeltaT from kaon <- omega expectation // n-sigmas DECLARE_SOA_COLUMN(TOFNSigmaXiLaPi, tofNSigmaXiLaPi, float); //! meson track NSigma from pion <- lambda <- xi expectation @@ -170,7 +170,7 @@ DECLARE_SOA_TABLE(CascTOFPIDs, "AOD", "CASCTOFPID", // processed information for cascdata::BachTOFDeltaTXiPi, cascdata::PosTOFDeltaTOmPi, cascdata::PosTOFDeltaTOmPr, cascdata::NegTOFDeltaTOmPi, cascdata::NegTOFDeltaTOmPr, - cascdata::BachTOFDeltaTOmPi); + cascdata::BachTOFDeltaTOmKa); DECLARE_SOA_TABLE(CascTOFNSigmas, "AOD", "CascTOFNSigmas", // Nsigmas for cascades cascdata::TOFNSigmaXiLaPi, cascdata::TOFNSigmaXiLaPr, cascdata::TOFNSigmaXiPi, cascdata::TOFNSigmaOmLaPi, cascdata::TOFNSigmaOmLaPr, cascdata::TOFNSigmaOmKa); diff --git a/PWGLF/DataModel/LFStrangenessTables.h b/PWGLF/DataModel/LFStrangenessTables.h index 9baca729fb4..fc7f3b950d7 100644 --- a/PWGLF/DataModel/LFStrangenessTables.h +++ b/PWGLF/DataModel/LFStrangenessTables.h @@ -20,11 +20,43 @@ #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" namespace o2::aod { +// for DF name follow-up and debug +namespace straorigin +{ +DECLARE_SOA_COLUMN(DataframeID, dataframeID, uint64_t); //! Data frame ID (what is usually found in directory name in the AO2D.root, i.e. +} // namespace straorigin + +DECLARE_SOA_TABLE(StraOrigins, "AOD", "STRAORIGIN", //! Table which contains the IDs of all dataframes merged into this dataframe + o2::soa::Index<>, straorigin::DataframeID); + +namespace stracollision +{ +DECLARE_SOA_DYNAMIC_COLUMN(IsUPC, isUPC, //! check whether this is a UPC or hadronic collision + [](int value) -> bool { return value <= 2 ? true : false; }); +DECLARE_SOA_DYNAMIC_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, //! get the total sum of the FV0 A amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(TotalFT0AmplitudeA, totalFT0AmplitudeA, //! get the total sum of the FT0 A amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, //! get the total sum of the FT0 C amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(TotalFDDAmplitudeA, totalFDDAmplitudeA, //! get the total sum of the FDD A amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(TotalFDDAmplitudeC, totalFDDAmplitudeC, //! get the total sum of the FDD C amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(EnergyCommonZNA, energyCommonZNA, //! get the total sum of the ZN A amplitudes + [](float value) -> float { return value; }); +DECLARE_SOA_DYNAMIC_COLUMN(EnergyCommonZNC, energyCommonZNC, //! get the total sum of the ZN A amplitudes + [](float value) -> float { return value; }); +} // namespace stracollision + //______________________________________________________ // Collision declarations for derived data analysis // this is optional but will ensure full flexibility @@ -34,13 +66,16 @@ DECLARE_SOA_TABLE(StraCollisions, "AOD", "STRACOLLISION", //! basic collision pr DECLARE_SOA_TABLE(StraCents, "AOD", "STRACENTS", //! centrality percentiles cent::CentFT0M, cent::CentFT0A, cent::CentFT0C, cent::CentFV0A); +// !!! 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); +// !!! DEPRECATED TABLE: StraRawCents_001 !!! All info in StraEvSels_001, in order to group all event characteristics in a unique table. Please use StraEvSels_001 DECLARE_SOA_TABLE_VERSIONED(StraRawCents_001, "AOD", "STRARAWCENTS", 1, //! debug information mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, // FIT detectors mult::MultNTracksPVeta1, // track multiplicities mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals mult::MultZEM2, mult::MultZPA, mult::MultZPC); +// !!! DEPRECATED TABLE: StraRawCents_002 !!! All info in StraEvSels_001, in order to group all event characteristics in a unique table. Please use StraEvSels_001 DECLARE_SOA_TABLE_VERSIONED(StraRawCents_002, "AOD", "STRARAWCENTS", 2, //! debug information mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, // FIT detectors mult::MultNTracksPVeta1, // track multiplicities with eta cut for INEL>0 @@ -48,6 +83,7 @@ DECLARE_SOA_TABLE_VERSIONED(StraRawCents_002, "AOD", "STRARAWCENTS", 2, mult::MultAllTracksTPCOnly, mult::MultAllTracksITSTPC, // track multiplicities, all, no eta cut mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals mult::MultZEM2, mult::MultZPA, mult::MultZPC); +// !!! DEPRECATED TABLE: StraRawCents_003 !!! All info in StraEvSels_001, in order to group all event characteristics in a unique table. Please use StraEvSels_001 DECLARE_SOA_TABLE_VERSIONED(StraRawCents_003, "AOD", "STRARAWCENTS", 3, //! debug information mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, // FIT detectors mult::MultNTracksPVeta1, // track multiplicities with eta cut for INEL>0 @@ -58,6 +94,7 @@ DECLARE_SOA_TABLE_VERSIONED(StraRawCents_003, "AOD", "STRARAWCENTS", 3, //! mult::MultAllTracksITSTPC, // ITSTPC track multiplicities, all, no eta cut mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals mult::MultZEM2, mult::MultZPA, mult::MultZPC); +// !!! DEPRECATED TABLE: StraRawCents_004 !!! All info in StraEvSels_001, in order to group all event characteristics in a unique table. Please use StraEvSels_001 DECLARE_SOA_TABLE_VERSIONED(StraRawCents_004, "AOD", "STRARAWCENTS", 4, //! debug information mult::MultFT0A, mult::MultFT0C, mult::MultFV0A, // FIT detectors mult::MultNTracksPVeta1, // track multiplicities with eta cut for INEL>0 @@ -69,8 +106,109 @@ DECLARE_SOA_TABLE_VERSIONED(StraRawCents_004, "AOD", "STRARAWCENTS", 4, //! mult::MultZNA, mult::MultZNC, mult::MultZEM1, // ZDC signals mult::MultZEM2, mult::MultZPA, mult::MultZPC, evsel::NumTracksInTimeRange); // add occupancy as extra -DECLARE_SOA_TABLE(StraEvSels, "AOD", "STRAEVSELS", //! event selection: sel8 +DECLARE_SOA_TABLE(StraEvSels_000, "AOD", "STRAEVSELS", //! event selection: sel8 evsel::Sel8, evsel::Selection); +DECLARE_SOA_TABLE_VERSIONED(StraEvSels_001, "AOD", "STRAEVSELS", 1, //! 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 as extra + 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 + + // Dynamic columns for manipulating information + // stracollision::TotalFV0AmplitudeA, + // stracollision::TotalFT0AmplitudeA, + // stracollision::TotalFT0AmplitudeC, + // stracollision::TotalFDDAmplitudeA, + // stracollision::TotalFDDAmplitudeC, + // stracollision::EnergyCommonZNA, + // stracollision::EnergyCommonZNC, + stracollision::IsUPC); + +DECLARE_SOA_TABLE_VERSIONED(StraEvSels_002, "AOD", "STRAEVSELS", 2, //! 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 + 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 + + // Dynamic columns for manipulating information + // stracollision::TotalFV0AmplitudeA, + // stracollision::TotalFT0AmplitudeA, + // stracollision::TotalFT0AmplitudeC, + // stracollision::TotalFDDAmplitudeA, + // stracollision::TotalFDDAmplitudeC, + // stracollision::EnergyCommonZNA, + // stracollision::EnergyCommonZNC, + stracollision::IsUPC); + +DECLARE_SOA_TABLE_VERSIONED(StraEvSels_003, "AOD", "STRAEVSELS", 3, //! 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 + + // Dynamic columns for manipulating information + // stracollision::TotalFV0AmplitudeA, + // stracollision::TotalFT0AmplitudeA, + // stracollision::TotalFT0AmplitudeC, + // stracollision::TotalFDDAmplitudeA, + // stracollision::TotalFDDAmplitudeC, + // stracollision::EnergyCommonZNA, + // stracollision::EnergyCommonZNC, + stracollision::IsUPC); + DECLARE_SOA_TABLE(StraFT0AQVs, "AOD", "STRAFT0AQVS", //! t0a Qvec qvec::QvecFT0ARe, qvec::QvecFT0AIm, qvec::SumAmplFT0A); DECLARE_SOA_TABLE(StraFT0CQVs, "AOD", "STRAFT0CQVS", //! t0c Qvec @@ -84,19 +222,27 @@ DECLARE_SOA_TABLE(StraTPCQVs, "AOD", "STRATPCQVS", //! tpc Qvec qvec::QvecBPosRe, qvec::QvecBPosIm, epcalibrationtable::QTPCR); DECLARE_SOA_TABLE(StraFT0CQVsEv, "AOD", "STRAFT0CQVSEv", //! events used to compute t0c Qvec epcalibrationtable::TriggerEventEP); +DECLARE_SOA_TABLE(StraZDCSP, "AOD", "STRAZDCSP", //! events used to compute the ZDC spectator plane + spcalibrationtable::TriggerEventSP, spcalibrationtable::PsiZDCA, spcalibrationtable::PsiZDCC); DECLARE_SOA_TABLE(StraStamps, "AOD", "STRASTAMPS", //! information for ID-ing mag field if needed bc::RunNumber, timestamp::Timestamp); using StraRawCents = StraRawCents_004; +using StraEvSels = StraEvSels_003; using StraCollision = StraCollisions::iterator; using StraCent = StraCents::iterator; //______________________________________________________ // for correlating information with MC // also allows for collision association cross-checks -DECLARE_SOA_TABLE(StraMCCollisions, "AOD", "STRAMCCOLLISION", //! MC collision properties +DECLARE_SOA_TABLE(StraMCCollisions_000, "AOD", "STRAMCCOLLISION", //! MC collision properties o2::soa::Index<>, mccollision::PosX, mccollision::PosY, mccollision::PosZ, mccollision::ImpactParameter); +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(StraMCCollMults, "AOD", "STRAMCCOLLMULTS", //! MC collision multiplicities mult::MultMCFT0A, mult::MultMCFT0C, mult::MultMCNParticlesEta05, mult::MultMCNParticlesEta08, mult::MultMCNParticlesEta10, o2::soa::Marker<2>); @@ -294,6 +440,9 @@ DECLARE_SOA_COLUMN(PzPosMC, pzPosMC, float); //! V0 positive DECLARE_SOA_COLUMN(PxNegMC, pxNegMC, float); //! V0 positive daughter px (GeV/c) DECLARE_SOA_COLUMN(PyNegMC, pyNegMC, float); //! V0 positive daughter py (GeV/c) DECLARE_SOA_COLUMN(PzNegMC, pzNegMC, float); //! V0 positive daughter pz (GeV/c) +DECLARE_SOA_COLUMN(PxMC, pxMC, float); //! V0 px (GeV/c) +DECLARE_SOA_COLUMN(PyMC, pyMC, float); //! V0 py (GeV/c) +DECLARE_SOA_COLUMN(PzMC, pzMC, float); //! V0 pz (GeV/c) //______________________________________________________ // Binned content for generated particles: derived data @@ -464,6 +613,22 @@ DECLARE_SOA_DYNAMIC_COLUMN(IsPhotonTPConly, isPhotonTPConly, //! is tpc-only pho [](uint8_t V0Type) -> bool { return V0Type & (1 << 1); }); DECLARE_SOA_DYNAMIC_COLUMN(IsCollinear, isCollinear, //! is collinear V0 [](uint8_t V0Type) -> bool { return V0Type & (1 << 2); }); + +DECLARE_SOA_DYNAMIC_COLUMN(RapidityMC, rapidityMC, //! rapidity (0:K0, 1:L, 2:Lbar) + [](float PxMC, float PyMC, float PzMC, int value) -> float { + if (value == 0) + return RecoDecay::y(std::array{PxMC, PyMC, PzMC}, o2::constants::physics::MassKaonNeutral); + if (value == 1 || value == 2) + return RecoDecay::y(std::array{PxMC, PyMC, PzMC}, o2::constants::physics::MassLambda); + return 0.0f; + }); + +DECLARE_SOA_DYNAMIC_COLUMN(NegativePtMC, negativeptMC, //! negative daughter pT + [](float pxnegMC, float pynegMC) -> float { return RecoDecay::sqrtSumOfSquares(pxnegMC, pynegMC); }); +DECLARE_SOA_DYNAMIC_COLUMN(PositivePtMC, positiveptMC, //! positive daughter pT + [](float pxposMC, float pyposMC) -> float { return RecoDecay::sqrtSumOfSquares(pxposMC, pyposMC); }); +DECLARE_SOA_DYNAMIC_COLUMN(PtMC, ptMC, //! V0 pT + [](float pxMC, float pyMC) -> float { return RecoDecay::sqrtSumOfSquares(pxMC, pyMC); }); } // namespace v0data DECLARE_SOA_TABLE(V0Indices, "AOD", "V0INDEX", //! index table when using AO2Ds @@ -472,110 +637,62 @@ DECLARE_SOA_TABLE(V0Indices, "AOD", "V0INDEX", //! index table when using AO2Ds DECLARE_SOA_TABLE(V0CollRefs, "AOD", "V0COLLREF", //! optional table to refer back to a collision o2::soa::Index<>, v0data::StraCollisionId); -DECLARE_SOA_TABLE(V0Extras, "AOD", "V0EXTRA", //! optional table to refer to custom track extras - o2::soa::Index<>, v0data::PosTrackExtraId, v0data::NegTrackExtraId); - -DECLARE_SOA_TABLE(StoredV0Extras, "AOD1", "V0EXTRA", //! optional table to refer to custom track extras - o2::soa::Index<>, v0data::PosTrackExtraId, v0data::NegTrackExtraId, soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(V0Extras, "V0EXTRA", //! optional table to refer to custom track extras + o2::soa::Index<>, v0data::PosTrackExtraId, v0data::NegTrackExtraId); DECLARE_SOA_TABLE(V0TrackXs, "AOD", "V0TRACKX", //! track X positions at minima when using AO2Ds v0data::PosX, v0data::NegX, o2::soa::Marker<1>); -DECLARE_SOA_TABLE_FULL(V0CoresBase, "V0Cores", "AOD", "V0CORE", //! core information about decay, viable with AO2Ds or derived - o2::soa::Index<>, - v0data::X, v0data::Y, v0data::Z, - v0data::PxPos, v0data::PyPos, v0data::PzPos, - v0data::PxNeg, v0data::PyNeg, v0data::PzNeg, - v0data::DCAV0Daughters, v0data::DCAPosToPV, v0data::DCANegToPV, - v0data::V0CosPA, v0data::DCAV0ToPV, v0data::V0Type, - - // Dynamic columns - v0data::PtHypertriton, - v0data::PtAntiHypertriton, - v0data::V0Radius, - v0data::DistOverTotMom, - v0data::Alpha, - v0data::QtArm, - v0data::PsiPair, - v0data::PFracPos, - v0data::PFracNeg, // 24 - - // Invariant masses - v0data::MLambda, - v0data::MAntiLambda, - v0data::MK0Short, - v0data::MGamma, - v0data::MHypertriton, - v0data::MAntiHypertriton, - v0data::M, - - // Longitudinal - v0data::YK0Short, - v0data::YLambda, - v0data::YHypertriton, - v0data::YAntiHypertriton, - v0data::Rapidity, - v0data::NegativePt, - v0data::PositivePt, - v0data::NegativeEta, - v0data::NegativePhi, - v0data::PositiveEta, - v0data::PositivePhi, - v0data::IsStandardV0, - v0data::IsPhotonTPConly, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(V0CoresBase, "V0CORE", //! core information about decay, viable with AO2Ds or derived + o2::soa::Index<>, + v0data::X, v0data::Y, v0data::Z, + v0data::PxPos, v0data::PyPos, v0data::PzPos, + v0data::PxNeg, v0data::PyNeg, v0data::PzNeg, + v0data::DCAV0Daughters, v0data::DCAPosToPV, v0data::DCANegToPV, + v0data::V0CosPA, v0data::DCAV0ToPV, v0data::V0Type, + + // Dynamic columns + v0data::PtHypertriton, + v0data::PtAntiHypertriton, + v0data::V0Radius, + v0data::DistOverTotMom, + v0data::Alpha, + v0data::QtArm, + v0data::PsiPair, + v0data::PFracPos, + v0data::PFracNeg, // 24 + + // Invariant masses + v0data::MLambda, + v0data::MAntiLambda, + v0data::MK0Short, + v0data::MGamma, + v0data::MHypertriton, + v0data::MAntiHypertriton, + v0data::M, + + // Longitudinal + v0data::YK0Short, + v0data::YLambda, + v0data::YHypertriton, + v0data::YAntiHypertriton, + v0data::Rapidity, + v0data::NegativePt, + v0data::PositivePt, + v0data::NegativeEta, + v0data::NegativePhi, + v0data::PositiveEta, + v0data::PositivePhi, + v0data::IsStandardV0, + 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_TABLE_FULL(StoredV0CoresBase, "V0Cores", "AOD1", "V0CORE", //! core information about decay, viable with AO2Ds or derived - o2::soa::Index<>, - v0data::X, v0data::Y, v0data::Z, - v0data::PxPos, v0data::PyPos, v0data::PzPos, - v0data::PxNeg, v0data::PyNeg, v0data::PzNeg, - v0data::DCAV0Daughters, v0data::DCAPosToPV, v0data::DCANegToPV, - v0data::V0CosPA, v0data::DCAV0ToPV, v0data::V0Type, - - // Dynamic columns - v0data::PtHypertriton, - v0data::PtAntiHypertriton, - v0data::V0Radius, - v0data::DistOverTotMom, - v0data::Alpha, - v0data::QtArm, - v0data::PsiPair, - v0data::PFracPos, - v0data::PFracNeg, // 24 - - // Invariant masses - v0data::MLambda, - v0data::MAntiLambda, - v0data::MK0Short, - v0data::MGamma, - v0data::MHypertriton, - v0data::MAntiHypertriton, - v0data::M, - - // Longitudinal - v0data::YK0Short, - v0data::YLambda, - v0data::YHypertriton, - v0data::YAntiHypertriton, - v0data::Rapidity, - v0data::NegativePt, - v0data::PositivePt, - v0data::NegativeEta, - v0data::NegativePhi, - v0data::PositiveEta, - v0data::PositivePhi, - v0data::IsStandardV0, - v0data::IsPhotonTPConly, - o2::soa::Marker<3>); - -// extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(StoredV0Cores, StoredV0CoresBase, "V0COREEXT", //! - v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta, o2::soa::Marker<2>); // 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", //! +// v0data::Px, v0data::Py, v0data::Pz, v0data::Pt, v0data::P, v0data::Phi, v0data::Eta, o2::soa::Marker<2>); // the table name has here to be the one with EXT which is not nice and under study DECLARE_SOA_TABLE(V0TraPosAtDCAs, "AOD", "V0TRAPOSATDCAs", //! positions of tracks at their DCA for debug v0data::XPosAtDCA, v0data::YPosAtDCA, v0data::ZPosAtDCA, @@ -651,37 +768,60 @@ DECLARE_SOA_EXTENDED_TABLE_USER(V0fCCores, StoredV0fCCores, "V0FCCOREEXT", DECLARE_SOA_TABLE_FULL(V0fCCovs, "V0fCCovs", "AOD", "V0FCCOVS", //! V0 covariance matrices v0data::PositionCovMat, v0data::MomentumCovMat, o2::soa::Marker<2>); -DECLARE_SOA_TABLE(V0MCCores_000, "AOD", "V0MCCORE", //! MC properties of the V0 for posterior analysis - v0data::PDGCode, v0data::PDGCodeMother, - v0data::PDGCodePositive, v0data::PDGCodeNegative, - v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, - v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, - v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC); - -DECLARE_SOA_TABLE_VERSIONED(V0MCCores_001, "AOD", "V0MCCORE", 1, //! debug information - v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis - v0data::PDGCode, v0data::PDGCodeMother, - v0data::PDGCodePositive, v0data::PDGCodeNegative, - v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, - v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, - v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC); - -DECLARE_SOA_TABLE(StoredV0MCCores_000, "AOD", "V0MCCORE", //! MC properties of the V0 for posterior analysis - v0data::PDGCode, v0data::PDGCodeMother, - v0data::PDGCodePositive, v0data::PDGCodeNegative, - v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, - v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, - v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, - o2::soa::Marker<1>); - -DECLARE_SOA_TABLE_VERSIONED(StoredV0MCCores_001, "AOD", "V0MCCORE", 1, //! debug information - v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis - v0data::PDGCode, v0data::PDGCodeMother, - v0data::PDGCodePositive, v0data::PDGCodeNegative, - v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, - v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, - v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, - o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(V0MCCores_000, "V0MCCORE", //! MC properties of the V0 for posterior analysis + v0data::PDGCode, v0data::PDGCodeMother, + v0data::PDGCodePositive, v0data::PDGCodeNegative, + v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, + v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, + v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC); + +DECLARE_SOA_TABLE_STAGED_VERSIONED(V0MCCores_001, "V0MCCORE", 1, //! debug information + v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis + v0data::PDGCode, v0data::PDGCodeMother, + v0data::PDGCodePositive, v0data::PDGCodeNegative, + v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, + v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, + v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC); + +DECLARE_SOA_TABLE_STAGED_VERSIONED(V0MCCores_002, "V0MCCORE", 2, //! debug information + v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis + v0data::PDGCode, v0data::PDGCodeMother, + v0data::PDGCodePositive, v0data::PDGCodeNegative, + v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, + v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, + v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, + v0data::PxMC, v0data::PyMC, v0data::PzMC, + v0data::RapidityMC, + v0data::NegativePtMC, + v0data::PositivePtMC, + v0data::PtMC); + +// DECLARE_SOA_TABLE(StoredV0MCCores_000, "AOD", "V0MCCORE", //! MC properties of the V0 for posterior analysis +// v0data::PDGCode, v0data::PDGCodeMother, +// v0data::PDGCodePositive, v0data::PDGCodeNegative, +// v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, +// v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, +// v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, +// o2::soa::Marker<1>); + +// DECLARE_SOA_TABLE_VERSIONED(StoredV0MCCores_001, "AOD", "V0MCCORE", 1, //! debug information +// v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis +// v0data::PDGCode, v0data::PDGCodeMother, +// v0data::PDGCodePositive, v0data::PDGCodeNegative, +// v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, +// v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, +// v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, +// o2::soa::Marker<1>); + +// DECLARE_SOA_TABLE_VERSIONED(StoredV0MCCores_002, "AOD", "V0MCCORE", 2, //! debug information +// v0data::ParticleIdMC, //! MC properties of the V0 for posterior analysis +// v0data::PDGCode, v0data::PDGCodeMother, +// v0data::PDGCodePositive, v0data::PDGCodeNegative, +// v0data::IsPhysicalPrimary, v0data::XMC, v0data::YMC, v0data::ZMC, +// v0data::PxPosMC, v0data::PyPosMC, v0data::PzPosMC, +// v0data::PxNegMC, v0data::PyNegMC, v0data::PzNegMC, +// v0data::PxMC, v0data::PyMC, v0data::PzMC, +// o2::soa::Marker<1>); DECLARE_SOA_TABLE(V0MCCollRefs, "AOD", "V0MCCOLLREF", //! refers MC candidate back to proper MC Collision o2::soa::Index<>, v0data::StraMCCollisionId, o2::soa::Marker<2>); @@ -690,14 +830,11 @@ DECLARE_SOA_TABLE(GeK0Short, "AOD", "GeK0Short", v0data::GeneratedK0Short); DECLARE_SOA_TABLE(GeLambda, "AOD", "GeLambda", v0data::GeneratedLambda); DECLARE_SOA_TABLE(GeAntiLambda, "AOD", "GeAntiLambda", v0data::GeneratedAntiLambda); -DECLARE_SOA_TABLE(V0MCMothers, "AOD", "V0MCMOTHER", //! optional table for MC mothers - o2::soa::Index<>, v0data::MotherMCPartId); - -DECLARE_SOA_TABLE(StoredV0MCMothers, "AOD1", "V0MCMOTHER", //! optional table for MC mothers - o2::soa::Index<>, v0data::MotherMCPartId, o2::soa::Marker<1>); +DECLARE_SOA_TABLE_STAGED(V0MCMothers, "V0MCMOTHER", //! optional table for MC mothers + o2::soa::Index<>, v0data::MotherMCPartId); -using V0MCCores = V0MCCores_001; -using StoredV0MCCores = StoredV0MCCores_001; +using V0MCCores = V0MCCores_002; +using StoredV0MCCores = StoredV0MCCores_002; using V0Index = V0Indices::iterator; using V0Core = V0Cores::iterator; @@ -708,6 +845,7 @@ using V0fCDatas = soa::Join; using V0fCData = V0fCDatas::iterator; using V0MCDatas = soa::Join; using V0MCData = V0MCDatas::iterator; +using V0MCCore = V0MCCores::iterator; // definitions of indices for interlink tables namespace v0data @@ -762,6 +900,7 @@ DECLARE_SOA_COLUMN(IsTrueLambda, isTrueLambda, bool); //! PDG DECLARE_SOA_COLUMN(IsTrueAntiLambda, isTrueAntiLambda, bool); //! PDG checked correctly in MC DECLARE_SOA_COLUMN(IsTrueHypertriton, isTrueHypertriton, bool); //! PDG checked correctly in MC DECLARE_SOA_COLUMN(IsTrueAntiHypertriton, isTrueAntiHypertriton, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! physical primary // dE/dx compatibility bools DECLARE_SOA_COLUMN(IsdEdxGamma, isdEdxGamma, bool); //! compatible with dE/dx hypotheses @@ -783,6 +922,7 @@ DECLARE_SOA_TABLE(V0Tags, "AOD", "V0TAGS", v0tag::IsTrueAntiLambda, v0tag::IsTrueHypertriton, v0tag::IsTrueAntiHypertriton, + v0tag::IsPhysicalPrimary, v0tag::IsdEdxGamma, v0tag::IsdEdxK0Short, v0tag::IsdEdxLambda, @@ -860,13 +1000,22 @@ DECLARE_SOA_COLUMN(BachX, bachX, float); //! bachelor track X at min //______________________________________________________ // REGULAR COLUMNS FOR CASCCOVS // Saved from finding: covariance matrix of parent track (on request) -DECLARE_SOA_COLUMN(PositionCovMat, positionCovMat, float[6]); //! covariance matrix elements -DECLARE_SOA_COLUMN(MomentumCovMat, momentumCovMat, float[6]); //! covariance matrix elements +DECLARE_SOA_DYNAMIC_COLUMN(PositionCovMat, positionCovMat, //! for transparent handling + [](const float covMat[21]) -> std::vector { + std::vector posCovMat { covMat[0], covMat[1], covMat[2], covMat[3], covMat[4], covMat[5] }; + return posCovMat; }); +DECLARE_SOA_DYNAMIC_COLUMN(MomentumCovMat, momentumCovMat, //! for transparent handling + [](const float covMat[21]) -> std::vector { + std::vector momCovMat { covMat[9], covMat[13], covMat[14], covMat[18], covMat[19], covMat[20] }; + return momCovMat; }); DECLARE_SOA_COLUMN(KFTrackCovMat, kfTrackCovMat, float[21]); //! covariance matrix elements for KF method (Cascade) DECLARE_SOA_COLUMN(KFTrackCovMatV0, kfTrackCovMatV0, float[21]); //! covariance matrix elements for KF method (V0) DECLARE_SOA_COLUMN(KFTrackCovMatV0DauPos, kfTrackCovMatV0DauPos, float[21]); //! covariance matrix elements for KF method (V0 pos daughter) DECLARE_SOA_COLUMN(KFTrackCovMatV0DauNeg, kfTrackCovMatV0DauNeg, float[21]); //! covariance matrix elements for KF method (V0 neg daughter) +// for CascCovs / TraCascCovs, meant to provide consistent interface everywhere +DECLARE_SOA_COLUMN(CovMat, covMat, float[21]); //! covariance matrix elements + //______________________________________________________ // REGULAR COLUMNS FOR CASCBBS // General cascade properties: position, momentum @@ -947,8 +1096,10 @@ 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}); }); +// 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 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}); }); + [](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)); }); @@ -995,6 +1146,24 @@ DECLARE_SOA_DYNAMIC_COLUMN(BachelorEta, bacheloreta, //! bachelor daughter eta [](float PxPos, float PyPos, float PzPos) -> float { return RecoDecay::eta(std::array{PxPos, PyPos, PzPos}); }); DECLARE_SOA_DYNAMIC_COLUMN(BachelorPhi, bachelorphi, //! bachelor daughter phi [](float PxPos, float PyPos) -> float { return RecoDecay::phi(PxPos, PyPos); }); + +DECLARE_SOA_DYNAMIC_COLUMN(RapidityMC, rapidityMC, //! rapidity (0, 1: Xi; 2, 3: Omega) + [](float PxMC, float PyMC, float PzMC, int value) -> float { + if (value == 0 || value == 1) + return RecoDecay::y(std::array{PxMC, PyMC, PzMC}, o2::constants::physics::MassXiMinus); + if (value == 2 || value == 3) + return RecoDecay::y(std::array{PxMC, PyMC, PzMC}, o2::constants::physics::MassOmegaMinus); + return 0.0f; + }); + +DECLARE_SOA_DYNAMIC_COLUMN(NegativePtMC, negativeptMC, //! negative daughter pT + [](float pxNegMC, float pyNegMC) -> float { return RecoDecay::sqrtSumOfSquares(pxNegMC, pyNegMC); }); +DECLARE_SOA_DYNAMIC_COLUMN(PositivePtMC, positiveptMC, //! positive daughter pT + [](float pxPosMC, float pyPosMC) -> float { return RecoDecay::sqrtSumOfSquares(pxPosMC, pyPosMC); }); +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 //______________________________________________________ @@ -1079,7 +1248,7 @@ DECLARE_SOA_TABLE(StoredCascCores, "AOD", "CASCCORE", //! core information about cascdata::V0Radius, cascdata::CascRadius, cascdata::V0CosPA, - cascdata::CascCosPA, + cascdata::CascCosPA, cascdata::DCAV0ToPV, // Invariant masses @@ -1122,7 +1291,7 @@ DECLARE_SOA_TABLE(StoredKFCascCores, "AOD", "KFCASCCORE", //! cascdata::V0Radius, cascdata::CascRadius, cascdata::V0CosPA, - cascdata::CascCosPA, + cascdata::CascCosPA, cascdata::DCAV0ToPV, // Invariant masses @@ -1160,7 +1329,7 @@ DECLARE_SOA_TABLE(StoredTraCascCores, "AOD", "TRACASCCORE", //! cascdata::V0Radius, cascdata::CascRadius, cascdata::V0CosPA, - cascdata::CascCosPA, + cascdata::CascCosPA, cascdata::DCAV0ToPV, // Invariant masses @@ -1188,7 +1357,12 @@ DECLARE_SOA_TABLE(CascMCCores, "AOD", "CASCMCCORE", //! bachelor-baryon correlat cascdata::PxPosMC, cascdata::PyPosMC, cascdata::PzPosMC, cascdata::PxNegMC, cascdata::PyNegMC, cascdata::PzNegMC, cascdata::PxBachMC, cascdata::PyBachMC, cascdata::PzBachMC, - cascdata::PxMC, cascdata::PyMC, cascdata::PzMC); + cascdata::PxMC, cascdata::PyMC, cascdata::PzMC, + cascdata::RapidityMC, + cascdata::NegativePtMC, + cascdata::PositivePtMC, + cascdata::BachelorPtMC, + cascdata::PtMC); namespace cascdata { @@ -1211,11 +1385,20 @@ DECLARE_SOA_TABLE(CascMCMothers, "AOD", "CASCMCMOTHER", //! optional table for M DECLARE_SOA_TABLE(CascBBs, "AOD", "CASCBB", //! bachelor-baryon correlation variables cascdata::BachBaryonCosPA, cascdata::BachBaryonDCAxyToPV) -DECLARE_SOA_TABLE_FULL(CascCovs, "CascCovs", "AOD", "CASCCOVS", //! - cascdata::PositionCovMat, cascdata::MomentumCovMat); +DECLARE_SOA_TABLE(CascCovs, "AOD", "CASCCOVS", //! + cascdata::CovMat, + cascdata::PositionCovMat, + cascdata::MomentumCovMat, + o2::soa::Marker<1>); + +DECLARE_SOA_TABLE(KFCascCovs, "AOD", "KFCASCCOVS", //! + cascdata::KFTrackCovMat, cascdata::KFTrackCovMatV0, cascdata::KFTrackCovMatV0DauPos, cascdata::KFTrackCovMatV0DauNeg); -DECLARE_SOA_TABLE_FULL(KFCascCovs, "KFCascCovs", "AOD", "KFCASCCOVS", //! - cascdata::KFTrackCovMat, cascdata::KFTrackCovMatV0, cascdata::KFTrackCovMatV0DauPos, cascdata::KFTrackCovMatV0DauNeg); +DECLARE_SOA_TABLE(TraCascCovs, "AOD", "TRACASCCOVS", //! + cascdata::CovMat, + cascdata::PositionCovMat, + 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", //! @@ -1291,6 +1474,8 @@ using CascadesLinked = soa::Join; using CascadeLinked = CascadesLinked::iterator; using KFCascadesLinked = soa::Join; using KFCascadeLinked = KFCascadesLinked::iterator; +using TraCascadesLinked = soa::Join; +using TraCascadeLinked = TraCascadesLinked::iterator; namespace cascdata { @@ -1312,10 +1497,11 @@ namespace casctag DECLARE_SOA_COLUMN(IsInteresting, isInteresting, bool); //! will this be built or not? // MC association bools -DECLARE_SOA_COLUMN(IsTrueXiMinus, isTrueXiMinus, bool); //! PDG checked correctly in MC -DECLARE_SOA_COLUMN(IsTrueXiPlus, isTrueXiPlus, bool); //! PDG checked correctly in MC -DECLARE_SOA_COLUMN(IsTrueOmegaMinus, isTrueOmegaMinus, bool); //! PDG checked correctly in MC -DECLARE_SOA_COLUMN(IsTrueOmegaPlus, isTrueOmegaPlus, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsTrueXiMinus, isTrueXiMinus, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsTrueXiPlus, isTrueXiPlus, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsTrueOmegaMinus, isTrueOmegaMinus, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsTrueOmegaPlus, isTrueOmegaPlus, bool); //! PDG checked correctly in MC +DECLARE_SOA_COLUMN(IsPhysicalPrimary, isPhysicalPrimary, bool); //! physical primary // dE/dx compatibility bools DECLARE_SOA_COLUMN(IsdEdxXiMinus, isdEdxXiMinus, bool); //! compatible with dE/dx hypotheses @@ -1329,6 +1515,7 @@ DECLARE_SOA_TABLE(CascTags, "AOD", "CASCTAGS", casctag::IsTrueXiPlus, casctag::IsTrueOmegaMinus, casctag::IsTrueOmegaPlus, + casctag::IsPhysicalPrimary, casctag::IsdEdxXiMinus, casctag::IsdEdxXiPlus, casctag::IsdEdxOmegaMinus, diff --git a/PWGLF/DataModel/LFhe3HadronTables.h b/PWGLF/DataModel/LFhe3HadronTables.h new file mode 100644 index 00000000000..9074fb8b20c --- /dev/null +++ b/PWGLF/DataModel/LFhe3HadronTables.h @@ -0,0 +1,128 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 LFhe3HadronTables.h +/// \brief Slim tables for he3Hadron +/// + +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" + +#ifndef PWGLF_DATAMODEL_LFHE3HADRONTABLES_H_ +#define PWGLF_DATAMODEL_LFHE3HADRONTABLES_H_ + +namespace o2::aod +{ +namespace he3HadronTablesNS +{ + +DECLARE_SOA_COLUMN(PtHe3, ptHe3, float); +DECLARE_SOA_COLUMN(EtaHe3, etaHe3, float); +DECLARE_SOA_COLUMN(PhiHe3, phiHe3, float); +DECLARE_SOA_COLUMN(PtHad, ptHad, float); +DECLARE_SOA_COLUMN(EtaHad, etaHad, float); +DECLARE_SOA_COLUMN(PhiHad, phiHad, float); + +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(SignalTPCHe3, signalTPCHe3, float); +DECLARE_SOA_COLUMN(InnerParamTPCHe3, innerParamTPCHe3, float); +DECLARE_SOA_COLUMN(SignalTPCHad, signalTPCHad, float); +DECLARE_SOA_COLUMN(InnerParamTPCHad, innerParamTPCHad, float); +DECLARE_SOA_COLUMN(NClsTPCHe3, nClsTPCHe3, uint8_t); +DECLARE_SOA_COLUMN(NSigmaTPCHe3, nSigmaTPCHe3, float); +DECLARE_SOA_COLUMN(NSigmaTPCHad, nSigmaTOFHad, float); +DECLARE_SOA_COLUMN(Chi2TPCHe3, chi2TPCHe3, float); +DECLARE_SOA_COLUMN(Chi2TPCHad, chi2TPCHad, float); +DECLARE_SOA_COLUMN(MassTOFHe3, massTOFHe3, float); +DECLARE_SOA_COLUMN(MassTOFHad, massTOFHad, float); +DECLARE_SOA_COLUMN(PIDtrkHe3, pidTrkHe3, uint32_t); +DECLARE_SOA_COLUMN(PIDtrkHad, pidTrkHad, uint32_t); + +DECLARE_SOA_COLUMN(ItsClusterSizeHe3, itsClusterSizeHe3, uint32_t); +DECLARE_SOA_COLUMN(ItsClusterSizeHad, itsClusterSizeHad, uint32_t); + +DECLARE_SOA_COLUMN(SharedClustersHe3, sharedClustersHe3, uint8_t); +DECLARE_SOA_COLUMN(SharedClustersHad, sharedClustersHad, uint8_t); + +DECLARE_SOA_COLUMN(IsBkgUS, isBkgUS, bool); +DECLARE_SOA_COLUMN(IsBkgEM, isBkgEM, bool); + +DECLARE_SOA_COLUMN(PtMCHe3, ptMCHe3, float); +DECLARE_SOA_COLUMN(EtaMCHe3, etaMCHe3, float); +DECLARE_SOA_COLUMN(PhiMCHe3, phiMCHe3, float); +DECLARE_SOA_COLUMN(PtMCHad, ptMCHad, float); +DECLARE_SOA_COLUMN(EtaMCHad, etaMCHad, float); +DECLARE_SOA_COLUMN(PhiMCHad, phiMCHad, float); +DECLARE_SOA_COLUMN(SignedPtMC, signedPtMC, float); +DECLARE_SOA_COLUMN(MassMC, massMC, float); + +DECLARE_SOA_COLUMN(CollisionId, collisionId, int64_t); +DECLARE_SOA_COLUMN(ZVertex, zVertex, float); +DECLARE_SOA_COLUMN(Multiplicity, multiplicity, uint16_t); +DECLARE_SOA_COLUMN(CentralityFT0C, centFT0C, float); +DECLARE_SOA_COLUMN(MultiplicityFT0C, multiplicityFT0C, float); + +} // namespace he3HadronTablesNS + +DECLARE_SOA_TABLE(he3HadronTable, "AOD", "HE3HADTABLE", + he3HadronTablesNS::PtHe3, + he3HadronTablesNS::EtaHe3, + he3HadronTablesNS::PhiHe3, + he3HadronTablesNS::PtHad, + he3HadronTablesNS::EtaHad, + he3HadronTablesNS::PhiHad, + he3HadronTablesNS::DCAxyHe3, + he3HadronTablesNS::DCAzHe3, + he3HadronTablesNS::DCAxyHad, + he3HadronTablesNS::DCAzHad, + he3HadronTablesNS::SignalTPCHe3, + he3HadronTablesNS::InnerParamTPCHe3, + he3HadronTablesNS::SignalTPCHad, + he3HadronTablesNS::InnerParamTPCHad, + he3HadronTablesNS::NClsTPCHe3, + he3HadronTablesNS::NSigmaTPCHe3, + he3HadronTablesNS::NSigmaTPCHad, + he3HadronTablesNS::Chi2TPCHe3, + he3HadronTablesNS::Chi2TPCHad, + he3HadronTablesNS::MassTOFHe3, + he3HadronTablesNS::MassTOFHad, + he3HadronTablesNS::PIDtrkHe3, + he3HadronTablesNS::PIDtrkHad, + he3HadronTablesNS::ItsClusterSizeHe3, + he3HadronTablesNS::ItsClusterSizeHad, + he3HadronTablesNS::SharedClustersHe3, + he3HadronTablesNS::SharedClustersHad, + he3HadronTablesNS::IsBkgUS, + he3HadronTablesNS::IsBkgEM) +DECLARE_SOA_TABLE(he3HadronTableMC, "AOD", "HE3HADTABLEMC", + he3HadronTablesNS::PtMCHe3, + he3HadronTablesNS::EtaMCHe3, + he3HadronTablesNS::PhiMCHe3, + he3HadronTablesNS::PtMCHad, + he3HadronTablesNS::EtaMCHad, + he3HadronTablesNS::PhiMCHad, + he3HadronTablesNS::SignedPtMC, + he3HadronTablesNS::MassMC) +DECLARE_SOA_TABLE(he3HadronMult, "AOD", "HE3HADMULT", + he3HadronTablesNS::CollisionId, + he3HadronTablesNS::ZVertex, + he3HadronTablesNS::Multiplicity, + he3HadronTablesNS::CentralityFT0C, + he3HadronTablesNS::MultiplicityFT0C) + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_LFHE3HADRONTABLES_H_ diff --git a/PWGLF/DataModel/SPCalibrationTables.h b/PWGLF/DataModel/SPCalibrationTables.h new file mode 100644 index 00000000000..2b417ce8758 --- /dev/null +++ b/PWGLF/DataModel/SPCalibrationTables.h @@ -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 SPCalibrationTables.h +/// +/// author: prottay das 07/09/2024 +/// email: prottay.das@cern.ch + +#ifndef PWGLF_DATAMODEL_SPCALIBRATIONTABLES_H_ +#define PWGLF_DATAMODEL_SPCALIBRATIONTABLES_H_ + +#include + +#include "Common/DataModel/PIDResponse.h" +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Framework/AnalysisDataModel.h" + +namespace o2::aod +{ +namespace spcalibrationtable +{ +DECLARE_SOA_COLUMN(TriggerEventSP, triggereventsp, bool); +DECLARE_SOA_COLUMN(TriggerEventRunNo, triggereventrunno, int); +DECLARE_SOA_COLUMN(Cent, cent, float); +DECLARE_SOA_COLUMN(Vx, vx, float); +DECLARE_SOA_COLUMN(Vy, vy, float); +DECLARE_SOA_COLUMN(Vz, vz, float); +DECLARE_SOA_COLUMN(ZNAC, znaC, float); +DECLARE_SOA_COLUMN(ZNCC, zncC, float); +DECLARE_SOA_COLUMN(ZNAE0, znaE0, float); +DECLARE_SOA_COLUMN(ZNAE1, znaE1, float); +DECLARE_SOA_COLUMN(ZNAE2, znaE2, float); +DECLARE_SOA_COLUMN(ZNAE3, znaE3, float); +DECLARE_SOA_COLUMN(ZNCE0, zncE0, float); +DECLARE_SOA_COLUMN(ZNCE1, zncE1, float); +DECLARE_SOA_COLUMN(ZNCE2, zncE2, float); +DECLARE_SOA_COLUMN(ZNCE3, zncE3, float); +DECLARE_SOA_COLUMN(QXZDCA, qxZDCA, float); +DECLARE_SOA_COLUMN(QXZDCC, qxZDCC, float); +DECLARE_SOA_COLUMN(QYZDCA, qyZDCA, float); +DECLARE_SOA_COLUMN(QYZDCC, qyZDCC, float); +DECLARE_SOA_COLUMN(PsiZDCC, psiZDCC, float); +DECLARE_SOA_COLUMN(PsiZDCA, psiZDCA, float); +} // namespace spcalibrationtable +DECLARE_SOA_TABLE(SPCalibrationTables, "AOD", "SPCALCOLS", + spcalibrationtable::TriggerEventSP, + spcalibrationtable::TriggerEventRunNo, + spcalibrationtable::Cent, + spcalibrationtable::Vx, + spcalibrationtable::Vy, + spcalibrationtable::Vz, + spcalibrationtable::ZNAC, + spcalibrationtable::ZNCC, + spcalibrationtable::ZNAE0, + spcalibrationtable::ZNAE1, + spcalibrationtable::ZNAE2, + spcalibrationtable::ZNAE3, + spcalibrationtable::ZNCE0, + spcalibrationtable::ZNCE1, + spcalibrationtable::ZNCE2, + spcalibrationtable::ZNCE3, + spcalibrationtable::QXZDCA, + spcalibrationtable::QXZDCC, + spcalibrationtable::QYZDCA, + spcalibrationtable::QYZDCC, + spcalibrationtable::PsiZDCC, + spcalibrationtable::PsiZDCA); +using SPCalibrationTable = SPCalibrationTables::iterator; +} // namespace o2::aod +#endif // PWGLF_DATAMODEL_SPCALIBRATIONTABLES_H_ diff --git a/PWGLF/DataModel/V0SelectorTables.h b/PWGLF/DataModel/V0SelectorTables.h new file mode 100644 index 00000000000..1283c754819 --- /dev/null +++ b/PWGLF/DataModel/V0SelectorTables.h @@ -0,0 +1,49 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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_V0SELECTORTABLES_H_ +#define PWGLF_DATAMODEL_V0SELECTORTABLES_H_ + +#include +#include +namespace o2::aod +{ + +namespace v0flags +{ + +enum V0Flags : uint8_t { + FK0S = 0x1, // K0S candidate + FLAMBDA = 0x2, // Lambda candidate + FANTILAMBDA = 0x4, // AntiLambda candidate + FREJECTED = 0x8 // Does not satisfy any of the above, or is randomly rejected +}; + +DECLARE_SOA_COLUMN(SignalFlag, signalFlag, uint8_t); +DECLARE_SOA_DYNAMIC_COLUMN(IsK0SCandidate, isK0SCandidate, //! Flag to check if V0 is a K0S candidate + [](uint8_t flag) -> bool { return flag & o2::aod::v0flags::FK0S; }); +DECLARE_SOA_DYNAMIC_COLUMN(IsLambdaCandidate, isLambdaCandidate, //! Flag to check if V0 is a Lambda candidate + [](uint8_t flag) -> bool { return flag & o2::aod::v0flags::FLAMBDA; }); +DECLARE_SOA_DYNAMIC_COLUMN(IsAntiLambdaCandidate, isAntiLambdaCandidate, //! Flag to check if V0 is a AntiLambda candidate + [](uint8_t flag) -> bool { return flag & o2::aod::v0flags::FANTILAMBDA; }); +DECLARE_SOA_DYNAMIC_COLUMN(IsRejectedCandidate, isRejectedCandidate, //! Flag to check if V0 is rejected + [](uint8_t flag) -> bool { return flag & o2::aod::v0flags::FREJECTED; }); +} // namespace v0flags + +DECLARE_SOA_TABLE_STAGED(V0SignalFlags, "V0SIGNALFLAGS", + v0flags::SignalFlag, + v0flags::IsK0SCandidate, + v0flags::IsLambdaCandidate, + v0flags::IsAntiLambdaCandidate, + v0flags::IsRejectedCandidate); + +} // namespace o2::aod + +#endif // PWGLF_DATAMODEL_V0SELECTORTABLES_H_ diff --git a/PWGLF/DataModel/Vtx3BodyTables.h b/PWGLF/DataModel/Vtx3BodyTables.h index 0e74ec86372..51e155206bd 100644 --- a/PWGLF/DataModel/Vtx3BodyTables.h +++ b/PWGLF/DataModel/Vtx3BodyTables.h @@ -43,6 +43,9 @@ 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 @@ -132,6 +135,7 @@ DECLARE_SOA_TABLE_FULL(StoredVtx3BodyDatas, "Vtx3BodyDatas", "AOD", "Vtx3BodyDAT 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, @@ -205,34 +209,29 @@ namespace hyp3body { // collision DECLARE_SOA_COLUMN(Centrality, centrality, float); //! centrality -DECLARE_SOA_COLUMN(XPV, xpv, float); //! primary vertex X -DECLARE_SOA_COLUMN(YPV, ypv, float); //! primary vertex Y -DECLARE_SOA_COLUMN(ZPV, zpv, float); //! primary vertex Z // 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(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(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(PProton, pProton, float); //! p of the proton daughter -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(PPion, pPion, float); //! p of the pion 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(PBachelor, pBachelor, float); //! p of the bachelor 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(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 @@ -246,15 +245,19 @@ DECLARE_SOA_COLUMN(TPCNSigmaPion, tpcNSigmaPion, float); //! nsigma of T 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(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 +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 @@ -265,50 +268,50 @@ DECLARE_SOA_COLUMN(SurvivedEventSelection, survivedEventSelection, bool); // boo DECLARE_SOA_TABLE(Hyp3BodyCands, "AOD", "HYP3BODYCANDS", o2::soa::Index<>, hyp3body::Centrality, - hyp3body::XPV, hyp3body::YPV, hyp3body::ZPV, // secondary vertex and reconstruced candidate hyp3body::IsMatter, hyp3body::M, hyp3body::P, hyp3body::Pt, hyp3body::Ct, - hyp3body::X, hyp3body::Y, hyp3body::Z, hyp3body::CosPA, hyp3body::DCADaughters, hyp3body::DCACandToPV, + hyp3body::VtxRadius, // daughter tracks - hyp3body::PProton, hyp3body::PtProton, hyp3body::EtaProton, hyp3body::PhiProton, - hyp3body::PPion, hyp3body::PtPion, hyp3body::EtaPion, hyp3body::PhiPion, - hyp3body::PBachelor, hyp3body::PtBachelor, hyp3body::EtaBachelor, hyp3body::PhiBachelor, + 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", o2::soa::Index<>, hyp3body::Centrality, - hyp3body::XPV, hyp3body::YPV, hyp3body::ZPV, // secondary vertex and reconstruced candidate hyp3body::IsMatter, hyp3body::M, hyp3body::P, hyp3body::Pt, hyp3body::Ct, - hyp3body::X, hyp3body::Y, hyp3body::Z, hyp3body::CosPA, hyp3body::DCADaughters, hyp3body::DCACandToPV, + hyp3body::VtxRadius, // daughter tracks - hyp3body::PProton, hyp3body::PtProton, hyp3body::EtaProton, hyp3body::PhiProton, - hyp3body::PPion, hyp3body::PtPion, hyp3body::EtaPion, hyp3body::PhiPion, - hyp3body::PBachelor, hyp3body::PtBachelor, hyp3body::EtaBachelor, hyp3body::PhiBachelor, + 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, @@ -316,6 +319,7 @@ DECLARE_SOA_TABLE(MCHyp3BodyCands, "AOD", "MCHYP3BODYCANDS", hyp3body::GenCt, hyp3body::GenPhi, hyp3body::GenEta, + hyp3body::GenRapidity, hyp3body::IsSignal, hyp3body::IsReco, hyp3body::PdgCode, @@ -327,18 +331,25 @@ DECLARE_SOA_TABLE(MCHyp3BodyCands, "AOD", "MCHYP3BODYCANDS", 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(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(Sign, sign, float); //! candidate sign +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(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) @@ -346,87 +357,236 @@ DECLARE_SOA_COLUMN(DecayLXYKF, decaylxykf, float); //! 3 body vtx de 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(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(DCAxyTrack0ToTrack1, dcaxytrack0totrack1kf, float); //! DCAxy of proton prong to pion from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack0ToTrack2, dcaxytrack0totrack2kf, float); //! DCAxy of proton prong to deuteron from KFParticle -DECLARE_SOA_COLUMN(DCAxyTrack1ToTrack2, 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(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 } // namespace kfvtx3body -DECLARE_SOA_TABLE(StoredKFVtx3BodyDatas, "AOD", "KFVTX3BODYDATA", //! - // indices +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 + 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::DCAxyTrack0ToTrack1, kfvtx3body::DCAxyTrack0ToTrack2, kfvtx3body::DCAxyTrack1ToTrack2, + kfvtx3body::DCAxyTrack0ToTrack1KF, kfvtx3body::DCAxyTrack0ToTrack2KF, kfvtx3body::DCAxyTrack1ToTrack2KF, kfvtx3body::DCAVtxDaughtersKF, - vtx3body::DCATrack0ToPV, vtx3body::DCATrack1ToPV, vtx3body::DCATrack2ToPV, + kfvtx3body::DCAxyTrackPosToPV, kfvtx3body::DCAxyTrackNegToPV, kfvtx3body::DCAxyTrackBachToPV, + kfvtx3body::DCATrackPosToPV, kfvtx3body::DCATrackNegToPV, kfvtx3body::DCATrackBachToPV, kfvtx3body::Track0Sign, kfvtx3body::Track1Sign, kfvtx3body::Track2Sign, // track sing: proton, pion, deuteron - vtx3body::TOFNSigmaBachDe, - - // dynamic columns - vtx3body::VtxRadius, - vtx3body::DistOverTotMom, - vtx3body::VtxCosPA, - vtx3body::DCAVtxToPV, - - // Longitudinal - vtx3body::YHypertriton, - vtx3body::Eta, - vtx3body::Phi, - vtx3body::Track0Pt, // proton pT - vtx3body::Track0Eta, // proton eta - vtx3body::Track0Phi, // proton phi - vtx3body::Track1Pt, // pion pT - vtx3body::Track1Eta, // pion eta - vtx3body::Track1Phi, // pion phi - vtx3body::Track2Pt, // deuteron pT - vtx3body::Track2Eta, // deuteron eta - vtx3body::Track2Phi); // deuteron phi - -using StoredKFVtx3BodyData = StoredKFVtx3BodyDatas::iterator; + 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(StoredKFVtx3BodyData, storedkfvtx3BodyData); //! Index to KFVtx3BodyData entry +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", + o2::soa::Index<>, + // hypertriton candidate + kfvtx3body::Mass, + 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; + +// MC candidate table for analysis +DECLARE_SOA_TABLE(McKFVtx3BodyDatas, "AOD", "MCKF3BODYDATAS", + o2::soa::Index<>, + // 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, + + // 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 + +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 90b4b362d81..30053e145a6 100644 --- a/PWGLF/DataModel/cascqaanalysis.h +++ b/PWGLF/DataModel/cascqaanalysis.h @@ -25,6 +25,8 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "TRandom.h" +#include "Math/Vector4D.h" +#include "Math/Boost.h" namespace o2::aod { @@ -39,6 +41,8 @@ enum EvFlags : uint8_t { }; DECLARE_SOA_COLUMN(CollisionZ, zcoll, float); +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); DECLARE_SOA_COLUMN(MultFT0M, multFT0M, float); DECLARE_SOA_COLUMN(MultFV0A, multFV0A, float); DECLARE_SOA_COLUMN(Sign, sign, int); @@ -111,7 +115,7 @@ namespace cascadesflow DECLARE_SOA_COLUMN(CentFT0A, centFT0A, float); DECLARE_SOA_COLUMN(CentFT0C, centFT0C, float); DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); -DECLARE_SOA_COLUMN(Sign, sign, int); +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); @@ -122,11 +126,17 @@ DECLARE_SOA_COLUMN(V2CSP, v2CSP, float); DECLARE_SOA_COLUMN(PsiT0C, psiT0C, float); DECLARE_SOA_COLUMN(BDTResponseXi, bdtResponseXi, float); DECLARE_SOA_COLUMN(BDTResponseOmega, bdtResponseOmega, float); +DECLARE_SOA_COLUMN(CosThetaStarLambdaFromOmega, cosThetaStarLambdaFromOmega, float); +DECLARE_SOA_COLUMN(CosThetaStarLambdaFromXi, cosThetaStarLambdaFromXi, float); +DECLARE_SOA_COLUMN(CosThetaStarProton, cosThetaStarProton, float); } // namespace cascadesflow DECLARE_SOA_TABLE(MyCascades, "AOD", "MYCASCADES", o2::soa::Index<>, - mycascades::CollisionZ, mycascades::MultFT0M, mycascades::MultFV0A, mycascades::Sign, mycascades::Pt, mycascades::RapXi, mycascades::RapOmega, mycascades::Eta, mycascades::MassXi, mycascades::MassOmega, mycascades::MassLambdaDau, mycascades::CascRadius, mycascades::V0Radius, + mycascades::CollisionZ, + mycascades::CentFT0M, mycascades::CentFV0A, + mycascades::MultFT0M, mycascades::MultFV0A, + mycascades::Sign, mycascades::Pt, mycascades::RapXi, mycascades::RapOmega, mycascades::Eta, mycascades::MassXi, mycascades::MassOmega, mycascades::MassLambdaDau, mycascades::CascRadius, mycascades::V0Radius, mycascades::CascCosPA, mycascades::V0CosPA, mycascades::DCAPosToPV, mycascades::DCANegToPV, mycascades::DCABachToPV, mycascades::DCACascDaughters, mycascades::DCAV0Daughters, mycascades::DCAV0ToPV, mycascades::PosEta, mycascades::NegEta, mycascades::BachEta, mycascades::PosITSHits, mycascades::NegITSHits, mycascades::BachITSHits, @@ -150,7 +160,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::Sign, cascadesflow::Pt, cascadesflow::Eta, cascadesflow::Phi, cascadesflow::MassXi, cascadesflow::MassOmega, cascadesflow::V2CSP, cascadesflow::V2CEP, cascadesflow::PsiT0C, cascadesflow::BDTResponseXi, cascadesflow::BDTResponseOmega); + cascadesflow::CentFT0C, 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); namespace myMCcascades { @@ -171,6 +181,9 @@ DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(IsPrimary, isPrimary, bool); DECLARE_SOA_COLUMN(NAssocColl, nAssocColl, int); // Number of reconstructed collisions assoceated to the generated one of this cascade DECLARE_SOA_COLUMN(NChInFT0M, nChInFT0M, float); // Number of charged particles in FT0M acceptance +DECLARE_SOA_COLUMN(NChInFV0A, nChInFV0A, float); // Number of charged particles in FV0A acceptance +DECLARE_SOA_COLUMN(CentFT0M, centFT0M, float); // centr. (mult.) % FT0M +DECLARE_SOA_COLUMN(CentFV0A, centFV0A, float); // centr. (mult.) % FV0A DECLARE_SOA_COLUMN(AssCollisionTypeFilterBitMask, assCollisionTypeFilterBitMask, uint8_t); DECLARE_SOA_COLUMN(McCollisionTypeFilterBitMask, mcCollisionTypeFilterBitMask, uint8_t); @@ -192,7 +205,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(IsINELgt1, isINELgt1, //! True if the Event belongs t DECLARE_SOA_TABLE(MyMCCascades, "AOD", "MYMCCASCADES", o2::soa::Index<>, myMCcascades::CollisionZ, myMCcascades::Sign, myMCcascades::PdgCode, myMCcascades::Y, myMCcascades::Eta, myMCcascades::Phi, myMCcascades::Pt, - myMCcascades::IsPrimary, myMCcascades::NAssocColl, myMCcascades::NChInFT0M, + myMCcascades::IsPrimary, myMCcascades::NAssocColl, + myMCcascades::NChInFT0M, myMCcascades::NChInFV0A, + myMCcascades::CentFT0M, myMCcascades::CentFV0A, myMCcascades::AssCollisionTypeFilterBitMask, myMCcascades::McCollisionTypeFilterBitMask, myMCcascades::IsINELassoc, diff --git a/PWGLF/DataModel/pidTOFGeneric.h b/PWGLF/DataModel/pidTOFGeneric.h new file mode 100644 index 00000000000..b43d4ecc9ff --- /dev/null +++ b/PWGLF/DataModel/pidTOFGeneric.h @@ -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. + +#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 00b9e60ee26..d6cf346b862 100644 --- a/PWGLF/DataModel/spectraTOF.h +++ b/PWGLF/DataModel/spectraTOF.h @@ -398,11 +398,11 @@ DECLARE_SOA_DYNAMIC_COLUMN(TRDSignal, trdSignal, //! Dummy [](float /*v*/) -> float { return 0.f; }); DECLARE_SOA_DYNAMIC_COLUMN(P, p, [](float signedpt, float eta) -> float { return std::abs(signedpt) * cosh(eta); }); DECLARE_SOA_DYNAMIC_COLUMN(TrackType, trackType, [](float /*v*/) -> uint8_t { return o2::aod::track::TrackTypeEnum::Track; }); -DECLARE_SOA_COLUMN(IsGlobalTrack, isGlobalTrack, bool); // if a track passed the isGlobalTrack requirement -DECLARE_SOA_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, bool); // if a track passed the isGlobalTrackWoDCA requirement -DECLARE_SOA_DYNAMIC_COLUMN(Flags, flags, [](float /*v*/) -> uint32_t { return 0; }); // Dummy +DECLARE_SOA_COLUMN(IsGlobalTrack, isGlobalTrack, bool); // if a track passed the isGlobalTrack requirement +DECLARE_SOA_COLUMN(IsGlobalTrackWoDCA, isGlobalTrackWoDCA, bool); // if a track passed the isGlobalTrackWoDCA requirement +DECLARE_SOA_DYNAMIC_COLUMN(Flags, flags, [](float /*v*/) -> uint32_t { return 0; }); // Dummy DECLARE_SOA_DYNAMIC_COLUMN(TRDPattern, trdPattern, [](float /*v*/) -> uint8_t { return 0; }); // Dummy -DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! Track rapidity, computed under the mass assumption given as input +DECLARE_SOA_DYNAMIC_COLUMN(Rapidity, rapidity, //! Track rapidity, computed under the mass assumption given as input [](float signedPt, float eta, float mass) -> float { const auto pt = std::abs(signedPt); const auto p = std::abs(signedPt) * cosh(eta); diff --git a/PWGLF/DataModel/v0qaanalysis.h b/PWGLF/DataModel/v0qaanalysis.h index 05c90791bde..9e4efd7c3c6 100644 --- a/PWGLF/DataModel/v0qaanalysis.h +++ b/PWGLF/DataModel/v0qaanalysis.h @@ -58,6 +58,8 @@ DECLARE_SOA_COLUMN(IsPhysicalPrimary, isphysprimary, bool); DECLARE_SOA_COLUMN(MultFT0M, multft0m, float); DECLARE_SOA_COLUMN(MultFV0A, multfv0a, float); DECLARE_SOA_COLUMN(EvFlag, evflag, int); +DECLARE_SOA_COLUMN(Alpha, alpha, float); +DECLARE_SOA_COLUMN(QtArm, qtarm, float); } // namespace myv0candidates @@ -73,7 +75,7 @@ DECLARE_SOA_TABLE(MyV0Candidates, "AOD", "MYV0CANDIDATES", o2::soa::Index<>, myv0candidates::PosHasTOF, myv0candidates::NegHasTOF, myv0candidates::PDGCode, myv0candidates::IsPhysicalPrimary, myv0candidates::MultFT0M, myv0candidates::MultFV0A, - myv0candidates::EvFlag); + myv0candidates::EvFlag, myv0candidates::Alpha, myv0candidates::QtArm); } // namespace o2::aod diff --git a/PWGLF/TableProducer/Common/CMakeLists.txt b/PWGLF/TableProducer/Common/CMakeLists.txt index a3c26273a81..e68b511978d 100644 --- a/PWGLF/TableProducer/Common/CMakeLists.txt +++ b/PWGLF/TableProducer/Common/CMakeLists.txt @@ -15,6 +15,11 @@ o2physics_add_dpl_workflow(epvector PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(spvector + SOURCES spvector.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(tpcpid SOURCES lfTPCPID.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -28,4 +33,4 @@ o2physics_add_dpl_workflow(zdcsp o2physics_add_dpl_workflow(mc-centrality SOURCES mcCentrality.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file + COMPONENT_NAME Analysis) diff --git a/PWGLF/TableProducer/Common/epvector.cxx b/PWGLF/TableProducer/Common/epvector.cxx index 25823ef6edd..f5c2aad66b9 100644 --- a/PWGLF/TableProducer/Common/epvector.cxx +++ b/PWGLF/TableProducer/Common/epvector.cxx @@ -108,6 +108,8 @@ 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}; + const AxisSpec centAxis{configAxisCentrality, "V0M (%)"}; // AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; AxisSpec multiplicity = {5000, -500, 500, "TPC Multiplicity"}; @@ -117,9 +119,12 @@ struct epvector { AxisSpec qyFT0Axis = {80000, -10000.0, 10000.0, "Qy"}; AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; AxisSpec vzAxis = {400, -20, 20, "vz"}; - AxisSpec resAxis = {400, -2, 2, "vz"}; + AxisSpec resAxis = {200, -2, 2, "Resv2"}; + AxisSpec resAxisSP = {800, -80, 80, "ResSP"}; + AxisSpec qAxis = {100, 0, 10, "Q axis"}; AxisSpec shiftAxis = {10, 0, 10, "shift"}; AxisSpec basisAxis = {2, 0, 2, "basis"}; + AxisSpec occupancyAxis = {occupancyBinning, "occupancy"}; histos.add("hCentrality", "hCentrality", kTH1F, {{8, 0, 80.0}}); histos.add("Vz", "Vz", kTH1F, {{400, -20.0, 20.0}}); @@ -139,9 +144,26 @@ struct epvector { histos.add("QxTPCR", "QxTPCR", kTH2F, {centAxis, multiplicity}); histos.add("QyTPCR", "QyTPCR", kTH2F, {centAxis, multiplicity}); histos.add("PsiTPCR", "PsiTPCR", kTH2F, {centAxis, phiAxis}); - histos.add("ResFT0CTPC", "ResFT0CTPC", kTH2F, {centAxis, resAxis}); - histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH2F, {centAxis, resAxis}); - histos.add("ResFT0ATPC", "ResFT0ATPC", kTH2F, {centAxis, resAxis}); + + histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH3F, {centAxis, resAxis, occupancyAxis}); + histos.add("ResFT0CTPC", "ResFT0CTPC", kTH3F, {centAxis, resAxis, occupancyAxis}); + histos.add("ResFT0ATPC", "ResFT0ATPC", kTH3F, {centAxis, resAxis, occupancyAxis}); + histos.add("ResFT0CTPCL", "ResFT0CTPCL", kTH3F, {centAxis, resAxis, occupancyAxis}); + histos.add("ResFT0CTPCR", "ResFT0CTPCR", kTH3F, {centAxis, resAxis, occupancyAxis}); + histos.add("ResTPCRTPCL", "ResTPCRTPCL", kTH3F, {centAxis, resAxis, occupancyAxis}); + + histos.add("ResFT0CFT0ASP", "ResFT0CFT0ASP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + histos.add("ResFT0CTPCSP", "ResFT0CTPCSP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + histos.add("ResFT0ATPCSP", "ResFT0ATPCSP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + histos.add("ResFT0CTPCLSP", "ResFT0CTPCLSP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + histos.add("ResFT0CTPCRSP", "ResFT0CTPCRSP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + histos.add("ResTPCRTPCLSP", "ResTPCRTPCLSP", kTH3F, {centAxis, resAxisSP, occupancyAxis}); + + histos.add("QFT0C", "QFT0C", kTH3F, {centAxis, qAxis, occupancyAxis}); + histos.add("QFT0A", "QFT0A", kTH3F, {centAxis, qAxis, occupancyAxis}); + histos.add("QTPCL", "QTPCL", kTH3F, {centAxis, qAxis, occupancyAxis}); + histos.add("QTPCR", "QTPCR", kTH3F, {centAxis, qAxis, occupancyAxis}); + histos.add("QTPC", "QTPC", kTH3F, {centAxis, qAxis, occupancyAxis}); histos.add("ShiftFT0C", "ShiftFT0C", kTProfile3D, {centAxis, basisAxis, shiftAxis}); @@ -266,7 +288,7 @@ struct epvector { if (useGainCallib && (currentRunNumber != lastRunNumber)) { gainprofile = ccdb->getForTimeStamp(ConfGainPath.value, bc.timestamp()); } - + int occupancy = coll.trackOccupancyInTimeRange(); histos.fill(HIST("hCentrality"), centrality); histos.fill(HIST("Vz"), vz); @@ -302,7 +324,7 @@ struct epvector { } for (auto& trk : tracks) { - if (!selectionTrack(trk) || abs(trk.eta()) > 0.8 || trk.pt() > cfgCutPTMax || abs(trk.eta()) < cfgMinEta) { + 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()); @@ -365,9 +387,31 @@ struct epvector { histos.fill(HIST("QyTPCR"), centrality, qyTPCR); histos.fill(HIST("PsiTPCR"), centrality, psiTPCR); - histos.fill(HIST("ResFT0CTPC"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPC))); - histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(2.0 * (psiFT0C - psiFT0A))); - histos.fill(HIST("ResFT0ATPC"), centrality, TMath::Cos(2.0 * (psiTPC - psiFT0A))); + 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); + + double qFT0Cmag = TMath::Sqrt(qxFT0C * qxFT0C + qyFT0C * qyFT0C); + double qFT0Amag = TMath::Sqrt(qxFT0A * qxFT0A + qyFT0A * qyFT0A); + double qTPCmag = TMath::Sqrt(qxTPC * qxTPC + qyTPC * qyTPC); + double qTPCLmag = TMath::Sqrt(qxTPCL * qxTPCL + qyTPCL * qyTPCL); + double qTPCRmag = TMath::Sqrt(qxTPCR * qxTPCR + qyTPCR * qyTPCR); + + histos.fill(HIST("QTPC"), centrality, qTPCmag, occupancy); + histos.fill(HIST("QTPCL"), centrality, qTPCLmag, occupancy); + histos.fill(HIST("QTPCR"), centrality, qTPCRmag, occupancy); + 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); for (int ishift = 1; ishift <= 10; ishift++) { histos.fill(HIST("ShiftFT0C"), centrality, 0.5, ishift - 0.5, TMath::Sin(ishift * 2.0 * psiFT0C)); diff --git a/PWGLF/TableProducer/Common/spvector.cxx b/PWGLF/TableProducer/Common/spvector.cxx new file mode 100644 index 00000000000..7afa0a23c20 --- /dev/null +++ b/PWGLF/TableProducer/Common/spvector.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. +// +// \author: prottay das 07/09/2024 +// \email: prottay.das@cern.ch + +// C++/ROOT includes. +#include +#include +#include +#include +#include +#include +#include +#include +#include "Math/Vector4D.h" +#include "TRandom3.h" +#include "TF1.h" + +// 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 "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/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 "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DetectorsBase/GeometryManager.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/ASoAHelpers.h" +#include "ReconstructionDataFormats/Track.h" +#include "PWGLF/DataModel/SPCalibrationTables.h" +// #include "SPCalibrationTableswrite.h" + +// o2 includes. +#include "CCDB/CcdbApi.h" +#include "CCDB/BasicCCDBManager.h" +#include "DetectorsCommonDataFormats/AlignParam.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; + +using BCsRun3 = soa::Join; + +struct spvector { + + Produces spcalibrationtable; + + // Configurables. + 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; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + 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 cfgCutPT{"cfgCutPT", 0.15, "PT cut on daughter track"}; + Configurable cfgCutPTMax{"cfgCutPTMax", 3.0, "Max PT cut on daughter track"}; + Configurable cfgCutEta{"cfgCutEta", 0.8, "Eta cut on daughter track"}; + Configurable cfgMinEta{"cfgMinEta", 0.1, "Min Eta cut on daughter track"}; + Configurable cfgCutDCAxy{"cfgCutDCAxy", 2.0f, "DCAxy range for tracks"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 2.0f, "DCAz range for tracks"}; + + 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 ZDCgainNbins{"ZDCgainNbins", 500, "Number of bins in Gaineq histograms"}; + // Configurable lbinZDCgain{"lbinZDCgain", 0.0, "lower bin value in Gaineq histograms"}; + // Configurable hbinZDCgain{"hbinZDCgain", 1000.0, "higher bin value in Gaineq 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 QA{"QA", false, "QA histograms"}; + Configurable ispolarization{"ispolarization", false, "Flag to check polarization"}; + Configurable finecorrection{"finecorrection", false, "Flag to check fine correction"}; + Configurable rejbadevent{"rejbadevent", true, "Flag to check bad events"}; + Configurable rejbadeventcent{"rejbadeventcent", true, "Flag to check bad events for cent"}; + Configurable rejbadeventvx{"rejbadeventvx", true, "Flag to check bad events for vx"}; + Configurable rejbadeventvy{"rejbadeventvy", true, "Flag to check bad events for vy"}; + Configurable rejbadeventvz{"rejbadeventvz", true, "Flag to check bad events for vz"}; + Configurable usesparse{"usesparse", false, "flag to use sparse histogram"}; + Configurable usenormqn{"usenormqn", true, "flag to use normalized qs"}; + Configurable refsys{"refsys", true, "flag to use own reference system"}; + Configurable followpub{"followpub", true, "flag to use alphaZDC"}; + Configurable useGainCallib{"useGainCallib", false, "use gain calibration"}; + Configurable useRecentereSp{"useRecentereSp", false, "use Recentering with Sparse or THn"}; + Configurable useRecenterefineSp{"useRecenterefineSp", false, "use fine Recentering with Sparse or THn"}; + Configurable useRecenteresqSp{"useRecenteresqSp", false, "use Recenteringsq with Sparse or THn"}; + Configurable recwitherror{"recwitherror", false, "use Recentering with error"}; + Configurable recfinewitherror{"recfinewitherror", false, "use Recentering fine with error"}; + Configurable ConfGainPath{"ConfGainPath", "Users/p/prottay/My/Object/NewPbPbpass4_10092024/gaincallib", "Path to gain calibration"}; + Configurable ConfRecentereSp{"ConfRecentereSp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for recentere"}; + Configurable ConfRecenterecentSp{"ConfRecenterecentSp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for cent recentere"}; + Configurable ConfRecenterevxSp{"ConfRecenterevxSp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vx recentere"}; + Configurable ConfRecenterevySp{"ConfRecenterevySp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vy recentere"}; + Configurable ConfRecenterevzSp{"ConfRecenterevzSp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for vz recentere"}; + Configurable ConfRecenteresqSp{"ConfRecenteresqSp", "Users/p/prottay/My/Object/Testingwithsparse/NewPbPbpass4_17092024/recenter", "Sparse or THn Path for recenteresq"}; + + // Event selection cuts - Alex + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + TF1* fMultCutLow = nullptr; + TF1* fMultCutHigh = nullptr; + TF1* fMultMultPVCut = nullptr; + + int mRunNumber{-1}; + + template + bool eventSelected(TCollision collision, const double& centrality) + { + auto multNTracksPV = collision.multNTracksPV(); + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) + return 0; + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) + return 0; + + return 1; + } + + void initCCDB(BCsRun3::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + } + + void init(o2::framework::InitContext&) + { + + // const AxisSpec centAxis{configAxisCentrality, "V0M (%)"}; + // AxisSpec amplitudeZDC = {configAxisZDCgain, "ZDC amplitude"}; + // AxisSpec amplitudeZDC = {ZDCgainNbins, lbinZDCgain, hbinZDCgain, "ZDC amplitude"}; + 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"}; + + histos.add("hCentrality", "hCentrality", kTH1F, {{centfineAxis}}); + histos.add("hpQxZDCAC", "hpQxZDCAC", kTProfile, {centfineAxis}); + histos.add("hpQyZDCAC", "hpQyZDCAC", kTProfile, {centfineAxis}); + histos.add("hpQxZDCAQyZDCC", "hpQxZDCAQyZDCC", kTProfile, {centfineAxis}); + histos.add("hpQxZDCCQyZDCA", "hpQxZDCCQyZDCA", kTProfile, {centfineAxis}); + + if (!ispolarization) { + if (usesparse == 1) { + histos.add("hsQxZDCA", "hsQxZDCA", kTHnSparseF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hsQyZDCA", "hsQyZDCA", kTHnSparseF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hsQxZDCC", "hsQxZDCC", kTHnSparseF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hsQyZDCC", "hsQyZDCC", kTHnSparseF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + } else { + histos.add("hnQxZDCA", "hnQxZDCA", kTHnF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hnQyZDCA", "hnQyZDCA", kTHnF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hnQxZDCC", "hnQxZDCC", kTHnF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + histos.add("hnQyZDCC", "hnQyZDCC", kTHnF, {{centAxis}, {vxAxis}, {vyAxis}, {vzAxis}, {qxZDCAxis}}); + + if (finecorrection) { + histos.add("hcentQxZDCA", "hcentQxZDCA", kTH2F, {{centfineAxis}, {qxZDCAxis}}); + histos.add("hcentQyZDCA", "hcentQyZDCA", kTH2F, {{centfineAxis}, {qxZDCAxis}}); + histos.add("hcentQxZDCC", "hcentQxZDCC", kTH2F, {{centfineAxis}, {qxZDCAxis}}); + histos.add("hcentQyZDCC", "hcentQyZDCC", kTH2F, {{centfineAxis}, {qxZDCAxis}}); + + histos.add("hvxQxZDCA", "hvxQxZDCA", kTH2F, {{vxfineAxis}, {qxZDCAxis}}); + histos.add("hvxQyZDCA", "hvxQyZDCA", kTH2F, {{vxfineAxis}, {qxZDCAxis}}); + histos.add("hvxQxZDCC", "hvxQxZDCC", kTH2F, {{vxfineAxis}, {qxZDCAxis}}); + histos.add("hvxQyZDCC", "hvxQyZDCC", kTH2F, {{vxfineAxis}, {qxZDCAxis}}); + + histos.add("hvyQxZDCA", "hvyQxZDCA", kTH2F, {{vyfineAxis}, {qxZDCAxis}}); + histos.add("hvyQyZDCA", "hvyQyZDCA", kTH2F, {{vyfineAxis}, {qxZDCAxis}}); + histos.add("hvyQxZDCC", "hvyQxZDCC", kTH2F, {{vyfineAxis}, {qxZDCAxis}}); + histos.add("hvyQyZDCC", "hvyQyZDCC", kTH2F, {{vyfineAxis}, {qxZDCAxis}}); + + histos.add("hvzQxZDCA", "hvzQxZDCA", kTH2F, {{vzfineAxis}, {qxZDCAxis}}); + histos.add("hvzQyZDCA", "hvzQyZDCA", kTH2F, {{vzfineAxis}, {qxZDCAxis}}); + histos.add("hvzQxZDCC", "hvzQxZDCC", kTH2F, {{vzfineAxis}, {qxZDCAxis}}); + histos.add("hvzQyZDCC", "hvzQyZDCC", kTH2F, {{vzfineAxis}, {qxZDCAxis}}); + } + } + } + + histos.add("PsiZDCC", "PsiZDCC", kTH2F, {centfineAxis, phiAxis}); + histos.add("PsiZDCA", "PsiZDCA", kTH2F, {centfineAxis, phiAxis}); + // histos.add("ZDCAmp", "ZDCAmp", kTProfile3D, {channelZDCAxis, vzfineAxis, centfineAxis}); + histos.add("ZDCAmp", "ZDCAmp", kTProfile2D, {channelZDCAxis, vzfineAxis}); + histos.add("ZDCAmpCommon", "ZDCAmpCommon", kTProfile2D, {{2, 0.0, 2.0}, vzfineAxis}); + // histos.add("ZDCAmpCommon", "ZDCAmpCommon", kTProfile3D, {{2,0.0,2.0}, vzfineAxis, centfineAxis}); + + if (QA) { + histos.add("Vz", "Vz", kTH1F, {vzfineAxis}); + histos.add("hpCosPsiAPsiC", "hpCosPsiAPsiC", kTProfile, {centfineAxis}); + histos.add("hpSinPsiAPsiC", "hpSinPsiAPsiC", kTProfile, {centfineAxis}); + } + // histos.add("hZDCAmp", "hZDCAmp", kTHnF, {channelZDCAxis, vzAxis, centfineAxis, {1000, 0, 1000}}); + + // Event selection cut additional - Alex + 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); + + 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()); + } + + int currentRunNumber = -999; + int lastRunNumber = -999; + // TH3D* gainprofile; + TH2D* gainprofile; + THnF* hrecentereSp; + TH2F* hrecenterecentSp; + TH2F* hrecenterevxSp; + TH2F* hrecenterevySp; + TH2F* hrecenterevzSp; + THnF* hrecenteresqSp; + + // 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); + + using MyCollisions = soa::Join; + // using MyTracks = soa::Filtered>; + + Preslice zdcPerCollision = aod::collision::bcId; + + void process(MyCollisions::iterator const& collision, aod::FT0s const& /*ft0s*/, aod::FV0As const& /*fv0s*/, BCsRun3 const& bcs, aod::Zdcs const&) + { + + auto centrality = collision.centFT0C(); + bool triggerevent = false; + + if (bcs.size() != 0) { + gRandom->SetSeed(bcs.iteratorAt(0).globalBC()); + } + + currentRunNumber = collision.foundBC_as().runNumber(); + auto vz = collision.posZ(); + auto vx = collision.posX(); + auto vy = collision.posY(); + + double psiZDCC = -99; + double psiZDCA = -99; + auto qxZDCA = 0.0; + auto qxZDCC = 0.0; + auto qyZDCA = 0.0; + auto qyZDCC = 0.0; + auto sumA = 0.0; + auto sumC = 0.0; + + auto bc = collision.foundBC_as(); + + if (!bc.has_zdc()) { + triggerevent = false; + spcalibrationtable(triggerevent, currentRunNumber, centrality, vx, vy, vz, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, qxZDCA, qxZDCC, qyZDCA, qyZDCC, psiZDCC, psiZDCA); + return; + } + + auto zdc = bc.zdc(); + auto zncEnergy = zdc.energySectorZNC(); + auto znaEnergy = zdc.energySectorZNA(); + auto zncEnergycommon = zdc.energyCommonZNC(); + auto znaEnergycommon = zdc.energyCommonZNA(); + + if (znaEnergycommon <= 0.0 || zncEnergycommon <= 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 (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; + } + 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)) { + triggerevent = true; + if (useGainCallib && (currentRunNumber != lastRunNumber)) { + // gainprofile = ccdb->getForTimeStamp(ConfGainPath.value, bc.timestamp()); + gainprofile = ccdb->getForTimeStamp(ConfGainPath.value, bc.timestamp()); + } + + // initCCDB(bc); + + auto gainequal = 1.0; + auto alphaZDC = 0.395; + constexpr double x[4] = {-1.75, 1.75, -1.75, 1.75}; + constexpr double y[4] = {-1.75, -1.75, 1.75, 1.75}; + + // histos.fill(HIST("ZDCAmpCommon"), 0.5, vz, centrality, znaEnergycommon); + // histos.fill(HIST("ZDCAmpCommon"), 1.5, vz, centrality, zncEnergycommon); + histos.fill(HIST("ZDCAmpCommon"), 0.5, vz, znaEnergycommon); + histos.fill(HIST("ZDCAmpCommon"), 1.5, vz, zncEnergycommon); + + // LOG(info) << "**********energy values************" << znaEnergycommon<<" "<GetBinContent(gainprofile->FindBin(vz, centrality, chanelid + 0.5)); + gainequal = gainprofile->GetBinContent(gainprofile->FindBin(vz, chanelid + 0.5)); + } + + if (iChA < 4) { + + if (znaEnergy[iChA] <= 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; + } else { + double ampl = gainequal * znaEnergy[iChA]; + if (followpub) { + ampl = TMath::Power(ampl, alphaZDC); + } + qxZDCA = qxZDCA - ampl * x[iChA]; + qyZDCA = qyZDCA + ampl * y[iChA]; + sumA = sumA + ampl; + histos.fill(HIST("ZDCAmp"), chanelid + 0.5, vz, ampl); + // histos.fill(HIST("hZDCAmp"), chanelid + 0.5, vz, centrality, ampl); + } + } else { + if (zncEnergy[iChA - 4] <= 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; + } else { + double ampl = gainequal * zncEnergy[iChA - 4]; + if (followpub) { + ampl = TMath::Power(ampl, alphaZDC); + } + qxZDCC = qxZDCC + ampl * x[iChA - 4]; + qyZDCC = qyZDCC + ampl * y[iChA - 4]; + sumC = sumC + ampl; + histos.fill(HIST("ZDCAmp"), chanelid + 0.5, vz, ampl); + // histos.fill(HIST("hZDCAmp"), chanelid + 0.5, vz, centrality, ampl); + } + } + } + + if (usenormqn) { + if (sumA > 0) { + qxZDCA = qxZDCA / sumA; + qyZDCA = qyZDCA / sumA; + } + if (sumC > 0) { + qxZDCC = qxZDCC / sumC; + qyZDCC = qyZDCC / sumC; + } + } else { + qxZDCA = qxZDCA; + qxZDCC = qxZDCC; + qyZDCA = qyZDCA; + qyZDCC = qyZDCC; + } + if (sumA <= 1e-4 || sumC <= 1e-4) { + qxZDCA = 0.0; + qxZDCC = 0.0; + qyZDCA = 0.0; + qyZDCC = 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("hCentrality"), centrality); + histos.fill(HIST("Vz"), vz); + + if (useRecentereSp && (currentRunNumber != lastRunNumber)) { + hrecentereSp = ccdb->getForTimeStamp(ConfRecentereSp.value, bc.timestamp()); + } + if (useRecenterefineSp && (currentRunNumber != lastRunNumber)) { + hrecenterecentSp = ccdb->getForTimeStamp(ConfRecenterecentSp.value, bc.timestamp()); + hrecenterevxSp = ccdb->getForTimeStamp(ConfRecenterevxSp.value, bc.timestamp()); + hrecenterevySp = ccdb->getForTimeStamp(ConfRecenterevySp.value, bc.timestamp()); + hrecenterevzSp = ccdb->getForTimeStamp(ConfRecenterevzSp.value, bc.timestamp()); + } + if (useRecenteresqSp && (currentRunNumber != lastRunNumber)) { + hrecenteresqSp = ccdb->getForTimeStamp(ConfRecenteresqSp.value, bc.timestamp()); + } + + if (useRecentereSp && hrecentereSp) { + + int binCoords[5]; + + // Get axes of the THnSparse + TAxis* centralityAxis = hrecentereSp->GetAxis(0); // Axis 0: centrality + TAxis* vxAxis = hrecentereSp->GetAxis(1); // Axis 1: vx + TAxis* vyAxis = hrecentereSp->GetAxis(2); // Axis 2: vy + TAxis* vzAxis = hrecentereSp->GetAxis(3); // Axis 3: vz + 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 + + // Get the global bin for meanxA + int globalBinMeanxA = hrecentereSp->GetBin(binCoords); + double meanxA = hrecentereSp->GetBinContent(globalBinMeanxA); + double meanxAerror = hrecentereSp->GetBinError(globalBinMeanxA); + + // Repeat for other channels (meanyA, meanxC, meanyC) + binCoords[4] = channelAxis->FindBin(1.5); // Channel for meanyA + int globalBinMeanyA = hrecentereSp->GetBin(binCoords); + double meanyA = hrecentereSp->GetBinContent(globalBinMeanyA); + double meanyAerror = hrecentereSp->GetBinError(globalBinMeanyA); + + binCoords[4] = channelAxis->FindBin(2.5); // Channel for meanxC + int globalBinMeanxC = hrecentereSp->GetBin(binCoords); + double meanxC = hrecentereSp->GetBinContent(globalBinMeanxC); + double meanxCerror = hrecentereSp->GetBinError(globalBinMeanxC); + + binCoords[4] = channelAxis->FindBin(3.5); // Channel for meanyC + int globalBinMeanyC = hrecentereSp->GetBin(binCoords); + double meanyC = hrecentereSp->GetBinContent(globalBinMeanyC); + double meanyCerror = hrecentereSp->GetBinError(globalBinMeanyC); + + if (rejbadevent) { + if ((TMath::Abs(meanxA) > 90000.0 || TMath::Abs(meanxC) > 90000.0 || TMath::Abs(meanyA) > 90000.0 || TMath::Abs(meanyC) > 90000.0) && (TMath::Abs(meanxAerror) > 9000.0 || TMath::Abs(meanxCerror) > 9000.0 || TMath::Abs(meanyAerror) > 9000.0 || TMath::Abs(meanyCerror) > 9000.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; + } + } + + qxZDCA = qxZDCA - meanxA; + qyZDCA = qyZDCA - meanyA; + qxZDCC = qxZDCC - meanxC; + qyZDCC = qyZDCC - meanyC; + + if (recwitherror) { + if (meanxAerror != 0.0) { + qxZDCA = qxZDCA / meanxAerror; + } + if (meanyAerror != 0.0) { + qyZDCA = qyZDCA / meanyAerror; + } + if (meanxCerror != 0.0) { + qxZDCC = qxZDCC / meanxCerror; + } + if (meanyCerror != 0.0) { + qyZDCC = qyZDCC / meanyCerror; + } + } + } + + if (useRecenterefineSp && hrecenterecentSp) { + + 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 meanxAcenterror = hrecenterecentSp->GetBinError(hrecenterecentSp->FindBin(centrality, 0.5)); + double meanyAcenterror = hrecenterecentSp->GetBinError(hrecenterecentSp->FindBin(centrality, 1.5)); + double meanxCcenterror = hrecenterecentSp->GetBinError(hrecenterecentSp->FindBin(centrality, 2.5)); + double meanyCcenterror = hrecenterecentSp->GetBinError(hrecenterecentSp->FindBin(centrality, 3.5)); + + if (rejbadeventcent) { + if ((TMath::Abs(meanxAcent) > 90000.0 || TMath::Abs(meanxCcent) > 90000.0 || TMath::Abs(meanyAcent) > 90000.0 || TMath::Abs(meanyCcent) > 90000.0) && (TMath::Abs(meanxAcenterror) > 9000.0 || TMath::Abs(meanxCcenterror) > 9000.0 || TMath::Abs(meanyAcenterror) > 9000.0 || TMath::Abs(meanyCcenterror) > 9000.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; + } + } + + qxZDCA = qxZDCA - hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 0.5)); + qyZDCA = qyZDCA - hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 1.5)); + qxZDCC = qxZDCC - hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 2.5)); + qyZDCC = qyZDCC - hrecenterecentSp->GetBinContent(hrecenterecentSp->FindBin(centrality, 3.5)); + + if (recfinewitherror) { + qxZDCA = qxZDCA / meanxAcenterror; + qyZDCA = qyZDCA / meanyAcenterror; + qxZDCC = qxZDCC / meanxCcenterror; + qyZDCC = qyZDCC / meanyCcenterror; + } + } + + if (useRecenterefineSp && hrecenterevxSp) { + + 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 meanxAvxerror = hrecenterevxSp->GetBinError(hrecenterevxSp->FindBin(vx, 0.5)); + double meanyAvxerror = hrecenterevxSp->GetBinError(hrecenterevxSp->FindBin(vx, 1.5)); + double meanxCvxerror = hrecenterevxSp->GetBinError(hrecenterevxSp->FindBin(vx, 2.5)); + double meanyCvxerror = hrecenterevxSp->GetBinError(hrecenterevxSp->FindBin(vx, 3.5)); + + if (rejbadeventvx) { + if ((TMath::Abs(meanxAvx) > 90000.0 || TMath::Abs(meanxCvx) > 90000.0 || TMath::Abs(meanyAvx) > 90000.0 || TMath::Abs(meanyCvx) > 90000.0) && (TMath::Abs(meanxAvxerror) > 9000.0 || TMath::Abs(meanxCvxerror) > 9000.0 || TMath::Abs(meanyAvxerror) > 9000.0 || TMath::Abs(meanyCvxerror) > 9000.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; + } + } + + qxZDCA = qxZDCA - hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 0.5)); + qyZDCA = qyZDCA - hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 1.5)); + qxZDCC = qxZDCC - hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 2.5)); + qyZDCC = qyZDCC - hrecenterevxSp->GetBinContent(hrecenterevxSp->FindBin(vx, 3.5)); + + if (recfinewitherror) { + qxZDCA = qxZDCA / meanxAvxerror; + qyZDCA = qyZDCA / meanyAvxerror; + qxZDCC = qxZDCC / meanxCvxerror; + qyZDCC = qyZDCC / meanyCvxerror; + } + } + + if (useRecenterefineSp && hrecenterevySp) { + + 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 meanxAvyerror = hrecenterevySp->GetBinError(hrecenterevySp->FindBin(vy, 0.5)); + double meanyAvyerror = hrecenterevySp->GetBinError(hrecenterevySp->FindBin(vy, 1.5)); + double meanxCvyerror = hrecenterevySp->GetBinError(hrecenterevySp->FindBin(vy, 2.5)); + double meanyCvyerror = hrecenterevySp->GetBinError(hrecenterevySp->FindBin(vy, 3.5)); + + if (rejbadeventvy) { + if ((TMath::Abs(meanxAvy) > 90000.0 || TMath::Abs(meanxCvy) > 90000.0 || TMath::Abs(meanyAvy) > 90000.0 || TMath::Abs(meanyCvy) > 90000.0) && (TMath::Abs(meanxAvyerror) > 9000.0 || TMath::Abs(meanxCvyerror) > 9000.0 || TMath::Abs(meanyAvyerror) > 9000.0 || TMath::Abs(meanyCvyerror) > 9000.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; + } + } + + qxZDCA = qxZDCA - hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 0.5)); + qyZDCA = qyZDCA - hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 1.5)); + qxZDCC = qxZDCC - hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 2.5)); + qyZDCC = qyZDCC - hrecenterevySp->GetBinContent(hrecenterevySp->FindBin(vy, 3.5)); + + if (recfinewitherror) { + qxZDCA = qxZDCA / meanxAvyerror; + qyZDCA = qyZDCA / meanyAvyerror; + qxZDCC = qxZDCC / meanxCvyerror; + qyZDCC = qyZDCC / meanyCvyerror; + } + } + + if (useRecenterefineSp && hrecenterevzSp) { + + 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 meanxAvzerror = hrecenterevzSp->GetBinError(hrecenterevzSp->FindBin(vz, 0.5)); + double meanyAvzerror = hrecenterevzSp->GetBinError(hrecenterevzSp->FindBin(vz, 1.5)); + double meanxCvzerror = hrecenterevzSp->GetBinError(hrecenterevzSp->FindBin(vz, 2.5)); + double meanyCvzerror = hrecenterevzSp->GetBinError(hrecenterevzSp->FindBin(vz, 3.5)); + + if (rejbadeventvz) { + if ((TMath::Abs(meanxAvz) > 90000.0 || TMath::Abs(meanxCvz) > 90000.0 || TMath::Abs(meanyAvz) > 90000.0 || TMath::Abs(meanyCvz) > 90000.0) && (TMath::Abs(meanxAvzerror) > 9000.0 || TMath::Abs(meanxCvzerror) > 9000.0 || TMath::Abs(meanyAvzerror) > 9000.0 || TMath::Abs(meanyCvzerror) > 9000.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; + } + } + + qxZDCA = qxZDCA - hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 0.5)); + qyZDCA = qyZDCA - hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 1.5)); + qxZDCC = qxZDCC - hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 2.5)); + qyZDCC = qyZDCC - hrecenterevzSp->GetBinContent(hrecenterevzSp->FindBin(vz, 3.5)); + + if (recfinewitherror) { + qxZDCA = qxZDCA / meanxAvzerror; + qyZDCA = qyZDCA / meanyAvzerror; + qxZDCC = qxZDCC / meanxCvzerror; + qyZDCC = qyZDCC / meanyCvzerror; + } + } + + // LOG(info) << "**********qxa values in spvector************" << qxZDCA<<" "<(cfgc)}; +} diff --git a/PWGLF/TableProducer/Nuspex/CMakeLists.txt b/PWGLF/TableProducer/Nuspex/CMakeLists.txt index af846903610..8670f8c424d 100644 --- a/PWGLF/TableProducer/Nuspex/CMakeLists.txt +++ b/PWGLF/TableProducer/Nuspex/CMakeLists.txt @@ -26,7 +26,7 @@ o2physics_add_dpl_workflow(hyper-kink-reco-task o2physics_add_dpl_workflow(hypertriton-reco-task SOURCES hyperRecoTask.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DCAFitter O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lnn-reco-task @@ -44,9 +44,9 @@ o2physics_add_dpl_workflow(nucleustreecreator PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(lithium4analysis - SOURCES lithium4analysis.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore +o2physics_add_dpl_workflow(he3hadronfemto + SOURCES he3HadronFemto.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(nuclei-spectra @@ -73,3 +73,18 @@ o2physics_add_dpl_workflow(ebye-maker SOURCES ebyeMaker.cxx PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(cluster-studies-tree-creator + SOURCES LFTreeCreatorClusterStudies.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(pidtof-generic + SOURCES pidTOFGeneric.cxx + 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) diff --git a/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx b/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx new file mode 100644 index 00000000000..ca382c8d2be --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/LFTreeCreatorClusterStudies.cxx @@ -0,0 +1,1347 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// TableProducer to generate Trees for pure protons ans pions (from Lambda), Kaons (from Omegas), deuterons (identified with TOF) and He3 (identified with TPC). +// The output trees contain the ITS cluster size information. +// +// 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/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/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseITS.h" +#include "DCAFitter/DCAFitterN.h" + +#include "PWGLF/DataModel/LFClusterStudiesTable.h" + +#include "TDatabasePDG.h" +#include "TPDGCode.h" + +using namespace ::o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using Track = o2::track::TrackParCov; +using TracksFullIU = soa::Join; +using TracksFullIUMc = soa::Join; +using CollisionsCustom = soa::Join; + +namespace BetheBloch +{ + +constexpr double defaultParams[1][6]{{-1.e32, -1.e32, -1.e32, -1.e32, -1.e32, -1.e32}}; +static const std::vector parNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; + +} // namespace BetheBloch + +enum V0Type : uint8_t { + K0s = 0, + Lambda, + AntiLambda, + Photon, + V0TypeAll +}; + +enum CascadeType : uint8_t { + XiMinus = 0, + OmegaMinus +}; + +enum Selections { + kNoCut = 0, + kSel8, + kVtxZ, + kAll +}; + +enum V0Selections { + kV0NoCut = 0, + kV0DaughterQuality, + kV0DaughterDCA, + // kV0DCA, + kV0Radius, + kV0CosPA, + kV0PID, + kV0DaughterDCAtoPV, + kV0All +}; + +enum CascSelections { + kCascNoCut = 0, + kCascDCA, + kCascCosPA, + kAcceptedOmega, + kRejectedXi, + kNSigmaTPC, + kCascAll +}; + +enum DeSelections { + kDeNoCut = 0, + kDeNClsIts, + kDePIDtpc, + kDePIDtof, + kDeAll +}; + +enum He3Selections { + kHe3NoCut = 0, + kHe3NClsIts, + kHe3PIDtpc, + kHe3PIDtof, + kHe3All +}; + +enum PartID { + none = 0, + el, + pi, + ka, + pr, + de, + he +}; + +struct LfTreeCreatorClusterStudies { + + Service m_ccdb; + int m_runNumber; + int m_collisionCounter = 0; + float m_d_bz; + uint32_t m_randomSeed = 0.; + + Configurable setting_fillV0{"fillV0", true, "Fill the V0 tree"}; + Configurable setting_fillK{"fillK", true, "Fill the K tree"}; + Configurable setting_fillDe{"fillDe", true, "Fill the De tree"}; + Configurable setting_fillHe3{"fillHe3", true, "Fill the He3 tree"}; + Configurable setting_fillPKPi{"fillPKPPi", true, "Fill the p, K, pi tree"}; + Configurable setting_smallTable{"smallTable", true, "Use a small table for testing"}; + + Configurable setting_materialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; + + Configurable setting_zVtxMax{"zVtxMax", 10.f, "Maximum z vertex position"}; + + Configurable setting_downscaleFactor{"downscaleFactor", 1.f, "Downscale factor for the V0 candidates"}; + Configurable setting_applyAdditionalEvSel{"applyAdditionalEvSel", false, "Apply additional event selection"}; + + Configurable track_nClsItsMin{"track_NclsItsMin", 0.f, "Minimum number of ITS clusters for the V0 daughters"}; + Configurable track_nClsTpcMin{"track_NclsTpcMin", 100.f, "Minimum number of TPC clusters for the V0 daughters"}; + Configurable track_nClsTpcMaxShared{"track_NclsTpcMaxShared", 5.f, "Maximum number of shared TPC clusters for the V0 daughters"}; + + // Configurable v0setting_etaMaxV0{"etaMaxV0", 0.8f, "Maximum eta for the V0 daughters"}; + Configurable v0setting_etaMaxV0dau{"etaMaxV0dau", 0.8f, "Maximum eta for the V0 daughters"}; + Configurable v0setting_dcaV0daughters{"v0setting_dcaV0daughters", 0.5f, "DCA between the V0 daughters"}; + Configurable v0setting_dcaV0toPV{"v0setting_dcaV0fromPV", 1.f, "DCA of the V0 to the primary vertex"}; + Configurable v0setting_dcaDaughtersToPV{"v0setting_dcaDaughtersToPV", 1.f, "DCA of the daughters to the primary vertex"}; + Configurable v0setting_radiusMax{"v0setting_radiusMax", 100.f, "Maximum radius of the V0 accepted"}; + Configurable v0setting_radiusMin{"v0setting_radiusMin", 5.f, "Minimum radius of the V0 accepted"}; + Configurable v0setting_cosPA{"v0setting_cosPA", 0.99f, "Cosine of the pointing angle of the V0"}; + Configurable v0setting_nsigmatpc{"v0setting_nsigmaTPC", 4.f, "Number of sigmas for the TPC PID"}; + Configurable v0setting_massWindowLambda{"v0setting_massWindowLambda", 0.02f, "Mass window for the Lambda"}; + Configurable v0setting_massWindowK0s{"v0setting_massWindowK0s", 0.02f, "Mass window for the K0s"}; + Configurable v0setting_nsigmatpcEl{"v0setting_nsigmaTPCEl", 1.f, "Number of sigmas for the TPC PID for electrons"}; + Configurable v0setting_nsigmatpcPi{"v0setting_nsigmaTPCPi", 2.f, "Number of sigmas for the TPC PID for pions"}; + 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 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"}; + Configurable cascsetting_massWindowOmega{"casc_setting_massWindowOmega", 0.01f, "Mass window for the Omega"}; + Configurable cascsetting_massWindowXi{"casc_setting_massWindowXi", 0.01f, "Mass window for the Xi"}; + Configurable cascsetting_nsigmatpc{"casc_setting_nsigmaTPC", 3.f, "Number of sigmas for the TPC PID"}; + + Configurable desetting_nClsIts{"desetting_nClsIts", 6, "Minimum number of ITS clusters"}; + Configurable desetting_nsigmatpc{"desetting_nsigmaCutTPC", 2.f, "Number of sigmas for the TPC PID"}; + Configurable desetting_nsigmatof{"desetting_nsigmaCutTOF", 2.f, "Number of sigmas for the TOF PID"}; + Configurable he3setting_nClsIts{"he3setting_nClsIts", 6, "Minimum number of ITS clusters"}; + Configurable he3setting_compensatePIDinTracking{"he3setting_compensatePIDinTracking", true, "Compensate PID in tracking"}; + Configurable he3setting_nsigmatpc{"he3setting_nsigmaCutTPC", 2.f, "Number of sigmas for the TPC PID"}; + Configurable he3setting_tofmasslow{"he3setting_tofmasslow", 1.8f, "Lower limit for the TOF mass"}; + Configurable he3setting_tofmasshigh{"he3setting_tofmasshigh", 4.2f, "Upper limit for the TOF mass"}; + + // Bethe Bloch parameters + std::array m_BBparamsDe, m_BBparamsHe; + Configurable> setting_BetheBlochParams{"setting_BetheBlochParams", {BetheBloch::defaultParams[0], 2, 6, {"De", "He3"}, BetheBloch::parNames}, "TPC Bethe-Bloch parameterisation for nuclei"}; + + Preslice m_perCollisionV0 = o2::aod::v0::collisionId; + Preslice m_perCollisionCascade = o2::aod::cascade::collisionId; + Preslice m_perCol = aod::track::collisionId; + Preslice m_perColMC = aod::track::collisionId; + + HistogramRegistry m_hAnalysis{ + "LFTreeCreator", + {{"collision_selections", "Collision selection; selection; counts", {HistType::kTH1F, {{Selections::kAll, -0.5, static_cast(Selections::kAll) - 0.5}}}}, + {"v0_selections", "V0 selection; selection; counts", {HistType::kTH1F, {{V0Selections::kV0All, -0.5, static_cast(V0Selections::kV0All) - 0.5}}}}, + {"casc_selections", "Cascade selection; selection; counts", {HistType::kTH1F, {{CascSelections::kCascAll, -0.5, static_cast(CascSelections::kCascAll) - 0.5}}}}, + {"de_selections", "Deuteron track selection; selection; counts", {HistType::kTH1F, {{DeSelections::kDeAll, -0.5, static_cast(DeSelections::kDeAll) - 0.5}}}}, + {"he3_selections", "He3 track selection; selection; counts", {HistType::kTH1F, {{He3Selections::kHe3All, -0.5, static_cast(He3Selections::kHe3All) - 0.5}}}}, + {"v0_type", "Selected V0; particle; counts", {HistType::kTH1F, {{V0Type::V0TypeAll, -0.5, static_cast(V0Type::V0TypeAll) - 0.5}}}}, + {"radiusV0", "Decay radius (xy) V0; radius (cm); counts", {HistType::kTH1F, {{100, 0., 100.}}}}, + {"massLambda", "#Lambda invariant mass; signed #it{p} (GeV/#it{c}); m (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, -5.f, 5.f}, {50, 1.08f, 1.18f}}}}, + {"Lambda_vs_K0s", "Mass #Lambda vs K^{0}_s; m_{K^{0}_{s}} (GeV/#it{c}^{2}); m_{#Lambda} (GeV/#it{c}^{2})", {HistType::kTH2F, {{50, 0.f, 1.f}, {70, 0.6f, 2.f}}}}, + {"armenteros_plot_before_selections", "Armenteros-Podolanski plot; #alpha; q_{T} (GeV/#it{c})", {HistType::kTH2F, {{100, -1.f, 1.f}, {100, 0.f, 0.3f}}}}, + {"armenteros_plot", "Armenteros-Podolanski plot; #alpha; q_{T} (GeV/#it{c})", {HistType::kTH2F, {{100, -1.f, 1.f}, {100, 0.f, 0.3f}}}}, + {"armenteros_plot_lambda", "Armenteros-Podolanski plot (#Lambda only); #alpha; q_{T} (GeV/#it{c})", {HistType::kTH2F, {{100, -1.f, 1.f}, {100, 0.f, 0.3f}}}}, + {"armenteros_plot_gamma", "Armenteros-Podolanski plot (#gamma only); #alpha; q_{T} (GeV/#it{c})", {HistType::kTH2F, {{100, -1.f, 1.f}, {100, 0.f, 0.3f}}}}, + {"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}}}}, + {"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}}}}, + {"nSigmaTPCEl", "nSigma TPC Electron; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} e", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {60, -2.0f, 2.0f}}}}, + {"nSigmaTPCPi", "nSigma TPC Pion; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} #pi", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {60, -3.0f, 3.0f}}}}, + {"nSigmaTPCKa", "nSigma TPC Kaon; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} e", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {60, -4.0f, 4.0f}}}}, + {"nSigmaTPCPr", "nSigma TPC Proton; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} p", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {60, -3.0f, 3.0f}}}}, + {"nSigmaTPCDe", "nSigma TPC Deuteron; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} d", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -3.0f, 3.0f}}}}, + {"nSigmaTPCHe", "nSigma TPC He3; signed #it{p} (GeV/#it{c}); n#sigma_{TPC} ^{3}He", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -3.0f, 3.0f}}}}, + {"nSigmaTOFDe", "nSigma TOF Deuteron; signed #it{p} (GeV/#it{c}); n#sigma_{TOF} d", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -3.0f, 3.0f}}}}, + {"TOFmassDe", "TOF mass De; signed #it{p}_{T} (GeV/#it{c}); mass_{TOF} ^{3}He (GeV/#it{c}^2)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, 1.0f, 5.0f}}}}, + {"TOFmassHe", "TOF mass He3; signed #it{p}_{T} (GeV/#it{c}); mass_{TOF} ^{3}He (GeV/#it{c}^2)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, 1.0f, 5.0f}}}}, + {"nSigmaITSEl", "nSigma ITS Electron; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} e", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {60, -2.0f, 2.0f}}}}, + {"nSigmaITSPi", "nSigma ITS Pion; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} #pi", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {60, -3.0f, 3.0f}}}}, + {"nSigmaITSKa", "nSigma ITS Kaon; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} e", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {60, -4.0f, 4.0f}}}}, + {"nSigmaITSPr", "nSigma ITS Proton; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} p", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {60, -3.0f, 3.0f}}}}, + {"nSigmaITSDe", "nSigma ITS Deuteron; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} d", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {100, -3.0f, 3.0f}}}}, + {"nSigmaITSHe", "nSigma ITS He3; signed #it{p} (GeV/#it{c}); n#sigma_{ITS} ^{3}He", {HistType::kTH2F, {{50, -5.0f, 5.0f}, {100, -3.0f, 3.0f}}}}, + {"pmatchingEl", "#it{p} matching e; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"pmatchingPi", "#it{p} matching #pi; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"pmatchingKa", "#it{p} matching K; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"pmatchingPr", "#it{p} matching p; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"pmatchingDe", "#it{p} matching d; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"pmatchingHe", "#it{p} matching ^{3}He; signed #it{p}_{TPC} (GeV/#it{c}); #frac{#it{p}_{TPC} - #it{p}}{#it{p}_{TPC}}", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {100, -0.5f, 0.5f}}}}, + {"zVtx", "Binning for the vertex z in cm", {HistType::kTH1F, {{100, -20.f, 20.f}}}}, + {"isPositive", "is the candidate positive?; isPositive; counts", {HistType::kTH1F, {{2, -0.5f, 1.5f}}}}}, + OutputObjHandlingPolicy::AnalysisObject, + false, + true}; // check histograms + + Produces m_ClusterStudiesTable; + Produces m_ClusterStudiesTableExtra; + Produces m_ClusterStudiesTableMc; + Produces m_ClusterStudiesTableMcExtra; + + struct V0TrackParCov { + int64_t globalIndex; + Track trackParCov; + }; + std::vector m_v0TrackParCovs; + + o2::vertexing::DCAFitterN<2> m_fitter; + o2::pid::tof::Beta m_responseBeta; + o2::pid::tof::Beta m_responseBetaMc; + o2::aod::ITSResponse m_responseITS; + + template + bool initializeFitter(const T& trackParCovA, const T& trackParCovB) + { + int nCand = 0; + try { + nCand = m_fitter.process(trackParCovA, trackParCovB); + } catch (...) { + LOG(error) << "Exception caught in DCA fitter process call!"; + return false; + } + if (nCand == 0) { + return false; + } + + return true; + } + + /** + * Compute the momentum of the track using the fitter + * @param itrack Index of the track in the fitter + * @param mom Array to store the momentum + */ + void computeTrackMomentum(const int itrack, std::array& mom) + { + auto fittedTrack = m_fitter.getTrack(itrack); + fittedTrack.getPxPyPzGlo(mom); + } + + void computeMotherMomentum(const std::array& momA, const std::array& momB, std::array& momMother) + { + momMother[0] = momA[0] + momB[0]; + momMother[1] = momA[1] + momB[1]; + momMother[2] = momA[2] + momB[2]; + } + + /** + * Compute the alpha for the Armenteros-Podolanski plot + */ + float computeAlphaAP(const std::array& momMother, const std::array& momP, const std::array& momN) + { + float lQlP = std::inner_product(momMother.begin(), momMother.end(), momP.begin(), 0.f); + float lQlN = std::inner_product(momMother.begin(), momMother.end(), momN.begin(), 0.f); + return (lQlP - lQlN) / (lQlP + lQlN); + } + + /** + * Compute the qt for the Armenteros-Podolanski plot + */ + float computeQtAP(const std::array& momMother, const std::array& momP) + { + float dp = std::inner_product(momMother.begin(), momMother.end(), momP.begin(), 0.f); + float p2V0 = std::inner_product(momMother.begin(), momMother.end(), momMother.begin(), 0.f); + float p2A = std::inner_product(momP.begin(), momP.end(), momP.begin(), 0.f); + return std::sqrt(p2A - dp * dp / p2V0); + } + + float dcaMotherToPV(const std::array& decayVtx, const std::array& PV, std::array momMother) const + { + std::array relPos = {decayVtx[0] - PV[0], decayVtx[1] - PV[1], decayVtx[2] - PV[2]}; + float lmomMotherl = std::hypot(momMother[0], momMother[1], momMother[2]); + return std::sqrt((std::pow(relPos[1] * momMother[2] - relPos[2] * momMother[1], 2) + std::pow(relPos[2] * momMother[0] - relPos[0] * momMother[2], 2) + std::pow(relPos[0] * momMother[1] - relPos[1] * momMother[0], 2))) / lmomMotherl; + } + + template + float dcaToPV(const std::array& PV, T& trackParCov, gpu::gpustd::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]); + } + + float computeMassMother(const float massA, const float massB, const std::array& momA, const std::array& momB, const std::array& momMother) const + { + float eA = std::hypot(massA, std::hypot(momA[0], momA[1], momA[2])); + float eB = std::hypot(massB, std::hypot(momB[0], momB[1], momB[2])); + float lmomMotherl = std::hypot(momMother[0], momMother[1], momMother[2]); + float eMother = eA + eB; + return std::sqrt(eMother * eMother - lmomMotherl * lmomMotherl); + } + + bool collisionSelection(const CollisionsCustom::iterator& collision) + { + m_hAnalysis.fill(HIST("collision_selections"), Selections::kNoCut); + if (!collision.sel8()) { + return false; + } + m_hAnalysis.fill(HIST("collision_selections"), Selections::kSel8); + // if (!collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + // return false; + // } + if (std::abs(collision.posZ()) > setting_zVtxMax) { + return false; + } + m_hAnalysis.fill(HIST("collision_selections"), Selections::kVtxZ); + return true; + } + + // ========================================================================================================= + + /** + * Select the V0 daughters based on the quality cuts + */ + template + bool qualityTrackSelection(const T& track) + { + if (std::abs(track.eta()) > v0setting_etaMaxV0dau) { + return false; + } + if (track.itsNCls() < track_nClsItsMin || + track.tpcNClsFound() < track_nClsTpcMin || + track.tpcNClsCrossedRows() < track_nClsTpcMin || + track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsShared() > track_nClsTpcMaxShared) { + return false; + } + return true; + } + + bool qualitySelectionV0(const double /*dcaV0toPV*/, const double dcaV0daughters, const double radiusV0, const double cosPA) + { + if (std::abs(dcaV0daughters) > v0setting_dcaV0daughters) { + return false; + } + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0DaughterDCA); + if (radiusV0 > v0setting_radiusMax || radiusV0 < v0setting_radiusMin) { + return false; + } + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0Radius); + if (std::abs(cosPA) < v0setting_cosPA) { + return false; + } + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0CosPA); + return true; + } + + bool qualitySelectionCascade(const double dcaCascDaughters, const double cosPA) + { + if (std::abs(dcaCascDaughters) > cascsetting_dcaCascDaughters) { + return false; + } + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kCascDCA); + if (std::abs(cosPA) < cascsetting_cosPA) { + return false; + } + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kCascCosPA); + return true; + } + + // ========================================================================================================= + + template + bool nucleiTrackSelection(const T& track) + { + if (track.tpcNClsFound() < 90) { + return false; + } + return true; + } + + // ========================================================================================================= + + template + float computeNSigmaDe(const T& candidate) + { + float expTPCSignal = o2::tpc::BetheBlochAleph(static_cast(candidate.tpcInnerParam() / constants::physics::MassDeuteron), m_BBparamsDe[0], m_BBparamsDe[1], m_BBparamsDe[2], m_BBparamsDe[3], m_BBparamsDe[4]); + double resoTPC{expTPCSignal * m_BBparamsDe[5]}; + return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); + } + + template + bool selectionPIDtpcDe(const T& candidate) + { + auto nSigmaDe = computeNSigmaDe(candidate); + if (std::abs(nSigmaDe) < desetting_nsigmatpc) { + return true; + } + return false; + } + + template + float computeTOFmassDe(const T& candidate) + { + if constexpr (isMC) { + float beta = m_responseBetaMc.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); + } else { + float beta = m_responseBeta.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); + } + } + + // ========================================================================================================= + + template + float computeNSigmaHe3(const T& candidate) + { + bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; + float correctedTPCinnerParam = (heliumPID && he3setting_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]); + double resoTPC{expTPCSignal * m_BBparamsHe[5]}; + return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); + } + + template + bool selectionPIDtpcHe3(const T& candidate) + { + auto nSigmaHe3 = computeNSigmaHe3(candidate); + if (std::abs(nSigmaHe3) < he3setting_nsigmatpc) { + return true; + } + return false; + } + + template + float computeTOFmassHe3(const T& candidate) + { + if constexpr (isMC) { + float beta = m_responseBetaMc.GetBeta(candidate); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; + float correctedTPCinnerParamHe3 = (heliumPID && he3setting_compensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); + return correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); + } else { + float beta = m_responseBeta.GetBeta(candidate); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; + float correctedTPCinnerParamHe3 = (heliumPID && he3setting_compensatePIDinTracking) ? candidate.tpcInnerParam() / 2.f : candidate.tpcInnerParam(); + return correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); + } + return -999.f; + } + + // ========================================================================================================= + + template + void initCCDB(Bc const& bc) + { + if (m_runNumber == bc.runNumber()) { + return; + } + + auto timestamp = bc.timestamp(); + o2::parameters::GRPMagField* grpmag = 0x0; + + auto grpmagPath{"GLO/Config/GRPMagField"}; + grpmag = m_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 + m_d_bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << m_d_bz << " kG"; + m_runNumber = bc.runNumber(); + m_fitter.setBz(m_d_bz); + + // o2::base::Propagator::Instance()->setMatLUT(lut); + } + + void init(o2::framework::InitContext&) + { + m_runNumber = 0; + m_d_bz = 0; + + m_ccdb->setURL("http://alice-ccdb.cern.ch"); + m_ccdb->setCaching(true); + m_ccdb->setLocalObjectValidityChecking(); + m_ccdb->setFatalWhenNull(false); + // lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + + m_fitter.setPropagateToPCA(true); + m_fitter.setMaxR(200.); + m_fitter.setMinParamChange(1e-3); + m_fitter.setMinRelChi2Change(0.9); + m_fitter.setMaxDZIni(4); + m_fitter.setMaxDXYIni(4); + m_fitter.setMaxChi2(1e9); + m_fitter.setUseAbsDCA(true); + m_fitter.setWeightedFinalPCA(false); + int mat{static_cast(setting_materialCorrection)}; + m_fitter.setMatCorrType(static_cast(mat)); + + LOG(info) << "Bethe-Bloch parameters for He3:"; + for (int i = 0; i < 5; i++) { + m_BBparamsHe[i] = setting_BetheBlochParams->get("He3", Form("p%i", i)); + LOG(info) << "p" << i << ": " << m_BBparamsHe[i]; + } + m_BBparamsHe[5] = setting_BetheBlochParams->get("He3", "resolution"); + LOG(info) << "resolution: " << m_BBparamsHe[5]; + + LOG(info) << "Bethe-Bloch parameters for De:"; + for (int i = 0; i < 5; i++) { + m_BBparamsDe[i] = setting_BetheBlochParams->get("De", Form("p%i", i)); + LOG(info) << "p" << i << ": " << m_BBparamsDe[i]; + } + m_BBparamsDe[5] = setting_BetheBlochParams->get("De", "resolution"); + LOG(info) << "resolution: " << m_BBparamsDe[5]; + + std::vector collision_selection_labels = {"All", "sel8", "z_{VTX} < 10 cm"}; + for (int i = 0; i < Selections::kAll; i++) + m_hAnalysis.get(HIST("collision_selections"))->GetXaxis()->SetBinLabel(i + 1, collision_selection_labels[i].c_str()); + + std::vector V0_selection_labels = {"All", "daughter track quality", "V0 daughters dca", "V0 radius", "V0 cosPA", "V0 mass selection", "V0 daughter DCA to PV"}; + for (int i = 0; i < V0Selections::kV0All; i++) + m_hAnalysis.get(HIST("v0_selections"))->GetXaxis()->SetBinLabel(i + 1, V0_selection_labels[i].c_str()); + + std::vector Casc_selection_labels = {"All", "Casc DCA", "Casc CosPA", "Accepted Omega", "Veto Xi", "n#sigma_{TPC} K"}; + for (int i = 0; i < CascSelections::kCascAll; i++) + m_hAnalysis.get(HIST("casc_selections"))->GetXaxis()->SetBinLabel(i + 1, Casc_selection_labels[i].c_str()); + + std::vector De_selection_labels = {"All", "n clusters ITS", "n#sigma_{TPC} d", "n#sigma_{TOF} d"}; + for (int i = 0; i < DeSelections::kDeAll; i++) + m_hAnalysis.get(HIST("de_selections"))->GetXaxis()->SetBinLabel(i + 1, De_selection_labels[i].c_str()); + + std::vector He3_selection_labels = {"All", "n clusters ITS", "n#sigma_{TPC} ^{3}He", "TOF mass ^{3}He"}; + for (int i = 0; i < He3Selections::kHe3All; i++) + m_hAnalysis.get(HIST("he3_selections"))->GetXaxis()->SetBinLabel(i + 1, He3_selection_labels[i].c_str()); + + std::vector V0Type_labels = {"K0s", "#Lambda", "#bar{#Lambda}", "Photon"}; + for (int i = 0; i < V0Type::V0TypeAll; i++) + m_hAnalysis.get(HIST("v0_type"))->GetXaxis()->SetBinLabel(i + 1, V0Type_labels[i].c_str()); + } + + template + void fillV0Cand(const std::array& PV, const aod::V0s::iterator& v0, const Track&) + { + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0NoCut); + + auto posTrack = v0.posTrack_as(); + auto negTrack = v0.negTrack_as(); + if (!qualityTrackSelection(posTrack) || !qualityTrackSelection(negTrack)) { + return; + } + m_hAnalysis.fill(HIST("v0_selections"), V0Selections::kV0DaughterQuality); + + auto daughterTrackCovarianceA = getTrackParCov(posTrack); + auto daughterTrackCovarianceB = getTrackParCov(negTrack); + if (!initializeFitter(daughterTrackCovarianceA, daughterTrackCovarianceB)) { + return; + } + + std::array momPos, momNeg, momMother; + computeTrackMomentum(0, momPos); + computeTrackMomentum(1, momNeg); + computeMotherMomentum(momPos, momNeg, momMother); + ROOT::Math::SVector vec_decayVtx = m_fitter.getPCACandidate(); + std::array decayVtx = {static_cast(vec_decayVtx[0]), static_cast(vec_decayVtx[1]), static_cast(vec_decayVtx[2])}; + float alphaAP = computeAlphaAP(momMother, momPos, momNeg); + float qtAP = computeQtAP(momMother, momPos); + m_hAnalysis.fill(HIST("armenteros_plot_before_selections"), alphaAP, qtAP); + + gpu::gpustd::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]); + float dcaV0toPV = dcaToPV(PV, v0TrackParCov.trackParCov, dcaInfo); + float cosPA = RecoDecay::cpa(PV, decayVtx, momMother); + if (!qualitySelectionV0(dcaV0toPV, dcaV0daughters, radiusV0, cosPA)) { + return; + } + + // mass hypothesis + float massLambdaV0 = computeMassMother(o2::constants::physics::MassProton, o2::constants::physics::MassPionCharged, momPos, momNeg, momMother); + float massAntiLambdaV0 = computeMassMother(o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, momPos, momNeg, momMother); + float massK0sV0 = computeMassMother(o2::constants::physics::MassPionCharged, o2::constants::physics::MassPionCharged, momPos, momNeg, momMother); + 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); + } + 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 { + return; + } + + float dcaToPVpos = dcaToPV(PV, daughterTrackCovarianceA, dcaInfo); + if (std::abs(dcaToPVpos) < v0setting_dcaDaughtersToPV /*&& std::abs(dcaInfo[0]) < v0setting_dcaDaughtersToPV*/) { + return; + } + float dcaToPVneg = dcaToPV(PV, daughterTrackCovarianceB, dcaInfo); + if (std::abs(dcaToPVneg) < v0setting_dcaDaughtersToPV /*&& std::abs(dcaInfo[0]) < v0setting_dcaDaughtersToPV*/) { + 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); + + if (!setting_fillV0) { + return; + } + + if constexpr (isMC) { // MC + if (!posTrack.has_mcParticle() || !negTrack.has_mcParticle()) { + return; + } + + 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 + } + } + + m_hAnalysis.fill(HIST("isPositive"), true); + m_hAnalysis.fill(HIST("isPositive"), false); + } + + template + void fillKCand(const std::array& PV, const aod::Cascades::iterator& cascade, const Track&) + { + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kCascNoCut); + + auto v0Track = cascade.template v0_as(); + auto bachelorTrack = cascade.template bachelor_as(); + + auto itv0 = std::find_if(m_v0TrackParCovs.begin(), m_v0TrackParCovs.end(), [&](const V0TrackParCov& v0) { return v0.globalIndex == v0Track.globalIndex(); }); + if (itv0 == m_v0TrackParCovs.end()) { + return; + } + + auto v0TrackCovariance = itv0->trackParCov; + auto bachelorTrackCovariance = getTrackParCov(bachelorTrack); + if (!initializeFitter(v0TrackCovariance, bachelorTrackCovariance)) { + return; + } + + std::array momV0, momBachelor, momMother; + computeTrackMomentum(0, momV0); + computeTrackMomentum(1, momBachelor); + computeMotherMomentum(momV0, momBachelor, momMother); + + ROOT::Math::SVector vec_decayVtx = m_fitter.getPCACandidate(); + std::array decayVtx = {static_cast(vec_decayVtx[0]), static_cast(vec_decayVtx[1]), static_cast(vec_decayVtx[2])}; + + float dcaV0daughters = std::sqrt(std::abs(m_fitter.getChi2AtPCACandidate())); + float cosPA = RecoDecay::cpa(PV, decayVtx, momMother); + + if (!qualitySelectionCascade(dcaV0daughters, cosPA)) { + return; + } + // gpu::gpustd::array dcaInfo; + // float dcaToPVbachelor = dcaToPV(PV, bachelorTrackCovariance, dcaInfo); + + float massXi = computeMassMother(o2::constants::physics::MassLambda0, o2::constants::physics::MassPionCharged, momV0, momBachelor, momMother); + float massOmega = computeMassMother(o2::constants::physics::MassLambda0, o2::constants::physics::MassKaonCharged, momV0, momBachelor, momMother); + m_hAnalysis.fill(HIST("Xi_vs_Omega"), massOmega, massXi); + if (std::abs(massOmega - o2::constants::physics::MassOmegaMinus) > cascsetting_massWindowOmega) { + return; + } + m_hAnalysis.fill(HIST("massOmegaWithBkg"), massOmega); + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kAcceptedOmega); + if (std::abs(massXi - o2::constants::physics::MassXiMinus) < cascsetting_massWindowXi) { + return; + } // enhance purity by rejecting Xi background + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kRejectedXi); + if (std::abs(bachelorTrack.tpcNSigmaKa()) > cascsetting_nsigmatpc) { + return; + } + m_hAnalysis.fill(HIST("casc_selections"), CascSelections::kNSigmaTPC); + m_hAnalysis.fill(HIST("massOmega"), std::hypot(momMother[0], momMother[1]) * bachelorTrack.sign(), massOmega); + m_hAnalysis.fill(HIST("pmatchingKa"), bachelorTrack.sign() * bachelorTrack.tpcInnerParam(), (bachelorTrack.tpcInnerParam() - bachelorTrack.p()) / bachelorTrack.tpcInnerParam()); + m_hAnalysis.fill(HIST("nSigmaTPCKa"), bachelorTrack.sign() * std::hypot(momBachelor[0], momBachelor[1], momBachelor[2]), bachelorTrack.tpcNSigmaKa()); + + uint8_t partID_bachelor = PartID::ka; + + 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_hAnalysis.fill(HIST("isPositive"), bachelorTrack.p() > 0); + } + + template + void fillDeTable(const Track& track) + { + if (track.sign() > 0) { + return; + } + m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDeNoCut); + if (track.itsNCls() < desetting_nClsIts) { + return; + } + m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDeNClsIts); + if (!selectionPIDtpcDe(track)) { + return; + } + m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDePIDtpc); + if (!track.hasTOF() || std::abs(track.tofNSigmaDe()) > desetting_nsigmatof) { + return; + } + m_hAnalysis.fill(HIST("de_selections"), DeSelections::kDePIDtof); + m_hAnalysis.fill(HIST("nSigmaTPCDe"), track.p() * track.sign(), computeNSigmaDe(track)); + 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)); + m_hAnalysis.fill(HIST("pmatchingDe"), track.sign() * track.tpcInnerParam(), (track.tpcInnerParam() - track.p()) / track.tpcInnerParam()); + + uint8_t partID = PartID::de; + + if constexpr (isMC) { + if (!track.has_mcParticle() || track.sign() > 0) { + return; + } + + 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_hAnalysis.fill(HIST("isPositive"), track.sign() > 0); + } + + template + void fillHe3Table(const Track& track) + { + m_hAnalysis.fill(HIST("he3_selections"), He3Selections::kHe3NoCut); + + if (track.itsNCls() < he3setting_nClsIts) { + return; + } + m_hAnalysis.fill(HIST("he3_selections"), He3Selections::kHe3NClsIts); + if (!selectionPIDtpcHe3(track)) { + return; + } + m_hAnalysis.fill(HIST("he3_selections"), He3Selections::kHe3PIDtpc); + float tofMass = track.hasTOF() ? computeTOFmassHe3(track) : -999.f; + if (track.hasTOF() && (tofMass < he3setting_tofmasslow || tofMass > he3setting_tofmasshigh)) { + return; + } + uint8_t partID = PartID::he; + bool heliumPID = track.pidForTracking() == o2::track::PID::Helium3 || track.pidForTracking() == o2::track::PID::Alpha; + float correctedTPCinnerParam = (heliumPID && he3setting_compensatePIDinTracking) ? track.tpcInnerParam() / 2.f : track.tpcInnerParam(); + + m_hAnalysis.fill(HIST("he3_selections"), He3Selections::kHe3PIDtof); + m_hAnalysis.fill(HIST("nSigmaTPCHe"), track.p() * track.sign(), computeNSigmaHe3(track)); + m_hAnalysis.fill(HIST("nSigmaITSHe"), track.p() * track.sign(), m_responseITS.nSigmaITS(track.itsClusterSizes(), track.p(), track.eta())); + m_hAnalysis.fill(HIST("TOFmassHe"), track.p() * track.sign(), tofMass); + m_hAnalysis.fill(HIST("pmatchingHe"), track.sign() * correctedTPCinnerParam, (correctedTPCinnerParam - track.p()) / correctedTPCinnerParam); + + 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_hAnalysis.fill(HIST("isPositive"), track.sign() > 0); + } + + void fillPKPiTable(const TracksFullIU::iterator& track) + { + uint8_t partID = 0; + float tpcNSigma = 0.f; + if (std::abs(track.tpcNSigmaPi()) < v0setting_nsigmatpcPi && std::abs(track.tpcNSigmaKa()) > 3) { + partID = PartID::pi; + tpcNSigma = track.tpcNSigmaPi(); + m_hAnalysis.fill(HIST("nSigmaTPCPi"), track.p() * track.sign(), tpcNSigma); + } else if (std::abs(track.tpcNSigmaKa()) < cascsetting_nsigmatpc && (std::abs(track.tpcNSigmaPi()) > 3 /*&& std::abs(track.tpcNSigmaPr()) > 3*/)) { + partID = PartID::ka; + tpcNSigma = track.tpcNSigmaKa(); + m_hAnalysis.fill(HIST("nSigmaTPCKa"), track.p() * track.sign(), tpcNSigma); + } else if (std::abs(track.tpcNSigmaPr()) < v0setting_nsigmatpcPr && std::abs(track.tpcNSigmaKa()) > 3) { + partID = PartID::pr; + tpcNSigma = track.tpcNSigmaPr(); + m_hAnalysis.fill(HIST("nSigmaTPCPr"), track.p() * track.sign(), tpcNSigma); + } else { + return; + } + + if (setting_smallTable) { + m_ClusterStudiesTable( + track.p() * track.sign(), + track.eta(), + track.phi(), + track.itsClusterSizes(), + partID); + } else { + 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, + -999.f, // TofNSigma, + -999.f, // TofMass, + -999.f, // cosPA, + -999.f); // massMother + } + } + + // ========================================================================================================= + + void processDataV0Casc(CollisionsCustom const& collisions, TracksFullIU const& tracks, aod::V0s const& v0s, aod::Cascades const& cascades, aod::BCsWithTimestamps const&) + { + for (const auto& collision : collisions) { + auto bc = collision.bc_as(); + initCCDB(bc); + + if (!collisionSelection(collision)) { + continue; + } + + m_hAnalysis.fill(HIST("zVtx"), collision.posZ()); + std::array PV = {collision.posX(), collision.posY(), collision.posZ()}; + + const uint64_t collIdx = collision.globalIndex(); + auto v0Table_thisCollision = v0s.sliceBy(m_perCollisionV0, collIdx); + auto cascTable_thisCollision = cascades.sliceBy(m_perCollisionCascade, collIdx); + v0Table_thisCollision.bindExternalIndices(&tracks); + cascTable_thisCollision.bindExternalIndices(&tracks); + cascTable_thisCollision.bindExternalIndices(&v0s); + + if (setting_fillV0 || setting_fillK) { + m_v0TrackParCovs.clear(); + for (auto& v0 : v0Table_thisCollision) { + fillV0Cand(PV, v0, tracks); + } + } + if (setting_fillK) { // the v0 loops are needed for the Ks + for (auto& cascade : cascTable_thisCollision) { + fillKCand(PV, cascade, tracks); + } + } + } + } + PROCESS_SWITCH(LfTreeCreatorClusterStudies, processDataV0Casc, "process Data V0 and cascade", false); + + void processDataNuclei(CollisionsCustom const& collisions, TracksFullIU const& tracks) + { + for (const auto& collision : collisions) { + if (!collisionSelection(collision)) { + continue; + } + + m_hAnalysis.fill(HIST("zVtx"), collision.posZ()); + + const uint64_t collIdx = collision.globalIndex(); + auto TrackTable_thisCollision = tracks.sliceBy(m_perCol, collIdx); + TrackTable_thisCollision.bindExternalIndices(&tracks); + + for (auto track : TrackTable_thisCollision) { + if (!nucleiTrackSelection(track)) { + continue; + } + + if (setting_fillDe) + fillDeTable(track); + if (setting_fillHe3) + fillHe3Table(track); + } + } + } + PROCESS_SWITCH(LfTreeCreatorClusterStudies, processDataNuclei, "process Data Nuclei", false); + + /** + * @brief Produce a dataset with high purity p, K, #pi + */ + void processDataPKPi(CollisionsCustom const& collisions, TracksFullIU const& tracks) + { + for (const auto& collision : collisions) { + if (!collisionSelection(collision)) { + continue; + } + + m_hAnalysis.fill(HIST("zVtx"), collision.posZ()); + + const uint64_t collIdx = collision.globalIndex(); + auto TrackTable_thisCollision = tracks.sliceBy(m_perCol, collIdx); + TrackTable_thisCollision.bindExternalIndices(&tracks); + + for (auto track : TrackTable_thisCollision) { + if (!qualityTrackSelection(track)) { + continue; + } + + if (setting_fillPKPi) + fillPKPiTable(track); + } + } + } + PROCESS_SWITCH(LfTreeCreatorClusterStudies, processDataPKPi, "process Data p, K, pi", false); + + void processMcV0Casc(CollisionsCustom const& collisions, TracksFullIUMc const& tracks, aod::V0s const& v0s, aod::Cascades const& cascades, aod::BCsWithTimestamps const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + auto bc = collision.bc_as(); + initCCDB(bc); + + if (!collisionSelection(collision)) { + continue; + } + + m_hAnalysis.fill(HIST("zVtx"), collision.posZ()); + std::array PV = {collision.posX(), collision.posY(), collision.posZ()}; + + const uint64_t collIdx = collision.globalIndex(); + auto v0Table_thisCollision = v0s.sliceBy(m_perCollisionV0, collIdx); + auto cascTable_thisCollision = cascades.sliceBy(m_perCollisionCascade, collIdx); + v0Table_thisCollision.bindExternalIndices(&tracks); + cascTable_thisCollision.bindExternalIndices(&tracks); + cascTable_thisCollision.bindExternalIndices(&v0s); + + m_v0TrackParCovs.clear(); + if (setting_fillV0 || setting_fillK) { + for (auto& v0 : v0Table_thisCollision) { + fillV0Cand(PV, v0, tracks); + } + } + + if (setting_fillK) { // the v0 loops are needed for the Ks + for (auto& cascade : cascTable_thisCollision) { + fillKCand(PV, cascade, tracks); + } + } + } + } + PROCESS_SWITCH(LfTreeCreatorClusterStudies, processMcV0Casc, "process Mc V0 and cascade", false); + + void processMcNuclei(CollisionsCustom const& collisions, TracksFullIUMc const& tracks, aod::BCs const&, aod::McParticles const&) + { + for (const auto& collision : collisions) { + if (!collisionSelection(collision)) { + continue; + } + + m_hAnalysis.fill(HIST("zVtx"), collision.posZ()); + + const uint64_t collIdx = collision.globalIndex(); + auto TrackTable_thisCollision = tracks.sliceBy(m_perColMC, collIdx); + TrackTable_thisCollision.bindExternalIndices(&tracks); + + for (auto track : TrackTable_thisCollision) { + if (!nucleiTrackSelection(track)) { + continue; + } + + if (setting_fillDe) { + fillDeTable(track); + } + if (setting_fillHe3) { + fillHe3Table(track); + } + } + } + } + PROCESS_SWITCH(LfTreeCreatorClusterStudies, processMcNuclei, "process Mc Nuclei", false); + +}; // LfTreeCreatorClusterStudies + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index b56614499f0..8bcbc20c98a 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -27,6 +30,7 @@ #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" @@ -60,21 +64,52 @@ using std::array; using MyCollisions = soa::Join; using FullTracksExtIU = soa::Join; -using FullTracksExtPIDIU = soa::Join; +using FullTracksExtPIDIU = soa::Join; + +using ColwithEvTimes = o2::soa::Join; +using FullCols = 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; +}; + struct decay3bodyBuilder { Produces vtx3bodydata; - Produces kfvtx3bodydata; + 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, @@ -84,69 +119,44 @@ struct decay3bodyBuilder { kKfVtxCollIds, kKfVtxCharge, kKfVtxEta, - kKfVtxTPCPID, kKfVtxTPCNcls, kKfVtxTPCRows, + kKfVtxTPCPID, kKfVtxDCAxyPV, kKfVtxDCAzPV, - kKfVtxTrackPt, - kKfVtxNoV0, + kKfVtxV0MassConst, kKfVtxhasSV, kKfVtxDcaDau, kKfVtxDcaDauVtx, + kKfVtxDauPt, + kKfVtxRap, kKfVtxPt, kKfVtxMass, kKfVtxCosPA, kKfVtxCosPAXY, kKfVtxChi2geo, + kKfVtxTopoConstr, kKfVtxChi2topo, kKfNVtxSteps }; - HistogramRegistry registry{ - "registry", - {{"hEventCounter", "hEventCounter", {HistType::kTH1F, {{1, 0.0f, 1.0f}}}}, - {"hVtx3BodyCounter", "hVtx3BodyCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - {"hVtx3BodyCounterKFParticle", "hVtx3BodyCounterKFParticle", {HistType::kTH1F, {{20, 0.0f, 20.0f}}}}, - {"hBachelorTOFNSigmaDe", "", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"QA/Tracks/hTrackPosTPCNcls", "hTrackPosTPCNcls", {HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}}}, - {"QA/Tracks/hTrackNegTPCNcls", "hTrackNegTPCNcls", {HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}}}, - {"QA/Tracks/hTrackBachTPCNcls", "hTrackBachTPCNcls", {HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}}}, - {"QA/Tracks/hTrackPosHasTPC", "hTrackPosHasTPC", {HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}}}, - {"QA/Tracks/hTrackNegHasTPC", "hTrackNegHasTPC", {HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}}}, - {"QA/Tracks/hTrackBachHasTPC", "hTrackBachHasTPC", {HistType::kTH1F, {{2, -0.5, 1.5, "has TPC"}}}}, - {"QA/Tracks/hTrackProtonTPCPID", "hTrackProtonTPCPID", {HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}}}, - {"QA/Tracks/hTrackPionTPCPID", "hTrackPionTPCPID", {HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}}}, - {"QA/Tracks/hTrackBachTPCPID", "hTrackBachTPCPID", {HistType::kTH2F, {{100, -10.0f, 10.0f, "p/z (GeV/c)"}, {100, -10.0f, 10.0f, "TPC n#sigma"}}}}, - {"QA/Tracks/hTrackProtonPt", "hTrackProtonPt", {HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"QA/Tracks/hTrackPionPt", "hTrackPionPt", {HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"QA/Tracks/hTrackBachPt", "hTrackBachPt", {HistType::kTH1F, {{100, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}}}}, - {"QA/Event/hVtxXKF", "hVtxXKF", {HistType::kTH1F, {{500, -0.5f, 0.5f, "PV X (cm)"}}}}, - {"QA/Event/hVtxYKF", "hVtxYKF", {HistType::kTH1F, {{500, -0.5f, 0.5f, "PV Y (cm)"}}}}, - {"QA/Event/hVtxZKF", "hVtxZKF", {HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}}}, - {"QA/Event/hVtxCovXXKF", "hVtxCovXXKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XX) (cm^{2})"}}}}, - {"QA/Event/hVtxCovYYKF", "hVtxCovYYKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(YY) (cm^{2})"}}}}, - {"QA/Event/hVtxCovZZKF", "hVtxCovZZKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(ZZ) (cm^{2})"}}}}, - {"QA/Event/hVtxCovXYKF", "hVtxCovXYKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XY) (cm^{2})"}}}}, - {"QA/Event/hVtxCovXZKF", "hVtxCovXZKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XZ) (cm^{2})"}}}}, - {"QA/Event/hVtxCovYZKF", "hVtxCovYZKF", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(YZ) (cm^{2})"}}}}, - {"QA/Event/hVtxX", "hVtxX", {HistType::kTH1F, {{500, -0.5f, 0.5f, "PV X (cm)"}}}}, - {"QA/Event/hVtxY", "hVtxY", {HistType::kTH1F, {{500, -0.5f, 0.5f, "PV Y (cm)"}}}}, - {"QA/Event/hVtxZ", "hVtxZ", {HistType::kTH1F, {{500, -15.0f, 15.0f, "PV Z (cm)"}}}}, - {"QA/Event/hVtxCovXX", "hVtxCovXX", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XX) (cm^{2})"}}}}, - {"QA/Event/hVtxCovYY", "hVtxCovYY", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(YY) (cm^{2})"}}}}, - {"QA/Event/hVtxCovZZ", "hVtxCovZZ", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(ZZ) (cm^{2})"}}}}, - {"QA/Event/hVtxCovXY", "hVtxCovXY", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XY) (cm^{2})"}}}}, - {"QA/Event/hVtxCovXZ", "hVtxCovXZ", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(XZ) (cm^{2})"}}}}, - {"QA/Event/hVtxCovYZ", "hVtxCovYZ", {HistType::kTH1F, {{200, -0.005f, 0.005f, "PV cov(YZ) (cm^{2})"}}}}}, - }; + HistogramRegistry registry{"registry", {}}; // hypothesis - Configurable bachelorcharge{"bachelorcharge", 1, "charge of the bachelor track"}; + 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"}; Configurable useMatCorrType{"useMatCorrType", 0, "0: none, 1: TGeo, 2: LUT"}; // CCDB options @@ -156,50 +166,83 @@ struct decay3bodyBuilder { 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 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"}; // for KFParticle reconstruction struct : ConfigurableGroup { - Configurable kfDoDCAFitterPreMinimum{"kfDoDCAFitterPreMinimum", false, "KF: do DCAFitter pre-optimization before KF fit to include material corrections for decay3body vertex"}; - Configurable doTrackQA{"doTrackQA", false, "Flag to fill QA histograms for daughter tracks."}; - Configurable doVertexQA{"doVertexQA", false, "Flag to fill QA histograms for KFParticle PV."}; - Configurable maxEta{"maxEta", 0.9, "Maximum eta for daughter tracks"}; - Configurable mintpcNClsTrack{"mintpcNClsTrack", 70, "Minimum number of TPC clusters for proton and deuteron track"}; - Configurable mintpcNClsPion{"mintpcNClsPion", 70, "Minimum number of TPC clusters for pion track"}; - Configurable mintpcCrossedRows{"mintpcCrossedRows", 70, "Minimum number of TPC crossed rows for proton and deuteron track"}; - Configurable mintpcCrossedRowsPion{"mintpcCrossedRowsPion", 70, "Minimum number of TPC crossed rows for pion track"}; - Configurable mindcaXYPionPV{"mindcaXYPionPV", 0.1, "Minimum DCA XY of the pion daughter track to the PV"}; - Configurable mindcaXYProtonPV{"mindcaXYProtonPV", 0.1, "Minimum DCA XY of the proton daughter track to the PV"}; - Configurable mindcaZPionPV{"mindcaZPionPV", 0.1, "Minimum DCA Z of the pion daughter track to the PV"}; - Configurable mindcaZProtonPV{"mindcaZProtonPV", 0.1, "Minimum DCA Z of the proton daughter track to the PV"}; - Configurable maxtpcnSigma{"maxtpcnSigma", 5., "Maximum nSigma TPC for daughter tracks"}; - Configurable maxPionPt{"maxPionPt", 1.2, "Maximum pion pT"}; - Configurable minProtonPt{"minProtonPt", 1.2, "Maximum pion pT"}; - Configurable minDeuteronPt{"minDeuteronPt", 1.2, "Maximum pion pT"}; - Configurable lambdaMassWindow{"lambdaMassWindow", 0.01, "Window cut around lambda mass for proton-pion vertex with KFParticle"}; - Configurable maxDcaProDeu{"maxDcaProDeu", 1000., "Maximum geometrical distance between proton and deuteron at the SV in 3D with KFParticle"}; - Configurable maxDcaProPi{"maxDcaProPi", 1000., "Maximum geometrical distance between proton and pion at the SV in 3D with KFParticle"}; - Configurable maxDcaPiDe{"maxDcaPiDe", 1000., "Maximum geometrical distance between pion and deuteron at the SV in 3D with KFParticle"}; - Configurable maxDcaXYSVDau{"maxDcaXYSVDau", 1.0, "Maximum geometrical distance of daughter tracks from the SV in XY with KFParticle"}; - Configurable maxDcaXYSVPion{"maxDcaXYSVPion", 1.0, "Maximum geometrical distance of daughter tracks from the SV in XY with KFParticle"}; - Configurable minPtHt{"minPtHt", 0., "Minimum momentum for Hypertriton candidates with KFParticle"}; - Configurable maxPtHt{"maxPtHt", 36., "Maximum momentum for Hypertriton candidates with KFParticle"}; - Configurable minMassHt{"minMassHt", 2.96, "Minimum candidate mass with KFParticle"}; - Configurable maxMassHt{"maxMassHt", 3.05, "Maximum candidate mass with KFParticle"}; - Configurable maxChi2geo{"maxChi2geo", 1000., "Maximum chi2 geometrical with KFParticle"}; - Configurable minCosPA{"minCosPA", 0.5, "Minimum cosine pointing angle with KFParticle"}; - Configurable minCosPAxy{"minCosPAxy", 0.5, "Minimum cosine pointing angle in xy with KFParticle"}; - Configurable applyTopoSels{"applyTopoSels", false, "Apply selections constraining the mother to the PV with KFParticle"}; - Configurable maxChi2topo{"maxChi2topo", 1000., "Maximum chi2 topological with KFParticle"}; + 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., "Minimum momentum for Hypertriton candidates with KFParticle"}; + 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.5, "Minimum cosine pointing angle with KFParticle"}; + Configurable minCosPAxy{"kfparticleConfigurations.minCosPAxy", 0.5, "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"}; } kfparticleConfigurations; + //------------------------------------------------------------------ + // Sets for event mixing + 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; + // Filters and slices - Filter collisionFilter = (aod::evsel::sel8 == true && nabs(aod::collision::posZ) < 10.f); + // Filter collisionFilter = (aod::evsel::sel8 == true && nabs(aod::collision::posZ) < 10.f); Preslice perCollision = o2::aod::decay3body::collisionId; int mRunNumber; @@ -216,6 +259,30 @@ struct decay3bodyBuilder { 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); @@ -241,34 +308,6 @@ struct decay3bodyBuilder { lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(lutPath)); } - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(2, "TPCNcls"); - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(3, "HasSV"); - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(4, "DcaDau"); - registry.get(HIST("hVtx3BodyCounter"))->GetXaxis()->SetBinLabel(5, "CosPA"); - - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(2, "CollIds"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(3, "Charge"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(4, "Eta"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(5, "TPCpid"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(6, "TPCNcls"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(7, "TPCRows"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(8, "DCAxyPV"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(9, "DCAzPV"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(10, "TrackPt"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(11, "NoV0"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(12, "HasSV"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(13, "DcaDau"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(14, "DCADauVtx"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(15, "Pt"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(16, "Mass"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(17, "CosPA"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(18, "CosPAxy"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(19, "Chi2geo"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->GetXaxis()->SetBinLabel(20, "Chi2topo"); - registry.get(HIST("hVtx3BodyCounterKFParticle"))->LabelsOption("v"); - // Material correction in the DCA fitter if (useMatCorrType == 1) matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo; @@ -276,6 +315,84 @@ struct decay3bodyBuilder { matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; fitter3body.setMatCorrType(matCorr); + + // 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 (doprocessRun3withKFParticle == 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, {{22, 0.0f, 22.0f}}); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(1, "Total"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(2, "CollIds"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(3, "Charge"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(4, "Eta"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(5, "TPCNcls"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(6, "TPCRows"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(7, "TPCpid"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(8, "DCAxyPV"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(9, "DCAzPV"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(10, "V0MassConst"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(11, "HasSV"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(12, "DcaDau"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(13, "DCADauVtx"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(14, "DauPt"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(15, "Rapidity"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(16, "Pt"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(17, "Mass"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(18, "CosPA"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(19, "CosPAXY"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(20, "Chi2geo"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(21, "TopoConstr"); + hVtx3BodyCounterKFParticle->GetXaxis()->SetBinLabel(22, "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})"}}); + } } void initCCDB(aod::BCsWithTimestamps::iterator const& bc) @@ -334,7 +451,8 @@ struct decay3bodyBuilder { } // Initial TOF PID Paras, copied from PIDTOF.h - ccdb->setTimestamp(bc.timestamp()); + 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 @@ -365,8 +483,8 @@ struct decay3bodyBuilder { 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 " << bc.timestamp(); - o2::tof::ParameterCollection* paramCollection = ccdb->getForTimeStamp(parametrizationPath.value, bc.timestamp()); + 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) { @@ -385,24 +503,38 @@ struct decay3bodyBuilder { 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()), bc.timestamp()), true); - mRespParamsV2.setTimeShiftParameters(ccdb->getForTimeStamp(Form("%s/neg", timeShiftCCDBPath.value.c_str()), bc.timestamp()), false); + 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); } //------------------------------------------------------------------ - // Recalculate TOF PID for bachelors (deuteron), copied from PIDTOF.h - template - static float GetExpectedSigma(const o2::pid::tof::TOFResoParamsV2& parameters, const TrackType& track, const float tofSignal, const float collisionTimeRes, double mMassZ) + // Select decay3body candidate based on daughter track PID + template + bool checkPID(TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackBachelor, const double& tofNSigmaBach) { - const float& mom = track.p(); - if (mom <= 0) { - return -999.f; + if ((tofNSigmaBach < TofPidNsigmaMin || tofNSigmaBach > TofPidNsigmaMax) && trackBachelor.p() > minBachPUseTOF) { + return false; + } + if (std::abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut) { + return false; } - const float dpp = parameters[9] + parameters[10] * mom + parameters[11] * mMassZ / mom; // mean relative pt resolution; - const float sigma = dpp * tofSignal / (1. + mom * mom / (mMassZ * mMassZ)); - return std::sqrt(sigma * sigma + parameters[12] * parameters[12] / mom / mom + parameters[4] * parameters[4] + collisionTimeRes * collisionTimeRes); + 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; } //------------------------------------------------------------------ @@ -410,13 +542,13 @@ struct decay3bodyBuilder { template bool selectTPCPID(TTrack const& trackProton, TTrack const& trackPion, TTrack const& trackDeuteron) { - if (abs(trackProton.tpcNSigmaPr()) > kfparticleConfigurations.maxtpcnSigma) { + if (std::abs(trackProton.tpcNSigmaPr()) > kfparticleConfigurations.maxtpcnSigma) { return false; } - if (abs(trackPion.tpcNSigmaPi()) > kfparticleConfigurations.maxtpcnSigma) { + if (std::abs(trackDeuteron.tpcNSigmaDe()) > kfparticleConfigurations.maxtpcnSigma) { return false; } - if (abs(trackDeuteron.tpcNSigmaDe()) > kfparticleConfigurations.maxtpcnSigma) { + if (kfparticleConfigurations.useTPCforPion && std::abs(trackPion.tpcNSigmaPi()) > kfparticleConfigurations.maxtpcnSigma) { return false; } return true; @@ -424,109 +556,175 @@ struct decay3bodyBuilder { //------------------------------------------------------------------ // 3body candidate builder - template - void buildVtx3BodyDataTable(TCollisionTable const& collision, TTrackTable const& /*tracks*/, aod::Decay3Bodys const& decay3bodys, int bachelorcharge = 1) + template + void fillVtxCand(TCollisionTable const& collision, TTrackTable const& t0, TTrackTable const& t1, TTrackTable const& t2, int64_t decay3bodyId, int bachelorcharge = 1) { - for (auto& vtx3body : decay3bodys) { - - registry.fill(HIST("hVtx3BodyCounter"), kVtxAll); - - auto t0 = vtx3body.template track0_as(); - auto t1 = vtx3body.template track1_as(); - auto t2 = vtx3body.template track2_as(); + registry.fill(HIST("hVtx3BodyCounter"), kVtxAll); - if (t0.tpcNClsFound() < mintpcNCls && t1.tpcNClsFound() < mintpcNCls && t2.tpcNClsFound() < mintpcNCls) { - continue; + 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); } - registry.fill(HIST("hVtx3BodyCounter"), kVtxTPCNcls); - - // 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 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 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 Track0 = getTrackParCov(t0); - auto Track1 = getTrackParCov(t1); - auto Track2 = getTrackParCov(t2); - int n3bodyVtx = fitter3body.process(Track0, Track1, Track2); - if (n3bodyVtx == 0) { // discard this pair - continue; + if (enablePidCut) { + if (t2.sign() > 0) { + if (!checkPIDH3L(t0, t1, t2, tofNSigmaBach)) + return; + } else { + if (!checkPIDH3L(t1, t0, t2, tofNSigmaBach)) + return; } - registry.fill(HIST("hVtx3BodyCounter"), kVtxhasSV); + } - std::array pos = {0.}; - const auto& vtxXYZ = fitter3body.getPCACandidate(); - for (int i = 0; i < 3; i++) { - pos[i] = vtxXYZ[i]; - } + registry.fill(HIST("hVtx3BodyCounter"), kVtxPIDCut); - 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]}; + // Calculate DCA with respect to the collision associated to the V0, not individual tracks + gpu::gpustd::array dcaInfo; - if (fitter3body.getChi2AtPCACandidate() > dcavtxdau) { - continue; - } - registry.fill(HIST("hVtx3BodyCounter"), kVtxDcaDau); + 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]); - 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) { - continue; - } - registry.fill(HIST("hVtx3BodyCounter"), kVtxCosPA); + 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]); - // Recalculate the TOF PID - double tofNsigmaDe = -999; - static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps + 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]); - if (t2.hasTOF()) { - double bachExpTime = t2.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (t2.tofExpMom() * t2.tofExpMom())) / (kCSPEED * t2.tofExpMom()); // L*E/(p*c) = L/v - double tofsignal = t2.trackTime() * 1000 + bachExpTime; - // double bachtime = t2.trackTime() * 1000 + bachExpTime - collision.collisionTime(); // in ps + 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 + return; + } + registry.fill(HIST("hVtx3BodyCounter"), kVtxhasSV); - double expSigma = GetExpectedSigma(mRespParamsV2, t2, tofsignal, collision.collisionTimeRes(), o2::constants::physics::MassDeuteron); - double corrTofMom = t2.tofExpMom() / (1.f + t2.sign() * mRespParamsV2.getShift(t2.eta())); - double corrSignal = t2.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (corrTofMom * corrTofMom)) / (kCSPEED * corrTofMom) + mRespParamsV2.getTimeShift(t2.eta(), t2.sign()); - tofNsigmaDe = (tofsignal - collision.collisionTime() - corrSignal) / expSigma; - } + 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]}; - registry.fill(HIST("hBachelorTOFNSigmaDe"), t2.sign() * t2.p(), tofNsigmaDe); + if (fitter3body.getChi2AtPCACandidate() > dcavtxdau) { + return; + } + registry.fill(HIST("hVtx3BodyCounter"), kVtxDcaDau); - vtx3bodydata( - t0.globalIndex(), t1.globalIndex(), t2.globalIndex(), collision.globalIndex(), vtx3body.globalIndex(), - pos[0], pos[1], pos[2], - p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2], - fitter3body.getChi2AtPCACandidate(), - Track0dcaXY, Track1dcaXY, Track2dcaXY, - tofNsigmaDe); + 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; } + 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, aod::Decay3Bodys const& decay3bodys, int bachelorcharge) + template + void buildVtx3BodyDataTableKFParticle(TCollision const& collision, aod::Decay3Bodys const& decay3bodys, int bachelorcharge = 1) { LOG(debug) << "buildVtx3BodyDataTableKFParticle called."; + + // 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()); + } + for (auto& vtx3body : decay3bodys) { LOG(debug) << "Entered decay3bodys loop."; @@ -540,13 +738,9 @@ struct decay3bodyBuilder { auto trackParCovBach = getTrackParCov(trackBach); LOG(debug) << "Got all daughter tracks."; - KFPVertex kfpVertex = createKFPVertexFromCollision(collision); - KFParticle kfpv(kfpVertex); - LOG(debug) << "Created KF PV."; - bool isMatter = trackBach.sign() > 0 ? true : false; - // ---------- fill trackQA and vertexQA histograms + // ---------- fill track QA histograms ---------- if (kfparticleConfigurations.doTrackQA) { registry.fill(HIST("QA/Tracks/hTrackPosTPCNcls"), trackPos.tpcNClsFound()); registry.fill(HIST("QA/Tracks/hTrackNegTPCNcls"), trackNeg.tpcNClsFound()); @@ -554,6 +748,7 @@ struct decay3bodyBuilder { 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()); @@ -569,27 +764,6 @@ struct decay3bodyBuilder { registry.fill(HIST("QA/Tracks/hTrackBachPt"), trackBach.pt()); } - 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()); - } - // -------- 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()) { @@ -605,26 +779,18 @@ struct decay3bodyBuilder { registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCharge); // track eta - if (trackPos.eta() > kfparticleConfigurations.maxEta || trackNeg.eta() > kfparticleConfigurations.maxEta || trackBach.eta() > kfparticleConfigurations.maxEta) { + if (abs(trackPos.eta()) > kfparticleConfigurations.maxEta || abs(trackNeg.eta()) > kfparticleConfigurations.maxEta || abs(trackBach.eta()) > kfparticleConfigurations.maxEta) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxEta); - // TPC PID - if (isMatter && !selectTPCPID(trackPos, trackNeg, trackBach)) { // hypertriton (proton, pi-, deuteron) - continue; - } else if (!isMatter && !selectTPCPID(trackNeg, trackPos, trackBach)) { // anti-hypertriton (anti-proton, pi+, deuteron) - continue; - } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTPCPID); - // number of TPC clusters - if (trackBach.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsTrack) { + if (trackBach.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsBach) { continue; } - if (isMatter && (trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion || trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsTrack)) { + if (isMatter && ((kfparticleConfigurations.useTPCforPion && trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion) || trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsProton)) { continue; - } else if (!isMatter && (trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion || trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsTrack)) { + } else if (!isMatter && ((kfparticleConfigurations.useTPCforPion && trackPos.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsPion) || trackNeg.tpcNClsFound() <= kfparticleConfigurations.mintpcNClsProton)) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTPCNcls); @@ -633,14 +799,59 @@ struct decay3bodyBuilder { if (trackBach.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows) { continue; } - if (isMatter && (trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion || trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { + if (isMatter && ((kfparticleConfigurations.useTPCforPion && trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion) || trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { continue; - } else if (!isMatter && (trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion || trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { + } else if (!isMatter && ((kfparticleConfigurations.useTPCforPion && trackPos.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRowsPion) || trackNeg.tpcNClsCrossedRows() <= kfparticleConfigurations.mintpcCrossedRows)) { continue; } 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)) { + continue; + } + } 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)) { + continue; + } + } + 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()) { + auto originalcol = trackBach.template collision_as(); + tofNSigmaDeuteron = bachelorTOFPID.GetTOFNSigma(trackBach, originalcol, collision); + } + + // 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); + // track DCAxy and DCAz to PV associated with decay3body o2::dataformats::VertexBase mPV; o2::dataformats::DCA mDcaInfoCovPos; @@ -650,40 +861,48 @@ struct decay3bodyBuilder { auto trackParCovPVNeg = trackParCovNeg; auto trackParCovPVBach = trackParCovBach; mPV.setPos({collision.posX(), collision.posY(), collision.posZ()}); - mPV.setCov(collision.covXX(), collision.covXX(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()); + 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(); if (isMatter && (fabs(TrackNegDcaXY) <= kfparticleConfigurations.mindcaXYPionPV || fabs(TrackPosDcaXY) <= kfparticleConfigurations.mindcaXYProtonPV)) { continue; } else if (!isMatter && (fabs(TrackPosDcaXY) <= kfparticleConfigurations.mindcaXYPionPV || fabs(TrackNegDcaXY) <= kfparticleConfigurations.mindcaXYProtonPV)) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDCAxyPV); - if (isMatter && (fabs(mDcaInfoCovNeg.getZ()) <= kfparticleConfigurations.mindcaZPionPV || fabs(mDcaInfoCovPos.getZ()) <= kfparticleConfigurations.mindcaZProtonPV)) { + if (isMatter && (fabs(TrackNegDcaZ) <= kfparticleConfigurations.mindcaZPionPV || fabs(TrackPosDcaZ) <= kfparticleConfigurations.mindcaZProtonPV)) { continue; - } else if (!isMatter && (fabs(mDcaInfoCovPos.getZ()) <= kfparticleConfigurations.mindcaZPionPV || fabs(mDcaInfoCovNeg.getZ()) <= kfparticleConfigurations.mindcaZProtonPV)) { + } else if (!isMatter && (fabs(TrackPosDcaZ) <= kfparticleConfigurations.mindcaZPionPV || fabs(TrackNegDcaZ) <= kfparticleConfigurations.mindcaZProtonPV)) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDCAzPV); - - // pT selection - if (trackBach.pt() <= kfparticleConfigurations.minDeuteronPt) { - continue; - } - if (isMatter && (trackNeg.pt() > kfparticleConfigurations.maxPionPt || trackPos.pt() <= kfparticleConfigurations.minProtonPt)) { - continue; - } else if (!isMatter && (trackPos.pt() > kfparticleConfigurations.maxPionPt || trackNeg.pt() <= kfparticleConfigurations.minProtonPt)) { - continue; + // 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); + + // 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(); } - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTrackPt); // -------- STEP 2: fit vertex with proton and pion -------- // Fit vertex with DCA fitter to find minimization point --> uses material corrections implicitly - if (kfparticleConfigurations.kfDoDCAFitterPreMinimum) { + if (kfparticleConfigurations.doDCAFitterPreMinimum) { try { fitter3body.process(trackParCovPos, trackParCovNeg, trackParCovBach); } catch (std::runtime_error& e) { @@ -709,13 +928,13 @@ struct decay3bodyBuilder { } LOG(debug) << "KFParticle objects created from daughter tracks."; - // Construct V0 + // Construct V0 as intermediate step KFParticle KFV0; - int nDaughters = 2; - const KFParticle* Daughters[2] = {&kfpProton, &kfpPion}; + int nDaughtersV0 = 2; + const KFParticle* DaughtersV0[2] = {&kfpProton, &kfpPion}; KFV0.SetConstructMethod(2); try { - KFV0.Construct(Daughters, nDaughters); + KFV0.Construct(DaughtersV0, nDaughtersV0); } catch (std::runtime_error& e) { LOG(debug) << "Failed to create V0 vertex from daughter tracks." << e.what(); continue; @@ -726,40 +945,44 @@ struct decay3bodyBuilder { // check V0 mass and set mass constraint float massV0, sigmaMassV0; KFV0.GetMass(massV0, sigmaMassV0); - if (abs(massV0 - constants::physics::MassLambda) <= kfparticleConfigurations.lambdaMassWindow) { - continue; - } KFParticle KFV0Mass = KFV0; KFV0Mass.SetNonlinearMassConstraint(o2::constants::physics::MassLambda); float chi2massV0 = KFV0Mass.GetChi2() / KFV0Mass.GetNDF(); - LOG(debug) << "V0 mass constraint applied."; - registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxNoV0); + if (kfparticleConfigurations.useLambdaMassConstraint) { + LOG(debug) << "V0 mass constraint applied."; + KFV0 = KFV0Mass; + } + registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxV0MassConst); - // -------- STEP 3: fit vertex with V0 and deuteron -------- + // -------- 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."; - // Add deuteron to V0 vertex + // Construct 3body vertex + int nDaughters3body = 3; + const KFParticle* Daughters3body[3] = {&kfpProton, &kfpPion, &kfpDeuteron}; KFParticle KFHt; - KFHt = KFV0; KFHt.SetConstructMethod(2); try { - KFHt.AddDaughter(kfpDeuteron); + KFHt.Construct(Daughters3body, nDaughters3body); } catch (std::runtime_error& e) { - LOG(debug) << "Failed to create Hyper triton from V0 and deuteron." << e.what(); + LOG(debug) << "Failed to create Hyper triton 3-body vertex." << e.what(); continue; } + // 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: selections after geometrical vertex fit -------- - // Get updated daughter tracks - kfpProton.SetProductionVertex(KFHt); - kfpPion.SetProductionVertex(KFHt); - kfpDeuteron.SetProductionVertex(KFHt); - LOG(debug) << "Topo constraint applied to daughters."; - // daughter DCAs + // daughter DCAs with KF if ((kfpProton.GetDistanceFromParticle(kfpPion) >= kfparticleConfigurations.maxDcaProPi) || (kfpProton.GetDistanceFromParticle(kfpDeuteron) >= kfparticleConfigurations.maxDcaProDeu) || (kfpPion.GetDistanceFromParticle(kfpDeuteron) >= kfparticleConfigurations.maxDcaPiDe)) { continue; } @@ -768,13 +991,27 @@ struct decay3bodyBuilder { LOG(debug) << "DCA selection after vertex fit applied."; // daughter DCAs to vertex - if (kfpProton.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau || kfpPion.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVPion || kfpDeuteron.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau) { + if (kfpProton.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau || kfpPion.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau || kfpDeuteron.GetDistanceFromVertexXY(KFHt) >= kfparticleConfigurations.maxDcaXYSVDau) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDcaDauVtx); LOG(debug) << "DCA to vertex selection after vertex fit applied."; + // 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) { + continue; + } + registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxDauPt); + LOG(debug) << "Daughter pT selection applied."; + // -------- 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) { + continue; + } + registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxRap); + // Pt selection if (KFHt.GetPt() <= kfparticleConfigurations.minPtHt || KFHt.GetPt() >= kfparticleConfigurations.maxPtHt) { continue; @@ -790,13 +1027,13 @@ struct decay3bodyBuilder { registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxMass); // cos(PA) to PV - if (abs(cpaFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPA) { + if (std::abs(cpaFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPA) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCosPA); // cos(PA) xy to PV - if (abs(cpaXYFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPAxy) { + if (std::abs(cpaXYFromKF(KFHt, kfpv)) <= kfparticleConfigurations.minCosPAxy) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxCosPAXY); @@ -809,34 +1046,28 @@ struct decay3bodyBuilder { registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxChi2geo); LOG(debug) << "Basic selections after vertex fit done."; + // ctau before topo constraint + if (KFHt.GetLifeTime() > kfparticleConfigurations.maxctauHt) { + return; + } + // -------- STEP 6: topological constraint -------- /// Set vertex constraint and topological selection KFParticle KFHtPV = KFHt; - KFHtPV.SetProductionVertex(kfpv); - KFHtPV.TransportToDecayVertex(); + try { + KFHtPV.SetProductionVertex(kfpv); + } catch (std::runtime_error& e) { + LOG(error) << "Exception caught KFParticle process call: Topological constraint failed"; + continue; + } + registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxTopoConstr); // to check if topo constraint fails + // get topological chi2 float chi2topoNDF = KFHtPV.GetChi2() / KFHtPV.GetNDF(); - if (kfparticleConfigurations.applyTopoSels && chi2topoNDF >= kfparticleConfigurations.maxChi2topo) { + KFHtPV.TransportToDecayVertex(); + if (kfparticleConfigurations.applyTopoSel && chi2topoNDF >= kfparticleConfigurations.maxChi2topo) { continue; } registry.fill(HIST("hVtx3BodyCounterKFParticle"), kKfVtxChi2topo); - LOG(debug) << "Topological constraint applied."; - - //------------------------------------------------------------------ - // Recalculate the bachelor TOF PID - double tofNsigmaDe = -999; - static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps - if (trackBach.hasTOF()) { - double bachExpTime = trackBach.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (trackBach.tofExpMom() * trackBach.tofExpMom())) / (kCSPEED * trackBach.tofExpMom()); // L*E/(p*c) = L/v - double tofsignal = trackBach.trackTime() * 1000 + bachExpTime; - // double bachtime = trackBach.trackTime() * 1000 + bachExpTime - collision.collisionTime(); // in ps - - double expSigma = GetExpectedSigma(mRespParamsV2, trackBach, tofsignal, collision.collisionTimeRes(), o2::constants::physics::MassDeuteron); - double corrTofMom = trackBach.tofExpMom() / (1.f + trackBach.sign() * mRespParamsV2.getShift(trackBach.eta())); - double corrSignal = trackBach.length() * sqrt((o2::constants::physics::MassDeuteron * o2::constants::physics::MassDeuteron) + (corrTofMom * corrTofMom)) / (kCSPEED * corrTofMom) + mRespParamsV2.getTimeShift(trackBach.eta(), trackBach.sign()); - tofNsigmaDe = (tofsignal - collision.collisionTime() - corrSignal) / expSigma; - } - registry.fill(HIST("hBachelorTOFNSigmaDe"), trackBach.sign() * trackBach.p(), tofNsigmaDe); - LOG(debug) << "Bachelor TOF info calculated."; //------------------------------------------------------------------ // table filling @@ -845,7 +1076,9 @@ struct decay3bodyBuilder { // 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 @@ -855,12 +1088,16 @@ struct decay3bodyBuilder { KFHtPV.GetDecayLength(), KFHtPV.GetDecayLengthXY(), // decay length defined after topological constraint KFHtPV.GetDecayLength() / KFHtPV.GetErrDecayLength(), // ldl chi2geoNDF, chi2topoNDF, + KFHtPV.GetLifeTime(), // V0 massV0, chi2massV0, - // daughter momenta + 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), @@ -875,50 +1112,245 @@ struct decay3bodyBuilder { kfpProton.GetDistanceFromParticle(kfpDeuteron), kfpPion.GetDistanceFromParticle(kfpDeuteron), DCAvtxDaughters3D, - // daughter DCAs to PV propagated with material + // 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 - trackPos.sign(), - trackNeg.sign(), + kfpProton.GetQ(), + kfpPion.GetQ(), trackBach.sign(), - // bachelor TOF PID - tofNsigmaDe); + // 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."; + + // fill event counter hist (has selected candidate) + registry.fill(HIST("hEventCounterKFParticle"), 3.5); } } //------------------------------------------------------------------ - void processRun3(aod::Collision const& collision, FullTracksExtIU const& tracksIU, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) + void processRun3(ColwithEvTimes const& collisions, TrackExtPIDIUwithEvTimes const& /*tracksIU*/, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) { - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); + 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); + } + } - buildVtx3BodyDataTable(collision, tracksIU, decay3bodys, bachelorcharge); + for (auto& candVtx : vtxCandidates) { + fillVtx3BodyTable(candVtx); + } } PROCESS_SWITCH(decay3bodyBuilder, processRun3, "Produce DCA fitter decay3body tables", true); - void processRun3withKFParticle(soa::Filtered::iterator const& collision, FullTracksExtPIDIU const& /*tracksIU*/, aod::Decay3Bodys const& decay3bodys, aod::BCsWithTimestamps const&) + //------------------------------------------------------------------ + // Event-mixing background + void processRun3EM(FullCols const& collisions, TrackExtPIDIUwithEvTimes const& tracksIU, aod::BCsWithTimestamps const&) { - // for (const auto& collision : collisions) { - LOG(debug) << "Start of processRun3withKFParticle."; - auto bc = collision.bc_as(); - initCCDB(bc); - registry.fill(HIST("hEventCounter"), 0.5); - 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..."; - buildVtx3BodyDataTableKFParticle(collision, decay3bodys, bachelorcharge); - LOG(debug) << "End of processKFParticle."; - // } + + 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())) { + 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); + } + } + + // 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, 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&) + { + + 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())) { + 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); + } + for (auto const& [tpos, tneg, tbach] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(pionsplus, antiprotons, bachelors))) { + fillVtxCand(c1, tpos, tneg, tbach, -1, bachelorcharge); + } + } + + // 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) { + 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..."; + buildVtx3BodyDataTableKFParticle(collision, Decay3BodyTable_thisCollision, bachelorcharge); + LOG(debug) << "End of processKFParticle."; + } } PROCESS_SWITCH(decay3bodyBuilder, processRun3withKFParticle, "Produce KFParticle decay3body tables", false); }; +// build link from decay3body -> vtx3body struct decay3bodyDataLinkBuilder { Produces vtxdataLink; @@ -931,7 +1363,9 @@ struct decay3bodyDataLinkBuilder { for (int ii = 0; ii < decay3bodytable.size(); ii++) lIndices[ii] = -1; for (auto& vtxdata : vtxdatatable) { - lIndices[vtxdata.decay3bodyId()] = vtxdata.globalIndex(); + if (vtxdata.decay3bodyId() != -1) { + lIndices[vtxdata.decay3bodyId()] = vtxdata.globalIndex(); + } } for (int ii = 0; ii < decay3bodytable.size(); ii++) { vtxdataLink(lIndices[ii]); @@ -939,30 +1373,51 @@ struct decay3bodyDataLinkBuilder { } }; +struct kfdecay3bodyDataLinkBuilder { + Produces kfvtxdataLink; + + void init(InitContext const&) {} + + // build Decay3Body -> KFDecay3BodyData link table + void process(aod::Decay3Bodys const& decay3bodytable, aod::KFVtx3BodyDatas const& vtxdatatable) + { + 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]); + } + } +}; + struct decay3bodyLabelBuilder { Produces vtxlabels; Produces vtxfulllabels; + Produces kfvtxlabels; + Produces kfvtxfulllabels; - // 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)"}}}}, - }, - }; + HistogramRegistry registry{"registry", {}}; void init(InitContext const&) { - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(2, "Have Same MotherTrack"); - registry.get(HIST("hLabelCounter"))->GetXaxis()->SetBinLabel(3, "True H3L"); + 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)"}}); + } } Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; @@ -1059,6 +1514,60 @@ struct decay3bodyLabelBuilder { } } PROCESS_SWITCH(decay3bodyLabelBuilder, processBuildLabels, "Produce MC label tables", false); + + void processBuildKFLabels(aod::KFDecay3BodysLinked const& decay3bodys, aod::KFVtx3BodyDatas const& vtx3bodydatas, MCLabeledTracksIU const&, aod::McParticles const&) + { + std::vector lIndices; + lIndices.reserve(vtx3bodydatas.size()); + for (int ii = 0; ii < vtx3bodydatas.size(); ii++) { + lIndices[ii] = -1; + } + + 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]); + } + } + PROCESS_SWITCH(decay3bodyLabelBuilder, processBuildKFLabels, "Produce MC KF label tables", false); }; struct decay3bodyInitializer { @@ -1071,6 +1580,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) return WorkflowSpec{ 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 8e2733a8f24..e00ff5476a8 100644 --- a/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx +++ b/PWGLF/TableProducer/Nuspex/ebyeMaker.cxx @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -41,18 +43,22 @@ #include "PWGLF/DataModel/LFEbyeTables.h" #include "TDatabasePDG.h" +#include "TFormula.h" 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 BCsWithRun2Info = soa::Join; namespace { constexpr int kNpart = 2; +constexpr float trackSels[10]{/* 60, */ 80, 100, 2, 3, /* 4, */ 0.05, 0.1, /* 0.15, */ 0.5, 1, /* 1.5, */ 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 estimatorsCorrelationCoef[2]{-0.669108, 1.04489}; constexpr double estimatorsSigmaPars[4]{0.933321, 0.0416976, -0.000936344, 8.92179e-06}; @@ -60,7 +66,10 @@ 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"}; +static const std::vector particleNamesPar{"p", "d"}; +static const std::vector trackSelsNames{"tpcClsMid", "tpcClsTight", "chi2TpcTight", "chi2TpcMid", "dcaxyTight", "dcaxyMid", "dcazTight", "dcazMid", "tpcNsigmaTight", "tpcNsigmaMid"}; +static const std::vector dcaSelsNames{"dcaxy", "dcaz", "dca"}; +static const std::vector particleName{"p"}; std::array, kNpart> tofMass; void momTotXYZ(std::array& momA, std::array const& momB, std::array const& momC) { @@ -136,9 +145,14 @@ struct CandidateTrack { float eta = -999.f; uint8_t mass = 100; float dcapv = 0; + float dcaxypv = 0; + float dcazpv = 0; uint8_t tpcncls = 0; + float tpcchi2 = 0; float tpcnsigma = -999.f; + float itsnsigma = -999.f; float tofmass = -999.f; + float outerPID = -999.f; float genpt = -999.f; float geneta = -999.f; int pdgcode = -999; @@ -147,12 +161,39 @@ struct CandidateTrack { int64_t globalIndex = -999; }; +enum selBits { + kTPCclsTight = BIT(0), + kTPCclsMid = BIT(1), + kChi2TPCTight = BIT(2), + kChi2TPCMid = BIT(3), + kDCAxyTight = BIT(4), + kDCAxyMid = BIT(5), + kDCAzTight = BIT(6), + kDCAzMid = BIT(7), + kITSPIDTight = BIT(8), + kITSPIDMid = BIT(9), + kTPCPIDTight = BIT(10), + 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 ebyeMaker { Produces collisionEbyeTable; + Produces miniCollTable; Produces nucleiEbyeTable; Produces lambdaEbyeTable; + Produces miniTrkTable; Produces mcNucleiEbyeTable; Produces mcLambdaEbyeTable; + Produces mcMiniTrkTable; std::mt19937 gen32; std::vector candidateV0s; std::array, 2> candidateTracks; @@ -161,10 +202,11 @@ struct ebyeMaker { int mRunNumber; float d_bz; + uint8_t nTrackletsColl; // o2::base::MatLayerCylSet* lut = nullptr; 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> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 2, 6, particleNamesPar, betheBlochParNames}, "TPC 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"}; @@ -182,8 +224,10 @@ struct ebyeMaker { 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 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 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)"}; @@ -203,7 +247,8 @@ struct ebyeMaker { 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 trackDcaCut{"trackDcaCut", 0.1f, "DCA antid to PV"}; + Configurable trackChi2Cut{"trackChi2Cut", 4.f, "Maximum chi2/ncls in TPC"}; + Configurable> cfgDcaSels{"cfgDcaSels", {dcaSels, 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"}; @@ -233,9 +278,13 @@ struct ebyeMaker { Configurable v0setting_nsigmatpc{"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, 10, particleName, trackSelsNames}, "Track selections"}; + std::array ptMin; std::array ptTof; std::array ptMax; @@ -247,6 +296,7 @@ struct ebyeMaker { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Preslice perCollisionTracksFull = o2::aod::track::collisionId; + Preslice perCollisionTracksFullPID = o2::aod::track::collisionId; Preslice perCollisionTracksFullIU = o2::aod::track::collisionId; Preslice perCollisionV0 = o2::aod::v0::collisionId; Preslice perCollisionMcParts = o2::aod::mcparticle::mcCollisionId; @@ -264,7 +314,7 @@ struct ebyeMaker { track.tpcNClsShared() > v0trackNsharedClusTpc) { return false; } - if (doprocessRun2 || doprocessMcRun2) { + if (doprocessRun2 || doprocessMiniRun2 || doprocessMcRun2 || doprocessMiniMcRun2) { if (!(track.trackType() & o2::aod::track::Run2Track) || !(track.flags() & o2::aod::track::TPCrefit)) { return false; @@ -289,11 +339,11 @@ struct ebyeMaker { track.tpcNClsFound() < trackNclusTpcCut || track.tpcNClsCrossedRows() < trackNcrossedRows || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || - track.tpcChi2NCl() > 4.f || + track.tpcChi2NCl() > trackChi2Cut || track.itsChi2NCl() > 36.f) { return false; } - if (doprocessRun2 || doprocessMcRun2) { + if (doprocessRun2 || doprocessMiniRun2 || doprocessMcRun2 || doprocessMiniMcRun2) { if (!(track.trackType() & o2::aod::track::Run2Track) || !(track.flags() & o2::aod::track::TPCrefit) || !(track.flags() & o2::aod::track::ITSrefit)) { @@ -313,6 +363,11 @@ struct ebyeMaker { return sum / track.itsNCls(); } + float dcaSigma(float const& pt) + { + return 0.0105 + 0.0350 / std::pow(std::abs(pt), 1.1); + } + template void initCCDB(Bc const& bc) { @@ -323,13 +378,40 @@ struct ebyeMaker { auto timestamp = bc.timestamp(); o2::parameters::GRPObject* grpo = 0x0; o2::parameters::GRPMagField* grpmag = 0x0; - if (doprocessRun2 || doprocessMcRun2) { + if (doprocessRun2 || doprocessMcRun2 || doprocessMiniRun2 || doprocessMiniMcRun2) { 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); @@ -347,6 +429,80 @@ struct ebyeMaker { // o2::base::Propagator::Instance()->setMatLUT(lut); } + template + float getOuterPID(T const& track) + { + if (doprocessMiniRun2 || doprocessMiniMcRun2) { + if (track.hasTOF() && track.pt() > antipPtTof) + return track.tofNSigmaPr(); + // else if (track.pt() < antipPtTof && track.pt() > antipPtMin) { + // return track.tpcNSigmaPr() > -4.f ? track.tpcNSigmaPr() : -999.f; + // } + else + return -999.f; + } + return -999.f; + } + + 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 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 { + v0m = multFV0A * Run2V0MInfo.mhVtxAmpCorrV0A->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0A->FindFixBin(zvtx)) + + multFV0C * Run2V0MInfo.mhVtxAmpCorrV0C->GetBinContent(Run2V0MInfo.mhVtxAmpCorrV0C->FindFixBin(zvtx)); + } + return v0m; + } + + template + int getTrackSelMask(T const& track) + { + int mask = 0x0; + if (track.tpcncls > cfgTrackSels->get("tpcClsTight")) + mask |= kTPCclsTight; + else if (track.tpcncls > cfgTrackSels->get("tpcClsMid")) + mask |= kTPCclsMid; + if (track.tpcchi2 < cfgTrackSels->get("chi2TpcTight")) + mask |= kChi2TPCTight; + else if (track.tpcchi2 < cfgTrackSels->get("chi2TpcMid")) + mask |= kChi2TPCMid; + if (std::abs(track.dcaxypv) < cfgTrackSels->get("dcaxyTight") * (constDCASel ? 1. : dcaSigma(track.pt))) + mask |= kDCAxyTight; + else if (std::abs(track.dcaxypv) < cfgTrackSels->get("dcaxyMid") * (constDCASel ? 1. : dcaSigma(track.pt))) + mask |= kDCAxyMid; + if (std::abs(track.dcazpv) < cfgTrackSels->get("dcazTight")) + mask |= kDCAzTight; + else if (std::abs(track.dcazpv) < cfgTrackSels->get("dcazMid")) + mask |= kDCAzMid; + if (std::abs(track.tpcnsigma) < cfgTrackSels->get("tpcNsigmaTight")) + mask |= kTPCPIDTight; + else if (std::abs(track.tpcnsigma) < cfgTrackSels->get("tpcNsigmaMid")) + mask |= kTPCPIDMid; + // if (track.itsnsigma < 2) mask |= kITSPIDTight; + // else if (track.itsnsigma < 3) mask |= kITSPIDMid; + return mask; + } + void init(o2::framework::InitContext&) { @@ -376,9 +532,11 @@ struct ebyeMaker { 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) { + } 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 @@ -386,6 +544,7 @@ struct ebyeMaker { // 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, {momAxis, tpcAxis}); + histos.add("QA/tpcSignalPr", ";#it{p}_{TPC} (GeV/#it{c});d#it{E}/d#it{x}_{TPC} (a.u.)", HistType::kTH2F, {momAxis, tpcAxis}); 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}); 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}); @@ -399,17 +558,36 @@ struct ebyeMaker { tofMassMax = std::array{antipTofMassMax, antidTofMassMax}; } + template + auto tracksSlice(T const& tracksAll, uint64_t const& collId) + { + if (doprocessRun3 || doprocessMcRun3) + return tracksAll.sliceBy(perCollisionTracksFullIU, collId); + else if (doprocessRun2 || doprocessMcRun2) + return tracksAll.sliceBy(perCollisionTracksFull, collId); + else + return tracksAll.sliceBy(perCollisionTracksFullPID, collId); + } + template void 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()); + auto tracks = tracksSlice(tracksAll, collision.globalIndex()); candidateTracks[0].clear(); candidateTracks[1].clear(); candidateV0s.clear(); gpu::gpustd::array dcaInfo; + uint8_t nTracklets[2]{0, 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; } @@ -419,7 +597,13 @@ struct ebyeMaker { auto dca = std::hypot(dcaInfo[0], dcaInfo[1]); auto trackPt = trackParCov.getPt(); auto trackEta = trackParCov.getEta(); - if (dca > trackDcaCut) { + 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 continue; } histos.fill(HIST("QA/tpcSignal"), track.tpcInnerParam(), track.tpcSignal()); @@ -469,157 +653,170 @@ struct ebyeMaker { candTrack.eta = trackEta; candTrack.mass = iP; candTrack.dcapv = dca; + candTrack.dcaxypv = dcaInfo[0]; + candTrack.dcazpv = dcaInfo[1]; + candTrack.tpcchi2 = track.tpcChi2NCl(); candTrack.tpcncls = track.tpcNClsFound(); candTrack.tpcnsigma = nSigmaTPC; candTrack.tofmass = hasTof ? mass : -999.f; candTrack.globalIndex = track.globalIndex(); + candTrack.outerPID = nSigmaTPC; candidateTracks[iP].push_back(candTrack); } } } + if (doprocessRun2 || doprocessMcRun2 || doprocessMiniRun2 || doprocessMiniMcRun2) { + histos.fill(HIST("QA/nTrklCorrelation"), nTracklets[0], nTracklets[1]); + nTrackletsColl = nTracklets[1]; + } - std::vector trkId; - for (const auto& v0 : V0s) { - auto posTrack = v0.posTrack_as(); - auto negTrack = v0.negTrack_as(); + if (lambdaPtMax > lambdaPtMin) { + 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; + 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) { + if (doprocessRun2 || doprocessMiniRun2 || doprocessMcRun2 || doprocessMiniMcRun2) { + 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 posTrackCov = getTrackParCov(posTrack); - auto negTrackCov = getTrackParCov(negTrack); + auto& posPropTrack = fitter.getTrack(0); + auto& negPropTrack = fitter.getTrack(1); - int nCand = 0; - try { - nCand = fitter.process(posTrackCov, negTrackCov); - } catch (...) { - LOG(error) << "Exception caught in DCA fitter process call!"; - continue; - } - if (nCand == 0) { - continue; - } + std::array momPos; + std::array momNeg; + std::array momV0; + posPropTrack.getPxPyPzGlo(momPos); + negPropTrack.getPxPyPzGlo(momNeg); + momTotXYZ(momV0, momPos, momNeg); - auto& posPropTrack = fitter.getTrack(0); - auto& negPropTrack = fitter.getTrack(1); + auto ptV0 = std::hypot(momV0[0], momV0[1]); + if (ptV0 < lambdaPtMin || ptV0 > lambdaPtMax) { + continue; + } - std::array momPos; - std::array momNeg; - std::array momV0; - posPropTrack.getPxPyPzGlo(momPos); - negPropTrack.getPxPyPzGlo(momNeg); - momTotXYZ(momV0, momPos, momNeg); + auto etaV0 = etaFromMom(momPos, momNeg); + if (std::abs(etaV0) > etaMax) { + continue; + } - auto ptV0 = std::hypot(momV0[0], momV0[1]); - if (ptV0 < lambdaPtMin || ptV0 > lambdaPtMax) { - 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), 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 tpcSigPr = matter ? posTrack.tpcSignal() : negTrack.tpcSignal(); + + if (std::abs(nSigmaTPCPos) > v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > v0setting_nsigmatpc) { + continue; + } - auto etaV0 = etaFromMom(momPos, momNeg); - if (std::abs(etaV0) > etaMax) { - continue; - } + // veto on K0s mass + if (std::abs(mK0Short - o2::constants::physics::MassK0Short) < vetoMassK0Short) { + 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), 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); - - if (std::abs(nSigmaTPCPos) > v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > v0setting_nsigmatpc) { - continue; - } + float dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); + if (dcaV0dau > v0setting_dcav0dau) { + continue; + } - // veto on K0s mass - if (std::abs(mK0Short - o2::constants::physics::MassK0Short) < vetoMassK0Short) { - continue; - } + std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; + const auto& vtx = fitter.getPCACandidate(); - float dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); - if (dcaV0dau > v0setting_dcav0dau) { - continue; - } + float radiusV0 = std::hypot(vtx[0], vtx[1]); + if (radiusV0 < v0setting_radius || radiusV0 > v0radiusMax) { + continue; + } - std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; - const auto& vtx = fitter.getPCACandidate(); + 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) { + continue; + } - float radiusV0 = std::hypot(vtx[0], vtx[1]); - if (radiusV0 < v0setting_radius || radiusV0 > v0radiusMax) { - continue; - } + double cosPA = RecoDecay::cpa(primVtx, vtx, momV0); + if (cosPA < v0setting_cospa) { + 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()); - if (std::abs(dcaV0Pv) > v0setting_dcav0pv) { - 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) { + continue; + } - double cosPA = RecoDecay::cpa(primVtx, vtx, momV0); - if (cosPA < v0setting_cospa) { - 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; + } - 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) { - 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) { + 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; - } + if (std::abs(mLambda - o2::constants::physics::MassLambda0) > lambdaMassCut) { // for QA histograms + continue; + } + histos.fill(HIST("QA/massLambda"), centrality, ptV0, mLambda); - 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) { - continue; - } + histos.fill(HIST("QA/tpcSignalPr"), matter > 0. ? posTrack.tpcInnerParam() : negTrack.tpcInnerParam(), tpcSigPr); - if (std::abs(mLambda - o2::constants::physics::MassLambda0) > lambdaMassCut) { // for QA histograms - continue; + CandidateV0 candV0; + candV0.pt = matter > 0. ? ptV0 : -ptV0; + candV0.eta = etaV0; + candV0.mass = mLambda; + candV0.cpa = cosPA; + candV0.dcav0daugh = dcaV0dau; + candV0.dcav0pv = dcaV0Pv; + candV0.dcanegpv = negDcaToPv; + candV0.dcapospv = posDcaToPv; + candV0.tpcnsigmaneg = nSigmaTPCNeg; + candV0.tpcnsigmapos = nSigmaTPCPos; + candV0.globalIndexPos = posTrack.globalIndex(); + candV0.globalIndexNeg = negTrack.globalIndex(); + candidateV0s.push_back(candV0); } - histos.fill(HIST("QA/massLambda"), centrality, ptV0, mLambda); - - CandidateV0 candV0; - candV0.pt = matter > 0. ? ptV0 : -ptV0; - candV0.eta = etaV0; - candV0.mass = mLambda; - candV0.cpa = cosPA; - candV0.dcav0daugh = dcaV0dau; - candV0.dcav0pv = dcaV0Pv; - candV0.dcanegpv = negDcaToPv; - candV0.dcapospv = posDcaToPv; - candV0.tpcnsigmaneg = nSigmaTPCNeg; - candV0.tpcnsigmapos = nSigmaTPCPos; - candV0.globalIndexPos = posTrack.globalIndex(); - candV0.globalIndexNeg = negTrack.globalIndex(); - candidateV0s.push_back(candV0); } } @@ -637,7 +834,7 @@ struct ebyeMaker { 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)) + if (((mcTrack.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcTrack.flags() & 0x2) || (mcTrack.flags() & 0x1)) continue; if (!mcTrack.isPhysicalPrimary()) continue; @@ -670,7 +867,7 @@ struct ebyeMaker { } if (!posMother.isPhysicalPrimary() && !posMother.has_mothers()) continue; - if (((posMother.flags() & 0x8) && doprocessMcRun2) || (posMother.flags() & 0x2) || (posMother.flags() & 0x1)) + if (((posMother.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (posMother.flags() & 0x2) || (posMother.flags() & 0x1)) continue; auto genPt = std::hypot(posMother.px(), posMother.py()); @@ -693,7 +890,7 @@ struct ebyeMaker { if (std::abs(genEta) > etaMax) { continue; } - if (((mcPart.flags() & 0x8) && doprocessMcRun2) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1)) + if (((mcPart.flags() & 0x8) && (doprocessMcRun2 || doprocessMiniMcRun2)) || (mcPart.flags() & 0x2) || (mcPart.flags() & 0x1)) continue; auto pdgCode = mcPart.pdgCode(); if (std::abs(pdgCode) == 3122) { @@ -718,7 +915,7 @@ struct ebyeMaker { if (it != candidateV0s.end()) { continue; } else { - LOGF(info, "not found!"); + LOGF(debug, "not found!"); candidateV0s.emplace_back(candV0); } } else if (std::abs(pdgCode) == partPdg[0] || std::abs(pdgCode) == partPdg[1]) { @@ -790,22 +987,24 @@ struct ebyeMaker { candidateV0.globalIndexPos); } - for (auto& candidateTrack : candidateTracks[1]) { // deuterons - nucleiEbyeTable( - collisionEbyeTable.lastIndex(), - candidateTrack.pt, - candidateTrack.eta, - candidateTrack.mass, - candidateTrack.dcapv, - candidateTrack.tpcncls, - candidateTrack.tpcnsigma, - candidateTrack.tofmass); + 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); + } } } } PROCESS_SWITCH(ebyeMaker, processRun3, "process (Run 3)", false); - void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::V0s const& V0s, BCsWithRun2Info const&) + void processRun2(soa::Join const& collisions, TracksFull const& tracks, aod::V0s const& V0s, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, BCsWithRun2Info const&) { for (const auto& collision : collisions) { auto bc = collision.bc_as(); @@ -820,8 +1019,9 @@ struct ebyeMaker { if (kUseTPCPileUpCut && !(bc.eventCuts() & BIT(aod::Run2EventCuts::kTPCPileUp))) continue; - auto centrality = collision.centRun2V0M(); - if (!(collision.sel7() && collision.alias_bit(kINT7)) && (!kINT7Intervals || (kINT7Intervals && ((centrality >= 10 && centrality < 30) || centrality > 50)))) + float v0m = getV0M(bc.globalIndex(), collision.posZ(), fv0as, fv0cs); + float cV0M = Run2V0MInfo.mhMultSelCalib->GetBinContent(Run2V0MInfo.mhMultSelCalib->FindFixBin(v0m)); + if (!(collision.sel7() && collision.alias_bit(kINT7)) && (!kINT7Intervals || (kINT7Intervals && ((cV0M >= 10 && cV0M < 30) || cV0M > 50)))) continue; auto centralityCl0 = collision.centRun2CL0(); @@ -829,7 +1029,7 @@ struct ebyeMaker { 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) { + if (cV0M < center - deltaEstimatorNsigma[0] * sigma || cV0M > center + deltaEstimatorNsigma[1] * sigma) { continue; } } @@ -841,12 +1041,12 @@ struct ebyeMaker { V0Table_thisCollision.bindExternalIndices(&tracks); auto multTracklets = collision.multTracklets(); - fillRecoEvent(collision, tracks, V0Table_thisCollision, centrality); + fillRecoEvent(collision, tracks, V0Table_thisCollision, cV0M); - histos.fill(HIST("QA/V0MvsCL0"), centralityCl0, centrality); - histos.fill(HIST("QA/trackletsVsV0M"), centrality, multTracklets); + histos.fill(HIST("QA/V0MvsCL0"), centralityCl0, cV0M); + histos.fill(HIST("QA/trackletsVsV0M"), cV0M, multTracklets); - collisionEbyeTable(centrality, collision.posZ()); + collisionEbyeTable(cV0M, collision.posZ()); for (auto& candidateV0 : candidateV0s) { lambdaEbyeTable( @@ -865,21 +1065,71 @@ struct ebyeMaker { candidateV0.globalIndexPos); } - for (auto& candidateTrack : candidateTracks[1]) { // deuterons - nucleiEbyeTable( - collisionEbyeTable.lastIndex(), - candidateTrack.pt, - candidateTrack.eta, - candidateTrack.mass, - candidateTrack.dcapv, - candidateTrack.tpcncls, - candidateTrack.tpcnsigma, - candidateTrack.tofmass); + 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); + } } } } PROCESS_SWITCH(ebyeMaker, processRun2, "process (Run 2)", false); + void processMiniRun2(soa::Join const& collisions, TracksFullPID const& tracks, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::V0s const& V0s, 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; + + 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()); + + const uint64_t collIdx = collision.globalIndex(); + auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); + V0Table_thisCollision.bindExternalIndices(&tracks); + + fillRecoEvent(collision, tracks, V0Table_thisCollision, cV0M); + + uint8_t trigger = collision.alias_bit(kINT7) ? 0x1 : 0x0; + miniCollTable(static_cast(collision.posZ() * 10), trigger, nTrackletsColl, cV0M); + + for (auto& candidateTrack : candidateTracks[0]) { // protons + auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); + float outerPID = getOuterPID(tk); + 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, 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&) { for (auto& collision : collisions) { @@ -929,26 +1179,28 @@ struct ebyeMaker { candidateV0.isreco); } - for (auto& candidateTrack : candidateTracks[1]) { // deuterons - 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 (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); + } } } } 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::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::FV0As const& fv0as, aod::FV0Cs const& fv0cs, aod::McParticles const& mcParticles, aod::McTrackLabels const& mcLab, BCsWithRun2Info const&) { for (auto& collision : collisions) { auto bc = collision.bc_as(); @@ -960,7 +1212,8 @@ struct ebyeMaker { if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) continue; - auto centrality = collision.centRun2V0M(); + 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()); @@ -968,10 +1221,10 @@ struct ebyeMaker { auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); V0Table_thisCollision.bindExternalIndices(&tracks); - fillMcEvent(collision, tracks, V0Table_thisCollision, centrality, mcParticles, mcLab); + fillMcEvent(collision, tracks, V0Table_thisCollision, cV0M, mcParticles, mcLab); fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); - collisionEbyeTable(centrality, collision.posZ()); + collisionEbyeTable(cV0M, collision.posZ()); for (auto& candidateV0 : candidateV0s) { mcLambdaEbyeTable( @@ -994,24 +1247,77 @@ struct ebyeMaker { candidateV0.isreco); } - for (auto& candidateTrack : candidateTracks[1]) { // deuterons - mcNucleiEbyeTable( - collisionEbyeTable.lastIndex(), + 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); + } + } + } + } + PROCESS_SWITCH(ebyeMaker, processMcRun2, "process MC (Run 2)", false); + + void processMiniMcRun2(soa::Join const& collisions, aod::McCollisions const& /*mcCollisions*/, TracksFullPID const& tracks, aod::FV0As const& fv0as, aod::FV0Cs const& fv0cs, 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); + + if (std::abs(collision.posZ()) > zVtxMax) + continue; + + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) + 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()); + + const uint64_t collIdx = collision.globalIndex(); + auto V0Table_thisCollision = V0s.sliceBy(perCollisionV0, collIdx); + V0Table_thisCollision.bindExternalIndices(&tracks); + + fillMcEvent(collision, tracks, V0Table_thisCollision, cV0M, mcParticles, mcLab); + fillMcGen(mcParticles, mcLab, collision.mcCollisionId()); + + miniCollTable(static_cast(collision.posZ() * 10), 0x0, nTrackletsColl, cV0M); + + for (auto& candidateTrack : candidateTracks[0]) { // protons + int selMask = -1; + if (candidateTrack.isreco) { + auto tk = tracks.rawIteratorAt(candidateTrack.globalIndex); + float outerPID = getOuterPID(tk); + candidateTrack.outerPID = tk.pt() < antipPtTof ? candidateTrack.outerPID : outerPID; + selMask = getTrackSelMask(candidateTrack); + // if (candidateTrack.outerPID < -4) + // continue; + } + mcMiniTrkTable( + miniCollTable.lastIndex(), candidateTrack.pt, - candidateTrack.eta, - candidateTrack.mass, - candidateTrack.dcapv, - candidateTrack.tpcncls, - candidateTrack.tpcnsigma, - candidateTrack.tofmass, - candidateTrack.genpt, - candidateTrack.geneta, - candidateTrack.pdgcode, + 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, processMcRun2, "process MC (Run 2)", false); + PROCESS_SWITCH(ebyeMaker, processMiniMcRun2, "process mini tables for mc(Run 2)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx new file mode 100644 index 00000000000..0c042c5f84b --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/he3HadronFemto.cxx @@ -0,0 +1,1060 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// Analysis task for he3-hadron femto analysis + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 "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/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 "ReconstructionDataFormats/Track.h" + +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "PWGLF/DataModel/LFhe3HadronTables.h" +#include "PWGLF/Utils/svPoolCreator.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +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 TrackCandidates = soa::Join; +using TrackCandidatesMC = soa::Join; + +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; + +enum Selections { + kNoCuts = 0, + kTrackCuts, + kPID, + kAll +}; + +} // namespace + +struct he3HadCandidate { + + float recoPtHe3() const { return signHe3 * std::hypot(momHe3[0], momHe3[1]); } + float recoPhiHe3() const { return std::atan2(momHe3[1], momHe3[0]); } + float recoEtaHe3() const { return std::asinh(momHe3[2] / recoPtHe3()); } + float recoPtHad() const { return signHad * std::hypot(momHad[0], momHad[1]); } + float recoPhiHad() const { return std::atan2(momHad[1], momHad[0]); } + float recoEtaHad() const { return std::asinh(momHad[2] / recoPtHad()); } + + std::array momHe3 = {99.f, 99.f, 99.f}; + std::array momHad = {99.f, 99.f, 99.f}; + + 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; + + uint16_t tpcSignalHe3 = 0u; + uint16_t tpcSignalHad = 0u; + float momHe3TPC = -99.f; + float momHadTPC = -99.f; + uint8_t nTPCClustersHe3 = 0u; + uint8_t sharedClustersHe3 = 0u; + uint8_t sharedClustersHad = 0u; + float chi2TPCHe3 = -10.f; + float chi2TPCHad = -10.f; + float nSigmaHe3 = -10.f; + float nSigmaHad = -10.f; + 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; + + bool isBkgUS = false; // unlike sign + bool isBkgEM = false; // event mixing + + int trackIDHe3 = -1; + int trackIDHad = -1; + + float l4MassMC = -10.f; + float l4PtMC = -99.f; + float momHe3MC = -99.f; + float etaHe3MC = -99.f; + float phiHe3MC = -99.f; + float momHadMC = -99.f; + float etaHadMC = -99.f; + float phiHadMC = -99.f; + + // collision information + int32_t collisionID = 0; +}; + +struct he3hadronfemto { + + Produces m_outputDataTable; + Produces m_outputMCTable; + Produces m_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_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_isMC{"setting_isMC", false, "Run MC"}; + Configurable setting_fillMultiplicity{"setting_fillMultiplicity", false, "Fill multiplicity table"}; + + // Zorro + Configurable setting_skimmedProcessing{"setting_skimmedProcessing", 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)"}; + + // 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> 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"}; + + Preslice m_perCol = aod::track::collisionId; + Preslice m_perColMC = aod::track::collisionId; + + // binning for EM background + ConfigurableAxis axisVertex{"axisVertex", {30, -10, 10}, "Binning for multiplicity"}; + ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0., 15., 30., 45., 60., 75., 95., 250.}, "Binning for centrality"}; + 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{ + "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}}}}, + {"hDCAxyHe3", ";DCA_{xy} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hDCAzHe3", ";DCA_{z} (cm)", {HistType::kTH1F, {{200, -1.0f, 1.0f}}}}, + {"hhe3HadtInvMass", "; M(^{3}He + p) (GeV/#it{c}^{2})", {HistType::kTH1F, {{50, 3.74f, 3.85f}}}}, + {"hHe3Pt", "#it{p}_{T} distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{200, -6.0f, 6.0f}}}}, + {"hHadronPt", "Pt distribution; #it{p}_{T} (GeV/#it{c})", {HistType::kTH1F, {{200, -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}}}}, + {"h2ClSizeCosLamHe3", "; n#sigma_{TPC} ; #LT ITS Cluster Size #GT #LT cos#lambda #GT (^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {120, 0.0f, 15.0f}}}}, + {"h2NsigmaHe3TPC", "NsigmaHe3 TPC distribution; #it{p}/z (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}/z (GeV/#it{c}); n#sigma_{TPC}(^{3}He)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {200, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTPC", "NsigmaHadron TPC distribution; #it{p}/z (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}, {200, -10.0f, 10.0f}}}}, + {"h2NsigmaHadronTOF", "NsigmaHadron TOF distribution; #it{p} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}}}, + {"h2NsigmaHadronTOF_preselection", "NsigmaHadron TOF distribution; #it{p} (GeV/#it{c}); n#sigma_{TOF}(p)", {HistType::kTH2F, {{100, -5.0f, 5.0f}, {200, -10.0f, 10.0f}}}}, + }, + OutputObjHandlingPolicy::AnalysisObject, + false, + true}; + + 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(); + } + + for (int i = 0; i < 5; i++) { + m_BBparamsHe[i] = setting_BetheBlochParams->get("He3", Form("p%i", i)); + } + m_BBparamsHe[5] = setting_BetheBlochParams->get("He3", "resolution"); + + std::vector selection_labels = {"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()); + } + + std::vector events_labels = {"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()); + } + + m_qaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(1, "False"); + m_qaRegistry.get(HIST("hEmptyPool"))->GetXaxis()->SetBinLabel(2, "True"); + } + + void initCCDB(const aod::BCsWithTimestamps::iterator& bc) + { + if (m_runNumber == bc.runNumber()) { + return; + } + if (setting_skimmedProcessing) { + m_zorro.initCCDB(m_ccdb.service, bc.runNumber(), bc.timestamp(), "fHe"); + m_zorro.populateHistRegistry(m_qaRegistry, bc.runNumber()); + } + m_runNumber = bc.runNumber(); + + auto run3grp_timestamp = bc.timestamp(); + o2::parameters::GRPObject* grpo = m_ccdb->getForTimeStamp(setting_grpPath, run3grp_timestamp); + o2::parameters::GRPMagField* grpmag = 0x0; + if (grpo) { + o2::base::Propagator::initFieldFromGRP(grpo); + if (setting_d_bz_input < -990) { + // 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"; + } else { + m_d_bz = setting_d_bz_input; + } + } else { + grpmag = m_ccdb->getForTimeStamp(setting_grpmagPath, run3grp_timestamp); + 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; + } + o2::base::Propagator::initFieldFromGRP(grpmag); + if (setting_d_bz_input < -990) { + // 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"; + } else { + m_d_bz = setting_d_bz_input; + } + } + } + + // ================================================================================================================== + + template + bool selectCollision(const Tcollision& collision, const aod::BCsWithTimestamps&) + { + m_qaRegistry.fill(HIST("hEvents"), 0); + + if constexpr (isMC) { + if (/*!collision.sel8() ||*/ std::abs(collision.posZ()) > setting_cutVertex) { + return false; + } + } else { + auto bc = collision.template bc_as(); + initCCDB(bc); + + if (!collision.sel8() || std::abs(collision.posZ()) > setting_cutVertex) { + return false; + } + if (setting_skimmedProcessing) { + bool zorroSelected = m_zorro.isSelected(collision.template bc_as().globalBC()); + if (zorroSelected) { + m_qaRegistry.fill(HIST("hEvents"), 2); + } + } + } + + m_qaRegistry.fill(HIST("hEvents"), 1); + m_qaRegistry.fill(HIST("hNcontributor"), collision.numContrib()); + m_qaRegistry.fill(HIST("hVtxZ"), collision.posZ()); + return true; + } + + template + bool selectTrack(const Ttrack& candidate) + { + if (std::abs(candidate.eta()) > setting_cutEta) { + 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) { + return false; + } + + return true; + } + + template + float computeTPCNSigmaHadron(const Ttrack& candidate) + { + float tpcNSigmaHad = 0; + if (setting_HadPDGCode == 211) { + tpcNSigmaHad = candidate.tpcNSigmaPi(); + } else if (setting_HadPDGCode == 2212) { + tpcNSigmaHad = candidate.tpcNSigmaPr(); + } else { + LOG(info) << "invalid PDG code for TPC"; + } + return tpcNSigmaHad; + } + + template + float computeTOFNSigmaHadron(const Ttrack& candidate) + { + float tofNSigmaHad = 0; + if (setting_HadPDGCode == 211) { + tofNSigmaHad = candidate.tofNSigmaPi(); + } else if (setting_HadPDGCode == 2212) { + tofNSigmaHad = candidate.tofNSigmaPr(); + } else { + LOG(info) << "invalid PDG code for TOF"; + } + return tofNSigmaHad; + } + + template + 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) { + auto tofNSigmaHad = computeTOFNSigmaHadron(candidate); + + if (std::abs(tpcNSigmaHad) > setting_cutNsigmaTPC) { + return false; + } + m_qaRegistry.fill(HIST("h2NsigmaHadronTOF_preselection"), candidate.p(), tofNSigmaHad); + if (std::abs(tofNSigmaHad) > setting_cutNsigmaTOF) { + return false; + } + m_qaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.tpcInnerParam(), tpcNSigmaHad); + m_qaRegistry.fill(HIST("h2NsigmaHadronTOF"), candidate.p(), tofNSigmaHad); + return true; + } else if (std::abs(tpcNSigmaHad) < setting_cutNsigmaTPC) { + m_qaRegistry.fill(HIST("h2NsigmaHadronTPC"), candidate.tpcInnerParam(), tpcNSigmaHad); + return true; + } + return false; + } + + template + 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]); + + double resoTPC{expTPCSignal * m_BBparamsHe[5]}; + return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); + } + + template + 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(); + + if (correctedTPCinnerParam < setting_cutRigidityMinHe3) { + return false; + } + + float cosl = 1. / std::cosh(candidate.eta()); + float meanClsizeIts = 0.f; + int nHitsIts = 0; + for (int ilayer = 0; ilayer < 7; ilayer++) { + float clsizeLayer = (candidate.itsClusterSizes() >> ilayer * 4) & 0b1111; + if (clsizeLayer > 0) { + nHitsIts++; + meanClsizeIts += clsizeLayer; + } + } + float clsizeCoslIts = meanClsizeIts / nHitsIts * cosl; + if (clsizeCoslIts < setting_cutClSizeItsHe3) { + return false; + } + + auto nSigmaHe3 = computeNSigmaHe3(candidate); + m_qaRegistry.fill(HIST("h2NsigmaHe3TPC_preselection"), candidate.sign() * correctedTPCinnerParam, nSigmaHe3); + if (std::abs(nSigmaHe3) > setting_cutNsigmaTPC) { + return false; + } + + m_qaRegistry.fill(HIST("h2dEdxHe3candidates"), candidate.sign() * correctedTPCinnerParam, candidate.tpcSignal()); + m_qaRegistry.fill(HIST("h2NsigmaHe3TPC"), candidate.sign() * correctedTPCinnerParam, nSigmaHe3); + m_qaRegistry.fill(HIST("h2ClSizeCosLamHe3"), nSigmaHe3, clsizeCoslIts); + return true; + } + + // ================================================================================================================== + + template + bool fillCandidateInfo(const Ttrack& trackHe3, const Ttrack& trackHad, const CollBracket& collBracket, const Tcollisions& collisions, he3HadCandidate& he3Hadcand, const Ttracks& /*trackTable*/, bool isMixedEvent) + { + 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; + } + + // 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; + } + } + + if (!m_goodCollisions[collIdxMin]) { + return false; + } + he3Hadcand.collisionID = collIdxMin; + } else { + he3Hadcand.collisionID = collBracket.getMin(); + } + + 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) { + invMass = RecoDecay::m(std::array{he3Hadcand.momHe3, he3Hadcand.momHad}, std::array{o2::constants::physics::MassHelium3, o2::constants::physics::MassPiPlus}); + } else if (setting_HadPDGCode == 2212) { + 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) { + return false; + } + float pthe3Had = std::hypot(he3Hadcand.momHe3[0] + he3Hadcand.momHad[0], he3Hadcand.momHe3[1] + he3Hadcand.momHad[1]); + if (pthe3Had < setting_cutPtMinhe3Had) { + 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.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(); + he3Hadcand.momHe3TPC = correctedTPCinnerParamHe3; + he3Hadcand.tpcSignalHad = trackHad.tpcSignal(); + he3Hadcand.momHadTPC = trackHad.tpcInnerParam(); + + he3Hadcand.nTPCClustersHe3 = trackHe3.tpcNClsFound(); + he3Hadcand.nSigmaHe3 = computeNSigmaHe3(trackHe3); + he3Hadcand.nSigmaHad = computeTPCNSigmaHadron(trackHad); + // he3Hadcand.nSigmaHad = trackHad.tpcNSigmaPi();/*tpcNSigmaHad*/ + he3Hadcand.chi2TPCHe3 = trackHe3.tpcChi2NCl(); + he3Hadcand.chi2TPCHad = trackHad.tpcChi2NCl(); + + he3Hadcand.PIDtrkHe3 = trackHe3.pidForTracking(); + he3Hadcand.PIDtrkHad = trackHad.pidForTracking(); + + he3Hadcand.itsClSizeHe3 = trackHe3.itsClusterSizes(); + he3Hadcand.itsClSizeHad = trackHad.itsClusterSizes(); + + he3Hadcand.sharedClustersHe3 = trackHe3.tpcNClsShared(); + he3Hadcand.sharedClustersHad = trackHad.tpcNClsShared(); + + he3Hadcand.isBkgUS = trackHe3.sign() * trackHad.sign() < 0; + he3Hadcand.isBkgEM = isMixedEvent; + + he3Hadcand.invMass = invMass; + + he3Hadcand.trackIDHe3 = trackHe3.globalIndex(); + he3Hadcand.trackIDHad = trackHad.globalIndex(); + + o2::pid::tof::Beta responseBeta; + if (trackHe3.hasTOF()) { + float beta = responseBeta.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(); + he3Hadcand.massTOFHe3 = correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); + } + if (trackHad.hasTOF()) { + float beta = responseBeta.GetBeta(trackHad); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + he3Hadcand.massTOFHad = trackHad.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); + } + + return true; + } + + template + void fillCandidateInfoMC(const Mc& mctrackHe3, const Mc& mctrackHad, const Mc& mctrackMother, he3HadCandidate& he3Hadcand) + { + he3Hadcand.momHe3MC = mctrackHe3.pt() * (mctrackHe3.pdgCode() > 0 ? 1 : -1); + he3Hadcand.etaHe3MC = mctrackHe3.eta(); + he3Hadcand.phiHe3MC = mctrackHe3.phi(); + he3Hadcand.momHadMC = mctrackHad.pt() * (mctrackHad.pdgCode() > 0 ? 1 : -1); + he3Hadcand.etaHadMC = mctrackHad.eta(); + he3Hadcand.phiHadMC = mctrackHad.phi(); + 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()); + } + + template + void pairTracksSameEvent(const Ttrack& tracks) + { + for (auto track0 : tracks) { + + m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + + if (!selectTrack(track0)) { + continue; + } + m_qaRegistry.fill(HIST("hTrackSel"), Selections::kTrackCuts); + + if (!selectionPIDHe3(track0)) { + continue; + } + m_qaRegistry.fill(HIST("hTrackSel"), Selections::kPID); + + for (auto track1 : tracks) { + + if (track0 == track1) { + continue; + } + + if (!setting_enableBkgUS && (track0.sign() * track1.sign() < 0)) { + continue; + } + if (setting_enableBkgUS && (track0.sign() * track1.sign() > 0)) { + continue; + } + + if (!selectTrack(track1) || !selectionPIDHadron(track1)) { + continue; + } + + SVCand trackPair; + trackPair.tr0Idx = track0.globalIndex(); + trackPair.tr1Idx = track1.globalIndex(); + const int collIdx = track0.collisionId(); + CollBracket collBracket{collIdx, collIdx}; + trackPair.collBracket = collBracket; + m_trackPairs.push_back(trackPair); + } + } + } + + template + void pairTracksEventMixing(T& he3Cands, T& hadronCands) + { + for (auto& he3Cand : he3Cands) { + if (!selectTrack(he3Cand) || !selectionPIDHe3(he3Cand)) { + continue; + } + for (auto& hadronCand : hadronCands) { + if (!selectTrack(hadronCand) || !selectionPIDHadron(hadronCand)) { + continue; + } + + SVCand trackPair; + trackPair.tr0Idx = he3Cand.globalIndex(); + trackPair.tr1Idx = hadronCand.globalIndex(); + const int collIdx = he3Cand.collisionId(); + CollBracket collBracket{collIdx, collIdx}; + trackPair.collBracket = collBracket; + m_trackPairs.push_back(trackPair); + } + } + } + + template + void fillTable(const he3HadCandidate& he3Hadcand, const Tcoll& collision, bool isMC = false) + { + m_outputDataTable( + he3Hadcand.recoPtHe3(), + he3Hadcand.recoEtaHe3(), + he3Hadcand.recoPhiHe3(), + he3Hadcand.recoPtHad(), + he3Hadcand.recoEtaHad(), + he3Hadcand.recoPhiHad(), + he3Hadcand.DCAxyHe3, + he3Hadcand.DCAzHe3, + he3Hadcand.DCAxyHad, + he3Hadcand.DCAzHad, + he3Hadcand.tpcSignalHe3, + he3Hadcand.momHe3TPC, + he3Hadcand.tpcSignalHad, + he3Hadcand.momHadTPC, + he3Hadcand.nTPCClustersHe3, + he3Hadcand.nSigmaHe3, + he3Hadcand.nSigmaHad, + he3Hadcand.chi2TPCHe3, + he3Hadcand.chi2TPCHad, + he3Hadcand.massTOFHe3, + he3Hadcand.massTOFHad, + he3Hadcand.PIDtrkHe3, + he3Hadcand.PIDtrkHad, + he3Hadcand.itsClSizeHe3, + he3Hadcand.itsClSizeHad, + he3Hadcand.sharedClustersHe3, + he3Hadcand.sharedClustersHad, + he3Hadcand.isBkgUS, + he3Hadcand.isBkgEM); + if (isMC) { + m_outputMCTable( + he3Hadcand.momHe3MC, + he3Hadcand.etaHe3MC, + he3Hadcand.phiHe3MC, + he3Hadcand.momHadMC, + he3Hadcand.etaHadMC, + he3Hadcand.phiHadMC, + he3Hadcand.l4PtMC, + he3Hadcand.l4MassMC); + } + if (setting_fillMultiplicity) { + m_outputMultiplicityTable( + collision.globalIndex(), + collision.posZ(), + collision.numContrib(), + collision.centFT0C(), + collision.multFT0C()); + } + } + + 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); + } + + // ================================================================================================================== + + template + void fillPairs(const Tcollisions& collisions, const Ttracks& tracks, const bool isMixedEvent) + { + for (auto& trackPair : m_trackPairs) { + + auto heTrack = tracks.rawIteratorAt(trackPair.tr0Idx); + auto hadTrack = tracks.rawIteratorAt(trackPair.tr1Idx); + auto collBracket = trackPair.collBracket; + + he3HadCandidate he3Hadcand; + if (!fillCandidateInfo(heTrack, hadTrack, collBracket, collisions, he3Hadcand, tracks, isMixedEvent)) { + continue; + } + fillHistograms(he3Hadcand); + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ false); + } + } + + template + void fillMcParticles(const Tcollisions& collisions, const TmcParticles& mcParticles, std::vector& filledMothers) + { + for (auto& mcParticle : mcParticles) { + + if (std::abs(mcParticle.pdgCode()) != li4PDG || std::abs(mcParticle.y()) > 1 || mcParticle.isPhysicalPrimary() == false) { + continue; + } + + if (std::find(filledMothers.begin(), filledMothers.end(), mcParticle.globalIndex()) != filledMothers.end()) { + continue; + } + + auto kDaughters = mcParticle.template daughters_as(); + bool daughtHe3(false), daughtHad(false); + McIter mcHe3, mcHad; + for (auto kCurrentDaughter : kDaughters) { + if (std::abs(kCurrentDaughter.pdgCode()) == hePDG) { + daughtHe3 = true; + mcHe3 = kCurrentDaughter; + } else if (std::abs(kCurrentDaughter.pdgCode()) == prPDG) { + daughtHad = true; + mcHad = kCurrentDaughter; + } + } + if (daughtHe3 && daughtHad) { + he3HadCandidate he3Hadcand; + fillCandidateInfoMC(mcHe3, mcHad, mcParticle, he3Hadcand); + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ true); + } + } + } + + // ================================================================================================================== + + void processSameEvent(const CollisionsFull& collisions, const TrackCandidates& tracks, const aod::BCsWithTimestamps& bcs) + { + m_goodCollisions.clear(); + m_goodCollisions.resize(collisions.size(), false); + + for (auto& collision : collisions) { + + m_trackPairs.clear(); + + if (!selectCollision(collision, bcs)) { + continue; + } + + m_goodCollisions[collision.globalIndex()] = true; + const uint64_t collIdx = collision.globalIndex(); + auto TrackTable_thisCollision = tracks.sliceBy(m_perCol, collIdx); + TrackTable_thisCollision.bindExternalIndices(&tracks); + + pairTracksSameEvent(TrackTable_thisCollision); + + if (m_trackPairs.size() == 0) { + continue; + } + + fillPairs(collisions, tracks, /*isMixedEvent*/ 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(); + + for (auto& [c1, tracks1, c2, tracks2] : m_pair) { + if (!c1.sel8() || !c2.sel8()) { + continue; + } + + m_qaRegistry.fill(HIST("hNcontributor"), c1.numContrib()); + m_qaRegistry.fill(HIST("hVtxZ"), c1.posZ()); + + pairTracksEventMixing(tracks1, tracks2); + pairTracksEventMixing(tracks2, tracks1); + } + + fillPairs(collisions, tracks, /*isMixedEvent*/ true); + } + 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); + + for (auto& collision : collisions) { + + m_trackPairs.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); + + pairTracksSameEvent(TrackTable_thisCollision); + + for (auto& trackPair : m_trackPairs) { + + auto heTrack = tracks.rawIteratorAt(trackPair.tr0Idx); + auto prTrack = tracks.rawIteratorAt(trackPair.tr1Idx); + auto collBracket = trackPair.collBracket; + + if (!heTrack.has_mcParticle() || !prTrack.has_mcParticle()) { + continue; + } + + auto mctrackHe3 = heTrack.mcParticle(); + auto mctrackHad = prTrack.mcParticle(); + + if (std::abs(mctrackHe3.pdgCode()) != hePDG || std::abs(mctrackHad.pdgCode()) != prPDG) { + 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()); + } + } + } + } + + fillMcParticles(collisions, mcParticles, filledMothers); + } + PROCESS_SWITCH(he3hadronfemto, processMC, "Process 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); + + for (auto& collision : collisions) { + if (selectCollision(collision, bcs)) { + m_goodCollisions[collision.globalIndex()] = true; + } + } + + m_svPoolCreator.clearPools(); + m_svPoolCreator.fillBC2Coll(collisions, bcs); + + for (auto& track : tracks) { + + m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + if (!selectTrack(track)) + continue; + m_qaRegistry.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); + + int pdgHypo = selHe ? hePDG : prPDG; + + m_svPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); + } + + m_trackPairs = m_svPoolCreator.getSVCandPool(collisions, true); + if (m_trackPairs.size() == 0) { + m_qaRegistry.fill(HIST("hEmptyPool"), 1); + return; + } + m_qaRegistry.fill(HIST("hEmptyPool"), 0); + + fillPairs(collisions, tracks, /*isMixedEvent*/ 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); + + for (auto& collision : collisions) { + if (selectCollision(collision, bcs)) { + m_goodCollisions[collision.globalIndex()] = true; + } + } + + m_svPoolCreator.clearPools(); + m_svPoolCreator.fillBC2Coll(collisions, bcs); + + for (auto& track : tracks) { + + m_qaRegistry.fill(HIST("hTrackSel"), Selections::kNoCuts); + if (!selectTrack(track)) + continue; + m_qaRegistry.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); + + int pdgHypo = selHe ? hePDG : prPDG; + + m_svPoolCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs); + } + + auto& svPool = m_svPoolCreator.getSVCandPool(collisions, true); + if (svPool.size() == 0) { + m_qaRegistry.fill(HIST("hEmptyPool"), 1); + return; + } + m_qaRegistry.fill(HIST("hEmptyPool"), 0); + + for (auto& svCand : svPool) { + auto heTrack = tracks.rawIteratorAt(svCand.tr0Idx); + auto prTrack = tracks.rawIteratorAt(svCand.tr1Idx); + auto heTrackLabel = mcTrackLabels.rawIteratorAt(svCand.tr0Idx); + auto prTrackLabel = mcTrackLabels.rawIteratorAt(svCand.tr1Idx); + auto collBracket = svCand.collBracket; + + if (!heTrackLabel.has_mcParticle() || !prTrackLabel.has_mcParticle()) { + continue; + } + + 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()) { + continue; + } + + for (auto& mothertrackHe : mctrackHe3.mothers_as()) { + for (auto& mothertrackHad : mctrackHad.mothers_as()) { + + if (mothertrackHe.globalIndex() != mothertrackHad.globalIndex() || std::abs(mothertrackHe.pdgCode()) != li4PDG || std::abs(mothertrackHe.y()) > 1) { + continue; + } + + he3HadCandidate he3Hadcand; + if (!fillCandidateInfo(heTrack, prTrack, collBracket, collisions, he3Hadcand, tracks, /*mix*/ false)) { + continue; + } + fillCandidateInfoMC(mctrackHe3, mctrackHad, mothertrackHe, he3Hadcand); + fillHistograms(he3Hadcand); + auto collision = collisions.rawIteratorAt(he3Hadcand.collisionID); + fillTable(he3Hadcand, collision, /*isMC*/ true); + filledMothers.push_back(mothertrackHe.globalIndex()); + } + } + } + + fillMcParticles(collisions, mcParticles, filledMothers); + } + PROCESS_SWITCH(he3hadronfemto, processMcPools, "Process MC pools", false); +}; + +WorkflowSpec defineDataProcessing(const ConfigContext& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"he3hadronfemto"})}; +} diff --git a/PWGLF/TableProducer/Nuspex/hyperKinkRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hyperKinkRecoTask.cxx index 658ab180d67..8e46e3326c1 100644 --- a/PWGLF/TableProducer/Nuspex/hyperKinkRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hyperKinkRecoTask.cxx @@ -332,7 +332,7 @@ struct hyperKinkRecoTask { bool isGoodTPCCand = false; if (candidate.itsNClsInnerBarrel() == 0 && candidate.itsNCls() < 4 && candidate.tpcNClsCrossedRows() >= 70 && candidate.tpcChi2NCl() < 4.f && - candidate.tpcNClsCrossedRows() > 0.8 * candidate.tpcNClsFindable() && candidate.tpcNClsFound() > 80 && abs(nSigmaTrit) < nSigmaTPCCutTrit) { + candidate.tpcNClsCrossedRows() > 0.8 * candidate.tpcNClsFindable() && candidate.tpcNClsFound() > 80 && std::abs(nSigmaTrit) < nSigmaTPCCutTrit) { isGoodTPCCand = true; } @@ -340,7 +340,7 @@ struct hyperKinkRecoTask { return false; } - if (candidate.hasTOF() && abs(nSigmaTOFTrit) > nSigmaTOFCutTrit) { + if (candidate.hasTOF() && std::abs(nSigmaTOFTrit) > nSigmaTOFCutTrit) { return false; } @@ -394,7 +394,7 @@ struct hyperKinkRecoTask { gpu::gpustd::array dcaInfoHyp; o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovHyperPV, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoHyp); - if (abs(dcaInfoHyp[0]) > maxDCAHypToPV) { + if (std::abs(dcaInfoHyp[0]) > maxDCAHypToPV) { continue; } @@ -412,7 +412,7 @@ struct hyperKinkRecoTask { // propagate to PV gpu::gpustd::array dcaInfoTrit; o2::base::Propagator::Instance()->propagateToDCABxByBz({primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, trackParCovTrit, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfoTrit); - if (abs(dcaInfoTrit[0]) < minDCATritToPV) { + if (std::abs(dcaInfoTrit[0]) < minDCATritToPV) { continue; } @@ -492,13 +492,13 @@ struct hyperKinkRecoTask { auto mcTrackHyper = mcLabHyper.mcParticle_as(); auto mcTrackTrit = mcLabTrit.mcParticle_as(); - if (abs(mcTrackHyper.pdgCode()) != hyperPdg || abs(mcTrackTrit.pdgCode()) != tritDauPdg) { + if (std::abs(mcTrackHyper.pdgCode()) != hyperPdg || std::abs(mcTrackTrit.pdgCode()) != tritDauPdg) { continue; } auto tritIdx = mcTrackTrit.globalIndex(); kinkCand.isSignal = false; for (auto& dauMCTracks : mcTrackHyper.daughters_as()) { - if (abs(dauMCTracks.pdgCode()) == tritDauPdg) { + if (std::abs(dauMCTracks.pdgCode()) == tritDauPdg) { if (dauMCTracks.globalIndex() == tritIdx) { kinkCand.isSignal = true; break; diff --git a/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx index 23278b221af..6acf6578717 100644 --- a/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx @@ -30,7 +30,12 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.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 "DCAFitter/DCAFitterN.h" #include "PWGLF/Utils/svPoolCreator.h" @@ -41,7 +46,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using std::array; using CollBracket = o2::math_utils::Bracket; -using TracksFull = soa::Join; +using TracksFull = soa::Join; using CollisionsFull = soa::Join; using CollisionsFullMC = soa::Join; @@ -51,7 +56,7 @@ 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 particleNames{"He3"}; +static const std::vector particleName{"He3"}; std::shared_ptr hEvents; std::shared_ptr hZvtx; std::shared_ptr hCentFT0A; @@ -99,6 +104,8 @@ struct hyperCandidate { std::array gDecVtx; uint16_t tpcSignalHe3 = 0u; uint16_t tpcSignalPi = 0u; + float tpcChi2He3 = 0.f; + float massTOFHe3 = 0.f; uint8_t nTPCClustersHe3 = 0u; uint8_t nTPCClustersPi = 0u; uint32_t clusterSizeITSHe3 = 0u; @@ -122,6 +129,8 @@ struct hyperRecoTask { Produces outputDataTableWithFlow; Produces outputMCTable; Service ccdb; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; // PDG codes Configurable hyperPdg{"hyperPDG", 1010010030, "PDG code of the hyper-mother (could be 3LamH or 4LamH)"}; @@ -131,6 +140,7 @@ struct hyperRecoTask { Configurable v0cospacut{"hypcospa", 0.95, "V0 CosPA"}; Configurable masswidth{"hypmasswidth", 0.06, "Mass width (GeV/c^2)"}; Configurable dcaToPvPion{"dcapvPi", 0., "DCA to PV pion"}; + Configurable dcaToPvHe{"dcapvHe", 0., "DCA to PV helium"}; Configurable dcav0dau{"hypdcaDau", 1.0, "DCA V0 Daughters"}; Configurable ptMin{"ptMin", 0.5, "Minimum pT of the hypercandidate"}; Configurable TPCRigidityMinHe{"TPCRigidityMinHe", 0.2, "Minimum rigidity of the helium candidate"}; @@ -139,11 +149,14 @@ struct hyperRecoTask { Configurable nTPCClusMinHe{"nTPCClusMinHe", 70, "helium NTPC clusters cut"}; 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"}; // Define o2 fitter, 2-prong, active memory (no need to redefine per event) o2::vertexing::DCAFitterN<2> fitter; svPoolCreator svCreator{heDauPdg, 211}; + o2::pid::tof::Beta responseBeta; + // daughter masses float he3Mass = o2::constants::physics::MassHelium3; float he4Mass = o2::constants::physics::MassAlpha; @@ -152,7 +165,7 @@ struct hyperRecoTask { Configurable useCustomVertexer{"useCustomVertexer", false, "Use custom vertexer"}; Configurable skipAmbiTracks{"skipAmbiTracks", false, "Skip ambiguous tracks"}; Configurable customVertexerTimeMargin{"customVertexerTimeMargin", 800, "Time margin for custom vertexer (ns)"}; - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; + 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"}; Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; @@ -180,7 +193,7 @@ struct hyperRecoTask { std::vector recoCollisionIds; std::vector isSurvEvSelCollision; std::vector goodCollision; - std::vector isTracked; + std::vector trackedClSize; Preslice perCollision = o2::aod::v0::collisionId; @@ -193,6 +206,8 @@ struct hyperRecoTask { void init(InitContext const&) { + zorroSummary.setObject(zorro.getZorroSummary()); + mRunNumber = 0; d_bz = 0; @@ -230,9 +245,10 @@ 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, {{2, -0.5, 1.5}}); + hEvents = qaRegistry.add("hEvents", ";Events; ", HistType::kTH1D, {{3, -0.5, 2.5}}); hEvents->GetXaxis()->SetBinLabel(1, "All"); hEvents->GetXaxis()->SetBinLabel(2, "Selected"); + hEvents->GetXaxis()->SetBinLabel(3, "Zorro He events"); if (doprocessMC) { hDecayChannel = qaRegistry.add("hDecayChannel", ";Decay channel; ", HistType::kTH1D, {{2, -0.5, 1.5}}); hDecayChannel->GetXaxis()->SetBinLabel(1, "2-body"); @@ -255,6 +271,10 @@ struct hyperRecoTask { if (mRunNumber == bc.runNumber()) { return; } + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fHe"); + zorro.populateHistRegistry(qaRegistry, bc.runNumber()); + } auto run3grp_timestamp = bc.timestamp(); o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); @@ -317,6 +337,13 @@ struct hyperRecoTask { continue; } + if (cfgSkimmedProcessing) { + bool zorroSelected = zorro.isSelected(collision.template bc_as().globalBC()); /// Just let Zorro do the accounting + if (zorroSelected) { + hEvents->Fill(2.); + } + } + goodCollision[collision.globalIndex()] = true; hEvents->Fill(1.); hZvtx->Fill(collision.posZ()); @@ -362,9 +389,12 @@ struct hyperRecoTask { hypCand.clusterSizeITSHe3 = heTrack.itsClusterSizes(); hypCand.nTPCClustersPi = piTrack.tpcNClsFound(); hypCand.tpcSignalPi = piTrack.tpcSignal(); + hypCand.tpcChi2He3 = heTrack.tpcChi2NCl(); hypCand.clusterSizeITSPi = piTrack.itsClusterSizes(); bool heliumPID = heTrack.pidForTracking() == o2::track::PID::Helium3 || heTrack.pidForTracking() == o2::track::PID::Alpha; hypCand.momHe3TPC = (heliumPID && cfgCompensatePIDinTracking) ? heTrack.tpcInnerParam() / 2 : heTrack.tpcInnerParam(); + if (hypCand.momHe3TPC < TPCRigidityMinHe) + return; hypCand.momPiTPC = piTrack.tpcInnerParam(); hDeDxTot->Fill(hypCand.momHe3TPC * heTrack.sign(), heTrack.tpcSignal()); hDeDxTot->Fill(hypCand.momPiTPC * piTrack.sign(), piTrack.tpcSignal()); @@ -420,7 +450,7 @@ struct hyperRecoTask { hH3LMassBefSel->Fill(massH3L); hH4LMassBefSel->Fill(massH4L); - if (!isTracked.empty() && isTracked[hypCand.v0ID]) { + if (!trackedClSize.empty() && trackedClSize[hypCand.v0ID] > 0) { hH3LMassTracked->Fill(massH3L); hH4LMassTracked->Fill(massH4L); } @@ -465,7 +495,7 @@ struct hyperRecoTask { o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, piTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); hypCand.piDCAXY = dcaInfo[0]; - if (abs(hypCand.piDCAXY) < dcaToPvPion) { + if (std::abs(hypCand.piDCAXY) < dcaToPvPion || std::abs(hypCand.he3DCAXY) < dcaToPvHe) { return; } @@ -475,6 +505,12 @@ struct hyperRecoTask { hypCand.piTrackID = piTrack.globalIndex(); hypCand.collisionID = collision.globalIndex(); + if (heTrack.hasTOF()) { + float beta = responseBeta.GetBeta(heTrack); + beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked + hypCand.massTOFHe3 = hypCand.momHe3TPC * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); + } + hDeDx3HeSel->Fill(heTrack.sign() * hypCand.momHe3TPC, heTrack.tpcSignal()); hNsigma3HeSel->Fill(heTrack.sign() * hypCand.momHe3TPC, hypCand.nSigmaHe3); hyperCandidates.push_back(hypCand); @@ -572,7 +608,7 @@ struct hyperRecoTask { for (auto& piMother : mcTrackPi.mothers_as()) { if (heMother.globalIndex() != piMother.globalIndex()) continue; - if (abs(mcTrackHe.pdgCode()) != heDauPdg || abs(mcTrackPi.pdgCode()) != 211) + if (std::abs(mcTrackHe.pdgCode()) != heDauPdg || std::abs(mcTrackPi.pdgCode()) != 211) continue; if (std::abs(heMother.pdgCode()) != hyperPdg) continue; @@ -598,10 +634,10 @@ struct hyperRecoTask { void processDataTracked(CollisionsFull const& collisions, aod::V0s const& V0s, aod::TrackedV0s const& tV0s, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const& bcs) { - isTracked.clear(); - isTracked.resize(V0s.size(), false); + trackedClSize.clear(); + trackedClSize.resize(V0s.size(), 0); for (const auto& tV0 : tV0s) { - isTracked[tV0.v0Id()] = true; + trackedClSize[tV0.v0Id()] = tV0.itsClsSize(); } processData(collisions, V0s, tracks, ambiTracks, bcs); } @@ -618,6 +654,7 @@ struct hyperRecoTask { for (auto& hypCand : hyperCandidates) { auto collision = collisions.rawIteratorAt(hypCand.collisionID); + float trackedHypClSize = !trackedClSize.empty() ? trackedClSize[hypCand.v0ID] : 0; outputDataTable(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.posX(), collision.posY(), collision.posZ(), hypCand.isMatter, @@ -626,8 +663,9 @@ struct hyperRecoTask { hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, - hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, - hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, !isTracked.empty() && isTracked[hypCand.v0ID]); + hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, + hypCand.massTOFHe3, + hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize); } } PROCESS_SWITCH(hyperRecoTask, processData, "Data analysis", true); @@ -644,6 +682,7 @@ struct hyperRecoTask { for (auto& hypCand : hyperCandidates) { auto collision = collisions.rawIteratorAt(hypCand.collisionID); + float trackedHypClSize = !trackedClSize.empty() ? trackedClSize[hypCand.v0ID] : 0; outputDataTableWithFlow(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.psiFT0A(), collision.multFT0A(), collision.psiFT0C(), collision.multFT0C(), @@ -655,8 +694,9 @@ struct hyperRecoTask { hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, - hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, - hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, !isTracked.empty() && isTracked[hypCand.v0ID]); + hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, + hypCand.massTOFHe3, + hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize); } } PROCESS_SWITCH(hyperRecoTask, processDataWithFlow, "Data analysis with flow", false); @@ -680,6 +720,7 @@ struct hyperRecoTask { if (!hypCand.isSignal && mcSignalOnly) continue; int chargeFactor = -1 + 2 * (hypCand.pdgCode > 0); + float trackedHypClSize = !trackedClSize.empty() ? trackedClSize[hypCand.v0ID] : 0; outputMCTable(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), collision.posX(), collision.posY(), collision.posZ(), hypCand.isMatter, @@ -688,8 +729,9 @@ struct hyperRecoTask { hypCand.decVtx[0], hypCand.decVtx[1], hypCand.decVtx[2], hypCand.dcaV0dau, hypCand.he3DCAXY, hypCand.piDCAXY, hypCand.nSigmaHe3, hypCand.nTPCClustersHe3, hypCand.nTPCClustersPi, - hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, - hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, !isTracked.empty() && isTracked[hypCand.v0ID], + hypCand.momHe3TPC, hypCand.momPiTPC, hypCand.tpcSignalHe3, hypCand.tpcSignalPi, hypCand.tpcChi2He3, + hypCand.massTOFHe3, + hypCand.clusterSizeITSHe3, hypCand.clusterSizeITSPi, hypCand.flags, trackedHypClSize, chargeFactor * hypCand.genPt(), hypCand.genPhi(), hypCand.genEta(), hypCand.genPtHe3(), hypCand.gDecVtx[0], hypCand.gDecVtx[1], hypCand.gDecVtx[2], hypCand.isReco, hypCand.isSignal, hypCand.isRecoMCCollision, hypCand.isSurvEvSelection); @@ -761,7 +803,7 @@ struct hyperRecoTask { -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, false, chargeFactor * hypCand.genPt(), hypCand.genPhi(), hypCand.genEta(), hypCand.genPtHe3(), hypCand.gDecVtx[0], hypCand.gDecVtx[1], hypCand.gDecVtx[2], @@ -772,10 +814,10 @@ struct hyperRecoTask { void processMCTracked(CollisionsFullMC const& collisions, aod::McCollisions const& mcCollisions, aod::V0s const& V0s, aod::TrackedV0s const& tV0s, TracksFull const& tracks, aod::AmbiguousTracks const& ambiTracks, aod::BCsWithTimestamps const& bcs, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC) { - isTracked.clear(); - isTracked.resize(V0s.size(), false); + trackedClSize.clear(); + trackedClSize.resize(V0s.size(), 0); for (const auto& tV0 : tV0s) { - isTracked[tV0.v0Id()] = true; + trackedClSize[tV0.v0Id()] = tV0.itsClsSize(); } processMC(collisions, mcCollisions, V0s, tracks, ambiTracks, bcs, trackLabelsMC, particlesMC); } diff --git a/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx b/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx index 52f038356dc..b4445a5619a 100644 --- a/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx +++ b/PWGLF/TableProducer/Nuspex/hypertriton3bodyfinder.cxx @@ -687,14 +687,17 @@ struct hypertriton3bodyFinder { 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()); @@ -712,6 +715,7 @@ struct hypertriton3bodyFinder { 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 } //------------------------------------------------------------------ diff --git a/PWGLF/TableProducer/Nuspex/lithium4analysis.cxx b/PWGLF/TableProducer/Nuspex/lithium4analysis.cxx deleted file mode 100644 index 20e717836a1..00000000000 --- a/PWGLF/TableProducer/Nuspex/lithium4analysis.cxx +++ /dev/null @@ -1,681 +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. -// Analysis task for anti-lithium4 analysis - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "Common/Core/PID/PIDTOF.h" -#include "Common/TableProducer/PID/pidTOFBase.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 "Common/Core/RecoDecay.h" -#include "Common/Core/TrackSelection.h" -#include "Framework/ASoAHelpers.h" -#include "DataFormatsTPC/BetheBlochAleph.h" -#include "CCDB/BasicCCDBManager.h" - -#include "PWGLF/DataModel/LFLithium4Tables.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; -using std::array; - -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 int lithium4PDG = 1000030040; -constexpr int protonPDG = 2212; -constexpr int he3PDG = 1000020030; - -enum Selections { - kNoCuts = 0, - kGlobalTrack, - kTrackCuts, - kPID, - kAll -}; - -} // namespace - -struct lithium4Candidate { - - float sign = 0.f; - - float recoPtHe3() const { return sign * std::hypot(momHe3[0], momHe3[1]); } - float recoPhiHe3() const { return std::atan2(momHe3[1], momHe3[0]); } - float recoEtaHe3() const { return std::asinh(momHe3[2] / recoPtHe3()); } - float recoPtPr() const { return sign * std::hypot(momPr[0], momPr[1]); } - float recoPhiPr() const { return std::atan2(momPr[1], momPr[0]); } - float recoEtaPr() const { return std::asinh(momPr[2] / recoPtPr()); } - - std::array momHe3 = {99.f, 99.f, 99.f}; - std::array momPr = {99.f, 99.f, 99.f}; - - uint32_t PIDtrkHe3 = 0xFFFFF; // PID in tracking - uint32_t PIDtrkPr = 0xFFFFF; - - float nSigmaHe3 = -10; - float nSigmaPr = -10; - float massTOFHe3 = -10; - float massTOFPr = -10; - - float DCAxyHe3 = -10; - float DCAzHe3 = -10; - float DCAxyPr = -10; - float DCAzPr = -10; - uint16_t tpcSignalHe3 = 0u; - float momHe3TPC = -99.f; - uint16_t tpcSignalPr = 0u; - float momPrTPC = -99.f; - float invMass = -10.f; - - uint32_t itsClSizeHe3 = 0u; - uint32_t itsClSizePr = 0u; - uint8_t nTPCClustersHe3 = 0u; - - float momHe3MC = -99.f; - float momPrMC = -99.f; - - uint8_t sharedClustersHe3 = 0u; - uint8_t sharedClustersPr = 0u; - - bool isBkgUS = false; - bool isBkgEM = false; - - float l4PtMC = -99.f; - float l4MassMC = -10.f; -}; - -struct lithium4analysis { - - Produces outputDataTable; - Produces outputMCTable; - - std::vector l4Candidates; - - SliceCache cache; - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; - // events - Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - // track - Configurable cfgCutPT{"cfgCutPT", 0.2, "PT cut on daughter track"}; - Configurable cfgCutMaxPrPT{"cfgCutMaxPrPT", 1.8, "Max PT cut on proton"}; - 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", 3.0, "Value of the TPC Nsigma cut"}; - Configurable nsigmaCutTOF{"nsigmaCutTOF", 3.0, "Value of the TOF Nsigma cut"}; - Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; - Configurable cfgEnableBkgUS{"cfgEnableBkgUS", false, "Enable US background"}; - - // bethe bloch parameters - std::array mBBparamsHe; - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, {"He3"}, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for He3"}; - // MC - Configurable isMC{"isMC", false, "Run MC"}; - void init(o2::framework::InitContext&) - { - - histos.add("hCentrality", "Centrality distribution", kTH1F, {{2001, -0.5, 2000.5}}); - histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); - histos.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 2000.0f}}); - histos.add("hDCAxyHe3", ";DCA_{xy} (cm)", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDCAzHe3", ";DCA_{z} (cm)", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hLitInvMass", "; M(^{3}He + p) (GeV/#it{c}^{2})", kTH1F, {{50, 3.74f, 3.85f}}); - histos.add("hHe3Pt", "#it{p}_{T} distribution; #it{p}_{T} (GeV/#it{c})", kTH1F, {{200, 0.0f, 6.0f}}); - histos.add("hProtonPt", "Pt distribution; #it{p}_{T} (GeV/#it{c})", kTH1F, {{200, 0.0f, 3.0f}}); - histos.add("h2dEdxHe3candidates", "dEdx distribution; Signed #it{p} (GeV/#it{c}); dE/dx (a.u.)", kTH2F, {{200, -5.0f, 5.0f}, {100, 0.0f, 2000.0f}}); - histos.add("h2NsigmaHe3TPC", "NsigmaHe3 TPC distribution; Signed #it{p}/#it{z} (GeV/#it{c}); n#sigma_{TPC}({}^{3}He)", kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}); - histos.add("h2NsigmaProtonTPC", "NsigmaProton TPC distribution; Signed #it{p}/#it{z} (GeV/#it{c}); n#sigma_{TPC}(p)", kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}); - histos.add("h2NsigmaProtonTOF", "NsigmaProton TOF distribution; #it{p}_{T} (GeV/#it{c}); n#sigma_{TOF}(p)", kTH2F, {{20, -5.0f, 5.0f}, {200, -5.0f, 5.0f}}); - histos.add("hTrackSel", "Accepted tracks", kTH1F, {{Selections::kAll, -0.5, static_cast(Selections::kAll) - 0.5}}); - - for (int i = 0; i < 5; i++) { - mBBparamsHe[i] = cfgBetheBlochParams->get("He3", Form("p%i", i)); - } - mBBparamsHe[5] = cfgBetheBlochParams->get("He3", "resolution"); - - std::vector labels = {"All", "Global track", "Track selection", "PID {}^{3}He"}; - for (int i = 0; i < Selections::kAll; i++) { - histos.get(HIST("hTrackSel"))->GetXaxis()->SetBinLabel(i + 1, labels[i].c_str()); - } - } - - template - bool selectionTrack(const T& candidate) - { - - if (candidate.itsNCls() < 5 || - candidate.tpcNClsFound() < 90 || // candidate.tpcNClsFound() < 70 || - candidate.tpcNClsCrossedRows() < 70 || - candidate.tpcNClsCrossedRows() < 0.8 * candidate.tpcNClsFindable() || - candidate.tpcChi2NCl() > 4.f || - candidate.itsChi2NCl() > 36.f) { - return false; - } - - return true; - } - - template - bool selectionPIDProton(const T& candidate) - { - if (candidate.hasTOF()) { - if (std::abs(candidate.tofNSigmaPr()) < nsigmaCutTOF && std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { - histos.fill(HIST("h2NsigmaProtonTPC"), candidate.tpcInnerParam(), candidate.tpcNSigmaPr()); - histos.fill(HIST("h2NsigmaProtonTOF"), candidate.p(), candidate.tofNSigmaPr()); - return true; - } - } else if (std::abs(candidate.tpcNSigmaPr()) < nsigmaCutTPC) { - histos.fill(HIST("h2NsigmaProtonTPC"), candidate.tpcInnerParam(), candidate.tpcNSigmaPr()); - return true; - } - return false; - } - - template - float computeNSigmaHe3(const T& candidate) - { - bool heliumPID = candidate.pidForTracking() == o2::track::PID::Helium3 || candidate.pidForTracking() == o2::track::PID::Alpha; - - float correctedTPCinnerParam = (heliumPID && cfgCompensatePIDinTracking) ? 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 * mBBparamsHe[5]}; - return static_cast((candidate.tpcSignal() - expTPCSignal) / resoTPC); - } - - template - bool selectionPIDHe3(const T& candidate) - { - auto nSigmaHe3 = computeNSigmaHe3(candidate); - if (std::abs(nSigmaHe3) < nsigmaCutTPC) { - return true; - } - return false; - } - - template - bool FillCandidateInfo(const T1& candidateHe3, const T2& candidatePr, bool mix, bool /*isMC*/ = false) - { - lithium4Candidate l4Cand; - - l4Cand.momHe3 = array{2 * candidateHe3.px(), 2 * candidateHe3.py(), 2 * candidateHe3.pz()}; - l4Cand.momPr = array{candidatePr.px(), candidatePr.py(), candidatePr.pz()}; - - float invMass = RecoDecay::m(array{l4Cand.momHe3, l4Cand.momPr}, array{he3Mass, protonMass}); - - if (invMass < 3.74 || invMass > 3.85 || candidatePr.pt() > cfgCutMaxPrPT) { - return false; - } - - l4Cand.PIDtrkHe3 = candidateHe3.pidForTracking(); - l4Cand.PIDtrkPr = candidatePr.pidForTracking(); - - l4Cand.sign = candidateHe3.sign(); - - l4Cand.isBkgUS = candidateHe3.sign() * candidatePr.sign() < 0; - l4Cand.isBkgEM = mix; - - l4Cand.DCAxyHe3 = candidateHe3.dcaXY(); - l4Cand.DCAzHe3 = candidateHe3.dcaZ(); - l4Cand.DCAxyPr = candidatePr.dcaXY(); - l4Cand.DCAzPr = candidatePr.dcaZ(); - - bool heliumPID = candidateHe3.pidForTracking() == o2::track::PID::Helium3 || candidateHe3.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && cfgCompensatePIDinTracking) ? candidateHe3.tpcInnerParam() / 2.f : candidateHe3.tpcInnerParam(); - - l4Cand.tpcSignalHe3 = candidateHe3.tpcSignal(); - l4Cand.momHe3TPC = correctedTPCinnerParamHe3; - l4Cand.tpcSignalPr = candidatePr.tpcSignal(); - l4Cand.momPrTPC = candidatePr.tpcInnerParam(); - l4Cand.invMass = invMass; - - l4Cand.itsClSizeHe3 = candidateHe3.itsClusterSizes(); - l4Cand.itsClSizePr = candidatePr.itsClusterSizes(); - - l4Cand.nTPCClustersHe3 = candidateHe3.tpcNClsFound(); - - l4Cand.nSigmaHe3 = computeNSigmaHe3(candidateHe3); - l4Cand.nSigmaPr = candidatePr.tpcNSigmaPr(); - - l4Cand.sharedClustersHe3 = candidateHe3.tpcNClsShared(); - l4Cand.sharedClustersPr = candidatePr.tpcNClsShared(); - - l4Candidates.push_back(l4Cand); - return true; - } - - template - void fillHistograms(const T& l4cand) - { - int candSign = l4cand.sign; - histos.fill(HIST("hHe3Pt"), l4cand.recoPtHe3()); - histos.fill(HIST("hProtonPt"), l4cand.recoPtPr()); - histos.fill(HIST("hLitInvMass"), l4cand.invMass); - histos.fill(HIST("hDCAxyHe3"), l4cand.DCAxyHe3); - histos.fill(HIST("hDCAzHe3"), l4cand.DCAzHe3); - histos.fill(HIST("h2NsigmaHe3TPC"), candSign * l4cand.momHe3TPC, l4cand.nSigmaHe3); - histos.fill(HIST("h2NsigmaProtonTPC"), candSign * l4cand.momPrTPC, l4cand.nSigmaPr); - histos.fill(HIST("h2NsigmaProtonTOF"), l4cand.recoPtPr(), l4cand.nSigmaPr); - } - - 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>; - using TrackCandidatesMC = soa::Filtered>; - o2::pid::tof::Beta responseBeta; - o2::pid::tof::Beta responseBetaMC; - - Preslice perCol = aod::track::collisionId; - Preslice perColMC = aod::track::collisionId; - - // binning for EM background - ConfigurableAxis axisVertex{"axisVertex", {30, -10, 10}, "vertex axis for bin"}; - using BinningType = ColumnBinningPolicy; - BinningType binningOnPositions{{axisVertex}, true}; - SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, &cache}; - - void processSameEvent(soa::Join const& collisions, TrackCandidates const& tracks, aod::BCs const&) - { - l4Candidates.clear(); - - for (auto& collision : collisions) { - if (!collision.sel8() || std::abs(collision.posZ()) > cfgCutVertex) { - continue; - } - histos.fill(HIST("hNcontributor"), collision.numContrib()); - histos.fill(HIST("hVtxZ"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto TrackTable_thisCollision = tracks.sliceBy(perCol, collIdx); - TrackTable_thisCollision.bindExternalIndices(&tracks); - - for (auto track1 : TrackTable_thisCollision) { - - histos.fill(HIST("hTrackSel"), Selections::kNoCuts); - bool heliumPID = track1.pidForTracking() == o2::track::PID::Helium3 || track1.pidForTracking() == o2::track::PID::Alpha; - - float correctedTPCinnerParam = (heliumPID && cfgCompensatePIDinTracking) ? track1.tpcInnerParam() / 2.f : track1.tpcInnerParam(); - histos.fill(HIST("h2dEdxHe3candidates"), correctedTPCinnerParam * 2.f, track1.tpcSignal()); - - if (!track1.isGlobalTrackWoDCA()) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kGlobalTrack); - - if (!selectionTrack(track1)) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kTrackCuts); - - if (!selectionPIDHe3(track1)) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kPID); - - for (auto track2 : TrackTable_thisCollision) { - - if (track1 == track2) { - continue; - } - - if (!cfgEnableBkgUS) { - if (track1.sign() * track2.sign() < 0) { - continue; - } - } - - if (!track2.isGlobalTrackWoDCA()) { - continue; - } - - if (!selectionTrack(track2)) { - continue; - } - - if (!selectionPIDProton(track2)) { - continue; - } - - if (!FillCandidateInfo(track1, track2, false)) { - continue; - } - // fill TOF info outside to avoide responseBeta crash - auto& cand = l4Candidates.back(); - if (track1.hasTOF()) { - float beta = responseBeta.GetBeta(track1); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - bool heliumPID = track1.pidForTracking() == o2::track::PID::Helium3 || track1.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && cfgCompensatePIDinTracking) ? track1.tpcInnerParam() / 2.f : track1.tpcInnerParam(); - cand.massTOFHe3 = correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); - } - if (track2.hasTOF()) { - float beta = responseBeta.GetBeta(track2); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - cand.massTOFPr = track2.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); - } - fillHistograms(cand); - } - } - } - - for (auto& l4Cand : l4Candidates) { - outputDataTable(l4Cand.recoPtHe3(), l4Cand.recoEtaHe3(), l4Cand.recoPhiHe3(), - l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), - l4Cand.DCAxyHe3, l4Cand.DCAzHe3, l4Cand.DCAxyPr, l4Cand.DCAzPr, - l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.tpcSignalPr, l4Cand.momPrTPC, - l4Cand.nTPCClustersHe3, - l4Cand.nSigmaHe3, l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, - l4Cand.PIDtrkHe3, l4Cand.PIDtrkPr, l4Cand.itsClSizeHe3, l4Cand.itsClSizePr, - l4Cand.sharedClustersHe3, l4Cand.sharedClustersPr, - l4Cand.isBkgUS, l4Cand.isBkgEM); - } - } - PROCESS_SWITCH(lithium4analysis, processSameEvent, "Process Same event", false); - - void processMixedEvent(EventCandidates& /*collisions*/, TrackCandidates const& /*tracks*/) - { - l4Candidates.clear(); - for (auto& [c1, tracks1, c2, tracks2] : pair) { - if (!c1.sel8()) { - continue; - } - if (!c2.sel8()) { - continue; - } - histos.fill(HIST("hNcontributor"), c1.numContrib()); - histos.fill(HIST("hVtxZ"), c1.posZ()); - - for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - if (!t1.isGlobalTrackWoDCA()) { - continue; - } - - if (!selectionTrack(t1)) { - continue; - } - - if (!t2.isGlobalTrackWoDCA()) { - continue; - } - - if (!selectionTrack(t2)) { - continue; - } - - TrackCandidates::iterator he3Cand, protonCand; - bool passPID = false; - if (selectionPIDHe3(t1) && selectionPIDProton(t2)) { - he3Cand = t1, protonCand = t2; - passPID = true; - } - if (selectionPIDHe3(t2) && selectionPIDProton(t1)) { - he3Cand = t2, protonCand = t1; - passPID = true; - } - if (!passPID) { - continue; - } - - bool heliumPID = he3Cand.pidForTracking() == o2::track::PID::Helium3 || he3Cand.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParam = (heliumPID && cfgCompensatePIDinTracking) ? he3Cand.tpcInnerParam() / 2.f : he3Cand.tpcInnerParam(); - histos.fill(HIST("h2dEdxHe3candidates"), correctedTPCinnerParam * 2.f, he3Cand.tpcSignal()); - - if (!FillCandidateInfo(he3Cand, protonCand, true)) { - continue; - } - // fill TOF info outside to avoide responseBeta crash - auto& cand = l4Candidates.back(); - if (he3Cand.hasTOF()) { - float beta = responseBeta.GetBeta(he3Cand); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - - bool heliumPID = t1.pidForTracking() == o2::track::PID::Helium3 || he3Cand.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && cfgCompensatePIDinTracking) ? he3Cand.tpcInnerParam() / 2.f : he3Cand.tpcInnerParam(); - cand.massTOFHe3 = correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); - } - if (protonCand.hasTOF()) { - float beta = responseBeta.GetBeta(protonCand); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - cand.massTOFPr = protonCand.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); - } - fillHistograms(cand); - } - } - - for (auto& l4Cand : l4Candidates) { - outputDataTable(l4Cand.recoPtHe3(), l4Cand.recoEtaHe3(), l4Cand.recoPhiHe3(), - l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), - l4Cand.DCAxyHe3, l4Cand.DCAzHe3, l4Cand.DCAxyPr, l4Cand.DCAzPr, - l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.tpcSignalPr, l4Cand.momPrTPC, - l4Cand.nTPCClustersHe3, - l4Cand.nSigmaHe3, l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, - l4Cand.PIDtrkHe3, l4Cand.PIDtrkPr, l4Cand.itsClSizeHe3, l4Cand.itsClSizePr, - l4Cand.sharedClustersHe3, l4Cand.sharedClustersPr, - l4Cand.isBkgUS, l4Cand.isBkgEM); - } - } - PROCESS_SWITCH(lithium4analysis, processMixedEvent, "Process Mixed event", false); - - void processMC(soa::Join const& collisions, aod::BCs const&, TrackCandidatesMC const& tracks, aod::McParticles const& mcParticles) - { - std::vector filledMothers; - l4Candidates.clear(); - - for (auto& collision : collisions) { - - if (!collision.sel8() || std::abs(collision.posZ()) > cfgCutVertex) { - continue; - } - - histos.fill(HIST("hNcontributor"), collision.numContrib()); - histos.fill(HIST("hVtxZ"), collision.posZ()); - - const uint64_t collIdx = collision.globalIndex(); - auto TrackTable_thisCollision = tracks.sliceBy(perColMC, collIdx); - TrackTable_thisCollision.bindExternalIndices(&tracks); - - for (auto track1 : TrackTable_thisCollision) { - - if (!track1.has_mcParticle()) { - continue; - } - - histos.fill(HIST("hTrackSel"), Selections::kNoCuts); - - if (!track1.isGlobalTrackWoDCA()) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kGlobalTrack); - - if (!selectionTrack(track1)) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kTrackCuts); - - if (!selectionPIDHe3(track1)) { - continue; - } - histos.fill(HIST("hTrackSel"), Selections::kPID); - - for (auto track2 : TrackTable_thisCollision) { - if (!track2.has_mcParticle()) { - continue; - } - - if (!track2.isGlobalTrackWoDCA()) { - continue; - } - - if (!selectionTrack(track2)) { - continue; - } - - if (!selectionPIDProton(track2)) { - continue; - } - - if (track1.sign() * track2.sign() < 0) { - continue; - } - - const auto mctrackHe3 = track1.mcParticle(); - const auto mctrackPr = track2.mcParticle(); - - if (std::abs(mctrackHe3.pdgCode()) != he3PDG || std::abs(mctrackPr.pdgCode()) != protonPDG) { - continue; - } - - for (auto& mothertrack : mctrackHe3.mothers_as()) { - for (auto& mothertrackPr : mctrackPr.mothers_as()) { - - if (mothertrack != mothertrackPr || std::abs(mothertrack.pdgCode()) != lithium4PDG) { - continue; - } - - if (std::abs(mothertrack.y()) > 1) { - continue; - } - - if (!FillCandidateInfo(track1, track2, false, true)) { - continue; - } - - // fill TOF info outside to avoide responseBeta crash - auto& cand = l4Candidates.back(); - if (track1.hasTOF()) { - float beta = responseBetaMC.GetBeta(track1); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - bool heliumPID = track1.pidForTracking() == o2::track::PID::Helium3 || track1.pidForTracking() == o2::track::PID::Alpha; - float correctedTPCinnerParamHe3 = (heliumPID && cfgCompensatePIDinTracking) ? track1.tpcInnerParam() / 2.f : track1.tpcInnerParam(); - cand.massTOFHe3 = correctedTPCinnerParamHe3 * 2.f * std::sqrt(1.f / (beta * beta) - 1.f); - } - if (track2.hasTOF()) { - float beta = responseBetaMC.GetBeta(track2); - beta = std::min(1.f - 1.e-6f, std::max(1.e-4f, beta)); /// sometimes beta > 1 or < 0, to be checked - cand.massTOFPr = track2.tpcInnerParam() * std::sqrt(1.f / (beta * beta) - 1.f); - } - - cand.momHe3MC = mctrackHe3.pt() * (mctrackHe3.pdgCode() > 0 ? 1 : -1); - cand.momPrMC = mctrackPr.pt() * (mctrackPr.pdgCode() > 0 ? 1 : -1); - cand.l4PtMC = mothertrack.pt() * (mothertrack.pdgCode() > 0 ? 1 : -1); - double eLit = mctrackHe3.e() + mctrackPr.e(); - cand.l4MassMC = std::sqrt(eLit * eLit - mothertrack.p() * mothertrack.p()); - filledMothers.push_back(mothertrack.globalIndex()); - fillHistograms(cand); - } - } - } - } - } - - for (auto& mcParticle : mcParticles) { - - if (std::abs(mcParticle.pdgCode()) != lithium4PDG) { - continue; - } - - if (std::abs(mcParticle.y()) > 1 || mcParticle.isPhysicalPrimary() == false) { - continue; - } - - if (std::find(filledMothers.begin(), filledMothers.end(), mcParticle.globalIndex()) != filledMothers.end()) { - continue; - } - - auto kDaughters = mcParticle.daughters_as(); - auto daughtHe3 = false; - auto daughtPr = false; - double eLit = 0; - int signHe3 = 0, signPr = 0; - double ptHe3 = 0, ptPr = 0; - for (auto kCurrentDaughter : kDaughters) { - if (std::abs(kCurrentDaughter.pdgCode()) == he3PDG) { - daughtHe3 = true; - signHe3 = kCurrentDaughter.pdgCode() > 0 ? 1 : -1; - ptHe3 = kCurrentDaughter.pt(); - eLit += kCurrentDaughter.e(); - } else if (std::abs(kCurrentDaughter.pdgCode()) == protonPDG) { - daughtPr = true; - signPr = kCurrentDaughter.pdgCode() > 0 ? 1 : -1; - ptPr = kCurrentDaughter.pt(); - eLit += kCurrentDaughter.e(); - } - } - if (daughtHe3 && daughtPr) { - lithium4Candidate l4Candidate; - int signLi = mcParticle.pdgCode() > 0 ? 1 : -1; - l4Candidate.l4PtMC = mcParticle.pt() * signLi; - l4Candidate.momHe3MC = ptHe3 * signHe3; - l4Candidate.momPrMC = ptPr * signPr; - l4Candidate.l4MassMC = std::sqrt(eLit * eLit - mcParticle.p() * mcParticle.p()); - l4Candidates.push_back(l4Candidate); - } - } - - for (auto& l4Cand : l4Candidates) { - outputMCTable(l4Cand.recoPtHe3(), l4Cand.recoEtaHe3(), l4Cand.recoPhiHe3(), - l4Cand.recoPtPr(), l4Cand.recoEtaPr(), l4Cand.recoPhiPr(), - l4Cand.DCAxyHe3, l4Cand.DCAzHe3, l4Cand.DCAxyPr, l4Cand.DCAzPr, - l4Cand.tpcSignalHe3, l4Cand.momHe3TPC, l4Cand.tpcSignalPr, l4Cand.momPrTPC, - l4Cand.nTPCClustersHe3, - l4Cand.nSigmaHe3, l4Cand.nSigmaPr, l4Cand.massTOFHe3, l4Cand.massTOFPr, - l4Cand.PIDtrkHe3, l4Cand.PIDtrkPr, l4Cand.itsClSizeHe3, l4Cand.itsClSizePr, - l4Cand.sharedClustersHe3, l4Cand.sharedClustersPr, - l4Cand.isBkgUS, l4Cand.isBkgEM, - l4Cand.momHe3MC, l4Cand.momPrMC, - l4Cand.l4PtMC, l4Cand.l4MassMC); - } - } - PROCESS_SWITCH(lithium4analysis, processMC, "Process MC", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc, TaskName{"lithium4analysis"})}; -} diff --git a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx index b60db27433d..6d8e13e69a6 100644 --- a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx @@ -12,6 +12,12 @@ // Build \Lambda-n-n candidates from V0s and tracks // ============================================================================== #include +#include +#include +#include +#include + +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -30,17 +36,25 @@ #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "Common/DataModel/PIDResponse.h" + #include "Common/Core/PID/TPCPIDResponse.h" #include "DataFormatsTPC/BetheBlochAleph.h" #include "DCAFitter/DCAFitterN.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Common/Core/PID/PIDTOF.h" +#include "Common/TableProducer/PID/pidTOFBase.h" + #include "PWGLF/DataModel/LFLnnTables.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -using TracksFull = soa::Join; +using TracksFull = soa::Join; +using TracksFullMC = soa::Join; using CollisionsFull = soa::Join; using CollisionsFullMC = soa::Join; @@ -48,8 +62,7 @@ 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 particleNames{"3H"}; - +static const std::vector NucleiName{"3H"}; std::shared_ptr hEvents; std::shared_ptr hZvtx; std::shared_ptr hCentFT0A; @@ -57,11 +70,27 @@ std::shared_ptr hCentFT0C; std::shared_ptr hCentFT0M; std::shared_ptr hCentFV0A; std::shared_ptr hNsigma3HSel; +std::shared_ptr hNsigma3HSelTOF; std::shared_ptr hdEdx3HSel; +std::shared_ptr hdEdx3HPosTrack; std::shared_ptr hdEdxTot; +std::shared_ptr h3HMassPtTOF; +std::shared_ptr h3HSignalPtTOF; std::shared_ptr hDecayChannel; std::shared_ptr hIsMatterGen; std::shared_ptr hIsMatterGenTwoBody; +std::shared_ptr hDCAxy3H; +std::shared_ptr hLnnCandLoss; +std::shared_ptr hNSigma3HTPC_preselection; + +float alphaAP(std::array const& momB, std::array const& momC) +{ + std::array momA = {momB[0] + momC[0], momB[1] + momC[1], momB[2] + momC[2]}; + float momTot = std::sqrt(momA[0] * momA[0] + momA[1] * momA[1] + momA[2] * momA[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); +} } // namespace @@ -86,6 +115,11 @@ struct lnnCandidate { float piDCAXY = -10; float mom3HTPC = -10.f; float momPiTPC = -10.f; + float mass2TrTOF = -10.f; + float DCAPvto3H = -10.f; + float DCAPvtoPi = -10.f; + float beta = -10.f; + float tpcChi3H = -10.f; std::array mom3H; std::array momPi; std::array decVtx; @@ -114,13 +148,20 @@ struct lnnRecoTask { // Selection criteria Configurable v0cospa{"lnncospa", 0.95, "V0 CosPA"}; - Configurable masswidth{"lnnmasswidth", 0.06, "Mass width (GeV/c^2)"}; - Configurable dcav0dau{"lnndcaDau", 1.0, "DCA V0 Daughters"}; + Configurable masswidth{"lnnmasswidth", 0.1, "Mass width (GeV/c^2)"}; + Configurable dcav0dau{"lnndcaDau", 0.6, "DCA V0 Daughters"}; + Configurable Chi2nClusTPCMax{"Chi2NClusTPCMax", 4, "Chi2 / nClusTPC for triton track max"}; + Configurable Chi2nClusTPCMin{"Chi2NClusTPC", 0.5, "Chi2 / nClusTPC for triton track min"}; + Configurable Chi2nClusITS{"Chi2NClusITS", 36., "Chi2 / nClusITS for triton track"}; Configurable ptMin{"ptMin", 0.5, "Minimum pT of the lnncandidate"}; - Configurable TPCRigidityMin3H{"TPCRigidityMin3H", 0.5, "Minimum rigidity of the triton candidate"}; - Configurable etaMax{"eta", 1., "eta daughter"}; - Configurable nSigmaMax3H{"nSigmaMax3H", 5, "triton dEdx cut (n sigma)"}; + Configurable etaMax{"eta", 0.8, "eta daughter"}; + Configurable TPCRigidityMin3H{"TPCRigidityMin3H", 0.2, "Minimum rigidity of the triton candidate"}; + 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 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"}; Configurable mcSignalOnly{"mcSignalOnly", true, "If true, save only signal in MC"}; // Define o2 fitter, 2-prong, active memory (no need to redefine per event) @@ -131,7 +172,7 @@ struct lnnRecoTask { float piMass = o2::constants::physics::MassPionCharged; // bethe bloch parameters - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for 3H"}; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], 1, 6, NucleiName, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for 3H"}; Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; // CCDB options @@ -149,10 +190,16 @@ struct lnnRecoTask { // histogram axes ConfigurableAxis rigidityBins{"rigidityBins", {200, -10.f, 10.f}, "Binning for rigidity #it{p}^{TPC}/#it{z}"}; - ConfigurableAxis dEdxBins{"dEdxBins", {1000, 0.f, 1000.f}, "Binning for dE/dx"}; + ConfigurableAxis dEdxBins{"dEdxBins", {5000, 0.f, 1000.f}, "Binning for dE/dx"}; ConfigurableAxis nSigmaBins{"nSigmaBins", {200, -5.f, 5.f}, "Binning for n sigma"}; ConfigurableAxis zVtxBins{"zVtxBins", {100, -20.f, 20.f}, "Binning for n sigma"}; ConfigurableAxis centBins{"centBins", {100, 0.f, 100.f}, "Binning for centrality"}; + ConfigurableAxis TritMomBins{"TritMomBins", {100, -5.f, 5.f}, "Binning for Triton momentum"}; + ConfigurableAxis MassTOFBins{"MassTOFBins", {400, 2.0f, 12.f}, "Binning for Triton Mass TOF"}; + ConfigurableAxis PtTritonBins{"PtTritonBins", {200, -5.f, 5.f}, "Binning for Triton p values"}; + ConfigurableAxis PtPosTritonBins{"PtPosTritonBins", {200, 0.f, 5.f}, "Binning for Triton pt positive values"}; + ConfigurableAxis BetaBins{"BetaBins", {550, 0.f, 1.1f}, "Binning for Beta"}; + ConfigurableAxis DCAxyBins{"DCAxyBins", {550, -5.f, 5.f}, "Binning for DCAxy"}; // std vector of candidates std::vector lnnCandidates; @@ -160,6 +207,7 @@ struct lnnRecoTask { std::vector filledMothers; // vector to keep track of the collisions passing the event selection in the MC std::vector isGoodCollision; + // vector to armazenade h3Track Preslice perCollision = o2::aod::v0::collisionId; @@ -195,14 +243,36 @@ struct lnnRecoTask { const AxisSpec nSigma3HAxis{nSigmaBins, "n_{#sigma}({}^{3}H)"}; const AxisSpec zVtxAxis{zVtxBins, "z_{vtx} (cm)"}; const AxisSpec centAxis{centBins, "Centrality"}; - - hNsigma3HSel = qaRegistry.add("hNsigma3HSel", "; p_{TPC}/z (GeV/#it{c}); n_{#sigma} ({}^{3}H)", HistType::kTH2F, {rigidityAxis, nSigma3HAxis}); - hdEdx3HSel = qaRegistry.add("hdEdx3HSel", ";p_{TPC}/z (GeV/#it{c}); dE/dx", HistType::kTH2F, {rigidityAxis, dEdxAxis}); + const AxisSpec TritMomAxis{TritMomBins, "#it{p}({}^{3}H)"}; + const AxisSpec PtTrAxis{PtTritonBins, "#it{p_T}({}^{3}H)"}; + const AxisSpec PtPosTrAxis{PtPosTritonBins, "#it{p_T}({}^{3}H)"}; + const AxisSpec MassTOFAxis{MassTOFBins, "{m}^{2}/{z}^{2}"}; + const AxisSpec BetaAxis{BetaBins, "#beta (TOF)"}; + const AxisSpec DCAxyAxis(DCAxyBins, "DCAxy ({}^{3}H) (cm)"); + + hNsigma3HSel = qaRegistry.add("hNsigma3HSel", "; #it{p}_{TPC}/z (GeV/#it{c}); n_{#sigma} ({}^{3}H)", HistType::kTH2F, {rigidityAxis, nSigma3HAxis}); + hNsigma3HSelTOF = qaRegistry.add("hNsigma3HSelTOF", "; Signed p_{T} ({}^{3}H) (GeV/#it{c^2}); n#sigma_{TOF} ({}^{3}H)", HistType::kTH2F, {PtTrAxis, nSigma3HAxis}); + hdEdx3HSel = qaRegistry.add("hdEdx3HSel", ";#it{p}_{TPC}/z (GeV/#it{c}); dE/dx", HistType::kTH2F, {rigidityAxis, dEdxAxis}); + hdEdx3HPosTrack = qaRegistry.add("hdEdx3HPosTrack", "; #it{p}^{TPC}({}^{3}H); dE/dx", HistType::kTH2F, {TritMomAxis, dEdxAxis}); hdEdxTot = qaRegistry.add("hdEdxTot", ";p_{TPC}/z (GeV/#it{c}); dE/dx", HistType::kTH2F, {rigidityAxis, dEdxAxis}); + h3HMassPtTOF = qaRegistry.add("hTrMassPtTOF", "; #it{p}_{T}({}^{3}H) (#it{GeV}^2/#it{c}^4); m^{2}/z", HistType::kTH2F, {PtTrAxis, MassTOFAxis}); + h3HSignalPtTOF = qaRegistry.add("h3HSignalPtTOF", "; #it{p}_{T}({}^{3}H) (GeV/#it{c}); #beta (TOF)", HistType::kTH2F, {PtTrAxis, BetaAxis}); + hDCAxy3H = qaRegistry.add("hDCAxy3H", "; #it{p}_{T}({}^{3}H) (GeV/#it{c}); #it{DCA}_{xy} 3H", HistType::kTH2F, {PtPosTrAxis, DCAxyAxis}); hEvents = qaRegistry.add("hEvents", ";Events; ", HistType::kTH1D, {{2, -0.5, 1.5}}); + hLnnCandLoss = qaRegistry.add("hLnnCandLoss", ";CandLoss; ", HistType::kTH1D, {{7, -0.5, 6.5}}); + hNSigma3HTPC_preselection = qaRegistry.add("hNSigma3HTPC_preselection", "#it{p}/z (GeV/#it{c}); n#sigma_{TPC}(^{3}H)", HistType::kTH2F, {rigidityAxis, nSigma3HAxis}); hEvents->GetXaxis()->SetBinLabel(1, "All"); hEvents->GetXaxis()->SetBinLabel(2, "sel8"); + hLnnCandLoss->GetYaxis()->SetTitle("#it{N}_{candidates}"); + hLnnCandLoss->GetXaxis()->SetTitle("Cuts"); + hLnnCandLoss->GetXaxis()->SetBinLabel(1, "Initial LnnCandidates"); + hLnnCandLoss->GetXaxis()->SetBinLabel(2, "not 3H"); + hLnnCandLoss->GetXaxis()->SetBinLabel(3, "not anti3H"); + hLnnCandLoss->GetXaxis()->SetBinLabel(4, "#it{p}_{Tmin}"); + hLnnCandLoss->GetXaxis()->SetBinLabel(5, "!isLnnMass"); + hLnnCandLoss->GetXaxis()->SetBinLabel(6, "DCA #it{V}_{0} daughter"); + hLnnCandLoss->GetXaxis()->SetBinLabel(7, "cosPA"); if (doprocessMC) { hDecayChannel = qaRegistry.add("hDecayChannel", ";Decay channel; ", HistType::kTH1D, {{2, -0.5, 1.5}}); hDecayChannel->GetXaxis()->SetBinLabel(1, "2-body"); @@ -273,6 +343,7 @@ struct lnnRecoTask { if (mBBparams3H[5] < 0) { LOG(fatal) << "Bethe-Bloch parameters for 3H not set, please check your CCDB and configuration"; } + for (auto& v0 : V0s) { auto posTrack = v0.posTrack_as(); @@ -285,9 +356,6 @@ struct lnnRecoTask { float posRigidity = posTrack.tpcInnerParam(); float negRigidity = negTrack.tpcInnerParam(); - hdEdxTot->Fill(posRigidity, posTrack.tpcSignal()); - hdEdxTot->Fill(-negRigidity, negTrack.tpcSignal()); - // Bethe-Bloch calcution for 3H & nSigma calculation double expBethePos{tpc::BetheBlochAleph(static_cast(posRigidity / constants::physics::MassTriton), mBBparams3H[0], mBBparams3H[1], mBBparams3H[2], mBBparams3H[3], mBBparams3H[4])}; double expBetheNeg{tpc::BetheBlochAleph(static_cast(negRigidity / constants::physics::MassTriton), mBBparams3H[0], mBBparams3H[1], mBBparams3H[2], mBBparams3H[3], mBBparams3H[4])}; @@ -296,29 +364,51 @@ struct lnnRecoTask { auto nSigmaTPCpos = static_cast((posTrack.tpcSignal() - expBethePos) / expSigmaPos); auto nSigmaTPCneg = static_cast((negTrack.tpcSignal() - expBetheNeg) / expSigmaNeg); + hdEdxTot->Fill(posRigidity, posTrack.tpcSignal()); + 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 > -1 * nSigmaMax3H; - bool isAnti3H = negTrack.hasTPC() && nSigmaTPCneg > -1 * nSigmaMax3H; + bool is3H = posTrack.hasTPC() && nSigmaTPCpos > nSigmaCutMinTPC && nSigmaTPCpos < nSigmaCutMaxTPC; + bool isAnti3H = negTrack.hasTPC() && nSigmaTPCneg > nSigmaCutMinTPC && nSigmaTPCneg < nSigmaCutMaxTPC; - if (!is3H && !isAnti3H) + if (!is3H && !isAnti3H) // discard if both tracks are not 3H candidates continue; - // Describing lnn as matter candidate + // if alphaAP is > 0 the candidate is 3H, if < 0 it is anti-3H + std::array momPos = std::array{posTrack.px(), posTrack.py(), posTrack.pz()}; + std::array momNeg = std::array{negTrack.px(), negTrack.py(), negTrack.pz()}; + float alpha = alphaAP(momPos, momNeg); lnnCandidate lnnCand; - lnnCand.isMatter = is3H && isAnti3H ? std::abs(nSigmaTPCpos) < std::abs(nSigmaTPCneg) : is3H; + lnnCand.isMatter = alpha > 0; + hLnnCandLoss->Fill(0.); + if ((lnnCand.isMatter && !is3H) || (!lnnCand.isMatter && !isAnti3H)) { + if (lnnCand.isMatter && !is3H) { + hLnnCandLoss->Fill(1.); + } + if (!lnnCand.isMatter && !isAnti3H) { + hLnnCandLoss->Fill(2.); + } + continue; + } auto& h3track = lnnCand.isMatter ? posTrack : negTrack; auto& h3Rigidity = lnnCand.isMatter ? posRigidity : negRigidity; - if (h3track.tpcNClsFound() < nTPCClusMin3H || h3Rigidity < TPCRigidityMin3H) { + + if (h3Rigidity < TPCRigidityMin3H || + h3track.tpcNClsFound() < nTPCClusMin3H || + h3track.tpcChi2NCl() < Chi2nClusTPCMin || + h3track.tpcChi2NCl() > Chi2nClusTPCMax || + h3track.itsChi2NCl() > Chi2nClusITS) { continue; } + lnnCand.tpcChi3H = lnnCand.isMatter ? h3track.tpcChi2NCl() : negTrack.tpcChi2NCl(); lnnCand.nSigma3H = lnnCand.isMatter ? nSigmaTPCpos : nSigmaTPCneg; - lnnCand.nTPCClusters3H = lnnCand.isMatter ? posTrack.tpcNClsFound() : negTrack.tpcNClsFound(); - lnnCand.tpcSignal3H = lnnCand.isMatter ? posTrack.tpcSignal() : negTrack.tpcSignal(); - lnnCand.clusterSizeITS3H = lnnCand.isMatter ? posTrack.itsClusterSizes() : negTrack.itsClusterSizes(); - lnnCand.nTPCClustersPi = !lnnCand.isMatter ? posTrack.tpcNClsFound() : negTrack.tpcNClsFound(); - lnnCand.tpcSignalPi = !lnnCand.isMatter ? posTrack.tpcSignal() : negTrack.tpcSignal(); - lnnCand.clusterSizeITSPi = !lnnCand.isMatter ? posTrack.itsClusterSizes() : negTrack.itsClusterSizes(); + lnnCand.nTPCClusters3H = lnnCand.isMatter ? h3track.tpcNClsFound() : negTrack.tpcNClsFound(); + lnnCand.tpcSignal3H = lnnCand.isMatter ? h3track.tpcSignal() : negTrack.tpcSignal(); + lnnCand.clusterSizeITS3H = lnnCand.isMatter ? h3track.itsClusterSizes() : negTrack.itsClusterSizes(); + lnnCand.nTPCClustersPi = !lnnCand.isMatter ? h3track.tpcNClsFound() : negTrack.tpcNClsFound(); + lnnCand.tpcSignalPi = !lnnCand.isMatter ? h3track.tpcSignal() : negTrack.tpcSignal(); + lnnCand.clusterSizeITSPi = !lnnCand.isMatter ? h3track.itsClusterSizes() : negTrack.itsClusterSizes(); lnnCand.mom3HTPC = lnnCand.isMatter ? posRigidity : negRigidity; lnnCand.momPiTPC = !lnnCand.isMatter ? posRigidity : negRigidity; @@ -327,6 +417,21 @@ struct lnnRecoTask { auto posTrackCov = getTrackParCov(posTrack); auto negTrackCov = getTrackParCov(negTrack); + int chargeFactor = -1 + 2 * lnnCand.isMatter; + + float beta = -1.f; + if (h3track.pt() >= ptMinTOF) { + hNSigma3HTPC_preselection->Fill(h3track.tpcInnerParam(), lnnCand.nSigma3H); + if (!h3track.hasTOF()) { + continue; + } + + beta = h3track.beta(); + lnnCand.mass2TrTOF = h3track.mass() * h3track.mass(); + if (lnnCand.mass2TrTOF < TrTOFMass2Cut || beta < BetaTrTOF) { + continue; + } + } int nCand = 0; try { @@ -362,23 +467,26 @@ struct lnnRecoTask { float lnnPt = std::hypot(lnnMom[0], lnnMom[1]); if (lnnPt < ptMin) { + hLnnCandLoss->Fill(3.); continue; } // Definition of lnn mass - float mLNN_HypHI = 2.99; // 2993.7 MeV/c**2 + float mLNN_HypHI = 3.00; // , but 2993.7 MeV/c**2 float massLNNL = std::sqrt(h3lE * h3lE - lnnMom[0] * lnnMom[0] - lnnMom[1] * lnnMom[1] - lnnMom[2] * lnnMom[2]); bool isLNNMass = false; if (massLNNL > mLNN_HypHI - masswidth && massLNNL < mLNN_HypHI + masswidth) { isLNNMass = true; } if (!isLNNMass) { + hLnnCandLoss->Fill(4.); continue; } // V0, primary vertex and poiting angle lnnCand.dcaV0dau = std::sqrt(fitter.getChi2AtPCACandidate()); if (lnnCand.dcaV0dau > dcav0dau) { + hLnnCandLoss->Fill(5.); continue; } @@ -386,6 +494,7 @@ struct lnnRecoTask { double cosPA = RecoDecay::cpa(primVtx, lnnCand.decVtx, lnnMom); if (cosPA < v0cospa) { + hLnnCandLoss->Fill(6.); continue; } @@ -395,22 +504,28 @@ struct lnnRecoTask { // if survived all selections, propagate decay daughters to PV gpu::gpustd::array dcaInfo; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, h3PropTrack, 2.f, fitter.getMatCorrType(), &dcaInfo); + lnnCand.h3DCAXY = dcaInfo[0]; - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, posTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); - lnnCand.isMatter ? lnnCand.h3DCAXY = dcaInfo[0] : lnnCand.piDCAXY = dcaInfo[0]; - - o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, negTrackCov, 2.f, fitter.getMatCorrType(), &dcaInfo); - lnnCand.isMatter ? lnnCand.piDCAXY = dcaInfo[0] : lnnCand.h3DCAXY = dcaInfo[0]; + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, piPropTrack, 2.f, fitter.getMatCorrType(), &dcaInfo); + lnnCand.piDCAXY = dcaInfo[0]; // finally, push back the candidate lnnCand.isReco = true; lnnCand.posTrackID = posTrack.globalIndex(); lnnCand.negTrackID = negTrack.globalIndex(); - int chargeFactor = -1 + 2 * lnnCand.isMatter; + lnnCandidates.push_back(lnnCand); + + // Fill QA histograms hdEdx3HSel->Fill(chargeFactor * lnnCand.mom3HTPC, h3track.tpcSignal()); hNsigma3HSel->Fill(chargeFactor * lnnCand.mom3HTPC, lnnCand.nSigma3H); - lnnCandidates.push_back(lnnCand); + hDCAxy3H->Fill(h3track.pt(), h3track.dcaXY()); + if (h3track.hasTOF()) { + h3HSignalPtTOF->Fill(chargeFactor * h3track.pt(), beta); + hNsigma3HSelTOF->Fill(chargeFactor * h3track.p(), h3track.tofNSigmaTr()); + h3HMassPtTOF->Fill(chargeFactor * h3track.pt(), lnnCand.mass2TrTOF); + } } } @@ -425,6 +540,7 @@ struct lnnRecoTask { if (mcLabPos.has_mcParticle() && mcLabNeg.has_mcParticle()) { auto mcTrackPos = mcLabPos.mcParticle_as(); auto mcTrackNeg = mcLabNeg.mcParticle_as(); + if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) { for (auto& negMother : mcTrackNeg.mothers_as()) { for (auto& posMother : mcTrackPos.mothers_as()) { @@ -450,7 +566,6 @@ struct lnnRecoTask { lnnCand.isSignal = true; lnnCand.pdgCode = posMother.pdgCode(); lnnCand.survEvSelection = isGoodCollision[posMother.mcCollisionId()]; - filledMothers.push_back(posMother.globalIndex()); } } @@ -468,7 +583,7 @@ struct lnnRecoTask { initCCDB(bc); hEvents->Fill(0.); - if (!collision.sel8() || std::abs(collision.posZ()) > 10) { + if ((!collision.sel8()) || std::abs(collision.posZ()) > 10) { continue; } hEvents->Fill(1.); @@ -494,6 +609,7 @@ struct lnnRecoTask { lnnCand.dcaV0dau, lnnCand.h3DCAXY, lnnCand.piDCAXY, lnnCand.nSigma3H, lnnCand.nTPCClusters3H, lnnCand.nTPCClustersPi, lnnCand.mom3HTPC, lnnCand.momPiTPC, lnnCand.tpcSignal3H, lnnCand.tpcSignalPi, + lnnCand.mass2TrTOF, lnnCand.tpcChi3H, lnnCand.clusterSizeITS3H, lnnCand.clusterSizeITSPi, lnnCand.flags); } } @@ -501,9 +617,11 @@ struct lnnRecoTask { PROCESS_SWITCH(lnnRecoTask, processData, "Data analysis", true); // MC process - void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcCollisions, aod::V0s const& V0s, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC) + void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcCollisions, aod::V0s const& V0s, aod::BCsWithTimestamps const&, TracksFull const& tracks, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC) { filledMothers.clear(); + + isGoodCollision.clear(); isGoodCollision.resize(mcCollisions.size(), false); for (const auto& collision : collisions) { @@ -548,6 +666,7 @@ struct lnnRecoTask { lnnCand.dcaV0dau, lnnCand.h3DCAXY, lnnCand.piDCAXY, lnnCand.nSigma3H, lnnCand.nTPCClusters3H, lnnCand.nTPCClustersPi, lnnCand.mom3HTPC, lnnCand.momPiTPC, lnnCand.tpcSignal3H, lnnCand.tpcSignalPi, + lnnCand.mass2TrTOF, lnnCand.tpcChi3H, lnnCand.clusterSizeITS3H, lnnCand.clusterSizeITSPi, lnnCand.flags, chargeFactor * lnnCand.genPt(), lnnCand.genPhi(), lnnCand.genEta(), lnnCand.genPt3H(), lnnCand.gDecVtx[0], lnnCand.gDecVtx[1], lnnCand.gDecVtx[2], lnnCand.isReco, lnnCand.isSignal, lnnCand.survEvSelection); @@ -617,6 +736,7 @@ struct lnnRecoTask { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, chargeFactor * lnnCand.genPt(), lnnCand.genPhi(), lnnCand.genEta(), lnnCand.genPt3H(), lnnCand.gDecVtx[0], lnnCand.gDecVtx[1], lnnCand.gDecVtx[2], lnnCand.isReco, lnnCand.isSignal, lnnCand.survEvSelection); diff --git a/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx b/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx index f76b97e0465..82477987971 100644 --- a/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx +++ b/PWGLF/TableProducer/Nuspex/nucleiSpectra.cxx @@ -19,7 +19,11 @@ // 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" @@ -36,6 +40,7 @@ #include "Common/TableProducer/PID/pidTOFBase.h" #include "Common/Core/EventPlaneHelper.h" #include "Common/DataModel/Qvectors.h" +#include "Common/Tools/TrackTuner.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" @@ -44,6 +49,7 @@ #include "DetectorsBase/Propagator.h" #include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" @@ -65,6 +71,7 @@ using namespace o2::constants::physics; struct NucleusCandidate { int globalIndex; + int collTrackIndex; float pt; float eta; float phi; @@ -76,11 +83,21 @@ struct NucleusCandidate { 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; }; @@ -143,12 +160,12 @@ constexpr int FlowHistDefault[5][1]{ {0}, {0}, {0}}; -constexpr int DCAHistDefault[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.}, @@ -165,7 +182,7 @@ 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 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"}; @@ -222,6 +239,8 @@ struct nucleiSpectra { Produces nucleiTableFlow; Service ccdb; Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + TrackTuner trackTunerObj; Configurable cfgCompensatePIDinTracking{"cfgCompensatePIDinTracking", false, "If true, divide tpcInnerParam by the electric charge"}; @@ -235,6 +254,8 @@ struct nucleiSpectra { 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> 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"}; @@ -242,9 +263,11 @@ struct nucleiSpectra { 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> 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"}; - Configurable> cfgDCAHist{"cfgDCAHist", {nuclei::DCAHistDefault[0], 5, 1, nuclei::names, nuclei::DCAConfigNames}, "DCA hist configuration"}; + Configurable cfgNsigmaTPCcutDCAhists{"cfgNsigmaTPCcutDCAhists", 3., "TPC nsigma cut for DCA hists"}; + Configurable cfgDeltaTOFmassCutDCAhists{"cfgDeltaTOFmassCutDCAhists", 0.2, "Delta TOF mass cut for DCA hists"}; ConfigurableAxis cfgDCAxyBinsProtons{"cfgDCAxyBinsProtons", {1500, -1.5f, 1.5f}, "DCAxy binning for Protons"}; ConfigurableAxis cfgDCAxyBinsDeuterons{"cfgDCAxyBinsDeuterons", {1500, -1.5f, 1.5f}, "DCAxy binning for Deuterons"}; ConfigurableAxis cfgDCAxyBinsTritons{"cfgDCAxyBinsTritons", {1500, -1.5f, 1.5f}, "DCAxy binning for Tritons"}; @@ -268,15 +291,22 @@ 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; + 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; - Filter trackFilter = nabs(aod::track::eta) < cfgCutEta && aod::track::tpcInnerParam > cfgCutTpcMom; - - using TrackCandidates = soa::Filtered>; + using TrackCandidates = soa::Join; // Collisions with chentrality using CollWithCent = soa::Join::iterator; @@ -287,7 +317,6 @@ struct nucleiSpectra { using CollWithQvec = soa::Join::iterator; HistogramRegistry spectra{"spectra", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - o2::pid::tof::Beta responseBeta; double getPhiInRange(double phi) { @@ -337,19 +366,23 @@ struct nucleiSpectra { return; } if (cfgSkimmedProcessing) { - zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fHe3"); + 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(); @@ -363,6 +396,9 @@ struct nucleiSpectra { const AxisSpec nITSClusAxis{cfgNITSClusBins, "N ITS clusters"}; const AxisSpec nTPCClusAxis{cfgNTPCClusBins, "N TPC clusters"}; const AxisSpec hasTRDAxis{2, -0.5, 1.5, "Has TRD"}; + const AxisSpec correctPVAxis{2, -0.5, 1.5, "Correct PV"}; + const AxisSpec isSecondaryAxis{2, -0.5, 1.5, "Is secondary"}; + const AxisSpec fromWeakDecayAxis{2, -0.5, 1.5, "From weak decay"}; const AxisSpec ptAxes[5]{ {cfgPtBinsProtons, "#it{p}_{T} (GeV/#it{c})"}, @@ -409,13 +445,15 @@ struct nucleiSpectra { if (doprocessMC) { nuclei::hMomRes[iS][iC] = spectra.add(fmt::format("h{}MomRes{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("Momentum resolution {}", nuclei::names[iS]).data(), HistType::kTH3D, {centAxis, ptAxes[iS], ptResAxis}); nuclei::hGenNuclei[iS][iC] = spectra.add(fmt::format("h{}Gen{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("Generated {}", nuclei::names[iS]).data(), HistType::kTH2D, {centAxis, ptAxes[iS]}); - } - if (doprocessDataFlow) { - if (cfgFlowHist->get(iS)) { - nuclei::hFlowHists[iC][iS] = spectra.add(fmt::format("hFlowHists{}_{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("Flow histograms {} {}", nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTHnSparseF, {centAxis, ptAxes[iS], nSigmaAxes[0], tofMassAxis, v2Axis, nITSClusAxis, nTPCClusAxis}); + nuclei::hDCAHists[iC][iS] = spectra.add(fmt::format("hDCAHists{}_{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("DCA histograms {} {}", nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTHnSparseF, {ptAxes[iS], dcaxyAxes[iS], dcazAxes[iS], nSigmaAxes[0], tofMassAxis, nITSClusAxis, nTPCClusAxis, correctPVAxis, isSecondaryAxis, fromWeakDecayAxis}); + } else { + if (doprocessDataFlow) { + if (cfgFlowHist->get(iS)) { + nuclei::hFlowHists[iC][iS] = spectra.add(fmt::format("hFlowHists{}_{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("Flow histograms {} {}", nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTHnSparseF, {centAxis, ptAxes[iS], nSigmaAxes[0], tofMassAxis, v2Axis, nITSClusAxis, nTPCClusAxis}); + } } + nuclei::hDCAHists[iC][iS] = spectra.add(fmt::format("hDCAHists{}_{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("DCA histograms {} {}", nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTHnSparseF, {ptAxes[iS], dcaxyAxes[iS], dcazAxes[iS], nSigmaAxes[0], tofMassAxis, nITSClusAxis, nTPCClusAxis}); } - nuclei::hDCAHists[iC][iS] = spectra.add(fmt::format("hDCAHists{}_{}", nuclei::matter[iC], nuclei::names[iS]).data(), fmt::format("DCA histograms {} {}", nuclei::matter[iC], nuclei::names[iS]).data(), HistType::kTHnSparseF, {ptAxes[iS], dcaxyAxes[iS], dcazAxes[iS], nSigmaAxes[0], tofMassAxis, nITSClusAxis, nTPCClusAxis}); } } @@ -426,7 +464,12 @@ struct nucleiSpectra { } nuclei::lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); - o2::base::Propagator::Instance(true)->setMatLUT(nuclei::lut); + // 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 @@ -452,8 +495,12 @@ struct nucleiSpectra { template void fillDataInfo(Tcoll const& collision, Ttrks const& tracks) { + o2::pid::tof::Beta responseBeta; 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()); @@ -475,7 +522,9 @@ struct nucleiSpectra { int nGloTracks[2]{0, 0}, nTOFTracks[2]{0, 0}; for (auto& track : tracks) { // start loop over tracks - if (track.itsNCls() < cfgCutNclusITS || + if (std::abs(track.eta()) > cfgCutEta || + track.tpcInnerParam() < cfgCutTpcMom || + track.itsNCls() < cfgCutNclusITS || track.tpcNClsFound() < cfgCutNclusTPC || track.tpcNClsCrossedRows() < 70 || track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || @@ -483,7 +532,6 @@ struct nucleiSpectra { 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(); @@ -501,10 +549,12 @@ struct nucleiSpectra { } 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)}; nSigma[0][iS] = static_cast((track.tpcSignal() - expBethe) / expSigma); + nSigmaTPC[iS] = nSigma[0][iS]; selectedTPC[iS] = (nSigma[0][iS] > nuclei::pidCuts[0][iS][0] && nSigma[0][iS] < nuclei::pidCuts[0][iS][1]); goodToAnalyse = goodToAnalyse || selectedTPC[iS]; if (selectedTPC[iS] && track.p() > 0.2) { @@ -515,15 +565,38 @@ struct nucleiSpectra { continue; } - auto trackParCov = getTrackParCov(track); // should we set the charge according to the nucleus? + 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; - o2::base::Propagator::Instance()->propagateToDCA(collVtx, trackParCov, mBz, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfo); + o2::base::Propagator::Instance()->propagateToDCA(collVtx, mTrackParCov, mBz, 2.f, static_cast(cfgMaterialCorrection.value), &dcaInfo); float beta{responseBeta.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{false}; + bool fillDCAHist{false}; + bool correctPV{false}; + bool isSecondary{false}; + bool fromWeakDecay{false}; + if (track.hasTOF()) { flag |= kHasTOF; } @@ -538,60 +611,62 @@ struct nucleiSpectra { if (std::abs(dcaInfo[1]) > cfgDCAcut->get(iS, 1)) { continue; } - ROOT::Math::LorentzVector> fvector{trackParCov.getPt() * nuclei::charges[iS], trackParCov.getEta(), trackParCov.getPhi(), nuclei::masses[iS]}; + ROOT::Math::LorentzVector> fvector{mTrackParCov.getPt() * nuclei::charges[iS], mTrackParCov.getEta(), mTrackParCov.getPhi(), nuclei::masses[iS]}; float y{fvector.Rapidity() + cfgCMrapidity}; - - for (int iPID{0}; iPID < 2; ++iPID) { + for (int iPID{0}; iPID < 2; ++iPID) { /// 0 TPC, 1 TOF if (selectedTPC[iS]) { if (iPID && !track.hasTOF()) { continue; } else if (iPID) { - selectedTOF = true; + 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 (!cfgCutOnReconstructedRapidity || (y > cfgCutRapidityMin && y < cfgCutRapidityMax)) { - nuclei::hDCAxy[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[0]); - nuclei::hDCAz[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[1]); + if (std::abs(nSigmaTPC[iS]) < cfgNsigmaTPCcutDCAhists && (!iPID || std::abs(tofMasses[iS]) < cfgDeltaTOFmassCutDCAhists)) { + nuclei::hDCAxy[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[0]); + nuclei::hDCAz[iPID][iS][iC]->Fill(centrality, fvector.pt(), dcaInfo[1]); + } if (std::abs(dcaInfo[0]) < cfgDCAcut->get(iS, 0u)) { - float tofMass = -10.f; if (!iPID) { /// temporary exclusion of the TOF nsigma PID for the He3 and Alpha nuclei::hNsigma[iPID][iS][iC]->Fill(centrality, fvector.pt(), nSigma[iPID][iS]); nuclei::hNsigmaEta[iPID][iS][iC]->Fill(fvector.eta(), fvector.pt(), nSigma[iPID][iS]); } if (iPID) { - tofMass = correctedTpcInnerParam * std::sqrt(1.f / (beta * beta) - 1.f) - nuclei::masses[iS]; - nuclei::hTOFmass[iS][iC]->Fill(centrality, fvector.pt(), tofMass); - nuclei::hTOFmassEta[iS][iC]->Fill(fvector.eta(), fvector.pt(), tofMass); + nuclei::hTOFmass[iS][iC]->Fill(centrality, fvector.pt(), tofMasses[iS]); + nuclei::hTOFmassEta[iS][iC]->Fill(fvector.eta(), fvector.pt(), tofMasses[iS]); } if (cfgFlowHist->get(iS) && doprocessDataFlow) { if constexpr (std::is_same::value) { auto deltaPhiInRange = getPhiInRange(fvector.phi() - collision.psiFT0C()); auto v2 = std::cos(2.0 * deltaPhiInRange); - nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMass, v2, track.itsNCls(), track.tpcNClsFound()); + 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) { auto deltaPhiInRange = getPhiInRange(fvector.phi() - computeEventPlane(collision.qvecFT0CIm(), collision.qvecFT0CRe())); auto v2 = std::cos(2.0 * deltaPhiInRange); - nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMass, v2, track.itsNCls(), track.tpcNClsFound()); + nuclei::hFlowHists[iC][iS]->Fill(collision.centFT0C(), fvector.pt(), nSigma[0][iS], tofMasses[iS], v2, track.itsNCls(), track.tpcNClsFound()); } } - if (cfgDCAHist->get(iS)) { - nuclei::hDCAHists[iC][iS]->Fill(fvector.pt(), dcaInfo[0], dcaInfo[1], nSigma[0][iS], tofMass, track.itsNCls(), track.tpcNClsFound()); - } } } } } - - if (cfgTreeConfig->get(iS, 0u) && selectedTPC[iS]) { + if (selectedTPC[iS]) { if (cfgTreeConfig->get(iS, 1u) && !selectedTOF) { continue; } - if (cfgDownscaling->get(iS) < 1. && gRandom->Rndm() > cfgDownscaling->get(iS)) { - continue; + !fillTree && cfgTreeConfig->get(iS, 0u) ? fillTree = true : fillTree; + !fillDCAHist && cfgDCAHists->get(iS, iC) ? fillDCAHist = true : fillDCAHist; + bool setPartFlag = cfgTreeConfig->get(iS, 0u) || cfgDCAHists->get(iS, iC); + if (setPartFlag) { + if (cfgDownscaling->get(iS) < 1. && gRandom->Rndm() > cfgDownscaling->get(iS)) { + continue; + } + flag |= BIT(iS); } - flag |= BIT(iS); } } if (flag & (kProton | kDeuteron | kTriton | kHe3 | kHe4) || doprocessMC) { /// ignore PID pre-selections for the MC @@ -624,7 +699,15 @@ struct nucleiSpectra { computeEventPlane(collision.qvecBPosIm(), collision.qvecBPosRe()), collision.multTPC()}); } - nuclei::candidates.emplace_back(NucleusCandidate{static_cast(track.globalIndex()), (1 - 2 * iC) * trackParCov.getPt(), trackParCov.getEta(), trackParCov.getPhi(), correctedTpcInnerParam, beta, collision.posZ(), dcaInfo[0], dcaInfo[1], track.tpcSignal(), track.itsChi2NCl(), track.tpcChi2NCl(), flag, track.tpcNClsFindable(), static_cast(track.tpcNClsCrossedRows()), track.itsClusterMap(), static_cast(track.tpcNClsFound()), static_cast(track.itsClusterSizes())}); + if (fillTree) { + if (track.pt() < cfgCutPtMinTree || track.pt() > cfgCutPtMaxTree) + 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(), + 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 @@ -638,13 +721,19 @@ struct nucleiSpectra { if (!eventSelection(collision)) { return; } - if (cfgSkimmedProcessing) { - zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting - } fillDataInfo(collision, tracks); for (auto& c : nuclei::candidates) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS); + 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); + } + if (c.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); + } + } + } } } PROCESS_SWITCH(nucleiSpectra, processData, "Data analysis", true); @@ -661,7 +750,16 @@ struct nucleiSpectra { } fillDataInfo(collision, tracks); for (auto& c : nuclei::candidates) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS); + 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); + } + if (c.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); + } + } + } } 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); @@ -681,7 +779,16 @@ struct nucleiSpectra { } fillDataInfo(collision, tracks); for (auto& c : nuclei::candidates) { - nucleiTable(c.pt, c.eta, c.phi, c.tpcInnerParam, c.beta, c.zVertex, c.DCAxy, c.DCAz, c.TPCsignal, c.ITSchi2, c.TPCchi2, c.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS); + 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); + } + if (c.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); + } + } + } } 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); @@ -690,7 +797,7 @@ struct nucleiSpectra { PROCESS_SWITCH(nucleiSpectra, processDataFlowAlternative, "Data analysis with flow - alternative framework", false); Preslice tracksPerCollisions = aod::track::collisionId; - void processMC(soa::Join const& collisions, aod::McCollisions const& mcCollisions, TrackCandidates const& tracks, aod::McTrackLabels const& trackLabelsMC, aod::McParticles const& particlesMC, aod::BCsWithTimestamps const&) + void processMC(soa::Join const& collisions, aod::McCollisions const& mcCollisions, soa::Join const& tracks, aod::McParticles const& particlesMC, aod::BCsWithTimestamps const&) { nuclei::candidates.clear(); for (auto& c : mcCollisions) { @@ -707,7 +814,7 @@ struct nucleiSpectra { } std::vector isReconstructed(particlesMC.size(), false); for (auto& c : nuclei::candidates) { - auto label = trackLabelsMC.iteratorAt(c.globalIndex); + auto label = tracks.iteratorAt(c.globalIndex); if (label.mcParticleId() < -1 || label.mcParticleId() >= particlesMC.size()) { continue; } @@ -715,9 +822,24 @@ struct nucleiSpectra { bool storeIt{false}; for (int iS{0}; iS < nuclei::species; ++iS) { if (std::abs(particle.pdgCode()) == nuclei::codes[iS]) { - nuclei::hMomRes[iS][particle.pdgCode() < 0]->Fill(1., std::abs(c.pt * nuclei::charges[iS]), 1. - std::abs(c.pt * nuclei::charges[iS]) / particle.pt()); - storeIt = cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u); /// store only the particles of interest - break; + if (c.fillTree && !storeIt) { + nuclei::hMomRes[iS][particle.pdgCode() < 0]->Fill(1., std::abs(c.pt * nuclei::charges[iS]), 1. - std::abs(c.pt * nuclei::charges[iS]) / particle.pt()); + storeIt = cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u); /// store only the particles of interest + } + auto coll = collisions.iteratorAt(c.collTrackIndex); + int collMCGlobId = coll.mcCollisionId(); + if (particle.mcCollisionId() == collMCGlobId) { + c.correctPV = true; + } + 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); + } } } if (!storeIt) { @@ -732,7 +854,7 @@ struct nucleiSpectra { c.flags |= kIsSecondaryFromMaterial; } 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.flags, c.TPCfindableCls, c.TPCcrossedRows, c.ITSclsMap, c.TPCnCls, c.clusterSizesITS, particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), goodCollisions[particle.mcCollisionId()], absoDecL); + 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(), goodCollisions[particle.mcCollisionId()], absoDecL); } int index{0}; @@ -753,7 +875,7 @@ struct nucleiSpectra { if (!isReconstructed[index] && (cfgTreeConfig->get(iS, 0u) || cfgTreeConfig->get(iS, 1u))) { float absDecL = computeAbsoDecL(particle); - nucleiTableMC(999., 999., 999., 0., 0., 999., 999., 999., -1, -1, -1, flags, 0, 0, 0, 0, 0, particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), goodCollisions[particle.mcCollisionId()], absDecL); + 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(), goodCollisions[particle.mcCollisionId()], absDecL); } break; } diff --git a/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx b/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx new file mode 100644 index 00000000000..9997d4d27c8 --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/pidTOFGeneric.cxx @@ -0,0 +1,410 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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.cxx +/// \origin Based on pidTOFBase.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 +/// + +#include +#include +#include + +// O2 includes +#include "CCDB/BasicCCDBManager.h" +#include "TOFBase/EventTimeMaker.h" +#include "Framework/AnalysisTask.h" +#include "ReconstructionDataFormats/Track.h" + +// O2Physics includes +#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 "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "PID/ParamBase.h" +#include "PID/PIDTOF.h" +#include "PWGLF/DataModel/pidTOFGeneric.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::pid; +using namespace o2::framework::expressions; +using namespace o2::track; + +/// 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)); +} // accept all + +/// Specialization of TOF event time maker +template typename response, + typename trackTypeContainer, + typename responseParametersType> +o2::tof::eventTimeContainer evTimeMakerForTracks(const trackTypeContainer& tracks, + const responseParametersType& responseParameters, + const float& diamond = 6.0, + bool isFast = false) +{ + return o2::tof::evTimeMakerFromParam(tracks, responseParameters, diamond, isFast); +} + +/// Task to produce the event time tables for generic TOF PID +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); + + 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 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"}; + + 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."); + } + // 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; + } + 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()); + } + } 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); + } + } + + 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; + + 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); + } + } + } + PROCESS_SWITCH(pidTOFGeneric, processNoFT0, "Process without FT0", false); + + /// + /// Process function to prepare the event for each track on Run 3 data with the FT0 + using EvTimeCollisionsFT0 = soa::Join; + void processFT0(TrksEvTime& tracks, + aod::FT0s const&, + EvTimeCollisionsFT0 const& collisions) + { + if (!enableTable) { + return; + } + 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; + } + } + + 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; + } + 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 + + float eventTime = 0.f; + float sumOfWeights = 0.f; + float weight = 0.f; + + if (t0TOF[1] < errDiamond && (maxEvTimeTOF <= 0 || 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 < 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)) { + 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()) { + 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; + } + 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); + + /// + /// 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()); + + // for tracks not assigned to a collision + for (auto track : tracks) { + if (!track.has_collision()) { + 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 < tracks.size(); i++) { + tableEvTimeForTrack(collision.t0AC() * 1000.f, collision.t0resolution() * 1000.f); + } + return; + } + } + 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); + } + } + } + PROCESS_SWITCH(pidTOFGeneric, processOnlyFT0, "Process only with FT0", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Nuspex/spectraDerivedMaker.cxx b/PWGLF/TableProducer/Nuspex/spectraDerivedMaker.cxx index c96b8b1fbb6..bce0c9153d1 100644 --- a/PWGLF/TableProducer/Nuspex/spectraDerivedMaker.cxx +++ b/PWGLF/TableProducer/Nuspex/spectraDerivedMaker.cxx @@ -178,7 +178,7 @@ struct spectraDerivedMaker { histos.fill(HIST("evsel"), 6.f); } } - if (abs(collision.posZ()) > cfgCutVertex) { + if (std::abs(collision.posZ()) > cfgCutVertex) { return false; } if constexpr (fillHistograms) { @@ -235,7 +235,7 @@ struct spectraDerivedMaker { if constexpr (fillHistograms) { histos.fill(HIST("tracksel"), 1); } - if (abs(track.eta()) > cfgCutEta) { + if (std::abs(track.eta()) > cfgCutEta) { return false; } if constexpr (fillHistograms) { @@ -388,4 +388,4 @@ struct spectraDerivedMaker { PROCESS_SWITCH(spectraDerivedMaker, processMC, "Process MC for derived dataset production", false); }; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } \ No newline at end of file +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx b/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx new file mode 100644 index 00000000000..7dad8981ee7 --- /dev/null +++ b/PWGLF/TableProducer/Nuspex/threebodyKFTask.cxx @@ -0,0 +1,450 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 index 337d87223ad..0f728f37574 100644 --- a/PWGLF/TableProducer/Nuspex/threebodyRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/threebodyRecoTask.cxx @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include "Framework/runDataProcessing.h" @@ -42,29 +44,35 @@ using FullTracksExtIU = soa::Join; struct Candidate3body { + // Index int mcmotherId; int track0Id; int track1Id; int track2Id; - std::array posSV; - TLorentzVector lcand; - TLorentzVector lproton; - TLorentzVector lpion; - TLorentzVector lbachelor; - // 0 - proton, 1 - pion, 2 - bachelor - uint8_t dautpcNclusters[3]; - uint8_t dauitsclussize[3]; - uint8_t daudcatopv[3]; - float dautpcNsigma[3]; + // 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; @@ -79,6 +87,9 @@ struct threebodyRecoTask { std::vector filledMothers; std::vector isGoodCollision; + //------------------------------------------------------------------ + 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 @@ -89,6 +100,7 @@ struct threebodyRecoTask { 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"}; @@ -108,32 +120,20 @@ struct threebodyRecoTask { 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}}}}, + {"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}}}}, - {"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}}}}, - {"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, {{240, -6.0f, 6.0f}}}}, - {"hTPCPIDPion", "hTPCPIDPion", {HistType::kTH1F, {{240, -6.0f, 6.0f}}}}, - {"hTPCPIDDeuteron", "hTPCPIDDeuteron", {HistType::kTH1F, {{240, -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"}}}}, @@ -144,41 +144,22 @@ struct threebodyRecoTask { {"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})"}}}}, - {"h3dMassHypertriton", "h3dMassHypertriton", {HistType::kTH3F, {{20, 0.0f, 100.0f, "Cent (%)"}, {200, 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 (%)"}, {200, 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)"}, {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - - {"hTrueHypertritonCounter", "hTrueHypertritonCounter", {HistType::kTH1F, {{12, 0.0f, 12.0f}}}}, - {"hDeuteronTOFVsPBeforeTOFCutSig", "hDeuteronTOFVsPBeforeTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronTOFVsPAtferTOFCutSig", "hDeuteronTOFVsPAtferTOFCutSig", {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)"}, {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}, {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}}}}, - - // for mcparticles information - {"hGeneratedHypertritonCounter", "hGeneratedHypertritonCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hPtGeneratedHypertriton", "hPtGeneratedHypertriton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hctGeneratedHypertriton", "hctGeneratedHypertriton", {HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}}}, - {"hEtaGeneratedHypertriton", "hEtaGeneratedHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hRapidityGeneratedHypertriton", "hRapidityGeneratedHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hPtGeneratedAntiHypertriton", "hPtGeneratedAntiHypertriton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hctGeneratedAntiHypertriton", "hctGeneratedAntiHypertriton", {HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}}}, - {"hEtaGeneratedAntiHypertriton", "hEtaGeneratedAntiHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hRapidityGeneratedAntiHypertriton", "hRapidityGeneratedAntiHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, }, }; //------------------------------------------------------------------ // Fill stats histograms enum vtxstep { kCandAll = 0, - kCandCosPA, kCandDauEta, + kCandDauPt, + kCandTPCNcls, + kCandTPCPID, + kCandTOFPID, + kCandDcaToPV, kCandRapidity, kCandct, + kCandCosPA, kCandDcaDau, - kCandTOFPID, - kCandTPCPID, - kCandTPCNcls, - kCandDauPt, - kCandDcaToPV, kCandInvMass, kNCandSteps }; @@ -205,7 +186,9 @@ struct threebodyRecoTask { { for (Int_t ii = 0; ii < kNCandSteps; ii++) { registry.fill(HIST("hCandidatesCounter"), ii, statisticsRegistry.candstats[ii]); - registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); + if (doprocessMC == true) { + registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); + } } } @@ -214,28 +197,47 @@ struct threebodyRecoTask { void init(InitContext const&) { - AxisSpec dcaAxis = {dcaBinning, "DCA (cm)"}; - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/c)"}; - AxisSpec massAxisHypertriton = {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"}; - 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"); - TString CandCounterbinLabel[12] = {"Total", "VtxCosPA", "TrackEta", "MomRapidity", "Lifetime", "VtxDcaDau", "d TOFPID", "TPCPID", "TPCNcls", "DauPt", "PionDcatoPV", "InvMass"}; + // 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]); - registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); + if (doprocessMC == true) { + registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); + } } - - registry.get(HIST("hGeneratedHypertritonCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hGeneratedHypertritonCounter"))->GetXaxis()->SetBinLabel(2, "3-body decay"); } //------------------------------------------------------------------ - Preslice perCollisionVtx3BodyDatas = o2::aod::vtx3body::collisionId; - //------------------------------------------------------------------ + // Check if the mcparticle is hypertriton which decays into 3 daughters template bool is3bodyDecayed(TMCParticle const& particle) { @@ -267,165 +269,61 @@ struct threebodyRecoTask { } //------------------------------------------------------------------ - // Analysis process for a single candidate - template - void CandidateAnalysis(TCollisionTable const& dCollision, TCandTable const& candData, bool& if_hasvtx, bool isTrueCand = false, int lLabel = -1, TLorentzVector lmother = {0, 0, 0, 0}, double MClifetime = -1) + // 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) { - FillCandCounter(kCandAll, isTrueCand); - - auto track0 = candData.template track0_as(); - auto track1 = candData.template track1_as(); - auto track2 = candData.template track2_as(); - - auto& trackProton = (track2.sign() > 0) ? track0 : track1; - auto& trackPion = (track2.sign() > 0) ? track1 : track0; - auto& trackDeuteron = track2; - - float cospa = candData.vtxcosPA(dCollision.posX(), dCollision.posY(), dCollision.posZ()); - if (cospa < vtxcospa) { - return; - } - FillCandCounter(kCandCosPA, isTrueCand); - if (TMath::Abs(trackProton.eta()) > etacut || TMath::Abs(trackPion.eta()) > etacut || TMath::Abs(trackDeuteron.eta()) > etacut) { - return; - } - FillCandCounter(kCandDauEta, isTrueCand); - if (TMath::Abs(candData.yHypertriton()) > rapiditycut) { - return; - } - FillCandCounter(kCandRapidity, isTrueCand); - double ct = candData.distovertotmom(dCollision.posX(), dCollision.posY(), dCollision.posZ()) * o2::constants::physics::MassHyperTriton; - if (ct > lifetimecut) { - return; - } - FillCandCounter(kCandct, isTrueCand); - if (candData.dcaVtxdaughters() > dcavtxdau) { - return; - } - FillCandCounter(kCandDcaDau, isTrueCand); - - registry.fill(HIST("hDeuteronTOFVsPBeforeTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - if (isTrueCand) { - registry.fill(HIST("hDeuteronTOFVsPBeforeTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - } - if ((candData.tofNSigmaBachDe() < TofPidNsigmaMin || candData.tofNSigmaBachDe() > TofPidNsigmaMax) && trackDeuteron.p() > minDeuteronPUseTOF) { - return; - } - FillCandCounter(kCandTOFPID, isTrueCand); - registry.fill(HIST("hDeuteronTOFVsPAtferTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - if (isTrueCand) { - registry.fill(HIST("hDeuteronTOFVsPAtferTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); - } - - if (TMath::Abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut || TMath::Abs(trackPion.tpcNSigmaPi()) > TpcPidNsigmaCut || TMath::Abs(trackDeuteron.tpcNSigmaDe()) > TpcPidNsigmaCut) { - return; - } - FillCandCounter(kCandTPCPID, isTrueCand); - - if (trackProton.tpcNClsFound() < mintpcNClsproton || trackPion.tpcNClsFound() < mintpcNClspion || trackDeuteron.tpcNClsFound() < mintpcNClsdeuteron) { - return; - } - FillCandCounter(kCandTPCNcls, isTrueCand); - - if (trackProton.pt() < minProtonPt || trackProton.pt() > maxProtonPt || trackPion.pt() < minPionPt || trackPion.pt() > maxPionPt || trackDeuteron.pt() < minDeuteronPt || trackDeuteron.pt() > maxDeuteronPt) { - return; - } - FillCandCounter(kCandDauPt, isTrueCand); - - double dcapion = (track2.sign() > 0) ? candData.dcatrack1topv() : candData.dcatrack0topv(); - if (TMath::Abs(dcapion) < dcapiontopv) { - return; - } - FillCandCounter(kCandDcaToPV, isTrueCand); - - // 3sigma region for Dalitz plot - double lowersignallimit = o2::constants::physics::MassHyperTriton - 3 * mcsigma; - double uppersignallimit = o2::constants::physics::MassHyperTriton + 3 * mcsigma; + 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; - // Hypertriton - if ((track2.sign() > 0 && candData.mHypertriton() > h3LMassLowerlimit && candData.mHypertriton() < h3LMassUpperlimit)) { - FillCandCounter(kCandInvMass, isTrueCand); - - registry.fill(HIST("hPtProton"), trackProton.pt()); - registry.fill(HIST("hPtPionMinus"), trackPion.pt()); - registry.fill(HIST("hPtDeuteron"), trackDeuteron.pt()); - 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()); // dCollision.centV0M() instead of 0. once available - registry.fill(HIST("h3dTotalHypertriton"), ct, candData.pt(), candData.mHypertriton()); - - cand3body.isMatter = true; + 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); - - 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, lmother.Pt(), candData.mHypertriton()); - } - } else if ((track2.sign() < 0 && candData.mAntiHypertriton() > h3LMassLowerlimit && candData.mAntiHypertriton() < h3LMassUpperlimit)) { - // AntiHypertriton - FillCandCounter(kCandInvMass, isTrueCand); - cand3body.isMatter = false; + } 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); - - registry.fill(HIST("hPtAntiProton"), trackProton.pt()); - registry.fill(HIST("hPtPionPlus"), trackPion.pt()); - registry.fill(HIST("hPtAntiDeuteron"), trackDeuteron.pt()); - 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()); // dCollision.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, lmother.Pt(), candData.mHypertriton()); - } - } else { - return; } - if_hasvtx = true; cand3body.mcmotherId = lLabel; cand3body.track0Id = candData.track0Id(); cand3body.track1Id = candData.track1Id(); cand3body.track2Id = candData.track2Id(); cand3body.invmass = cand3body.isMatter ? candData.mHypertriton() : candData.mAntiHypertriton(); - cand3body.posSV[0] = candData.x(); - cand3body.posSV[1] = candData.y(); - cand3body.posSV[2] = candData.z(); + 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] = trackPion.itsClusterSizes(); + 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.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(dCollision.posX(), dCollision.posY(), dCollision.posZ()); + 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; @@ -435,15 +333,6 @@ struct threebodyRecoTask { Candidates3body.push_back(cand3body); - registry.fill(HIST("hDCADeuteronToPV"), candData.dcatrack2topv()); - registry.fill(HIST("hVtxCosPA"), candData.vtxcosPA(dCollision.posX(), dCollision.posY(), dCollision.posZ())); - registry.fill(HIST("hDCAVtxDau"), candData.dcaVtxdaughters()); - registry.fill(HIST("hProtonTPCNcls"), trackProton.tpcNClsFound()); - registry.fill(HIST("hPionTPCNcls"), trackPion.tpcNClsFound()); - registry.fill(HIST("hDeuteronTPCNcls"), trackDeuteron.tpcNClsFound()); - 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()); @@ -451,6 +340,148 @@ struct threebodyRecoTask { 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(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})); + } + } 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(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})); + } + } 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()); + } + } } //------------------------------------------------------------------ @@ -458,7 +489,7 @@ struct threebodyRecoTask { void GetGeneratedH3LInfo(aod::McParticles const& particlesMC) { for (auto& mcparticle : particlesMC) { - if (mcparticle.pdgCode() != motherPdgCode && mcparticle.pdgCode() != -motherPdgCode) { + if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { continue; } registry.fill(HIST("hGeneratedHypertritonCounter"), 0.5); @@ -502,58 +533,104 @@ struct threebodyRecoTask { //------------------------------------------------------------------ // process real data analysis - void processData(soa::Join::iterator const& collision, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) + void processData(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) { - Candidates3body.clear(); - 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); + for (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 && abs(collision.posZ()) > 10.f) { // 10cm + continue; + } + registry.fill(HIST("hEventCounter"), 2.5); + registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - bool if_hasvtx = false; + bool if_hasvtx = false; + auto d3bodyCands = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); + for (auto vtx : d3bodyCands) { + CandidateAnalysis(collision, vtx, if_hasvtx); + } + if (if_hasvtx) + registry.fill(HIST("hEventCounter"), 3.5); + fillHistos(); + resetHistos(); - for (auto& vtx : vtx3bodydatas) { - CandidateAnalysis(collision, vtx, if_hasvtx); + for (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); - if (if_hasvtx) - registry.fill(HIST("hEventCounter"), 3.5); - fillHistos(); - resetHistos(); + //------------------------------------------------------------------ + // process like-sign signal + void processDataLikeSign(soa::Join const& collisions, aod::Vtx3BodyDatas const& vtx3bodydatas, FullTracksExtIU const& /*tracks*/) + { + for (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 && abs(collision.posZ()) > 10.f) { // 10cm + continue; + } + registry.fill(HIST("hEventCounter"), 2.5); + registry.fill(HIST("hCentFT0C"), collision.centFT0C()); - for (auto& cand3body : Candidates3body) { - outputDataTable(collision.centFT0C(), collision.posX(), collision.posY(), collision.posZ(), - cand3body.isMatter, cand3body.invmass, cand3body.lcand.P(), cand3body.lcand.Pt(), cand3body.ct, - cand3body.posSV[0], cand3body.posSV[1], cand3body.posSV[2], - cand3body.cosPA, cand3body.dcadaughters, cand3body.dcacandtopv, - cand3body.lproton.P(), cand3body.lproton.Pt(), cand3body.lproton.Eta(), cand3body.lproton.Phi(), - cand3body.lpion.P(), cand3body.lpion.Pt(), cand3body.lpion.Eta(), cand3body.lpion.Phi(), - cand3body.lbachelor.P(), cand3body.lbachelor.Pt(), cand3body.lbachelor.Eta(), cand3body.lbachelor.Phi(), - 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.daudcatopv[0], cand3body.daudcatopv[1], cand3body.daudcatopv[2]); + bool if_hasvtx = false; + auto d3bodyCands = vtx3bodydatas.sliceBy(perCollisionVtx3BodyDatas, collision.globalIndex()); + for (auto vtx : d3bodyCands) { + LikeSignAnalysis(collision, vtx, if_hasvtx); + } + if (if_hasvtx) + registry.fill(HIST("hEventCounter"), 3.5); + fillHistos(); + resetHistos(); + + for (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_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) { - Candidates3body.clear(); filledMothers.clear(); GetGeneratedH3LInfo(particlesMC); isGoodCollision.resize(mcCollisions.size(), false); for (const auto& collision : collisions) { + Candidates3body.clear(); registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { + if (mc_event_selection && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { continue; } registry.fill(HIST("hEventCounter"), 1.5); @@ -561,6 +638,8 @@ struct threebodyRecoTask { continue; } registry.fill(HIST("hEventCounter"), 2.5); + registry.fill(HIST("hCentFT0C"), collision.centFT0C()); + if (collision.mcCollisionId() >= 0) { isGoodCollision[collision.mcCollisionId()] = true; } @@ -587,7 +666,7 @@ struct threebodyRecoTask { for (auto& lMother2 : lMCTrack2.mothers_as()) { if (lMother0.globalIndex() == lMother1.globalIndex() && lMother0.globalIndex() == lMother2.globalIndex()) { lLabel = lMother0.globalIndex(); - lPDG = lMother1.pdgCode(); + 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; @@ -610,18 +689,18 @@ struct threebodyRecoTask { resetHistos(); for (auto& cand3body : Candidates3body) { - outputMCTable(collision.centFT0C(), collision.posX(), collision.posY(), collision.posZ(), // centV0M() instead of 0. once available + outputMCTable(collision.centFT0C(), cand3body.isMatter, cand3body.invmass, cand3body.lcand.P(), cand3body.lcand.Pt(), cand3body.ct, - cand3body.posSV[0], cand3body.posSV[1], cand3body.posSV[2], - cand3body.cosPA, cand3body.dcadaughters, cand3body.dcacandtopv, - cand3body.lproton.P(), cand3body.lproton.Pt(), cand3body.lproton.Eta(), cand3body.lproton.Phi(), - cand3body.lpion.P(), cand3body.lpion.Pt(), cand3body.lpion.Eta(), cand3body.lpion.Phi(), - cand3body.lbachelor.P(), cand3body.lbachelor.Pt(), cand3body.lbachelor.Eta(), cand3body.lbachelor.Phi(), + 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.P(), cand3body.lgencand.Pt(), cand3body.genct, cand3body.lgencand.Phi(), cand3body.lgencand.Eta(), cand3body.lgencand.Rapidity(), cand3body.isSignal, cand3body.isReco, cand3body.pdgCode, cand3body.SurvivedEventSelection); } } @@ -642,10 +721,9 @@ struct threebodyRecoTask { } } 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, + 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, @@ -653,7 +731,8 @@ struct threebodyRecoTask { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - mcparticle.p(), mcparticle.pt(), MClifetime, mcparticle.phi(), mcparticle.eta(), + -1, -1, -1, + mcparticle.p(), mcparticle.pt(), MClifetime, mcparticle.phi(), mcparticle.eta(), mcparticle.y(), true, false, mcparticle.pdgCode(), isSurEvSelection); } } diff --git a/PWGLF/TableProducer/Resonances/CMakeLists.txt b/PWGLF/TableProducer/Resonances/CMakeLists.txt index baa9b98325a..b8a16e14c53 100644 --- a/PWGLF/TableProducer/Resonances/CMakeLists.txt +++ b/PWGLF/TableProducer/Resonances/CMakeLists.txt @@ -17,7 +17,7 @@ o2physics_add_dpl_workflow(f1protoninitializer o2physics_add_dpl_workflow(f1protonreducedtable SOURCES f1protonreducedtable.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2Physics::EventFilteringUtils COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(filterf1proton diff --git a/PWGLF/TableProducer/Resonances/LFResonanceInitializer.cxx b/PWGLF/TableProducer/Resonances/LFResonanceInitializer.cxx index de8d26cc611..23876a82286 100644 --- a/PWGLF/TableProducer/Resonances/LFResonanceInitializer.cxx +++ b/PWGLF/TableProducer/Resonances/LFResonanceInitializer.cxx @@ -15,6 +15,8 @@ /// /// \author Bong-Hwi Lim +#include +#include #include "Common/DataModel/PIDResponse.h" #include "Common/Core/TrackSelection.h" #include "Common/DataModel/Centrality.h" @@ -89,6 +91,7 @@ struct reso2initializer { /// Event cuts o2::analysis::CollisonCuts colCuts; Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; + Configurable ConfEvtOccupancyInTimeRange{"ConfEvtOccupancyInTimeRange", -1, "Evt sel: maximum 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"}; @@ -510,6 +513,18 @@ struct reso2initializer { 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(), v0.v0cosPA(), v0.dcaV0daughters(), v0.dcapostopv(), @@ -544,6 +559,24 @@ struct reso2initializer { 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(), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.dcaV0daughters(), @@ -831,13 +864,15 @@ struct reso2initializer { mcPart.pz(), mcPart.eta(), mcPart.phi(), - mcPart.y()); + mcPart.y(), + mcPart.e(), + mcPart.statusCode()); daughterPDGs.clear(); } } template - void fillMCCollision(MCCol const& mccol, MCPart const& mcparts) + void fillMCCollision(MCCol const& mccol, MCPart const& mcparts, float impactpar = -999.0) { auto centrality = 0.0; if constexpr (!isRun2) @@ -849,7 +884,7 @@ struct reso2initializer { bool isTriggerTVX = mccol.selection_bit(aod::evsel::kIsTriggerTVX); bool isSel8 = mccol.sel8(); bool isSelected = colCuts.isSelected(mccol); - resoMCCollisions(inVtx10, isTrueINELgt0, isTriggerTVX, isSel8, isSelected); + resoMCCollisions(inVtx10, isTrueINELgt0, isTriggerTVX, isSel8, isSelected, impactpar); // QA for Trigger efficiency qaRegistry.fill(HIST("Event/hMCEventIndices"), centrality, aod::resocollision::kINEL); @@ -923,7 +958,7 @@ struct reso2initializer { if (doprocessTrackDataRun2 || doprocessTrackV0DataRun2 || doprocessTrackV0CascDataRun2 || doprocessTrackMCRun2 || doprocessTrackV0MCRun2 || doprocessTrackV0CascMCRun2) { colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, false); } else if (doprocessTrackData || doprocessTrackV0Data || doprocessTrackV0CascData || doprocessTrackMC || doprocessTrackV0MC || doprocessTrackV0CascMC || doprocessTrackEPData) { - colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, true); + colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, true, false, ConfEvtOccupancyInTimeRange); } colCuts.init(&qaRegistry); colCuts.setTriggerTVX(ConfEvtTriggerTVXSel); @@ -1014,7 +1049,7 @@ struct reso2initializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1031,7 +1066,7 @@ struct reso2initializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1048,7 +1083,7 @@ struct reso2initializer { return; colCuts.fillQA(collision); - resoCollisions(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), d_bz, bc.timestamp()); + resoCollisions(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), d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); } @@ -1066,7 +1101,7 @@ struct reso2initializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1085,7 +1120,7 @@ struct reso2initializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1105,7 +1140,7 @@ struct reso2initializer { return; colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1126,7 +1161,7 @@ struct reso2initializer { return; colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillTracks(collision, tracks); fillV0s(collision, V0s, tracks); @@ -1143,8 +1178,11 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); - fillMCCollision(collision, mcParticles); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); + + auto mccollision = collision.mcCollision_as(); + float impactpar = mccollision.impactParameter(); + fillMCCollision(collision, mcParticles, impactpar); // Loop over tracks fillTracks(collision, tracks); @@ -1163,7 +1201,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(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), d_bz, bc.timestamp()); + resoCollisions(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), d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1183,7 +1221,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1204,7 +1242,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1226,7 +1264,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1249,7 +1287,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQA(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), CentEst(collision), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks @@ -1274,7 +1312,7 @@ struct reso2initializer { initCCDB(bc); colCuts.fillQARun2(collision); - resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp()); + resoCollisions(0, collision.posX(), collision.posY(), collision.posZ(), collision.centRun2V0M(), ComputeSpherocity(tracks, trackSphMin, trackSphDef), 0., 0., 0., 0., d_bz, bc.timestamp(), collision.trackOccupancyInTimeRange()); fillMCCollision(collision, mcParticles); // Loop over tracks diff --git a/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx b/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx index 9668afc3e01..9850a7bf23a 100644 --- a/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx +++ b/PWGLF/TableProducer/Resonances/LFResonanceMergeDF.cxx @@ -25,6 +25,7 @@ /// /// /// \author Bong-Hwi Lim /// Nasir Mehdi Malik +#include #include "Common/DataModel/PIDResponse.h" #include "Common/Core/TrackSelection.h" @@ -60,7 +61,6 @@ using namespace o2::soa; 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"}; @@ -184,7 +184,7 @@ struct reso2dfmerged { const auto& innerVector = vecOfVecOfTuples[i]; histos.fill(HIST("Event/h1d_ft0_mult_percentile"), std::get<3>(tuple)); - resoCollisionsdf(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); + 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, 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) { @@ -239,9 +239,10 @@ struct reso2dfmerged { if (doprocessTrackDataDF) LOG(fatal) << "Disable processTrackDataDF first!"; + histos.fill(HIST("Event/h1d_ft0_mult_percentile"), collision.cent()); - resoCollisionsdf(collision.posX(), collision.posY(), collision.posZ(), collision.cent(), collision.spherocity(), collision.evtPl(), 0., 0., 0., 0., 0); + resoCollisionsdf(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()) diff --git a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx index 30082692386..87fcc6ab1d5 100644 --- a/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx +++ b/PWGLF/TableProducer/Resonances/f1protonreducedtable.cxx @@ -25,6 +25,10 @@ #include #include #include +#include + +#include "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" #include "PWGLF/DataModel/ReducedF1ProtonTables.h" #include "Framework/ASoAHelpers.h" @@ -57,6 +61,9 @@ struct f1protonreducedtable { Service ccdb; o2::ccdb::CcdbApi ccdbApi; + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + // Configs for events Configurable ConfEvtSelectZvtx{"ConfEvtSelectZvtx", true, "Event selection includes max. z-Vertex"}; Configurable ConfEvtZvtx{"ConfEvtZvtx", 10.f, "Evt sel: Max. z-Vertex (cm)"}; @@ -66,6 +73,7 @@ struct f1protonreducedtable { Configurable trackSphMin{"trackSphMin", 10, "Number of tracks for Spherocity Calculation"}; // Configs for track PID + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", true, "Analysed skimmed events"}; Configurable ConfUseManualPIDproton{"ConfUseManualPIDproton", true, "True: use home-made PID solution for proton "}; Configurable ConfUseManualPIDkaon{"ConfUseManualPIDkaon", true, "True: use home-made PID solution for kaon "}; Configurable ConfUseManualPIDpion{"ConfUseManualPIDpion", true, "True: use home-made PID solution for pion "}; @@ -135,6 +143,7 @@ struct f1protonreducedtable { Configurable cMaxRelMom{"cMaxRelMom", 0.5, "Relative momentum cut"}; // Histogram + OutputObj hProcessedEvents{TH1D("hProcessedEvents", ";; Number of events", 2, 0.0f, 2.0f)}; HistogramRegistry qaRegistry{"QAHistos", { {"hEventstat", "hEventstat", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, {"hInvMassf1", "hInvMassf1", {HistType::kTH2F, {{400, 1.1f, 1.9f}, {100, 0.0f, 10.0f}}}}, @@ -163,6 +172,9 @@ struct f1protonreducedtable { ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); + zorroSummary.setObject(zorro.getZorroSummary()); + hProcessedEvents->GetXaxis()->SetBinLabel(1, "All Trigger events"); + hProcessedEvents->GetXaxis()->SetBinLabel(2, "Events with F1 Trigger"); } template @@ -535,10 +547,15 @@ struct f1protonreducedtable { currentRunNumber = collision.bc_as().runNumber(); auto bc = collision.bc_as(); - + hProcessedEvents->Fill(0.5); + bool zorroSelected = false; if (isSelectedEvent(collision)) { - if (ConfUseManualPIDproton || ConfUseManualPIDkaon || ConfUseManualPIDpion) { - if (currentRunNumber != lastRunNumber) { + if (currentRunNumber != lastRunNumber) { + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fTriggerEventF1Proton"); + zorro.populateHistRegistry(qaRegistry, bc.runNumber()); + } + if (ConfUseManualPIDproton || ConfUseManualPIDkaon || ConfUseManualPIDpion) { if (ConfUseManualPIDproton) { BBProton = setValuesBB(ccdbApi, bc, ConfPIDBBProton); BBAntiproton = setValuesBB(ccdbApi, bc, ConfPIDBBAntiProton); @@ -551,201 +568,208 @@ struct f1protonreducedtable { BBKaon = setValuesBB(ccdbApi, bc, ConfPIDBBKaon); BBAntikaon = setValuesBB(ccdbApi, bc, ConfPIDBBAntiKaon); } - lastRunNumber = currentRunNumber; } + lastRunNumber = currentRunNumber; } - - 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 (ConfUseManualPIDproton) { - auto bgScalingProton = 1 / massPr; // momentum scaling? - if (BBProton.size() == 6) - nTPCSigmaP[2] = updatePID(track, bgScalingProton, BBProton); - if (BBAntiproton.size() == 6) - nTPCSigmaN[2] = updatePID(track, bgScalingProton, BBAntiproton); - } - if (ConfUseManualPIDkaon) { - auto bgScalingKaon = 1 / massKa; // momentum scaling? - if (BBKaon.size() == 6) - nTPCSigmaP[1] = updatePID(track, bgScalingKaon, BBKaon); - if (BBAntikaon.size() == 6) - nTPCSigmaN[1] = updatePID(track, bgScalingKaon, BBAntikaon); - } - if (ConfUseManualPIDpion) { - auto bgScalingPion = 1 / massPi; // momentum scaling? - if (BBPion.size() == 6) - nTPCSigmaP[0] = updatePID(track, bgScalingPion, BBPion); - if (BBAntipion.size() == 6) - 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]))) { - 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()); - auto PionTOF = 0; - if (track.sign() > 0) { - qaRegistry.fill(HIST("hNsigmaPtpionTPC"), nTPCSigmaP[0], track.pt()); + if (cfgSkimmedProcessing) { + zorroSelected = zorro.isSelected(collision.template bc_as().globalBC()); + } else { + zorroSelected = true; + } + if (zorroSelected) { + for (auto& track : tracks) { + hProcessedEvents->Fill(1.5); + 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 (ConfUseManualPIDproton) { + auto bgScalingProton = 1 / massPr; // momentum scaling? + if (BBProton.size() == 6) + nTPCSigmaP[2] = updatePID(track, bgScalingProton, BBProton); + if (BBAntiproton.size() == 6) + nTPCSigmaN[2] = updatePID(track, bgScalingProton, BBAntiproton); } - if (track.sign() < 0) { - qaRegistry.fill(HIST("hNsigmaPtpionTPC"), nTPCSigmaN[0], track.pt()); + if (ConfUseManualPIDkaon) { + auto bgScalingKaon = 1 / massKa; // momentum scaling? + if (BBKaon.size() == 6) + nTPCSigmaP[1] = updatePID(track, bgScalingKaon, BBKaon); + if (BBAntikaon.size() == 6) + nTPCSigmaN[1] = updatePID(track, bgScalingKaon, BBAntikaon); } - if (track.hasTOF()) { - qaRegistry.fill(HIST("hNsigmaPtpionTOF"), track.tofNSigmaPi(), track.pt()); - PionTOF = 1; + if (ConfUseManualPIDpion) { + auto bgScalingPion = 1 / massPi; // momentum scaling? + if (BBPion.size() == 6) + nTPCSigmaP[0] = updatePID(track, bgScalingPion, BBPion); + if (BBAntipion.size() == 6) + nTPCSigmaN[0] = updatePID(track, bgScalingPion, BBAntipion); } - 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]))) { - 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()); - auto KaonTOF = 0; - if (track.sign() > 0) { - qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), nTPCSigmaP[1], track.pt()); + 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()); + auto PionTOF = 0; + 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()); + PionTOF = 1; + } + PionTOFHit.push_back(PionTOF); } - if (track.sign() < 0) { - qaRegistry.fill(HIST("hNsigmaPtkaonTPC"), nTPCSigmaN[1], 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()); + auto KaonTOF = 0; + 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()); + KaonTOF = 1; + } + KaonTOFHit.push_back(KaonTOF); } - if (track.hasTOF()) { - qaRegistry.fill(HIST("hNsigmaPtkaonTOF"), track.tofNSigmaKa(), track.pt()); - KaonTOF = 1; + + 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); + 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()); + ProtonTPCNsigma.push_back(nTPCSigmaP[2]); + } + if (track.sign() < 0) { + qaRegistry.fill(HIST("hNsigmaPtprotonTPC"), nTPCSigmaN[2], track.pt()); + ProtonTPCNsigma.push_back(nTPCSigmaN[2]); + } + if (track.hasTOF()) { + qaRegistry.fill(HIST("hNsigmaPtprotonTOF"), track.tofNSigmaPr(), track.pt()); + ProtonTOFNsigma.push_back(track.tofNSigmaPr()); + ProtonTOFHit.push_back(1); + } + if (!track.hasTOF()) { + ProtonTOFNsigma.push_back(999.0); + ProtonTOFHit.push_back(0); + } } - KaonTOFHit.push_back(KaonTOF); - } + } // track loop end + for (auto& v0 : V0s) { - 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); - 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()); - ProtonTPCNsigma.push_back(nTPCSigmaP[2]); + if (!SelectionV0(collision, v0)) { + continue; } - if (track.sign() < 0) { - qaRegistry.fill(HIST("hNsigmaPtprotonTPC"), nTPCSigmaN[2], track.pt()); - ProtonTPCNsigma.push_back(nTPCSigmaN[2]); + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; + double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; + if (ConfUseManualPIDdaughterPion) { + auto bgScalingPion = 1 / massPi; // momentum scaling? + if (BBPion.size() == 6) + nTPCSigmaPos[0] = updatePID(postrack, bgScalingPion, BBPion); + if (BBAntipion.size() == 6) + nTPCSigmaNeg[0] = updatePID(negtrack, bgScalingPion, BBAntipion); } - if (track.hasTOF()) { - qaRegistry.fill(HIST("hNsigmaPtprotonTOF"), track.tofNSigmaPr(), track.pt()); - ProtonTOFNsigma.push_back(track.tofNSigmaPr()); - ProtonTOFHit.push_back(1); + if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { + continue; } - if (!track.hasTOF()) { - ProtonTOFNsigma.push_back(999.0); - ProtonTOFHit.push_back(0); + if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { + continue; } + qaRegistry.fill(HIST("hInvMassk0"), v0.mK0Short(), v0.pt()); + ROOT::Math::PtEtaPhiMVector temp(v0.pt(), v0.eta(), v0.phi(), massK0s); + kshorts.push_back(temp); + KshortPosDaughIndex.push_back(postrack.globalIndex()); + KshortNegDaughIndex.push_back(negtrack.globalIndex()); } - } // track loop end - for (auto& v0 : V0s) { - - if (!SelectionV0(collision, v0)) { - continue; - } - auto postrack = v0.template posTrack_as(); - auto negtrack = v0.template negTrack_as(); - double nTPCSigmaPos[1]{postrack.tpcNSigmaPi()}; - double nTPCSigmaNeg[1]{negtrack.tpcNSigmaPi()}; - if (ConfUseManualPIDdaughterPion) { - auto bgScalingPion = 1 / massPi; // momentum scaling? - if (BBPion.size() == 6) - nTPCSigmaPos[0] = updatePID(postrack, bgScalingPion, BBPion); - if (BBAntipion.size() == 6) - nTPCSigmaNeg[0] = updatePID(negtrack, bgScalingPion, BBAntipion); - } - if (!isSelectedV0Daughter(postrack, 1, nTPCSigmaPos[0])) { - continue; - } - if (!isSelectedV0Daughter(negtrack, -1, nTPCSigmaNeg[0])) { - continue; - } - qaRegistry.fill(HIST("hInvMassk0"), v0.mK0Short(), v0.pt()); - ROOT::Math::PtEtaPhiMVector temp(v0.pt(), v0.eta(), v0.phi(), massK0s); - 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 (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) + 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 (PionIndex.at(i1) == KaonIndex.at(i2)) continue; - F1Vector = KKs0Vector + pions.at(i1); - if (F1Vector.M() > cMaxMassF1) - continue; - if (F1Vector.Pt() < cMinF1Pt) - continue; - - // check if the pair is unlike or wrongsign - auto pairsign = 1; - if (PionCharge.at(i1) * KaonCharge.at(i2) > 0) { - qaRegistry.fill(HIST("hInvMassf1Like"), F1Vector.M(), F1Vector.Pt()); - pairsign = -1; - } - ROOT::Math::PtEtaPhiMVector temp(F1Vector.Pt(), F1Vector.Eta(), F1Vector.Phi(), F1Vector.M()); - f1resonance.push_back(temp); - f1resonanced1.push_back(pions.at(i1)); - f1resonanced2.push_back(kaons.at(i2)); - f1resonanced3.push_back(kshorts.at(i3)); - f1signal.push_back(pairsign); - f1kaonkshortmass.push_back(KKs0Vector.M()); - F1PionIndex.push_back(PionIndex.at(i1)); - F1KaonIndex.push_back(KaonIndex.at(i2)); - F1KshortDaughterPositiveIndex.push_back(KshortPosDaughIndex.at(i3)); - F1KshortDaughterNegativeIndex.push_back(KshortNegDaughIndex.at(i3)); - PionTOFHitFinal.push_back(PionTOFHit.at(i1)); // Pion TOF Hit - KaonTOFHitFinal.push_back(KaonTOFHit.at(i2)); // Kaon TOF Hit - if (pairsign == 1) { - 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); - ProtonVectorDummy = protons.at(i4); - if (numberF1 == 1) { - //////////// Fill final proton information after pairing////////// - ROOT::Math::PtEtaPhiMVector temp(ProtonVectorDummy.Pt(), ProtonVectorDummy.Eta(), ProtonVectorDummy.Phi(), massPr); - protonsfinal.push_back(temp); // 4 vector - ProtonChargeFinal.push_back(ProtonCharge.at(i4)); // Charge - ProtonTOFHitFinal.push_back(ProtonTOFHit.at(i4)); // TOF Hit - ProtonTOFNsigmaFinal.push_back(ProtonTOFNsigma.at(i4)); // Nsigma TOF - ProtonTPCNsigmaFinal.push_back(ProtonTPCNsigma.at(i4)); // Nsigma TPC - F1ProtonIndex.push_back(ProtonIndex.at(i4)); // proton index for share track - } - - if ((ProtonIndex.at(i4) == PionIndex.at(i1)) || (ProtonIndex.at(i4) == KaonIndex.at(i2)) || (ProtonIndex.at(i4) == KshortPosDaughIndex.at(i3)) || (ProtonIndex.at(i4) == KshortNegDaughIndex.at(i3))) { - 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; + + // check if the pair is unlike or wrongsign + auto pairsign = 1; + if (PionCharge.at(i1) * KaonCharge.at(i2) > 0) { + qaRegistry.fill(HIST("hInvMassf1Like"), F1Vector.M(), F1Vector.Pt()); + pairsign = -1; + } + ROOT::Math::PtEtaPhiMVector temp(F1Vector.Pt(), F1Vector.Eta(), F1Vector.Phi(), F1Vector.M()); + f1resonance.push_back(temp); + f1resonanced1.push_back(pions.at(i1)); + f1resonanced2.push_back(kaons.at(i2)); + f1resonanced3.push_back(kshorts.at(i3)); + f1signal.push_back(pairsign); + f1kaonkshortmass.push_back(KKs0Vector.M()); + F1PionIndex.push_back(PionIndex.at(i1)); + F1KaonIndex.push_back(KaonIndex.at(i2)); + F1KshortDaughterPositiveIndex.push_back(KshortPosDaughIndex.at(i3)); + F1KshortDaughterNegativeIndex.push_back(KshortNegDaughIndex.at(i3)); + PionTOFHitFinal.push_back(PionTOFHit.at(i1)); // Pion TOF Hit + KaonTOFHitFinal.push_back(KaonTOFHit.at(i2)); // Kaon TOF Hit + if (pairsign == 1) { + 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); + ProtonVectorDummy = protons.at(i4); + if (numberF1 == 1) { + //////////// Fill final proton information after pairing////////// + ROOT::Math::PtEtaPhiMVector temp(ProtonVectorDummy.Pt(), ProtonVectorDummy.Eta(), ProtonVectorDummy.Phi(), massPr); + protonsfinal.push_back(temp); // 4 vector + ProtonChargeFinal.push_back(ProtonCharge.at(i4)); // Charge + ProtonTOFHitFinal.push_back(ProtonTOFHit.at(i4)); // TOF Hit + ProtonTOFNsigmaFinal.push_back(ProtonTOFNsigma.at(i4)); // Nsigma TOF + ProtonTPCNsigmaFinal.push_back(ProtonTPCNsigma.at(i4)); // Nsigma TPC + F1ProtonIndex.push_back(ProtonIndex.at(i4)); // proton index for share track + } + + if ((ProtonIndex.at(i4) == PionIndex.at(i1)) || (ProtonIndex.at(i4) == KaonIndex.at(i2)) || (ProtonIndex.at(i4) == KshortPosDaughIndex.at(i3)) || (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; } - - kstar = getkstar(F1Vector, *iproton); - qaRegistry.fill(HIST("hkstarDist"), kstar); - if (kstar > cMaxRelMom) - continue; - qaRegistry.fill(HIST("hInvMassf1kstar"), F1Vector.M(), F1Vector.Pt(), kstar); - keepEventF1Proton = true; } } } diff --git a/PWGLF/TableProducer/Strangeness/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/CMakeLists.txt index a4f8061f68d..04e614c1811 100644 --- a/PWGLF/TableProducer/Strangeness/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/CMakeLists.txt @@ -56,6 +56,12 @@ o2physics_add_dpl_workflow(hstrangecorrelationfilter PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(double-casc-tree-creator + SOURCES doubleCascTreeCreator.cxx + 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 @@ -101,6 +107,11 @@ o2physics_add_dpl_workflow(strangederivedbuilder PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(v0-selector + SOURCES v0selector.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(v0qaanalysis SOURCES v0qaanalysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore diff --git a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt index 660365da5ac..582047b6b60 100644 --- a/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt +++ b/PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt @@ -24,7 +24,52 @@ o2physics_add_dpl_workflow(strarawcentsconverter2v4 PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(straevselsconverter + SOURCES straevselsconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter2 + SOURCES straevselsconverter2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter3 + SOURCES straevselsconverter3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter2rawcents + SOURCES straevselsconverter2rawcents.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter2rawcents2 + SOURCES straevselsconverter2rawcents2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(straevselsconverter2rawcents3 + SOURCES straevselsconverter2rawcents3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(v0coresconverter SOURCES v0coresconverter.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0coresconverter2 + SOURCES v0coresconverter2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0mlscoresconverter + SOURCES v0mlscoresconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(stramccollisionconverter + SOURCES stramccollisionconverter.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter.cxx new file mode 100644 index 00000000000..9806e15abfc --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter.cxx @@ -0,0 +1,62 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Event selections from 000 to 001 +struct straevselsconverter { + Produces straEvSels_001; + + void process(soa::Join const& straEvSels_000_RawCents_004) + { + for (auto& values : straEvSels_000_RawCents_004) { + straEvSels_001(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(), + -1 /*dummy gap side value*/, + -999. /*dummy FT0-A value*/, + -999. /*dummy FT0-C value*/, + -999. /*dummy FV0-A value*/, + -999. /*dummy FDD-A value*/, + -999. /*dummy FDD-C value*/, + -999. /*dummy ZN-A value*/, + -999. /*dummy ZN-C 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 new file mode 100644 index 00000000000..401b04bbc83 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2.cxx @@ -0,0 +1,64 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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" + +using namespace o2; +using namespace o2::framework; + +// Converts Stra Event selections from 000 to 001 +struct straevselsconverter2 { + Produces straEvSels_002; + + void process(aod::StraEvSels_001 const& straEvSels_001) + { + for (auto& values : straEvSels_001) { + straEvSels_002(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(), + values.gapSide(), + values.totalFT0AmplitudeA(), + values.totalFT0AmplitudeC(), + values.totalFV0AmplitudeA(), + values.totalFDDAmplitudeA(), + values.totalFDDAmplitudeC(), + values.energyCommonZNA(), + values.energyCommonZNC(), + o2::its::Vertex::FlagsMask /*dummy flag value*/); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents.cxx new file mode 100644 index 00000000000..deeafa8eeca --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents.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. +#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 straevselsconverter2rawcents { + Produces straRawCents_004; + + void process(aod::StraEvSels_001 const& straEvSels_001) + { + for (auto& values : straEvSels_001) { + straRawCents_004(values.multFT0A(), + values.multFT0C(), + values.multFT0A(), + 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()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents2.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents2.cxx new file mode 100644 index 00000000000..ffed58e9072 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents2.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. +#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 straevselsconverter2rawcents2 { + Produces straRawCents_004; + + void process(aod::StraEvSels_002 const& straEvSels_002) + { + for (auto& values : straEvSels_002) { + straRawCents_004(values.multFT0A(), + values.multFT0C(), + values.multFT0A(), + 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()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents3.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents3.cxx new file mode 100644 index 00000000000..8d92146d6f7 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter2rawcents3.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. +#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 straevselsconverter2rawcents3 { + Produces straRawCents_004; + + void process(aod::StraEvSels_003 const& straEvSels_003) + { + for (auto& values : straEvSels_003) { + straRawCents_004(values.multFT0A(), + values.multFT0C(), + values.multFT0A(), + 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()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx new file mode 100644 index 00000000000..ecbd738f5fa --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/straevselsconverter3.cxx @@ -0,0 +1,65 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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" + +using namespace o2; +using namespace o2::framework; + +// Converts Stra Event selections from 000 to 001 +struct straevselsconverter3 { + Produces straEvSels_003; + + void process(aod::StraEvSels_002 const& straEvSels_002) + { + for (auto& values : straEvSels_002) { + straEvSels_003(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(), + o2::its::Vertex::FlagsMask /*dummy flag value*/); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter.cxx new file mode 100644 index 00000000000..8c7950dc4fd --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/stramccollisionconverter.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. +#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 stramccollisionconverter { + Produces straMCCollisions_001; + + void process(aod::StraMCCollisions_000 const& straMCcoll) + { + for (auto& mccollision : straMCcoll) { + straMCCollisions_001(mccollision.posX(), mccollision.posY(), mccollision.posZ(), + mccollision.impactParameter(), 0.0f); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/v0coresconverter2.cxx b/PWGLF/TableProducer/Strangeness/Converters/v0coresconverter2.cxx new file mode 100644 index 00000000000..c918f227525 --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/v0coresconverter2.cxx @@ -0,0 +1,52 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 v0coresconverter2 { + Produces v0MCCores_002; + + void process(aod::V0MCCores_001 const& v0MCCores_001) + { + for (auto& values : v0MCCores_001) { + v0MCCores_002(0, + values.pdgCode(), + values.pdgCodeMother(), + values.pdgCodePositive(), + values.pdgCodeNegative(), + values.isPhysicalPrimary(), + values.xMC(), + values.yMC(), + values.zMC(), + values.pxPosMC(), + values.pyPosMC(), + values.pzPosMC(), + values.pxNegMC(), + values.pyNegMC(), + values.pzNegMC(), + values.pxPosMC() + values.pxNegMC(), + values.pyPosMC() + values.pyNegMC(), + values.pzPosMC() + values.pzNegMC()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/Converters/v0mlscoresconverter.cxx b/PWGLF/TableProducer/Strangeness/Converters/v0mlscoresconverter.cxx new file mode 100644 index 00000000000..f7e901e780f --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/Converters/v0mlscoresconverter.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. +#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; + +// Converts V0 version 001 to 002 +struct v0mlscoresconverter { + Produces gammaMLSelections; // gamma scores + Produces lambdaMLSelections; // lambda scores + Produces antiLambdaMLSelections; // AntiLambda scores + Produces k0ShortMLSelections; // K0Short scores + + void process(aod::V0Cores const& v0cores) + { + for (auto& values : v0cores) { + gammaMLSelections(-1); + lambdaMLSelections(-1); + antiLambdaMLSelections(-1); + k0ShortMLSelections(-1); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx b/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx index fad38e38b67..fd5f225ea99 100644 --- a/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx +++ b/PWGLF/TableProducer/Strangeness/LFStrangeTreeCreator.cxx @@ -119,6 +119,8 @@ struct CandidateV0 { o2::track::TrackParCov trackv0; std::array mompos; std::array momneg; + std::array momposMC; + std::array momnegMC; float dcav0daugh = -999.f; float dcanegpv = -999.f; float dcapospv = -999.f; @@ -132,8 +134,11 @@ struct CandidateV0 { int pdgcode = -999; int pdgcodemother = -999; int pdgposdau = -999; + int pdgcodemotherdaupos = -999; int pdgnegdau = -999; + int pdgcodemotherdauneg = -999; bool isreco = 0; + int64_t pdgmatchmothersecondmother = -999; int64_t mcIndex = -999; int64_t globalIndex = -999; int64_t globalIndexPos = -999; @@ -157,8 +162,6 @@ struct LFStrangeTreeCreator { 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"}; @@ -195,6 +198,7 @@ struct LFStrangeTreeCreator { Configurable cascsetting_vetoOm{"cascsetting_vetoOm", 0.01f, "vetoOm"}; Configurable cascsetting_mXi{"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)"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -273,8 +277,6 @@ struct LFStrangeTreeCreator { // event QA histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); - 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}); // 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}); @@ -314,9 +316,9 @@ struct LFStrangeTreeCreator { auto& posPropTrack = fitter.getTrack(0); auto& negPropTrack = fitter.getTrack(1); - std::array momPos; - std::array momNeg; - std::array momV0; + std::array momPos = std::array{static_cast(-999.), static_cast(-999.), static_cast(-999.)}; + std::array momNeg = std::array{static_cast(-999.), static_cast(-999.), static_cast(-999.)}; + std::array momV0 = std::array{static_cast(-999.), static_cast(-999.), static_cast(-999.)}; posPropTrack.getPxPyPzGlo(momPos); negPropTrack.getPxPyPzGlo(momNeg); momTotXYZ(momV0, momPos, momNeg); @@ -341,13 +343,18 @@ struct LFStrangeTreeCreator { // pid selections auto nSigmaTPCPos = matter ? posTrack.tpcNSigmaPr() : posTrack.tpcNSigmaPi(); auto nSigmaTPCNeg = matter ? negTrack.tpcNSigmaPi() : negTrack.tpcNSigmaPr(); + // change for k0 + if (k0short) { + nSigmaTPCPos = posTrack.tpcNSigmaPi(); + nSigmaTPCNeg = negTrack.tpcNSigmaPi(); + } if (std::abs(nSigmaTPCPos) > v0setting_nsigmatpc || std::abs(nSigmaTPCNeg) > v0setting_nsigmatpc) { continue; } - // veto on K0s mass - if (std::abs(mK0Short - o2::constants::physics::MassK0Short) < vetoMassK0Short) { + // veto on K0s mass (only for lambda) + if (!k0short && (std::abs(mK0Short - o2::constants::physics::MassK0Short) < vetoMassK0Short)) { continue; } @@ -381,8 +388,15 @@ struct LFStrangeTreeCreator { 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) { + // change calculation of ML2P for k0 and lambda + float particlemass; + if (k0short) { + particlemass = o2::constants::physics::MassK0; + } else { + particlemass = o2::constants::physics::MassLambda; + } + float ML2P = particlemass * lengthTraveled / ptotal; + if (ML2P > v0setting_lifetime) { continue; } @@ -406,7 +420,7 @@ struct LFStrangeTreeCreator { CandidateV0 candV0; candV0.pt = matter > 0. ? ptV0 : -ptV0; candV0.eta = etaV0; - candV0.ct = ML2P_Lambda; + candV0.ct = ML2P; candV0.len = lengthTraveled; candV0.mass = mLambda; candV0.radius = radiusV0; @@ -501,45 +515,114 @@ struct LFStrangeTreeCreator { auto mcTrackNeg = mcLabNeg.template mcParticle_as(); candidateV0.pdgposdau = mcTrackPos.pdgCode(); candidateV0.pdgnegdau = mcTrackNeg.pdgCode(); + auto pdgCodeMotherDauPos = -999; + 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()) { - if (posMother.globalIndex() != negMother.globalIndex()) - continue; - candidateV0.pdgcode = posMother.pdgCode(); - if (!((mcTrackPos.pdgCode() == 2212 && mcTrackNeg.pdgCode() == -211) || (mcTrackPos.pdgCode() == 211 && mcTrackNeg.pdgCode() == -2212))) - continue; - if (std::abs(posMother.pdgCode()) != 3122) { - continue; - } - if (!posMother.isPhysicalPrimary() && !posMother.has_mothers()) - continue; - - auto pdgCodeMother = -999; - if (posMother.isPhysicalPrimary()) { - pdgCodeMother = 0; - } else if (posMother.has_mothers()) { - for (auto& mcMother : posMother.mothers_as()) { - if (std::abs(mcMother.pdgCode()) == 3322 || std::abs(mcMother.pdgCode()) == 3312 || std::abs(mcMother.pdgCode()) == 3334) { - pdgCodeMother = mcMother.pdgCode(); - break; + if (posMother.globalIndex() != negMother.globalIndex()) { + pdgCodeMotherDauPos = posMother.pdgCode(); + pdgCodeMotherDauNeg = negMother.pdgCode(); + if (negMother.pdgCode() == -211) { + if (negMother.has_mothers()) { + for (auto& negSecondMother : negMother.template mothers_as()) { + if (negSecondMother.globalIndex() == posMother.globalIndex()) { + pdgMatchMotherSecondMother = negSecondMother.pdgCode(); + } + } } } + if (posMother.pdgCode() == 211) { + if (posMother.has_mothers()) { + for (auto& posSecondMother : posMother.template mothers_as()) { + if (posSecondMother.globalIndex() == negMother.globalIndex()) { + pdgMatchMotherSecondMother = posSecondMother.pdgCode(); + } + } + } + } + } else { + candidateV0.pdgcode = posMother.pdgCode(); + pdgCodeMotherDauPos = posMother.pdgCode(); + pdgCodeMotherDauNeg = negMother.pdgCode(); + // build conditions for mother/daughter for k0short or lambda + 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); + } 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)); + } + // check conditions + if (!mother || !daughter) { + continue; + } + + if (!posMother.isPhysicalPrimary() && !posMother.has_mothers()) + continue; + + auto pdgCodeMother = -999; + if (posMother.isPhysicalPrimary()) { + pdgCodeMother = 0; + } else if (posMother.has_mothers()) { + for (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)) { + pdgCodeMother = mcMother.pdgCode(); + break; + } + } + } + auto genPt = std::hypot(posMother.px(), posMother.py()); + auto posPrimVtx = std::array{posMother.vx(), posMother.vy(), posMother.vz()}; + auto secVtx = std::array{mcTrackPos.vx(), mcTrackPos.vy(), mcTrackPos.vz()}; + auto mom = std::sqrt(std::pow(posMother.px(), 2) + std::pow(posMother.py(), 2) + std::pow(posMother.pz(), 2)); + auto len = std::sqrt(std::pow(secVtx[0] - posPrimVtx[0], 2) + std::pow(secVtx[1] - posPrimVtx[1], 2) + std::pow(secVtx[2] - posPrimVtx[2], 2)); + candidateV0.genpt = genPt; + candidateV0.genlen = len; + candidateV0.genct = len / (mom + 1e-10) * o2::constants::physics::MassLambda0; + candidateV0.pdgcodemother = pdgCodeMother; + candidateV0.geneta = posMother.eta(); + candidateV0.mcIndex = posMother.globalIndex(); } - auto genPt = std::hypot(posMother.px(), posMother.py()); - auto posPrimVtx = std::array{posMother.vx(), posMother.vy(), posMother.vz()}; - auto secVtx = std::array{mcTrackPos.vx(), mcTrackPos.vy(), mcTrackPos.vz()}; - auto mom = std::sqrt(std::pow(posMother.px(), 2) + std::pow(posMother.py(), 2) + std::pow(posMother.pz(), 2)); - auto len = std::sqrt(std::pow(secVtx[0] - posPrimVtx[0], 2) + std::pow(secVtx[1] - posPrimVtx[1], 2) + std::pow(secVtx[2] - posPrimVtx[2], 2)); - candidateV0.genpt = genPt; - candidateV0.genlen = len; - candidateV0.genct = len / (mom + 1e-10) * o2::constants::physics::MassLambda0; - candidateV0.pdgcodemother = pdgCodeMother; - candidateV0.geneta = posMother.eta(); - candidateV0.mcIndex = posMother.globalIndex(); } } } + if ((!mcTrackPos.has_mothers()) && mcTrackNeg.has_mothers()) { + pdgCodeMotherDauPos = -999; + for (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()) { + pdgCodeMotherDauPos = posMother.pdgCode(); + } + } + if ((!mcTrackNeg.has_mothers()) && (!mcTrackPos.has_mothers())) { + pdgCodeMotherDauNeg = -999; + pdgCodeMotherDauPos = -999; + } + candidateV0.pdgcodemotherdauneg = pdgCodeMotherDauNeg; + candidateV0.pdgcodemotherdaupos = pdgCodeMotherDauPos; + candidateV0.pdgmatchmothersecondmother = pdgMatchMotherSecondMother; + // momentum of daughters + 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.)}; + momPosMC[0] = mcTrackPos.px(); + momPosMC[1] = mcTrackPos.py(); + momPosMC[2] = mcTrackPos.pz(); + momNegMC[0] = mcTrackNeg.px(); + momNegMC[1] = mcTrackNeg.py(); + momNegMC[2] = mcTrackNeg.pz(); + candidateV0.momposMC = std::array{momPosMC[0], momPosMC[1], momPosMC[2]}; + candidateV0.momnegMC = std::array{momNegMC[0], momNegMC[1], momNegMC[2]}; } } } @@ -555,18 +638,45 @@ struct LFStrangeTreeCreator { auto pdgCode = mcPart.pdgCode(); std::array secVtx; - if (std::abs(pdgCode) == 3122) { + 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; + if (k0short) + pdg_test = 310; + + if (std::abs(pdgCode) == pdg_test) { if (!mcPart.isPhysicalPrimary() && !mcPart.has_mothers()) continue; - bool foundPr = false; + // check if its the right decay containing proton (2122) for lambda and charged pion (211) for k0short + int pdg_particle; + if (k0short) { + pdg_particle = 211; + } else { + pdg_particle = 2212; + } + bool foundParticle = false; for (auto& mcDaught : mcPart.daughters_as()) { - if (std::abs(mcDaught.pdgCode()) == 2212) { - foundPr = true; + if (std::abs(mcDaught.pdgCode()) == pdg_particle) { + foundParticle = true; secVtx = std::array{mcDaught.vx(), mcDaught.vy(), mcDaught.vz()}; break; } } - if (!foundPr) { + // momentum of daughters + for (auto& mcDaught : mcPart.daughters_as()) { + if (mcDaught.pdgCode() < 0) { + momNegMC[0] = mcDaught.px(); + momNegMC[1] = mcDaught.py(); + momNegMC[2] = mcDaught.pz(); + } else { + momPosMC[0] = mcDaught.px(); + momPosMC[1] = mcDaught.py(); + momPosMC[2] = mcDaught.pz(); + } + } + if (!foundParticle) { continue; } auto pdgCodeMother = -999; @@ -574,7 +684,8 @@ struct LFStrangeTreeCreator { pdgCodeMother = 0; } else if (mcPart.has_mothers()) { for (auto& mcMother : mcPart.mothers_as()) { - if (std::abs(mcMother.pdgCode()) == 3322 || std::abs(mcMother.pdgCode()) == 3312 || std::abs(mcMother.pdgCode()) == 3334) { + // 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)) { pdgCodeMother = mcMother.pdgCode(); break; } @@ -592,6 +703,8 @@ struct LFStrangeTreeCreator { candV0.geneta = mcPart.eta(); candV0.pdgcode = pdgCode; candV0.pdgcodemother = pdgCodeMother; + candV0.momposMC = std::array{momPosMC[0], momPosMC[1], momPosMC[2]}; + candV0.momnegMC = std::array{momNegMC[0], momNegMC[1], momNegMC[2]}; auto it = find_if(candidateV0s.begin(), candidateV0s.end(), [&](CandidateV0 v0) { return v0.mcIndex == mcPart.globalIndex(); }); if (it == candidateV0s.end()) { candidateV0s.emplace_back(candV0); @@ -633,13 +746,9 @@ struct LFStrangeTreeCreator { CascTable_thisCollision.bindExternalIndices(&tracks); CascTable_thisCollision.bindExternalIndices(&V0s); - auto multiplicity = collision.multFT0C(); auto centrality = collision.centFT0C(); fillRecoEvent(collision, tracks, V0Table_thisCollision, V0s, CascTable_thisCollision, centrality); - histos.fill(HIST("QA/PvMultVsCent"), centrality, collision.numContrib()); - histos.fill(HIST("QA/MultVsCent"), centrality, multiplicity); - for (auto& candidateV0 : candidateV0s) { lambdaTableML( candidateV0.pt, @@ -727,10 +836,13 @@ struct LFStrangeTreeCreator { candidateV0.geneta, candidateV0.genct, candidateV0.pdgposdau, + candidateV0.pdgcodemotherdaupos, candidateV0.pdgnegdau, + candidateV0.pdgcodemotherdauneg, candidateV0.pdgcode, candidateV0.pdgcodemother, - candidateV0.isreco); + candidateV0.isreco, + candidateV0.pdgmatchmothersecondmother); mcV0TableAP( candidateV0.eta, @@ -741,6 +853,12 @@ struct LFStrangeTreeCreator { candidateV0.momneg[0], candidateV0.momneg[1], candidateV0.momneg[2], + candidateV0.momposMC[0], + candidateV0.momposMC[1], + candidateV0.momposMC[2], + candidateV0.momnegMC[0], + candidateV0.momnegMC[1], + candidateV0.momnegMC[2], candidateV0.radius, candidateV0.dcav0pv, candidateV0.dcapospv, diff --git a/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx b/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx index c06c054fef3..ed2e5f32820 100644 --- a/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadebuilder.cxx @@ -53,6 +53,7 @@ #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" #include "PWGLF/DataModel/LFParticleIdentification.h" #include "Common/Core/TrackSelection.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -123,15 +124,20 @@ struct cascadeBuilder { Produces cascTrackXs; // if desired for replaying of position information Produces cascbb; // if enabled Produces casccovs; // if requested by someone + Produces tracasccovs; // if requested by someone Produces kfcasccovs; // if requested by someone + // produces calls for machine-learning selections + Produces xiMLSelections; // Xi scores + Produces omegaMLSelections; // Omega scores + o2::ccdb::CcdbApi ccdbApi; Service ccdb; Configurable d_UseAutodetectMode{"d_UseAutodetectMode", false, "Autodetect requested topo sels"}; // Configurables related to table creation - Configurable createCascCovMats{"createCascCovMats", -1, {"Produces V0 cov matrices. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; + Configurable createCascCovMats{"createCascCovMats", -1, {"Produces casc cov matrices. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; Configurable createCascTrackXs{"createCascTrackXs", -1, {"Produces track X at minima table. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; // Topological selection criteria @@ -194,6 +200,8 @@ struct cascadeBuilder { 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"}; + // for using cascade momentum at prim. vtx + Configurable useCascadeMomentumAtPrimVtx{"useCascadeMomentumAtPrimVtx", false, "if enabled, store cascade momentum at prim. vtx instead of decay point (= default)"}; // for topo var QA struct : ConfigurableGroup { ConfigurableAxis axisTopoVarPointingAngle{"axisConfigurations.axisTopoVarPointingAngle", {50, 0.0, 1.0}, "pointing angle"}; @@ -1118,6 +1126,14 @@ struct cascadeBuilder { cascadecandidate.v0dcapostopv = v0.dcapostopv(); cascadecandidate.v0dcanegtopv = v0.dcanegtopv(); + if (useCascadeMomentumAtPrimVtx) { + lCascadeTrack.getPxPyPzGlo(cascadecandidate.cascademom); + } else { + cascadecandidate.cascademom[0] = cascadecandidate.bachP[0] + cascadecandidate.v0mompos[0] + cascadecandidate.v0momneg[0]; + cascadecandidate.cascademom[1] = cascadecandidate.bachP[1] + cascadecandidate.v0mompos[1] + cascadecandidate.v0momneg[1]; + cascadecandidate.cascademom[2] = cascadecandidate.bachP[2] + cascadecandidate.v0mompos[2] + cascadecandidate.v0momneg[2]; + } + if (d_doTrackQA) { if (posTrack.itsNCls() < 10) statisticsRegistry.posITSclu[posTrack.itsNCls()]++; @@ -1555,9 +1571,7 @@ struct cascadeBuilder { cascadecandidate.v0mompos[0], cascadecandidate.v0mompos[1], cascadecandidate.v0mompos[2], cascadecandidate.v0momneg[0], cascadecandidate.v0momneg[1], cascadecandidate.v0momneg[2], cascadecandidate.bachP[0], cascadecandidate.bachP[1], cascadecandidate.bachP[2], - cascadecandidate.bachP[0] + cascadecandidate.v0mompos[0] + cascadecandidate.v0momneg[0], // <--- redundant but ok - cascadecandidate.bachP[1] + cascadecandidate.v0mompos[1] + cascadecandidate.v0momneg[1], // <--- redundant but ok - cascadecandidate.bachP[2] + cascadecandidate.v0mompos[2] + cascadecandidate.v0momneg[2], // <--- redundant but ok + cascadecandidate.cascademom[0], cascadecandidate.cascademom[1], cascadecandidate.cascademom[2], cascadecandidate.v0dcadau, cascadecandidate.dcacascdau, cascadecandidate.v0dcapostopv, cascadecandidate.v0dcanegtopv, cascadecandidate.bachDCAxy, cascadecandidate.cascDCAxy, cascadecandidate.cascDCAz); // <--- no corresponding stratrack information available @@ -1565,6 +1579,13 @@ struct cascadeBuilder { cascTrackXs(cascadecandidate.positiveX, cascadecandidate.negativeX, cascadecandidate.bachelorX); } cascbb(cascadecandidate.bachBaryonCosPA, cascadecandidate.bachBaryonDCAxyToPV); + if (cascadecandidate.charge < 0) { + xiMLSelections(cascadecandidate.mlXiMinusScore); + omegaMLSelections(cascadecandidate.mlOmegaMinusScore); + } else { + xiMLSelections(cascadecandidate.mlXiPlusScore); + omegaMLSelections(cascadecandidate.mlOmegaPlusScore); + } // populate cascade covariance matrices if required by any other task if (createCascCovMats) { @@ -1581,15 +1602,19 @@ struct cascadeBuilder { // store momentum covariance matrix std::array covTv0 = {0.}; std::array covTbachelor = {0.}; + float covCascade[21]; // std::array momentumCovariance; - float momentumCovariance[6]; 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++) { + covCascade[i] = 0.0f; + } for (int i = 0; i < 6; i++) { - momentumCovariance[i] = covTv0[MomInd[i]] + covTbachelor[MomInd[i]]; + covCascade[i] = positionCovariance[i]; + covCascade[MomInd[i]] = covTv0[MomInd[i]] + covTbachelor[MomInd[i]]; } - casccovs(positionCovariance, momentumCovariance); + casccovs(covCascade); } } @@ -1735,6 +1760,13 @@ struct cascadeBuilder { cascTrackXs(cascadecandidate.positiveX, cascadecandidate.negativeX, cascadecandidate.bachelorX); } cascbb(cascadecandidate.bachBaryonCosPA, cascadecandidate.bachBaryonDCAxyToPV); + if (cascadecandidate.charge < 0) { + xiMLSelections(cascadecandidate.mlXiMinusScore); + omegaMLSelections(cascadecandidate.mlOmegaMinusScore); + } else { + xiMLSelections(cascadecandidate.mlXiPlusScore); + omegaMLSelections(cascadecandidate.mlOmegaPlusScore); + } // populate cascade covariance matrices if required by any other task if (createCascCovMats) { @@ -1751,15 +1783,19 @@ struct cascadeBuilder { // store momentum covariance matrix std::array covTv0 = {0.}; std::array covTbachelor = {0.}; + float covCascade[21]; // std::array momentumCovariance; - float momentumCovariance[6]; 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++) { + covCascade[i] = 0.0f; + } for (int i = 0; i < 6; i++) { - momentumCovariance[i] = covTv0[MomInd[i]] + covTbachelor[MomInd[i]]; + covCascade[i] = positionCovariance[i]; + covCascade[MomInd[i]] = covTv0[MomInd[i]] + covTbachelor[MomInd[i]]; } - casccovs(positionCovariance, momentumCovariance); + casccovs(covCascade); } float lPt = 0.0f; @@ -1803,7 +1839,7 @@ struct cascadeBuilder { continue; // safety (should be fine but depends on future stratrack dev) // Track casting to auto cascadeTrack = trackedCascade.template track_as(); - auto cascadeTrackPar = getTrackPar(cascadeTrack); + auto cascadeTrackPar = getTrackParCov(cascadeTrack); auto const& collision = cascade.collision(); gpu::gpustd::array dcaInfo; lCascadeTrack.setPID(o2::track::PID::XiMinus); // FIXME: not OK for omegas @@ -1883,6 +1919,19 @@ struct cascadeBuilder { cascadecandidate.v0dcapostopv, cascadecandidate.v0dcanegtopv, cascadecandidate.bachDCAxy, cascadecandidate.cascDCAxy, cascadecandidate.cascDCAz, // <--- stratrack (cascDCAxy/z) trackedCascade.matchingChi2(), trackedCascade.topologyChi2(), trackedCascade.itsClsSize()); // <--- stratrack fit info + + if (createCascCovMats) { + // create tracked cascade covariance in exactly the same way as non-tracked + // ensures getter consistency and full compatibility in template functions + // (easy switching between tracked and non-tracked) + std::array traCovMat = {0.}; + cascadeTrackPar.getCovXYZPxPyPzGlo(traCovMat); + float traCovMatArray[21]; + for (int ii = 0; ii < 21; ii++) { + traCovMatArray[ii] = traCovMat[ii]; + } + tracasccovs(traCovMatArray); + } } } // En masse filling at end of process call @@ -1999,6 +2048,7 @@ struct cascadePreselector { bitTrueXiMinus, bitTrueXiPlus, bitTrueOmegaMinus, + bitPhysicalPrimary, bitTrueOmegaPlus, bitdEdxXiMinus, bitdEdxXiPlus, @@ -2098,6 +2148,7 @@ struct cascadePreselector { void checkPDG(TCascadeObject const& lCascadeCandidate, uint16_t& maskElement) { int lPDG = -1; + bool physicalPrimary = false; // Acquire all three daughter tracks, please auto lBachTrack = lCascadeCandidate.template bachelor_as(); @@ -2123,6 +2174,7 @@ struct cascadePreselector { for (auto& lBachMother : lMCBachTrack.template mothers_as()) { if (lV0Mother == lBachMother) { lPDG = lV0Mother.pdgCode(); + physicalPrimary = lV0Mother.isPhysicalPrimary(); // additionally check PDG of the mother particle if requested if (dIfMCselectV0MotherPDG != 0) { @@ -2152,6 +2204,8 @@ struct cascadePreselector { bitset(maskElement, bitTrueOmegaMinus); if (lPDG == -3334) bitset(maskElement, bitTrueOmegaPlus); + if (physicalPrimary) + bitset(maskElement, bitPhysicalPrimary); } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* /// function to check early dE/dx selection @@ -2232,6 +2286,7 @@ struct cascadePreselector { casctags(validCascade, bitcheck(selectionMask[ii], bitTrueXiMinus), bitcheck(selectionMask[ii], bitTrueXiPlus), bitcheck(selectionMask[ii], bitTrueOmegaMinus), bitcheck(selectionMask[ii], bitTrueOmegaPlus), + bitcheck(selectionMask[ii], bitPhysicalPrimary), bitcheck(selectionMask[ii], bitdEdxXiMinus), bitcheck(selectionMask[ii], bitdEdxXiPlus), bitcheck(selectionMask[ii], bitdEdxOmegaMinus), bitcheck(selectionMask[ii], bitdEdxOmegaPlus)); } @@ -2323,9 +2378,9 @@ struct cascadePreselector { /// Extends the cascdata table with expression columns struct cascadeInitializer { - Spawns cascdataext; - Spawns kfcascdataext; - Spawns tracascdataext; + Spawns cascdataext; + Spawns kfcascdataext; + Spawns tracascdataext; void init(InitContext const&) {} }; diff --git a/PWGLF/TableProducer/Strangeness/cascadefinder.cxx b/PWGLF/TableProducer/Strangeness/cascadefinder.cxx index ae4cc41802a..a56b02666a1 100644 --- a/PWGLF/TableProducer/Strangeness/cascadefinder.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadefinder.cxx @@ -432,7 +432,7 @@ struct cascadefinderQA { /// Extends the cascdata table with expression columns struct cascadeinitializer { - Spawns cascdataext; + Spawns cascdataext; void init(InitContext const&) {} }; diff --git a/PWGLF/TableProducer/Strangeness/cascadeflow.cxx b/PWGLF/TableProducer/Strangeness/cascadeflow.cxx index 434f27f284f..5ae3308785d 100644 --- a/PWGLF/TableProducer/Strangeness/cascadeflow.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadeflow.cxx @@ -12,6 +12,9 @@ /// \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) +#include +#include +#include #include "Math/Vector3D.h" #include "TRandom3.h" #include "Common/DataModel/Centrality.h" @@ -35,8 +38,11 @@ using namespace o2::framework::expressions; using std::array; using DauTracks = soa::Join; -using CollEventPlane = soa::Join::iterator; -using CollEventPlaneCentralFW = soa::Join::iterator; +using CollEventPlane = soa::Join::iterator; +using CollEventPlaneCentralFW = soa::Join::iterator; +using MCCollisionsStra = soa::Join; +using CascCandidates = soa::Join; +using CascMCCandidates = soa::Join; namespace cascadev2 { @@ -123,6 +129,7 @@ struct cascadeFlow { ConfigurableAxis axisQVsNorm{"axisQVsNorm", {200, -1.f, 1.f}, "axisQVsNorm"}; // 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"}; @@ -142,6 +149,8 @@ struct cascadeFlow { Configurable nsigmatpcPr{"nsigmatpcPr", 5, "nsigmatpcPr"}; Configurable nsigmatpcPi{"nsigmatpcPi", 5, "nsigmatpcPi"}; Configurable mintpccrrows{"mintpccrrows", 70, "mintpccrrows"}; + Configurable etaCascMCGen{"etaCascMCGen", 0.8, "etaCascMCGen"}; + Configurable yCascMCGen{"yCascMCGen", 0.5, "yCascMCGen"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable> modelPathsCCDBXi{"modelPathsCCDBXi", std::vector{"Users/c/chdemart/CascadesFlow"}, "Paths of models on CCDB"}; @@ -156,7 +165,7 @@ struct cascadeFlow { Configurable> binsPtMl{"binsPtMl", std::vector{cascade_flow_cuts_ml::vecBinsPt}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{cascade_flow_cuts_ml::vecCutDir}, "Whether to reject score values greater or smaller than the threshold"}; 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", (int8_t)cascade_flow_cuts_ml::nCutScores, "Number of classes in ML model"}; + Configurable nClassesMl{"nClassesMl", static_cast(cascade_flow_cuts_ml::nCutScores), "Number of classes in ML model"}; o2::ccdb::CcdbApi ccdbApi; @@ -165,43 +174,50 @@ struct cascadeFlow { o2::analysis::MlResponse mlResponseOmega; template - bool AcceptEvent(TCollision const& collision) + bool AcceptEvent(TCollision const& collision, bool isFillHisto) { - histos.fill(HIST("hNEvents"), 0.5); - histos.fill(HIST("hEventNchCorrelationBefCuts"), collision.multNTracksPVeta1(), collision.multNTracksGlobal()); - histos.fill(HIST("hEventPVcontributorsVsCentralityBefCuts"), collision.centFT0C(), collision.multNTracksPVeta1()); - histos.fill(HIST("hEventGlobalTracksVsCentralityBefCuts"), collision.centFT0C(), collision.multNTracksGlobal()); + if (isFillHisto) { + histos.fill(HIST("hNEvents"), 0.5); + histos.fill(HIST("hEventNchCorrelationBefCuts"), collision.multNTracksPVeta1(), collision.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentralityBefCuts"), collision.centFT0C(), collision.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentralityBefCuts"), collision.centFT0C(), collision.multNTracksGlobal()); + } // Event selection if required if (sel8 && !collision.sel8()) { return false; } - histos.fill(HIST("hNEvents"), 1.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 1.5); // Z vertex selection if (TMath::Abs(collision.posZ()) > cutzvertex) { return false; } - histos.fill(HIST("hNEvents"), 2.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 2.5); // kNoSameBunchPileup selection if (isNoSameBunchPileupCut && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return false; } - histos.fill(HIST("hNEvents"), 3.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 3.5); // kIsGoodZvtxFT0vsPV selection if (isGoodZvtxFT0vsPVCut && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { return false; } - histos.fill(HIST("hNEvents"), 4.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 4.5); // occupancy cut int occupancy = collision.trackOccupancyInTimeRange(); if (occupancy < MinOccupancy || occupancy > MaxOccupancy) { return false; } - histos.fill(HIST("hNEvents"), 5.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 5.5); if (isCollInStandardTimeRange && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { return false; @@ -210,11 +226,14 @@ struct cascadeFlow { if (isCollInNarrowTimeRange && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { return false; } - histos.fill(HIST("hNEvents"), 6.5); + if (isFillHisto) + histos.fill(HIST("hNEvents"), 6.5); - histos.fill(HIST("hEventNchCorrelation"), collision.multNTracksPVeta1(), collision.multNTracksGlobal()); - histos.fill(HIST("hEventPVcontributorsVsCentrality"), collision.centFT0C(), collision.multNTracksPVeta1()); - histos.fill(HIST("hEventGlobalTracksVsCentrality"), collision.centFT0C(), collision.multNTracksGlobal()); + if (isFillHisto) { + histos.fill(HIST("hEventNchCorrelation"), collision.multNTracksPVeta1(), collision.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentrality"), collision.centFT0C(), collision.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentrality"), collision.centFT0C(), collision.multNTracksGlobal()); + } return true; } @@ -252,8 +271,9 @@ struct cascadeFlow { return phi; } - HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - HistogramRegistry resolution{"resolution", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry histosMCGen{"histosMCGen", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + HistogramRegistry resolution{"resolution", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; // Tables to produce Produces trainingSample; @@ -296,8 +316,27 @@ struct cascadeFlow { } template - void fillAnalysedTable(collision_t coll, cascade_t casc, float v2CSP, float v2CEP, float PsiT0C, float BDTresponseXi, float BDTresponseOmega) + void fillAnalysedTable(collision_t coll, cascade_t casc, float v2CSP, float v2CEP, 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; + 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 < 2; ++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(); + } + analysisSample(coll.centFT0C(), casc.sign(), casc.pt(), @@ -309,7 +348,11 @@ struct cascadeFlow { v2CEP, PsiT0C, BDTresponseXi, - BDTresponseOmega); + BDTresponseOmega, + cosThetaStarLambda[0], + cosThetaStarLambda[1], + cosThetaStarProton, + pdgCode); } void init(InitContext const&) @@ -323,6 +366,8 @@ struct cascadeFlow { const AxisSpec v2Axis{200, -1., 1., "#it{v}_{2}"}; const AxisSpec CentAxis{18, 0., 90., "FT0C centrality percentile"}; TString hNEventsLabels[8] = {"All", "sel8", "z vrtx", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "trackOccupancyInTimeRange", "kNoCollInTimeRange", "kIsGoodEventEP"}; + TString hNEventsLabelsMC[6] = {"All", "z vtx", ">=1RecoColl", "1Reco", "2Reco", "EvSelected"}; + TString hNCascLabelsMC[8] = {"All Xi", "all Omega", "Xi: has MC coll", "Om: has MC coll", "Xi: isPrimary", "Om: is Primary", "Xi: |eta|<0.8", "Om: |eta| < 0.8"}; resolution.add("QVectorsT0CTPCA", "QVectorsT0CTPCA", HistType::kTH2F, {axisQVs, CentAxis}); resolution.add("QVectorsT0CTPCC", "QVectorsT0CTPCC", HistType::kTH2F, {axisQVs, CentAxis}); @@ -348,14 +393,34 @@ struct cascadeFlow { histos.add("hEventNchCorrelationAfterEP", "hEventNchCorrelationAfterEP", kTH2F, {{5000, 0, 5000}, {2500, 0, 2500}}); histos.add("hEventPVcontributorsVsCentralityAfterEP", "hEventPVcontributorsVsCentralityAfterEP", kTH2F, {{100, 0, 100}, {5000, 0, 5000}}); histos.add("hEventGlobalTracksVsCentralityAfterEP", "hEventGlobalTracksVsCentralityAfterEP", kTH2F, {{100, 0, 100}, {2500, 0, 2500}}); + histos.add("hMultNTracksITSTPCVsCentrality", "hMultNTracksITSTPCVsCentrality", kTH2F, {{100, 0, 100}, {1000, 0, 5000}}); histos.add("hCandidate", "hCandidate", HistType::kTH1F, {{22, -0.5, 21.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("hXiPtvsCent", "hXiPtvsCent", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}}); + histos.add("hOmegaPtvsCent", "hOmegaPtvsCent", HistType::kTH2F, {{100, 0, 100}, {200, 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("hv2CEPvsFT0C", "hv2CEPvsFT0C", HistType::kTH2F, {CentAxis, {100, -1, 1}}); histos.add("hv2CEPvsv2CSP", "hv2CEPvsV2CSP", HistType::kTH2F, {{100, -1, 1}, {100, -1, 1}}); + + histosMCGen.add("h2DGenXiEta08", "h2DGenXiEta08", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}}); + histosMCGen.add("h2DGenOmegaEta08", "h2DGenOmegaEta08", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}}); + histosMCGen.add("h2DGenXiY05", "h2DGenXiY05", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}}); + histosMCGen.add("h2DGenOmegaY05", "h2DGenOmegaY05", HistType::kTH2F, {{100, 0, 100}, {200, 0, 20}}); + histosMCGen.add("hGenXiY", "hGenXiY", HistType::kTH1F, {{100, -1, 1}}); + histosMCGen.add("hGenOmegaY", "hGenOmegaY", HistType::kTH1F, {{100, -1, 1}}); + histosMCGen.add("hZvertexGen", "hZvertexGen", HistType::kTH1F, {{100, -20, 20}}); + histosMCGen.add("hNEventsMC", "hNEventsMC", {HistType::kTH1F, {{6, 0.f, 6.f}}}); + for (Int_t n = 1; n <= histosMCGen.get(HIST("hNEventsMC"))->GetNbinsX(); n++) { + histosMCGen.get(HIST("hNEventsMC"))->GetXaxis()->SetBinLabel(n, hNEventsLabelsMC[n - 1]); + } + histosMCGen.add("hNCascGen", "hNCascGen", {HistType::kTH1F, {{8, 0.f, 8.f}}}); + for (Int_t n = 1; n <= histosMCGen.get(HIST("hNCascGen"))->GetNbinsX(); n++) { + 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}); @@ -383,12 +448,12 @@ struct cascadeFlow { } } - void processTrainingBackground(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) + void processTrainingBackground(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) { int counter = 0; - if (!AcceptEvent(coll)) { + if (!AcceptEvent(coll, 1)) { return; } @@ -436,19 +501,23 @@ struct cascadeFlow { } } - void processTrainingSignal(soa::Join::iterator const& coll, soa::Join const& Cascades, DauTracks const&) + void processTrainingSignal(soa::Join::iterator const& coll, CascMCCandidates const& Cascades, DauTracks const&, soa::Join const&) { - if (!AcceptEvent(coll)) { + if (!AcceptEvent(coll, 1)) { return; } histos.fill(HIST("hEventCentrality"), coll.centFT0C()); histos.fill(HIST("hEventVertexZ"), coll.posZ()); for (auto& casc : Cascades) { - int pdgCode{casc.pdgCode()}; - if (!(std::abs(pdgCode) == 3312 && std::abs(casc.pdgCodeV0()) == 3122 && std::abs(casc.pdgCodeBachelor()) == 211) // Xi - && !(std::abs(pdgCode) == 3334 && std::abs(casc.pdgCodeV0()) == 3122 && std::abs(casc.pdgCodeBachelor()) == 321)) // Omega + 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 continue; auto negExtra = casc.negTrackExtra_as(); @@ -464,10 +533,10 @@ struct cascadeFlow { } } - void processAnalyseData(CollEventPlane const& coll, soa::Join const& Cascades, DauTracks const&) + void processAnalyseData(CollEventPlane const& coll, CascCandidates const& Cascades, DauTracks const&) { - if (!AcceptEvent(coll)) { + if (!AcceptEvent(coll, 1)) { return; } @@ -582,14 +651,14 @@ struct cascadeFlow { BDTresponse[1] = bdtScore[1][1]; } if (isSelectedCasc[0] || isSelectedCasc[1]) - fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1]); + fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], 0); } } - void processAnalyseDataEPCentralFW(CollEventPlaneCentralFW const& coll, soa::Join const& Cascades, DauTracks const&) + void processAnalyseDataEPCentralFW(CollEventPlaneCentralFW const& coll, CascCandidates const& Cascades, DauTracks const&) { - if (!AcceptEvent(coll)) { + if (!AcceptEvent(coll, 1)) { return; } @@ -710,7 +779,216 @@ struct cascadeFlow { BDTresponse[1] = bdtScore[1][1]; } if (isSelectedCasc[0] || isSelectedCasc[1]) - fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1]); + fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], 0); + } + } + + void processAnalyseMC(soa::Join::iterator const& coll, CascMCCandidates const& Cascades, DauTracks const&, soa::Join const&) + { + + if (!AcceptEvent(coll, 1)) { + return; + } + + histos.fill(HIST("hNEvents"), 7.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()); + histos.fill(HIST("hMultNTracksITSTPCVsCentrality"), coll.centFT0C(), coll.multNTracksITSTPC()); + + std::vector bdtScore[2]; + for (auto& 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 + { + pdgCode = 0; + } + + // true reco cascades before applying any selection + if (std::abs(pdgCode) == 3312 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 211) { + histos.fill(HIST("hXiPtvsCent"), coll.centFT0C(), casc.pt()); + } else if (std::abs(pdgCode) == 3334 && std::abs(cascMC.pdgCodeV0()) == 3122 && std::abs(cascMC.pdgCodeBachelor()) == 321) { + histos.fill(HIST("hOmegaPtvsCent"), coll.centFT0C(), casc.pt()); + } + + /// 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; + IsCascAccepted(casc, negExtra, posExtra, bachExtra, counter); + histos.fill(HIST("hCascade"), counter); + + // ML selections + bool isSelectedCasc[2]{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[2]{casc.mXi(), casc.mOmega()}; + + if (casc.pt() < MinPt || casc.pt() > 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 < 2; ++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; + } + + histos.fill(HIST("hCascadePhi"), casc.phi()); + + float BDTresponse[2]{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 + + if (isApplyML) { + BDTresponse[0] = bdtScore[0][1]; + BDTresponse[1] = bdtScore[1][1]; + } + if (isStoreTrueCascOnly) { + if (pdgCode == 0) + continue; + } + if (isSelectedCasc[0] || isSelectedCasc[1]) + fillAnalysedTable(coll, casc, v2CSP, v2CEP, PsiT0C, BDTresponse[0], BDTresponse[1], pdgCode); + } + } + + void processMCGen(MCCollisionsStra::iterator const& mcCollision, const soa::SmallGroups>& collisions, const soa::SmallGroups>& cascMC) + { + + histosMCGen.fill(HIST("hZvertexGen"), mcCollision.posZ()); + histosMCGen.fill(HIST("hNEventsMC"), 0.5); + // Generated with accepted z vertex + if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + return; + } + histosMCGen.fill(HIST("hNEventsMC"), 1.5); + // Check if there is at least one of the reconstructed collisions associated to this MC collision + if (collisions.size() < 1) + return; + histosMCGen.fill(HIST("hNEventsMC"), 2.5); + if (collisions.size() == 1) + histosMCGen.fill(HIST("hNEventsMC"), 3.5); + else if (collisions.size() == 2) + histosMCGen.fill(HIST("hNEventsMC"), 4.5); + + int biggestNContribs = -1; + int bestCollisionIndex = -1; + float centrality = 100.5f; + int nCollisions = 0; + for (auto const& coll : collisions) { + if (!AcceptEvent(coll, 0)) { + continue; + } + if (biggestNContribs < coll.multPVTotalContributors()) { + biggestNContribs = coll.multPVTotalContributors(); + bestCollisionIndex = coll.globalIndex(); + centrality = coll.centFT0C(); + } + nCollisions++; + } + if (nCollisions < 1) { + return; + } + + histosMCGen.fill(HIST("hNEventsMC"), 5.5); + + for (auto const& cascmc : cascMC) { + if (TMath::Abs(cascmc.pdgCode()) == 3312) + histosMCGen.fill(HIST("hNCascGen"), 0.5); + else if (TMath::Abs(cascmc.pdgCode()) == 3334) + histosMCGen.fill(HIST("hNCascGen"), 1.5); + if (!cascmc.has_straMCCollision()) + continue; + if (TMath::Abs(cascmc.pdgCode()) == 3312) + histosMCGen.fill(HIST("hNCascGen"), 2.5); + else if (TMath::Abs(cascmc.pdgCode()) == 3334) + histosMCGen.fill(HIST("hNCascGen"), 3.5); + if (!cascmc.isPhysicalPrimary()) + continue; + if (TMath::Abs(cascmc.pdgCode()) == 3312) + histosMCGen.fill(HIST("hNCascGen"), 4.5); + else if (TMath::Abs(cascmc.pdgCode()) == 3334) + histosMCGen.fill(HIST("hNCascGen"), 5.5); + + float ptmc = RecoDecay::sqrtSumOfSquares(cascmc.pxMC(), cascmc.pyMC()); + + float theta = std::atan(ptmc / cascmc.pzMC()); //-pi/2 < theta < pi/2 + + float theta1 = 0; + + // if pz is positive (i.e. positive rapidity): 0 < theta < pi/2 + if (theta > 0) + 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 + + float cascMCeta = -log(std::tan(theta1 / 2)); + float cascMCy = 0; + + if (TMath::Abs(cascmc.pdgCode()) == 3312) { + cascMCy = RecoDecay::y(std::array{cascmc.pxMC(), cascmc.pyMC(), cascmc.pzMC()}, constants::physics::MassXiMinus); + if (TMath::Abs(cascMCeta) < etaCascMCGen) { + histosMCGen.fill(HIST("h2DGenXiEta08"), centrality, ptmc); + histosMCGen.fill(HIST("hNCascGen"), 6.5); + } + if (TMath::Abs(cascMCy) < yCascMCGen) + histosMCGen.fill(HIST("h2DGenXiY05"), centrality, ptmc); + histosMCGen.fill(HIST("hGenXiY"), cascMCy); + } else if (TMath::Abs(cascmc.pdgCode() == 3334)) { + cascMCy = RecoDecay::y(std::array{cascmc.pxMC(), cascmc.pyMC(), cascmc.pzMC()}, constants::physics::MassOmegaMinus); + if (TMath::Abs(cascMCeta) < etaCascMCGen) { + histosMCGen.fill(HIST("h2DGenOmegaEta08"), centrality, ptmc); + histosMCGen.fill(HIST("hNCascGen"), 7.5); + } + if (TMath::Abs(cascMCy) < yCascMCGen) + histosMCGen.fill(HIST("h2DGenOmegaY05"), centrality, ptmc); + histosMCGen.fill(HIST("hGenOmegaY"), cascMCy); + } } } @@ -718,6 +996,8 @@ struct cascadeFlow { 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, processAnalyseDataEPCentralFW, "Process to apply ML model to the data - 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); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/TableProducer/Strangeness/cascademcbuilder.cxx b/PWGLF/TableProducer/Strangeness/cascademcbuilder.cxx index 4084afdcae4..4e8e62d9db7 100644 --- a/PWGLF/TableProducer/Strangeness/cascademcbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/cascademcbuilder.cxx @@ -61,6 +61,8 @@ struct cascademcbuilder { Configurable addGeneratedOmegaMinus{"addGeneratedOmegaMinus", false, "add CascMCCore entry for generated, not-recoed OmegaMinus"}; Configurable addGeneratedOmegaPlus{"addGeneratedOmegaPlus", false, "add CascMCCore entry for generated, not-recoed OmegaPlus"}; + Configurable treatPiToMuDecays{"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 rapidityWindow{"rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* @@ -76,6 +78,9 @@ struct cascademcbuilder { int pdgCodeNegative; int pdgCodeBachelor; bool isPhysicalPrimary; + int processPositive = -1; + int processNegative = -1; + int processBachelor = -1; std::array xyz; std::array lxyz; std::array posP; @@ -89,7 +94,35 @@ struct cascademcbuilder { mcCascinfo thisInfo; //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - void init(InitContext const&) {} + // kink handling + template + int getOriginatingParticle(mcpart const& part, int& indexForPositionOfDecay) + { + 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 generateCascadeMCinfo(TCascadeTable cascTable, TMCParticleTable mcParticles) @@ -142,60 +175,63 @@ struct cascademcbuilder { thisInfo.bachP[0] = lMCBachTrack.px(); thisInfo.bachP[1] = lMCBachTrack.py(); thisInfo.bachP[2] = lMCBachTrack.pz(); + thisInfo.processPositive = lMCPosTrack.getProcess(); + thisInfo.processNegative = lMCNegTrack.getProcess(); + thisInfo.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); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForLambdaDecayPositionIdx); + bachOriginating = getOriginatingParticle(lMCBachTrack, particleForCascadeDecayPositionIdx); + + if (negOriginating > -1 && negOriginating == posOriginating) { + auto originatingV0 = mcParticles.rawIteratorAt(negOriginating); + auto particleForLambdaDecayPosition = mcParticles.rawIteratorAt(particleForLambdaDecayPositionIdx); + + thisInfo.label = originatingV0.globalIndex(); + thisInfo.lxyz[0] = particleForLambdaDecayPosition.vx(); + thisInfo.lxyz[1] = particleForLambdaDecayPosition.vy(); + thisInfo.lxyz[2] = particleForLambdaDecayPosition.vz(); + + if (originatingV0.has_mothers()) { + for (auto& lV0Mother : originatingV0.template mothers_as()) { + if (lV0Mother.globalIndex() == bachOriginating) { // found mother particle + thisInfo.label = lV0Mother.globalIndex(); + + if (lV0Mother.has_mcCollision()) { + thisInfo.mcCollision = lV0Mother.mcCollisionId(); // save this reference, please + } - // Step 1: check if the mother is the same, go up a level - if (lMCNegTrack.has_mothers() && lMCPosTrack.has_mothers()) { - for (auto& lNegMother : lMCNegTrack.template mothers_as()) { - for (auto& lPosMother : lMCPosTrack.template mothers_as()) { - if (lNegMother == lPosMother) { - // acquire information - thisInfo.lxyz[0] = lMCPosTrack.vx(); - thisInfo.lxyz[1] = lMCPosTrack.vy(); - thisInfo.lxyz[2] = lMCPosTrack.vz(); - thisInfo.pdgCodeV0 = lNegMother.pdgCode(); - - // if we got to this level, it means the mother particle exists and is the same - // now we have to go one level up and compare to the bachelor mother too - if (lNegMother.has_mothers() && lMCBachTrack.has_mothers()) { - for (auto& lV0Mother : lNegMother.template mothers_as()) { - for (auto& lBachMother : lMCBachTrack.template mothers_as()) { - if (lV0Mother == lBachMother) { - thisInfo.label = lV0Mother.globalIndex(); - - if (lV0Mother.has_mcCollision()) { - thisInfo.mcCollision = lV0Mother.mcCollisionId(); // save this reference, please - } - - thisInfo.pdgCode = lV0Mother.pdgCode(); - thisInfo.isPhysicalPrimary = lV0Mother.isPhysicalPrimary(); - thisInfo.xyz[0] = lMCBachTrack.vx(); - thisInfo.xyz[1] = lMCBachTrack.vy(); - thisInfo.xyz[2] = lMCBachTrack.vz(); - thisInfo.momentum[0] = lV0Mother.px(); - thisInfo.momentum[1] = lV0Mother.py(); - thisInfo.momentum[2] = lV0Mother.pz(); - if (lV0Mother.has_mothers()) { - for (auto& lV0GrandMother : lV0Mother.template mothers_as()) { - thisInfo.pdgCodeMother = lV0GrandMother.pdgCode(); - thisInfo.motherLabel = lV0GrandMother.globalIndex(); - } - } - } - } - } // end conditional V0-bach pair - } // end has mothers - } // end neg = pos mother conditional - } - } // end loop neg/pos mothers - } // end conditional of mothers existing + thisInfo.pdgCode = lV0Mother.pdgCode(); + thisInfo.isPhysicalPrimary = lV0Mother.isPhysicalPrimary(); + thisInfo.xyz[0] = originatingV0.vx(); + thisInfo.xyz[1] = originatingV0.vy(); + thisInfo.xyz[2] = originatingV0.vz(); + thisInfo.momentum[0] = lV0Mother.px(); + thisInfo.momentum[1] = lV0Mother.py(); + thisInfo.momentum[2] = lV0Mother.pz(); + if (lV0Mother.has_mothers()) { + for (auto& lV0GrandMother : lV0Mother.template mothers_as()) { + thisInfo.pdgCodeMother = lV0GrandMother.pdgCode(); + thisInfo.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 // Construct label table (note: this will be joinable with CascDatas) casclabels( thisInfo.label, thisInfo.motherLabel); // Mark mcParticle as recoed (no searching necessary afterwards) - if (thisInfo.motherLabel > -1) { - mcParticleIsReco[thisInfo.motherLabel] = true; + if (thisInfo.label > -1) { + mcParticleIsReco[thisInfo.label] = true; } if (populateCascMCCoresSymmetric) { @@ -216,10 +252,7 @@ struct cascademcbuilder { // 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 ( - thisInfo.mcParticlePositive == mcCascinfos[ii].mcParticlePositive && mcCascinfos[ii].mcParticlePositive > 0 && - thisInfo.mcParticleNegative == mcCascinfos[ii].mcParticleNegative && mcCascinfos[ii].mcParticleNegative > 0 && - thisInfo.mcParticleBachelor == mcCascinfos[ii].mcParticleBachelor && mcCascinfos[ii].mcParticleBachelor > 0) { + if (thisInfo.label == mcCascinfos[ii].label && mcCascinfos[ii].label > -1) { thisCascMCCoreIndex = ii; break; // this exists already in list } @@ -272,6 +305,54 @@ struct cascademcbuilder { thisInfo.momentum[0] = mcParticle.px(); thisInfo.momentum[1] = mcParticle.py(); thisInfo.momentum[2] = mcParticle.pz(); + thisInfo.label = mcParticle.globalIndex(); + + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.template daughters_as(); + for (auto& dau : daughters) { + if (dau.getProcess() != 4) // check whether the daughter comes from a decay + continue; + + if (TMath::Abs(dau.pdgCode()) == 211 || TMath::Abs(dau.pdgCode()) == 321) { + thisInfo.pdgCodeBachelor = dau.pdgCode(); + thisInfo.bachP[0] = dau.px(); + thisInfo.bachP[1] = dau.py(); + thisInfo.bachP[2] = dau.pz(); + thisInfo.xyz[0] = dau.vx(); + thisInfo.xyz[1] = dau.vy(); + thisInfo.xyz[2] = dau.vz(); + thisInfo.mcParticleBachelor = dau.globalIndex(); + } + if (TMath::Abs(dau.pdgCode()) == 2212) { + thisInfo.pdgCodeV0 = dau.pdgCode(); + + for (auto& v0Dau : dau.template daughters_as()) { + if (v0Dau.getProcess() != 4) + continue; + + if (v0Dau.pdgCode() > 0) { + thisInfo.pdgCodePositive = v0Dau.pdgCode(); + thisInfo.processPositive = v0Dau.getProcess(); + thisInfo.posP[0] = v0Dau.px(); + thisInfo.posP[1] = v0Dau.py(); + thisInfo.posP[2] = v0Dau.pz(); + thisInfo.lxyz[0] = v0Dau.vx(); + thisInfo.lxyz[1] = v0Dau.vy(); + thisInfo.lxyz[2] = v0Dau.vz(); + thisInfo.mcParticlePositive = v0Dau.globalIndex(); + } + if (v0Dau.pdgCode() < 0) { + thisInfo.pdgCodeNegative = v0Dau.pdgCode(); + thisInfo.processNegative = v0Dau.getProcess(); + thisInfo.negP[0] = v0Dau.px(); + thisInfo.negP[1] = v0Dau.py(); + thisInfo.negP[2] = v0Dau.pz(); + thisInfo.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(thisInfo); diff --git a/PWGLF/TableProducer/Strangeness/cascadepid.cxx b/PWGLF/TableProducer/Strangeness/cascadepid.cxx index c9faa24a4ed..3c7c82dacdd 100644 --- a/PWGLF/TableProducer/Strangeness/cascadepid.cxx +++ b/PWGLF/TableProducer/Strangeness/cascadepid.cxx @@ -101,6 +101,10 @@ struct cascadepid { Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; Configurable nSigmaPath{"nSigmaPath", "Users/d/ddobrigk/stratof", "Path of information for n-sigma calculation"}; + // manual + Configurable useCustomRunNumber{"useCustomRunNumber", false, "Use custom timestamp"}; + Configurable manualRunNumber{"manualRunNumber", 544122, "manual run number if no collisions saved"}; + ConfigurableAxis axisEta{"axisEta", {20, -1.0f, +1.0f}, "#eta"}; ConfigurableAxis axisDeltaTime{"axisDeltaTime", {2000, -1000.0f, +1000.0f}, "delta-time (ps)"}; ConfigurableAxis axisNSigma{"axisNSigma", {200, -10.0f, +10.0f}, "N(#sigma)"}; @@ -296,10 +300,9 @@ struct cascadepid { } } - template - void initCCDB(TInformationClass const& infoObject) + void initCCDB(int runNumber) { - if (mRunNumber == infoObject.runNumber()) { + if (mRunNumber == runNumber) { return; } @@ -311,32 +314,31 @@ struct cascadepid { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); - mRunNumber = infoObject.runNumber(); + mRunNumber = runNumber; return; } - auto run3grp_timestamp = infoObject.timestamp(); - o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + o2::parameters::GRPObject* grpo = ccdb->getForRun(grpPath, runNumber); 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"; + LOG(info) << "Retrieved GRP for run " << runNumber << " with magnetic field of " << d_bz << " kZG"; } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + grpmag = ccdb->getForRun(grpmagPath, runNumber); if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for run " << runNumber; } 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 run " << runNumber << " with magnetic field of " << d_bz << " kZG"; } // if TOF Nsigma desired if (doNSigmas) { - nSigmaCalibObjects = ccdb->getForTimeStamp(nSigmaPath, infoObject.timestamp()); + nSigmaCalibObjects = ccdb->getForRun(nSigmaPath, runNumber); if (nSigmaCalibObjects) { LOGF(info, "loaded TList with this many objects: %i", nSigmaCalibObjects->GetEntries()); @@ -372,7 +374,7 @@ struct cascadepid { LOG(info) << "Problems finding omega sigma histograms!"; } } - mRunNumber = infoObject.runNumber(); + mRunNumber = runNumber; } float velocity(float lMomentum, float lMass) @@ -568,10 +570,15 @@ struct cascadepid { void processStandardData(aod::Collisions const& collisions, CascOriginalDatas const& Cascades, TracksWithAllExtras const&, aod::BCsWithTimestamps const& /*bcs*/) { - auto collision = collisions.begin(); - auto bc = collision.bc_as(); - // Fire up CCDB - based on standard collisions - initCCDB(bc); + // Fire up CCDB with first collision in record. If no collisions, bypass + if (useCustomRunNumber || collisions.size() < 1) { + initCCDB(manualRunNumber); + } else { + auto collision = collisions.begin(); + auto bc = collision.bc_as(); + initCCDB(bc.runNumber()); + } + for (const auto& collision : collisions) { // Do analysis with collision-grouped V0s, retain full collision information const uint64_t collIdx = collision.globalIndex(); @@ -590,9 +597,15 @@ struct cascadepid { void processDerivedData(soa::Join const& collisions, CascDerivedDatas const& Cascades, dauTracks const&) { + // Fire up CCDB with first collision in record. If no collisions, bypass + if (useCustomRunNumber || collisions.size() < 1) { + initCCDB(manualRunNumber); + } else { + auto collision = collisions.begin(); + initCCDB(collision.runNumber()); + } + for (const auto& collision : collisions) { - // Fire up CCDB - based on StraCollisions for derived analysis - initCCDB(collision); // Do analysis with collision-grouped V0s, retain full collision information const uint64_t collIdx = collision.globalIndex(); auto CascTable_thisCollision = Cascades.sliceBy(perCollisionDerived, collIdx); diff --git a/PWGLF/TableProducer/Strangeness/cascadespawner.cxx b/PWGLF/TableProducer/Strangeness/cascadespawner.cxx index 4e2d0c68a44..dc004b91e78 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 44b9f784447..0e14c0f491f 100644 --- a/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx +++ b/PWGLF/TableProducer/Strangeness/cascqaanalysis.cxx @@ -16,6 +16,9 @@ /// \modified by Roman Nepeivoda (roman.nepeivoda@cern.ch) /// \since June 1, 2023 +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -28,6 +31,7 @@ #include "TRandom2.h" #include "Framework/O2DatabasePDGPlugin.h" #include "PWGLF/Utils/inelGt.h" +#include "PWGLF/DataModel/mcCentrality.h" using namespace o2; using namespace o2::framework; @@ -48,13 +52,15 @@ struct cascqaanalysis { // Event selection criteria Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable isVertexITSTPCCut{"isVertexITSTPCCut", 0, "Select collisions with at least one ITS-TPC track"}; - Configurable isNoSameBunchPileupCut{"isNoSameBunchPileupCut", 0, "Same found-by-T0 bunch crossing rejection"}; - Configurable isGoodZvtxFT0vsPVCut{"isGoodZvtxFT0vsPVCut", 0, "z of PV by tracks and z of PV from FT0 A-C time difference cut"}; + Configurable isVertexITSTPC{"isVertexITSTPC", 0, "Select collisions with at least one ITS-TPC track"}; + Configurable isNoSameBunchPileup{"isNoSameBunchPileup", 0, "Same found-by-T0 bunch crossing rejection"}; + Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", 0, "z of PV by tracks and z of PV from FT0 A-C time difference cut"}; + Configurable isVertexTOFmatched{"isVertexTOFmatched", 0, "Is Vertex TOF matched"}; Configurable isTriggerTVX{"isTriggerTVX", 1, "TVX trigger"}; Configurable isNoTimeFrameBorder{"isNoTimeFrameBorder", 1, "TF border cut"}; Configurable isNoITSROFrameBorder{"isNoITSROFrameBorder", 1, "ITS ROF border cut"}; + Configurable isNoCollInTimeRangeNarrow{"isNoCollInTimeRangeNarrow", 1, "No collisions in +-2us window"}; // Cascade selection criteria Configurable scalefactor{"scalefactor", 1.0, "Scaling factor"}; @@ -75,6 +81,9 @@ struct cascqaanalysis { // QA histograms for the multiplicity estimation Configurable multQA{"multQA", 0, "0 - not to do QA, 1 - do the QA"}; + // QA histograms for cascade rec. + Configurable candidateQA{"candidateQA", 1, "0 - not to do QA, 1 - do the QA"}; + // Necessary for particle charges Service pdgDB; @@ -106,23 +115,26 @@ struct cascqaanalysis { 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[5] = {"All candidates", "v0data exists", "passed topo cuts", "has associated MC particle", "associated with Xi(Omega)"}; + 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[11] = {"All", "kIsTriggerTVX", "kNoTimeFrameBorder", "kNoITSROFrameBorder", "kIsVertexITSTPC", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "z vrtx", "INEL", "INEL>0", "INEL>1"}; + 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::kTH1F, {{11, 0.f, 11.f}}}); for (Int_t 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("hCandidateCounter", "hCandidateCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}); + registry.add("hCandidateCounter", "hCandidateCounter", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}); for (Int_t 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 @@ -136,19 +148,24 @@ struct cascqaanalysis { 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}}); - } else { - registry.add("hFT0MpvContr", "hFT0MpvContr", {HistType::kTH3F, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hFV0ApvContr", "hFV0ApvContr", {HistType::kTH3F, {centFV0AAxis, multNTracksAxis, eventTypeAxis}}); + registry.add("hCentFT0M_genMC", "hCentFT0M_genMC", {HistType::kTH2F, {centFT0MAxis, eventTypeAxis}}); + } + + registry.add("hCentFT0M_rec", "hCentFT0M_rec", {HistType::kTH2F, {centFT0MAxis, eventTypeAxis}}); + + if (candidateQA) { + registry.add("hNcandidates", "hNcandidates", {HistType::kTH3F, {nCandidates, centFT0MAxis, {2, -0.5f, 1.5f}}}); } if (multQA) { if (isMC) { // Rec. lvl registry.add("hNchFT0Mglobal", "hNchFT0Mglobal", {HistType::kTH3F, {nChargedFT0MGenAxis, multNTracksAxis, eventTypeAxis}}); - } else { - registry.add("hFT0Mglobal", "hFT0Mglobal", {HistType::kTH3F, {centFT0MAxis, multNTracksAxis, eventTypeAxis}}); - registry.add("hFV0AFT0M", "hFV0AFT0M", {HistType::kTH3F, {centFV0AAxis, centFT0MAxis, 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}}); } @@ -161,7 +178,7 @@ struct cascqaanalysis { aod::cascdata::dcaV0daughters < dcav0dau && aod::cascdata::dcacascdaughters < dcacascdau); - Partition pvContribTracksIUEta1 = (nabs(aod::track::eta) < 1.0f) && ((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 & static_cast(o2::aod::track::PVContributor)) == static_cast(o2::aod::track::PVContributor)); Partition globalTracksIUEta05 = (nabs(aod::track::eta) < 0.5f) && (requireGlobalTrackInFilter()); template @@ -239,14 +256,14 @@ struct cascqaanalysis { { // 0 - INEL, 1 - INEL>0, 2 - INEL>1 int evFlag = 0; - registry.fill(HIST("hNEvents"), 8.5); // INEL + registry.fill(HIST("hNEvents"), 10.5); // INEL if (collision.isInelGt0()) { evFlag += 1; - registry.fill(HIST("hNEvents"), 9.5); // INEL>0 + registry.fill(HIST("hNEvents"), 11.5); // INEL>0 } if (collision.isInelGt1()) { evFlag += 1; - registry.fill(HIST("hNEvents"), 10.5); // INEL>1 + registry.fill(HIST("hNEvents"), 12.5); // INEL>1 } return evFlag; } @@ -286,33 +303,47 @@ struct cascqaanalysis { } // kIsVertexITSTPC selection - if (isVertexITSTPCCut && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) { + if (isVertexITSTPC && !collision.selection_bit(aod::evsel::kIsVertexITSTPC)) { return false; } if (isFillEventSelectionQA) { registry.fill(HIST("hNEvents"), 4.5); } // kNoSameBunchPileup selection - if (isNoSameBunchPileupCut && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + if (isNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { return false; } if (isFillEventSelectionQA) { registry.fill(HIST("hNEvents"), 5.5); } // kIsGoodZvtxFT0vsPV selection - if (isGoodZvtxFT0vsPVCut && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { return false; } if (isFillEventSelectionQA) { registry.fill(HIST("hNEvents"), 6.5); } + // isVertexTOFmatched selection + if (isVertexTOFmatched && !collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + if (isFillEventSelectionQA) { + registry.fill(HIST("hNEvents"), 7.5); + } + // kNoCollInTimeRangeNarrow selection + if (isNoCollInTimeRangeNarrow && !collision.selection_bit(aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; + } + if (isFillEventSelectionQA) { + registry.fill(HIST("hNEvents"), 8.5); + } // Z vertex selection if (TMath::Abs(collision.posZ()) > cutzvertex) { return false; } if (isFillEventSelectionQA) { - registry.fill(HIST("hNEvents"), 7.5); + registry.fill(HIST("hNEvents"), 9.5); registry.fill(HIST("hZCollision"), collision.posZ()); } @@ -338,10 +369,11 @@ struct cascqaanalysis { auto tracksGroupedGlobal = globalTracksIUEta05->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); int nTracksGlobal = tracksGroupedGlobal.size(); - registry.fill(HIST("hFT0MpvContr"), collision.centFT0M(), nTracksPVcontr, evType); - registry.fill(HIST("hFV0ApvContr"), collision.centFV0A(), nTracksPVcontr, evType); + registry.fill(HIST("hCentFT0M_rec"), collision.centFT0M(), evType); if (multQA) { + registry.fill(HIST("hFT0MpvContr"), collision.centFT0M(), nTracksPVcontr, evType); + registry.fill(HIST("hFV0ApvContr"), collision.centFV0A(), nTracksPVcontr, evType); registry.fill(HIST("hFT0Mglobal"), collision.centFT0M(), nTracksGlobal, evType); registry.fill(HIST("hFV0AFT0M"), collision.centFV0A(), collision.centFT0M(), evType); registry.fill(HIST("hFT0MFV0Asignal"), collision.multFT0A() + collision.multFT0C(), collision.multFV0A()); @@ -349,13 +381,15 @@ struct cascqaanalysis { } float lEventScale = scalefactor; + int nCandSel = 0; + int nCandAll = 0; for (const auto& casc : Cascades) { // loop over Cascades registry.fill(HIST("hCandidateCounter"), 0.5); // all candidates - registry.fill(HIST("hCandidateCounter"), 1.5); // v0data exists, deprecated - + nCandAll++; if (AcceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { - registry.fill(HIST("hCandidateCounter"), 2.5); // passed topo cuts + registry.fill(HIST("hCandidateCounter"), 1.5); // passed topo cuts + nCandSel++; // Fill table if (fRand->Rndm() < lEventScale) { auto posdau = casc.posTrack_as(); @@ -391,7 +425,10 @@ struct cascqaanalysis { float ctauXi = pdgDB->Mass(3312) * cascpos / (cascptotmom + 1e-13); float ctauOmega = pdgDB->Mass(3334) * cascpos / (cascptotmom + 1e-13); - mycascades(collision.posZ(), collision.centFT0M(), collision.centFV0A(), casc.sign(), casc.pt(), casc.yXi(), casc.yOmega(), casc.eta(), + mycascades(collision.posZ(), + collision.centFT0M(), collision.centFV0A(), + collision.multFT0M(), collision.multFV0A(), + casc.sign(), casc.pt(), casc.yXi(), casc.yOmega(), casc.eta(), casc.mXi(), casc.mOmega(), casc.mLambda(), casc.cascradius(), casc.v0radius(), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.dcapostopv(), casc.dcanegtopv(), casc.dcabachtopv(), casc.dcacascdaughters(), casc.dcaV0daughters(), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()), @@ -405,6 +442,11 @@ struct cascqaanalysis { } } } + + if (candidateQA) { + registry.fill(HIST("hNcandidates"), nCandAll, collision.centFT0M(), 0); + registry.fill(HIST("hNcandidates"), nCandSel, collision.centFT0M(), 1); + } } Preslice perMcCollision = aod::mcparticle::mcCollisionId; @@ -415,13 +457,20 @@ struct cascqaanalysis { aod::V0Datas const&, soa::Filtered const& Cascades, DauTracks const&, - aod::McCollisions const&, + soa::Join const&, // aod::McCentFV0As to be added aod::McParticles const& mcParticles) { if (!AcceptEvent(collision, 1)) { return; } + if (!collision.has_mcCollision()) { + registry.fill(HIST("fakeEvents"), 0); // no assoc. MC collisions + return; + } + + const auto& mcCollision = collision.mcCollision_as>(); // aod::McCentFV0As to be added + auto tracksGroupedPVcontr = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); int nTracksPVcontr = tracksGroupedPVcontr.size(); @@ -429,48 +478,55 @@ struct cascqaanalysis { int nTracksGlobal = tracksGroupedGlobal.size(); // N charged in FT0M region in corresponding gen. MC collision - auto mcPartSlice = mcParticles.sliceBy(perMcCollision, collision.mcCollision_as().globalIndex()); + auto mcPartSlice = mcParticles.sliceBy(perMcCollision, collision.mcCollision_as>().globalIndex()); // mcCollision.centFV0A() to be added uint16_t nchFT0 = GetGenNchInFT0Mregion(mcPartSlice); uint16_t nchFV0 = GetGenNchInFV0Aregion(mcPartSlice); int evType = 0; - registry.fill(HIST("hNEvents"), 8.5); // INEL + registry.fill(HIST("hNEvents"), 10.5); // INEL // Rec. collision associated with INEL>0 gen. one if (pwglf::isINELgtNmc(mcPartSlice, 0, pdgDB)) { - registry.fill(HIST("hNEvents"), 9.5); // INEL + registry.fill(HIST("hNEvents"), 11.5); // INEL evType++; } // Rec. collision associated with INEL>1 gen. one if (pwglf::isINELgtNmc(mcPartSlice, 1, pdgDB)) { - registry.fill(HIST("hNEvents"), 10.5); // INEL + registry.fill(HIST("hNEvents"), 12.5); // INEL evType++; } - registry.fill(HIST("hNchFT0MPVContr"), nchFT0, nTracksPVcontr, evType); - registry.fill(HIST("hNchFV0APVContr"), nchFV0, nTracksPVcontr, evType); + registry.fill(HIST("hCentFT0M_rec"), mcCollision.centFT0M(), evType); if (multQA) { + registry.fill(HIST("hNchFT0MPVContr"), nchFT0, nTracksPVcontr, evType); + registry.fill(HIST("hNchFV0APVContr"), nchFV0, nTracksPVcontr, evType); + registry.fill(HIST("hFT0MpvContr"), mcCollision.centFT0M(), nTracksPVcontr, evType); + registry.fill(HIST("hFV0ApvContr"), 0, nTracksPVcontr, evType); // mcCollision.centFV0A() to be added + registry.fill(HIST("hFT0Mglobal"), mcCollision.centFT0M(), nTracksGlobal, evType); + registry.fill(HIST("hFV0AFT0M"), 0, mcCollision.centFT0M(), evType); // mcCollision.centFV0A() to be added registry.fill(HIST("hNchFT0Mglobal"), nchFT0, nTracksGlobal, evType); registry.fill(HIST("hFT0MFV0Asignal"), collision.multFT0A() + collision.multFT0C(), collision.multFV0A()); registry.fill(HIST("hFT0MsignalPVContr"), collision.multFT0A() + collision.multFT0C(), nTracksPVcontr, evType); } float lEventScale = scalefactor; + int nCandSel = 0; + int nCandAll = 0; for (const auto& casc : Cascades) { // loop over Cascades registry.fill(HIST("hCandidateCounter"), 0.5); // all candidates - registry.fill(HIST("hCandidateCounter"), 1.5); // v0data exists - deprecated - + nCandAll++; if (AcceptCascCandidate(casc, collision.posX(), collision.posY(), collision.posZ())) { - registry.fill(HIST("hCandidateCounter"), 2.5); // passed topo cuts + registry.fill(HIST("hCandidateCounter"), 1.5); // passed topo cuts + nCandSel++; // Check mc association float lPDG = -1; float isPrimary = -1; if (casc.has_mcParticle()) { - registry.fill(HIST("hCandidateCounter"), 3.5); // has associated MC particle + 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) { - registry.fill(HIST("hCandidateCounter"), 4.5); // associated with Xi or Omega + registry.fill(HIST("hCandidateCounter"), 3.5); // associated with Xi or Omega lPDG = cascmc.pdgCode(); isPrimary = cascmc.isPhysicalPrimary() ? 1 : 0; } @@ -511,7 +567,10 @@ struct cascqaanalysis { float ctauXi = pdgDB->Mass(3312) * cascpos / (cascptotmom + 1e-13); float ctauOmega = pdgDB->Mass(3334) * cascpos / (cascptotmom + 1e-13); - mycascades(collision.posZ(), nchFT0, collision.multFV0A(), casc.sign(), casc.pt(), casc.yXi(), casc.yOmega(), casc.eta(), + mycascades(collision.posZ(), + mcCollision.centFT0M(), 0, // mcCollision.centFV0A() to be added + collision.multFT0M(), collision.multFV0A(), + casc.sign(), casc.pt(), casc.yXi(), casc.yOmega(), casc.eta(), casc.mXi(), casc.mOmega(), casc.mLambda(), casc.cascradius(), casc.v0radius(), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()), casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()), casc.dcapostopv(), casc.dcanegtopv(), casc.dcabachtopv(), casc.dcacascdaughters(), casc.dcaV0daughters(), casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()), @@ -525,9 +584,14 @@ struct cascqaanalysis { } } } + + if (candidateQA) { + registry.fill(HIST("hNcandidates"), nCandAll, mcCollision.centFT0M(), 0); + registry.fill(HIST("hNcandidates"), nCandSel, mcCollision.centFT0M(), 1); + } } - void processMCgen(aod::McCollision const& mcCollision, + void processMCgen(soa::Join::iterator const& mcCollision, // mcCollision.centFV0A() to be added aod::McParticles const& mcParticles, const soa::SmallGroups>& collisions, DauTracks const&) @@ -560,6 +624,8 @@ struct cascqaanalysis { registry.fill(HIST("hNEventsMC"), 4.5); } + registry.fill(HIST("hCentFT0M_genMC"), mcCollision.centFT0M(), evType); + uint16_t nchFT0 = GetGenNchInFT0Mregion(mcParticles); uint16_t nchFV0 = GetGenNchInFV0Aregion(mcParticles); registry.fill(HIST("hNchFT0MGenEvType"), nchFT0, evType); @@ -574,7 +640,7 @@ struct cascqaanalysis { if (!AcceptEvent(collision, 0)) { continue; } - collWithType.index = collision.mcCollision_as().globalIndex(); + collWithType.index = collision.mcCollision_as>().globalIndex(); // mcCollision.centFV0A() to be added collWithType.typeFlag |= o2::aod::myMCcascades::EvFlags::EvINEL; if (collision.isInelGt0()) { @@ -585,7 +651,7 @@ struct cascqaanalysis { } SelectedEvents[nevts++] = collWithType; - if (collision.mcCollision_as().globalIndex() == mcCollision.globalIndex()) { + if (collision.mcCollision_as>().globalIndex() == mcCollision.globalIndex()) { // mcCollision.centFV0A() to be added nAssocColl++; NumberOfContributors.push_back(collision.numContrib()); } @@ -650,7 +716,9 @@ struct cascqaanalysis { } myMCcascades(mcCollision.posZ(), sign, mcParticle.pdgCode(), mcParticle.y(), mcParticle.eta(), mcParticle.phi(), mcParticle.pt(), - mcParticle.isPhysicalPrimary(), nAssocColl, nchFT0, + mcParticle.isPhysicalPrimary(), nAssocColl, + nchFT0, nchFV0, + mcCollision.centFT0M(), 0, // mcCollision.centFV0A() to be added flagsAssoc, flagsGen); } diff --git a/PWGLF/TableProducer/Strangeness/doubleCascTreeCreator.cxx b/PWGLF/TableProducer/Strangeness/doubleCascTreeCreator.cxx new file mode 100644 index 00000000000..5ecffca742f --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/doubleCascTreeCreator.cxx @@ -0,0 +1,334 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "EventFiltering/Zorro.h" +#include "EventFiltering/ZorroSummary.h" + +#include "Common/Core/PID/TPCPIDResponse.h" +#include "Common/DataModel/PIDResponse.h" +#include "DCAFitter/DCAFitterN.h" + +#include "PWGLF/DataModel/LFDoubleCascTables.h" +#include "TDatabasePDG.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using Collisions = soa::Join::iterator; +using FullCascades = aod::CascDataExt; +using TracksFull = soa::Join; + +struct doubleCascCand { + float ptCasc1 = -999.f; // signed pt of the cascade + float etaCasc1 = -999.f; + float phiCasc1 = -999.f; + float cascDecLength1 = -999.f; + float omegaMassCasc1 = -999.f; + float xiMassCasc1 = -999.f; + float cosPACasc1 = -999.f; + float dcaBachPVCasc1 = -999.f; + float dcaV0BachCasc1 = -999.f; + float nSigmaKBach1 = -999.f; + + float ptCasc2 = -999.f; + float etaCasc2 = -999.f; + float phiCasc2 = -999.f; + float cascDecLength2 = -999.f; + float omegaMassCasc2 = -999.f; + float xiMassCasc2 = -999.f; + float cosPACasc2 = -999.f; + float dcaBachPVCasc2 = -999.f; + float dcaV0BachCasc2 = -999.f; + float nSigmaKBach2 = -999.f; + float doubleOmegaMass = -999.f; +}; + +struct doubleCascTreeCreator { + Produces doubleCascTable; + std::vector doubleCascCands; + Service ccdb; + o2::vertexing::DCAFitterN<2> fitter; + + int mRunNumber; + + Zorro zorro; + OutputObj zorroSummary{"zorroSummary"}; + + Configurable cfgSkimmedProcessing{"cfgSkimmedProcessing", false, "Skimmed dataset processing"}; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + 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"}; + + // binning of (anti)lambda mass QA histograms + ConfigurableAxis massOmegaAxis{"massLambdaAxis", {400, o2::constants::physics::MassOmegaMinus - 0.05f, o2::constants::physics::MassOmegaMinus + 0.035}, "binning for the Omega invariant-mass"}; + ConfigurableAxis massXiAxis{"massXiAxis", {400, o2::constants::physics::MassXiMinus - 0.05f, o2::constants::physics::MassXiMinus + 0.05f}, "binning for the Xi invariant-mass"}; + + Configurable zVtxMax{"zVtxMax", 10.0f, "maximum z position of the primary vertex"}; + Configurable etaMax{"etaMax", 0.9f, "maximum eta"}; + ConfigurableAxis momAxis{"momAxisFine", {5.e2, 0.f, 5.f}, "momentum axis binning"}; + + Configurable cascPtMin{"cascPtMin", 1.f, "minimum (anti)casc pT (GeV/c)"}; + Configurable cascPtMax{"cascPtMax", 4.f, "maximum (anti)casc pT (GeV/c)"}; + + Configurable minNCrossedRows{"minNCrossedRows", 100, "Minimum number of crossed TPC rows"}; + Configurable minNITSClus{"minNITSClus", 0., "Minimum number of ITS clusters"}; + Configurable minNTPCClus{"minNTPCClus", 100, "Minimum number of TPC clusters"}; + Configurable maxNSharedTPCClus{"maxNSharedTPCClus", 5, "Maximum number of shared TPC clusters"}; + + Configurable minCascCosPA{"minCascCosPA", 0.99f, "Minimum cosine of the pointing angle of the cascade"}; + Configurable nSigmaTPCCut{"nSigmaTPCCut", 3.f, "Number of sigmas for the TPC PID"}; + Configurable dcaBachToPV{"dcaBachToPV", 0.05f, "DCA of the bachelor to the primary vertex"}; + Configurable dcaV0Bach{"dcaV0Bach", 1.f, "DCA between the V0 daughters"}; + Configurable mXiWindow{"mXiWindow", 0.02f, "mXiWindow"}; + Configurable mOmegaWindow{"mOmegaWindow", 0.01f, "mOmegaWindow"}; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + template + bool selectTrack(T const& track) + { + if (std::abs(track.eta()) > etaMax) { + return false; + } + if (track.itsNCls() < minNITSClus || + track.tpcNClsFound() < minNTPCClus || + track.tpcNClsCrossedRows() < minNCrossedRows || + track.tpcNClsCrossedRows() < 0.8 * track.tpcNClsFindable() || + track.tpcNClsShared() > maxNSharedTPCClus) { + return false; + } + return true; + } + + template + void initCCDB(Bc const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + auto timestamp = bc.timestamp(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp; + mRunNumber = bc.runNumber(); + if (cfgSkimmedProcessing) { + zorro.initCCDB(ccdb.service, bc.runNumber(), bc.timestamp(), "fDoubleOmega,fOmegaXi"); + zorro.populateHistRegistry(histos, bc.runNumber()); + } + } + + void init(o2::framework::InitContext&) + { + mRunNumber = 0; + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + + zorroSummary.setObject(zorro.getZorroSummary()); + + // event QA + histos.add("QA/zVtx", ";#it{z}_{vtx} (cm);Entries", HistType::kTH1F, {zVtxAxis}); + histos.add("QA/massXi", ";#it{p}_{T} (GeV/#it{c});#it{M}(#Lambda + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH2F, {momAxis, massXiAxis}); + histos.add("QA/massOmega", ";#it{p}_{T} (GeV/#it{c});#it{M}(#Omega + #pi^{-}) (GeV/#it{c}^{2});Entries", HistType::kTH2F, {momAxis, massOmegaAxis}); + } + + template + bool isSelectedCasc(C const& collision, T const&, FullCascades::iterator const& casc) + { + + auto bachelor = casc.bachelor_as(); + auto posDau = casc.posTrack_as(); + auto negDau = casc.negTrack_as(); + + if (!selectTrack(bachelor) || !selectTrack(posDau) || !selectTrack(negDau)) { + return false; + } + if (casc.sign() > 0) { + if (TMath::Abs(posDau.tpcNSigmaPi()) > nSigmaTPCCut || TMath::Abs(negDau.tpcNSigmaPr()) > nSigmaTPCCut) { + return false; + } + } else if (casc.sign() < 0) { + if (TMath::Abs(negDau.tpcNSigmaPi()) > nSigmaTPCCut || TMath::Abs(posDau.tpcNSigmaPr()) > nSigmaTPCCut) { + return false; + } + } + if (TMath::Abs(casc.dcabachtopv()) < dcaBachToPV) { + return false; + } + if (TMath::Abs(casc.dcacascdaughters()) > dcaV0Bach) { + return false; + } + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < minCascCosPA) { + return false; + } + if (TMath::Abs(casc.eta()) > etaMax) { + return false; + } + // mass cuts + bool massInWindow = false; + if (casc.mOmega() > o2::constants::physics::MassOmegaMinus - mOmegaWindow && casc.mOmega() < o2::constants::physics::MassOmegaMinus + mOmegaWindow) { + massInWindow = true; + } + if (casc.mXi() > o2::constants::physics::MassXiMinus - mXiWindow && casc.mXi() < o2::constants::physics::MassXiMinus + mXiWindow) { + massInWindow = true; + } + if (!massInWindow) { + return false; + } + return true; + }; + + template + bool doubleOmegaMass(T const&, FullCascades::iterator const& casc1, FullCascades::iterator const& casc2) + { + // the fake omega decay is the one with the smaller radius + auto& fakeOmega = casc1.cascradius() < casc2.cascradius() ? casc1 : casc2; + auto& realOmega = casc1.cascradius() < casc2.cascradius() ? casc2 : casc1; + auto kaon = fakeOmega.bachelor_as(); + float momKaon[3] = {kaon.px(), kaon.py(), kaon.pz()}; + float momLambda[3] = {fakeOmega.pxlambda(), fakeOmega.pylambda(), fakeOmega.pzlambda()}; + // now compute real Omega-lambda-kaon mass + float momTot[3] = {momKaon[0] + momLambda[0] + realOmega.px(), momKaon[1] + momLambda[1] + realOmega.py(), momKaon[2] + momLambda[2] + realOmega.pz()}; + float eK = std::sqrt(o2::constants::physics::MassKaonCharged * o2::constants::physics::MassKaonCharged + momKaon[0] * momKaon[0] + momKaon[1] * momKaon[1] + momKaon[2] * momKaon[2]); + float eL = std::sqrt(o2::constants::physics::MassLambda0 * o2::constants::physics::MassLambda0 + momLambda[0] * momLambda[0] + momLambda[1] * momLambda[1] + momLambda[2] * momLambda[2]); + float eO = std::sqrt(o2::constants::physics::MassOmegaMinus * o2::constants::physics::MassOmegaMinus + momTot[0] * momTot[0] + momTot[1] * momTot[1] + momTot[2] * momTot[2]); + float eTot = eK + eL + eO; + float mass = std::sqrt(eTot * eTot - momTot[0] * momTot[0] - momTot[1] * momTot[1] - momTot[2] * momTot[2]); + return mass; + } + + template + void fillDoubleCasc(C const& collision, T const& tracks, FullCascades const& cascades) + { + doubleCascCands.clear(); + + for (auto& casc1 : cascades) { + if (!isSelectedCasc(collision, tracks, casc1)) { + continue; + } + for (auto& casc2 : cascades) { + if (!isSelectedCasc(collision, tracks, casc2)) { + continue; + } + + if (casc1.posTrackId() == casc2.posTrackId() || casc1.posTrackId() == casc2.negTrackId() || casc1.bachelorId() == casc2.bachelorId()) { + continue; + } + + auto bach1 = casc1.bachelor_as(); + auto bach2 = casc2.bachelor_as(); + + doubleCascCand cand; + cand.ptCasc1 = casc1.pt(); + cand.etaCasc1 = casc1.eta(); + cand.phiCasc1 = casc1.phi(); + cand.cascDecLength1 = std::hypot(casc1.x() - collision.posX(), casc1.y() - collision.posY(), casc1.z() - collision.posZ()); + cand.omegaMassCasc1 = casc1.mOmega(); + cand.xiMassCasc1 = casc1.mXi(); + cand.cosPACasc1 = casc1.v0cosPA(collision.posX(), collision.posY(), collision.posZ()); + cand.dcaBachPVCasc1 = casc1.dcabachtopv(); + cand.dcaV0BachCasc1 = casc1.dcacascdaughters(); + cand.nSigmaKBach1 = bach1.tpcNSigmaKa(); + + cand.ptCasc2 = casc2.pt(); + cand.etaCasc2 = casc2.eta(); + cand.phiCasc2 = casc2.phi(); + cand.cascDecLength2 = std::hypot(casc2.x() - collision.posX(), casc2.y() - collision.posY(), casc2.z() - collision.posZ()); + cand.omegaMassCasc2 = casc2.mOmega(); + cand.xiMassCasc2 = casc2.mXi(); + cand.cosPACasc2 = casc2.v0cosPA(collision.posX(), collision.posY(), collision.posZ()); + cand.dcaBachPVCasc2 = casc2.dcabachtopv(); + cand.dcaV0BachCasc2 = casc2.dcacascdaughters(); + cand.nSigmaKBach2 = bach2.tpcNSigmaKa(); + + cand.doubleOmegaMass = doubleOmegaMass(tracks, casc1, casc2); + + doubleCascCands.push_back(cand); + } + } + }; + + void processData(Collisions const& collision, TracksFull const& tracks, FullCascades const& cascades, aod::BCsWithTimestamps const&) + { + auto bc = collision.bc_as(); + initCCDB(bc); + + if (!collision.sel8()) + return; + + if (std::abs(collision.posZ()) > zVtxMax) + return; + + if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return; + + if (cfgSkimmedProcessing) { + zorro.isSelected(collision.bc_as().globalBC()); /// Just let Zorro do the accounting + } + histos.fill(HIST("QA/zVtx"), collision.posZ()); + fillDoubleCasc(collision, tracks, cascades); + + for (auto& cand : doubleCascCands) { + doubleCascTable( + cand.ptCasc1, + cand.etaCasc1, + cand.phiCasc1, + cand.cascDecLength1, + cand.omegaMassCasc1, + cand.xiMassCasc1, + cand.cosPACasc1, + cand.dcaBachPVCasc1, + cand.dcaV0BachCasc1, + cand.nSigmaKBach1, + cand.ptCasc2, + cand.etaCasc2, + cand.phiCasc2, + cand.cascDecLength2, + cand.omegaMassCasc2, + cand.xiMassCasc2, + cand.cosPACasc2, + cand.dcaBachPVCasc2, + cand.dcaV0BachCasc2, + cand.nSigmaKBach2, + cand.doubleOmegaMass); + } + } + PROCESS_SWITCH(doubleCascTreeCreator, processData, "process (Run 3)", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx b/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx index 4c84b1d3279..0dd6cf1d4ec 100644 --- a/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx +++ b/PWGLF/TableProducer/Strangeness/hStrangeCorrelationFilter.cxx @@ -33,6 +33,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +#define bitset(var, nbit) ((var) |= (1 << (nbit))) #define bitcheck(var, nbit) ((var) & (1 << (nbit))) struct hstrangecorrelationfilter { @@ -40,7 +41,9 @@ struct hstrangecorrelationfilter { // Operational Configurable fillTableOnlyWithCompatible{"fillTableOnlyWithCompatible", true, "pre-apply dE/dx, broad mass window in table filling"}; - Configurable strangedEdxNSigma{"strangedEdxNSigma", 5, "Nsigmas for strange decay daughters"}; + 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"}; // Trigger particle selections in phase space Configurable triggerEtaMin{"triggerEtaCutMin", -0.8, "triggeretamin"}; @@ -102,9 +105,8 @@ struct hstrangecorrelationfilter { 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)"}; - // definitions of peak and background - Configurable peakNsigma{"peakNsigma", 3.0f, "peak region is +/- this many sigmas away"}; - Configurable backgroundNsigma{"backgroundNsigma", 6.0f, "bg region is +/- this many sigmas away (minus peak)"}; + // must include windows for background and peak + Configurable maxMassNSigma{"maxMassNSigma", 12.0f, "max mass region to be considered for further analysis"}; // For extracting strangeness mass QA plots ConfigurableAxis axisPtQA{"axisPtQA", {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"}; @@ -114,6 +116,8 @@ struct hstrangecorrelationfilter { ConfigurableAxis axisOmegaMass{"axisOmegaMass", {200, 1.57f, 1.77f}, "Inv. Mass (GeV/c^{2})"}; 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}, "Centrality percentile bins"}; + // QA + Configurable doTrueSelectionInMass{"doTrueSelectionInMass", false, "Fill mass histograms only with true primary Particles for MC"}; // Do declarative selections for DCAs, if possible Filter preFilterTracks = nabs(aod::track::dcaXY) < dcaXYconstant + dcaXYpTdep * nabs(aod::track::signed1Pt); Filter preFilterV0 = nabs(aod::v0data::dcapostopv) > dcaPostopv&& @@ -128,6 +132,7 @@ struct hstrangecorrelationfilter { using V0LinkedTagged = soa::Join; using CascadesLinkedTagged = soa::Join; using DauTracks = soa::Join; + using DauTracksMC = soa::Join; // using IDTracks= soa::Join; // prepared for Bayesian PID using IDTracks = soa::Join; using V0DatasWithoutTrackX = soa::Join; @@ -166,6 +171,33 @@ struct hstrangecorrelationfilter { histos.add("h3dMassOmegaPlus", "h3dMassOmegaPlus", kTH3F, {axisPtQA, axisOmegaMass, axisMult}); } + // reco-level trigger quality checks (N.B.: DCA is filtered, not selected) + template + bool isValidTrigger(TTrack track) + { + if (track.eta() > triggerEtaMax || track.eta() < triggerEtaMin) { + return false; + } + // if (track.sign()= 1 ) {continue;} + if (track.pt() > triggerPtCutMax || track.pt() < triggerPtCutMin) { + return false; + } + if (track.tpcNClsCrossedRows() < minTPCNCrossedRows) { + return false; // crossed rows + } + if (!track.hasITS() && triggerRequireITS) { + return false; // skip, doesn't have ITS signal (skips lots of TPC-only!) + } + if (track.tpcNClsShared() > triggerMaxTPCSharedClusters) { + return false; // skip, has shared clusters + } + if (!(bitcheck(track.itsClusterMap(), 0)) && triggerRequireL0) { + return false; // skip, doesn't have cluster in ITS L0 + } + return true; + } + + // for real data processing void processTriggers(soa::Join::iterator const& collision, soa::Filtered const& tracks) { // Perform basic event selection @@ -180,30 +212,48 @@ struct hstrangecorrelationfilter { /// _________________________________________________ /// Step 1: Populate table with trigger tracks for (auto const& track : tracks) { - if (track.eta() > triggerEtaMax || track.eta() < triggerEtaMin) { + if (!isValidTrigger(track)) continue; - } - // if (track.sign()= 1 ) {continue;} - if (track.pt() > triggerPtCutMax || track.pt() < triggerPtCutMin) { + triggerTrack( + track.collisionId(), + false, // if you decide to check real data for primaries, you'll have a hard time + track.globalIndex(), + 0); + } + } + + // for MC processing + void processTriggersMC(soa::Join::iterator const& collision, soa::Filtered const& tracks, aod::McParticles 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) { + return; + } + + /// _________________________________________________ + /// Step 1: Populate table with trigger tracks + for (auto const& track : tracks) { + if (!isValidTrigger(track)) continue; - } - if (track.tpcNClsCrossedRows() < minTPCNCrossedRows) { - continue; // crossed rows - } - if (!track.hasITS() && triggerRequireITS) { - continue; // skip, doesn't have ITS signal (skips lots of TPC-only!) - } - if (track.tpcNClsShared() > triggerMaxTPCSharedClusters) { - continue; // skip, has shared clusters - } - if (!(bitcheck(track.itsClusterMap(), 0)) && triggerRequireL0) { - continue; // skip, doesn't have cluster in ITS L0 + bool physicalPrimary = false; + float origPt = -1; + if (track.has_mcParticle()) { + auto mcParticle = track.mcParticle(); + physicalPrimary = mcParticle.isPhysicalPrimary(); + origPt = mcParticle.pt(); } triggerTrack( track.collisionId(), - track.globalIndex()); + physicalPrimary, + track.globalIndex(), + origPt); } } + void processAssocPions(soa::Join::iterator const& collision, soa::Filtered const& tracks) { // Perform basic event selection @@ -287,9 +337,9 @@ struct hstrangecorrelationfilter { continue; } // check dE/dx compatibility - bool compatibleK0Short = false; - bool compatibleLambda = false; - bool compatibleAntiLambda = false; + int compatibleK0Short = 0; + int compatibleLambda = 0; + int compatibleAntiLambda = 0; auto posdau = v0.posTrack_as(); auto negdau = v0.negTrack_as(); @@ -300,88 +350,55 @@ struct hstrangecorrelationfilter { if (posdau.tpcNClsCrossedRows() < minTPCNCrossedRows) continue; - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { - compatibleK0Short = true; - } - if (TMath::Abs(posdau.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPi()) < strangedEdxNSigma) { - if (v0.v0cosPA() > lambdaCospa) { - compatibleLambda = true; - } - } - if (TMath::Abs(posdau.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negdau.tpcNSigmaPr()) < strangedEdxNSigma) { - if (v0.v0cosPA() > lambdaCospa) { - compatibleAntiLambda = true; - } - } - // check whether V0s are in the regin - int massRegK0Short = -1; - if (TMath::Abs(v0.mK0Short() - fK0Mean->Eval(v0.pt()) < peakNsigma * fK0Width->Eval(v0.pt()))) { - massRegK0Short = 2; - } - if (v0.mK0Short() > fK0Mean->Eval(v0.pt()) + peakNsigma * fK0Width->Eval(v0.pt()) && v0.mK0Short() < fK0Mean->Eval(v0.pt()) + backgroundNsigma * fK0Width->Eval(v0.pt())) { - massRegK0Short = 3; - } - if (v0.mK0Short() < fK0Mean->Eval(v0.pt()) - peakNsigma * fK0Width->Eval(v0.pt()) && v0.mK0Short() > fK0Mean->Eval(v0.pt()) - backgroundNsigma * fK0Width->Eval(v0.pt())) { - massRegK0Short = 1; - } - if (v0.mK0Short() > fK0Mean->Eval(v0.pt()) + backgroundNsigma * fK0Width->Eval(v0.pt())) { - massRegK0Short = 4; - } - if (v0.mK0Short() < fK0Mean->Eval(v0.pt()) - backgroundNsigma * fK0Width->Eval(v0.pt())) { - massRegK0Short = 0; - } - - int massRegLambda = -1; - if (TMath::Abs(v0.mLambda() - fLambdaMean->Eval(v0.pt()) < peakNsigma * fLambdaWidth->Eval(v0.pt()))) { - massRegLambda = 2; - } - if (v0.mLambda() > fLambdaMean->Eval(v0.pt()) + peakNsigma * fLambdaWidth->Eval(v0.pt()) && v0.mLambda() < fLambdaMean->Eval(v0.pt()) + backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegLambda = 3; - } - if (v0.mLambda() < fLambdaMean->Eval(v0.pt()) - peakNsigma * fLambdaWidth->Eval(v0.pt()) && v0.mLambda() > fLambdaMean->Eval(v0.pt()) - backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegLambda = 1; - } - if (v0.mLambda() > fLambdaMean->Eval(v0.pt()) + backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegLambda = 4; - } - if (v0.mLambda() < fLambdaMean->Eval(v0.pt()) - backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegLambda = 0; - } - - int massRegAntiLambda = -1; - if (TMath::Abs(v0.mAntiLambda() - fLambdaMean->Eval(v0.pt()) < peakNsigma * fLambdaWidth->Eval(v0.pt()))) { - massRegAntiLambda = 2; - } - if (v0.mAntiLambda() > fLambdaMean->Eval(v0.pt()) + peakNsigma * fLambdaWidth->Eval(v0.pt()) && v0.mAntiLambda() < fLambdaMean->Eval(v0.pt()) + backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegAntiLambda = 3; - } - if (v0.mAntiLambda() < fLambdaMean->Eval(v0.pt()) - peakNsigma * fLambdaWidth->Eval(v0.pt()) && v0.mAntiLambda() > fLambdaMean->Eval(v0.pt()) - backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegAntiLambda = 1; - } - if (v0.mAntiLambda() > fLambdaMean->Eval(v0.pt()) + backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegAntiLambda = 4; - } - if (v0.mAntiLambda() < fLambdaMean->Eval(v0.pt()) - backgroundNsigma * fLambdaWidth->Eval(v0.pt())) { - massRegAntiLambda = 0; - } - - if (compatibleK0Short) + 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); + + // 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) + if (compatibleLambda && (!doTrueSelectionInMass || (origV0entry.isTrueLambda() && origV0entry.isPhysicalPrimary()))) histos.fill(HIST("h3dMassLambda"), v0.pt(), v0.mLambda(), collision.centFT0M()); - if (compatibleAntiLambda) + if (compatibleAntiLambda && (!doTrueSelectionInMass || (origV0entry.isTrueAntiLambda() && origV0entry.isPhysicalPrimary()))) histos.fill(HIST("h3dMassAntiLambda"), v0.pt(), v0.mAntiLambda(), collision.centFT0M()); if (!fillTableOnlyWithCompatible || ( // start major condition check - (compatibleK0Short && massRegK0Short > 0 && massRegK0Short < 4) || - (compatibleLambda && massRegLambda > 0 && massRegLambda < 4) || - (compatibleAntiLambda && massRegAntiLambda > 0 && massRegAntiLambda < 4)) // end 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, - origV0entry.isTrueK0Short(), origV0entry.isTrueLambda(), origV0entry.isTrueAntiLambda(), - massRegK0Short, massRegLambda, massRegAntiLambda); + origV0entry.isTrueK0Short(), origV0entry.isTrueLambda(), origV0entry.isTrueAntiLambda(), origV0entry.isPhysicalPrimary(), + massNSigmaK0Short, massNSigmaLambda, massNSigmaAntiLambda); } } } @@ -412,82 +429,68 @@ struct hstrangecorrelationfilter { continue; // check dE/dx compatibility - bool compatibleXiMinus = false; - bool compatibleXiPlus = false; - bool compatibleOmegaMinus = false; - bool compatibleOmegaPlus = false; - - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() < 0) { - compatibleXiMinus = true; - } - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && casc.sign() > 0) { - compatibleXiPlus = true; - } - if (TMath::Abs(posTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() < 0) { - compatibleOmegaMinus = true; - } - if (TMath::Abs(posTrackCast.tpcNSigmaPi()) < strangedEdxNSigma && TMath::Abs(negTrackCast.tpcNSigmaPr()) < strangedEdxNSigma && TMath::Abs(bachTrackCast.tpcNSigmaKa()) < strangedEdxNSigma && casc.sign() > 0) { - compatibleOmegaPlus = true; - } - - int massRegXi = -1; - if (TMath::Abs(casc.mXi() - fXiMean->Eval(casc.pt()) < peakNsigma * fXiWidth->Eval(casc.pt()))) { - massRegXi = 2; - } - if (casc.mXi() > fXiMean->Eval(casc.pt()) + peakNsigma * fXiWidth->Eval(casc.pt()) && casc.mXi() < fXiMean->Eval(casc.pt()) + backgroundNsigma * fXiWidth->Eval(casc.pt())) { - massRegXi = 3; - } - if (casc.mXi() < fXiMean->Eval(casc.pt()) - peakNsigma * fXiWidth->Eval(casc.pt()) && casc.mXi() > fXiMean->Eval(casc.pt()) - backgroundNsigma * fXiWidth->Eval(casc.pt())) { - massRegXi = 1; - } - if (casc.mXi() > fXiMean->Eval(casc.pt()) + backgroundNsigma * fXiWidth->Eval(casc.pt())) { - massRegXi = 4; - } - if (casc.mXi() < fXiMean->Eval(casc.pt()) - backgroundNsigma * fXiWidth->Eval(casc.pt())) { - massRegXi = 0; - } - - int massRegOmega = -1; - if (TMath::Abs(casc.mOmega() - fOmegaMean->Eval(casc.pt()) < peakNsigma * fOmegaWidth->Eval(casc.pt()))) { - massRegOmega = 2; - } - if (casc.mOmega() > fOmegaMean->Eval(casc.pt()) + peakNsigma * fOmegaWidth->Eval(casc.pt()) && casc.mOmega() < fOmegaMean->Eval(casc.pt()) + backgroundNsigma * fOmegaWidth->Eval(casc.pt())) { - massRegOmega = 3; - } - if (casc.mOmega() < fOmegaMean->Eval(casc.pt()) - peakNsigma * fOmegaWidth->Eval(casc.pt()) && casc.mOmega() > fOmegaMean->Eval(casc.pt()) - backgroundNsigma * fOmegaWidth->Eval(casc.pt())) { - massRegOmega = 1; - } - if (casc.mOmega() > fOmegaMean->Eval(casc.pt()) + backgroundNsigma * fOmegaWidth->Eval(casc.pt())) { - massRegOmega = 4; - } - if (casc.mOmega() < fOmegaMean->Eval(casc.pt()) - backgroundNsigma * fOmegaWidth->Eval(casc.pt())) { - massRegOmega = 0; - } - - if (compatibleXiMinus) + int compatibleXiMinus = 0; + int compatibleXiPlus = 0; + int compatibleOmegaMinus = 0; + int compatibleOmegaPlus = 0; + + 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); + + 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) + if (compatibleXiPlus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueXiPlus() && origCascadeEntry.isPhysicalPrimary()))) histos.fill(HIST("h3dMassXiPlus"), casc.pt(), casc.mXi(), collision.centFT0M()); - if (compatibleOmegaMinus) + if (compatibleOmegaMinus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueOmegaMinus() && origCascadeEntry.isPhysicalPrimary()))) histos.fill(HIST("h3dMassOmegaMinus"), casc.pt(), casc.mOmega(), collision.centFT0M()); - if (compatibleOmegaPlus) + if (compatibleOmegaPlus && (!doTrueSelectionInMass || (origCascadeEntry.isTrueOmegaPlus() && origCascadeEntry.isPhysicalPrimary()))) histos.fill(HIST("h3dMassOmegaPlus"), casc.pt(), casc.mOmega(), collision.centFT0M()); if (!fillTableOnlyWithCompatible || ( // start major condition check - ((compatibleXiMinus || compatibleXiPlus) && massRegXi > 0 && massRegXi < 4) || - ((compatibleOmegaMinus || compatibleOmegaPlus) && massRegOmega > 0 && massRegOmega < 4)) // end 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, origCascadeEntry.isTrueXiMinus(), origCascadeEntry.isTrueXiPlus(), origCascadeEntry.isTrueOmegaMinus(), origCascadeEntry.isTrueOmegaPlus(), - massRegXi, massRegOmega); + origCascadeEntry.isPhysicalPrimary(), + 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); diff --git a/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx b/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx index 18d854aa1f6..d4a87d2f502 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzerobuilder.cxx @@ -263,6 +263,7 @@ struct lambdakzeroBuilder { static constexpr float defaultLambdaWindowParameters[1][4] = {{1.17518e-03, 1.24099e-04, 5.47937e-03, 3.08009e-01}}; 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 massCutPhoton{"massCutPhoton", 0.2, "Photon max mass"}; Configurable massWindownumberOfSigmas{"massWindownumberOfSigmas", 5e+6, "number of sigmas around mass peaks to keep"}; Configurable massWindowWithTPCPID{"massWindowWithTPCPID", false, "when checking mass windows, correlate with TPC dE/dx"}; Configurable massWindowSafetyMargin{"massWindowSafetyMargin", 0.001, "Extra mass window safety margin"}; @@ -977,15 +978,18 @@ struct lambdakzeroBuilder { bool desiredMassK0Short = false; bool desiredMassLambda = false; bool desiredMassAntiLambda = false; + bool desiredMassGamma = false; if (massWindownumberOfSigmas > 1e+3) { desiredMassK0Short = true; // safety fallback desiredMassLambda = true; // safety fallback desiredMassAntiLambda = true; // safety fallback + desiredMassGamma = true; // safety fallback } else { desiredMassK0Short = TMath::Abs(v0candidate.k0ShortMass - o2::constants::physics::MassKaonNeutral) < massWindownumberOfSigmas * getMassSigmaK0Short(lPt) + massWindowSafetyMargin; desiredMassLambda = TMath::Abs(v0candidate.lambdaMass - o2::constants::physics::MassLambda) < massWindownumberOfSigmas * getMassSigmaLambda(lPt) + massWindowSafetyMargin; desiredMassAntiLambda = TMath::Abs(v0candidate.antiLambdaMass - o2::constants::physics::MassLambda) < massWindownumberOfSigmas * getMassSigmaLambda(lPt) + massWindowSafetyMargin; + desiredMassGamma = TMath::Abs(lGammaMass) < massCutPhoton; } // check if user requested to correlate mass requirement with TPC PID @@ -993,6 +997,7 @@ struct lambdakzeroBuilder { bool dEdxK0Short = V0.isdEdxK0Short() || !massWindowWithTPCPID; bool dEdxLambda = V0.isdEdxLambda() || !massWindowWithTPCPID; bool dEdxAntiLambda = V0.isdEdxAntiLambda() || !massWindowWithTPCPID; + bool dEdxGamma = V0.isdEdxGamma() || !massWindowWithTPCPID; // check proper lifetime if asked for bool passML2P_K0Short = lML2P_K0Short < lifetimecut->get("lifetimecutK0S") || lifetimecut->get("lifetimecutK0S") > 1000; @@ -1004,6 +1009,8 @@ struct lambdakzeroBuilder { keepCandidate = true; if (passML2P_Lambda && dEdxAntiLambda && desiredMassAntiLambda) keepCandidate = true; + if (dEdxGamma && desiredMassGamma) + keepCandidate = true; if (!keepCandidate) return false; @@ -1182,16 +1189,11 @@ struct lambdakzeroBuilder { if (V0.v0Type() > 1 && !storePhotonCandidates) continue; - if (mlConfigurations.calculateK0ShortScores || - mlConfigurations.calculateLambdaScores || - mlConfigurations.calculateAntiLambdaScores || - mlConfigurations.calculateGammaScores) { - // at this stage, the candidate is interesting -> populate table - gammaMLSelections(gammaScore); - lambdaMLSelections(lambdaScore); - antiLambdaMLSelections(antiLambdaScore); - k0ShortMLSelections(k0ShortScore); - } + // at this stage, the candidate is interesting -> populate table + gammaMLSelections(gammaScore); + lambdaMLSelections(lambdaScore); + antiLambdaMLSelections(antiLambdaScore); + k0ShortMLSelections(k0ShortScore); // populates the various tables for analysis statisticsRegistry.v0stats[kCountStandardV0]++; @@ -1377,7 +1379,7 @@ struct lambdakzeroPreselector { Configurable minITSCluITSOnly{"minITSCluITSOnly", 0, "minimum number of ITS clusters to ask for if daughter track does not have TPC"}; // for bit-packed maps - std::vector selectionMask; + std::vector selectionMask; enum v0bit { bitInteresting = 0, bitTrackQuality, bitTrueGamma, @@ -1386,6 +1388,7 @@ struct lambdakzeroPreselector { bitTrueAntiLambda, bitTrueHypertriton, bitTrueAntiHypertriton, + bitPhysicalPrimary, bitdEdxGamma, bitdEdxK0Short, bitdEdxLambda, @@ -1419,7 +1422,7 @@ struct lambdakzeroPreselector { //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* /// function to check track quality template - void checkTrackQuality(TV0Object const& lV0Candidate, uint16_t& maskElement, bool passdEdx = false) + void checkTrackQuality(TV0Object const& lV0Candidate, uint32_t& maskElement, bool passdEdx = false) { auto lNegTrack = lV0Candidate.template negTrack_as(); auto lPosTrack = lV0Candidate.template posTrack_as(); @@ -1462,9 +1465,10 @@ struct lambdakzeroPreselector { //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* /// function to check PDG association template - void checkPDG(TV0Object const& lV0Candidate, uint16_t& maskElement) + void checkPDG(TV0Object const& lV0Candidate, uint32_t& maskElement) { int lPDG = -1; + bool physicalPrimary = false; auto lNegTrack = lV0Candidate.template negTrack_as(); auto lPosTrack = lV0Candidate.template posTrack_as(); @@ -1478,6 +1482,7 @@ struct lambdakzeroPreselector { for (auto& lPosMother : lMCPosTrack.template mothers_as()) { if (lNegMother.globalIndex() == lPosMother.globalIndex() && (!dIfMCselectPhysicalPrimary || lNegMother.isPhysicalPrimary())) { lPDG = lNegMother.pdgCode(); + physicalPrimary = lNegMother.isPhysicalPrimary(); // additionally check PDG of the mother particle if requested if (dIfMCselectV0MotherPDG != 0) { @@ -1507,10 +1512,12 @@ struct lambdakzeroPreselector { bitset(maskElement, bitTrueHypertriton); if (lPDG == -1010010030) bitset(maskElement, bitTrueAntiHypertriton); + if (physicalPrimary) + bitset(maskElement, bitPhysicalPrimary); } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* template - void checkdEdx(TV0Object const& lV0Candidate, uint16_t& maskElement) + void checkdEdx(TV0Object const& lV0Candidate, uint32_t& maskElement) { auto lNegTrack = lV0Candidate.template negTrack_as(); auto lPosTrack = lV0Candidate.template posTrack_as(); @@ -1593,7 +1600,8 @@ struct lambdakzeroPreselector { } v0tags(validV0, bitcheck(selectionMask[ii], bitTrueGamma), bitcheck(selectionMask[ii], bitTrueK0Short), bitcheck(selectionMask[ii], bitTrueLambda), - bitcheck(selectionMask[ii], bitTrueAntiLambda), bitcheck(selectionMask[ii], bitTrueHypertriton), bitcheck(selectionMask[ii], bitTrueAntiHypertriton), + bitcheck(selectionMask[ii], bitTrueAntiLambda), + bitcheck(selectionMask[ii], bitTrueHypertriton), bitcheck(selectionMask[ii], bitTrueAntiHypertriton), bitcheck(selectionMask[ii], bitPhysicalPrimary), bitcheck(selectionMask[ii], bitdEdxGamma), bitcheck(selectionMask[ii], bitdEdxK0Short), bitcheck(selectionMask[ii], bitdEdxLambda), bitcheck(selectionMask[ii], bitdEdxAntiLambda), bitcheck(selectionMask[ii], bitdEdxHypertriton), bitcheck(selectionMask[ii], bitdEdxAntiHypertriton), bitcheck(selectionMask[ii], bitUsedInCascade), bitcheck(selectionMask[ii], bitUsedInTrackedCascade)); diff --git a/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx b/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx index c1085762b6f..60d331ea61d 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzerofinder.cxx @@ -270,11 +270,11 @@ struct lambdakzerofinder { int collisionIndex = -1; // float getDCAtoPV(float X, float Y, float Z, float Px, float Py, float Pz, float pvX, float pvY, float pvZ){ for (auto const& collision : collisions) { - float thisDCA = TMath::Abs(getDCAtoPV(vtx[0], vtx[1], vtx[2], pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2], collision.posX(), collision.posY(), collision.posY())); + float thisDCA = TMath::Abs(getDCAtoPV(vtx[0], vtx[1], vtx[2], pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2], collision.posX(), collision.posY(), collision.posZ())); if (thisDCA < smallestDCA) { collisionIndex = collision.globalIndex(); smallestDCA = thisDCA; - cosPA = RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posY()}, array{vtx[0], vtx[1], vtx[2]}, array{pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}); + cosPA = RecoDecay::cpa(std::array{collision.posX(), collision.posY(), collision.posZ()}, array{vtx[0], vtx[1], vtx[2]}, array{pvec0[0] + pvec1[0], pvec0[1] + pvec1[1], pvec0[2] + pvec1[2]}); } } if (smallestDCA > maxV0DCAtoPV) diff --git a/PWGLF/TableProducer/Strangeness/lambdakzeromcbuilder.cxx b/PWGLF/TableProducer/Strangeness/lambdakzeromcbuilder.cxx index 8fe57bc144f..1d7b1c29490 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzeromcbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzeromcbuilder.cxx @@ -55,6 +55,8 @@ struct lambdakzeromcbuilder { Configurable addGeneratedAntiLambda{"addGeneratedAntiLambda", false, "add V0MCCore entry for generated, not-recoed AntiLambda"}; Configurable addGeneratedGamma{"addGeneratedGamma", false, "add V0MCCore entry for generated, not-recoed Gamma"}; + Configurable treatPiToMuDecays{"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 rapidityWindow{"rapidityWindow", 0.5, "rapidity window to save non-recoed candidates"}; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -77,31 +79,72 @@ struct lambdakzeromcbuilder { h->GetXaxis()->SetBinLabel(2, "V0MCCores population"); h->GetXaxis()->SetBinLabel(3, "x check: duplicates"); h->GetXaxis()->SetBinLabel(4, "x check: unique"); + + auto hK0s = histos.add("hStatisticsK0s", "hBuildingStatisticsK0s", kTH1F, {{3, -0.5, 2.5f}}); + hK0s->GetXaxis()->SetBinLabel(1, "MC associated to reco."); + hK0s->GetXaxis()->SetBinLabel(2, "Not originating from decay"); + hK0s->GetXaxis()->SetBinLabel(3, "MC with un-recoed V0"); + + auto hLambda = histos.add("hStatisticsLambda", "hBuildingStatisticsLambda", kTH1F, {{3, -0.5, 2.5f}}); + hLambda->GetXaxis()->SetBinLabel(1, "MC associated to reco."); + hLambda->GetXaxis()->SetBinLabel(2, "Not originating from decay"); + hLambda->GetXaxis()->SetBinLabel(3, "MC with un-recoed V0"); + + auto hAlambda = histos.add("hStatisticsAlambda", "hBuildingStatisticsAlambda", kTH1F, {{3, -0.5, 2.5f}}); + hAlambda->GetXaxis()->SetBinLabel(1, "MC associated to reco."); + hAlambda->GetXaxis()->SetBinLabel(2, "Not originating from decay"); + hAlambda->GetXaxis()->SetBinLabel(3, "MC with un-recoed V0"); } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* // Helper struct to contain V0MCCore information prior to filling struct mcV0info { - int label; - int motherLabel; - int pdgCode; - int pdgCodeMother; - int pdgCodePositive; - int pdgCodeNegative; - int mcCollision; - bool isPhysicalPrimary; + 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; - uint64_t packedMcParticleIndices; + std::array momentum; }; mcV0info thisInfo; //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* - // prong index combiner - uint64_t combineProngIndices(uint32_t low, uint32_t high) + // kink handling + template + int getOriginatingParticle(mcpart const& part, int& indexForPositionOfDecay) { - return (((uint64_t)high) << 32) | ((uint64_t)low); + 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; } //*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* @@ -113,7 +156,6 @@ struct lambdakzeromcbuilder { std::vector mcParticleIsReco(mcParticles.size(), false); // mc Particle not recoed by V0s for (auto& v0 : v0table) { - thisInfo.packedMcParticleIndices = 0; // not de-referenced properly yet thisInfo.label = -1; thisInfo.motherLabel = -1; thisInfo.pdgCode = 0; @@ -124,57 +166,99 @@ struct lambdakzeromcbuilder { 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; auto lNegTrack = v0.negTrack_as(); auto lPosTrack = v0.posTrack_as(); // Association check // There might be smarter ways of doing this in the future if (lNegTrack.has_mcParticle() && lPosTrack.has_mcParticle()) { - thisInfo.packedMcParticleIndices = combineProngIndices(lPosTrack.mcParticleId(), lNegTrack.mcParticleId()); auto lMCNegTrack = lNegTrack.mcParticle_as(); auto lMCPosTrack = lPosTrack.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(); - if (lMCNegTrack.has_mothers() && lMCPosTrack.has_mothers()) { - for (auto& lNegMother : lMCNegTrack.mothers_as()) { - for (auto& lPosMother : lMCPosTrack.mothers_as()) { - if (lNegMother.globalIndex() == lPosMother.globalIndex()) { - thisInfo.label = lNegMother.globalIndex(); - - if (lNegMother.has_mcCollision()) { - thisInfo.mcCollision = lNegMother.mcCollisionId(); // save this reference, please - } - // acquire information - thisInfo.xyz[0] = lMCPosTrack.vx(); - thisInfo.xyz[1] = lMCPosTrack.vy(); - thisInfo.xyz[2] = lMCPosTrack.vz(); - thisInfo.pdgCode = lNegMother.pdgCode(); - thisInfo.isPhysicalPrimary = lNegMother.isPhysicalPrimary(); - if (lNegMother.has_mothers()) { - for (auto& lNegGrandMother : lNegMother.mothers_as()) { - thisInfo.pdgCodeMother = lNegGrandMother.pdgCode(); - thisInfo.motherLabel = lNegGrandMother.globalIndex(); - } - } - } + // 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); + posOriginating = getOriginatingParticle(lMCPosTrack, particleForDecayPositionIdx); + + 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(); + + // MC pos. and neg. daughters are the same! Looking for replacement... + // if (lMCPosTrack.globalIndex() == lMCNegTrack.globalIndex()) { + // auto const& daughters = lNegMother.daughters_as(); + // for (auto& ldau : daughters) { + // // check if the candidate originates from a decay + // // if not, this is not a suitable candidate for one of the decay daughters + // if (ldau.getProcess() != 4) // see TMCProcess.h + // continue; + + // if (lMCPosTrack.pdgCode() < 0 && ldau.pdgCode() > 0) { // the positive track needs to be changed + // thisInfo.pdgCodePositive = ldau.pdgCode(); + // thisInfo.processPositive = ldau.getProcess(); + // thisInfo.posP[0] = ldau.px(); + // thisInfo.posP[1] = ldau.py(); + // thisInfo.posP[2] = ldau.pz(); + // thisInfo.xyz[0] = ldau.vx(); + // thisInfo.xyz[1] = ldau.vy(); + // thisInfo.xyz[2] = ldau.vz(); + // } + // if (lMCNegTrack.pdgCode() > 0 && ldau.pdgCode() < 0) { // the negative track needs to be changed + // thisInfo.pdgCodeNegative = ldau.pdgCode(); + // thisInfo.processNegative = ldau.getProcess(); + // thisInfo.negP[0] = ldau.px(); + // thisInfo.negP[1] = ldau.py(); + // thisInfo.negP[2] = ldau.pz(); + // } + // } + // } + + 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 (auto& lV0Mother : originatingV0.mothers_as()) { + thisInfo.pdgCodeMother = lV0Mother.pdgCode(); + thisInfo.motherLabel = lV0Mother.globalIndex(); } } } + } // end association check // Construct label table (note: this will be joinable with V0Datas!) v0labels( thisInfo.label, thisInfo.motherLabel); // Mark mcParticle as recoed (no searching necessary afterwards) - if (thisInfo.motherLabel > -1) { - mcParticleIsReco[thisInfo.motherLabel] = true; + if (thisInfo.label > -1) { + mcParticleIsReco[thisInfo.label] = true; } // ---] Symmetric populate [--- @@ -187,7 +271,8 @@ struct lambdakzeromcbuilder { 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.negP[0], thisInfo.negP[1], thisInfo.negP[2], + thisInfo.momentum[0], thisInfo.momentum[1], thisInfo.momentum[2]); v0mccollref(thisInfo.mcCollision); // n.b. placing the interlink index here allows for the writing of @@ -204,17 +289,45 @@ struct lambdakzeromcbuilder { // 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.packedMcParticleIndices == mcV0infos[ii].packedMcParticleIndices && mcV0infos[ii].packedMcParticleIndices > 0) { + if (thisInfo.label == mcV0infos[ii].label && mcV0infos[ii].label > -1) { thisV0MCCoreIndex = ii; histos.fill(HIST("hBuildingStatistics"), 2.0f); // found break; // this exists already in list } } - if (thisV0MCCoreIndex < 0) { + if (thisV0MCCoreIndex < 0 && thisInfo.label > -1) { // this V0MCCore does not exist yet. Create it and reference it histos.fill(HIST("hBuildingStatistics"), 3.0f); // new thisV0MCCoreIndex = mcV0infos.size(); mcV0infos.push_back(thisInfo); + + // For bookkeeping + if (thisInfo.label > -1 && thisInfo.isPhysicalPrimary) { + float ymc = 1e3; + if (thisInfo.pdgCode == 310) + ymc = RecoDecay::y(std::array{thisInfo.posP[0] + thisInfo.negP[0], thisInfo.posP[1] + thisInfo.negP[1], thisInfo.posP[2] + thisInfo.negP[2]}, o2::constants::physics::MassKaonNeutral); + else if (TMath::Abs(thisInfo.pdgCode) == 3122) + ymc = RecoDecay::y(std::array{thisInfo.posP[0] + thisInfo.negP[0], thisInfo.posP[1] + thisInfo.negP[1], thisInfo.posP[2] + thisInfo.negP[2]}, o2::constants::physics::MassLambda); + + if (thisInfo.pdgCode == 310 && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsK0s"), 0.0f); // found + if (thisInfo.processPositive != 4 || thisInfo.processNegative != 4) { + histos.fill(HIST("hStatisticsK0s"), 1.0f); // Not originating from decay + } + } + if (thisInfo.pdgCode == 3122 && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsLambda"), 0.0f); // found + if (thisInfo.processPositive != 4 || thisInfo.processNegative != 4) { + histos.fill(HIST("hStatisticsLambda"), 1.0f); // Not originating from decay + } + } + if (thisInfo.pdgCode == -3122 && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsAlambda"), 0.0f); // found + if (thisInfo.processPositive != 4 || thisInfo.processNegative != 4) { + histos.fill(HIST("hStatisticsAlambda"), 1.0f); // Not originating from decay + } + } + } } v0CoreMCLabels(thisV0MCCoreIndex); // interlink index } @@ -224,17 +337,17 @@ struct lambdakzeromcbuilder { if (populateV0MCCoresAsymmetric) { // first step: add any un-recoed v0mmcores that were requested for (auto& mcParticle : mcParticles) { - thisInfo.packedMcParticleIndices = 0; thisInfo.label = -1; thisInfo.motherLabel = -1; thisInfo.pdgCode = 0; - thisInfo.pdgCodeMother = 0; - thisInfo.pdgCodePositive = 0; - thisInfo.pdgCodeNegative = 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 @@ -249,16 +362,65 @@ struct lambdakzeromcbuilder { (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 } - // guarantee compressibility: keep momentum entirely in the positive prong - // WARNING: THIS IS AS ARBITRARY AS IT GETS but should be ok - thisInfo.posP[0] = mcParticle.px(); - thisInfo.posP[1] = mcParticle.py(); - thisInfo.posP[2] = mcParticle.pz(); + // + thisInfo.momentum[0] = mcParticle.px(); + thisInfo.momentum[1] = mcParticle.py(); + thisInfo.momentum[2] = mcParticle.pz(); + + if (mcParticle.has_mothers()) { + auto const& mother = mcParticle.mothers_first_as(); + thisInfo.pdgCodeMother = mother.pdgCode(); + thisInfo.motherLabel = mother.globalIndex(); + } + if (mcParticle.has_daughters()) { + auto const& daughters = mcParticle.daughters_as(); + + for (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(); + } + } + } + + // For bookkeeping + float ymc = 1e3; + if (mcParticle.pdgCode() == 310) + ymc = RecoDecay::y(std::array{thisInfo.posP[0] + thisInfo.negP[0], thisInfo.posP[1] + thisInfo.negP[0], thisInfo.posP[2] + thisInfo.negP[2]}, o2::constants::physics::MassKaonNeutral); + else if (TMath::Abs(mcParticle.pdgCode()) == 3122) + ymc = RecoDecay::y(std::array{thisInfo.posP[0] + thisInfo.negP[0], thisInfo.posP[1] + thisInfo.negP[0], thisInfo.posP[2] + thisInfo.negP[2]}, o2::constants::physics::MassLambda); + + if (mcParticle.pdgCode() == 310 && mcParticle.isPhysicalPrimary() && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsK0s"), 2.0f); // found + } + if (mcParticle.pdgCode() == 3122 && mcParticle.isPhysicalPrimary() && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsLambda"), 2.0f); // found + } + if (mcParticle.pdgCode() == -3122 && mcParticle.isPhysicalPrimary() && TMath::Abs(ymc) < rapidityWindow) { + histos.fill(HIST("hStatisticsAlambda"), 2.0f); // found + } // if I got here, it means this MC particle was not recoed and is of interest. Add it please mcV0infos.push_back(thisInfo); @@ -271,8 +433,9 @@ struct lambdakzeromcbuilder { 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]); - v0mccollref(thisInfo.mcCollision); + info.negP[0], info.negP[1], info.negP[2], + info.momentum[0], info.momentum[1], info.momentum[2]); + v0mccollref(info.mcCollision); } } diff --git a/PWGLF/TableProducer/Strangeness/lambdakzeropid.cxx b/PWGLF/TableProducer/Strangeness/lambdakzeropid.cxx index 8871c983668..c6041aa0e02 100644 --- a/PWGLF/TableProducer/Strangeness/lambdakzeropid.cxx +++ b/PWGLF/TableProducer/Strangeness/lambdakzeropid.cxx @@ -107,8 +107,8 @@ struct lambdakzeropid { Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; // manual + Configurable useCustomRunNumber{"useCustomRunNumber", false, "Use custom timestamp"}; Configurable manualRunNumber{"manualRunNumber", 544122, "manual run number if no collisions saved"}; - Configurable manualTimeStamp{"manualTimeStamp", 1696549226920, "manual time stamp if no collisions saved"}; ConfigurableAxis axisEta{"axisEta", {20, -1.0f, +1.0f}, "#eta"}; ConfigurableAxis axisDeltaTime{"axisDeltaTime", {2000, -1000.0f, +1000.0f}, "delta-time (ps)"}; @@ -327,7 +327,7 @@ struct lambdakzeropid { } } - void initCCDB(int runNumber, uint64_t timeStamp) + void initCCDB(int runNumber) { if (mRunNumber == runNumber) { return; @@ -341,34 +341,33 @@ struct lambdakzeropid { grpmag.setL3Current(30000.f / (d_bz / 5.0f)); } o2::base::Propagator::initFieldFromGRP(&grpmag); - mVtx = ccdb->getForTimeStamp(mVtxPath, timeStamp); + mVtx = ccdb->getForRun(mVtxPath, runNumber); mRunNumber = runNumber; return; } - auto run3grp_timestamp = timeStamp; - o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(grpPath, run3grp_timestamp); + o2::parameters::GRPObject* grpo = ccdb->getForRun(grpPath, runNumber); 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"; + LOG(info) << "Retrieved GRP for run " << runNumber << " with magnetic field of " << d_bz << " kZG"; } else { - grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); + grpmag = ccdb->getForRun(grpmagPath, runNumber); if (!grpmag) { - LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; + LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for run " << runNumber; } o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - mVtx = ccdb->getForTimeStamp(mVtxPath, timeStamp); - LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; + mVtx = ccdb->getForRun(mVtxPath, runNumber); + LOG(info) << "Retrieved GRP for run " << runNumber << " with magnetic field of " << d_bz << " kZG"; } // if TOF Nsigma desired if (doNSigmas) { - nSigmaCalibObjects = ccdb->getForTimeStamp(nSigmaPath, timeStamp); + nSigmaCalibObjects = ccdb->getForRun(nSigmaPath, runNumber); if (nSigmaCalibObjects) { LOGF(info, "loaded TList with this many objects: %i", nSigmaCalibObjects->GetEntries()); @@ -593,12 +592,12 @@ struct lambdakzeropid { void processStandardData(aod::Collisions const& collisions, V0OriginalDatas const& V0s, TracksWithAllExtras const&, aod::BCsWithTimestamps const& /*bcs*/) { // Fire up CCDB with first collision in record. If no collisions, bypass - if (collisions.size() > 0) { + if (useCustomRunNumber || collisions.size() < 1) { + initCCDB(manualRunNumber); + } else { auto collision = collisions.begin(); auto bc = collision.bc_as(); - initCCDB(bc.runNumber(), bc.timestamp()); - } else { - initCCDB(manualRunNumber, manualTimeStamp); + initCCDB(bc.runNumber()); } for (const auto& V0 : V0s) { @@ -621,11 +620,11 @@ struct lambdakzeropid { void processDerivedData(soa::Join const& collisions, V0DerivedDatas const& V0s, dauTracks const&) { // Fire up CCDB with first collision in record. If no collisions, bypass - if (collisions.size() > 0) { - auto collision = collisions.begin(); - initCCDB(collision.runNumber(), collision.timestamp()); + if (useCustomRunNumber || collisions.size() < 1) { + initCCDB(manualRunNumber); } else { - initCCDB(manualRunNumber, manualTimeStamp); + auto collision = collisions.begin(); + initCCDB(collision.runNumber()); } for (const auto& V0 : V0s) { diff --git a/PWGLF/TableProducer/Strangeness/sigma0builder.cxx b/PWGLF/TableProducer/Strangeness/sigma0builder.cxx index 19a0dbd77ae..e6b7d2495a9 100644 --- a/PWGLF/TableProducer/Strangeness/sigma0builder.cxx +++ b/PWGLF/TableProducer/Strangeness/sigma0builder.cxx @@ -54,22 +54,20 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -using std::cout; -using std::endl; using dauTracks = soa::Join; -using V0DerivedMCDatas = soa::Join; -using V0MLDerivedDatas = soa::Join; -using V0StandardDerivedDatas = soa::Join; +using V0DerivedMCDatas = soa::Join; +using V0MLDerivedDatas = soa::Join; +using V0StandardDerivedDatas = soa::Join; struct sigma0builder { SliceCache cache; - Produces v0sigma0Coll; // characterises collisions - Produces v0Sigma0CollRefs; // characterises collisions - Produces v0Sigmas; // save sigma0 candidates for analysis - Produces v0SigmaPhotonExtras; // save sigma0 candidates for analysis - Produces v0SigmaLambdaExtras; // save sigma0 candidates for analysis - Produces v0MCSigmas; + Produces sigma0Coll; // characterises collisions + Produces sigma0CollRefs; // characterises collisions + Produces sigma0cores; // save sigma0 candidates for analysis + Produces sigmaPhotonExtras; // save sigma0 candidates for analysis + Produces sigmaLambdaExtras; // save sigma0 candidates for analysis + Produces sigma0mccores; // For manual sliceBy Preslice perCollisionMCDerived = o2::aod::v0data::straCollisionId; @@ -86,45 +84,134 @@ struct sigma0builder { // For standard approach: //// Lambda criteria: - Configurable LambdaDauPseudoRap{"LambdaDauPseudoRap", 1.0, "Max pseudorapidity of daughter tracks"}; - Configurable LambdaMinDCANegToPv{"LambdaMinDCANegToPv", .01, "min DCA Neg To PV (cm)"}; - Configurable LambdaMinDCAPosToPv{"LambdaMinDCAPosToPv", .01, "min DCA Pos To PV (cm)"}; + 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)"}; Configurable LambdaMaxDCAV0Dau{"LambdaMaxDCAV0Dau", 3.5, "Max DCA V0 Daughters (cm)"}; - Configurable LambdaMinv0radius{"LambdaMinv0radius", 0.1, "Min V0 radius (cm)"}; - Configurable LambdaMaxv0radius{"LambdaMaxv0radius", 200, "Max V0 radius (cm)"}; - Configurable LambdaWindow{"LambdaWindow", 0.01, "Mass window around expected (in GeV/c2)"}; + Configurable LambdaMinv0radius{"LambdaMinv0radius", 0.0, "Min V0 radius (cm)"}; + Configurable LambdaMaxv0radius{"LambdaMaxv0radius", 60, "Max V0 radius (cm)"}; + Configurable LambdaWindow{"LambdaWindow", 0.05, "Mass window around expected (in GeV/c2)"}; //// Photon criteria: - Configurable PhotonMaxDauPseudoRap{"PhotonMaxDauPseudoRap", 1.0, "Max pseudorapidity of daughter tracks"}; - Configurable PhotonMinDCAToPv{"PhotonMinDCAToPv", 0.001, "Min DCA daughter To PV (cm)"}; - Configurable PhotonMaxDCAV0Dau{"PhotonMaxDCAV0Dau", 3.0, "Max DCA V0 Daughters (cm)"}; - Configurable PhotonMinRadius{"PhotonMinRadius", 0.5, "Min photon conversion radius (cm)"}; - Configurable PhotonMaxRadius{"PhotonMaxRadius", 250, "Max photon conversion radius (cm)"}; + Configurable PhotonMaxDauPseudoRap{"PhotonMaxDauPseudoRap", 1.5, "Max pseudorapidity of daughter tracks"}; + Configurable PhotonMinDCAToPv{"PhotonMinDCAToPv", 0.0, "Min DCA daughter To PV (cm)"}; + Configurable PhotonMaxDCAV0Dau{"PhotonMaxDCAV0Dau", 3.5, "Max DCA V0 Daughters (cm)"}; + Configurable PhotonMinRadius{"PhotonMinRadius", 0.0, "Min photon conversion radius (cm)"}; + Configurable PhotonMaxRadius{"PhotonMaxRadius", 240, "Max photon conversion radius (cm)"}; Configurable PhotonMaxMass{"PhotonMaxMass", 0.3, "Max photon mass (GeV/c^{2})"}; //// Sigma0 criteria: - Configurable Sigma0Window{"Sigma0Window", 0.05, "Mass window around expected (in GeV/c2)"}; + Configurable Sigma0Window{"Sigma0Window", 0.1, "Mass window around expected (in GeV/c2)"}; + Configurable SigmaMaxRap{"SigmaMaxRap", 0.8, "Max sigma0 rapidity"}; // Axis // base properties - ConfigurableAxis vertexZ{"vertexZ", {30, -15.0f, 15.0f}, ""}; + 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 axisLambdaMass{"axisLambdaMass", {200, 1.05f, 1.151f}, "M_{#Lambda} (GeV/c^{2})"}; + ConfigurableAxis axisPhotonMass{"axisPhotonMass", {600, -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 + ConfigurableAxis axisTPCrows{"axisTPCrows", {160, 0.0f, 160.0f}, "N TPC rows"}; + + // topological variable QA axes + ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {500, 0.0f, 50.0f}, "DCA (cm)"}; + ConfigurableAxis axisDCAdau{"axisDCAdau", {50, 0.0f, 5.0f}, "DCA (cm)"}; + ConfigurableAxis axisRadius{"axisRadius", {240, 0.0f, 120.0f}, "V0 radius (cm)"}; + ConfigurableAxis axisRapidity{"axisRapidity", {100, -2.0f, 2.0f}, "Rapidity"}; + ConfigurableAxis axisCandSel{"axisCandSel", {13, 0.5f, +13.5f}, "Candidate Selection"}; int nSigmaCandidates = 0; void init(InitContext const&) { // Event counter - histos.add("hEventVertexZ", "hEventVertexZ", kTH1F, {vertexZ}); - histos.add("hCandidateBuilderSelection", "hCandidateBuilderSelection", kTH1F, {{11, -0.5f, +10.5f}}); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(1, "Photon Mass Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(2, "Photon DauEta Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(3, "Photon DCAToPV Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(4, "Photon DCADau Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(5, "Photon Radius Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(6, "Lambda Mass Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(7, "Lambda DauEta Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(8, "Lambda DCAToPV Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(9, "Lambda Radius Cut"); - histos.get(HIST("hCandidateBuilderSelection"))->GetXaxis()->SetBinLabel(10, "Lambda DCADau Cut"); + 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}); + + // 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}); + + // 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}}); + + histos.add("h3dMassSigmasBeforeSel", "h3dMassSigmasBeforeSel", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + histos.add("h3dMassSigmasAfterSel", "h3dMassSigmasAfterSel", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); } // Process sigma candidate and store properties in object @@ -134,6 +221,10 @@ struct sigma0builder { 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())) + return false; + if constexpr ( requires { gamma.gammaBDTScore(); } && requires { lambda.lambdaBDTScore(); } && @@ -151,48 +242,112 @@ struct sigma0builder { } else { // Standard selection // Gamma basic selection criteria: - if (TMath::Abs(gamma.mGamma()) > PhotonMaxMass) + histos.fill(HIST("hCandidateBuilderSelection"), 1.); + histos.fill(HIST("Selection/hPhotonMass"), gamma.mGamma()); + if ((gamma.mGamma() < 0) || (gamma.mGamma() > PhotonMaxMass)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 0.); + 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)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 1.); + histos.fill(HIST("Selection/hPhotonDCANegToPV"), TMath::Abs(gamma.dcanegtopv())); + histos.fill(HIST("Selection/hPhotonDCAPosToPV"), TMath::Abs(gamma.dcapostopv())); + histos.fill(HIST("hCandidateBuilderSelection"), 3.); if ((TMath::Abs(gamma.dcapostopv()) < PhotonMinDCAToPv) || (TMath::Abs(gamma.dcanegtopv()) < PhotonMinDCAToPv)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 2.); + histos.fill(HIST("Selection/hPhotonDCADau"), TMath::Abs(gamma.dcaV0daughters())); + histos.fill(HIST("hCandidateBuilderSelection"), 4.); if (TMath::Abs(gamma.dcaV0daughters()) > PhotonMaxDCAV0Dau) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 3.); + histos.fill(HIST("Selection/hPhotonRadius"), gamma.v0radius()); + histos.fill(HIST("hCandidateBuilderSelection"), 5.); if ((gamma.v0radius() < PhotonMinRadius) || (gamma.v0radius() > PhotonMaxRadius)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 4.); + histos.fill(HIST("hCandidateBuilderSelection"), 6.); + histos.fill(HIST("Selection/hLambdaMass"), lambda.mLambda()); + histos.fill(HIST("Selection/hAntiLambdaMass"), lambda.mAntiLambda()); // Lambda basic selection criteria: - if (TMath::Abs(lambda.mLambda() - 1.115683) > LambdaWindow) + if ((TMath::Abs(lambda.mLambda() - 1.115683) > LambdaWindow) && (TMath::Abs(lambda.mAntiLambda() - 1.115683) > LambdaWindow)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 5.); + 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)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 6.); + histos.fill(HIST("Selection/hLambdaDCANegToPV"), lambda.dcanegtopv()); + histos.fill(HIST("Selection/hLambdaDCAPosToPV"), lambda.dcapostopv()); + histos.fill(HIST("hCandidateBuilderSelection"), 8.); if ((TMath::Abs(lambda.dcapostopv()) < LambdaMinDCAPosToPv) || (TMath::Abs(lambda.dcanegtopv()) < LambdaMinDCANegToPv)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 7.); + histos.fill(HIST("Selection/hLambdaRadius"), lambda.v0radius()); + histos.fill(HIST("hCandidateBuilderSelection"), 9.); if ((lambda.v0radius() < LambdaMinv0radius) || (lambda.v0radius() > LambdaMaxv0radius)) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 8.); - if (lambda.dcaV0daughters() > LambdaMaxDCAV0Dau) + histos.fill(HIST("Selection/hLambdaDCADau"), lambda.dcaV0daughters()); + histos.fill(HIST("hCandidateBuilderSelection"), 10.); + if (TMath::Abs(lambda.dcaV0daughters()) > LambdaMaxDCAV0Dau) return false; - histos.fill(HIST("hCandidateBuilderSelection"), 9.); + histos.fill(HIST("hCandidateBuilderSelection"), 11.); } // 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 SigmapT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); + + 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(); }) { + + histos.fill(HIST("MC/h2dPtVsMassSigma_All"), SigmapT, sigmamass); + + // 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 (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.); + + if (TMath::Abs(sigmarap) > SigmaMaxRap) + return false; + + histos.fill(HIST("hCandidateBuilderSelection"), 13.); return true; } // Helper struct to pass v0 information @@ -200,6 +355,9 @@ struct sigma0builder { float mass; float pT; float Rapidity; + float OPAngle; + float DeltaEta; + float DeltaPhi; } sigmaCandidate; // Fill tables with reconstructed sigma0 candidate @@ -221,19 +379,6 @@ struct sigma0builder { AntiLambdaBDTScore = lambda.antiLambdaBDTScore(); } - // 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}; - sigmaCandidate.mass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); - sigmaCandidate.pT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); - sigmaCandidate.Rapidity = RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0); - - // Sigma related - float fSigmapT = sigmaCandidate.pT; - float fSigmaMass = sigmaCandidate.mass; - float fSigmaRap = sigmaCandidate.Rapidity; - // Daughters related /// Photon auto posTrackGamma = gamma.template posTrackExtra_as(); @@ -251,6 +396,7 @@ struct sigma0builder { float fPhotonZconv = gamma.z(); 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(); uint8_t fPhotonPosTPCCrossedRows = posTrackGamma.tpcCrossedRows(); @@ -274,6 +420,7 @@ struct sigma0builder { float fLambdaPt = lambda.pt(); float fLambdaMass = lambda.mLambda(); + float fAntiLambdaMass = lambda.mAntiLambda(); float fLambdaQt = lambda.qtarm(); float fLambdaAlpha = lambda.alpha(); float fLambdaRadius = lambda.v0radius(); @@ -283,10 +430,17 @@ struct sigma0builder { float fLambdaDCAPosPV = lambda.dcapostopv(); float fLambdaEta = lambda.eta(); float fLambdaY = lambda.yLambda(); + float fLambdaPhi = RecoDecay::phi(lambda.px(), lambda.py()); float fLambdaPosPrTPCNSigma = posTrackLambda.tpcNSigmaPr(); float fLambdaPosPiTPCNSigma = posTrackLambda.tpcNSigmaPi(); float fLambdaNegPrTPCNSigma = negTrackLambda.tpcNSigmaPr(); float fLambdaNegPiTPCNSigma = negTrackLambda.tpcNSigmaPi(); + + float fLambdaPrTOFNSigma = lambda.tofNSigmaLaPr(); + float fLambdaPiTOFNSigma = lambda.tofNSigmaLaPi(); + float fALambdaPrTOFNSigma = lambda.tofNSigmaALaPr(); + float fALambdaPiTOFNSigma = lambda.tofNSigmaALaPi(); + uint8_t fLambdaPosTPCCrossedRows = posTrackLambda.tpcCrossedRows(); uint8_t fLambdaNegTPCCrossedRows = negTrackLambda.tpcCrossedRows(); float fLambdaPosPt = lambda.positivept(); @@ -303,28 +457,51 @@ struct sigma0builder { uint32_t fLambdaNegITSClSize = negTrackLambda.itsClusterSizes(); uint8_t fLambdaV0Type = lambda.v0Type(); + // 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}; + TVector3 v1(gamma.px(), gamma.py(), gamma.pz()); + TVector3 v2(lambda.px(), lambda.py(), lambda.pz()); + + sigmaCandidate.mass = RecoDecay::m(arrMom, std::array{o2::constants::physics::MassPhoton, o2::constants::physics::MassLambda0}); + sigmaCandidate.pT = RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()}); + sigmaCandidate.Rapidity = RecoDecay::y(std::array{gamma.px() + lambda.px(), gamma.py() + lambda.py(), gamma.pz() + lambda.pz()}, o2::constants::physics::MassSigma0); + sigmaCandidate.OPAngle = v1.Angle(v2); + sigmaCandidate.DeltaEta = fLambdaEta - fPhotonEta; + sigmaCandidate.DeltaPhi = fLambdaPhi - fPhotonPhi; + + // Sigma related + float fSigmapT = sigmaCandidate.pT; + float fSigmaMass = sigmaCandidate.mass; + float fSigmaRap = sigmaCandidate.Rapidity; + float fSigmaOPAngle = sigmaCandidate.OPAngle; + float fSigmaDeltaEta = sigmaCandidate.DeltaEta; + float fSigmaDeltaPhi = sigmaCandidate.DeltaPhi; + // Filling TTree for ML analysis - v0Sigmas(fSigmapT, fSigmaMass, fSigmaRap); - - v0SigmaPhotonExtras(fPhotonPt, fPhotonMass, fPhotonQt, fPhotonAlpha, fPhotonRadius, - fPhotonCosPA, fPhotonDCADau, fPhotonDCANegPV, fPhotonDCAPosPV, fPhotonZconv, - fPhotonEta, fPhotonY, fPhotonPosTPCNSigma, fPhotonNegTPCNSigma, fPhotonPosTPCCrossedRows, - fPhotonNegTPCCrossedRows, fPhotonPosPt, fPhotonNegPt, fPhotonPosEta, - fPhotonNegEta, fPhotonPosY, fPhotonNegY, fPhotonPsiPair, - fPhotonPosITSCls, fPhotonNegITSCls, fPhotonPosITSClSize, fPhotonNegITSClSize, - fPhotonV0Type, GammaBDTScore); - - v0SigmaLambdaExtras(fLambdaPt, fLambdaMass, fLambdaQt, fLambdaAlpha, - fLambdaRadius, fLambdaCosPA, fLambdaDCADau, fLambdaDCANegPV, - fLambdaDCAPosPV, fLambdaEta, fLambdaY, fLambdaPosPrTPCNSigma, - fLambdaPosPiTPCNSigma, fLambdaNegPrTPCNSigma, fLambdaNegPiTPCNSigma, fLambdaPosTPCCrossedRows, - fLambdaNegTPCCrossedRows, fLambdaPosPt, fLambdaNegPt, fLambdaPosEta, - fLambdaNegEta, fLambdaPosPrY, fLambdaPosPiY, fLambdaNegPrY, fLambdaNegPiY, - fLambdaPosITSCls, fLambdaNegITSCls, fLambdaPosITSClSize, fLambdaNegITSClSize, - fLambdaV0Type, LambdaBDTScore, AntiLambdaBDTScore); + sigma0cores(fSigmapT, fSigmaMass, fSigmaRap, fSigmaOPAngle, fSigmaDeltaEta, fSigmaDeltaPhi); + + sigmaPhotonExtras(fPhotonPt, fPhotonMass, fPhotonQt, fPhotonAlpha, fPhotonRadius, + fPhotonCosPA, fPhotonDCADau, fPhotonDCANegPV, fPhotonDCAPosPV, fPhotonZconv, + fPhotonEta, fPhotonY, fPhotonPhi, fPhotonPosTPCNSigma, fPhotonNegTPCNSigma, fPhotonPosTPCCrossedRows, + fPhotonNegTPCCrossedRows, fPhotonPosPt, fPhotonNegPt, fPhotonPosEta, + fPhotonNegEta, fPhotonPosY, fPhotonNegY, fPhotonPsiPair, + fPhotonPosITSCls, fPhotonNegITSCls, fPhotonPosITSClSize, fPhotonNegITSClSize, + fPhotonV0Type, GammaBDTScore); + + sigmaLambdaExtras(fLambdaPt, fLambdaMass, fAntiLambdaMass, fLambdaQt, fLambdaAlpha, + 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, + fLambdaV0Type, LambdaBDTScore, AntiLambdaBDTScore); } - void processMonteCarlo(aod::StraCollisions const& collisions, V0DerivedMCDatas const& V0s, dauTracks const&) + void processMonteCarlo(soa::Join const& collisions, V0DerivedMCDatas const& V0s) { for (const auto& coll : collisions) { // Do analysis with collision-grouped V0s, retain full collision information @@ -332,16 +509,91 @@ struct sigma0builder { auto V0Table_thisCollision = V0s.sliceBy(perCollisionMCDerived, collIdx); // V0 table sliced - for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 + for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 + float centrality = coll.centFT0C(); + + // Auxiliary histograms: + if (gamma.pdgCode() == 22) { + float GammaY = TMath::Abs(RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassGamma)); + + 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 + + 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 + } + } + } + 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()); + } + } + } + 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 + } + } + } + for (auto& lambda : V0Table_thisCollision) { // selecting lambdas from Sigma0 - if (!processSigmaCandidate(lambda, gamma)) + // 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)); + + 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; bool fIsSigma = false; - if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == 3212) && (lambda.pdgCode() == 3122) && (lambda.pdgCodeMother() == 3212) && (gamma.motherMCPartId() == lambda.motherMCPartId())) + 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; - - v0MCSigmas(fIsSigma); + histos.fill(HIST("MC/h2dPtVsCentrality_Sigma0AfterSel"), centrality, RecoDecay::pt(array{gamma.px() + lambda.px(), gamma.py() + lambda.py()})); + } + if ((gamma.pdgCode() == 22) && (gamma.pdgCodeMother() == -3212) && (lambda.pdgCode() == -3122) && (lambda.pdgCodeMother() == -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 + } + 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); } } } @@ -354,21 +606,32 @@ struct sigma0builder { const uint64_t collIdx = coll.globalIndex(); auto V0Table_thisCollision = V0s.sliceBy(perCollisionSTDDerived, collIdx); - histos.fill(HIST("hEventVertexZ"), coll.posZ()); - v0sigma0Coll(coll.posX(), coll.posY(), coll.posZ(), coll.centFT0M(), coll.centFT0A(), coll.centFT0C(), coll.centFV0A()); + histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + sigma0Coll(coll.posX(), coll.posY(), coll.posZ(), coll.centFT0M(), coll.centFT0A(), coll.centFT0C(), coll.centFV0A()); // V0 table sliced for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 for (auto& lambda : V0Table_thisCollision) { // selecting lambdas from Sigma0 + 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); + if (!processSigmaCandidate(lambda, gamma)) // applying selection for reconstruction continue; + histos.fill(HIST("h3dMassSigmasAfterSel"), coll.centFT0C(), SigmapT, SigmaMass); + + sigma0CollRefs(collIdx); + fillTables(lambda, gamma); // filling tables with accepted candidates + nSigmaCandidates++; if (nSigmaCandidates % 5000 == 0) { LOG(info) << "Sigma0 Candidates built: " << nSigmaCandidates; } - v0Sigma0CollRefs(v0sigma0Coll.lastIndex()); - fillTables(lambda, gamma); // filling tables with accepted candidates } } } @@ -381,8 +644,8 @@ struct sigma0builder { const uint64_t collIdx = coll.globalIndex(); auto V0Table_thisCollision = V0s.sliceBy(perCollisionMLDerived, collIdx); - histos.fill(HIST("hEventVertexZ"), coll.posZ()); - v0sigma0Coll(coll.posX(), coll.posY(), coll.posZ(), coll.centFT0M(), coll.centFT0A(), coll.centFT0C(), coll.centFV0A()); + histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + sigma0Coll(coll.posX(), coll.posY(), coll.posZ(), coll.centFT0M(), coll.centFT0A(), coll.centFT0C(), coll.centFV0A()); // V0 table sliced for (auto& gamma : V0Table_thisCollision) { // selecting photons from Sigma0 @@ -394,7 +657,7 @@ struct sigma0builder { if (nSigmaCandidates % 5000 == 0) { LOG(info) << "Sigma0 Candidates built: " << nSigmaCandidates; } - v0Sigma0CollRefs(v0sigma0Coll.lastIndex()); + sigma0CollRefs(collIdx); fillTables(lambda, gamma); // filling tables with accepted candidates } } diff --git a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx index e6bfeee0ced..ee8db63d0a6 100644 --- a/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangederivedbuilder.cxx @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/RunningWorkflowInfo.h" @@ -58,6 +60,7 @@ using TracksWithExtra = soa::Join; using FullTracksExtIUTOF = soa::Join; using FullCollisions = soa::Join; +using UDCollisionsFull = soa::Join; // simple bit checkers #define bitset(var, nbit) ((var) |= (1 << (nbit))) @@ -73,8 +76,7 @@ struct strangederivedbuilder { Produces strangeMCColl; // characterises collisions / MC Produces strangeMCMults; // characterises collisions / MC mults Produces strangeCents; // characterises collisions / centrality - Produces strangeRawCents; // characterises collisions / centrality - Produces strangeEvSels; // characterises collisions / sel8 selection + Produces strangeEvSels; // characterises collisions / centrality / sel8 selection Produces strangeStamps; // provides timestamps, run numbers Produces v0collref; // references collisions from V0s Produces casccollref; // references collisions from cascades @@ -112,6 +114,7 @@ struct strangederivedbuilder { Produces StraFV0AQVs; // FV0A Q-vector Produces StraTPCQVs; // TPC Q-vector Produces StraFT0CQVsEv; // events used to compute FT0C Q-vector (LF) + Produces StraZDCSP; // ZDC Sums and Products //__________________________________________________ // Generated binned data @@ -129,6 +132,10 @@ struct strangederivedbuilder { Produces v0FoundTags; Produces cascFoundTags; + //__________________________________________________ + // Debug + Produces straOrigin; + // histogram registry for bookkeeping HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -164,15 +171,28 @@ struct strangederivedbuilder { Configurable roundNSigmaVariables{"roundNSigmaVariables", false, "round NSigma variables"}; Configurable precisionNSigmas{"precisionNSigmas", 0.1f, "precision to keep NSigmas"}; - 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 fillRawZDC{"fillRawZDC", false, "Fill raw ZDC information for debug"}; - Configurable fillRawNTracksEta1{"fillRawNTracksEta1", true, "Fill raw NTracks |eta|<1 information for debug"}; - Configurable fillRawNTracksForCorrelation{"fillRawNTracksForCorrelation", true, "Fill raw NTracks for correlation cuts"}; - Configurable fillTOFInformation{"fillTOFInformation", true, "Fill Daughter Track TOF information"}; + struct : ConfigurableGroup { + 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 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 fillRawNTracksForCorrelation{"fillRawNTracksForCorrelation", true, "Fill raw NTracks for correlation cuts"}; + Configurable fillTOFInformation{"fillTOFInformation", true, "Fill Daughter Track TOF information"}; + } fillTruncationOptions; Configurable qaCentrality{"qaCentrality", false, "qa centrality flag: check base raw values"}; + struct : ConfigurableGroup { + ConfigurableAxis axisFT0A{"FT0Aamplitude", {100, 0.0f, 2000.0f}, "FT0Aamplitude"}; + ConfigurableAxis axisFT0C{"FT0Camplitude", {100, 0.0f, 2000.0f}, "FT0Camplitude"}; + ConfigurableAxis axisFV0A{"FV0Aamplitude", {100, 0.0f, 2000.0f}, "FV0Aamplitude"}; + ConfigurableAxis axisFDDA{"FDDAamplitude", {100, 0.0f, 2000.0f}, "FDDAamplitude"}; + ConfigurableAxis axisFDDC{"FDDCamplitude", {100, 0.0f, 2000.0f}, "FDDCamplitude"}; + ConfigurableAxis axisZNA{"ZNAamplitude", {100, 0.0f, 250.0f}, "ZNAamplitude"}; + ConfigurableAxis axisZNC{"ZNCamplitude", {100, 0.0f, 250.0f}, "ZNCamplitude"}; + } axisDetectors; // For manual sliceBy Preslice V0perCollision = o2::aod::v0data::collisionId; @@ -180,6 +200,7 @@ struct strangederivedbuilder { Preslice KFCascperCollision = o2::aod::cascdata::collisionId; Preslice TraCascperCollision = o2::aod::cascdata::collisionId; Preslice mcParticlePerMcCollision = o2::aod::mcparticle::mcCollisionId; + Preslice udCollisionsPerCollision = o2::aod::udcollision::collisionId; std::vector genK0Short; std::vector genLambda; @@ -211,8 +232,8 @@ struct strangederivedbuilder { // Creation of histograms: MC generated for (Int_t i = 0; i < nSpecies; i++) { - histos.add(Form("hGen%s", particleNames[i].data()), Form("hGen%s", particleNames[i].data()), kTH1D, {axisPt}); - histos.add(Form("h2dGen%s", particleNames[i].data()), Form("h2dGen%s", particleNames[i].data()), kTH2D, {axisCentrality, axisPt}); + histos.add(Form("hGenerated%s", particleNames[i].data()), Form("hGenerated%s", particleNames[i].data()), kTH1D, {axisPt}); + histos.add(Form("h2dGenerated%s", particleNames[i].data()), Form("h2dGenerated%s", particleNames[i].data()), kTH2D, {axisCentrality, axisPt}); } histos.add("h2dNVerticesVsCentrality", "h2dNVerticesVsCentrality", kTH2D, {axisCentrality, axisNVertices}); @@ -230,6 +251,14 @@ struct strangederivedbuilder { // for QA and test purposes auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1F, {axisRawCentrality}); + auto hFT0AMultVsFT0AUD = histos.add("hFT0AMultVsFT0AUD", "hFT0AMultVsFT0AUD; FT0-A Mult; FT0-A UD", kTH2F, {axisDetectors.axisFT0A, axisDetectors.axisFT0A}); + auto hFT0CMultVsFT0CUD = histos.add("hFT0CMultVsFT0CUD", "hFT0CMultVsFT0CUD; FT0-C Mult; FT0-C UD", kTH2F, {axisDetectors.axisFT0C, axisDetectors.axisFT0C}); + auto hFV0AMultVsFV0AUD = histos.add("hFV0AMultVsFV0AUD", "hFV0AMultVsFV0AUD; FV0-A Mult; FV0-A UD", kTH2F, {axisDetectors.axisFV0A, axisDetectors.axisFV0A}); + auto hFDDAMultVsFDDAUD = histos.add("hFDDAMultVsFDDAUD", "hFDDAMultVsFDDAUD; FDD-A Mult; FDD-A UD", kTH2F, {axisDetectors.axisFDDA, axisDetectors.axisFDDA}); + auto hFDDCMultVsFDDCUD = histos.add("hFDDCMultVsFDDCUD", "hFDDCMultVsFDDCUD; FDD-C Mult; FDD-C UD", kTH2F, {axisDetectors.axisFDDC, axisDetectors.axisFDDC}); + auto hZNAMultVsZNAUD = histos.add("hZNAMultVsZNAUD", "hZNAMultVsZNAUD; ZNA Mult; ZNA UD", kTH2F, {axisDetectors.axisZNA, axisDetectors.axisZNA}); + auto hZNCMultVsZNCUD = histos.add("hZNCMultVsZNCUD", "hZNCMultVsZNCUD; ZNC Mult; ZNC UD", kTH2F, {axisDetectors.axisZNC, axisDetectors.axisZNC}); + for (int ii = 1; ii < 101; ii++) { float value = 100.5f - static_cast(ii); hRawCentrality->SetBinContent(ii, value); @@ -237,7 +266,7 @@ struct strangederivedbuilder { if (doprocessBinnedGenerated) { // reserve space for generated vectors if that process enabled - auto hBinFinder = histos.get(HIST("h2dGenK0Short")); + auto hBinFinder = histos.get(HIST("h2dGeneratedK0Short")); LOGF(info, "Binned generated processing enabled. Initialising with %i elements...", hBinFinder->GetNcells()); genK0Short.resize(hBinFinder->GetNcells(), 0); genLambda.resize(hBinFinder->GetNcells(), 0); @@ -250,46 +279,9 @@ struct strangederivedbuilder { } } - void processCollisionsV0sOnly(soa::Join const& collisions, aod::V0Datas const& V0s, aod::BCsWithTimestamps const&) - { - for (const auto& collision : collisions) { - const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisColl = V0s.sliceBy(V0perCollision, collIdx); - bool strange = V0Table_thisColl.size() > 0; - // casc table sliced - if (strange || fillEmptyCollisions) { - strangeColl(collision.posX(), collision.posY(), collision.posZ()); - strangeCents(collision.centFT0M(), collision.centFT0A(), - collision.centFT0C(), collision.centFV0A()); - strangeEvSels(collision.sel8(), collision.selection_raw()); - auto bc = collision.bc_as(); - strangeStamps(bc.runNumber(), bc.timestamp()); - - if (fillRawFT0C || fillRawFT0C || fillRawFV0A || fillRawNTracksEta1 || fillRawZDC) { - strangeRawCents(collision.multFT0A() * static_cast(fillRawFT0A), - collision.multFT0C() * static_cast(fillRawFT0C), - collision.multFV0A() * static_cast(fillRawFV0A), - collision.multNTracksPVeta1() * static_cast(fillRawNTracksEta1), - collision.multPVTotalContributors() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksGlobal() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksTPCOnly() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multZNA() * static_cast(fillRawZDC), - collision.multZNC() * static_cast(fillRawZDC), - collision.multZEM1() * static_cast(fillRawZDC), - collision.multZEM2() * static_cast(fillRawZDC), - collision.multZPA() * static_cast(fillRawZDC), - collision.multZPC() * static_cast(fillRawZDC), - collision.trackOccupancyInTimeRange()); - } - } - for (int i = 0; i < V0Table_thisColl.size(); i++) - v0collref(strangeColl.lastIndex()); - } - } - - 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&) + // 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) { // create collision indices beforehand std::vector V0CollIndices(V0s.size(), -1); // index -1: no collision @@ -297,6 +289,7 @@ struct strangederivedbuilder { std::vector KFCascadeCollIndices(KFCascades.size(), -1); // index -1: no collision std::vector TraCascadeCollIndices(TraCascades.size(), -1); // index -1: no collision + // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ for (const auto& collision : collisions) { const uint64_t collIdx = collision.globalIndex(); @@ -314,35 +307,83 @@ struct strangederivedbuilder { CascTable_thisColl.size() > 0 || KFCascTable_thisColl.size() > 0 || TraCascTable_thisColl.size() > 0; - // casc table sliced + + auto bc = collision.template bc_as(); + + int gapSide = -1; + float totalFT0AmplitudeA = -999; + float totalFT0AmplitudeC = -999; + float totalFV0AmplitudeA = -999; + float totalFDDAmplitudeA = -999; + float totalFDDAmplitudeC = -999; + float energyCommonZNA = -999; + float energyCommonZNC = -999; + + // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + // set UD information in case present at this stage + auto udCollIterator = udCollisions.begin(); + if constexpr (requires { udCollIterator.gapSide(); }) { // check if this table is the expected one + auto udCollision = udCollisions.sliceBy(udCollisionsPerCollision, collIdx); + if (udCollision.size() == 1) { // check that the slicing provide a unique UD collision + for (auto& udColl : udCollision) { + gapSide = udColl.gapSide(); + totalFT0AmplitudeA = udColl.totalFT0AmplitudeA(); + totalFT0AmplitudeC = udColl.totalFT0AmplitudeC(); + totalFV0AmplitudeA = udColl.totalFV0AmplitudeA(); + totalFDDAmplitudeA = udColl.totalFDDAmplitudeA(); + totalFDDAmplitudeC = udColl.totalFDDAmplitudeC(); + energyCommonZNA = udColl.energyCommonZNA(); + energyCommonZNC = udColl.energyCommonZNC(); + + histos.fill(HIST("hFT0AMultVsFT0AUD"), collision.multFT0A(), udColl.totalFT0AmplitudeA()); + histos.fill(HIST("hFT0CMultVsFT0CUD"), collision.multFT0C(), udColl.totalFT0AmplitudeC()); + histos.fill(HIST("hFV0AMultVsFV0AUD"), collision.multFV0A(), udColl.totalFV0AmplitudeA()); + histos.fill(HIST("hFDDAMultVsFDDAUD"), collision.multFDDA(), udColl.totalFDDAmplitudeA()); + histos.fill(HIST("hFDDCMultVsFDDCUD"), collision.multFDDC(), udColl.totalFDDAmplitudeC()); + histos.fill(HIST("hZNAMultVsZNAUD"), collision.multZNA(), udColl.energyCommonZNA()); + histos.fill(HIST("hZNCMultVsZNCUD"), collision.multZNC(), udColl.energyCommonZNC()); + } + } + } + + // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ + // fill collision tables if (strange || fillEmptyCollisions) { 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()); - auto bc = collision.bc_as(); + 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()); strangeStamps(bc.runNumber(), bc.timestamp()); - - if (fillRawFT0C || fillRawFT0C || fillRawFV0A || fillRawNTracksEta1 || fillRawZDC) { - strangeRawCents(collision.multFT0A() * static_cast(fillRawFT0A), - collision.multFT0C() * static_cast(fillRawFT0C), - collision.multFV0A() * static_cast(fillRawFV0A), - collision.multNTracksPVeta1() * static_cast(fillRawNTracksEta1), - collision.multPVTotalContributors() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksGlobal() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksTPCOnly() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multZNA() * static_cast(fillRawZDC), - collision.multZNC() * static_cast(fillRawZDC), - collision.multZEM1() * static_cast(fillRawZDC), - collision.multZEM2() * static_cast(fillRawZDC), - collision.multZPA() * static_cast(fillRawZDC), - collision.multZPC() * static_cast(fillRawZDC), - collision.trackOccupancyInTimeRange()); - } } - for (const auto& v0 : V0Table_thisColl) V0CollIndices[v0.globalIndex()] = strangeColl.lastIndex(); for (const auto& casc : CascTable_thisColl) @@ -353,105 +394,58 @@ struct strangederivedbuilder { TraCascadeCollIndices[casc.globalIndex()] = strangeColl.lastIndex(); } + // +-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+ // populate references, including those that might not be assigned - for (const auto& v0 : V0s) + for (const auto& v0 : V0s) { v0collref(V0CollIndices[v0.globalIndex()]); - for (const auto& casc : Cascades) + } + for (const auto& casc : Cascades) { casccollref(CascadeCollIndices[casc.globalIndex()]); - for (const auto& casc : KFCascades) + } + for (const auto& casc : KFCascades) { kfcasccollref(KFCascadeCollIndices[casc.globalIndex()]); - for (const auto& casc : KFCascades) + } + for (const auto& casc : TraCascades) { tracasccollref(TraCascadeCollIndices[casc.globalIndex()]); + } } - void processCollisionsMC(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&, soa::Join const& mcCollisions, aod::McParticles const&) + // master function to process a collision + template + void populateMCCollisionTable(mccoll const& mcCollisions) { - // create collision indices beforehand - std::vector V0CollIndices(V0s.size(), -1); // index -1: no collision - std::vector V0MCCollIndices(V0s.size(), -1); // index -1: no collision - std::vector CascadeCollIndices(Cascades.size(), -1); // index -1: no collision - std::vector CascadeMCCollIndices(Cascades.size(), -1); // index -1: no collision - std::vector KFCascadeCollIndices(KFCascades.size(), -1); // index -1: no collision - std::vector TraCascadeCollIndices(TraCascades.size(), -1); // index -1: no collision - // ______________________________________________ // fill all MC collisions, correlate via index later on for (const auto& mccollision : mcCollisions) { - strangeMCColl(mccollision.posX(), mccollision.posY(), mccollision.posZ(), mccollision.impactParameter()); + strangeMCColl(mccollision.posX(), mccollision.posY(), mccollision.posZ(), + mccollision.impactParameter(), mccollision.eventPlaneAngle()); strangeMCMults(mccollision.multMCFT0A(), mccollision.multMCFT0C(), mccollision.multMCNParticlesEta05(), mccollision.multMCNParticlesEta08(), mccollision.multMCNParticlesEta10()); } + } - // ______________________________________________ - 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())); - } + 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*/) + { + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades); + } - auto V0Table_thisColl = V0s.sliceBy(V0perCollision, collIdx); - auto CascTable_thisColl = Cascades.sliceBy(CascperCollision, collIdx); - auto KFCascTable_thisColl = KFCascades.sliceBy(KFCascperCollision, collIdx); - auto TraCascTable_thisColl = TraCascades.sliceBy(TraCascperCollision, collIdx); - bool strange = V0Table_thisColl.size() > 0 || - CascTable_thisColl.size() > 0 || - KFCascTable_thisColl.size() > 0 || - TraCascTable_thisColl.size() > 0; - // casc table sliced - if (strange || fillEmptyCollisions) { - strangeColl(collision.posX(), collision.posY(), collision.posZ()); - strangeCollLabels(collision.mcCollisionId()); - strangeCents(collision.centFT0M(), collision.centFT0A(), - centrality, collision.centFV0A()); - strangeEvSels(collision.sel8(), collision.selection_raw()); - auto bc = collision.bc_as(); - strangeStamps(bc.runNumber(), bc.timestamp()); + 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) + { + populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades); + } - if (fillRawFT0C || fillRawFT0C || fillRawFV0A || fillRawNTracksEta1 || fillRawZDC) { - strangeRawCents(collision.multFT0A() * static_cast(fillRawFT0A), - collision.multFT0C() * static_cast(fillRawFT0C), - collision.multFV0A() * static_cast(fillRawFV0A), - collision.multNTracksPVeta1() * static_cast(fillRawNTracksEta1), - collision.multPVTotalContributors() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksGlobal() * static_cast(fillRawNTracksForCorrelation), - collision.multNTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksTPCOnly() * static_cast(fillRawNTracksForCorrelation), - collision.multAllTracksITSTPC() * static_cast(fillRawNTracksForCorrelation), - collision.multZNA() * static_cast(fillRawZDC), - collision.multZNC() * static_cast(fillRawZDC), - collision.multZEM1() * static_cast(fillRawZDC), - collision.multZEM2() * static_cast(fillRawZDC), - collision.multZPA() * static_cast(fillRawZDC), - collision.multZPC() * static_cast(fillRawZDC), - collision.trackOccupancyInTimeRange()); - } - } - for (const auto& v0 : V0Table_thisColl) - V0CollIndices[v0.globalIndex()] = strangeColl.lastIndex(); - for (const auto& casc : CascTable_thisColl) - CascadeCollIndices[casc.globalIndex()] = strangeColl.lastIndex(); - for (const auto& casc : KFCascTable_thisColl) - KFCascadeCollIndices[casc.globalIndex()] = strangeColl.lastIndex(); - for (const auto& casc : TraCascTable_thisColl) - TraCascadeCollIndices[casc.globalIndex()] = strangeColl.lastIndex(); - } + 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&) + { + populateMCCollisionTable(mcCollisions); + populateCollisionTables(collisions, collisions, V0s, Cascades, KFCascades, TraCascades); + } - // populate references, including those that might not be assigned - for (const auto& v0 : V0s) { - v0collref(V0CollIndices[v0.globalIndex()]); - } - for (const auto& casc : Cascades) { - casccollref(CascadeCollIndices[casc.globalIndex()]); - } - for (const auto& casc : KFCascades) - kfcasccollref(KFCascadeCollIndices[casc.globalIndex()]); - for (const auto& casc : KFCascades) - tracasccollref(TraCascadeCollIndices[casc.globalIndex()]); + 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&) + { + populateMCCollisionTable(mcCollisions); + populateCollisionTables(collisions, udCollisions, V0s, Cascades, KFCascades, TraCascades); } void processTrackExtrasV0sOnly(aod::V0Datas const& V0s, TracksWithExtra const& tracksExtra) @@ -470,7 +464,7 @@ struct strangederivedbuilder { // Figure out the numbering of the new tracks table // assume filling per order int nTracks = 0; - for (int i = 0; i < trackMap.size(); i++) { + for (int i = 0; i < static_cast(trackMap.size()); i++) { if (trackMap[i] >= 0) { trackMap[i] = nTracks++; } @@ -545,7 +539,7 @@ struct strangederivedbuilder { // Figure out the numbering of the new tracks table // assume filling per order int nTracks = 0; - for (int i = 0; i < trackMap.size(); i++) { + for (int i = 0; i < static_cast(trackMap.size()); i++) { if (trackMap[i] >= 0) { trackMap[i] = nTracks++; } @@ -637,7 +631,7 @@ struct strangederivedbuilder { // Figure out the numbering of the new mcMother table // assume filling per order int nParticles = 0; - for (int i = 0; i < motherReference.size(); i++) { + for (int i = 0; i < static_cast(motherReference.size()); i++) { if (motherReference[i] >= 0) { motherReference[i] = nParticles++; // count particles of interest } @@ -710,7 +704,7 @@ struct strangederivedbuilder { static_for<0, nSpecies - 1>([&](auto i) { constexpr int index = i.value; if (mcp.pdgCode() == particlePDGCodes[index] && bitcheck(enabledBits, index)) { - histos.fill(HIST("hGen") + HIST(particleNamesConstExpr[index]), mcp.pt()); + histos.fill(HIST("hGenerated") + HIST(particleNamesConstExpr[index]), mcp.pt()); } }); } @@ -740,7 +734,7 @@ struct strangederivedbuilder { static_for<0, nSpecies - 1>([&](auto i) { constexpr int index = i.value; if (mcp.pdgCode() == particlePDGCodes[index] && bitcheck(enabledBits, index)) { - histos.fill(HIST("h2dGen") + HIST(particleNamesConstExpr[index]), bestCentrality, mcp.pt()); + histos.fill(HIST("h2dGenerated") + HIST(particleNamesConstExpr[index]), bestCentrality, mcp.pt()); } }); } @@ -763,7 +757,7 @@ struct strangederivedbuilder { const uint64_t mcCollIndex = mcCollision.globalIndex(); // use one of the generated histograms as the bin finder - auto hBinFinder = histos.get(HIST("h2dGenK0Short")); + auto hBinFinder = histos.get(HIST("h2dGeneratedK0Short")); auto mcParticles = mcParticlesEntireTable.sliceBy(mcParticlePerMcCollision, mcCollIndex); for (auto& mcp : mcParticles) { @@ -810,6 +804,10 @@ struct strangederivedbuilder { StraFT0CQVs(collision.qFT0C() * std::cos(2 * collision.psiFT0C()), collision.qFT0C() * std::sin(2 * collision.psiFT0C()), collision.qFT0C()); StraFT0CQVsEv(collision.triggereventep()); } + void processZDCSP(soa::Join::iterator const& collision) + { + StraZDCSP(collision.triggereventsp(), collision.psiZDCA(), collision.psiZDCC()); + } void processFT0MQVectors(soa::Join::iterator const& collision) { StraFT0MQVs(collision.qvecFT0MRe(), collision.qvecFT0MIm(), collision.sumAmplFT0M()); @@ -829,7 +827,7 @@ struct strangederivedbuilder { uint64_t combineProngIndices(uint32_t low, uint32_t high) { - return (((uint64_t)high) << 32) | ((uint64_t)low); + return ((static_cast(high)) << 32) | (static_cast(low)); } void processV0FoundTags(aod::V0s const& foundV0s, aod::V0Datas const& findableV0s, aod::FindableV0s const& /* added to avoid troubles */) @@ -851,7 +849,7 @@ struct strangederivedbuilder { using uint128_t = __uint128_t; uint128_t combineProngIndices128(uint32_t pos, uint32_t neg, uint32_t bach) { - return (((uint128_t)pos) << 64) | (((uint128_t)neg) << 32) | ((uint128_t)bach); + return ((static_cast(pos)) << 64) | ((static_cast(neg)) << 32) | (static_cast(bach)); } void processCascFoundTags(aod::Cascades const& foundCascades, aod::CascDatas const& findableCascades, aod::V0s const&, aod::FindableCascades const& /* added to avoid troubles */) @@ -881,9 +879,22 @@ struct strangederivedbuilder { } } - PROCESS_SWITCH(strangederivedbuilder, processCollisionsV0sOnly, "Produce collisions (V0s only)", true); - PROCESS_SWITCH(strangederivedbuilder, processCollisions, "Produce collisions (V0s + casc)", true); - PROCESS_SWITCH(strangederivedbuilder, processCollisionsMC, "Produce collisions (V0s + casc)", false); + 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); + + // 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, processTrackExtrasMC, "Produce track extra information (V0s + casc)", false); @@ -902,6 +913,7 @@ struct strangederivedbuilder { PROCESS_SWITCH(strangederivedbuilder, processFV0AQVectors, "Produce FV0A Q-vectors table", false); 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); diff --git a/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx b/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx index 875d0f1c671..1d0c3e50187 100644 --- a/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx +++ b/PWGLF/TableProducer/Strangeness/v0qaanalysis.cxx @@ -248,7 +248,7 @@ struct LfV0qaanalysis { 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); + collision.centFT0M(), collision.centFV0A(), evFlag, v0.alpha(), v0.qtarm()); } } } @@ -294,7 +294,7 @@ struct LfV0qaanalysis { } auto v0mcparticle = v0.mcParticle(); - if (abs(v0mcparticle.y()) > 0.5f) { + if (std::abs(v0mcparticle.y()) > 0.5f) { continue; } @@ -360,7 +360,7 @@ struct LfV0qaanalysis { 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); + mcCollision.centFT0M(), cent, evFlag, v0.alpha(), v0.qtarm()); } } @@ -372,7 +372,7 @@ struct LfV0qaanalysis { continue; } - if (abs(mcParticle.y()) > 0.5f) { + if (std::abs(mcParticle.y()) > 0.5f) { continue; } @@ -432,7 +432,7 @@ struct LfV0qaanalysis { if (!mcParticle.isPhysicalPrimary()) { continue; } - if (abs(mcParticle.y()) > 0.5f) { + if (std::abs(mcParticle.y()) > 0.5f) { continue; } @@ -491,7 +491,7 @@ struct LfV0qaanalysis { continue; } - if (abs(mcParticle.y()) > 0.5f) { + if (std::abs(mcParticle.y()) > 0.5f) { continue; } @@ -543,7 +543,7 @@ struct LfV0qaanalysis { continue; } - if (abs(mcParticle.y()) > 0.5f) { + if (std::abs(mcParticle.y()) > 0.5f) { continue; } diff --git a/PWGLF/TableProducer/Strangeness/v0selector.cxx b/PWGLF/TableProducer/Strangeness/v0selector.cxx new file mode 100644 index 00000000000..454fce2c6da --- /dev/null +++ b/PWGLF/TableProducer/Strangeness/v0selector.cxx @@ -0,0 +1,261 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 to select V0s based on cuts +/// +/// \author Gijs van Weelden + +#include +#include +#include + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" + +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/RecoDecay.h" + +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/V0SelectorTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +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> 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> 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 massCuts{"massCuts", true, "Apply mass cuts"}; + Configurable competingMassCuts{"competingMassCuts", true, "Apply competing mass cuts"}; + Configurable> K0SMassLowVals{"K0SMassLowVals", {0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4}, "K0S mass cut lower values (MeV)"}; + Configurable> K0SMassHighVals{"K0SMassHighVals", {0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6}, "K0S mass cut upper values (MeV)"}; + Configurable> LambdaMassLowVals{"LambdaMassLowVals", {1.08, 1.08, 1.08, 1.08, 1.08, 1.08, 1.08, 1.08}, "Lambda mass cut lower values (MeV)"}; + Configurable> LambdaMassHighVals{"LambdaMassHighVals", {1.125, 1.125, 1.125, 1.125, 1.125, 1.125, 1.125, 1.125}, "Lambda mass cut upper values (MeV)"}; + Configurable> AntiLambdaMassLowVals{"AntiLambdaMassLowVals", {1.08, 1.08, 1.08, 1.08, 1.08, 1.08, 1.08, 1.08}, "AntiLambda mass cut lower values (MeV)"}; + 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> 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"}; + + void init(InitContext const&) + { + } + + template + bool K0SCuts(T const& collision, U const& v0) + { + 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 (TMath::Abs(v0.dcapostopv()) < K0SDCAVals->at(ptBin)) { + return false; + } + if (TMath::Abs(v0.dcanegtopv()) < K0SDCAVals->at(ptBin)) { + return false; + } + 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; + } + return true; + } + 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)) { + return false; + } + 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; + } + return true; + } + 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)) { + return false; + } + 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; + } + return true; + } + 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); + } + } + 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); + } + } + 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); + } + } + 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; + + if (candidateK0S + candidateLambda + candidateAntiLambda == 0) { + flag += aod::v0flags::FREJECTED; + } else if (randomSelection) { + flag += RandomlyReject(v0, flag) * aod::v0flags::FREJECTED; + } + v0FlagTable(flag); + } + } + PROCESS_SWITCH(V0SelectorTask, processV0, "flags V0 candidates as potential signal", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"v0-selector"})}; +} diff --git a/PWGLF/Tasks/CMakeLists.txt b/PWGLF/Tasks/CMakeLists.txt index 972d36a7251..f4c5eea7f02 100644 --- a/PWGLF/Tasks/CMakeLists.txt +++ b/PWGLF/Tasks/CMakeLists.txt @@ -13,6 +13,7 @@ add_subdirectory(QC) # PAGs +add_subdirectory(GlobalEventProperties) add_subdirectory(Nuspex) add_subdirectory(Resonances) add_subdirectory(Strangeness) diff --git a/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt b/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt new file mode 100644 index 00000000000..17bb6e42f65 --- /dev/null +++ b/PWGLF/Tasks/GlobalEventProperties/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + diff --git a/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx b/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx index ad3db4a7091..6d751cde7c1 100644 --- a/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx +++ b/PWGLF/Tasks/Nuspex/AngularCorrelationsInJets.cxx @@ -12,6 +12,8 @@ // author: Lars Jörgensen #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -29,103 +31,127 @@ #include "fastjet/AreaDefinition.hh" #include "fastjet/ClusterSequenceArea.hh" #include "fastjet/GhostedAreaSpec.hh" -#include "fastjet/Selector.hh" -#include "fastjet/tools/Subtractor.hh" -#include "fastjet/tools/JetMedianBackgroundEstimator.hh" +#include "PWGJE/Core/JetBkgSubUtils.h" #include "TVector2.h" -// #include "PWGJE/Core/JetFinder.h" -// #include "PWGJE/Core/JetFindingUtilities.h" +#include "TVector3.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 fMinNCrossedRowsTPC{"minNCrossedRowsTPC", 70, "min number of crossed rows TPC"}; Configurable fMinReqClusterITS{"minReqClusterITS", 2, "min number of clusters required in ITS"}; Configurable fMinReqClusterTPC{"minReqClusterTPC", 70, "min number of clusters required in TPC"}; - Configurable fMinRatioCrossedRowsTPC{"minRatioCrossedRowsTPC", 0.7f, "min ratio of crossed rows over findable clusters TPC"}; - Configurable fMaxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; - Configurable fMaxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; - Configurable fMaxDCAxy{"maxDCA_xy", 0.5f, "max DCA to vertex xy"}; - Configurable fMaxDCAz{"maxDCA_z", 2.4f, "max DCA to vertex z"}; + Configurable fMinRatioCrossedRowsTPC{"minRatioCrossedRowsTPC", 0.7, "min ratio of crossed rows over findable clusters TPC"}; + Configurable fMaxChi2ITS{"maxChi2ITS", 36.0, "max chi2 per cluster ITS"}; + Configurable fMaxChi2TPC{"maxChi2TPC", 4.0, "max chi2 per cluster TPC"}; + Configurable fMaxDCAxy{"maxDCA_xy", 0.5, "max DCA to vertex xy"}; + Configurable fMaxDCAz{"maxDCA_z", 1.0, "max DCA to vertex z"}; Configurable fMaxEta{"maxEta", 0.8, "max pseudorapidity"}; // consider jet cone? // Jet Cuts Configurable fJetR{"jetR", 0.4, "jet resolution parameter"}; - Configurable fMinJetPt{"minJetPt", 10.0, "minimum total pT to accept jet"}; + Configurable fMinJetPt{"minJetPt", 5.0, "minimum total pT to accept jet"}; Configurable fMinJetParticlePt{"minJetParticlePt", 0.0, "minimum pT to accept jet particle"}; - Configurable fMinLeadingPt{"minLeadingPt", 5.0, "minimum pT for leading track"}; // Proton Cuts - Configurable fProtonDCAxy{"protonDCAxy", 0.5, "[proton] DCAxy cut"}; - Configurable fProtonDCAz{"protonDCAz", 1.0, "[proton] DCAz cut"}; + Configurable fProtonDCAxyYield{"protonDCAxyYield", 0.05, "[proton] DCAxy cut for yield"}; + Configurable fProtonDCAzYield{"protonDCAzYield", 1.0, "[proton] DCAz cut for yield"}; + Configurable fProtonDCAxyCF{"protonDCAxyCF", 0.05, "[proton] DCAxy cut for CF"}; + Configurable fProtonDCAzCF{"protonDCAzCF", 1.0, "[proton] DCAz cut for CF"}; Configurable fProtonTPCTOFpT{"protonTPCTOFswitchpT", 0.7, "[proton] pT for switch in TPC/TOF nsigma"}; - Configurable fProtonTPCnsigLow{"protonTPCnsigmapTLow", 5.0, "[proton] max TPC nsigma with low pT"}; - Configurable fProtonTPCnsigHigh{"protonTPCnsigmapTHigh", 4.0, "[proton] max TPC nsigma with high pT"}; - Configurable fProtonTOFnsigLow{"protonTOFnsigmapTLow", 10.0, "[proton] max TOF nsigma with low pT"}; - Configurable fProtonTOFnsigHigh{"protonTOFnsigmapTHigh", 10.0, "[proton] max TOF nsigma with high pT"}; + Configurable fProtonTPCnsigLowYield{"protonTPCnsigmaLowPtYield", 4.0, "[proton] max TPC nsigma with low pT for yield"}; + Configurable fProtonTPCnsigHighYield{"protonTPCnsigmaHighPtYield", 4.0, "[proton] max TPC nsigma with high pT for yield"}; + Configurable fProtonTPCnsigLowCF{"protonTPCnsigmaLowPtCF", 2.0, "[proton] max TPC nsigma with low pT for CF"}; + Configurable fProtonTPCnsigHighCF{"protonTPCnsigmaHighPtCF", 3.0, "[proton] max TPC nsigma with high pT for CF"}; + Configurable fProtonTOFnsigYield{"protonTOFnsigmaHighPtYield", 4.0, "[proton] max TOF nsigma with high pT yield"}; + Configurable fProtonTOFnsigCF{"protonTOFnsigmaHighPtCF", 4.0, "[proton] max TOF nsigma for CF"}; // Antiproton Cuts - Configurable fAntiprotonDCAxy{"antiprotonDCAxy", 0.5, "[antiproton] DCAxy cut"}; - Configurable fAntiprotonDCAz{"antiprotonDCAz", 1.0, "[antiproton] DCAz cut"}; + Configurable fAntiprotonDCAxyYield{"antiprotonDCAxyYield", 0.05, "[antiproton] DCAxy cut for yield"}; + Configurable fAntiprotonDCAzYield{"antiprotonDCAzYield", 1.0, "[antiproton] DCAz cut for yield"}; + Configurable fAntiprotonDCAxyCF{"antiprotonDCAxyCF", 0.05, "[antiproton] DCAxy cut for CF"}; + Configurable fAntiprotonDCAzCF{"antiprotonDCAzCF", 1.0, "[antiproton] DCAz cut for CF"}; Configurable fAntiprotonTPCTOFpT{"antiprotonTPCTOFswitchpT", 0.7, "[antiproton] pT for switch in TPC/TOF nsigma"}; - Configurable fAntiprotonTPCnsigLow{"antiprotonTPCnsigmapTLow", 5.0, "[antiproton] max TPC nsigma with low pT"}; - Configurable fAntiprotonTPCnsigHigh{"antiprotonTPCnsigmapTHigh", 4.0, "[antiproton] max TPC nsigma with high pT"}; - Configurable fAntiprotonTOFnsigLow{"antiprotonTOFnsigmapTLow", 10.0, "[antiproton] max TOF nsigma with low pT"}; - Configurable fAntiprotonTOFnsigHigh{"antiprotonTOFnsigmapTHigh", 10.0, "[antiproton] max TOF nsigma with high pT"}; - - // Deuteron Cuts - Configurable fDeuteronDCAxy{"deuteronDCAxy", 0.5, "[deuteron] DCAxy cut"}; - Configurable fDeuteronDCAz{"deuteronDCAz", 1.0, "[deuteron] DCAz cut"}; - Configurable fDeuteronTPCTOFpT{"deuteronTPCTOFswitchpT", 0.7, "[deuteron] pT for switch in TPC/TOF nsigma"}; - Configurable fDeuteronTPCnsigLow{"deuteronTPCnsigmapTLow", 5.0, "[deuteron] max TPC nsigma with low pT"}; - Configurable fDeuteronTPCnsigHigh{"deuteronTPCnsigmapTHigh", 4.0, "[deuteron] max TPC nsigma with high pT"}; - Configurable fDeuteronTOFnsigLow{"deuteronTOFnsigmapTLow", 10.0, "[deuteron] max TOF nsigma with low pT"}; - Configurable fDeuteronTOFnsigHigh{"deuteronTOFnsigmapTHigh", 10.0, "[deuteron] max TOF nsigma with high pT"}; - - // Antideuteron Cuts - Configurable fAntideuteronDCAxy{"antideuteronDCAxy", 0.5, "[antideuteron] DCAxy cut"}; - Configurable fAntideuteronDCAz{"antideuteronDCAz", 1.0, "[antideuteron] DCAz cut"}; - Configurable fAntideuteronTPCTOFpT{"antideuteronTPCTOFswitchpT", 0.7, "[antideuteron] pT for switch in TPC/TOF nsigma"}; - Configurable fAntideuteronTPCnsigLow{"antideuteronTPCnsigmapTLow", 5.0, "[antideuteron] max TPC nsigma with low pT"}; - Configurable fAntideuteronTPCnsigHigh{"antideuteronTPCnsigmapTHigh", 4.0, "[antideuteron] max TPC nsigma with high pT"}; - Configurable fAntideuteronTOFnsigLow{"antideuteronTOFnsigmapTLow", 10.0, "[antideuteron] max TOF nsigma with low pT"}; - Configurable fAntideuteronTOFnsigHigh{"antideuteronTOFnsigmapTHigh", 10.0, "[antideuteron] max TOF nsigma with high pT"}; - - Configurable fTrackBufferSize{"trackBufferSize", 2000, "Number of mixed-event tracks being stored"}; + Configurable fAntiprotonTPCnsigLowYield{"antiprotonTPCnsigmaLowPtYield", 4.0, "[antiproton] max TPC nsigma with low pT for yield"}; + Configurable fAntiprotonTPCnsigHighYield{"antiprotonTPCnsigmaHighPtYield", 4.0, "[antiproton] max TPC nsigma with high pT for yield"}; + Configurable fAntiprotonTPCnsigLowCF{"antiprotonTPCnsigmaLowPtCF", 2.0, "[antiproton] max TPC nsigma with low pT for CF"}; + Configurable fAntiprotonTPCnsigHighCF{"antiprotonTPCnsigmaHighPtCF", 3.0, "[antiproton] max TPC nsigma with high pT for CF"}; + Configurable fAntiprotonTOFnsigYield{"antiprotonTOFnsigmaHighPtYield", 4.0, "[antiproton] min TOF nsigma with high pT for yield"}; + Configurable fAntiprotonTOFnsigCF{"antiprotonTOFnsigmaHighPtCF", 4.0, "[antiproton] max TOF nsigma for CF"}; + + // Nuclei Cuts + Configurable fNucleiDCAxyYield{"nucleiDCAxyYield", 0.05, "[nuclei] DCAxy cut for yield"}; + Configurable fNucleiDCAzYield{"nucleiDCAzYield", 1.0, "[nuclei] DCAz cut for yield"}; + Configurable fNucleiDCAxyCF{"nucleiDCAxyCF", 0.05, "[nuclei] DCAxy cut for CF"}; + Configurable fNucleiDCAzCF{"nucleiDCAzCF", 1.0, "[nuclei] DCAz cut for CF"}; + Configurable fNucleiTPCTOFpT{"nucleiTPCTOFswitchpT", 0.7, "[nuclei] pT for switch in TPC/TOF nsigma"}; + Configurable fNucleiTPCnsigLowYield{"nucleiTPCnsigmaLowPtYield", 4.0, "[nuclei] max TPC nsigma with low pT for yield"}; + Configurable fNucleiTPCnsigHighYield{"nucleiTPCnsigmaHighPtYield", 4.0, "[nuclei] max TPC nsigma with high pT for yield"}; + Configurable fNucleiTPCnsigLowCF{"nucleiTPCnsigmaLowPtCF", 2.0, "[nuclei] max TPC nsigma with low pT for CF"}; + Configurable fNucleiTPCnsigHighCF{"nucleiTPCnsigmaHighPtCF", 3.0, "[nuclei] max TPC nsigma with high pT for CF"}; + Configurable fNucleiTOFnsigYield{"nucleiTOFnsigmaHighPtYield", 4.0, "[nuclei] min TOF nsigma with high pT for yield"}; + Configurable fNucleiTOFnsigCF{"nucleiTOFnsigmaHighPtCF", 4.0, "[nuclei] max TOF nsigma for CF"}; + + // Antinuclei Cuts + Configurable fAntinucleiDCAxyYield{"antinucleiDCAxyYield", 0.05, "[antinuclei] DCAxy cut for yield"}; + Configurable fAntinucleiDCAzYield{"antinucleiDCAzYield", 1.0, "[antinuclei] DCAz cut for yield"}; + Configurable fAntinucleiDCAxyCF{"antinucleiDCAxyCF", 0.05, "[antinuclei] DCAxy cut for CF"}; + Configurable fAntinucleiDCAzCF{"antinucleiDCAzCF", 1.0, "[antinuclei] DCAz cut for CF"}; + Configurable fAntinucleiTPCTOFpT{"antinucleiTPCTOFswitchpT", 0.7, "[antinuclei] pT for switch in TPC/TOF nsigma"}; + Configurable fAntinucleiTPCnsigLowYield{"antinucleiTPCnsigmaLowPtYield", 4.0, "[antinuclei] max TPC nsigma with low pT for yield"}; + Configurable fAntinucleiTPCnsigHighYield{"antinucleiTPCnsigmaHighPtYield", 4.0, "[antinuclei] max TPC nsigma with high pT for yield"}; + Configurable fAntinucleiTPCnsigLowCF{"antinucleiTPCnsigmaLowPtCF", 2.0, "[antinuclei] max TPC nsigma with low pT for CF"}; + Configurable fAntinucleiTPCnsigHighCF{"antinucleiTPCnsigmaHighPtCF", 3.0, "[antinuclei] max TPC nsigma with high pT for CF"}; + Configurable fAntinucleiTOFnsigYield{"antinucleiTOFnsigmaHighPtYield", 4.0, "[antinuclei] min TOF nsigma with high pT for yield"}; + Configurable fAntinucleiTOFnsigCF{"antinucleiTOFnsigmaHighPtCF", 4.0, "[antinuclei] max TOF nsigma for CF"}; + Configurable fDeuteronAnalysis{"deuteronAnalysis", true, "true [false]: analyse (anti)deuterons [(anti)helium-3]"}; + Configurable fUseTOFMass{"useTOFmass", true, "use TOF mass instead of pion mass if available"}; + + Configurable fBufferSize{"trackBufferSize", 2000, "Number of mixed-event tracks being stored"}; + + // QC Configurables + Configurable fZVtx{"zVtx", 9999, "max zVertex"}; + Configurable fRmax{"Rmax", 0.4, "Maximum radius for jet and UE regions"}; Service ccdb; int mRunNumber; using FullTracksRun2 = soa::Join; + aod::TrackSelectionExtension, aod::TracksDCA, aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullHe, aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullHe, aod::pidTOFmass, aod::pidTOFbeta>; using FullTracksRun3 = soa::Join; + aod::TracksDCA, aod::pidTPCFullPr, aod::pidTPCFullDe, aod::pidTPCFullHe, aod::pidTOFFullPr, aod::pidTOFFullDe, aod::pidTOFFullHe, aod::pidTOFmass, aod::pidTOFbeta>; using BCsWithRun2Info = soa::Join; Filter prelimTrackCuts = (aod::track::itsChi2NCl < fMaxChi2ITS && aod::track::tpcChi2NCl < fMaxChi2TPC && nabs(aod::track::dcaXY) < fMaxDCAxy && nabs(aod::track::dcaZ) < fMaxDCAz && - nabs(aod::track::eta) < fMaxEta); + nabs(aod::track::eta) < fMaxEta); // add more preliminary cuts to filter if possible Preslice perCollisionFullTracksRun2 = o2::aod::track::collisionId; Preslice perCollisionFullTracksRun3 = o2::aod::track::collisionId; - AxisSpec ptAxis = {1000, 0, 100, "#it{p}_{T} [GeV/#it{c}]"}; - AxisSpec particleTypeAxis = {4, 1, 5, "[p, ap, d, ad]"}; - AxisSpec nsigmapTAxis = {1000, -50, 50, "#it{p}_{T} [GeV/#it{c}]"}; - AxisSpec nsigmaAxis = {1000, -5, 5, "n#sigma"}; - AxisSpec dcazAxis = {200, -3, 3, "DCA_{z} [cm]"}; - AxisSpec dcaxyAxis = {200, -2, 2, "DCA_{xy} [cm]"}; - AxisSpec angDistPhiAxis = {1000, -2, 5, "#Delta#varphi"}; - AxisSpec angDistEtaAxis = {1000, -2, 2, "#Delta#eta"}; + AxisSpecs axisSpecs; HistogramRegistry registryData{"dataOutput", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; HistogramRegistry registryQA{"dataQA", {}, OutputObjHandlingPolicy::AnalysisObject, false, true}; + JetBkgSubUtils bkgSub; + void init(o2::framework::InitContext&) { mRunNumber = 0; @@ -140,65 +166,144 @@ struct AngularCorrelationsInJets { 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, {ptAxis}); - registryData.add("hPtSubtractedJet", "Subtracted jet p_{T}", HistType::kTH1D, {ptAxis}); - registryData.add("hPtJetProtonDeuteron", "p_{T} of (anti)p, (anti)d", HistType::kTH2D, {particleTypeAxis, ptAxis}); - registryData.add("hPtTotalJet", "p_{T} of entire jet;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1F, {{2000, 0, 500}}); - registryData.add("hPtDiff", "pT difference PseudoJet/original track;#it{p}_{T} [GeV/#it{c}]", HistType::kTH1D, {{100, -5, 5}}); + 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("hPtJetProton_15", "Proton p_{T} for jet p_{T} < 15 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetProton_20", "Proton p_{T} for jet p_{T} < 20 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetProton_30", "Proton p_{T} for jet p_{T} < 30 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetProton_50", "Proton p_{T} for jet p_{T} < 50 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntiproton_15", "Antiproton p_{T} for jet p_{T} < 15 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntiproton_20", "Antiproton p_{T} for jet p_{T} < 20 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntiproton_30", "Antiproton p_{T} for jet p_{T} < 30 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntiproton_50", "Antiproton p_{T} for jet p_{T} < 50 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetNuclei_15", "Nuclei p_{T} for jet p_{T} < 15 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetNuclei_20", "Nuclei p_{T} for jet p_{T} < 20 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetNuclei_30", "Nuclei p_{T} for jet p_{T} < 30 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetNuclei_50", "Nuclei p_{T} for jet p_{T} < 50 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntinuclei_15", "Antinuclei p_{T} for jet p_{T} < 15 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntinuclei_20", "Antinuclei p_{T} for jet p_{T} < 20 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntinuclei_30", "Antinuclei p_{T} for jet p_{T} < 30 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); + registryQA.add("hPtJetAntinuclei_50", "Antinuclei p_{T} for jet p_{T} < 50 GeV", HistType::kTH1D, {axisSpecs.ptAxisPos}); // nSigma - registryData.add("hTPCsignal", "TPC signal", HistType::kTH2F, {{1000, 0, 100, "#it{p} [GeV/#it{c}]"}, {5000, 0, 5000, "d#it{E}/d#it{X} (a.u.)"}}); - registryData.add("hTOFsignal", "TOF signal", HistType::kTH2F, {{1000, 0, 100, "#it{p} [GeV/#it{c}]"}, {550, 0, 1.1, "#beta (TOF)"}}); - registryData.add("hTPCnsigmaProton", "TPC n#sigma for (anti)proton", HistType::kTH2F, {nsigmapTAxis, nsigmaAxis}); - registryData.add("hTOFnsigmaProton", "TOF n#sigma for (anti)proton", HistType::kTH2F, {nsigmapTAxis, nsigmaAxis}); - registryData.add("hTPCnsigmaDeuteron", "TPC n#sigma for (anti)deuteron", HistType::kTH2F, {nsigmapTAxis, nsigmaAxis}); - registryData.add("hTOFnsigmaDeuteron", "TOF n#sigma for (anti)deuteron", HistType::kTH2F, {nsigmapTAxis, nsigmaAxis}); + registryData.add("hTPCsignal", "TPC signal", HistType::kTH2F, {{1000, -100, 100, "#it{p} [GeV/#it{c}]"}, {5000, 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, {ptAxis, dcaxyAxis}); - registryData.add("hDCAzFullJet", "DCA_{z} of full jet", HistType::kTH2F, {ptAxis, dcazAxis}); - registryData.add("hDCAzJetProton", "DCA_{z} of protons after TPC cut", HistType::kTH2F, {ptAxis, dcazAxis}); - registryData.add("hDCAzJetAntiproton", "DCA_{z} of antiprotons after TPC cut", HistType::kTH2F, {ptAxis, dcazAxis}); - registryData.add("hDCAzJetDeuteron", "DCA_{z} of deuterons after TPC cut", HistType::kTH2F, {ptAxis, dcazAxis}); - registryData.add("hDCAzJetAntideuteron", "DCA_{z} of antideuterons after TPC cut", HistType::kTH2F, {ptAxis, dcazAxis}); + 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 - registryData.add("hDeltaPhiSE", "#Delta#varphi of (anti)p, (anti)d in single event", HistType::kTH2D, {particleTypeAxis, angDistPhiAxis}); - registryData.add("hDeltaPhiME", "#Delta#varphi of (anti)p, (anti)d in mixed events", HistType::kTH2D, {particleTypeAxis, angDistPhiAxis}); - registryData.add("hDeltaPhiEtaSE", "#Delta#varphi vs #Delta#eta of (anti)p, (anti)d in single event", HistType::kTH3D, {particleTypeAxis, angDistPhiAxis, angDistEtaAxis}); - registryData.add("hDeltaPhiEtaME", "#Delta#varphi vs #Delta#eta of (anti)p, (anti)d in mixed events", HistType::kTH3D, {particleTypeAxis, angDistPhiAxis, angDistEtaAxis}); - - registryData.add("hJetConeRadius", "Jet Radius;#it{R}", HistType::kTH1F, {{100, 0, 1}}); + registryQA.add("hPhiFullEvent", "#varphi in full event", HistType::kTH1F, {{1000, -6.3, 6.3}}); + registryQA.add("hPhiPtFullEvent", "#varphi vs. p_{T} in full event", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -6.3, 6.3}}); + registryQA.add("hPhiJet", "#varphi in jet", HistType::kTH1F, {{1000, -6.3, 6.3}}); + registryQA.add("hPhiPtJet", "#varphi vs. p_{T} in jet", HistType::kTH2F, {axisSpecs.ptAxisPos, {1000, -6.3, 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("hTOFmass", "TOF mass", HistType::kTH2F, {ptAxis, {1000, 0, 5, "#it{m} [GeV/#it{c}^{2}]"}}); - registryQA.add("hPtFullEvent", "p_{T} after basic cuts", HistType::kTH1F, {ptAxis}); - registryQA.add("hEtaFullEvent", "Particle pseudorapidity;#eta", HistType::kTH1F, {{200, -1, 1}}); + 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("hCrossedRowsTPC", "Crossed rows TPC", HistType::kTH2I, {ptAxis, {135, 65, 200}}); - registryQA.add("hClusterITS", "ITS clusters", HistType::kTH2I, {ptAxis, {10, 0, 10}}); - registryQA.add("hClusterTPC", "TPC clusters", HistType::kTH2I, {ptAxis, {135, 65, 200}}); - registryQA.add("hRatioCrossedRowsTPC", "Ratio crossed rows/findable TPC", HistType::kTH2F, {ptAxis, {100, 0.5, 1.5}}); - registryQA.add("hChi2ITS", "ITS #chi^{2}", HistType::kTH2F, {ptAxis, {400, 0, 40}}); - registryQA.add("hChi2TPC", "TPC #chi^{2}", HistType::kTH2F, {ptAxis, {50, 0, 5}}); - registryQA.add("hDCAxyFullEvent", "DCA_{xy} of full event", HistType::kTH2F, {ptAxis, dcaxyAxis}); - registryQA.add("hDCAzFullEvent", "DCA_{z} of full event", HistType::kTH2F, {ptAxis, dcazAxis}); + 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})"}}); } - std::vector fTrackBufferProtonRun2; - std::vector fTrackBufferAntiprotonRun2; - std::vector fTrackBufferDeuteronRun2; - std::vector fTrackBufferAntideuteronRun2; - std::vector fTrackBufferProtonRun3; - std::vector fTrackBufferAntiprotonRun3; - std::vector fTrackBufferDeuteronRun3; - std::vector fTrackBufferAntideuteronRun3; - // TODO: check if FullTracksRun2 works for Run3 too or add Run3 track buffers + std::vector> fBufferProton; + std::vector> fBufferAntiproton; + std::vector> fBufferNuclei; + std::vector> fBufferAntinuclei; + std::vector> fBufferJet; + std::vector> fBufferFull; template void initCCDB(Bc const& bc) @@ -219,435 +324,850 @@ struct AngularCorrelationsInJets { return false; } if (doprocessRun2) { - if (!(track.trackType() & o2::aod::track::Run2Track) //|| - //!(track.flags() & o2::aod::track::TPCrefit) || - //!(track.flags() & o2::aod::track::ITSrefit) - ) { + if (!(track.trackType() & o2::aod::track::Run2Track) || + !(track.flags() & o2::aod::track::TPCrefit) || + !(track.flags() & o2::aod::track::ITSrefit)) { return false; } } return true; } - std::vector findJets(std::vector jetInput) + template + bool isProton(const T& track, bool tightCuts) { - std::vector jets; - std::vector constituents; - jets.clear(); - constituents.clear(); - fastjet::PseudoJet hardestJet(0., 0., 0., 0.); - fastjet::PseudoJet subtractedJet(0., 0., 0., 0.); + if (track.sign() < 0) + return false; - double ghost_maxrap = 1.0; - double ghost_area = 0.005; - int ghost_repeat = 1; - fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, fJetR); - 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 constituents; + if (tightCuts) { // for correlation function + // DCA + if (TMath::Abs(track.dcaXY()) > fProtonDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fProtonDCAzCF) + return false; - registryData.fill(HIST("hEventProtocol"), 3); + registryData.fill(HIST("hTPCnsigmaProtonCF"), track.pt(), track.tpcNSigmaPr()); - hardestJet = jets[0]; + // TPC + if (track.pt() < fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fProtonTPCnsigLowCF) + return false; + if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fProtonTPCnsigHighCF) + return false; - if (hardestJet.pt() < fMinJetPt) - return constituents; - registryData.fill(HIST("hEventProtocol"), 4); - if (hardestJet.constituents().size() < 2) - return constituents; - registryData.fill(HIST("hEventProtocol"), 5); - registryData.fill(HIST("hNumberOfJets"), 0); - registryData.fill(HIST("hPtTotalJet"), hardestJet.pt()); - registryData.fill(HIST("hJetRapidity"), hardestJet.rap()); - registryData.fill(HIST("hNumPartInJet"), hardestJet.constituents().size()); + registryData.fill(HIST("hTOFnsigmaProtonCF"), track.pt(), track.tofNSigmaPr()); - for (const auto& constituent : hardestJet.constituents()) { - registryData.fill(HIST("hPtJetParticle"), constituent.pt()); - double DeltaPhi = TVector2::Phi_0_2pi(constituent.phi() - hardestJet.phi()); - double DeltaEta = constituent.eta() - hardestJet.eta(); - double Delta = TMath::Sqrt(DeltaPhi * DeltaPhi + DeltaEta * DeltaEta); - registryData.fill(HIST("hJetConeRadius"), Delta); - } + // TOF + if (track.hasTOF()) { + if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > fProtonTOFnsigCF) + return false; + } + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fProtonDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fProtonDCAzYield) + return false; + + registryData.fill(HIST("hTPCnsigmaProton"), track.pt(), track.tpcNSigmaPr()); + + // TPC + if (track.pt() < fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fProtonTPCnsigLowYield) + return false; + if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fProtonTPCnsigHighYield) + return false; - fastjet::Selector selector = fastjet::SelectorAbsEtaMax(1.0) * (!fastjet::SelectorNHardest(2)); // TODO: fix subtraction - fastjet::JetMedianBackgroundEstimator bkgEst(selector, jetDefBkg, areaDefBkg); - fastjet::Subtractor subtractor(&bkgEst); - subtractor.set_use_rho_m(true); - bkgEst.set_particles(jetInput); + registryData.fill(HIST("hTOFnsigmaProton"), track.pt(), track.tofNSigmaPr()); - subtractedJet = subtractor(hardestJet); - if (subtractedJet.has_constituents()) { - for (const auto& subConstituent : subtractedJet.constituents()) { - registryData.fill(HIST("hPtSubtractedJet"), subConstituent.pt()); + // TOF + if (track.hasTOF()) { + if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > fProtonTOFnsigYield) + return false; } } - return hardestJet.constituents(); + + return true; } template - bool isProton(const T& track) + bool isAntiproton(const T& track, bool tightCuts) { - bool isProton = false; - if (track.sign() < 0) - return isProton; - - // TPC - if (track.pt() < fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) < fProtonTPCnsigLow) - isProton = true; - if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) < fProtonTPCnsigHigh) - isProton = true; + if (track.sign() > 0) + return false; - registryData.fill(HIST("hDCAzJetProton"), track.pt() * track.sign(), track.dcaZ()); + if (tightCuts) { // for correlation function + // DCA + if (TMath::Abs(track.dcaXY()) > fAntiprotonDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fAntiprotonDCAzCF) + return false; - if (TMath::Abs(track.dcaXY()) > fProtonDCAxy) - return false; - if (TMath::Abs(track.dcaZ()) > fProtonDCAz) - return false; + registryData.fill(HIST("hTPCnsigmaAntiprotonCF"), track.pt(), track.tpcNSigmaPr()); - // TOF - if (track.pt() < fProtonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) < fProtonTOFnsigLow) - isProton = true; - if (track.pt() > fProtonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) < fProtonTOFnsigHigh) - isProton = true; + // TPC + if (track.pt() < fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fAntiprotonTPCnsigLowCF) + return false; + if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fAntiprotonTPCnsigHighCF) + return false; - return isProton; - } + registryData.fill(HIST("hTOFnsigmaAntiprotonCF"), track.pt(), track.tofNSigmaPr()); - template - bool isAntiproton(const T& track) - { - bool isAntiproton = false; - if (track.sign() < 0) - return isAntiproton; + // TOF + if (track.hasTOF()) { + if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > fAntiprotonTOFnsigCF) + return false; + } + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fAntiprotonDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fAntiprotonDCAzYield) + return false; - // TPC - if (track.pt() < fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) < fAntiprotonTPCnsigLow) - isAntiproton = true; - if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) < fAntiprotonTPCnsigHigh) - isAntiproton = true; + registryData.fill(HIST("hTPCnsigmaAntiproton"), track.pt(), track.tpcNSigmaPr()); - registryData.fill(HIST("hDCAzJetAntiproton"), track.pt() * track.sign(), track.dcaZ()); + // TPC + if (track.pt() < fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fAntiprotonTPCnsigLowYield) + return false; + if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tpcNSigmaPr()) > fAntiprotonTPCnsigHighYield) + return false; - if (TMath::Abs(track.dcaXY()) > fAntiprotonDCAxy) - return false; - if (TMath::Abs(track.dcaZ()) > fAntiprotonDCAz) - return false; + registryData.fill(HIST("hTOFnsigmaAntiproton"), track.pt(), track.tofNSigmaPr()); - // TOF - if (track.pt() < fAntiprotonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) < fAntiprotonTOFnsigLow) - isAntiproton = true; - if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) < fAntiprotonTOFnsigHigh) - isAntiproton = true; + // TOF + if (track.hasTOF()) { + if (track.pt() > fAntiprotonTPCTOFpT && TMath::Abs(track.tofNSigmaPr()) > fAntiprotonTOFnsigYield) + return false; + } + } - return isAntiproton; + return true; } template - bool isDeuteron(const T& track) + bool isNucleus(const T& track, bool tightCuts) { - bool isDeuteron = false; if (track.sign() < 0) - return isDeuteron; - - // TPC - if (track.pt() < fDeuteronTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) < fDeuteronTPCnsigLow) - isDeuteron = true; - if (track.pt() > fDeuteronTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) < fDeuteronTPCnsigHigh) - isDeuteron = true; - - registryData.fill(HIST("hDCAzJetDeuteron"), track.pt() * track.sign(), track.dcaZ()); - - if (TMath::Abs(track.dcaXY()) > fDeuteronDCAxy) return false; - if (TMath::Abs(track.dcaZ()) > fDeuteronDCAz) - return false; - - // TOF - if (track.pt() < fDeuteronTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) < fDeuteronTOFnsigLow) - isDeuteron = true; - if (track.pt() > fDeuteronTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) < fDeuteronTOFnsigHigh) - isDeuteron = true; + if (fDeuteronAnalysis) { + if (tightCuts) { // for correlation function + // DCA + if (TMath::Abs(track.dcaXY()) > fNucleiDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fNucleiDCAzCF) + return false; + + registryData.fill(HIST("hTPCnsigmaNucleiCF"), track.pt(), track.tpcNSigmaDe()); + + // TPC + if (track.pt() < fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fNucleiTPCnsigLowCF) + return false; + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fNucleiTPCnsigHighCF) + return false; + + registryData.fill(HIST("hTOFnsigmaNucleiCF"), track.pt(), track.tofNSigmaDe()); + + // TOF + if (track.hasTOF()) { + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > fNucleiTOFnsigCF) + return false; + } + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fNucleiDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fNucleiDCAzYield) + return false; + + registryData.fill(HIST("hTPCnsigmaNuclei"), track.pt(), track.tpcNSigmaDe()); + + // TPC + if (track.pt() < fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fNucleiTPCnsigLowYield) + return false; + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fNucleiTPCnsigHighYield) + return false; + + registryData.fill(HIST("hTOFnsigmaNuclei"), track.pt(), track.tofNSigmaDe()); + + // TOF + if (track.hasTOF()) { + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > fNucleiTOFnsigYield) + 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()) > fNucleiDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fNucleiDCAzCF) + return false; + + registryData.fill(HIST("hTPCnsigmaNucleiCF"), track.pt(), track.tpcNSigmaHe()); + + // TPC + if (track.pt() < fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fNucleiTPCnsigLowCF) + return false; + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fNucleiTPCnsigHighCF) + return false; + + registryData.fill(HIST("hTOFnsigmaNucleiCF"), track.pt(), track.tofNSigmaHe()); + + // TOF + if (track.hasTOF()) { + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > fNucleiTOFnsigCF) + return false; + } + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fNucleiDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fNucleiDCAzYield) + return false; + + registryData.fill(HIST("hTPCnsigmaNuclei"), track.pt(), track.tpcNSigmaHe()); + + // TPC + if (track.pt() < fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fNucleiTPCnsigLowYield) + return false; + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fNucleiTPCnsigHighYield) + return false; + + registryData.fill(HIST("hTOFnsigmaNuclei"), track.pt(), track.tofNSigmaHe()); + + // TOF + if (track.hasTOF()) { + if (track.pt() > fNucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > fNucleiTOFnsigYield) + return false; + } + } + } - return isDeuteron; + return true; } template - bool isAntideuteron(const T& track) + bool isAntinucleus(const T& track, bool tightCuts) { - bool isAntideuteron = false; - if (track.sign() < 0) - return isAntideuteron; - - // TPC - if (track.pt() < fAntideuteronTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) < fAntideuteronTPCnsigLow) - isAntideuteron = true; - if (track.pt() > fAntideuteronTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) < fAntideuteronTPCnsigHigh) - isAntideuteron = true; - - registryData.fill(HIST("hDCAzJetAntideuteron"), track.pt() * track.sign(), track.dcaZ()); - - if (TMath::Abs(track.dcaXY()) > fAntideuteronDCAxy) - return false; - if (TMath::Abs(track.dcaZ()) > fAntideuteronDCAz) + if (track.sign() > 0) return false; - // TOF - if (track.pt() < fAntideuteronTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) < fAntideuteronTOFnsigLow) - isAntideuteron = true; - if (track.pt() > fAntideuteronTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) < fAntideuteronTOFnsigHigh) - isAntideuteron = true; + if (fDeuteronAnalysis) { + if (tightCuts) { // for correlation function + // DCA + if (TMath::Abs(track.dcaXY()) > fAntinucleiDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fAntinucleiDCAzCF) + return false; + + registryData.fill(HIST("hTPCnsigmaAntinucleiCF"), track.pt(), track.tpcNSigmaDe()); + + // TPC + if (track.pt() < fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fAntinucleiTPCnsigLowCF) + return false; + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fAntinucleiTPCnsigHighCF) + return false; + + registryData.fill(HIST("hTOFnsigmaAntinucleiCF"), track.pt(), track.tofNSigmaDe()); + + // TOF + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > fAntinucleiTOFnsigCF) + return false; + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fAntinucleiDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fAntinucleiDCAzYield) + return false; + + registryData.fill(HIST("hTPCnsigmaAntinuclei"), track.pt(), track.tpcNSigmaDe()); + + // TPC + if (track.pt() < fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fAntinucleiTPCnsigLowYield) + return false; + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaDe()) > fAntinucleiTPCnsigHighYield) + return false; + + registryData.fill(HIST("hTOFnsigmaAntinuclei"), track.pt(), track.tofNSigmaDe()); + + // TOF + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaDe()) > fAntinucleiTOFnsigYield) + 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()) > fAntinucleiDCAxyCF) + return false; + if (TMath::Abs(track.dcaZ()) > fAntinucleiDCAzCF) + return false; + + registryData.fill(HIST("hTPCnsigmaAntinucleiCF"), track.pt(), track.tpcNSigmaHe()); + + // TPC + if (track.pt() < fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fAntinucleiTPCnsigLowCF) + return false; + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fAntinucleiTPCnsigHighCF) + return false; + + registryData.fill(HIST("hTOFnsigmaAntinucleiCF"), track.pt(), track.tofNSigmaHe()); + + // TOF + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > fAntinucleiTOFnsigCF) + return false; + } else { // for yields + // DCA + if (TMath::Abs(track.dcaXY()) > fAntinucleiDCAxyYield) + return false; + if (TMath::Abs(track.dcaZ()) > fAntinucleiDCAzYield) + return false; + + registryData.fill(HIST("hTPCnsigmaAntinuclei"), track.pt(), track.tpcNSigmaHe()); + + // TPC + if (track.pt() < fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fAntinucleiTPCnsigLowYield) + return false; + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tpcNSigmaHe()) > fAntinucleiTPCnsigHighYield) + return false; + + registryData.fill(HIST("hTOFnsigmaAntinuclei"), track.pt(), track.tofNSigmaHe()); + + // TOF + if (track.pt() > fAntinucleiTPCTOFpT && TMath::Abs(track.tofNSigmaHe()) > fAntinucleiTOFnsigYield) + return false; + } + } - return isAntideuteron; + return true; } void setTrackBuffer(const auto& tempBuffer, auto& buffer) { - for (const auto& track : tempBuffer) { - if (static_cast(buffer.size()) == fTrackBufferSize) { - buffer.insert(buffer.begin(), track); - buffer.resize(fTrackBufferSize); - } else if (static_cast(buffer.size()) < fTrackBufferSize) { - buffer.emplace_back(track); + for (const auto& pair : tempBuffer) { + if (static_cast(buffer.size()) == fBufferSize) { + buffer.insert(buffer.begin(), pair); + buffer.resize(fBufferSize); + } else if (static_cast(buffer.size()) < fBufferSize) { + buffer.emplace_back(pair); } } } - void fillMixedEventDeltas(const auto& track, const auto& buffer, int particleType) + void fillMixedEventDeltas(const auto& track, const auto& buffer, int particleType, const TVector3 jetAxis) { if (buffer.size() == 0) return; - for (int i = 0; i < static_cast(buffer.size()); i++) { - if (std::isnan(buffer.at(i).phi())) + 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).phi() > 2 * TMath::Pi() || buffer.at(i).phi() < -2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 13); + if (buffer.at(i).first > 2 * TMath::Pi() || buffer.at(i).first < -2 * TMath::Pi()) { + registryData.fill(HIST("hTrackProtocol"), 16); continue; } - double DeltaPhi = TVector2::Phi_0_2pi(track.phi() - buffer.at(i).phi()); - if (DeltaPhi > (1.5 * TMath::Pi())) { + 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 = TMath::Abs(track.eta() - buffer.at(i).eta()); - registryData.fill(HIST("hDeltaPhiME"), particleType, DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaME"), particleType, DeltaPhi, DeltaEta); - } + 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) + void doCorrelations(const auto& particleVector, const auto& buffer, auto& tempBuffer, int particleType, const TVector3 jetAxis) { - for (int i = 0; i < static_cast(particleVector.size()); i++) { // maybe simply introduce phi cut? - if (particleVector.at(i).phi() > 2 * TMath::Pi() || particleVector.at(i).phi() < -2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 11); + 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 (particleVector.at(j).phi() > 2 * TMath::Pi() || particleVector.at(j).phi() < -2 * TMath::Pi()) { - registryData.fill(HIST("hTrackProtocol"), 12); + 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 = TMath::Abs(particleVector.at(i).eta() - particleVector[j].eta()); + double DeltaEta = particleVector.at(i).eta() - particleVector[j].eta(); if (DeltaPhi > (1.5 * TMath::Pi())) { DeltaPhi = DeltaPhi - 2 * TMath::Pi(); } - registryData.fill(HIST("hDeltaPhiSE"), 1, DeltaPhi); - registryData.fill(HIST("hDeltaPhiEtaSE"), 1, DeltaPhi, DeltaEta); + 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); - tempBuffer.emplace_back(particleVector.at(i)); + fillMixedEventDeltas(particleVector.at(i), buffer, particleType, jetAxis); + tempBuffer.emplace_back(std::make_pair(phiToAxis, etaToAxis)); } } - template - void fillHistogramsRun2(T const& collision, U const& allTracks) + double getDeltaPhi(double a1, double a2) { - std::vector fTempBufferProton; - std::vector fTempBufferAntiproton; - std::vector fTempBufferDeuteron; - std::vector fTempBufferAntideuteron; - fTempBufferProton.clear(); - fTempBufferAntiproton.clear(); - fTempBufferDeuteron.clear(); - fTempBufferAntideuteron.clear(); - std::vector jetInput; - std::map particles; - jetInput.clear(); - particles.clear(); - int index = 0; + 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; + } - auto tracks = allTracks.sliceBy(perCollisionFullTracksRun2, collision.globalIndex()); + void getPerpendicularAxis(TVector3 p, TVector3& u, double sign) + { + // Initialization + double ux(0), uy(0), uz(0); - for (const auto& track : tracks) { - if (!selectTrack(track)) - continue; + // Components of Vector p + double px = p.X(); + double py = p.Y(); + double pz = p.Z(); - double mass; - 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"), 4); - } else { - mass = 0.139; // pion mass as default, ~80% are pions - registryData.fill(HIST("hTrackProtocol"), 5); - } + // Protection 1 + if (px == 0 && py != 0) { - // double ratioCrossedRowsTPC = track.tpcNClsCrossedRows()/track.tpcNClsFindable(); - registryQA.fill(HIST("hPtFullEvent"), track.pt()); - registryQA.fill(HIST("hEtaFullEvent"), track.eta()); - 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("hRatioCrossedRowsTPC"), track.pt(), ratioCrossedRowsTPC); - 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()); - fastjet::PseudoJet inputPseudoJet(track.px(), track.py(), track.pz(), track.energy(mass)); - inputPseudoJet.set_user_index(index); - particles[index] = track; - jetInput.emplace_back(inputPseudoJet); + uy = -(pz * pz) / py; + ux = sign * sqrt(py * py - (pz * pz * pz * pz) / (py * py)); + uz = pz; + u.SetXYZ(ux, uy, uz); + return; + } - index++; - } // for (const auto& track : tracks) + // Protection 2 + if (py == 0 && px != 0) { - if (jetInput.size() < 2) + ux = -(pz * pz) / px; + uy = sign * sqrt(px * px - (pz * pz * pz * pz) / (px * px)); + uz = pz; + u.SetXYZ(ux, uy, uz); return; - registryData.fill(HIST("hEventProtocol"), 2); + } - std::vector constituents = findJets(jetInput); - if (constituents.empty()) + // 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; + } - std::vector jetProtons; // replace with IDs? - std::vector jetAntiprotons; - std::vector jetDeuterons; - std::vector jetAntideuterons; + // 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() < fMinJetPt) // 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); + 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); // no entries - weird! + + // 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 < fRmax) { + if (deltaPhiJet != -999) + registryQA.fill(HIST("hDeltaEtadeltaPhiJet"), deltaEtaJet, deltaPhiJet); + NchJetPlusUE++; + ptJetPlusUE = ptJetPlusUE + track.pt(); + } + if (deltaRUE1 < fRmax) { + if (deltaPhiUE1 != -999) + registryQA.fill(HIST("hDeltaEtadeltaPhiUE"), deltaEtaUE1, deltaPhiUE1); + NchUE++; + ptUE = ptUE + track.pt(); + } + if (deltaRUE2 < fRmax) { + 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); - for (int i = 0; i < static_cast(constituents.size()); i++) { - registryData.fill(HIST("hTrackProtocol"), 10); + int nPartClusteredJet = static_cast(constituents.size()); + + // Fill QA Histograms + if (ptJetPlusUE < fMinJetPt) { // 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[id]; + 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()) + if (jetParticle.hasTOF()) { registryData.fill(HIST("hTOFsignal"), jetParticle.pt() * jetParticle.sign(), jetParticle.beta()); - + } double ptDiff = pseudoParticle.pt() - jetParticle.pt(); - registryData.fill(HIST("hPtDiff"), ptDiff); - int particleType = 0; + registryQA.fill(HIST("hPtDiff"), ptDiff); if (jetParticle.pt() < fMinJetParticlePt) continue; - if (isProton(jetParticle) || isAntiproton(jetParticle)) { // collect (anti)protons in jet - registryData.fill(HIST("hTPCnsigmaProton"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcNSigmaPr()); + if (isProton(jetParticle, false)) { // collect protons in jet + registryData.fill(HIST("hPtJetProton"), jetParticle.pt()); + if (subtractedJetPerp.pt() < 15) { + registryQA.fill(HIST("hPtJetProton_15"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 20) { + registryQA.fill(HIST("hPtJetProton_20"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 30) { + registryQA.fill(HIST("hPtJetProton_30"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 50) { + registryQA.fill(HIST("hPtJetProton_50"), jetParticle.pt()); + } if (jetParticle.hasTOF()) - registryData.fill(HIST("hTOFnsigmaProton"), jetParticle.pt() * jetParticle.sign(), jetParticle.tofNSigmaPr()); - if (isProton(jetParticle)) { - particleType = 1; - registryData.fill(HIST("hTrackProtocol"), 6); // # protons + registryData.fill(HIST("hTOFnsigmaProton"), jetParticle.pt(), jetParticle.tofNSigmaPr()); + registryData.fill(HIST("hTrackProtocol"), 4); // # protons + if (isProton(jetParticle, true)) { + registryData.fill(HIST("hTrackProtocol"), 5); // # high purity protons jetProtons.emplace_back(jetParticle); - } else { - particleType = 2; - registryData.fill(HIST("hTrackProtocol"), 7); // # antiprotons - jetAntiprotons.emplace_back(jetParticle); + registryData.fill(HIST("hDCAzJetProton"), jetParticle.pt(), jetParticle.dcaZ()); } - } else if (isDeuteron(jetParticle) || isAntideuteron(jetParticle)) { // collect (anti)deuterons in jet - registryData.fill(HIST("hTPCnsigmaDeuteron"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcNSigmaDe()); + } else if (isAntiproton(jetParticle, false)) { // collect antiprotons in jet + registryData.fill(HIST("hPtJetAntiproton"), jetParticle.pt()); + if (subtractedJetPerp.pt() < 15) { + registryQA.fill(HIST("hPtJetAntiproton_15"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 20) { + registryQA.fill(HIST("hPtJetAntiproton_20"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 30) { + registryQA.fill(HIST("hPtJetAntiproton_30"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 50) { + registryQA.fill(HIST("hPtJetAntiproton_50"), jetParticle.pt()); + } + registryData.fill(HIST("hTPCnsigmaAntiproton"), jetParticle.pt(), jetParticle.tpcNSigmaPr()); if (jetParticle.hasTOF()) - registryData.fill(HIST("hTOFnsigmaDeuteron"), jetParticle.pt() * jetParticle.sign(), jetParticle.tofNSigmaDe()); - if (isDeuteron(jetParticle)) { - particleType = 3; - registryData.fill(HIST("hTrackProtocol"), 8); // # deuterons - jetDeuterons.emplace_back(jetParticle); + registryData.fill(HIST("hTOFnsigmaAntiproton"), jetParticle.pt(), jetParticle.tofNSigmaPr()); + 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()); + if (subtractedJetPerp.pt() < 15) { + registryQA.fill(HIST("hPtJetNuclei_15"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 20) { + registryQA.fill(HIST("hPtJetNuclei_20"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 30) { + registryQA.fill(HIST("hPtJetNuclei_30"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 50) { + registryQA.fill(HIST("hPtJetNuclei_50"), jetParticle.pt()); + } + if (fDeuteronAnalysis) { + registryData.fill(HIST("hTPCnsigmaNuclei"), jetParticle.pt(), jetParticle.tpcNSigmaDe()); } else { - particleType = 4; - registryData.fill(HIST("hTrackProtocol"), 9); // # antideuterons - jetAntideuterons.emplace_back(jetParticle); + registryData.fill(HIST("hTPCnsigmaNuclei"), jetParticle.pt(), jetParticle.tpcNSigmaHe()); + } + if (jetParticle.hasTOF()) { + if (fDeuteronAnalysis) { + registryData.fill(HIST("hTOFnsigmaNuclei"), jetParticle.pt(), jetParticle.tofNSigmaDe()); + } else { + registryData.fill(HIST("hTOFnsigmaNuclei"), jetParticle.pt(), jetParticle.tofNSigmaHe()); + } + } + 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()); + if (subtractedJetPerp.pt() < 15) { + registryQA.fill(HIST("hPtJetAntinuclei_15"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 20) { + registryQA.fill(HIST("hPtJetAntinuclei_20"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 30) { + registryQA.fill(HIST("hPtJetAntinuclei_30"), jetParticle.pt()); + } else if (subtractedJetPerp.pt() < 50) { + registryQA.fill(HIST("hPtJetAntinuclei_50"), jetParticle.pt()); + } + if (fDeuteronAnalysis) { + registryData.fill(HIST("hTPCnsigmaAntinuclei"), jetParticle.pt(), jetParticle.tpcNSigmaDe()); + } else { + registryData.fill(HIST("hTPCnsigmaAntinuclei"), jetParticle.pt(), jetParticle.tpcNSigmaHe()); + } + if (jetParticle.hasTOF()) { + if (fDeuteronAnalysis) { + registryData.fill(HIST("hTOFnsigmaAntinuclei"), jetParticle.pt(), jetParticle.tofNSigmaDe()); + } else { + registryData.fill(HIST("hTOFnsigmaAntinuclei"), jetParticle.pt(), jetParticle.tofNSigmaHe()); + } + } + 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()); } } - registryData.fill(HIST("hPtJetProtonDeuteron"), particleType, jetParticle.pt()); } // for (int i=0; i(constituents.size()); i++) - if ((jetProtons.size() < 2) && (jetAntiprotons.size() < 2) && (jetDeuterons.size() < 2) && (jetAntideuterons.size() < 2)) - return; + 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, fTrackBufferProtonRun2, fTempBufferProton, 1); - setTrackBuffer(fTempBufferProton, fTrackBufferProtonRun2); + doCorrelations(jetProtons, fBufferProton, fTempBufferProton, 1, pJet); + setTrackBuffer(fTempBufferProton, fBufferProton); } if (jetAntiprotons.size() > 1) { - doCorrelations(jetAntiprotons, fTrackBufferAntiprotonRun2, fTempBufferAntiproton, 2); - setTrackBuffer(fTempBufferAntiproton, fTrackBufferAntiprotonRun2); + doCorrelations(jetAntiprotons, fBufferAntiproton, fTempBufferAntiproton, 2, pJet); + setTrackBuffer(fTempBufferAntiproton, fBufferAntiproton); } - if (jetDeuterons.size() > 1) { - doCorrelations(jetDeuterons, fTrackBufferDeuteronRun2, fTempBufferDeuteron, 3); - setTrackBuffer(fTempBufferDeuteron, fTrackBufferDeuteronRun2); + if (jetNuclei.size() > 1) { + doCorrelations(jetNuclei, fBufferNuclei, fTempBufferNuclei, 3, pJet); + setTrackBuffer(fTempBufferNuclei, fBufferNuclei); } - if (jetAntideuterons.size() > 1) { - doCorrelations(jetAntideuterons, fTrackBufferAntideuteronRun2, fTempBufferAntideuteron, 4); - setTrackBuffer(fTempBufferAntideuteron, fTrackBufferAntideuteronRun2); + if (jetAntinuclei.size() > 1) { + doCorrelations(jetAntinuclei, fBufferAntinuclei, fTempBufferAntinuclei, 4, pJet); + setTrackBuffer(fTempBufferAntinuclei, fBufferAntinuclei); } + return jetCounter; } - template - void fillHistogramsRun3(T const& collision, U const& allTracks) + template + void fillHistograms(U const& tracks) { - std::vector fTempBufferProton; - std::vector fTempBufferAntiproton; - std::vector fTempBufferDeuteron; - std::vector fTempBufferAntideuteron; - fTempBufferProton.clear(); - fTempBufferAntiproton.clear(); - fTempBufferDeuteron.clear(); - fTempBufferAntideuteron.clear(); - std::vector jetInput; - std::map particles; + 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; - - auto tracks = allTracks.sliceBy(perCollisionFullTracksRun2, collision.globalIndex()); + int jetCounter = 0; + // int leadingID = 0; + std::vector jets; + jets.clear(); for (const auto& track : tracks) { if (!selectTrack(track)) continue; double mass; - 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"), 4); + if (fUseTOFMass) { + 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; // pion mass as default, ~80% are pions - registryData.fill(HIST("hTrackProtocol"), 5); + mass = 0.139; } - // double ratioCrossedRowsTPC = track.tpcNClsCrossedRows()/track.tpcNClsFindable(); + // if (track.pt() > fMinLeadingPt) { + // leadingID = track.globalIndex(); + // } + + if (track.tpcNClsFindable() != 0) { + registryQA.fill(HIST("hRatioCrossedRowsTPC"), track.pt(), track.tpcNClsCrossedRows() / track.tpcNClsFindable()); + } registryQA.fill(HIST("hPtFullEvent"), track.pt()); - registryQA.fill(HIST("hEtaFullEvent"), track.eta()); 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("hRatioCrossedRowsTPC"), track.pt(), ratioCrossedRowsTPC); 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++; @@ -657,83 +1177,34 @@ struct AngularCorrelationsInJets { return; registryData.fill(HIST("hEventProtocol"), 2); - std::vector constituents = findJets(jetInput); - if (constituents.empty()) - return; - - std::vector jetProtons; // replace with IDs? - std::vector jetAntiprotons; - std::vector jetDeuterons; - std::vector jetAntideuterons; - - for (int i = 0; i < static_cast(constituents.size()); i++) { - registryData.fill(HIST("hTrackProtocol"), 10); - fastjet::PseudoJet pseudoParticle = constituents.at(i); - int id = pseudoParticle.user_index(); - const auto& jetParticle = particles[id]; - - 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()); + // Reconstruct Jets + double ghost_maxrap = 1.0; + double ghost_area = 0.005; + int ghost_repeat = 1; + fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, fJetR); + 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()); - double ptDiff = pseudoParticle.pt() - jetParticle.pt(); - registryData.fill(HIST("hPtDiff"), ptDiff); - int particleType = 0; + if (jets.size() == 0) + return; - if (jetParticle.pt() < fMinJetParticlePt) - continue; - if (isProton(jetParticle) || isAntiproton(jetParticle)) { // collect (anti)protons in jet - registryData.fill(HIST("hTPCnsigmaProton"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcNSigmaPr()); - if (jetParticle.hasTOF()) - registryData.fill(HIST("hTOFnsigmaProton"), jetParticle.pt() * jetParticle.sign(), jetParticle.tofNSigmaPr()); - if (isProton(jetParticle)) { - particleType = 1; - registryData.fill(HIST("hTrackProtocol"), 6); // # protons - jetProtons.emplace_back(jetParticle); - } else { - particleType = 2; - registryData.fill(HIST("hTrackProtocol"), 7); // # antiprotons - jetAntiprotons.emplace_back(jetParticle); - } - } else if (isDeuteron(jetParticle) || isAntideuteron(jetParticle)) { // collect (anti)deuterons in jet - registryData.fill(HIST("hTPCnsigmaDeuteron"), jetParticle.pt() * jetParticle.sign(), jetParticle.tpcNSigmaDe()); - if (jetParticle.hasTOF()) - registryData.fill(HIST("hTOFnsigmaDeuteron"), jetParticle.pt() * jetParticle.sign(), jetParticle.tofNSigmaDe()); - if (isDeuteron(jetParticle)) { - particleType = 3; - registryData.fill(HIST("hTrackProtocol"), 8); // # deuterons - jetDeuterons.emplace_back(jetParticle); - } else { - particleType = 4; - registryData.fill(HIST("hTrackProtocol"), 9); // # antideuterons - jetAntideuterons.emplace_back(jetParticle); - } - } - registryData.fill(HIST("hPtJetProtonDeuteron"), particleType, jetParticle.pt()); - } // for (int i=0; i(constituents.size()); i++) + registryData.fill(HIST("hEventProtocol"), 3); - if ((jetProtons.size() < 2) && (jetAntiprotons.size() < 2) && (jetDeuterons.size() < 2) && (jetAntideuterons.size() < 2)) - return; - registryData.fill(HIST("hEventProtocol"), 6); + bool doSparse = true; + auto [rho, rhoM] = bkgSub.estimateRhoAreaMedian(jetInput, doSparse); + auto [rhoPerp, rhoMPerp] = bkgSub.estimateRhoPerpCone(jetInput, jets); - if (jetProtons.size() > 1) { - doCorrelations(jetProtons, fTrackBufferProtonRun3, fTempBufferProton, 1); - setTrackBuffer(fTempBufferProton, fTrackBufferProtonRun3); - } - if (jetAntiprotons.size() > 1) { - doCorrelations(jetAntiprotons, fTrackBufferAntiprotonRun3, fTempBufferAntiproton, 2); - setTrackBuffer(fTempBufferAntiproton, fTrackBufferAntiprotonRun3); - } - if (jetDeuterons.size() > 1) { - doCorrelations(jetDeuterons, fTrackBufferDeuteronRun3, fTempBufferDeuteron, 3); - setTrackBuffer(fTempBufferDeuteron, fTrackBufferDeuteronRun3); - } - if (jetAntideuterons.size() > 1) { - doCorrelations(jetAntideuterons, fTrackBufferAntideuteronRun3, fTempBufferAntideuteron, 4); - setTrackBuffer(fTempBufferAntideuteron, fTrackBufferAntideuteronRun3); + 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); } void processRun2(soa::Join const& collisions, @@ -745,19 +1216,34 @@ struct AngularCorrelationsInJets { initCCDB(bc); registryData.fill(HIST("hEventProtocol"), 0); - registryData.fill(HIST("hNumberOfEvents"), 0); if (!collision.alias_bit(kINT7)) continue; + registryData.fill(HIST("hNumberOfEvents"), 0); registryData.fill(HIST("hEventProtocol"), 1); - fillHistogramsRun2(collision, tracks); + auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun2, collision.globalIndex()); + + fillHistograms(slicedTracks); } } PROCESS_SWITCH(AngularCorrelationsInJets, processRun2, "process Run 2 data", true); - void processRun3(aod::Collision const& collision, soa::Filtered const& tracks) + void processRun3(soa::Join const& collisions, + soa::Filtered const& tracks) { - fillHistogramsRun3(collision, 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()) > fZVtx) + continue; + + auto slicedTracks = tracks.sliceBy(perCollisionFullTracksRun3, collision.globalIndex()); + + fillHistograms(slicedTracks); + } } PROCESS_SWITCH(AngularCorrelationsInJets, processRun3, "process Run 3 data", false); }; diff --git a/PWGLF/Tasks/Nuspex/CMakeLists.txt b/PWGLF/Tasks/Nuspex/CMakeLists.txt index a69ac7d6743..3ab4d352396 100644 --- a/PWGLF/Tasks/Nuspex/CMakeLists.txt +++ b/PWGLF/Tasks/Nuspex/CMakeLists.txt @@ -31,7 +31,7 @@ o2physics_add_dpl_workflow(hypertriton3bodyanalysis o2physics_add_dpl_workflow(hypertriton3bodymcqa SOURCES hypertriton3bodyMCQA.cxx - PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2::DCAFitter O2Physics::AnalysisCore O2::TOFBase COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(nuclei-in-jets @@ -134,9 +134,19 @@ o2physics_add_dpl_workflow(nuclei-ebye PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(nuclei-toward-transv + SOURCES nuclei_in_toward_transv_regions.cxx + 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) + if(FastJet_FOUND) o2physics_add_dpl_workflow(angular-correlations-in-jets SOURCES AngularCorrelationsInJets.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore FastJet::FastJet FastJet::Contrib + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::PWGJECore FastJet::FastJet FastJet::Contrib COMPONENT_NAME Analysis) endif() \ No newline at end of file diff --git a/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx b/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx index 8d55234b567..37ad72ef487 100644 --- a/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx +++ b/PWGLF/Tasks/Nuspex/NucleiHistTask.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "ReconstructionDataFormats/Track.h" #include "Framework/runDataProcessing.h" @@ -57,7 +58,9 @@ struct NucleiHistTask { // MC HistogramRegistry MC_recon_reg{"MC_particles_reco", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - OutputObj histPDG{TH1F("PDG", "PDG;PDG code", 20, 0.0, 20.0)}; + OutputObj histPDG{TH1I("PDG", "PDG;PDG code", 20, 0.0, 20.0)}; + OutputObj histTrackcuts_data{TH1I("histTrackcuts_data", "Entires;Track cut", 15, 0, 15)}; + OutputObj histTrackcuts_MC{TH1I("histTrackcuts_MC", "Entires;Track cut", 15, 0, 15)}; void init(o2::framework::InitContext&) { @@ -66,20 +69,43 @@ struct NucleiHistTask { LOG(fatal) << "Can't enable processData and processDataCent in the same time, pick one!"; } + // +++++++++++++++++++++ Data ++++++++++++++++++++++++ + histTrackcuts_data->GetXaxis()->SetBinLabel(1, "Events read"); + histTrackcuts_data->GetXaxis()->SetBinLabel(2, "Ev. sel. passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(3, "Rap. cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(4, "DCA cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(5, "TPCnCls cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(6, "TPCCrossedRowsOverFindable cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(7, "Chi2 cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(8, "Passed TPC refit cut"); + histTrackcuts_data->GetXaxis()->SetBinLabel(9, "Passed ITS refit cut"); + histTrackcuts_data->GetXaxis()->SetBinLabel(10, "ITSnCls cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(11, "Momentum cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(12, "hasITS & hasTPC cut passed"); + histTrackcuts_data->GetXaxis()->SetBinLabel(13, "GoldenChi2 cut passed"); + + // +++++++++++++++++++++ MC ++++++++++++++++++++++++ + histTrackcuts_MC->GetXaxis()->SetBinLabel(1, "Events read"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(2, "Prim. particle. sel. passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(3, "Rap. cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(4, "DCA cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(5, "TPCnCls cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(6, "TPCCrossedRowsOverFindable cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(7, "Chi2 cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(8, "Passed TPC refit cut"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(9, "Passed ITS refit cut"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(10, "ITSnCls cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(11, "Momentum cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(12, "hasITS & hasTPC cut passed"); + histTrackcuts_MC->GetXaxis()->SetBinLabel(13, "GoldenChi2 cut passed"); + 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 ptBinning_short = {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}; - std::vector ptBinning_diff = {-14.0, -12.0, -10.0, -8.0, -6.0, -5.0, -4.0, -3.6, -3.2, -2.8, -2.4, -2.2, -2.0, -1.8, -1.6, -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.8, 2.0, 2.2, 2.4, 2.8, 3.2, 3.6, 4., 5., 6., 8., 10., 12., 14.}; - std::vector centBinning = {0., 1., 5., 10., 20., 30., 40., 50., 70., 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 ptAxis_reduced = {ptBinning_short, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec pAxis = {ptBinning, "#it{p} (GeV/#it{c})"}; - AxisSpec pAxis_reduced = {ptBinning_short, "#it{p} (GeV/#it{c})"}; - AxisSpec centAxis = {centBinning, "V0M (%)"}; - 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 PDGBINNING = {PDGBinning, "PDG code"}; @@ -87,40 +113,31 @@ struct NucleiHistTask { // QA histograms 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("histTpcSignalData_pT", "Specific energy loss", HistType::kTH2F, {{600, -6., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - spectra_reg.add("histTofSignalData_pT", "TOF signal", HistType::kTH2F, {{600, -6., 6., "#it{p}_{T} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); + 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("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("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("histTOFm2_pT", "TOF m^2 vs Pt", HistType::kTH2F, {ptAxis, {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"}}); spectra_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); spectra_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); spectra_reg.add("histChi2TPC", "chi^2 TPC vs Pt", HistType::kTH2F, {ptAxis, {100, 0.0, 5.0, "chi^2"}}); spectra_reg.add("histChi2ITS", "chi^2 ITS vs Pt", HistType::kTH2F, {ptAxis, {500, 0.0, 50.0, "chi^2"}}); - spectra_reg.add("histCentrality", "Centrality", HistType::kTH1F, {centralityAxis_extended}); + spectra_reg.add("histCentrality", "Centrality", HistType::kTH1F, {centralityAxis}); spectra_reg.add("histEtaWithOverFlow", "Pseudorapidity 0 - 105%% centrality", HistType::kTH1F, {etaAxis}); spectra_reg.add("histEta", "Pseudorapidity with centrality cut", HistType::kTH1F, {etaAxis}); - spectra_reg.add("histEta_cent", "Pseudorapidity vs Centrality", HistType::kTH2F, {centralityAxis_extended, etaAxis}); + spectra_reg.add("histEta_cent", "Pseudorapidity vs Centrality", HistType::kTH2F, {centralityAxis, etaAxis}); // histograms for pi⁺ - pion_reg.add("histKeepEventData", "skimming histogram (#pi^{+})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (#pi^{+})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - pion_reg.add("histTofSignalData_pT", "TOF signal (#pi^{+})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (#pi^{+})", 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("histTOFm2_pT", "TOF m^2 vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {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^{+}}"}}); - pion_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (#pi^{+})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - pion_reg.add("histTofNsigmaData_pT", "n-sigma TOF (#pi^{+})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); pion_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); pion_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); pion_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (#pi^{+})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -134,19 +151,13 @@ struct NucleiHistTask { pion_reg.add("histTofm2_eta", "mass^2 TOF (#pi^{+}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{#pi^{+}}"}, etaAxis}); // histograms for pi⁻ - apion_reg.add("histKeepEventData", "skimming histogram (#pi^{-})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (#pi^{-})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - apion_reg.add("histTofSignalData_pT", "TOF signal (#pi^{-})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (#pi^{-})", 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("histTOFm2_pT", "TOF m^2 vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {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^{+}}"}}); - apion_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (#pi^{-})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - apion_reg.add("histTofNsigmaData_pT", "n-sigma TOF (#pi^{-})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); apion_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); apion_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); apion_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (#pi^{-})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -160,19 +171,13 @@ struct NucleiHistTask { apion_reg.add("histTofm2_eta", "mass^2 TOF (#pi^{-}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{#pi^{+}}"}, etaAxis}); // histograms for Proton - proton_reg.add("histKeepEventData", "skimming histogram (p)", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (p)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - proton_reg.add("histTofSignalData_pT", "TOF signal (p)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (p)", 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("histTOFm2_pT", "TOF m^2 vs Pt (p)", HistType::kTH2F, {ptAxis, {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}"}}); - proton_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (p)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); - proton_reg.add("histTofNsigmaData_pT", "n-sigma TOF (p)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); proton_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (p)", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); proton_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (p)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); proton_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (p)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -186,19 +191,13 @@ struct NucleiHistTask { proton_reg.add("histTofm2_eta", "mass^2 TOF (p) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{p}"}, etaAxis}); // histograms for antiProton - aproton_reg.add("histKeepEventData", "skimming histogram (#bar{p})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (#bar{p})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - aproton_reg.add("histTofSignalData_pT", "TOF signal (#bar{p})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (#bar{p})", 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("histTOFm2_pT", "TOF m^2 vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {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}}"}}); - aproton_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (#bar{p})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{p}}"}}); - aproton_reg.add("histTofNsigmaData_pT", "n-sigma TOF (#bar{p})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{p}}"}}); aproton_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); aproton_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); aproton_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (#bar{p})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -212,19 +211,13 @@ struct NucleiHistTask { aproton_reg.add("histTofm2_eta", "mass^2 TOF (#bar{p}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{#bar{p}}"}, etaAxis}); // histograms for Deuterons - deuteron_reg.add("histKeepEventData", "skimming histogram (d)", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (d)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - deuteron_reg.add("histTofSignalData_pT", "TOF signal (d)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (d)", 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("histTOFm2_pT", "TOF m^2 vs Pt (d)", HistType::kTH2F, {ptAxis, {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}"}}); - deuteron_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (d)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); - deuteron_reg.add("histTofNsigmaData_pT", "n-sigma TOF (d)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); deuteron_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (d)", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); deuteron_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (d)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); deuteron_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (d)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -238,19 +231,13 @@ struct NucleiHistTask { deuteron_reg.add("histTofm2_eta", "mass^2 TOF (d) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{d}"}, etaAxis}); // histograms for antiDeuterons - adeuteron_reg.add("histKeepEventData", "skimming histogram (#bar{d})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (#bar{d})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - adeuteron_reg.add("histTofSignalData_pT", "TOF signal (#bar{d})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (#bar{d})", 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("histTOFm2_pT", "TOF m^2 vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {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}}"}}); - adeuteron_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (#bar{d})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{d}}"}}); - adeuteron_reg.add("histTofNsigmaData_pT", "n-sigma TOF (#bar{d})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{d}}"}}); adeuteron_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); adeuteron_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); adeuteron_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (#bar{d})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -264,19 +251,13 @@ struct NucleiHistTask { adeuteron_reg.add("histTofm2_eta", "mass^2 TOF (#bar{d}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{#bar{d}}"}, etaAxis}); // histograms for Triton - triton_reg.add("histKeepEventData", "skimming histogram (t)", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (t)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - triton_reg.add("histTofSignalData_pT", "TOF signal (t)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (t)", 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("histTOFm2_pT", "TOF m^2 vs Pt (t)", HistType::kTH2F, {ptAxis, {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}"}}); - triton_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (t)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); - triton_reg.add("histTofNsigmaData_pT", "n-sigma TOF (t)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); triton_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (t)", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); triton_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (t)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); triton_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (t)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -290,19 +271,13 @@ struct NucleiHistTask { triton_reg.add("histTofm2_eta", "mass^2 TOF (t) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{t}"}, etaAxis}); // histograms for antiTriton - atriton_reg.add("histKeepEventData", "skimming histogram (#bar{t})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (#bar{t})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - atriton_reg.add("histTofSignalData_pT", "TOF signal (#bar{t})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (#bar{t})", 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("histTOFm2_pT", "TOF m^2 vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {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}}"}}); - atriton_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (#bar{t})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{t}}"}}); - atriton_reg.add("histTofNsigmaData_pT", "n-sigma TOF (#bar{t})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#bar{t}}"}}); atriton_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); atriton_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); atriton_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (#bar{t})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -316,19 +291,13 @@ struct NucleiHistTask { atriton_reg.add("histTofm2_eta", "mass^2 TOF (#bar{t}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{#bar{t}}"}, etaAxis}); // histograms for Helium-3 - Helium3_reg.add("histKeepEventData", "skimming histogram (^{3}He)", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (^{3}He)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - Helium3_reg.add("histTofSignalData_pT", "TOF signal (^{3}He)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (^{3}He)", 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("histTOFm2_pT", "TOF m^2 vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {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}"}}); - Helium3_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (^{3}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); - Helium3_reg.add("histTofNsigmaData_pT", "n-sigma TOF (^{3}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); Helium3_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); Helium3_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); Helium3_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (^{3}He)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -342,19 +311,13 @@ struct NucleiHistTask { Helium3_reg.add("histTofm2_eta", "mass^2 TOF (^{3}He) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{^{3}He}"}, etaAxis}); // histograms for antiHelium-3 - aHelium3_reg.add("histKeepEventData", "skimming histogram (^{3}#bar{He})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (^{3}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - aHelium3_reg.add("histTofSignalData_pT", "TOF signal (^{3}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (^{3}#bar{He})", 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("histTOFm2_pT", "TOF m^2 vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {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}"}}); - aHelium3_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); - aHelium3_reg.add("histTofNsigmaData_pT", "n-sigma TOF (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); aHelium3_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); aHelium3_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); aHelium3_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -368,19 +331,13 @@ struct NucleiHistTask { aHelium3_reg.add("histTofm2_eta", "mass^2 TOF (^{3}#bar{He}) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{^{3}He}"}, etaAxis}); // histograms for Helium-4 (alpha) - Helium4_reg.add("histKeepEventData", "skimming histogram (^{4}He)", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (^{4}He)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - Helium4_reg.add("histTofSignalData_pT", "TOF signal (^{4}He)", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (^{4}He)", 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("histTOFm2_pT", "TOF m^2 vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {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}"}}); - Helium4_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (^{4}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); - Helium4_reg.add("histTofNsigmaData_pT", "n-sigma TOF (^{4}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); Helium4_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); Helium4_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); Helium4_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (^{4}He)", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -394,19 +351,13 @@ struct NucleiHistTask { Helium4_reg.add("histTofm2_eta", "mass^2 TOF (^{4}He) vs eta", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2_{^{4}He}"}, etaAxis}); // histograms for antiHelium-4 (alpha) - aHelium4_reg.add("histKeepEventData", "skimming histogram (^{4}#bar{He})", HistType::kTH1F, {{2, -0.5, +1.5, "true: keep event, false: reject event"}}); 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("histTpcSignalData_pT", "Specific energy loss (^{4}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); - aHelium4_reg.add("histTofSignalData_pT", "TOF signal (^{4}#bar{He})", HistType::kTH2F, {{600, 0., 6., "#it{p}_{T} (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("histDcaZVsPtData", "dcaZ vs Pt (^{4}#bar{He})", 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("histTOFm2_pT", "TOF m^2 vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {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}"}}); - aHelium4_reg.add("histTpcNsigmaData_pT", "n-sigma TPC (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{antiHe-4}"}}); - aHelium4_reg.add("histTofNsigmaData_pT", "n-sigma TOF (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{antiHe-4}"}}); aHelium4_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {160, 0.0, 160.0, "nCluster"}}); aHelium4_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); aHelium4_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {10, 0.0, 10.0, "nCluster"}}); @@ -423,19 +374,16 @@ struct NucleiHistTask { // MC 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("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("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}); - MC_recon_reg.add("histTpcSignalData_pT", "Specific energy loss", HistType::kTH3F, {{600, -6., 6., "#it{p}_{T} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}, PDGBINNING}); - MC_recon_reg.add("histTofSignalData_pT", "TOF signal", HistType::kTH3F, {{600, -6., 6., "#it{p}_{T} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}, PDGBINNING}); MC_recon_reg.add("histTpcSignalData_all_species", "Specific energy loss", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {5000, 0, 5000, "d#it{E} / d#it{X} (a. u.)"}}); MC_recon_reg.add("histTofSignalData_all_species", "TOF signal", HistType::kTH2F, {{600, -6., 6., "#it{p} (GeV/#it{c})"}, {550, 0.0, 1.1, "#beta (TOF)"}}); MC_recon_reg.add("histTOFm2", "TOF m^2 vs Pt", HistType::kTH3F, {pAxis, {400, 0.0, 10.0, "m^2"}, PDGBINNING}); - MC_recon_reg.add("histTOFm2_pT", "TOF m^2 vs Pt", HistType::kTH3F, {ptAxis, {400, 0.0, 10.0, "m^2"}, PDGBINNING}); MC_recon_reg.add("histNClusterTPC", "Number of Clusters in TPC vs Pt", HistType::kTH3F, {ptAxis, {80, 0.0, 160.0, "nCluster"}, PDGBINNING}); MC_recon_reg.add("histNClusterITS", "Number of Clusters in ITS vs Pt", HistType::kTH3F, {ptAxis, {10, 0.0, 10.0, "ITS nCls"}, PDGBINNING}); MC_recon_reg.add("histNClusterITSib", "Number of Clusters in ib of ITS vs Pt", HistType::kTH3F, {ptAxis, {10, 0.0, 10.0, "ITS ib nCls"}, PDGBINNING}); @@ -466,38 +414,15 @@ struct NucleiHistTask { MC_recon_reg.add("histTofNsigmaDataaHe", "TOF nSigma (^{3}#bar{He})", HistType::kTH2F, {pAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); 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_recon_reg.add("histTpcNsigmaDataPi_pT", "TPC nSigma (#pi^{+})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - MC_recon_reg.add("histTpcNsigmaDataaPi_pT", "TPC nSigma (#pi^{-})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - MC_recon_reg.add("histTpcNsigmaDataPr_pT", "TPC nSigma (p)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); - MC_recon_reg.add("histTpcNsigmaDataaPr_pT", "TPC nSigma (#bar{p})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); - MC_recon_reg.add("histTpcNsigmaDataDe_pT", "TPC nSigma (d)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); - MC_recon_reg.add("histTpcNsigmaDataaDe_pT", "TPC nSigma (#bar{d})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); - MC_recon_reg.add("histTpcNsigmaDataTr_pT", "TPC nSigma (t)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); - MC_recon_reg.add("histTpcNsigmaDataaTr_pT", "TPC nSigma (#bar{t})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); - MC_recon_reg.add("histTpcNsigmaDataHe_pT", "TPC nSigma (^{3}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{He-3}"}}); - MC_recon_reg.add("histTpcNsigmaDataaHe_pT", "TPC nSigma (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{He-3}"}}); - MC_recon_reg.add("histTpcNsigmaDataAl_pT", "TPC nSigma (^{4}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{He-4}"}}); - MC_recon_reg.add("histTpcNsigmaDataaAl_pT", "TPC nSigma (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{He-4}"}}); - MC_recon_reg.add("histTofNsigmaDataPi_pT", "TOF nSigma (#pi^{+})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - MC_recon_reg.add("histTofNsigmaDataaPi_pT", "TOF nSigma (#pi^{-})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{#pi^{+}}"}}); - MC_recon_reg.add("histTofNsigmaDataPr_pT", "TOF nSigma (p)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); - MC_recon_reg.add("histTofNsigmaDataaPr_pT", "TOF nSigma (#bar{p})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{p}"}}); - MC_recon_reg.add("histTofNsigmaDataDe_pT", "TOF nSigma (d)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); - MC_recon_reg.add("histTofNsigmaDataaDe_pT", "TOF nSigma (#bar{d})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{d}"}}); - MC_recon_reg.add("histTofNsigmaDataTr_pT", "TOF nSigma (t)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); - MC_recon_reg.add("histTofNsigmaDataaTr_pT", "TOF nSigma (#bar{t})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{t}"}}); - MC_recon_reg.add("histTofNsigmaDataHe_pT", "TOF nSigma (^{3}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); - MC_recon_reg.add("histTofNsigmaDataaHe_pT", "TOF nSigma (^{3}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{3}He}"}}); - MC_recon_reg.add("histTofNsigmaDataAl_pT", "TOF nSigma (^{4}He)", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); - MC_recon_reg.add("histTofNsigmaDataaAl_pT", "TOF nSigma (^{4}#bar{He})", HistType::kTH2F, {ptAxis, {160, -20., +20., "n#sigma_{^{4}He}"}}); } // Configurables + Configurable use_momentum_getter{"use_momentum_getter", 0, "0: track.p(), 1: track.pt(), 2: track.tpcInnerParam()"}; + Configurable momentum_He3{"momentum_He3", 0, "0: momentum * 1.0, 1: momentum * 2.0"}; Configurable yMin{"yMin", -0.5, "Maximum rapidity"}; Configurable yMax{"yMax", 0.5, "Minimum rapidity"}; - Configurable pTmin{"pTmin", 0.1f, "min pT"}; - Configurable pTmax{"pTmax", 1e+10f, "max pT"}; + Configurable p_min{"p_min", 0.1f, "min momentum"}; + Configurable p_max{"p_max", 1e+10f, "max momentum"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutEta{"cfgCutEta", 0.9f, "Eta range for tracks"}; Configurable nsigmacutLow{"nsigmacutLow", -3.0, "Value of the Nsigma cut"}; @@ -507,17 +432,23 @@ struct NucleiHistTask { Configurable enable_Centrality_cut_global{"enable_Centrality_cut_global", true, "use Centrality cut"}; // Replacement for globalTrack 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", 2.0f, "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 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 maxDCA_XY{"maxDCA_XY", 0.5f, "max DCA to vertex xy"}; 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 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"}; @@ -525,20 +456,6 @@ struct NucleiHistTask { void fillHistograms(const CollisionType& event, const TracksType& tracks) { - bool keepEvent_pi = kFALSE; - bool keepEvent_p = kFALSE; - bool keepEvent_d = kFALSE; - bool keepEvent_t = kFALSE; - bool keepEvent_He3 = kFALSE; - bool keepEvent_He4 = kFALSE; - - bool keepEvent_antipi = kFALSE; - bool keepEvent_antip = kFALSE; - bool keepEvent_antid = kFALSE; - bool keepEvent_antit = kFALSE; - bool keepEvent_antiHe3 = kFALSE; - bool keepEvent_antiHe4 = kFALSE; - if (event_selection_sel8 && event.sel8()) { spectra_reg.fill(HIST("histRecVtxZData"), event.posZ()); } @@ -548,9 +465,65 @@ struct NucleiHistTask { for (auto track : tracks) { + histTrackcuts_data->AddBinContent(1); if (event_selection_sel8 && !event.sel8()) continue; + histTrackcuts_data->AddBinContent(2); + double momentum = 0.0; + double momentum_Z_equal_2 = 0.0; + int momentum_getter = 0; + int momentum_getter_Z_equal_2 = 0; + switch (use_momentum_getter) { + case 0: + momentum = track.p(); + switch (momentum_He3) { + case 0: + momentum_Z_equal_2 = track.p(); + break; + case 1: + momentum_Z_equal_2 = track.p() * 2.0; + break; + default: + momentum_getter_Z_equal_2 = -1; + break; + } + break; + case 1: + momentum = track.pt(); + switch (momentum_He3) { + case 0: + momentum_Z_equal_2 = track.pt(); + break; + case 1: + momentum_Z_equal_2 = track.pt() * 2.0; + break; + default: + momentum_getter_Z_equal_2 = -1; + break; + } + break; + case 2: + momentum = track.tpcInnerParam(); + switch (momentum_He3) { + case 0: + momentum_Z_equal_2 = track.tpcInnerParam(); + break; + case 1: + momentum_Z_equal_2 = track.tpcInnerParam() * 2.0; + break; + default: + momentum_getter_Z_equal_2 = -1; + break; + } + break; + default: + momentum_getter = -1; + break; + } + if (momentum_getter == -1 || momentum_getter_Z_equal_2 == -1) + break; + float TPCnumberClsFound = track.tpcNClsFound(); float TPC_nCls_Crossed_Rows = track.tpcNClsCrossedRows(); float RatioCrossedRowsOverFindableTPC = track.tpcCrossedRowsOverFindableCls(); @@ -587,6 +560,7 @@ struct NucleiHistTask { lorentzVector_He3.Rapidity() < yMin || lorentzVector_He3.Rapidity() > yMax || lorentzVector_He4.Rapidity() < yMin || lorentzVector_He4.Rapidity() > yMax) continue; + histTrackcuts_data->AddBinContent(3); float nSigmaPion = track.tpcNSigmaPi(); float nSigmaProton = track.tpcNSigmaPr(); @@ -601,25 +575,46 @@ struct NucleiHistTask { spectra_reg.fill(HIST("histChi2TPC"), track.pt(), track.tpcChi2NCl()); spectra_reg.fill(HIST("histChi2ITS"), track.pt(), track.itsChi2NCl()); - if (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.pt() < pTmin || track.pt() > pTmax) + if (TMath::Abs(track.dcaXY()) > maxDCA_XY || TMath::Abs(track.dcaZ()) > maxDCA_Z) + continue; + histTrackcuts_data->AddBinContent(4); + if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC) continue; + histTrackcuts_data->AddBinContent(5); + if (RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC) + continue; + histTrackcuts_data->AddBinContent(6); + if (Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS) + continue; + histTrackcuts_data->AddBinContent(7); + if (!(track.passedTPCRefit())) + continue; + histTrackcuts_data->AddBinContent(8); + if (!(track.passedITSRefit())) + continue; + histTrackcuts_data->AddBinContent(9); + if ((track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) + continue; + histTrackcuts_data->AddBinContent(10); + if (track.pt() < p_min || track.pt() > p_max) + continue; + histTrackcuts_data->AddBinContent(11); + if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) + continue; + histTrackcuts_data->AddBinContent(12); + if (requireGoldenChi2 && !(track.passedGoldenChi2())) + continue; + histTrackcuts_data->AddBinContent(13); - spectra_reg.fill(HIST("histTpcSignalData"), track.p() * track.sign(), track.tpcSignal()); - spectra_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * track.sign(), track.tpcSignal()); + spectra_reg.fill(HIST("histTpcSignalData"), momentum * track.sign(), track.tpcSignal()); if (track.sign() > 0) { - pion_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaPion); - proton_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaProton); - deuteron_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaDeut); - triton_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaTriton); - Helium3_reg.fill(HIST("histTpcNsigmaData"), track.p() * 2.0, nSigmaHe3); - Helium4_reg.fill(HIST("histTpcNsigmaData"), track.p() * 2.0, nSigmaHe4); - pion_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaPion); - proton_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaProton); - deuteron_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaDeut); - triton_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaTriton); - Helium3_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt() * 2.0, nSigmaHe3); - Helium4_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt() * 2.0, nSigmaHe4); + pion_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaPion); + proton_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaProton); + deuteron_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaDeut); + triton_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaTriton); + Helium3_reg.fill(HIST("histTpcNsigmaData"), momentum_Z_equal_2, nSigmaHe3); + Helium4_reg.fill(HIST("histTpcNsigmaData"), momentum_Z_equal_2, nSigmaHe4); if (track.hasTOF()) { if (track.hasTRD() && (lastRequiredTrdCluster > 0)) { @@ -634,24 +629,17 @@ struct NucleiHistTask { continue; } Float_t TOFmass2 = ((track.mass()) * (track.mass())); - spectra_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - spectra_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); + spectra_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); } } if (track.sign() < 0) { - apion_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaPion); - aproton_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaProton); - adeuteron_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaDeut); - atriton_reg.fill(HIST("histTpcNsigmaData"), track.p(), nSigmaTriton); - aHelium3_reg.fill(HIST("histTpcNsigmaData"), track.p() * 2.0, nSigmaHe3); - aHelium4_reg.fill(HIST("histTpcNsigmaData"), track.p() * 2.0, nSigmaHe4); - apion_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaPion); - aproton_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaProton); - adeuteron_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaDeut); - atriton_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt(), nSigmaTriton); - aHelium3_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt() * 2.0, nSigmaHe3); - aHelium4_reg.fill(HIST("histTpcNsigmaData_pT"), track.pt() * 2.0, nSigmaHe4); + apion_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaPion); + aproton_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaProton); + adeuteron_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaDeut); + atriton_reg.fill(HIST("histTpcNsigmaData"), momentum, nSigmaTriton); + aHelium3_reg.fill(HIST("histTpcNsigmaData"), momentum_Z_equal_2, nSigmaHe3); + aHelium4_reg.fill(HIST("histTpcNsigmaData"), momentum_Z_equal_2, nSigmaHe4); if (track.hasTOF()) { if (track.hasTRD() && (lastRequiredTrdCluster > 0)) { @@ -666,8 +654,7 @@ struct NucleiHistTask { continue; } Float_t TOFmass2 = ((track.mass()) * (track.mass())); - spectra_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - spectra_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); + spectra_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); } } @@ -676,11 +663,9 @@ struct NucleiHistTask { if (nSigmaPion > nsigmacutLow && nSigmaPion < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_pi = kTRUE; pion_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); pion_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - pion_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - pion_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + pion_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); pion_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); pion_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); pion_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -701,21 +686,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - pion_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - pion_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - pion_reg.fill(HIST("histTofSignalData"), track.p(), beta); - pion_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - pion_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaPi()); - pion_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaPi()); + pion_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + pion_reg.fill(HIST("histTofSignalData"), momentum, beta); + pion_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaPi()); } } if (track.sign() < 0) { - keepEvent_antipi = kTRUE; apion_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); apion_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - apion_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - apion_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + apion_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); apion_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); apion_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); apion_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -736,12 +716,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - apion_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - apion_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - apion_reg.fill(HIST("histTofSignalData"), track.p(), beta); - apion_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - apion_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaPi()); - apion_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaPi()); + apion_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + apion_reg.fill(HIST("histTofSignalData"), momentum, beta); + apion_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaPi()); } } @@ -757,8 +734,7 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } @@ -767,11 +743,9 @@ struct NucleiHistTask { if (nSigmaProton > nsigmacutLow && nSigmaProton < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_p = kTRUE; proton_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); proton_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - proton_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - proton_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + proton_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); proton_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); proton_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); proton_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -792,21 +766,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - proton_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - proton_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - proton_reg.fill(HIST("histTofSignalData"), track.p(), beta); - proton_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - proton_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaPr()); - proton_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaPr()); + proton_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + proton_reg.fill(HIST("histTofSignalData"), momentum, beta); + proton_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaPr()); } } if (track.sign() < 0) { - keepEvent_antip = kTRUE; aproton_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); aproton_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - aproton_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - aproton_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + aproton_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); aproton_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); aproton_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); aproton_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -827,12 +796,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - aproton_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - aproton_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - aproton_reg.fill(HIST("histTofSignalData"), track.p(), beta); - aproton_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - aproton_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaPr()); - aproton_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaPr()); + aproton_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + aproton_reg.fill(HIST("histTofSignalData"), momentum, beta); + aproton_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaPr()); } } @@ -848,8 +814,7 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } @@ -858,11 +823,9 @@ struct NucleiHistTask { if (nSigmaDeut > nsigmacutLow && nSigmaDeut < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_d = kTRUE; deuteron_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); deuteron_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - deuteron_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - deuteron_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + deuteron_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); deuteron_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); deuteron_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); deuteron_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -883,21 +846,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - deuteron_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - deuteron_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - deuteron_reg.fill(HIST("histTofSignalData"), track.p(), beta); - deuteron_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - deuteron_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaDe()); - deuteron_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaDe()); + deuteron_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + deuteron_reg.fill(HIST("histTofSignalData"), momentum, beta); + deuteron_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaDe()); } } if (track.sign() < 0) { - keepEvent_antid = kTRUE; adeuteron_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); adeuteron_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - adeuteron_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - adeuteron_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + adeuteron_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); adeuteron_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); adeuteron_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); adeuteron_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -918,12 +876,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - adeuteron_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - adeuteron_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - adeuteron_reg.fill(HIST("histTofSignalData"), track.p(), beta); - adeuteron_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - adeuteron_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaDe()); - adeuteron_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaDe()); + adeuteron_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + adeuteron_reg.fill(HIST("histTofSignalData"), momentum, beta); + adeuteron_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaDe()); } } @@ -939,8 +894,7 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } @@ -949,11 +903,9 @@ struct NucleiHistTask { if (nSigmaTriton > nsigmacutLow && nSigmaTriton < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_t = kTRUE; triton_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); triton_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - triton_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - triton_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + triton_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); triton_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); triton_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); triton_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -974,21 +926,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - triton_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - triton_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - triton_reg.fill(HIST("histTofSignalData"), track.p(), beta); - triton_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - triton_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaTr()); - triton_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaTr()); + triton_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + triton_reg.fill(HIST("histTofSignalData"), momentum, beta); + triton_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaTr()); } } if (track.sign() < 0) { - keepEvent_antit = kTRUE; atriton_reg.fill(HIST("histDcaVsPtData"), track.pt(), track.dcaXY()); atriton_reg.fill(HIST("histDcaZVsPtData"), track.pt(), track.dcaZ()); - atriton_reg.fill(HIST("histTpcSignalData"), track.p(), track.tpcSignal()); - atriton_reg.fill(HIST("histTpcSignalData_pT"), track.pt(), track.tpcSignal()); + atriton_reg.fill(HIST("histTpcSignalData"), momentum, track.tpcSignal()); atriton_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsFound()); atriton_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls()); atriton_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel()); @@ -1009,12 +956,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - atriton_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2); - atriton_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2); - atriton_reg.fill(HIST("histTofSignalData"), track.p(), beta); - atriton_reg.fill(HIST("histTofSignalData_pT"), track.pt(), beta); - atriton_reg.fill(HIST("histTofNsigmaData"), track.p(), track.tofNSigmaTr()); - atriton_reg.fill(HIST("histTofNsigmaData_pT"), track.pt(), track.tofNSigmaTr()); + atriton_reg.fill(HIST("histTOFm2"), momentum, TOFmass2); + atriton_reg.fill(HIST("histTofSignalData"), momentum, beta); + atriton_reg.fill(HIST("histTofNsigmaData"), momentum, track.tofNSigmaTr()); } } @@ -1030,8 +974,7 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta()); } } @@ -1040,11 +983,9 @@ struct NucleiHistTask { if (nSigmaHe3 > nsigmacutLow && nSigmaHe3 < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_He3 = kTRUE; Helium3_reg.fill(HIST("histDcaVsPtData"), track.pt() * 2.0, track.dcaXY()); Helium3_reg.fill(HIST("histDcaZVsPtData"), track.pt() * 2.0, track.dcaZ()); - Helium3_reg.fill(HIST("histTpcSignalData"), track.p() * 2.0, track.tpcSignal()); - Helium3_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * 2.0, track.tpcSignal()); + Helium3_reg.fill(HIST("histTpcSignalData"), momentum_Z_equal_2, track.tpcSignal()); Helium3_reg.fill(HIST("histNClusterTPC"), track.pt() * 2.0, track.tpcNClsFound()); Helium3_reg.fill(HIST("histNClusterITS"), track.pt() * 2.0, track.itsNCls()); Helium3_reg.fill(HIST("histNClusterITSib"), track.pt() * 2.0, track.itsNClsInnerBarrel()); @@ -1065,21 +1006,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - Helium3_reg.fill(HIST("histTOFm2"), track.p() * 2.0, TOFmass2); - Helium3_reg.fill(HIST("histTOFm2_pT"), track.pt() * 2.0, TOFmass2); - Helium3_reg.fill(HIST("histTofSignalData"), track.p() * 2.0, beta); - Helium3_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0, beta); - Helium3_reg.fill(HIST("histTofNsigmaData"), track.p() * 2.0, track.tofNSigmaHe()); - Helium3_reg.fill(HIST("histTofNsigmaData_pT"), track.pt() * 2.0, track.tofNSigmaHe()); + Helium3_reg.fill(HIST("histTOFm2"), momentum_Z_equal_2, TOFmass2); + Helium3_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2, beta); + Helium3_reg.fill(HIST("histTofNsigmaData"), momentum_Z_equal_2, track.tofNSigmaHe()); } } if (track.sign() < 0) { - keepEvent_antiHe3 = kTRUE; aHelium3_reg.fill(HIST("histDcaVsPtData"), track.pt() * 2.0, track.dcaXY()); aHelium3_reg.fill(HIST("histDcaZVsPtData"), track.pt() * 2.0, track.dcaZ()); - aHelium3_reg.fill(HIST("histTpcSignalData"), track.p() * 2.0, track.tpcSignal()); - aHelium3_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * 2.0, track.tpcSignal()); + aHelium3_reg.fill(HIST("histTpcSignalData"), momentum_Z_equal_2, track.tpcSignal()); aHelium3_reg.fill(HIST("histNClusterTPC"), track.pt() * 2.0, track.tpcNClsFound()); aHelium3_reg.fill(HIST("histNClusterITS"), track.pt() * 2.0, track.itsNCls()); aHelium3_reg.fill(HIST("histNClusterITSib"), track.pt() * 2.0, track.itsNClsInnerBarrel()); @@ -1100,12 +1036,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - aHelium3_reg.fill(HIST("histTOFm2"), track.p() * 2.0, TOFmass2); - aHelium3_reg.fill(HIST("histTOFm2_pT"), track.pt() * 2.0, TOFmass2); - aHelium3_reg.fill(HIST("histTofSignalData"), track.p() * 2.0, beta); - aHelium3_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0, beta); - aHelium3_reg.fill(HIST("histTofNsigmaData"), track.p() * 2.0, track.tofNSigmaHe()); - aHelium3_reg.fill(HIST("histTofNsigmaData_pT"), track.pt() * 2.0, track.tofNSigmaHe()); + aHelium3_reg.fill(HIST("histTOFm2"), momentum_Z_equal_2, TOFmass2); + aHelium3_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2, beta); + aHelium3_reg.fill(HIST("histTofNsigmaData"), momentum_Z_equal_2, track.tofNSigmaHe()); } } @@ -1121,8 +1054,7 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * 2.0 * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0 * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2 * track.sign(), track.beta()); } } @@ -1131,11 +1063,9 @@ struct NucleiHistTask { if (nSigmaHe4 > nsigmacutLow && nSigmaHe4 < nsigmacutHigh) { if (track.sign() > 0) { - keepEvent_He4 = kTRUE; Helium4_reg.fill(HIST("histDcaVsPtData"), track.pt() * 2.0, track.dcaXY()); Helium4_reg.fill(HIST("histDcaZVsPtData"), track.pt() * 2.0, track.dcaZ()); - Helium4_reg.fill(HIST("histTpcSignalData"), track.p() * 2.0, track.tpcSignal()); - Helium4_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * 2.0, track.tpcSignal()); + Helium4_reg.fill(HIST("histTpcSignalData"), momentum_Z_equal_2, track.tpcSignal()); Helium4_reg.fill(HIST("histNClusterTPC"), track.pt() * 2.0, track.tpcNClsFound()); Helium4_reg.fill(HIST("histNClusterITS"), track.pt() * 2.0, track.itsNCls()); Helium4_reg.fill(HIST("histNClusterITSib"), track.pt() * 2.0, track.itsNClsInnerBarrel()); @@ -1156,21 +1086,16 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - Helium4_reg.fill(HIST("histTOFm2"), track.p() * 2.0, TOFmass2); - Helium4_reg.fill(HIST("histTOFm2_pT"), track.pt() * 2.0, TOFmass2); - Helium4_reg.fill(HIST("histTofSignalData"), track.p() * 2.0, beta); - Helium4_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0, beta); - Helium4_reg.fill(HIST("histTofNsigmaData"), track.p() * 2.0, track.tofNSigmaAl()); - Helium4_reg.fill(HIST("histTofNsigmaData_pT"), track.pt() * 2.0, track.tofNSigmaAl()); + Helium4_reg.fill(HIST("histTOFm2"), momentum_Z_equal_2, TOFmass2); + Helium4_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2, beta); + Helium4_reg.fill(HIST("histTofNsigmaData"), momentum_Z_equal_2, track.tofNSigmaAl()); } } if (track.sign() < 0) { - keepEvent_antiHe4 = kTRUE; aHelium4_reg.fill(HIST("histDcaVsPtData"), track.pt() * 2.0, track.dcaXY()); aHelium4_reg.fill(HIST("histDcaZVsPtData"), track.pt() * 2.0, track.dcaZ()); - aHelium4_reg.fill(HIST("histTpcSignalData"), track.p() * 2.0, track.tpcSignal()); - aHelium4_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * 2.0, track.tpcSignal()); + aHelium4_reg.fill(HIST("histTpcSignalData"), momentum_Z_equal_2, track.tpcSignal()); aHelium4_reg.fill(HIST("histNClusterTPC"), track.pt() * 2.0, track.tpcNClsFound()); aHelium4_reg.fill(HIST("histNClusterITS"), track.pt() * 2.0, track.itsNCls()); aHelium4_reg.fill(HIST("histNClusterITSib"), track.pt() * 2.0, track.itsNClsInnerBarrel()); @@ -1191,12 +1116,9 @@ struct NucleiHistTask { } Float_t TOFmass2 = ((track.mass()) * (track.mass())); Float_t beta = track.beta(); - aHelium4_reg.fill(HIST("histTOFm2"), track.p() * 2.0, TOFmass2); - aHelium4_reg.fill(HIST("histTOFm2_pT"), track.pt() * 2.0, TOFmass2); - aHelium4_reg.fill(HIST("histTofSignalData"), track.p() * 2.0, beta); - aHelium4_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0, beta); - aHelium4_reg.fill(HIST("histTofNsigmaData"), track.p() * 2.0, track.tofNSigmaAl()); - aHelium4_reg.fill(HIST("histTofNsigmaData_pT"), track.pt() * 2.0, track.tofNSigmaAl()); + aHelium4_reg.fill(HIST("histTOFm2"), momentum_Z_equal_2, TOFmass2); + aHelium4_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2, beta); + aHelium4_reg.fill(HIST("histTofNsigmaData"), momentum_Z_equal_2, track.tofNSigmaAl()); } } @@ -1212,24 +1134,10 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - spectra_reg.fill(HIST("histTofSignalData"), track.p() * 2.0 * track.sign(), track.beta()); - spectra_reg.fill(HIST("histTofSignalData_pT"), track.pt() * 2.0 * track.sign(), track.beta()); + spectra_reg.fill(HIST("histTofSignalData"), momentum_Z_equal_2 * track.sign(), track.beta()); } } } - - pion_reg.fill(HIST("histKeepEventData"), keepEvent_pi); - apion_reg.fill(HIST("histKeepEventData"), keepEvent_antipi); - proton_reg.fill(HIST("histKeepEventData"), keepEvent_p); - aproton_reg.fill(HIST("histKeepEventData"), keepEvent_antip); - deuteron_reg.fill(HIST("histKeepEventData"), keepEvent_d); - adeuteron_reg.fill(HIST("histKeepEventData"), keepEvent_antid); - triton_reg.fill(HIST("histKeepEventData"), keepEvent_t); - atriton_reg.fill(HIST("histKeepEventData"), keepEvent_antit); - Helium3_reg.fill(HIST("histKeepEventData"), keepEvent_He3); - aHelium3_reg.fill(HIST("histKeepEventData"), keepEvent_antiHe3); - Helium4_reg.fill(HIST("histKeepEventData"), keepEvent_He4); - aHelium4_reg.fill(HIST("histKeepEventData"), keepEvent_antiHe4); } //**************************************************************************************************** @@ -1248,6 +1156,25 @@ struct NucleiHistTask { if ((event_selection_sel8 && !event.sel8()) || (enable_Centrality_cut_global && (event.centFT0C() < minCentrality) && (event.centFT0C() > maxCentrality))) continue; + double momentum = 0.0; + int momentum_getter = 0; + switch (use_momentum_getter) { + case 0: + momentum = track.p(); + break; + case 1: + momentum = track.pt(); + break; + case 2: + momentum = track.tpcInnerParam(); + break; + default: + momentum_getter = -1; + break; + } + if (momentum_getter == -1) + break; + spectra_reg.fill(HIST("histEtaWithOverFlow"), track.eta()); spectra_reg.fill(HIST("histEta_cent"), event.centFT0C(), track.eta()); @@ -1261,7 +1188,25 @@ struct NucleiHistTask { float Chi2perClusterTPC = track.tpcChi2NCl(); float Chi2perClusterITS = track.itsChi2NCl(); - 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) + if (TMath::Abs(track.dcaXY()) > maxDCA_XY || TMath::Abs(track.dcaZ()) > maxDCA_Z) + continue; + 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; TLorentzVector lorentzVector_pion{}; @@ -1288,20 +1233,20 @@ struct NucleiHistTask { if (track.sign() > 0) { - pion_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaPi(), event.centFT0C()); - proton_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaPr(), event.centFT0C()); - deuteron_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaDe(), event.centFT0C()); - triton_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaTr(), event.centFT0C()); - Helium3_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt() * 2.0, track.tpcNSigmaHe(), event.centFT0C()); - Helium4_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt() * 2.0, track.tpcNSigmaAl(), event.centFT0C()); + pion_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaPi(), event.centFT0C()); + proton_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaPr(), event.centFT0C()); + deuteron_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaDe(), event.centFT0C()); + triton_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaTr(), event.centFT0C()); + Helium3_reg.fill(HIST("histTpcNsigmaData_cent"), momentum * 2.0, track.tpcNSigmaHe(), event.centFT0C()); + Helium4_reg.fill(HIST("histTpcNsigmaData_cent"), momentum * 2.0, track.tpcNSigmaAl(), event.centFT0C()); if ((event.centFT0C() > minCentrality) && (event.centFT0C() < maxCentrality)) { - pion_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaPi(), track.eta()); - proton_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaPr(), track.eta()); - deuteron_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaDe(), track.eta()); - triton_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaTr(), track.eta()); - Helium3_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt() * 2.0, track.tpcNSigmaHe(), track.eta()); - Helium4_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt() * 2.0, track.tpcNSigmaAl(), track.eta()); + pion_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaPi(), track.eta()); + proton_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaPr(), track.eta()); + deuteron_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaDe(), track.eta()); + triton_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaTr(), track.eta()); + Helium3_reg.fill(HIST("histTpcNsigmaData_eta"), momentum * 2.0, track.tpcNSigmaHe(), track.eta()); + Helium4_reg.fill(HIST("histTpcNsigmaData_eta"), momentum * 2.0, track.tpcNSigmaAl(), track.eta()); } if (track.hasTOF()) { @@ -1316,54 +1261,53 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - - pion_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaPi(), event.centFT0C()); - proton_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaPr(), event.centFT0C()); - deuteron_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaDe(), event.centFT0C()); - triton_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaTr(), event.centFT0C()); - Helium3_reg.fill(HIST("histTofNsigmaData_cent"), track.pt() * 2.0, track.tofNSigmaHe(), event.centFT0C()); - Helium4_reg.fill(HIST("histTofNsigmaData_cent"), track.pt() * 2.0, track.tofNSigmaAl(), event.centFT0C()); - - pion_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - proton_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - deuteron_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - triton_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - Helium3_reg.fill(HIST("histTofm2_cent"), track.pt() * 2.0, track.mass() * track.mass(), event.centFT0C()); - Helium4_reg.fill(HIST("histTofm2_cent"), track.pt() * 2.0, track.mass() * track.mass(), event.centFT0C()); + pion_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaPi(), event.centFT0C()); + proton_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaPr(), event.centFT0C()); + deuteron_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaDe(), event.centFT0C()); + triton_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaTr(), event.centFT0C()); + Helium3_reg.fill(HIST("histTofNsigmaData_cent"), momentum * 2.0, track.tofNSigmaHe(), event.centFT0C()); + Helium4_reg.fill(HIST("histTofNsigmaData_cent"), momentum * 2.0, track.tofNSigmaAl(), event.centFT0C()); + + pion_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + proton_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + deuteron_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + triton_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + Helium3_reg.fill(HIST("histTofm2_cent"), momentum * 2.0, track.mass() * track.mass(), event.centFT0C()); + Helium4_reg.fill(HIST("histTofm2_cent"), momentum * 2.0, track.mass() * track.mass(), event.centFT0C()); if ((event.centFT0C() > minCentrality) && (event.centFT0C() < maxCentrality)) { - pion_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - pion_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaPi(), track.eta()); - proton_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - proton_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaPr(), track.eta()); - deuteron_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - deuteron_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaDe(), track.eta()); - triton_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - triton_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaTr(), track.eta()); - Helium3_reg.fill(HIST("histTofm2_eta"), track.pt() * 2.0, track.mass() * track.mass(), track.eta()); - Helium3_reg.fill(HIST("histTofNsigmaData_eta"), track.pt() * 2.0, track.tofNSigmaHe(), track.eta()); - Helium4_reg.fill(HIST("histTofm2_eta"), track.pt() * 2.0, track.mass() * track.mass(), track.eta()); - Helium4_reg.fill(HIST("histTofNsigmaData_eta"), track.pt() * 2.0, track.tofNSigmaAl(), track.eta()); + pion_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + pion_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaPi(), track.eta()); + proton_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + proton_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaPr(), track.eta()); + deuteron_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + deuteron_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaDe(), track.eta()); + triton_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + triton_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaTr(), track.eta()); + Helium3_reg.fill(HIST("histTofm2_eta"), momentum * 2.0, track.mass() * track.mass(), track.eta()); + Helium3_reg.fill(HIST("histTofNsigmaData_eta"), momentum * 2.0, track.tofNSigmaHe(), track.eta()); + Helium4_reg.fill(HIST("histTofm2_eta"), momentum * 2.0, track.mass() * track.mass(), track.eta()); + Helium4_reg.fill(HIST("histTofNsigmaData_eta"), momentum * 2.0, track.tofNSigmaAl(), track.eta()); } } } if (track.sign() < 0) { - apion_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaPi(), event.centFT0C()); - aproton_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaPr(), event.centFT0C()); - adeuteron_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaDe(), event.centFT0C()); - atriton_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt(), track.tpcNSigmaTr(), event.centFT0C()); - aHelium3_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt() * 2.0, track.tpcNSigmaHe(), event.centFT0C()); - aHelium4_reg.fill(HIST("histTpcNsigmaData_cent"), track.pt() * 2.0, track.tpcNSigmaAl(), event.centFT0C()); + apion_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaPi(), event.centFT0C()); + aproton_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaPr(), event.centFT0C()); + adeuteron_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaDe(), event.centFT0C()); + atriton_reg.fill(HIST("histTpcNsigmaData_cent"), momentum, track.tpcNSigmaTr(), event.centFT0C()); + aHelium3_reg.fill(HIST("histTpcNsigmaData_cent"), momentum * 2.0, track.tpcNSigmaHe(), event.centFT0C()); + aHelium4_reg.fill(HIST("histTpcNsigmaData_cent"), momentum * 2.0, track.tpcNSigmaAl(), event.centFT0C()); if ((event.centFT0C() > minCentrality) && (event.centFT0C() < maxCentrality)) { - apion_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaPi(), track.eta()); - aproton_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaPr(), track.eta()); - adeuteron_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaDe(), track.eta()); - atriton_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt(), track.tpcNSigmaTr(), track.eta()); - aHelium3_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt() * 2.0, track.tpcNSigmaHe(), track.eta()); - aHelium4_reg.fill(HIST("histTpcNsigmaData_eta"), track.pt() * 2.0, track.tpcNSigmaAl(), track.eta()); + apion_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaPi(), track.eta()); + aproton_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaPr(), track.eta()); + adeuteron_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaDe(), track.eta()); + atriton_reg.fill(HIST("histTpcNsigmaData_eta"), momentum, track.tpcNSigmaTr(), track.eta()); + aHelium3_reg.fill(HIST("histTpcNsigmaData_eta"), momentum * 2.0, track.tpcNSigmaHe(), track.eta()); + aHelium4_reg.fill(HIST("histTpcNsigmaData_eta"), momentum * 2.0, track.tpcNSigmaAl(), track.eta()); } if (track.hasTOF()) { @@ -1378,34 +1322,33 @@ struct NucleiHistTask { if (lastLayer < lastRequiredTrdCluster) continue; } - - apion_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaPi(), event.centFT0C()); - aproton_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaPr(), event.centFT0C()); - adeuteron_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaDe(), event.centFT0C()); - atriton_reg.fill(HIST("histTofNsigmaData_cent"), track.pt(), track.tofNSigmaTr(), event.centFT0C()); - aHelium3_reg.fill(HIST("histTofNsigmaData_cent"), track.pt() * 2.0, track.tofNSigmaHe(), event.centFT0C()); - aHelium4_reg.fill(HIST("histTofNsigmaData_cent"), track.pt() * 2.0, track.tofNSigmaAl(), event.centFT0C()); - - apion_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - aproton_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - adeuteron_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - atriton_reg.fill(HIST("histTofm2_cent"), track.pt(), track.mass() * track.mass(), event.centFT0C()); - aHelium3_reg.fill(HIST("histTofm2_cent"), track.pt() * 2.0, track.mass() * track.mass(), event.centFT0C()); - aHelium4_reg.fill(HIST("histTofm2_cent"), track.pt() * 2.0, track.mass() * track.mass(), event.centFT0C()); + apion_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaPi(), event.centFT0C()); + aproton_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaPr(), event.centFT0C()); + adeuteron_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaDe(), event.centFT0C()); + atriton_reg.fill(HIST("histTofNsigmaData_cent"), momentum, track.tofNSigmaTr(), event.centFT0C()); + aHelium3_reg.fill(HIST("histTofNsigmaData_cent"), momentum * 2.0, track.tofNSigmaHe(), event.centFT0C()); + aHelium4_reg.fill(HIST("histTofNsigmaData_cent"), momentum * 2.0, track.tofNSigmaAl(), event.centFT0C()); + + apion_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + aproton_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + adeuteron_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + atriton_reg.fill(HIST("histTofm2_cent"), momentum, track.mass() * track.mass(), event.centFT0C()); + aHelium3_reg.fill(HIST("histTofm2_cent"), momentum * 2.0, track.mass() * track.mass(), event.centFT0C()); + aHelium4_reg.fill(HIST("histTofm2_cent"), momentum * 2.0, track.mass() * track.mass(), event.centFT0C()); if ((event.centFT0C() > minCentrality) && (event.centFT0C() < maxCentrality)) { - apion_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - apion_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaPi(), track.eta()); - aproton_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - aproton_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaPr(), track.eta()); - adeuteron_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - adeuteron_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaDe(), track.eta()); - atriton_reg.fill(HIST("histTofm2_eta"), track.pt(), track.mass() * track.mass(), track.eta()); - atriton_reg.fill(HIST("histTofNsigmaData_eta"), track.pt(), track.tofNSigmaTr(), track.eta()); - aHelium3_reg.fill(HIST("histTofm2_eta"), track.pt() * 2.0, track.mass() * track.mass(), track.eta()); - aHelium3_reg.fill(HIST("histTofNsigmaData_eta"), track.pt() * 2.0, track.tofNSigmaHe(), track.eta()); - aHelium4_reg.fill(HIST("histTofm2_eta"), track.pt() * 2.0, track.mass() * track.mass(), track.eta()); - aHelium4_reg.fill(HIST("histTofNsigmaData_eta"), track.pt() * 2.0, track.tofNSigmaAl(), track.eta()); + apion_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + apion_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaPi(), track.eta()); + aproton_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + aproton_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaPr(), track.eta()); + adeuteron_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + adeuteron_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaDe(), track.eta()); + atriton_reg.fill(HIST("histTofm2_eta"), momentum, track.mass() * track.mass(), track.eta()); + atriton_reg.fill(HIST("histTofNsigmaData_eta"), momentum, track.tofNSigmaTr(), track.eta()); + aHelium3_reg.fill(HIST("histTofm2_eta"), momentum * 2.0, track.mass() * track.mass(), track.eta()); + aHelium3_reg.fill(HIST("histTofNsigmaData_eta"), momentum * 2.0, track.tofNSigmaHe(), track.eta()); + aHelium4_reg.fill(HIST("histTofm2_eta"), momentum * 2.0, track.mass() * track.mass(), track.eta()); + aHelium4_reg.fill(HIST("histTofNsigmaData_eta"), momentum * 2.0, track.tofNSigmaAl(), track.eta()); } } } @@ -1446,9 +1389,11 @@ struct NucleiHistTask { MC_recon_reg.fill(HIST("histCentrality"), collisions.centFT0C()); for (auto& track : tracks) { + histTrackcuts_MC->AddBinContent(1); const auto particle = track.mcParticle(); if (!particle.isPhysicalPrimary()) continue; + histTrackcuts_MC->AddBinContent(2); int pdgbin = 0; switch (particle.pdgCode()) { @@ -1513,6 +1458,25 @@ struct NucleiHistTask { break; } + double momentum = 0.0; + int momentum_getter = 0; + switch (use_momentum_getter) { + case 0: + momentum = track.p(); + break; + case 1: + momentum = track.pt(); + break; + case 2: + momentum = track.tpcInnerParam(); + break; + default: + momentum_getter = -1; + break; + } + if (momentum_getter == -1) + break; + TLorentzVector lorentzVector_pion{}; TLorentzVector lorentzVector_kaon{}; TLorentzVector lorentzVector_proton{}; @@ -1537,6 +1501,7 @@ struct NucleiHistTask { lorentzVector_He3.Rapidity() < yMin || lorentzVector_He3.Rapidity() > yMax || lorentzVector_He4.Rapidity() < yMin || lorentzVector_He4.Rapidity() > yMax) continue; + histTrackcuts_MC->AddBinContent(3); MC_recon_reg.fill(HIST("histEta"), track.eta(), pdgbin); @@ -1544,9 +1509,8 @@ struct NucleiHistTask { MC_recon_reg.fill(HIST("histPt"), track.pt() * 2.0, pdgbin); MC_recon_reg.fill(HIST("histDCA"), track.pt() * 2.0, track.dcaXY(), pdgbin); MC_recon_reg.fill(HIST("histDCAz"), track.pt() * 2.0, track.dcaZ(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData"), track.p() * 2.0 * track.sign(), track.tpcSignal(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * 2.0 * track.sign(), track.tpcSignal(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData_all_species"), track.pt() * 2.0 * track.sign(), track.tpcSignal()); + MC_recon_reg.fill(HIST("histTpcSignalData"), momentum * 2.0 * track.sign(), track.tpcSignal(), pdgbin); + MC_recon_reg.fill(HIST("histTpcSignalData_all_species"), momentum * 2.0 * track.sign(), track.tpcSignal()); MC_recon_reg.fill(HIST("histNClusterTPC"), track.pt() * 2.0, track.tpcNClsCrossedRows(), pdgbin); MC_recon_reg.fill(HIST("histNClusterITS"), track.pt() * 2.0, track.itsNCls(), pdgbin); MC_recon_reg.fill(HIST("histNClusterITSib"), track.pt() * 2.0, track.itsNClsInnerBarrel(), pdgbin); @@ -1557,9 +1521,8 @@ struct NucleiHistTask { MC_recon_reg.fill(HIST("histPt"), track.pt(), pdgbin); MC_recon_reg.fill(HIST("histDCA"), track.pt(), track.dcaXY(), pdgbin); MC_recon_reg.fill(HIST("histDCAz"), track.pt(), track.dcaZ(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData"), track.p() * track.sign(), track.tpcSignal(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData_pT"), track.pt() * track.sign(), track.tpcSignal(), pdgbin); - MC_recon_reg.fill(HIST("histTpcSignalData_all_species"), track.pt() * track.sign(), track.tpcSignal()); + MC_recon_reg.fill(HIST("histTpcSignalData"), momentum * track.sign(), track.tpcSignal(), pdgbin); + MC_recon_reg.fill(HIST("histTpcSignalData_all_species"), momentum * track.sign(), track.tpcSignal()); MC_recon_reg.fill(HIST("histNClusterTPC"), track.pt(), track.tpcNClsCrossedRows(), pdgbin); MC_recon_reg.fill(HIST("histNClusterITS"), track.pt(), track.itsNCls(), pdgbin); MC_recon_reg.fill(HIST("histNClusterITSib"), track.pt(), track.itsNClsInnerBarrel(), pdgbin); @@ -1574,8 +1537,37 @@ struct NucleiHistTask { float Chi2perClusterTPC = track.tpcChi2NCl(); float Chi2perClusterITS = track.itsChi2NCl(); - 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 (TMath::Abs(track.dcaXY()) > maxDCA_XY || TMath::Abs(track.dcaZ()) > maxDCA_Z) + continue; + histTrackcuts_MC->AddBinContent(4); + if (TPCnumberClsFound < minTPCnClsFound || TPC_nCls_Crossed_Rows < minNCrossedRowsTPC) + continue; + histTrackcuts_MC->AddBinContent(5); + if (RatioCrossedRowsOverFindableTPC < minRatioCrossedRowsTPC || RatioCrossedRowsOverFindableTPC > maxRatioCrossedRowsTPC) + continue; + histTrackcuts_MC->AddBinContent(6); + if (Chi2perClusterTPC > maxChi2PerClusterTPC || Chi2perClusterTPC < minChi2PerClusterTPC || Chi2perClusterITS > maxChi2PerClusterITS) + continue; + histTrackcuts_MC->AddBinContent(7); + if (!(track.passedTPCRefit())) + continue; + histTrackcuts_MC->AddBinContent(8); + if (!(track.passedITSRefit())) + continue; + histTrackcuts_MC->AddBinContent(9); + if ((track.itsNClsInnerBarrel()) < minReqClusterITSib || (track.itsNCls()) < minReqClusterITS) + continue; + histTrackcuts_MC->AddBinContent(10); + if (track.pt() < p_min || track.pt() > p_max) + continue; + histTrackcuts_MC->AddBinContent(11); + + if ((requireITS && !(track.hasITS())) || (requireTPC && !(track.hasTPC()))) + continue; + histTrackcuts_MC->AddBinContent(12); + if (requireGoldenChi2 && !(track.passedGoldenChi2())) continue; + histTrackcuts_MC->AddBinContent(13); float nSigmaPion = track.tpcNSigmaPi(); float nSigmaProton = track.tpcNSigmaPr(); @@ -1585,82 +1577,56 @@ struct NucleiHistTask { float nSigmaHe4 = track.tpcNSigmaAl(); if (track.sign() > 0) { - MC_recon_reg.fill(HIST("histTpcNsigmaDataPi"), track.p(), nSigmaPion); - MC_recon_reg.fill(HIST("histTpcNsigmaDataPr"), track.p(), nSigmaProton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataDe"), track.p(), nSigmaDeuteron); - MC_recon_reg.fill(HIST("histTpcNsigmaDataTr"), track.p(), nSigmaTriton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataHe"), track.p() * 2.0, nSigmaHe3); - MC_recon_reg.fill(HIST("histTpcNsigmaDataAl"), track.p() * 2.0, nSigmaHe4); - MC_recon_reg.fill(HIST("histTpcNsigmaDataPi_pT"), track.pt(), nSigmaPion); - MC_recon_reg.fill(HIST("histTpcNsigmaDataPr_pT"), track.pt(), nSigmaProton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataDe_pT"), track.pt(), nSigmaDeuteron); - MC_recon_reg.fill(HIST("histTpcNsigmaDataTr_pT"), track.pt(), nSigmaTriton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataHe_pT"), track.pt() * 2.0, nSigmaHe3); - MC_recon_reg.fill(HIST("histTpcNsigmaDataAl_pT"), track.pt() * 2.0, nSigmaHe4); + MC_recon_reg.fill(HIST("histTpcNsigmaDataPi"), momentum, nSigmaPion); + MC_recon_reg.fill(HIST("histTpcNsigmaDataPr"), momentum, nSigmaProton); + MC_recon_reg.fill(HIST("histTpcNsigmaDataDe"), momentum, nSigmaDeuteron); + MC_recon_reg.fill(HIST("histTpcNsigmaDataTr"), momentum, nSigmaTriton); + MC_recon_reg.fill(HIST("histTpcNsigmaDataHe"), momentum * 2.0, nSigmaHe3); + MC_recon_reg.fill(HIST("histTpcNsigmaDataAl"), momentum * 2.0, nSigmaHe4); } if (track.sign() < 0) { - MC_recon_reg.fill(HIST("histTpcNsigmaDataaPi"), track.p(), nSigmaPion); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaPr"), track.p(), nSigmaProton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaDe"), track.p(), nSigmaDeuteron); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaTr"), track.p(), nSigmaTriton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaHe"), track.p() * 2.0, nSigmaHe3); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaAl"), track.p() * 2.0, nSigmaHe4); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaPi_pT"), track.pt(), nSigmaPion); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaPr_pT"), track.pt(), nSigmaProton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaDe_pT"), track.pt(), nSigmaDeuteron); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaTr_pT"), track.pt(), nSigmaTriton); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaHe_pT"), track.pt() * 2.0, nSigmaHe3); - MC_recon_reg.fill(HIST("histTpcNsigmaDataaAl_pT"), track.pt() * 2.0, nSigmaHe4); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaPi"), momentum, nSigmaPion); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaPr"), momentum, nSigmaProton); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaDe"), momentum, nSigmaDeuteron); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaTr"), momentum, nSigmaTriton); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaHe"), momentum * 2.0, nSigmaHe3); + MC_recon_reg.fill(HIST("histTpcNsigmaDataaAl"), momentum * 2.0, nSigmaHe4); } if (track.hasTOF()) { Float_t TOFmass2 = ((track.mass()) * (track.mass())); - MC_recon_reg.fill(HIST("histTOFm2"), track.p(), TOFmass2, pdgbin); - MC_recon_reg.fill(HIST("histTOFm2_pT"), track.pt(), TOFmass2, pdgbin); - MC_recon_reg.fill(HIST("histTofSignalData"), track.p() * track.sign(), track.beta(), pdgbin); - MC_recon_reg.fill(HIST("histTofSignalData_pT"), track.pt() * track.sign(), track.beta(), pdgbin); - MC_recon_reg.fill(HIST("histTofSignalData_all_species"), track.pt() * track.sign(), track.beta()); + MC_recon_reg.fill(HIST("histTOFm2"), momentum, TOFmass2, pdgbin); + MC_recon_reg.fill(HIST("histTofSignalData"), momentum * track.sign(), track.beta(), pdgbin); + MC_recon_reg.fill(HIST("histTofSignalData_all_species"), momentum * track.sign(), track.beta()); if (track.sign() > 0) { if (nSigmaPion > nsigmacutLow && nSigmaPion < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataPi"), track.p(), track.tofNSigmaPi()); - MC_recon_reg.fill(HIST("histTofNsigmaDataPi_pT"), track.pt(), track.tofNSigmaPi()); + MC_recon_reg.fill(HIST("histTofNsigmaDataPi"), momentum, track.tofNSigmaPi()); if (nSigmaProton > nsigmacutLow && nSigmaProton < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataPr"), track.p(), track.tofNSigmaPr()); - MC_recon_reg.fill(HIST("histTofNsigmaDataPr_pT"), track.pt(), track.tofNSigmaPr()); + MC_recon_reg.fill(HIST("histTofNsigmaDataPr"), momentum, track.tofNSigmaPr()); if (nSigmaDeuteron > nsigmacutLow && nSigmaDeuteron < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataDe"), track.p(), track.tofNSigmaDe()); - MC_recon_reg.fill(HIST("histTofNsigmaDataDe_pT"), track.pt(), track.tofNSigmaDe()); + MC_recon_reg.fill(HIST("histTofNsigmaDataDe"), momentum, track.tofNSigmaDe()); if (nSigmaTriton > nsigmacutLow && nSigmaTriton < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataTr"), track.p(), track.tofNSigmaTr()); - MC_recon_reg.fill(HIST("histTofNsigmaDataTr_pT"), track.pt(), track.tofNSigmaTr()); + MC_recon_reg.fill(HIST("histTofNsigmaDataTr"), momentum, track.tofNSigmaTr()); if (nSigmaHe3 > nsigmacutLow && nSigmaHe3 < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataHe"), track.p() * 2.0, track.tofNSigmaHe()); - MC_recon_reg.fill(HIST("histTofNsigmaDataHe_pT"), track.pt() * 2.0, track.tofNSigmaHe()); + MC_recon_reg.fill(HIST("histTofNsigmaDataHe"), momentum * 2.0, track.tofNSigmaHe()); if (nSigmaHe4 > nsigmacutLow && nSigmaHe4 < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataAl"), track.p() * 2.0, track.tofNSigmaAl()); - MC_recon_reg.fill(HIST("histTofNsigmaDataAl_pT"), track.pt() * 2.0, track.tofNSigmaAl()); + MC_recon_reg.fill(HIST("histTofNsigmaDataAl"), momentum * 2.0, track.tofNSigmaAl()); } if (track.sign() < 0) { if (nSigmaPion > nsigmacutLow && nSigmaPion < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaPi"), track.p(), track.tofNSigmaPi()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaPi_pT"), track.pt(), track.tofNSigmaPi()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaPi"), momentum, track.tofNSigmaPi()); if (nSigmaProton > nsigmacutLow && nSigmaProton < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaPr"), track.p(), track.tofNSigmaPr()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaPr_pT"), track.pt(), track.tofNSigmaPr()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaPr"), momentum, track.tofNSigmaPr()); if (nSigmaDeuteron > nsigmacutLow && nSigmaDeuteron < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaDe"), track.p(), track.tofNSigmaDe()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaDe_pT"), track.pt(), track.tofNSigmaDe()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaDe"), momentum, track.tofNSigmaDe()); if (nSigmaTriton > nsigmacutLow && nSigmaTriton < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaTr"), track.p(), track.tofNSigmaTr()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaTr_pT"), track.pt(), track.tofNSigmaTr()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaTr"), momentum, track.tofNSigmaTr()); if (nSigmaHe3 > nsigmacutLow && nSigmaHe3 < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaHe"), track.p() * 2.0, track.tofNSigmaHe()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaHe_pT"), track.pt() * 2.0, track.tofNSigmaHe()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaHe"), momentum * 2.0, track.tofNSigmaHe()); if (nSigmaHe4 > nsigmacutLow && nSigmaHe4 < nsigmacutHigh) - MC_recon_reg.fill(HIST("histTofNsigmaDataaAl"), track.p() * 2.0, track.tofNSigmaAl()); - MC_recon_reg.fill(HIST("histTofNsigmaDataaAl_pT"), track.pt() * 2.0, track.tofNSigmaAl()); + MC_recon_reg.fill(HIST("histTofNsigmaDataaAl"), momentum * 2.0, track.tofNSigmaAl()); } } } diff --git a/PWGLF/Tasks/Nuspex/ebyeMult.cxx b/PWGLF/Tasks/Nuspex/ebyeMult.cxx new file mode 100644 index 00000000000..66231c71549 --- /dev/null +++ b/PWGLF/Tasks/Nuspex/ebyeMult.cxx @@ -0,0 +1,500 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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/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 "TDatabasePDG.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 d_bz; + uint8_t nTrackletsColl; + + 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"}; + 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.4f, "minimum pT (GeV/c)"}; + Configurable ptMax{"ptMax", 4.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 + d_bz = o2::base::Propagator::Instance()->getNominalBz(); + LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " 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 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 { + // 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; + d_bz = 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/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.}}); + + // 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}}); + + 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}}); + + // 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.}}); + + // response + histos.add("GenRecTracks", ";Tracklets |#eta| > 0.7#it;#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}}); + } + } + + 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; + 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 + ++nTracks; + } + } + + histos.fill(HIST("QA/nTrklCorrelation"), nTracklets[0], nTracklets[1]); + nTrackletsColl = nTracklets[1]; + + candidateEvent.nTklRec = nTracklets[0]; + histos.fill(HIST("TracksDistr"), nTracklets[1], nTracks); + histos.fill(HIST("TrackletsDistr"), nTracklets[1], 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 (auto& candidateTrack : candidateTracks) { + candidateTrack.isreco = true; + + auto mcLab = mcLabels.rawIteratorAt(candidateTrack.globalIndex); + if (mcLab.has_mcParticle()) { + auto mcTrack = mcLab.template mcParticle_as(); + if (((mcTrack.flags() & 0x8) && (doprocessMcRun2)) || (mcTrack.flags() & 0x2)) + continue; + if (!mcTrack.isPhysicalPrimary()) { + if (mcTrack.has_mothers()) { // sec WD + histos.fill(HIST("SecWDTracks"), nTrackletsColl, candidateTrack.pt, candidateTrack.dcaxypv); + } else { // from material + histos.fill(HIST("SecTracks"), nTrackletsColl, candidateTrack.pt, candidateTrack.dcaxypv); + } + } + if ((mcTrack.flags() & 0x1)) + continue; + if (mcTrack.isPhysicalPrimary()) { // primary + histos.fill(HIST("PrimTracks"), nTrackletsColl, candidateTrack.pt, candidateTrack.dcaxypv); + } + + if (std::abs(candidateTrack.dcaxypv) > cfgDcaSels->get("dcaxy")) + continue; + int partType = getPartType(mcTrack.pdgCode()); + if (mcTrack.isPhysicalPrimary()) { // primary + histos.fill(HIST("RecPart"), nTrackletsColl, candidateTrack.pt, partType); + if (partType < PartTypes::kOther) { + ++nTracks; + } + } + auto genPt = std::hypot(mcTrack.px(), mcTrack.py()); + candidateTrack.pdgcode = mcTrack.pdgCode(); + candidateTrack.genpt = genPt; + candidateTrack.geneta = mcTrack.eta(); + candidateTrack.mcIndex = mcTrack.globalIndex(); + } + } + candidateEvent.nTrkRec = nTracks; + } + + void fillMcGen(aod::McParticles const& mcParticles, aod::McTrackLabels const& /*mcLab*/, uint64_t const& collisionId) + { + int nParticles = 0; + auto mcParticles_thisCollision = mcParticles.sliceBy(perCollisionMcParts, collisionId); + for (auto& mcPart : mcParticles_thisCollision) { + 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()); + 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); + + 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("GenRecTracks"), nTrackletsColl, candidateEvent.nTrkRec, nParticles); + histos.fill(HIST("GenRecTracklets"), nTrackletsColl, candidateEvent.nTklRec, nParticles); + } + + 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; + + // 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 t : candidateTracks) { + histos.fill(HIST("RecTracks"), nTrackletsColl, 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) { + auto bc = collision.bc_as(); + initCCDB(bc); + + if (std::abs(collision.posZ()) > zVtxMax) + continue; + + if (!(bc.eventCuts() & BIT(aod::Run2EventCuts::kAliEventCutsAccepted))) + 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()); + } + } + 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 64f02f95886..334c952a105 100644 --- a/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx +++ b/PWGLF/Tasks/Nuspex/hadronnucleicorrelation.cxx @@ -15,8 +15,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -53,9 +53,9 @@ struct hadronnucleicorrelation { static constexpr int pdgDeuteron = 1000010020; Configurable doQA{"doQA", true, "save QA histograms"}; + Configurable doMCQA{"doMCQA", false, "save MC QA histograms"}; Configurable isMC{"isMC", false, "is MC"}; Configurable mcCorrelation{"mcCorrelation", false, "true: build the correlation function only for SE"}; - Configurable disable_pantip{"disable_pantip", false, "disable_pantip"}; Configurable docorrection{"docorrection", false, "do efficiency correction"}; Configurable fCorrectionPath{"fCorrectionPath", "", "Correction path to file"}; @@ -66,6 +66,8 @@ struct hadronnucleicorrelation { Configurable cutzvertex{"cutzvertex", 10.0, "|vertexZ| value limit"}; // Track selection + Configurable par0{"par0", 0.004, "par 0"}; + Configurable par1{"par1", 0.013, "par 1"}; Configurable min_TPC_nClusters{"min_TPC_nClusters", 80, "minimum number of found TPC clusters"}; Configurable min_TPC_nCrossedRowsOverFindableCls{"min_TPC_nCrossedRowsOverFindableCls", 0.8, "n TPC Crossed Rows Over Findable Cls"}; Configurable max_chi2_TPC{"max_chi2_TPC", 4.0f, "maximum TPC chi^2/Ncls"}; @@ -74,14 +76,16 @@ struct hadronnucleicorrelation { Configurable max_dcaxy{"max_dcaxy", 0.14f, "Maximum DCAxy"}; Configurable max_dcaz{"max_dcaz", 0.1f, "Maximum DCAz"}; Configurable nsigmaTPC{"nsigmaTPC", 3.0f, "cut nsigma TPC"}; + Configurable nsigmaElPr{"nsigmaElPr", 1.0f, "cut nsigma TPC El for protons"}; + Configurable nsigmaElDe{"nsigmaElDe", 3.0f, "cut nsigma TPC El for protons"}; Configurable nsigmaTOF{"nsigmaTOF", 3.5f, "cut nsigma TOF"}; Configurable pTthrpr_TOF{"pTthrpr_TOF", 0.8f, "threshold pT proton to use TOF"}; - Configurable debug_ptthrp{"debug_ptthrp", 2.0f, "threshold pT proton for phi/eta debug"}; - Configurable debug_ptthrd{"debug_ptthrd", 2.0f, "threshold pT deuteron for phi/eta debug"}; + Configurable pTthrpr_TPCEl{"pTthrpr_TPCEl", 1.0f, "threshold pT proton to use TPC El rejection"}; + Configurable pTthrde_TOF{"pTthrde_TOF", 1.0f, "threshold pT deuteron to use TOF"}; + Configurable pTthrde_TPCEl{"pTthrde_TPCEl", 1.0f, "threshold pT deuteron to use TPC El rejection"}; + 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 threta{"threta", 0.1, "threshold for debug DeltaEta"}; - Configurable thrphi{"thrphi", 0.5, "threshold for debug DeltaPhi"}; // Mixing parameters Configurable _vertexNbinsToMix{"vertexNbinsToMix", 10, "Number of vertexZ bins for the mixing"}; @@ -89,14 +93,12 @@ struct hadronnucleicorrelation { // pT/A bins Configurable> pTBins{"pTBins", {0.4f, 0.6f, 0.8f}, "p_{T} bins"}; - Configurable> etaBins{"etaBins", {-0.8f, 0.f, 0.8f}, "#eta bins"}; - Configurable> phiBins{"phiBins", {0.f, TMath::Pi(), 2 * TMath::Pi()}, "#phi bins"}; - ConfigurableAxis AxisNSigma{"AxisNSigma", {50, -10.f, 10.f}, "n#sigma"}; + ConfigurableAxis AxisNSigma{"AxisNSigma", {35, -7.f, 7.f}, "n#sigma"}; using FilteredCollisions = soa::Filtered; - using FilteredTracks = soa::Filtered; - using FilteredTracksMC = soa::Filtered>; + using FilteredTracks = soa::Filtered>; + using FilteredTracksMC = soa::Filtered>; HistogramRegistry registry{"registry"}; HistogramRegistry QA{"QA"}; @@ -107,13 +109,16 @@ struct hadronnucleicorrelation { // key: int64_t - value: vector of trkType objects std::map> selectedtracks_p; + std::map> selectedtracks_d; std::map> selectedtracks_antid; std::map> selectedtracks_antip; // key: int64_t - value: vector of trkType objects + std::map> selectedtracksMC_d; std::map> selectedtracksMC_p; std::map> selectedtracksMC_antid; std::map> selectedtracksMC_antip; + std::map> selectedtracksPIDMC_d; std::map> selectedtracksPIDMC_p; std::map> selectedtracksPIDMC_antid; std::map> selectedtracksPIDMC_antip; @@ -121,16 +126,10 @@ 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_pantip; std::map, std::vector> mixbinsPID_antidantip; - std::map, std::vector> mixbinsPID_pantip; - std::vector> hEtaPhi_PrAntiPr_SE; - std::vector> hEtaPhi_PrAntiPr_ME; std::vector> hEtaPhi_AntiDeAntiPr_SE; std::vector> hEtaPhi_AntiDeAntiPr_ME; - std::vector> hCorrEtaPhi_PrAntiPr_SE; - std::vector> hCorrEtaPhi_PrAntiPr_ME; std::vector> hCorrEtaPhi_AntiDeAntiPr_SE; std::vector> hCorrEtaPhi_AntiDeAntiPr_ME; @@ -138,20 +137,12 @@ struct hadronnucleicorrelation { std::vector> hEtaPhiGen_AntiDeAntiPr_SE; std::vector> hEtaPhiRec_AntiDeAntiPr_ME; std::vector> hEtaPhiGen_AntiDeAntiPr_ME; - std::vector> hEtaPhiRec_PrAntiPr_SE; - std::vector> hEtaPhiGen_PrAntiPr_SE; - std::vector> hEtaPhiRec_PrAntiPr_ME; - std::vector> hEtaPhiGen_PrAntiPr_ME; std::vector> hPIDEtaPhiRec_AntiDeAntiPr_SE; std::vector> hPIDEtaPhiGen_AntiDeAntiPr_SE; std::vector> hPIDEtaPhiRec_AntiDeAntiPr_ME; std::vector> hPIDEtaPhiGen_AntiDeAntiPr_ME; - std::vector> hPIDEtaPhiRec_PrAntiPr_SE; - std::vector> hPIDEtaPhiGen_PrAntiPr_SE; - std::vector> hPIDEtaPhiRec_PrAntiPr_ME; - std::vector> hPIDEtaPhiGen_PrAntiPr_ME; - int nBinspT, nBinseta, nBinsphi; + int nBinspT; TH2F* hEffpTEta_proton; TH2F* hEffpTEta_antiproton; TH2F* hEffpTEta_deuteron; @@ -178,115 +169,62 @@ struct hadronnucleicorrelation { } AxisSpec ptBinnedAxis = {pTBins, "#it{p}_{T} of #bar{p} (GeV/c)"}; - AxisSpec etaBinnedAxis = {etaBins, "#eta"}; - AxisSpec phiBinnedAxis = {phiBins, "#phi"}; - AxisSpec etaAxis = {100, -1.5, 1.5, "#Delta#eta"}; - AxisSpec phiAxis = {100, -TMath::Pi() / 2, 1.5 * TMath::Pi(), "#Delta#phi"}; + AxisSpec etaAxis = {100, -1., 1., "#eta"}; + AxisSpec phiAxis = {157, 0., 2 * TMath::Pi(), "#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"}; - registry.add("hNEvents", "hNEvents", {HistType::kTH1I, {{3, 0.f, 3.f}}}); + 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.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "Selected"); - registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "#bar{d}-#bar{p}"); - registry.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "p-#bar{p}"); + 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"); nBinspT = pTBins.value.size() - 1; - nBinseta = etaBins.value.size() - 1; - nBinsphi = phiBins.value.size() - 1; if (mcCorrelation) { 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("hEtaPhiRec_PrAntiPr_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_PrAntiPr_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_PrAntiPr_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_PrAntiPr_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("hPIDEtaPhiGen_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("hPIDEtaPhiRec_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("hPIDEtaPhiGen_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_PrAntiPr_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("hPIDEtaPhiGen_PrAntiPr_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("hPIDEtaPhiRec_PrAntiPr_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("hPIDEtaPhiGen_PrAntiPr_ME_pt%02.0f%02.0f", pTBins.value.at(i) * 10, pTBins.value.at(i + 1) * 10), - Form("Gen #Delta#eta#Delta#phi (%.1f(HIST("hDebug"))->GetXaxis()->SetBinLabel(1, "all"); - registry.get(HIST("hDebug"))->GetXaxis()->SetBinLabel(2, "ev. with #bar{d}"); - registry.get(HIST("hDebug"))->GetXaxis()->SetBinLabel(3, "ev. with #bar{p}"); - registry.get(HIST("hDebug"))->GetXaxis()->SetBinLabel(4, "ev. with p"); - - registry.add("hDebugdp", "hDebugdp", {HistType::kTH1I, {{6, 0.f, 6.f}}}); - registry.get(HIST("hDebugdp"))->GetXaxis()->SetBinLabel(1, "N coll with #bar{d}"); - registry.get(HIST("hDebugdp"))->GetXaxis()->SetBinLabel(2, "N mixing bins"); - registry.get(HIST("hDebugdp"))->GetXaxis()->SetBinLabel(3, "N coll with #bar{d}"); - registry.get(HIST("hDebugdp"))->GetXaxis()->SetBinLabel(4, "#bar{d}-#bar{p} pairs SE"); - registry.get(HIST("hDebugdp"))->GetXaxis()->SetBinLabel(5, "#bar{d}-#bar{p} pairs ME"); - for (int i = 0; i < nBinspT; i++) { - if (!disable_pantip) { - auto htempSE_PrAntiPr = registry.add(Form("hEtaPhi_PrAntiPr_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_PrAntiPr_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("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("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_PrAntiPr_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_PrAntiPr_ME_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_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("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(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_v1)) <= max_dcaxy && // For now no filtering on the DCAxy or DCAz (casting not supported) - // nabs(o2::aod::singletrackselector::unPack(o2::aod::singletrackselector::storedDcaXY_v1)) <= max_dcaz && // For now no filtering on the DCAxy or DCAz (casting not supported) + 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::eta) <= etacut; + template + bool IsProton(Type const& track, int sign) + { + bool isProton = false; + + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC) { + if (track.pt() < pTthrpr_TOF) { + if (sign > 0) { + if (track.sign() > 0) { + isProton = true; + } else if (track.sign() < 0) { + isProton = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isProton = false; + } else if (track.sign() < 0) { + isProton = true; + } + } + } else if (rejectionEl && track.beta() < -100 && track.pt() < pTthrpr_TPCEl && track.tpcNSigmaEl() >= nsigmaElPr) { + if (sign > 0) { + if (track.sign() > 0) { + isProton = true; + } else if (track.sign() < 0) { + isProton = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isProton = false; + } else if (track.sign() < 0) { + isProton = true; + } + } + } else if (std::abs(track.tofNSigmaPr()) < nsigmaTOF) { + if (sign > 0) { + if (track.sign() > 0) { + isProton = true; + } else if (track.sign() < 0) { + isProton = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isProton = false; + } else if (track.sign() < 0) { + isProton = true; + } + } + } + } + return isProton; + } + + template + bool IsDeuteron(Type const& track, int sign) + { + bool isDeuteron = false; + + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC) { + if (track.pt() < pTthrde_TOF) { + if (sign > 0) { + if (track.sign() > 0) { + isDeuteron = true; + } else if (track.sign() < 0) { + isDeuteron = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isDeuteron = false; + } else if (track.sign() < 0) { + isDeuteron = true; + } + } + } else if (rejectionEl && track.beta() < -100 && track.pt() < pTthrde_TPCEl && track.tpcNSigmaEl() >= nsigmaElDe) { + if (sign > 0) { + if (track.sign() > 0) { + isDeuteron = true; + } else if (track.sign() < 0) { + isDeuteron = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isDeuteron = false; + } else if (track.sign() < 0) { + isDeuteron = true; + } + } + } else if (std::abs(track.tofNSigmaDe()) < nsigmaTOF) { + if (sign > 0) { + if (track.sign() > 0) { + isDeuteron = true; + } else if (track.sign() < 0) { + isDeuteron = false; + } + } else if (sign < 0) { + if (track.sign() > 0) { + isDeuteron = false; + } else if (track.sign() < 0) { + isDeuteron = true; + } + } + } + } + return isDeuteron; + } + + template + bool applyDCAcut(const T1& track) + { + bool passcut = true; + // pt-dependent selection + if (TMath::Abs(track.dcaXY()) > (par0 + par1 / track.pt())) + passcut = false; + if (TMath::Abs(track.dcaZ()) > (par0 + par1 / track.pt())) + passcut = false; + + return passcut; + } + template - void mixTracks(Type const& tracks1, Type const& tracks2, bool isDe, bool isMCPID) + void mixTracks(Type const& tracks1, Type const& tracks2, bool isMCPID) { // last value: 0 -- SE; 1 -- ME for (auto it1 : tracks1) { for (auto it2 : tracks2) { - // Variables + // Calculate Delta-eta Delta-phi (reco) float deltaEta = it2->eta() - it1->eta(); float deltaPhi = it2->phi() - it1->phi(); deltaPhi = getDeltaPhi(deltaPhi); + // Calculate Delta-eta Delta-phi (gen) float deltaEtaGen = -999.; float deltaPhiGen = -999.; if constexpr (doMC) { @@ -407,114 +485,48 @@ struct hadronnucleicorrelation { deltaPhiGen = getDeltaPhi(deltaPhiGen); } - float pcorr = 1, antipcorr = 1, antidcorr = 1; + float antipcorr = 1, antidcorr = 1; for (int k = 0; k < nBinspT; k++) { - if (!isDe && !disable_pantip) { - if (it1->pt() > pTBins.value.at(k) && it1->pt() <= pTBins.value.at(k + 1)) { - - if (doQA) { - QA.fill(HIST("QA/Pt_Pr"), it1->pt()); - QA.fill(HIST("QA/Pt_AntiPr"), it2->pt()); - } - - if (docorrection) { - pcorr = hEffpTEta_proton->Interpolate(it1->pt(), it1->eta()); - antipcorr = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); - } + if (it1->pt() >= pTBins.value.at(k) && it1->pt() < pTBins.value.at(k + 1)) { - if (ME) { - if constexpr (!doMC) { - hEtaPhi_PrAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_PrAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (pcorr * antipcorr)); - } - if constexpr (doMC) { - if (isMCPID) { - hPIDEtaPhiRec_PrAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hPIDEtaPhiGen_PrAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } else { - hEtaPhiRec_PrAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hEtaPhiGen_PrAntiPr_ME[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } - } - } else { - if constexpr (!doMC) { - hEtaPhi_PrAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_PrAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (pcorr * antipcorr)); - - if (doQA && abs(deltaEta) < threta && abs(deltaPhi) < thrphi) { - QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr_Debug"), it1->pt(), it1->tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr_Debug"), -1.f * it2->pt(), it2->tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr_Debug"), it1->pt(), it1->tofNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr_Debug"), -1.f * it2->pt(), it2->tofNSigmaPr()); - } - } - if constexpr (doMC) { - if (isMCPID) { - hPIDEtaPhiRec_PrAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hPIDEtaPhiGen_PrAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } else { - hEtaPhiRec_PrAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hEtaPhiGen_PrAntiPr_SE[k]->Fill(deltaEtaGen, deltaPhiGen, it2->pt()); - } - } - } + if (docorrection) { // Apply corrections + antipcorr = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); + antidcorr = hEffpTEta_antideuteron->Interpolate(it1->pt(), it1->eta()); } - } else { - if (it1->pt() > pTBins.value.at(k) && it1->pt() <= pTBins.value.at(k + 1)) { - - if (doQA) { - QA.fill(HIST("QA/Pt_AntiDe"), it1->pt()); - QA.fill(HIST("QA/Pt_AntiPr"), it2->pt()); - } - - if (docorrection) { - antipcorr = hEffpTEta_antiproton->Interpolate(it2->pt(), it2->eta()); - antidcorr = hEffpTEta_antideuteron->Interpolate(it1->pt(), it1->eta()); - } - if (ME) { - if constexpr (!doMC) { - hEtaPhi_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_AntiDeAntiPr_ME[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (antipcorr * antidcorr)); + 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 constexpr (doMC) { - 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) { - hEtaPhi_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt()); - hCorrEtaPhi_AntiDeAntiPr_SE[k]->Fill(deltaEta, deltaPhi, it2->pt(), 1. / (antipcorr * antidcorr)); - - if (doQA && abs(deltaEta) < threta && abs(deltaPhi) < thrphi) { - QA.fill(HIST("QA/hnSigmaTPCVsPt_De_Debug"), -1.f * it1->pt(), it1->tpcNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTPCVsPt_APrDe_Debug"), -1.f * it2->pt(), it2->tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsPt_De_Debug"), -1.f * it1->pt(), it1->tofNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTOFVsPt_APrDe_Debug"), -1.f * it2->pt(), it2->tofNSigmaPr()); - } - } - if constexpr (doMC) { - 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()); - } + } + } 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()); } - } // SE - } - } + } + } // SE + } // pT condition } // nBinspT loop - } - } + } // tracks 2 + } // tracks 1 } float getDeltaPhi(float deltaPhi) @@ -563,105 +575,80 @@ struct hadronnucleicorrelation { void processData(FilteredCollisions const& collisions, FilteredTracks const& tracks) { for (auto track : tracks) { - if (abs(track.template singleCollSel_as().posZ()) > cutzvertex) + if (std::abs(track.template singleCollSel_as().posZ()) > cutzvertex) + continue; + + if (track.tpcFractionSharedCls() > max_tpcSharedCls) continue; - if (abs(track.dcaXY()) > max_dcaxy || abs(track.dcaZ()) > max_dcaz) { // For now no filtering on the DCAxy or DCAz (casting not supported) + if (track.itsNCls() < min_itsNCls) continue; - } + if (!applyDCAcut(track)) + continue; + if (doQA) { QA.fill(HIST("QA/hTPCnClusters"), track.tpcNClsFound()); QA.fill(HIST("QA/hTPCchi2"), track.tpcChi2NCl()); QA.fill(HIST("QA/hTPCcrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); QA.fill(HIST("QA/hITSchi2"), track.itsChi2NCl()); - QA.fill(HIST("QA/hDCAxy"), track.dcaXY()); - QA.fill(HIST("QA/hDCAz"), track.dcaZ()); + QA.fill(HIST("QA/hDCAxy"), track.dcaXY(), track.pt()); + QA.fill(HIST("QA/hDCAz"), track.dcaZ(), track.pt()); + QA.fill(HIST("QA/TPCChi2VsPZ"), track.tpcInnerParam() / track.sign(), track.tpcChi2NCl()); QA.fill(HIST("QA/hVtxZ_trk"), track.template singleCollSel_as().posZ()); + QA.fill(HIST("QA/hnSigmaTPCVsPt_El"), track.pt() * track.sign(), track.tpcNSigmaEl()); QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr"), track.pt() * track.sign(), track.tpcNSigmaPr()); QA.fill(HIST("QA/hnSigmaTPCVsPt_De"), track.pt() * track.sign(), track.tpcNSigmaDe()); QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr"), track.pt() * track.sign(), track.tofNSigmaPr()); QA.fill(HIST("QA/hnSigmaTOFVsPt_De"), track.pt() * track.sign(), track.tofNSigmaDe()); } + // Discard candidates outside pT of interest if (track.pt() > pTBins.value.at(nBinspT) || track.pt() < pTBins.value.at(0)) continue; - // Additional track cuts - if (track.tpcFractionSharedCls() > max_tpcSharedCls || track.itsNCls() < min_itsNCls) - continue; - - bool isPr = false; - bool isAntiPr = false; - bool isDeTPCTOF = false; - bool isAntiDeTPCTOF = false; + bool isPr = IsProton(track, +1); + bool isAntiPr = IsProton(track, -1); + bool isDe = IsDeuteron(track, +1); + bool isAntiDe = IsDeuteron(track, -1); - if (TMath::Abs(track.tpcNSigmaPr()) < nsigmaTPC && track.sign() > 0) { - if (track.pt() < pTthrpr_TOF) { - isPr = true; - } else if (TMath::Abs(track.tofNSigmaPr()) < nsigmaTOF) { - isPr = true; - } - } - if (TMath::Abs(track.tpcNSigmaPr()) < nsigmaTPC && track.sign() < 0) { - if (track.pt() < pTthrpr_TOF) { - isAntiPr = true; - } else if (TMath::Abs(track.tofNSigmaPr()) < nsigmaTOF) { - isAntiPr = true; - } - } - if (TMath::Abs(track.tpcNSigmaDe()) < nsigmaTPC && TMath::Abs(track.tofNSigmaDe()) < nsigmaTOF && track.sign() > 0) - isDeTPCTOF = true; - if (TMath::Abs(track.tpcNSigmaDe()) < nsigmaTPC && TMath::Abs(track.tofNSigmaDe()) < nsigmaTOF && track.sign() < 0) - isAntiDeTPCTOF = true; - - if (!isPr && !isAntiPr && !isDeTPCTOF && !isAntiDeTPCTOF) + if (!isPr && !isAntiPr && !isDe && !isAntiDe) continue; - if (isPr && isDeTPCTOF) { - isDeTPCTOF = 0; + if (isPr && isDe) { + isDe = 0; } - if (isAntiPr && isAntiDeTPCTOF) { - isAntiDeTPCTOF = 0; + if (isAntiPr && isAntiDe) { + isAntiDe = 0; } - // Deuterons - if (isAntiDeTPCTOF) { + // Deuterons Fill & QA + if (isAntiDe) { selectedtracks_antid[track.singleCollSelId()].push_back(std::make_shared(track)); if (doQA) { QA.fill(HIST("QA/hEtaAntiDe"), track.eta()); QA.fill(HIST("QA/hPhiAntiDe"), track.phi()); - QA.fill(HIST("QA/hnSigmaTPCVsPhi_AntiDe"), track.phi(), track.tpcNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTPCVsEta_AntiDe"), track.eta(), track.tpcNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTOFVsPhi_AntiDe"), track.phi(), track.tofNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTOFVsEta_AntiDe"), track.eta(), track.tofNSigmaDe()); QA.fill(HIST("QA/hnSigmaTOFVsPt_De_AfterSel"), track.pt() * track.sign(), track.tofNSigmaDe()); QA.fill(HIST("QA/hnSigmaTPCVsPt_De_AfterSel"), track.pt() * track.sign(), track.tpcNSigmaDe()); } } - if (isDeTPCTOF) { + if (isDe) { + selectedtracks_d[track.singleCollSelId()].push_back(std::make_shared(track)); + if (doQA) { QA.fill(HIST("QA/hEtaDe"), track.eta()); QA.fill(HIST("QA/hPhiDe"), track.phi()); - QA.fill(HIST("QA/hnSigmaTPCVsPhi_De"), track.phi(), track.tpcNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTPCVsEta_De"), track.eta(), track.tpcNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTOFVsPhi_De"), track.phi(), track.tofNSigmaDe()); - QA.fill(HIST("QA/hnSigmaTOFVsEta_De"), track.eta(), track.tofNSigmaDe()); QA.fill(HIST("QA/hnSigmaTOFVsPt_De_AfterSel"), track.pt() * track.sign(), track.tofNSigmaDe()); QA.fill(HIST("QA/hnSigmaTPCVsPt_De_AfterSel"), track.pt() * track.sign(), track.tpcNSigmaDe()); } } - // Protons + // Protons Fill & QA if (isPr) { selectedtracks_p[track.singleCollSelId()].push_back(std::make_shared(track)); if (doQA) { QA.fill(HIST("QA/hEtaPr"), track.eta()); QA.fill(HIST("QA/hPhiPr"), track.phi()); - QA.fill(HIST("QA/hnSigmaTPCVsPhi_Pr"), track.phi(), track.tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTPCVsEta_Pr"), track.eta(), track.tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsPhi_Pr"), track.phi(), track.tofNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsEta_Pr"), track.eta(), track.tofNSigmaPr()); QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr_AfterSel"), track.pt() * track.sign(), track.tpcNSigmaPr()); QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr_AfterSel"), track.pt() * track.sign(), track.tofNSigmaPr()); } @@ -671,10 +658,6 @@ struct hadronnucleicorrelation { if (doQA) { QA.fill(HIST("QA/hEtaAntiPr"), track.eta()); QA.fill(HIST("QA/hPhiAntiPr"), track.phi()); - QA.fill(HIST("QA/hnSigmaTPCVsPhi_AntiPr"), track.phi(), track.tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTPCVsEta_AntiPr"), track.eta(), track.tpcNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsPhi_AntiPr"), track.phi(), track.tofNSigmaPr()); - QA.fill(HIST("QA/hnSigmaTOFVsEta_AntiPr"), track.eta(), track.tofNSigmaPr()); QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr_AfterSel"), track.pt() * track.sign(), track.tpcNSigmaPr()); QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr_AfterSel"), track.pt() * track.sign(), track.tofNSigmaPr()); } @@ -683,76 +666,28 @@ struct hadronnucleicorrelation { for (auto collision : collisions) { - if (TMath::Abs(collision.posZ()) > cutzvertex) + if (std::abs(collision.posZ()) > cutzvertex) continue; registry.fill(HIST("hNEvents"), 0.5); - registry.fill(HIST("hDebug"), 0.5); - - if (selectedtracks_p.find(collision.globalIndex()) != selectedtracks_p.end() && - selectedtracks_antip.find(collision.globalIndex()) != selectedtracks_antip.end()) { - registry.fill(HIST("hNEvents"), 2.5); - } if (selectedtracks_antid.find(collision.globalIndex()) != selectedtracks_antid.end() && selectedtracks_antip.find(collision.globalIndex()) != selectedtracks_antip.end()) { registry.fill(HIST("hNEvents"), 1.5); } - int vertexBinToMix = std::floor((collision.posZ() + cutzvertex) / (2 * cutzvertex / _vertexNbinsToMix)); - int centBinToMix = std::floor(collision.multPerc() / (100.0 / _multNsubBins)); - - if (selectedtracks_p.find(collision.globalIndex()) != selectedtracks_p.end()) { - registry.fill(HIST("hDebug"), 3.5); - mixbins_pantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); + if (selectedtracks_d.find(collision.globalIndex()) != selectedtracks_d.end() && + selectedtracks_p.find(collision.globalIndex()) != selectedtracks_p.end()) { + registry.fill(HIST("hNEvents"), 2.5); } - if (selectedtracks_antip.find(collision.globalIndex()) != selectedtracks_antip.end()) { - registry.fill(HIST("hDebug"), 2.5); - } + int vertexBinToMix = std::floor((collision.posZ() + cutzvertex) / (2 * cutzvertex / _vertexNbinsToMix)); + int centBinToMix = std::floor(collision.multPerc() / (100.0 / _multNsubBins)); if (selectedtracks_antid.find(collision.globalIndex()) != selectedtracks_antid.end()) { - registry.fill(HIST("hDebug"), 1.5); - registry.fill(HIST("hDebugdp"), 0.5); // numero tot di collisioni nella mappa mixbins_antidantip - mixbins_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); - } - } - - registry.get(HIST("hDebugdp"))->SetBinContent(6, mixbins_antidantip.size()); - - if (!disable_pantip) { - if (!mixbins_pantip.empty()) { - for (auto i = mixbins_pantip.begin(); i != mixbins_pantip.end(); i++) { // iterating over all vertex&mult bins - - int EvPerBin = (i->second).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 + registry.fill(HIST("hNEvents"), 3.5); - auto col1 = (i->second)[indx1]; - - if (selectedtracks_antip.find(col1->index()) != selectedtracks_antip.end()) { - mixTracks<0, 0>(selectedtracks_p[col1->index()], selectedtracks_antip[col1->index()], 0, 0); // mixing SE - } - - int indx3 = EvPerBin; - if (indx1 < (EvPerBin - 11)) { - indx3 = indx1 + 11; - } - - for (int indx2 = indx1 + 1; indx2 < indx3; indx2++) { // nested loop for all the combinations of collisions in a chosen mult/vertex bin - - auto col2 = (i->second)[indx2]; - - if (col1 == col2) { - continue; - } - - if (selectedtracks_antip.find(col2->index()) != selectedtracks_antip.end()) { - mixTracks<1, 0>(selectedtracks_p[col1->index()], selectedtracks_antip[col2->index()], 0, 0); // mixing ME - } - } - } - } + mixbins_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); } } @@ -760,20 +695,15 @@ struct hadronnucleicorrelation { for (auto i = mixbins_antidantip.begin(); i != mixbins_antidantip.end(); i++) { // iterating over all vertex&mult bins - registry.fill(HIST("hDebugdp"), 1.5); // numero di keys (vertex&mult bins) nella mappa mixbins_antidantip - 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 - registry.fill(HIST("hDebugdp"), 2.5); - auto col1 = value[indx1]; if (selectedtracks_antip.find(col1->index()) != selectedtracks_antip.end()) { - registry.fill(HIST("hDebugdp"), 3.5); - mixTracks<0, 0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col1->index()], 1, 0); // mixing SE + mixTracks<0, 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 @@ -785,8 +715,7 @@ struct hadronnucleicorrelation { } if (selectedtracks_antip.find(col2->index()) != selectedtracks_antip.end()) { - registry.fill(HIST("hDebugdp"), 4.5); - mixTracks<1, 0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col2->index()], 1, 0); // mixing ME + mixTracks<1, 0>(selectedtracks_antid[col1->index()], selectedtracks_antip[col2->index()], 0); // mixing ME } } } @@ -806,72 +735,82 @@ struct hadronnucleicorrelation { (i->second).clear(); selectedtracks_p.clear(); - for (auto& pair : mixbins_antidantip) { - pair.second.clear(); // Clear the vector associated with the key - } - mixbins_antidantip.clear(); // Then clear the map itself + for (auto i = selectedtracks_d.begin(); i != selectedtracks_d.end(); i++) + (i->second).clear(); + selectedtracks_d.clear(); for (auto& pair : mixbins_antidantip) { pair.second.clear(); // Clear the vector associated with the key } mixbins_antidantip.clear(); // Then clear the map itself - - for (auto& pair : mixbins_pantip) { - pair.second.clear(); // Clear the vector associated with the key - } - mixbins_pantip.clear(); // Then clear the map itself } PROCESS_SWITCH(hadronnucleicorrelation, processData, "processData", true); void processMC(FilteredCollisions const& collisions, FilteredTracksMC const& tracks) { for (auto track : tracks) { - if (abs(track.template singleCollSel_as().posZ()) > cutzvertex) + if (std::abs(track.template singleCollSel_as().posZ()) > cutzvertex) continue; - if (abs(track.dcaXY()) > max_dcaxy || abs(track.dcaZ()) > max_dcaz) { // For now no filtering on the DCAxy or DCAz (casting not supported) + if (track.tpcFractionSharedCls() > max_tpcSharedCls) continue; - } + if (track.itsNCls() < min_itsNCls) + continue; + if (!applyDCAcut(track)) + continue; + + // Keep only protons and deuterons + // if (std::abs(track.pdgCode()) != pdgProton && std::abs(track.pdgCode()) != pdgDeuteron) + // continue; if (doQA) { QA.fill(HIST("QA/hTPCnClusters"), track.tpcNClsFound()); QA.fill(HIST("QA/hTPCchi2"), track.tpcChi2NCl()); QA.fill(HIST("QA/hTPCcrossedRowsOverFindableCls"), track.tpcCrossedRowsOverFindableCls()); QA.fill(HIST("QA/hITSchi2"), track.itsChi2NCl()); - QA.fill(HIST("QA/hDCAxy"), track.dcaXY()); - QA.fill(HIST("QA/hDCAz"), track.dcaZ()); + QA.fill(HIST("QA/hDCAxy"), track.dcaXY(), track.pt()); + QA.fill(HIST("QA/hDCAz"), track.dcaZ(), track.pt()); QA.fill(HIST("QA/hVtxZ_trk"), track.template singleCollSel_as().posZ()); + QA.fill(HIST("QA/hnSigmaTPCVsPt_El"), track.pt() * track.sign(), track.tpcNSigmaEl()); QA.fill(HIST("QA/hnSigmaTPCVsPt_Pr"), track.pt() * track.sign(), track.tpcNSigmaPr()); QA.fill(HIST("QA/hnSigmaTPCVsPt_De"), track.pt() * track.sign(), track.tpcNSigmaDe()); QA.fill(HIST("QA/hnSigmaTOFVsPt_Pr"), track.pt() * track.sign(), track.tofNSigmaPr()); QA.fill(HIST("QA/hnSigmaTOFVsPt_De"), track.pt() * track.sign(), track.tofNSigmaDe()); } - if (track.origin() != 0) - continue; + bool isPr = (IsProton(track, +1) && track.pdgCode() == pdgProton); + bool isAntiPr = (IsProton(track, -1) && track.pdgCode() == -pdgProton); + bool isDe = (IsDeuteron(track, +1) && track.pdgCode() == pdgDeuteron); + bool isAntiDe = (IsDeuteron(track, -1) && track.pdgCode() == -pdgDeuteron); - if (abs(track.pdgCode()) != pdgProton && abs(track.pdgCode()) != pdgDeuteron) - continue; + if (track.origin() == 1 || track.origin() == 0) { // primaries and secondaries + if (isPr) { + registry.fill(HIST("hPrimSec_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * +1); + if (track.origin() == 1) { // secondaries + registry.fill(HIST("hSec_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * +1); + } + } + if (isAntiPr) { + registry.fill(HIST("hPrimSec_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); + if (track.origin() == 1) { + registry.fill(HIST("hSec_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); + } + } + } - bool isPr = false; - bool isAntiPr = false; - bool isAntiDeTPCTOF = false; + if (track.origin() != 0) + continue; if (track.pdgCode() == pdgProton) { registry.fill(HIST("hReco_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt()); registry.fill(HIST("hReco_EtaPhiPtMC_Proton"), track.eta_MC(), track.phi_MC(), track.pt_MC()); registry.fill(HIST("hResPt_Proton"), track.pt_MC(), track.pt() - track.pt_MC()); - registry.fill(HIST("hResEta_Proton"), track.eta_MC(), track.eta() - track.eta_MC()); - registry.fill(HIST("hResPhi_Proton"), track.phi_MC(), track.phi() - track.phi_MC()); - - if (TMath::Abs(track.tpcNSigmaPr()) < nsigmaTPC) { - if (track.pt() < pTthrpr_TOF) { - isPr = true; - registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt()); - } else if (TMath::Abs(track.tofNSigmaPr()) < nsigmaTOF) { - isPr = true; - registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt()); - } + if (doMCQA) { + registry.fill(HIST("hResEta_Proton"), track.eta_MC(), track.eta() - track.eta_MC()); + registry.fill(HIST("hResPhi_Proton"), track.phi_MC(), track.phi() - track.phi_MC()); + } + if (isPr) { + registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt()); } registry.fill(HIST("hnSigmaTPCVsPt_Pr_MC"), track.pt(), track.tpcNSigmaPr()); registry.fill(HIST("hnSigmaTOFVsPt_Pr_MC"), track.pt(), track.tofNSigmaPr()); @@ -880,17 +819,12 @@ struct hadronnucleicorrelation { registry.fill(HIST("hReco_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); registry.fill(HIST("hReco_EtaPhiPtMC_Proton"), track.eta_MC(), track.phi_MC(), track.pt_MC() * -1); registry.fill(HIST("hResPt_AntiProton"), track.pt_MC(), track.pt() - track.pt_MC()); - registry.fill(HIST("hResEta_AntiProton"), track.eta_MC(), track.eta() - track.eta_MC()); - registry.fill(HIST("hResPhi_AntiProton"), track.phi_MC(), track.phi() - track.phi_MC()); - - if (TMath::Abs(track.tpcNSigmaPr()) < nsigmaTPC) { - if (track.pt() < pTthrpr_TOF) { - isAntiPr = true; - registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); - } else if (TMath::Abs(track.tofNSigmaPr()) < nsigmaTOF) { - isAntiPr = true; - registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); - } + if (doMCQA) { + registry.fill(HIST("hResEta_AntiProton"), track.eta_MC(), track.eta() - track.eta_MC()); + registry.fill(HIST("hResPhi_AntiProton"), track.phi_MC(), track.phi() - track.phi_MC()); + } + if (isAntiPr) { + registry.fill(HIST("hReco_PID_EtaPhiPt_Proton"), track.eta(), track.phi(), track.pt() * -1); } registry.fill(HIST("hnSigmaTPCVsPt_Pr_MC"), track.pt() * -1, track.tpcNSigmaPr()); registry.fill(HIST("hnSigmaTOFVsPt_Pr_MC"), track.pt() * -1, track.tofNSigmaPr()); @@ -899,10 +833,11 @@ struct hadronnucleicorrelation { registry.fill(HIST("hReco_EtaPhiPt_Deuteron"), track.eta(), track.phi(), track.pt()); registry.fill(HIST("hReco_EtaPhiPtMC_Deuteron"), track.eta_MC(), track.phi_MC(), track.pt_MC()); registry.fill(HIST("hResPt_Deuteron"), track.pt_MC(), track.pt() - track.pt_MC()); - registry.fill(HIST("hResEta_Deuteron"), track.eta_MC(), track.eta() - track.eta_MC()); - registry.fill(HIST("hResPhi_Deuteron"), track.phi_MC(), track.phi() - track.phi_MC()); - - if (TMath::Abs(track.tpcNSigmaDe()) < nsigmaTPC && TMath::Abs(track.tofNSigmaDe()) < nsigmaTOF) { + if (doMCQA) { + registry.fill(HIST("hResEta_Deuteron"), track.eta_MC(), track.eta() - track.eta_MC()); + registry.fill(HIST("hResPhi_Deuteron"), track.phi_MC(), track.phi() - track.phi_MC()); + } + if (isDe) { registry.fill(HIST("hReco_PID_EtaPhiPt_Deuteron"), track.eta(), track.phi(), track.pt()); } registry.fill(HIST("hnSigmaTPCVsPt_De_MC"), track.pt(), track.tpcNSigmaDe()); @@ -912,22 +847,242 @@ struct hadronnucleicorrelation { registry.fill(HIST("hReco_EtaPhiPt_Deuteron"), track.eta(), track.phi(), track.pt() * -1); registry.fill(HIST("hReco_EtaPhiPtMC_Deuteron"), track.eta_MC(), track.phi_MC(), track.pt_MC() * -1); registry.fill(HIST("hResPt_AntiDeuteron"), track.pt_MC(), track.pt() - track.pt_MC()); - registry.fill(HIST("hResEta_AntiDeuteron"), track.eta_MC(), track.eta() - track.eta_MC()); - registry.fill(HIST("hResPhi_AntiDeuteron"), track.phi_MC(), track.phi() - track.phi_MC()); - - if (TMath::Abs(track.tpcNSigmaDe()) < nsigmaTPC && TMath::Abs(track.tofNSigmaDe()) < nsigmaTOF) { - isAntiDeTPCTOF = true; + if (doMCQA) { + registry.fill(HIST("hResEta_AntiDeuteron"), track.eta_MC(), track.eta() - track.eta_MC()); + registry.fill(HIST("hResPhi_AntiDeuteron"), track.phi_MC(), track.phi() - track.phi_MC()); + } + if (isAntiDe) { registry.fill(HIST("hReco_PID_EtaPhiPt_Deuteron"), track.eta(), track.phi(), track.pt() * -1); } registry.fill(HIST("hnSigmaTPCVsPt_De_MC"), track.pt() * -1, track.tpcNSigmaDe()); registry.fill(HIST("hnSigmaTOFVsPt_De_MC"), track.pt() * -1, track.tofNSigmaDe()); } + // Purity + // Numerators + if (isPr) { + registry.fill(HIST("hNumeratorPurity_Proton"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton"), track.pt()); + } + if (isAntiPr) { + registry.fill(HIST("hNumeratorPurity_Proton"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton"), track.pt() * -1); + } + if (isDe) { + registry.fill(HIST("hNumeratorPurity_Deuteron"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron"), track.pt()); + } + if (isAntiDe) { + registry.fill(HIST("hNumeratorPurity_Deuteron"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron"), track.pt() * -1); + } + if (IsProton(track, +1)) + registry.fill(HIST("hDenominatorPurity_Proton"), track.pt()); + if (IsProton(track, -1)) + registry.fill(HIST("hDenominatorPurity_Proton"), track.pt() * -1); + if (IsDeuteron(track, +1)) + registry.fill(HIST("hDenominatorPurity_Deuteron"), track.pt()); + if (IsDeuteron(track, -1)) + registry.fill(HIST("hDenominatorPurity_Deuteron"), track.pt() * -1); + + if (doMCQA) { + // Proton + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.pdgCode() == pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPC"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton_TPC"), track.pt()); + } + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF && + track.pdgCode() == pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCTOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton_TPCTOF"), track.pt()); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.pdgCode() == pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPC_or_TOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton_TPC_or_TOF"), track.pt()); + } + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElPr && track.pdgCode() == pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCEl"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton_TPCEl"), track.pt()); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElPr && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.pdgCode() == pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCEl_or_TOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Proton_TPCEl_or_TOF"), track.pt()); + } + + // AntiProton + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.pdgCode() == -pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPC"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton_TPC"), track.pt() * -1); + } + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF && + track.pdgCode() == -pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCTOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton_TPCTOF"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.pdgCode() == -pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPC_or_TOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton_TPC_or_TOF"), track.pt() * -1); + } + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElPr && track.pdgCode() == -pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCEl"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton_TPCEl"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElPr && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.pdgCode() == -pdgProton) { + registry.fill(HIST("hNumeratorPurity_Proton_TPCEl_or_TOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Proton_TPCEl_or_TOF"), track.pt() * -1); + } + + // Deuteron + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPC"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron_TPC"), track.pt()); + } + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF && + track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCTOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron_TPCTOF"), track.pt()); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPC_or_TOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron_TPC_or_TOF"), track.pt()); + } + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElDe && track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCEl"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron_TPCEl"), track.pt()); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElDe && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.pdgCode() == pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCEl_or_TOF"), track.pt()); + registry.fill(HIST("hReco_Pt_Deuteron_TPCEl_or_TOF"), track.pt()); + } + + // AntiDeuteron + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPC"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron_TPC"), track.pt() * -1); + } + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF && + track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCTOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron_TPCTOF"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPC_or_TOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron_TPC_or_TOF"), track.pt() * -1); + } + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElDe && track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCEl"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron_TPCEl"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElDe && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.pdgCode() == -pdgDeuteron) { + registry.fill(HIST("hNumeratorPurity_Deuteron_TPCEl_or_TOF"), track.pt() * -1); + registry.fill(HIST("hReco_Pt_Deuteron_TPCEl_or_TOF"), track.pt() * -1); + } + + // Denominators + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPC"), track.pt()); + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF && track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPCTOF"), track.pt()); + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPC_or_TOF"), track.pt()); + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElPr && track.sign() > 0) { + registry.fill(HIST("hDenominatorPurity_Proton_TPCEl"), track.pt()); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElPr && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.sign() > 0) { + registry.fill(HIST("hDenominatorPurity_Proton_TPCEl_or_TOF"), track.pt()); + } + + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPC"), track.pt() * -1); + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF && track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPCTOF"), track.pt() * -1); + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Proton_TPC_or_TOF"), track.pt() * -1); + if (std::abs(track.tpcNSigmaPr()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElPr && track.sign() < 0) { + registry.fill(HIST("hDenominatorPurity_Proton_TPCEl"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaPr()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElPr && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaPr()) < nsigmaTPC && std::abs(track.tofNSigmaPr()) < nsigmaTOF)) && + track.sign() < 0) { + registry.fill(HIST("hDenominatorPurity_Proton_TPCEl_or_TOF"), track.pt() * -1); + } + + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPC"), track.pt()); + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF && track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCTOF"), track.pt()); + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.sign() > 0) { + registry.fill(HIST("hDenominatorPurity_Deuteron_TPC_or_TOF"), track.pt()); + } + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElDe && track.sign() > 0) { + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCEl"), track.pt()); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElDe && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.sign() > 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCEl_or_TOF"), track.pt()); + + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPC"), track.pt() * -1); + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF && track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCTOF"), track.pt() * -1); + if (( + (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPC_or_TOF"), track.pt() * -1); + if (std::abs(track.tpcNSigmaDe()) < nsigmaTPC && + track.tpcNSigmaEl() >= nsigmaElDe && track.sign() < 0) { + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCEl"), track.pt() * -1); + } + if (((std::abs(track.tpcNSigmaDe()) < nsigmaTPC && track.tpcNSigmaEl() >= nsigmaElDe && track.beta() < -100) || + (track.beta() > -100 && std::abs(track.tpcNSigmaDe()) < nsigmaTPC && std::abs(track.tofNSigmaDe()) < nsigmaTOF)) && + track.sign() < 0) + registry.fill(HIST("hDenominatorPurity_Deuteron_TPCEl_or_TOF"), track.pt() * -1); + } + if (!mcCorrelation) { continue; } - if (isAntiDeTPCTOF) { + if (isDe) { + selectedtracksPIDMC_d[track.singleCollSelId()].push_back(std::make_shared(track)); + } + if (track.pdgCode() == pdgDeuteron) { + selectedtracksMC_d[track.singleCollSelId()].push_back(std::make_shared(track)); + } + if (isAntiDe) { selectedtracksPIDMC_antid[track.singleCollSelId()].push_back(std::make_shared(track)); } if (track.pdgCode() == -pdgDeuteron) { @@ -952,92 +1107,22 @@ struct hadronnucleicorrelation { } for (auto collision : collisions) { - if (TMath::Abs(collision.posZ()) > cutzvertex) + if (std::abs(collision.posZ()) > cutzvertex) continue; registry.fill(HIST("hNEvents"), 0.5); int vertexBinToMix = std::floor((collision.posZ() + cutzvertex) / (2 * cutzvertex / _vertexNbinsToMix)); int centBinToMix = std::floor(collision.multPerc() / (100.0 / _multNsubBins)); - if (selectedtracksMC_p.find(collision.globalIndex()) != selectedtracksMC_p.end()) { - mixbins_pantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); - } - if (selectedtracksMC_antid.find(collision.globalIndex()) != selectedtracksMC_antid.end()) { mixbins_antidantip[std::pair{vertexBinToMix, centBinToMix}].push_back(std::make_shared(collision)); } - if (selectedtracksPIDMC_p.find(collision.globalIndex()) != selectedtracksPIDMC_p.end()) { - mixbinsPID_pantip[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)); } } // coll - if (!mixbins_pantip.empty()) { - - for (auto i = mixbins_pantip.begin(); i != mixbins_pantip.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 (selectedtracksMC_antip.find(col1->index()) != selectedtracksMC_antip.end()) { - mixTracks<0, 1 /*MC qa*/>(selectedtracksMC_p[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 - - auto col2 = (i->second)[indx2]; - - if (col1 == col2) { - continue; - } - - if (selectedtracksMC_antip.find(col2->index()) != selectedtracksMC_antip.end()) { - mixTracks<1, 1>(selectedtracksMC_p[col1->index()], selectedtracksMC_antip[col2->index()], 0, 0); // mixing ME - } - } - } // event - } - } - - if (!mixbinsPID_pantip.empty()) { - - for (auto i = mixbinsPID_pantip.begin(); i != mixbinsPID_pantip.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 (selectedtracksPIDMC_antip.find(col1->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<0, 1 /*MC qa*/>(selectedtracksPIDMC_p[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 - - auto col2 = (i->second)[indx2]; - - if (col1 == col2) { - continue; - } - - if (selectedtracksPIDMC_antip.find(col2->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<1, 1>(selectedtracksPIDMC_p[col1->index()], selectedtracksPIDMC_antip[col2->index()], 0, 1); // mixing ME - } - } - } - } - } - if (!mixbins_antidantip.empty()) { for (auto i = mixbins_antidantip.begin(); i != mixbins_antidantip.end(); i++) { // iterating over all vertex&mult bins @@ -1050,7 +1135,7 @@ struct hadronnucleicorrelation { auto col1 = value[indx1]; if (selectedtracksMC_antip.find(col1->index()) != selectedtracksMC_antip.end()) { - mixTracks<0, 1 /*MC qa*/>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col1->index()], 1, 0); // mixing SE + mixTracks<0, 1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col1->index()], 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 @@ -1062,7 +1147,7 @@ struct hadronnucleicorrelation { } if (selectedtracksMC_antip.find(col2->index()) != selectedtracksMC_antip.end()) { - mixTracks<1, 1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col2->index()], 1, 0); // mixing ME + mixTracks<1, 1>(selectedtracksMC_antid[col1->index()], selectedtracksMC_antip[col2->index()], 0); // mixing ME } } } @@ -1081,7 +1166,7 @@ struct hadronnucleicorrelation { auto col1 = value[indx1]; if (selectedtracksPIDMC_antip.find(col1->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<0, 1 /*MC qa*/>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col1->index()], 1, 1); // mixing SE + mixTracks<0, 1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col1->index()], 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 @@ -1093,7 +1178,7 @@ struct hadronnucleicorrelation { } if (selectedtracksPIDMC_antip.find(col2->index()) != selectedtracksPIDMC_antip.end()) { - mixTracks<1, 1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col2->index()], 1, 1); // mixing ME + mixTracks<1, 1>(selectedtracksPIDMC_antid[col1->index()], selectedtracksPIDMC_antip[col2->index()], 1); // mixing ME } } } @@ -1105,6 +1190,10 @@ struct hadronnucleicorrelation { (i->second).clear(); selectedtracksMC_antid.clear(); + for (auto i = selectedtracksMC_d.begin(); i != selectedtracksMC_d.end(); i++) + (i->second).clear(); + selectedtracksMC_d.clear(); + for (auto i = selectedtracksMC_antip.begin(); i != selectedtracksMC_antip.end(); i++) (i->second).clear(); selectedtracksMC_antip.clear(); @@ -1117,6 +1206,10 @@ struct hadronnucleicorrelation { (i->second).clear(); selectedtracksPIDMC_antid.clear(); + for (auto i = selectedtracksPIDMC_d.begin(); i != selectedtracksPIDMC_d.end(); i++) + (i->second).clear(); + selectedtracksPIDMC_d.clear(); + for (auto i = selectedtracksPIDMC_antip.begin(); i != selectedtracksPIDMC_antip.end(); i++) (i->second).clear(); selectedtracksPIDMC_antip.clear(); @@ -1134,16 +1227,6 @@ struct hadronnucleicorrelation { pair.second.clear(); // clear the vector associated with the key } mixbins_antidantip.clear(); // clear the map - - for (auto& pair : mixbinsPID_pantip) { - pair.second.clear(); // clear the vector associated with the key - } - mixbinsPID_pantip.clear(); // clear the map - - for (auto& pair : mixbins_pantip) { - pair.second.clear(); // clear the vector associated with the key - } - mixbins_pantip.clear(); // clear the map } PROCESS_SWITCH(hadronnucleicorrelation, processMC, "processMC", false); }; diff --git a/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx b/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx index a01b19ba2be..7d54bd86d48 100644 --- a/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx +++ b/PWGLF/Tasks/Nuspex/hypertriton3bodyMCQA.cxx @@ -19,8 +19,13 @@ #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" @@ -29,19 +34,22 @@ #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 FullTracksExtIU = soa::Join; +using ColwithEvTimes = o2::soa::Join; +using FullTracksExtIU = soa::Join; using MCLabeledTracksIU = soa::Join; template @@ -101,12 +109,16 @@ bool isPairedH3LDaughters(TMCParticle const& mctrack0, TMCParticle const& mctrac // 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}}}}, - {"hParticleCount", "hParticleCount", {HistType::kTH1F, {{7, 0.0f, 7.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}}}}, @@ -121,7 +133,7 @@ struct hypertriton3bodyTrackMcinfo { {"hHypertritonMcRapidity", "hHypertritonMcRapidity", {HistType::kTH1F, {{200, -10.0f, 10.0f}}}}, {"hHypertritonMcPt", "hHypertritonMcPt", {HistType::kTH1F, {{300, 0.0f, 15.0f}}}}, - {"hProtonCount", "hProtonCount", {HistType::kTH1F, {{6, 0.0f, 6.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}}}}, @@ -137,7 +149,7 @@ struct hypertriton3bodyTrackMcinfo { {"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"}}}}, - {"hPionCount", "hPionCount", {HistType::kTH1F, {{7, 0.0f, 7.0f}}}}, + {"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}}}}, @@ -152,8 +164,9 @@ struct hypertriton3bodyTrackMcinfo { {"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}}}}, - {"hDeuteronCount", "hDeuteronCount", {HistType::kTH1F, {{7, 0.0f, 7.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}}}}, @@ -169,7 +182,6 @@ struct hypertriton3bodyTrackMcinfo { {"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"}}}}, - {"hDeuteronTOFMatchCounter", "hDeuteronTOFMatchCounter", {HistType::kTH1F, {{8, 0.0f, 8.0f}}}}, {"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"}}}}, @@ -177,38 +189,47 @@ struct hypertriton3bodyTrackMcinfo { {"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}}}}, - {"hTestCounter", "hTestCounter", {HistType::kTH1F, {{22, 0.0f, 22.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("hParticleCount"))->GetXaxis()->SetBinLabel(1, "Readin"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(2, "Has_mcparticle"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(3, "Rapidity Cut"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(4, "McisHypertriton"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(5, "McisProton"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(6, "McisPion"); - registry.get(HIST("hParticleCount"))->GetXaxis()->SetBinLabel(7, "McisDeuteron"); - - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(1, "All track"); - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(2, "hasMC"); - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(3, "hasMC&TPC&TOF"); - for (int i = 0; i < 16; i++) { - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(i + 4, Form("Bit %d", i)); - } - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(20, "hasMC&TPC&TOF&(!Bit15)"); - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(21, "hasMC&TPC&TOF&(!Bit11)"); - registry.get(HIST("hTestCounter"))->GetXaxis()->SetBinLabel(21, "hasMC&TPC&TOF&(!Bit13)&(Bit15)"); - - TString TrackCounterbinLabel[6] = {"hasMom", "FromHypertriton", "TPCNcls", "Eta", "Pt", "TPCPID"}; - for (int i{0}; i < 6; i++) { - registry.get(HIST("hProtonCount"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); - registry.get(HIST("hPionCount"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); - registry.get(HIST("hDeuteronCount"))->GetXaxis()->SetBinLabel(i + 1, TrackCounterbinLabel[i]); + 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("hPionCount"))->GetXaxis()->SetBinLabel(7, "DcatoPV"); - registry.get(HIST("hDeuteronCount"))->GetXaxis()->SetBinLabel(7, "hasTOF"); registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(1, "proton"); registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(2, "pion"); registry.get(HIST("hDuplicatedH3LDaughers"))->GetXaxis()->SetBinLabel(3, "deuteron"); @@ -217,6 +238,17 @@ struct hypertriton3bodyTrackMcinfo { 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"}; @@ -226,8 +258,83 @@ struct hypertriton3bodyTrackMcinfo { Configurable maxPionPt{"maxPionPt", 1.2, "maxPionPt"}; Configurable minDeuteronPt{"minDeuteronPt", 0.6, "minDeuteronPt"}; Configurable maxDeuteronPt{"maxDeuteronPt", 10, "maxDeuteronPt"}; - Configurable event_sel8_selection{"event_sel8_selection", true, "event selection count post sel8 cut"}; - Configurable event_posZ_selection{"event_posZ_selection", true, "event selection count post poZ cut"}; + 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; @@ -239,292 +346,341 @@ struct hypertriton3bodyTrackMcinfo { } }; - void process(soa::Join::iterator const& collision, aod::McParticles const& /*particlesMC*/, MCLabeledTracksIU const& tracks, aod::McCollisions const& /*mcCollisions*/) + 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); + 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; + std::vector protons, pions, deuterons; // index for daughter tracks + std::unordered_set set_proton, set_pion, set_deuteron; // check duplicated daughters + int itrack = -1; - for (auto& track : tracks) { + auto coltracks = tracks.sliceBy(perCollisionTracks, collision.globalIndex()); - ++itrack; - registry.fill(HIST("hParticleCount"), 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()); - - registry.fill(HIST("hTestCounter"), 0.5); - for (int i = 0; i < 16; i++) { - if (track.mcMask() & 1 << i) { // Bit ON means mismatch - registry.fill(HIST("hTestCounter"), i + 3.5); - } - } + for (auto& track : coltracks) { - if (!track.has_mcParticle()) { - continue; - } - registry.fill(HIST("hTestCounter"), 1.5); - auto mcparticle = track.mcParticle_as(); - registry.fill(HIST("hTPCBB"), track.p() * track.sign(), track.tpcSignal()); + ++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.hasTOF() && track.hasTPC()) { - registry.fill(HIST("hTestCounter"), 2.5); - if (!(track.mcMask() & 1 << 15)) { - registry.fill(HIST("hTestCounter"), 19.5); - } - if (!(track.mcMask() & 1 << 11)) { - registry.fill(HIST("hTestCounter"), 20.5); + if (!track.has_mcParticle()) { + continue; } - if (!(track.mcMask() & 1 << 13) && (track.mcMask() & 1 << 15)) { - registry.fill(HIST("hTestCounter"), 21.5); + 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()); } - } - registry.fill(HIST("hParticleCount"), 1.5); - - // if (TMath::Abs(mcparticle.y()) > 0.9) {continue;} - registry.fill(HIST("hParticleCount"), 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("hParticleCount"), 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("hParticleCount"), 4.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hProtonTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); - } + // 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("hProtonCount"), 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("hProtonCount"), 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()); - if (track.tpcNClsFound() < 70) { - continue; - } - registry.fill(HIST("hProtonCount"), 2.5); - if (TMath::Abs(track.eta()) > 0.9) { - continue; - } - registry.fill(HIST("hProtonCount"), 3.5); - if (track.pt() < minProtonPt || track.pt() > maxProtonPt) { - continue; - } - registry.fill(HIST("hProtonCount"), 4.5); - if (TMath::Abs(track.tpcNSigmaPr()) > 5) { - continue; + 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("hProtonCount"), 5.5); } - } - 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("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("hParticleCount"), 5.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hPionTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); + 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()); } - if (mcparticle.has_mothers()) { - registry.fill(HIST("hPionCount"), 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("hPionCount"), 1.5); - registry.fill(HIST("hDauPionPt"), track.pt()); - registry.fill(HIST("hDauPionMcPt"), mcparticle.pt()); - registry.fill(HIST("hDauPionTPCVsPt"), track.pt(), track.tpcNSigmaPi()); - if (track.tpcNClsFound() < 70) { - continue; - } - registry.fill(HIST("hPionCount"), 2.5); - if (TMath::Abs(track.eta()) > 0.9) { - continue; - } - registry.fill(HIST("hPionCount"), 3.5); - if (track.pt() < minPionPt || track.pt() > maxPionPt) { - continue; - } - registry.fill(HIST("hPionCount"), 4.5); - if (TMath::Abs(track.tpcNSigmaPi()) > 5) { - continue; - } - registry.fill(HIST("hPionCount"), 5.5); - if (TMath::Abs(track.dcaXY()) < dcapiontopv) { - continue; + // 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("hPionCount"), 6.5); } + + 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()); } - registry.fill(HIST("hPionMcPt"), mcparticle.pt()); - registry.fill(HIST("hPionMcP"), mcparticle.p()); - registry.fill(HIST("hPionPt"), track.pt()); - registry.fill(HIST("hPionP"), track.p()); + float tofNsigmaDe = -999; + static constexpr float kCSPEED = TMath::C() * 1.0e2f * 1.0e-12f; // c in cm/ps - 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()); - } + 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 - // Deuteron - if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { - registry.fill(HIST("hParticleCount"), 6.5); - if (track.tpcNClsFound() > 70) { - registry.fill(HIST("hDeuteronTPCBBAfterTPCNclsCut"), track.p() * track.sign(), track.tpcSignal()); + 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)); } - if (mcparticle.has_mothers()) { - registry.fill(HIST("hDeuteronCount"), 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("hDeuteronCount"), 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()); - if (track.hasTOF()) { - registry.fill(HIST("hDauDeuteronTOFNSigmaVsPHasTOF"), track.sign() * track.p(), track.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); + // 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"), 3.5); + 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); + } } } - if (track.tpcNClsFound() < 70) { - continue; - } - registry.fill(HIST("hDeuteronCount"), 2.5); - if (TMath::Abs(track.eta()) > 0.9) { - continue; - } - registry.fill(HIST("hDeuteronCount"), 3.5); - if (track.pt() < minDeuteronPt || track.pt() > maxDeuteronPt) { - continue; - } - registry.fill(HIST("hDeuteronCount"), 4.5); - if (TMath::Abs(track.tpcNSigmaDe()) > 5) { - continue; - } - registry.fill(HIST("hDeuteronCount"), 5.5); - if (!track.hasTOF()) { - continue; - } - registry.fill(HIST("hDeuteronCount"), 6.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); } } + } - 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()); - registry.fill(HIST("hDeuteronTOFMatchCounter"), 0.5); - if (!(track.mcMask() & 1 << 15)) { - registry.fill(HIST("hDeuteronTOFMatchCounter"), 1.5); - if (track.hasTPC() && track.hasTOF()) { - registry.fill(HIST("hDeuteronTOFMatchCounter"), 2.5); - if (!(track.mcMask() & 1 << 11)) { // Bit ON means mismatch - registry.fill(HIST("hDeuteronTOFMatchCounter"), 3.5); + 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); + } } } } } } - 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) + // 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("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); + }*/ + 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); + } } } } @@ -534,56 +690,85 @@ struct hypertriton3bodyTrackMcinfo { }; // check the performance of mcparticle -struct hypertriton3bodyMcParticleCount { +struct hypertriton3bodyMcParticleCheck { // Basic checks HistogramRegistry registry{ "registry", { - {"hTotalMcCollCounter", "hTotalMcCollCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, + {"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)"}}}}, - {"hMcPhysicalPrimaryParticleCount", "hMcPhysicalPrimaryParticleCount", {HistType::kTH1F, {{8, 0.0f, 8.0f}}}}, - {"hMcHypertritonCount", "hMcHypertritonCount", {HistType::kTH1F, {{9, 0.0f, 9.0f}}}}, + {"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("hTotalMcCollCounter"))->GetXaxis()->SetBinLabel(1, "Total Count"); - registry.get(HIST("hTotalMcCollCounter"))->GetXaxis()->SetBinLabel(2, "Recoonstructed"); - - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(1, "Readin"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(2, "IsPhysicalPrimary"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(3, "y<0.9(off)"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(4, "(Anti)Proton"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(5, "(Anti)Pion"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(6, "(Anti)Deuteron"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(7, "(Anti)Hypertriton"); - registry.get(HIST("hMcPhysicalPrimaryParticleCount"))->GetXaxis()->SetBinLabel(8, "HasDaughter"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(1, "Hypertriton All"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(2, "Matter All"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(3, "AntiMatter All"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(4, "confirm to 3-body decay"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(5, "Matter"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(6, "AntiMatter"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(7, "Rapidity"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(8, "Lifetime"); - registry.get(HIST("hMcHypertritonCount"))->GetXaxis()->SetBinLabel(9, "PtCut"); + 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", true, "event selection count post sel8 cut"}; - Configurable event_posZ_selection{"event_posZ_selection", true, "event selection count post poZ cut"}; + 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; - void process(aod::McCollision const& mcCollision, aod::McParticles const& particlesMC, const soa::SmallGroups>& collisions) + 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) { @@ -597,119 +782,116 @@ struct hypertriton3bodyMcParticleCount { } SelectedEvents.resize(nevts); - registry.fill(HIST("hTotalMcCollCounter"), 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("hTotalMcCollCounter"), 1.5); - // return; - } + 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; + } - for (auto& mcparticle : particlesMC) { + const auto& dparticlesMC = particlesMC.sliceBy(permcCollision, mcCollision.globalIndex()); - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 0.5); + 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("hMcHypertritonCount"), 1.5); - } else if (mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCount"), 2.5); - } - if (mcparticle.pdgCode() == 1010010030 || mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCount"), 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; - bool flag_H3L = is3bodyDecayedH3L(mcparticle); - if (!flag_H3L) { - continue; + if (mcparticle.pdgCode() == 2212 || mcparticle.pdgCode() == -2212) { + registry.fill(HIST("hMcProtonPt"), mcparticle.pt()); } - 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 (std::abs(mcparticleDaughter.pdgCode()) == 211) { - dauPionMom[0] = mcparticleDaughter.px(); - dauPionMom[1] = mcparticleDaughter.py(); - dauPionMom[2] = mcparticleDaughter.pz(); - } - 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 (mcparticle.pdgCode() == 211 || mcparticle.pdgCode() == -211) { + registry.fill(HIST("hMcPionPt"), mcparticle.pt()); } - if (mcparticle.pdgCode() == 1010010030) { - registry.fill(HIST("hMcHypertritonCount"), 3.5); - registry.fill(HIST("hMcHypertritonCount"), 4.5); + if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { + registry.fill(HIST("hMcDeuteronPt"), mcparticle.pt()); } - if (mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcHypertritonCount"), 3.5); - registry.fill(HIST("hMcHypertritonCount"), 5.5); + if (mcparticle.pdgCode() == 1010010030) { + registry.fill(HIST("hMcHypertritonCounter"), 1.5); + } else if (mcparticle.pdgCode() == -1010010030) { + registry.fill(HIST("hMcHypertritonCounter"), 2.5); } - MClifetime = RecoDecay::sqrtSumOfSquares(dauDeuteronPos[0] - mcparticle.vx(), dauDeuteronPos[1] - mcparticle.vy(), dauDeuteronPos[2] - mcparticle.vz()) * o2::constants::physics::MassHyperTriton / mcparticle.p(); - registry.fill(HIST("hMcRecoInvMass"), 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("h3dMCDecayedHypertriton"), mcparticle.y(), mcparticle.pt(), MClifetime); - - // int daughterPionCount = 0; - // for (auto& mcparticleDaughter : mcparticle.daughters_as()) { - // if (std::abs(mcparticleDaughter.pdgCode()) == 211) { - // daughterPionCount++; - // } - // } - - // Count for hypertriton N_gen - if (TMath::Abs(mcparticle.y()) < 1) { - registry.fill(HIST("hMcHypertritonCount"), 6.5); - if (MClifetime < 40) { - registry.fill(HIST("hMcHypertritonCount"), 7.5); - if (mcparticle.pt() > 1 && mcparticle.pt() < 10) { - registry.fill(HIST("hMcHypertritonCount"), 8.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); + } + } } } } } - - if (!mcparticle.isPhysicalPrimary()) { - continue; - } - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 1.5); - if (TMath::Abs(mcparticle.y()) > rapidityMCcut) { - continue; - } - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 2.5); - - if (mcparticle.pdgCode() == 211 || mcparticle.pdgCode() == -211) { - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 3.5); - } else if (mcparticle.pdgCode() == 2212 || mcparticle.pdgCode() == -2212) { - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 4.5); - } else if (mcparticle.pdgCode() == 1000010020 || mcparticle.pdgCode() == -1000010020) { - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 5.5); - } else if (mcparticle.pdgCode() == 1010010030 || mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 6.5); - } - - if (!mcparticle.has_daughters()) { - continue; - } - registry.fill(HIST("hMcPhysicalPrimaryParticleCount"), 7.5); } } }; @@ -718,6 +900,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx b/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx index 4e0b781d897..6d07b9e1de4 100644 --- a/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx +++ b/PWGLF/Tasks/Nuspex/hypertriton3bodyanalysis.cxx @@ -46,6 +46,7 @@ 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 { @@ -61,6 +62,9 @@ struct hypertriton3bodyQa { {"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"}}}}, @@ -74,12 +78,19 @@ struct hypertriton3bodyQa { {"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) { @@ -93,8 +104,6 @@ struct hypertriton3bodyQa { registry.fill(HIST("hVtxPt"), vtx.pt()); registry.fill(HIST("hMassHypertriton"), vtx.mHypertriton()); registry.fill(HIST("hMassAntiHypertriton"), vtx.mAntiHypertriton()); - registry.fill(HIST("hTOFPIDDeuteron"), vtx.tofNSigmaBachDe()); - registry.fill(HIST("hDeuTOFNsigma"), track2.tpcInnerParam() * track2.sign(), vtx.tofNSigmaBachDe()); if (std::abs(track2.tpcNSigmaDe()) < 5) { registry.fill(HIST("hDeuTOFNsigmaWithTPC"), track2.tpcInnerParam() * track2.sign(), vtx.tofNSigmaBachDe()); } @@ -102,27 +111,43 @@ struct hypertriton3bodyQa { 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 @@ -133,6 +158,7 @@ struct hypertriton3bodyAnalysis { 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"}; @@ -149,6 +175,12 @@ struct hypertriton3bodyAnalysis { 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", @@ -164,6 +196,9 @@ struct hypertriton3bodyAnalysis { {"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"}}}}, @@ -183,44 +218,37 @@ struct hypertriton3bodyAnalysis { {"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"}}}}, - {"hDeuteronTOFVsPAtferTOFCut", "hDeuteronTOFVsPAtferTOFCut", {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})"}}}}, - {"hTrueHypertritonCounter", "hTrueHypertritonCounter", {HistType::kTH1F, {{12, 0.0f, 12.0f}}}}, {"hDeuteronTOFVsPBeforeTOFCutSig", "hDeuteronTOFVsPBeforeTOFCutSig", {HistType::kTH2F, {{40, -10.0f, 10.0f, "p/z (GeV/c)"}, {40, -10.0f, 10.0f, "TOF n#sigma"}}}}, - {"hDeuteronTOFVsPAtferTOFCutSig", "hDeuteronTOFVsPAtferTOFCutSig", {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 mcparticles information - {"hGeneratedHypertritonCounter", "hGeneratedHypertritonCounter", {HistType::kTH1F, {{2, 0.0f, 2.0f}}}}, - {"hPtGeneratedHypertriton", "hPtGeneratedHypertriton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hctGeneratedHypertriton", "hctGeneratedHypertriton", {HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}}}, - {"hEtaGeneratedHypertriton", "hEtaGeneratedHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hRapidityGeneratedHypertriton", "hRapidityGeneratedHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hPtGeneratedAntiHypertriton", "hPtGeneratedAntiHypertriton", {HistType::kTH1F, {{200, 0.0f, 10.0f}}}}, - {"hctGeneratedAntiHypertriton", "hctGeneratedAntiHypertriton", {HistType::kTH1F, {{50, 0, 50, "ct(cm)"}}}}, - {"hEtaGeneratedAntiHypertriton", "hEtaGeneratedAntiHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, - {"hRapidityGeneratedAntiHypertriton", "hRapidityGeneratedAntiHypertriton", {HistType::kTH1F, {{40, -2.0f, 2.0f}}}}, + // 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, - kCandCosPA, kCandDauEta, + kCandDauPt, + kCandTPCNcls, + kCandTPCPID, + kCandTOFPID, + kCandDcaToPV, kCandRapidity, kCandct, + kCandCosPA, kCandDcaDau, - kCandTOFPID, - kCandTPCPID, - kCandTPCNcls, - kCandDauPt, - kCandDcaToPV, kCandInvMass, kNCandSteps }; @@ -247,7 +275,9 @@ struct hypertriton3bodyAnalysis { { for (Int_t ii = 0; ii < kNCandSteps; ii++) { registry.fill(HIST("hCandidatesCounter"), ii, statisticsRegistry.candstats[ii]); - registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); + if (doprocessMC == true) { + registry.fill(HIST("hTrueHypertritonCounter"), ii, statisticsRegistry.truecandstats[ii]); + } } } @@ -256,117 +286,122 @@ struct hypertriton3bodyAnalysis { void init(InitContext const&) { - /*AxisSpec dcaAxis = {dcaBinning, "DCA (cm)"}; - AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/c)"}; - AxisSpec massAxisHypertriton = {80, 2.96f, 3.04f, "Inv. Mass (GeV/c^{2})"};*/ - 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"); - TString CandCounterbinLabel[12] = {"Total", "VtxCosPA", "TrackEta", "MomRapidity", "Lifetime", "VtxDcaDau", "d TOFPID", "TPCPID", "TPCNcls", "DauPt", "PionDcatoPV", "InvMass"}; + 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]); - registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); + if (doprocessMC == true) { + registry.get(HIST("hTrueHypertritonCounter"))->GetXaxis()->SetBinLabel(i + 1, CandCounterbinLabel[i]); + } } - - registry.get(HIST("hGeneratedHypertritonCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hGeneratedHypertritonCounter"))->GetXaxis()->SetBinLabel(2, "3-body decay"); } //------------------------------------------------------------------ - Preslice perCollisionVtx3BodyDatas = o2::aod::vtx3body::collisionId; - //------------------------------------------------------------------ - // Analysis process for a single candidate - template - void CandidateAnalysis(TCollisionTable const& dCollision, TCandTable const& candData, bool& if_hasvtx, bool isTrueCand = false, double MClifetime = -1, double lPt = -1) + // 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); - auto track0 = candData.template track0_as(); - auto track1 = candData.template track1_as(); - auto track2 = candData.template track2_as(); - - auto& trackProton = (track2.sign() > 0) ? track0 : track1; - auto& trackPion = (track2.sign() > 0) ? track1 : track0; - auto& trackDeuteron = track2; - - if (candData.vtxcosPA(dCollision.posX(), dCollision.posY(), dCollision.posZ()) < vtxcospa) { - return; - } - FillCandCounter(kCandCosPA, isTrueCand); - if (TMath::Abs(trackProton.eta()) > etacut || TMath::Abs(trackPion.eta()) > etacut || TMath::Abs(trackDeuteron.eta()) > etacut) { - return; + // 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 (TMath::Abs(candData.yHypertriton()) > rapiditycut) { - return; + + if (trackProton.pt() < minProtonPt || trackProton.pt() > maxProtonPt || trackPion.pt() < minPionPt || trackPion.pt() > maxPionPt || trackDeuteron.pt() < minDeuteronPt || trackDeuteron.pt() > maxDeuteronPt) { + return false; } - FillCandCounter(kCandRapidity, isTrueCand); - double ct = candData.distovertotmom(dCollision.posX(), dCollision.posY(), dCollision.posZ()) * o2::constants::physics::MassHyperTriton; - if (ct > lifetimecut) { - return; + FillCandCounter(kCandDauPt, isTrueCand); + + if (trackProton.tpcNClsFound() < mintpcNClsproton || trackPion.tpcNClsFound() < mintpcNClspion || trackDeuteron.tpcNClsFound() < mintpcNClsdeuteron) { + return false; } - FillCandCounter(kCandct, isTrueCand); - if (candData.dcaVtxdaughters() > dcavtxdau) { - return; + FillCandCounter(kCandTPCNcls, isTrueCand); + + if (std::abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut || std::abs(trackPion.tpcNSigmaPi()) > TpcPidNsigmaCut || std::abs(trackDeuteron.tpcNSigmaDe()) > TpcPidNsigmaCut) { + return false; } - FillCandCounter(kCandDcaDau, isTrueCand); + 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; + return false; } FillCandCounter(kCandTOFPID, isTrueCand); - registry.fill(HIST("hDeuteronTOFVsPAtferTOFCut"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); + // 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("hDeuteronTOFVsPAtferTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); + // registry.fill(HIST("hDeuteronDefaultTOFVsPAfterTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), trackDeuteron.tofNSigmaDe()); + registry.fill(HIST("hDeuteronTOFVsPAfterTOFCutSig"), trackDeuteron.sign() * trackDeuteron.p(), candData.tofNSigmaBachDe()); } - if (TMath::Abs(trackProton.tpcNSigmaPr()) > TpcPidNsigmaCut || TMath::Abs(trackPion.tpcNSigmaPi()) > TpcPidNsigmaCut || TMath::Abs(trackDeuteron.tpcNSigmaDe()) > TpcPidNsigmaCut) { - return; + double dcapion = isMatter ? candData.dcatrack1topv() : candData.dcatrack0topv(); + if (std::abs(dcapion) < dcapiontopv) { + return false; } - FillCandCounter(kCandTPCPID, isTrueCand); + FillCandCounter(kCandDcaToPV, isTrueCand); - if (trackProton.tpcNClsFound() < mintpcNClsproton || trackPion.tpcNClsFound() < mintpcNClspion || trackDeuteron.tpcNClsFound() < mintpcNClsdeuteron) { - return; + // Selection on candidate hypertriton + if (std::abs(candData.yHypertriton()) > rapiditycut) { + return false; } - FillCandCounter(kCandTPCNcls, isTrueCand); + FillCandCounter(kCandRapidity, isTrueCand); - if (trackProton.pt() < minProtonPt || trackProton.pt() > maxProtonPt || trackPion.pt() < minPionPt || trackPion.pt() > maxPionPt || trackDeuteron.pt() < minDeuteronPt || trackDeuteron.pt() > maxDeuteronPt) { - return; + double ct = candData.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassHyperTriton; + if (ct > lifetimecut) { + return false; } - FillCandCounter(kCandDauPt, isTrueCand); + FillCandCounter(kCandct, isTrueCand); - double dcapion = (track2.sign() > 0) ? candData.dcatrack1topv() : candData.dcatrack0topv(); - if (TMath::Abs(dcapion) < dcapiontopv) { - return; + double cospa = candData.vtxcosPA(collision.posX(), collision.posY(), collision.posZ()); + if (cospa < vtxcospa) { + return false; } - FillCandCounter(kCandDcaToPV, isTrueCand); - - // 3sigma region for Dalitz plot - double lowersignallimit = o2::constants::physics::MassHyperTriton - 3 * mcsigma; - double uppersignallimit = o2::constants::physics::MassHyperTriton + 3 * mcsigma; + FillCandCounter(kCandCosPA, isTrueCand); - // Hypertriton - if ((track2.sign() > 0 && candData.mHypertriton() > h3LMassLowerlimit && candData.mHypertriton() < h3LMassUpperlimit)) { - if_hasvtx = true; - FillCandCounter(kCandInvMass, 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()); // dCollision.centV0M() instead of 0. once available + 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})); @@ -374,20 +409,19 @@ struct hypertriton3bodyAnalysis { if (isTrueCand) { registry.fill(HIST("h3dTotalTrueHypertriton"), MClifetime, lPt, candData.mHypertriton()); } - } else if ((track2.sign() < 0 && candData.mAntiHypertriton() > h3LMassLowerlimit && candData.mAntiHypertriton() < h3LMassUpperlimit)) { + } else if ((!isMatter && candData.mAntiHypertriton() > h3LMassLowerlimit && candData.mAntiHypertriton() < h3LMassUpperlimit)) { // AntiHypertriton - if_hasvtx = true; - FillCandCounter(kCandInvMass, isTrueCand); - 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()); // dCollision.centV0M() instead of 0. once available + 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})); @@ -396,10 +430,14 @@ struct hypertriton3bodyAnalysis { registry.fill(HIST("h3dTotalTrueHypertriton"), MClifetime, lPt, candData.mHypertriton()); } } else { - return; + return false; } + + FillCandCounter(kCandInvMass, isTrueCand); + + registry.fill(HIST("hDCAXYDeuteronToPV"), candData.dcaXYtrack2topv()); registry.fill(HIST("hDCADeuteronToPV"), candData.dcatrack2topv()); - registry.fill(HIST("hVtxCosPA"), candData.vtxcosPA(dCollision.posX(), dCollision.posY(), dCollision.posZ())); + 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()); @@ -414,6 +452,29 @@ struct hypertriton3bodyAnalysis { 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; + } } //------------------------------------------------------------------ @@ -421,7 +482,7 @@ struct hypertriton3bodyAnalysis { void GetGeneratedH3LInfo(aod::McParticles const& particlesMC) { for (auto& mcparticle : particlesMC) { - if (std::abs(mcparticle.pdgCode()) != 1010010030) { + if (std::abs(mcparticle.pdgCode()) != motherPdgCode) { continue; } registry.fill(HIST("hGeneratedHypertritonCounter"), 0.5); @@ -438,22 +499,22 @@ struct hypertriton3bodyAnalysis { havePionPlus = true; if (mcparticleDaughter.pdgCode() == -211) havePionMinus = true; - if (mcparticleDaughter.pdgCode() == 1000010020) { + 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() == -1000010020) { + 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() == 1010010030) { + 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() == -1010010030) { + } 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); @@ -498,12 +559,12 @@ struct hypertriton3bodyAnalysis { for (const auto& collision : collisions) { registry.fill(HIST("hEventCounter"), 0.5); - if (event_sel8_selection && !collision.sel8()) { + 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 - return; + continue; } registry.fill(HIST("hEventCounter"), 2.5); @@ -531,8 +592,8 @@ struct hypertriton3bodyAnalysis { // lLabel = lMother1.globalIndex(); lPt = lMother1.pt(); lPDG = lMother1.pdgCode(); - if ((lPDG == 1010010030 && lMCTrack0.pdgCode() == 2212 && lMCTrack1.pdgCode() == -211 && lMCTrack2.pdgCode() == 1000010020) || - (lPDG == -1010010030 && lMCTrack0.pdgCode() == 211 && lMCTrack1.pdgCode() == -2212 && lMCTrack2.pdgCode() == -1000010020)) { + 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(); } @@ -557,45 +618,48 @@ struct hypertriton3bodyAnalysis { // check vtx3body with mclabels struct hypertriton3bodyLabelCheck { - HistogramRegistry registry{ - "registry", - { - {"hLabeledVtxCounter", "hLabeledVtxCounter", {HistType::kTH1F, {{3, 0.0f, 3.0f}}}}, - {"hMassTrueH3L", "hMassTrueH3L", {HistType::kTH1F, {{80, 2.96f, 3.04f}}}}, - {"hMassTrueH3LMatter", "hMassTrueH3LMatter", {HistType::kTH1F, {{80, 2.96f, 3.04f}}}}, - {"hMassTrueH3LAntiMatter", "hMassTrueH3LAntiMatter", {HistType::kTH1F, {{80, 2.96f, 3.04f}}}}, - {"hPIDCounter", "hPIDCounter", {HistType::kTH1F, {{6, 0.0f, 6.0f}}}}, - {"hHypertritonCounter", "hHypertritonCounter", {HistType::kTH1F, {{4, 0.0f, 4.0f}}}}, - {"hDecay3BodyCounter", "hDecay3BodyCounter", {HistType::kTH1F, {{5, 0.0f, 5.0f}}}}, - }, - }; + + 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&) { - registry.get(HIST("hLabeledVtxCounter"))->GetXaxis()->SetBinLabel(1, "Readin"); - registry.get(HIST("hLabeledVtxCounter"))->GetXaxis()->SetBinLabel(2, "TrueMCH3L"); - registry.get(HIST("hLabeledVtxCounter"))->GetXaxis()->SetBinLabel(3, "Nonrepetitive"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(1, "H3L Proton PID > 5"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(2, "H3L Pion PID > 5"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(3, "H3L Deuteron PID > 5"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(4, "#bar{H3L} Proton PID > 5"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(5, "#bar{H3L} Pion PID > 5"); - registry.get(HIST("hPIDCounter"))->GetXaxis()->SetBinLabel(6, "#bar{H3L} Deuteron PID > 5"); - registry.get(HIST("hHypertritonCounter"))->GetXaxis()->SetBinLabel(1, "H3L"); - registry.get(HIST("hHypertritonCounter"))->GetXaxis()->SetBinLabel(2, "H3L daughters pass PID"); - registry.get(HIST("hHypertritonCounter"))->GetXaxis()->SetBinLabel(3, "#bar{H3L}"); - registry.get(HIST("hHypertritonCounter"))->GetXaxis()->SetBinLabel(4, "#bar{H3L} daughters pass PID"); - registry.get(HIST("hDecay3BodyCounter"))->GetXaxis()->SetBinLabel(1, "Total"); - registry.get(HIST("hDecay3BodyCounter"))->GetXaxis()->SetBinLabel(2, "True H3L"); - registry.get(HIST("hDecay3BodyCounter"))->GetXaxis()->SetBinLabel(3, "Unduplicated H3L"); - registry.get(HIST("hDecay3BodyCounter"))->GetXaxis()->SetBinLabel(4, "Correct collision"); - registry.get(HIST("hDecay3BodyCounter"))->GetXaxis()->SetBinLabel(4, "Same ColID for daughters"); + 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 + } } - 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"}; - Configurable TpcPidNsigmaCut{"TpcPidNsigmaCut", 5, "TpcPidNsigmaCut"}; - struct Indexdaughters { // check duplicated paired daughters int64_t index0; int64_t index1; @@ -606,11 +670,11 @@ struct hypertriton3bodyLabelCheck { } }; - void process(soa::Join::iterator const&) + void processData(soa::Join::iterator const&) { // dummy function } - PROCESS_SWITCH(hypertriton3bodyLabelCheck, process, "Donot check MC label tables", true); + 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*/) { @@ -655,7 +719,7 @@ struct hypertriton3bodyLabelCheck { } } - if (event_sel8_selection && !collision.sel8()) { + if (mc_event_selection && (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))) { return; } @@ -671,11 +735,17 @@ struct hypertriton3bodyLabelCheck { auto lTrack0 = vtx.track0_as(); auto lTrack1 = vtx.track1_as(); auto lTrack2 = vtx.track2_as(); - if (mcparticle.pdgCode() == 1010010030) { - registry.fill(HIST("hLabeledVtxCounter"), 1.5); + 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()); @@ -693,11 +763,12 @@ struct hypertriton3bodyLabelCheck { if (TMath::Abs(lTrack0.tpcNSigmaPr()) < TpcPidNsigmaCut && TMath::Abs(lTrack1.tpcNSigmaPi()) < TpcPidNsigmaCut && TMath::Abs(lTrack2.tpcNSigmaDe()) < TpcPidNsigmaCut) { registry.fill(HIST("hHypertritonCounter"), 1.5); } - } else if (mcparticle.pdgCode() == -1010010030) { - registry.fill(HIST("hLabeledVtxCounter"), 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()); diff --git a/PWGLF/Tasks/Nuspex/nucleiEbye.cxx b/PWGLF/Tasks/Nuspex/nucleiEbye.cxx index 0915320f529..681d8b2892e 100644 --- a/PWGLF/Tasks/Nuspex/nucleiEbye.cxx +++ b/PWGLF/Tasks/Nuspex/nucleiEbye.cxx @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -357,6 +359,8 @@ struct nucleiEbye { histos.fill(HIST("QA/nClsTPC"), track.tpcNcls()); for (int iP{0}; iP < kNpart; ++iP) { + if (track.mass() != iP) + continue; if (trackPt < ptMin[iP] || trackPt > ptMax[iP]) { continue; } @@ -673,6 +677,8 @@ struct nucleiEbye { void processData(aod::CollEbyeTable const& collision, aod::NucleiEbyeTables const& tracks, aod::LambdaEbyeTables const& v0s) { + if (std::abs(collision.zvtx()) > zVtxMax) + return; histos.fill(HIST("QA/zVtx"), collision.zvtx()); fillRecoEvent(collision, tracks, v0s, collision.centrality()); } @@ -681,6 +687,8 @@ struct nucleiEbye { void processMc(aod::CollEbyeTables const& collisions, aod::McNucleiEbyeTables const& tracksTot, aod::McLambdaEbyeTables const& v0sTot) { for (auto& collision : collisions) { + if (std::abs(collision.zvtx()) > zVtxMax) + continue; auto tracks = tracksTot.sliceBy(perCollTrack, collision.globalIndex()); auto v0s = v0sTot.sliceBy(perCollV0s, collision.globalIndex()); histos.fill(HIST("QA/zVtx"), collision.zvtx()); diff --git a/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx b/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx index 5b984cfc03a..ab26df26ea1 100644 --- a/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx +++ b/PWGLF/Tasks/Nuspex/nuclei_in_jets.cxx @@ -14,12 +14,18 @@ #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" @@ -40,6 +46,8 @@ 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; @@ -48,7 +56,7 @@ using std::array; using SelectedCollisions = soa::Join; using SimCollisions = soa::Join; -using FullTracks = soa::Join; +using FullNucleiTracks = soa::Join; using MCTracks = soa::Join; @@ -79,12 +87,16 @@ struct nuclei_in_jets { true}; // Global Parameters - Configurable min_pt_leading{"min_pt_leading", 5.0, "Minimum pt of leading particle"}; + Configurable min_jet_pt{"min_jet_pt", 10.0, "Minimum pt of the jet"}; Configurable Rjet{"Rjet", 0.3, "Jet resolution parameter R"}; - Configurable Rmax{"Rmax", 0.3, "Maximum radius for jet and UE regions"}; 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"}; @@ -93,89 +105,133 @@ struct nuclei_in_jets { 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 min_y{"min_y", -0.5, "minimum y"}; - Configurable max_y{"max_y", +0.5, "maximum y"}; - Configurable max_dcaxy{"max_dcaxy", 0.1, "Maximum DCAxy"}; - Configurable max_dcaz{"max_dcaz", 0.1, "Maximum DCAz"}; + 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("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("ptLeading", "ptLeading", HistType::kTH1F, {{500, 0, 50, "#it{p}_{T} (GeV/#it{c})"}}); - registryQC.add("etaLeading", "etaLeading", HistType::kTH1F, {{100, -0.8, 0.8, "#eta"}}); - registryQC.add("phiLeading", "phiLeading", HistType::kTH1F, {{100, 0, TMath::TwoPi(), "#phi"}}); - registryQC.add("rJet", "rJet", HistType::kTH1F, {{100, 0.0, 0.5, "#it{R}"}}); - registryQC.add("rUE", "rUE", HistType::kTH1F, {{100, 0.0, 0.5, "#it{R}"}}); - registryQC.add("angle_jet_leading_track", "angle_jet_leading_track", HistType::kTH1F, {{200, 0.0, 50.0, "#theta"}}); - 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, 0.5 * TMath::Pi(), "#Delta#phi"}}); - registryQC.add("deltaEtadeltaPhiUE", "deltaEtadeltaPhiUE", HistType::kTH2F, {{200, -0.5, 0.5, "#Delta#eta"}, {200, 0, 0.5 * TMath::Pi(), "#Delta#phi"}}); + 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, {{20, 0.0, 1.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antiproton_jet_tof", "antiproton_jet_tof", HistType::kTH2F, {{90, 0.5, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antiproton_ue_tpc", "antiproton_ue_tpc", HistType::kTH2F, {{20, 0.0, 1.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antiproton_ue_tof", "antiproton_ue_tof", HistType::kTH2F, {{90, 0.5, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antiproton_dca_jet", "antiproton_dca_jet", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - registryData.add("antiproton_dca_ue", "antiproton_dca_ue", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); + 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, {{10, 0.0, 1.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antideuteron_jet_tof", "antideuteron_jet_tof", HistType::kTH2F, {{45, 0.5, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); - registryData.add("antideuteron_ue_tpc", "antideuteron_ue_tpc", HistType::kTH2F, {{10, 0.0, 1.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antideuteron_ue_tof", "antideuteron_ue_tof", HistType::kTH2F, {{45, 0.5, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + 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, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); - registryData.add("antihelium3_ue_tpc", "antihelium3_ue_tpc", HistType::kTH2F, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + 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, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_gen", "antideuteron_jet_gen", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_jet_gen", "antihelium3_jet_gen", HistType::kTH1F, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_gen", "antiproton_ue_gen", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_gen", "antideuteron_ue_gen", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_ue_gen", "antihelium3_ue_gen", HistType::kTH1F, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}}); + 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, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_rec_tpc", "antideuteron_jet_rec_tpc", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_jet_rec_tpc", "antihelium3_jet_rec_tpc", HistType::kTH1F, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_rec_tpc", "antiproton_ue_rec_tpc", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_rec_tpc", "antideuteron_ue_rec_tpc", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antihelium3_ue_rec_tpc", "antihelium3_ue_rec_tpc", HistType::kTH1F, {{40, 1.0, 7.0, "#it{p}_{T} (GeV/#it{c})"}}); + 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, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_jet_rec_tof", "antideuteron_jet_rec_tof", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_ue_rec_tof", "antiproton_ue_rec_tof", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antideuteron_ue_rec_tof", "antideuteron_ue_rec_tof", HistType::kTH1F, {{50, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + 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, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); - registryMC.add("antiproton_dca_sec", "antiproton_dca_sec", HistType::kTH2F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}, {200, -0.5, 0.5, "DCA_{xy} (cm)"}}); + 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, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all", "antiproton_all", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_prim_jet", "antiproton_prim_jet", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all_jet", "antiproton_all_jet", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_prim_ue", "antiproton_prim_ue", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); - registryMC.add("antiproton_all_ue", "antiproton_all_ue", HistType::kTH1F, {{100, 0.0, 5.0, "#it{p}_{T} (GeV/#it{c})"}}); + 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 @@ -184,12 +240,10 @@ struct nuclei_in_jets { { if (!track.hasITS()) return false; - if (track.itsNCls() < 2) + if (track.itsNCls() < 3) return false; if (!track.hasTPC()) return false; - if (track.tpcNClsFound() < 70) - return false; if (track.tpcNClsCrossedRows() < 70) return false; if (track.tpcChi2NCl() > 4) @@ -200,10 +254,22 @@ struct nuclei_in_jets { return false; if (track.pt() < 0.15) return false; - if (TMath::Abs(track.dcaXY()) > 0.5) - return false; - if (TMath::Abs(track.dcaZ()) > 0.5) - 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; } @@ -277,16 +343,6 @@ struct nuclei_in_jets { return delta_phi; } - // Rapidity - double get_rapidity(double px, double py, double pz, double mass) - { - double rap(0); - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(px, py, pz, mass); - rap = lorentzVect.Rapidity(); - return rap; - } - void get_perpendicular_axis(TVector3 p, TVector3& u, double sign) { // Initialization @@ -323,7 +379,7 @@ struct nuclei_in_jets { 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 + // Protection against delta<0 if (delta < 0) { return; } @@ -336,11 +392,56 @@ struct nuclei_in_jets { 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, FullTracks const& tracks) + 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()) @@ -350,310 +451,349 @@ struct nuclei_in_jets { registryData.fill(HIST("number_of_events_data"), 1.5); // Cut on z-vertex - if (abs(collision.posZ()) > zVtx) + if (TMath::Abs(collision.posZ()) > zVtx) return; // Event Counter: after z-vertex cut registryData.fill(HIST("number_of_events_data"), 2.5); - // Indices of Reduced Event - std::vector particle_ID; - - // Leading Track - int leading_ID(0); - double pt_max(0); - - // Track Index - int i = -1; + // List of Tracks + std::vector trk; - // Loop over Reconstructed Tracks for (auto track : tracks) { - i++; if (!passedTrackSelectionForJetReconstruction(track)) continue; + registryQC.fill(HIST("dcaxy_vs_pt"), track.pt(), track.dcaXY()); + registryQC.fill(HIST("dcaz_vs_pt"), track.pt(), track.dcaZ()); - if (track.pt() > pt_max) { - leading_ID = i; - pt_max = track.pt(); - } - particle_ID.push_back(i); + TVector3 momentum(track.px(), track.py(), track.pz()); + trk.push_back(momentum); } - // Momentum of the Leading Particle - auto const& leading_track = tracks.iteratorAt(leading_ID); - TVector3 p_leading(leading_track.px(), leading_track.py(), leading_track.pz()); - TVector3 p_jet(leading_track.px(), leading_track.py(), leading_track.pz()); + // Anti-kt Jet Finder + int n_particles_removed(0); + std::vector jet; + std::vector ue1; + std::vector ue2; - // QC: pt, eta, and phi Distributions of Leading Track - registryQC.fill(HIST("ptLeading"), p_leading.Pt()); - registryQC.fill(HIST("etaLeading"), p_leading.Eta()); - registryQC.fill(HIST("phiLeading"), p_leading.Phi()); + 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())); - // Event Counter: Skip Events with pt(jet.size())); - // Labels - int exit(0); - int nPartAssociated(0); - int nParticles = static_cast(particle_ID.size()); + // Jet Selection + std::vector isSelected; + for (int i = 0; i < static_cast(jet.size()); i++) { + isSelected.push_back(0); + } - // Jet Finder - do { - // Initialization - double distance_jet_min(1e+08); - double distance_bkg_min(1e+08); - int label_jet_particle(0); - int i_jet_particle(0); + int n_jets_selected(0); + for (int i = 0; i < static_cast(jet.size()); i++) { - for (int i = 0; i < nParticles; i++) { + if ((TMath::Abs(jet[i].Eta()) + Rjet) > max_eta) + continue; - // Skip Leading Particle & Elements already associated to the Jet - if (particle_ID[i] == leading_ID || particle_ID[i] == -1) - 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); - // Get Particle Momentum - auto stored_track = tracks.iteratorAt(particle_ID[i]); - TVector3 p_particle(stored_track.px(), stored_track.py(), stored_track.pz()); + double nPartJetPlusUE(0); + double nPartJet(0); + double nPartUE(0); + double ptJetPlusUE(0); + double ptJet(0); + double ptUE(0); - // Variables - double one_over_pt2_part = 1.0 / (p_particle.Pt() * p_particle.Pt()); - double one_over_pt2_lead = 1.0 / (p_jet.Pt() * p_jet.Pt()); - double deltaEta = p_particle.Eta() - p_jet.Eta(); - double deltaPhi = GetDeltaPhi(p_particle.Phi(), p_jet.Phi()); - double min = Minimum(one_over_pt2_part, one_over_pt2_lead); - double Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; - - // Distances - double distance_jet = min * Delta2 / (Rjet * Rjet); - double distance_bkg = one_over_pt2_part; - - // Find Minimum Distance Jet - if (distance_jet < distance_jet_min) { - distance_jet_min = distance_jet; - label_jet_particle = particle_ID[i]; - i_jet_particle = i; - } + for (auto track : tracks) { - // Find Minimum Distance Bkg - if (distance_bkg < distance_bkg_min) { - distance_bkg_min = distance_bkg; + 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 + //************************************************************************************************************************************ - if (distance_jet_min <= distance_bkg_min) { + // Leading Track + double pt_max(0); - // Update Momentum of Leading Particle - auto jet_track = tracks.iteratorAt(label_jet_particle); - TVector3 p_i(jet_track.px(), jet_track.py(), jet_track.pz()); - p_jet = p_jet + p_i; + // Loop over Reconstructed Tracks + for (auto const& track : tracks) { - // Remove Element - particle_ID[i_jet_particle] = -1; - nPartAssociated++; - } + if (!passedTrackSelectionForJetReconstruction(track)) + continue; - if (nPartAssociated >= (nParticles - 1)) - exit = 1; - if (distance_jet_min > distance_bkg_min) - exit = 2; + if (track.pt() > pt_max) { + pt_max = track.pt(); + } + } + // Event Counter: Skip Events with pt 5 GeV/c selected - } while (exit == 0); + // Overlaps + int nOverlaps(0); + for (int i = 0; i < static_cast(jet.size()); i++) { + if (isSelected[i] == 0) + continue; - // QA Plots - registryQC.fill(HIST("angle_jet_leading_track"), (180.0 / TMath::Pi()) * p_leading.Angle(p_jet)); + 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); - // Event Counter: Skip Events with jet not fully inside acceptance - if ((TMath::Abs(p_jet.Eta()) + Rmax) > max_eta) + if (n_jets_selected > n_jets_per_event_max) return; registryData.fill(HIST("number_of_events_data"), 4.5); - // Perpendicular Cones for the UE Estimate - TVector3 ue_axis1(0.0, 0.0, 0.0); - TVector3 ue_axis2(0.0, 0.0, 0.0); - get_perpendicular_axis(p_jet, ue_axis1, +1.0); - get_perpendicular_axis(p_jet, ue_axis2, -1.0); - - // Protection against delta<0 - if (ue_axis1.Mag() == 0 || ue_axis2.Mag() == 0) + if (requireNoOverlap && nOverlaps > 0) return; registryData.fill(HIST("number_of_events_data"), 5.5); - // Loop over Reconstructed Tracks - for (auto track : tracks) { + //************************************************************************************************************************************ - if (!passedTrackSelection(track)) - continue; - if (require_PV_contributor && !(track.isPVContributor())) - continue; - if (track.sign() > 0) - 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(); - double y_proton = get_rapidity(track.px(), track.py(), track.pz(), 0.93827208816); - double y_deuteron = get_rapidity(track.px(), track.py(), track.pz(), 1.87561294257); - double y_helium3 = get_rapidity(2.0 * track.px(), 2.0 * track.py(), 2.0 * track.pz(), 2.80839160743); - - TVector3 particle_dir(track.px(), track.py(), track.pz()); - double deltaEta_jet = particle_dir.Eta() - p_jet.Eta(); - double deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), p_jet.Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = particle_dir.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = particle_dir.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - // DCAxy Distributions of Antiprotons - if (isHighPurityAntiproton(track) && TMath::Abs(dcaz) < max_dcaz) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("antiproton_dca_jet"), pt, dcaxy); - } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("antiproton_dca_ue"), pt, dcaxy); - } - } + for (int i = 0; i < static_cast(jet.size()); i++) { - // DCA Cuts - if (TMath::Abs(dcaxy) > max_dcaxy) - continue; - if (TMath::Abs(dcaz) > max_dcaz) + if (isSelected[i] == 0) continue; - // Jet - if (deltaR_jet < Rmax) { + for (auto track : tracks) { + if (!passedTrackSelection(track)) + continue; + if (require_PV_contributor && !(track.isPVContributor())) + continue; - // Antiproton - if (y_proton > min_y && y_proton < max_y) { - if (pt < 1.0) - registryData.fill(HIST("antiproton_jet_tpc"), pt, nsigmaTPCPr); - if (pt >= 0.5 && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antiproton_jet_tof"), pt, nsigmaTOFPr); - } + // 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(); - // Antideuteron - if (y_deuteron > min_y && y_deuteron < max_y) { - if (pt < 1.0) - registryData.fill(HIST("antideuteron_jet_tpc"), pt, nsigmaTPCDe); - if (pt >= 0.5 && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antideuteron_jet_tof"), pt, nsigmaTOFDe); + 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; - // Antihelium3 - if (y_helium3 > min_y && y_helium3 < max_y) { - registryData.fill(HIST("antihelium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); - } - } + // Jet + if (deltaR_jet < Rjet) { - // UE - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { + 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); - // Antiproton - if (y_proton > min_y && y_proton < max_y) { - if (pt < 1.0) - registryData.fill(HIST("antiproton_ue_tpc"), pt, nsigmaTPCPr); - if (pt >= 0.5 && 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_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); - // Antideuteron - if (y_deuteron > min_y && y_deuteron < max_y) { - if (pt < 1.0) - registryData.fill(HIST("antideuteron_ue_tpc"), pt, nsigmaTPCDe); - if (pt >= 0.5 && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF()) - registryData.fill(HIST("antideuteron_ue_tof"), pt, nsigmaTOFDe); - } + // Antihelium3 + registryData.fill(HIST("antihelium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); + } - // Antihelium3 - if (y_helium3 > min_y && y_helium3 < max_y) { - 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_jet_tof"), pt, nsigmaTOFDe); + + // Helium3 + registryData.fill(HIST("helium3_jet_tpc"), 2.0 * pt, nsigmaTPCHe); + } } - } - } - // QC Variables - double Nch_jet(0); - double Nch_ue(0); - double pt_jet(0); - double pt_ue(0); + // UE + if (deltaR_ue1 < Rjet || deltaR_ue2 < Rjet) { - // Loop over Reconstructed Tracks - for (auto track : tracks) { - if (!passedTrackSelectionForJetReconstruction(track)) - continue; + 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); - TVector3 particle_dir(track.px(), track.py(), track.pz()); - double deltaEta_jet = particle_dir.Eta() - p_jet.Eta(); - double deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), p_jet.Phi()); - double deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - double deltaEta_ue1 = particle_dir.Eta() - ue_axis1.Eta(); - double deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue_axis1.Phi()); - double deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - double deltaEta_ue2 = particle_dir.Eta() - ue_axis2.Eta(); - double deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue_axis2.Phi()); - double deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rmax) { - Nch_jet++; - pt_jet = pt_jet + track.pt(); - registryQC.fill(HIST("deltaEtadeltaPhiJet"), deltaEta_jet, deltaPhi_jet); - registryQC.fill(HIST("rJet"), deltaR_jet); - } + // 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); - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - Nch_ue++; - pt_ue = pt_ue + track.pt(); - registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEta_ue1, deltaPhi_ue1); - registryQC.fill(HIST("deltaEtadeltaPhiUE"), deltaEta_ue2, deltaPhi_ue2); - registryQC.fill(HIST("rUE"), deltaR_ue1); - registryQC.fill(HIST("rUE"), deltaR_ue2); + // 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); + } + } } } - registryQC.fill(HIST("multiplicityJetPlusUE"), Nch_jet); - registryQC.fill(HIST("multiplicityJet"), Nch_jet - 0.5 * Nch_ue); - registryQC.fill(HIST("multiplicityUE"), 0.5 * Nch_ue); - registryQC.fill(HIST("ptJetPlusUE"), pt_jet); - registryQC.fill(HIST("ptJet"), pt_jet - 0.5 * pt_ue); - registryQC.fill(HIST("ptUE"), 0.5 * pt_ue); } + PROCESS_SWITCH(nuclei_in_jets, processData, "Process Data", true); Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; Preslice perCollision = o2::aod::track::collisionId; - void processGen(o2::aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) + void processEfficiency(o2::aod::McCollisions const& mcCollisions, SimCollisions const& collisions, MCTracks const& mcTracks, aod::McParticles const& mcParticles) { + // Generated Events for (const auto& mccollision : mcCollisions) { - // Event Counter (before event sel) registryMC.fill(HIST("number_of_events_mc"), 0.5); - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - // Generated Particles for (auto& particle : mcParticles_per_coll) { if (!particle.isPhysicalPrimary()) continue; if ((particle.pdgCode() != -2212) && (particle.pdgCode() != -1000010020) && (particle.pdgCode() != -1000020030)) continue; - if (particle.y() < min_y || particle.y() > max_y) + if (particle.eta() < min_eta || particle.eta() > max_eta) continue; - // Fill Histograms + 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()); - registryMC.fill(HIST("antiproton_ue_gen"), particle.pt()); + 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()); @@ -665,20 +805,17 @@ struct nuclei_in_jets { } } } - } - void processRec(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McCollisions const&, const aod::McParticles&) - { + // Reconstructed Events for (const auto& collision : collisions) { - // Event Counter (before event sel) registryMC.fill(HIST("number_of_events_mc"), 1.5); // Event Selection if (!collision.sel8()) continue; - if (abs(collision.posZ()) > 10) + if (TMath::Abs(collision.posZ()) > 10) continue; // Event Counter (after event sel) @@ -735,25 +872,44 @@ struct nuclei_in_jets { 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 < 1.0 && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC) { - registryMC.fill(HIST("antiproton_jet_rec_tpc"), pt); - registryMC.fill(HIST("antiproton_ue_rec_tpc"), pt); + 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 >= 0.5 && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF() && nsigmaTOFPr > min_nsigmaTOF && nsigmaTOFPr < max_nsigmaTOF) { - registryMC.fill(HIST("antiproton_jet_rec_tof"), pt); - registryMC.fill(HIST("antiproton_ue_rec_tof"), pt); + 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 < 1.0 && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC) { + 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 >= 0.5 && nsigmaTPCDe > min_nsigmaTPC && nsigmaTPCDe < max_nsigmaTPC && track.hasTOF() && nsigmaTOFDe > min_nsigmaTOF && nsigmaTOFDe < max_nsigmaTOF) { + 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); } @@ -769,188 +925,416 @@ struct nuclei_in_jets { } } } + PROCESS_SWITCH(nuclei_in_jets, processEfficiency, "process efficiency", false); - void processSecAntiprotons(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McCollisions const&, const aod::McParticles&) + 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 (abs(collision.posZ()) > 10) + 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()); - // Reduced Event - std::vector particle_ID; - int leading_ID(0); - double pt_max(0); - int i = -1; + // List of Tracks + std::vector trk; - // Loop over Reconstructed Tracks for (auto track : tracks_per_coll) { - // Global Track Index - i++; - - // Track Selection for Jet if (!passedTrackSelectionForJetReconstruction(track)) continue; - // Find pt Leading - if (track.pt() > pt_max) { - leading_ID = i; - pt_max = track.pt(); + 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())); - // Store Array Element - particle_ID.push_back(i); + // Jet Selection + std::vector isSelected; + for (int i = 0; i < static_cast(jet.size()); i++) { + isSelected.push_back(0); } - if (pt_max < min_pt_leading) + 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); - // Number of Stored Particles - int nParticles = static_cast(particle_ID.size()); + for (int i = 0; i < static_cast(jet.size()); i++) { - // Event Counter: Skip Events with 0 Particles - if (nParticles < 1) + 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); - // Momentum of the Leading Particle - auto const& leading_track = tracks_per_coll.iteratorAt(leading_ID); - TVector3 p_leading(leading_track.px(), leading_track.py(), leading_track.pz()); + // MC Particles per Collision + auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - // Labels - Int_t exit(0); - Int_t nPartAssociated(0); + // List of Tracks + std::vector trk; - // Jet Finder - do { - // Initialization - double distance_jet_min(1e+08); - double distance_bkg_min(1e+08); - int label_jet_particle(0); - int i_jet_particle(0); + for (auto& particle : mcParticles_per_coll) { + if (particle.isPhysicalPrimary() && particle.pdgCode() == -2212) { + registryMC.fill(HIST("antiproton_eta_pt_pythia"), particle.pt(), particle.eta()); + } - for (int i = 0; i < nParticles; i++) { + // 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); - // Skip Leading Particle & Elements already associated to the Jet - if (particle_ID[i] == leading_ID || particle_ID[i] == -1) + 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; + } - // Get Particle Momentum - auto stored_track = tracks_per_coll.iteratorAt(particle_ID[i]); - TVector3 p_particle(stored_track.px(), stored_track.py(), stored_track.pz()); + if (TMath::Abs(particle.eta()) > 0.8) + continue; + if (particle.pt() < 0.15) + continue; - // Variables - double one_over_pt2_part = 1.0 / (p_particle.Pt() * p_particle.Pt()); - double one_over_pt2_lead = 1.0 / (p_leading.Pt() * p_leading.Pt()); - double deltaEta = p_particle.Eta() - p_leading.Eta(); - double deltaPhi = GetDeltaPhi(p_particle.Phi(), p_leading.Phi()); - double min = Minimum(one_over_pt2_part, one_over_pt2_lead); - double Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; + // PDG Selection + int pdg = TMath::Abs(particle.pdgCode()); + if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) + continue; - // Distances - double distance_jet = min * Delta2 / (Rjet * Rjet); - double distance_bkg = one_over_pt2_part; + TVector3 momentum(particle.px(), particle.py(), particle.pz()); + trk.push_back(momentum); + } - // Find Minimum Distance Jet - if (distance_jet < distance_jet_min) { - distance_jet_min = distance_jet; - label_jet_particle = particle_ID[i]; - i_jet_particle = i; - } + // Anti-kt Jet Finder + int n_particles_removed(0); + std::vector jet; + std::vector ue1; + std::vector ue2; - // Find Minimum Distance Bkg - if (distance_bkg < distance_bkg_min) { - distance_bkg_min = distance_bkg; + 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())); - if (distance_jet_min <= distance_bkg_min) { + // Jet Selection + std::vector isSelected; + for (int i = 0; i < static_cast(jet.size()); i++) { + isSelected.push_back(0); + } - // Update Momentum of Leading Particle - auto jet_track = tracks_per_coll.iteratorAt(label_jet_particle); - TVector3 p_i(jet_track.px(), jet_track.py(), jet_track.pz()); - p_leading = p_leading + p_i; + int n_jets_selected(0); + for (int i = 0; i < static_cast(jet.size()); i++) { - // Remove Element - particle_ID[i_jet_particle] = -1; - nPartAssociated++; - } + if ((TMath::Abs(jet[i].Eta()) + Rjet) > max_eta) + continue; - if (nPartAssociated >= (nParticles - 1)) - exit = 1; - if (distance_jet_min > distance_bkg_min) - exit = 2; + // 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; + } - } while (exit == 0); + if (TMath::Abs(particle.eta()) > 0.8) + continue; + if (particle.pt() < 0.15) + continue; - if ((TMath::Abs(p_leading.Eta()) + Rmax) > max_eta) - continue; - TVector3 jet_axis(p_leading.X(), p_leading.Y(), p_leading.Z()); + // PDG Selection + int pdg = TMath::Abs(particle.pdgCode()); + if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) + continue; - // Perpendicular Cones for UE Estimate - TVector3 ue_axis1(0.0, 0.0, 0.0); - TVector3 ue_axis2(0.0, 0.0, 0.0); - get_perpendicular_axis(jet_axis, ue_axis1, +1.0); - get_perpendicular_axis(jet_axis, ue_axis2, -1.0); + 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; - // Protection against delta<0 - if (ue_axis1.X() == 0 && ue_axis1.Y() == 0 && ue_axis1.Z() == 0) - continue; - if (ue_axis2.X() == 0 && ue_axis2.Y() == 0 && ue_axis2.Z() == 0) + if (ptJet < min_jet_pt) + continue; + if (nPartJetPlusUE < min_nPartInJet) + continue; + n_jets_selected++; + isSelected[i] = 1; + } + if (n_jets_selected == 0) continue; - for (auto track : tracks_per_coll) { + for (int i = 0; i < static_cast(jet.size()); i++) { - if (!passedTrackSelection(track)) - continue; - if (require_PV_contributor && !(track.isPVContributor())) - continue; - if (TMath::Abs(track.dcaXY()) > max_dcaxy) - continue; - if (TMath::Abs(track.dcaZ()) > max_dcaz) + if (isSelected[i] == 0) continue; - // Get MC Particle - if (!track.has_mcParticle()) - continue; - const auto particle = track.mcParticle(); - if (particle.pdgCode() != -2212) - continue; + // Generated Particles + for (auto& particle : mcParticles_per_coll) { - TVector3 particle_dir(track.px(), track.py(), track.pz()); - float deltaEta_jet = particle_dir.Eta() - jet_axis.Eta(); - float deltaPhi_jet = GetDeltaPhi(particle_dir.Phi(), jet_axis.Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = particle_dir.Eta() - ue_axis1.Eta(); - float deltaPhi_ue1 = GetDeltaPhi(particle_dir.Phi(), ue_axis1.Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = particle_dir.Eta() - ue_axis2.Eta(); - float deltaPhi_ue2 = GetDeltaPhi(particle_dir.Phi(), ue_axis2.Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - if (deltaR_jet < Rmax) { - registryMC.fill(HIST("antiproton_all_jet"), track.pt()); - if (particle.isPhysicalPrimary()) - registryMC.fill(HIST("antiproton_prim_jet"), track.pt()); - } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryMC.fill(HIST("antiproton_all_ue"), track.pt()); - if (particle.isPhysicalPrimary()) - registryMC.fill(HIST("antiproton_prim_ue"), track.pt()); + 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, processSecAntiprotons, "Process sec antip", false); - PROCESS_SWITCH(nuclei_in_jets, processData, "Process Data", true); - PROCESS_SWITCH(nuclei_in_jets, processGen, "process Gen MC", false); - PROCESS_SWITCH(nuclei_in_jets, processRec, "process Rec MC", false); + PROCESS_SWITCH(nuclei_in_jets, processAntiprotonReweighting, "Process antiproton reweighting", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Nuspex/nuclei_in_toward_transv_regions.cxx b/PWGLF/Tasks/Nuspex/nuclei_in_toward_transv_regions.cxx new file mode 100644 index 00000000000..a64ba6dc09c --- /dev/null +++ b/PWGLF/Tasks/Nuspex/nuclei_in_toward_transv_regions.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. +/// +/// \author Alberto Caliva (alberto.caliva@cern.ch) +/// \since August 22, 2024 + +#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/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::framework; +using namespace o2::framework::expressions; +using namespace o2::constants::physics; +using std::array; + +using SelectedCollisions = soa::Join; +using SimCollisions = soa::Join; + +using FullTracks = soa::Join; + +using MCTracks = soa::Join; + +struct nuclei_in_toward_transv_regions { + + // Analysis Histograms: Data + HistogramRegistry registryData{ + "registryData", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + + // Analysis Histograms: MC + HistogramRegistry registryMC{ + "registryMC", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + + // Global Parameters + Configurable min_pt_leading{"min_pt_leading", 5.0, "Minimum pt of leading particle"}; + Configurable zVtx{"zVtx", 10.0, "Maximum zVertex"}; + + // Track Parameters + 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 min_y{"min_y", -0.5, "minimum y"}; + Configurable max_y{"max_y", +0.5, "maximum y"}; + Configurable max_dcaxy{"max_dcaxy", 0.1, "Maximum DCAxy"}; + Configurable max_dcaz{"max_dcaz", 0.1, "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 require_PV_contributor{"require_PV_contributor", true, "require that the track is a PV contributor"}; + + void init(InitContext const&) + { + // 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"}}); + + // Data + registryData.add("antiproton_jet_tpc", "antiproton_jet_tpc", HistType::kTH2F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antiproton_jet_tof", "antiproton_jet_tof", HistType::kTH2F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + registryData.add("antiproton_ue_tpc", "antiproton_ue_tpc", HistType::kTH2F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TPC}"}}); + registryData.add("antiproton_ue_tof", "antiproton_ue_tof", HistType::kTH2F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}, {400, -20.0, 20.0, "n#sigma_{TOF}"}}); + + // MC + registryMC.add("antiproton_prim_jet", "antiproton_prim_jet", HistType::kTH1F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_all_jet", "antiproton_all_jet", HistType::kTH1F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_prim_ue", "antiproton_prim_ue", HistType::kTH1F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}}); + registryMC.add("antiproton_all_ue", "antiproton_all_ue", HistType::kTH1F, {{120, 0.0, 6.0, "#it{p}_{T} (GeV/#it{c})"}}); + } + + // Single-Track Selection for Particles inside Jets + template + bool passedTrackSelectionForJetReconstruction(const JetTrackType& 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.1) + return false; + if (TMath::Abs(track.dcaXY()) > (0.004f + 0.013f / track.pt())) + return false; + if (TMath::Abs(track.dcaZ()) > 2.0) + return false; + + return true; + } + + // Single-Track Selection + template + bool passedTrackSelection(const TrackType& 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; + } + + // Rapidity + double get_rapidity(double px, double py, double pz, double mass) + { + double rap(0); + TLorentzVector lorentzVect; + lorentzVect.SetXYZM(px, py, pz, mass); + rap = lorentzVect.Rapidity(); + return rap; + } + + template + bool isTrackInTowardRegion(const T1& track, const T2& leading_track) + { + // Initialization + bool isInTowardRegion = false; + + // DeltaPhi + double phi_ref = TVector2::Phi_0_2pi(leading_track.phi()); + double phi_trk = TVector2::Phi_0_2pi(track.phi()); + double delta_phi = (180.0 / TMath::Pi()) * TVector2::Phi_0_2pi(phi_trk - phi_ref); + if (delta_phi >= 0.0 && delta_phi < 60.0) + isInTowardRegion = true; + if (delta_phi >= 300.0 && delta_phi <= 360.0) + isInTowardRegion = true; + + return isInTowardRegion; + } + + template + bool isTrackInTransverseRegion(const T3& track, const T4& leading_track) + { + // Initialization + bool isInTransverseRegion = false; + + // DeltaPhi + double phi_ref = TVector2::Phi_0_2pi(leading_track.phi()); + double phi_trk = TVector2::Phi_0_2pi(track.phi()); + double delta_phi = (180.0 / TMath::Pi()) * TVector2::Phi_0_2pi(phi_trk - phi_ref); + if (delta_phi >= 60.0 && delta_phi < 120.0) + isInTransverseRegion = true; + if (delta_phi >= 240.0 && delta_phi < 300.0) + isInTransverseRegion = true; + + return isInTransverseRegion; + } + + // Process Data + void processData(SelectedCollisions::iterator const& collision, FullTracks 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 (abs(collision.posZ()) > zVtx) + return; + + // Event Counter: after z-vertex cut + registryData.fill(HIST("number_of_events_data"), 2.5); + + // Leading Track + int leading_ID(0); + double pt_max(0); + + // Track Index + int i = -1; + + // Loop over Reconstructed Tracks + for (auto track : tracks) { + + i++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + if (track.pt() > pt_max) { + leading_ID = i; + pt_max = track.pt(); + } + } + // Event Counter: Skip Events with pt 0) + continue; + if (TMath::Abs(track.dcaXY()) > max_dcaxy) + continue; + if (TMath::Abs(track.dcaZ()) > max_dcaz) + continue; + + // Variables + double nsigmaTPCPr = track.tpcNSigmaPr(); + double nsigmaTOFPr = track.tofNSigmaPr(); + double y_proton = get_rapidity(track.px(), track.py(), track.pz(), 0.93827208816); + if (y_proton < min_y || y_proton > max_y) + continue; + + // Jet + if (isTrackInTowardRegion(track, leading_track)) { + if (track.pt() < 1.0) + registryData.fill(HIST("antiproton_jet_tpc"), track.pt(), nsigmaTPCPr); + if (track.pt() >= 0.5 && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF()) + registryData.fill(HIST("antiproton_jet_tof"), track.pt(), nsigmaTOFPr); + } + + // UE + if (isTrackInTransverseRegion(track, leading_track)) { + if (track.pt() < 1.0) + registryData.fill(HIST("antiproton_ue_tpc"), track.pt(), nsigmaTPCPr); + if (track.pt() >= 0.5 && nsigmaTPCPr > min_nsigmaTPC && nsigmaTPCPr < max_nsigmaTPC && track.hasTOF()) + registryData.fill(HIST("antiproton_ue_tof"), track.pt(), nsigmaTOFPr); + } + } + } + + Preslice perCollision = o2::aod::track::collisionId; + + void processSecAntiprotons(SimCollisions const& collisions, MCTracks const& mcTracks, aod::McCollisions const&, const aod::McParticles&) + { + for (const auto& collision : collisions) { + + registryMC.fill(HIST("number_of_events_mc"), 0.5); + + // Event Selection + if (!collision.sel8()) + continue; + registryMC.fill(HIST("number_of_events_mc"), 1.5); + + if (abs(collision.posZ()) > zVtx) + continue; + registryMC.fill(HIST("number_of_events_mc"), 2.5); + + auto tracks_per_coll = mcTracks.sliceBy(perCollision, collision.globalIndex()); + + int leading_ID(0); + double pt_max(0); + int i = -1; + + // Loop over Reconstructed Tracks + for (auto track : tracks_per_coll) { + + i++; + if (!passedTrackSelectionForJetReconstruction(track)) + continue; + + if (track.pt() > pt_max) { + leading_ID = i; + pt_max = track.pt(); + } + } + if (pt_max < min_pt_leading) + continue; + registryMC.fill(HIST("number_of_events_mc"), 3.5); + + // Momentum of the Leading Particle + auto const& leading_track = tracks_per_coll.iteratorAt(leading_ID); + + // Loop over Reconstructed Tracks + 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; + double y_proton = get_rapidity(track.px(), track.py(), track.pz(), 0.93827208816); + if (y_proton < min_y || y_proton > max_y) + continue; + + // Get MC Particle + if (!track.has_mcParticle()) + continue; + const auto particle = track.mcParticle(); + if (particle.pdgCode() != -2212) + continue; + + // Jet + if (isTrackInTowardRegion(track, leading_track)) { + registryMC.fill(HIST("antiproton_all_jet"), track.pt()); + if (particle.isPhysicalPrimary()) { + registryMC.fill(HIST("antiproton_prim_jet"), track.pt()); + } + } + // UE + if (isTrackInTransverseRegion(track, leading_track)) { + registryMC.fill(HIST("antiproton_all_ue"), track.pt()); + if (particle.isPhysicalPrimary()) { + registryMC.fill(HIST("antiproton_prim_ue"), track.pt()); + } + } + } + } + } + PROCESS_SWITCH(nuclei_in_toward_transv_regions, processData, "Process Data", true); + PROCESS_SWITCH(nuclei_in_toward_transv_regions, processSecAntiprotons, "Process sec antip", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Nuspex/spectraTOF.cxx b/PWGLF/Tasks/Nuspex/spectraTOF.cxx index afeb2da7758..a16e466f884 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOF.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOF.cxx @@ -18,6 +18,7 @@ /// // O2 includes +#include #include "ReconstructionDataFormats/Track.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -36,9 +37,8 @@ #include "Framework/O2DatabasePDGPlugin.h" #include "PWGLF/Utils/inelGt.h" #include "PWGLF/DataModel/mcCentrality.h" - +#include "Common/Core/RecoDecay.h" #include "TPDGCode.h" - using namespace o2; using namespace o2::track; using namespace o2::framework; @@ -52,6 +52,21 @@ std::array, NpCharge> hDcaXYZMat; std::array, NpCharge> hDcaXYWrongCollisionPrm; std::array, NpCharge> hDcaXYWrongCollisionStr; std::array, NpCharge> hDcaXYWrongCollisionMat; +std::array, NpCharge> hDcaXYMC; // DCA xy in the MC +std::array, NpCharge> hDcaZMC; // DCA z in the MC +std::array, NpCharge> hDcaXYMCD0; // DCA xy in the MC for particles from D0 +std::array, NpCharge> hDcaZMCD0; // DCA z in the MC for particles from D0 +std::array, NpCharge> hDcaXYMCCharm; // DCA xy in the MC for particles from charm +std::array, NpCharge> hdcaZMCCharm; // DCA z in the MC for particles from charm +std::array, NpCharge> hDcaXYMCBeauty; // DCA xy in the MC for particles from beauty +std::array, NpCharge> hDcaZMCBeauty; // DCA z in the MC for particles from beauty +std::array, NpCharge> hDcaXYMCNotHF; // DCA xy in the MC for particles from not a HF +std::array, NpCharge> hDcaZMCNotHF; // DCA z in the MC for particles from not a HF +std::array, NpCharge> hDecayLengthStr; // Decay Length for particles from Strange +std::array, NpCharge> hDecayLengthMCD0; // Decay Length in the MC for particles from D0 +std::array, NpCharge> hDecayLengthMCCharm; // Decay Length in the MC for particles from charm +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 // Spectra task struct tofSpectra { @@ -83,6 +98,7 @@ struct tofSpectra { Configurable enableTPCTOFHistograms{"enableTPCTOFHistograms", true, "Enables TPC TOF histograms"}; Configurable enableDCAxyzHistograms{"enableDCAxyzHistograms", false, "Enables DCAxyz correlation histograms"}; Configurable enableDCAxyphiHistograms{"enableDCAxyphiHistograms", false, "Enables DCAxyphi correlation histograms"}; + Configurable enableDCAvsmotherHistograms{"enableDCAvsmotherHistograms", false, "Enables DCA vs mother histograms"}; struct : ConfigurableGroup { 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.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.6, 4.8, 5.0}, "Binning of the pT axis"}; @@ -93,6 +109,7 @@ struct tofSpectra { ConfigurableAxis binsdeltaTOF{"binsdeltaTOF", {500, -1000, 1000}, "Binning of the nsigmaTOF axis"}; ConfigurableAxis binsDca{"binsDca", {VARIABLE_WIDTH, -3.0, -2.95, -2.9, -2.85, -2.8, -2.75, -2.7, -2.65, -2.6, -2.55, -2.5, -2.45, -2.4, -2.35, -2.3, -2.25, -2.2, -2.15, -2.1, -2.05, -2.0, -1.975, -1.95, -1.925, -1.9, -1.875, -1.85, -1.825, -1.8, -1.775, -1.75, -1.725, -1.7, -1.675, -1.65, -1.625, -1.6, -1.575, -1.55, -1.525, -1.5, -1.475, -1.45, -1.425, -1.4, -1.375, -1.35, -1.325, -1.3, -1.275, -1.25, -1.225, -1.2, -1.175, -1.15, -1.125, -1.1, -1.075, -1.05, -1.025, -1.0, -0.99, -0.98, -0.97, -0.96, -0.95, -0.94, -0.93, -0.92, -0.91, -0.9, -0.89, -0.88, -0.87, -0.86, -0.85, -0.84, -0.83, -0.82, -0.81, -0.8, -0.79, -0.78, -0.77, -0.76, -0.75, -0.74, -0.73, -0.72, -0.71, -0.7, -0.69, -0.68, -0.67, -0.66, -0.65, -0.64, -0.63, -0.62, -0.61, -0.6, -0.59, -0.58, -0.57, -0.56, -0.55, -0.54, -0.53, -0.52, -0.51, -0.5, -0.49, -0.48, -0.47, -0.46, -0.45, -0.44, -0.43, -0.42, -0.41, -0.4, -0.396, -0.392, -0.388, -0.384, -0.38, -0.376, -0.372, -0.368, -0.364, -0.36, -0.356, -0.352, -0.348, -0.344, -0.34, -0.336, -0.332, -0.328, -0.324, -0.32, -0.316, -0.312, -0.308, -0.304, -0.3, -0.296, -0.292, -0.288, -0.284, -0.28, -0.276, -0.272, -0.268, -0.264, -0.26, -0.256, -0.252, -0.248, -0.244, -0.24, -0.236, -0.232, -0.228, -0.224, -0.22, -0.216, -0.212, -0.208, -0.204, -0.2, -0.198, -0.196, -0.194, -0.192, -0.19, -0.188, -0.186, -0.184, -0.182, -0.18, -0.178, -0.176, -0.174, -0.172, -0.17, -0.168, -0.166, -0.164, -0.162, -0.16, -0.158, -0.156, -0.154, -0.152, -0.15, -0.148, -0.146, -0.144, -0.142, -0.14, -0.138, -0.136, -0.134, -0.132, -0.13, -0.128, -0.126, -0.124, -0.122, -0.12, -0.118, -0.116, -0.114, -0.112, -0.11, -0.108, -0.106, -0.104, -0.102, -0.1, -0.099, -0.098, -0.097, -0.096, -0.095, -0.094, -0.093, -0.092, -0.091, -0.09, -0.089, -0.088, -0.087, -0.086, -0.085, -0.084, -0.083, -0.082, -0.081, -0.08, -0.079, -0.078, -0.077, -0.076, -0.075, -0.074, -0.073, -0.072, -0.071, -0.07, -0.069, -0.068, -0.067, -0.066, -0.065, -0.064, -0.063, -0.062, -0.061, -0.06, -0.059, -0.058, -0.057, -0.056, -0.055, -0.054, -0.053, -0.052, -0.051, -0.05, -0.049, -0.048, -0.047, -0.046, -0.045, -0.044, -0.043, -0.042, -0.041, -0.04, -0.039, -0.038, -0.037, -0.036, -0.035, -0.034, -0.033, -0.032, -0.031, -0.03, -0.029, -0.028, -0.027, -0.026, -0.025, -0.024, -0.023, -0.022, -0.021, -0.02, -0.019, -0.018, -0.017, -0.016, -0.015, -0.014, -0.013, -0.012, -0.011, -0.01, -0.009, -0.008, -0.007, -0.006, -0.005, -0.004, -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.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.102, 0.104, 0.106, 0.108, 0.11, 0.112, 0.114, 0.116, 0.118, 0.12, 0.122, 0.124, 0.126, 0.128, 0.13, 0.132, 0.134, 0.136, 0.138, 0.14, 0.142, 0.144, 0.146, 0.148, 0.15, 0.152, 0.154, 0.156, 0.158, 0.16, 0.162, 0.164, 0.166, 0.168, 0.17, 0.172, 0.174, 0.176, 0.178, 0.18, 0.182, 0.184, 0.186, 0.188, 0.19, 0.192, 0.194, 0.196, 0.198, 0.2, 0.204, 0.208, 0.212, 0.216, 0.22, 0.224, 0.228, 0.232, 0.236, 0.24, 0.244, 0.248, 0.252, 0.256, 0.26, 0.264, 0.268, 0.272, 0.276, 0.28, 0.284, 0.288, 0.292, 0.296, 0.3, 0.304, 0.308, 0.312, 0.316, 0.32, 0.324, 0.328, 0.332, 0.336, 0.34, 0.344, 0.348, 0.352, 0.356, 0.36, 0.364, 0.368, 0.372, 0.376, 0.38, 0.384, 0.388, 0.392, 0.396, 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.025, 1.05, 1.075, 1.1, 1.125, 1.15, 1.175, 1.2, 1.225, 1.25, 1.275, 1.3, 1.325, 1.35, 1.375, 1.4, 1.425, 1.45, 1.475, 1.5, 1.525, 1.55, 1.575, 1.6, 1.625, 1.65, 1.675, 1.7, 1.725, 1.75, 1.775, 1.8, 1.825, 1.85, 1.875, 1.9, 1.925, 1.95, 1.975, 2.0, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3.0}, "Binning of DCA xy and z axis"}; ConfigurableAxis binsMultiplicity{"binsMultiplicity", {100, 0, 100}, "Binning for multiplicity"}; + ConfigurableAxis binsOccupancy{"binsOccupancy", {3000, 0, 15000}, "Binning for occupancy"}; ConfigurableAxis binsPercentile{"binsPercentile", {100, 0, 100}, "Binning for percentiles"}; ConfigurableAxis binsImpactParam{"binsImpactParam", {2500, 0, 25}, "Binning for impact parameter"}; } binsOptions; @@ -110,6 +127,7 @@ struct tofSpectra { 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 minChi2PerClusterTPC{"minChi2PerClusterTPC", 0.5f, "Additional cut on the minimum 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 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"}; @@ -118,6 +136,7 @@ struct tofSpectra { Configurable enableTPCTOFvsEtaHistograms{"enableTPCTOFvsEtaHistograms", false, "choose if produce TPC tof vs Eta"}; Configurable includeCentralityMC{"includeCentralityMC", true, "choose if include Centrality to MC"}; Configurable enableTPCTOFVsMult{"enableTPCTOFVsMult", false, "Produce TPC-TOF plots vs multiplicity"}; + Configurable includeCentralityToTracks{"includeCentralityToTracks", false, "choose if include Centrality to tracks"}; // Histograms HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -191,6 +210,7 @@ struct tofSpectra { LOG(info) << "\trequireTPC=" << requireTPC.value; LOG(info) << "\trequireGoldenChi2=" << requireGoldenChi2.value; LOG(info) << "\tmaxChi2PerClusterTPC=" << maxChi2PerClusterTPC.value; + LOG(info) << "\tminChi2PerClusterTPC=" << minChi2PerClusterTPC.value; LOG(info) << "\tminNCrossedRowsTPC=" << minNCrossedRowsTPC.value; LOG(info) << "\tminTPCNClsFound=" << minTPCNClsFound.value; LOG(info) << "\tmaxChi2PerClusterITS=" << maxChi2PerClusterITS.value; @@ -217,7 +237,7 @@ struct tofSpectra { const AxisSpec ptAxis{binsOptions.binsPt, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec etaAxis{binsOptions.binsEta, "#eta"}; const AxisSpec impParamAxis{binsOptions.binsImpactParam, "Impact parameter"}; - + const AxisSpec occupancyAxis{binsOptions.binsOccupancy, "Occupancy Axis"}; AxisSpec multAxis{binsOptions.binsMultiplicity, "Undefined multiplicity estimator"}; switch (multiplicityEstimator) { case MultCodes::kNoMultiplicity: // No multiplicity @@ -320,6 +340,7 @@ struct tofSpectra { const AxisSpec phiAxis{200, 0, 7, "#it{#varphi} (rad)"}; const AxisSpec dcaZAxis{binsOptions.binsDca, "DCA_{z} (cm)"}; const AxisSpec lengthAxis{100, 0, 600, "Track length (cm)"}; + const AxisSpec decayLengthAxis{100, 0, 0.1, "Decay Length (cm)"}; if (enableTrackCutHistograms) { const AxisSpec chargeAxis{2, -2.f, 2.f, "Charge"}; @@ -400,6 +421,33 @@ struct tofSpectra { histos.add("Data/pos/pt/tpc", "pos TPC", kTH1D, {ptAxis}); histos.add("Data/neg/pt/tpc", "neg TPC", kTH1D, {ptAxis}); + if (includeCentralityToTracks) { + histos.add("Data/cent/pos/pt/its_tpc_tof", "pos ITS-TPC-TOF", kTH3D, {ptAxis, multAxis, occupancyAxis}); + histos.add("Data/cent/neg/pt/its_tpc_tof", "neg ITS-TPC-TOF", kTH3D, {ptAxis, multAxis, occupancyAxis}); + histos.add("Data/cent/pos/pt/its_tpc", "pos ITS-TPC", kTH3D, {ptAxis, multAxis, occupancyAxis}); + histos.add("Data/cent/neg/pt/its_tpc", "neg ITS-TPC", kTH3D, {ptAxis, multAxis, occupancyAxis}); + 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}); + } + + 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}); + histos.add("nsigmatpc/test_occupancy/pos/ka", "occuppancy dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatpc/test_occupancy/neg/ka", "occuppancy dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatpc/test_occupancy/pos/pr", "occuppancy dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatpc/test_occupancy/neg/pr", "occuppancy dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + + histos.add("nsigmatof/test_occupancy/pos/pi", "occuppancy dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatof/test_occupancy/neg/pi", "occuppancy dependent pion", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatof/test_occupancy/pos/ka", "occuppancy dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatof/test_occupancy/neg/ka", "occuppancy dependent kaon", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatof/test_occupancy/pos/pr", "occuppancy dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + histos.add("nsigmatof/test_occupancy/neg/pr", "occuppancy dependent proton", kTHnSparseD, {ptAxis, nsigmaTPCAxisOccupancy, multAxis, occupancyAxis}); + } + if (doprocessMC) { histos.add("MC/fake/pos", "Fake positive tracks", kTH1D, {ptAxis}); histos.add("MC/fake/neg", "Fake negative tracks", kTH1D, {ptAxis}); @@ -592,28 +640,46 @@ struct tofSpectra { } 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(Form("dcaprm/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); - hDcaXYZStr[i] = histos.add(Form("dcastr/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); - hDcaXYZMat[i] = histos.add(Form("dcamat/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); + hDcaXYZPrm[i] = histos.add("dcaprm" + cpName, pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); + hDcaXYZStr[i] = histos.add("dcastr" + cpName, pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); + hDcaXYZMat[i] = histos.add("dcamat" + cpName, pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); if (enableDcaGoodEvents) { histos.add(hdcaxyprmgoodevs[i].data(), pTCharge[i], kTH3D, {ptAxis, dcaXyAxis, dcaZAxis}); } } else { - hDcaXYWrongCollisionPrm[i] = histos.add(Form("dcaxywrongcollprm/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); - hDcaXYWrongCollisionStr[i] = histos.add(Form("dcaxywrongcollstr/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); - hDcaXYWrongCollisionMat[i] = histos.add(Form("dcaxywrongcollmat/%s/%s", (i < Np) ? "pos" : "neg", pN[i % Np]), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaXYWrongCollisionPrm[i] = histos.add("dcaxywrongcollprm" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaXYWrongCollisionStr[i] = histos.add("dcaxywrongcollstr" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaXYWrongCollisionMat[i] = histos.add("dcaxywrongcollmat" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + histos.add(hdcaxyprm[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); histos.add(hdcazprm[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); histos.add(hdcaxystr[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); histos.add(hdcazstr[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); histos.add(hdcaxymat[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); histos.add(hdcazmat[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDecayLengthStr[i] = histos.add("decaylengthstr" + cpName, pTCharge[i], kTH2D, {ptAxis, decayLengthAxis}); if (enableDcaGoodEvents) { histos.add(hdcaxyprmgoodevs[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); histos.add(hdcazprmgoodevs[i].data(), pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); } + if (enableDCAvsmotherHistograms) { + hDcaXYMC[i] = histos.add("dcaxymc" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaZMC[i] = histos.add("dcazmc" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDcaXYMCNotHF[i] = histos.add("dcaxynothf" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaZMCNotHF[i] = histos.add("dcaznothf" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDcaXYMCD0[i] = histos.add("dcaxyD0" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaZMCD0[i] = histos.add("dcazD0" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDcaXYMCCharm[i] = histos.add("dcaxycharm" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hdcaZMCCharm[i] = histos.add("dcazcharm" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDcaXYMCBeauty[i] = histos.add("dcaxybeauty" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaXyAxis}); + hDcaZMCBeauty[i] = histos.add("dcazbeauty" + cpName, pTCharge[i], kTH2D, {ptAxis, dcaZAxis}); + hDecayLengthMCD0[i] = histos.add("decaylengthD0" + cpName, pTCharge[i], kTH2D, {ptAxis, decayLengthAxis}); + hDecayLengthMCCharm[i] = histos.add("decaylengthcharm" + cpName, pTCharge[i], kTH2D, {ptAxis, decayLengthAxis}); + hDecayLengthMCBeauty[i] = histos.add("decaylengthbeauty" + cpName, pTCharge[i], kTH2D, {ptAxis, decayLengthAxis}); + hDecayLengthMCNotHF[i] = histos.add("decaylengthnothf" + cpName, pTCharge[i], kTH2D, {ptAxis, decayLengthAxis}); + } } // Mismatched info @@ -657,7 +723,7 @@ struct tofSpectra { template void fillParticleHistos(const T& track, const C& collision) { - if (abs(track.rapidity(PID::getMass(id))) > trkselOptions.cfgCutY) { + if (std::abs(track.rapidity(PID::getMass(id))) > trkselOptions.cfgCutY) { return; } if constexpr (id == PID::Kaon) { @@ -982,7 +1048,7 @@ struct tofSpectra { histos.fill(HIST("evsel"), 12.f); } } - if (abs(collision.posZ()) > evselOptions.cfgCutVertex) { + if (std::abs(collision.posZ()) > evselOptions.cfgCutVertex) { return false; } if constexpr (fillHistograms) { @@ -1032,7 +1098,7 @@ struct tofSpectra { return false; } } - return (abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); + return (std::abs(track.dcaXY()) <= (maxDcaXYFactor.value * (0.0105f + 0.0350f / pow(track.pt(), 1.1f)))); } return track.isGlobalTrack(); } @@ -1057,8 +1123,8 @@ struct tofSpectra { return track.isGlobalTrackWoDCA(); } - template - bool isTrackSelected(TrackType const& track) + template + bool isTrackSelected(TrackType const& track, CollisionType const& collision) { if constexpr (fillHistograms) { histos.fill(HIST("tracksel"), 1); @@ -1110,6 +1176,10 @@ struct tofSpectra { } } + if (track.tpcChi2NCl() < minChi2PerClusterTPC || track.tpcChi2NCl() > maxChi2PerClusterTPC) { + return false; + } + if (!passesCutWoDCA(track)) { return false; } @@ -1254,10 +1324,75 @@ struct tofSpectra { return false; } - using CollisionCandidates = soa::Join; + using CollisionCandidates = soa::Join; using TrackCandidates = soa::Join; + void processOccupancy(CollisionCandidates::iterator const& collision, + soa::Join const& tracks) + { + if (!isEventSelected(collision)) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + const float multiplicity = collision.centFT0C(); + histos.fill(HIST("nsigmatpc/test_occupancy/Mult_vs_Occupancy"), multiplicity, occupancy); + for (const auto& track : tracks) { + if (!isTrackSelected(track, collision)) { + continue; + } + if (includeCentralityToTracks) { + + if (track.sign() > 0) { + if (track.hasITS() && track.hasTPC() && track.hasTOF()) { + histos.fill(HIST("Data/cent/pos/pt/its_tpc_tof"), track.pt(), collision.centFT0C(), occupancy); + } + if (track.hasITS() && track.hasTOF()) { + histos.fill(HIST("Data/cent/pos/pt/its_tof"), track.pt(), collision.centFT0C(), occupancy); + } + if (track.hasITS() && track.hasTPC()) { + histos.fill(HIST("Data/cent/pos/pt/its_tpc"), track.pt(), collision.centFT0C(), occupancy); + } + } else { + if (track.hasITS() && track.hasTPC() && track.hasTOF()) { + histos.fill(HIST("Data/cent/neg/pt/its_tpc_tof"), track.pt(), collision.centFT0C(), occupancy); + } + if (track.hasITS() && track.hasTPC()) { + histos.fill(HIST("Data/cent/neg/pt/its_tpc"), track.pt(), collision.centFT0C(), occupancy); + } + if (track.hasITS() && track.hasTOF()) { + histos.fill(HIST("Data/cent/neg/pt/its_tof"), track.pt(), collision.centFT0C(), occupancy); + } + } + } + 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); + 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); + histos.fill(HIST("nsigmatpc/test_occupancy/pos/pi"), track.pt(), nsigmaTPCPi, multiplicity, occupancy); + histos.fill(HIST("nsigmatpc/test_occupancy/neg/pi"), track.pt(), nsigmaTPCPi, multiplicity, occupancy); + histos.fill(HIST("nsigmatpc/test_occupancy/pos/ka"), track.pt(), nsigmaTPCKa, multiplicity, occupancy); + histos.fill(HIST("nsigmatpc/test_occupancy/neg/ka"), track.pt(), nsigmaTPCKa, multiplicity, occupancy); + histos.fill(HIST("nsigmatpc/test_occupancy/pos/pr"), track.pt(), nsigmaTPCPr, multiplicity, occupancy); + histos.fill(HIST("nsigmatpc/test_occupancy/neg/pr"), track.pt(), nsigmaTPCPr, multiplicity, occupancy); + + histos.fill(HIST("nsigmatof/test_occupancy/pos/pi"), track.pt(), nsigmaTOFPi, multiplicity, occupancy); + histos.fill(HIST("nsigmatof/test_occupancy/neg/pi"), track.pt(), nsigmaTOFPi, multiplicity, occupancy); + histos.fill(HIST("nsigmatof/test_occupancy/pos/ka"), track.pt(), nsigmaTOFKa, multiplicity, occupancy); + histos.fill(HIST("nsigmatof/test_occupancy/neg/ka"), track.pt(), nsigmaTOFKa, multiplicity, occupancy); + histos.fill(HIST("nsigmatof/test_occupancy/pos/pr"), track.pt(), nsigmaTOFPr, multiplicity, occupancy); + histos.fill(HIST("nsigmatof/test_occupancy/neg/pr"), track.pt(), nsigmaTOFPr, multiplicity, occupancy); + + } // track + } // process function + PROCESS_SWITCH(tofSpectra, processOccupancy, "check for occupancy plots", false); + void processStandard(CollisionCandidates::iterator const& collision, TrackCandidates const& tracks) { @@ -1266,7 +1401,7 @@ struct tofSpectra { } hMultiplicityvsPercentile->Fill(getMultiplicity(collision), collision.multNTracksPV()); for (const auto& track : tracks) { - if (!isTrackSelected(track)) { + if (!isTrackSelected(track, collision)) { continue; } } @@ -1284,7 +1419,7 @@ struct tofSpectra { } const auto& tracksInCollision = tracks.sliceByCached(aod::spectra::collisionId, collision.globalIndex(), cacheTrk); for (const auto& track : tracksInCollision) { - if (!isTrackSelected(track)) { + if (!isTrackSelected(track, collision)) { continue; } fillParticleHistos(track, collision); @@ -1305,7 +1440,7 @@ struct tofSpectra { return; \ } \ for (const auto& track : tracks) { \ - if (!isTrackSelected(track)) { \ + if (!isTrackSelected(track, collision)) { \ continue; \ } \ fillParticleHistos(track, collision); \ @@ -1466,7 +1601,10 @@ struct tofSpectra { using RecoMCCollisions = soa::Join; // RD template - void fillTrackHistograms_MC(TrackType const& track, ParticleType const& mcParticle, RecoMCCollisions::iterator const& collision) + void fillTrackHistograms_MC(TrackType const& track, + ParticleType::iterator const& mcParticle, + RecoMCCollisions::iterator const& collision, + ParticleType const& mcParticles) { if (!isParticleEnabled()) { // Check if the particle is enabled return; @@ -1490,7 +1628,12 @@ struct tofSpectra { if (std::abs(mcParticle.y()) > trkselOptions.cfgCutY) { return; } - if (!mcParticle.isPhysicalPrimary()) { + + 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()); @@ -1498,6 +1641,13 @@ struct tofSpectra { histos.fill(HIST(hdcaxystr[i]), track.pt(), track.dcaXY()); histos.fill(HIST(hdcazstr[i]), track.pt(), track.dcaZ()); } + if (mcParticle.has_daughters()) { + auto daughter0 = mcParticle.template daughters_as().begin(); + double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; + double vertexPrimary[3] = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; + auto decayLength = RecoDecay::distance(vertexPrimary, vertexDau) / 10000; + hDecayLengthStr[i]->Fill(track.pt(), decayLength); + } } else { if (enableDCAxyzHistograms) { hDcaXYZMat[i]->Fill(track.pt(), track.dcaXY(), track.dcaZ()); @@ -1506,18 +1656,81 @@ struct tofSpectra { histos.fill(HIST(hdcazmat[i]), track.pt(), track.dcaZ()); } } - } else { + } 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 (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; + 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 && ((motherPdgCode) / 1000 == 5 || (motherPdgCode) / 100 == 5)) { + IsBeautyMother = true; + } + if (charmOrigin == RecoDecay::OriginType::Prompt && ((motherPdgCode) / 1000 == 4 || (motherPdgCode) / 100 == 4)) { + IsCharmMother = true; + } + if (!(motherPdgCode / 1000 == 4 || motherPdgCode / 100 == 4) && !(motherPdgCode / 1000 == 5 || motherPdgCode / 100 == 5)) { + IsNotHFMother = true; + } + } + } + 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_daughters()) { + auto daughter0 = mcParticle.template daughters_as().begin(); + double vertexDau[3] = {daughter0.vx(), daughter0.vy(), daughter0.vz()}; + double vertexPrimary[3] = {mcCollision.posX(), mcCollision.posY(), mcCollision.posZ()}; + auto decayLength = RecoDecay::distance(vertexPrimary, vertexDau) / 10000; + + 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); + } } } } @@ -1540,18 +1753,37 @@ struct tofSpectra { if (!mcParticle.isPhysicalPrimary()) { if (mcParticle.getProcess() == 4) { - 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); + } if (track.hasTOF()) { - histos.fill(HIST(hpt_numtof_str[i]), track.pt(), multiplicity, track.dcaXY()); + if (includeCentralityMC) { + histos.fill(HIST(hpt_numtof_str[i]), track.pt(), multiplicity, track.dcaXY()); + } else { + histos.fill(HIST(hpt_numtof_str[i]), track.pt(), multiplicity); + } } } else { - histos.fill(HIST(hpt_num_mat[i]), track.pt(), multiplicity, track.dcaXY()); - if (track.hasTOF()) { - histos.fill(HIST(hpt_numtof_mat[i]), track.pt(), multiplicity, track.dcaXY()); + if (includeCentralityMC) { + histos.fill(HIST(hpt_num_mat[i]), track.pt(), multiplicity, track.dcaXY()); + if (track.hasTOF()) { + histos.fill(HIST(hpt_numtof_mat[i]), track.pt(), multiplicity, track.dcaXY()); + } + } else { + histos.fill(HIST(hpt_num_mat[i]), track.pt(), multiplicity); + if (track.hasTOF()) { + histos.fill(HIST(hpt_numtof_mat[i]), track.pt(), multiplicity); + } } } } else { - histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity, track.dcaXY()); + if (includeCentralityMC) { + histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity, track.dcaXY()); + } else { + histos.fill(HIST(hpt_num_prm[i]), track.pt(), multiplicity); + } if (track.hasTRD() && trkselOptions.lastRequiredTrdCluster > 0) { int lastLayer = 0; for (int l = 7; l >= 0; l--) { @@ -1565,7 +1797,11 @@ struct tofSpectra { } } if (track.hasTOF()) { - histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity, track.dcaXY()); + if (includeCentralityMC) { + histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity, track.dcaXY()); + } else { + histos.fill(HIST(hpt_numtof_prm[i]), track.pt(), multiplicity); + } if (!(track.mcMask() & (1 << 11))) { if (includeCentralityMC) { histos.fill(HIST(hpt_numtofgoodmatch_prm[i]), track.pt(), multiplicity, track.eta()); // RD @@ -1685,7 +1921,7 @@ struct tofSpectra { const float multiplicity = getMultiplicityMC(mcCollision); if (mcParticle.isPhysicalPrimary()) { - if (abs(mcCollision.posZ()) < evselOptions.cfgCutVertex) { + if (std::abs(mcCollision.posZ()) < evselOptions.cfgCutVertex) { histos.fill(HIST(hpt_den_prm_mcgoodev[i]), mcParticle.pt(), multiplicity); } else { histos.fill(HIST(hpt_den_prm_mcbadev[i]), mcParticle.pt(), multiplicity); @@ -1735,7 +1971,7 @@ struct tofSpectra { const auto& mcParticle = track.mcParticle(); static_for<0, 17>([&](auto i) { - fillTrackHistograms_MC(track, mcParticle, track.collision_as()); + fillTrackHistograms_MC(track, mcParticle, track.collision_as(), mcParticles); }); } if (includeCentralityMC) { @@ -1804,7 +2040,7 @@ struct tofSpectra { // Loop on generated collisions for (const auto& mcCollision : mcCollisions) { - if (abs(mcCollision.posZ()) > evselOptions.cfgCutVertex) { + if (std::abs(mcCollision.posZ()) > evselOptions.cfgCutVertex) { continue; } histos.fill(HIST("MC/Multiplicity"), getMultiplicityMC(mcCollision)); diff --git a/PWGLF/Tasks/Nuspex/spectraTOFRun2.cxx b/PWGLF/Tasks/Nuspex/spectraTOFRun2.cxx index efcc58dd55d..9c31160f0a1 100644 --- a/PWGLF/Tasks/Nuspex/spectraTOFRun2.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTOFRun2.cxx @@ -348,7 +348,7 @@ struct tofSpectraRun2 { template void fillParticleHistos(const T& track, const C& /*collision*/) { - if (abs(track.rapidity(PID::getMass(id))) > cfgCutY) { + if (std::abs(track.rapidity(PID::getMass(id))) > cfgCutY) { return; } const auto& nsigmaTOF = o2::aod::pidutils::tofNSigma(track); @@ -468,7 +468,7 @@ struct tofSpectraRun2 { if constexpr (fillHistograms) { histos.fill(HIST("evsel"), 2); } - if (abs(collision.posZ()) > cfgCutVertex) { + if (std::abs(collision.posZ()) > cfgCutVertex) { return false; } if constexpr (fillHistograms) { @@ -496,7 +496,7 @@ struct tofSpectraRun2 { if constexpr (fillHistograms) { histos.fill(HIST("tracksel"), 1); } - if (abs(track.eta()) > cfgCutEta) { + if (std::abs(track.eta()) > cfgCutEta) { return false; } if constexpr (fillHistograms) { diff --git a/PWGLF/Tasks/Nuspex/spectraTPC.cxx b/PWGLF/Tasks/Nuspex/spectraTPC.cxx index 18f7275e523..fd929553fb6 100644 --- a/PWGLF/Tasks/Nuspex/spectraTPC.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTPC.cxx @@ -117,7 +117,7 @@ struct tpcSpectra { void fillParticleHistos(const T& track) { const float y = TMath::ASinH(track.pt() / TMath::Sqrt(PID::getMass2(id) + track.pt() * track.pt()) * TMath::SinH(track.eta())); - if (abs(y) > 0.5) { + if (std::abs(y) > 0.5) { return; } const auto& nsigma = o2::aod::pidutils::tpcNSigma(track); @@ -131,7 +131,7 @@ struct tpcSpectra { if (!track.isGlobalTrack()) { return; } - if (abs(nsigma) > cfgNSigmaCut) { + if (std::abs(nsigma) > cfgNSigmaCut) { return; } histos.fill(HIST(hp[id]), track.p()); @@ -155,7 +155,7 @@ struct tpcSpectra { return; } histos.fill(HIST("evsel"), 2); - if (abs(collision.posZ()) > cfgCutVertex) { + if (std::abs(collision.posZ()) > cfgCutVertex) { return; } histos.fill(HIST("evsel"), 3); @@ -163,7 +163,7 @@ struct tpcSpectra { for (const auto& track : tracks) { histos.fill(HIST("tracksel"), 1); - if (abs(track.eta()) > cfgCutEta) { + if (std::abs(track.eta()) > cfgCutEta) { continue; } histos.fill(HIST("tracksel"), 2); @@ -279,7 +279,7 @@ struct tpcPidQaSignalwTof { TrackCandidates const& tracks) { histos.fill(HIST("evsel"), 1); - if (abs(collision.posZ()) > cfgCutVertex) { + if (std::abs(collision.posZ()) > cfgCutVertex) { return; } histos.fill(HIST("evsel"), 2); @@ -287,7 +287,7 @@ struct tpcPidQaSignalwTof { for (const auto& track : tracks) { histos.fill(HIST("tracksel"), 1); - if (abs(track.eta()) > cfgCutEta) { + if (std::abs(track.eta()) > cfgCutEta) { continue; } histos.fill(HIST("tracksel"), 2); diff --git a/PWGLF/Tasks/Nuspex/spectraTPCtiny.cxx b/PWGLF/Tasks/Nuspex/spectraTPCtiny.cxx index 12fc53f6bfc..d58a8777771 100644 --- a/PWGLF/Tasks/Nuspex/spectraTPCtiny.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTPCtiny.cxx @@ -58,7 +58,7 @@ struct tpcSpectraTiny { template void fillParticleHistos(const T& track, const float& nsigma) { - if (abs(nsigma) > cfgNSigmaCut) { + if (std::abs(nsigma) > cfgNSigmaCut) { return; } histos.fill(HIST(hp[i]), track.p()); @@ -78,7 +78,7 @@ struct tpcSpectraTiny { TrackCandidates const& tracks) { histos.fill(HIST("evsel"), 1); - if (abs(collision.posZ()) > cfgCutVertex) { + if (std::abs(collision.posZ()) > cfgCutVertex) { return; } histos.fill(HIST("evsel"), 2); @@ -86,7 +86,7 @@ struct tpcSpectraTiny { for (const auto& track : tracks) { histos.fill(HIST("tracksel"), 1); - if (abs(track.eta()) > cfgCutEta) { + if (std::abs(track.eta()) > cfgCutEta) { continue; } histos.fill(HIST("tracksel"), 2); diff --git a/PWGLF/Tasks/Nuspex/spectraTPCtinyPiKaPr.cxx b/PWGLF/Tasks/Nuspex/spectraTPCtinyPiKaPr.cxx index 328b44d5477..9c9a340bfcf 100644 --- a/PWGLF/Tasks/Nuspex/spectraTPCtinyPiKaPr.cxx +++ b/PWGLF/Tasks/Nuspex/spectraTPCtinyPiKaPr.cxx @@ -49,7 +49,7 @@ struct tpcSpectraTinyPiKaPr { template void fillParticleHistos(const T& track, const float& nsigma) { - if (abs(nsigma) > cfgNSigmaCut) { + if (std::abs(nsigma) > cfgNSigmaCut) { return; } histos.fill(HIST(hp[i]), track.p()); diff --git a/PWGLF/Tasks/QC/CMakeLists.txt b/PWGLF/Tasks/QC/CMakeLists.txt index c640ee82586..5fba2292100 100644 --- a/PWGLF/Tasks/QC/CMakeLists.txt +++ b/PWGLF/Tasks/QC/CMakeLists.txt @@ -44,6 +44,12 @@ o2physics_add_dpl_workflow(its-tpc-matching-qa PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(strangeness-tracking-qc + SOURCES strangenessTrackingQC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::ReconstructionDataFormats O2Physics::AnalysisCore O2::DetectorsBase + COMPONENT_NAME Analysis) + + o2physics_add_dpl_workflow(mc-signal-loss SOURCES mcSignalLoss.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -66,7 +72,7 @@ o2physics_add_dpl_workflow(tpc-dedx-qa o2physics_add_dpl_workflow(vertexqa SOURCES vertexQA.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::AnalysisCCDB COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(efficiencyqa @@ -113,3 +119,8 @@ o2physics_add_dpl_workflow(mc-particle-predictions SOURCES mcParticlePrediction.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(strange-derived-qa + SOURCES strangederivedqa.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/QC/mcParticlePrediction.cxx b/PWGLF/Tasks/QC/mcParticlePrediction.cxx index 6d769fecae5..8a4a1ec3ac9 100644 --- a/PWGLF/Tasks/QC/mcParticlePrediction.cxx +++ b/PWGLF/Tasks/QC/mcParticlePrediction.cxx @@ -43,21 +43,27 @@ bool enabledParticlesArray[PIDExtended::NIDsTot]; // Estimators struct Estimators { - static const int FT0A = 0; - static const int FT0C = 1; - static const int FT0AC = 2; - static const int FV0A = 3; - static const int FDDA = 4; - static const int FDDC = 5; - static const int FDDAC = 6; - static const int ZNA = 7; - static const int ZNC = 8; - static const int ZEM1 = 9; - static const int ZEM2 = 10; - static const int ZPA = 11; - static const int ZPC = 12; - static const int ITS = 13; - static const int nEstimators = 14; + typedef int estID; + static constexpr estID FT0A = 0; + static constexpr estID FT0C = 1; + static constexpr estID FT0AC = 2; + static constexpr estID FV0A = 3; + static constexpr estID FDDA = 4; + static constexpr estID FDDC = 5; + static constexpr estID FDDAC = 6; + static constexpr estID ZNA = 7; + static constexpr estID ZNC = 8; + static constexpr estID ZEM1 = 9; + static constexpr estID ZEM2 = 10; + static constexpr estID ZPA = 11; + static constexpr estID ZPC = 12; + static constexpr estID ITSIB = 13; + static constexpr estID ETA05 = 14; + static constexpr estID ETA08 = 15; + 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 const char* estimatorNames[nEstimators] = {"FT0A", "FT0C", @@ -72,10 +78,18 @@ struct Estimators { "ZEM2", "ZPA", "ZPC", - "ITS"}; + "ITSIB", + "ETA05", + "ETA08", + "V0A", + "V0C", + "V0AC"}; static std::vector arrayNames() { - std::vector names; + static std::vector names; + if (!names.empty()) { + return names; + } for (int i = 0; i < nEstimators; i++) { names.push_back(estimatorNames[i]); } @@ -96,11 +110,18 @@ static const int defaultEstimators[Estimators::nEstimators][nParameters]{{0}, / {0}, // ZEM2 {0}, // ZPA {0}, // ZPC - {0}}; // ITS + {0}, // ITSIB + {0}, // ETA05 + {0}, // ETA08 + {0}, // V0A (Run2) + {0}, // V0C (Run2) + {0}}; // V0AC (Run2 V0M) // 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> hestimatorsRecoEvGenVsReco; std::array, Estimators::nEstimators> hestimatorsRecoEvGenVsReco_BCMC; std::array, Estimators::nEstimators> hestimatorsRecoEvGenVsRecoITS; @@ -135,7 +156,7 @@ struct mcParticlePrediction { "Estimators enabled"}; Configurable selectInelGt0{"selectInelGt0", true, "Select only inelastic events"}; Configurable selectPrimaries{"selectPrimaries", true, "Select only primary particles"}; - + Configurable requireCoincidenceEstimators{"requireCoincidenceEstimators", false, "Asks for a coincidence when two estimators are used"}; Configurable discardkIsGoodZvtxFT0vsPV{"discardkIsGoodZvtxFT0vsPV", false, "Select only collisions with matching BC and MC BC"}; Configurable discardMismatchedBCs{"discardMismatchedBCs", false, "Select only collisions with matching BC and MC BC"}; Configurable discardMismatchedFoundBCs{"discardMismatchedFoundBCs", false, "Select only collisions with matching found BC and MC BC"}; @@ -145,6 +166,9 @@ struct mcParticlePrediction { Configurable requirekIsVertexITSTPC{"requirekIsVertexITSTPC", false, "Require kIsVertexITSTPC: at least one ITS-TPC track (reject vertices built from ITS-only tracks)"}; Configurable requirekIsVertexTOFmatched{"requirekIsVertexTOFmatched", false, "Require kIsVertexTOFmatched: at least one of vertex contributors is matched to TOF"}; Configurable requirekIsVertexTRDmatched{"requirekIsVertexTRDmatched", false, "Require kIsVertexTRDmatched: at least one of vertex contributors is matched to TRD"}; + 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"}; Service pdgDB; o2::pwglf::ParticleCounter mCounter; @@ -160,7 +184,7 @@ struct mcParticlePrediction { const AxisSpec axisPt{binsPt, "#it{p}_{T} (GeV/#it{c})"}; const AxisSpec axisMultiplicity{binsMultiplicity, "Multiplicity (undefined)"}; const AxisSpec axisMultiplicityReco{binsMultiplicityReco, "Multiplicity Reco. (undefined)"}; - const AxisSpec axisMultiplicityRecoITS{100, 0, 100, "Multiplicity Reco. ITS"}; + const AxisSpec axisMultiplicityRecoITS{100, 0, 100, "Multiplicity Reco. ITSIB"}; const AxisSpec axisMultiplicityGenV0s{100, 0, 100, "K0s gen"}; const AxisSpec axisMultiplicityRecoV0s{20, 0, 20, "K0s reco"}; const AxisSpec axisBCID{o2::constants::lhc::LHCMaxBunches, -0.5, -0.5 + o2::constants::lhc::LHCMaxBunches, "BC ID in orbit"}; @@ -238,14 +262,32 @@ struct mcParticlePrediction { hestimators[i] = histos.add(Form("multiplicity/%s", name), name, kTH1D, {axisMultiplicity}); hestimators[i]->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); - hestimatorsVsITS[i] = histos.add(Form("multiplicity/vsITS/%s", name), name, kTH2D, {axisMultiplicity, axisMultiplicity}); - hestimatorsVsITS[i]->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); - hestimatorsVsITS[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", Estimators::estimatorNames[Estimators::ITS])); + auto make2DH = [&](const std::string& h, const char* ytitle) { + auto hist = histos.add(Form("%s%s", h.c_str(), name), + name, + kTH2D, + {axisMultiplicity, axisMultiplicity}); + hist->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); + hist->GetXaxis()->SetTitle(Form("Multiplicity %s", ytitle)); + return hist; + }; + if (enableVsITSHistograms) { + hestimatorsVsITS[i] = make2DH("multiplicity/vsITS/", Estimators::estimatorNames[Estimators::ITSIB]); + } + if (enableVsEta05Histograms) { + hestimatorsVsETA05[i] = make2DH("multiplicity/vsETA05/", Estimators::estimatorNames[Estimators::ETA05]); + } + if (enableVsEta08Histograms) { + hestimatorsVsETA08[i] = make2DH("multiplicity/vsETA08/", Estimators::estimatorNames[Estimators::ETA08]); + } hvertexPosZ[i] = histos.add(Form("multiplicity/posZ/%s", name), name, kTH2D, {{200, -20, 20, "pos Z"}, axisMultiplicity}); hvertexPosZ[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", name)); - // Reco events + if (!doprocessReco) { // Reco events + continue; + } + hestimatorsRecoEvGenVsReco[i] = histosRecoEvs.add(Form("multiplicity/Reco/GenVsReco/%s", name), name, kTH2D, {axisMultiplicity, axisMultiplicityReco}); hestimatorsRecoEvGenVsReco[i]->GetXaxis()->SetTitle(Form("Multiplicity %s", name)); hestimatorsRecoEvGenVsReco[i]->GetYaxis()->SetTitle(Form("Multiplicity Reco. %s", name)); @@ -259,7 +301,7 @@ struct mcParticlePrediction { hestimatorsRecoEvRecoVsITS[i] = histosRecoEvs.add(Form("multiplicity/Reco/RecoVsITS/%s", name), name, kTH2D, {axisMultiplicityReco, axisMultiplicity}); hestimatorsRecoEvRecoVsITS[i]->GetXaxis()->SetTitle(Form("Multiplicity Reco. %s", name)); - hestimatorsRecoEvRecoVsITS[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", Estimators::estimatorNames[Estimators::ITS])); + hestimatorsRecoEvRecoVsITS[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", Estimators::estimatorNames[Estimators::ITSIB])); hestimatorsRecoEvRecoVsRecoITS[i] = histosRecoEvs.add(Form("multiplicity/Reco/RecoVsRecoITS/%s", name), name, kTH2D, {axisMultiplicityReco, axisMultiplicityRecoITS}); hestimatorsRecoEvRecoVsRecoITS[i]->GetXaxis()->SetTitle(Form("Multiplicity Reco. %s", name)); @@ -274,8 +316,7 @@ struct mcParticlePrediction { hestimatorsRecoEvRecoVsBCId[i] = histosRecoEvs.add(Form("multiplicity/Reco/RecoVsBCId/%s", name), name, kTH2D, {axisBCID, axisMultiplicityReco}); hestimatorsRecoEvRecoVsBCId[i]->GetYaxis()->SetTitle(Form("Multiplicity Reco. %s", name)); - hestimatorsRecoEvVsBCId[i] = histosRecoEvs.add(Form("multiplicity/Reco/VsBCId/%s", name), name, kTH2D, - {axisBCID, axisMultiplicity}); + hestimatorsRecoEvVsBCId[i] = histosRecoEvs.add(Form("multiplicity/Reco/VsBCId/%s", name), name, kTH2D, {axisBCID, axisMultiplicity}); hestimatorsRecoEvVsBCId[i]->GetYaxis()->SetTitle(Form("Multiplicity %s", name)); } @@ -304,6 +345,66 @@ struct mcParticlePrediction { histosYield.print(); } + std::array genMult(const auto& mcParticles) + { + std::array nMult; + if (enabledEstimatorsArray[Estimators::FT0A] || enabledEstimatorsArray[Estimators::FT0AC]) { + nMult[Estimators::FT0A] = mCounter.countFT0A(mcParticles); + } + if (enabledEstimatorsArray[Estimators::FT0C] || enabledEstimatorsArray[Estimators::FT0AC]) { + nMult[Estimators::FT0C] = mCounter.countFT0C(mcParticles); + } + if (enabledEstimatorsArray[Estimators::FT0AC]) { + nMult[Estimators::FT0AC] = nMult[Estimators::FT0A] + nMult[Estimators::FT0C]; + if (requireCoincidenceEstimators && (nMult[Estimators::FT0A] <= 0.f || nMult[Estimators::FT0C] <= 0.f)) { + nMult[Estimators::FT0AC] = 0; + } + } + if (enabledEstimatorsArray[Estimators::FV0A]) { + nMult[Estimators::FV0A] = mCounter.countFV0A(mcParticles); + } + if (enabledEstimatorsArray[Estimators::FDDA]) { + nMult[Estimators::FDDA] = mCounter.countFDDA(mcParticles); + } + if (enabledEstimatorsArray[Estimators::FDDC]) { + nMult[Estimators::FDDC] = mCounter.countFDDC(mcParticles); + } + if (enabledEstimatorsArray[Estimators::FDDAC]) { + nMult[Estimators::FDDAC] = nMult[Estimators::FDDA] + nMult[Estimators::FDDC]; + if (requireCoincidenceEstimators && (nMult[Estimators::FDDA] <= 0.f || nMult[Estimators::FDDC] <= 0.f)) { + nMult[Estimators::FDDAC] = 0; + } + } + if (enabledEstimatorsArray[Estimators::ZNA]) { + nMult[Estimators::ZNA] = mCounter.countZNA(mcParticles); + } + if (enabledEstimatorsArray[Estimators::ZNC]) { + nMult[Estimators::ZNC] = mCounter.countZNC(mcParticles); + } + if (enabledEstimatorsArray[Estimators::ITSIB] || enableVsITSHistograms) { + nMult[Estimators::ITSIB] = mCounter.countITSIB(mcParticles); + } + if (enabledEstimatorsArray[Estimators::ETA05] || enableVsEta05Histograms) { + nMult[Estimators::ETA05] = mCounter.countEta05(mcParticles); + } + if (enabledEstimatorsArray[Estimators::ETA08] || enableVsEta08Histograms) { + nMult[Estimators::ETA08] = mCounter.countEta08(mcParticles); + } + if (enabledEstimatorsArray[Estimators::V0A] || enabledEstimatorsArray[Estimators::V0AC]) { + nMult[Estimators::V0A] = mCounter.countV0A(mcParticles); + } + if (enabledEstimatorsArray[Estimators::V0C] || enabledEstimatorsArray[Estimators::V0AC]) { + nMult[Estimators::V0C] = mCounter.countV0C(mcParticles); + } + if (enabledEstimatorsArray[Estimators::V0AC]) { + nMult[Estimators::V0AC] = nMult[Estimators::V0A] + nMult[Estimators::V0C]; + if (requireCoincidenceEstimators && (nMult[Estimators::V0A] <= 0 || nMult[Estimators::V0C] <= 0)) { + nMult[Estimators::V0AC] = 0; + } + } + return nMult; + } + void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) { @@ -313,21 +414,12 @@ struct mcParticlePrediction { } histos.fill(HIST("collisions/generated"), 1); - if (abs(mcCollision.posZ()) > 10.f) { + if (std::abs(mcCollision.posZ()) > 10.f) { return; } histos.fill(HIST("collisions/generated"), 2); - float nMult[Estimators::nEstimators]; - nMult[Estimators::FT0A] = mCounter.countFT0A(mcParticles); - nMult[Estimators::FT0C] = mCounter.countFT0C(mcParticles); - nMult[Estimators::FT0AC] = nMult[Estimators::FT0A] + nMult[Estimators::FT0C]; - nMult[Estimators::FV0A] = mCounter.countFV0A(mcParticles); - nMult[Estimators::FDDA] = mCounter.countFDDA(mcParticles); - nMult[Estimators::FDDC] = mCounter.countFDDC(mcParticles); - nMult[Estimators::FDDAC] = nMult[Estimators::FDDA] + nMult[Estimators::FDDC]; - nMult[Estimators::ZNA] = mCounter.countZNA(mcParticles); - nMult[Estimators::ZNC] = mCounter.countZNC(mcParticles); - nMult[Estimators::ITS] = mCounter.countITSIB(mcParticles); + + const std::array& nMult = genMult(mcParticles); for (int i = 0; i < Estimators::nEstimators; i++) { if (!enabledEstimatorsArray[i]) { @@ -335,7 +427,15 @@ struct mcParticlePrediction { } hestimators[i]->Fill(nMult[i]); - hestimatorsVsITS[i]->Fill(nMult[i], nMult[Estimators::ITS]); + if (enableVsITSHistograms) { + hestimatorsVsITS[i]->Fill(nMult[i], nMult[Estimators::ITSIB]); + } + if (enableVsEta05Histograms) { + hestimatorsVsETA05[i]->Fill(nMult[i], nMult[Estimators::ETA05]); + } + if (enableVsEta08Histograms) { + hestimatorsVsETA08[i]->Fill(nMult[i], nMult[Estimators::ETA08]); + } hvertexPosZ[i]->Fill(mcCollision.posZ(), nMult[i]); } @@ -355,14 +455,14 @@ struct mcParticlePrediction { TParticlePDG* p = pdgDB->GetParticle(particle.pdgCode()); if (p) { - if (abs(p->Charge()) > 1e-3) { + if (std::abs(p->Charge()) > 1e-3) { histos.fill(HIST("particles/eta/charged"), particle.eta()); } else { histos.fill(HIST("particles/eta/neutral"), particle.eta()); } } - if (abs(particle.y()) > 0.5) { + if (std::abs(particle.y()) > 0.5) { continue; } @@ -436,7 +536,7 @@ struct mcParticlePrediction { } histos.fill(HIST("collisions/reconstructed"), 8); - if (abs(collision.posZ()) > posZCut.value) { + if (std::abs(collision.posZ()) > posZCut.value) { return; } histos.fill(HIST("collisions/reconstructed"), 9); @@ -511,17 +611,7 @@ struct mcParticlePrediction { histos.fill(HIST("particles/FromCollVsFromCollBad"), particlesFromColl, particlesFromCollWrongBC); histos.fill(HIST("particles/FromCollBadOverFromCollVsVsFromMCColl"), 1.f * particlesFromCollWrongBC / particlesFromColl, particlesInCollision.size()); - float nMult[Estimators::nEstimators]; - nMult[Estimators::FT0A] = mCounter.countFT0A(particlesInCollision); - nMult[Estimators::FT0C] = mCounter.countFT0C(particlesInCollision); - nMult[Estimators::FT0AC] = nMult[Estimators::FT0A] + nMult[Estimators::FT0C]; - nMult[Estimators::FV0A] = mCounter.countFV0A(particlesInCollision); - nMult[Estimators::FDDA] = mCounter.countFDDA(particlesInCollision); - nMult[Estimators::FDDC] = mCounter.countFDDC(particlesInCollision); - nMult[Estimators::FDDAC] = nMult[Estimators::FDDA] + nMult[Estimators::FDDC]; - nMult[Estimators::ZNA] = mCounter.countZNA(particlesInCollision); - nMult[Estimators::ZNC] = mCounter.countZNC(particlesInCollision); - nMult[Estimators::ITS] = mCounter.countITSIB(particlesInCollision); + const std::array& nMult = genMult(mcParticles); float nMultReco[Estimators::nEstimators]; nMultReco[Estimators::FT0A] = collision.multFT0A(); @@ -533,7 +623,7 @@ struct mcParticlePrediction { nMultReco[Estimators::FDDAC] = collision.multFDDM(); nMultReco[Estimators::ZNA] = collision.multZNA(); nMultReco[Estimators::ZNC] = collision.multZNC(); - nMultReco[Estimators::ITS] = collision.multNTracksPV(); + nMultReco[Estimators::ITSIB] = collision.multNTracksPV(); float nMultRecoMCBC[Estimators::nEstimators] = {0}; if (mcBC.has_ft0()) { @@ -556,10 +646,10 @@ struct mcParticlePrediction { } hestimatorsRecoEvGenVsReco[i]->Fill(nMult[i], nMultReco[i]); hestimatorsRecoEvGenVsReco_BCMC[i]->Fill(nMult[i], nMultRecoMCBC[i]); - hestimatorsRecoEvGenVsRecoITS[i]->Fill(nMult[i], nMultReco[Estimators::ITS]); - hestimatorsRecoEvRecoVsITS[i]->Fill(nMultReco[i], nMult[Estimators::ITS]); - hestimatorsRecoEvRecoVsRecoITS[i]->Fill(nMultReco[i], nMultReco[Estimators::ITS]); - hestimatorsRecoEvRecoVsRecoITS_BCMC[i]->Fill(nMultRecoMCBC[i], nMultReco[Estimators::ITS]); + hestimatorsRecoEvGenVsRecoITS[i]->Fill(nMult[i], nMultReco[Estimators::ITSIB]); + hestimatorsRecoEvRecoVsITS[i]->Fill(nMultReco[i], nMult[Estimators::ITSIB]); + hestimatorsRecoEvRecoVsRecoITS[i]->Fill(nMultReco[i], nMultReco[Estimators::ITSIB]); + hestimatorsRecoEvRecoVsRecoITS_BCMC[i]->Fill(nMultRecoMCBC[i], nMultReco[Estimators::ITSIB]); hestimatorsRecoEvRecoVsFT0A[i]->Fill(nMultReco[i], nMult[Estimators::FT0A]); hestimatorsRecoEvRecoVsBCId[i]->Fill(foundBCid, nMult[i]); hestimatorsRecoEvVsBCId[i]->Fill(foundBCid, nMultReco[i]); diff --git a/PWGLF/Tasks/QC/mcinelgt0.cxx b/PWGLF/Tasks/QC/mcinelgt0.cxx index cac4eff5bf7..40acd66a67f 100644 --- a/PWGLF/Tasks/QC/mcinelgt0.cxx +++ b/PWGLF/Tasks/QC/mcinelgt0.cxx @@ -48,7 +48,7 @@ struct mcInelGt0 { if (!track.isPVContributor()) { continue; } - if (abs(track.eta()) > 1) { + if (std::abs(track.eta()) > 1) { LOG(info) << "Track with eta > 1: " << track.eta() << (track.hasTPC() ? "hasTPC" diff --git a/PWGLF/Tasks/QC/strangederivedqa.cxx b/PWGLF/Tasks/QC/strangederivedqa.cxx new file mode 100644 index 00000000000..2e709e07338 --- /dev/null +++ b/PWGLF/Tasks/QC/strangederivedqa.cxx @@ -0,0 +1,158 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// +// V0 analysis task +// ================ +// +// This code does basic QA of strangeness derived data + +#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 "PWGLF/DataModel/LFStrangenessTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; +using std::array; + +struct strangederivedqa { + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + ConfigurableAxis axisNCollisions{"axisNCollisions", {50000, -0.5f, 49999.5f}, "collisions"}; + ConfigurableAxis axisNV0s{"axisNV0s", {50000, -0.5f, 49999.5f}, "V0s"}; + + Configurable verbose{"verbose", false, "do more printouts"}; + + void init(InitContext const&) + { + auto h = histos.add("hDFCounter", "hDFCounter", kTH1D, {{6, -0.5f, 5.5f}}); + h->GetXaxis()->SetBinLabel(1, "All"); + h->GetXaxis()->SetBinLabel(2, "Ordered"); + h->GetXaxis()->SetBinLabel(3, "Unordered"); + + auto h2 = histos.add("hEventCounter", "hEventCounter", kTH2D, {{1, -0.5f, 0.5f}, {3, -0.5f, 2.5f}}); + auto h3 = histos.add("hEventsPerDF", "hEventsPerDF", kTH2D, {axisNCollisions, {3, -0.5f, 2.5f}}); + auto h4 = histos.add("hV0sPerDF", "hV0sPerDF", kTH2D, {axisNV0s, {3, -0.5f, 2.5f}}); + + h2->GetYaxis()->SetBinLabel(1, "All"); + h2->GetYaxis()->SetBinLabel(2, "Ordered"); + h2->GetYaxis()->SetBinLabel(3, "Unordered"); + h3->GetYaxis()->SetBinLabel(1, "All"); + h3->GetYaxis()->SetBinLabel(2, "Ordered"); + h3->GetYaxis()->SetBinLabel(3, "Unordered"); + h4->GetYaxis()->SetBinLabel(1, "All"); + h4->GetYaxis()->SetBinLabel(2, "Ordered"); + h4->GetYaxis()->SetBinLabel(3, "Unordered"); + } + + // Real data processing + void processOriginal(aod::Collisions const& collisions, aod::Origins const& origins, soa::Join const& fullV0s) + { + histos.fill(HIST("hDFCounter"), 0.0f); + histos.fill(HIST("hEventCounter"), 0.0f, 0.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 0.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 0.0f); + bool ordered = true; + int previousIndex = -100; + for (auto const& v0 : fullV0s) { + if (v0.collisionId() < previousIndex) { + ordered = false; + } + previousIndex = v0.collisionId(); + } + if (ordered) { + histos.fill(HIST("hEventCounter"), 0.0f, 1.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 1.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 1.0f); + + if (verbose) { + auto origin = origins.begin(); + LOGF(info, "Sorted DF ID: %lld collisions: %i V0s: %i", origin.dataframeID(), collisions.size(), fullV0s.size()); + } + } else { + histos.fill(HIST("hEventCounter"), 0.0f, 2.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 2.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 2.0f); + + if (verbose) { + auto origin = origins.begin(); + LOGF(info, "Unsorted DF ID: %lld collisions: %i V0s: %i", origin.dataframeID(), collisions.size(), fullV0s.size()); + } + } + } + + // Real data processing + void processDerived(aod::StraCollisions const& collisions, aod::StraOrigins const& origins, soa::Join const& fullV0s) + { + histos.fill(HIST("hDFCounter"), 0.0f); + histos.fill(HIST("hEventCounter"), 0.0f, 0.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 0.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 0.0f); + bool ordered = true; + int previousIndex = -100; + for (auto const& v0 : fullV0s) { + if (v0.straCollisionId() < previousIndex) { + ordered = false; + } + previousIndex = v0.straCollisionId(); + } + if (ordered) { + histos.fill(HIST("hEventCounter"), 0.0f, 1.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 1.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 1.0f); + + if (verbose) { + auto origin = origins.begin(); + LOGF(info, "Sorted DF ID: %lld collisions: %i V0s: %i Origins size: %i", origin.dataframeID(), collisions.size(), fullV0s.size(), origins.size()); + } + } else { + histos.fill(HIST("hEventCounter"), 0.0f, 2.0f, collisions.size()); + histos.fill(HIST("hEventsPerDF"), collisions.size(), 2.0f); + histos.fill(HIST("hV0sPerDF"), fullV0s.size(), 2.0f); + + if (verbose) { + auto origin = origins.begin(); + LOGF(info, "Unsorted DF ID: %lld collisions: %i V0s: %i Origins size: %i", origin.dataframeID(), collisions.size(), fullV0s.size(), origins.size()); + uint64_t directoryName = origin.dataframeID(); + for (auto const& orig : origins) { + LOGF(info, "Unsorted DF ID: %lld separate origin: %lld", directoryName, orig.dataframeID()); + } + } + } + } + + PROCESS_SWITCH(strangederivedqa, processOriginal, "Process original data", false); + PROCESS_SWITCH(strangederivedqa, processDerived, "Process derived data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/QC/strangenessTrackingQC.cxx b/PWGLF/Tasks/QC/strangenessTrackingQC.cxx new file mode 100644 index 00000000000..09c5698fd92 --- /dev/null +++ b/PWGLF/Tasks/QC/strangenessTrackingQC.cxx @@ -0,0 +1,311 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "DataFormatsParameters/GRPMagField.h" +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsTPC/BetheBlochAleph.h" +#include "DCAFitter/DCAFitterN.h" +#include "DetectorsBase/Propagator.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +// #include "PWGHF/Core/PDG.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" +#include "PWGLF/DataModel/LFNonPromptCascadeTables.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace +{ + +}; + +struct miniCasc { + bool fillOmega; + float pt; + float eta; + float phi; + float radius; + float massOmega; + float massXi; + float dcaXYCasc; + float dcaXYTracked; +}; + +struct strangenessTrackingQC { + + using TrackCandidates = soa::Join; + using CollisionCandidates = soa::Join; + + Configurable setting_materialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"}; + + Configurable cascsetting_dcaCascDaughters{"casc_setting_dcaV0daughters", 0.1f, "DCA between the V0 daughters"}; + Configurable cascsetting_cosPA{"casc_setting_cosPA", 0.995f, "Cosine of the pointing angle of the V0"}; + Configurable cascsetting_massWindowXi{"casc_setting_massWindowXi", 0.01f, "Mass window for the Xi"}; + + Configurable cfgGRPmagPath{"cfgGRPmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + Configurable cfgGRPpath{"cfgGRPpath", "GLO/GRP/GRP", "Path of the grp file"}; + + Configurable cfgCutNclusTPC{"cfgCutNclusTPC", 70, "Minimum number of TPC clusters"}; + + ConfigurableAxis ptBins{"ptBins", {200, -10.f, 10.f}, "Binning for #it{p}_{T} (GeV/#it{c})"}; + ConfigurableAxis dcaBins{"dcaBins", {1e3, -0.1, 0.1}, "Binning for DCA (cm)"}; + ConfigurableAxis decayRadBins{"decayRadBins", {100, 0.f, 40.f}, "Binning for decay radius (cm)"}; + ConfigurableAxis omegaMassBins{"omegaMassBins", {125, 1.650, 1.700}, "Invariant mass (GeV/#it{c}^{2})"}; + ConfigurableAxis xiMassBins{"xiMassBins", {125, 1.296, 1.346}, "Invariant mass (GeV/#it{c}^{2})"}; + + Service ccdb; + int mRunNumber = 0; + float bz = 0.f; + o2::vertexing::DCAFitterN<2> m_fitter; + + HistogramRegistry registry{ + "registry", + { + {"omegaMass", "; Mass (GeV/#it{c}^{2}); Counts", {HistType::kTH1F, {{125, 1.650, 1.700}}}}, + {"xiMass", "; Mass (GeV/#it{c}^{2}); Counts", {HistType::kTH1F, {{125, 1.296, 1.346}}}}, + {"omegaMassTracked", "; Mass (GeV/#it{c}^{2}); Counts", {HistType::kTH1F, {{125, 1.650, 1.700}}}}, + {"xiMassTracked", "; Mass (GeV/#it{c}^{2}); Counts", {HistType::kTH1F, {{125, 1.296, 1.346}}}}, + + {"omegaHist", "; #it{p}_{T} (GeV/#it{c}); Radius (cm); Mass", {HistType::kTH3F, {{ptBins, decayRadBins, omegaMassBins}}}}, + {"xiHist", "; #it{p}_{T} (GeV/#it{c}); Radius (cm); Mass", {HistType::kTH3F, {{ptBins, decayRadBins, xiMassBins}}}}, + {"xiHistTracked", "; #it{p}_{T} (GeV/#it{c}); Radius (cm); Mass", {HistType::kTH3F, {{ptBins, decayRadBins, xiMassBins}}}}, + {"omegaHistTracked", "; #it{p}_{T} (GeV/#it{c}); Radius (cm); Mass", {HistType::kTH3F, {{ptBins, decayRadBins, omegaMassBins}}}}, + + {"xiDCAvsPt", "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", {HistType::kTH2F, {{ptBins, dcaBins}}}}, + {"omegaDCAvsPt", "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", {HistType::kTH2F, {{ptBins, dcaBins}}}}, + {"xiDCAvsPtTracked", "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", {HistType::kTH2F, {{ptBins, dcaBins}}}}, + {"omegaDCAvsPtTracked", "; #it{p}_{T} (GeV/#it{c}); DCA (cm)", {HistType::kTH2F, {{ptBins, dcaBins}}}}, + }}; + + template + float dcaToPV(o2::dataformats::VertexBase& PV, T& trackParCov) + { + auto matCorr = static_cast(setting_materialCorrection.value); + o2::dataformats::DCA impactParameterTrk; + o2::base::Propagator::Instance()->propagateToDCA(PV, trackParCov, bz, 2.f, matCorr, &impactParameterTrk); + return impactParameterTrk.getY(); + } + + template + bool qualityTrackSelection(const T& track) + { + if (std::abs(track.eta()) > 0.9) { + return false; + } + if (track.tpcNClsFound() < cfgCutNclusTPC) { + return false; + } + return true; + } + + float computeMassMother(const float massA, const float massB, const std::array& momA, const std::array& momB) const + { + float eA = std::hypot(massA, std::hypot(momA[0], momA[1], momA[2])); + float eB = std::hypot(massB, std::hypot(momB[0], momB[1], momB[2])); + float momTot = std::hypot(momA[0] + momB[0], momA[1] + momB[1], momA[2] + momB[2]); + float eMother = eA + eB; + return std::sqrt(eMother * eMother - momTot * momTot); + } + + template + bool buildCascade(TCasc const& casc, CollisionCandidates::iterator const& collision, aod::V0s const&, TrackCandidates const&, miniCasc& miniCasc) + { + const auto& v0 = casc.template v0_as(); + const auto& bachelor = casc.template bachelor_as(); + const auto& ptrack = v0.template posTrack_as(); + const auto& ntrack = v0.template negTrack_as(); + if (!qualityTrackSelection(ptrack) || !qualityTrackSelection(ntrack) || !qualityTrackSelection(bachelor)) { + return false; + } + const auto& protonTrack = bachelor.sign() > 0 ? ntrack : ptrack; + const auto& pionTrack = bachelor.sign() > 0 ? ptrack : ntrack; + if (std::abs(protonTrack.tpcNSigmaPr()) > 3 || std::abs(pionTrack.tpcNSigmaPi()) > 3) { + return false; + } + auto primaryVertex = getPrimaryVertex(collision); + std::array pvPos = {primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}; + + float cascCpa = -1; + float cascDauDCA = -1; + + std::array cascMom; + std::array v0Mom; + std::array bachelorMom; + + // track propagation + o2::track::TrackParCov trackParCovV0; + o2::track::TrackPar trackParV0; + o2::track::TrackPar trackParBachelor; + o2::track::TrackParCov trackParCovCasc; + if (m_fitter.process(getTrackParCov(pionTrack), getTrackParCov(protonTrack))) { + trackParCovV0 = m_fitter.createParentTrackParCov(0); // V0 track retrieved from p and pi daughters + if (m_fitter.process(trackParCovV0, getTrackParCov(bachelor))) { + trackParV0 = m_fitter.getTrackParamAtPCA(0); + trackParBachelor = m_fitter.getTrackParamAtPCA(1); + trackParV0.getPxPyPzGlo(v0Mom); + trackParBachelor.getPxPyPzGlo(bachelorMom); + trackParCovCasc = m_fitter.createParentTrackParCov(); + trackParCovCasc.getPxPyPzGlo(cascMom); + cascCpa = RecoDecay::cpa(pvPos, m_fitter.getPCACandidate(), cascMom); + cascDauDCA = std::sqrt(std::abs(m_fitter.getChi2AtPCACandidate())); + } else { + return false; + } + } else { + return false; + } + + if (cascCpa < cascsetting_cosPA) { + return false; + } + + if (cascDauDCA > cascsetting_dcaCascDaughters) { + return false; + } + + int chargeFactor = bachelor.sign() > 0 ? 1 : -1; + miniCasc.pt = chargeFactor * std::hypot(cascMom[0], cascMom[1]); + miniCasc.massOmega = computeMassMother(constants::physics::MassLambda0, constants::physics::MassKaonCharged, v0Mom, bachelorMom); + miniCasc.massXi = computeMassMother(constants::physics::MassLambda0, constants::physics::MassPionCharged, v0Mom, bachelorMom); + miniCasc.fillOmega = false; + if (TMath::Abs(miniCasc.massXi - constants::physics::MassXiMinus) > cascsetting_massWindowXi && std::abs(bachelor.tpcNSigmaKa()) < 3) { + miniCasc.fillOmega = true; + } + + miniCasc.dcaXYCasc = dcaToPV(primaryVertex, trackParCovCasc); + auto svPos = m_fitter.getPCACandidate(); + miniCasc.radius = std::hypot(svPos[0], svPos[1]); + + return true; + } + + void initCCDB(aod::BCsWithTimestamps::iterator const& bc) + { + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + auto timestamp = bc.timestamp(); + + if (o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(cfgGRPpath, timestamp)) { + o2::base::Propagator::initFieldFromGRP(grpo); + bz = grpo->getNominalL3Field(); + } else if (o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp(cfgGRPmagPath, timestamp)) { + o2::base::Propagator::initFieldFromGRP(grpmag); + bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(debug) << "bz = " << bz; + } else { + LOG(fatal) << "Got nullptr from CCDB for path " << cfgGRPmagPath << " of object GRPMagField and " << cfgGRPpath << " of object GRPObject for timestamp " << timestamp; + } + } + + void init(InitContext const&) + { + mRunNumber = 0; + bz = 0; + + if (static_cast(setting_materialCorrection.value) == o2::base::Propagator::MatCorrType::USEMatCorrLUT) { + auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); + LOG(info) << "Setting material correction LUT"; + o2::base::Propagator::Instance(true)->setMatLUT(lut); + } + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setFatalWhenNull(false); + m_fitter.setPropagateToPCA(true); + m_fitter.setMaxR(200.); + m_fitter.setMinParamChange(1e-3); + m_fitter.setMinRelChi2Change(0.9); + m_fitter.setMaxDZIni(4); + m_fitter.setMaxDXYIni(4); + m_fitter.setMaxChi2(1e9); + m_fitter.setUseAbsDCA(true); + m_fitter.setWeightedFinalPCA(false); + // int mat{static_cast(setting_materialCorrection)}; + // m_fitter.setMatCorrType(static_cast(mat)); + } + + void process(CollisionCandidates const&, aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& cascades, aod::V0s const& v0s, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) + { + + for (const auto& trackedCascade : trackedCascades) { + miniCasc miniCasc; + const auto& casc = trackedCascade.cascade(); + auto collision = trackedCascade.collision_as(); + if (!collision.sel8() || std::abs(collision.posZ()) > 10) { + continue; + } + initCCDB(collision.bc_as()); + m_fitter.setBz(bz); + if (buildCascade(casc, collision, v0s, tracks, miniCasc)) { + + // compute the dca of the tracked cascade + const auto& track = trackedCascade.track_as(); + auto trackCovTrk = getTrackParCov(track); + + auto primaryVertex = getPrimaryVertex(collision); + miniCasc.dcaXYTracked = dcaToPV(primaryVertex, trackCovTrk); + // fill the histograms + if (miniCasc.fillOmega) { + registry.fill(HIST("omegaMassTracked"), miniCasc.massOmega); + registry.fill(HIST("omegaDCAvsPtTracked"), miniCasc.pt, miniCasc.dcaXYTracked); + registry.fill(HIST("omegaHistTracked"), miniCasc.pt, miniCasc.radius, miniCasc.massOmega); + } + registry.fill(HIST("xiMassTracked"), miniCasc.massXi); + registry.fill(HIST("xiDCAvsPtTracked"), miniCasc.pt, miniCasc.dcaXYTracked); + registry.fill(HIST("xiHistTracked"), miniCasc.pt, miniCasc.radius, miniCasc.massXi); + } + } + + for (auto& cascade : cascades) { + miniCasc miniCasc; + auto collision = cascade.collision_as(); + if (!collision.sel8() || std::abs(collision.posZ()) > 10) { + continue; + } + initCCDB(collision.bc_as()); + m_fitter.setBz(bz); + if (buildCascade(cascade, collision, v0s, tracks, miniCasc)) { + if (miniCasc.fillOmega) { + registry.fill(HIST("omegaMass"), miniCasc.massOmega); + registry.fill(HIST("omegaDCAvsPt"), miniCasc.pt, miniCasc.dcaXYCasc); + registry.fill(HIST("omegaHist"), miniCasc.pt, miniCasc.radius, miniCasc.massOmega); + } + registry.fill(HIST("xiMass"), miniCasc.massXi); + registry.fill(HIST("xiDCAvsPt"), miniCasc.pt, miniCasc.dcaXYCasc); + registry.fill(HIST("xiHist"), miniCasc.pt, miniCasc.radius, miniCasc.massXi); + } + } + } +}; + +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 index f474657b95c..e2f93dbe481 100644 --- a/PWGLF/Tasks/QC/tracked_cascade_properties.cxx +++ b/PWGLF/Tasks/QC/tracked_cascade_properties.cxx @@ -37,6 +37,8 @@ #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; @@ -75,44 +77,40 @@ struct tracked_cascade_properties { Configurable maximumCascRadius{"maximumCascRadius", 18.0f, "Maximum Cascade Radius"}; // Mass Cuts - Configurable mMin_xi{"mMin_xi", 1.31f, "mMin Xi"}; - Configurable mMax_xi{"mMax_xi", 1.33f, "mMax Xi"}; - Configurable mMin_omega{"mMin_omega", 1.66f, "mMin Omega"}; - Configurable mMax_omega{"mMax_omega", 1.68f, "mMax Omega"}; + 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, 400, "#chi^{2}_{matching}"}}); - registryQC.add("topologyChi2", "topology Chi2", HistType::kTH1F, {{200, 0, 20, "#chi^{2}_{topology}"}}); - registryQC.add("nITS_Xi", "nITS Xi", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); - registryQC.add("nITS_Omega", "nITS Omega", HistType::kTH2F, {{100, 0, 10, "#it{p} (GeV/#it{c})"}, {8, 0, 8, "n_{ITS}^{cls}"}}); - registryQC.add("tgl_Distr", "tgl_Distr", HistType::kTH1F, {{200, 0, 200, "tan (#lambda)"}}); - registryQC.add("nITSclusters", "nITSclusters", HistType::kTH1F, {{7, 0, 7, "n_{cls}^{ITS}"}}); - registryQC.add("clusterSize", "clusterSize", HistType::kTH1F, {{200, 0, 200, "cluster size ITS"}}); - registryQC.add("decayXY", "decayXY", HistType::kTH2F, {{200, -50, 50, "x"}, {200, -50, 50, "y"}}); - registryQC.add("signBachelor", "signBachelor", HistType::kTH1F, {{4, -2, 2, "sign"}}); - registryQC.add("ITSclusterSizeTrkCasc", "ITSclusterSizeTrkCasc", HistType::kTH1F, {{200, 0, 20, "ITS cluster Size"}}); + 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_clustersize", "xi_pos_clustersize", HistType::kTH3F, {{100, 0.0, 100, "ITS cluster size"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("xi_neg_clustersize", "xi_neg_clustersize", HistType::kTH3F, {{100, 0.0, 100, "ITS cluster size"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_pos_clustersize", "omega_pos_clustersize", HistType::kTH3F, {{100, 0.0, 100, "ITS cluster size"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_neg_clustersize", "omega_neg_clustersize", HistType::kTH3F, {{100, 0.0, 100, "ITS cluster size"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - - registryData.add("xi_pos_avgclustersize", "xi_pos_avgclustersize", HistType::kTH3F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("xi_neg_avgclustersize", "xi_neg_avgclustersize", HistType::kTH3F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_pos_avgclustersize", "omega_pos_avgclustersize", HistType::kTH3F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - registryData.add("omega_neg_avgclustersize", "omega_neg_avgclustersize", HistType::kTH3F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}, {16, -0.8, 0.8, "#eta"}}); - - registryData.add("xi_pos_avgclustersize_cosL", "xi_pos_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("xi_neg_avgclustersize_cosL", "xi_neg_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("omega_pos_avgclustersize_cosL", "omega_pos_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("omega_neg_avgclustersize_cosL", "omega_neg_avgclustersize_cosL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT cos(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - - registryData.add("xi_pos_avgclustersize_sinL", "xi_pos_avgclustersize_sinL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT sin(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("xi_neg_avgclustersize_sinL", "xi_neg_avgclustersize_sinL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT sin(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("omega_pos_avgclustersize_sinL", "omega_pos_avgclustersize_sinL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT sin(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); - registryData.add("omega_neg_avgclustersize_sinL", "omega_neg_avgclustersize_sinL", HistType::kTH2F, {{100, 0.0, 20.0, "#LT ITS cluster size #GT sin(#lambda)"}, {100, 0.0, 10.0, "#it{p} (GeV/#it{c})"}}); + 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})"}}); @@ -120,6 +118,17 @@ struct tracked_cascade_properties { 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&) { @@ -135,7 +144,17 @@ struct tracked_cascade_properties { for (const auto& trackedCascade : trackedCascades) { - const auto track = trackedCascade.itsTrack_as(); + 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(); @@ -146,70 +165,69 @@ struct tracked_cascade_properties { registryQC.fill(HIST("matchingChi2"), trackedCascade.matchingChi2()); registryQC.fill(HIST("topologyChi2"), trackedCascade.topologyChi2()); - registryQC.fill(HIST("nITSclusters"), track.itsNCls()); - registryQC.fill(HIST("ITSclusterSizeTrkCasc"), trackedCascade.itsClsSize()); registryQC.fill(HIST("decayXY"), dx, dy); - registryQC.fill(HIST("signBachelor"), btrack.sign()); // Calculate (Average) Cluster Size - int clusterSize[7]; double averageClusterSize(0); + int nCls(0); for (int i = 0; i < 7; i++) { - clusterSize[i] = track.itsClsSizeInLayer(i); - registryQC.fill(HIST("clusterSize"), clusterSize[i]); - averageClusterSize += static_cast(clusterSize[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()); } - averageClusterSize = averageClusterSize / static_cast(track.itsNCls()); // Track Inclination - registryQC.fill(HIST("tgl_Distr"), track.tgl()); - double lambda = atan(track.tgl()); - double cosL = cos(lambda); - double sinL = sin(lambda); + double lambda = track_inclination(track.eta()); // Xi if (trackedCascade.xiMass() > mMin_xi && trackedCascade.xiMass() < mMax_xi) { - registryQC.fill(HIST("nITS_Xi"), track.p(), track.itsNCls()); + registryQC.fill(HIST("nITScls_vs_p_xi"), track.p(), trackITS.itsNCls()); if (btrack.sign() > 0) { - for (int i = 0; i < 7; i++) { - registryData.fill(HIST("xi_pos_clustersize"), clusterSize[i], track.p(), track.eta()); - } - registryData.fill(HIST("xi_pos_avgclustersize"), averageClusterSize, track.p(), track.eta()); - registryData.fill(HIST("xi_pos_avgclustersize_cosL"), averageClusterSize * cosL, track.p()); - registryData.fill(HIST("xi_pos_avgclustersize_sinL"), averageClusterSize * sinL, track.p()); - registryData.fill(HIST("xi_mass_pos"), track.p(), trackedCascade.xiMass()); + 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) { - for (int i = 0; i < 7; i++) { - registryData.fill(HIST("xi_neg_clustersize"), clusterSize[i], track.p(), track.eta()); - } - registryData.fill(HIST("xi_neg_avgclustersize"), averageClusterSize, track.p(), track.eta()); - registryData.fill(HIST("xi_neg_avgclustersize_cosL"), averageClusterSize * cosL, track.p()); - registryData.fill(HIST("xi_neg_avgclustersize_sinL"), averageClusterSize * sinL, track.p()); - registryData.fill(HIST("xi_mass_neg"), track.p(), trackedCascade.xiMass()); + 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("nITS_Omega"), track.p(), track.itsNCls()); + registryQC.fill(HIST("nITScls_vs_p_omega"), track.p(), trackITS.itsNCls()); if (btrack.sign() > 0) { - for (int i = 0; i < 7; i++) { - registryData.fill(HIST("omega_pos_clustersize"), clusterSize[i], track.p(), track.eta()); - } - registryData.fill(HIST("omega_pos_avgclustersize"), averageClusterSize, track.p(), track.eta()); - registryData.fill(HIST("omega_pos_avgclustersize_cosL"), averageClusterSize * cosL, track.p()); - registryData.fill(HIST("omega_pos_avgclustersize_sinL"), averageClusterSize * sinL, track.p()); - registryData.fill(HIST("omega_mass_pos"), track.p(), trackedCascade.omegaMass()); + 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) { - for (int i = 0; i < 7; i++) { - registryData.fill(HIST("omega_neg_clustersize"), clusterSize[i], track.p(), track.eta()); - } - registryData.fill(HIST("omega_neg_avgclustersize"), averageClusterSize, track.p(), track.eta()); - registryData.fill(HIST("omega_neg_avgclustersize_cosL"), averageClusterSize * cosL, track.p()); - registryData.fill(HIST("omega_neg_avgclustersize_sinL"), averageClusterSize * sinL, track.p()); - registryData.fill(HIST("omega_mass_neg"), track.p(), trackedCascade.omegaMass()); + 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)); } } } diff --git a/PWGLF/Tasks/QC/vertexQA.cxx b/PWGLF/Tasks/QC/vertexQA.cxx index 5e9060d51ce..66ae298813d 100644 --- a/PWGLF/Tasks/QC/vertexQA.cxx +++ b/PWGLF/Tasks/QC/vertexQA.cxx @@ -9,14 +9,18 @@ // 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 "CCDB/BasicCCDBManager.h" +#include "Common/CCDB/ctpRateFetcher.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" using namespace o2; using namespace o2::framework; @@ -34,7 +38,7 @@ double deltaTimeColl(BCcoll const bccoll1, BCcoll const bccoll2) auto coll2 = std::get(bccoll2); auto bc1 = std::get(bccoll1); auto bc2 = std::get(bccoll2); - int64_t tmpDT = int64_t(bc1.globalBC()) - int64_t(bc2.globalBC()); + int64_t tmpDT = static_cast(bc1.globalBC()) - static_cast(bc2.globalBC()); double deltaT = tmpDT * LHCBunchSpacingNS + coll1.collisionTime() - coll2.collisionTime(); return deltaT; } @@ -57,6 +61,9 @@ DECLARE_SOA_TABLE(VtxQAtable, "AOD", "VTXQATABLE", } // namespace o2::aod struct vertexQA { + Service ccdb; + ctpRateFetcher mRateFetcher; + Produces vtxQAtable; Configurable storeTree{"storeTree", 1000, "Store in tree collisions from BC's with more than 'storeTree' vertices, for in-depth analysis"}; @@ -87,10 +94,15 @@ struct vertexQA { ConfigurableAxis nContribAxis{"nContribBins", {1000, 0, 5000}, "Binning for number of contributors to PV"}; ConfigurableAxis nContribDiffAxis{"nContribDiffBins", {1000, -5000, 5000}, "Binning for the difference in number of contributors to PV"}; + ConfigurableAxis irBinning{"IRbinning", {500, 0, 100}, "Binning for the interaction rate (kHz)"}; + Configurable irSource{"irSource", "ZNC hadronic", "Source of the interaction rate"}; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; std::deque colls; + int64_t mFirstBCid = -1; + void init(InitContext const&) { histos.add("nVtxHistogram", ";#it{N}_{vtx}^{rec};Entries", HistType::kTH1F, {nVtxAxis}); @@ -121,6 +133,11 @@ struct vertexQA { histos.add("nContribITSRofTimeSeriesHistogram", ";#it{N}_{contrib}^{1};#it{N}_{contrib}^{2}", HistType::kTH2F, {nContribAxis, nContribAxis}); histos.add("tDiffDuplicateTimeSeriesHistogram", ";#Delta#it{t}_{vtx} (ns);Entries", HistType::kTH1F, {tDiffVtxAxisExtend}); + histos.add("tIRvsCollisionRateHistogram", Form(";IR from %s (kHz);IR from reconstructed vertices (kHz)", irSource.value.data()), HistType::kTH2D, {irBinning, irBinning}); + + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setFatalWhenNull(false); } void process(aod::BC const& bc, aod::Collisions const& collisions) @@ -231,6 +248,48 @@ struct vertexQA { } } } + PROCESS_SWITCH(vertexQA, process, "Standard vertex QA", true); + + void processIR(aod::BCsWithTimestamps const& bcs, aod::Collisions const& collisions) + { + if (collisions.size() <= 2) { + return; + } + + std::vector jumps{0ll}; + int64_t lastBC = bcs.rawIteratorAt(0).globalBC(); + for (auto bc : bcs) { + if (bc.globalBC() - lastBC > 3564 * 32) { // 32 orbits + jumps.push_back(bc.globalIndex()); + lastBC = bc.globalBC(); + } + } + uint64_t jumpsSentinel{1}; + std::vector collisionsIndices{0ll}; + for (auto col : collisions) { + if (jumpsSentinel == jumps.size()) { + break; + } + if (col.bcId() > jumps[jumpsSentinel]) { + collisionsIndices.push_back(col.globalIndex()); + jumpsSentinel++; + } + } + jumps.push_back(bcs.size()); + collisionsIndices.push_back(collisions.size()); + + for (size_t i{0}; i < jumps.size() - 1; ++i) { + auto startBC = bcs.rawIteratorAt(jumps[i]); + auto endBC = bcs.rawIteratorAt(jumps[i + 1] - 1); + double startIR = mRateFetcher.fetch(ccdb.service, startBC.timestamp(), startBC.runNumber(), irSource.value); + double endIR = mRateFetcher.fetch(ccdb.service, endBC.timestamp(), endBC.runNumber(), irSource.value); + double deltaT = (endBC.globalBC() - startBC.globalBC()) * LHCBunchSpacingNS * 1.e-9; + double collisionRate = (collisionsIndices[i + 1] - collisionsIndices[i]) / deltaT; /// -1 to remove the bias of the collisions at extremities? + double ir = (startIR + endIR) * 0.5; + histos.fill(HIST("tIRvsCollisionRateHistogram"), ir * 1.e-3, collisionRate * 1.e-3); + } + } + PROCESS_SWITCH(vertexQA, processIR, "Checks on interaction rate", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Resonances/CMakeLists.txt b/PWGLF/Tasks/Resonances/CMakeLists.txt index dbcbf6b1d37..e6f7b573f2e 100644 --- a/PWGLF/Tasks/Resonances/CMakeLists.txt +++ b/PWGLF/Tasks/Resonances/CMakeLists.txt @@ -24,6 +24,16 @@ o2physics_add_dpl_workflow(k892analysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(k892analysispbpb + SOURCES k892analysis_PbPb.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(kstar892analysis + SOURCES kstar892analysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(k892pmanalysis SOURCES k892pmanalysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -49,6 +59,11 @@ o2physics_add_dpl_workflow(f0980analysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(f0980pbpbanalysis + SOURCES f0980pbpbanalysis.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(lambda1520spherocityanalysis SOURCES lambda1520SpherocityAnalysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -124,6 +139,11 @@ o2physics_add_dpl_workflow(xi1530analysis PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(xi1530analysisqa + SOURCES xi1530Analysisqa.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(kaonkaonanalysis SOURCES kaonkaonanalysis.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore @@ -138,3 +158,8 @@ o2physics_add_dpl_workflow(lambdav2 SOURCES lambdav2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(highmasslambdasvx + SOURCES highmasslambdasvx.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Resonances/KshortKshort.cxx b/PWGLF/Tasks/Resonances/KshortKshort.cxx index 44ec7740f62..69e967b2d94 100644 --- a/PWGLF/Tasks/Resonances/KshortKshort.cxx +++ b/PWGLF/Tasks/Resonances/KshortKshort.cxx @@ -21,17 +21,22 @@ #include #include #include -#include "TF1.h" - #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" // @@ -42,9 +47,6 @@ #include "Framework/AnalysisTask.h" // #include "Framework/runDataProcessing.h" // #include "PWGLF/DataModel/LFStrangenessTables.h" // -#include "Framework/O2DatabasePDGPlugin.h" -// #include "CommonConstants/PhysicsConstants.h" -// #include "Framework/HistogramRegistry.h" using namespace o2; using namespace o2::framework; @@ -55,17 +57,20 @@ using std::array; struct strangeness_tutorial { SliceCache cache; - HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry rKzeroShort{"kzeroShort", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry hglue{"hglueball", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; Configurable QAv0{"QAv0", false, "QAv0"}; - Configurable QAPID{"QAPID", false, "QAPID"}; + Configurable QAPID{"QAPID", true, "QAPID"}; Configurable QAv0_daughters{"QAv0_daughters", false, "QA of v0 daughters"}; + Configurable QAevents{"QAevents", false, "QA of events"}; Configurable inv_mass1D{"inv_mass1D", false, "1D invariant mass histograms"}; + Configurable correlation2Dhist{"correlation2Dhist", true, "Lamda K0 mass correlation"}; Configurable DCAv0topv{"DCAv0topv", 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)"}; @@ -75,19 +80,17 @@ struct strangeness_tutorial { 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 daughters + // Configurable parameters for V0 selection Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 1.0f, "DCA b/w 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 ConfDaughEta{"ConfDaughEta", 0.8f, "V0 Daugh sel: max eta"}; - Configurable ConfDaughTPCnclsMin{"ConfDaughTPCnclsMin", 70.f, "V0 Daugh sel: Min. nCls TPC"}; - Configurable ConfTPCnsimacutpi{"ConfTPCnsimacutpi", 5, "PID selections for KS0 daughters"}; - Configurable ConfKsrapidity{"ConfKsrapidity", 0.5f, "Rapidity cut on K0s"}; + 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 parameters for V0 selection - Configurable cMaxV0DCA{"cMaxV0DCA", 1, "DCA V0 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"}; @@ -95,10 +98,14 @@ struct strangeness_tutorial { 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 isStandarv0{"isStandarv0", false, "Standard V0"}; // Configurable for track selection and multiplicity Configurable cfgPTcut{"cfgPTcut", 0.2f, "Track PT cut"}; @@ -106,24 +113,37 @@ struct strangeness_tutorial { 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"}; + // 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 c_nof_rotations{"c_nof_rotations", 3, "Number of random rotations in the rotational background"}; + // Other cuts on Ks and glueball Configurable rapidityks{"rapidityks", true, "rapidity cut on K0s"}; - Configurable CompetingCascadeRejection{"CompetingCascadeRejection", false, "mass under lambda hypothesis"}; - Configurable LambdaRejectionCut{"LambdaRejectionCut", 4.3, "rejecting competing cascade lambda (MeV)"}; - Configurable AntiLambdaRejectionCut{"AntiLambdaRejectionCut", 4.3, "rejecting competing cascade anti-lambda (MeV)"}; + Configurable apply_competingcut{"apply_competingcut", 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", 15.0f, "Maximum pT"}; - Configurable cPtBins{"cPtBins", 150, "Number of pT bins"}; + Configurable cPtMax{"cPtMax", 50.0f, "Maximum pT"}; + Configurable cPtBins{"cPtBins", 500, "Number of pT bins"}; Configurable cMassMin{"cMassMin", 0.9f, "Minimum mass of glueball"}; - Configurable cMassMax{"cMassMax", 2.4f, "Maximum mass of glueball"}; - Configurable cMassBins{"cMassBins", 150, "Number of mass bins for 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 rotational_cut{"rotational_cut", 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 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"}; // Event selection cuts - Alex (Temporary, need to fix!) TF1* fMultPVCutLow = nullptr; @@ -131,39 +151,84 @@ struct strangeness_tutorial { TF1* fMultCutLow = nullptr; TF1* fMultCutHigh = nullptr; TF1* fMultMultPVCut = nullptr; - - // to get the particle masses - Service pdgDB; // pdg database + Service PDGdatabase; + TRandom* rn = new TRandom(); void init(InitContext const&) { // 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 vertexZAxis = {100, -15.f, 15.f, "vrtx_{Z} [cm]"}; // for histogram + 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 occupancy_axis = {occupancy_bins, "Occupancy [-40,100]"}; + + // THnSparses + std::array sparses = {activateTHnSparseCosThStarHelicity, activateTHnSparseCosThStarProduction, activateTHnSparseCosThStarBeam, activateTHnSparseCosThStarRandom}; + + // std::array sparses = {activateTHnSparseCosThStarHelicity}; + + if (std::accumulate(sparses.begin(), sparses.end(), 0) == 0) { + LOGP(fatal, "No output THnSparses enabled"); + } else { + if (activateTHnSparseCosThStarHelicity) { + LOGP(info, "THnSparse with cosThStar w.r.t. helicity axis active."); + } + if (activateTHnSparseCosThStarProduction) { + LOGP(info, "THnSparse with cosThStar w.r.t. production axis active."); + } + if (activateTHnSparseCosThStarBeam) { + LOGP(info, "THnSparse with cosThStar w.r.t. beam axis active. (Gottified jackson frame)"); + } + if (activateTHnSparseCosThStarRandom) { + LOGP(info, "THnSparse with cosThStar w.r.t. random axis active."); + } + } - // Histograms // Event selection - rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hmultiplicity", "hmultiplicity", {HistType::kTH1F, {{150, 0.0f, 150.0f}}}); + if (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 (inv_mass1D) { hglue.add("h1glueInvMassDS", "h1glueInvMassDS", kTH1F, {glueballMassAxis}); hglue.add("h1glueInvMassME", "h1glueInvMassME", kTH1F, {glueballMassAxis}); + hglue.add("h1glueInvMassRot", "h1glueInvMassRot", kTH1F, {glueballMassAxis}); } - hglue.add("h3glueInvMassDS", "h3glueInvMassDS", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis}, true); - hglue.add("h3glueInvMassME", "h3glueInvMassME", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis}, true); - hglue.add("h3glueInvMassRot", "h3glueInvMassRot", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis}, true); - hglue.add("heventscheck", "heventscheck", kTH1F, {{9, 0, 9}}); - hglue.add("hmasscorrelation", "hmasscorrelation", kTH2F, {K0ShortMassAxis, K0ShortMassAxis}); + + hglue.add("h3glueInvMassDS", "h3glueInvMassDS", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancy_axis}, true); + hglue.add("h3glueInvMassME", "h3glueInvMassME", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancy_axis}, true); + hglue.add("h3glueInvMassRot", "h3glueInvMassRot", kTHnSparseF, {multiplicityAxis, ptAxis, glueballMassAxis, thnAxisPOL, occupancy_axis}, 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) { + 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_after10", "mass under lambda hypotheses and Kshort mass", kTH2F, {{100, 0.2, 0.8}, {100, 0.9, 1.5}}); + } if (QAv0) { // Invariant Mass rKzeroShort.add("hMassK0Shortbefore", "hMassK0Shortbefore", kTHnSparseF, {K0ShortMassAxis, ptAxis}); + rKzeroShort.add("hMasscorrelationbefore", "hMasscorrelationbefore", kTH2F, {K0ShortMassAxis, K0ShortMassAxis}); rKzeroShort.add("hMassK0ShortSelected", "hMassK0ShortSelected", kTHnSparseF, {K0ShortMassAxis, ptAxis}); // Topological histograms (after the selection) rKzeroShort.add("hDCAV0Daughters", "DCA between v0 daughters", {HistType::kTH1F, {{60, -3.0f, 3.0f}}}); @@ -172,6 +237,7 @@ struct strangeness_tutorial { 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}}); @@ -180,8 +246,9 @@ struct strangeness_tutorial { rKzeroShort.add("hDCAnegtopv", "DCA negative daughter to PV", kTH1F, {{1000, -10.0f, 10.0f}}); rKzeroShort.add("hDCAv0topv", "DCA V0 to PV", kTH1F, {{60, -3.0f, 3.0f}}); rKzeroShort.add("halpha", "Armenteros alpha", kTH1F, {{100, -5.0f, 5.0f}}); - rKzeroShort.add("hqtarm", "qtarm", kTH1F, {{100, 0.0f, 1.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}}); // // Topological histograms (before the selection) // rKzeroShort.add("hDCAV0Daughters_before", "DCA between v0 daughters before the selection", {HistType::kTH1F, {{60, -3.0f, 3.0f}}}); @@ -190,9 +257,10 @@ struct strangeness_tutorial { } if (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("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 (QAv0_daughters) { rKzeroShort.add("negative_pt", "Negative daughter pT", kTH1F, {ptAxis}); @@ -201,8 +269,6 @@ struct strangeness_tutorial { 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("negative_y", "Negative daughter y", kTH1F, {{100, -1.0f, 1.0f}}); - rKzeroShort.add("positive_y", "Positive daughter y", kTH1F, {{100, -1.0f, 1.0f}}); } 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,96 +287,42 @@ struct strangeness_tutorial { template bool eventselection(Collision const& collision, const float& multiplicity) { - if (!collision.sel8()) { + hglue.fill(HIST("heventscheck"), 1.5); + + if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { return false; } - if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + hglue.fill(HIST("heventscheck"), 2.5); + + if (!collision.sel8()) { return false; } + 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 (itstpctracks && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { return false; } - // if (collision.alias_bit(kTVXinTRD)) { - // // TRD triggered - // // return 0; - // } + hglue.fill(HIST("heventscheck"), 6.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; } - // if (multTrk < fMultCutLow->Eval(multiplicity)) - // return 0; - // if (multTrk > fMultCutHigh->Eval(multiplicity)) - // return 0; - // if (multTrk > fMultMultPVCut->Eval(multNTracksPV)) - // return 0; - return true; - } - - template - bool SelectionV0Daughter(T const& track, float charge, - double nsigmaV0Daughter, V0s const& /*candidate*/) - { - if (QAPID) { - // Filling the PID of the V0 daughters in the region of the K0 peak. - // tpcInnerParam is the momentum at the inner wall of TPC. So momentum of tpc vs nsigma of tpc is plotted. - // if (0.45 < candidate.mK0Short() && candidate.mK0Short() < 0.55) { - (charge == 1) ? rKzeroShort.fill(HIST("hNSigmaPosPionK0s_before"), track.tpcInnerParam(), track.tpcNSigmaPi()) : rKzeroShort.fill(HIST("hNSigmaNegPionK0s_before"), track.tpcInnerParam(), track.tpcNSigmaPi()); - // } - } - const auto eta = track.eta(); - const auto tpcNClsF = track.tpcNClsFound(); - // const auto dcaXY = track.dcaXY(); // for this we need TrackDCA table - const auto sign = track.sign(); - - if (!track.hasTPC()) - return false; - if (track.tpcNClsCrossedRows() < tpcCrossedrows) - return false; - if (track.tpcCrossedRowsOverFindableCls() < tpcCrossedrowsOverfcls) - return false; - - 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(dcaXY) < ConfDaughDCAMin) { - // return false; - // } - // v0 PID selection - if (std::abs(nsigmaV0Daughter) > ConfTPCnsimacutpi) { - return false; - } - - if (QAPID) { - // if (0.45 < candidate.mK0Short() && candidate.mK0Short() < 0.55) { - (charge == 1) ? rKzeroShort.fill(HIST("hNSigmaPosPionK0s_after"), track.tpcInnerParam(), track.tpcNSigmaPi()) : rKzeroShort.fill(HIST("hNSigmaNegPionK0s_after"), track.tpcInnerParam(), track.tpcNSigmaPi()); - // } - } - - if (QAv0_daughters) { - (charge == 1) ? rKzeroShort.fill(HIST("positive_pt"), track.pt()) : rKzeroShort.fill(HIST("negative_pt"), track.pt()); - (charge == 1) ? rKzeroShort.fill(HIST("positive_eta"), track.eta()) : rKzeroShort.fill(HIST("negative_eta"), track.eta()); - (charge == 1) ? rKzeroShort.fill(HIST("positive_phi"), track.phi()) : rKzeroShort.fill(HIST("negative_phi"), track.phi()); - (charge == 1) ? rKzeroShort.fill(HIST("positive_y"), track.y()) : rKzeroShort.fill(HIST("negative_y"), track.y()); - } + hglue.fill(HIST("heventscheck"), 8.5); return true; } @@ -326,14 +338,15 @@ struct strangeness_tutorial { const float tranRad = candidate.v0radius(); const float dcaDaughv0 = candidate.dcaV0daughters(); const float cpav0 = candidate.v0cosPA(); - auto pdgmasslambda = pdgDB->GetParticle(3122)->Mass(); - float CtauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * pdgDB->GetParticle(310)->Mass(); + + float CtauK0s = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * PDGdatabase->Mass(310); 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 (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()); @@ -348,50 +361,152 @@ struct strangeness_tutorial { rKzeroShort.fill(HIST("hDCAnegtopv"), candidate.dcanegtopv()); rKzeroShort.fill(HIST("hDCAv0topv"), candidate.dcav0topv()); rKzeroShort.fill(HIST("halpha"), candidate.alpha()); - rKzeroShort.fill(HIST("hqtarm"), candidate.qtarm()); + rKzeroShort.fill(HIST("hqtarmbyalpha"), arm); rKzeroShort.fill(HIST("hpsipair"), candidate.psipair()); } + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_before"), candidate.mK0Short(), candidate.mLambda()); + + hglue.fill(HIST("htrackscheck_v0"), 0.5); - if (!DCAv0topv && fabs(candidate.dcav0topv()) > cMaxV0DCA) { + if (DCAv0topv && fabs(candidate.dcav0topv()) > cMaxV0DCA) { return false; } + hglue.fill(HIST("htrackscheck_v0"), 1.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after1"), candidate.mK0Short(), candidate.mLambda()); if (rapidityks && TMath::Abs(candidate.yK0Short()) >= ConfKsrapidity) { return false; } - if (CompetingCascadeRejection && (TMath::Abs(candidate.mLambda() - pdgmasslambda) <= LambdaRejectionCut * 1e-3 || TMath::Abs(candidate.mAntiLambda() - pdgmasslambda) <= AntiLambdaRejectionCut * 1e-3)) { - return false; - } - // std::cout<<"candidate.mLambda() = "< ConfV0DCADaughMax) { return false; } + hglue.fill(HIST("htrackscheck_v0"), 4.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after4"), candidate.mK0Short(), candidate.mLambda()); + if (cpav0 < ConfV0CPAMin) { return false; } + hglue.fill(HIST("htrackscheck_v0"), 5.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after5"), candidate.mK0Short(), candidate.mLambda()); + if (tranRad < ConfV0TranRadV0Min) { return false; } + hglue.fill(HIST("htrackscheck_v0"), 6.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after6"), candidate.mK0Short(), candidate.mLambda()); + if (tranRad > ConfV0TranRadV0Max) { return false; } - if (fabs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { + hglue.fill(HIST("htrackscheck_v0"), 7.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after7"), candidate.mK0Short(), candidate.mLambda()); + + if (fabs(CtauK0s) > cMaxV0LifeTime) { + return false; + } + hglue.fill(HIST("htrackscheck_v0"), 8.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after8"), candidate.mK0Short(), candidate.mLambda()); + + if (armcut && arm < Confarmcut) { return false; } - if (!armcut && arm < Confarmcut) { + hglue.fill(HIST("htrackscheck_v0"), 9.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after9"), candidate.mK0Short(), candidate.mLambda()); + + if (apply_competingcut && (TMath::Abs(candidate.mLambda() - PDGdatabase->Mass(3122)) <= competingcascrejlambda || TMath::Abs(candidate.mAntiLambda() - PDGdatabase->Mass(-3122)) <= competingcascrejlambdaanti)) { return false; } + hglue.fill(HIST("htrackscheck_v0"), 10.5); + if (correlation2Dhist) + rKzeroShort.fill(HIST("mass_lambda_kshort_after10"), candidate.mK0Short(), candidate.mLambda()); if (QAv0) { rKzeroShort.fill(HIST("hMassK0ShortSelected"), candidate.mK0Short(), candidate.pt()); + // rKzeroShort.fill(HIST("mass_lambda_kshort_after"), candidate.mK0Short(), candidate.mLambda()); + } + + if (candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { + return false; + } + return true; + } + + template + bool isSelectedV0Daughter(T const& track, float charge, double nsigmaV0Daughter, V0s const& /*candidate*/) + { + if (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()); + } + const auto eta = track.eta(); + const auto tpcNClsF = track.tpcNClsFound(); + const auto sign = track.sign(); + + hglue.fill(HIST("htrackscheck_v0_daughters"), 0.5); + + if (hasTPC && !track.hasTPC()) + return false; + hglue.fill(HIST("htrackscheck_v0_daughters"), 1.5); + + if (!globalTracks) { + if (track.tpcNClsCrossedRows() < tpcCrossedrows) + return false; + hglue.fill(HIST("htrackscheck_v0_daughters"), 2.5); + + if (track.tpcCrossedRowsOverFindableCls() < tpcCrossedrowsOverfcls) + return false; + hglue.fill(HIST("htrackscheck_v0_daughters"), 3.5); + + if (tpcNClsF < ConfDaughTPCnclsMin) { + return false; + } + hglue.fill(HIST("htrackscheck_v0_daughters"), 4.5); + } else { + if (!track.isGlobalTrack()) + return false; + hglue.fill(HIST("htrackscheck_v0_daughters"), 4.5); + } + + if (charge < 0 && sign > 0) { + return false; + } + hglue.fill(HIST("htrackscheck_v0_daughters"), 5.5); + + if (charge > 0 && sign < 0) { + return false; + } + hglue.fill(HIST("htrackscheck_v0_daughters"), 6.5); + + if (std::abs(eta) > ConfDaughEta) { + return false; + } + hglue.fill(HIST("htrackscheck_v0_daughters"), 7.5); + + if (std::abs(nsigmaV0Daughter) > ConfDaughPIDCuts) { + return false; } + hglue.fill(HIST("htrackscheck_v0_daughters"), 8.5); + return true; } @@ -414,10 +529,12 @@ struct strangeness_tutorial { // soa::Filtered const& V0s, // DaughterTracks const&) + ROOT::Math::PxPyPzMVector daughter1, daughter2; + ROOT::Math::PxPyPzMVector lv3; void processSE(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::V0Datas const& V0s) { hglue.fill(HIST("heventscheck"), 0.5); - const double massK0s = pdgDB->GetParticle(310)->Mass(); + const double massK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); float multiplicity = 0.0f; if (cfgMultFOTM) { multiplicity = collision.centFT0M(); @@ -428,14 +545,23 @@ struct strangeness_tutorial { return; } - hglue.fill(HIST("heventscheck"), 1.5); + auto occupancy_no = collision.trackOccupancyInTimeRange(); + if (applyOccupancyCut && occupancy_no < OccupancyCut) { + return; + } - rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); - rEventSelection.fill(HIST("hmultiplicity"), multiplicity); + if (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()); + } - for (auto& [v1, v2] : combinations(CombinationsStrictlyUpperIndexPolicy(V0s, V0s))) { + std::vector v0indexes; - hglue.fill(HIST("heventscheck"), 2.5); + for (auto& [v1, v2] : combinations(CombinationsUpperIndexPolicy(V0s, V0s))) { if (v1.size() == 0 || v2.size() == 0) { continue; @@ -453,54 +579,129 @@ struct strangeness_tutorial { auto postrack2 = v2.template posTrack_as(); auto negtrack2 = v2.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 (!SelectionV0Daughter(postrack1, 1, nTPCSigmaPos1, v1)) { + 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 (!SelectionV0Daughter(postrack2, 1, nTPCSigmaPos2, v2)) { + + if (QAv0_daughters) { + 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 (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, v1)) { + // continue; + // } + // if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, v2)) { + // continue; + // } + + if (!(std::find(v0indexes.begin(), v0indexes.end(), v1.globalIndex()) != v0indexes.end())) { + v0indexes.push_back(v1.globalIndex()); + } + // 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 (v1.globalIndex() == v2.globalIndex()) { continue; } - if (!SelectionV0Daughter(negtrack1, -1, nTPCSigmaNeg1, v1)) { + + if (postrack1.globalIndex() == postrack2.globalIndex()) { continue; } - if (!SelectionV0Daughter(negtrack2, -1, nTPCSigmaNeg2, v2)) { + if (negtrack1.globalIndex() == negtrack2.globalIndex()) { continue; } - hglue.fill(HIST("heventscheck"), 3.5); + TLorentzVector lv1, lv2, lv3, lv4, lv5; - TLorentzVector lv1, lv2, lv3, lv4, lv5, lv6, lv7; lv1.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi(), massK0s); + lv2.SetPtEtaPhiM(v2.pt(), v2.eta(), v2.phi(), massK0s); + lv3 = lv1 + lv2; - lv4.SetPtEtaPhiM(v1.pt(), v1.eta(), v1.phi() + TMath::Pi(), massK0s); // for rotated background - lv5.SetPtEtaPhiM(v2.pt(), v2.eta(), v2.phi() + TMath::Pi(), massK0s); // for rotated background - lv6 = lv1 + lv5; // rotating one of the daughters - lv7 = lv2 + lv4; + + daughter1 = ROOT::Math::PxPyPzMVector(v1.px(), v1.py(), v1.pz(), massK0s); // Kplus + daughter2 = ROOT::Math::PxPyPzMVector(v2.px(), v2.py(), v2.pz(), massK0s); // Kminus + + // 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 if (TMath::Abs(lv3.Rapidity() < 0.5)) { + if (inv_mass1D) { - hglue.fill(HIST("h1glueInvMassDS"), lv3.M()); + hglue.fill(HIST("h1glueInvMassRot"), lv3.M()); } - hglue.fill(HIST("h3glueInvMassDS"), multiplicity, lv3.Pt(), lv3.M()); - hglue.fill(HIST("hmasscorrelation"), v1.mK0Short(), v2.mK0Short()); - std::cout << "The value of mass of first daughter is: " << lv1.M() << std::endl; - std::cout << "The value of mass of second daughter is: " << lv2.M() << std::endl; - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv6.Pt(), lv6.M()); // rotating one of the daughters - hglue.fill(HIST("h3glueInvMassRot"), multiplicity, lv7.Pt(), lv7.M()); // rotating one of the daughters + 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, occupancy_no); + 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); + 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, occupancy_no); + } + + } 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, occupancy_no); + 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); + 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, occupancy_no); + } + } 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, occupancy_no); + 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); + 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, occupancy_no); + } + } 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, occupancy_no); + 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); + 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, occupancy_no); + } + } } } + if (QAv0) { + int sizeofv0indexes = v0indexes.size(); + rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes); + // std::cout << "Size of v0indexes: " << sizeofv0indexes << std::endl; + } } PROCESS_SWITCH(strangeness_tutorial, processSE, "same event process", true); @@ -514,9 +715,8 @@ struct strangeness_tutorial { void processME(EventCandidates const& collisions, TrackCandidates const& /*tracks*/, V0TrackCandidate const& v0s) { - hglue.fill(HIST("heventscheck"), 4.5); - const double massK0s = pdgDB->GetParticle(310)->Mass(); + const double massK0s = TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(); auto tracksTuple = std::make_tuple(v0s); BinningTypeVertexContributor binningOnPositions1{{mevz, memult}, true}; BinningTypeCentralityM binningOnPositions2{{mevz, memult}, true}; @@ -527,18 +727,21 @@ struct strangeness_tutorial { if (cfgMultFOTM) { for (auto& [c1, tracks1, c2, tracks2] : pair2) // two different centrality c1 and c2 and tracks corresponding to them { - hglue.fill(HIST("heventscheck"), 5.5); float multiplicity = 0.0f; + multiplicity = c1.centFT0M(); if (!eventselection(c1, multiplicity) || !eventselection(c2, multiplicity)) { continue; } - hglue.fill(HIST("heventscheck"), 6.5); + auto occupancy_no = c1.trackOccupancyInTimeRange(); + auto occupancy_no2 = c2.trackOccupancyInTimeRange(); + if (applyOccupancyCut && (occupancy_no < OccupancyCut || occupancy_no2 < OccupancyCut)) { + return; + } for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - hglue.fill(HIST("heventscheck"), 7.5); if (t1.size() == 0 || t2.size() == 0) { continue; @@ -564,31 +767,60 @@ struct strangeness_tutorial { double nTPCSigmaPos2{postrack2.tpcNSigmaPi()}; double nTPCSigmaNeg2{negtrack2.tpcNSigmaPi()}; - if (!SelectionV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { + if (!isSelectedV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { continue; } - if (!SelectionV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { + if (!isSelectedV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { continue; } - if (!SelectionV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { + if (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { continue; } - if (!SelectionV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { + if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { continue; } - hglue.fill(HIST("heventscheck"), 8.5); - 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 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 + if (TMath::Abs(lv3.Rapidity() < 0.5)) { - if (inv_mass1D) { - hglue.fill(HIST("h1glueInvMassME"), lv3.M()); + + 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, occupancy_no); + } 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, occupancy_no); + } 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, occupancy_no); + } 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, occupancy_no); } - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); } + + // if (TMath::Abs(lv3.Rapidity() < 0.5)) { + // if (inv_mass1D) { + // hglue.fill(HIST("h1glueInvMassME"), lv3.M()); + // } + // hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); + // } } } } else { @@ -600,6 +832,11 @@ struct strangeness_tutorial { if (!eventselection(c1, multiplicity) || !eventselection(c2, multiplicity)) { continue; } + auto occupancy_no = c1.trackOccupancyInTimeRange(); + auto occupancy_no2 = c2.trackOccupancyInTimeRange(); + if (applyOccupancyCut && (occupancy_no < OccupancyCut || occupancy_no2 < OccupancyCut)) { + return; + } for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { if (t1.size() == 0 || t2.size() == 0) { @@ -626,16 +863,16 @@ struct strangeness_tutorial { double nTPCSigmaPos2{postrack2.tpcNSigmaPi()}; double nTPCSigmaNeg2{negtrack2.tpcNSigmaPi()}; - if (!SelectionV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { + if (!isSelectedV0Daughter(postrack1, 1, nTPCSigmaPos1, t1)) { continue; } - if (!SelectionV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { + if (!isSelectedV0Daughter(postrack2, 1, nTPCSigmaPos2, t2)) { continue; } - if (!SelectionV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { + if (!isSelectedV0Daughter(negtrack1, -1, nTPCSigmaNeg1, t1)) { continue; } - if (!SelectionV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { + if (!isSelectedV0Daughter(negtrack2, -1, nTPCSigmaNeg2, t2)) { continue; } @@ -643,12 +880,47 @@ struct strangeness_tutorial { 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 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 + if (TMath::Abs(lv3.Rapidity() < 0.5)) { - if (inv_mass1D) { - hglue.fill(HIST("h1glueInvMassME"), lv3.M()); + + 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, occupancy_no); + } 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, occupancy_no); + } 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, occupancy_no); + } 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, occupancy_no); } - hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); } + + // 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 (TMath::Abs(lv3.Rapidity() < 0.5)) { + // if (inv_mass1D) { + // hglue.fill(HIST("h1glueInvMassME"), lv3.M()); + // } + // hglue.fill(HIST("h3glueInvMassME"), multiplicity, lv3.Pt(), lv3.M()); + // } } } } diff --git a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx index c3d0437fe54..9daeae66180 100644 --- a/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx +++ b/PWGLF/Tasks/Resonances/chargedkstaranalysis.cxx @@ -48,9 +48,13 @@ #include "PWGLF/DataModel/LFStrangenessTables.h" #include "ReconstructionDataFormats/Track.h" +// For charged kstarpp analysis +#include "PWGLF/DataModel/LFResonanceTables.h" + using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::soa; using std::array; struct chargedkstaranalysis { @@ -68,6 +72,15 @@ struct chargedkstaranalysis { SliceCache cache; + // 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", {}, @@ -84,6 +97,34 @@ struct chargedkstaranalysis { 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 + + // 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"}; @@ -158,11 +199,57 @@ struct chargedkstaranalysis { 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 ptAxis = {200, 0.0f, 20.0f, "#it{p}_{T} (GeV/#it{c})"}; AxisSpec multAxis = {100, 0.0f, 100.0f, "Multiplicity"}; // Histograms @@ -459,6 +546,161 @@ struct chargedkstaranalysis { 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) + { + // 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()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + 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 @@ -698,7 +940,7 @@ struct chargedkstaranalysis { } } - PROCESS_SWITCH(chargedkstaranalysis, processSE, "Process Same event", true); + PROCESS_SWITCH(chargedkstaranalysis, processSE, "Process Same event", false); void processME(EventCandidates const& /*collisions*/, TrackCandidates const& /*tracks*/, V0TrackCandidate const& /*V0s*/) @@ -803,7 +1045,7 @@ struct chargedkstaranalysis { } } - PROCESS_SWITCH(chargedkstaranalysis, processME, "Process Mixed event", true); + PROCESS_SWITCH(chargedkstaranalysis, processME, "Process Mixed event", false); void processGenMC(aod::McCollision const& mcCollision, aod::McParticles& mcParticles, const soa::SmallGroups& collisions) { @@ -1045,8 +1287,29 @@ struct chargedkstaranalysis { } // track loop ends } - PROCESS_SWITCH(chargedkstaranalysis, processGenMC, "Process Gen event", true); - PROCESS_SWITCH(chargedkstaranalysis, processRecMC, "Process Rec event", true); + PROCESS_SWITCH(chargedkstaranalysis, processGenMC, "Process Gen event", false); + PROCESS_SWITCH(chargedkstaranalysis, processRecMC, "Process Rec event", false); + + void processSEnew(aod::ResoCollision& collision, aod::ResoTracks const& resotracks, aod::ResoV0s const& resov0s) + { + // Fill the event counter + histos1.fill(HIST("hVertexZ"), collision.posZ()); + fillHistograms(collision, resotracks, resov0s); // Fill histograms, no MC, no mixing + } + PROCESS_SWITCH(chargedkstaranalysis, processSEnew, "Process Same event new", true); + + using BinningTypeVtxZT0M = ColumnBinningPolicy; + void processMEnew(aod::ResoCollisions& collisions, aod::ResoTracks const& resotracks, aod::ResoV0s const& resov0s) + { + 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) { + fillHistograms(c1, restrk1, resov0s2); + } + } + PROCESS_SWITCH(chargedkstaranalysis, processMEnew, "Process Mixed events new", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Resonances/f0980analysis.cxx b/PWGLF/Tasks/Resonances/f0980analysis.cxx index 406c3cad88c..3353fbebbab 100644 --- a/PWGLF/Tasks/Resonances/f0980analysis.cxx +++ b/PWGLF/Tasks/Resonances/f0980analysis.cxx @@ -33,8 +33,6 @@ using namespace o2::constants::physics; struct f0980analysis { SliceCache cache; - Preslice perRCol = aod::resodaughter::resoCollisionId; - Preslice perCollision = aod::track::collisionId; HistogramRegistry histos{ "histos", {}, @@ -52,6 +50,7 @@ struct f0980analysis { Configurable cfgMaxTOF{"cfgMaxTOF", 3.0, "Maximum TOF PID with TPC"}; 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{ @@ -92,16 +91,14 @@ struct f0980analysis { Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; Configurable SelectType{"SelectType", 0, "PID selection type"}; + // 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"}; void init(o2::framework::InitContext&) { - std::vector ptBinning = {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}; std::vector lptBinning = {0, 5.0, 13.0, 20.0, 50.0, 1000.0}; - AxisSpec centAxis = {22, 0, 110}; - AxisSpec ptAxis = {ptBinning}; - AxisSpec massAxis = {400, 0.2, 2.2}; AxisSpec RTAxis = {3, 0, 3}; AxisSpec LptAxis = {lptBinning}; // Minimum leading hadron pT selection @@ -112,13 +109,14 @@ struct f0980analysis { AxisSpec EPqaAxis = {200, -constants::math::PI, constants::math::PI}; AxisSpec EPresAxis = {200, -2, 2}; - 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}}); - + 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_EPA", "unlike invariant mass", {HistType::kTHnSparseF, {massAxis, ptAxis, centAxis, EPAxis}}); histos.add("hInvMass_f0980_LSpp_EPA", "++ invariant mass", @@ -230,12 +228,15 @@ struct f0980analysis { double LHpt = 0.; double LHphi = 0.; double relPhi = 0.; - for (auto& trk : dTracks) { - if (trk.pt() > LHpt) { - LHpt = trk.pt(); - LHphi = trk.phi(); + if (cfgFindRT) { + for (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()); @@ -244,7 +245,7 @@ struct f0980analysis { TLorentzVector Pion1, Pion2, Reco; for (auto& [trk1, trk2] : - combinations(CombinationsUpperIndexPolicy(dTracks, dTracks))) { + combinations(CombinationsStrictlyUpperIndexPolicy(dTracks, dTracks))) { if (trk1.index() == trk2.index()) { if (!SelTrack(trk1)) continue; @@ -272,8 +273,10 @@ struct f0980analysis { } if (trk1.sign() * trk2.sign() < 0) { - histos.fill(HIST("hInvMass_f0980_US"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + 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_EPA"), Reco.M(), Reco.Pt(), collision.cent(), relPhi); if constexpr (IsMC) { @@ -287,13 +290,17 @@ struct f0980analysis { collision.cent()); } } else if (trk1.sign() > 0 && trk2.sign() > 0) { - histos.fill(HIST("hInvMass_f0980_LSpp"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + 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_EPA"), Reco.M(), Reco.Pt(), collision.cent(), relPhi); } else if (trk1.sign() < 0 && trk2.sign() < 0) { - histos.fill(HIST("hInvMass_f0980_LSmm"), Reco.M(), Reco.Pt(), - collision.cent(), RTIndex(Reco.Phi(), LHphi), LHpt); + 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_EPA"), Reco.M(), Reco.Pt(), collision.cent(), relPhi); } diff --git a/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx b/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx new file mode 100644 index 00000000000..bb27b5f81c7 --- /dev/null +++ b/PWGLF/Tasks/Resonances/f0980pbpbanalysis.cxx @@ -0,0 +1,408 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +#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 "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 "CommonConstants/PhysicsConstants.h" + +#include "ReconstructionDataFormats/Track.h" + +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPMagField.h" + +#include "CCDB/CcdbApi.h" +#include "CCDB/BasicCCDBManager.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; + +struct f0980pbpbanalysis { + HistogramRegistry histos{ + "histos", + {}, + OutputObjHandlingPolicy::AnalysisObject}; + + Service ccdb; + 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 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 cfgNCollinTR{"cfgNCollinTR", false, "Additional selection for the number of coll in time range"}; + + Configurable cfgCentSel{"cfgCentSel", 80., "Centrality selection"}; + Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; + + 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 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 cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; + Configurable cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; + Configurable cfgPVContributor{"cfgPVContributor", 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 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"}; + + 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"}; + + TF1* fMultPVCutLow = nullptr; + TF1* fMultPVCutHigh = nullptr; + + int DetId; + int RefAId; + int RefBId; + + int QvecDetInd; + int QvecRefAInd; + int QvecRefBInd; + + float centrality; + + double angle; + double relPhi; + + double massPi = o2::constants::physics::MassPionCharged; + + 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); + + using EventCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; + + template + int GetDetId(const T& name) + { + 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 0; + } + } + + template + bool eventSelected(TCollision collision) + { + if (!collision.sel8()) { + return 0; + } + + if (cfgCentSel < centrality) { + return 0; + } + /* + auto multNTracksPV = collision.multNTracksPV(); + if (multNTracksPV < fMultPVCutLow->Eval(centrality)) { + return 0; + } + if (multNTracksPV > fMultPVCutHigh->Eval(centrality)) { + return 0; + } + */ + if (!collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return 0; + } + 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)) { + return 0; + } + if (cfgOccupancySel && (collision.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + return 0; + } + if (cfgNCollinTR && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return 0; + } + + return 1; + } // event selection + + template + bool trackSelected(const TrackType track) + { + if (std::abs(track.pt()) < cfgMinPt) { + return 0; + } + if (std::fabs(track.eta()) > cfgMaxEta) { + return 0; + } + if (std::fabs(track.dcaXY()) > cfgMaxDCArToPVcut) { + return 0; + } + if (std::fabs(track.dcaZ()) > cfgMaxDCAzToPVcut) { + return 0; + } + if (track.tpcNClsFound() < cfgTPCcluster) { + return 0; + } + if (cfgPVContributor && !track.isPVContributor()) { + return 0; + } + if (cfgPrimaryTrack && !track.isPrimaryTrack()) { + return 0; + } + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) { + return 0; + } + if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) { + return 0; + } + + return 1; + } + + template + bool PIDSelected(const TrackType track) + { + if (cfgUSETOF) { + if (!track.hasTOF()) { + return 0; + } + if (std::fabs(track.tofNSigmaPi()) > cMaxTOFnSigmaPion) { + return 0; + } + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPion) { + return 0; + } + } + if (std::fabs(track.tpcNSigmaPi()) > cMaxTPCnSigmaPionS) { + return 0; + } + + return 1; + } + + template + 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; + + 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); + + 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()); + continue; + } + + if (!trackSelected(trk1) || !trackSelected(trk2)) + 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; + + if (Reco.Rapidity() > cfgMaxRap || Reco.Rapidity() < cfgMinRap) + 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); + /* + 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); + } + } + } + + 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 epresAxis = {102, -1.02, 1.02}; + + histos.add("QA/CentDist", "", {HistType::kTH1F, {centQaAxis}}); + histos.add("QA/Vz", "", {HistType::kTH1F, {vzQaAxis}}); + + 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_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/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("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}}); + + // 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}); + // } + + 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"); + DetId = 0; + RefAId = 4; + RefBId = 5; + } + + 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(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()); + } + + void processData(EventCandidates::iterator const& collision, + TrackCandidates const& tracks, aod::BCsWithTimestamps const&) + { + if (cfgCentEst == 1) { + centrality = collision.centFT0C(); + } else if (cfgCentEst == 2) { + centrality = collision.centFT0M(); + } + if (!eventSelected(collision)) { + return; + } + histos.fill(HIST("QA/CentDist"), centrality, 1.0); + histos.fill(HIST("QA/Vz"), collision.posZ(), 1.0); + + FillHistograms(collision, tracks, 2); // second order + }; + PROCESS_SWITCH(f0980pbpbanalysis, processData, "Process Event for data", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"lf-f0980pbpbanalysis"})}; +} diff --git a/PWGLF/Tasks/Resonances/highmasslambda.cxx b/PWGLF/Tasks/Resonances/highmasslambda.cxx index 8b3a0bc6ade..9ef449cb83b 100644 --- a/PWGLF/Tasks/Resonances/highmasslambda.cxx +++ b/PWGLF/Tasks/Resonances/highmasslambda.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include "TRandom3.h" #include "Math/Vector3D.h" @@ -74,12 +75,11 @@ struct highmasslambda { // Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; // fill output + Configurable fillQA{"fillQA", false, "fillQA"}; Configurable useSP{"useSP", false, "useSP"}; Configurable useSignDCAV0{"useSignDCAV0", true, "useSignDCAV0"}; - Configurable additionalEvSel{"additionalEvSel", true, "additionalEvSel"}; - Configurable additionalEvSel2{"additionalEvSel2", false, "additionalEvSel2"}; Configurable fillDefault{"fillDefault", false, "fill Occupancy"}; - Configurable fillOccupancy{"fillOccupancy", true, "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"}; @@ -88,9 +88,10 @@ struct highmasslambda { Configurable cfgCutCentralityMax{"cfgCutCentralityMax", 50.0f, "Accepted maximum Centrality"}; Configurable cfgCutCentralityMin{"cfgCutCentralityMin", 30.0f, "Accepted minimum Centrality"}; // proton track cut + Configurable rejectPID{"reject PID", 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 rejectPID{"rejectPID", true, "Reject PID"}; 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"}; @@ -108,10 +109,12 @@ struct highmasslambda { 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 ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; + 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 nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; - Configurable nsigmaCutTOF{"nsigmacutTOF", 3.0, "Value of the TOF Nsigma cut"}; - Configurable nsigmaCutTPCPre{"nsigmacutTPCPre", 5.0, "Value of the TPC Nsigma cut Pre filter"}; + 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"}; // Configs for V0 Configurable ConfV0PtMin{"ConfV0PtMin", 0.f, "Minimum transverse momentum of V0"}; Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 0.2f, "Maximum DCA between the V0 daughters"}; @@ -121,6 +124,8 @@ struct highmasslambda { Configurable cMaxV0DCA{"cMaxV0DCA", 0.2, "Maximum V0 DCA to PV"}; Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 20, "Maximum V0 life time"}; Configurable cSigmaMassKs0{"cSigmaMassKs0", 0.006, "Sigma cut on KS0 mass"}; + 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"}; @@ -151,10 +156,10 @@ struct highmasslambda { 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 = nabs(aod::pidtpc::tpcNSigmaPr) < nsigmaCutTPCPre; + Filter pidFilter = aod::pidtpc::tpcNSigmaPr > minnsigmaCutTPCPre&& aod::pidtpc::tpcNSigmaPr < nsigmaCutTPCPre; using EventCandidates = soa::Filtered>; - using TrackCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; using AllTrackCandidates = soa::Join; using ResoV0s = aod::V0Datas; @@ -168,9 +173,9 @@ struct highmasslambda { { 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.002, 0.003, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.08, 0.1, 0.3, 1.0}; - std::vector ptProtonBinning = {0.2, 0.3, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 100.0}; - std::vector ptLambdaBinning = {2.0, 3.0, 4.0, 5.0, 8.0, 16.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}; const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; const AxisSpec thnAxisPt{configThnAxisPt, "#it{p}_{T} (GeV/#it{c})"}; @@ -189,11 +194,10 @@ struct highmasslambda { AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; // AxisSpec ptProtonAxis = {16, 0.0, 8, "V0M (%)"}; AxisSpec dcaAxis = {dcaBinning, "DCAxy"}; - AxisSpec dcatoPVAxis = {50, 0.0, 0.4, "V0M (%)"}; + AxisSpec dcatoPVAxis = {50, 0.0, 0.5, "V0M (%)"}; AxisSpec occupancyAxis = {occupancyBinning, "occupancy"}; AxisSpec ptProtonAxis = {ptProtonBinning, "pT proton"}; - histos.add("hRejectPID", "hRejectPID", kTH1F, {{2, 0.0f, 2.0f}}); histos.add("hMomCorr", "hMomCorr", kTH3F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}, {8, 0.0f, 80.0f}}); histos.add("hInvMassKs0", "hInvMassKs0", kTH1F, {{200, 0.4f, 0.6f}}); histos.add("hV0Dca", "hV0Dca", kTH1F, {{2000, -1.0f, 1.0f}}); @@ -209,33 +213,34 @@ struct highmasslambda { 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("hNsigmaProtonTPC", "NsigmaProton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {80, 0.0f, 8.0f}}); - histos.add("hNsigmaProtonTOF", "NsigmaProton TOF distribution", kTH2F, {{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("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("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) { - if (fillDecayLength) { - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum}); - histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum}); - } - histos.add("hSparseV2SASameEvent_V2_new", "hSparseV2SASameEvent_V2_new", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); - histos.add("hSparseV2SAMixedEvent_V2_new", "hSparseV2SAMixedEvent_V2_new", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); - histos.add("hSparseV2SASameEventRotational_V2_new", "hSparseV2SASameEventRotational_V2_new", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis}); + 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 (fillOccupancy) { - if (fillDecayLength) { - histos.add("hSparseV2SASameEvent_V2_occupancy", "hSparseV2SASameEvent_V2_occupancy", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum, dcaAxis, occupancyAxis}); - histos.add("hSparseV2SASameEventRotational_V2_occupancy", "hSparseV2SASameEventRotational_V2_occupancy", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum, dcaAxis, occupancyAxis}); - histos.add("hSparseV2SAMixedEvent_V2_occupancy", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, thnAxisDCASum, dcaAxis, occupancyAxis}); - } - histos.add("hSparseV2SASameEvent_V2_new_occupancy", "hSparseV2SASameEvent_V2_new_occupancy", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis, occupancyAxis}); - histos.add("hSparseV2SASameEventRotational_V2_new_occupancy", "hSparseV2SASameEventRotational_V2_new_occupancy", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis, occupancyAxis}); - histos.add("hSparseV2SAMixedEvent_V2_new_occupancy", "hSparseV2SAMixedEvent_V2_new", HistType::kTHnSparseF, {thnAxisInvMass, ptLambdaBinning, thnAxisSP, dcaAxis, ptProtonAxis, occupancyAxis}); + 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}); @@ -264,10 +269,10 @@ struct highmasslambda { template bool selectionTrack(const T& candidate) { - if (isPVContributor && !(candidate.isGlobalTrack() && candidate.isPVContributor() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster)) { + 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)) { + if (!isPVContributor && !(candidate.isGlobalTrackWoDCA() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster && candidate.itsNClsInnerBarrel() >= 1)) { return false; } @@ -313,106 +318,156 @@ struct highmasslambda { } template - bool selectionPIDpTdependent(const T& candidate) + bool rejectPi(const T& candidate) { - if (candidate.p() <= 0.5 && TMath::Abs(candidate.tpcNSigmaPr()) < 5.0) { - return true; + if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.0 && candidate.tpcNSigmaPi() < 6.0) { + return false; } - if (candidate.p() > 0.5 && candidate.p() <= 0.8 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; + if (candidate.tpcInnerParam() > 1.0 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaPi() < 4.0) { + return false; } - if (candidate.p() > 0.8 && candidate.hasTOF() && TMath::Sqrt(candidate.tofNSigmaPr() * candidate.tofNSigmaPr() + candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr()) < nsigmaCutTOF) { - return true; + if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaPi() < 3.0) { + return false; } - return false; + if (candidate.tpcInnerParam() > 1.2 && candidate.tpcInnerParam() < 1.4 && candidate.tpcNSigmaPi() < 1.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaPi() < 0.5) { + return false; + } + return true; } template - bool selectionPID(const T& candidate) + bool rejectEl(const T& candidate) { - if (candidate.hasTOF()) { - if (candidate.pt() < 0.8 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && TMath::Abs(candidate.tofNSigmaPr()) < 10.0) { - return true; - } - if (candidate.pt() >= 0.8 && candidate.pt() < 3.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && TMath::Abs(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() > -2.0 && candidate.tofNSigmaPr() < 3.0) { - return true; - } - if (candidate.pt() >= 4.0 && candidate.pt() < 5.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < 3.0) { - return true; - } - if (candidate.pt() >= 5.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -1.5 && candidate.tofNSigmaPr() < 3.0) { - return true; - } + + if (candidate.tpcInnerParam() > 0.7 && candidate.tpcInnerParam() < 0.8 && candidate.tpcNSigmaEl() < 2.0) { + return false; } - if (!candidate.hasTOF()) { - if (candidate.pt() < 0.7 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; - } - if (candidate.pt() >= 0.7 && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < 3.0) { - return true; - } - if (candidate.pt() >= 0.8 && candidate.tpcNSigmaPr() > -1.5 && candidate.tpcNSigmaPr() < 3.0) { - return true; - } + if (candidate.tpcInnerParam() > 0.8 && candidate.tpcInnerParam() < 0.9 && candidate.tpcNSigmaEl() < 0.0) { + return false; } - return false; + if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.0 && candidate.tpcNSigmaEl() < -1.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.0 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaEl() < -2.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaEl() < -3.0) { + return false; + } + + return true; } template - bool selectionPIDNew(const T& candidate) + bool rejectKa(const T& candidate) { - if (candidate.pt() < 0.7 && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { - return true; + if (candidate.tpcInnerParam() > 0.7 && candidate.tpcInnerParam() < 0.8 && candidate.tpcNSigmaKa() < 7.5) { + return false; } - if (candidate.pt() >= 0.7 && !candidate.hasTOF() && candidate.pt() < 0.8 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < 3.0) { - return true; + if (candidate.tpcInnerParam() > 0.8 && candidate.tpcInnerParam() < 0.9 && candidate.tpcNSigmaKa() < 6.0) { + return false; } - if (candidate.pt() < 0.8 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && TMath::Abs(candidate.tofNSigmaPr()) < 10.0) { - return true; + if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaKa() < 5.0) { + return false; } - if (candidate.pt() >= 0.8 && candidate.pt() < 1.0 && !candidate.hasTOF() && candidate.tpcNSigmaPr() > -1.5 && candidate.tpcNSigmaPr() < 3.0) { - return true; + if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaKa() < 3.5) { + return false; } - if (candidate.pt() >= 0.8 && candidate.pt() < 3.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && TMath::Abs(candidate.tofNSigmaPr()) < 3.0) { - return true; + if (candidate.tpcInnerParam() > 1.2 && candidate.tpcInnerParam() < 1.4 && candidate.tpcNSigmaKa() < 3.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaKa() < 2.5) { + return false; } - if (candidate.pt() >= 3.0 && candidate.pt() < 4.0 && candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0 && candidate.tofNSigmaPr() > -2.0 && candidate.tofNSigmaPr() < 4.0) { + return true; + } + + // TPC TOF + template + bool selectionPID1(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 4.0 && candidate.pt() < 5.0 && candidate.hasTOF() && candidate.tofNSigmaPr() > -2.0) { + if (candidate.tpcInnerParam() >= 0.85) { + if (candidate.hasTOF()) { + if (candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + return false; + } + + // TOF Veto + template + bool selectionPID2(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 5.0 && candidate.hasTOF() && candidate.tofNSigmaPr() > -1.5) { + if (candidate.tpcInnerParam() >= 0.85 && candidate.beta() > cfgCutTOFBeta && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPr()) < nsigmaCutTOF) { return true; } return false; } + // TOF veto loose template - bool RejectPion(const T& candidate) + bool selectionPID3(const T& candidate) { - if (candidate.p() > 1.0 && candidate.p() < 2.0 && !candidate.hasTOF() && candidate.tpcNSigmaPi() < 2) { - return false; + if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; } - 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) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + return false; } + // TOF veto very loose template - bool RejectKaon(const T& candidate) + bool selectionPID4(const T& candidate) { - if (candidate.p() > 1.0 && candidate.p() < 2.0 && !candidate.hasTOF() && candidate.tpcNSigmaKa() < 2) { - return false; + if (candidate.tpcInnerParam() < 0.85 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; } - 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) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcInnerParam() < 1.8 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < nsigmaCutTPC) { + return true; + } + } + } + return false; } template bool SelectionV0(Collision const& collision, V0 const& candidate) { - if (fabs(candidate.dcav0topv()) > cMaxV0DCA) { + if (TMath::Abs(candidate.dcav0topv()) > cMaxV0DCA) { return false; } const float pT = candidate.pt(); @@ -440,7 +495,7 @@ struct highmasslambda { if (tranRad > ConfV0TranRadV0Max) { return false; } - if (fabs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { + if (TMath::Abs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { return false; } return true; @@ -459,19 +514,19 @@ struct highmasslambda { if (charge > 0 && sign < 0) { return false; } - if (std::abs(eta) > ConfDaughEta) { + if (TMath::Abs(eta) > ConfDaughEta) { return false; } - if (std::abs(pt) < ConfDaughPt) { + if (TMath::Abs(pt) < ConfDaughPt) { return false; } if (tpcNClsF < ConfDaughTPCnclsMin) { return false; } - if (std::abs(dcaXY) < ConfDaughDCAMin) { + if (TMath::Abs(dcaXY) < ConfDaughDCAMin) { return false; } - if (std::abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { + if (TMath::Abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { return false; } return true; @@ -494,7 +549,7 @@ struct highmasslambda { ConfigurableAxis axisEPAngle{"axisEPAngle", {1, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; using BinningTypeVertexContributor = ColumnBinningPolicy; - ROOT::Math::PxPyPzMVector Lambdac, Proton, Kshort, LambdacRot, ProtonRot, fourVecDauCM; + 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 @@ -502,22 +557,17 @@ struct highmasslambda { double v2, v2Rot; void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, AllTrackCandidates const&, ResoV0s const& V0s, aod::BCs const&) { - if (!collision.sel8()) { + 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; } + auto centrality = collision.centFT0C(); auto multTPC = collision.multNTracksPV(); histos.fill(HIST("hFTOCvsTPCNoCut"), centrality, multTPC); - if (!collision.triggereventep()) { - return; - } - if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - return; - } - if (additionalEvSel2 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgOccupancyCut) { return; } - int occupancy = collision.trackOccupancyInTimeRange(); auto psiFT0C = collision.psiFT0C(); auto psiFT0A = collision.psiFT0A(); auto psiTPC = collision.psiTPC(); @@ -551,28 +601,49 @@ struct highmasslambda { if (!selectionTrack(track1)) { continue; } + // PID check - if (ispTdepPID && !selectionPIDNew(track1)) { + if (PIDstrategy == 0 && !selectionPID1(track1)) { continue; } - if (!ispTdepPID && !selectionPID(track1)) { + if (PIDstrategy == 1 && !selectionPID2(track1)) { continue; } - if (!ispTdepPID && rejectPID && !RejectPion(track1)) { - histos.fill(HIST("hRejectPID"), 0.5); + if (PIDstrategy == 2 && !selectionPID3(track1)) { continue; } - if (!ispTdepPID && rejectPID && !RejectKaon(track1)) { - histos.fill(HIST("hRejectPID"), 1.5); + if (PIDstrategy == 3 && !selectionPID4(track1)) { continue; } + + if (track1.hasTOF()) { + histos.fill(HIST("hNsigmaProtonTOFPre"), track1.tofNSigmaPr(), track1.pt()); + } + 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()); + } + } + 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("hNsigmaProtonTPC"), track1.tpcNSigmaPr(), track1.pt()); - histos.fill(HIST("hNsigmaProtonTOF"), track1.tofNSigmaPr(), track1.pt()); + if (track1.hasTOF()) { + histos.fill(HIST("hNsigmaProtonTOF"), track1.tofNSigmaPr(), track1.pt()); + } auto track1ID = track1.globalIndex(); for (auto v0 : V0s) { if (!SelectionV0(collision, v0)) { @@ -602,11 +673,8 @@ struct highmasslambda { } firstprimarytrack = firstprimarytrack + 1; Proton = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPr); - Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), massK0s); + Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); Lambdac = Proton + Kshort; - if (TMath::Abs(Lambdac.Rapidity()) > confRapidity) { - continue; - } auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); if (useSP) { @@ -620,36 +688,29 @@ struct highmasslambda { dcasum = anglesign * (v0.dcav0topv()) - track1.dcaXY(); } if (!useSignDCAV0) { - dcasum = TMath::Sqrt((track1.dcaXY() + (v0.dcav0topv())) * (track1.dcaXY() + (v0.dcav0topv()))); + dcasum = v0.dcav0topv() - track1.dcaXY(); } - // auto diffangle = Proton.Phi() - Lambdac.Phi(); - // auto decaylength = std::abs((track1.dcaXY() / TMath::Sin(diffangle)) / (Lambdac.P() / 2.286)); - // auto dcasum = TMath::Sqrt(track1.dcaXY() * track1.dcaXY() + v0.dcav0topv() * v0.dcav0topv()); histos.fill(HIST("hMassvsDecaySum"), Lambdac.M(), dcasum); - if (fillDefault && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, 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()); } - histos.fill(HIST("hSparseV2SASameEvent_V2_new"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), Proton.Pt()); - } - if (fillOccupancy && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEvent_V2_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, dcasum, std::abs(track1.dcaXY()), occupancy); + histos.fill(HIST("hSparseV2SASameEvent_V2_dcatopv"), Lambdac.M(), Lambdac.Pt(), v2, v0.dcav0topv(), Proton.Pt()); } - histos.fill(HIST("hSparseV2SASameEvent_V2_new_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), Proton.Pt(), occupancy); } + if (fillRotation) { for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { auto anglestart = confMinRot; auto angleend = confMaxRot; - // auto anglestep = nrotbkg * (TMath::Pi() / nBkgRotations); auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); auto rotangle = anglestart + nrotbkg * anglestep; histos.fill(HIST("hRotation"), rotangle); - auto rotProtonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); - auto rotProtonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); - ProtonRot = ROOT::Math::PxPyPzMVector(rotProtonPx, rotProtonPy, track1.pz(), massPr); - LambdacRot = ProtonRot + Kshort; + auto rotKaonPx = Kshort.px() * std::cos(rotangle) - Kshort.py() * std::sin(rotangle); + auto rotKaonPy = Kshort.px() * std::sin(rotangle) + Kshort.py() * std::cos(rotangle); + KshortRot = ROOT::Math::PxPyPzMVector(rotKaonPx, rotKaonPy, Kshort.pz(), massK0s); + LambdacRot = Proton + KshortRot; auto phiminuspsiRot = GetPhiInRange(LambdacRot.Phi() - psiFT0C); if (useSP) { v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; @@ -657,30 +718,26 @@ struct highmasslambda { if (!useSP) { v2Rot = TMath::Cos(2.0 * phiminuspsiRot); } - // auto diffangleRot = ProtonRot.Phi() - LambdacRot.Phi(); - // auto decaylengthRot = std::abs((track1.dcaXY() / TMath::Sin(diffangleRot)) / (Lambdac.P() / 2.286)); - if (fillDefault && LambdacRot.M() > 2.18 && LambdacRot.M() <= 2.42) { - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEventRotational_V2"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, dcasum); + + 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()); } - histos.fill(HIST("hSparseV2SASameEventRotational_V2_new"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, std::abs(track1.dcaXY()), Proton.Pt()); - } - if (fillOccupancy && LambdacRot.M() > 2.18 && LambdacRot.M() <= 2.42) { if (fillDecayLength) { - histos.fill(HIST("hSparseV2SASameEventRotational_V2_occupancy"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, dcasum, std::abs(track1.dcaXY()), occupancy); + histos.fill(HIST("hSparseV2SASameEventRotational_V2_dcatopv"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, v0.dcav0topv(), Proton.Pt()); } - histos.fill(HIST("hSparseV2SASameEventRotational_V2_new_occupancy"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, std::abs(track1.dcaXY()), Proton.Pt(), occupancy); } } } - 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 (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); @@ -702,39 +759,56 @@ 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() || !collision2.sel8()) { + 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 (!collision1.triggereventep() || !collision2.triggereventep()) { + 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 (additionalEvSel && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + if (collision1.bcId() == collision2.bcId()) { continue; } - if (additionalEvSel && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - continue; - } - if (additionalEvSel2 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - return; - } - if (additionalEvSel2 && (!collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - return; - } auto centrality = collision1.centFT0C(); auto psiFT0C = collision1.psiFT0C(); auto QFT0C = collision1.qFT0C(); - int occupancy = collision1.trackOccupancyInTimeRange(); + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision1.trackOccupancyInTimeRange(); + if (occupancy1 > cfgOccupancyCut) { + continue; + } + if (occupancy2 > cfgOccupancyCut) { + continue; + } for (auto& [track1, v0] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { if (!selectionTrack(track1)) { continue; } + if (!track1.hasTOF()) { + if (rejectPID && !rejectPi(track1)) { + continue; + } + if (rejectPID && !rejectEl(track1)) { + continue; + } + if (rejectPID && !rejectKa(track1)) { + continue; + } + } + // PID check - if (ispTdepPID && !selectionPIDNew(track1)) { + if (PIDstrategy == 0 && !selectionPID1(track1)) { continue; } - if (!ispTdepPID && !selectionPID(track1)) { + if (PIDstrategy == 1 && !selectionPID2(track1)) { continue; } + if (PIDstrategy == 2 && !selectionPID3(track1)) { + continue; + } + if (PIDstrategy == 3 && !selectionPID4(track1)) { + continue; + } + if (!SelectionV0(collision2, v0)) { continue; } @@ -746,10 +820,12 @@ struct highmasslambda { if (!isSelectedV0Daughter(negtrack, -1)) { continue; } - Proton = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPr); - Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), massK0s); + Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); Lambdac = Proton + Kshort; + if (Lambdac.Pt() > 6.0 || Lambdac.Pt() < 2.0) { + continue; + } if (TMath::Abs(Lambdac.Rapidity()) > confRapidity) { continue; } @@ -767,31 +843,26 @@ struct highmasslambda { dcasum = anglesign * (v0.dcav0topv()) - track1.dcaXY(); } if (!useSignDCAV0) { - dcasum = TMath::Sqrt((track1.dcaXY() + (v0.dcav0topv())) * (track1.dcaXY() + (v0.dcav0topv()))); + dcasum = v0.dcav0topv() - track1.dcaXY(); } - // auto diffangle = Proton.Phi() - Lambdac.Phi(); - // auto decaylength = std::abs((track1.dcaXY() / TMath::Sin(diffangle)) / (Lambdac.P() / 2.286)); - // auto dcasum = TMath::Sqrt(track1.dcaXY() * track1.dcaXY() + v0.dcav0topv() * v0.dcav0topv()); - if (fillDefault && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { - if (fillDecayLength) { - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, dcasum); + + 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()); } - histos.fill(HIST("hSparseV2SAMixedEvent_V2_new"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), Proton.Pt()); - } - if (fillOccupancy && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { if (fillDecayLength) { - histos.fill(HIST("hSparseV2SAMixedEvent_V2_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, dcasum, std::abs(track1.dcaXY()), occupancy); + histos.fill(HIST("hSparseV2SAMixedEvent_V2_dcatopv"), Lambdac.M(), Lambdac.Pt(), v2, v0.dcav0topv(), Proton.Pt()); } - histos.fill(HIST("hSparseV2SAMixedEvent_V2_new_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, std::abs(track1.dcaXY()), Proton.Pt(), occupancy); - } - 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 (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); diff --git a/PWGLF/Tasks/Resonances/highmasslambdasvx.cxx b/PWGLF/Tasks/Resonances/highmasslambdasvx.cxx new file mode 100644 index 00000000000..d6405483d13 --- /dev/null +++ b/PWGLF/Tasks/Resonances/highmasslambdasvx.cxx @@ -0,0 +1,927 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// Phi meson spin alignment task +// sourav.kundu@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 "Common/Core/trackUtilities.h" +#include "PWGLF/DataModel/EPCalibrationTables.h" +#include "Framework/runDataProcessing.h" +#include "DCAFitter/DCAFitterN.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 "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 "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/V0.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; +struct highmasslambdasvx { + + int mRunNumber; + int multEstimator; + float d_bz; + Service ccdb; + Service pdg; + + o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter + o2::base::MatLayerCylSet* lut; + o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; + 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"}; + + // fill output + 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 useSP{"useSP", false, "useSP"}; + Configurable additionalEvSel{"additionalEvSel", true, "additionalEvSel"}; + Configurable additionalEvSel2{"additionalEvSel2", false, "additionalEvSel2"}; + // events + Configurable cnfabsdca{"cnfabsdca", false, "Use Abs DCA for secondary vertex fitting"}; + 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 useDecayLengthxy{"useDecayLengthxy", true, "use decay length xy"}; + Configurable ispTdifferentialDCA{"ispTdifferentialDCA", true, "is pT differential DCA"}; + 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 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 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 cfgITSclusterInnerlayer{"cfgITSclusterInnerlayer", 1, "Minimum Number of ITS cluster in inner barrel"}; + 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 nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "TPC TOF combined PID"}; + Configurable nsigmaCutTPCPre{"nsigmacutTPCPre", 3.0, "Value of the TPC Nsigma cut Pre filter"}; + // Configs for V0 + Configurable ConfV0DCADaughMax{"ConfV0DCADaughMax", 0.2f, "Maximum DCA between the V0 daughters"}; + Configurable ConfV0CPAMin{"ConfV0CPAMin", 0.9998f, "Minimum CPA of V0"}; + Configurable cMaxV0DCA{"cMaxV0DCA", 0.1, "Maximum V0 DCA to PV"}; + Configurable cMaxV0LifeTime{"cMaxV0LifeTime", 20, "Maximum V0 life time"}; + Configurable cSigmaMassKs0{"cSigmaMassKs0", 0.006, "Sigma cut on KS0 mass"}; + Configurable cMinLambdaMass{"cMinLambdaMass", 2.18, "Minimum lambda mass"}; + Configurable cMaxLambdaMass{"cMaxLambdaMass", 2.42, "Maximum lambda mass"}; + + // config for V0 daughters + 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"}; + // 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"}; + Configurable cutchi2PCA{"cutchi2PCA", 0.1f, "cut on chi2PCA"}; + // THnsparse bining + ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {60, 2.15, 2.45}, "#it{M} (GeV/#it{c}^{2})"}; + ConfigurableAxis configThnAxisV2{"configThnAxisV2", {80, -1, 1}, "V2"}; + ConfigurableAxis configThnAxisSA{"configThnAxisSA", {100, -1, 1}, "SA"}; + ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; + ConfigurableAxis configThnAxisCentrality{"configThnAxisCentrality", {1, 30., 50}, "Centrality"}; + ConfigurableAxis configThnAxisDecayLength{"configThnAxisDecayLength", {60, 0.0, 0.06}, "Decay length"}; + + 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 = nabs(aod::pidtpc::tpcNSigmaPr) < nsigmaCutTPCPre; + + using EventCandidates = soa::Filtered>; + // using TrackCandidates = soa::Filtered>; + // using AllTrackCandidates = soa::Join; + + using TrackCandidates = soa::Filtered>; + using AllTrackCandidates = soa::Join; + using ResoV0s = 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.006, 0.3}; + std::vector ptProtonBinning = {0.0, 0.3, 0.5, 0.8, 1.2, 6.0}; + std::vector ptLambdaBinning = {2.0, 3.0, 4.0, 5.0, 6.0}; + + AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; + AxisSpec decaylengthAxis = {configThnAxisDecayLength, "decaylength"}; + AxisSpec resAxis = {1000, -10, 10, "Res"}; + AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; + const AxisSpec thnAxisInvMass{configThnAxisInvMass, "#it{M} (GeV/#it{c}^{2})"}; + const AxisSpec thnAxisV2{configThnAxisV2, "V2"}; + const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; + const AxisSpec thnAxisPhiminusPsi{configThnAxisPhiminusPsi, "#phi - #psi"}; + AxisSpec occupancyAxis = {occupancyBinning, "occupancy"}; + AxisSpec ptAxis = {ptLambdaBinning, "pt"}; + AxisSpec dcaAxis = {dcaBinning, "dca"}; + AxisSpec ptProtonAxis = {ptProtonBinning, "daughter pt"}; + histos.add("hSparseV2SASameEvent_V2_EP", "hSparseV2SASameEvent_V2_EP", HistType::kTHnSparseF, {thnAxisInvMass, ptAxis, thnAxisV2, ptProtonAxis, decaylengthAxis, dcaAxis}); + histos.add("hSparseV2SASameEventRotational_V2_EP", "hSparseV2SASameEventRotational_V2_EP", HistType::kTHnSparseF, {thnAxisInvMass, ptAxis, thnAxisV2, ptProtonAxis, decaylengthAxis, dcaAxis}); + histos.add("hV0decaylength", "hV0decaylength", kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("hMomCorr", "hMomCorr", kTH3F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}, {8, 0.0f, 80.0f}}); + histos.add("hInvMassKs0", "hInvMassKs0", kTH1F, {{200, 0.4f, 0.6f}}); + histos.add("hchi2PCA", "hchi2PCA", kTH1F, {{1000, 0.0f, 1.f}}); + 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("hRotation", "hRotation", kTH1F, {{360, 0.0, 2.0 * TMath::Pi()}}); + + 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("hNsigmaProtonTPC", "NsigmaProton TPC distribution", kTH2F, {{100, -5.0f, 5.0f}, {80, 0.0f, 8.0f}}); + histos.add("hNsigmaProtonTOF", "NsigmaProton TOF distribution", kTH2F, {{100, -5.0f, 5.0f}, {80, 0.0f, 8.0f}}); + + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hDcaz", "Dcaz distribution", kTH1F, {{1000, -0.5f, 0.5f}}); + histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{1000, -0.5f, 0.5f}}); + histos.add("hsignprotonDca", "hsignprotonDca", kTH1F, {{2000, -1.0f, 1.0f}}); + histos.add("hunsignprotonDca", "hunsignprotonDca", kTH1F, {{2000, -1.0f, 1.0f}}); + histos.add("hsignCPALambdac", "hsignCPALambdac", kTH1F, {{2000, -1.0f, 1.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}); + + // histogram for resolution + histos.add("ResFT0CTPC", "ResFT0CTPC", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0CTPCR", "ResFT0CTPCR", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0CTPCL", "ResFT0CTPCL", kTH2F, {centAxis, resAxis}); + histos.add("ResTPCRTPCL", "ResTPCRTPCL", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0ATPC", "ResFT0ATPC", kTH2F, {centAxis, resAxis}); + + df.setPropagateToPCA(true); + df.setMaxR(200); + df.setMaxDZIni(4); + df.setMinParamChange(1.e-3); + df.setMinRelChi2Change(0.9); + df.setUseAbsDCA(cnfabsdca); + df.setWeightedFinalPCA(true); + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); + runNumber = 0; + } + template + bool selectionTrack(const T& candidate) + { + if (!(candidate.isGlobalTrackWoDCA() && candidate.itsNCls() > cfgITScluster && candidate.tpcNClsFound() > cfgTPCcluster && candidate.itsNClsInnerBarrel() >= cfgITSclusterInnerlayer)) { + return false; + } + 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() < 3.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin5) { + return false; + } + if (candidate.pt() >= 3.0 && TMath::Abs(candidate.dcaXY()) < cfgCutDCAxymin6) { + return false; + } + return true; + } + + template + bool rejectPi(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) { + return false; + } + if (candidate.tpcInnerParam() > 1.2 && candidate.tpcInnerParam() < 1.4 && candidate.tpcNSigmaPi() < 1.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaPi() < 0.5) { + 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) { + return false; + } + if (candidate.tpcInnerParam() > 0.9 && candidate.tpcInnerParam() < 1.0 && candidate.tpcNSigmaEl() < -1.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.0 && candidate.tpcInnerParam() < 1.1 && candidate.tpcNSigmaEl() < -2.0) { + return false; + } + if (candidate.tpcInnerParam() > 1.1 && candidate.tpcInnerParam() < 1.2 && candidate.tpcNSigmaEl() < -3.0) { + return false; + } + + return true; + } + + template + bool rejectKa(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.tpcInnerParam() > 1.4 && candidate.tpcInnerParam() < 1.5 && candidate.tpcNSigmaKa() < 2.5) { + return false; + } + return true; + } + + // TPC TOF + template + bool selectionPID1(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.7 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 0.7) { + // printf("I am here: %.3f\n", candidate.tpcInnerParam()); + if (candidate.hasTOF()) { + auto combinedPID = TMath::Sqrt(candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + candidate.tofNSigmaPr() * candidate.tofNSigmaPr()) / TMath::Sqrt(2.0); + // printf("combine PIDA: %.3f\n", combinedPID); + if (combinedPID < nsigmaCutCombined) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcInnerParam() < 1.5 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 1.5 && candidate.tpcNSigmaPr() > -2.0 && candidate.tpcNSigmaPr() < 2.0) { + return true; + } + } + } + return false; + } + + // TOF Veto + template + bool selectionPID2(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.7 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 0.7) { + if (candidate.hasTOF()) { + auto combinedPID = TMath::Sqrt(candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + candidate.tofNSigmaPr() * candidate.tofNSigmaPr()) / TMath::Sqrt(2.0); + if (combinedPID < nsigmaCutCombined) { + return true; + } + } + } + return false; + } + + // TOF veto loose + template + bool selectionPID3(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.7 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 0.7) { + if (candidate.hasTOF()) { + auto combinedPID = TMath::Sqrt(candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + candidate.tofNSigmaPr() * candidate.tofNSigmaPr()) / TMath::Sqrt(2.0); + if (combinedPID < nsigmaCutCombined) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcInnerParam() < 1.5 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + } + } + return false; + } + + // TOF veto very loose + template + bool selectionPID4(const T& candidate) + { + if (candidate.tpcInnerParam() < 0.7 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 0.7) { + if (candidate.hasTOF()) { + auto combinedPID = TMath::Sqrt(candidate.tpcNSigmaPr() * candidate.tpcNSigmaPr() + candidate.tofNSigmaPr() * candidate.tofNSigmaPr()) / TMath::Sqrt(2.0); + if (combinedPID < nsigmaCutCombined) { + return true; + } + } + if (!candidate.hasTOF()) { + if (candidate.tpcInnerParam() < 1.5 && TMath::Abs(candidate.tpcNSigmaPr()) < 3.0) { + return true; + } + if (candidate.tpcInnerParam() >= 1.5 && candidate.tpcInnerParam() < 1.8 && candidate.tpcNSigmaPr() > -1.5 && candidate.tpcNSigmaPr() < 2.0) { + return true; + } + } + } + return false; + } + + template + bool SelectionV0(Collision const& collision, V0 const& candidate) + { + // 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 cpav0 = candidate.v0cosPA(); + float decaylength = TMath::Sqrt(TMath::Power(collision.posX() - candidate.x(), 2.0) + TMath::Power(collision.posY() - candidate.y(), 2.0) + TMath::Power(collision.posZ() - candidate.z(), 2.0)); + 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 - 2.0 * cSigmaMassKs0; + float highmasscutks0 = 0.497 + 2.0 * cSigmaMassKs0; + + if (TMath::Abs(CtauK0s) < 2.0 || TMath::Abs(CtauK0s) > cMaxV0LifeTime || candidate.mK0Short() < lowmasscutks0 || candidate.mK0Short() > highmasscutks0) { + return false; + } + if (dcaDaughv0 > ConfV0DCADaughMax) { + return false; + } + if (TMath::Abs(candidate.dcav0topv()) > cMaxV0DCA) { + return false; + } + if (cpav0 < ConfV0CPAMin) { + return false; + } + if (decaylength > 100) { + return false; + } + if (tranRad > 100) { + return false; + } + return true; + } + template + bool isSelectedV0Daughter(T const& track, float charge) + { + 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 (TMath::Abs(eta) > 0.8) { + return false; + } + if (TMath::Abs(pt) < ConfDaughPt) { + return false; + } + if (tpcNClsF < ConfDaughTPCnclsMin) { + return false; + } + if (TMath::Abs(dcaXY) < ConfDaughDCAMin) { + return false; + } + if (TMath::Abs(track.tpcNSigmaPi()) > ConfDaughPIDCuts) { + return false; + } + return true; + } + + 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; + } + + ConfigurableAxis axisVertex{"axisVertex", {10, -10, 10}, "vertex axis for bin"}; + ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {10, 0, 100}, "multiplicity percentile for bin"}; + ConfigurableAxis axisEPAngle{"axisEPAngle", {1, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; + + using BinningTypeVertexContributor = ColumnBinningPolicy; + ROOT::Math::PxPyPzMVector Lambdac, Proton, Kshort, LambdacRot, KshortRot; + // ROOT::Math::PxPyPzMVector fourVecDauCM; + // ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY, eventplaneVec, eventplaneVecNorm, beamvector; + 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::BCsWithTimestamps const&) + { + if (!collision.sel8()) { + return; + } + auto bc = collision.template bc_as(); + if (runNumber != bc.runNumber()) { + initCCDB(bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2); + bz = o2::base::Propagator::Instance()->getNominalBz(); + // df.setBz(bz); /// put it outside the 'if'! Otherwise we have a difference wrt bz Configurable (< 1 permille) in Run2 conv. data + } + df.setBz(bz); + auto centrality = collision.centFT0C(); + auto multTPC = collision.multNTracksPV(); + histos.fill(HIST("hFTOCvsTPCNoCut"), centrality, multTPC); + if (!collision.triggereventep()) { + return; + } + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + if (additionalEvSel2 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + int occupancy = collision.trackOccupancyInTimeRange(); + 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("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, TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResFT0CTPCR"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPCR))); + histos.fill(HIST("ResFT0CTPCL"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPCL))); + histos.fill(HIST("ResTPCRTPCL"), centrality, TMath::Cos(2.0 * (psiTPCR - psiTPCL))); + histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResFT0ATPC"), centrality, 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; + } + + if (!track1.hasTOF()) { + if (!rejectPi(track1)) { + continue; + } + if (!rejectEl(track1)) { + continue; + } + if (!rejectKa(track1)) { + continue; + } + } + + // PID check + if (PIDstrategy == 0 && !selectionPID1(track1)) { + continue; + } + if (PIDstrategy == 1 && !selectionPID2(track1)) { + continue; + } + if (PIDstrategy == 2 && !selectionPID3(track1)) { + continue; + } + if (PIDstrategy == 3 && !selectionPID4(track1)) { + continue; + } + histos.fill(HIST("hMomCorr"), track1.p() / track1.sign(), track1.p() - track1.tpcInnerParam(), centrality); + histos.fill(HIST("hEta"), track1.eta()); + histos.fill(HIST("hDcaz"), track1.dcaZ()); + histos.fill(HIST("hNsigmaProtonTPCDiff"), track1.tpcNSigmaPr(), track1.tpcNSigmaKa(), track1.pt()); + histos.fill(HIST("hNsigmaProtonTPC"), track1.tpcNSigmaPr(), track1.pt()); + histos.fill(HIST("hNsigmaProtonTOF"), track1.tofNSigmaPr(), track1.pt()); + auto track1ID = track1.globalIndex(); + auto trackParCovBach = getTrackParCov(track1); + for (auto v0 : V0s) { + if (!SelectionV0(collision, v0)) { + continue; + } + 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; + } + auto v0decaylength = TMath::Sqrt(TMath::Power(collision.posX() - v0.x(), 2.0) + TMath::Power(collision.posY() - v0.y(), 2.0) + TMath::Power(collision.posZ() - v0.z(), 2.0)); + if (firstprimarytrack == 0) { + histos.fill(HIST("hV0decaylength"), v0decaylength); + } + float v0x, v0y, v0z, v0px, v0py, v0pz; + // float v0PosPx, v0PosPy, v0PosPz, v0NegPx, v0NegPy, v0NegPz; + // float dcaV0dau, dcaPosToPV, dcaNegToPV, v0cosPA; + float posTrackX, negTrackX; + o2::track::TrackParCov trackParCovV0DaughPos; + o2::track::TrackParCov trackParCovV0DaughNeg; + + // const auto& trackV0DaughPos = v0.posTrack_as(); + // const auto& trackV0DaughNeg = v0.negTrack_as(); + + 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]; + } + // dcaV0dau = v0.dcaV0daughters(); + // dcaPosToPV = v0.dcapostopv(); + // dcaNegToPV = v0.dcanegtopv(); + // v0cosPA = v0.v0cosPA(); + + 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 { + // LOG(info) << "Vertexing succeeded for Lc candidate"; + } + } catch (const std::runtime_error& error) { + // LOG(info) << "Run time error found: " << error.what() << ". DCAFitterN cannot work, skipping the candidate."; + continue; + } + if (firstprimarytrack == 0) { + histos.fill(HIST("hInvMassKs0"), v0.mK0Short()); + } + + 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 + pVecCand = RecoDecay::pVec(pVecV0, pVecBach); + + const auto& secondaryVertex = df.getPCACandidate(); + auto chi2PCA = df.getChi2AtPCACandidate(); + if (chi2PCA > cutchi2PCA) { + continue; + } + // auto covMatrixPCA = df.calcPCACovMatrixFlat(); + if (firstprimarytrack == 0) { + histos.fill(HIST("hchi2PCA"), chi2PCA); + } + // get track impact parameters + // This modifies track momenta! + auto primaryVertex = getPrimaryVertex(collision); + // auto covMatrixPV = primaryVertex.getCov(); + o2::dataformats::DCA impactParameter0; + o2::dataformats::DCA impactParameter1; + trackV0.propagateToDCA(primaryVertex, bz, &impactParameter0); + trackParCovBach.propagateToDCA(primaryVertex, bz, &impactParameter1); + + // get uncertainty of the decay length + 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; + + double protonimpactparameter = impactParameter1.getY(); + // double kshortimpactparameter=impactParameter0.getY(); + + 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 lambdaclifetime = (decaylength * Lambdac.M()) / Lambdac.P(); + // if (lambdaclifetime > cutmaxctaulambdac) { + // continue; + // } + double anglesign = decaylengthx * Lambdac.Px() + decaylengthy * Lambdac.Py() + decaylengthz * Lambdac.Pz(); + double CPAlambdac = anglesign / (decaylength * Lambdac.P()); + anglesign = anglesign / TMath::Abs(anglesign); + auto signprotonimpactparameter = protonimpactparameter * anglesign; + if (firstprimarytrack == 0) { + histos.fill(HIST("hDcaxy"), track1.dcaXY()); + histos.fill(HIST("hunsignprotonDca"), protonimpactparameter); + histos.fill(HIST("hsignCPALambdac"), TMath::Abs(CPAlambdac)); + histos.fill(HIST("hsignprotonDca"), signprotonimpactparameter); + } + firstprimarytrack = firstprimarytrack + 1; + auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); + v2 = TMath::Cos(2.0 * phiminuspsi); + // if (TMath::Abs(CPAlambdac) > cutCPAlambdac && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { + if (Lambdac.M() > 2.18 && Lambdac.M() <= 2.42 && TMath::Abs(Lambdac.Rapidity()) < confRapidity && Lambdac.Pt() > 2 && Lambdac.Pt() <= 6.0) { + if (!useDecayLengthxy) { + histos.fill(HIST("hSparseV2SASameEvent_V2_EP"), Lambdac.M(), Lambdac.Pt(), v2, Proton.Pt(), decaylength, TMath::Abs(track1.dcaXY())); + } + if (useDecayLengthxy) { + histos.fill(HIST("hSparseV2SASameEvent_V2_EP"), Lambdac.M(), Lambdac.Pt(), v2, Proton.Pt(), decaylengthxy, TMath::Abs(track1.dcaXY())); + } + } + 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 rotKshortPx = Kshort.Px() * std::cos(rotangle) - Kshort.Py() * std::sin(rotangle); + auto rotKshortPy = Kshort.Px() * std::sin(rotangle) + Kshort.Py() * std::cos(rotangle); + KshortRot = ROOT::Math::PxPyPzMVector(rotKshortPx, rotKshortPy, Kshort.pz(), massK0s); + LambdacRot = Proton + KshortRot; + auto phiminuspsiRot = GetPhiInRange(LambdacRot.Phi() - psiFT0C); + v2Rot = TMath::Cos(2.0 * phiminuspsiRot); + // double CPAlambdacRot = (decaylengthx * LambdacRot.Px() + decaylengthy * LambdacRot.Py() + decaylengthz * LambdacRot.Pz()) / (decaylength * LambdacRot.P()); + // if (TMath::Abs(CPAlambdacRot) > cutCPAlambdac && LambdacRot.M() > 2.18 && LambdacRot.M() <= 2.42) { + if (LambdacRot.M() > 2.18 && LambdacRot.M() <= 2.42 && TMath::Abs(LambdacRot.Rapidity()) < confRapidity && LambdacRot.Pt() > 2 && LambdacRot.Pt() <= 6.0) { + if (!useDecayLengthxy) { + histos.fill(HIST("hSparseV2SASameEventRotational_V2_EP"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, Proton.Pt(), decaylength, TMath::Abs(track1.dcaXY())); + } + if (useDecayLengthxy) { + histos.fill(HIST("hSparseV2SASameEventRotational_V2_EP"), LambdacRot.M(), LambdacRot.Pt(), v2Rot, Proton.Pt(), decaylengthxy, TMath::Abs(track1.dcaXY())); + } + } + } + + // 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 (fillPolarization) { + // 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); + // } + // } + } + } + } + PROCESS_SWITCH(highmasslambdasvx, processSameEvent, "Process Same event", true); + /* void processMixedEventOpti(EventCandidates const& collisions, TrackCandidates const& tracks, AllTrackCandidates const&, ResoV0s const& V0s) + { + auto tracksV0sTuple = std::make_tuple(tracks, V0s); + 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() || !collision2.sel8()) { + continue; + } + if (!collision1.triggereventep() || !collision2.triggereventep()) { + 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.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + if (additionalEvSel2 && (!collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + auto centrality = collision1.centFT0C(); + auto psiFT0C = collision1.psiFT0C(); + auto QFT0C = collision1.qFT0C(); + int occupancy = collision1.trackOccupancyInTimeRange(); + for (auto& [track1, v0] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { + if (!selectionTrack(track1)) { + continue; + } + // PID check + if (ispTdepPID && !selectionPIDNew(track1)) { + continue; + } + if (!ispTdepPID && !selectionPID(track1)) { + continue; + } + if (!SelectionV0(collision2, v0)) { + continue; + } + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + if (!isSelectedV0Daughter(postrack, 1)) { + continue; + } + if (!isSelectedV0Daughter(negtrack, -1)) { + continue; + } + + Proton = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPr); + Kshort = ROOT::Math::PxPyPzMVector(v0.px(), v0.py(), v0.pz(), massK0s); + Lambdac = Proton + Kshort; + if (TMath::Abs(Lambdac.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(Lambdac.Phi() - psiFT0C); + 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); + auto dcasum = 0.0; + if (useSignDCAV0) { + dcasum = anglesign * (v0.dcav0topv()) - track1.dcaXY(); + } + if (!useSignDCAV0) { + dcasum = TMath::Sqrt((track1.dcaXY() + (v0.dcav0topv())) * (track1.dcaXY() + (v0.dcav0topv()))); + } + // auto diffangle = Proton.Phi() - Lambdac.Phi(); + // auto decaylength = TMath::Abs((track1.dcaXY() / TMath::Sin(diffangle)) / (Lambdac.P() / 2.286)); + // auto dcasum = TMath::Sqrt(track1.dcaXY() * track1.dcaXY() + v0.dcav0topv() * v0.dcav0topv()); + if (fillDefault && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { + if (fillDecayLength) { + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), Lambdac.M(), Lambdac.Pt(), v2, dcasum); + } + histos.fill(HIST("hSparseV2SAMixedEvent_V2_new"), Lambdac.M(), Lambdac.Pt(), v2, TMath::Abs(track1.dcaXY()), Proton.Pt()); + } + if (fillOccupancy && Lambdac.M() > 2.18 && Lambdac.M() <= 2.42) { + if (fillDecayLength) { + histos.fill(HIST("hSparseV2SAMixedEvent_V2_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, dcasum, TMath::Abs(track1.dcaXY()), occupancy); + } + histos.fill(HIST("hSparseV2SAMixedEvent_V2_new_occupancy"), Lambdac.M(), Lambdac.Pt(), v2, TMath::Abs(track1.dcaXY()), Proton.Pt(), occupancy); + } + 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 (fillPolarization) { + 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); + } + } + } + } + } + PROCESS_SWITCH(highmasslambdasvx, processMixedEventOpti, "Process Mixed event new", true);*/ +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"highmasslambdasvx"})}; +} diff --git a/PWGLF/Tasks/Resonances/k1analysis.cxx b/PWGLF/Tasks/Resonances/k1analysis.cxx index e3599531046..7d145eff641 100644 --- a/PWGLF/Tasks/Resonances/k1analysis.cxx +++ b/PWGLF/Tasks/Resonances/k1analysis.cxx @@ -27,55 +27,96 @@ #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; struct k1analysis { + 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 - Configurable cUseOnlyTOFTrackKa{"cUseOnlyTOFTrackKa", false, "Use only TOF track for PID selection"}; // Use only TOF track for Kaon 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 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 cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; // PV Contriuibutor - - // bachelor pion TOF PID? - Configurable cDoTOFPID{"cDoTOFPID", 1, "Do TOF PID"}; - - // K(892)0 selection - Configurable cK892masswindow{"cK892masswindow", 0.1, "K(892)0 inv mass selection window"}; - Configurable cPiPiMin{"cPiPiMin", 0, "Pion pair inv mass selection minimum"}; - Configurable cPiPiMax{"cPiPiMax", 999, "Pion pair inv mass selection maximum"}; - Configurable cPiKaMin{"cPiKaMin", 0, "bPion-Kaon pair inv mass selection minimum"}; - Configurable cPiKaMax{"cPiKaMax", 999, "bPion-Kaon pair inv mass selection maximum"}; + 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 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 + Configurable cfgModeK892orRho{"cfgModeK892orRho", true, "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"}; @@ -92,108 +133,174 @@ struct k1analysis { 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{xy}} (cm)"}; - AxisSpec invMassAxis = {900, 0.6, 1.5, "Invariant Mass (GeV/#it{c}^2)"}; // K(892)0 - AxisSpec invMassAxisReso = {1600, 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 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"}; - // Mass QA (quick check) - histos.add("k892invmass", "Invariant mass of K(892)0", HistType::kTH1F, {invMassAxis}); - histos.add("k1invmass", "Invariant mass of K1(1270)pm", HistType::kTH1F, {invMassAxisReso}); - histos.add("k1invmass_LS", "Invariant mass of K1(1270)pm", HistType::kTH1F, {invMassAxisReso}); - histos.add("k1invmass_Mix", "Invariant mass of K1(1270)pm", HistType::kTH1F, {invMassAxisReso}); - if (doprocessMC) { - histos.add("k1invmass_MC", "Invariant mass of K1(1270)pm", HistType::kTH1F, {invMassAxisReso}); - } + // 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 - histos.add("QA/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QA/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QA/trkDCAxy_pi_bach", "DCAxy distribution of bachelor pion track candidates", HistType::kTH1F, {dcaxyAxis}); - histos.add("QA/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); - histos.add("QA/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {dcazAxis}); - histos.add("QA/trkDCAz_pi_bach", "DCAz distribution of bachelor pion track candidates", HistType::kTH1F, {dcazAxis}); - - // pT QA - histos.add("QA/trkpT_pi", "pT distribution of pion track candidates", HistType::kTH1F, {ptAxis}); - histos.add("QA/trkpT_ka", "pT distribution of kaon track candidates", HistType::kTH1F, {ptAxis}); - histos.add("QA/trkpT_pi_bach", "pT distribution of bachelor pion track candidates", HistType::kTH1F, {ptAxis}); - // PID QA after cuts - histos.add("QA/TOF_TPC_Map_pi", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QA/TOF_Nsigma_pi", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/TPC_Nsigma_pi", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/TOF_TPC_Map_ka", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QA/TOF_Nsigma_ka", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/TPC_Nsigmaka", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/TOF_TPC_Map_pi_bach", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QA/TOF_Nsigma_pi_bach", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/TPC_Nsigma_pi_bach", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH2F, {ptAxis, pidQAAxis}}); - histos.add("QA/InvMass_piK_pipi", "Invariant mass of pion + kaon and pion+pion;Invariant Mass (GeV/#it{c}^{2});Invariant Mass (GeV/#it{c}^{2});", {HistType::kTH2F, {invMassAxisScan, invMassAxisScan}}); - histos.add("QA/InvMass_piK_pika", "Invariant mass of pion + kaon and pion+kaon;Invariant Mass (GeV/#it{c}^{2});Invariant Mass (GeV/#it{c}^{2});", {HistType::kTH2F, {invMassAxisScan, invMassAxisScan}}); - histos.add("QA/K1OA", "Opening angle of K1(1270)pm", HistType::kTH1F, {AxisSpec{100, 0, 3.14, "Opening angle of K1(1270)pm"}}); - histos.add("QA/K1PairAsymm", "Pair asymmetry of K1(1270)pm", HistType::kTH1F, {AxisSpec{100, -1, 1, "Pair asymmetry of K1(1270)pm"}}); - - // Invariant mass histograms - histos.add("hK892invmass_PP", "Invariant mass of K(892)0 (Matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("hK892invmass_NP", "Invariant mass of K(892)0 (Matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("hK892invmass_PN", "Invariant mass of K(892)0 (Anti-matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("hK892invmass_NN", "Invariant mass of K(892)0 (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("hK1invmass_NPP", "Invariant mass of K(892)0 + pion (Matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_NPN", "Invariant mass of K(892)0 + pion (Matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PNP", "Invariant mass of K(892)0 + pion (Anti-matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PNN", "Invariant mass of K(892)0 + pion (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - // K892-LS bkg - histos.add("hK1invmass_PPP", "Invariant mass of K(892)0 + pion (Matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PPN", "Invariant mass of K(892)0 + pion (Anti-matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_NNP", "Invariant mass of K(892)0 + pion (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_NNN", "Invariant mass of K(892)0 + pion (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - // Mixed event - histos.add("hK1invmass_NPP_Mix", "Invariant mass of K(892)0 + pion (Matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_NPN_Mix", "Invariant mass of K(892)0 + pion (Matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PNP_Mix", "Invariant mass of K(892)0 + pion (Anti-matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PNN_Mix", "Invariant mass of K(892)0 + pion (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); + // Primary pion + histos.add("QA/trkppionDCAxy", "DCAxy distribution of primary pion candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkppionDCAz", "DCAz distribution of primary pion candidates", HistType::kTH1F, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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/K1PairAssym", "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, {invMassAxisK892, 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/K1PairAssym", "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, {invMassAxisK892, 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)", HistType::kTHnSparseD, {axisAnti, axisType, centAxis, ptAxis, invMassAxisReso}); + // Mass QA (quick check) + histos.add("k1invmass", "Invariant mass of K1(1270)", HistType::kTH1F, {invMassAxisReso}); + histos.add("k1invmass_Mix", "Invariant mass of K1(1270)", HistType::kTH1F, {invMassAxisReso}); + // MC if (doprocessMC) { - histos.add("QAMC/InvMass_piK_pipi", "Invariant mass of pion + kaon and pion+pion;Invariant Mass (GeV/#it{c}^{2});Invariant Mass (GeV/#it{c}^{2});", {HistType::kTH2F, {invMassAxisScan, invMassAxisScan}}); - histos.add("QAMC/InvMass_piK_pika", "Invariant mass of pion + kaon and pion+kaon;Invariant Mass (GeV/#it{c}^{2});Invariant Mass (GeV/#it{c}^{2});", {HistType::kTH2F, {invMassAxisScan, invMassAxisScan}}); - histos.add("QAMC/K1OA", "Opening angle of K1(1270)pm", HistType::kTH1F, {AxisSpec{100, 0, 3.14, "Opening angle of K1(1270)pm"}}); - histos.add("QAMC/K1PairAsymm", "Pair asymmetry of K1(1270)pm", HistType::kTH1F, {AxisSpec{100, 0, 1, "Pair asymmetry of K1(1270)pm"}}); - - histos.add("hK1invmass_NPP_MC", "Invariant mass of K(892)0 + pion (Matter + Matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - histos.add("hK1invmass_PNN_MC", "Invariant mass of K(892)0 + pion (Anti-matter + Anti-matter)", HistType::kTH3F, {centAxis, ptAxis, invMassAxisReso}); - - histos.add("hReconK892pt", "pT distribution of Reconstructed MC K(892)0", HistType::kTH1F, {ptAxis}); - histos.add("hTrueK1pt", "pT distribution of True MC K1", HistType::kTH1F, {ptAxis}); - histos.add("hReconK1pt", "pT distribution of Reconstructed MC K1", HistType::kTH1F, {ptAxis}); - - histos.add("k1invmass_noK1", "Invariant mass of K1(1270)pm", HistType::kTH1F, {invMassAxisReso}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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, {dcaxyAxis}); + 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/K1PairAssym", "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, {invMassAxisK892, 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}); } // Print output histograms statistics - LOG(info) << "Size of the histograms in spectraTOF"; + LOG(info) << "Size of the histograms in K1 Analysis Task"; histos.print(); } - double massKa = TDatabasePDG::Instance()->GetParticle(kKPlus)->Mass(); // FIXME: Get from the common header - double massPi = TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(); // FIXME: Get from the common header - double massK892 = TDatabasePDG::Instance()->GetParticle(313)->Mass(); // FIXME: Get from the common header + double massKa = MassKaonCharged; + double massPi = MassPionCharged; + // double massRho770 = MassRho770; + // double massK892 = MassKStar892; + double massRho770 = 0.77526; + double massK892 = 0.892; + + // PDG code + int kPDGRho770 = 113; + int kK1Plus = 10323; template bool trackCut(const TrackType track) { // basic track cuts - if (track.pt() < cMinPtcut) + 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.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) + return false; + if (track.itsChi2NCl() >= cfgITSChi2NCl) return false; - if (track.dcaXY() > cMaxDCArToPVcut) + if (track.tpcChi2NCl() >= cfgTPCChi2NCl) return false; - if (track.dcaZ() < cMinDCAzToPVcut || track.dcaZ() > cMaxDCAzToPVcut) + 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 (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - if (cfgPVContributor && !track.isPVContributor()) + if (cfgGlobalTrack && !track.isGlobalTrack()) return false; + return true; } @@ -204,6 +311,8 @@ struct k1analysis { 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) { @@ -213,6 +322,9 @@ struct k1analysis { tofPIDPassed = true; } } else { + if (!cTOFVeto) { + return false; + } tofPIDPassed = true; } if (tpcPIDPassed && tofPIDPassed) { @@ -226,6 +338,8 @@ struct k1analysis { 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) { @@ -235,6 +349,9 @@ struct k1analysis { tofPIDPassed = true; } } else { + if (!cTOFVeto) { + return false; + } tofPIDPassed = true; } if (tpcPIDPassed && tofPIDPassed) { @@ -245,6 +362,42 @@ struct k1analysis { template bool isTrueK1(const T& trk1, const T& trk2, const T2& bTrack) + { + if (abs(trk1.pdgCode()) != kPiPlus || abs(trk2.pdgCode()) != kKPlus) + return false; + if (abs(bTrack.pdgCode()) != kPiPlus) + return false; + if (cfgModeK892orRho) { // K892 mode + auto mother1 = trk1.motherId(); + auto mother2 = trk2.motherId(); + if (mother1 != mother2) + return false; + if (abs(trk1.motherPDG()) != kK0Star892) + return false; + if (abs(bTrack.motherPDG()) != kK1Plus) + return false; + auto siblings = bTrack.siblingIds(); + if (siblings[0] != mother1 && siblings[1] != mother1) + return false; + return true; + } else { // Rho mode + auto mother1 = trk1.motherId(); + auto motherb = bTrack.motherId(); + if (mother1 != motherb) + return false; + if (abs(trk1.motherPDG()) != kPDGRho770) + return false; + if (abs(trk2.motherPDG()) != kK1Plus) + return false; + auto siblings = trk2.siblingIds(); + if (siblings[0] != mother1 && siblings[1] != mother1) + return false; + return true; + } + } + + template + bool isTrueK892(const T& trk1, const T& trk2) { if (abs(trk1.pdgCode()) != kPiPlus || abs(trk2.pdgCode()) != kKPlus) return false; @@ -252,29 +405,21 @@ struct k1analysis { auto mother2 = trk2.motherId(); if (mother1 != mother2) return false; - if (abs(trk1.motherPDG()) != 313) - return false; - if (abs(bTrack.pdgCode()) != kPiPlus) - return false; - if (abs(bTrack.motherPDG()) != 10323) + if (abs(trk1.motherPDG()) != kK0Star892) return false; - auto siblings = bTrack.siblingIds(); - if (siblings[0] != mother1 && siblings[1] != mother1) - return false; - return true; } template - bool isTrueK892(const T& trk1, const T& trk2) + bool isTrueRho(const T& trk1, const T& trk2) { - if (abs(trk1.pdgCode()) != kPiPlus || abs(trk2.pdgCode()) != kKPlus) + if (abs(trk1.pdgCode()) != kPiPlus || abs(trk2.pdgCode()) != kPiPlus) return false; auto mother1 = trk1.motherId(); auto mother2 = trk2.motherId(); if (mother1 != mother2) return false; - if (abs(trk1.motherPDG()) != 313) + if (abs(trk1.motherPDG()) != kPDGRho770) return false; return true; } @@ -283,7 +428,7 @@ struct k1analysis { void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) { auto multiplicity = collision.cent(); - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonanceK892, lDecayDaughter_bach, lResonanceK1; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonanceSecondary, lDecayDaughter_bach, lResonanceK1; for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks2, dTracks2))) { // Full index policy is needed to consider all possible combinations if (trk1.index() == trk2.index()) @@ -295,211 +440,217 @@ struct k1analysis { auto isTrk1hasTOF = trk1.hasTOF(); auto isTrk2hasTOF = trk2.hasTOF(); - auto trk1ptPi = trk1.pt(); + auto trk1pt = trk1.pt(); auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; - auto trk2ptKa = trk2.pt(); + auto trk2pt = trk2.pt(); auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; + // for rho mode + auto trk2NSigmaPiTPC = trk2.tpcNSigmaPi(); + auto trk2NSigmaPiTOF = (isTrk2hasTOF) ? trk2.tofNSigmaPi() : -999.; //// PID selections if (cUseOnlyTOFTrackPi && !isTrk1hasTOF) continue; if (cUseOnlyTOFTrackKa && !isTrk2hasTOF) continue; - if (!selectionPIDPion(trk1) || !selectionPIDKaon(trk2)) - continue; + + if (cfgModeK892orRho) { // K892 mode + if (!selectionPIDPion(trk1) || !selectionPIDKaon(trk2)) + continue; + } else { // Rho mode + if (!selectionPIDPion(trk1) || !selectionPIDPion(trk2)) + continue; + } //// QA plots after the selection - // --- PID QA Pion if constexpr (!IsMix) { - histos.fill(HIST("QA/TPC_Nsigma_pi"), trk1ptPi, trk1NSigmaPiTPC); + // --- PID QA Pion + histos.fill(HIST("QA/trkspionTPCPID"), trk1pt, trk1NSigmaPiTPC); if (isTrk1hasTOF) { - histos.fill(HIST("QA/TOF_Nsigma_pi"), trk1ptPi, trk1NSigmaPiTOF); - histos.fill(HIST("QA/TOF_TPC_Map_pi"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + histos.fill(HIST("QA/trkspionTOFPID"), trk1pt, trk1NSigmaPiTOF); + histos.fill(HIST("QA/trkspionTPCTOFPID"), trk1NSigmaPiTPC, trk1NSigmaPiTOF); } - // --- PID QA Kaon - histos.fill(HIST("QA/TPC_Nsigmaka"), trk2ptKa, trk2NSigmaKaTPC); - if (isTrk1hasTOF) { - histos.fill(HIST("QA/TOF_Nsigma_ka"), trk2ptKa, trk2NSigmaKaTOF); - histos.fill(HIST("QA/TOF_TPC_Map_ka"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + histos.fill(HIST("QA/trkspionpT"), trk1pt); + histos.fill(HIST("QA/trkspionDCAxy"), trk1.dcaXY()); + histos.fill(HIST("QA/trkspionDCAz"), trk1.dcaZ()); + + if (cfgModeK892orRho) { // K892 mode + // --- PID QA Kaon + histos.fill(HIST("QA/trkkaonTPCPID"), trk2pt, trk2NSigmaKaTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/trkkaonTOFPID"), trk2pt, trk2NSigmaKaTOF); + histos.fill(HIST("QA/trkkaonTPCTOFPID"), trk2NSigmaKaTPC, trk2NSigmaKaTOF); + } + histos.fill(HIST("QA/trkkaonpT"), trk2pt); + histos.fill(HIST("QA/trkkaonDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QA/trkkaonDCAz"), trk2.dcaZ()); + } else { // Rho mode + // --- PID QA Pion + histos.fill(HIST("QA/trkppionTPCPID"), trk2pt, trk2NSigmaPiTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/trkppionTOFPID"), trk2pt, trk2NSigmaPiTOF); + histos.fill(HIST("QA/trkppionTPCTOFPID"), trk2NSigmaPiTPC, trk2NSigmaPiTOF); + } + histos.fill(HIST("QA/trkppionpT"), trk2pt); + histos.fill(HIST("QA/trkppionDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QA/trkppionDCAz"), trk2.dcaZ()); } - histos.fill(HIST("QA/trkpT_pi"), trk1ptPi); - histos.fill(HIST("QA/trkpT_ka"), trk2ptKa); - - histos.fill(HIST("QA/trkDCAxy_pi"), trk1.dcaXY()); - histos.fill(HIST("QA/trkDCAxy_ka"), trk2.dcaXY()); - histos.fill(HIST("QA/trkDCAz_pi"), trk1.dcaZ()); - histos.fill(HIST("QA/trkDCAz_ka"), trk2.dcaZ()); } //// Resonance reconstruction lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); - lResonanceK892 = lDecayDaughter1 + lDecayDaughter2; + lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), (cfgModeK892orRho) ? massKa : massPi); + lResonanceSecondary = lDecayDaughter1 + lDecayDaughter2; if constexpr (!IsMix) { - histos.fill(HIST("k892invmass"), lResonanceK892.M()); // quick check - if (trk1.sign() > 0) { // Positive pion - if (trk2.sign() > 0) // Positive kaon - histos.fill(HIST("hK892invmass_PP"), multiplicity, lResonanceK892.Pt(), lResonanceK892.M()); - else // Negative kaon - histos.fill(HIST("hK892invmass_PN"), multiplicity, lResonanceK892.Pt(), lResonanceK892.M()); // Anti-K(892)0 - } else { // Negative pion - if (trk2.sign() > 0) // Positive kaon - histos.fill(HIST("hK892invmass_NP"), multiplicity, lResonanceK892.Pt(), lResonanceK892.M()); // K(892)0 - else // Negative kaon - histos.fill(HIST("hK892invmass_NN"), multiplicity, lResonanceK892.Pt(), lResonanceK892.M()); - } + histos.fill(HIST("QA/hInvmassSecon"), lResonanceSecondary.M()); } - // Like-sign rejection for K(892)0 - disabled for further LS bkg study - // if (trk1.sign() * trk2.sign() > 0) - // continue; - if constexpr (IsMC) { // MC Check of K(892)0 - if (isTrueK892(trk1, trk2)) - histos.fill(HIST("hReconK892pt"), lResonanceK892.Pt()); + if constexpr (IsMC) { // MC Check + if (cfgModeK892orRho) { + 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()); + } } // Mass window cut - if (std::abs(lResonanceK892.M() - massK892) > cK892masswindow) + double massCut = cfgModeK892orRho ? massK892 : massRho770; + if (std::abs(lResonanceSecondary.M() - massCut) > cSecondaryMasswindow) continue; - // Add one more track loop for K1 reconstruction + + // bTrack loop for K1 reconstruction for (auto bTrack : dTracks1) { - // ID cut if (bTrack.index() == trk1.index() || bTrack.index() == trk2.index()) continue; - // Track cut if (!trackCut(bTrack)) continue; - auto bTrkPt = bTrack.pt(); - auto bTrkTPCnSigmaPi = bTrack.tpcNSigmaPi(); - auto isbTrkhasTOF = bTrack.hasTOF(); - auto bTrack_TOFnSigma = (isbTrkhasTOF) ? bTrack.tofNSigmaPi() : -999.; - - // PID selection - if (!selectionPIDPion(bTrack)) + // Kaon or Pion + if (cfgModeK892orRho && !selectionPIDPion(bTrack)) + continue; + if (!cfgModeK892orRho && !selectionPIDKaon(bTrack)) continue; - - if constexpr (!IsMix) { - histos.fill(HIST("QA/trkpT_pi_bach"), bTrkPt); - // --- PID QA Pion - histos.fill(HIST("QA/TPC_Nsigma_pi_bach"), bTrkPt, bTrkTPCnSigmaPi); - if (isbTrkhasTOF) { - histos.fill(HIST("QA/TOF_Nsigma_pi_bach"), bTrkPt, bTrack_TOFnSigma); - histos.fill(HIST("QA/TOF_TPC_Map_pi_bach"), bTrack_TOFnSigma, bTrkTPCnSigmaPi); - } - histos.fill(HIST("QA/trkDCAxy_pi_bach"), bTrack.dcaXY()); - histos.fill(HIST("QA/trkDCAz_pi_bach"), bTrack.dcaZ()); - } // K1 reconstruction - lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), massPi); - lResonanceK1 = lResonanceK892 + lDecayDaughter_bach; + lDecayDaughter_bach.SetXYZM(bTrack.px(), bTrack.py(), bTrack.pz(), cfgModeK892orRho ? massPi : massKa); + lResonanceK1 = lResonanceSecondary + lDecayDaughter_bach; - // Rapidity cut + // Cuts if (lResonanceK1.Rapidity() > cK1MaxRap || lResonanceK1.Rapidity() < cK1MinRap) continue; - // Opening angle cut - auto lK1Angle = lResonanceK892.Angle(lDecayDaughter_bach.Vect()); - // Pair asymmetry cut - auto lPairAsym = (lResonanceK892.E() - lDecayDaughter_bach.E()) / (lResonanceK892.E() + lDecayDaughter_bach.E()); - // PiPi, PiKa mass range cut - TLorentzVector tempPiPi = lDecayDaughter1 + lDecayDaughter_bach; - TLorentzVector tempPiKa = lDecayDaughter2 + lDecayDaughter_bach; + + 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 histograms if constexpr (!IsMix) { - histos.fill(HIST("QA/InvMass_piK_pipi"), lResonanceK892.M(), tempPiPi.M()); - histos.fill(HIST("QA/InvMass_piK_pika"), lResonanceK892.M(), tempPiKa.M()); histos.fill(HIST("QA/K1OA"), lK1Angle); - histos.fill(HIST("QA/K1PairAsymm"), lPairAsym); + histos.fill(HIST("QA/K1PairAssym"), lPairAsym); + if (cfgModeK892orRho) { + histos.fill(HIST("QA/hInvmassK892_Rho"), lResonanceSecondary.M(), temp13.M()); + } else { + 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()); } - if (tempPiPi.M() < cPiPiMin || tempPiPi.M() > cPiPiMax) + + // Selection cuts + if (temp13.M() < cMinAnotherSecondaryMassCut || temp13.M() > cMaxAnotherSecondaryMassCut) continue; - if (tempPiKa.M() < cPiKaMin || tempPiKa.M() > cPiKaMax) + if (temp23.M() < cMinPiKaMassCut || temp23.M() > cMaxPiKaMassCut) continue; if (lK1Angle < cMinAngle || lK1Angle > cMaxAngle) continue; if (lPairAsym < cMinPairAsym || lPairAsym > cMaxPairAsym) continue; - if constexpr (!IsMix) { // Same event pair - if (trk1.sign() * trk2.sign() < 0) { // K892 - if (bTrack.sign() > 0) { // bachelor pi+ - if (trk2.sign() > 0) { // kaon + means K(892)0 is matter. - histos.fill(HIST("k1invmass"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_NPP"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } else { - histos.fill(HIST("k1invmass_LS"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_PNP"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } - } else { // bachelor pi- - if (trk2.sign() > 0) { // kaon + means K(892)0 is matter. - histos.fill(HIST("k1invmass_LS"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_NPN"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } else { - histos.fill(HIST("k1invmass"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_PNN"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } - } - } else { // K892-LS (false) - if (bTrack.sign() > 0) { // bachelor pi+ - if (trk2.sign() > 0) { // Kaon+ - histos.fill(HIST("hK1invmass_PPP"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } else { - histos.fill(HIST("hK1invmass_PPN"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } - } else { // bachelor pi- - if (trk2.sign() > 0) { // Kaon_ - histos.fill(HIST("hK1invmass_NNN"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } else { - histos.fill(HIST("hK1invmass_NNP"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } - } + // QA histograms after the cuts + if constexpr (!IsMix) { + histos.fill(HIST("QAcut/K1OA"), lK1Angle); + histos.fill(HIST("QAcut/K1PairAssym"), lPairAsym); + if (cfgModeK892orRho) { + histos.fill(HIST("QAcut/hInvmassK892_Rho"), lResonanceSecondary.M(), temp13.M()); + } else { + histos.fill(HIST("QAcut/hInvmassK892_Rho"), temp13.M(), lResonanceSecondary.M()); } + histos.fill(HIST("QAcut/hInvmassSecon_PiKa"), lResonanceSecondary.M(), temp23.M()); + histos.fill(HIST("QAcut/hInvmassSecon"), lResonanceSecondary.M()); + histos.fill(HIST("QAcut/hpT_Secondary"), lResonanceSecondary.Pt()); + } + + if constexpr (!IsMix) { + unsigned int typeK1 = bTrack.sign() > 0 ? binType::kK1P : binType::kK1N; + unsigned int typeNormal = cfgModeK892orRho ? (trk1.sign() < 0 ? binAnti::kNormal : binAnti::kAnti) : binAnti::kNormal; + histos.fill(HIST("k1invmass"), lResonanceK1.M()); + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); if constexpr (IsMC) { if (isTrueK1(trk1, trk2, bTrack)) { - histos.fill(HIST("hReconK1pt"), lResonanceK1.Pt()); - histos.fill(HIST("QAMC/InvMass_piK_pipi"), lResonanceK892.M(), tempPiPi.M()); - histos.fill(HIST("QAMC/InvMass_piK_pika"), lResonanceK892.M(), tempPiKa.M()); + 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/K1PairAsymm"), lPairAsym); - - if ((bTrack.sign() > 0) && (trk2.sign() > 0)) { // Matter - histos.fill(HIST("hK1invmass_NPP_MC"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - histos.fill(HIST("k1invmass_MC"), lResonanceK1.M()); // quick check - } - if ((bTrack.sign() < 0) && (trk2.sign() < 0)) { // Anti-matter - histos.fill(HIST("hK1invmass_PNN_MC"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - histos.fill(HIST("k1invmass_MC"), lResonanceK1.M()); // quick check - } - histos.fill(HIST("hTrueK1pt"), lResonanceK1.Pt()); - } else { - if (((bTrack.sign() > 0) && (trk2.sign() > 0)) || ((bTrack.sign() < 0) && (trk2.sign() < 0))) - histos.fill(HIST("k1invmass_noK1"), lResonanceK1.M()); // quick check - } - } - } else { // Mixed event pair - if (trk1.sign() * trk2.sign() < 0) { // K892 - if (bTrack.sign() > 0) { // bachelor pi+ - if (trk2.sign() > 0) { // kaon + means K(892)0 is matter. - histos.fill(HIST("k1invmass_Mix"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_NPP_Mix"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("QAMC/K1PairAssym"), lPairAsym); + if (cfgModeK892orRho) { + histos.fill(HIST("QAMC/hInvmassK892_Rho"), lResonanceSecondary.M(), temp13.M()); } else { - histos.fill(HIST("hK1invmass_PNP_Mix"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("QAMC/hInvmassK892_Rho"), temp13.M(), lResonanceSecondary.M()); } - } else { // bachelor pi- - if (trk2.sign() > 0) { // kaon + means K(892)0 is matter. - histos.fill(HIST("hK1invmass_NPN_Mix"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); - } else { - histos.fill(HIST("k1invmass_Mix"), lResonanceK1.M()); // quick check - histos.fill(HIST("hK1invmass_PNN_Mix"), multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("QAMC/hInvmassSecon_PiKa"), lResonanceSecondary.M(), temp23.M()); + histos.fill(HIST("QAMC/hInvmassSecon"), lResonanceSecondary.M()); + histos.fill(HIST("QAMC/hpT_Secondary"), lResonanceSecondary.Pt()); + + // --- PID QA Pion + histos.fill(HIST("QAMC/trkspionTPCPID"), trk1pt, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAMC/trkspionTOFPID"), trk1pt, trk1NSigmaPiTOF); + histos.fill(HIST("QAMC/trkspionTPCTOFPID"), trk1NSigmaPiTPC, trk1NSigmaPiTOF); + } + histos.fill(HIST("QAMC/trkspionpT"), trk1pt); + histos.fill(HIST("QAMC/trkspionDCAxy"), trk1.dcaXY()); + histos.fill(HIST("QAMC/trkspionDCAz"), trk1.dcaZ()); + + if (cfgModeK892orRho) { // K892 mode + // --- PID QA Kaon + histos.fill(HIST("QAMC/trkkaonTPCPID"), trk2pt, trk2NSigmaKaTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAMC/trkkaonTOFPID"), trk2pt, trk2NSigmaKaTOF); + histos.fill(HIST("QAMC/trkkaonTPCTOFPID"), trk2NSigmaKaTPC, trk2NSigmaKaTOF); + } + histos.fill(HIST("QAMC/trkkaonpT"), trk2pt); + histos.fill(HIST("QAMC/trkkaonDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QAMC/trkkaonDCAz"), trk2.dcaZ()); + } else { // Rho mode + // --- PID QA Pion + histos.fill(HIST("QAMC/trkppionTPCPID"), trk2pt, trk2NSigmaPiTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAMC/trkppionTOFPID"), trk2pt, trk2NSigmaPiTOF); + histos.fill(HIST("QAMC/trkppionTPCTOFPID"), trk2NSigmaPiTPC, trk2NSigmaPiTOF); + } + histos.fill(HIST("QAMC/trkppionpT"), trk2pt); + histos.fill(HIST("QAMC/trkppionDCAxy"), trk2.dcaXY()); + histos.fill(HIST("QAMC/trkppionDCAz"), trk2.dcaZ()); } + } else { + histos.fill(HIST("k1invmass_MC_noK1"), lResonanceK1.M()); } - } + } // MC + } else { // Mixed event handling + unsigned int typeK1 = bTrack.sign() > 0 ? binType::kK1P_Mix : binType::kK1N_Mix; + unsigned int typeNormal = cfgModeK892orRho ? (trk1.sign() < 0 ? binAnti::kNormal : binAnti::kAnti) : binAnti::kNormal; + histos.fill(HIST("hInvmass_K1"), typeNormal, typeK1, multiplicity, lResonanceK1.Pt(), lResonanceK1.M()); + histos.fill(HIST("k1invmass_Mix"), lResonanceK1.M()); } - } + } // bTrack } } @@ -517,25 +668,57 @@ struct k1analysis { } PROCESS_SWITCH(k1analysis, processMC, "Process Event for MC", false); - void processMCTrue(aod::ResoMCParents& resoParents) + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents& resoParents) { - for (auto& part : resoParents) { // loop over all pre-filtered MC particles - if (abs(part.pdgCode()) != 10323) // K892(0) + auto multiplicity = collision.cent(); + for (auto& part : resoParents) { // loop over all pre-filtered MC particles + if (abs(part.pdgCode()) != kK1Plus) // K892(0) continue; if (abs(part.y()) > 0.5) { // rapidity cut continue; } bool pass1 = false; bool pass2 = false; - if (abs(part.daughterPDG1()) == 313 || abs(part.daughterPDG2()) == 313) { // At least one decay to Kaon - pass2 = true; + if (cfgModeK892orRho) { + if (abs(part.daughterPDG1()) == 313 || abs(part.daughterPDG2()) == 313) { // At least one decay to K892 + pass2 = true; + } + if (abs(part.daughterPDG1()) == kPiPlus || abs(part.daughterPDG2()) == kPiPlus) { // At least one decay to Pion + pass1 = true; + } + if (!pass1 || !pass2) // If we have both decay products + continue; + } else { + if (abs(part.daughterPDG1()) == kPDGRho770 || abs(part.daughterPDG2()) == kPDGRho770) { // At least one decay to Rho + pass2 = true; + } + if (abs(part.daughterPDG1()) == kKPlus || abs(part.daughterPDG2()) == kKPlus) { // At least one decay to Kaon + pass1 = true; + } + if (!pass1 || !pass2) // If we have both decay products + continue; } - if (abs(part.daughterPDG1()) == kPiPlus || abs(part.daughterPDG2()) == kPiPlus) { // At least one decay to Pion - pass1 = true; + auto typeNormal = part.pdgCode() > 0 ? binAnti::kNormal : binAnti::kAnti; + if (collision.isVtxIn10()) // INEL10 + { + 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); } - if (!pass1 || !pass2) // If we have both decay products - continue; - histos.fill(HIST("hTrueK1pt"), part.pt()); } } PROCESS_SWITCH(k1analysis, processMCTrue, "Process Event for MC", false); diff --git a/PWGLF/Tasks/Resonances/k892analysis.cxx b/PWGLF/Tasks/Resonances/k892analysis.cxx index 14e5f4e496e..2a980b3ffcd 100644 --- a/PWGLF/Tasks/Resonances/k892analysis.cxx +++ b/PWGLF/Tasks/Resonances/k892analysis.cxx @@ -17,6 +17,7 @@ #include #include "TF1.h" +#include "TRandom3.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Centrality.h" @@ -47,6 +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 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"}; @@ -54,6 +56,12 @@ struct k892analysis { Configurable cPIDBins{"cPIDBins", 65, "PID binning"}; 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"}; + /// 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"}; @@ -99,6 +107,12 @@ struct k892analysis { 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"}; + // MC Event selection Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; @@ -117,6 +131,7 @@ struct k892analysis { 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"}; + TRandom* rn = new TRandom(); void init(o2::framework::InitContext&) { @@ -128,6 +143,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]"}; if (additionalQAeventPlots) { // Test on Mixed event @@ -149,11 +165,15 @@ struct k892analysis { } // Mass QA (quick check) - histos.add("k892invmassDS", "Invariant mass of K(892)0 differnt sign", kTH1F, {invMassAxis}); - histos.add("k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt 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}); - histos.add("k892invmassME", "Invariant mass of K(892)0 mixed event", kTH1F, {invMassAxis}); + if (invmass1D) { + 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) { + 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}); + } + } if (additionalMEPlots) { histos.add("k892invmassME_DS", "Invariant mass of K(892)0 mixed event DS", kTH1F, {invMassAxis}); @@ -194,19 +214,21 @@ 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 - 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}}); - histos.add("QAbefore/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QAbefore/TOF_Nsigma_ka_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - histos.add("QAbefore/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - // PID QA after cuts - histos.add("QAafter/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QAafter/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - histos.add("QAafter/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - histos.add("QAafter/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); - histos.add("QAafter/TOF_Nsigma_ka_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - histos.add("QAafter/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + if (PIDplots) { + 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}}); + histos.add("QAbefore/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAbefore/TOF_Nsigma_ka_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAbefore/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + // PID QA after cuts + histos.add("QAafter/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAafter/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAafter/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAafter/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAafter/TOF_Nsigma_ka_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAafter/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + } // eta phi QA if (cfgCutsOnDaughters) { @@ -231,11 +253,18 @@ struct k892analysis { } // 3d histogram - 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}); - histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTH3F, {centAxis, ptAxis, invMassAxis}); + 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}); + + if (study_antiparticle) { + histos.add("h3k892invmassDSAnti", "Invariant mass of Anti-K(892)0 differnt sign", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); + } + + if (IsCalcRotBkg) { + histos.add("h3K892InvMassRotation", "Invariant mass of K(892)0 rotation", kTHnSparseF, {centAxis, ptAxis, invMassAxis, occupancy_axis}); + } if (additionalMEPlots) { histos.add("h3k892invmassME_DS", "Invariant mass of K(892)0 mixed event DS", kTH3F, {centAxis, ptAxis, invMassAxis}); @@ -248,14 +277,16 @@ 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}); - 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}}); - histos.add("QAMCTrue/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); - histos.add("h3Reck892invmass", "Invariant mass of Reconstructed MC K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("h3Reck892invmassAnti", "Invariant mass of Reconstructed MC Anti-K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); - histos.add("k892Gen", "pT distribution of True MC K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); - histos.add("k892GenAnti", "pT distribution of True MC Anti-K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); + if (PIDplots) { + 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}}); + histos.add("QAMCTrue/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + } + histos.add("h3Reck892invmass", "Invariant mass of Reconstructed MC K(892)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); + histos.add("h3Reck892invmassAnti", "Invariant mass of Reconstructed MC Anti-K(892)0", kTHnSparseF, {centAxis, ptAxis, invMassAxis}); + histos.add("k892Gen", "pT distribution of True MC K(892)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis}); + histos.add("k892GenAnti", "pT distribution of True MC Anti-K(892)0", kTHnSparseF, {mcLabelAxis, ptAxis, centAxis}); histos.add("k892Rec", "pT distribution of Reconstructed MC K(892)0", kTH2F, {ptAxis, centAxis}); histos.add("k892RecAnti", "pT distribution of Reconstructed MC Anti-K(892)0", kTH2F, {ptAxis, centAxis}); histos.add("k892Recinvmass", "Inv mass distribution of Reconstructed MC Phi", kTH1F, {invMassAxis}); @@ -421,6 +452,10 @@ struct k892analysis { if (additionalEvsel && !eventSelected(collision, multiplicity)) { return; } + auto occupancy_no = collision.trackOccupancyInTimeRange(); + if (applyOccupancyCut && occupancy_no < OccupancyCut) { + return; + } if (additionalQAplots) { histos.fill(HIST("MultCalib/centglopi_before"), multiplicity, dTracks1.size()); // centrality vs global tracks before the multiplicity calibration cuts @@ -446,7 +481,7 @@ 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; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughter_rot, lresonance_rot; for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { // Full index policy is needed to consider all possible combinations @@ -483,16 +518,18 @@ struct k892analysis { if constexpr (!IsMix) { //// QA plots before the selection // --- PID QA Pion - histos.fill(HIST("QAbefore/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); - if (isTrk1hasTOF) { - histos.fill(HIST("QAbefore/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); - histos.fill(HIST("QAbefore/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); - } - // --- PID QA Kaon - histos.fill(HIST("QAbefore/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); - if (isTrk2hasTOF) { - histos.fill(HIST("QAbefore/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); - histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + if (PIDplots) { + histos.fill(HIST("QAbefore/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAbefore/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAbefore/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QAbefore/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAbefore/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QAbefore/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } } histos.fill(HIST("QAbefore/trkpT_pi"), trk1ptPi); histos.fill(HIST("QAbefore/trkpT_ka"), trk2ptKa); @@ -528,16 +565,18 @@ struct k892analysis { if constexpr (!IsMix) { //// QA plots after the selection // --- PID QA Pion - histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); - if (isTrk1hasTOF) { - histos.fill(HIST("QAafter/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); - histos.fill(HIST("QAafter/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); - } - // --- PID QA Kaon - histos.fill(HIST("QAafter/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); - if (isTrk2hasTOF) { - histos.fill(HIST("QAafter/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); - histos.fill(HIST("QAafter/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + if (PIDplots) { + histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAafter/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QAafter/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAafter/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QAafter/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } } histos.fill(HIST("QAafter/trkpT_pi"), trk1ptPi); histos.fill(HIST("QAafter/trkpT_ka"), trk2ptKa); @@ -558,8 +597,8 @@ struct k892analysis { } //// Resonance reconstruction - lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPi); - lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + lDecayDaughter1.SetPtEtaPhiM(trk1.pt(), trk1.eta(), trk1.phi(), massPi); + lDecayDaughter2.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi(), massKa); lResonance = lDecayDaughter1 + lDecayDaughter2; // Rapidity cut if (abs(lResonance.Rapidity()) >= 0.5) @@ -590,22 +629,41 @@ struct k892analysis { //// Un-like sign pair only if (trk1.sign() * trk2.sign() < 0) { if constexpr (!IsMix) { - if (trk1.sign() < 0) { - histos.fill(HIST("k892invmassDS"), lResonance.M()); - histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); - } else if (trk1.sign() > 0) { - histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); - histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + 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 (study_antiparticle) { + if (trk1.sign() < 0) { + if (invmass1D) + histos.fill(HIST("k892invmassDS"), lResonance.M()); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + } else if (trk1.sign() > 0) { + if (invmass1D) + histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); + } + } else { + if (invmass1D) + histos.fill(HIST("k892invmassDS"), lResonance.M()); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); } } else { - histos.fill(HIST("k892invmassME"), lResonance.M()); - histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); + if (invmass1D) + histos.fill(HIST("k892invmassME"), lResonance.M()); + histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); if (additionalMEPlots) { if (trk1.sign() < 0) { - histos.fill(HIST("k892invmassME_DS"), lResonance.M()); + if (invmass1D) + histos.fill(HIST("k892invmassME_DS"), lResonance.M()); histos.fill(HIST("h3k892invmassME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); } else if (trk1.sign() > 0) { - histos.fill(HIST("k892invmassME_DSAnti"), lResonance.M()); + if (invmass1D) + histos.fill(HIST("k892invmassME_DSAnti"), lResonance.M()); histos.fill(HIST("h3k892invmassME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); } } @@ -625,13 +683,15 @@ 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()); - 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 (PIDplots) { + 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 @@ -648,11 +708,13 @@ struct k892analysis { } else if (trk1.sign() * trk2.sign() > 0) { if constexpr (!IsMix) { if (trk1.sign() < 0) { - histos.fill(HIST("k892invmassLS"), lResonance.M()); - histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M()); + if (invmass1D) + histos.fill(HIST("k892invmassLS"), lResonance.M()); + histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); } else if (trk1.sign() > 0) { - histos.fill(HIST("k892invmassLSAnti"), lResonance.M()); - histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + if (invmass1D) + histos.fill(HIST("k892invmassLSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M(), occupancy_no); } } } diff --git a/PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx b/PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx new file mode 100644 index 00000000000..200a3340e6b --- /dev/null +++ b/PWGLF/Tasks/Resonances/k892analysis_PbPb.cxx @@ -0,0 +1,789 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Marta Urioni + +#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/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 "DataFormatsParameters/GRPObject.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; + +using std::array; +struct k892analysis_PbPb { + SliceCache cache; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // histos + 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", 0.6, "Invariant mass start"}; + Configurable cInvMassEnd{"cInvMassEnd", 1.5, "Invariant mass end"}; + Configurable cInvMassBins{"cInvMassBins", 900, "Invariant mass binning"}; + Configurable cPIDBins{"cPIDBins", 65, "PID binning"}; + Configurable cPIDQALimit{"cPIDQALimit", 6.5, "PID QA limit"}; + Configurable cDCABins{"cDCABins", 300, "DCA binning"}; + + // events + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; + Configurable additionalEvSel2{"additionalEvSel2", true, "Additional evsel2"}; + Configurable additionalEvSel3{"additionalEvSel3", false, "Additional evsel3"}; + + // presel + Configurable cfgCutCentrality{"cfgCutCentrality", 80.0f, "Accepted maximum Centrality"}; + + // 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 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 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 cMaxTPCnSigmaKaon{"cMaxTPCnSigmaKaon", 3.0, "TPC nSigma cut for Kaon"}; // TPC + Configurable cMaxTOFnSigmaKaon{"cMaxTOFnSigmaKaon", 3.0, "TOF nSigma cut for Kaon"}; // TOF + 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 TofandTpcPID{"TOFandTPCPID", false, "apply both TOF and TPC PID"}; + + Configurable tpclowpt{"tpclowpt", true, "apply TPC at low pt"}; + Configurable tofhighpt{"tofhighpt", false, "apply TOF at high pt"}; + + // 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"}; + + // cuts on mother + Configurable cfgCutsOnMother{"cfgCutsOnMother", false, "Enamble additional cuts on mother"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 15.0, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 1.5, "Maximum Minv of mother cut"}; + + // configurables for partitions + Configurable cMaxPtTPC{"cMaxPtTPC", 1.2, "maximum pt to apply TPC PID and TOF if available"}; + Configurable cMinPtTOF{"cMinPtTOF", 0.8, "minimum pt to require TOF PID in addition to TPC"}; + + // plots + Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; + Configurable additionalQAeventPlots{"additionalQAeventPlots", false, "Additional QA event plots"}; + 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"}; + + void init(o2::framework::InitContext&) + { + AxisSpec centAxis = {binsCent, "V0M (%)"}; + 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 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}; + + if (doprocessSameEvent || doprocessMixedEvent) { + // 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}}); + histos.add("QAevent/hVertexZSameE", "Collision Vertex Z position", HistType::kTH1F, {{100, -15., 15.}}); + + 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}}); + histos.add("TestME/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("TestME/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("TestME/hPairsCounterSameE", "tot n pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("TestME/hPairsCounterMixedE", "tot n pairs mixedE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + + // event histograms + 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}}); + } + } + + // Mass QA (quick check) + histos.add("k892invmassDS", "Invariant mass of K(892)0 different sign", kTH1F, {invMassAxis}); + 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) { + 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}); + histos.add("k892invmassME_DSAnti", "Invariant mass of K(892)0 mixed event DSAnti", kTH1F, {invMassAxis}); + } + } + + 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"}}); + } + + // DCA QA + histos.add("QA/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QA/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {dcazAxis}); + // pT QA + histos.add("QA/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxis}); + histos.add("QA/trkpT_ka", "pT distribution of kaon track candidates", kTH1F, {ptAxis}); + // PID QA + histos.add("QA/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QA/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QA/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QA/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + 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 + 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) { + histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTH3F, {centAxis, ptAxis, invMassAxis}); + + if (additionalMEPlots) { + histos.add("QAME/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAME/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAME/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("h3k892invmassME_DS", "Invariant mass of K(892)0 mixed event DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassME_DSAnti", "Invariant mass of K(892)0 mixed event DSAnti", kTH3F, {centAxis, ptAxis, invMassAxis}); + } + } + + if (doprocessMC) { + histos.add("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}}); + // MC QA + histos.add("QAMCTrue/hGlobalIndexMotherRec", "index of rec mothers", HistType::kTH1F, {{static_cast(1e5), 0.0f, 1e5f}}); + histos.add("QAMCTrue/hGlobalIndexMotherGen", "index of gen mothers", HistType::kTH1F, {{static_cast(1e5), 0.0f, 1e5f}}); + 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 Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAMCTrue/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("k892Recinvmass", "Inv mass distribution of Reconstructed MC K(892)", kTH1F, {invMassAxis}); + histos.add("k892RecinvmassAnti", "Inv mass distribution of Reconstructed MC AntiK(892)", kTH1F, {invMassAxis}); + histos.add("k892GenInvmass", "Invariant mass of generated K(892)0", kTH1F, {invMassAxis}); + histos.add("k892GenInvmassAnti", "Invariant mass of generated Anti-K(892)0", kTH1F, {invMassAxis}); + + histos.add("h3Reck892invmass", "Invariant mass of Reconstructed MC K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3Reck892invmassAnti", "Invariant mass of Reconstructed MC Anti-K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("k892Gen", "pT distribution of True MC K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); + histos.add("k892GenAnti", "pT distribution of True MC Anti-K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); + histos.add("k892Rec", "pT distribution of Reconstructed MC K(892)0", kTH2F, {ptAxis, centAxis}); + 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}); + } + // Print output histograms statistics + LOG(info) << "Size of the histograms in spectraTOF"; + histos.print(); + } + + double massKa = o2::constants::physics::MassKPlus; + double massPi = o2::constants::physics::MassPiPlus; + + template + bool trackCut(const TrackType track) + { + // basic track cuts + if (track.itsNCls() < cfgITScluster) + return false; + if (track.tpcNClsFound() < cfgTPCcluster) + return false; + if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) + 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; + + return true; + } + + template + bool selectionPIDKaon(const T& candidate) + { + + if (TofandTpcPID) { + + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon && candidate.hasTPC() && std::abs(candidate.tpcNSigmaKa()) < cMaxTPCnSigmaKaon) { // tof and tpc cut + return true; + } + + } else { + + if (candidate.hasTPC() && std::abs(candidate.tpcNSigmaKa()) < cMaxTPCnSigmaKaon) { // tpc cut, tof when available + + if (cByPassTOF) // skip tof selection + return true; + + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon) { + return true; + } + } else { + return true; + } + } + } + + return false; + } + + template + bool selectionPIDPion(const T& candidate) + { + + if (TofandTpcPID) { + + if (candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion && candidate.hasTPC() && std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { // tof and tpc cut + return true; + } + + } else { + + if (candidate.hasTPC() && std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { // tpc cut, tof when available + + if (cByPassTOF) // skip tof selection + return true; + + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion) { + return true; + } + } else { + return true; + } + } + } + + return false; + } + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + + auto multiplicity = collision.centFT0C(); + + auto oldindex = -999; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + for (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 (!IsMix) { + histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); + } else { + histos.fill(HIST("TestME/hPairsCounterMixedE"), 1.0); + } + } + } + + //// Initialize variables + // Trk1: Pion, Trk2: Kaon + // apply the track cut + if (!trackCut(trk1) || !trackCut(trk2)) + continue; + + auto isTrk1hasTOF = trk1.hasTOF(); + auto isTrk2hasTOF = trk2.hasTOF(); + auto trk1ptPi = trk1.pt(); + auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; + auto trk2ptKa = trk2.pt(); + auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); + auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; + + if (!selectionPIDPion(trk1) || !selectionPIDKaon(trk2)) + continue; + + if constexpr (IsMC) { + if (tpclowpt) { + if (trk1ptPi > cMaxPtTPC || trk2ptKa > cMaxPtTPC) + continue; + } else if (tofhighpt) { + if (trk1ptPi < cMinPtTOF || trk2ptKa < cMinPtTOF) + continue; + } + } + + if (additionalQAplots) { + // 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()); + } + + if constexpr (!IsMix) { + //// QA plots after the selection + // --- PID QA Pion + histos.fill(HIST("QA/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QA/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QA/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + histos.fill(HIST("QA/trkpT_pi"), trk1ptPi); + histos.fill(HIST("QA/trkpT_ka"), trk2ptKa); + histos.fill(HIST("QA/trkDCAxy_pi"), trk1.dcaXY()); + 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) { + // --- PID QA Pion + histos.fill(HIST("QAME/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAME/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAME/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QAME/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAME/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QAME/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + } + + //// 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) + continue; + if (cfgCutsOnMother) { + 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 (track1Sign < 0) { + histos.fill(HIST("k892invmassDS"), lResonance.M()); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (track1Sign > 0) { + histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } else { + 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()); + } else if (track1Sign > 0) { + histos.fill(HIST("k892invmassME_DSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + + // MC + if constexpr (IsMC) { + + 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()); + + if (!mctrack1.isPhysicalPrimary() || !mctrack2.isPhysicalPrimary()) + continue; + + if (track1PDG != 211 || track2PDG != 321) + continue; + + 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 (!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()); + } else { + histos.fill(HIST("k892RecAnti"), lResonance.Pt(), multiplicity); + histos.fill(HIST("k892RecinvmassAnti"), lResonance.M()); + histos.fill(HIST("h3Reck892invmassAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } else if (track1Sign * track2Sign > 0) { + if constexpr (!IsMix) { + if (track1Sign < 0) { + histos.fill(HIST("k892invmassLS"), lResonance.M()); + histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (track1Sign > 0) { + histos.fill(HIST("k892invmassLSAnti"), lResonance.M()); + 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 + + 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>; + + // partitions tpc low pt + Partition negPitpc = (aod::track::signed1Pt < static_cast(0)) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) < cMaxPtTPC); + Partition posKatpc = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtpc::tpcNSigmaKa) <= cMaxTPCnSigmaKaon) && (nabs(aod::track::pt) < cMaxPtTPC); + + Partition posPitpc = (aod::track::signed1Pt > static_cast(0)) && (nabs(aod::pidtpc::tpcNSigmaPi) <= cMaxTPCnSigmaPion) && (nabs(aod::track::pt) < cMaxPtTPC); + 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 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); + + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { + 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(); + + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1); + histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), centrality); + + 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); + + //-+ + auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candNegPitpc, candPosKatpc); + + } else if (tofhighpt) { + //+- + auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPosPitof, candNegKatof); + + //-+ + auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candNegPitof, candPosKatof); + } + } + PROCESS_SWITCH(k892analysis_PbPb, processSameEvent, "Process Same event TOF High Pt", false); + + using BinningTypeVtxCent = ColumnBinningPolicy; + void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) + { + auto tracksTuple = std::make_tuple(tracks); + 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()) { + return; + } + auto centrality = collision1.centFT0C(); + + 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))) { + return; + } + 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))) { + return; + } + if (additionalEvSel3 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) || !collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + return; + } + + if (additionalQAeventPlots) { + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + histos.fill(HIST("QAevent/hVertexZMixedE"), collision1.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentMixedE"), centrality); + 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, candPosPitpc, candNegKatpc); + + //-+ + auto candNegPitpc = negPitpc->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candPosKatpc = posKatpc->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candNegPitpc, candPosKatpc); + + } else if (tofhighpt) { + + //+- + auto candPosPitof = posPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candNegKatof = negKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candPosPitof, candNegKatof); + + //-+ + auto candNegPitof = negPitof->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + auto candPosKatof = posKatof->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candNegPitof, candPosKatof); + } + } + } + PROCESS_SWITCH(k892analysis_PbPb, processMixedEvent, "Process Mixed event TPC low pt", true); + + // MC + + using EventCandidatesMCrec = soa::Join; + using TrackCandidatesMCrec = soa::Filtered>; + + void processMC(aod::McCollisions::iterator const& /*mcCollision*/, aod::McParticles& mcParticles, const soa::SmallGroups& recCollisions, TrackCandidatesMCrec const& RecTracks) + { + histos.fill(HIST("hMCrecCollSels"), 0); + if (recCollisions.size() == 0) { + histos.fill(HIST("hMCrecCollSels"), 1); + return; + } + if (recCollisions.size() > 1) { + histos.fill(HIST("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))) { + continue; + } + histos.fill(HIST("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); + + // Generated MC + for (auto& mcPart : mcParticles) { + if (abs(mcPart.y()) >= 0.5 || abs(mcPart.pdgCode()) != 313) + continue; + + auto kDaughters = mcPart.daughters_as(); + if (kDaughters.size() != 2) { + continue; + } + + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + + auto daughtp = false; + auto daughtk = false; + for (auto kCurrentDaughter : kDaughters) { + if (!kCurrentDaughter.isPhysicalPrimary()) + break; + if (genacceptancecut && (kCurrentDaughter.pt() < cfgCutPT || TMath::Abs(kCurrentDaughter.eta()) > cfgCutEta)) + break; + + if (abs(kCurrentDaughter.pdgCode()) == 211) { + daughtp = true; + lDecayDaughter1.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massPi); + } else if (abs(kCurrentDaughter.pdgCode()) == 321) { + daughtk = true; + lDecayDaughter2.SetXYZM(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), massKa); + } + } + + if (!daughtp || !daughtk) + continue; + + lResonance = lDecayDaughter1 + lDecayDaughter2; + + histos.fill(HIST("QAMCTrue/hGlobalIndexMotherGen"), mcPart.globalIndex()); + + if (mcPart.pdgCode() > 0) { // no cuts, purely generated + histos.fill(HIST("k892GenInvmass"), lResonance.M()); + histos.fill(HIST("h3k892GenInvmass"), centrality, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("k892Gen"), 3, mcPart.pt(), centrality); + } else { + histos.fill(HIST("k892GenInvmassAnti"), lResonance.M()); + histos.fill(HIST("h3k892GenInvmassAnti"), centrality, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("k892GenAnti"), 3, mcPart.pt(), centrality); + } + + } // end loop on gen particles + + } // end loop on rec collisions + } + PROCESS_SWITCH(k892analysis_PbPb, processMC, "Process Monte Carlo", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"k892analysis_PbPb"})}; +} diff --git a/PWGLF/Tasks/Resonances/k892pmanalysis.cxx b/PWGLF/Tasks/Resonances/k892pmanalysis.cxx index 16d9da6fe0c..16963b77e6b 100644 --- a/PWGLF/Tasks/Resonances/k892pmanalysis.cxx +++ b/PWGLF/Tasks/Resonances/k892pmanalysis.cxx @@ -60,6 +60,9 @@ struct k892pmanalysis { Configurable cLambdaAntiLambdaMassBins{"cLambdaAntiLambdaMassBins", 250, "V0 mass (in the (Anti)Lambda0 hypothesis) binning"}; Configurable cDCABinsQA{"cDCABinsQA", 150, "DCA binning"}; + + Configurable cTpcNsigmaPionBinsQA{"cTpcNsigmaPionBinsQA", 140, "tpcNSigmaPi binning"}; + // Pre-selection cuts Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minimum pt cut"}; Configurable cMaxEtacut{"cMaxEtacut", 0.8, "Track maximum eta cut"}; @@ -72,10 +75,7 @@ struct k892pmanalysis { /// 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 cMaxTPCnSigmaV0Pion{"cMaxTPCnSigmaV0Pion", 5.0, "TPC nSigma cut for V0 Pion"}; // TPC, secondary pions - Configurable cMaxTOFnSigmaV0Pion{"cMaxTOFnSigmaV0Pion", 5.0, "TOF nSigma cut for V0 Pion"}; // TOF, secondary pions Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined - Configurable nsigmaCutCombinedV0Pion{"nsigmaCutCombinedV0Pion", -999, "Combined nSigma cut for V0 Pion"}; // Combined, secondary pions Configurable cUseOnlyTOFTrackPi{"cUseOnlyTOFTrackPi", false, "Use only TOF track for PID selection"}; // Use only TOF track for Pion PID selection Configurable cUseOnlyTOFTrackKa{"cUseOnlyTOFTrackKa", false, "Use only TOF track for PID selection"}; // Use only TOF track for Kaon PID selection // Track selections @@ -86,7 +86,7 @@ struct k892pmanalysis { 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.004, "Mass window for competing Lambda0 rejection"}; + Configurable cV0MassWindow{"cV0MassWindow", 0.0043, "Mass window for competing Lambda0 rejection"}; // Resonance selection // Configurable cMaxResRapidity{"cMaxResRapidity", 0.5, "Maximum pseudo-rapidity value of reconstructed K*(892)pm resonance"}; // Event mixing @@ -102,6 +102,7 @@ struct k892pmanalysis { AxisSpec dcazAxisQA = {cDCABinsQA, 0.0, 3.0, "DCA_{#it{xy}} (cm)"}; AxisSpec daughdcaAxisQa = {cDCABinsQA, 0.0, 3.0, "V0 daughters DCA (cm)"}; AxisSpec CosPointAngleAxisQA = {binsV0CosPointAngleQA, "CosPA"}; + AxisSpec tpcNSigmaPiAxisQA = {cTpcNsigmaPionBinsQA, -7.0, 7.0, "N#sigma_{TPC}"}; 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)"}; @@ -112,11 +113,11 @@ struct k892pmanalysis { // Mass QA (quick check) // QA before - histos.add("QAbefore/k0shortmass", "Invariant mass of K0Short", kTH1F, {k0sMassAxisQA}); + histos.add("QAbefore/k0shortmassPt", "Invariant mass of K0Short vs K0Short Pt", kTH2F, {ptAxisQA, k0sMassAxisQA}); histos.add("QAbefore/lambda0mass", "Invariant mass of V0 in Lambda0 hypothesis", kTH1F, {lambdaAntilambdaMassAxisQA}); histos.add("QAbefore/antilambda0mass", "Invariant mass of V0 in AntiLambda0 hypothesis", kTH1F, {lambdaAntilambdaMassAxisQA}); // QA after - histos.add("QAafter/k0shortmass", "Invariant mass of K0Short", kTH1F, {k0sMassAxisQA}); + histos.add("QAafter/k0shortmassPt", "Invariant mass of K0Short vs K0Short Pt", kTH2F, {ptAxisQA, k0sMassAxisQA}); histos.add("QAafter/lambda0mass", "Invariant mass of V0 in Lambda0 hypothesis", kTH1F, {lambdaAntilambdaMassAxisQA}); histos.add("QAafter/antilambda0mass", "Invariant mass of V0 in AntiLambda0 hypothesis", kTH1F, {lambdaAntilambdaMassAxisQA}); histos.add("k892pminvmass", "Invariant mass of charged K*(892)", kTH1F, {invMassAxis}); @@ -152,6 +153,11 @@ struct k892pmanalysis { // QA after histos.add("QAafter/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxisQA}); histos.add("QAafter/trkpT_k0s", "pT distribution of k0short track candidates", kTH1F, {ptAxisQA}); + // Primary pion TPC PID + // QA before + histos.add("QAbefore/tpcNsigmaPionQA", "NsigmaTPC distribution of primary pion candidates", kTH2F, {ptAxisQA, tpcNSigmaPiAxisQA}); + // QA after + histos.add("QAafter/tpcNsigmaPionQA", "NsigmaTPC distribution of primary pion candidates", kTH2F, {ptAxisQA, tpcNSigmaPiAxisQA}); // Good tracks and V0 counts QA histos.add("QAafter/hGoodTracksV0s", "Number of good track and V0 passed", kTH1F, {goodTrackCountAxis}); // Mass vs Pt vs Multiplicity 3-dimensional histogram @@ -244,30 +250,6 @@ struct k892pmanalysis { return false; } - // Secondary PID selection tools - template - bool selectionPIDSecondaryPion(const T& candidate) - { - bool tpcPIDPassed{false}, tofPIDPassed{false}; - if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaV0Pion) { - tpcPIDPassed = true; - } - if (candidate.hasTOF()) { - if (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaV0Pion) { - tofPIDPassed = true; - } - if ((nsigmaCutCombinedPion > 0) && (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi() + candidate.tofNSigmaPi() * candidate.tofNSigmaPi() < nsigmaCutCombinedV0Pion * nsigmaCutCombinedV0Pion)) { - tofPIDPassed = true; - } - } else { - tofPIDPassed = true; - } - if (tpcPIDPassed && tofPIDPassed) { - return true; - } - return false; - } - /*// Resonance candidate selection template bool selectionResoK892pm(const ResoCandidate& resoCandidate) @@ -311,6 +293,8 @@ struct k892pmanalysis { histos.fill(HIST("QAbefore/trkEta_pi"), trketaPi); // pT QA (before cuts) histos.fill(HIST("QAbefore/trkpT_pi"), trkptPi); + // TPC PID (before cuts) + histos.fill(HIST("QAbefore/tpcNsigmaPionQA"), trkptPi, trk.tpcNSigmaPi()); } // apply the track cut @@ -329,6 +313,8 @@ struct k892pmanalysis { histos.fill(HIST("QAafter/trkEta_pi"), trketaPi); // pT QA (after cuts) histos.fill(HIST("QAafter/trkpT_pi"), trk.pt()); + // TPC PID (after cuts) + histos.fill(HIST("QAafter/tpcNsigmaPionQA"), trkptPi, trk.tpcNSigmaPi()); } for (auto& v0 : dV0s) { @@ -350,7 +336,7 @@ struct k892pmanalysis { // pT QA (before cuts) histos.fill(HIST("QAbefore/trkpT_k0s"), v0ptK0s); // K0s mass QA (before cuts) - histos.fill(HIST("QAbefore/k0shortmass"), v0.mK0Short()); + histos.fill(HIST("QAbefore/k0shortmassPt"), v0ptK0s, v0.mK0Short()); } // apply the track cut @@ -366,9 +352,9 @@ struct k892pmanalysis { } // apply the competing V0 rejection cut (excluding Lambda0 candidates, massLambdaPDG = 1115.683 MeV/c2) - if (abs(v0.mLambda() - massLambda0) < cV0MassWindow) + if (std::abs(v0.mLambda() - massLambda0) < cV0MassWindow) continue; - if (abs(v0.mAntiLambda() - massAntiLambda0) < cV0MassWindow) + if (std::abs(v0.mAntiLambda() - massAntiLambda0) < cV0MassWindow) continue; if (!IsMix && !IsV0QAFilled) { @@ -381,7 +367,7 @@ struct k892pmanalysis { // pt QA (after cuts) histos.fill(HIST("QAafter/trkpT_k0s"), v0ptK0s); // K0s mass QA (after cuts) - histos.fill(HIST("QAafter/k0shortmass"), v0.mK0Short()); + histos.fill(HIST("QAafter/k0shortmassPt"), v0ptK0s, v0.mK0Short()); histos.fill(HIST("QAafter/lambda0mass"), v0.mLambda()); histos.fill(HIST("QAafter/antilambda0mass"), v0.mAntiLambda()); } @@ -396,7 +382,7 @@ struct k892pmanalysis { } // Checking whether the mid-rapidity condition is met - if (abs(lResonance.Rapidity()) > 0.5) { + if (std::abs(lResonance.Rapidity()) > 0.5) { continue; } @@ -415,7 +401,7 @@ struct k892pmanalysis { histos.fill(HIST("k892pmMassPtMult3d"), lResonance.M(), lResonance.Pt(), multiplicity); if constexpr (IsMC) { // LOG(info) << "track PDG:\t" << trk.pdgCode() << "\tV0 PDG:\t" << v0.pdgCode(); - if (abs(trk.pdgCode()) != 211 || abs(v0.pdgCode()) != 310) // Skip to next iteration if daughters are not charged pion + K0s/AntiK0s + if (std::abs(trk.pdgCode()) != 211 || std::abs(v0.pdgCode()) != 310) // Skip to next iteration if daughters are not charged pion + K0s/AntiK0s continue; if (trk.motherPDG() != v0.motherPDG()) continue; @@ -458,17 +444,17 @@ struct k892pmanalysis { void processMCTrue(aod::ResoMCParents& resoParents) { for (auto& part : resoParents) { // loop over all pre-filtered MC particles - if (abs(part.pdgCode()) != 323) // K*892(pm) + if (std::abs(part.pdgCode()) != 323) // K*892(pm) continue; - if (abs(part.y()) > 0.5) // rapidity cut + if (std::abs(part.y()) > 0.5) // rapidity cut continue; bool pass1 = false; bool pass2 = false; /*// Sanity check: looking for K*0 resonances for sanity check - if (abs(part.pdgCode()) == 323) { + if (std::abs(part.pdgCode()) == 323) { LOG(info) << "Found charged K*: " << part.pdgCode() << ". Daughters' PDG are " << part.daughterPDG1() << " and " << part.daughterPDG2(); } - if (abs(part.pdgCode()) == 313) { + if (std::abs(part.pdgCode()) == 313) { LOG(info) << "Found non-charged K*: " << part.pdgCode() << ". Daughters' PDG are " << part.daughterPDG1() << " and " << part.daughterPDG2(); }*/ @@ -480,11 +466,11 @@ struct k892pmanalysis { pass2 = true; histos.fill(HIST("hK892pmCounter"), 1.5); } - /*if (abs(part.daughterPDG1()) == 211) + /*if (std::abs(part.daughterPDG1()) == 211) histos.fill(HIST("hDaughterCounter"), 0.5); - if (abs(part.daughterPDG2()) == 310) + if (std::abs(part.daughterPDG2()) == 310) histos.fill(HIST("hDaughterCounter"), 1.5); - if (abs(part.daughterPDG1()) == 211 && abs(part.daughterPDG2()) == 310) + if (std::abs(part.daughterPDG1()) == 211 && std::abs(part.daughterPDG2()) == 310) histos.fill(HIST("hDaughterCounter"), 2.5);*/ // if (!pass1 || !pass2) // Go on only if we have both decay products, else skip to next iteration if (!pass1 && !pass2) // Go on only if we have both decay products, else skip to next iteration diff --git a/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx b/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx index 14e98174c48..81af59575ab 100644 --- a/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx +++ b/PWGLF/Tasks/Resonances/kaonkaonanalysis.cxx @@ -29,11 +29,14 @@ #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" @@ -67,6 +70,8 @@ struct kaonkaonAnalysisRun3 { 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!) @@ -77,6 +82,7 @@ struct kaonkaonAnalysisRun3 { TF1* fMultMultPVCut = nullptr; // track + Configurable rotational_cut{"rotational_cut", 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"}; @@ -102,47 +108,92 @@ struct kaonkaonAnalysisRun3 { 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"}; + + // different frames + Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", true, "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", 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"}; + // MC Configurable isMC{"isMC", false, "Run MC"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; + TRandom* rn = new TRandom(); + void init(o2::framework::InitContext&) { - AxisSpec axisMult{cmultBins, cmultLow, cmultHigh}; - AxisSpec axisPt{cpTbins, cpTlow, cpThigh}; - AxisSpec axisMass{cMassbins, cMasslow, cMasshigh}; - histos.add("hCentrality", "Centrality distribution", kTH1F, {axisMult}); - histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); - histos.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); - 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_before", "NsigmaKaon TPC distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_before", "NsigmaKaon TOF distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTPC_after", "NsigmaKaon TPC distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_after", "NsigmaKaon TOF distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_TPC_before", "NsigmaKaon TOF-TPC distribution", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_TPC_after", "NsigmaKaon TOF-TPC distribution", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}); + AxisSpec axisMult{cmultBins, cmultLow, cmultHigh, "Multiplicity"}; + AxisSpec axisPt{cpTbins, cpTlow, cpThigh, "pT (GeV/c)"}; + AxisSpec axisMass{cMassbins, cMasslow, cMasshigh, "Invariant mass (GeV/c^2)"}; + const AxisSpec thnAxisPOL{configThnAxisPOL, "Frame axis"}; + + // THnSparses + std::array sparses = {activateTHnSparseCosThStarHelicity, activateTHnSparseCosThStarProduction, activateTHnSparseCosThStarBeam, activateTHnSparseCosThStarRandom}; + + // std::array sparses = {activateTHnSparseCosThStarHelicity}; + + if (std::accumulate(sparses.begin(), sparses.end(), 0) == 0) { + LOGP(fatal, "No output THnSparses enabled"); + } else { + if (activateTHnSparseCosThStarHelicity) { + LOGP(info, "THnSparse with cosThStar w.r.t. helicity axis active."); + } + if (activateTHnSparseCosThStarProduction) { + LOGP(info, "THnSparse with cosThStar w.r.t. production axis active."); + } + if (activateTHnSparseCosThStarBeam) { + LOGP(info, "THnSparse with cosThStar w.r.t. beam axis active. (Gottified jackson frame)"); + } + if (activateTHnSparseCosThStarRandom) { + LOGP(info, "THnSparse with cosThStar w.r.t. random axis active."); + } + } + + if (QAevents) { + histos.add("hmutiplicity", "Multiplicity percentile distribution", kTH1F, {axisMult}); + histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); + histos.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); + histos.add("multdist_FT0M", "FT0M Multiplicity distribution", kTH1F, {axisMultdist}); + histos.add("multdist_FT0A", "FT0A Multiplicity distribution", kTH1F, {axisMultdist}); + histos.add("multdist_FT0C", "FT0C Multiplicity distribution", kTH1F, {axisMultdist}); + } + + if (QAPID) { + 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_before", "NsigmaKaon TPC distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); + histos.add("hNsigmaKaonTOF_before", "NsigmaKaon TOF distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaKaonTPC_after", "NsigmaKaon TPC distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaKaonTOF_after", "NsigmaKaon TOF distribution", kTH2F, {{axisPt}, {200, -10.0f, 10.0f}}); + histos.add("hNsigmaKaonTOF_TPC_before", "NsigmaKaon TOF-TPC distribution", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaKaonTOF_TPC_after", "NsigmaKaon TOF-TPC distribution", kTH2F, {{200, -10.0f, 10.0f}, {200, -10.0f, 10.0f}}); + histos.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {axisPtfordEbydx, axisdEdx}); + } + if (otherQAplots) { + 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}}); + + // chi2 plots histos.add("Chi2perclusterITS", "Chi2 / cluster for the ITS track segment", kTH1F, {{50, 0.0f, 50.0f}}); histos.add("Chi2perclusterTPC", "Chi2 / cluster for the TPC track segment", kTH1F, {{50, 0.0f, 50.0f}}); histos.add("Chi2perclusterTRD", "Chi2 / cluster for the TRD track segment", kTH1F, {{50, 0.0f, 50.0f}}); histos.add("Chi2perclusterTOF", "Chi2 / cluster for the TOF track segment", kTH1F, {{50, 0.0f, 50.0f}}); - histos.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {{100, 0.0f, 100.0f}, {axisPt}}); } if (!isMC) { - histos.add("h3PhiInvMassUnlikeSign", "Invariant mass of Phi meson Unlike Sign", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassLikeSignPP", "Invariant mass of Phi meson Like Sign positive", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassLikeSignMM", "Invariant mass of Phi meson Like Sign negative", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassMixed", "Invariant mass of Phi meson Mixed", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassRotation", "Invariant mass of Phi meson Rotation", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - if (isEtaAssym) { - histos.add("h3PhiInvMassUnlikeSignAside", "Invariant mass of Phi meson Unlike Sign A side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassLikeSignAside", "Invariant mass of Phi meson Like Sign A side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassMixedAside", "Invariant mass of Phi meson Mixed A side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassUnlikeSignCside", "Invariant mass of Phi meson Unlike Sign C side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassLikeSignCside", "Invariant mass of Phi meson Like Sign C side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - histos.add("h3PhiInvMassMixedCside", "Invariant mass of Phi meson Mixed C side", kTHnSparseF, {axisMult, axisPt, axisMass}, true); - } + 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); } else if (isMC) { histos.add("hMC", "MC Event statistics", kTH1F, {{6, 0.0f, 6.0f}}); histos.add("h1PhiGen", "Phi meson Gen", kTH1F, {axisPt}); @@ -174,6 +225,7 @@ struct kaonkaonAnalysisRun3 { array pvec1; array pvec1rotation; array pvec2rotation; + ROOT::Math::PxPyPzMVector daughter1, daughter2; template bool eventselection(Collision const& collision, const float& multiplicity) @@ -258,44 +310,18 @@ struct kaonkaonAnalysisRun3 { } return true; } - template - void FillinvMass(const T1& candidate1, const T2& candidate2, float multiplicity, bool unlike, bool mix, bool likesign, bool rotation, float massd1, float massd2) + 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) { - pvec0 = array{candidate1.px(), candidate1.py(), candidate1.pz()}; - pvec1 = array{candidate2.px(), candidate2.py(), candidate2.pz()}; - pvec1rotation = array{-candidate2.px(), -candidate2.py(), candidate2.pz()}; - pvec2rotation = array{-candidate1.px(), -candidate1.py(), candidate1.pz()}; - auto arrMom = array{pvec0, pvec1}; - auto arrMomrotation1 = array{pvec0, pvec1rotation}; - auto arrMomrotation2 = array{pvec1, pvec2rotation}; int track1Sign = candidate1.sign(); int track2Sign = candidate2.sign(); - mass = RecoDecay::m(arrMom, array{massd1, massd2}); - massrotation1 = RecoDecay::m(arrMomrotation1, array{massd1, massd2}); - massrotation2 = RecoDecay::m(arrMomrotation2, 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); - if (isEtaAssym && unlike && track1Sign * track2Sign < 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassUnlikeSignAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassUnlikeSignCside"), multiplicity, pT, mass); - } - } - if (isEtaAssym && mix && track1Sign * track2Sign < 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassMixedAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassMixedCside"), multiplicity, pT, mass); - } - } - if (isEtaAssym && likesign && track1Sign * track2Sign > 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassLikeSignAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassLikeSignCside"), multiplicity, pT, mass); - } - } + 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(); if (otherQAplots) { histos.fill(HIST("Chi2perclusterITS"), candidate1.itsChi2NCl()); @@ -306,30 +332,51 @@ struct kaonkaonAnalysisRun3 { histos.fill(HIST("Chi2perclusterTRD"), candidate2.trdChi2()); histos.fill(HIST("Chi2perclusterTOF"), candidate1.tofChi2()); histos.fill(HIST("Chi2perclusterTOF"), candidate2.tofChi2()); - histos.fill(HIST("dE_by_dx_TPC"), candidate1.tpcSignal(), candidate1.pt()); - histos.fill(HIST("dE_by_dx_TPC"), candidate2.tpcSignal(), candidate2.pt()); + } + if (QAPID) { + histos.fill(HIST("dE_by_dx_TPC"), candidate1.p(), candidate1.tpcSignal()); + histos.fill(HIST("dE_by_dx_TPC"), candidate2.p(), candidate2.tpcSignal()); } + // 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 (std::abs(rapidity) < 0.5 && !isEtaAssym && track1Sign * track2Sign < 0) { + // 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, pT, mass); + histos.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); } if (mix) { - histos.fill(HIST("h3PhiInvMassMixed"), multiplicity, pT, mass); + histos.fill(HIST("h3PhiInvMassMixed"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); } + if (rotation) { - histos.fill(HIST("h3PhiInvMassRotation"), multiplicity, pT, massrotation1); - histos.fill(HIST("h3PhiInvMassRotation"), multiplicity, pT, massrotation2); + 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); + } } } - if (std::abs(rapidity) < 0.5 && !isEtaAssym && track1Sign * track2Sign > 0 && likesign) { + if (std::abs(rapidity) < 0.5 && track1Sign * track2Sign > 0 && likesign) { if (track1Sign > 0 && track2Sign > 0) { - histos.fill(HIST("h3PhiInvMassLikeSignPP"), multiplicity, pT, mass); + histos.fill(HIST("h3PhiInvMassLikeSignPP"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); } else { - histos.fill(HIST("h3PhiInvMassLikeSignMM"), multiplicity, pT, mass); + histos.fill(HIST("h3PhiInvMassLikeSignMM"), multiplicity, vec3.Pt(), vec3.M(), framecalculation); } } + // } } Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; @@ -353,19 +400,26 @@ struct kaonkaonAnalysisRun3 { multiplicity = collision.centFT0M(); else multiplicity = collision.centFT0C(); - histos.fill(HIST("hCentrality"), multiplicity); - histos.fill(HIST("hNcontributor"), collision.numContrib()); - histos.fill(HIST("hVtxZ"), collision.posZ()); + if (QAevents) { + histos.fill(HIST("hmutiplicity"), multiplicity); + histos.fill(HIST("hVtxZ"), collision.posZ()); + histos.fill(HIST("hNcontributor"), collision.numContrib()); + histos.fill(HIST("multdist_FT0M"), collision.multFT0M()); + histos.fill(HIST("multdist_FT0A"), collision.multFT0A()); + histos.fill(HIST("multdist_FT0C"), collision.multFT0C()); + } for (auto track1 : tracks) { if (!selectionTrack(track1)) { continue; } - histos.fill(HIST("hEta"), track1.eta()); - histos.fill(HIST("hDcaxy"), track1.dcaXY()); - histos.fill(HIST("hDcaz"), track1.dcaZ()); - histos.fill(HIST("hNsigmaKaonTPC_before"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("hNsigmaKaonTOF_before"), track1.pt(), track1.tofNSigmaKa()); - histos.fill(HIST("hNsigmaKaonTOF_TPC_before"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + if (QAPID) { + histos.fill(HIST("hEta"), track1.eta()); + histos.fill(HIST("hDcaxy"), track1.dcaXY()); + histos.fill(HIST("hDcaz"), track1.dcaZ()); + histos.fill(HIST("hNsigmaKaonTPC_before"), track1.pt(), track1.tpcNSigmaKa()); + histos.fill(HIST("hNsigmaKaonTOF_before"), track1.pt(), track1.tofNSigmaKa()); + histos.fill(HIST("hNsigmaKaonTOF_TPC_before"), track1.tofNSigmaKa(), track1.tpcNSigmaKa()); + } auto track1ID = track1.index(); for (auto track2 : tracks) { if (!selectionTrack(track2)) { @@ -379,19 +433,74 @@ 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 (isITSOnlycut) { - FillinvMass(track1, track2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); - 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()); + 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 (!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()); + // } } } } @@ -436,12 +545,77 @@ struct kaonkaonAnalysisRun3 { if (!selectionPair(t1, t2)) { continue; } - 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); + + // 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 (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 (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); + // } } } } else { @@ -468,12 +642,78 @@ struct kaonkaonAnalysisRun3 { if (!selectionPair(t1, t2)) { continue; } - 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); + + // 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 (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 (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); + // } } } } diff --git a/PWGLF/Tasks/Resonances/kstar892analysis.cxx b/PWGLF/Tasks/Resonances/kstar892analysis.cxx new file mode 100644 index 00000000000..eb75690babd --- /dev/null +++ b/PWGLF/Tasks/Resonances/kstar892analysis.cxx @@ -0,0 +1,913 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 kstar892analysis.cxx +/// \brief Reconstruction of track-track decay resonance candidates +/// +/// +/// adaped from k892analysis.cxx by Bong-Hwi Lim , Sawan Sawan +/// \author Marta Urioni + +#include +#include "TF1.h" +#include + +#include "Common/Core/RecoDecay.h" +#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; + +struct kstar892analysis { + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + ///// Configurables + /// 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"}; + 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"}; + + Configurable cInvMassStart{"cInvMassStart", 0.6, "Invariant mass start"}; + Configurable cInvMassEnd{"cInvMassEnd", 1.5, "Invariant mass end"}; + Configurable cInvMassBins{"cInvMassBins", 900, "Invariant mass binning"}; + Configurable cPIDBins{"cPIDBins", 65, "PID binning"}; + Configurable cPIDQALimit{"cPIDQALimit", 6.5, "PID QA limit"}; + Configurable cDCABins{"cDCABins", 150, "DCA 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.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"}; + /// DCA Selections + // 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"}; + Configurable cMinDCAzToPVcut{"cMinDCAzToPVcut", 0.0, "Track DCAz cut to PV Minimum"}; + /// PID Selections + Configurable cfgHighPt{"cfgHighPt", 999.0, "Minimum Pt to apply tighter PID selections on Mixed Event"}; + // Pion + Configurable cMaxTPCnSigmaPion{"cMaxTPCnSigmaPion", 3.0, "TPC nSigma cut for Pion"}; // TPC + Configurable cMaxTOFnSigmaPion{"cMaxTOFnSigmaPion", 3.0, "TOF nSigma cut for Pion"}; // TOF + Configurable cMaxTPCnSigmaPionHighPtME{"cMaxTPCnSigmaPionHighPtME", 2.0, "TPC nSigma cut for Pion at high pt for Mixed Event"}; // TPC + Configurable cMaxTOFnSigmaPionHighPtME{"cMaxTOFnSigmaPionHighPtME", 2.0, "TOF nSigma cut for Pion at high pt for Mixed Event"}; // TOF + Configurable nsigmaCutCombinedPion{"nsigmaCutCombinedPion", -999, "Combined nSigma cut for Pion"}; // Combined + // Kaon + Configurable cMaxTPCnSigmaKaon{"cMaxTPCnSigmaKaon", 3.0, "TPC nSigma cut for Kaon"}; // TPC + Configurable cMaxTOFnSigmaKaon{"cMaxTOFnSigmaKaon", 3.0, "TOF nSigma cut for Kaon"}; // TOF + Configurable cMaxTPCnSigmaKaonHighPtME{"cMaxTPCnSigmaKaonHighPtME", 2.0, "TPC nSigma cut for Kaon at pt>3GeV for Mixed Event"}; // TPC + Configurable cMaxTOFnSigmaKaonHighPtME{"cMaxTOFnSigmaKaonHighPtME", 2.0, "TOF nSigma cut for Kaon at pt>3GeV for Mixed Event"}; // TOF + Configurable nsigmaCutCombinedKaon{"nsigmaCutCombinedKaon", -999, "Combined nSigma cut for Kaon"}; // Combined + + Configurable cByPassTOF{"cByPassTOF", false, "By pass TOF PID selection"}; // By pass TOF PID selection + Configurable cfgGlobalTrack{"cfgGlobalTrack", false, "Global track selection"}; // kGoldenChi2 | kDCAxy | kDCAz + Configurable additionalQAplots{"additionalQAplots", true, "Additional QA plots"}; + 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 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"}; + + // MC Event selection + Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; + + // cuts on mother + Configurable cfgCutsOnMother{"cfgCutsOnMother", false, "Enamble additional cuts on mother"}; + Configurable cMaxPtMotherCut{"cMaxPtMotherCut", 15.0, "Maximum pt of mother cut"}; + Configurable cMaxMinvMotherCut{"cMaxMinvMotherCut", 1.5, "Maximum Minv of mother cut"}; + + // configurables for partitions + Configurable cMaxPtTPC{"cMaxPtTPC", 1.2, "maximum pt to apply TPC PID and TOF if available"}; + Configurable cMinPtTOF{"cMinPtTOF", 0.8, "minimum pt to require TOF PID in addition to TPC"}; + + void init(o2::framework::InitContext&) + { + + // LOG(info) << "\n cfgITScluster ============>"<< static_cast(cfgITScluster); + // LOG(info)<< "\n cfgTPCcluster ============>"<< static_cast(cfgTPCcluster); + + AxisSpec centAxis = {binsCent, "V0M (%)"}; + AxisSpec ImpactParAxis = {binsImpactPar, "Impact Parameter"}; + 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 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}; + + 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}}); + histos.add("TestME/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("TestME/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("TestME/hPairsCounterSameE", "tot n pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("TestME/hPairsCounterMixedE", "tot n pairs mixedE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + + // event histograms + 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("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}}); + } + + // Mass QA (quick check) + histos.add("k892invmassDS", "Invariant mass of K(892)0 different sign", kTH1F, {invMassAxis}); + 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 (doprocessMELight || doprocessMELightWithTof || doprocessMELightTPCLowPt || doprocessMELightTOFHighPt) { + 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}); + histos.add("k892invmassME_DSAnti", "Invariant mass of K(892)0 mixed event DSAnti", kTH1F, {invMassAxis}); + } + } + + 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"}}); + } + + // DCA QA + histos.add("QA/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkDCAxy_ka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {dcaxyAxis}); + histos.add("QA/trkDCAz_pi", "DCAz distribution of pion track candidates", HistType::kTH1F, {dcazAxis}); + histos.add("QA/trkDCAz_ka", "DCAz distribution of kaon track candidates", HistType::kTH1F, {dcazAxis}); + // pT QA + histos.add("QA/trkpT_pi", "pT distribution of pion track candidates", kTH1F, {ptAxis}); + histos.add("QA/trkpT_ka", "pT distribution of kaon track candidates", kTH1F, {ptAxis}); + // PID QA + histos.add("QA/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QA/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QA/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QA/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + 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 + 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 (doprocessMELight || doprocessMELightWithTof || doprocessMELightTPCLowPt || doprocessMELightTOFHighPt) { + histos.add("h3k892invmassME", "Invariant mass of K(892)0 mixed event", kTH3F, {centAxis, ptAxis, invMassAxis}); + + if (additionalMEPlots) { + histos.add("QAME/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAME/TOF_Nsigma_pi_all", "TOF NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TOF_TPC_Mapka_all", "TOF + TPC Combined PID for Kaon;#sigma_{TOF}^{Kaon};#sigma_{TPC}^{Kaon}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAME/TOF_Nsigma_ka_all", "TOF NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAME/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("h3k892invmassME_DS", "Invariant mass of K(892)0 mixed event DS", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3k892invmassME_DSAnti", "Invariant mass of K(892)0 mixed event DSAnti", kTH3F, {centAxis, ptAxis, invMassAxis}); + } + } + + if (doprocessMCLight || doprocessMCLightWithTof || doprocessMCLightTPCLowPt || doprocessMCLightTOFHighPt) { + // MC QA + histos.add("QAMCTrue/ImpactParameter", "Impact parameter of event", HistType::kTH1F, {ImpactParAxis}); + histos.add("QAMCTrue/trkDCAxy_pi", "DCAxy distribution of pion track candidates", HistType::kTH1F, {dcaxyAxis}); + 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}); + 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 Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TOF}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAMCTrue/TPC_Nsigmaka_all", "TPC NSigma for Kaon;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Kaon};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("k892Recinvmass", "Inv mass distribution of Reconstructed MC K(892)", kTH1F, {invMassAxis}); + histos.add("k892GenInvmass", "Invariant mass of generated K(892)0", kTH1F, {invMassAxis}); + histos.add("k892GenInvmassAnti", "Invariant mass of generated Anti-K(892)0", kTH1F, {invMassAxis}); + + histos.add("h3Reck892invmass", "Invariant mass of Reconstructed MC K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("h3Reck892invmassAnti", "Invariant mass of Reconstructed MC Anti-K(892)0", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("k892Gen", "pT distribution of True MC K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); + histos.add("k892GenAnti", "pT distribution of True MC Anti-K(892)0", kTH3F, {mcLabelAxis, ptAxis, centAxis}); + histos.add("k892Rec", "pT distribution of Reconstructed MC K(892)0", kTH2F, {ptAxis, centAxis}); + 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("ImpactParPlots/h3Reck892invmass", "Invariant mass of Reconstructed MC K(892)0", kTH3F, {ImpactParAxis, ptAxis, invMassAxis}); + histos.add("ImpactParPlots/h3Reck892invmassAnti", "Invariant mass of Reconstructed MC Anti-K(892)0", kTH3F, {ImpactParAxis, ptAxis, invMassAxis}); + histos.add("ImpactParPlots/k892Gen", "pT distribution of True MC K(892)0", kTH3F, {mcLabelAxis, ptAxis, ImpactParAxis}); + histos.add("ImpactParPlots/k892GenAnti", "pT distribution of True MC Anti-K(892)0", kTH3F, {mcLabelAxis, ptAxis, ImpactParAxis}); + histos.add("ImpactParPlots/k892Rec", "pT distribution of Reconstructed MC K(892)0", kTH2F, {ptAxis, ImpactParAxis}); + histos.add("ImpactParPlots/k892RecAnti", "pT distribution of Reconstructed MC Anti-K(892)0", kTH2F, {ptAxis, ImpactParAxis}); + histos.add("ImpactParPlots/h3k892GenInvmass", "Invariant mass of generated K(892)0", kTH3F, {ImpactParAxis, ptAxis, invMassAxis}); + histos.add("ImpactParPlots/h3k892GenInvmassAnti", "Invariant mass of generated Anti-K(892)0", kTH3F, {ImpactParAxis, ptAxis, invMassAxis}); + } + // Print output histograms statistics + LOG(info) << "Size of the histograms in spectraTOF"; + histos.print(); + } + + /////////////////////////////////////////////////////// + + SliceCache cache; + Preslice perRCol = aod::resodaughter::resoCollisionId; + Preslice perCollision = aod::track::collisionId; + + // 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; + + // 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); + + // 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); + + using ResoMCCols = soa::Join; + + //****************************************** + + float massKa = MassKaonCharged; + float massPi = MassPionCharged; + + template + bool trackCut(const TrackType track) + { + if (track.itsNCls() < cfgITScluster) + return false; + if (track.tpcNClsFound() < cfgTPCcluster) + return false; + + if (cfgUseITSRefit && !track.passedITSRefit()) + return false; + if (cfgUseTPCRefit && !track.passedTPCRefit()) + return false; + + if (cfgGlobalTrack && !track.isGlobalTrack()) + return false; + + return true; + } + // PID selection tools + + template + bool selectionPIDPion(const T& candidate) + { + if (tof_at_high_pt) { + if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaPi()) < cMaxTOFnSigmaPion)) { + return true; + } + if (!candidate.hasTOF() && (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion)) { + return true; + } + } else { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaPi()) < cMaxTPCnSigmaPion) { + tpcPIDPassed = true; + } + if (cByPassTOF && tpcPIDPassed) { + return true; + } + 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 { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } + return false; + } + template + bool selectionPIDKaon(const T& candidate) + { + if (tof_at_high_pt) { + if (candidate.hasTOF() && (std::abs(candidate.tofNSigmaKa()) < cMaxTOFnSigmaKaon)) { + return true; + } + if (!candidate.hasTOF() && (std::abs(candidate.tpcNSigmaKa()) < cMaxTPCnSigmaKaon)) { + return true; + } + } else { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaKa()) < cMaxTPCnSigmaKaon) { + tpcPIDPassed = true; + } + if (cByPassTOF && tpcPIDPassed) { + return true; + } + 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 { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + } + return false; + } + + template + bool selectionPIDPionME(const T& candidate) + { + float NsigmaTOF; + float NsigmaTPC; + + if (std::abs(candidate.pt()) < cfgHighPt) { + NsigmaTOF = cMaxTOFnSigmaPion; + NsigmaTPC = cMaxTPCnSigmaPion; + } else { + NsigmaTOF = cMaxTOFnSigmaPionHighPtME; + NsigmaTPC = cMaxTPCnSigmaPionHighPtME; + } + + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaPi()) < NsigmaTPC) { + tpcPIDPassed = true; + } + if (cByPassTOF && tpcPIDPassed) { + return true; + } + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < NsigmaTOF) { + tofPIDPassed = true; + } + } else { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + return false; + } + template + bool selectionPIDKaonME(const T& candidate) + { + float NsigmaTOF; + float NsigmaTPC; + + if (std::abs(candidate.pt()) < cfgHighPt) { + NsigmaTOF = cMaxTOFnSigmaKaon; + NsigmaTPC = cMaxTPCnSigmaKaon; + } else { + NsigmaTOF = cMaxTOFnSigmaKaonHighPtME; + NsigmaTPC = cMaxTPCnSigmaKaonHighPtME; + } + + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaKa()) < NsigmaTPC) { + tpcPIDPassed = true; + } + if (cByPassTOF && tpcPIDPassed) { + return true; + } + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaKa()) < NsigmaTOF) { + tofPIDPassed = true; + } + } else { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + return false; + } + + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + // auto multNTracksPV = collision.multNTracksPV(); + float impactpar = -999.0; + if constexpr (IsMC) { + impactpar = collision.impactParameter(); + } + auto multiplicity = collision.cent(); + + if (additionalQAeventPlots) { + if constexpr (!IsMix) { + histos.fill(HIST("QAevent/hVertexZSameE"), collision.posZ()); + histos.fill(HIST("QAevent/hMultiplicityPercentSameE"), collision.cent()); + 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"), collision.cent()); + histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision.globalIndex()); + histos.fill(HIST("TestME/hnTrksMixedE"), dTracks1.size()); + } + } + + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + for (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 (!IsMix) { + histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); + } else { + histos.fill(HIST("TestME/hPairsCounterMixedE"), 1.0); + } + } + + //// Initialize variables + // Trk1: Pion, Trk2: Kaon + // apply the track cut + if (!trackCut(trk1) || !trackCut(trk2)) + continue; + + auto isTrk1hasTOF = trk1.hasTOF(); + auto isTrk2hasTOF = trk2.hasTOF(); + auto trk1ptPi = trk1.pt(); + auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; + auto trk2ptKa = trk2.pt(); + auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); + auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; + + if constexpr (!IsMix) { + if (!selectionPIDPion(trk1) || !selectionPIDKaon(trk2)) + continue; + } else { + if (!selectionPIDPionME(trk1) || !selectionPIDKaonME(trk2)) + continue; + } + + if (additionalQAplots) { + // 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()); + } + + if constexpr (!IsMix) { + //// QA plots after the selection + // --- PID QA Pion + histos.fill(HIST("QA/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QA/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QA/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QA/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QA/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QA/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + histos.fill(HIST("QA/trkpT_pi"), trk1ptPi); + histos.fill(HIST("QA/trkpT_ka"), trk2ptKa); + histos.fill(HIST("QA/trkDCAxy_pi"), trk1.dcaXY()); + 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) { + // --- PID QA Pion + histos.fill(HIST("QAME/TPC_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (isTrk1hasTOF) { + histos.fill(HIST("QAME/TOF_Nsigma_pi_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAME/TOF_TPC_Map_pi_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // --- PID QA Kaon + histos.fill(HIST("QAME/TPC_Nsigmaka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTPC); + if (isTrk2hasTOF) { + histos.fill(HIST("QAME/TOF_Nsigma_ka_all"), multiplicity, trk2ptKa, trk2NSigmaKaTOF); + histos.fill(HIST("QAME/TOF_TPC_Mapka_all"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); + } + } + + //// 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) + continue; + if (cfgCutsOnMother) { + if (lResonance.Pt() >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (lResonance.M() >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + //// Un-like sign pair only + if (trk1.sign() * trk2.sign() < 0) { + if constexpr (!IsMix) { + if (trk1.sign() < 0) { + histos.fill(HIST("k892invmassDS"), lResonance.M()); + histos.fill(HIST("h3k892invmassDS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (trk1.sign() > 0) { + histos.fill(HIST("k892invmassDSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassDSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } else { + histos.fill(HIST("k892invmassME"), lResonance.M()); + histos.fill(HIST("h3k892invmassME"), multiplicity, lResonance.Pt(), lResonance.M()); + if (additionalMEPlots) { + if (trk1.sign() < 0) { + histos.fill(HIST("k892invmassME_DS"), lResonance.M()); + histos.fill(HIST("h3k892invmassME_DS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (trk1.sign() > 0) { + histos.fill(HIST("k892invmassME_DSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassME_DSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + + // MC + if constexpr (IsMC) { + if (abs(trk1.pdgCode()) != 211 || abs(trk2.pdgCode()) != 321) + continue; + if (trk1.motherId() != trk2.motherId()) // Same mother + continue; + if (abs(trk1.motherPDG()) != 313) + continue; + + // Track selection check. + histos.fill(HIST("QAMCTrue/trkDCAxy_pi"), trk1.dcaXY()); + histos.fill(HIST("QAMCTrue/trkDCAxy_ka"), trk2.dcaXY()); + histos.fill(HIST("QAMCTrue/trkDCAz_pi"), trk1.dcaZ()); + histos.fill(HIST("QAMCTrue/trkDCAz_ka"), trk2.dcaZ()); + 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 (trk1.motherPDG() > 0) { + histos.fill(HIST("k892Rec"), lResonance.Pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892Rec"), lResonance.Pt(), impactpar); + histos.fill(HIST("k892Recinvmass"), lResonance.M()); + histos.fill(HIST("h3Reck892invmass"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("ImpactParPlots/h3Reck892invmass"), impactpar, lResonance.Pt(), lResonance.M()); + } else { + histos.fill(HIST("k892RecAnti"), lResonance.Pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892RecAnti"), lResonance.Pt(), impactpar); + histos.fill(HIST("k892Recinvmass"), lResonance.M()); + histos.fill(HIST("h3Reck892invmassAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("ImpactParPlots/h3Reck892invmassAnti"), impactpar, lResonance.Pt(), lResonance.M()); + } + } + } else if (trk1.sign() * trk2.sign() > 0) { + if constexpr (!IsMix) { + if (trk1.sign() < 0) { + histos.fill(HIST("k892invmassLS"), lResonance.M()); + histos.fill(HIST("h3k892invmassLS"), multiplicity, lResonance.Pt(), lResonance.M()); + } else if (trk1.sign() > 0) { + histos.fill(HIST("k892invmassLSAnti"), lResonance.M()); + histos.fill(HIST("h3k892invmassLSAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + } + } // end of fillHistograms + + /////////////////////////////////////////////////////////////////////////////// + ///// ///// + ///// PROCESS FUNCTIONS ///// + ///// ///// + /////////////////////////////////////////////////////////////////////////////// + + void processDataLight(aod::ResoCollision& collision, + soa::Filtered const&) + { + // LOG(info) << "new collision, zvtx: " << collision.posZ(); + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + + auto candPi = resoPi->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoKa->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processDataLight, "Process Event for data", false); + + void processDataLightWithTof(aod::ResoCollision& collision, + soa::Filtered const&) + { + // LOG(info) << "new collision, zvtx: " << collision.posZ(); + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + + auto candPiwithtof = resoPiWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKawithtof = resoKaWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPiwithtof, candKawithtof); + } + PROCESS_SWITCH(kstar892analysis, processDataLightWithTof, "Process Event for data, tracks with TOF", false); + + void processDataTPCLowPt(aod::ResoCollision& collision, + soa::Filtered const&) + { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + + auto candPi = resoPiTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoKaTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processDataTPCLowPt, "Process Event for data, TPC at low pt", false); + + void processDataTOFHighPt(aod::ResoCollision& collision, + soa::Filtered const&) + { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + + auto candPi = resoPiTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoKaTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processDataTOFHighPt, "Process Event for data, TOF at high pt", false); + + void processMCLight(ResoMCCols::iterator const& collision, + soa::Filtered> const&) + { + if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + return; + + auto candPi = resoMCrecPi->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoMCrecKa->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processMCLight, "Process Event for MC (Reconstructed)", false); + + void processMCLightWithTof(ResoMCCols::iterator const& collision, + soa::Filtered> const&) + { + if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + return; + + auto candPiwithtof = resoMCrecPiWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKawithtof = resoMCrecKaWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPiwithtof, candKawithtof); + } + PROCESS_SWITCH(kstar892analysis, processMCLightWithTof, "Process Event for MC (Reconstructed), tracks with TOF", false); + + void processMCLightTPCLowPt(ResoMCCols::iterator const& collision, + soa::Filtered> const&) + { + if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + return; + + auto candPi = resoMCrecPiTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoMCrecKaTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processMCLightTPCLowPt, "Process Event for MC (reconstructed), TPC at low pt", false); + + void processMCLightTOFHighPt(ResoMCCols::iterator const& collision, + soa::Filtered> const&) + { + if (!collision.isInAfterAllCuts() || (abs(collision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + return; + + auto candPi = resoMCrecPiTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + auto candKa = resoMCrecKaTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision.globalIndex(), cache); + + fillHistograms(collision, candPi, candKa); + } + PROCESS_SWITCH(kstar892analysis, processMCLightTOFHighPt, "Process Event for MC (reconstructed), TOF at high pt", false); + + void processMCTrue(ResoMCCols::iterator const& collision, aod::ResoMCParents& resoParents, aod::McParticles& mcparticles) + { + auto multiplicity = collision.cent(); + float impactpar = collision.impactParameter(); + histos.fill(HIST("QAMCTrue/ImpactParameter"), impactpar); + + for (auto& part : resoParents) { // loop over all pre-filtered MC particles + if (abs(part.pdgCode()) != 313 || 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; + + if (!pass1 || !pass2) + continue; + + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + + std::vector listDaughters{}; + std::array dauPdgs = {211, 321}; + + auto mcparticle = part.mcParticle_as(); + + RecoDecay::getDaughters(mcparticle, &listDaughters, dauPdgs, 1); + + for (const auto& dauIdx : listDaughters) { + auto dauPart = mcparticles.rawIteratorAt(dauIdx - mcparticles.offset()); + + if (std::abs(dauPart.pdgCode()) == 211) { + lDecayDaughter1.SetXYZM(dauPart.px(), dauPart.py(), dauPart.pz(), massPi); + } else if (std::abs(dauPart.pdgCode()) == 321) { + lDecayDaughter2.SetXYZM(dauPart.px(), dauPart.py(), dauPart.pz(), massKa); + } + } + lResonance = lDecayDaughter1 + lDecayDaughter2; + + if (part.pdgCode() > 0) { // no cuts, purely generated + histos.fill(HIST("k892GenInvmass"), lResonance.M()); + histos.fill(HIST("h3k892GenInvmass"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("ImpactParPlots/h3k892GenInvmass"), impactpar, lResonance.Pt(), lResonance.M()); + } else { + histos.fill(HIST("k892GenInvmassAnti"), lResonance.M()); + histos.fill(HIST("h3k892GenInvmassAnti"), multiplicity, lResonance.Pt(), lResonance.M()); + histos.fill(HIST("ImpactParPlots/h3k892GenInvmassAnti"), impactpar, lResonance.Pt(), lResonance.M()); + } + + if (collision.isVtxIn10()) // INEL10 + { + if (part.pdgCode() > 0) { + histos.fill(HIST("k892Gen"), 0, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892Gen"), 0, part.pt(), impactpar); + } else { + histos.fill(HIST("k892GenAnti"), 0, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892GenAnti"), 0, part.pt(), impactpar); + } + } + if (collision.isVtxIn10() && collision.isInSel8()) // INEL>10, vtx10 + { + if (part.pdgCode() > 0) { + histos.fill(HIST("k892Gen"), 1, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892Gen"), 1, part.pt(), impactpar); + } else { + histos.fill(HIST("k892GenAnti"), 1, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892GenAnti"), 1, part.pt(), impactpar); + } + } + if (collision.isVtxIn10() && collision.isTriggerTVX()) // vtx10, TriggerTVX + { + if (part.pdgCode() > 0) { + histos.fill(HIST("k892Gen"), 2, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892Gen"), 2, part.pt(), impactpar); + } else { + histos.fill(HIST("k892GenAnti"), 2, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892GenAnti"), 2, part.pt(), impactpar); + } + } + if (collision.isInAfterAllCuts()) // after all event selection + { + if (part.pdgCode() > 0) { + histos.fill(HIST("k892Gen"), 3, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892Gen"), 3, part.pt(), impactpar); + } else { + histos.fill(HIST("k892GenAnti"), 3, part.pt(), multiplicity); + histos.fill(HIST("ImpactParPlots/k892GenAnti"), 3, part.pt(), impactpar); + } + } + } + } + PROCESS_SWITCH(kstar892analysis, processMCTrue, "Process Event for MC (Generated)", false); + + // Processing Event Mixing + using BinningTypeVtxZT0M = ColumnBinningPolicy; + void processMELight(o2::aod::ResoCollisions& collisions, soa::Filtered const& resotracks) + { + auto tracksTuple = std::make_tuple(resotracks); + BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + SameKindPair, BinningTypeVtxZT0M> pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + + auto candPi = resoPi->sliceByCached(aod::resodaughter::resoCollisionId, collision1.globalIndex(), cache); + auto candKa = resoKa->sliceByCached(aod::resodaughter::resoCollisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candPi, candKa); + } + } + PROCESS_SWITCH(kstar892analysis, processMELight, "Process EventMixing light without partition", false); + + void processMELightWithTof(o2::aod::ResoCollisions& collisions, soa::Filtered const& resotracks) + { + auto tracksTuple = std::make_tuple(resotracks); + BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + SameKindPair, BinningTypeVtxZT0M> pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + + auto candPiwithtof = resoPiWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision1.globalIndex(), cache); + auto candKawithtof = resoKaWithTof->sliceByCached(aod::resodaughter::resoCollisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candPiwithtof, candKawithtof); + } + } + PROCESS_SWITCH(kstar892analysis, processMELightWithTof, "Process EventMixing light with tof", false); + + void processMELightTPCLowPt(o2::aod::ResoCollisions& collisions, soa::Filtered const& resotracks) + { + auto tracksTuple = std::make_tuple(resotracks); + BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + SameKindPair, BinningTypeVtxZT0M> pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + + auto candPi = resoPiTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision1.globalIndex(), cache); + auto candKa = resoKaTPClowPt->sliceByCached(aod::resodaughter::resoCollisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candPi, candKa); + } + } + PROCESS_SWITCH(kstar892analysis, processMELightTPCLowPt, "Process EventMixing light with TPC at low pt", false); + + void processMELightTOFHighPt(o2::aod::ResoCollisions& collisions, soa::Filtered const& resotracks) + { + auto tracksTuple = std::make_tuple(resotracks); + BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + SameKindPair, BinningTypeVtxZT0M> pairs{colBinning, nEvtMixing, -1, collisions, tracksTuple, &cache}; // -1 is the number of the bin to skip + + for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterMixedE"), 1.0); + + auto candPi = resoPiTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision1.globalIndex(), cache); + auto candKa = resoKaTOFhighPt->sliceByCached(aod::resodaughter::resoCollisionId, collision2.globalIndex(), cache); + + fillHistograms(collision1, candPi, candKa); + } + } + PROCESS_SWITCH(kstar892analysis, processMELightTOFHighPt, "Process EventMixing light with TOF at high pt", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"lf-kstar892analysis"})}; +} diff --git a/PWGLF/Tasks/Resonances/kstarpbpb.cxx b/PWGLF/Tasks/Resonances/kstarpbpb.cxx index be6f8280a9e..712b2d411a3 100644 --- a/PWGLF/Tasks/Resonances/kstarpbpb.cxx +++ b/PWGLF/Tasks/Resonances/kstarpbpb.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. -// sourav.kundu@cern.ch +// sourav.kundu@cern.ch , sarjeeta.gami@cern.ch #include #include @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -73,42 +75,54 @@ struct kstarpbpb { // 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 additionalEvSel2{"additionalEvSel2", true, "Additional evsel2"}; + Configurable additionalEvSel3{"additionalEvSel3", true, "Additional evsel3"}; 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 confRapidity{"confRapidity", 0.5, "Rapidity cut"}; - ConfigurableAxis configThnAxisInvMass{"configThnAxisInvMass", {120, 0.66, 1.2}, "#it{M} (GeV/#it{c}^{2})"}; + 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"}; + 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"}; Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; + Configurable OnlyTOF{"OnlyTOF", true, "OnlyTOF"}; + 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"}; 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 fillOccupancy{"fillOccupancy", false, "fill Occupancy"}; + Configurable cfgOccupancyCut{"cfgOccupancyCut", 500, "Occupancy cut"}; 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>; - - using EventCandidatesMC = soa::Join; - using TrackCandidatesMC = soa::Filtered>; + using TrackCandidates = soa::Filtered>; SliceCache cache; Partition posTracks = aod::track::signed1Pt > cfgCutCharge; @@ -137,21 +151,27 @@ struct kstarpbpb { AxisSpec occupancyAxis = {occupancyBinning, "Occupancy"}; histos.add("hpTvsRapidity", "pT vs Rapidity", kTH2F, {{100, 0.0f, 10.0f}, {300, -1.5f, 1.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("hPsiFT0C", "PsiFT0C", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiFT0A", "PsiFT0A", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hPsiTPC", "PsiTPC", kTH3F, {centAxis, occupancyAxis, phiAxis}); - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality, occupancyAxis}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality, occupancyAxis}); - histos.add("hSparseV2SASameEventRotational_V2", "hSparseV2SASameEventRotational_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality, occupancyAxis}); - - // histogram for resolution - histos.add("ResFT0CTPC", "ResFT0CTPC", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH3F, {centAxis, occupancyAxis, resAxis}); - histos.add("ResFT0ATPC", "ResFT0ATPC", kTH3F, {centAxis, occupancyAxis, resAxis}); + 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 (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}}); + histos.add("hOccupancy", "Occupancy distribution", kTH1F, {occupancyAxis}); + histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{400, -20.0, 20.0}}); + histos.add("hPsiFT0C", "PsiFT0C", kTH2F, {centAxis, phiAxis}); + histos.add("hPsiFT0A", "PsiFT0A", kTH2F, {centAxis, phiAxis}); + histos.add("hPsiTPC", "PsiTPC", kTH2F, {centAxis, phiAxis}); + histos.add("ResFT0CTPC", "ResFT0CTPC", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0CFT0A", "ResFT0CFT0A", kTH2F, {centAxis, resAxis}); + histos.add("ResFT0ATPC", "ResFT0ATPC", kTH2F, {centAxis, resAxis}); + } if (additionalQAplots) { // DCA QA histos.add("QAbefore/trkDCAxyka", "DCAxy distribution of kaon track candidates", HistType::kTH1F, {{150, 0.0f, 1.0f}}); @@ -203,7 +223,7 @@ struct kstarpbpb { double massPi = o2::constants::physics::MassPiMinus; template - bool eventSelected(TCollision collision, const int& /*multTrk*/, const float& centrality) + bool eventSelected(TCollision collision, const float& centrality) { if (collision.alias_bit(kTVXinTRD)) { // TRD triggered @@ -223,7 +243,6 @@ struct kstarpbpb { return 1; } - template bool selectionTrack(const T& candidate) { @@ -237,20 +256,20 @@ struct kstarpbpb { } template - bool selectionPIDpTdependent(const T& candidate, int PID) + bool selectionPIDNew(const T& candidate, int PID) { if (PID == 0) { - if (candidate.p() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (candidate.p() >= 0.5 && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } } else if (PID == 1) { - if (candidate.p() < 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { return true; } - if (candidate.p() >= 0.5 && candidate.hasTOF() && ((candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) + (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { return true; } } @@ -261,17 +280,23 @@ struct kstarpbpb { bool selectionPID(const T& candidate, int PID) { if (PID == 0) { - if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!OnlyTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (!OnlyTOF && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + return true; + } + if (OnlyTOF && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } } else if (PID == 1) { - if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + if (!OnlyTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC) { + return true; + } + if (!OnlyTOF && candidate.hasTOF() && ((candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) + (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi())) < (nsigmaCutCombined * nsigmaCutCombined)) { return true; } - if (candidate.hasTOF() && ((candidate.tofNSigmaPi() * candidate.tofNSigmaPi()) + (candidate.tpcNSigmaPi() * candidate.tpcNSigmaPi())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (OnlyTOF && candidate.hasTOF() && TMath::Abs(candidate.tofNSigmaPi()) < nsigmaCutTOF) { return true; } } @@ -279,21 +304,60 @@ struct kstarpbpb { } template - bool selectionPIDNew(const T& candidate, int PID) + bool strategySelectionPID(const T& candidate, int PID, int strategy) { if (PID == 0) { - if (candidate.p() < 0.6 && TMath::Abs(candidate.tpcNSigmaKa()) < 2.0) { - return true; - } - if (candidate.p() >= 0.6 && candidate.p() < 3.0 && candidate.hasTOF() && candidate.tpcNSigmaKa() > -2.0 && candidate.tpcNSigmaKa() < 3.0 && TMath::Abs(candidate.tofNSigmaKa()) < 2.0) { - return true; - } - } else if (PID == 1) { - if (candidate.p() < 1.0 && TMath::Abs(candidate.tpcNSigmaPi()) < 2.0) { - return true; + 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; + } } - if (candidate.p() >= 1.0 && candidate.p() < 3.0 && candidate.hasTOF() && candidate.tpcNSigmaPi() > -2.0 && candidate.tpcNSigmaPi() < 3.0 && TMath::Abs(candidate.tofNSigmaPi()) < 2.0) { - return true; + } + if (PID == 1) { + if (strategy == 0) { + 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) { + 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) { + 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) { + return true; + } + if (candidate.pt() >= 0.5 && TMath::Abs(candidate.tpcNSigmaPi()) < nsigmaCutTPC && !candidate.hasTOF()) { + return true; + } } } return false; @@ -310,48 +374,175 @@ struct kstarpbpb { } return result; } - + template + bool isFakeKaon(T const& track, int PID) + { + const auto pglobal = track.p(); + const auto ptpc = track.tpcInnerParam(); + if (TMath::Abs(pglobal - ptpc) > ConfFakeKaonCut) { + return true; + } + return false; + } 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 axisEPAngle{"axisEPAngle", {9, -TMath::Pi() / 2, TMath::Pi() / 2}, "event plane angle"}; using BinningTypeVertexContributor = ColumnBinningPolicy; ROOT::Math::PxPyPzMVector KstarMother, daughter1, daughter2, kaonrot, kstarrot; - void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { - if (!collision.sel8()) { + 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; } + auto centrality = collision.centFT0C(); + auto multTPC = collision.multNTracksPV(); + int occupancy = collision.trackOccupancyInTimeRange(); + auto psiFT0C = collision.psiFT0C(); + auto psiFT0A = collision.psiFT0A(); + auto psiTPC = collision.psiTPC(); + if (fillOccupancy && occupancy >= cfgOccupancyCut) { + return; + } + if (additionalEvsel && !eventSelected(collision, centrality)) { + return; + } + if (additionalQAplots1) { + histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); + histos.fill(HIST("hPsiFT0C"), centrality, psiFT0C); + histos.fill(HIST("hPsiFT0A"), centrality, psiFT0A); + histos.fill(HIST("hPsiTPC"), centrality, psiTPC); + histos.fill(HIST("ResFT0CTPC"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResFT0ATPC"), centrality, TMath::Cos(2.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hOccupancy"), occupancy); + histos.fill(HIST("hVtxZ"), collision.posZ()); + } + for (auto track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + bool track1kaon = false; + auto track1ID = track1.globalIndex(); + if (!strategySelectionPID(track1, 0, strategyPID)) { + 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()); + } + for (auto track2 : tracks) { + if (!selectionTrack(track2)) { + continue; + } + bool track2pion = false; + auto track2ID = track2.globalIndex(); + if (!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 (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 (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + auto 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); + auto v2Rot = TMath::Cos(2.0 * phiminuspsiRot); + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, 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); + } + if (track1.sign() < 0 && track2.sign() < 0) { + histos.fill(HIST("hSparseV2SAlikeEventNN_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + } + } + } + } + } + PROCESS_SWITCH(kstarpbpb, processSE, "Process Same event latest", true); + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) + { + if (!collision.sel8()) { + return; + } + auto centrality = collision.centFT0C(); + auto multTPC = collision.multNTracksPV(); if (!collision.triggereventep()) { return; } 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(); auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); - auto centrality = collision.centFT0C(); - auto multTPC = collision.multNTracksPV(); auto psiFT0C = collision.psiFT0C(); auto psiFT0A = collision.psiFT0A(); auto psiTPC = collision.psiTPC(); - int occupancy = collision.trackOccupancyInTimeRange(); - histos.fill(HIST("hFTOCvsTPC"), centrality, multTPC); - if (additionalEvsel && !eventSelected(collision, tracks.size(), centrality)) { + if (fillOccupancy && occupancy >= cfgOccupancyCut) // occupancy info is available for this collision (*) + { return; } - histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); - histos.fill(HIST("hPsiFT0C"), centrality, occupancy, psiFT0C); - histos.fill(HIST("hPsiFT0A"), centrality, occupancy, psiFT0A); - histos.fill(HIST("hPsiTPC"), centrality, occupancy, psiTPC); - histos.fill(HIST("ResFT0CTPC"), centrality, occupancy, TMath::Cos(2.0 * (psiFT0C - psiTPC))); - 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("hCentrality"), centrality); - histos.fill(HIST("hVtxZ"), collision.posZ()); - + if (additionalEvsel && !eventSelected(collision, centrality)) { + return; + } + if (additionalQAplots1) { + histos.fill(HIST("hFTOCvsTPCSelected"), centrality, multTPC); + histos.fill(HIST("hPsiFT0C"), centrality, psiFT0C); + histos.fill(HIST("hPsiFT0A"), centrality, psiFT0A); + histos.fill(HIST("hPsiTPC"), centrality, psiTPC); + histos.fill(HIST("ResFT0CTPC"), centrality, TMath::Cos(2.0 * (psiFT0C - psiTPC))); + histos.fill(HIST("ResFT0CFT0A"), centrality, TMath::Cos(2.0 * (psiFT0C - psiFT0A))); + histos.fill(HIST("ResFT0ATPC"), centrality, TMath::Cos(2.0 * (psiTPC - psiFT0A))); + histos.fill(HIST("hCentrality"), centrality); + histos.fill(HIST("hOccupancy"), occupancy); + histos.fill(HIST("hVtxZ"), collision.posZ()); + } for (auto track1 : posThisColl) { if (!selectionTrack(track1)) { continue; @@ -372,6 +563,7 @@ struct kstarpbpb { if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { continue; } + auto track1ID = track1.globalIndex(); for (auto track2 : negThisColl) { bool track2pion = false; bool track2kaon = false; @@ -391,6 +583,10 @@ struct kstarpbpb { if (!ispTdepPID && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { continue; } + auto track2ID = track2.globalIndex(); + if (isGI && (track2ID <= track1ID)) { + continue; + } if (track1.sign() * track2.sign() > 0) { continue; } @@ -399,20 +595,32 @@ struct kstarpbpb { if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { track1pion = true; track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } } if (selectionPIDNew(track2, 1) && selectionPIDNew(track1, 0)) { track2pion = true; track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } } } if (!ispTdepPID) { if (selectionPID(track1, 1) && selectionPID(track2, 0)) { track1pion = true; track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } } if (selectionPID(track2, 1) && selectionPID(track1, 0)) { track2pion = true; track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } } } @@ -445,8 +653,7 @@ struct kstarpbpb { } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); auto v2 = TMath::Cos(2.0 * phiminuspsi); - histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality, occupancy); - + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); if (fillRotation) { for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { auto anglestart = confMinRot; @@ -468,31 +675,170 @@ struct kstarpbpb { continue; } kstarrot = kaonrot + daughter2; + if (TMath::Abs(kstarrot.Rapidity()) > confRapidity) { + continue; + } auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); auto v2Rot = TMath::Cos(2.0 * phiminuspsiRot); - histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality, occupancy); + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); } } } } } - PROCESS_SWITCH(kstarpbpb, processSameEvent, "Process Same event", true); - void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) + PROCESS_SWITCH(kstarpbpb, processSameEvent, "Process Same event", false); + void processlikeEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + { + if (!collision.sel8()) { + return; + } + auto centrality = collision.centFT0C(); + if (!collision.triggereventep()) { + return; + } + 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(); + auto psiFT0C = collision.psiFT0C(); + if (fillOccupancy && occupancy >= cfgOccupancyCut) // occupancy info is available for this collision (*) + { + return; + } + + if (additionalEvsel && !eventSelected(collision, centrality)) { + return; + } + for (auto track1 : tracks) { + if (!selectionTrack(track1)) { + continue; + } + bool track1pion = false; + bool track1kaon = false; + if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { + continue; + } + if (!ispTdepPID && !(selectionPID(track1, 0) || selectionPID(track1, 1))) { + continue; + } + for (auto track2 : tracks) { + bool track2pion = false; + bool track2kaon = false; + if (!selectionTrack(track2)) { + continue; + } + if (ispTdepPID && !(selectionPIDNew(track2, 0) || selectionPIDNew(track2, 1))) { + continue; + } + if (!ispTdepPID && !(selectionPID(track2, 0) || selectionPID(track2, 1))) { + continue; + } + if (track1.sign() * track2.sign() < 0) { + continue; + } + + if (ispTdepPID) { + if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { + track1pion = true; + track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } + } + if (selectionPIDNew(track2, 1) && selectionPIDNew(track1, 0)) { + track2pion = true; + track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } + } + } + if (!ispTdepPID) { + if (selectionPID(track1, 1) && selectionPID(track2, 0)) { + track1pion = true; + track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } + } + if (selectionPID(track2, 1) && selectionPID(track1, 0)) { + track2pion = true; + track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } + } + } + if (track1kaon && track2pion) { + 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); + + KstarMother = daughter1 + daughter2; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + auto v2 = TMath::Cos(2.0 * phiminuspsi); + histos.fill(HIST("hSparseV2SAlikeEventNN_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + } + } else if (track1pion && track2kaon) { + if (track1.sign() > 0 && track2.sign() > 0) { + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massPi); + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); + KstarMother = daughter1 + daughter2; + if (TMath::Abs(KstarMother.Rapidity()) > confRapidity) { + continue; + } + auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); + auto v2 = TMath::Cos(2.0 * phiminuspsi); + histos.fill(HIST("hSparseV2SAlikeEventPP_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + } + } + } + } + } + + PROCESS_SWITCH(kstarpbpb, processlikeEvent, "Process like event", false); + void processMixedEvent(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) { + 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); + continue; + } + if (additionalEvSel2 && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { continue; } - int occupancy = collision1.trackOccupancyInTimeRange(); + if (additionalEvSel2 && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel3 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel3 && (!collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + 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); auto centrality = collision1.centFT0C(); auto centrality2 = collision2.centFT0C(); auto psiFT0C = collision1.psiFT0C(); @@ -500,19 +846,22 @@ struct kstarpbpb { bool track1kaon = false; bool track2pion = false; bool track2kaon = false; - - if (additionalEvsel && !eventSelected(collision1, tracks.size(), centrality)) { + if (additionalEvsel && !eventSelected(collision1, centrality)) { + // printf("Mix = %d\n", 4); continue; } - if (additionalEvsel && !eventSelected(collision2, tracks.size(), centrality2)) { + if (additionalEvsel && !eventSelected(collision2, centrality2)) { + // printf("Mix = %d\n", 5); continue; } - - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - if (track1.sign() * track2.sign() > 0) { - continue; - } + if (fillOccupancy && occupancy1 >= cfgOccupancyCut && occupancy2 >= cfgOccupancyCut) // occupancy info is available for this collision (*) + { + continue; + } + for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { + // track selection if (!selectionTrack(track1) || !selectionTrack(track2)) { + // printf("Mix = %d\n", 6); continue; } if (ispTdepPID && !(selectionPIDNew(track1, 0) || selectionPIDNew(track1, 1))) { @@ -532,20 +881,32 @@ struct kstarpbpb { if (selectionPIDNew(track1, 1) && selectionPIDNew(track2, 0)) { track1pion = true; track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } } if (selectionPIDNew(track2, 1) && selectionPIDNew(track1, 0)) { track2pion = true; track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } } } if (!ispTdepPID) { if (selectionPID(track1, 1) && selectionPID(track2, 0)) { track1pion = true; track2kaon = true; + if (removefaketrak && isFakeKaon(track2, 0)) { + continue; + } } if (selectionPID(track2, 1) && selectionPID(track1, 0)) { track2pion = true; track1kaon = true; + if (removefaketrak && isFakeKaon(track1, 0)) { + continue; + } } } if (track1kaon && track2pion) { @@ -563,11 +924,11 @@ struct kstarpbpb { } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); auto v2 = TMath::Cos(2.0 * phiminuspsi); - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality, occupancy); + histos.fill(HIST("hSparseV2SAMixedEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } } } - PROCESS_SWITCH(kstarpbpb, processMixedEvent, "Process Mixed event", true); + PROCESS_SWITCH(kstarpbpb, processMixedEvent, "Process Mixed event", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGLF/Tasks/Resonances/kstarqa.cxx b/PWGLF/Tasks/Resonances/kstarqa.cxx index 1606a75ac8b..5517a69818e 100644 --- a/PWGLF/Tasks/Resonances/kstarqa.cxx +++ b/PWGLF/Tasks/Resonances/kstarqa.cxx @@ -23,11 +23,10 @@ #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 "Common/Core/TrackSelection.h" @@ -50,15 +49,11 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::soa; using std::array; struct kstarqa { - // 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"}; - SliceCache cache; // Histograms are defined with HistogramRegistry @@ -66,14 +61,18 @@ struct kstarqa { HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Confugrable for QA histograms - Configurable QA{"QA", false, "QA"}; + Configurable CalcLikeSign{"CalcLikeSign", true, "Calculate Like Sign"}; + Configurable CalcRotational{"CalcRotational", true, "Calculate Rotational"}; Configurable QAbefore{"QAbefore", true, "QAbefore"}; Configurable QAafter{"QAafter", true, "QAafter"}; + Configurable QAevents{"QAevents", 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 cfgFT0M{"cfgFT0M", true, "1: pp, 0: PbPb"}; // Configurables for track selections + Configurable rotational_cut{"rotational_cut", 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"}; @@ -112,6 +111,20 @@ struct kstarqa { ConfigurableAxis binsMultPlot{"binsCent", {201, -0.5f, 200.5f}, "Binning of the centrality axis for plots"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", true, "avoid split track in MC"}; Configurable AllGenCollisions{"AllGenCollisions", true, "To fill all generated collisions for the signal loss calculations"}; + 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"}; + + // Event plane configurables + Configurable boost_daugter1{"boost_daugter1", false, "Boost daughter Kaon in the COM frame"}; + Configurable boost_daugter2{"boost_daugter2", true, "Boost daughter Pion in the COM frame"}; + Configurable activateTHnSparseCosThStarHelicity{"activateTHnSparseCosThStarHelicity", true, "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", 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 c_nof_rotations{"c_nof_rotations", 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&) { @@ -119,35 +132,34 @@ struct kstarqa { 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 thnAxisPOL{configThnAxisPOL, "cos(#theta)"}; // Histograms // Event selection rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hmult", "Centrality distribution", kTH1F, {{binsMultPlot}}); + rEventSelection.add("hmult", "Multiplicity percentile", kTH1F, {{binsMultPlot}}); // for primary tracks if (QAbefore && QAafter) { - histos.add("hNsigmaPionTPC_before", "NsigmaPion TPC distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaPionTOF_before", "NsigmaPion TOF distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTPC_before", "NsigmaKaon TPC distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_before", "NsigmaKaon TOF distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("deoverdx_tpc", "dE/dx TPC distribution", kTH2F, {{ptAxis}, {250, 0, 500}}); + histos.add("hNsigmaTPC_before", "NsigmaKaon TPC distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + histos.add("hNsigmaTOF_before", "NsigmaKaon TOF distribution before", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + histos.add("dE_by_dx_TPC", "dE/dx signal in the TPC as a function of pT", kTH2F, {axisPtfordEbydx, axisdEdx}); histos.add("hphi", "Phi distribution", kTH1F, {{65, 0, 6.5}}); histos.add("hEta_after", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); histos.add("hCRFC_after", "CRFC after distribution", kTH1F, {{100, 0.0f, 10.0f}}); histos.add("hCRFC_before", "CRFC before distribution", kTH1F, {{100, 0.0f, 10.0f}}); - histos.add("hNsigmaPionTPC_after", "NsigmaPion TPC distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaPionTOF_after", "NsigmaPion TOF distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTPC_after", "NsigmaKaon TPC distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); - histos.add("hNsigmaKaonTOF_after", "NsigmaKaon TOF distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaPionTPC_after", "NsigmaPion TPC distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaPionTOF_after", "NsigmaPion TOF distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaKaonTPC_after", "NsigmaKaon TPC distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); + // histos.add("hNsigmaKaonTOF_after", "NsigmaKaon TOF distribution", kTH2F, {{100, 0.0f, 10.0f}, {200, -10.0f, 10.0f}}); } // KStar histograms - histos.add("h3KstarInvMassUnlikeSign", "Invariant mass of kstar meson Unlike Sign", kTHnSparseF, {{binsMultPlot}, {ptAxis}, {invmassAxis}}, true); - histos.add("h3KstarInvMasslikeSign", "Invariant mass of kstar meson like Sign", kTHnSparseF, {{binsMultPlot}, {ptAxis}, {invmassAxis}}, true); - histos.add("h3KstarInvMassRotated", "Invariant mass of kstar meson rotated", kTHnSparseF, {{binsMultPlot}, {ptAxis}, {invmassAxis}}, true); - histos.add("h3KstarInvMassMixed", "Invariant mass of kstar meson Mixed", kTHnSparseF, {{binsMultPlot}, {ptAxis}, {invmassAxis}}, true); + histos.add("h3KstarInvMassUnlikeSign", "kstar Unlike Sign", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); + histos.add("h3KstarInvMasslikeSign", "kstar like Sign", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); + histos.add("h3KstarInvMassRotated", "kstar rotated", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); + histos.add("h3KstarInvMassMixed", "kstar Mixed", kTHnSparseF, {binsMultPlot, ptAxis, invmassAxis, thnAxisPOL}); // MC generated histograms histos.add("k892Gen", "pT distribution of True MC K(892)0", kTH1D, {ptAxis}); @@ -158,15 +170,20 @@ struct kstarqa { histos.add("h1KstarRecpt", "pT of kstar meson", kTH1F, {ptAxis}); histos.add("h1genmass", "Invariant mass of generated kstar meson", kTH1D, {invmassAxis}); histos.add("h1recpt", "pT of generated kstar meson", kTH1F, {ptAxis}); - histos.add("events_check", "No. of events in the generated MC", kTH1F, {{20, 0, 20}}); - histos.add("events_checkrec", "No. of events in the reconstructed MC", kTH1F, {{20, 0, 20}}); + histos.add("events_check_data", "No. of events in the data", kTH1I, {{20, 0, 20}}); + histos.add("events_check", "No. of events in the generated MC", kTH1I, {{20, 0, 20}}); + histos.add("events_checkrec", "No. of events in the reconstructed MC", kTH1I, {{20, 0, 20}}); histos.add("h1KSRecsplit", "KS meson Rec split", kTH1F, {{100, 0.0f, 10.0f}}); // Multplicity distribution - histos.add("multdist", "FT0M multiplicity distribution", kTH1F, {{1000, 0, 10000}}); - histos.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); - histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); - histos.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); + if (QAevents) { + histos.add("multdist_FT0M", "FT0M Multiplicity distribution", kTH1F, {axisMultdist}); + histos.add("multdist_FT0A", "FT0A Multiplicity distribution", kTH1F, {axisMultdist}); + histos.add("multdist_FT0C", "FT0C Multiplicity distribution", kTH1F, {axisMultdist}); + // histos.add("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); + histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); + } } double massPi = TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(); // FIXME: Get from the common header @@ -360,263 +377,346 @@ struct kstarqa { using EventCandidates = soa::Filtered>; using TrackCandidates = soa::Filtered>; - using V0TrackCandidate = aod::V0Datas; using EventCandidatesMC = soa::Join; - // using TrackCandidatesMC = soa::Filtered>; - using TrackCandidatesMC = soa::Filtered>; - - ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for ME mixing"}; - // ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {10, 0, 100}, "multiplicity percentile for ME mixing"}; - ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2000, 0, 10000}, "TPC multiplicity for bin for ME mixing"}; - using BinningTypeTPCMultiplicity = ColumnBinningPolicy; - // using BinningTypeVertexContributor = - // ColumnBinningPolicy; - using BinningTypeCentralityM = ColumnBinningPolicy; - using BinningTypeVertexContributor = ColumnBinningPolicy; + using TrackCandidatesMC = soa::Filtered>; - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; + template + void fillInvMass(const T1& track1, const T2& track2, const T3& lv2, const T4& lv3, float multiplicity, bool isMix) + { + ROOT::Math::PxPyPzMVector daughter1, daughter2, daughter_selected; + daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); // Kaon + daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); // Pion + daughter_selected = (boost_daugter1) ? daughter1 : daughter2; + auto selected_dau_mass = (boost_daugter1) ? massKa : massPi; + + TLorentzVector lv4, lv5; + // polarization calculations + + ROOT::Math::PxPyPzMVector fourVecDau1 = ROOT::Math::PxPyPzMVector(daughter_selected.Px(), daughter_selected.Py(), daughter_selected.Pz(), selected_dau_mass); // Kaon or Pion + + 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(fourVecDau1); // 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 (TMath::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())); + + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + histos.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); + + 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); + lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background + lv5 = lv2 + lv4; + if (CalcRotational) + histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarHelicity); + } + } else { + histos.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); + } + } else { + if (!isMix) { + if (CalcLikeSign) + histos.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarHelicity); + } + } - SameKindPair pair{binningOnPositions, cfgNoMixedEvents, -1, &cache}; + } 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())); - double totmomka = 0.0; - double totmompi = 0.0; - double totmomkamix = 0.0; - double totmompimix = 0.0; - // double openingangle = 0.0; - // double openinganglemix = 0.0; + if (track1.sign() * track2.sign() < 0) { + if (!isMix) { + histos.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); + for (int i = 0; i < c_nof_rotations; i++) { + float theta2 = rn->Uniform(0, TMath::Pi()); + lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background + lv5 = lv2 + lv4; + if (CalcRotational) + histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarProduction); + } + } else { + histos.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); + } + } else { + if (!isMix) { + if (CalcLikeSign) + histos.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarProduction); + } + } + } 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 (track1.sign() * track2.sign() < 0) { + if (!isMix) { + histos.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam); + for (int i = 0; i < c_nof_rotations; i++) { + float theta2 = rn->Uniform(0, TMath::Pi()); + lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background + lv5 = lv2 + lv4; + if (CalcRotational) + histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarBeam); + } + } else { + histos.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarBeam); + } + } else { + if (CalcLikeSign) + histos.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); + + 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 (track1.sign() * track2.sign() < 0) { + if (!isMix) { + histos.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); + for (int i = 0; i < c_nof_rotations; i++) { + float theta2 = rn->Uniform(0, TMath::Pi()); + lv4.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi() + theta2, massKa); // for rotated background + lv5 = lv2 + lv4; + if (CalcRotational) + histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, lv5.Pt(), lv5.M(), cosThetaStarRandom); + } + } else { + histos.fill(HIST("h3KstarInvMassMixed"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); + } + } else { + if (!isMix) { + if (CalcLikeSign) + histos.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, lv3.Pt(), lv3.M(), cosThetaStarRandom); + } + } + } + } + } void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) { + histos.fill(HIST("events_check_data"), 0.5); - if (!collision.sel8()) { + if (TVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { return; } + histos.fill(HIST("events_check_data"), 1.5); if (timFrameEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { return; } + histos.fill(HIST("events_check_data"), 2.5); - if (TVXEvsel && (!collision.selection_bit(aod::evsel::kIsTriggerTVX))) { + if (!collision.sel8()) { return; } - - std::vector pions, kaons, pionsrot, kaonsrot; - std::vector PionIndex = {}; - std::vector KaonIndex = {}; - std::vector PioncollIndex = {}; - std::vector KaoncollIndex = {}; - std::vector PionSign = {}; - std::vector KaonSign = {}; - - std::vector PionPx = {}; - std::vector KaonPx = {}; - std::vector PionPy = {}; - std::vector KaonPy = {}; - std::vector PionPz = {}; - std::vector KaonPz = {}; - std::vector PionP = {}; - std::vector KaonP = {}; + histos.fill(HIST("events_check_data"), 3.5); float multiplicity = 0.0f; - multiplicity = collision.centFT0M(); - // multiplicity = collision.centFT0C(); - // Fill the event counter - rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); - rEventSelection.fill(HIST("hmult"), multiplicity); - histos.fill(HIST("multdist"), collision.multFT0M()); - histos.fill(HIST("hNcontributor"), collision.numContrib()); + multiplicity = (cfgFT0M) ? collision.centFT0M() : collision.centFT0C(); - for (auto track1 : tracks) { + // Fill the event counter + if (QAevents) { + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + rEventSelection.fill(HIST("hmult"), multiplicity); + histos.fill(HIST("multdist_FT0M"), collision.multFT0M()); + histos.fill(HIST("multdist_FT0A"), collision.multFT0A()); + histos.fill(HIST("multdist_FT0C"), collision.multFT0C()); + // histos.fill(HIST("hNcontributor"), collision.numContrib()); + } + for (auto& [track1, track2] : combinations(CombinationsFullIndexPolicy(tracks, tracks))) { if (QAbefore) { - histos.fill(HIST("hNsigmaKaonTPC_before"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("hNsigmaKaonTOF_before"), track1.pt(), track1.tofNSigmaKa()); + histos.fill(HIST("hNsigmaTPC_before"), track1.pt(), track1.tpcNSigmaKa()); + histos.fill(HIST("hNsigmaTOF_before"), track1.pt(), track1.tofNSigmaKa()); histos.fill(HIST("hCRFC_before"), track1.tpcCrossedRowsOverFindableCls()); - histos.fill(HIST("deoverdx_tpc"), track1.pt(), track1.tpcSignal()); + histos.fill(HIST("dE_by_dx_TPC"), track1.p(), track1.tpcSignal()); histos.fill(HIST("hphi"), track1.phi()); } + histos.fill(HIST("events_check_data"), 4.5); if (!selectionTrack(track1)) { continue; } - histos.fill(HIST("hDcaxy"), track1.dcaXY()); - histos.fill(HIST("hDcaz"), track1.dcaZ()); - if (!selectionPID(track1, 1)) // kaon + if (!selectionTrack(track2)) { continue; + } + histos.fill(HIST("events_check_data"), 5.5); + if (QAevents) { + histos.fill(HIST("hDcaxy"), track1.dcaXY()); + histos.fill(HIST("hDcaz"), track1.dcaZ()); + } + + // 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 + continue; + if (!selectionPID(track2, 0)) // Track 2 is checked with Pion + continue; + + histos.fill(HIST("events_check_data"), 6.5); if (MID) { - if (MIDselectionPID(track1, 0)) // misidentified as pion + if (MIDselectionPID(track1, 0)) // Kaon misidentified as pion continue; - - if (MIDselectionPID(track1, 2)) // misidentified as proton + if (MIDselectionPID(track1, 2)) // Kaon misidentified as proton + continue; + if (MIDselectionPID(track2, 1)) // Pion misidentified as kaon continue; } + histos.fill(HIST("events_check_data"), 7.5); + if (QAafter) { histos.fill(HIST("hEta_after"), track1.eta()); histos.fill(HIST("hCRFC_after"), track1.tpcCrossedRowsOverFindableCls()); - histos.fill(HIST("hNsigmaKaonTPC_after"), track1.pt(), track1.tpcNSigmaKa()); - histos.fill(HIST("hNsigmaKaonTOF_after"), track1.pt(), track1.tofNSigmaKa()); + // histos.fill(HIST("hNsigmaKaonTPC_after"), track1.pt(), track1.tpcNSigmaKa()); + // histos.fill(HIST("hNsigmaKaonTOF_after"), track1.pt(), track1.tofNSigmaKa()); + // histos.fill(HIST("hNsigmaPionTPC_after"), track2.pt(), track2.tpcNSigmaPi()); + // histos.fill(HIST("hNsigmaPionTOF_after"), track2.pt(), track2.tofNSigmaPi()); } - totmomka = TMath::Sqrt(track1.px() * track1.px() + track1.py() * track1.py() + track1.pz() * track1.pz()); + if (track1.globalIndex() == track2.globalIndex()) + continue; - ROOT::Math::PtEtaPhiMVector temp1(track1.pt(), track1.eta(), track1.phi(), massKa); - ROOT::Math::PtEtaPhiMVector temp1rot(track1.pt(), track1.eta(), track1.phi() + TMath::Pi(), massKa); - kaons.push_back(temp1); - kaonsrot.push_back(temp1rot); - KaonIndex.push_back(track1.globalIndex()); - KaoncollIndex.push_back(track1.collisionId()); - KaonSign.push_back(track1.sign()); - KaonPx.push_back(track1.px()); - KaonPy.push_back(track1.py()); - KaonPz.push_back(track1.pz()); - KaonP.push_back(totmomka); + histos.fill(HIST("events_check_data"), 8.5); - } // track loop ends + TLorentzVector lv1, lv2, lv3; + lv1.SetPtEtaPhiM(track1.pt(), track1.eta(), track1.phi(), massKa); + lv2.SetPtEtaPhiM(track2.pt(), track2.eta(), track2.phi(), massPi); + lv3 = lv1 + lv2; + bool isMix = false; + fillInvMass(track1, track2, lv2, lv3, multiplicity, isMix); + } + } - for (auto track2 : tracks) { + PROCESS_SWITCH(kstarqa, processSE, "Process Same event", true); - if (QAbefore) { - histos.fill(HIST("hNsigmaPionTPC_before"), track2.pt(), track2.tpcNSigmaPi()); - histos.fill(HIST("hNsigmaPionTOF_before"), track2.pt(), track2.tofNSigmaPi()); - } + ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for ME mixing"}; + ConfigurableAxis axisMultiplicityClass{"axisMultiplicityClass", {10, 0, 100}, "multiplicity percentile for ME mixing"}; + // ConfigurableAxis axisMultiplicity{"axisMultiplicity", {2000, 0, 10000}, "TPC multiplicity for bin for ME mixing"}; - if (!selectionTrack(track2)) { - continue; - } + // using BinningTypeTPCMultiplicity = ColumnBinningPolicy; + using BinningTypeCentralityM = ColumnBinningPolicy; + using BinningTypeVertexContributor = ColumnBinningPolicy; - if (!selectionPID(track2, 0)) // pion - continue; + BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass}, true}; + BinningTypeCentralityM binningOnCentrality{{axisVertex, axisMultiplicityClass}, true}; - if (MID) { - if (MIDselectionPID(track2, 1)) // misidentified as kaon + SameKindPair pair1{binningOnPositions, cfgNoMixedEvents, -1, &cache}; + SameKindPair pair2{binningOnCentrality, cfgNoMixedEvents, -1, &cache}; + + void processME(EventCandidates const&, TrackCandidates const&) + { + if (cfgFT0M) { + for (auto& [c1, tracks1, c2, tracks2] : pair1) { + + if (!c1.sel8()) { continue; - } - if (QAafter) { - histos.fill(HIST("hNsigmaPionTPC_after"), track2.pt(), track2.tpcNSigmaPi()); - histos.fill(HIST("hNsigmaPionTOF_after"), track2.pt(), track2.tofNSigmaPi()); - } + } + if (!c2.sel8()) { + continue; + } - totmompi = TMath::Sqrt(track2.px() * track2.px() + track2.py() * track2.py() + track2.pz() * track2.pz()); - - ROOT::Math::PtEtaPhiMVector temp2(track2.pt(), track2.eta(), track2.phi(), massPi); - ROOT::Math::PtEtaPhiMVector temp2rot(track2.pt(), track2.eta(), track2.phi() + TMath::Pi(), massPi); - pions.push_back(temp2); - pionsrot.push_back(temp2rot); - PionIndex.push_back(track2.globalIndex()); - PioncollIndex.push_back(track2.collisionId()); - PionSign.push_back(track2.sign()); - PionPx.push_back(track2.px()); - PionPy.push_back(track2.py()); - PionPz.push_back(track2.pz()); - PionP.push_back(totmompi); - } // track loop ends - - if (!QA) { - if (pions.size() != 0 && kaons.size() != 0) { - for (auto ikaon = kaons.begin(); ikaon != kaons.end(); ++ikaon) { - auto i1 = std::distance(kaons.begin(), ikaon); - for (auto ipion = pions.begin(); ipion != pions.end(); ++ipion) { - auto i3 = std::distance(pions.begin(), ipion); - - if (PionIndex.at(i3) <= KaonIndex.at(i1)) - continue; - CKSVector = kaons.at(i1) + pions.at(i3); - CKSVectorRot1 = kaonsrot.at(i1) + pions.at(i3); - CKSVectorRot2 = kaons.at(i1) + pionsrot.at(i3); - - // openingangle = TMath::Abs((PionPx.at(i3) * KaonPx.at(i1) + PionPy.at(i3) * KaonPy.at(i1) + PionPz.at(i3) * KaonPz.at(i1)) / (PionP.at(i3) * KaonP.at(i1))); - - // openingangle = (PionPx.at(i3)*KaonPx.at(i1) + PionPy.at(i3)*KaonPy.at(i1) + PionPz.at(i3)*KaonPz.at(i1)); - // LOG(info) << "opening angle" << openingangle; - - if (TMath::Abs(CKSVector.Rapidity()) < 0.5) { - if (PionSign.at(i3) * KaonSign.at(i1) < 0) { - histos.fill(HIST("h3KstarInvMassUnlikeSign"), multiplicity, CKSVector.Pt(), CKSVector.M()); - histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, CKSVectorRot1.Pt(), CKSVectorRot1.M()); - histos.fill(HIST("h3KstarInvMassRotated"), multiplicity, CKSVectorRot2.Pt(), CKSVectorRot2.M()); - } else if (PionSign.at(i3) * KaonSign.at(i1) > 0) { - histos.fill(HIST("h3KstarInvMasslikeSign"), multiplicity, CKSVector.Pt(), CKSVector.M()); - } - } - } + 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; } - } - } - } - PROCESS_SWITCH(kstarqa, processSE, "Process Same event", true); + if (TVXEvsel && (!c1.selection_bit(aod::evsel::kIsTriggerTVX) || !c2.selection_bit(aod::evsel::kIsTriggerTVX))) { + return; + } - void processME(EventCandidates const&, TrackCandidates const&) + auto multiplicity = c1.centFT0M(); - { + for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - for (auto& [c1, tracks1, c2, tracks2] : pair) { + if (!selectionTrack(t1)) // Kaon + continue; + if (!selectionTrack(t2)) // Pion + continue; + if (!selectionPID(t1, 1)) // Kaon + continue; + if (!selectionPID(t2, 0)) // Pion + continue; + if (MID) { + if (MIDselectionPID(t1, 0)) // misidentified as pion + continue; + if (MIDselectionPID(t1, 2)) // misidentified as proton + continue; + if (MIDselectionPID(t2, 1)) // misidentified as kaon + continue; + } - if (!c1.sel8()) { - continue; - } - if (!c2.sel8()) { - continue; - } + TLorentzVector KAON; + KAON.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); + TLorentzVector PION; + PION.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massPi); - 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; - } + TLorentzVector Kstar = KAON + PION; + bool isMix = true; - if (TVXEvsel && (!c1.selection_bit(aod::evsel::kIsTriggerTVX) || !c2.selection_bit(aod::evsel::kIsTriggerTVX))) { - return; + if (TMath::Abs(Kstar.Rapidity()) < 0.5) { + fillInvMass(t1, t2, PION, Kstar, multiplicity, isMix); + } + } } + } else { + for (auto& [c1, tracks1, c2, tracks2] : pair2) { - // float multiplicity = 0.0f; - /* if (cfgMultFT0) - multiplicity = c1.multZeqFT0A() + c1.multZeqFT0C(); - if (cfgMultFT0 == 0 && cfgCentFT0C == 1) - multiplicity = c1.centFT0C(); - if (cfgMultFT0 == 0 && cfgCentFT0C == 0)*/ - auto multiplicity = c1.centFT0M(); - - for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - - if (!selectionTrack(t1)) + if (!c1.sel8()) { continue; - if (!selectionTrack(t2)) - continue; - if (!selectionPID(t1, 1)) + } + if (!c2.sel8()) { continue; - if (!selectionPID(t2, 0)) + } + + 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 (MID) { - if (MIDselectionPID(t1, 0)) // misidentified as pion - continue; - if (MIDselectionPID(t1, 2)) // misidentified as proton - continue; - if (MIDselectionPID(t2, 1)) // misidentified as kaon - continue; } - TLorentzVector KAON; - KAON.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); - TLorentzVector PION; - PION.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massPi); + if (TVXEvsel && (!c1.selection_bit(aod::evsel::kIsTriggerTVX) || !c2.selection_bit(aod::evsel::kIsTriggerTVX))) { + return; + } + + auto multiplicity = c1.centFT0C(); - // totmompimix = TMath::Sqrt(t2.px() * t2.px() + t2.py() * t2.py() + t2.pz() * t2.pz()); - // totmomkamix = TMath::Sqrt(t1.px() * t1.px() + t1.py() * t1.py() + t1.pz() * t1.pz()); + for (auto& [t1, t2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) { - // openinganglemix = TMath::Abs((t1.px() * t2.px() + t1.py() * t2.py() + t1.pz() * t2.pz()) / (totmomkamix * totmompimix)); + if (!selectionTrack(t1)) // Kaon + continue; + if (!selectionTrack(t2)) // Pion + continue; + if (!selectionPID(t1, 1)) // Kaon + continue; + if (!selectionPID(t2, 0)) // Pion + continue; + if (MID) { + if (MIDselectionPID(t1, 0)) // misidentified as pion + continue; + if (MIDselectionPID(t1, 2)) // misidentified as proton + continue; + if (MIDselectionPID(t2, 1)) // misidentified as kaon + continue; + } - // LOG(info) << "mix angle" << openinganglemix; + TLorentzVector KAON; + KAON.SetPtEtaPhiM(t1.pt(), t1.eta(), t1.phi(), massKa); + TLorentzVector PION; + PION.SetPtEtaPhiM(t2.pt(), t2.eta(), t2.phi(), massPi); - TLorentzVector CKSmix = KAON + PION; + TLorentzVector Kstar = KAON + PION; + bool isMix = true; - if (!QA) { - if (TMath::Abs(CKSmix.Rapidity()) < 0.5) { - if (t1.sign() * t2.sign() < 0) - histos.fill(HIST("h3KstarInvMassMixed"), multiplicity, CKSmix.Pt(), CKSmix.M()); + if (TMath::Abs(Kstar.Rapidity()) < 0.5) { + fillInvMass(t1, t2, PION, Kstar, multiplicity, isMix); } } } diff --git a/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx b/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx index 63f1c7d58d5..74234cb8bd1 100644 --- a/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520_PbPb.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Centrality.h" @@ -42,6 +43,8 @@ struct lambdaAnalysis_pb { Preslice perRCol = aod::resodaughter::resoCollisionId; Preslice perCollision = aod::track::collisionId; // Configurables. + + Configurable ConfEvtOccupancyInTimeRange{"ConfEvtOccupancyInTimeRange", -1, "Evt sel: maximum track occupancy"}; Configurable nBinsPt{"nBinsPt", 100, "N bins in pT histogram"}; Configurable nBinsInvM{"nBinsInvM", 120, "N bins in InvMass histogram"}; Configurable lambda1520id{"lambda1520id", 3124, "pdg"}; @@ -138,7 +141,7 @@ struct lambdaAnalysis_pb { histos.add("QAbefore/Kaon/h2d_ka_nsigma_tof_vs_tpc", "n#sigma^{TPC} vs n#sigma^{TOF} Kaons", kTH2F, {axisTPCNsigma, axisTOFNsigma}); // QA After - histos.add("QAafter/Proton/hd_pr_pt", "p_{T}-spectra Protons", kTH1F, {axisPt_pid}); + histos.add("QAafter/Proton/hd_pr_pt", "p_{T}-spectra Protons", kTH2F, {axisPt_pid, axisCent}); histos.add("QAafter/Proton/h2d_pr_dca_z", "dca_{z} Protons", kTH2F, {axisPt_pid, axisDCAz}); histos.add("QAafter/Proton/h2d_pr_dca_xy", "dca_{xy} Protons", kTH2F, {axisPt_pid, axisDCAxy}); histos.add("QAafter/Proton/h2d_pr_dEdx_p", "TPC Signal Protons", kTH2F, {axisP_pid, axisdEdx}); @@ -153,7 +156,7 @@ struct lambdaAnalysis_pb { 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", kTH1F, {axisPt_pid}); + 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}); histos.add("QAafter/Kaon/h2d_ka_dca_xy", "dca_{xy} Kaons", kTH2F, {axisPt_pid, axisDCAxy}); histos.add("QAafter/Kaon/h2d_ka_dEdx_p", "TPC Signal Kaon", kTH2F, {axisP_pid, axisdEdx}); @@ -427,7 +430,7 @@ struct lambdaAnalysis_pb { auto _tpcnsigmaPr = trkPr.tpcNSigmaPr(); // Proton - histos.fill(HIST("QAafter/Proton/hd_pr_pt"), _ptPr); + histos.fill(HIST("QAafter/Proton/hd_pr_pt"), _ptPr, mult); histos.fill(HIST("QAafter/Proton/h2d_pr_dca_z"), _ptPr, trkPr.dcaZ()); histos.fill(HIST("QAafter/Proton/h2d_pr_dca_xy"), _ptPr, trkPr.dcaXY()); histos.fill(HIST("QAafter/Proton/h2d_pr_dEdx_p"), p_ptot, trkPr.tpcSignal()); @@ -449,7 +452,7 @@ struct lambdaAnalysis_pb { auto _tpcnsigmaKa = trkKa.tpcNSigmaKa(); // Kaon - histos.fill(HIST("QAafter/Kaon/hd_ka_pt"), _ptKa); + histos.fill(HIST("QAafter/Kaon/hd_ka_pt"), _ptKa, mult); histos.fill(HIST("QAafter/Kaon/h2d_ka_dca_z"), _ptKa, trkKa.dcaZ()); histos.fill(HIST("QAafter/Kaon/h2d_ka_dca_xy"), _ptKa, trkKa.dcaXY()); histos.fill(HIST("QAafter/Kaon/h2d_ka_dEdx_p"), k_ptot, trkKa.tpcSignal()); @@ -558,6 +561,8 @@ struct lambdaAnalysis_pb { { // 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()); fillDataHistos(tracks, tracks, collision.cent()); } @@ -597,7 +602,6 @@ struct lambdaAnalysis_pb { } for (auto const& part : resoParents) { - if (abs(part.pdgCode()) != lambda1520id) // // L* pdg_code = 3124 continue; if (abs(part.y()) > 0.5) { // rapidity cut @@ -616,7 +620,10 @@ struct lambdaAnalysis_pb { if (!pass1 || !pass2) // If we have both decay products continue; - auto mass = 1.520; // part.M() + + TLorentzVector p4; + p4.SetPxPyPzE(part.px(), part.py(), part.pz(), part.e()); + auto mass = p4.M(); if (part.pdgCode() > 0) histos.fill(HIST("Analysis/h3d_gen_lstar_PM"), mass, part.pt(), mult); else @@ -637,7 +644,8 @@ 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()); @@ -656,7 +664,8 @@ struct lambdaAnalysis_pb { if (doprocessData) LOG(error) << "Disable processData() first!"; - + if (ConfEvtOccupancyInTimeRange > 0 && collision.trackOccupancyInTimeRange() > ConfEvtOccupancyInTimeRange) + return; // 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()); @@ -676,6 +685,8 @@ 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()); @@ -691,13 +702,13 @@ struct lambdaAnalysis_pb { if (doprocessMix || doprocessMixDF) LOG(fatal) << "Disable processMix() or processMixDF() first!"; LOGF(debug, "Event Mixing Started"); - BinningTypeEP binningPositions2{{cMixVtxBins, cMixMultBins, cMixEPAngle}, true}; auto tracksTuple = std::make_tuple(tracks); 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 5884c7b067a..97cec72b2c2 100644 --- a/PWGLF/Tasks/Resonances/lambda1520analysis.cxx +++ b/PWGLF/Tasks/Resonances/lambda1520analysis.cxx @@ -15,6 +15,7 @@ #include "TLorentzVector.h" #include "TF1.h" +#include "TRandom3.h" #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "PWGLF/DataModel/LFResonanceTables.h" @@ -39,14 +40,12 @@ struct lambda1520analysis { // switches Configurable cEtaAssym{"cEtaAssym", false, "Turn on/off EtaAssym calculation"}; Configurable isFilladditionalQA{"isFilladditionalQA", false, "Turn on/off additional QA plots"}; - Configurable cAddlTrackcut{"cAddlTrackcut", false, "Switch to turn on/off Additional track cut"}; 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 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"}; - Configurable additionalEvsel{"additionalEvsel", true, "Additional event selcection"}; Configurable additionalQAeventPlots{"additionalQAeventPlots", false, "Additional QA event plots"}; Configurable additionalMEPlots{"additionalMEPlots", false, "Additional Mixed event plots"}; @@ -73,6 +72,8 @@ struct lambda1520analysis { 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"}; /// PID Selections Configurable cRejNsigmaTpc{"cRejNsigmaTpc", 3.0, "Reject tracks to improve purity of TPC PID"}; // Reject missidentified particles when tpc bands merge @@ -121,6 +122,11 @@ struct lambda1520analysis { Configurable cfgCutsOnMother{"cfgCutsOnMother", false, "Enamble 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 cfgCutsOnDaughters{"cfgCutsOnDaughters", false, "Enamble additional cuts on daughters"}; + 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"}; + 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"}; @@ -132,13 +138,14 @@ struct lambda1520analysis { ConfigurableAxis binsTPCXrows{"binsTPCXrows", {200, 0, 200}, ""}; 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"}; + Configurable applyOccupancyCut{"applyOccupancyCut", false, "Apply occupancy cut"}; + Configurable OccupancyCut{"OccupancyCut", 1000, "Mimimum Occupancy cut"}; - // Event selection cuts - (Temporary, need to fix!) - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; + // 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"}; void init(o2::framework::InitContext&) { @@ -153,6 +160,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]"}; if (additionalQAeventPlots) { // Test on Mixed event @@ -198,16 +206,10 @@ struct lambda1520analysis { histos.add("TPCncluster/TPCnclusterPhika", "TPC ncluster vs phi", kTH2F, {{160, 0, 160, "TPC nCluster"}, {63, 0, 6.28, "#phi"}}); // Multiplicity correlation calibrations - histos.add("MultCalib/centglopr_before", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); - histos.add("MultCalib/centgloka_before", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); - histos.add("MultCalib/GloPVpr_before", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); - histos.add("MultCalib/GloPVka_before", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); - - // Multiplicity correlation calibrations - histos.add("MultCalib/centglopr_after", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); - histos.add("MultCalib/centgloka_after", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); - histos.add("MultCalib/GloPVpr_after", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); - histos.add("MultCalib/GloPVka_after", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); + histos.add("MultCalib/centglopr", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); + histos.add("MultCalib/centgloka", "Centrality vs Global-Tracks", kTH2F, {{110, 0, 110, "Centrality"}, {500, 0, 5000, "Global Tracks"}}); + histos.add("MultCalib/GloPVpr", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); + histos.add("MultCalib/GloPVka", "Global tracks vs PV tracks", kTH2F, {{500, 0, 5000, "Global tracks"}, {500, 0, 5000, "PV tracks"}}); } // PID QA after cuts @@ -241,6 +243,26 @@ struct lambda1520analysis { 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}}); + histos.add("QAbefore/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); + + histos.add("QAafter/deltaEta", "deltaEta of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); + histos.add("QAafter/deltaPhi", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); + + histos.add("QAafter/deltaEtaafter", "deltaEta of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); + histos.add("QAafter/deltaPhiafter", "deltaPhi of kaon and proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 3.15}}); + histos.add("QAafter/EtaPrafter", "Eta of proton candidates", HistType::kTH1F, {{cetaphiBins, -1.6, 1.6}}); + histos.add("QAafter/PhiPrafter", "Phi of proton candidates", HistType::kTH1F, {{cetaphiBins, 0.0, 6.30}}); + histos.add("QAafter/EtaKaafter", "Eta of kaon candidates", HistType::kTH1F, {{cetaphiBins, -1.6, 1.6}}); + 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}); + } + // 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}); @@ -301,45 +323,11 @@ struct lambda1520analysis { histos.add("Result/MC/hantilambda1520Recoinvmass", "Inv mass distribution of Reconstructed MC Anti-#Lambda(1520)", kTH1F, {axisMassLambda1520}); } - 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); - } // Print output histograms statistics LOG(info) << "Size of the histograms in spectraTOF"; histos.print(); } - 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; - } - double massKa = MassKaonCharged; double massPr = MassProton; @@ -358,22 +346,22 @@ struct lambda1520analysis { } if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) return false; - if (track.tpcNClsCrossedRows() < cMinTPCncr) + if (track.itsNCls() < cfgITScluster) return false; - if (cAddlTrackcut) { - if (!track.passedITSRefit() || !track.passedTPCRefit()) - return false; - if (track.tpcCrossedRowsOverFindableCls() < cfgRatioTPCRowsOverFindableCls) - return false; - if (track.itsChi2NCl() > cMaxChi2ITScut) - return false; - if (track.tpcChi2NCl() > cMaxChi2TPCcut) - 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()) return false; if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) @@ -382,11 +370,11 @@ struct lambda1520analysis { return false; if (cfgGlobalTrack && !track.isGlobalTrack()) return false; - if (cfgHasITS && !track.hasITS()) + if (cfgUseITSRefit && !track.passedITSRefit()) return false; - if (cfgHasTPC && !track.hasTPC()) + if (cfgUseTPCRefit && !track.passedTPCRefit()) return false; - if (cfgHasTOF && !track.hasTOF()) + if (track.tpcNClsCrossedRows() < cMinTPCncr) return false; return true; @@ -679,25 +667,20 @@ struct lambda1520analysis { { auto multiplicity = collision.cent(); - // Multiplicity correlation calibration plots - if (isFilladditionalQA) { - if constexpr (IsData) { - histos.fill(HIST("MultCalib/centglopr_before"), multiplicity, dTracks1.size()); - histos.fill(HIST("MultCalib/centgloka_before"), multiplicity, dTracks2.size()); - histos.fill(HIST("MultCalib/GloPVpr_before"), dTracks1.size(), collision.multNTracksPV()); - histos.fill(HIST("MultCalib/GloPVka_before"), dTracks2.size(), collision.multNTracksPV()); - } - } + // LOG(info) << "Before pass, Collision index:" << collision.index() << "multiplicity: " << collision.cent() << std::endl; - if (additionalEvsel && !eventSelected(collision, multiplicity)) { + auto occupancy_no = collision.trackOccupancyInTimeRange(); + if (applyOccupancyCut && occupancy_no < OccupancyCut) { return; } + + // Multiplicity correlation calibration plots if (isFilladditionalQA) { if constexpr (IsData) { - histos.fill(HIST("MultCalib/centglopr_after"), multiplicity, dTracks1.size()); - histos.fill(HIST("MultCalib/centgloka_after"), multiplicity, dTracks2.size()); - histos.fill(HIST("MultCalib/GloPVpr_after"), dTracks1.size(), collision.multNTracksPV()); - histos.fill(HIST("MultCalib/GloPVka_after"), dTracks2.size(), collision.multNTracksPV()); + histos.fill(HIST("MultCalib/centglopr"), multiplicity, dTracks1.size()); + histos.fill(HIST("MultCalib/centgloka"), multiplicity, dTracks2.size()); + histos.fill(HIST("MultCalib/GloPVpr"), dTracks1.size(), collision.multNTracksPV()); + histos.fill(HIST("MultCalib/GloPVka"), dTracks2.size(), collision.multNTracksPV()); } } @@ -714,8 +697,8 @@ struct lambda1520analysis { histos.fill(HIST("TestME/hnTrksMixedE"), dTracks1.size()); } } - - TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; + // LOG(info) << "After pass, Collision index:" << collision.index() << "multiplicity: " << collision.cent() << std::endl; + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance, ldaughter_rot, lresonance_rot; for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { // Full index policy is needed to consider all possible combinations @@ -746,6 +729,10 @@ 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; + //// QA plots before the selection // --- Track QA all if constexpr (IsData) { @@ -771,6 +758,10 @@ struct lambda1520analysis { 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 (cfgCutsOnDaughters) { + histos.fill(HIST("QAbefore/deltaEta"), deltaEta); + histos.fill(HIST("QAbefore/deltaPhi"), deltaPhi); + } } //// Apply the pid selection @@ -823,7 +814,10 @@ struct lambda1520analysis { 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()); - + if (cfgCutsOnDaughters) { + histos.fill(HIST("QAafter/deltaEta"), deltaEta); + histos.fill(HIST("QAafter/deltaPhi"), deltaPhi); + } if (isFilladditionalQA) { // TPCncluster distributions histos.fill(HIST("TPCncluster/TPCnclusterpr"), trk1.tpcNClsFound()); @@ -843,8 +837,8 @@ struct lambda1520analysis { } //// Resonance reconstruction - lDecayDaughter1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), massPr); - lDecayDaughter2.SetXYZM(trk2.px(), trk2.py(), trk2.pz(), massKa); + lDecayDaughter1.SetPtEtaPhiM(trk1.pt(), trk1.eta(), trk1.phi(), massPr); + lDecayDaughter2.SetPtEtaPhiM(trk2.pt(), trk2.eta(), trk2.phi(), massKa); lResonance = lDecayDaughter1 + lDecayDaughter2; // Rapidity cut if (abs(lResonance.Rapidity()) > 0.5) @@ -857,13 +851,38 @@ struct lambda1520analysis { continue; } + if (cfgCutsOnDaughters) { + 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 < 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 (trk1.sign() < 0) { histos.fill(HIST("Result/Data/lambda1520invmass"), lResonance.M()); histos.fill(HIST("Result/Data/h3lambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); - } else { + } else if (trk1.sign() > 0) { histos.fill(HIST("Result/Data/antilambda1520invmass"), lResonance.M()); histos.fill(HIST("Result/Data/h3antilambda1520invmass"), multiplicity, lResonance.Pt(), lResonance.M()); } @@ -981,16 +1000,12 @@ struct lambda1520analysis { continue; if (abs(part.y()) > 0.5) // rapidity cut continue; - bool pass1 = false; - bool pass2 = false; - if (abs(part.daughterPDG1()) == 321 || abs(part.daughterPDG2()) == 321) { // At least one decay to Kaon - pass2 = true; - } - if (abs(part.daughterPDG1()) == 2212 || abs(part.daughterPDG2()) == 2212) { // At least one decay to Proton - pass1 = true; - } + 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 + if (!pass1 || !pass2) // If we have both decay products continue; + if (collision.isVtxIn10()) // INEL10 { if (part.pdgCode() > 0) diff --git a/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx b/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx index 9de16794c14..9d41ffb6eaa 100644 --- a/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx +++ b/PWGLF/Tasks/Resonances/phianalysisrun3_PbPb.cxx @@ -27,17 +27,24 @@ #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 "ReconstructionDataFormats/Track.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Common/DataModel/PIDResponse.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" @@ -47,13 +54,17 @@ #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 { - SliceCache cache; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; @@ -62,60 +73,69 @@ 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", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutTPC{"nsigmacutTPC", 2.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmaCutTOF{"nsigmacutTOF", 2.0, "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 tof{"TOF", true, "TOF"}; - Configurable tpc{"TPC", false, "TPC"}; - Configurable combined{"combined", true, "combined"}; - Configurable isEtaAssym{"isEtaAssym", false, "isEtaAssym"}; + Configurable fillOccupancy{"fillOccupancy", true, "fill Occupancy"}; + Configurable cfgOccupancyCut{"cfgOccupancyCut", 2500, "Occupancy cut"}; + Configurable cfgCutTOFBeta{"cfgCutTOFBeta", 0.0, "cut TOF beta"}; + Configurable isNoTOF{"isNoTOF", false, "isNoTOF"}; + Configurable additionalEvSel2{"additionalEvSel2", true, "Additional evsel2"}; + Configurable additionalEvSel3{"additionalEvSel3", true, "Additional evsel3"}; Configurable cfgMultFT0{"cfgMultFT0", true, "cfgMultFT0"}; Configurable iscustomDCAcut{"iscustomDCAcut", false, "iscustomDCAcut"}; Configurable ismanualDCAcut{"ismanualDCAcut", true, "ismanualDCAcut"}; - Configurable isITSOnlycut{"isITSOnlycut", true, "isITSOnlycut"}; + Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; Configurable cfgITScluster{"cfgITScluster", 0, "Number of ITS cluster"}; + Configurable confRapidity{"confRapidity", 0.5, "Rapidity cut"}; + 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 genacceptancecut{"genacceptancecut", true, "use acceptance cut for generated"}; // MC Configurable isMC{"isMC", false, "Run MC"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; 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}; + AxisSpec occupancyAxis = {occupancyBinning, "Occupancy"}; + 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("hNcontributor", "Number of primary vertex contributor", kTH1F, {{2000, 0.0f, 10000.0f}}); - 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("hOccupancy", "Occupancy distribution", kTH1F, {occupancyAxis}); 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("h3PhiInvMassLikeSignPP", "Invariant mass of Phi meson Like Sign positive", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassLikeSignMM", "Invariant mass of Phi meson Like Sign negative", 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("h3PhiInvMassRotation", "Invariant mass of Phi meson Rotation", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - if (isEtaAssym) { - histos.add("h3PhiInvMassUnlikeSignAside", "Invariant mass of Phi meson Unlike Sign A side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassLikeSignAside", "Invariant mass of Phi meson Like Sign A side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassMixedAside", "Invariant mass of Phi meson Mixed A side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassUnlikeSignCside", "Invariant mass of Phi meson Unlike Sign C side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassLikeSignCside", "Invariant mass of Phi meson Like Sign C side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - histos.add("h3PhiInvMassMixedCside", "Invariant mass of Phi meson Mixed C side", kTH3F, {{200, 0.0, 200.0}, {200, 0.0f, 20.0f}, {200, 0.9, 1.1}}); - } } else if (isMC) { - histos.add("hMC", "MC Event statistics", kTH1F, {{6, 0.0f, 6.0f}}); + histos.add("hMC", "MC Event statistics", kTH1F, {{10, 0.0f, 10.0f}}); histos.add("h1PhiGen", "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("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("h2PhiGen2", "Phi meson gen", kTH2F, {{200, 0.0f, 20.0f}, {200, 0.0, 200.0}}); 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("h1Phipt", "Phi meson Rec", kTH1F, {{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}}); + // 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}}}); + // 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}}}); } double massKa = o2::constants::physics::MassKPlus; @@ -136,19 +156,30 @@ struct phianalysisrun3_PbPb { if (ismanualDCAcut && !(candidate.isGlobalTrackWoDCA() && candidate.isPVContributor() && std::abs(candidate.dcaXY()) < cfgCutDCAxy && std::abs(candidate.dcaZ()) < cfgCutDCAz && candidate.itsNCls() > cfgITScluster)) { return false; } - if (isITSOnlycut && !(candidate.isPVContributor() && std::abs(candidate.dcaXY()) < cfgCutDCAxy && std::abs(candidate.dcaZ()) < cfgCutDCAz && candidate.itsNCls() > cfgITScluster)) { - return false; - } return true; } template bool selectionPID(const T& candidate) { - if (tof && combined && (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 (tpc && combined && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (!isNoTOF && !candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (isNoTOF && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + return false; + } + template + bool selectionPIDpTdependent(const T& candidate) + { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + return true; + } + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } return false; @@ -171,112 +202,87 @@ struct phianalysisrun3_PbPb { return true; } template - void FillinvMass(const T1& candidate1, const T2& candidate2, float multiplicity, bool unlike, bool mix, bool likesign, bool rotation, 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()}; - pvec1rotation = array{-candidate2.px(), -candidate2.py(), candidate2.pz()}; auto arrMom = array{pvec0, pvec1}; - auto arrMomrotation = array{pvec0, pvec1rotation}; int track1Sign = candidate1.sign(); int track2Sign = candidate2.sign(); mass = RecoDecay::m(arrMom, array{massd1, massd2}); - massrotation = RecoDecay::m(arrMomrotation, 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); - if (isEtaAssym && unlike && track1Sign * track2Sign < 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassUnlikeSignAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassUnlikeSignCside"), multiplicity, pT, mass); - } - } - if (isEtaAssym && mix && track1Sign * track2Sign < 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassMixedAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassMixedCside"), multiplicity, pT, mass); - } - } - if (isEtaAssym && likesign && track1Sign * track2Sign > 0) { - if (candidate1.eta() > 0.2 && candidate1.eta() < 0.8 && candidate2.eta() > 0.2 && candidate2.eta() < 0.8) { - histos.fill(HIST("h3PhiInvMassLikeSignAside"), multiplicity, pT, mass); - } else if (candidate1.eta() > -0.6 && candidate1.eta() < 0.0 && candidate2.eta() > -0.6 && candidate2.eta() < 0.0) { - histos.fill(HIST("h3PhiInvMassLikeSignCside"), multiplicity, pT, mass); - } - } // default filling - if (std::abs(rapidity) < 0.5 && !isEtaAssym && track1Sign * track2Sign < 0) { + if (std::abs(rapidity) < 0.5 && track1Sign * track2Sign < 0) { if (unlike) { histos.fill(HIST("h3PhiInvMassUnlikeSign"), multiplicity, pT, mass); } if (mix) { histos.fill(HIST("h3PhiInvMassMixed"), multiplicity, pT, mass); } - if (rotation) { - histos.fill(HIST("h3PhiInvMassRotation"), multiplicity, pT, massrotation); - } - } - if (std::abs(rapidity) < 0.5 && !isEtaAssym && track1Sign * track2Sign > 0 && likesign) { - if (track1Sign > 0 && track2Sign > 0) { - histos.fill(HIST("h3PhiInvMassLikeSignPP"), multiplicity, pT, mass); - } else { - histos.fill(HIST("h3PhiInvMassLikeSignMM"), multiplicity, pT, mass); - } } } - 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>; + using TrackCandidates = soa::Filtered>; // using EventCandidatesMC = soa::Join; using EventCandidatesMC = soa::Join; using TrackCandidatesMC = soa::Filtered>; + using CollisionMCTrueTable = aod::McCollisions; + using TrackMCTrueTable = aod::McParticles; + using CollisionMCRecTableCentFT0C = soa::SmallGroups>; + using TrackMCRecTable = soa::Join; + 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"}; - // using BinningType = BinningPolicy>; - // BinningType binningOnPositions{{axisVertex, axisMultiplicityClass}, true}; + Preslice perCollision = aod::track::collisionId; - // using BinningTypeTPCMultiplicity = ColumnBinningPolicy; - using BinningTypeVertexContributor = ColumnBinningPolicy; - // using BinningTypeCentrality = ColumnBinningPolicy; - - // using BinningType = ColumnBinningPolicy; - // BinningType binningOnPositions{{axisVertex, axisMultiplicity}, true}; + SliceCache cache; + using BinningTypeVertexContributor = ColumnBinningPolicy; + ROOT::Math::PxPyPzMVector PhiMesonMother, KaonPlus, KaonMinus; void processSameEvent(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 > cfgOccupancyCut) // occupancy info is available for this collision (*) + { + return; + } float multiplicity; if (cfgMultFT0) multiplicity = collision.centFT0C(); - if (!cfgMultFT0) - multiplicity = collision.numContrib(); histos.fill(HIST("hCentrality"), multiplicity); - histos.fill(HIST("hNcontributor"), collision.numContrib()); histos.fill(HIST("hVtxZ"), collision.posZ()); + histos.fill(HIST("hOccupancy"), occupancy); for (auto track1 : tracks) { if (!selectionTrack(track1)) { continue; } - histos.fill(HIST("hEta"), track1.eta()); - histos.fill(HIST("hDcaxy"), track1.dcaXY()); - histos.fill(HIST("hDcaz"), track1.dcaZ()); - histos.fill(HIST("hNsigmaKaonTPC"), track1.tpcNSigmaKa()); - histos.fill(HIST("hNsigmaKaonTOF"), track1.tofNSigmaKa()); + 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()); + auto track1ID = track1.globalIndex(); for (auto track2 : tracks) { if (!selectionTrack(track2)) { @@ -291,13 +297,21 @@ struct phianalysisrun3_PbPb { } bool unlike = true; bool mix = false; - bool likesign = true; - bool rotation = true; - if (isITSOnlycut) { - FillinvMass(track1, track2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); + 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); } - if (!isITSOnlycut && selectionPID(track1) && selectionPID(track2)) { - FillinvMass(track1, track2, multiplicity, unlike, mix, likesign, rotation, 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); } } } @@ -317,7 +331,24 @@ struct phianalysisrun3_PbPb { if (!c2.sel8()) { continue; } - + if (additionalEvSel2 && (!c1.selection_bit(aod::evsel::kNoSameBunchPileup) || !c1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel2 && (!c2.selection_bit(aod::evsel::kNoSameBunchPileup) || !c2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + continue; + } + if (additionalEvSel3 && (!c1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + if (additionalEvSel3 && (!c2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + continue; + } + int occupancy1 = c1.trackOccupancyInTimeRange(); + int occupancy2 = c2.trackOccupancyInTimeRange(); + if (fillOccupancy && occupancy1 > cfgOccupancyCut && occupancy2 > cfgOccupancyCut) // occupancy info is available for this collision (*) + { + return; + } float multiplicity; if (cfgMultFT0) multiplicity = c1.centFT0C(); @@ -327,8 +358,6 @@ struct phianalysisrun3_PbPb { 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; } @@ -338,17 +367,197 @@ struct phianalysisrun3_PbPb { if (!selectionPair(t1, t2)) { continue; } - if (isITSOnlycut) { - FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); + if (!ispTdepPID && selectionPID(t1) && selectionPID(t2)) { + FillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); } - if (!isITSOnlycut && selectionPID(t1) && selectionPID(t2)) { - FillinvMass(t1, t2, multiplicity, unlike, mix, likesign, rotation, massKa, massKa); + if (ispTdepPID && selectionPIDpTdependent(t1) && selectionPIDpTdependent(t2)) { + FillinvMass(t1, t2, multiplicity, unlike, mix, massKa, massKa); } } } } PROCESS_SWITCH(phianalysisrun3_PbPb, processMixedEvent, "Process Mixed 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 (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; + } + int occupancy = RecCollision.trackOccupancyInTimeRange(); + if (fillOccupancy && occupancy > cfgOccupancyCut) // occupancy info is available for this collision (*) + { + return; + } + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { + histos.fill(HIST("hMC"), 6); + 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)) { + continue; + } + if (!ispTdepPID && !selectionPID(track1)) { + continue; + } + if (ispTdepPID && !selectionPIDpTdependent(track1)) { + 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 && !selectionPID(track2)) { + continue; + } + if (ispTdepPID && !selectionPIDpTdependent(track2)) { + continue; + } + if (!track2.has_mcParticle()) { + 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 = TMath::Abs(mctrack1.pdgCode()); + int track2PDG = TMath::Abs(mctrack2.pdgCode()); + if (!mctrack1.isPhysicalPrimary()) { + continue; + } + if (!mctrack2.isPhysicalPrimary()) { + continue; + } + if (!(track1PDG == 321 && track2PDG == 321)) { + 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 (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { + continue; + } + if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { + histos.fill(HIST("h1PhiRecsplit"), mothertrack1.pt()); + 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); + } + PhiMesonMother = KaonPlus + KaonMinus; + + if (TMath::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()); + } + } + } + } + // loop over generated particle + for (auto& mcParticle : GenParticles) { + 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 (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() == -321) { + if (genacceptancecut && kCurrentDaughter.pt() > cfgCutPT && TMath::Abs(kCurrentDaughter.eta()) < cfgCutEta) { + daughtm = true; + } + if (!genacceptancecut) { + daughtm = true; + } + 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()); + } + } + } // rec collision loop + + } // process MC + 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); @@ -413,7 +622,6 @@ struct phianalysisrun3_PbPb { } } } - PROCESS_SWITCH(phianalysisrun3_PbPb, processGen, "Process Generated", false); void processRec(EventCandidatesMC::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const& /*mcParticles*/, aod::McCollisions const& /*mcCollisions*/) { @@ -482,7 +690,10 @@ struct phianalysisrun3_PbPb { if (std::abs(mothertrack1.pdgCode()) != 333) { continue; } - if (!isITSOnlycut && !(selectionPID(track1) && selectionPID(track2))) { + if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { + continue; + } + if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { continue; } if (avoidsplitrackMC && oldindex == mothertrack1.globalIndex()) { diff --git a/PWGLF/Tasks/Resonances/phipbpb.cxx b/PWGLF/Tasks/Resonances/phipbpb.cxx index 5ba8198e1da..8d837d8314f 100644 --- a/PWGLF/Tasks/Resonances/phipbpb.cxx +++ b/PWGLF/Tasks/Resonances/phipbpb.cxx @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "TRandom3.h" #include "Math/Vector3D.h" @@ -75,24 +77,23 @@ struct phipbpb { // 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 additionalEvSel2{"additionalEvSel2", true, "Additional evsel2"}; - Configurable additionalEvSel3{"additionalEvSel3", false, "Additional evsel3"}; + Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; Configurable ConfFakeKaonCut{"ConfFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; - Configurable fillRapidity{"fillRapidity", false, "fill rapidity bin"}; 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", 3.0, "Value of the TPC Nsigma cut"}; - Configurable nsigmaCutCombined{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; + Configurable nsigmaCutTOF{"nsigmaCutTOF", 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 isNoTOF{"isNoTOF", false, "isNoTOF"}; Configurable isDeepAngle{"isDeepAngle", false, "Deep Angle cut"}; Configurable ispTdepPID{"ispTdepPID", true, "pT dependent PID"}; Configurable cfgDeepAngle{"cfgDeepAngle", 0.04, "Deep Angle cut value"}; @@ -103,12 +104,9 @@ struct phipbpb { 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 configThnAxisSP{"configThnAxisSP", {400, -4, 4}, "SP"}; ConfigurableAxis configThnAxisRapidity{"configThnAxisRapidity", {8, 0, 0.8}, "Rapidity"}; ConfigurableAxis configThnAxisSA{"configThnAxisSA", {200, -1, 1}, "SA"}; ConfigurableAxis configThnAxiscosthetaSA{"configThnAxiscosthetaSA", {200, 0, 1}, "costhetaSA"}; - Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; - Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; Configurable isMC{"isMC", false, "use MC"}; Configurable genacceptancecut{"genacceptancecut", true, "use acceptance cut for generated"}; Configurable avoidsplitrackMC{"avoidsplitrackMC", false, "avoid split track in MC"}; @@ -120,12 +118,12 @@ struct phipbpb { Filter PIDcutFilter = nabs(aod::pidtpc::tpcNSigmaKa) < nsigmaCutTPC; using EventCandidates = soa::Filtered>; - using TrackCandidates = soa::Filtered>; + using TrackCandidates = soa::Filtered>; using CollisionMCTrueTable = aod::McCollisions; using TrackMCTrueTable = aod::McParticles; using CollisionMCRecTableCentFT0C = soa::SmallGroups>; - using TrackMCRecTable = soa::Join; + using TrackMCRecTable = soa::Join; using FilTrackMCRecTable = soa::Filtered; Preslice perCollision = aod::track::collisionId; @@ -149,15 +147,12 @@ struct phipbpb { 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 thnAxisCosThetaStarOP{configThnAxisCosThetaStar, "cos(#vartheta_{OP})"}; - const AxisSpec thnAxisCosThetaStarIP{configThnAxisCosThetaStar, "cos(#vartheta_{IP})"}; - const AxisSpec thnAxisPhiminusPsi{configThnAxisPhiminusPsi, "#phi - #psi"}; + const AxisSpec thnAxisCosThetaStar{configThnAxisCosThetaStar, "cos(#vartheta_{OP})"}; const AxisSpec thnAxisCentrality{configThnAxisCentrality, "Centrality (%)"}; const AxisSpec thnAxisV2{configThnAxisV2, "V2"}; - const AxisSpec thnAxisSP{configThnAxisSP, "SP"}; const AxisSpec thnAxisRapidity{configThnAxisRapidity, "Rapidity"}; const AxisSpec thnAxisSA{configThnAxisSA, "SA"}; - const AxisSpec thnAxiscosthetaSA{configThnAxiscosthetaSA, "costhetaSA"}; + AxisSpec cumulantAxis = {200, -1, 1, "phi"}; AxisSpec phiAxis = {500, -6.28, 6.28, "phi"}; AxisSpec resAxis = {2000, -10, 10, "Res"}; AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; @@ -180,36 +175,24 @@ struct phipbpb { histos.add("hPsiTPC", "PsiTPC", kTH3F, {centAxis, occupancyAxis, phiAxis}); histos.add("hPsiTPCR", "PsiTPCR", kTH3F, {centAxis, occupancyAxis, phiAxis}); histos.add("hPsiTPCL", "PsiTPCL", kTH3F, {centAxis, occupancyAxis, phiAxis}); - if (!fillRapidity) { - histos.add("hSparseV2SASameEvent_costhetastarOP", "hSparseV2SASameEvent_costhetastarOP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP", "hSparseV2SASameEvent_costhetastarIP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA", "hSparseV2SASameEvent_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA", "hSparseV2SASameEvent_costheta_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0", "hSparseV2SASameEvent_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costhetastarOP", "hSparseV2SAMixedEvent_costhetastarOP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costhetastarIP", "hSparseV2SAMixedEvent_costhetastarIP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_SA", "hSparseV2SAMixedEvent_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costheta_SA", "hSparseV2SAMixedEvent_costheta_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_SA_A0", "hSparseV2SAMixedEvent_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SP", "hSparseV2SASameEvent_SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSP, thnAxisCentrality, occupancyAxis}); - histos.add("hSparseV2SAMixedEvent_SP", "hSparseV2SAMixedEvent_SP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSP, thnAxisCentrality, occupancyAxis}); - } - if (fillRapidity) { - histos.add("hSparseV2SASameEvent_costhetastarOP", "hSparseV2SASameEvent_costhetastarOP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP", "hSparseV2SASameEvent_costhetastarIP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA", "hSparseV2SASameEvent_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA", "hSparseV2SASameEvent_costheta_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0", "hSparseV2SASameEvent_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costhetastarOP", "hSparseV2SAMixedEvent_costhetastarOP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costhetastarIP", "hSparseV2SAMixedEvent_costhetastarIP", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_SA", "hSparseV2SAMixedEvent_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_costheta_SA", "hSparseV2SAMixedEvent_costheta_SA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_SA_A0", "hSparseV2SAMixedEvent_SA_A0", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SAMixedEvent_V2", "hSparseV2SAMixedEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - } + + 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("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}); @@ -230,40 +213,12 @@ struct phipbpb { 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}}); - if (!fillRapidity) { - histos.add("hSparseV2SASameEvent_costhetastarOP_beam_MCGen", "hSparseV2SASameEvent_costhetastar_beamOP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarOP_MCGen", "hSparseV2SASameEvent_costhetastarOP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP_MCGen", "hSparseV2SASameEvent_costhetastarIP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_MCGen", "hSparseV2SASameEvent_SA_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA_MCGen", "hSparseV2SASameEvent_costheta_SA_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0_MCGen", "hSparseV2SASameEvent_SA_A0_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2_MCGen", "hSparseV2SASameEvent_V2_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - - histos.add("hSparseV2SASameEvent_costhetastarOP_beam_MCRec", "hSparseV2SASameEvent_costhetastar_beamOP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarOP_MCRec", "hSparseV2SASameEvent_costhetastarOP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP_MCRec", "hSparseV2SASameEvent_costhetastarIP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_MCRec", "hSparseV2SASameEvent_SA_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA_MCRec", "hSparseV2SASameEvent_costheta_SA_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0_MCRec", "hSparseV2SASameEvent_SA_A0_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisPhiminusPsi, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2_MCRec", "hSparseV2SASameEvent_V2_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - } - if (fillRapidity) { - histos.add("hSparseV2SASameEvent_costhetastarOP_beam_MCGen", "hSparseV2SASameEvent_costhetastar_beamOP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarOP_MCGen", "hSparseV2SASameEvent_costhetastarOP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP_MCGen", "hSparseV2SASameEvent_costhetastarIP_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_MCGen", "hSparseV2SASameEvent_SA_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA_MCGen", "hSparseV2SASameEvent_costheta_SA_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0_MCGen", "hSparseV2SASameEvent_SA_A0_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2_MCGen", "hSparseV2SASameEvent_V2_MCGen", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - - histos.add("hSparseV2SASameEvent_costhetastarOP_beam_MCRec", "hSparseV2SASameEvent_costhetastar_beamOP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarOP_MCRec", "hSparseV2SASameEvent_costhetastarOP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costhetastarIP_MCRec", "hSparseV2SASameEvent_costhetastarIP_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisCosThetaStarOP, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_MCRec", "hSparseV2SASameEvent_SA_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_costheta_SA_MCRec", "hSparseV2SASameEvent_costheta_SA_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxiscosthetaSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_SA_A0_MCRec", "hSparseV2SASameEvent_SA_A0_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisSA, thnAxisRapidity, thnAxisCentrality}); - histos.add("hSparseV2SASameEvent_V2_MCRec", "hSparseV2SASameEvent_V2_MCRec", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - } + + 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}); } // Event selection cut additional - Alex if (additionalEvsel) { @@ -321,7 +276,7 @@ struct phipbpb { if (candidate.pt() < 0.5 && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (candidate.pt() >= 0.5 && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (candidate.pt() >= 0.5 && candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } if (!useGlobalTrack && !candidate.hasTPC()) { @@ -332,13 +287,10 @@ struct phipbpb { template bool selectionPID(const T& candidate) { - if (!isNoTOF && !candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { - return true; - } - if (!isNoTOF && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombined * nsigmaCutCombined)) { + if (!candidate.hasTOF() && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { return true; } - if (isNoTOF && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC) { + if (candidate.hasTOF() && candidate.beta() > cfgCutTOFBeta && TMath::Abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC && TMath::Abs(candidate.tofNSigmaKa()) < nsigmaCutTOF) { return true; } return false; @@ -389,7 +341,7 @@ struct phipbpb { { const auto pglobal = track.p(); const auto ptpc = track.tpcInnerParam(); - if (std::abs(pglobal - ptpc) > ConfFakeKaonCut) { + if (TMath::Abs(pglobal - ptpc) > ConfFakeKaonCut) { return true; } return false; @@ -406,24 +358,12 @@ struct phipbpb { void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) { - if (!collision.sel8()) { + 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; } auto centrality = collision.centFT0C(); auto multTPC = collision.multNTracksPV(); histos.fill(HIST("hFTOCvsTPCNoCut"), centrality, multTPC); - if (!collision.triggereventep()) { - return; - } - 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; - } auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto psiFT0C = collision.psiFT0C(); @@ -437,6 +377,9 @@ struct phipbpb { auto QTPCR = collision.qTPCR(); auto QTPCL = collision.qTPCL(); int occupancy = collision.trackOccupancyInTimeRange(); + if (occupancy > cfgCutOccupancy) { + return; + } histos.fill(HIST("hFTOCvsTPC"), centrality, multTPC); if (additionalEvsel && !eventSelected(collision, centrality)) { return; @@ -515,117 +458,19 @@ struct phipbpb { 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; - histos.fill(HIST("hpTvsRapidity"), PhiMesonMother.Pt(), PhiMesonMother.Rapidity()); - if (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { - continue; - } - 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 cosinephidaughterstarminuspsi = eventplaneVec.Dot(threeVecDauCMXY) / std::sqrt(threeVecDauCMXY.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - // auto SA = (2.0 * cosinephidaughterstarminuspsi * cosinephidaughterstarminuspsi) - 1.0; - auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); - auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); - // auto cosThetaStarOP = TMath::Abs(eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2())); - auto cosThetaStarOP = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - auto SA_A0 = 1 - (cosThetaStarOP * cosThetaStarOP); - // auto cosThetaStarIP = TMath::Abs(eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2())); - auto cosThetaStarIP = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); auto v2 = TMath::Cos(2.0 * phiminuspsi); - if (!fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SP"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality, occupancy); - } + auto v2sin = TMath::Sin(2.0 * phiminuspsi); + auto phimother = PhiMesonMother.Phi(); + histos.fill(HIST("hpTvsRapidity"), PhiMesonMother.Pt(), PhiMesonMother.Rapidity()); + if (TMath::Abs(PhiMesonMother.Rapidity()) < confRapidity) { + histos.fill(HIST("hSparseV2SameEventCosDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality); + histos.fill(HIST("hSparseV2SameEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); - if (fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } - } - Npostrack = Npostrack + 1; - } - } - PROCESS_SWITCH(phipbpb, processSameEvent, "Process Same event", true); - void processMixedEvent(EventCandidates const& collisions, TrackCandidates const& /*tracks*/) - { - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicityClass, axisOccup}, 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); - continue; - } - if (additionalEvSel2 && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - continue; - } - if (additionalEvSel2 && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - continue; - } - int occupancy = collision1.trackOccupancyInTimeRange(); - auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); - auto centrality = collision1.centFT0C(); - auto centrality2 = collision2.centFT0C(); - auto psiFT0C = collision1.psiFT0C(); - auto QFT0C = collision1.qFT0C(); - if (additionalEvsel && !eventSelected(collision1, centrality)) { - // printf("Mix = %d\n", 4); - continue; - } - if (additionalEvsel && !eventSelected(collision2, centrality2)) { - // printf("Mix = %d\n", 5); - continue; - } - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { - // track selection - if (!selectionTrack(track1) || !selectionTrack(track2)) { - // printf("Mix = %d\n", 6); - continue; - } - // PID check - if (ispTdepPID && (!selectionPIDpTdependent(track1) || !selectionPIDpTdependent(track2))) { - // printf("Mix = %d\n", 7); - continue; - } - if (!ispTdepPID && (!selectionPID(track1) || !selectionPID(track2))) { - continue; - } - if (!selectionPair(track1, track2)) { - // printf("Mix = %d\n", 8); - continue; - } - if (removefaketrak && isFakeKaon(track1)) { - continue; - } - if (removefaketrak && isFakeKaon(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 (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { - continue; + 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); @@ -633,67 +478,39 @@ struct phipbpb { 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 cosinephidaughterstarminuspsi = eventplaneVec.Dot(threeVecDauCMXY) / std::sqrt(threeVecDauCMXY.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - // auto SA = (2.0 * cosinephidaughterstarminuspsi * cosinephidaughterstarminuspsi) - 1.0; auto cosPhistarminuspsi = GetPhiInRange(fourVecDauCM.Phi() - psiFT0C); auto SA = TMath::Cos(2.0 * cosPhistarminuspsi); - // auto cosThetaStarOP = TMath::Abs(eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2())); - auto cosThetaStarOP = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - auto SA_A0 = 1 - (cosThetaStarOP * cosThetaStarOP); - // auto cosThetaStarIP = TMath::Abs(eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2())); - auto cosThetaStarIP = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); - auto v2 = TMath::Cos(2.0 * phiminuspsi); - if (!fillRapidity) { - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SP"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality, occupancy); - } - if (fillRapidity) { - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } + 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); } + Npostrack = Npostrack + 1; } } - PROCESS_SWITCH(phipbpb, processMixedEvent, "Process Mixed event", true); + PROCESS_SWITCH(phipbpb, processSameEvent, "Process Same event", true); void processMixedEventOpti(EventCandidates const& collisions, TrackCandidates const& tracks) { 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() || !collision2.sel8()) { + 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 (!collision1.triggereventep() || !collision2.triggereventep()) { + 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 (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))) { + if (collision1.bcId() == collision2.bcId()) { continue; } - if (additionalEvSel2 && (!collision1.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision1.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - return; - } - if (additionalEvSel3 && (!collision1.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - return; - } - if (additionalEvSel2 && (!collision2.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision2.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { - return; + int occupancy1 = collision1.trackOccupancyInTimeRange(); + int occupancy2 = collision2.trackOccupancyInTimeRange(); + if (occupancy1 > cfgCutOccupancy) { + continue; } - if (additionalEvSel3 && (!collision2.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { - return; + if (occupancy2 > cfgCutOccupancy) { + continue; } - int occupancy = collision1.trackOccupancyInTimeRange(); auto centrality = collision1.centFT0C(); auto centrality2 = collision2.centFT0C(); auto psiFT0C = collision1.psiFT0C(); @@ -735,10 +552,14 @@ struct phipbpb { 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 (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { - continue; + 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("hSparseV2MixedEventSinDeltaPhi"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2sin * QFT0C, centrality); } ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; fourVecDauCM = boost(KaonMinus); @@ -746,33 +567,11 @@ struct phipbpb { 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 cosThetaStarOP = TMath::Abs(eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2())); - auto cosThetaStarOP = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - auto SA_A0 = 1 - (cosThetaStarOP * cosThetaStarOP); - // auto cosThetaStarIP = TMath::Abs(eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2())); - auto cosThetaStarIP = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); - auto v2 = TMath::Cos(2.0 * phiminuspsi); - if (!fillRapidity) { - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SP"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2 * QFT0C, centrality, occupancy); - } - if (fillRapidity) { - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarOP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costheta_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_costhetastarIP"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_SA_A0"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SAMixedEvent_V2"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } + 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); } } } @@ -795,11 +594,12 @@ struct phipbpb { histos.fill(HIST("hMC"), 4); continue; } - if (timFrameEvsel && (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + + if (!RecCollision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !RecCollision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { histos.fill(HIST("hMC"), 5); continue; } - if (std::abs(RecCollision.posZ()) > cfgCutVertex) { + if (TMath::Abs(RecCollision.posZ()) > cfgCutVertex) { histos.fill(HIST("hMC"), 6); continue; } @@ -848,8 +648,8 @@ struct phipbpb { } const auto mctrack1 = track1.mcParticle(); const auto mctrack2 = track2.mcParticle(); - int track1PDG = std::abs(mctrack1.pdgCode()); - int track2PDG = std::abs(mctrack2.pdgCode()); + int track1PDG = TMath::Abs(mctrack1.pdgCode()); + int track2PDG = TMath::Abs(mctrack2.pdgCode()); if (!mctrack1.isPhysicalPrimary()) { continue; } @@ -867,10 +667,10 @@ struct phipbpb { if (mothertrack1 != mothertrack2) { continue; } - if (std::abs(mothertrack1.y()) > confRapidity) { + if (TMath::Abs(mothertrack1.y()) > confRapidity) { continue; } - if (std::abs(mothertrack1.pdgCode()) != 333) { + if (TMath::Abs(mothertrack1.pdgCode()) != 333) { continue; } if (!selectionPID(track1) || !selectionPID(track2)) { @@ -890,10 +690,6 @@ struct phipbpb { KaonPlus = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa); } PhiMesonMother = KaonPlus + KaonMinus; - - if (TMath::Abs(PhiMesonMother.Rapidity()) > confRapidity) { - continue; - } ROOT::Math::Boost boost{PhiMesonMother.BoostToCM()}; fourVecDauCM = boost(KaonMinus); threeVecDauCM = fourVecDauCM.Vect(); @@ -903,39 +699,16 @@ struct phipbpb { 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 cosThetaStarOP = TMath::Abs(eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2())); - auto cosThetaStarIP = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - auto cosThetaStarOP = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - auto cosThetaStarOPbeam = beamvector.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(beamvector.Mag2()); - auto SA_A0 = 1 - (cosThetaStarOP * cosThetaStarOP); - // auto cosThetaStarIP = TMath::Abs(eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2())); - auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); - auto v2 = TMath::Cos(2.0 * phiminuspsi); - if (!fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_beam_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOPbeam, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } - if (fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_beam_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOPbeam, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2_MCRec"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } + auto cosThetaStar = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); + histos.fill(HIST("hSparseV2MCRecCosThetaStar_effy"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + histos.fill(HIST("hSparseV2MCRecSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); } } } } // loop over generated particle for (auto& mcParticle : GenParticles) { - if (std::abs(mcParticle.y()) > confRapidity) { + if (TMath::Abs(mcParticle.y()) > confRapidity) { continue; } if (mcParticle.pdgCode() != 333) { @@ -980,30 +753,9 @@ struct phipbpb { 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 cosThetaStarIP = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); - auto cosThetaStarOP = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); - auto cosThetaStarOPbeam = beamvector.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(beamvector.Mag2()); - auto SA_A0 = 1 - (cosThetaStarOP * cosThetaStarOP); - auto phiminuspsi = GetPhiInRange(PhiMesonMother.Phi() - psiFT0C); - auto v2 = TMath::Cos(2.0 * phiminuspsi); - if (!fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_beam_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOPbeam, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, phiminuspsi, centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } - if (fillRapidity) { - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarOP_beam_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOPbeam, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costheta_SA_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarOP * cosThetaStarOP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_costhetastarIP_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStarIP, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_SA_A0_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA_A0, TMath::Abs(PhiMesonMother.Rapidity()), centrality); - histos.fill(HIST("hSparseV2SASameEvent_V2_MCGen"), PhiMesonMother.M(), PhiMesonMother.Pt(), v2, centrality); - } + auto cosThetaStar = eventplaneVec.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVec.Mag2()); + histos.fill(HIST("hSparseV2MCGenCosThetaStar_effy"), PhiMesonMother.M(), PhiMesonMother.Pt(), cosThetaStar, TMath::Abs(PhiMesonMother.Rapidity()), centrality); + histos.fill(HIST("hSparseV2MCGenSA"), PhiMesonMother.M(), PhiMesonMother.Pt(), SA, TMath::Abs(PhiMesonMother.Rapidity()), centrality); } } } // rec collision loop diff --git a/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx new file mode 100644 index 00000000000..6781fdffdaf --- /dev/null +++ b/PWGLF/Tasks/Resonances/xi1530Analysisqa.cxx @@ -0,0 +1,1011 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 xi1530Analysisqa.cxx +/// \brief Reconstruction of Xi* resonance. +/// +/// \author Min-jae Kim , Bong-Hwi Lim +#include +#include "TF1.h" +#include "TRandom3.h" + +#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 "PWGLF/DataModel/LFStrangenessTables.h" +#include "CommonConstants/PhysicsConstants.h" +#include "Common/Core/RecoDecay.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace o2::soa; +using namespace o2::constants::physics; +Service pdgDB; + +enum { + kData = 0, + kLS, + kMixing, + kMCReco, + kMCTrue, + kMCTruePS, + kINEL10, + kINELg010, + kAllType +}; + +enum { + PionPID = 211, + XiPID = 3312, + XiStarPID = 3324 +}; + +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; + + // 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 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"}; + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + // Track selections (Execpt DCA selelctions) // + + // Primary track selections + 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 cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; // Minmimum + Configurable cfgTPCcluster{"cfgTPCcluster", 1, "Minimum Number of TPC cluster"}; // Minmimum + + Configurable cfgTPCRows{"cfgTPCRows", 70, "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", 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"}; + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + // DCA selections // + + // Primary track DCAr to PV + Configurable cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + + // 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"}; + + // 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 ? + + // 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"}; + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + // PID Selections// + + Configurable cPIDBound{"cPIDBound", 6.349, "configurable for replacing to .has"}; + + // 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 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"}; + + // 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 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"}; + + // 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 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"}; + + // 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 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"}; + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + // MC Event selection // + Configurable cZvertCutMC{"cZvertCutMC", 10.0, "MC Z-vertex cut"}; + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + // Cuts on mother particle + 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"}; + TRandom* rn = new TRandom(); + + //*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*// + + struct PIDSelectionParam { + double cMaxTPCnSigma; + double cMaxTOFnSigma; + bool cByPassTOF; + double nsigmaCutCombined; + }; + + 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 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"}; + + 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}}); + + histos.add("TestME/hnTrksSameE", "n tracks per event SameE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + histos.add("TestME/hnTrksMixedE", "n tracks per event MixedE", HistType::kTH1F, {{1000, 0.0f, 1000.0f}}); + + histos.add("TestME/hPairsCounterSameE", "tot n pairs sameE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + histos.add("TestME/hPairsCounterMixedE", "tot n pairs mixedE", HistType::kTH1F, {{1, 0.5f, 1.5f}}); + + // event histograms + 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("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}}); + } + + 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) { + 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) { + 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("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}); + + // 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/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) { + + // 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}}); + histos.add("QAbefore/TPC_Nsigma_pi_first_all", "TPC NSigma for Pion_{First};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAbefore/TOF_TPC_Map_pi_bachelor_all", "TOF + TPC Combined PID for Pion_{Bachelor};#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAbefore/TPC_Nsigma_pi_bachelor_all", "TPC NSigma for Pion_{Bachelor};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAbefore/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAbefore/TOF_TPC_Map_antipr_all", "TOF + TPC Combined PID for Anti-Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + + histos.add("QAbefore/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAbefore/TPC_Nsigma_antipr_all", "TPC NSigma for Anti-Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + 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_TPC_Map_piminus_all", "TOF + TPC Combined PID for Pion -;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, 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}}); + histos.add("QAbefore/TPC_Nsigma_piminus_all", "TPC NSigma for Pion -;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + // Plots for QA after + histos.add("QAafter/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("QAafter/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("QAafter/TPC_Nsigma_pi_first_all", "TPC NSigma for Pion_{First};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAafter/TOF_TPC_Map_pi_bachelor_all", "TOF + TPC Combined PID for Pion_{Bachelor};#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAafter/TPC_Nsigma_pi_bachelor_all", "TPC NSigma for Pion_{Bachelor};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAafter/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAafter/TOF_TPC_Map_antipr_all", "TOF + TPC Combined PID for Anti-Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + + histos.add("QAafter/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAafter/TPC_Nsigma_antipr_all", "TPC NSigma for Anti-Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAafter/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAafter/TOF_TPC_Map_piminus_all", "TOF + TPC Combined PID for Pion -;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + + histos.add("QAafter/TPC_Nsigma_pi_all", "TPC NSigma for Pion;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAafter/TPC_Nsigma_piminus_all", "TPC NSigma for Pion -;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + } + + // 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}); + + 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 (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 (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/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}); + + 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}}); + + histos.add("QAMCTrue/TOF_TPC_Map_pi_bachelor_all", "TOF + TPC Combined PID for Pion_{Bachelor};#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAMCTrue/TPC_Nsigma_pi_bachelor_all", "TPC NSigma for Pion_{Bachelor};#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Pion};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAMCTrue/TOF_TPC_Map_pr_all", "TOF + TPC Combined PID for Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAMCTrue/TOF_TPC_Map_antipr_all", "TOF + TPC Combined PID for Anti-Proton;#sigma_{TOF}^{Proton};#sigma_{TPC}^{Proton}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + + histos.add("QAMCTrue/TPC_Nsigma_pr_all", "TPC NSigma for Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + histos.add("QAMCTrue/TPC_Nsigma_antipr_all", "TPC NSigma for Anti-Proton;#it{p}_{T} (GeV/#it{c});#sigma_{TPC}^{Proton};", {HistType::kTH3F, {centAxis, ptAxisQA, pidQAAxis}}); + + histos.add("QAMCTrue/TOF_TPC_Map_pi_all", "TOF + TPC Combined PID for Pion;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, pidQAAxis}}); + histos.add("QAMCTrue/TOF_TPC_Map_piminus_all", "TOF + TPC Combined PID for Pion -;#sigma_{TOF}^{Pion};#sigma_{TPC}^{Pion}", {HistType::kTH2F, {pidQAAxis, 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/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("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("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}); + } + } + + double massPi = MassPionCharged; + + // Primary track selection for the first pion // + template + bool PtrackCut(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 (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; + + return true; + } + + bool hasSubsystemInfo(float Nsigma) // this will be replaced // .hasXX() was not appied in resocascade yet + { + return std::abs(Nsigma) < cPIDBound; + } + + // Primary track selection for cascades, Need to more informations for cascades // + template + bool cascPtrackCut(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; + + return true; + } + + // Secondary track selection for cascades // need to more information, + + // Topological cuts for cascades + template + bool casctopCut(const TracksTypeCasc track) + { + // Topological cuts for V0s + if (std::abs(track.daughDCA()) > cDCALambdaDaugtherscut) + return false; + if (std::abs(track.dcav0topv()) < cDCALambdaToPVcut) + return false; + if (track.sign() < 0) { + if (std::abs(track.dcanegtopv()) < cDCAPionToPVcut) + return false; + if (std::abs(track.dcapostopv()) < cDCAProtonToPVcut) + return false; + } else { + if (std::abs(track.dcanegtopv()) < cDCAProtonToPVcut) + return false; + if (std::abs(track.dcapostopv()) < cDCAPionToPVcut) + return false; + } + if (track.v0CosPA() < cCosV0cut) + return false; + if (track.transRadius() > cMaxV0radiuscut || track.transRadius() < cMinV0radiuscut) + return false; + + // Topological Cuts for Cascades + if (track.dcabachtopv() < cDCABachlorToPVcut) + return false; + if (track.cascdaughDCA() > cDCAXiDaugtherscut) + return false; + if (track.cascCosPA() < cCosPACasc) + 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 tpcPIDPassed{false}, tofPIDPassed{false}; + + if (tofAtHighPt) { + // TOF based PID + if (hasSubsystemInfo(TOFNsigma) && std::abs(TOFNsigma) < params.cMaxTOFnSigma) { + return true; + } + if (!hasSubsystemInfo(TOFNsigma) && std::abs(TPCNsigma) < params.cMaxTPCnSigma) { + return true; + } + return false; + } else { + + if (std::abs(TPCNsigma) < params.cMaxTPCnSigma) { + tpcPIDPassed = true; + } + + if (params.cByPassTOF && tpcPIDPassed) { + return true; + } + + 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; + } + } + + // PID selection for the First Pion // + template + bool selectionPIDPionFirst(const T& candidate) + { + + float TPCNsigmaPionFirst, TOFNsigmaPionFirst; + + TPCNsigmaPionFirst = candidate.tpcNSigmaPi(); + TOFNsigmaPionFirst = candidate.tofNSigmaPi(); + + PIDSelectionParam PionFirstParams = {cMaxTPCnSigmaPionFirst, cMaxTOFnSigmaPionFirst, cByPassTOFPionFirst, nsigmaCutCombinedPionFirst}; + + return PIDSelector(TPCNsigmaPionFirst, TOFNsigmaPionFirst, PionFirstParams, tof_at_high_pt); + } + + template + bool selectionPIDCascades(const TCascade& candidate) + { + bool lConsistentWithXi{false}, lConsistentWithLambda{false}, lConsistentWithPion{false}, lConsistentWithProton{false}; + + float TPCNsigmaBachelor, TOFNsigmaBachelor; + float TPCNsigmaPion, TOFNsigmaPion; + float TPCNsigmaProton, TOFNsigmaProton; + + if (candidate.sign() < 0) { // Xi- candidates + TPCNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); + TOFNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); + + TPCNsigmaPion = candidate.daughterTPCNSigmaNegPi(); + TOFNsigmaPion = candidate.daughterTOFNSigmaNegPi(); + + TPCNsigmaProton = candidate.daughterTPCNSigmaPosPr(); + TOFNsigmaProton = candidate.daughterTOFNSigmaPosPr(); + } else { // Anti-Xi- candidates + + TPCNsigmaBachelor = candidate.daughterTPCNSigmaBachPi(); + TOFNsigmaBachelor = candidate.daughterTOFNSigmaBachPi(); + + TPCNsigmaPion = candidate.daughterTPCNSigmaPosPi(); + TOFNsigmaPion = candidate.daughterTOFNSigmaPosPi(); + + TPCNsigmaProton = candidate.daughterTPCNSigmaNegPr(); + TOFNsigmaProton = candidate.daughterTOFNSigmaNegPr(); + } + + 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); + + lConsistentWithLambda = lConsistentWithProton && lConsistentWithPion; + + return lConsistentWithXi && lConsistentWithLambda; + } + + 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()); + 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"), collision.cent()); + histos.fill(HIST("TestME/hCollisionIndexMixedE"), collision.globalIndex()); + histos.fill(HIST("TestME/hnTrksMixedE"), dTracks1.size()); + } + } + + TLorentzVector lDecayDaughter1, lDecayDaughter2, lResonance; // It will be replaced to use RecoDecay (In fixing...) + + for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) { + + if (additionalQAeventPlots) { + if constexpr (!IsMix) { + histos.fill(HIST("TestME/hPairsCounterSameE"), 1.0); + } else { + histos.fill(HIST("TestME/hPairsCounterMixedE"), 1.0); + } + } + + if (!PtrackCut(trk1) || !cascPtrackCut(trk2)) // Primary track selections + continue; + + auto trk1ptPi = trk1.pt(); + auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); + auto trk1NSigmaPiTOF = trk1.tofNSigmaPi(); + + auto trk2ptXi = trk2.pt(); + // Need to daughther's pt info. in the table + // auto trk2ptPiBachelor = trk2.pt(); + float trk2NSigmaPiBachelorTPC = trk2.daughterTPCNSigmaBachPi(); + float trk2NSigmaPiBachelorTOF = trk2.daughterTOFNSigmaBachPi(); + + // auto trk2ptPr = trk2.pt(); + float trk2NSigmaPrPosTPC = trk2.daughterTPCNSigmaPosPr(); + float trk2NSigmaPrNegTPC = trk2.daughterTPCNSigmaNegPr(); + + float trk2NSigmaPrPosTOF = trk2.daughterTOFNSigmaPosPr(); + float trk2NSigmaPrNegTOF = trk2.daughterTOFNSigmaNegPr(); + + // auto trk2ptPi = trk2.pt(); + float trk2NSigmaPiPosTPC = trk2.daughterTPCNSigmaPosPi(); + float trk2NSigmaPiNegTPC = trk2.daughterTPCNSigmaNegPi(); + + float trk2NSigmaPiPosTOF = trk2.daughterTOFNSigmaPosPi(); + float trk2NSigmaPiNegTOF = trk2.daughterTOFNSigmaNegPi(); + + if constexpr (!IsMix) { + //// QA plots before the selection // need to pt for cascade tracks + // --- PID QA + 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); + histos.fill(HIST("QAbefore/TOF_TPC_Map_pi_first_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + // hasSubsystemInfo is Temporary, it will be replaced. + + histos.fill(HIST("QAbefore/TPC_Nsigma_pi_bachelor_all"), multiplicity, 0, trk2NSigmaPiBachelorTPC); // can't take pt information for the cascade secondary + if (hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) { + histos.fill(HIST("QAbefore/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); + } + + histos.fill(HIST("QAbefore/TPC_Nsigma_pr_all"), multiplicity, 0, trk2NSigmaPrPosTPC); + if (hasSubsystemInfo(trk2NSigmaPrPosTOF)) { + histos.fill(HIST("QAbefore/TOF_TPC_Map_pr_all"), trk2NSigmaPrPosTOF, trk2NSigmaPrPosTPC); + } + + histos.fill(HIST("QAbefore/TPC_Nsigma_antipr_all"), multiplicity, 0, trk2NSigmaPrNegTPC); + if (hasSubsystemInfo(trk2NSigmaPrNegTOF)) { + histos.fill(HIST("QAbefore/TOF_TPC_Map_antipr_all"), trk2NSigmaPrNegTOF, trk2NSigmaPrNegTPC); + } + + histos.fill(HIST("QAbefore/TPC_Nsigma_pi_all"), multiplicity, 0, trk2NSigmaPiPosTPC); + if (hasSubsystemInfo(trk2NSigmaPiPosTOF)) { + histos.fill(HIST("QAbefore/TOF_TPC_Map_pi_all"), trk2NSigmaPiPosTOF, trk2NSigmaPiPosTPC); + } + + histos.fill(HIST("QAbefore/TPC_Nsigma_piminus_all"), multiplicity, 0, trk2NSigmaPiNegTPC); + if (hasSubsystemInfo(trk2NSigmaPiNegTOF)) { + histos.fill(HIST("QAbefore/TOF_TPC_Map_piminus_all"), trk2NSigmaPiNegTOF, trk2NSigmaPiNegTPC); + } + } + + histos.fill(HIST("QAbefore/trkpT_pi"), trk1ptPi); + histos.fill(HIST("QAbefore/trkpT_Xi"), trk2ptXi); + + histos.fill(HIST("QAbefore/trkDCAxy_pi"), trk1.dcaXY()); + histos.fill(HIST("QAbefore/trkDCAxy_Xi"), trk2.dcaXYCascToPV()); + + histos.fill(HIST("QAbefore/trkDCAz_pi"), trk1.dcaZ()); + histos.fill(HIST("QAbefore/trkDCAz_Xi"), trk2.dcaZCascToPV()); + } + + // PID selection + if (cUseOnlyTOFTrackPionFirst && !hasSubsystemInfo(trk1NSigmaPiTOF)) + continue; + + if (cUseOnlyTOFTrackPionBachelor && !hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) + continue; + + if (cUseOnlyTOFTrackProton && !hasSubsystemInfo(trk2NSigmaPrPosTOF)) + continue; + if (cUseOnlyTOFTrackProton && !hasSubsystemInfo(trk2NSigmaPrNegTOF)) + continue; + + if (cUseOnlyTOFTrackPion && !hasSubsystemInfo(trk2NSigmaPiPosTOF)) + continue; + if (cUseOnlyTOFTrackPion && !hasSubsystemInfo(trk2NSigmaPiNegTOF)) + continue; + + 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()); + } + + if constexpr (!IsMix) { + //// QA plots before the selection + // --- PID QA + if (PIDplots) { + histos.fill(HIST("QAafter/TPC_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + + if (hasSubsystemInfo(trk1NSigmaPiTOF)) { + histos.fill(HIST("QAafter/TOF_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_first_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + + if (trk2.sign() < 0) { + histos.fill(HIST("QAafter/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("QAafter/TPC_Nsigma_pr_all"), multiplicity, 0, trk2NSigmaPrPosTPC); + if (hasSubsystemInfo(trk2NSigmaPrPosTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pr_all"), trk2NSigmaPrPosTOF, trk2NSigmaPrPosTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_piminus_all"), multiplicity, 0, trk2NSigmaPiNegTPC); + if (hasSubsystemInfo(trk2NSigmaPiNegTOF)) { + histos.fill(HIST("QAafter/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. + if (hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_antipr_all"), multiplicity, 0, trk2NSigmaPrNegTPC); + if (hasSubsystemInfo(trk2NSigmaPrNegTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_antipr_all"), trk2NSigmaPrNegTOF, trk2NSigmaPrNegTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, 0, trk2NSigmaPiPosTPC); + if (hasSubsystemInfo(trk2NSigmaPiPosTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_all"), trk2NSigmaPiPosTOF, trk2NSigmaPiPosTPC); + } + } + } + + histos.fill(HIST("QAafter/trkpT_pi"), trk1ptPi); + histos.fill(HIST("QAafter/trkpT_Xi"), trk2ptXi); + + histos.fill(HIST("QAafter/trkDCAxy_pi"), trk1.dcaXY()); + histos.fill(HIST("QAafter/trkDCAxy_Xi"), trk2.dcaXYCascToPV()); + + histos.fill(HIST("QAafter/trkDCAz_pi"), trk1.dcaZ()); + histos.fill(HIST("QAafter/trkDCAz_Xi"), trk2.dcaZCascToPV()); + } + + lDecayDaughter1.SetPtEtaPhiM(trk1ptPi, trk1.eta(), trk1.phi(), massPi); + lDecayDaughter2.SetPtEtaPhiM(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) + continue; + + if (cfgCutsOnMother) { + if (lResonancePt >= cMaxPtMotherCut) // excluding candidates in overflow + continue; + if (lResonanceInMass >= cMaxMinvMotherCut) // excluding candidates in overflow + continue; + } + + if (trk1.sign() * trk2.sign() < 0) { + + if constexpr (!IsMix) { + if (study_antiparticle) { + if (trk1.sign() > 0) { + if (invmass1D) + histos.fill(HIST("Xi1530invmassDS"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassDS"), multiplicity, lResonancePt, lResonanceInMass, kData); + } else if (trk1.sign() < 0) { + if (invmass1D) + histos.fill(HIST("Xi1530invmassDSAnti"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassDSAnti"), multiplicity, lResonancePt, lResonanceInMass, kData); + } + } else { + if (invmass1D) + histos.fill(HIST("Xi1530invmassDS"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassDS"), multiplicity, lResonancePt, lResonanceInMass, kData); + } + } else { + if (invmass1D) + histos.fill(HIST("Xi1530invmassME"), lResonanceInMass); + if (trk1.sign() > 0) { + if (invmass1D) + histos.fill(HIST("Xi1530invmassME_DS"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassME_DS"), multiplicity, lResonancePt, lResonanceInMass, kMixing); + } else if (trk1.sign() < 0) { + 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 constexpr (IsMC) { + if (std::abs(trk2.motherPDG()) != XiStarPID) + continue; + if (std::abs(trk1.pdgCode()) != PionPID || std::abs(trk2.pdgCode()) != XiPID) + 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/TPC_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTPC); + if (hasSubsystemInfo(trk1NSigmaPiTOF)) { + histos.fill(HIST("QAMCTrue/TOF_Nsigma_pi_first_all"), multiplicity, trk1ptPi, trk1NSigmaPiTOF); + histos.fill(HIST("QAMCTrue/TOF_TPC_Map_pi_first_all"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); + } + + if (trk2.sign() < 0) { + histos.fill(HIST("QAafter/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("QAafter/TPC_Nsigma_pr_all"), multiplicity, 0, trk2NSigmaPrPosTPC); + if (hasSubsystemInfo(trk2NSigmaPrPosTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pr_all"), trk2NSigmaPrPosTOF, trk2NSigmaPrPosTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_piminus_all"), multiplicity, 0, trk2NSigmaPiNegTPC); + if (hasSubsystemInfo(trk2NSigmaPiNegTOF)) { + histos.fill(HIST("QAafter/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. + if (hasSubsystemInfo(trk2NSigmaPiBachelorTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_bachelor_all"), trk2NSigmaPiBachelorTOF, trk2NSigmaPiBachelorTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_antipr_all"), multiplicity, 0, trk2NSigmaPrNegTPC); + if (hasSubsystemInfo(trk2NSigmaPrNegTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_antipr_all"), trk2NSigmaPrNegTOF, trk2NSigmaPrNegTPC); + } + + histos.fill(HIST("QAafter/TPC_Nsigma_pi_all"), multiplicity, 0, trk2NSigmaPiPosTPC); + if (hasSubsystemInfo(trk2NSigmaPiPosTOF)) { + histos.fill(HIST("QAafter/TOF_TPC_Map_pi_all"), trk2NSigmaPiPosTOF, trk2NSigmaPiPosTPC); + } + } + // MC histograms + if (trk2.motherPDG() > 0) { + histos.fill(HIST("Xi1530Rec"), lResonancePt, multiplicity); + histos.fill(HIST("Xi1530Recinvmass"), lResonanceInMass); + histos.fill(HIST("h3RecXi1530invmass"), multiplicity, lResonancePt, lResonanceInMass, kMCReco); + } else { + histos.fill(HIST("Xi1530RecAnti"), lResonancePt, multiplicity); + histos.fill(HIST("Xi1530Recinvmass"), lResonanceInMass); + histos.fill(HIST("h3RecXi1530invmassAnti"), multiplicity, lResonancePt, lResonanceInMass, kMCReco); + } + } + + } else { + if constexpr (!IsMix) { + if (study_antiparticle) { + if (trk1.sign() < 0) { + if (invmass1D) + histos.fill(HIST("Xi1530invmassLS"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassLS"), multiplicity, lResonancePt, lResonanceInMass, kLS); + } else if (trk1.sign() > 0) { + if (invmass1D) + histos.fill(HIST("Xi1530invmassLSAnti"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassLSAnti"), multiplicity, lResonancePt, lResonanceInMass, kLS); + } + } else { + if (invmass1D) + histos.fill(HIST("Xi1530invmassLS"), lResonanceInMass); + histos.fill(HIST("h3Xi1530invmassLS"), multiplicity, lResonancePt, lResonanceInMass, kLS); + } + } + } + } + } + + void processData(aod::ResoCollision& resoCollision, aod::ResoTracks const& resoTracks, aod::ResoCascades const& cascTracks) + { + if (additionalQAeventPlots) + histos.fill(HIST("QAevent/hEvtCounterSameE"), 1.0); + fillHistograms(resoCollision, resoTracks, cascTracks); + } + + void processMC(ResoMCCols::iterator const& resoCollision, + soa::Join const& cascTracks, + soa::Join const& resoTracks) + { + if (!resoCollision.isInAfterAllCuts() || (std::abs(resoCollision.posZ()) > cZvertCutMC)) // MC event selection, all cuts missing vtx cut + return; + fillHistograms(resoCollision, resoTracks, cascTracks); + } + + void processMCTrue(ResoMCCols::iterator const& resoCollision, aod::ResoMCParents& 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) + 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; + + if (!pass1 || !pass2) + continue; + + if (resoCollision.isVtxIn10()) // INEL10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("h3Xi1530Gen"), 0, part.pt(), multiplicity, kINEL10); + else + histos.fill(HIST("h3Xi1530GenAnti"), 0, part.pt(), multiplicity, kINEL10); + } + if (resoCollision.isVtxIn10() && resoCollision.isInSel8()) // INEL>10, vtx10 + { + if (part.pdgCode() > 0) + histos.fill(HIST("h3Xi1530Gen"), 1, part.pt(), multiplicity, kINELg010); + else + histos.fill(HIST("h3Xi1530GenAnti"), 1, part.pt(), multiplicity, kINELg010); + } + if (resoCollision.isVtxIn10() && resoCollision.isTriggerTVX()) // vtx10, TriggerTVX + { + if (part.pdgCode() > 0) + histos.fill(HIST("h3Xi1530Gen"), 2, part.pt(), multiplicity, kMCTruePS); + else + histos.fill(HIST("h3Xi1530GenAnti"), 2, part.pt(), multiplicity, kMCTruePS); + } + if (resoCollision.isInAfterAllCuts()) // after all event selection + { + if (part.pdgCode() > 0) + histos.fill(HIST("h3Xi1530Gen"), 3, part.pt(), multiplicity, kAllType); + else + histos.fill(HIST("h3Xi1530GenAnti"), 3, part.pt(), multiplicity, kAllType); + } + } + } + + using BinningTypeVtxZT0M = ColumnBinningPolicy; + void processME(aod::ResoCollisions const& resoCollisions, aod::ResoTracks const& resoTracks, aod::ResoCascades const& cascTracks) + { + auto tracksTuple = std::make_tuple(resoTracks, cascTracks); + + BinningTypeVtxZT0M colBinning{{CfgVtxBins, CfgMultBins}, true}; + Pair pairs{colBinning, nEvtMixing, -1, resoCollisions, tracksTuple, &cache}; + + for (auto& [collision1, tracks1, collision2, tracks2] : pairs) { + if (additionalQAeventPlots) + 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); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/CMakeLists.txt b/PWGLF/Tasks/Strangeness/CMakeLists.txt index 32a70cfb412..660c7ce8610 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 + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(lambdakzeroanalysis-mc @@ -94,7 +94,32 @@ o2physics_add_dpl_workflow(lambdapolarization PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(lambdapolsp + SOURCES lambdapolsp.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(strangeness-in-jets SOURCES strangeness_in_jets.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0topologicalcuts + SOURCES v0topologicalcuts.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(v0ptinvmassplots + SOURCES v0ptinvmassplots.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(strange-yield-pbpb + SOURCES strange-yield-pbpb.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdak0sflattenicity + SOURCES lambdak0sflattenicity.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx b/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx index 05df2504e4e..896d366a1fa 100644 --- a/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx +++ b/PWGLF/Tasks/Strangeness/cascadeanalysisMC.cxx @@ -78,16 +78,23 @@ struct cascadeGenerated { Configurable maxPt{"maxPt", 20.0, "max generated pT"}; 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"}; void init(InitContext const&) { - AxisSpec ptAxis = {nPtBins, 0.0f, maxPt, "it{p}_{T} (GeV/c)"}; + AxisSpec ptAxis = {nPtBins, 0.0f, maxPt, "#it{p}_{T} (GeV/c)"}; + AxisSpec rapidityAxis = {nRapidityBins, -rapidityCut, rapidityCut, "y"}; registry.add("hEventCounter", "hEventCounter", {HistType::kTH1F, {{10, 0.0f, 10.0f}}}); registry.add("hPtXiMinus", "hPtXiMinus", {HistType::kTH1F, {ptAxis}}); registry.add("hPtXiPlus", "hPtXiPlus", {HistType::kTH1F, {ptAxis}}); registry.add("hPtOmegaMinus", "hPtOmegaMinus", {HistType::kTH1F, {ptAxis}}); registry.add("hPtOmegaPlus", "hPtOmegaPlus", {HistType::kTH1F, {ptAxis}}); + registry.add("h2DXiMinus", "h2DXiMinus", {HistType::kTH2F, {ptAxis, rapidityAxis}}); + registry.add("h2DXiPlus", "h2DXiPlus", {HistType::kTH2F, {ptAxis, rapidityAxis}}); + registry.add("h2DOmegaMinus", "h2DOmegaMinus", {HistType::kTH2F, {ptAxis, rapidityAxis}}); + registry.add("h2DOmegaPlus", "h2DOmegaPlus", {HistType::kTH2F, {ptAxis, rapidityAxis}}); } void process(aod::McCollision const& /*collision*/, aod::McParticles const& mcparts) @@ -99,16 +106,24 @@ struct cascadeGenerated { // Count all generated MC particles // WARNING: event-level losses have to be understood too for (auto& particle : mcparts) { - if (TMath::Abs(particle.y()) > 0.5) + if (TMath::Abs(particle.y()) > rapidityCut) continue; - if (particle.pdgCode() == 3312) + if (particle.pdgCode() == 3312) { registry.fill(HIST("hPtXiMinus"), particle.pt()); - if (particle.pdgCode() == -3312) + registry.fill(HIST("h2DXiMinus"), particle.pt(), particle.y()); + } + if (particle.pdgCode() == -3312) { registry.fill(HIST("hPtXiPlus"), particle.pt()); - if (particle.pdgCode() == 3334) + registry.fill(HIST("h2DXiPlus"), particle.pt(), particle.y()); + } + if (particle.pdgCode() == 3334) { registry.fill(HIST("hPtOmegaMinus"), particle.pt()); - if (particle.pdgCode() == -3334) + registry.fill(HIST("h2DOmegaMinus"), particle.pt(), particle.y()); + } + if (particle.pdgCode() == -3334) { registry.fill(HIST("hPtOmegaPlus"), particle.pt()); + registry.fill(HIST("h2DOmegaPlus"), particle.pt(), particle.y()); + } } } }; @@ -184,9 +199,13 @@ struct cascadeAnalysisMC { {}, }; + Configurable rapidityCut{"rapidityCut", 0.5, "max (absolute) rapidity of cascade candidate"}; + Configurable nRapidityBins{"nRapidityBins", 200, "number of pT bins"}; + void init(InitContext const&) { - AxisSpec ptAxis = {200, 0.0f, 10.0f, "it{p}_{T} (GeV/c)"}; + AxisSpec ptAxis = {200, 0.0f, 10.0f, "#it{p}_{T} (GeV/c)"}; + AxisSpec rapidityAxis = {nRapidityBins, -rapidityCut, rapidityCut, "y"}; AxisSpec massAxisXi = {200, 1.222f, 1.422f, "Inv. Mass (GeV/c^{2})"}; AxisSpec massAxisOmega = {200, 1.572f, 1.772f, "Inv. Mass (GeV/c^{2})"}; @@ -195,6 +214,10 @@ struct cascadeAnalysisMC { registry.add("h2dMassXiPlus", "h2dMassXiPlus", {HistType::kTH2F, {ptAxis, massAxisXi}}); registry.add("h2dMassOmegaMinus", "h2dMassOmegaMinus", {HistType::kTH2F, {ptAxis, massAxisOmega}}); registry.add("h2dMassOmegaPlus", "h2dMassOmegaPlus", {HistType::kTH2F, {ptAxis, massAxisOmega}}); + registry.add("hPtYMassXiMinus", "hPtYMassXiMinus", {HistType::kTH3F, {ptAxis, rapidityAxis, massAxisXi}}); + registry.add("hPtYMassXiPlus", "hPtYMassXiPlus", {HistType::kTH3F, {ptAxis, rapidityAxis, massAxisXi}}); + registry.add("hPtYMassOmegaMinus", "hPtYMassOmegaMinus", {HistType::kTH3F, {ptAxis, rapidityAxis, massAxisOmega}}); + registry.add("hPtYMassOmegaPlus", "hPtYMassOmegaPlus", {HistType::kTH3F, {ptAxis, rapidityAxis, massAxisOmega}}); } // Selection criteria @@ -347,14 +370,16 @@ struct cascadeAnalysisMC { TMath::Abs(casc.mLambda() - 1.115683) < cascadesetting_v0masswindow) { registry.fill(HIST("hCandidateCounter"), 3.5); // pass cascade selections if (casc.sign() < 0) { // FIXME: could be done better... - if (TMath::Abs(casc.yXi()) < 0.5 && lCompatiblePID_Xi && ((!assocMC) || (lPDG == 3312))) { + if (TMath::Abs(casc.yXi()) < rapidityCut && lCompatiblePID_Xi && ((!assocMC) || (lPDG == 3312))) { + registry.fill(HIST("hPtYMassXiMinus"), casc.pt(), casc.yXi(), casc.mXi()); if (!doCentralityStudy) { registry.fill(HIST("h2dMassXiMinus"), casc.pt(), casc.mXi()); } else { registry.fill(HIST("h3dMassXiMinus"), lPercentile, casc.pt(), casc.mXi()); } } - if (TMath::Abs(casc.yOmega()) < 0.5 && lCompatiblePID_Om && ((!assocMC) || (lPDG == 3334))) { + if (TMath::Abs(casc.yOmega()) < rapidityCut && lCompatiblePID_Om && ((!assocMC) || (lPDG == 3334))) { + registry.fill(HIST("hPtYMassOmegaMinus"), casc.pt(), casc.yOmega(), casc.mOmega()); if (!doCentralityStudy) { registry.fill(HIST("h2dMassOmegaMinus"), casc.pt(), casc.mOmega()); } else { @@ -362,14 +387,16 @@ struct cascadeAnalysisMC { } } } else { - if (TMath::Abs(casc.yXi()) < 0.5 && lCompatiblePID_Xi && ((!assocMC) || (lPDG == -3312))) { + if (TMath::Abs(casc.yXi()) < rapidityCut && lCompatiblePID_Xi && ((!assocMC) || (lPDG == -3312))) { + registry.fill(HIST("hPtYMassXiPlus"), casc.pt(), casc.yXi(), casc.mXi()); if (!doCentralityStudy) { registry.fill(HIST("h2dMassXiPlus"), casc.pt(), casc.mXi()); } else { registry.fill(HIST("h3dMassXiPlus"), lPercentile, casc.pt(), casc.mXi()); } } - if (TMath::Abs(casc.yOmega()) < 0.5 && lCompatiblePID_Om && ((!assocMC) || (lPDG == -3334))) { + if (TMath::Abs(casc.yOmega()) < rapidityCut && lCompatiblePID_Om && ((!assocMC) || (lPDG == -3334))) { + registry.fill(HIST("hPtYMassOmegaPlus"), casc.pt(), casc.yOmega(), casc.mOmega()); if (!doCentralityStudy) { registry.fill(HIST("h2dMassOmegaPlus"), casc.pt(), casc.mOmega()); } else { diff --git a/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx b/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx index 152ca106846..c9ff1f74f88 100644 --- a/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx +++ b/PWGLF/Tasks/Strangeness/cascadecorrelations.cxx @@ -34,7 +34,10 @@ #include "Common/DataModel/Centrality.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponse.h" +#include "CCDB/BasicCCDBManager.h" + #include +#include #include #include #include @@ -263,16 +266,50 @@ struct cascadeSelector { }; // struct struct cascadeCorrelations { + Service ccdb; Configurable zVertexCut{"zVertexCut", 10, "Cut on PV position"}; + Configurable nMixedEvents{"nMixedEvents", 10, "Number of events to be mixed"}; + Configurable doEfficiencyCorrection{"doEfficiencyCorrection", true, "flag to do efficiency corrections"}; + Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "CCDB url"}; + Configurable efficiencyCCDBPath{"efficiencyCCDBPath", "Users/r/rspijker/test/EffTest", "Path of the efficiency corrections"}; AxisSpec invMassAxis = {2000, 1.0f, 3.0f, "Inv. Mass (GeV/c^{2})"}; AxisSpec deltaPhiAxis = {100, -PI / 2, 1.5 * PI, "#Delta#varphi"}; - AxisSpec deltaEtaAxis = {40, -2, 2, "#Delta#eta"}; + AxisSpec deltaYAxis = {40, -2, 2, "#Delta y"}; // TODO: narrower range? AxisSpec ptAxis = {200, 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, -2, 2, "y"}; + + // initialize efficiency maps + TH1D* hEffXiMin; + TH1D* hEffXiPlus; + TH1D* hEffOmegaMin; + TH1D* hEffOmegaPlus; + + void init(InitContext const&) + { + ccdb->setURL(ccdburl); + ccdb->setCaching(true); + if (doEfficiencyCorrection) { + TList* effList = ccdb->getForTimeStamp(efficiencyCCDBPath, 1); + if (!effList) { + LOGF(fatal, "null ptr in efficiency list!"); + } + hEffXiMin = static_cast(effList->FindObject("hXiMinEff")); + hEffXiPlus = static_cast(effList->FindObject("hXiPlusEff")); + hEffOmegaMin = static_cast(effList->FindObject("hOmegaMinEff")); + hEffOmegaPlus = static_cast(effList->FindObject("hOmegaPlusEff")); + } + } + + 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)); + } HistogramRegistry registry{ "registry", @@ -282,6 +319,9 @@ struct cascadeCorrelations { {"hMassXiPlus", "hMassXiPlus", {HistType::kTH2F, {invMassAxis, ptAxis}}}, {"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}, // basic selection variables {"hV0Radius", "hV0Radius", {HistType::kTH1F, {{1000, 0.0f, 100.0f, "cm"}}}}, @@ -301,34 +341,37 @@ struct cascadeCorrelations { {"hAutoCorrelationOS", "hAutoCorrelationOS", {HistType::kTH1I, {{2, -1.f, 1.f, "Charge of OS autocorrelated track"}}}}, {"hPhi", "hPhi", {HistType::kTH1F, {{100, 0, 2 * PI, "#varphi"}}}}, {"hEta", "hEta", {HistType::kTH1F, {{100, -2, 2, "#eta"}}}}, + {"hRapidityXi", "hRapidityXi", {HistType::kTH1F, {rapidityAxis}}}, + {"hRapidityOmega", "hRapidityOmega", {HistType::kTH1F, {rapidityAxis}}}, // correlation histos {"hDeltaPhiSS", "hDeltaPhiSS", {HistType::kTH1F, {deltaPhiAxis}}}, {"hDeltaPhiOS", "hDeltaPhiOS", {HistType::kTH1F, {deltaPhiAxis}}}, - // THnSparses containing all relevant dimensions, to be extended with e.g. multiplicity - // TODO: maybe use a seperate table/tree for this? - {"hXiXiOS", "hXiXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hXiXiSS", "hXiXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hXiOmOS", "hXiOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hXiOmSS", "hXiOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hOmXiOS", "hOmXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hOmXiSS", "hOmXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hOmOmOS", "hOmOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"hOmOmSS", "hOmOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - - // ad hoc mixed events + + {"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}, + + // Mixed events {"MixedEvents/hMEVz1", "hMEVz1", {HistType::kTH1F, {vertexAxis}}}, {"MixedEvents/hMEVz2", "hMEVz2", {HistType::kTH1F, {vertexAxis}}}, {"MixedEvents/hMEDeltaPhiSS", "hMEDeltaPhiSS", {HistType::kTH1F, {deltaPhiAxis}}}, {"MixedEvents/hMEDeltaPhiOS", "hMEDeltaPhiOS", {HistType::kTH1F, {deltaPhiAxis}}}, - {"MixedEvents/hMEXiXiOS", "hMEXiXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEXiXiSS", "hMEXiXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEXiOmOS", "hMEXiOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEXiOmSS", "hMEXiOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEOmXiOS", "hMEOmXiOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEOmXiSS", "hMEOmXiSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEOmOmOS", "hMEOmOmOS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, - {"MixedEvents/hMEOmOmSS", "hMEOmOmSS", {HistType::kTHnSparseF, {deltaPhiAxis, deltaEtaAxis, ptAxis, ptAxis, invMassAxis, invMassAxis, selectionFlagAxis, selectionFlagAxis, vertexAxis, multiplicityAxis}}}, + {"MixedEvents/hMEQA", "hMEQA", {HistType::kTH1I, {{2, 0, 2, "QA for exceptions in ME (this histogram should have 0 entries!)"}}}}, + + {"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}, }, }; @@ -345,7 +388,7 @@ struct cascadeCorrelations { using BinningType = ColumnBinningPolicy>; BinningType colBinning{{axisVtxZ, axisMult}, true}; // true is for 'ignore overflows' (true by default). Underflows and overflows will have bin -1. // Preslice collisionSliceCascades = aod::CascDataExtSelected::collisionId; - SameKindPair pair{colBinning, 5, -1, &cache}; + SameKindPair pair{colBinning, nMixedEvents, -1, &cache}; void processSameEvent(myCollisions::iterator const& collision, myCascades const& Cascades, aod::V0sLinked const&, aod::V0Datas const&, FullTracksExtIU const&) { @@ -353,21 +396,30 @@ struct cascadeCorrelations { return; } + double weight; // Some QA on the cascades for (auto& 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()); } else { registry.fill(HIST("hMassXiPlus"), casc.mXi(), casc.pt()); + weight = 1. / getEfficiency(hEffXiPlus, casc.pt()); } + registry.fill(HIST("hMassXiEffCorrected"), casc.mXi(), 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()); } else { registry.fill(HIST("hMassOmegaPlus"), casc.mOmega(), casc.pt()); + weight = 1. / getEfficiency(hEffOmegaPlus, casc.pt()); } + registry.fill(HIST("hMassOmegaEffCorrected"), casc.mOmega(), casc.pt(), casc.yOmega(), collision.posZ(), collision.multFT0M(), weight); + registry.fill(HIST("hRapidityOmega"), casc.yOmega()); } registry.fill(HIST("hV0Radius"), casc.v0radius()); registry.fill(HIST("hCascRadius"), casc.cascradius()); @@ -404,7 +456,6 @@ struct cascadeCorrelations { int negIdAssoc = assoc.negTrackId(); // calculate angular correlations - double deta = trigger.eta() - assoc.eta(); double dphi = RecoDecay::constrainAngle(trigger.phi() - assoc.phi(), -0.5 * PI); double invMassXiTrigg = trigger.mXi(); @@ -412,9 +463,10 @@ struct cascadeCorrelations { double invMassXiAssoc = assoc.mXi(); double invMassOmAssoc = assoc.mOmega(); - double weight = 1.; // Will be changed by Efficiency-correction + double weightTrigg = 1.; + double weightAssoc = 1.; - // Fill the correct histograms based on same-sign or opposite-sign + // 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) { @@ -441,12 +493,36 @@ struct cascadeCorrelations { continue; } } - registry.fill(HIST("hDeltaPhiOS"), dphi); - registry.fill(HIST("hXiXiOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hXiOmOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hOmXiOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hOmOmOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); + // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) + if (trigger.isSelected() <= 2) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } + if (trigger.isSelected() >= 2) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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) { @@ -482,10 +558,35 @@ struct cascadeCorrelations { } } registry.fill(HIST("hDeltaPhiSS"), dphi); - registry.fill(HIST("hXiXiSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hXiOmSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hOmXiSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); - registry.fill(HIST("hOmOmSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), collision.posZ(), collision.multFT0M(), weight); + // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) + if (trigger.isSelected() <= 2) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } + if (trigger.isSelected() >= 2) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } } } // correlations } // process same event @@ -500,6 +601,10 @@ struct cascadeCorrelations { continue; if (TMath::Abs(col1.posZ()) > zVertexCut || TMath::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()); @@ -514,7 +619,11 @@ struct cascadeCorrelations { auto trigger = *triggerAddress; auto assoc = *assocAddress; - double deta = trigger.eta() - assoc.eta(); + if (trigger.collisionId() == assoc.collisionId()) { + registry.fill(HIST("hMEQA"), 1.5); + continue; + } + double dphi = RecoDecay::constrainAngle(trigger.phi() - assoc.phi(), -0.5 * PI); double invMassXiTrigg = trigger.mXi(); @@ -522,21 +631,140 @@ struct cascadeCorrelations { double invMassXiAssoc = assoc.mXi(); double invMassOmAssoc = assoc.mOmega(); - double weight = 1.; // Will be changed by Efficiency-correction + // 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("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("MixedEvents/hMEDeltaPhiOS"), dphi); - registry.fill(HIST("MixedEvents/hMEXiXiOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEXiOmOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEOmXiOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEOmOmOS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); + + // Fill the different THnSparses depending on PID logic (important for rapidity & inv mass information) + if (trigger.isSelected() <= 2) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } + if (trigger.isSelected() >= 2) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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("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; + } + 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("MixedEvents/hMEDeltaPhiSS"), dphi); - registry.fill(HIST("MixedEvents/hMEXiXiSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEXiOmSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassXiTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEOmXiSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassXiAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - registry.fill(HIST("MixedEvents/hMEOmOmSS"), dphi, deta, trigger.pt(), assoc.pt(), invMassOmTrigg, invMassOmAssoc, trigger.isSelected(), assoc.isSelected(), col1.posZ(), col1.multFT0M(), weight); - } + + if (trigger.isSelected() <= 2) { // trigger Xi + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffXiMin, trigger.pt()) : 1. / getEfficiency(hEffXiPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } + if (trigger.isSelected() >= 2) { // trigger Omega + if (doEfficiencyCorrection) + weightTrigg = trigger.sign() < 0 ? 1. / getEfficiency(hEffOmegaMin, trigger.pt()) : 1. / getEfficiency(hEffOmegaPlus, trigger.pt()); + if (assoc.isSelected() <= 2) { // 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) { // 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); + } + } + } // same sign } // correlations } // collisions } // process mixed events diff --git a/PWGLF/Tasks/Strangeness/cascpostprocessing.cxx b/PWGLF/Tasks/Strangeness/cascpostprocessing.cxx index c51eaaa7725..d92e48733b5 100644 --- a/PWGLF/Tasks/Strangeness/cascpostprocessing.cxx +++ b/PWGLF/Tasks/Strangeness/cascpostprocessing.cxx @@ -158,8 +158,8 @@ struct cascpostprocessing { registry.add("hPt", "hPt", {HistType::kTH1F, {ptAxis}}); registry.add("hCascMinusInvMassvsPt", "hCascMinusInvMassvsPt", HistType::kTH2F, {ptAxis, massAxis}); registry.add("hCascPlusInvMassvsPt", "hCascPlusInvMassvsPt", HistType::kTH2F, {ptAxis, massAxis}); - registry.add("hCascMinusInvMassvsPt_FT0M", "hCascMinusInvMassvsPt_FT0M", HistType::kTH3F, {isMC ? nChargedFT0MGenAxis : centFT0MAxis, ptAxis, massAxis}); - registry.add("hCascPlusInvMassvsPt_FT0M", "hCascPlusInvMassvsPt_FT0M", HistType::kTH3F, {isMC ? nChargedFT0MGenAxis : centFT0MAxis, ptAxis, massAxis}); + registry.add("hCascMinusInvMassvsPt_FT0M", "hCascMinusInvMassvsPt_FT0M", HistType::kTH3F, {centFT0MAxis, ptAxis, massAxis}); + registry.add("hCascPlusInvMassvsPt_FT0M", "hCascPlusInvMassvsPt_FT0M", HistType::kTH3F, {centFT0MAxis, ptAxis, massAxis}); registry.add("hCascMinusInvMassvsPt_FV0A", "hCascMinusInvMassvsPt_FV0A", HistType::kTH3F, {centFV0AAxis, ptAxis, massAxis}); registry.add("hCascPlusInvMassvsPt_FV0A", "hCascPlusInvMassvsPt_FV0A", HistType::kTH3F, {centFV0AAxis, ptAxis, massAxis}); registry.add("hXiMinusInvMassvsPt_BefSels", "hXiMinusInvMassvsPt_BefSels", HistType::kTH2F, {ptAxis, ximassAxis}); @@ -213,22 +213,22 @@ struct cascpostprocessing { registry.add("hCascMinusEtaBach", "hCascMinusEtaBach", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); // Info for eff x acc from MC - registry.add("hPtCascPlusTrueRec", "hPtCascPlusTrueRec", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtCascMinusTrueRec", "hPtCascMinusTrueRec", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); + registry.add("hPtCascPlusTrueRec", "hPtCascPlusTrueRec", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtCascMinusTrueRec", "hPtCascMinusTrueRec", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); - registry.add("hCascMinusMassvsPtTrueRec", "hCascMinusMassvsPtTrueRec", {HistType::kTH2F, {ptAxis, massAxis}}); - registry.add("hCascPlusMassvsPtTrueRec", "hCascPlusMassvsPtTrueRec", {HistType::kTH2F, {ptAxis, massAxis}}); + registry.add("hCascMinusMassvsPtTrueRec", "hCascMinusMassvsPtTrueRec", {HistType::kTH3F, {ptAxis, massAxis, centFT0MAxis}}); + registry.add("hCascPlusMassvsPtTrueRec", "hCascPlusMassvsPtTrueRec", {HistType::kTH3F, {ptAxis, massAxis, centFT0MAxis}}); registry.add("hCascMinusMassvsPtBG", "hCascMinusMassvsPtBG", {HistType::kTH2F, {ptAxis, massAxis}}); registry.add("hCascPlusMassvsPtBG", "hCascPlusMassvsPtBG", {HistType::kTH2F, {ptAxis, massAxis}}); if (isMC) { - registry.add("hPtXiPlusTrue", "hPtXiPlusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtXiMinusTrue", "hPtXiMinusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtOmegaPlusTrue", "hPtOmegaPlusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtOmegaMinusTrue", "hPtOmegaMinusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtXiPlusTrueAssocWithSelColl", "hPtXiPlusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtXiMinusTrueAssocWithSelColl", "hPtXiMinusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtOmegaPlusTrueAssocWithSelColl", "hPtOmegaPlusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); - registry.add("hPtOmegaMinusTrueAssocWithSelColl", "hPtOmegaMinusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, nChargedFT0MGenAxis}}); + registry.add("hPtXiPlusTrue", "hPtXiPlusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtXiMinusTrue", "hPtXiMinusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtOmegaPlusTrue", "hPtOmegaPlusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtOmegaMinusTrue", "hPtOmegaMinusTrue", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtXiPlusTrueAssocWithSelColl", "hPtXiPlusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtXiMinusTrueAssocWithSelColl", "hPtXiMinusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtOmegaPlusTrueAssocWithSelColl", "hPtOmegaPlusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); + registry.add("hPtOmegaMinusTrueAssocWithSelColl", "hPtOmegaMinusTrueAssocWithSelColl", {HistType::kTH3F, {ptAxis, rapidityAxis, centFT0MAxis}}); } } @@ -488,25 +488,25 @@ struct cascpostprocessing { if (candidate.sign() < 0) { if (isCorrectlyRec) { - registry.fill(HIST("hPtCascMinusTrueRec"), candidate.pt(), rapidity, candidate.multFT0M()); // 3rd axis is N charged in FT0M region from gen. MC - registry.fill(HIST("hCascMinusMassvsPtTrueRec"), candidate.pt(), invmass); + registry.fill(HIST("hPtCascMinusTrueRec"), candidate.pt(), rapidity, candidate.centFT0M()); // 3rd axis is from MC calibration + registry.fill(HIST("hCascMinusMassvsPtTrueRec"), candidate.pt(), invmass, candidate.centFT0M()); } else { registry.fill(HIST("hCascMinusMassvsPtBG"), candidate.pt(), invmass); } registry.fill(HIST("hCascMinusInvMassvsPt"), candidate.pt(), invmass); - registry.fill(HIST("hCascMinusInvMassvsPt_FT0M"), candidate.multFT0M(), candidate.pt(), invmass); - registry.fill(HIST("hCascMinusInvMassvsPt_FV0A"), isMC ? 0 : candidate.multFV0A(), candidate.pt(), invmass); + registry.fill(HIST("hCascMinusInvMassvsPt_FT0M"), candidate.centFT0M(), candidate.pt(), invmass); + registry.fill(HIST("hCascMinusInvMassvsPt_FV0A"), candidate.centFV0A(), candidate.pt(), invmass); } if (candidate.sign() > 0) { if (isCorrectlyRec) { - registry.fill(HIST("hPtCascPlusTrueRec"), candidate.pt(), rapidity, candidate.multFT0M()); // 3rd axis is N charged in FT0M region from gen. MC - registry.fill(HIST("hCascPlusMassvsPtTrueRec"), candidate.pt(), invmass); + registry.fill(HIST("hPtCascPlusTrueRec"), candidate.pt(), rapidity, candidate.centFT0M()); // 3rd axis is from MC calibration + registry.fill(HIST("hCascPlusMassvsPtTrueRec"), candidate.pt(), invmass, candidate.centFT0M()); } else { registry.fill(HIST("hCascPlusMassvsPtBG"), candidate.pt(), invmass); } registry.fill(HIST("hCascPlusInvMassvsPt"), candidate.pt(), invmass); - registry.fill(HIST("hCascPlusInvMassvsPt_FT0M"), candidate.multFT0M(), candidate.pt(), invmass); - registry.fill(HIST("hCascPlusInvMassvsPt_FV0A"), isMC ? 0 : candidate.multFV0A(), candidate.pt(), invmass); + registry.fill(HIST("hCascPlusInvMassvsPt_FT0M"), candidate.centFT0M(), candidate.pt(), invmass); + registry.fill(HIST("hCascPlusInvMassvsPt_FV0A"), candidate.centFV0A(), candidate.pt(), invmass); } } } @@ -545,16 +545,16 @@ struct cascpostprocessing { // Histos of generated cascades from generated events with accepted z vrtx + chosen event type (evSelFlag) (for signal loss correction) if (genCascade.pdgCode() == -3312) { - registry.fill(HIST("hPtXiPlusTrue"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtXiPlusTrue"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == 3312) { - registry.fill(HIST("hPtXiMinusTrue"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtXiMinusTrue"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == -3334) { - registry.fill(HIST("hPtOmegaPlusTrue"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtOmegaPlusTrue"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == 3334) { - registry.fill(HIST("hPtOmegaMinusTrue"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtOmegaMinusTrue"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } // Histos of generated cascades from generated events with good z vrtx + chosen event type (evSelFlag) + associated to the accepted reconstructed event of the same type (for signal loss + efficiency x acceptance correction) @@ -580,16 +580,16 @@ struct cascpostprocessing { } if (genCascade.pdgCode() == -3312) { - registry.fill(HIST("hPtXiPlusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtXiPlusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == 3312) { - registry.fill(HIST("hPtXiMinusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtXiMinusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == -3334) { - registry.fill(HIST("hPtOmegaPlusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtOmegaPlusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } if (genCascade.pdgCode() == 3334) { - registry.fill(HIST("hPtOmegaMinusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.nChInFT0M()); + registry.fill(HIST("hPtOmegaMinusTrueAssocWithSelColl"), genCascade.pt(), genCascade.y(), genCascade.centFT0M()); } } } diff --git a/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx index 012da260c95..824266cdd5e 100644 --- a/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedcascadeanalysis.cxx @@ -29,6 +29,19 @@ #include "Common/DataModel/PIDResponse.h" #include "Framework/StaticFor.h" +#include "Framework/ConfigParamSpec.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/CCDB/TriggerAliases.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/LHCConstants.h" +#include "Framework/HistogramRegistry.h" +#include "DataFormatsFT0/Digit.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "ITSMFTBase/DPLAlpideParam.h" +#include "MetadataHelper.h" +#include "DataFormatsParameters/AggregatedRunInfo.h" + #include #include #include @@ -45,151 +58,179 @@ using namespace o2::framework; using namespace o2::framework::expressions; using std::array; +using dauTracks = soa::Join; +using cascMCCandidates = soa::Join; + struct derivedCascadeAnalysis { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - Configurable zVertexCut{"zVertexCut", 10, "Cut on PV position"}; - 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 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 axis"}; - + 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, 25000.0f}, "occupancy axis"}; + ConfigurableAxis axisOccupancyFt0{"axisOccupancyFt0", {VARIABLE_WIDTH, 0.0f, 2500.0f, 5000.0f, 7500.0f, 10000.0f, 15000.0f, 20000.0f, 30000.0f, 45000.0f, 60000.0f, 80000.0f, 100000.0f, 250000.0f}, "occupancy axis for the FT0 definition"}; + 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 axisXiMass{"axisXiMass", {200, 1.222f, 1.422f}, ""}; - ConfigurableAxis axisOmegaMass{"axisOmegaMass", {200, 1.572f, 1.772f}, ""}; + ConfigurableAxis axisMass{"axisMass", {200, 1.222f, 1.422f}, "range of invariant mass, in case of omega take 1.572f, 1.772f"}; Configurable isXi{"isXi", 1, "Apply cuts for Xi identification"}; - Configurable isMC{"isMC", false, "MC data are processed"}; - Configurable doBefSelCheck{"doBefSelCheck", false, "Fill mass histograms of all candidates before selections"}; - Configurable doPtDepCutStudy{"doPtDepCutStudy", false, "Fill histogram with a cutting paramer"}; - 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"}; - Configurable doVertexTOFmatch{"doVertexTOFmatch", false, "Checks wherher at least one of vertex contributors is matched to TOF"}; - Configurable doVertexTRDmatch{"doVertexTRDmatch", false, "Checks wherher at least one of vertex contributors is matched to TRD"}; - Configurable doBefSelEventMultCorr{"doBefSelEventMultCorr", false, "Enable histogram of multiplicity correlation before cuts"}; - Configurable doTFeventCut{"doTFeventCut", false, "Enable TF event Cut"}; - Configurable doITSFrameBorderCut{"doITSFrameBorderCut", false, "Enable ITSFrame event cut"}; - Configurable doMultiplicityCorrCut{"doMultiplicityCorrCut", false, "Enable multiplicity vs centrality correlation cut"}; - Configurable doOccupancyCheck{"doOccupancyCheck", true, ""}; - Configurable doTimeRangeStandardCut{"doTimeRangeStandardCut", true, "It rejects a given collision if there are other events nearby in |dt|< 10 μs"}; - + 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 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 masswin{"masswin", 0.05, "Mass window limit"}; - Configurable lambdaMassWin{"lambdaMassWin", 0.005, "V0 Mass window limit"}; - Configurable rapCut{"rapCut", 0.5, "Rapidity acceptance"}; - Configurable etaDauCut{"etaDauCut", 0.8, "Pseudorapidity acceptance of the cascade daughters"}; - 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.04, "DCA Bach To PV"}; - Configurable casccospa{"casccospa", 0.97, "Casc CosPA"}; - Configurable v0cospa{"v0cospa", 0.97, "V0 CosPA"}; - Configurable dcacascdau{"dcacascdau", 1., "DCA Casc Daughters"}; - Configurable dcav0dau{"dcav0dau", 1.5, "DCA V0 Daughters"}; - Configurable dcaV0ToPV{"dcaV0ToPV", 0.06, "DCA V0 To PV"}; - Configurable minRadius{"minRadius", 1.4f, "minRadius"}; - Configurable maxRadius{"maxRadius", 100.0f, "maxRadius"}; - Configurable minV0Radius{"minV0Radius", 1.2f, "V0 transverse decay radius, minimum"}; - Configurable maxV0Radius{"maxV0Radius", 100.0f, "V0 transverse decay radius, maximum"}; - Configurable nsigmatpcPi{"nsigmatpcPi", 5, "N sigma TPC Pion"}; - Configurable nsigmatpcPr{"nsigmatpcPr", 5, "N sigma TPC Proton"}; - Configurable nsigmatpcKa{"nsigmatpcKa", 5, "N sigma TPC Kaon"}; - Configurable nsigmatofPr{"nsigmatofPr", 3, "N sigma TOF Proton"}; - Configurable nsigmatofPion{"nsigmatofPion", 3, "N sigma TOF for Pion from V0"}; - Configurable nsigmatofBachPion{"nsigmatofBachPion", 3, "N sigma TOF for bachelor Pion"}; - Configurable nsigmatofBachKaon{"nsigmatofBachKaon", 3, "N sigma TOF for bachelor Kaon"}; - Configurable bachBaryonCosPA{"bachBaryonCosPA", 0.9999, "Bachelor baryon CosPA"}; - Configurable bachBaryonDCAxyToPV{"bachBaryonDCAxyToPV", 0.08, "DCA bachelor baryon to PV"}; - Configurable mintpccrrows{"mintpccrrows", 50, "min N TPC crossed rows"}; - Configurable dooobrej{"dooobrej", 0, "OOB rejection: 0 no selection, 1 = ITS||TOF, 2 = TOF only for pT > ptthrtof"}; - Configurable ptthrtof{"ptthrtof", 2, "Pt threshold for applying only tof oob rejection"}; - Configurable proplifetime{"proplifetime", 3, "ctau/"}; - Configurable rejcomp{"rejcomp", 0.008, "Competing Cascade rejection"}; - - Configurable doPtDepCosPaCut{"doPtDepCosPaCut", false, "Enable pt dependent cos PA cut"}; - Configurable doPtDepCascRadiusCut{"doPtDepCascRadiusCut", false, "Enable pt dependent cascade radius cut"}; - 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 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"}; - Configurable doDCAV0DauCut{"doDCAV0DauCut", true, "Enable cut DCA betweenn V0 daughter tracks"}; - Configurable doCascadeRadiusCut{"doCascadeRadiusCut", true, "Enable cut on the cascade radius"}; - Configurable doV0RadiusCut{"doV0RadiusCut", true, "Enable cut on the V0 radius"}; - Configurable doDCAV0ToPVCut{"doDCAV0ToPVCut", true, "Enable cut DCA of V0 to PV"}; - Configurable doNTPCSigmaCut{"doNTPCSigmaCut", false, "Enable cut N sigma TPC"}; - Configurable doBachelorBaryonCut{"doBachelorBaryonCut", true, "Enable Bachelor-Baryon cut "}; - Configurable doProperLifeTimeCut{"doProperLifeTimeCut", true, "Enable proper life-time cut "}; - Configurable doNTOFSigmaProtonCut{"doNTOFSigmaProtonCut", true, "Enable n sigma TOF PID cut for proton from V0"}; - 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 doFillNsigmaTPCHistPionBach{"doFillNsigmaTPCHistPionBach", false, ""}; - Configurable doFillNsigmaTPCHistKaonBach{"doFillNsigmaTPCHistKaonBach", false, ""}; - Configurable doFillNsigmaTPCHistProton{"doFillNsigmaTPCHistProton", false, ""}; - Configurable doFillNsigmaTPCHistV0Pion{"doFillNsigmaTPCHistV0Pion", false, ""}; Configurable nPtBinsForNsigmaTPC{"nPtBinsForNsigmaTPC", 100, ""}; - Configurable cosPApar0{"cosPApar0", 0.2, "const par for pt dep cosPA cut"}; - Configurable cosPApar1{"cosPApar1", -0.022, "linear par for pt dep cosPA cut"}; - - Configurable parCascRadius0{"parCascRadius0", 1.216159, "const par for pt dep radius cut"}; - Configurable parCascRadius1{"parCascRadius1", 0.064462, "linear par for pt dep radius cut"}; - - Configurable parV0Radius0{"parV0Radius0", 2.136381, "const par for pt dep V0 radius cut"}; - Configurable parV0Radius1{"parV0Radius1", 0.437074, "linear par for pt dep V0 radius cut"}; - - 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"}; + struct : ConfigurableGroup { + std::string prefix = "qa"; + Configurable doFillNsigmaTPCHistPionBach{"doFillNsigmaTPCHistPionBach", false, ""}; + Configurable doFillNsigmaTPCHistKaonBach{"doFillNsigmaTPCHistKaonBach", false, ""}; + Configurable doFillNsigmaTPCHistProton{"doFillNsigmaTPCHistProton", false, ""}; + Configurable doFillNsigmaTPCHistV0Pion{"doFillNsigmaTPCHistV0Pion", false, ""}; + Configurable doBefSelCheck{"doBefSelCheck", false, "Fill mass histograms of all candidates before selections"}; + 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, ""}; + } qaFlags; + + struct : ConfigurableGroup { + std::string prefix = "evSelection"; + 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"}; + Configurable doVertexTOFmatch{"doVertexTOFmatch", false, "Checks wherher at least one of vertex contributors is matched to TOF"}; + 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 zVertexCut{"zVertexCut", 10, "Cut on PV position"}; + } eventSelectionFlags; + + struct : ConfigurableGroup { + std::string prefix = "candidateSelFlag"; + Configurable doPtDepCosPaCut{"doPtDepCosPaCut", false, "Enable pt dependent cos PA cut"}; + Configurable doPtDepCascRadiusCut{"doPtDepCascRadiusCut", false, "Enable pt dependent cascade radius cut"}; + 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 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"}; + Configurable doDCAV0DauCut{"doDCAV0DauCut", true, "Enable cut DCA betweenn V0 daughter tracks"}; + Configurable doCascadeRadiusCut{"doCascadeRadiusCut", true, "Enable cut on the cascade radius"}; + Configurable doV0RadiusCut{"doV0RadiusCut", true, "Enable cut on the V0 radius"}; + Configurable doDCAV0ToPVCut{"doDCAV0ToPVCut", true, "Enable cut DCA of V0 to PV"}; + Configurable doNTPCSigmaCut{"doNTPCSigmaCut", false, "Enable cut N sigma TPC"}; + Configurable doBachelorBaryonCut{"doBachelorBaryonCut", true, "Enable Bachelor-Baryon cut "}; + Configurable doProperLifeTimeCut{"doProperLifeTimeCut", true, "Enable proper life-time cut "}; + Configurable doNTOFSigmaProtonCut{"doNTOFSigmaProtonCut", true, "Enable n sigma TOF PID cut for proton from V0"}; + 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"}; + } candidateSelectionFlags; + + struct : ConfigurableGroup { + std::string prefix = "candidateSelection"; + 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.04, "DCA Bach To PV"}; + Configurable casccospa{"casccospa", 0.97, "Casc CosPA"}; + Configurable v0cospa{"v0cospa", 0.97, "V0 CosPA"}; + Configurable dcacascdau{"dcacascdau", 1., "DCA Casc Daughters"}; + Configurable dcav0dau{"dcav0dau", 1.5, "DCA V0 Daughters"}; + Configurable dcaV0ToPV{"dcaV0ToPV", 0.06, "DCA V0 To PV"}; + Configurable minRadius{"minRadius", 1.4f, "minRadius"}; + Configurable maxRadius{"maxRadius", 100.0f, "maxRadius"}; + Configurable minV0Radius{"minV0Radius", 1.2f, "V0 transverse decay radius, minimum"}; + Configurable maxV0Radius{"maxV0Radius", 100.0f, "V0 transverse decay radius, maximum"}; + Configurable nsigmatpcPi{"nsigmatpcPi", 5, "N sigma TPC Pion"}; + Configurable nsigmatpcPr{"nsigmatpcPr", 5, "N sigma TPC Proton"}; + Configurable nsigmatpcKa{"nsigmatpcKa", 5, "N sigma TPC Kaon"}; + Configurable nsigmatofPr{"nsigmatofPr", 3, "N sigma TOF Proton"}; + Configurable nsigmatofPion{"nsigmatofPion", 3, "N sigma TOF for Pion from V0"}; + Configurable nsigmatofBachPion{"nsigmatofBachPion", 3, "N sigma TOF for bachelor Pion"}; + Configurable nsigmatofBachKaon{"nsigmatofBachKaon", 3, "N sigma TOF for bachelor Kaon"}; + Configurable bachBaryonCosPA{"bachBaryonCosPA", 0.9999, "Bachelor baryon CosPA"}; + Configurable bachBaryonDCAxyToPV{"bachBaryonDCAxyToPV", 0.08, "DCA bachelor baryon to PV"}; + Configurable mintpccrrows{"mintpccrrows", 70, "min N TPC crossed rows"}; + Configurable cosPApar0{"cosPApar0", 0.2, "const par for pt dep cosPA cut"}; + Configurable cosPApar1{"cosPApar1", -0.022, "linear par for pt dep cosPA cut"}; + Configurable parCascRadius0{"parCascRadius0", 1.216159, "const par for pt dep radius cut"}; + Configurable parCascRadius1{"parCascRadius1", 0.064462, "linear par for pt dep radius cut"}; + Configurable parV0Radius0{"parV0Radius0", 2.136381, "const par for pt dep V0 radius cut"}; + Configurable parV0Radius1{"parV0Radius1", 0.437074, "linear par for pt dep V0 radius cut"}; + 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 lambdaMassWin{"lambdaMassWin", 0.005, "V0 Mass window limit"}; + Configurable proplifetime{"proplifetime", 3, "ctau/"}; + Configurable ptthrtof{"ptthrtof", 2, "Pt threshold for applying only tof oob rejection"}; + Configurable rejcomp{"rejcomp", 0.008, "Competing Cascade rejection"}; + 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"}; + } candidateSelectionValues; Service pdgDB; static constexpr std::string_view Index[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; static constexpr float centralityIntervals[11] = {0., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90.}; + static constexpr std::string_view charge[] = {"Positive", "Negative"}; + static constexpr std::string_view selectionNames[] = {"BachelorBaryonDCA", "DCAV0ToPV", "V0Radius", "CascadeRadius", "DCAV0Daughters", "DCACascDaughters", "V0pa", "CascPA", "DCABachelorToPV", "DCAMesonToPV", "DCABaryonToPV", "CascadeProperLifeTime"}; + + // For manual sliceBy + // Preslice> perMcCollision = aod::v0data::straMCCollisionId; + PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; void init(InitContext const&) { histos.add("hEventVertexZ", "hEventVertexZ", kTH1F, {vertexZ}); histos.add("hEventCentrality", "hEventCentrality", kTH1F, {{101, 0, 101}}); - histos.add("hEventSelection", "hEventSelection", kTH1F, {{13, 0, 13}}); - histos.add("hOccupancyVsCentrality", "", kTH2F, {axisOccupancy, {100, 0, 100}}); + histos.add("hEventSelection", "hEventSelection", kTH1F, {{21, 0, 21}}); + histos.add("hOccupancyVsOccupFt0VsCentrality", "", kTH3F, {axisOccupancy, axisOccupancyFt0, {100, 0, 100}}); 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}}); - if (doBefSelEventMultCorr) { + if (qaFlags.doBefSelEventMultCorr) { histos.add("hEventNchCorrelationBefCuts", "hEventNchCorrelationBefCuts", kTH2F, {{5000, 0, 5000}, {2500, 0, 2500}}); histos.add("hEventPVcontributorsVsCentralityBefCuts", "hEventPVcontributorsVsCentralityBefCuts", kTH2F, {{100, 0, 100}, {5000, 0, 5000}}); histos.add("hEventGlobalTracksVsCentralityBefCuts", "hEventGlobalTracksVsCentralityBefCuts", kTH2F, {{100, 0, 100}, {2500, 0, 2500}}); } histos.add("hCandidate", "hCandidate", HistType::kTH1D, {{22, -0.5, 21.5}}); - histos.add("hCutValue", "hCutValue", HistType::kTH2D, {{22, -0.5, 21.5}, {300, 0, 3.01}}); + histos.add("hCutValue", "hCutValue", HistType::kTH2D, {{22, -0.5, 21.5}, {300, 0, 3.1}}); - if (doFillNsigmaTPCHistProton) { + if (qaFlags.doFillNsigmaTPCHistProton) { histos.add("hNsigmaProton", "hNsigmaProton", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 6}, {100, 0, 100}}); histos.add("hNsigmaProtonNeg", "hNsigmaProtonNeg", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 6}, {100, 0, 100}}); } - if (doFillNsigmaTPCHistV0Pion) { + if (qaFlags.doFillNsigmaTPCHistV0Pion) { histos.add("hNsigmaPionNeg", "hNsigmaPionNeg", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 2}, {100, 0, 100}}); histos.add("hNsigmaPionPos", "hNsigmaPionPos", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 2}, {100, 0, 100}}); } - if (doFillNsigmaTPCHistPionBach) { + if (qaFlags.doFillNsigmaTPCHistPionBach) { histos.add("hNsigmaPionPosBach", "hNsigmaPionPosBach", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 2}, {100, 0, 100}}); histos.add("hNsigmaPionNegBach", "hNsigmaPionNegBach", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 2}, {100, 0, 100}}); } - if (doFillNsigmaTPCHistKaonBach) + if (qaFlags.doFillNsigmaTPCHistKaonBach) histos.add("hNsigmaKaon", "hNsigmaKaon", HistType::kTH3D, {{280, -7, 7}, {nPtBinsForNsigmaTPC, 0, 6}, {100, 0, 100}}); - if (doNTOFSigmaProtonCut) + if (candidateSelectionFlags.doNTOFSigmaProtonCut) histos.add("hNsigmaTOFProton", "", HistType::kTH3D, {{70, -7, 7}, {100, 0, 10}, {100, 0, 100}}); - if (doNTOFSigmaV0PionCut) + if (candidateSelectionFlags.doNTOFSigmaV0PionCut) histos.add("hNsigmaTOFV0Pion", "", HistType::kTH3D, {{70, -7, 7}, {100, 0, 10}, {100, 0, 100}}); - if (doNTOFSigmaBachelorCut) { + if (candidateSelectionFlags.doNTOFSigmaBachelorCut) { if (isXi) histos.add("hNsigmaTOFBachelorPion", "", HistType::kTH3D, {{70, -7, 7}, {100, 0, 10}, {100, 0, 100}}); else @@ -202,12 +243,16 @@ struct derivedCascadeAnalysis { histos.get(HIST("hCutValue"))->GetXaxis()->SetBinLabel(i, CutLabel[i - 1]); } - histos.add("InvMassAfterSel/hNegativeCascade", "hNegativeCascade", HistType::kTH3F, {axisPt, axisXiMass, {101, 0, 101}}); - histos.add("InvMassAfterSel/hPositiveCascade", "hPositiveCascade", {HistType::kTH3F, {axisPt, axisXiMass, {101, 0, 101}}}); + histos.add("InvMassAfterSel/hNegativeCascade", "hNegativeCascade", HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}); + histos.add("InvMassAfterSel/hPositiveCascade", "hPositiveCascade", {HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}}); - if (doOccupancyCheck) { - histos.add("InvMassAfterSelCent1/hNegativeCascade", "hNegativeCascade", HistType::kTH3F, {axisPt, axisXiMass, axisOccupancy}); - histos.add("InvMassAfterSelCent1/hPositiveCascade", "hPositiveCascade", HistType::kTH3F, {axisPt, axisXiMass, axisOccupancy}); + 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) { + histos.add("InvMassAfterSelCent1/hNegativeCascadeMCTruth", "hNegativeCascadeMCTruth", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); + histos.add("InvMassAfterSelCent1/hPositiveCascadeMCTruth", "hPositiveCascadeMCTruth", HistType::kTH3F, {axisPt, axisMass, axisOccupancy}); + } histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent2/"); histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent3/"); histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent4/"); @@ -219,118 +264,88 @@ struct derivedCascadeAnalysis { histos.addClone("InvMassAfterSelCent1/", "InvMassAfterSelCent10/"); } - if (!isXi) { - histos.get(HIST("InvMassAfterSel/hNegativeCascade"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("InvMassAfterSel/hPositiveCascade"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } - - if (doBefSelCheck) + if (qaFlags.doBefSelCheck) histos.addClone("InvMassAfterSel/", "InvMassBefSel/"); - if (isMC) + if (doprocessCascadesMCrec) histos.addClone("InvMassAfterSel/", "InvMassAfterSelMCrecTruth/"); - if (doPtDepCutStudy && !doProperLifeTimeCut) { - histos.add("PtDepCutStudy/hNegativeCascadeProperLifeTime", "hNegativeCascadeProperLifeTime", HistType::kTH3F, {axisPt, axisXiMass, {100, 0, 10}}); - histos.add("PtDepCutStudy/hPositiveCascadeProperLifeTime", "hPositiveCascadeProperLifeTime", {HistType::kTH3F, {axisPt, axisXiMass, {100, 0, 10}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeCascadeProperLifeTime"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveCascadeProperLifeTime"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doProperLifeTimeCut) { + histos.add("PtDepCutStudy/hNegativeCascadeProperLifeTime", "hNegativeCascadeProperLifeTime", HistType::kTH3F, {axisPt, axisMass, {100, 0, 10}}); + histos.add("PtDepCutStudy/hPositiveCascadeProperLifeTime", "hPositiveCascadeProperLifeTime", {HistType::kTH3F, {axisPt, axisMass, {100, 0, 10}}}); } - if (doPtDepCutStudy && !doBachelorBaryonCut) { - histos.add("PtDepCutStudy/hNegativeBachelorBaryonDCA", "hNegativeBachelorBaryonDCA", HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 1}}); - histos.add("PtDepCutStudy/hPositiveBachelorBaryonDCA", "hPositiveBachelorBaryonDCA", {HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 1}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeBachelorBaryonDCA"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveBachelorBaryonDCA"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doBachelorBaryonCut) { + histos.add("PtDepCutStudy/hNegativeBachelorBaryonDCA", "hNegativeBachelorBaryonDCA", HistType::kTH3F, {axisPt, axisMass, {40, 0, 1}}); + histos.add("PtDepCutStudy/hPositiveBachelorBaryonDCA", "hPositiveBachelorBaryonDCA", {HistType::kTH3F, {axisPt, axisMass, {40, 0, 1}}}); } - if (doPtDepCutStudy && !doDCAV0ToPVCut) { - histos.add("PtDepCutStudy/hNegativeDCAV0ToPV", "hNegativeDCAV0ToPV", HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 1}}); - histos.add("PtDepCutStudy/hPositiveDCAV0ToPV", "hPositiveDCAV0ToPV", {HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 1}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeDCAV0ToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveDCAV0ToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAV0ToPVCut) { + histos.add("PtDepCutStudy/hNegativeDCAV0ToPV", "hNegativeDCAV0ToPV", HistType::kTH3F, {axisPt, axisMass, {40, 0, 1}}); + histos.add("PtDepCutStudy/hPositiveDCAV0ToPV", "hPositiveDCAV0ToPV", {HistType::kTH3F, {axisPt, axisMass, {40, 0, 1}}}); } - if (doPtDepCutStudy && !doV0RadiusCut) { - histos.add("PtDepCutStudy/hNegativeV0Radius", "hNegativeV0Radius", HistType::kTH3F, {axisPt, axisXiMass, {20, 0, 10}}); - histos.add("PtDepCutStudy/hPositiveV0Radius", "hPositiveV0Radius", {HistType::kTH3F, {axisPt, axisXiMass, {20, 0, 10}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeV0Radius"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveV0Radius"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doV0RadiusCut) { + histos.add("PtDepCutStudy/hNegativeV0Radius", "hNegativeV0Radius", HistType::kTH3F, {axisPt, axisMass, {20, 0, 10}}); + histos.add("PtDepCutStudy/hPositiveV0Radius", "hPositiveV0Radius", {HistType::kTH3F, {axisPt, axisMass, {20, 0, 10}}}); } - if (doPtDepCutStudy && !doCascadeRadiusCut) { - histos.add("PtDepCutStudy/hNegativeCascadeRadius", "hNegativeCascadeRadius", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 5}}); - histos.add("PtDepCutStudy/hPositiveCascadeRadius", "hPositiveCascadeRadius", {HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 5}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeCascadeRadius"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveCascadeRadius"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doCascadeRadiusCut) { + histos.add("PtDepCutStudy/hNegativeCascadeRadius", "hNegativeCascadeRadius", HistType::kTH3F, {axisPt, axisMass, {50, 0, 5}}); + histos.add("PtDepCutStudy/hPositiveCascadeRadius", "hPositiveCascadeRadius", {HistType::kTH3F, {axisPt, axisMass, {50, 0, 5}}}); } - if (doPtDepCutStudy && !doDCAV0DauCut) { - histos.add("PtDepCutStudy/hNegativeDCAV0Daughters", "hNegativeDCAV0Daughters", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 5}}); - histos.add("PtDepCutStudy/hPositiveDCAV0Daughters", "hPositiveDCAV0Daughters", {HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 5}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeDCAV0Daughters"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveDCAV0Daughters"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAV0DauCut) { + histos.add("PtDepCutStudy/hNegativeDCAV0Daughters", "hNegativeDCAV0Daughters", HistType::kTH3F, {axisPt, axisMass, {50, 0, 5}}); + histos.add("PtDepCutStudy/hPositiveDCAV0Daughters", "hPositiveDCAV0Daughters", {HistType::kTH3F, {axisPt, axisMass, {50, 0, 5}}}); } - if (doPtDepCutStudy && !doDCACascadeDauCut) { - histos.add("PtDepCutStudy/hNegativeDCACascDaughters", "hNegativeDCACascDaughters", {HistType::kTH3F, {axisPt, axisXiMass, {20, 0, 1}}}); - histos.add("PtDepCutStudy/hPositiveDCACascDaughters", "hPositiveDCACascDaughters", {HistType::kTH3F, {axisPt, axisXiMass, {20, 0, 1}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hPositiveDCACascDaughters"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hNegativeDCACascDaughters"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCACascadeDauCut) { + histos.add("PtDepCutStudy/hNegativeDCACascDaughters", "hNegativeDCACascDaughters", {HistType::kTH3F, {axisPt, axisMass, {20, 0, 1}}}); + histos.add("PtDepCutStudy/hPositiveDCACascDaughters", "hPositiveDCACascDaughters", {HistType::kTH3F, {axisPt, axisMass, {20, 0, 1}}}); } - if (doPtDepCutStudy && !doV0CosPaCut) { - histos.add("PtDepCutStudy/hNegativeV0pa", "hNegativeV0pa", HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 0.4}}); - histos.add("PtDepCutStudy/hPositiveV0pa", "hPositiveV0pa", {HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 0.4}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeV0pa"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveV0pa"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doV0CosPaCut) { + 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 (doPtDepCutStudy && !doDCAdauToPVCut) { - histos.add("PtDepCutStudy/hNegativeDCABachelorToPV", "hNegativeDCABachelorToPV", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hNegativeDCABaryonToPV", "hNegativeDCABaryonToPV", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hNegativeDCAMesonToPV", "hNegativeDCAMesonToPV", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hPositiveDCABachelorToPV", "hPositiveDCABachelorToPV", {HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}}); - histos.add("PtDepCutStudy/hPositiveDCABaryonToPV", "hPositiveDCABaryonToPV", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}); - histos.add("PtDepCutStudy/hPositiveDCAMesonToPV", "hPositiveDCAMesonToPV", HistType::kTH3F, {axisPt, axisXiMass, {50, 0, 0.5}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeDCABachelorToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hNegativeDCABaryonToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hNegativeDCAMesonToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveDCABachelorToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveDCABaryonToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveDCAMesonToPV"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + if (qaFlags.doPtDepCutStudy && !candidateSelectionFlags.doDCAdauToPVCut) { + 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}}); + histos.add("PtDepCutStudy/hPositiveDCAMesonToPV", "hPositiveDCAMesonToPV", HistType::kTH3F, {axisPt, axisMass, {50, 0, 0.5}}); } - if (doPtDepCutStudy && !doCascadeCosPaCut) { - histos.add("PtDepCutStudy/hNegativeCascPA", "hNegativeCascPA", HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 0.4}}); - histos.add("PtDepCutStudy/hPositiveCascPA", "hPositiveCascPA", {HistType::kTH3F, {axisPt, axisXiMass, {40, 0, 0.4}}}); - if (!isXi) { - histos.get(HIST("PtDepCutStudy/hNegativeCascPA"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("PtDepCutStudy/hPositiveCascPA"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + 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 (isMC) { + if (doprocessCascadesMCrec) { histos.addClone("PtDepCutStudy/", "PtDepCutStudyMCTruth/"); - histos.add("hNegativeCascadePtForEfficiency", "hNegativeCascadePtForEfficiency", HistType::kTH3F, {axisPt, axisXiMass, {101, 0, 101}}); - histos.add("hPositiveCascadePtForEfficiency", "hPositiveCascadePtForEfficiency", {HistType::kTH3F, {axisPt, axisXiMass, {101, 0, 101}}}); - if (!isXi) { - histos.get(HIST("hNegativeCascadePtForEfficiency"))->GetYaxis()->Set(200, 1.572f, 1.772f); - histos.get(HIST("hPositiveCascadePtForEfficiency"))->GetYaxis()->Set(200, 1.572f, 1.772f); - } + histos.add("hNegativeCascadePtForEfficiency", "hNegativeCascadePtForEfficiency", HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}); + histos.add("hPositiveCascadePtForEfficiency", "hPositiveCascadePtForEfficiency", {HistType::kTH3F, {axisPt, axisMass, {101, 0, 101}}}); + } + + if (doprocessCascadesMCforEff) { + histos.add("hGenEvents", "", HistType::kTH2F, {{axisNch}, {2, 0, 2}}); + histos.add("hCentralityVsMultMC", "", kTH2F, {{101, 0.0f, 101.0f}, axisNch}); + + 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("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}); } } template @@ -340,183 +355,228 @@ struct derivedCascadeAnalysis { if (ptdepcut) { double ptdepCut; if (isCascPa) - ptdepCut = cosPApar0 + cosPApar1 * casc.pt(); + ptdepCut = candidateSelectionValues.cosPApar0 + candidateSelectionValues.cosPApar1 * casc.pt(); else - ptdepCut = cosPApar0 + cosPApar1 * casc.pt(); + ptdepCut = candidateSelectionValues.cosPApar0 + candidateSelectionValues.cosPApar1 * casc.pt(); if (ptdepCut > 0.3 && casc.pt() < 0.5) ptdepCut = 0.3; if (ptdepCut < 0.012) ptdepCut = 0.012; if (isCascPa) - histos.fill(HIST("hCutValue"), 16, TMath::Cos(ptdepCut)); + histos.fill(HIST("hCutValue"), 15, TMath::Cos(ptdepCut)); if (!isCascPa) - histos.fill(HIST("hCutValue"), 12, TMath::Cos(ptdepCut)); + histos.fill(HIST("hCutValue"), 11, TMath::Cos(ptdepCut)); if (isCascPa && casc.casccosPA(x, y, z) < TMath::Cos(ptdepCut)) return false; if (!isCascPa && casc.v0cosPA(x, y, z) < TMath::Cos(ptdepCut)) return false; } else { - float cut = casccospa; - float cutV0 = v0cospa; + float cut = candidateSelectionValues.casccospa; + float cutV0 = candidateSelectionValues.v0cospa; if (isCascPa) - histos.fill(HIST("hCutValue"), 16, cut); + histos.fill(HIST("hCutValue"), 15, cut); if (!isCascPa) - histos.fill(HIST("hCutValue"), 12, cutV0); - if (isCascPa && casc.casccosPA(x, y, z) < casccospa) + histos.fill(HIST("hCutValue"), 11, cutV0); + if (isCascPa && casc.casccosPA(x, y, z) < candidateSelectionValues.casccospa) return false; - if (!isCascPa && casc.v0cosPA(x, y, z) < v0cospa) + if (!isCascPa && casc.v0cosPA(x, y, z) < candidateSelectionValues.v0cospa) return false; } return true; } + template - bool IsEventAccepted(TCollision coll, bool sel) + bool IsEventAccepted(TCollision coll, bool fillHists) { - histos.fill(HIST("hEventSelection"), 0.5 /* all collisions */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 0.5 /* all collisions */); - if (doBefSelEventMultCorr) { + if (qaFlags.doBefSelEventMultCorr) { histos.fill(HIST("hEventNchCorrelationBefCuts"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); histos.fill(HIST("hEventPVcontributorsVsCentralityBefCuts"), coll.centFT0C(), coll.multNTracksPVeta1()); histos.fill(HIST("hEventGlobalTracksVsCentralityBefCuts"), coll.centFT0C(), coll.multNTracksGlobal()); } - if (isMC) { - if (!coll.selection_bit(aod::evsel::kIsTriggerTVX)) { - return false; - } - histos.fill(HIST("hEventSelection"), 1.5 /* MB trigger*/); - if (TMath::Abs(coll.posZ()) > zVertexCut) { - return false; - } + if (eventSelectionFlags.doTriggerTVXEventCut && !coll.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 1.5 /* collisions after sel*/); - histos.fill(HIST("hEventSelection"), 2.5 /* collisions after sel pvz sel*/); + if (eventSelectionFlags.doTriggerSel8EventCut && !coll.sel8()) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 2.5 /* collisions after sel*/); - if (doTFeventCut && !coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return false; - } - histos.fill(HIST("hEventSelection"), 3.5 /* Not at TF border */); - if (doITSFrameBorderCut && !coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return false; - } - histos.fill(HIST("hEventSelection"), 4.5 /* Not at ITS ROF border */); - } else { - if (!sel) { - return false; - } - histos.fill(HIST("hEventSelection"), 1.5 /* collisions after sel*/); - if (TMath::Abs(coll.posZ()) > zVertexCut) { - return false; - } + if (TMath::Abs(coll.posZ()) > eventSelectionFlags.zVertexCut) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 3.5 /* collisions after sel pvz sel*/); - histos.fill(HIST("hEventSelection"), 2.5 /* collisions after sel pvz sel*/); + if (coll.centFT0C() > centMax || coll.centFT0C() < centMin) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 4.5 /* collisions after centrality sel*/); - if (coll.centFT0C() > centMax || coll.centFT0C() < centMin) { - return false; - } + 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 */); - histos.fill(HIST("hEventSelection"), 3.5 /* collisions after centrality sel*/); + 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 (doSameBunchPileUpEventCut && !coll.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return false; - } - histos.fill(HIST("hEventSelection"), 4.5 /* Not same Bunch pile up */); + 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 (doGoodPVFT0EventCut && !coll.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return false; - } - histos.fill(HIST("hEventSelection"), 5.5 /* No large vertexZ difference from tracks and FT0*/); + 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 (doITSTPCvertexEventCut && !coll.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return false; - } - histos.fill(HIST("hEventSelection"), 6.5 /* At least one ITS-TPC track in the event*/); + 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 (doVertexTOFmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return false; - } - histos.fill(HIST("hEventSelection"), 7.5 /* At least one of vertex contributors is matched to TOF*/); + 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 (doVertexTRDmatch && !coll.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return false; - } - histos.fill(HIST("hEventSelection"), 8.5 /* At least one of vertex contributors is matched to TRD*/); + 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 (doITSFrameBorderCut && !coll.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + if (eventSelectionFlags.doMultiplicityCorrCut) { + if (coll.multNTracksGlobal() < (1343.3 * TMath::Exp(-0.0443259 * coll.centFT0C()) - 50) || coll.multNTracksGlobal() > (2098.9 * TMath::Exp(-0.0332444 * coll.centFT0C()))) return false; - } - histos.fill(HIST("hEventSelection"), 9.5 /* Not at ITS ROF border */); - - if (doTFeventCut && !coll.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + if (coll.multNTracksPVeta1() < (3703 * TMath::Exp(-0.0455483 * coll.centFT0C()) - 150) || coll.multNTracksPVeta1() > (4937.33 * TMath::Exp(-0.0372668 * coll.centFT0C()) + 20)) return false; - } - histos.fill(HIST("hEventSelection"), 10.5 /* Not at TF border */); - - if (doMultiplicityCorrCut) { - if (coll.multNTracksGlobal() < (1343.3 * TMath::Exp(-0.0443259 * coll.centFT0C()) - 50) || coll.multNTracksGlobal() > (2098.9 * TMath::Exp(-0.0332444 * coll.centFT0C()))) - return false; - if (coll.multNTracksPVeta1() < (3703 * TMath::Exp(-0.0455483 * coll.centFT0C()) - 150) || coll.multNTracksPVeta1() > (4937.33 * TMath::Exp(-0.0372668 * coll.centFT0C()) + 20)) - return false; - } - histos.fill(HIST("hEventSelection"), 11.5 /* Remove outlyers */); } + if (fillHists) + histos.fill(HIST("hEventSelection"), 12.5 /* Remove outlyers */); - if (doTimeRangeStandardCut && !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + 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 */); - histos.fill(HIST("hEventSelection"), 12.5 /* Rejection of events too close in time */); + 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 */); int occupancy = coll.trackOccupancyInTimeRange(); - histos.fill(HIST("hOccupancyVsCentrality"), occupancy, coll.centFT0C()); - histos.fill(HIST("hEventCentrality"), coll.centFT0C()); - histos.fill(HIST("hEventVertexZ"), coll.posZ()); - histos.fill(HIST("hEventNchCorrelationAfCuts"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); - histos.fill(HIST("hEventPVcontributorsVsCentrality"), coll.centFT0C(), coll.multNTracksPVeta1()); - histos.fill(HIST("hEventGlobalTracksVsCentrality"), coll.centFT0C(), coll.multNTracksGlobal()); + 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 (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 (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*/); + + 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*/); + + 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 (fillHists) { + histos.fill(HIST("hOccupancyVsOccupFt0VsCentrality"), occupancy, occupancyFT0, coll.centFT0C()); + histos.fill(HIST("hEventCentrality"), coll.centFT0C()); + histos.fill(HIST("hEventVertexZ"), coll.posZ()); + histos.fill(HIST("hEventNchCorrelationAfCuts"), coll.multNTracksPVeta1(), coll.multNTracksGlobal()); + histos.fill(HIST("hEventPVcontributorsVsCentrality"), coll.centFT0C(), coll.multNTracksPVeta1()); + histos.fill(HIST("hEventGlobalTracksVsCentrality"), coll.centFT0C(), coll.multNTracksGlobal()); + } + return true; } template bool IsCascadeCandidateAccepted(TCascade casc, int counter, float /*centrality*/) { - float cut = masswin; + float cut = candidateSelectionValues.masswin; + histos.fill(HIST("hCutValue"), 1, cut); + cut = candidateSelectionValues.rapCut; histos.fill(HIST("hCutValue"), 2, cut); - cut = rapCut; - histos.fill(HIST("hCutValue"), 3, cut); if (isXi) { - if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > masswin) { + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > candidateSelectionValues.masswin) { return false; } histos.fill(HIST("hCandidate"), ++counter); - if (TMath::Abs(casc.yXi()) > rapCut) + if (TMath::Abs(casc.yXi()) > candidateSelectionValues.rapCut) return false; histos.fill(HIST("hCandidate"), ++counter); } else { - if (TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) > masswin) { + if (TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) > candidateSelectionValues.masswin) { return false; } histos.fill(HIST("hCandidate"), ++counter); - if (TMath::Abs(casc.yOmega()) > rapCut) + if (TMath::Abs(casc.yOmega()) > candidateSelectionValues.rapCut) return false; histos.fill(HIST("hCandidate"), ++counter); } - if (doDCACascadeDauCut) { - if (doPtDepDCAcascDauCut) { - float ptDepCut = dcaCacsDauPar0; + if (candidateSelectionFlags.doDCACascadeDauCut) { + if (candidateSelectionFlags.doPtDepDCAcascDauCut) { + float ptDepCut = candidateSelectionValues.dcaCacsDauPar0; if (casc.pt() > 1 && casc.pt() < 4) - ptDepCut = dcaCacsDauPar1; + ptDepCut = candidateSelectionValues.dcaCacsDauPar1; else if (casc.pt() > 4) - ptDepCut = dcaCacsDauPar2; - histos.fill(HIST("hCutValue"), 4, ptDepCut); + ptDepCut = candidateSelectionValues.dcaCacsDauPar2; + histos.fill(HIST("hCutValue"), 3, ptDepCut); if (casc.dcacascdaughters() > ptDepCut) return false; } else { - cut = dcacascdau; - histos.fill(HIST("hCutValue"), 4, cut); - if (casc.dcacascdaughters() > dcacascdau) + cut = candidateSelectionValues.dcacascdau; + histos.fill(HIST("hCutValue"), 3, cut); + if (casc.dcacascdaughters() > candidateSelectionValues.dcacascdau) return false; } histos.fill(HIST("hCandidate"), ++counter); @@ -524,67 +584,67 @@ struct derivedCascadeAnalysis { ++counter; } - if (doDCAV0DauCut) { - cut = dcav0dau; - histos.fill(HIST("hCutValue"), 5, cut); - if (casc.dcaV0daughters() > dcav0dau) + if (candidateSelectionFlags.doDCAV0DauCut) { + cut = candidateSelectionValues.dcav0dau; + histos.fill(HIST("hCutValue"), 4, cut); + if (casc.dcaV0daughters() > candidateSelectionValues.dcav0dau) return false; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (doCascadeRadiusCut) { - if (doPtDepCascRadiusCut) { - double ptdepminRadius = parCascRadius0 + parCascRadius1 * casc.pt(); - histos.fill(HIST("hCutValue"), 6, ptdepminRadius); + if (candidateSelectionFlags.doCascadeRadiusCut) { + if (candidateSelectionFlags.doPtDepCascRadiusCut) { + double ptdepminRadius = candidateSelectionValues.parCascRadius0 + candidateSelectionValues.parCascRadius1 * casc.pt(); + histos.fill(HIST("hCutValue"), 5, ptdepminRadius); if (casc.cascradius() < ptdepminRadius) return false; } else { - cut = minRadius; - histos.fill(HIST("hCutValue"), 6, cut); - if (casc.cascradius() < minRadius) + cut = candidateSelectionValues.minRadius; + histos.fill(HIST("hCutValue"), 5, cut); + if (casc.cascradius() < candidateSelectionValues.minRadius) return false; } histos.fill(HIST("hCandidate"), ++counter); - if (casc.cascradius() > maxRadius) + if (casc.cascradius() > candidateSelectionValues.maxRadius) return false; histos.fill(HIST("hCandidate"), ++counter); } else { counter += 2; } - if (doV0RadiusCut) { - if (doPtDepV0RadiusCut) { - float cut = parV0Radius0 + casc.pt() * parV0Radius1; - histos.fill(HIST("hCutValue"), 8, cut); + if (candidateSelectionFlags.doV0RadiusCut) { + if (candidateSelectionFlags.doPtDepV0RadiusCut) { + float cut = candidateSelectionValues.parV0Radius0 + casc.pt() * candidateSelectionValues.parV0Radius1; + histos.fill(HIST("hCutValue"), 7, cut); if (casc.v0radius() < cut) return false; } else { - cut = minV0Radius; - histos.fill(HIST("hCutValue"), 8, cut); - if (casc.v0radius() < minV0Radius) + cut = candidateSelectionValues.minV0Radius; + histos.fill(HIST("hCutValue"), 7, cut); + if (casc.v0radius() < candidateSelectionValues.minV0Radius) return false; } histos.fill(HIST("hCandidate"), ++counter); - if (casc.v0radius() > maxV0Radius) + if (casc.v0radius() > candidateSelectionValues.maxV0Radius) return false; histos.fill(HIST("hCandidate"), ++counter); } else { counter += 2; } - cut = lambdaMassWin; - histos.fill(HIST("hCutValue"), 10, cut); - if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > lambdaMassWin) + cut = candidateSelectionValues.lambdaMassWin; + histos.fill(HIST("hCutValue"), 9, cut); + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > candidateSelectionValues.lambdaMassWin) return false; histos.fill(HIST("hCandidate"), ++counter); - cut = bachBaryonDCAxyToPV; - histos.fill(HIST("hCutValue"), 11, cut); - if (doBachelorBaryonCut) { - if ((casc.bachBaryonCosPA() > bachBaryonCosPA || TMath::Abs(casc.bachBaryonDCAxyToPV()) < bachBaryonDCAxyToPV)) { // Bach-baryon selection if required + cut = candidateSelectionValues.bachBaryonDCAxyToPV; + histos.fill(HIST("hCutValue"), 10, cut); + if (candidateSelectionFlags.doBachelorBaryonCut) { + if ((casc.bachBaryonCosPA() > candidateSelectionValues.bachBaryonCosPA || TMath::Abs(casc.bachBaryonDCAxyToPV()) < candidateSelectionValues.bachBaryonDCAxyToPV)) { // Bach-baryon selection if required return false; } histos.fill(HIST("hCandidate"), ++counter); @@ -592,38 +652,38 @@ struct derivedCascadeAnalysis { ++counter; } - if (doV0CosPaCut) { - if (!IsCosPAAccepted(casc, casc.x(), casc.y(), casc.z(), doPtDepV0CosPaCut, false)) + if (candidateSelectionFlags.doV0CosPaCut) { + if (!IsCosPAAccepted(casc, casc.x(), casc.y(), casc.z(), candidateSelectionFlags.doPtDepV0CosPaCut, false)) return false; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - cut = rejcomp; - histos.fill(HIST("hCutValue"), 13, cut); + cut = candidateSelectionValues.rejcomp; + histos.fill(HIST("hCutValue"), 12, cut); if (isXi) { - if (TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) < rejcomp) + if (TMath::Abs(casc.mOmega() - pdgDB->Mass(3334)) < candidateSelectionValues.rejcomp) return false; histos.fill(HIST("hCandidate"), ++counter); } else { - if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) < rejcomp) + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) < candidateSelectionValues.rejcomp) return false; histos.fill(HIST("hCandidate"), ++counter); } - cut = dcaBachToPV; - histos.fill(HIST("hCutValue"), 14, cut); - cut = dcaMesonToPV; - histos.fill(HIST("hCutValue"), 14, cut); - cut = dcaBaryonToPV; - histos.fill(HIST("hCutValue"), 14, cut); - if (doDCAdauToPVCut) { - if (TMath::Abs(casc.dcabachtopv()) < dcaBachToPV) + cut = candidateSelectionValues.dcaBachToPV; + histos.fill(HIST("hCutValue"), 13, cut); + cut = candidateSelectionValues.dcaMesonToPV; + histos.fill(HIST("hCutValue"), 13, cut); + cut = candidateSelectionValues.dcaBaryonToPV; + histos.fill(HIST("hCutValue"), 13, cut); + if (candidateSelectionFlags.doDCAdauToPVCut) { + if (TMath::Abs(casc.dcabachtopv()) < candidateSelectionValues.dcaBachToPV) return false; - if (casc.sign() > 0 && (TMath::Abs(casc.dcanegtopv()) < dcaBaryonToPV || TMath::Abs(casc.dcapostopv()) < dcaMesonToPV)) + if (casc.sign() > 0 && (TMath::Abs(casc.dcanegtopv()) < candidateSelectionValues.dcaBaryonToPV || TMath::Abs(casc.dcapostopv()) < candidateSelectionValues.dcaMesonToPV)) return false; - if (casc.sign() < 0 && (TMath::Abs(casc.dcapostopv()) < dcaBaryonToPV || TMath::Abs(casc.dcanegtopv()) < dcaMesonToPV)) + if (casc.sign() < 0 && (TMath::Abs(casc.dcapostopv()) < candidateSelectionValues.dcaBaryonToPV || TMath::Abs(casc.dcanegtopv()) < candidateSelectionValues.dcaMesonToPV)) return false; histos.fill(HIST("hCandidate"), ++counter); } else { @@ -633,10 +693,10 @@ struct derivedCascadeAnalysis { return true; } - void processCascades(soa::Join::iterator const& coll, soa::Join const& Cascades, soa::Join const&) + void processCascades(soa::Join::iterator const& coll, soa::Join const& Cascades, soa::Join const&) { - if (!IsEventAccepted(coll, coll.sel8())) + if (!IsEventAccepted(coll, true)) return; for (auto& casc : Cascades) { @@ -644,17 +704,27 @@ struct derivedCascadeAnalysis { 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; + double invmass; if (isXi) invmass = casc.mXi(); else invmass = casc.mOmega(); // To have trace of how it was before selections - if (casc.sign() < 0 && doBefSelCheck) { - histos.fill(HIST("InvMassBefSel/hNegativeCascade"), casc.pt(), invmass, coll.centFT0C()); - } - if (casc.sign() > 0 && doBefSelCheck) { - histos.fill(HIST("InvMassBefSel/hPositiveCascade"), casc.pt(), invmass, coll.centFT0C()); + + if (qaFlags.doBefSelCheck) { + if (isPositive) + histos.fill(HIST("InvMassBefSel/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), invmass, coll.centFT0C()); + if (isNegative) + histos.fill(HIST("InvMassBefSel/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), invmass, coll.centFT0C()); } if (!IsCascadeCandidateAccepted(casc, counter, coll.centFT0C())) @@ -673,24 +743,24 @@ struct derivedCascadeAnalysis { auto fullmomentumNegDaugh = TMath::Sqrt(TMath::Power(casc.pxneg(), 2) + TMath::Power(casc.pyneg(), 2) + TMath::Power(casc.pzneg(), 2)); auto fullmomentumBachelor = TMath::Sqrt(TMath::Power(casc.pxbach(), 2) + TMath::Power(casc.pybach(), 2) + TMath::Power(casc.pzbach(), 2)); - float cut = etaDauCut; + float cut = candidateSelectionValues.etaDauCut; histos.fill(HIST("hCutValue"), counter + 1, cut); - if (TMath::Abs(poseta) > etaDauCut || TMath::Abs(negeta) > etaDauCut || TMath::Abs(bacheta) > etaDauCut) + if (TMath::Abs(poseta) > candidateSelectionValues.etaDauCut || TMath::Abs(negeta) > candidateSelectionValues.etaDauCut || TMath::Abs(bacheta) > candidateSelectionValues.etaDauCut) continue; histos.fill(HIST("hCandidate"), ++counter); - if (doCascadeCosPaCut) { - if (!IsCosPAAccepted(casc, coll.posX(), coll.posY(), coll.posZ(), doPtDepCosPaCut, true)) + if (candidateSelectionFlags.doCascadeCosPaCut) { + if (!IsCosPAAccepted(casc, coll.posX(), coll.posY(), coll.posZ(), candidateSelectionFlags.doPtDepCosPaCut, true)) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - cut = dcaV0ToPV; - histos.fill(HIST("hCutValue"), 17, cut); - if (doDCAV0ToPVCut) { - if (TMath::Abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < dcaV0ToPV) + cut = candidateSelectionValues.dcaV0ToPV; + histos.fill(HIST("hCutValue"), 16, cut); + if (candidateSelectionFlags.doDCAV0ToPVCut) { + if (TMath::Abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < candidateSelectionValues.dcaV0ToPV) continue; histos.fill(HIST("hCandidate"), ++counter); } else { @@ -698,37 +768,37 @@ struct derivedCascadeAnalysis { } if (casc.sign() < 0) { - if (doFillNsigmaTPCHistProton) + if (qaFlags.doFillNsigmaTPCHistProton) histos.fill(HIST("hNsigmaProton"), posExtra.tpcNSigmaPr(), fullMomentumPosDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistV0Pion) + if (qaFlags.doFillNsigmaTPCHistV0Pion) histos.fill(HIST("hNsigmaPionNeg"), negExtra.tpcNSigmaPi(), fullmomentumNegDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) histos.fill(HIST("hNsigmaPionNegBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && !isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); } else if (casc.sign() > 0) { - if (doFillNsigmaTPCHistV0Pion) + if (qaFlags.doFillNsigmaTPCHistV0Pion) histos.fill(HIST("hNsigmaPionPos"), posExtra.tpcNSigmaPi(), fullMomentumPosDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistProton) + if (qaFlags.doFillNsigmaTPCHistProton) histos.fill(HIST("hNsigmaProtonNeg"), negExtra.tpcNSigmaPr(), fullmomentumNegDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) histos.fill(HIST("hNsigmaPionPosBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && !isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); } if (casc.sign() < 0) { - if (doNTPCSigmaCut) { - if (TMath::Abs(posExtra.tpcNSigmaPr()) > nsigmatpcPr || TMath::Abs(negExtra.tpcNSigmaPi()) > nsigmatpcPi) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(posExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr || TMath::Abs(negExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } } else if (casc.sign() > 0) { - if (doNTPCSigmaCut) { - if (TMath::Abs(posExtra.tpcNSigmaPi()) > nsigmatpcPi || TMath::Abs(negExtra.tpcNSigmaPr()) > nsigmatpcPr) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(posExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi || TMath::Abs(negExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr) continue; histos.fill(HIST("hCandidate"), ++counter); } else { @@ -736,18 +806,18 @@ struct derivedCascadeAnalysis { } } - if (posExtra.tpcCrossedRows() < mintpccrrows || negExtra.tpcCrossedRows() < mintpccrrows || bachExtra.tpcCrossedRows() < mintpccrrows) + if (posExtra.tpcCrossedRows() < candidateSelectionValues.mintpccrrows || negExtra.tpcCrossedRows() < candidateSelectionValues.mintpccrrows || 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 (dooobrej == 1) { + if (candidateSelectionFlags.dooobrej == 1) { if (!kHasTOF && !kHasITS) continue; histos.fill(HIST("hCandidate"), ++counter); - } else if (dooobrej == 2) { - if (!kHasTOF && (casc.pt() > ptthrtof)) + } else if (candidateSelectionFlags.dooobrej == 2) { + if (!kHasTOF && (casc.pt() > candidateSelectionValues.ptthrtof)) continue; histos.fill(HIST("hCandidate"), ++counter); } else { @@ -759,178 +829,200 @@ struct derivedCascadeAnalysis { float ctau = -10; cut = ctau; - histos.fill(HIST("hCutValue"), 22, cut); + histos.fill(HIST("hCutValue"), 21, cut); if (posExtra.hasTOF()) { - if (doNTOFSigmaProtonCut && casc.sign() < 0) { + if (candidateSelectionFlags.doNTOFSigmaProtonCut && casc.sign() < 0) { histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullMomentumPosDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPr()) > nsigmatofPr && fullMomentumPosDaugh > 0.6) + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullMomentumPosDaugh > 0.6) continue; } - if (doNTOFSigmaV0PionCut && casc.sign() > 0) { + if (candidateSelectionFlags.doNTOFSigmaV0PionCut && casc.sign() > 0) { histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullMomentumPosDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPi()) > nsigmatofPion) + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) continue; } } if (negExtra.hasTOF()) { - if (doNTOFSigmaProtonCut && casc.sign() > 0) { + if (candidateSelectionFlags.doNTOFSigmaProtonCut && casc.sign() > 0) { histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullmomentumNegDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPr()) > nsigmatofPr && fullmomentumNegDaugh > 0.6) + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullmomentumNegDaugh > 0.6) continue; } - if (doNTOFSigmaV0PionCut && casc.sign() < 0) { + if (candidateSelectionFlags.doNTOFSigmaV0PionCut && casc.sign() < 0) { histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullmomentumNegDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPi()) > nsigmatofPion) + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) continue; } } if (isXi) { - if (doNTPCSigmaCut) { - if (TMath::Abs(bachExtra.tpcNSigmaPi()) > nsigmatpcPi) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(bachExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (bachExtra.hasTOF() && doNTOFSigmaBachelorCut) { + if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { histos.fill(HIST("hNsigmaTOFBachelorPion"), casc.tofNSigmaXiPi(), fullmomentumBachelor, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiPi()) > nsigmatofBachPion) + if (TMath::Abs(casc.tofNSigmaXiPi()) > candidateSelectionValues.nsigmatofBachPion) continue; } ctau = pdgDB->Mass(3312) * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); - if (doProperLifeTimeCut) { - if (ctau > proplifetime) + if (candidateSelectionFlags.doProperLifeTimeCut) { + if (ctau > candidateSelectionValues.proplifetime) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } } else { - if (doNTPCSigmaCut) { - if (TMath::Abs(bachExtra.tpcNSigmaKa()) > nsigmatpcKa) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(bachExtra.tpcNSigmaKa()) > candidateSelectionValues.nsigmatpcKa) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (bachExtra.hasTOF() && doNTOFSigmaBachelorCut) { + if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { histos.fill(HIST("hNsigmaTOFBachelorKaon"), casc.tofNSigmaOmKa(), TMath::Sqrt(TMath::Power(casc.pxbach(), 2) + TMath::Power(casc.pybach(), 2) + TMath::Power(casc.pzbach(), 2)), coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaOmKa()) > nsigmatofBachKaon) + if (TMath::Abs(casc.tofNSigmaOmKa()) > candidateSelectionValues.nsigmatofBachKaon) continue; } ctau = pdgDB->Mass(3334) * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); - if (doProperLifeTimeCut) { - if (ctau > proplifetime) + if (candidateSelectionFlags.doProperLifeTimeCut) { + if (ctau > candidateSelectionValues.proplifetime) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } } + if (isPositive) + histos.fill(HIST("InvMassAfterSel/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), invmass, coll.centFT0C()); + if (isNegative) + histos.fill(HIST("InvMassAfterSel/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), invmass, coll.centFT0C()); + + if (qaFlags.doOccupancyCheck) { + float occupancy = -1; + if (useTrackOccupancyDef) + occupancy = coll.trackOccupancyInTimeRange(); + if (useFT0OccupancyDef) + occupancy = coll.ft0cOccupancyInTimeRange(); + static_for<0, 9>([&](auto i) { + constexpr int index = i.value; + if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { + if (isPositive) + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), invmass, occupancy); + if (isNegative) + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), invmass, occupancy); + } + }); + } - if (casc.sign() < 0) { - histos.fill(HIST("InvMassAfterSel/hNegativeCascade"), casc.pt(), invmass, coll.centFT0C()); - if (doOccupancyCheck) { - static_for<0, 9>([&](auto i) { - constexpr int index = i.value; - if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/hNegativeCascade"), casc.pt(), invmass, coll.trackOccupancyInTimeRange()); - } - }); - } - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudy/hNegativeDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudy/hNegativeDCAMesonToPV"), casc.pt(), invmass, casc.dcanegtopv()); - histos.fill(HIST("PtDepCutStudy/hNegativeDCABaryonToPV"), casc.pt(), invmass, casc.dcapostopv()); - } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascadeProperLifeTime"), casc.pt(), invmass, ctau); - } else { - histos.fill(HIST("InvMassAfterSel/hPositiveCascade"), casc.pt(), invmass, coll.centFT0C()); - if (doOccupancyCheck) { - static_for<0, 9>([&](auto i) { - constexpr int index = i.value; - if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/hPositiveCascade"), casc.pt(), invmass, coll.trackOccupancyInTimeRange()); - } - }); - } - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudy/hPositiveDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudy/hPositiveDCAMesonToPV"), casc.pt(), invmass, casc.dcapostopv()); - histos.fill(HIST("PtDepCutStudy/hPositiveDCABaryonToPV"), casc.pt(), invmass, casc.dcanegtopv()); - } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascadeProperLifeTime"), casc.pt(), invmass, ctau); + 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(), + TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z())), + casc.v0radius(), + casc.cascradius(), + casc.dcaV0daughters(), + casc.dcacascdaughters(), + TMath::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 index = i.value; + if (!selectionToBeTested[index]) { + if (isPositive) + histos.fill(HIST("PtDepCutStudy/h") + HIST(charge[0]) + HIST(selectionNames[index]), casc.pt(), invmass, selections[index]); + if (isNegative) + histos.fill(HIST("PtDepCutStudy/h") + HIST(charge[1]) + HIST(selectionNames[index]), casc.pt(), invmass, selections[index]); + } + }); } } } - void processCascadesMCrec(soa::Join::iterator const& coll, soa::Join const& Cascades, soa::Join const&) + 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, coll.sel8())) + if (!IsEventAccepted(coll, true)) return; for (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 (casc.sign() < 0 && doBefSelCheck) { - if (isXi) - histos.fill(HIST("InvMassBefSel/hNegativeCascade"), casc.pt(), casc.mXi(), coll.centFT0C()); - else - histos.fill(HIST("InvMassBefSel/hNegativeCascade"), casc.pt(), casc.mOmega(), coll.centFT0C()); - } - if (casc.sign() > 0 && doBefSelCheck) { - if (isXi) - histos.fill(HIST("InvMassBefSel/hPositiveCascade"), casc.pt(), casc.mXi(), coll.centFT0C()); - else - histos.fill(HIST("InvMassBefSel/hPositiveCascade"), casc.pt(), casc.mOmega(), coll.centFT0C()); + if (qaFlags.doBefSelCheck) { + if (isPositive) + histos.fill(HIST("InvMassBefSel/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), mass, coll.centFT0C()); + if (isNegative) + histos.fill(HIST("InvMassBefSel/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), mass, coll.centFT0C()); } + 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, coll.centFT0C())) continue; counter += 13; @@ -947,59 +1039,56 @@ struct derivedCascadeAnalysis { auto fullmomentumNegDaugh = TMath::Sqrt(TMath::Power(casc.pxneg(), 2) + TMath::Power(casc.pyneg(), 2) + TMath::Power(casc.pzneg(), 2)); auto fullmomentumBachelor = TMath::Sqrt(TMath::Power(casc.pxbach(), 2) + TMath::Power(casc.pybach(), 2) + TMath::Power(casc.pzbach(), 2)); - if (TMath::Abs(poseta) > etaDauCut || TMath::Abs(negeta) > etaDauCut || TMath::Abs(bacheta) > etaDauCut) + if (TMath::Abs(poseta) > candidateSelectionValues.etaDauCut || TMath::Abs(negeta) > candidateSelectionValues.etaDauCut || TMath::Abs(bacheta) > candidateSelectionValues.etaDauCut) continue; histos.fill(HIST("hCandidate"), ++counter); - if (doCascadeCosPaCut) { - if (!IsCosPAAccepted(casc, coll.posX(), coll.posY(), coll.posZ(), doPtDepCosPaCut, true)) + if (candidateSelectionFlags.doCascadeCosPaCut) { + if (!IsCosPAAccepted(casc, coll.posX(), coll.posY(), coll.posZ(), candidateSelectionFlags.doPtDepCosPaCut, true)) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (doDCAV0ToPVCut) { - if (TMath::Abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < dcaV0ToPV) + if (candidateSelectionFlags.doDCAV0ToPVCut) { + if (TMath::Abs(casc.dcav0topv(coll.posX(), coll.posY(), coll.posZ())) < candidateSelectionValues.dcaV0ToPV) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (casc.sign() < 0) { - if (doFillNsigmaTPCHistProton) + if (isNegative) { + if (qaFlags.doFillNsigmaTPCHistProton) histos.fill(HIST("hNsigmaProton"), posExtra.tpcNSigmaPr(), fullMomentumPosDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistV0Pion) + if (qaFlags.doFillNsigmaTPCHistV0Pion) histos.fill(HIST("hNsigmaPionNeg"), negExtra.tpcNSigmaPi(), fullmomentumNegDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) histos.fill(HIST("hNsigmaPionNegBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && !isXi) - histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - - } else if (casc.sign() > 0) { - if (doFillNsigmaTPCHistV0Pion) - histos.fill(HIST("hNsigmaPionPos"), posExtra.tpcNSigmaPi(), fullMomentumPosDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistProton) - histos.fill(HIST("hNsigmaProtonNeg"), negExtra.tpcNSigmaPr(), fullmomentumNegDaugh, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && isXi) - histos.fill(HIST("hNsigmaPionPosBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - if (doFillNsigmaTPCHistPionBach && !isXi) + if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - } - if (casc.sign() < 0) { - if (doNTPCSigmaCut) { - if (TMath::Abs(posExtra.tpcNSigmaPr()) > nsigmatpcPr || TMath::Abs(negExtra.tpcNSigmaPi()) > nsigmatpcPi) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(posExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr || TMath::Abs(negExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } + } + if (isPositive) { + if (qaFlags.doFillNsigmaTPCHistV0Pion) + histos.fill(HIST("hNsigmaPionPos"), posExtra.tpcNSigmaPi(), fullMomentumPosDaugh, coll.centFT0C()); + if (qaFlags.doFillNsigmaTPCHistProton) + histos.fill(HIST("hNsigmaProtonNeg"), negExtra.tpcNSigmaPr(), fullmomentumNegDaugh, coll.centFT0C()); + if (qaFlags.doFillNsigmaTPCHistPionBach && isXi) + histos.fill(HIST("hNsigmaPionPosBach"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); + if (qaFlags.doFillNsigmaTPCHistPionBach && !isXi) + histos.fill(HIST("hNsigmaKaon"), bachExtra.tpcNSigmaPi(), fullmomentumBachelor, coll.centFT0C()); - } else if (casc.sign() > 0) { - if (doNTPCSigmaCut) { - if (TMath::Abs(posExtra.tpcNSigmaPi()) > nsigmatpcPi || TMath::Abs(negExtra.tpcNSigmaPr()) > nsigmatpcPr) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(posExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi || TMath::Abs(negExtra.tpcNSigmaPr()) > candidateSelectionValues.nsigmatpcPr) continue; histos.fill(HIST("hCandidate"), ++counter); } else { @@ -1007,237 +1096,290 @@ struct derivedCascadeAnalysis { } } - if (posExtra.tpcCrossedRows() < mintpccrrows || negExtra.tpcCrossedRows() < mintpccrrows || bachExtra.tpcCrossedRows() < mintpccrrows) + if (posExtra.tpcCrossedRows() < candidateSelectionValues.mintpccrrows || negExtra.tpcCrossedRows() < candidateSelectionValues.mintpccrrows || 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 (dooobrej == 1) { + if (candidateSelectionFlags.dooobrej == 1) { if (!kHasTOF && !kHasITS) continue; histos.fill(HIST("hCandidate"), ++counter); - } else if (dooobrej == 2) { - if (!kHasTOF && (casc.pt() > ptthrtof)) + } else if (candidateSelectionFlags.dooobrej == 2) { + if (!kHasTOF && (casc.pt() > candidateSelectionValues.ptthrtof)) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - double invmass; 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 (doNTOFSigmaProtonCut && casc.sign() < 0) { + if (candidateSelectionFlags.doNTOFSigmaProtonCut && isNegative) { histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullMomentumPosDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPr()) > nsigmatofPr && fullMomentumPosDaugh > 0.6) + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullMomentumPosDaugh > 0.6) continue; } - if (doNTOFSigmaV0PionCut && casc.sign() > 0) { + if (candidateSelectionFlags.doNTOFSigmaV0PionCut && isPositive) { histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullMomentumPosDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPi()) > nsigmatofPion) + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) continue; } } if (negExtra.hasTOF()) { - if (doNTOFSigmaProtonCut && casc.sign() > 0) { + if (candidateSelectionFlags.doNTOFSigmaProtonCut && isPositive) { histos.fill(HIST("hNsigmaTOFProton"), casc.tofNSigmaXiLaPr(), fullmomentumNegDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPr()) > nsigmatofPr && fullmomentumNegDaugh > 0.6) + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > candidateSelectionValues.nsigmatofPr && fullmomentumNegDaugh > 0.6) continue; } - if (doNTOFSigmaV0PionCut && casc.sign() < 0) { + if (candidateSelectionFlags.doNTOFSigmaV0PionCut && isNegative) { histos.fill(HIST("hNsigmaTOFV0Pion"), casc.tofNSigmaXiLaPi(), fullmomentumNegDaugh, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiLaPi()) > nsigmatofPion) + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > candidateSelectionValues.nsigmatofPion) continue; } } if (isXi) { - if (doNTPCSigmaCut) { - if (TMath::Abs(bachExtra.tpcNSigmaPi()) > nsigmatpcPi) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(bachExtra.tpcNSigmaPi()) > candidateSelectionValues.nsigmatpcPi) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (bachExtra.hasTOF() && doNTOFSigmaBachelorCut) { + if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { histos.fill(HIST("hNsigmaTOFBachelorPion"), casc.tofNSigmaXiPi(), fullmomentumBachelor, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaXiPi()) > nsigmatofBachPion) + if (TMath::Abs(casc.tofNSigmaXiPi()) > candidateSelectionValues.nsigmatofBachPion) continue; } ctau = pdgDB->Mass(3312) * cascpos / ((cascptotmom + 1e-13) * ctauxiPDG); - if (doProperLifeTimeCut) { - if (ctau > proplifetime) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - - invmass = casc.mXi(); } else { - if (doNTPCSigmaCut) { - if (TMath::Abs(bachExtra.tpcNSigmaKa()) > nsigmatpcKa) + if (candidateSelectionFlags.doNTPCSigmaCut) { + if (TMath::Abs(bachExtra.tpcNSigmaKa()) > candidateSelectionValues.nsigmatpcKa) continue; histos.fill(HIST("hCandidate"), ++counter); } else { ++counter; } - if (bachExtra.hasTOF() && doNTOFSigmaBachelorCut) { + if (bachExtra.hasTOF() && candidateSelectionFlags.doNTOFSigmaBachelorCut) { histos.fill(HIST("hNsigmaTOFBachelorKaon"), casc.tofNSigmaOmKa(), fullmomentumBachelor, coll.centFT0C()); - if (TMath::Abs(casc.tofNSigmaOmKa()) > nsigmatofBachKaon) + if (TMath::Abs(casc.tofNSigmaOmKa()) > candidateSelectionValues.nsigmatofBachKaon) continue; } ctau = pdgDB->Mass(3334) * cascpos / ((cascptotmom + 1e-13) * ctauomegaPDG); - if (doProperLifeTimeCut) { - if (ctau > proplifetime) - continue; - histos.fill(HIST("hCandidate"), ++counter); - } else { - ++counter; - } - invmass = casc.mOmega(); } - if (casc.sign() < 0) { - histos.fill(HIST("InvMassAfterSel/hNegativeCascade"), casc.pt(), invmass, coll.centFT0C()); - if (doOccupancyCheck) { - static_for<0, 9>([&](auto i) { - constexpr int index = i.value; - if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/hNegativeCascade"), casc.pt(), invmass, coll.trackOccupancyInTimeRange()); + if (candidateSelectionFlags.doProperLifeTimeCut) { + if (ctau > candidateSelectionValues.proplifetime) + continue; + histos.fill(HIST("hCandidate"), ++counter); + } else { + ++counter; + } + + if (isPositive) { + histos.fill(HIST("InvMassAfterSel/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), mass, coll.centFT0C()); + if (isTrueMCCascadeDecay) + histos.fill(HIST("hPositiveCascadePtForEfficiency"), ptmc, mass, coll.centFT0C()); + } + if (isNegative) { + histos.fill(HIST("InvMassAfterSel/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), mass, coll.centFT0C()); + if (isTrueMCCascadeDecay) + histos.fill(HIST("hNegativeCascadePtForEfficiency"), ptmc, mass, coll.centFT0C()); + } + if (isTrueMCCascade) { + if (isPositive) + histos.fill(HIST("InvMassAfterSelMCrecTruth/h") + HIST(charge[0]) + HIST("Cascade"), ptmc, mass, coll.centFT0C()); + if (isNegative) + histos.fill(HIST("InvMassAfterSelMCrecTruth/h") + HIST(charge[1]) + HIST("Cascade"), ptmc, mass, coll.centFT0C()); + } + if (qaFlags.doOccupancyCheck) { + float occupancy = -1; + if (useTrackOccupancyDef) + occupancy = coll.trackOccupancyInTimeRange(); + if (useFT0OccupancyDef) + occupancy = coll.ft0cOccupancyInTimeRange(); + static_for<0, 9>([&](auto i) { + constexpr int index = i.value; + if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { + if (isPositive) { + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[0]) + HIST("Cascade"), casc.pt(), mass, occupancy); + if (isTrueMCCascadeDecay) + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[0]) + HIST("CascadeMCTruth"), casc.pt(), mass, occupancy); } - }); - } - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudy/hNegativeDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudy/hNegativeDCAMesonToPV"), casc.pt(), invmass, casc.dcanegtopv()); - histos.fill(HIST("PtDepCutStudy/hNegativeDCABaryonToPV"), casc.pt(), invmass, casc.dcapostopv()); - } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hNegativeCascadeProperLifeTime"), casc.pt(), invmass, ctau); - if (casc.isPhysicalPrimary()) { - if ((isXi && casc.pdgCode() == 3312) || (!isXi && casc.pdgCode() == 3334)) { - histos.fill(HIST("InvMassAfterSelMCrecTruth/hNegativeCascade"), casc.pt(), invmass, coll.centFT0C()); - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCAMesonToPV"), casc.pt(), invmass, casc.dcanegtopv()); - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeDCABaryonToPV"), casc.pt(), invmass, casc.dcapostopv()); + if (isNegative) { + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[1]) + HIST("Cascade"), casc.pt(), mass, occupancy); + if (isTrueMCCascadeDecay) + histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/h") + HIST(charge[1]) + HIST("CascadeMCTruth"), casc.pt(), mass, occupancy); } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hNegativeCascadeProperLifeTime"), casc.pt(), invmass, ctau); - if ((isXi && casc.pdgCodeV0() == 3122 && casc.pdgCodePositive() == 2212 && casc.pdgCodeNegative() == -211 && casc.pdgCodeBachelor() == -211) || (!isXi && casc.pdgCodeV0() == 3122 && casc.pdgCodePositive() == 2212 && casc.pdgCodeNegative() == -211 && casc.pdgCodeBachelor() == -321)) - histos.fill(HIST("hNegativeCascadePtForEfficiency"), casc.pt(), invmass, coll.centFT0C()); } - } - } else { - histos.fill(HIST("InvMassAfterSel/hPositiveCascade"), casc.pt(), invmass, coll.centFT0C()); - if (doOccupancyCheck) { - static_for<0, 9>([&](auto i) { - constexpr int index = i.value; - if (coll.centFT0C() < centralityIntervals[index + 1] && coll.centFT0C() > centralityIntervals[index]) { - histos.fill(HIST("InvMassAfterSelCent") + HIST(Index[index]) + HIST("/hPositiveCascade"), casc.pt(), invmass, coll.trackOccupancyInTimeRange()); - } - }); - } - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudy/hPositiveDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudy/hPositiveDCAMesonToPV"), casc.pt(), invmass, casc.dcapostopv()); - histos.fill(HIST("PtDepCutStudy/hPositiveDCABaryonToPV"), casc.pt(), invmass, casc.dcanegtopv()); - } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudy/hPositiveCascadeProperLifeTime"), casc.pt(), invmass, ctau); - if (casc.isPhysicalPrimary()) { - if ((isXi && casc.pdgCode() == -3312) || (!isXi && casc.pdgCode() == -3334)) { - histos.fill(HIST("InvMassAfterSelMCrecTruth/hPositiveCascade"), casc.pt(), invmass, coll.centFT0C()); - if (!doBachelorBaryonCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveBachelorBaryonDCA"), casc.pt(), invmass, casc.bachBaryonDCAxyToPV()); - if (!doDCAV0ToPVCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCAV0ToPV"), casc.pt(), invmass, TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z()))); - if (!doV0RadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveV0Radius"), casc.pt(), invmass, casc.v0radius()); - if (!doCascadeRadiusCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveCascadeRadius"), casc.pt(), invmass, casc.cascradius()); - if (!doDCAV0DauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCAV0Daughters"), casc.pt(), invmass, casc.dcaV0daughters()); - if (!doDCACascadeDauCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCACascDaughters"), casc.pt(), invmass, casc.dcacascdaughters()); - if (!doV0CosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveV0pa"), casc.pt(), invmass, TMath::ACos(casc.v0cosPA(casc.x(), casc.y(), casc.z()))); - if (!doCascadeCosPaCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveCascPA"), casc.pt(), invmass, TMath::ACos(casc.casccosPA(coll.posX(), coll.posY(), coll.posZ()))); - if (!doDCAdauToPVCut && doPtDepCutStudy) { - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCABachelorToPV"), casc.pt(), invmass, casc.dcabachtopv()); - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCAMesonToPV"), casc.pt(), invmass, casc.dcapostopv()); - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveDCABaryonToPV"), casc.pt(), invmass, casc.dcanegtopv()); + }); + } + 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(), + TMath::Abs(casc.dcav0topv(casc.x(), casc.y(), casc.z())), + casc.v0radius(), + casc.cascradius(), + casc.dcaV0daughters(), + casc.dcacascdaughters(), + TMath::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 index = i.value; + if (!selectionToBeTested[index]) { + if (isPositive) + histos.fill(HIST("PtDepCutStudy/h") + HIST(charge[0]) + HIST(selectionNames[index]), casc.pt(), mass, selections[index]); + if (isNegative) + histos.fill(HIST("PtDepCutStudy/h") + HIST(charge[1]) + HIST(selectionNames[index]), casc.pt(), mass, selections[index]); + if (isTrueMCCascade) { + if (isPositive) + histos.fill(HIST("PtDepCutStudyMCTruth/h") + HIST(charge[0]) + HIST(selectionNames[index]), ptmc, mass, selections[index]); + if (isNegative) + histos.fill(HIST("PtDepCutStudyMCTruth/h") + HIST(charge[1]) + HIST(selectionNames[index]), ptmc, mass, selections[index]); } - if (!doProperLifeTimeCut && doPtDepCutStudy) - histos.fill(HIST("PtDepCutStudyMCTruth/hPositiveCascadeProperLifeTime"), casc.pt(), invmass, ctau); - if ((isXi && casc.pdgCodeV0() == -3122 && casc.pdgCodePositive() == 211 && casc.pdgCodeNegative() == -2212 && casc.pdgCodeBachelor() == 211) || (!isXi && casc.pdgCodeV0() == -3122 && casc.pdgCodePositive() == 211 && casc.pdgCodeNegative() == -2212 && casc.pdgCodeBachelor() == 321)) - histos.fill(HIST("hPositiveCascadePtForEfficiency"), casc.pt(), invmass, coll.centFT0C()); } + }); + } + } + } + void processCascadesMCforEff(soa::Join const& mcCollisions, soa::Join const& Cascades, soa::Join const& collisions) + { + + std::vector listBestCollisionIdx = fillGenEventHist(mcCollisions, collisions); + + for (auto const& cascMC : Cascades) { + if (!cascMC.has_straMCCollision()) + continue; + + if (!cascMC.isPhysicalPrimary()) + continue; + + float ptmc = RecoDecay::sqrtSumOfSquares(cascMC.pxMC(), cascMC.pyMC()); + float ymc = 1e3; + if (TMath::Abs(cascMC.pdgCode()) == 3312) + ymc = RecoDecay::y(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()}, o2::constants::physics::MassXiMinus); + else if (TMath::Abs(cascMC.pdgCode()) == 3334) + ymc = RecoDecay::y(std::array{cascMC.pxMC(), cascMC.pyMC(), cascMC.pzMC()}, o2::constants::physics::MassOmegaMinus); + + if (TMath::Abs(ymc) > candidateSelectionValues.rapCut) + continue; + + auto mcCollision = cascMC.straMCCollision_as>(); + float centrality = 100.5f; + float occupancy = 49000; + 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 (cascMC.pdgCode() == 3312) { + histos.fill(HIST("h2dGenXiMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenXiMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenXiMinusVsCentOccupancy"), ptmc, centrality, occupancy); + } + if (cascMC.pdgCode() == -3312) { + histos.fill(HIST("h2dGenXiPlus"), centrality, ptmc); + histos.fill(HIST("h2dGenXiPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenXiPlusVsCentOccupancy"), ptmc, centrality, occupancy); + } + if (cascMC.pdgCode() == 3334) { + histos.fill(HIST("h2dGenOmegaMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsCentOccupancy"), ptmc, centrality, occupancy); + } + if (cascMC.pdgCode() == -3334) { + histos.fill(HIST("h2dGenOmegaPlus"), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsCentOccupancy"), ptmc, centrality, occupancy); + } + } + } + // ______________________________________________________ + // 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) + { + 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()); + // 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; + int bestCollisionIndex = -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(); + bestCollisionIndex = collision.globalIndex(); + centrality = collision.centFT0C(); + } + nCollisions++; + + atLeastOne = true; + } + listBestCollisionIdx[mcCollision.globalIndex()] = bestCollisionIndex; + + histos.fill(HIST("hCentralityVsNcoll_beforeEvSel"), centrality, groupedCollisions.size() + 0.5); + histos.fill(HIST("hCentralityVsNcoll_afterEvSel"), centrality, nCollisions + 0.5); + + histos.fill(HIST("hCentralityVsMultMC"), centrality, mcCollision.multMCNParticlesEta05()); + + if (atLeastOne) { + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 1.5 /* at least 1 rec. event*/); } } + return listBestCollisionIdx; } PROCESS_SWITCH(derivedCascadeAnalysis, processCascades, "cascade analysis, run3 data ", true); PROCESS_SWITCH(derivedCascadeAnalysis, processCascadesMCrec, "cascade analysis, run3 rec MC", false); + PROCESS_SWITCH(derivedCascadeAnalysis, processCascadesMCforEff, "cascade analysis, run3 rec MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index ac1835fa9ea..c40b0e6adb3 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -39,9 +39,11 @@ #include "Framework/AnalysisDataModel.h" #include "Framework/ASoAHelpers.h" #include "ReconstructionDataFormats/Track.h" +#include "CommonConstants/MathConstants.h" #include "CommonConstants/PhysicsConstants.h" #include "Common/Core/trackUtilities.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/LFStrangenessMLTables.h" #include "PWGLF/DataModel/LFStrangenessPIDTables.h" #include "Common/Core/TrackSelection.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -49,6 +51,9 @@ #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/PIDResponse.h" +#include "PWGUD/Core/SGSelector.h" +#include "Tools/ML/MlResponse.h" +#include "Tools/ML/model.h" using namespace o2; using namespace o2::framework; @@ -57,8 +62,9 @@ using std::array; using dauTracks = soa::Join; using dauMCTracks = soa::Join; -using v0Candidates = soa::Join; -using v0MCCandidates = 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))) @@ -72,52 +78,66 @@ struct derivedlambdakzeroanalysis { Configurable analyseLambda{"analyseLambda", true, "process Lambda-like candidates"}; Configurable analyseAntiLambda{"analyseAntiLambda", true, "process AntiLambda-like candidates"}; Configurable calculateFeeddownMatrix{"calculateFeeddownMatrix", true, "fill feeddown matrix if MC"}; + + 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 requireNoHighOccupancyAgressive{"requireNoHighOccupancyAgressive", false, "reject collisions with high occupancies according to the aggressive cuts"}; - Configurable requireNoHighOccupancyStrict{"requireNoHighOccupancyStrict", false, "reject collisions with high occupancies according to the strict cuts"}; - Configurable requireNoHighOccupancyMedium{"requireNoHighOccupancyMedium", false, "reject collisions with high occupancies according to the medium cuts"}; - Configurable requireNoHighOccupancyRelaxed{"requireNoHighOccupancyRelaxed", false, "reject collisions with high occupancies according to the relaxed cuts"}; - Configurable requireNoHighOccupancyGentle{"requireNoHighOccupancyGentle", false, "reject collisions with high occupancies according to the gentle cuts"}; - Configurable requireNoCollInTimeRangeStd{"requireNoCollInTimeRangeStd", true, "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 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)"}; - - // 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 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 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"}; + + 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)"}; + + // 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; Configurable doCompleteTopoQA{"doCompleteTopoQA", false, "do topological variable QA histograms"}; Configurable doTPCQA{"doTPCQA", false, "do TPC QA histograms"}; @@ -129,17 +149,57 @@ struct derivedlambdakzeroanalysis { Configurable qaMaxPt{"qaMaxPt", 1000.0f, "maximum pT for QA plots"}; Configurable qaCentrality{"qaCentrality", false, "qa centrality flag: check base raw values"}; - // PID (TOF) - Configurable maxDeltaTimeProton{"maxDeltaTimeProton", 1e+9, "check maximum allowed time"}; - Configurable maxDeltaTimePion{"maxDeltaTimePion", 1e+9, "check maximum allowed time"}; - // 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 doCollisionAssociationQA{"doCollisionAssociationQA", true, "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"}; + // Machine learning evaluation for pre-selection and corresponding information generation + o2::ml::OnnxModel mlCustomModelK0Short; + o2::ml::OnnxModel mlCustomModelLambda; + o2::ml::OnnxModel mlCustomModelAntiLambda; + o2::ml::OnnxModel mlCustomModelGamma; + + struct : ConfigurableGroup { + // 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 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"}; + + // 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)"}; + + // 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."}; + + // 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"}; + } 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"}; + } ccdbConfigurations; + + o2::ccdb::CcdbApi ccdbApi; + int mRunNumber; + std::map metadata; static constexpr float defaultLifetimeCuts[1][2] = {{30., 20.}}; Configurable> lifetimecut{"lifetimecut", {defaultLifetimeCuts[0], 2, {"lifetimecutLambda", "lifetimecutK0S"}}, "lifetimecut"}; @@ -164,6 +224,21 @@ struct derivedlambdakzeroanalysis { 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 axisPhi{"axisPhi", {18, 0.0f, constants::math::TwoPI}, "Azimuth angle (rad)"}; + ConfigurableAxis axisEta{"axisEta", {10, -1.0f, 1.0f}, "#eta"}; + + // UPC axes + ConfigurableAxis axisSelGap{"axisSelGap", {4, -1.5, 2.5}, "Gap side"}; + + // 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; // AP plot axes ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; @@ -180,6 +255,10 @@ struct derivedlambdakzeroanalysis { // MC coll assoc QA axis ConfigurableAxis axisMonteCarloNch{"axisMonteCarloNch", {300, 0.0f, 3000.0f}, "N_{ch} MC"}; + // For manual sliceBy + // Preslice> perMcCollision = aod::v0data::straMCCollisionId; + PresliceUnsorted> perMcCollision = aod::v0data::straMCCollisionId; + enum selection : uint64_t { selCosPA = 0, selRadius, selRadiusMax, @@ -258,44 +337,44 @@ struct derivedlambdakzeroanalysis { // ask for specific TPC/TOF PID selections maskTrackProperties = 0; - if (requirePosITSonly) { + if (v0Selections.requirePosITSonly) { maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosItsOnly) | (uint64_t(1) << selPosGoodITSTrack); } else { maskTrackProperties = maskTrackProperties | (uint64_t(1) << selPosGoodTPCTrack) | (uint64_t(1) << selPosGoodITSTrack); // TPC signal is available: ask for positive track PID - if (TpcPidNsigmaCut < 1e+5) { // safeguard for no cut + 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); } // TOF PID - if (TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTOFNSigmaPositivePionK0Short) | (uint64_t(1) << selTOFDeltaTPositivePionK0Short); - if (TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTOFNSigmaPositiveProtonLambda) | (uint64_t(1) << selTOFDeltaTPositiveProtonLambda); - if (TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTOFNSigmaPositivePionLambda) | (uint64_t(1) << selTOFDeltaTPositivePionLambda); } - if (requireNegITSonly) { + if (v0Selections.requireNegITSonly) { maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegItsOnly) | (uint64_t(1) << selNegGoodITSTrack); } else { maskTrackProperties = maskTrackProperties | (uint64_t(1) << selNegGoodTPCTrack) | (uint64_t(1) << selNegGoodITSTrack); // TPC signal is available: ask for negative track PID - if (TpcPidNsigmaCut < 1e+5) { // safeguard for no cut + 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); } // TOF PID - if (TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutK0Pi < 1e+5) // safeguard for no cut maskK0ShortSpecific = maskK0ShortSpecific | (uint64_t(1) << selTOFNSigmaNegativePionK0Short) | (uint64_t(1) << selTOFDeltaTNegativePionK0Short); - if (TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut maskLambdaSpecific = maskLambdaSpecific | (uint64_t(1) << selTOFNSigmaNegativePionLambda) | (uint64_t(1) << selTOFDeltaTNegativePionLambda); - if (TofPidNsigmaCutLaPi < 1e+5) // safeguard for no cut + if (v0Selections.TofPidNsigmaCutLaPr < 1e+5) // safeguard for no cut maskAntiLambdaSpecific = maskAntiLambdaSpecific | (uint64_t(1) << selTOFNSigmaNegativeProtonLambda) | (uint64_t(1) << selTOFDeltaTNegativeProtonLambda); } - if (skipTPConly) { + 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); @@ -314,21 +393,21 @@ struct derivedlambdakzeroanalysis { 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, "posZ 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, "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, "kNoHighOccupancyAgressive"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(12, "kNoHighOccupancyStrict"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(13, "kNoHighOccupancyMedium"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(14, "kNoHighOccupancyRelaxed"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(15, "kNoHighOccupancyGentle"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(16, "kNoCollInTimeRangeStd"); - histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(17, "kNoCollInTimeRangeNarrow"); + 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"); histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(18, "Below min occup."); histos.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(19, "Above max occup."); @@ -338,6 +417,10 @@ struct derivedlambdakzeroanalysis { 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}); + // for QA and test purposes auto hRawCentrality = histos.add("hRawCentrality", "hRawCentrality", kTH1F, {axisRawCentrality}); @@ -348,7 +431,14 @@ struct derivedlambdakzeroanalysis { // histograms versus mass if (analyseK0Short) { + histos.add("h2dNbrOfK0ShortVsCentrality", "h2dNbrOfK0ShortVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); histos.add("h3dMassK0Short", "h3dMassK0Short", kTH3F, {axisCentrality, axisPt, axisK0Mass}); + // Non-UPC info + histos.add("h3dMassK0ShortHadronic", "h3dMassK0ShortHadronic", kTH3F, {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}); if (doTPCQA) { histos.add("K0Short/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); histos.add("K0Short/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); @@ -387,7 +477,14 @@ struct derivedlambdakzeroanalysis { } } if (analyseLambda) { + histos.add("h2dNbrOfLambdaVsCentrality", "h2dNbrOfLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); histos.add("h3dMassLambda", "h3dMassLambda", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + // Non-UPC info + histos.add("h3dMassLambdaHadronic", "h3dMassLambdaHadronic", kTH3F, {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}); if (doTPCQA) { histos.add("Lambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); histos.add("Lambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); @@ -426,7 +523,14 @@ struct derivedlambdakzeroanalysis { } } if (analyseAntiLambda) { + histos.add("h2dNbrOfAntiLambdaVsCentrality", "h2dNbrOfAntiLambdaVsCentrality", kTH2F, {axisCentrality, {10, -0.5f, 9.5f}}); histos.add("h3dMassAntiLambda", "h3dMassAntiLambda", kTH3F, {axisCentrality, axisPt, axisLambdaMass}); + // Non-UPC info + histos.add("h3dMassAntiLambdaHadronic", "h3dMassAntiLambdaHadronic", kTH3F, {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}); if (doTPCQA) { histos.add("AntiLambda/h3dPosNsigmaTPC", "h3dPosNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); histos.add("AntiLambda/h3dNegNsigmaTPC", "h3dNegNsigmaTPC", kTH3F, {axisCentrality, axisPtCoarse, axisNsigmaTPC}); @@ -482,6 +586,7 @@ struct derivedlambdakzeroanalysis { 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}); } if (analyseLambda) { histos.add("Lambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); @@ -489,6 +594,7 @@ struct derivedlambdakzeroanalysis { 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}); } if (analyseAntiLambda) { histos.add("AntiLambda/h4dPosDCAToPV", "h4dPosDCAToPV", kTHnF, {axisCentrality, axisPtCoarse, axisLambdaMass, axisDCAtoPV}); @@ -496,6 +602,7 @@ struct derivedlambdakzeroanalysis { 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}); } } @@ -542,7 +649,17 @@ struct derivedlambdakzeroanalysis { histos.add("GeneralQA/h2dArmenterosSelected", "h2dArmenterosSelected", kTH2F, {axisAPAlpha, axisAPQt}); // Creation of histograms: MC generated - if (doprocessBinnedGenerated) { + if (doprocessGenerated) { + histos.add("hGenEvents", "hGenEvents", kTH2F, {{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("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("hCentralityVsMultMC", "hCentralityVsMultMC", kTH2F, {{100, 0.0f, 100.0f}, axisNch}); + histos.add("h2dGenK0Short", "h2dGenK0Short", kTH2D, {axisCentrality, axisPt}); histos.add("h2dGenLambda", "h2dGenLambda", kTH2D, {axisCentrality, axisPt}); histos.add("h2dGenAntiLambda", "h2dGenAntiLambda", kTH2D, {axisCentrality, axisPt}); @@ -550,92 +667,129 @@ struct derivedlambdakzeroanalysis { histos.add("h2dGenXiPlus", "h2dGenXiPlus", kTH2D, {axisCentrality, axisPt}); histos.add("h2dGenOmegaMinus", "h2dGenOmegaMinus", kTH2D, {axisCentrality, axisPt}); histos.add("h2dGenOmegaPlus", "h2dGenOmegaPlus", kTH2D, {axisCentrality, axisPt}); + + histos.add("h2dGenK0ShortVsMultMC", "h2dGenK0ShortVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenLambdaVsMultMC", "h2dGenLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + histos.add("h2dGenAntiLambdaVsMultMC", "h2dGenAntiLambdaVsMultMC", kTH2D, {axisNch, axisPt}); + 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 (doprocessBinnedGenerated) { + histos.add("h2dGeneratedK0Short", "h2dGeneratedK0Short", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedLambda", "h2dGeneratedLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedAntiLambda", "h2dGeneratedAntiLambda", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedXiMinus", "h2dGeneratedXiMinus", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedXiPlus", "h2dGeneratedXiPlus", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedOmegaMinus", "h2dGeneratedOmegaMinus", kTH2D, {axisCentrality, axisPt}); + histos.add("h2dGeneratedOmegaPlus", "h2dGeneratedOmegaPlus", kTH2D, {axisCentrality, axisPt}); } // inspect histogram sizes, please histos.print(); } + template + void initCCDB(TCollision collision) + { + if (mRunNumber == collision.runNumber()) { + return; + } + + mRunNumber = collision.runNumber(); + + // machine learning initialization if requested + if (mlConfigurations.calculateK0ShortScores || + mlConfigurations.calculateLambdaScores || + mlConfigurations.calculateAntiLambdaScores) { + int64_t timeStampML = collision.timestamp(); + if (mlConfigurations.timestampCCDB.value != -1) + timeStampML = mlConfigurations.timestampCCDB.value; + LoadMachines(timeStampML); + } + } + template uint64_t computeReconstructionBitmap(TV0 v0, TCollision collision, float rapidityLambda, float rapidityK0Short, float /*pT*/) // precalculate this information so that a check is one mask operation, not many { uint64_t bitMap = 0; // Base topological variables - if (v0.v0radius() > v0radius) + if (v0.v0radius() > v0Selections.v0radius) bitset(bitMap, selRadius); - if (v0.v0radius() < v0radiusMax) + if (v0.v0radius() < v0Selections.v0radiusMax) bitset(bitMap, selRadiusMax); - if (TMath::Abs(v0.dcapostopv()) > dcapostopv) + if (TMath::Abs(v0.dcapostopv()) > v0Selections.dcapostopv) bitset(bitMap, selDCAPosToPV); - if (TMath::Abs(v0.dcanegtopv()) > dcanegtopv) + if (TMath::Abs(v0.dcanegtopv()) > v0Selections.dcanegtopv) bitset(bitMap, selDCANegToPV); - if (v0.v0cosPA() > v0cospa) + if (v0.v0cosPA() > v0Selections.v0cospa) bitset(bitMap, selCosPA); - if (v0.dcaV0daughters() < dcav0dau) + if (v0.dcaV0daughters() < v0Selections.dcav0dau) bitset(bitMap, selDCAV0Dau); // rapidity - if (TMath::Abs(rapidityLambda) < rapidityCut) + if (TMath::Abs(rapidityLambda) < v0Selections.rapidityCut) bitset(bitMap, selLambdaRapidity); - if (TMath::Abs(rapidityK0Short) < rapidityCut) + if (TMath::Abs(rapidityK0Short) < v0Selections.rapidityCut) bitset(bitMap, selK0ShortRapidity); auto posTrackExtra = v0.template posTrackExtra_as(); auto negTrackExtra = v0.template negTrackExtra_as(); // ITS quality flags - if (posTrackExtra.itsNCls() >= minITSclusters) + if (posTrackExtra.itsNCls() >= v0Selections.minITSclusters) bitset(bitMap, selPosGoodITSTrack); - if (negTrackExtra.itsNCls() >= minITSclusters) + if (negTrackExtra.itsNCls() >= v0Selections.minITSclusters) bitset(bitMap, selNegGoodITSTrack); // TPC quality flags - if (posTrackExtra.tpcCrossedRows() >= minTPCrows) + if (posTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) bitset(bitMap, selPosGoodTPCTrack); - if (negTrackExtra.tpcCrossedRows() >= minTPCrows) + if (negTrackExtra.tpcCrossedRows() >= v0Selections.minTPCrows) bitset(bitMap, selNegGoodTPCTrack); // TPC PID - if (fabs(posTrackExtra.tpcNSigmaPi()) < TpcPidNsigmaCut) + if (fabs(posTrackExtra.tpcNSigmaPi()) < v0Selections.TpcPidNsigmaCut) bitset(bitMap, selTPCPIDPositivePion); - if (fabs(posTrackExtra.tpcNSigmaPr()) < TpcPidNsigmaCut) + if (fabs(posTrackExtra.tpcNSigmaPr()) < v0Selections.TpcPidNsigmaCut) bitset(bitMap, selTPCPIDPositiveProton); - if (fabs(negTrackExtra.tpcNSigmaPi()) < TpcPidNsigmaCut) + if (fabs(negTrackExtra.tpcNSigmaPi()) < v0Selections.TpcPidNsigmaCut) bitset(bitMap, selTPCPIDNegativePion); - if (fabs(negTrackExtra.tpcNSigmaPr()) < TpcPidNsigmaCut) + if (fabs(negTrackExtra.tpcNSigmaPr()) < v0Selections.TpcPidNsigmaCut) bitset(bitMap, selTPCPIDNegativeProton); // TOF PID in DeltaT // Positive track - if (fabs(v0.posTOFDeltaTLaPr()) < maxDeltaTimeProton) + if (fabs(v0.posTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) bitset(bitMap, selTOFDeltaTPositiveProtonLambda); - if (fabs(v0.posTOFDeltaTLaPi()) < maxDeltaTimePion) + if (fabs(v0.posTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) bitset(bitMap, selTOFDeltaTPositivePionLambda); - if (fabs(v0.posTOFDeltaTK0Pi()) < maxDeltaTimePion) + if (fabs(v0.posTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) bitset(bitMap, selTOFDeltaTPositivePionK0Short); // Negative track - if (fabs(v0.negTOFDeltaTLaPr()) < maxDeltaTimeProton) + if (fabs(v0.negTOFDeltaTLaPr()) < v0Selections.maxDeltaTimeProton) bitset(bitMap, selTOFDeltaTNegativeProtonLambda); - if (fabs(v0.negTOFDeltaTLaPi()) < maxDeltaTimePion) + if (fabs(v0.negTOFDeltaTLaPi()) < v0Selections.maxDeltaTimePion) bitset(bitMap, selTOFDeltaTNegativePionLambda); - if (fabs(v0.negTOFDeltaTK0Pi()) < maxDeltaTimePion) + if (fabs(v0.negTOFDeltaTK0Pi()) < v0Selections.maxDeltaTimePion) bitset(bitMap, selTOFDeltaTNegativePionK0Short); // TOF PID in NSigma // Positive track - if (fabs(v0.tofNSigmaLaPr()) < TofPidNsigmaCutLaPr) + if (fabs(v0.tofNSigmaLaPr()) < v0Selections.TofPidNsigmaCutLaPr) bitset(bitMap, selTOFNSigmaPositiveProtonLambda); - if (fabs(v0.tofNSigmaALaPi()) < TofPidNsigmaCutLaPi) + if (fabs(v0.tofNSigmaALaPi()) < v0Selections.TofPidNsigmaCutLaPi) bitset(bitMap, selTOFNSigmaPositivePionLambda); - if (fabs(v0.tofNSigmaK0PiPlus()) < TofPidNsigmaCutK0Pi) + if (fabs(v0.tofNSigmaK0PiPlus()) < v0Selections.TofPidNsigmaCutK0Pi) bitset(bitMap, selTOFNSigmaPositivePionK0Short); // Negative track - if (fabs(v0.tofNSigmaALaPr()) < TofPidNsigmaCutLaPr) + if (fabs(v0.tofNSigmaALaPr()) < v0Selections.TofPidNsigmaCutLaPr) bitset(bitMap, selTOFNSigmaNegativeProtonLambda); - if (fabs(v0.tofNSigmaLaPi()) < TofPidNsigmaCutLaPi) + if (fabs(v0.tofNSigmaLaPi()) < v0Selections.TofPidNsigmaCutLaPi) bitset(bitMap, selTOFNSigmaNegativePionLambda); - if (fabs(v0.tofNSigmaK0PiMinus()) < TofPidNsigmaCutK0Pi) + if (fabs(v0.tofNSigmaK0PiMinus()) < v0Selections.TofPidNsigmaCutK0Pi) bitset(bitMap, selTOFNSigmaNegativePionK0Short); // ITS only tag @@ -657,7 +811,7 @@ struct derivedlambdakzeroanalysis { bitset(bitMap, selK0ShortCTau); // armenteros - if (v0.qtarm() * armPodCut > TMath::Abs(v0.alpha()) || armPodCut < 1e-4) + if (v0.qtarm() * v0Selections.armPodCut > TMath::Abs(v0.alpha()) || v0Selections.armPodCut < 1e-4) bitset(bitMap, selK0ShortArmenteros); return bitMap; @@ -668,19 +822,22 @@ struct derivedlambdakzeroanalysis { // precalculate this information so that a check is one mask operation, not many { uint64_t bitMap = 0; - // check for specific particle species + bool isPositiveProton = v0.pdgCodePositive() == 2212; + bool isPositivePion = v0.pdgCodePositive() == 211 || (doTreatPiToMuon && v0.pdgCodePositive() == -13); + bool isNegativeProton = v0.pdgCodeNegative() == -2212; + bool isNegativePion = v0.pdgCodeNegative() == -211 || (doTreatPiToMuon && v0.pdgCodeNegative() == 13); - if (v0.pdgCode() == 310 && v0.pdgCodePositive() == 211 && v0.pdgCodeNegative() == -211) { + if (v0.pdgCode() == 310 && isPositivePion && isNegativePion) { bitset(bitMap, selConsiderK0Short); if (v0.isPhysicalPrimary()) bitset(bitMap, selPhysPrimK0Short); } - if (v0.pdgCode() == 3122 && v0.pdgCodePositive() == 2212 && v0.pdgCodeNegative() == -211) { + if (v0.pdgCode() == 3122 && isPositiveProton && isNegativePion) { bitset(bitMap, selConsiderLambda); if (v0.isPhysicalPrimary()) bitset(bitMap, selPhysPrimLambda); } - if (v0.pdgCode() == -3122 && v0.pdgCodePositive() == 211 && v0.pdgCodeNegative() == -2212) { + if (v0.pdgCode() == -3122 && isPositivePion && isNegativeProton) { bitset(bitMap, selConsiderAntiLambda); if (v0.isPhysicalPrimary()) bitset(bitMap, selPhysPrimAntiLambda); @@ -799,10 +956,108 @@ struct derivedlambdakzeroanalysis { return bitMap; } + // function to load models for ML-based classifiers + void LoadMachines(int64_t timeStampML) + { + if (mlConfigurations.loadCustomModelsFromCCDB) { + ccdbApi.init(ccdbConfigurations.ccdburl); + LOG(info) << "Fetching models for timestamp: " << timeStampML; + + if (mlConfigurations.calculateLambdaScores) { + bool retrieveSuccessLambda = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathLambda.value); + if (retrieveSuccessLambda) { + mlCustomModelLambda.initModel(mlConfigurations.localModelPathLambda.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the Lambda model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateAntiLambdaScores) { + bool retrieveSuccessAntiLambda = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathAntiLambda.value); + if (retrieveSuccessAntiLambda) { + mlCustomModelAntiLambda.initModel(mlConfigurations.localModelPathAntiLambda.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the AntiLambda model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + + if (mlConfigurations.calculateK0ShortScores) { + bool retrieveSuccessKZeroShort = ccdbApi.retrieveBlob(mlConfigurations.customModelPathCCDB, ".", metadata, timeStampML, false, mlConfigurations.localModelPathK0Short.value); + if (retrieveSuccessKZeroShort) { + mlCustomModelK0Short.initModel(mlConfigurations.localModelPathK0Short.value, mlConfigurations.enableOptimizations.value); + } else { + LOG(fatal) << "Error encountered while fetching/loading the K0Short model from CCDB! Maybe the model doesn't exist yet for this runnumber/timestamp?"; + } + } + } else { + if (mlConfigurations.calculateLambdaScores) + mlCustomModelLambda.initModel(mlConfigurations.localModelPathLambda.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateAntiLambdaScores) + mlCustomModelAntiLambda.initModel(mlConfigurations.localModelPathAntiLambda.value, mlConfigurations.enableOptimizations.value); + if (mlConfigurations.calculateK0ShortScores) + mlCustomModelK0Short.initModel(mlConfigurations.localModelPathK0Short.value, mlConfigurations.enableOptimizations.value); + } + LOG(info) << "ML Models loaded."; + } + template - void analyseCandidate(TV0 v0, float pt, float centrality, uint64_t selMap) + void analyseCandidate(TV0 v0, float pt, float centrality, uint64_t selMap, uint8_t gapSide, int& nK0Shorts, int& nLambdas, int& nAntiLambdas) // precalculate this information so that a check is one mask operation, not many { + bool passK0ShortSelections = false; + bool passLambdaSelections = false; + bool passAntiLambdaSelections = false; + + // machine learning is on, go for calculation of thresholds + // FIXME THIS NEEDS ADJUSTING + std::vector inputFeatures{pt, 0.0f, 0.0f, v0.v0radius(), v0.v0cosPA(), v0.dcaV0daughters(), v0.dcapostopv(), v0.dcanegtopv()}; + + if (mlConfigurations.useK0ShortScores) { + float k0shortScore = -1; + if (mlConfigurations.calculateK0ShortScores) { + // evaluate machine-learning scores + float* k0shortProbability = mlCustomModelK0Short.evalModel(inputFeatures); + k0shortScore = k0shortProbability[1]; + } else { + k0shortScore = v0.k0ShortBDTScore(); + } + if (k0shortScore > mlConfigurations.thresholdK0Short.value) { + passK0ShortSelections = true; + } + } else { + passK0ShortSelections = verifyMask(selMap, maskSelectionK0Short); + } + if (mlConfigurations.useLambdaScores) { + float lambdaScore = -1; + if (mlConfigurations.calculateLambdaScores) { + // evaluate machine-learning scores + float* lambdaProbability = mlCustomModelLambda.evalModel(inputFeatures); + lambdaScore = lambdaProbability[1]; + } else { + lambdaScore = v0.lambdaBDTScore(); + } + if (lambdaScore > mlConfigurations.thresholdK0Short.value) { + passLambdaSelections = true; + } + } else { + passLambdaSelections = verifyMask(selMap, maskSelectionLambda); + } + if (mlConfigurations.useLambdaScores) { + float antiLambdaScore = -1; + if (mlConfigurations.calculateAntiLambdaScores) { + // evaluate machine-learning scores + float* antilambdaProbability = mlCustomModelAntiLambda.evalModel(inputFeatures); + antiLambdaScore = antilambdaProbability[1]; + } else { + antiLambdaScore = v0.antiLambdaBDTScore(); + } + if (antiLambdaScore > mlConfigurations.thresholdK0Short.value) { + passAntiLambdaSelections = true; + } + } else { + passAntiLambdaSelections = verifyMask(selMap, maskSelectionAntiLambda); + } + auto posTrackExtra = v0.template posTrackExtra_as(); auto negTrackExtra = v0.template negTrackExtra_as(); @@ -828,9 +1083,17 @@ struct derivedlambdakzeroanalysis { // __________________________________________ // main analysis - if (verifyMask(selMap, maskSelectionK0Short) && analyseK0Short) { + if (passK0ShortSelections && analyseK0Short) { histos.fill(HIST("GeneralQA/h2dArmenterosSelected"), v0.alpha(), v0.qtarm()); // cross-check histos.fill(HIST("h3dMassK0Short"), centrality, pt, v0.mK0Short()); + if (gapSide == 0) + histos.fill(HIST("h3dMassK0ShortSGA"), centrality, pt, v0.mK0Short()); + else if (gapSide == 1) + histos.fill(HIST("h3dMassK0ShortSGC"), centrality, pt, v0.mK0Short()); + else if (gapSide == 2) + histos.fill(HIST("h3dMassK0ShortDG"), centrality, pt, v0.mK0Short()); + else + histos.fill(HIST("h3dMassK0ShortHadronic"), centrality, pt, v0.mK0Short()); histos.fill(HIST("hMassK0Short"), v0.mK0Short()); if (doPlainTopoQA) { histos.fill(HIST("K0Short/hPosDCAToPV"), v0.dcapostopv()); @@ -873,9 +1136,18 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTK0Pi()); histos.fill(HIST("K0Short/h3dNegTOFdeltaTvsTrackPt"), centrality, v0.negativept(), v0.negTOFDeltaTK0Pi()); } + nK0Shorts++; } - if (verifyMask(selMap, maskSelectionLambda) && analyseLambda) { + if (passLambdaSelections && analyseLambda) { histos.fill(HIST("h3dMassLambda"), centrality, pt, v0.mLambda()); + if (gapSide == 0) + histos.fill(HIST("h3dMassLambdaSGA"), centrality, pt, v0.mLambda()); + else if (gapSide == 1) + histos.fill(HIST("h3dMassLambdaSGC"), centrality, pt, v0.mLambda()); + else if (gapSide == 2) + histos.fill(HIST("h3dMassLambdaDG"), centrality, pt, v0.mLambda()); + else + histos.fill(HIST("h3dMassLambdaHadronic"), centrality, pt, v0.mLambda()); if (doPlainTopoQA) { histos.fill(HIST("Lambda/hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("Lambda/hNegDCAToPV"), v0.dcanegtopv()); @@ -917,9 +1189,18 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTLaPr()); histos.fill(HIST("Lambda/h3dNegTOFdeltaTvsTrackPt"), centrality, v0.negativept(), v0.negTOFDeltaTLaPi()); } + nLambdas++; } - if (verifyMask(selMap, maskSelectionAntiLambda) && analyseAntiLambda) { + if (passAntiLambdaSelections && analyseAntiLambda) { histos.fill(HIST("h3dMassAntiLambda"), centrality, pt, v0.mAntiLambda()); + if (gapSide == 0) + histos.fill(HIST("h3dMassAntiLambdaSGA"), centrality, pt, v0.mAntiLambda()); + else if (gapSide == 1) + histos.fill(HIST("h3dMassAntiLambdaSGC"), centrality, pt, v0.mAntiLambda()); + else if (gapSide == 2) + histos.fill(HIST("h3dMassAntiLambdaDG"), centrality, pt, v0.mAntiLambda()); + else + histos.fill(HIST("h3dMassAntiLambdaHadronic"), centrality, pt, v0.mAntiLambda()); if (doPlainTopoQA) { histos.fill(HIST("AntiLambda/hPosDCAToPV"), v0.dcapostopv()); histos.fill(HIST("AntiLambda/hNegDCAToPV"), v0.dcanegtopv()); @@ -961,6 +1242,7 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/h3dPosTOFdeltaTvsTrackPt"), centrality, v0.positivept(), v0.posTOFDeltaTLaPi()); histos.fill(HIST("AntiLambda/h3dNegTOFdeltaTvsTrackPt"), centrality, v0.negativept(), v0.negTOFDeltaTLaPr()); } + nAntiLambdas++; } // __________________________________________ @@ -977,6 +1259,9 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("K0Short/h4dPointingAngle"), centrality, pt, v0.mK0Short(), TMath::ACos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskK0ShortSpecific)) histos.fill(HIST("K0Short/h4dDCADaughters"), centrality, pt, v0.mK0Short(), v0.dcaV0daughters()); + + if (passK0ShortSelections) + histos.fill(HIST("K0Short/h4dV0PhiVsEta"), pt, v0.mK0Short(), v0.phi(), v0.eta()); } if (analyseLambda) { @@ -990,6 +1275,9 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("Lambda/h4dPointingAngle"), centrality, pt, v0.mLambda(), TMath::ACos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskLambdaSpecific)) histos.fill(HIST("Lambda/h4dDCADaughters"), centrality, pt, v0.mLambda(), v0.dcaV0daughters()); + + if (passLambdaSelections) + histos.fill(HIST("Lambda/h4dV0PhiVsEta"), pt, v0.mLambda(), v0.phi(), v0.eta()); } if (analyseAntiLambda) { if (verifyMask(selMap, maskTopoNoV0Radius | maskAntiLambdaSpecific)) @@ -1002,6 +1290,9 @@ struct derivedlambdakzeroanalysis { histos.fill(HIST("AntiLambda/h4dPointingAngle"), centrality, pt, v0.mAntiLambda(), TMath::ACos(v0.v0cosPA())); if (verifyMask(selMap, maskTopoNoDCAV0Dau | maskAntiLambdaSpecific)) histos.fill(HIST("AntiLambda/h4dDCADaughters"), centrality, pt, v0.mAntiLambda(), v0.dcaV0daughters()); + + if (passAntiLambdaSelections) + histos.fill(HIST("AntiLambda/h4dV0PhiVsEta"), pt, v0.mAntiLambda(), v0.phi(), v0.eta()); } } // end systematics / qa } @@ -1053,120 +1344,244 @@ struct derivedlambdakzeroanalysis { } } - // ______________________________________________________ - // Real data processing - no MC subscription - void processRealData(soa::Join::iterator const& collision, v0Candidates const& fullV0s, dauTracks const&) + template + bool IsEventAccepted(TCollision collision, bool fillHists) + // check whether the collision passes our collision selections { - histos.fill(HIST("hEventSelection"), 0. /* all collisions */); - if (!collision.sel8()) { - return; + if (fillHists) + histos.fill(HIST("hEventSelection"), 0. /* all collisions */); + + if (requireSel8 && !collision.sel8()) { + return false; } - histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); - if (std::abs(collision.posZ()) > 10.f) { - return; + if (requireTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; } - histos.fill(HIST("hEventSelection"), 2 /* vertex-Z selected */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 2 /* FT0 vertex (acceptable FT0C-FT0A time difference) collisions */); if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); + + if (std::abs(collision.posZ()) > maxZVtxPosition) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 5 /* vertex-Z selected */); if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 5 /* Contains at least one ITS-TPC track */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 6 /* Contains at least one ITS-TPC track */); if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 6 /* PV position consistency check */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 7 /* PV position consistency check */); if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 7 /* PV with at least one contributor matched with TOF */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TOF */); if (requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TRD */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 9 /* PV with at least one contributor matched with TRD */); if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return; + return false; } - histos.fill(HIST("hEventSelection"), 9 /* Not at same bunch pile-up */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 10 /* Not at same bunch pile-up */); - if (requireNoHighOccupancyAgressive && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyAgressive)) { - return; + if (requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; } - histos.fill(HIST("hEventSelection"), 10 /* No occupancy according to the aggressive cuts */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 11 /* No other collision within +/- 2 microseconds or mult above a certain threshold in -4 - -2 microseconds*/); - if (requireNoHighOccupancyStrict && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyStrict)) { - return; + if (requireNoCollInTimeRangeStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStrict)) { + return false; } - histos.fill(HIST("hEventSelection"), 11 /* No occupancy according to the strict cuts */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 12 /* No other collision within +/- 10 microseconds */); - if (requireNoHighOccupancyMedium && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyMedium)) { - return; + if (requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { + return false; } - histos.fill(HIST("hEventSelection"), 12 /* No occupancy according to the medium cuts */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 13 /* No other collision within +/- 2 microseconds */); - if (requireNoHighOccupancyRelaxed && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyRelaxed)) { - return; + if (requireNoCollInTimeRangeVzDep && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeVzDependent)) { + return false; } - histos.fill(HIST("hEventSelection"), 13 /* No occupancy according to the relaxed cuts */); + 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 (requireNoHighOccupancyGentle && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyGentle)) { - return; + if (requireNoCollInROFStd && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + return false; } - histos.fill(HIST("hEventSelection"), 14 /* No occupancy according to the gentle cuts */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 15 /* No other collision within the same ITS ROF with mult. above a certain threshold */); - if (requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return; + if (requireNoCollInROFStrict && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStrict)) { + return false; } - histos.fill(HIST("hEventSelection"), 15 /* No other collision within +/- 10 microseconds */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 16 /* No other collision within the same ITS ROF */); - if (requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { - return; + float collisionOccupancy = useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + if (minOccupancy > 0 && collisionOccupancy < minOccupancy) { + return false; } - histos.fill(HIST("hEventSelection"), 16 /* No other collision within +/- 4 microseconds */); + if (fillHists) + histos.fill(HIST("hEventSelection"), 17 /* Below min occupancy */); - if (minOccupancy > 0 && collision.trackOccupancyInTimeRange() < minOccupancy) { - return; + if (maxOccupancy > 0 && collisionOccupancy > maxOccupancy) { + return false; + } + if (fillHists) + histos.fill(HIST("hEventSelection"), 18 /* Above max occupancy */); + + 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; } - histos.fill(HIST("hEventSelection"), 17 /* Below min occupancy */); - if (maxOccupancy > 0 && collision.trackOccupancyInTimeRange() > maxOccupancy) { + 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("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 = collision.centFT0C(); + } + nCollisions++; + + atLeastOne = true; + } + + histos.fill(HIST("hCentralityVsNcoll_beforeEvSel"), centrality, groupedCollisions.size()); + histos.fill(HIST("hCentralityVsNcoll_afterEvSel"), centrality, nCollisions); + + histos.fill(HIST("hCentralityVsMultMC"), centrality, mcCollision.multMCNParticlesEta05()); + + if (atLeastOne) { + histos.fill(HIST("hGenEvents"), mcCollision.multMCNParticlesEta05(), 1 /* at least 1 rec. event*/); + + histos.fill(HIST("hGenEventCentrality"), centrality); + } + } + return; + } + + // ______________________________________________________ + // Real data processing - no MC subscription + void processRealData(soa::Join::iterator const& collision, v0Candidates const& fullV0s, dauTracks const&) + { + // Fire up CCDB + if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || + (mlConfigurations.useLambdaScores && mlConfigurations.calculateLambdaScores) || + (mlConfigurations.useAntiLambdaScores && mlConfigurations.calculateAntiLambdaScores)) { + initCCDB(collision); + } + + if (!IsEventAccepted(collision, true)) { return; } - histos.fill(HIST("hEventSelection"), 18 /* Above max occupancy */); float centrality = collision.centFT0C(); if (qaCentrality) { auto hRawCentrality = histos.get(HIST("hRawCentrality")); centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0C())); } + float collisionOccupancy = useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + // 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()); - histos.fill(HIST("hEventOccupancy"), collision.trackOccupancyInTimeRange()); - histos.fill(HIST("hCentralityVsOccupancy"), centrality, collision.trackOccupancyInTimeRange()); + histos.fill(HIST("hEventOccupancy"), collisionOccupancy); + histos.fill(HIST("hCentralityVsOccupancy"), centrality, collisionOccupancy); // __________________________________________ // perform main analysis + int nK0Shorts = 0; + int nLambdas = 0; + int nAntiLambdas = 0; for (auto& v0 : fullV0s) { - if (std::abs(v0.negativeeta()) > daughterEtaCut || std::abs(v0.positiveeta()) > daughterEtaCut) + 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() != v0TypeSelection && v0TypeSelection > -1) + if (v0.v0Type() != v0Selections.v0TypeSelection && v0Selections.v0TypeSelection > -1) continue; // skip V0s that are not standard // fill AP plot for all V0s @@ -1178,135 +1593,88 @@ struct derivedlambdakzeroanalysis { 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); - analyseCandidate(v0, v0.pt(), centrality, selMap); + analyseCandidate(v0, v0.pt(), centrality, selMap, selGapSide, nK0Shorts, nLambdas, nAntiLambdas); } // end v0 loop - } - - // ______________________________________________________ - // 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*/) - { - histos.fill(HIST("hEventSelection"), 0. /* all collisions */); - if (!collision.sel8()) { - return; - } - histos.fill(HIST("hEventSelection"), 1 /* sel8 collisions */); - - if (std::abs(collision.posZ()) > 10.f) { - return; - } - histos.fill(HIST("hEventSelection"), 2 /* vertex-Z selected */); - - if (rejectITSROFBorder && !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - return; - } - histos.fill(HIST("hEventSelection"), 3 /* Not at ITS ROF border */); - - if (rejectTFBorder && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - return; - } - histos.fill(HIST("hEventSelection"), 4 /* Not at TF border */); - - if (requireIsVertexITSTPC && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - return; - } - histos.fill(HIST("hEventSelection"), 5 /* Contains at least one ITS-TPC track */); - - if (requireIsGoodZvtxFT0VsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return; - } - histos.fill(HIST("hEventSelection"), 6 /* PV position consistency check */); - - if (requireIsVertexTOFmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTOFmatched)) { - return; - } - histos.fill(HIST("hEventSelection"), 7 /* PV with at least one contributor matched with TOF */); - if (requireIsVertexTRDmatched && !collision.selection_bit(o2::aod::evsel::kIsVertexTRDmatched)) { - return; - } - histos.fill(HIST("hEventSelection"), 8 /* PV with at least one contributor matched with TRD */); - - if (rejectSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - return; - } - histos.fill(HIST("hEventSelection"), 9 /* Not at same bunch pile-up */); - - if (requireNoHighOccupancyAgressive && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyAgressive)) { - return; - } - histos.fill(HIST("hEventSelection"), 10 /* No occupancy according to the aggressive cuts */); - - if (requireNoHighOccupancyStrict && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyStrict)) { - return; - } - histos.fill(HIST("hEventSelection"), 11 /* No occupancy according to the strict cuts */); - - if (requireNoHighOccupancyMedium && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyMedium)) { - return; - } - histos.fill(HIST("hEventSelection"), 12 /* No occupancy according to the medium cuts */); - - if (requireNoHighOccupancyRelaxed && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyRelaxed)) { - return; + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + if (analyseK0Short) { + histos.fill(HIST("h2dNbrOfK0ShortVsCentrality"), centrality, nK0Shorts); } - histos.fill(HIST("hEventSelection"), 13 /* No occupancy according to the relaxed cuts */); - - if (requireNoHighOccupancyGentle && !collision.selection_bit(o2::aod::evsel::kNoHighOccupancyGentle)) { - return; + if (analyseLambda) { + histos.fill(HIST("h2dNbrOfLambdaVsCentrality"), centrality, nLambdas); } - histos.fill(HIST("hEventSelection"), 14 /* No occupancy according to the gentle cuts */); - - if (requireNoCollInTimeRangeStd && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return; + if (analyseAntiLambda) { + histos.fill(HIST("h2dNbrOfAntiLambdaVsCentrality"), centrality, nAntiLambdas); } - histos.fill(HIST("hEventSelection"), 15 /* No other collision within +/- 10 microseconds */); + } - if (requireNoCollInTimeRangeNarrow && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { - return; + // ______________________________________________________ + // 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&) + { + // Fire up CCDB + if ((mlConfigurations.useK0ShortScores && mlConfigurations.calculateK0ShortScores) || + (mlConfigurations.useLambdaScores && mlConfigurations.calculateLambdaScores) || + (mlConfigurations.useAntiLambdaScores && mlConfigurations.calculateAntiLambdaScores)) { + initCCDB(collision); } - histos.fill(HIST("hEventSelection"), 16 /* No other collision within +/- 4 microseconds */); - if (minOccupancy > 0 && collision.trackOccupancyInTimeRange() < minOccupancy) { + if (!IsEventAccepted(collision, true)) { return; } - histos.fill(HIST("hEventSelection"), 17 /* Below min occupancy */); - if (maxOccupancy > 0 && collision.trackOccupancyInTimeRange() > maxOccupancy) { - return; - } - histos.fill(HIST("hEventSelection"), 18 /* Above max occupancy */); float centrality = collision.centFT0C(); if (qaCentrality) { auto hRawCentrality = histos.get(HIST("hRawCentrality")); centrality = hRawCentrality->GetBinContent(hRawCentrality->FindBin(collision.multFT0C())); } + float collisionOccupancy = useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + // 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()); - histos.fill(HIST("hEventOccupancy"), collision.trackOccupancyInTimeRange()); - histos.fill(HIST("hCentralityVsOccupancy"), centrality, collision.trackOccupancyInTimeRange()); + histos.fill(HIST("hEventOccupancy"), collisionOccupancy); + histos.fill(HIST("hCentralityVsOccupancy"), centrality, collisionOccupancy); // __________________________________________ // perform main analysis + int nK0Shorts = 0; + int nLambdas = 0; + int nAntiLambdas = 0; for (auto& v0 : fullV0s) { - if (std::abs(v0.negativeeta()) > daughterEtaCut || std::abs(v0.positiveeta()) > daughterEtaCut) + 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.has_v0MCCore()) + continue; + + auto v0MC = v0.v0MCCore_as>(); + // fill AP plot for all V0s histos.fill(HIST("GeneralQA/h2dArmenterosAll"), v0.alpha(), v0.qtarm()); - float ptmc = RecoDecay::sqrtSumOfSquares(v0.pxPosMC() + v0.pxNegMC(), v0.pyPosMC() + v0.pyNegMC()); + float ptmc = RecoDecay::sqrtSumOfSquares(v0MC.pxPosMC() + v0MC.pxNegMC(), v0MC.pyPosMC() + v0MC.pyNegMC()); float ymc = 1e-3; - if (v0.pdgCode() == 310) - ymc = RecoDecay::y(std::array{v0.pxPosMC() + v0.pxNegMC(), v0.pyPosMC() + v0.pyNegMC(), v0.pzPosMC() + v0.pzNegMC()}, o2::constants::physics::MassKaonNeutral); - else if (TMath::Abs(v0.pdgCode()) == 3122) - ymc = RecoDecay::y(std::array{v0.pxPosMC() + v0.pxNegMC(), v0.pyPosMC() + v0.pyNegMC(), v0.pzPosMC() + v0.pzNegMC()}, o2::constants::physics::MassLambda); + 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) + 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); - selMap = selMap | computeMCAssociation(v0); + selMap = selMap | computeMCAssociation(v0MC); // feeddown matrix always with association if (calculateFeeddownMatrix) @@ -1318,7 +1686,7 @@ struct derivedlambdakzeroanalysis { selMap = selMap | (uint64_t(1) << selPhysPrimK0Short) | (uint64_t(1) << selPhysPrimLambda) | (uint64_t(1) << selPhysPrimAntiLambda); } - analyseCandidate(v0, ptmc, centrality, selMap); + analyseCandidate(v0, ptmc, centrality, selMap, selGapSide, nK0Shorts, nLambdas, nAntiLambdas); if (doCollisionAssociationQA) { // check collision association explicitly @@ -1327,12 +1695,126 @@ struct derivedlambdakzeroanalysis { if (collision.has_straMCCollision()) { auto mcCollision = collision.straMCCollision_as>(); mcNch = mcCollision.multMCNParticlesEta05(); - correctCollision = (v0.straMCCollisionId() == mcCollision.globalIndex()); + correctCollision = (v0MC.straMCCollisionId() == mcCollision.globalIndex()); } analyseCollisionAssociation(v0, ptmc, mcNch, correctCollision, selMap); } } // end v0 loop + + // fill the histograms with the number of reconstructed K0s/Lambda/antiLambda per collision + if (analyseK0Short) { + histos.fill(HIST("h2dNbrOfK0ShortVsCentrality"), centrality, nK0Shorts); + } + if (analyseLambda) { + histos.fill(HIST("h2dNbrOfLambdaVsCentrality"), centrality, nLambdas); + } + if (analyseAntiLambda) { + histos.fill(HIST("h2dNbrOfAntiLambdaVsCentrality"), centrality, nAntiLambdas); + } + } + + // ______________________________________________________ + // 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>(); + float centrality = 100.5f; + if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); + centrality = collision.centFT0C(); + float collisionOccupancy = useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + if (minOccupancy > 0 && collisionOccupancy < minOccupancy) { + continue; + } + if (maxOccupancy > 0 && collisionOccupancy > maxOccupancy) { + continue; + } + } + + if (v0MC.pdgCode() == 310) { + histos.fill(HIST("h2dGenK0Short"), centrality, ptmc); + histos.fill(HIST("h2dGenK0ShortVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == 3122) { + histos.fill(HIST("h2dGenLambda"), centrality, ptmc); + histos.fill(HIST("h2dGenLambdaVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (v0MC.pdgCode() == -3122) { + histos.fill(HIST("h2dGenAntiLambda"), centrality, ptmc); + histos.fill(HIST("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>(); + float centrality = 100.5f; + if (listBestCollisionIdx[mcCollision.globalIndex()] > -1) { + auto collision = collisions.iteratorAt(listBestCollisionIdx[mcCollision.globalIndex()]); + centrality = collision.centFT0C(); + float collisionOccupancy = useFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + + if (minOccupancy > 0 && collisionOccupancy < minOccupancy) { + continue; + } + if (maxOccupancy > 0 && collisionOccupancy > maxOccupancy) { + continue; + } + } + + if (cascMC.pdgCode() == 3312) { + histos.fill(HIST("h2dGenXiMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenXiMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3312) { + histos.fill(HIST("h2dGenXiPlus"), centrality, ptmc); + histos.fill(HIST("h2dGenXiPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == 3334) { + histos.fill(HIST("h2dGenOmegaMinus"), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaMinusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + if (cascMC.pdgCode() == -3334) { + histos.fill(HIST("h2dGenOmegaPlus"), centrality, ptmc); + histos.fill(HIST("h2dGenOmegaPlusVsMultMC"), mcCollision.multMCNParticlesEta05(), ptmc); + } + } } // ______________________________________________________ @@ -1342,59 +1824,59 @@ struct derivedlambdakzeroanalysis { aod::GeXiMinus const& geXiMinus, aod::GeXiPlus const& geXiPlus, aod::GeOmegaMinus const& geOmegaMinus, aod::GeOmegaPlus const& geOmegaPlus) { - auto hK0Short = histos.get(HIST("h2dGenK0Short")); - auto hLambda = histos.get(HIST("h2dGenLambda")); - auto hAntiLambda = histos.get(HIST("h2dGenAntiLambda")); - auto hXiMinus = histos.get(HIST("h2dGenXiMinus")); - auto hXiPlus = histos.get(HIST("h2dGenXiPlus")); - auto hOmegaMinus = histos.get(HIST("h2dGenOmegaMinus")); - auto hOmegaPlus = histos.get(HIST("h2dGenOmegaPlus")); + auto hK0Short = histos.get(HIST("h2dGeneratedK0Short")); + auto hLambda = histos.get(HIST("h2dGeneratedLambda")); + auto hAntiLambda = histos.get(HIST("h2dGeneratedAntiLambda")); + auto hXiMinus = histos.get(HIST("h2dGeneratedXiMinus")); + auto hXiPlus = histos.get(HIST("h2dGeneratedXiPlus")); + auto hOmegaMinus = histos.get(HIST("h2dGeneratedOmegaMinus")); + auto hOmegaPlus = histos.get(HIST("h2dGeneratedOmegaPlus")); for (auto& gVec : geK0Short) { - if (gVec.generatedK0Short().size() != hK0Short->GetNcells()) + 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 (uint64_t iv = 0; iv < hK0Short->GetNcells(); iv++) { + for (int iv = 0; iv < hK0Short->GetNcells(); iv++) { hK0Short->SetBinContent(iv, hK0Short->GetBinContent(iv) + gVec.generatedK0Short()[iv]); } } for (auto& gVec : geLambda) { - if (gVec.generatedLambda().size() != hLambda->GetNcells()) + 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 (uint64_t iv = 0; iv < hLambda->GetNcells(); iv++) { + for (int iv = 0; iv < hLambda->GetNcells(); iv++) { hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]); } } for (auto& gVec : geAntiLambda) { - if (gVec.generatedAntiLambda().size() != hAntiLambda->GetNcells()) + 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 (uint64_t iv = 0; iv < hAntiLambda->GetNcells(); iv++) { + for (int iv = 0; iv < hAntiLambda->GetNcells(); iv++) { hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]); } } for (auto& gVec : geXiMinus) { - if (gVec.generatedXiMinus().size() != hXiMinus->GetNcells()) + 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 (uint64_t iv = 0; iv < hXiMinus->GetNcells(); iv++) { + for (int iv = 0; iv < hXiMinus->GetNcells(); iv++) { hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]); } } for (auto& gVec : geXiPlus) { - if (gVec.generatedXiPlus().size() != hXiPlus->GetNcells()) + 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 (uint64_t iv = 0; iv < hXiPlus->GetNcells(); iv++) { + for (int iv = 0; iv < hXiPlus->GetNcells(); iv++) { hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]); } } for (auto& gVec : geOmegaMinus) { - if (gVec.generatedOmegaMinus().size() != hOmegaMinus->GetNcells()) + 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 (uint64_t iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { + for (int iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]); } } for (auto& gVec : geOmegaPlus) { - if (gVec.generatedOmegaPlus().size() != hOmegaPlus->GetNcells()) + 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 (uint64_t iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { + for (int iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { hOmegaPlus->SetBinContent(iv, hOmegaPlus->GetBinContent(iv) + gVec.generatedOmegaPlus()[iv]); } } @@ -1403,6 +1885,7 @@ struct derivedlambdakzeroanalysis { PROCESS_SWITCH(derivedlambdakzeroanalysis, processRealData, "process as if real data", true); PROCESS_SWITCH(derivedlambdakzeroanalysis, processMonteCarlo, "process as if MC", false); PROCESS_SWITCH(derivedlambdakzeroanalysis, processBinnedGenerated, "process MC generated", false); + PROCESS_SWITCH(derivedlambdakzeroanalysis, processGenerated, "process MC generated", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx b/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx index 4ca2287ccd1..01d843fa74e 100644 --- a/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx +++ b/PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx @@ -20,6 +20,8 @@ /// \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" @@ -28,6 +30,7 @@ #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/PIDResponse.h" #include "Framework/ASoAHelpers.h" +#include "Framework/O2DatabasePDGPlugin.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" #include "Framework/StaticFor.h" @@ -42,13 +45,15 @@ using namespace o2::framework::expressions; #define bitset(var, nbit) ((var) |= (1 << (nbit))) #define bitcheck(var, nbit) ((var) & (1 << (nbit))) -using TracksComplete = soa::Join; +using TracksComplete = soa::Join; using V0DatasWithoutTrackX = soa::Join; struct correlateStrangeness { // for efficiency corrections if requested Service ccdb; + Service pdgDB; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Configurable doCorrelationK0Short{"doCorrelationK0Short", true, "do K0Short correlation"}; @@ -59,14 +64,20 @@ struct correlateStrangeness { Configurable doCorrelationOmegaMinus{"doCorrelationOmegaMinus", false, "do OmegaMinus correlation"}; Configurable doCorrelationOmegaPlus{"doCorrelationOmegaPlus", false, "do OmegaPlus correlation"}; Configurable doCorrelationPion{"doCorrelationPion", false, "do Pion correlation"}; + 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 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 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 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"}; + // 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"}; @@ -78,13 +89,60 @@ struct correlateStrangeness { ConfigurableAxis axisPtTrigger{"axisPtTrigger", {VARIABLE_WIDTH, 0.0, 1.0, 2.0, 3.0, 100}, "pt associated axis for histograms"}; ConfigurableAxis axisPtQA{"axisPtQA", {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 axisMultCount{"axisMultCount", {VARIABLE_WIDTH, 0, 200, 400, 600, 800, 1000, 1400, 1800, 2300, 2800, 3300, 4000, 5000, 6000}, "Mixing bins - multiplicity"}; + ConfigurableAxis axisMassNSigma{"axisMassNSigma", {40, -2, 2}, "Axis for mass Nsigma"}; + + // for topo var QA + struct : ConfigurableGroup { + Configurable maxPeakNSigma{"maxPeakNSigma", 5, "Peak region edge definition (in sigma)"}; + Configurable minBgNSigma{"minBgNSigma", 5, "Bg region edge closest to peak (in sigma)"}; + Configurable maxBgNSigma{"maxBgNSigma", 10, "Bg region edge furthest to peak (in sigma)"}; + } massWindowConfigurations; // allows for gap between peak and bg in case someone wants to // 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 efficiencyCCDBPath{"efficiencyCCDBPath", "GLO/Config/GeometryAligned", "Path of the efficiency corrections"}; + // Configurables for doing subwagon systematics + // Group all settings necessary for systematics in a specific ConfigurableGroup + struct : ConfigurableGroup { + std::string prefix = "systematics"; + // --- Track quality variations (single track, both trigger and assoc daughters) + 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 triggerMaxTPCSharedClusters{"triggerMaxTPCSharedClusters", 200, "maximum number of shared TPC clusters (inclusive)"}; + Configurable triggerRequireL0{"triggerRequireL0", false, "require ITS L0 cluster for trigger"}; + + // --- 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"}; + + // --- 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 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"}; + + // 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"}; + + // dE/dx for associated daughters + Configurable dEdxCompatibility{"dEdxCompatibility", 1, "0: loose, 1: normal, 2: tight. Defined in hStrangeCorrelationFilter"}; + + // (N.B.: sources that can be investigated in post are not listed!) + } systCuts; + // objects to use for efficiency corrections + TH2F* hEfficiencyTrigger; TH2F* hEfficiencyPion; TH2F* hEfficiencyK0Short; TH2F* hEfficiencyLambda; @@ -106,7 +164,8 @@ struct correlateStrangeness { 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[] = {"Pion", "K0Short", "Lambda", "AntiLambda", "XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus"}; + static constexpr std::string_view particlenames[] = {"K0Short", "Lambda", "AntiLambda", "XiMinus", "XiPlus", "OmegaMinus", "OmegaPlus", "Pion"}; + static constexpr int pdgCodes[] = {310, 3122, -3122, 3312, -3312, 3334, -3334, 211}; uint8_t doCorrelation; int mRunNumber; @@ -145,6 +204,7 @@ struct correlateStrangeness { LOG(fatal) << "Problem getting TList object with efficiencies!"; } + hEfficiencyTrigger = static_cast(listEfficiencies->FindObject("hEfficiencyTrigger")); hEfficiencyK0Short = static_cast(listEfficiencies->FindObject("hEfficiencyK0Short")); hEfficiencyLambda = static_cast(listEfficiencies->FindObject("hEfficiencyLambda")); hEfficiencyAntiLambda = static_cast(listEfficiencies->FindObject("hEfficiencyAntiLambda")); @@ -154,16 +214,63 @@ struct correlateStrangeness { hEfficiencyOmegaPlus = static_cast(listEfficiencies->FindObject("hEfficiencyOmegaPlus")); LOG(info) << "Efficiencies now loaded for " << mRunNumber; } - + template + bool isValidTrigger(TTrack track) + { + if (track.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsTrigger) { + return false; // crossed rows + } + if (!track.hasITS() && systCuts.triggerRequireITS) { + return false; // skip, doesn't have ITS signal (skips lots of TPC-only!) + } + if (track.tpcNClsShared() > systCuts.triggerMaxTPCSharedClusters) { + return false; // skip, has shared clusters + } + if (!(bitcheck(track.itsClusterMap(), 0)) && systCuts.triggerRequireL0) { + return false; // skip, doesn't have cluster in ITS L0 + } + // systematic variations: trigger DCAxy + if (std::abs(track.dcaXY()) > systCuts.dcaXYconstant + systCuts.dcaXYpTdep * std::abs(track.signed1Pt())) { + return false; + } + if (track.pt() > axisRanges[3][1] || track.pt() < axisRanges[3][0]) { + return false; + } + if (triggerParticleCharge > 0 && track.sign() < 0) { + return false; + } + if (triggerParticleCharge < 0 && track.sign() > 0) { + return false; + } + return true; + } void fillCorrelationsV0(aod::TriggerTracks const& triggers, aod::AssocV0s const& assocs, bool mixing, float pvz, float mult) { for (auto& triggerTrack : triggers) { + if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) + continue; auto trigg = triggerTrack.track_as(); - if (!mixing) - histos.fill(HIST("sameEvent/TriggerParticlesV0"), trigg.pt(), mult); + if (!isValidTrigger(trigg)) + continue; + + if (!mixing) { + float efficiency = 1.0f; + if (applyEfficiencyForTrigger) { + efficiency = hEfficiencyTrigger->Interpolate(trigg.pt(), trigg.eta()); + } + float weight = (applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; + histos.fill(HIST("sameEvent/TriggerParticlesV0"), trigg.pt(), mult, weight); + } + for (auto& 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) + continue; + //---] removing autocorrelations [--- auto postrack = assoc.posTrack_as(); auto negtrack = assoc.negTrack_as(); @@ -178,6 +285,10 @@ struct correlateStrangeness { } } + //---] track quality check [--- + if (postrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || negtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) + continue; + float deltaphi = ComputeDeltaPhi(trigg.phi(), assoc.phi()); float deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); @@ -190,8 +301,7 @@ struct correlateStrangeness { continue; if (ptassoc < axisRanges[2][0] || ptassoc > axisRanges[2][1]) continue; - if (pttrigger < axisRanges[3][0] || pttrigger > axisRanges[3][1]) - continue; + TH2F* hEfficiencyV0[3]; hEfficiencyV0[0] = hEfficiencyK0Short; hEfficiencyV0[1] = hEfficiencyLambda; @@ -200,21 +310,34 @@ struct correlateStrangeness { constexpr int index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyV0[index]->GetBinContent(hEfficiencyV0[index]->GetXaxis()->FindBin(ptassoc), hEfficiencyV0[index]->GetYaxis()->FindBin(assoc.eta())); + efficiency = hEfficiencyV0[index]->Interpolate(ptassoc, assoc.eta()); } - float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; + if (applyEfficiencyForTrigger) { + efficiency = efficiency * hEfficiencyTrigger->Interpolate(pttrigger, trigg.eta()); + } + + float weight = (applyEfficiencyCorrection || applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; if (bitcheck(doCorrelation, index) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (assocCandidate.compatible(index) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 1)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 2)) + 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 (assocCandidate.compatible(index) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 3)) + 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()); + } + 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 (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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 1)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 2)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 3)) + 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); } }); @@ -222,15 +345,39 @@ struct correlateStrangeness { } } - void fillCorrelationsCascade(aod::TriggerTracks const& triggers, aod::AssocCascades const& assocs, bool mixing, float pvz, float mult) + void fillCorrelationsCascade(aod::TriggerTracks const& triggers, aod::AssocCascades const& assocs, bool mixing, float pvx, float pvy, float pvz, float mult) { for (auto& triggerTrack : triggers) { + if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) + continue; auto trigg = triggerTrack.track_as(); - if (!mixing) - histos.fill(HIST("sameEvent/TriggerParticlesCascade"), trigg.pt(), mult); + if (!isValidTrigger(trigg)) + continue; + + if (!mixing) { + float efficiency = 1.0f; + if (applyEfficiencyForTrigger) { + efficiency = hEfficiencyTrigger->Interpolate(trigg.pt(), trigg.eta()); + } + float weight = (applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; + histos.fill(HIST("sameEvent/TriggerParticlesCascade"), trigg.pt(), mult, weight); + } for (auto& 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) + continue; + //---] removing autocorrelations [--- auto postrack = assoc.posTrack_as(); auto negtrack = assoc.negTrack_as(); @@ -250,6 +397,10 @@ struct correlateStrangeness { } } + //---] 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 deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); @@ -262,8 +413,7 @@ struct correlateStrangeness { continue; if (ptassoc < axisRanges[2][0] || ptassoc > axisRanges[2][1]) continue; - if (pttrigger < axisRanges[3][0] || pttrigger > axisRanges[3][1]) - continue; + TH2F* hEfficiencyCascade[4]; hEfficiencyCascade[0] = hEfficiencyXiMinus; hEfficiencyCascade[1] = hEfficiencyXiPlus; @@ -276,19 +426,22 @@ struct correlateStrangeness { if (applyEfficiencyCorrection) { efficiency = hEfficiencyCascade[index]->GetBinContent(hEfficiencyCascade[index]->GetXaxis()->FindBin(ptassoc), hEfficiencyCascade[index]->GetYaxis()->FindBin(assoc.eta())); } - float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; + if (applyEfficiencyForTrigger) { + efficiency = efficiency * hEfficiencyTrigger->Interpolate(pttrigger, trigg.eta()); + } + float weight = (applyEfficiencyCorrection || applyEfficiencyForTrigger) ? 1. / efficiency : 1.0f; if (bitcheck(doCorrelation, index + 3) && (!applyEfficiencyCorrection || efficiency != 0)) { - if (assocCandidate.compatible(index) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 1)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 2)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && !mixing && assocCandidate.invMassRegionCheck(index, 3)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 1)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 2)) + 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) && (!doMCassociation || assocCandidate.mcTrue(index)) && mixing && assocCandidate.invMassRegionCheck(index, 3)) + 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); } }); @@ -300,7 +453,12 @@ struct correlateStrangeness { { for (auto& triggerTrack : triggers) { + if (doTriggPhysicalPrimary && !triggerTrack.mcPhysicalPrimary()) + continue; auto trigg = triggerTrack.track_as(); + if (!isValidTrigger(trigg)) + continue; + if (!mixing) histos.fill(HIST("sameEvent/TriggerParticlesPion"), trigg.pt(), mult); for (auto& assocTrack : assocs) { @@ -314,6 +472,10 @@ struct correlateStrangeness { } } + //---] track quality check [--- + if (assoc.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) + continue; + float deltaphi = ComputeDeltaPhi(trigg.phi(), assoc.phi()); float deltaeta = trigg.eta() - assoc.eta(); float ptassoc = assoc.pt(); @@ -326,8 +488,6 @@ struct correlateStrangeness { continue; if (ptassoc < axisRanges[2][0] || ptassoc > axisRanges[2][1]) continue; - if (pttrigger < axisRanges[3][0] || pttrigger > axisRanges[3][1]) - continue; if (!mixing) histos.fill(HIST("sameEvent/Pion"), deltaphi, deltaeta, ptassoc, pttrigger, pvz, mult); @@ -518,72 +678,15 @@ struct correlateStrangeness { const AxisSpec axisVtxZNDim{edgesVtxZ, "vertex Z (cm)"}; const AxisSpec axisMultNDim{edgesMult, "mult percentile"}; - if (bitcheck(doCorrelation, 0)) { - histos.add("h3dK0ShortSpectrum", "h3dK0ShortSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dK0ShortSpectrumY", "h3dK0ShortSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hK0ShortEtaVsPtVsPhi", "hK0ShortEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hK0ShortEtaVsPtVsPhiBg", "hK0ShortEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/K0Short", "K0Short", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 1)) { - histos.add("h3dLambdaSpectrum", "h3dLambdaSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dLambdaSpectrumY", "h3dLambdaSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hLambdaEtaVsPtVsPhi", "hLambdaEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hLambdaEtaVsPtVsPhiBg", "hLambdaEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/Lambda", "Lambda", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 2)) { - histos.add("h3dAntiLambdaSpectrum", "h3dAntiLambdaSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dAntiLambdaSpectrumY", "h3dAntiLambdaSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hAntiLambdaEtaVsPtVsPhi", "hAntiLambdaEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hAntiLambdaEtaVsPtVsPhiBg", "hAntiLambdaEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/AntiLambda", "AntiLambda", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 3)) { - histos.add("h3dXiMinusSpectrum", "h3dXiMinusSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dXiMinusSpectrumY", "h3dXiMinusSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hXiMinusEtaVsPtVsPhi", "hXiMinusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hXiMinusEtaVsPtVsPhiBg", "hXiMinusEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/XiMinus", "XiMinus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 4)) { - histos.add("h3dXiPlusSpectrum", "h3dXiPlusSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dXiPlusSpectrumY", "h3dXiPlusSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hXiPlusEtaVsPtVsPhi", "hXiPlusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hXiPlusEtaVsPtVsPhiBg", "hXiPlusEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/XiPlus", "XiPlus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 5)) { - histos.add("h3dOmegaMinusSpectrum", "h3dOmegaMinusSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dOmegaMinusSpectrumY", "h3dOmegaMinusSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hOmegaMinusEtaVsPtVsPhi", "hOmegaMinusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hOmegaMinusEtaVsPtVsPhiBg", "hOmegaMinusEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/OmegaMinus", "OmegaMinus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 6)) { - histos.add("h3dOmegaPlusSpectrum", "h3dOmegaPlusSpectrum", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("h3dOmegaPlusSpectrumY", "h3dOmegaPlusSpectrumY", kTH3F, {axisPtQA, axisMult, {3, 0.5f, 3.5f}}); - histos.add("hOmegaPlusEtaVsPtVsPhi", "hOmegaPlusEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("hOmegaPlusEtaVsPtVsPhiBg", "hOmegaPlusEtaVsPtVsPhiBg", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("sameEvent/Signal/OmegaPlus", "OmegaPlus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - } - if (bitcheck(doCorrelation, 7)) { - histos.add("sameEvent/Pion", "Pion", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultNDim}); - histos.add("hPionEtaVsPtVsPhi", "hPionEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); - } - LOGF(info, "Init THnFs done"); - if (doCorrelationK0Short || doCorrelationLambda || doCorrelationAntiLambda || doCorrelationXiMinus || doCorrelationXiPlus || doCorrelationOmegaMinus || doCorrelationOmegaPlus) { - histos.addClone("sameEvent/Signal/", "sameEvent/LeftBg/"); - histos.addClone("sameEvent/Signal/", "sameEvent/RightBg/"); - } + // 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}}); - // mixed-event correlation functions - if (doprocessMixedEventHV0s || doprocessMixedEventHCascades || doprocessMixedEventHPions) { - histos.addClone("sameEvent/", "mixedEvent/"); - } + histos.add("hTriggerAllSelectedEtaVsPt", "hTriggerAllSelectedEtaVsPt", kTH3F, {axisPtQA, axisEta, axisMult}); - // Some QA plots - histos.add("hTrackEtaVsPtVsPhi", "hTrackEtaVsPtVsPhi", kTH3F, {axisPtQA, axisEta, axisPhi}); + histos.add("hClosureTestEventCounter", "hClosureTestEventCounter", kTH1F, {{10, 0, 10}}); histos.add("hNumberOfRejectedPairsV0", "hNumberOfRejectedPairsV0", kTH1F, {{1, 0, 1}}); histos.add("hNumberOfRejectedPairsCascades", "hNumberOfRejectedPairsCascades", kTH1F, {{1, 0, 1}}); @@ -603,57 +706,69 @@ struct correlateStrangeness { 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}); + + bool hStrange = false; + for (int i = 0; i < 8; i++) { + if ((doprocessSameEventHV0s && i < 3) || (doprocessSameEventHCascades && i > 2 && i < 7) || (doprocessSameEventHPions && i == 7)) + histos.add(fmt::format("h{}EtaVsPtVsPhi", particlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); + if ((doprocessSameEventHV0s && i < 3) || (doprocessSameEventHCascades && i > 2 && i < 7)) + histos.add(fmt::format("h{}EtaVsPtVsPhiBg", particlenames[i]).c_str(), "", kTH3F, {axisPtQA, axisEta, axisPhi}); + if (bitcheck(doCorrelation, i)) { + 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("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 (i < 7) + hStrange = true; + } + } + if (hStrange) { + histos.addClone("sameEvent/Signal/", "sameEvent/LeftBg/"); + histos.addClone("sameEvent/Signal/", "sameEvent/RightBg/"); + } + + LOGF(info, "Init THnFs done"); + // mixed-event correlation functions + if (doprocessMixedEventHV0s || doprocessMixedEventHCascades || doprocessMixedEventHPions) { + histos.addClone("sameEvent/", "mixedEvent/"); + } // MC generated plots if (doprocessMCGenerated) { - histos.add("Generated/hPion", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hK0Short", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hLambda", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hAntiLambda", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hXiMinus", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hXiPlus", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hOmegaMinus", "", kTH2F, {axisPtQA, axisEta}); - histos.add("Generated/hOmegaPlus", "", kTH2F, {axisPtQA, axisEta}); - + 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}); + } histos.addClone("Generated/", "GeneratedWithPV/"); // histograms within |y|<0.5, vs multiplicity - histos.add("GeneratedWithPV/hPion_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hK0Short_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hLambda_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hAntiLambda_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hXiMinus_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hXiPlus_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hOmegaMinus_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hOmegaPlus_MidYVsMult", "", kTH2F, {axisPtQA, axisMult}); - - histos.add("GeneratedWithPV/hPion_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hK0Short_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hLambda_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hAntiLambda_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hXiMinus_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hXiPlus_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hOmegaMinus_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - histos.add("GeneratedWithPV/hOmegaPlus_MidYVsMult_TwoPVsOrMore", "", kTH2F, {axisPtQA, axisMult}); - - histos.add("ClosureTest/sameEvent/Pion", "Pion", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/K0Short", "K0Short", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/Lambda", "Lambda", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/AntiLambda", "AntiLambda", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/XiMinus", "XiMinus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/XiPlus", "XiPlus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/OmegaMinus", "OmegaMinus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/sameEvent/OmegaPlus", "OmegaPlus", kTHnF, {axisDeltaPhiNDim, axisDeltaEtaNDim, axisPtAssocNDim, axisPtTriggerNDim, axisVtxZNDim, axisMultCount}); - histos.add("ClosureTest/hTrigger", "Trigger Tracks", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hPion", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hK0Short", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hLambda", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hAntiLambda", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hXiMinus", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hXiPlus", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hOmegaMinus", "", kTH3F, {axisPtQA, axisEta, axisPhi}); - histos.add("ClosureTest/hOmegaPlus", "", kTH3F, {axisPtQA, axisEta, axisPhi}); + 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}); + } + } + 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}); + } + histos.add("ClosureTest/hTrigger", "Trigger Tracks", kTH3F, {axisPtQA, axisEta, axisMult}); } + + // visual inspection of sizes + histos.print(); + // initialize CCDB *only* if efficiency correction requested // skip if not requested, saves a bit of time if (applyEfficiencyCorrection) { @@ -664,10 +779,60 @@ struct correlateStrangeness { } } + // 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) + + // for map determining which trigger bins are present and which aren't + std::vector triggerPresenceMap; + + void processSelectEventWithTrigger(soa::Join const& collisions, + aod::TriggerTracks const& triggerTracks, TracksComplete const&, aod::BCsWithTimestamps const&) + { + // setup + triggerPresenceMap.clear(); + triggerPresenceMap.resize(collisions.size(), 0); + + for (auto const& collision : collisions) { + // ________________________________________________ + // Perform basic event selection + if (!collision.sel8()) { + continue; + } + if (TMath::Abs(collision.posZ()) > zVertexCut) { + continue; + } + if (collision.centFT0M() > axisRanges[5][1] || collision.centFT0M() < axisRanges[5][0]) { + continue; + } + if (!collision.isInelGt0() && selectINELgtZERO) { + continue; + } + + // do not forget to re-group ... + auto slicedTriggerTracks = triggerTracks.sliceBy(collisionSliceTracks, collision.globalIndex()); + + for (auto const& triggerTrack : slicedTriggerTracks) { + auto track = triggerTrack.track_as(); + if (!isValidTrigger(track)) { + continue; + } + auto binNumber = histos.get(HIST("axes/hPtTriggerAxis"))->FindFixBin(track.pt()) - 1; + bitset(triggerPresenceMap[collision.globalIndex()], binNumber); + } + } + } + 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&) { + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + return; + } + // ________________________________________________ // Perform basic event selection if (!collision.sel8()) { @@ -687,8 +852,10 @@ struct correlateStrangeness { 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()); + histos.fill(HIST("EventQA/hMultFT0vsTPC"), collision.centFT0M(), collision.multNTracksPVeta1()); } // Do basic QA + if (applyEfficiencyCorrection) { auto bc = collision.bc_as(); initEfficiencyFromCCDB(bc); @@ -700,28 +867,51 @@ struct correlateStrangeness { 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; + + //---] 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; + static_for<0, 2>([&](auto i) { constexpr int index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyV0[index]->GetBinContent(hEfficiencyV0[index]->GetXaxis()->FindBin(v0Data.pt()), hEfficiencyV0[index]->GetYaxis()->FindBin(v0Data.eta())); + efficiency = hEfficiencyV0[index]->Interpolate(v0Data.pt(), v0Data.eta()); } float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; - if (v0.compatible(index) && (!doMCassociation || v0.mcTrue(index)) && bitcheck(doCorrelation, index) && (!applyEfficiencyCorrection || efficiency != 0)) { - histos.fill(HIST("h3d") + HIST(v0names[index]) + HIST("Spectrum"), v0Data.pt(), collision.centFT0M(), v0.invMassRegion(index), weight); - if (std::abs(v0Data.rapidity(index)) < 0.5) { - histos.fill(HIST("h3d") + HIST(v0names[index]) + HIST("SpectrumY"), v0Data.pt(), collision.centFT0M(), v0.invMassRegion(index), weight); + 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.invMassRegionCheck(index, 2)) - histos.fill(HIST("h") + HIST(v0names[index]) + HIST("EtaVsPtVsPhi"), v0Data.pt(), v0Data.eta(), v0Data.phi(), weight); - if (v0.invMassRegionCheck(index, 1) || v0.invMassRegionCheck(index, 3)) + 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); + } } }); } if (!doprocessSameEventHCascades) { for (auto const& triggerTrack : triggerTracks) { auto track = triggerTrack.track_as(); + if (!isValidTrigger(track)) + continue; + 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()); } } @@ -735,6 +925,12 @@ struct correlateStrangeness { aod::AssocV0s const&, aod::AssocCascades const& associatedCascades, aod::TriggerTracks const& triggerTracks, V0DatasWithoutTrackX const&, aod::V0sLinked const&, aod::CascDatas const&, TracksComplete const&, aod::BCsWithTimestamps const&) { + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + return; + } + // ________________________________________________ // Perform basic event selection if (!collision.sel8()) { @@ -766,38 +962,76 @@ struct correlateStrangeness { for (auto const& casc : associatedCascades) { 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) + continue; + + //---] track quality check [--- + auto postrack = cascData.posTrack_as(); + auto negtrack = cascData.negTrack_as(); + auto bachtrack = cascData.bachelor_as(); + if (postrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || negtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated || bachtrack.tpcNClsCrossedRows() < systCuts.minTPCNCrossedRowsAssociated) + continue; + static_for<0, 3>([&](auto i) { constexpr int index = i.value; float efficiency = 1.0f; if (applyEfficiencyCorrection) { - efficiency = hEfficiencyCascade[index]->GetBinContent(hEfficiencyCascade[index]->GetXaxis()->FindBin(cascData.pt()), hEfficiencyCascade[index]->GetYaxis()->FindBin(cascData.eta())); + efficiency = hEfficiencyCascade[index]->Interpolate(cascData.pt(), cascData.eta()); } float weight = applyEfficiencyCorrection ? 1. / efficiency : 1.0f; - if (casc.compatible(index) && (!doMCassociation || casc.mcTrue(index)) && bitcheck(doCorrelation, index + 3) && (!applyEfficiencyCorrection || efficiency != 0)) { - histos.fill(HIST("h3d") + HIST(cascadenames[index]) + HIST("Spectrum"), cascData.pt(), collision.centFT0M(), casc.invMassRegion(index), weight); - if (std::abs(cascData.rapidity(index)) < 0.5) { - histos.fill(HIST("h3d") + HIST(cascadenames[index]) + HIST("SpectrumY"), cascData.pt(), collision.centFT0M(), casc.invMassRegion(index), weight); + 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.invMassRegionCheck(index, 2)) + 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 (casc.invMassRegionCheck(index, 1) || casc.invMassRegionCheck(index, 3)) + } + + 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); } }); } for (auto const& triggerTrack : triggerTracks) { auto track = triggerTrack.track_as(); + if (!isValidTrigger(track)) + continue; + 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()); } // ________________________________________________ // Do hadron - cascade correlations - fillCorrelationsCascade(triggerTracks, associatedCascades, false, collision.posZ(), collision.centFT0M()); + fillCorrelationsCascade(triggerTracks, associatedCascades, false, collision.posX(), collision.posY(), collision.posZ(), collision.centFT0M()); } void processSameEventHPions(soa::Join::iterator const& collision, aod::AssocPions const& associatedPions, aod::TriggerTracks const& triggerTracks, TracksComplete const&, aod::BCsWithTimestamps const&) { + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && !bitcheck(triggerPresenceMap[collision.globalIndex()], triggerBinToSelect)) { + return; + } + // ________________________________________________ // Perform basic event selection if (!collision.sel8()) { @@ -826,6 +1060,13 @@ struct correlateStrangeness { if (!doprocessSameEventHCascades && !doprocessSameEventHV0s) { for (auto const& triggerTrack : triggerTracks) { auto track = triggerTrack.track_as(); + if (!isValidTrigger(track)) + continue; + 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()); } } @@ -844,6 +1085,12 @@ struct correlateStrangeness { 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))) { + return; + } + // Perform basic event selection on both collisions if (!collision1.sel8() || !collision2.sel8()) continue; @@ -883,6 +1130,12 @@ struct correlateStrangeness { 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))) { + return; + } + // Perform basic event selection on both collisions if (!collision1.sel8() || !collision2.sel8()) continue; @@ -908,7 +1161,7 @@ struct correlateStrangeness { auto slicedAssocCascades = associatedCascades.sliceBy(collisionSliceCascades, collision2.globalIndex()); // ________________________________________________ // Do hadron - cascade correlations - fillCorrelationsCascade(slicedTriggerTracks, slicedAssocCascades, true, collision1.posZ(), collision1.centFT0M()); + fillCorrelationsCascade(slicedTriggerTracks, slicedAssocCascades, true, collision1.posX(), collision1.posY(), collision1.posZ(), collision1.centFT0M()); } } void processMixedEventHPions(soa::Join const& collisions, @@ -916,6 +1169,13 @@ struct correlateStrangeness { TracksComplete const&) { for (auto& [collision1, collision2] : soa::selfCombinations(colBinning, mixingParameter, -1, collisions, collisions)) { + + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && (!bitcheck(triggerPresenceMap[collision1.globalIndex()], triggerBinToSelect) || !bitcheck(triggerPresenceMap[collision2.globalIndex()], triggerBinToSelect))) { + return; + } + // ________________________________________________ // Perform basic event selection on both collisions if (!collision1.sel8() || !collision2.sel8()) @@ -946,28 +1206,42 @@ struct correlateStrangeness { } } - void processMCGenerated(aod::McCollision const&, soa::SmallGroups> const& collisions, aod::McParticles const& mcParticles) + void processMCGenerated(aod::McCollision const& mcCollision, soa::SmallGroups> const& collisions, aod::McParticles const& mcParticles) { + histos.fill(HIST("hClosureTestEventCounter"), 2.5f); + + for (auto const& mcParticle : mcParticles) { + Double_t geta = mcParticle.eta(); + if (std::abs(geta) > 0.8f) { + 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) { + 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) { + histos.fill(HIST("hGeneratedQAPtAssociatedK0"), gpt, 0.0f); // step 1: before all selections + } + } + } for (auto const& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) continue; - if (abs(mcParticle.pdgCode()) == 211) - histos.fill(HIST("Generated/hPion"), mcParticle.pt(), mcParticle.eta()); - if (abs(mcParticle.pdgCode()) == 310) - histos.fill(HIST("Generated/hK0Short"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == 3122) - histos.fill(HIST("Generated/hLambda"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == -3122) - histos.fill(HIST("Generated/hAntiLambda"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == 3312) - histos.fill(HIST("Generated/hXiMinus"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == -3312) - histos.fill(HIST("Generated/hXiPlus"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == 3334) - histos.fill(HIST("Generated/hOmegaMinus"), mcParticle.pt(), mcParticle.eta()); - if (mcParticle.pdgCode() == -3334) - histos.fill(HIST("Generated/hOmegaPlus"), mcParticle.pt(), mcParticle.eta()); + static_for<0, 7>([&](auto i) { + 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()); + } else { + if (mcParticle.pdgCode() == pdgCodes[i]) + histos.fill(HIST("Generated/h") + HIST(particlenames[index]), mcParticle.pt(), mcParticle.eta()); + } + }); } if (collisions.size() < 1) return; @@ -978,6 +1252,8 @@ struct correlateStrangeness { float bestCollisionVtxZ = 0.0f; bool bestCollisionSel8 = false; bool bestCollisionINELgtZERO = false; + uint32_t bestCollisionTriggerPresenceMap = 0; + for (auto& collision : collisions) { if (biggestNContribs < collision.numContrib()) { biggestNContribs = collision.numContrib(); @@ -985,6 +1261,8 @@ struct correlateStrangeness { bestCollisionSel8 = collision.sel8(); bestCollisionVtxZ = collision.posZ(); bestCollisionINELgtZERO = collision.isInelGt0(); + if (triggerPresenceMap.size() > 0) + bestCollisionTriggerPresenceMap = triggerPresenceMap[collision.globalIndex()]; } } @@ -992,30 +1270,30 @@ struct correlateStrangeness { for (auto const& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) continue; - if (abs(mcParticle.y()) < 0.5) { - if (abs(mcParticle.pdgCode()) == 211) - histos.fill(HIST("GeneratedWithPV/hPion_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (abs(mcParticle.pdgCode()) == 310) - histos.fill(HIST("GeneratedWithPV/hK0Short_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3122) - histos.fill(HIST("GeneratedWithPV/hLambda_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3122) - histos.fill(HIST("GeneratedWithPV/hAntiLambda_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3312) - histos.fill(HIST("GeneratedWithPV/hXiMinus_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3312) - histos.fill(HIST("GeneratedWithPV/hXiPlus_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3334) - histos.fill(HIST("GeneratedWithPV/hOmegaMinus_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3334) - histos.fill(HIST("GeneratedWithPV/hOmegaPlus_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); - } + if (abs(mcParticle.y()) > 0.5) + continue; + static_for<0, 7>([&](auto i) { + 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); + } else { + if (mcParticle.pdgCode() == pdgCodes[i]) + histos.fill(HIST("GeneratedWithPV/h") + HIST(particlenames[index]) + HIST("_MidYVsMult_TwoPVsOrMore"), mcParticle.pt(), bestCollisionFT0Mpercentile); + } + }); } } // do selections on best collision // WARNING: if 2 PV case large, this will not necessarily be fine! // caution advised! + + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && !bitcheck(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { + return; + } if (!bestCollisionSel8) return; if (std::abs(bestCollisionVtxZ) > 10.0f) @@ -1023,50 +1301,55 @@ struct correlateStrangeness { if (!bestCollisionINELgtZERO) return; + histos.fill(HIST("hClosureTestEventCounter"), 3.5f); + + for (auto const& mcParticle : mcParticles) { + Double_t geta = mcParticle.eta(); + if (std::abs(geta) > 0.8f) { + 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) { + 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) { + histos.fill(HIST("hGeneratedQAPtAssociatedK0"), gpt, 1.0f); // step 2: before all selections + } + } + } + for (auto const& mcParticle : mcParticles) { if (!mcParticle.isPhysicalPrimary()) { continue; } Double_t geta = mcParticle.eta(); Double_t gpt = mcParticle.pt(); - if (abs(mcParticle.pdgCode()) == 211) - histos.fill(HIST("GeneratedWithPV/hPion"), gpt, geta); - if (abs(mcParticle.pdgCode()) == 310) - histos.fill(HIST("GeneratedWithPV/hK0Short"), gpt, geta); - if (mcParticle.pdgCode() == 3122) - histos.fill(HIST("GeneratedWithPV/hLambda"), gpt, geta); - if (mcParticle.pdgCode() == -3122) - histos.fill(HIST("GeneratedWithPV/hAntiLambda"), gpt, geta); - if (mcParticle.pdgCode() == 3312) - histos.fill(HIST("GeneratedWithPV/hXiMinus"), gpt, geta); - if (mcParticle.pdgCode() == -3312) - histos.fill(HIST("GeneratedWithPV/hXiPlus"), gpt, geta); - if (mcParticle.pdgCode() == 3334) - histos.fill(HIST("GeneratedWithPV/hOmegaMinus"), gpt, geta); - if (mcParticle.pdgCode() == -3334) - histos.fill(HIST("GeneratedWithPV/hOmegaPlus"), gpt, geta); - - if (abs(mcParticle.y()) < 0.5) { - if (abs(mcParticle.pdgCode()) == 211) - histos.fill(HIST("GeneratedWithPV/hPion_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (abs(mcParticle.pdgCode()) == 310) - histos.fill(HIST("GeneratedWithPV/hK0Short_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3122) - histos.fill(HIST("GeneratedWithPV/hLambda_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3122) - histos.fill(HIST("GeneratedWithPV/hAntiLambda_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3312) - histos.fill(HIST("GeneratedWithPV/hXiMinus_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3312) - histos.fill(HIST("GeneratedWithPV/hXiPlus_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == 3334) - histos.fill(HIST("GeneratedWithPV/hOmegaMinus_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - if (mcParticle.pdgCode() == -3334) - histos.fill(HIST("GeneratedWithPV/hOmegaPlus_MidYVsMult"), gpt, bestCollisionFT0Mpercentile); - } + if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) + histos.fill(HIST("GeneratedWithPV/hTrigger"), gpt, geta); + static_for<0, 7>([&](auto i) { + 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); + } + + } 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); + } + } + }); } } - void processClosureTest(aod::McCollision const& collision, aod::McParticles const& mcParticles) + void processClosureTest(aod::McCollision const& mcCollision, soa::SmallGroups> const& recCollisions, aod::McParticles const& mcParticles) { std::vector triggerIndices; @@ -1080,56 +1363,142 @@ struct correlateStrangeness { std::vector omegaMinusIndices; std::vector omegaPlusIndices; - int iteratorNum = -1; for (auto const& mcParticle : mcParticles) { - iteratorNum = iteratorNum + 1; - if (!mcParticle.isPhysicalPrimary()) { - continue; - } Double_t geta = mcParticle.eta(); - Double_t gpt = mcParticle.pt(); - Double_t gphi = mcParticle.phi(); - if (abs(geta) > 0.8) { + if (std::abs(geta) > 0.8f) { 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) { - triggerIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hTrigger"), gpt, geta, gphi); + if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("hClosureQAPtTrigger"), gpt, 0.0f); // step 1: no event selection whatsoever + } } - if (abs(mcParticle.pdgCode()) == 211) { - piIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hPion"), gpt, geta, gphi); + + if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + histos.fill(HIST("hClosureQAPtAssociatedK0"), gpt, 0.0f); // step 1: no event selection whatsoever + } + } + } + + histos.fill(HIST("hClosureTestEventCounter"), 0.5f); + + int bestCollisionFT0Mpercentile = -1; + float bestCollisionVtxZ = 0.0f; + bool bestCollisionSel8 = false; + bool bestCollisionINELgtZERO = false; + int biggestNContribs = -1; + uint32_t bestCollisionTriggerPresenceMap = 0; + + for (auto& recCollision : recCollisions) { + if (biggestNContribs < recCollision.numContrib()) { + biggestNContribs = recCollision.numContrib(); + bestCollisionFT0Mpercentile = recCollision.centFT0M(); + bestCollisionSel8 = recCollision.sel8(); + bestCollisionVtxZ = recCollision.posZ(); + bestCollisionINELgtZERO = recCollision.isInelGt0(); + if (triggerPresenceMap.size() > 0) + bestCollisionTriggerPresenceMap = triggerPresenceMap[recCollision.globalIndex()]; } - if (abs(mcParticle.pdgCode()) == 310) { - k0ShortIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hK0Short"), gpt, geta, gphi); + } + // ________________________________________________ + // skip if desired trigger not found + if (triggerPresenceMap.size() > 0 && !bitcheck(bestCollisionTriggerPresenceMap, triggerBinToSelect)) { + return; + } + + if (doGenEventSelection) { + if (!bestCollisionSel8) + return; + if (std::abs(bestCollisionVtxZ) > zVertexCut) + return; + if (!bestCollisionINELgtZERO) + return; + if (bestCollisionFT0Mpercentile > axisRanges[5][1] || bestCollisionFT0Mpercentile < axisRanges[5][0]) { + return; } - if (mcParticle.pdgCode() == 3122) { - lambdaIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hLambda"), gpt, geta, gphi); + } + + histos.fill(HIST("hClosureTestEventCounter"), 1.5f); + + for (auto const& mcParticle : mcParticles) { + Double_t geta = mcParticle.eta(); + if (std::abs(geta) > 0.8f) { + continue; } - if (mcParticle.pdgCode() == -3122) { - antiLambdaIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hAntiLambda"), gpt, geta, gphi); + 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) { + if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + histos.fill(HIST("hClosureQAPtTrigger"), gpt, 1.0f); // step 2: after event selection + } } - if (mcParticle.pdgCode() == 3312) { - xiMinusIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hXiMinus"), gpt, geta, gphi); + + if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + histos.fill(HIST("hClosureQAPtAssociatedK0"), gpt, 1.0f); // step 2: after event selection + } } - if (mcParticle.pdgCode() == -3312) { - xiPlusIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hXiPlus"), gpt, geta, gphi); + } + + 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) { + continue; } - if (mcParticle.pdgCode() == 3334) { - omegaMinusIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hOmegaMinus"), gpt, geta, gphi); + if (abs(mcParticle.pdgCode()) == 211 || abs(mcParticle.pdgCode()) == 321 || abs(mcParticle.pdgCode()) == 2212 || abs(mcParticle.pdgCode()) == 11 || abs(mcParticle.pdgCode()) == 13) { + Int_t charge = 0; + if (mcParticle.pdgCode() < 0) + charge = -1; + if (mcParticle.pdgCode() > 0) + charge = 1; + if (!doTriggPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + if ((triggerParticleCharge > 0 && charge > 0) || (triggerParticleCharge < 0 && charge < 0) || triggerParticleCharge == 0) { + triggerIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hTrigger"), gpt, geta, bestCollisionFT0Mpercentile); + } + } } - if (mcParticle.pdgCode() == -3334) { - omegaPlusIndices.emplace_back(iteratorNum); - histos.fill(HIST("ClosureTest/hOmegaPlus"), gpt, geta, gphi); + if (!doAssocPhysicalPrimary || mcParticle.isPhysicalPrimary()) { + if (abs(mcParticle.pdgCode()) == 211 && doCorrelationPion) { + piIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hPion"), gpt, geta, gphi); + } + if (abs(mcParticle.pdgCode()) == 310 && doCorrelationK0Short) { + k0ShortIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hK0Short"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == 3122 && doCorrelationLambda) { + lambdaIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hLambda"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == -3122 && doCorrelationAntiLambda) { + antiLambdaIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hAntiLambda"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == 3312 && doCorrelationXiMinus) { + xiMinusIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hXiMinus"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == -3312 && doCorrelationXiPlus) { + xiPlusIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hXiPlus"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == 3334 && doCorrelationOmegaMinus) { + omegaMinusIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hOmegaMinus"), gpt, geta, gphi); + } + if (mcParticle.pdgCode() == -3334 && doCorrelationOmegaPlus) { + omegaPlusIndices.emplace_back(iteratorNum); + histos.fill(HIST("ClosureTest/hOmegaPlus"), gpt, geta, gphi); + } } } - associatedIndices.emplace_back(piIndices); + associatedIndices.emplace_back(k0ShortIndices); associatedIndices.emplace_back(lambdaIndices); associatedIndices.emplace_back(antiLambdaIndices); @@ -1137,12 +1506,14 @@ struct correlateStrangeness { associatedIndices.emplace_back(xiPlusIndices); associatedIndices.emplace_back(omegaMinusIndices); associatedIndices.emplace_back(omegaPlusIndices); + associatedIndices.emplace_back(piIndices); for (Int_t iTrigger = 0; iTrigger < triggerIndices.size(); iTrigger++) { auto triggerParticle = mcParticles.iteratorAt(triggerIndices[iTrigger]); - // if (!mcParticle) { - // continue; - // } + // check range of trigger particle + 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(); @@ -1156,13 +1527,25 @@ struct correlateStrangeness { Double_t getaassoc = assocParticle.eta(); Double_t gphiassoc = assocParticle.phi(); Double_t ptassoc = assocParticle.pt(); - histos.fill(HIST("ClosureTest/sameEvent/") + HIST(particlenames[index]), ComputeDeltaPhi(gphitrigger, gphiassoc), getatrigger - getaassoc, ptassoc, pttrigger, collision.posZ(), iteratorNum); + Double_t deltaphi = ComputeDeltaPhi(gphitrigger, gphiassoc); + Double_t deltaeta = getatrigger - getaassoc; + + // skip if basic ranges not met + if (deltaphi < axisRanges[0][0] || deltaphi > axisRanges[0][1]) + continue; + if (deltaeta < axisRanges[1][0] || deltaeta > axisRanges[1][1]) + 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); } } }); } } + PROCESS_SWITCH(correlateStrangeness, processSelectEventWithTrigger, "Select events with trigger only", false); 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); diff --git a/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx b/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx index d43be490657..b76fbee0fa8 100644 --- a/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx +++ b/PWGLF/Tasks/Strangeness/k0_mixed_events.cxx @@ -299,10 +299,10 @@ struct K0MixedEvents { registry.fill(HIST("Trks"), 1); const float& vtxZ = track.singleCollSel_as().posZ(); registry.fill(HIST("VTX"), vtxZ); - if (abs(vtxZ) > _vertexZ) + if (std::abs(vtxZ) > _vertexZ) continue; registry.fill(HIST("eta"), track.pt(), track.eta()); - if (abs(track.rapidity(particle_mass(_particlePDG_1))) > _maxy) { + if (std::abs(track.rapidity(particle_mass(_particlePDG_1))) > _maxy) { continue; } registry.fill(HIST("rapidity_first"), track.pt(), track.rapidity(particle_mass(_particlePDG_1))); diff --git a/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx b/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx new file mode 100755 index 00000000000..b0636238735 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdak0sflattenicity.cxx @@ -0,0 +1,1691 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// Making modifications to the Strangeness Tutorial code +/// 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) + +#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 "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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct lambdak0sflattenicity { + // Histograms are defined with HistogramRegistry + Service pdg; + HistogramRegistry rEventSelection{"eventSelection", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + HistogramRegistry rKzeroShort{ + "kzeroShort", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + HistogramRegistry rLambda{ + "lambda", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + HistogramRegistry rAntiLambda{ + "antilambda", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + HistogramRegistry rFlattenicity{ + "flattenicity", + {}, + OutputObjHandlingPolicy::AnalysisObject, + true, + true}; + + static constexpr std::string_view nhEst[8] = { + "eGlobaltrack", "eFV0", "e1flatencityFV0", "eFT0", + "e1flatencityFT0", "eFV0FT0C", "e1flatencityFV0FT0C", "ePtTrig"}; + static constexpr std::string_view tEst[8] = { + "GlobalTrk", "FV0", "1-flatencity_FV0", "FT0", + "1-flatencityFT0", "FV0_FT0C", "1-flatencity_FV0_FT0C", "PtTrig"}; + static constexpr std::string_view nhPtEst[8] = { + "ptVsGlobaltrack", "ptVsFV0", + "ptVs1flatencityFV0", "ptVsFT0", + "ptVs1flatencityFT0", "ptVsFV0FT0C", + "ptVs1flatencityFV0FT0C", "pTVsPtTrig"}; + + // Configurable for histograms + Configurable nBinsVz{"nBinsVz", 100, "N bins in Vz"}; + Configurable nBinsK0sMass{"nBinsK0sMass", 200, "N bins in K0sMass"}; + Configurable nBinsLambdaMass{"nBinsLambdaMass", 200, + "N bins in LambdaMass"}; + Configurable nBinspT{"nBinspT", 250, "N bins in pT"}; + Configurable nBinsFlattenicity{"nBinsFlattenicity", 100, "N bins in Flattenicity"}; + + // Configurable for event selection + + Configurable applyEvSel{"applyEvSel", true, + "Apply event selection to Data and MCRec"}; + 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, + "Is Vertex ITSTPC"}; + Configurable IsNoSameBunchPileup{"IsNoSameBunchPileup", false, + "Is No Same Bunch Pileup"}; + Configurable IsGoodZvtxFT0vsPV{"IsGoodZvtxFT0vsPV", false, + "Is Good Zvtx FT0 vs PV"}; + Configurable IsTriggerTVX{"IsTriggerTVX", true, + "coincidence of a signal in FT0A and FT0C"}; + + // Configurables for Flattenicity + Configurable flattenicityQA{"flattenicityQA", true, "Store Flattenicity QA plots"}; + Configurable applyCalibCh{"applyCalibCh", false, "equalize FV0"}; + Configurable applyCalibVtx{"applyCalibVtx", false, + "equalize FV0 vs vtx"}; + Configurable applyNorm{"applyNorm", false, "normalization to eta"}; + Configurable isflattenicitywithFV0{"isflattenicitywithFV0", true, + "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"}; + + // 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 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 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 parameters for PID selection + Configurable NSigmaTPCPion{"NSigmaTPCPion", 5, "NSigmaTPCPion"}; + Configurable NSigmaTPCProton{"NSigmaTPCProton", 5, "NSigmaTPCProton"}; + + // Configurable v0daughter_etacut{"V0DaughterEtaCut", 0.8, + // "V0DaughterEtaCut"}; + Configurable v0_etacut{"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"}; + + void init(InitContext const&) + { + // Axes + AxisSpec K0sMassAxis = {nBinsK0sMass, 0.45f, 0.55f, + "#it{M}_{#pi^{+}#pi^{-}} [GeV/#it{c}^{2}]"}; + AxisSpec LambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, + "#it{M}_{p#pi^{-}} [GeV/#it{c}^{2}]"}; + AxisSpec AntiLambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, + "#it{M}_{#pi^{+}#bar{p}} [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}"}; + + int nBinsEst[8] = {100, 500, 102, 500, 102, 500, 102, 150}; + float lowEdgeEst[8] = {-0.5, -0.5, -0.01, -0.5, -0.01, -0.5, -0.01, .0}; + float upEdgeEst[8] = {99.5, 49999.5, 1.01, 499.5, 1.01, 499.5, 1.01, 150.0}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZ", "hVertexZ", + {HistType::kTH1F, {vertexZAxis}}); + rEventSelection.add("hEventsSelected", "hEventsSelected", + {HistType::kTH1I, {{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.add("hFlattenicityDistribution", "hFlattenicityDistribution", + {HistType::kTH1F, {flatAxis}}); + if (doprocessRecMC) { + rEventSelection.add("hFlattenicityDistributionMCGen_Rec", "hFlattenicityDistributionMCGen_Rec", + {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlattenicity_Corr_Gen_vs_Rec", "hFlattenicity_Corr_Gen_vs_Rec", + {HistType::kTH2F, {flatAxis, flatAxis}}); + } + if (doprocessGenMC) { + rEventSelection.add("hVertexZGen", "hVertexZGen", + {HistType::kTH1F, {vertexZAxis}}); + + rEventSelection.add("hFlattenicityDistributionMCGen", "hFlattenicityDistributionMCGen", + {HistType::kTH1F, {flatAxis}}); + + rEventSelection.add("hFlat_RecoColl_MC", "hFlat_RecoColl_MC", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlat_RecoColl_MC_INELgt0", "hFlat_RecoColl_MC_INELgt0", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlat_GenRecoColl_MC", "hFlat_GenRecoColl_MC", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlat_GenRecoColl_MC_INELgt0", "hFlat_GenRecoColl_MC_INELgt0", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlat_GenColl_MC", "hFlat_GenColl_MC", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hFlat_GenColl_MC_INELgt0", "hFlat_GenColl_MC_INELgt0", {HistType::kTH1F, {flatAxis}}); + rEventSelection.add("hNEventsMCGen", "hNEventsMCGen", {HistType::kTH1I, {{4, 0.f, 4.f}}}); + rEventSelection.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(1, "all"); + rEventSelection.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(2, "zvertex_true"); + rEventSelection.get(HIST("hNEventsMCGen"))->GetXaxis()->SetBinLabel(3, "INELgt0_true"); + rEventSelection.add("hNEventsMCGenReco", "hNEventsMCGenReco", {HistType::kTH1I, {{2, 0.f, 2.f}}}); + rEventSelection.get(HIST("hNEventsMCGenReco"))->GetXaxis()->SetBinLabel(1, "INEL"); + rEventSelection.get(HIST("hNEventsMCGenReco"))->GetXaxis()->SetBinLabel(2, "INELgt0"); + rEventSelection.add("hNEventsMCReco", "hNEventsMCReco", {HistType::kTH1I, {{4, 0.f, 4.f}}}); + rEventSelection.get(HIST("hNEventsMCReco"))->GetXaxis()->SetBinLabel(1, "all"); + 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::kTH1F, {K0sMassAxis}}); + rKzeroShort.add("hMassK0sSelected", "hMassK0sSelected", + {HistType::kTH1F, {K0sMassAxis}}); + + // K0s topological/PID cuts + rKzeroShort.add("hrapidityK0s", "hrapidityK0s", + {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); + rKzeroShort.add("hctauK0s", "hctauK0s", + {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rKzeroShort.add( + "h2DdecayRadiusK0s", "h2DdecayRadiusK0s", + {HistType::kTH1F, {{100, 0.0f, 1.0f, "Decay Radius (cm)"}}}); + rKzeroShort.add("hDCAV0DaughtersK0s", "hDCAV0DaughtersK0s", + {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rKzeroShort.add("hV0CosPAK0s", "hV0CosPAK0s", + {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); + rKzeroShort.add("hNSigmaPosPionFromK0s", "hNSigmaPosPionFromK0s", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rKzeroShort.add("hNSigmaNegPionFromK0s", "hNSigmaNegPionFromK0s", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rKzeroShort.add("hMassK0spT", "hMassK0spT", + {HistType::kTH2F, {{K0sMassAxis}, {ptAxis}}}); + rKzeroShort.add("hMassK0spTFlat", "hMassK0spTFlat", + {HistType::kTH3F, {{K0sMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMC) { + rKzeroShort.add("Generated_MCRecoCollCheck_INEL_K0Short", "Generated_MCRecoCollCheck_INEL_K0Short", + {HistType::kTH2F, {{ptAxis}, {flatAxis}}}); + } + + if (doprocessGenMC) { + rKzeroShort.add("pGen_MCGenRecoColl_INEL_K0Short", "pGen_MCGenRecoColl_INEL_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("Generated_MCRecoColl_INEL_K0Short", "Generated_MCRecoColl_INEL_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("pGen_MCGenColl_INEL_K0Short", "pGen_MCGenColl_INEL_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("pGen_MCGenRecoColl_INELgt0_K0Short", "pGen_MCGenRecoColl_INELgt0_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("Generated_MCRecoColl_INELgt0_K0Short", "Generated_MCRecoColl_INELgt0_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("Generated_MCRecoCollCheck_INELgt0_K0Short", "Generated_MCRecoCollCheck_INELgt0_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rKzeroShort.add("pGen_MCGenColl_INELgt0_K0Short", "pGen_MCGenColl_INELgt0_K0Short", + {HistType::kTH2F, {ptAxis, flatAxis}}); + } + // Lambda reconstruction Mass + rLambda.add("hMassLambda", "hMassLambda", + {HistType::kTH1F, {LambdaMassAxis}}); + rLambda.add("hMassLambdaSelected", "hMassLambdaSelected", + {HistType::kTH1F, {LambdaMassAxis}}); + + // Lambda topological/PID cuts + rLambda.add("hDCAV0DaughtersLambda", "hDCAV0DaughtersLambda", + {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rLambda.add("hV0CosPALambda", "hV0CosPALambda", + {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); + rLambda.add("hNSigmaPosPionFromLambda", "hNSigmaPosPionFromLambda", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rLambda.add("hNSigmaNegPionFromLambda", "hNSigmaNegPionFromLambda", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rLambda.add("hrapidityLambda", "hrapidityLambda", + {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); + rLambda.add("hctauLambda", "hctauLambda", + {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rLambda.add("h2DdecayRadiusLambda", "h2DdecayRadiusLambda", + {HistType::kTH1F, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); + rLambda.add("hMassLambdapT", "hMassLambdapT", + {HistType::kTH2F, {{LambdaMassAxis}, {ptAxis}}}); + rLambda.add("hMassLambdapTFlat", "hMassLambdapTFlat", + {HistType::kTH3F, {{LambdaMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMC) { + rLambda.add("Generated_MCRecoCollCheck_INEL_Lambda", "Generated_MCRecoCollCheck_INEL_Lambda", + {HistType::kTH2F, {{ptAxis}, {flatAxis}}}); + } + + if (doprocessGenMC) { + rLambda.add("pGen_MCGenRecoColl_INEL_Lambda", "pGen_MCGenRecoColl_INEL_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("Generated_MCRecoColl_INEL_Lambda", "Generated_MCRecoColl_INEL_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("pGen_MCGenColl_INEL_Lambda", "pGen_MCGenColl_INEL_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("pGen_MCGenRecoColl_INELgt0_Lambda", "pGen_MCGenRecoColl_INELgt0_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("Generated_MCRecoColl_INELgt0_Lambda", "Generated_MCRecoColl_INELgt0_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("Generated_MCRecoCollCheck_INELgt0_Lambda", "Generated_MCRecoCollCheck_INELgt0_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rLambda.add("pGen_MCGenColl_INELgt0_Lambda", "pGen_MCGenColl_INELgt0_Lambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + } + // AntiLambda reconstruction + // Mass + rAntiLambda.add("hMassAntiLambda", "hMassAntiLambda", + {HistType::kTH1F, {AntiLambdaMassAxis}}); + rAntiLambda.add("hMassAntiLambdaSelected", "hMassAntiLambdaSelected", + {HistType::kTH1F, {AntiLambdaMassAxis}}); + + // AntiLambda topological/PID cuts + rAntiLambda.add("hDCAV0DaughtersAntiLambda", "hDCAV0DaughtersAntiLambda", + {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); + rAntiLambda.add("hV0CosPAAntiLambda", "hV0CosPAAntiLambda", + {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); + rAntiLambda.add("hNSigmaPosPionFromAntiLambda", + "hNSigmaPosPionFromAntiLambda", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rAntiLambda.add("hNSigmaNegPionFromAntiLambda", + "hNSigmaNegPionFromAntiLambda", + {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); + rAntiLambda.add("hrapidityAntiLambda", "hrapidityAntiLambda", + {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); + rAntiLambda.add("hctauAntiLambda", "hctauAntiLambda", + {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); + rAntiLambda.add("h2DdecayRadiusAntiLambda", "h2DdecayRadiusAntiLambda", + {HistType::kTH1F, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); + rAntiLambda.add("hMassAntiLambdapT", "hMassAntiLambdapT", + {HistType::kTH2F, {{AntiLambdaMassAxis}, {ptAxis}}}); + rAntiLambda.add("hMassAntiLambdapTFlat", "hMassAntiLambdapTFlat", + {HistType::kTH3F, {{AntiLambdaMassAxis}, {ptAxis}, {flatAxis}}}); + if (doprocessRecMC) { + rAntiLambda.add("Generated_MCRecoCollCheck_INEL_AntiLambda", "Generated_MCRecoCollCheck_INEL_AntiLambda", + {HistType::kTH2F, {{ptAxis}, {flatAxis}}}); + } + + if (doprocessGenMC) { + rAntiLambda.add("pGen_MCGenRecoColl_INEL_AntiLambda", "pGen_MCGenRecoColl_INEL_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("Generated_MCRecoColl_INEL_AntiLambda", "Generated_MCRecoColl_INEL_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("pGen_MCGenColl_INEL_AntiLambda", "pGen_MCGenColl_INEL_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("pGen_MCGenRecoColl_INELgt0_AntiLambda", "pGen_MCGenRecoColl_INELgt0_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("Generated_MCRecoColl_INELgt0_AntiLambda", "Generated_MCRecoColl_INELgt0_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("Generated_MCRecoCollCheck_INELgt0_AntiLambda", "Generated_MCRecoCollCheck_INELgt0_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + rAntiLambda.add("pGen_MCGenColl_INELgt0_AntiLambda", "pGen_MCGenColl_INELgt0_AntiLambda", + {HistType::kTH2F, {ptAxis, flatAxis}}); + } + + if (flattenicityQA) { + rFlattenicity.add("hEv", "Ev", HistType::kTH1F, + {{6, -0.5, 5.5, "index activated detector"}}); + rFlattenicity.add("hFV0amplRing1to4", "FV01to4", HistType::kTH1F, + {{4000, -0.5, +49999.5, "FV0 amplitude"}}); + rFlattenicity.add("hFT0Aampl", "FTAampl", HistType::kTH1F, + {{50000, -0.5, +199999.5, "FT0A amplitude"}}); + rFlattenicity.add("hFT0Campl", "FTCampl", HistType::kTH1F, + {{10000, -0.5, +4999.5, "FT0C amplitude"}}); + rFlattenicity.add("hFT0C", "FT0C", HistType::kTH1F, + {{50000, -0.5, 199999.5, "FT0C amplitudes"}}); + rFlattenicity.add("hFT0A", "FT0A", HistType::kTH1F, + {{2000, -0.5, 1999.5, "FT0A amplitudes"}}); + + // estimators + for (int i_e = 0; i_e < 8; ++i_e) { + rFlattenicity.add( + nhEst[i_e].data(), "", HistType::kTH2F, + {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}, + {100, -0.5, +99.5, "Global track"}}); + } + + // vs pT + for (int i_e = 0; i_e < 8; ++i_e) { + rFlattenicity.add( + nhPtEst[i_e].data(), "", HistType::kTProfile, + {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}}); + } + + rFlattenicity.add("fMultFv0", "FV0 amp", HistType::kTH1F, + {{5000, -0.5, +199999.5, "FV0 amplitude"}}); + rFlattenicity.add( + "hAmpV0VsCh", "", HistType::kTH2F, + {{48, -0.5, 47.5, "channel"}, {500, -0.5, +19999.5, "FV0 amplitude"}}); + rFlattenicity.add( + "hAmpV0VsChBeforeCalibration", "", HistType::kTH2F, + {{48, -0.5, 47.5, "channel"}, {500, -0.5, +19999.5, "FV0 amplitude"}}); + + rFlattenicity.add( + "hAmpT0AVsChBeforeCalibration", "", HistType::kTH2F, + {{24, -0.5, 23.5, "channel"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); + rFlattenicity.add( + "hAmpT0CVsChBeforeCalibration", "", HistType::kTH2F, + {{28, -0.5, 27.5, "channel"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); + + rFlattenicity.add( + "hAmpT0AVsCh", "", HistType::kTH2F, + {{24, -0.5, 23.5, "channel"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); + rFlattenicity.add( + "hAmpT0CVsCh", "", HistType::kTH2F, + {{28, -0.5, 27.5, "channel"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); + + rFlattenicity.add("hFlatFT0CvsFlatFT0A", "", HistType::kTH2F, + {{20, -0.01, +1.01, "flatenicity (FT0C)"}, + {20, -0.01, +1.01, "flatenicity (FT0A)"}}); + rFlattenicity.add( + "fEtaPhiFv0", "eta vs phi", HistType::kTH2F, + {{8, 0.0, 2 * M_PI, "#phi (rad)"}, {5, 2.2, 5.1, "#eta"}}); + + rFlattenicity.add("hAmpV0vsVtxBeforeCalibration", "", HistType::kTH2F, + {{30, -15.0, +15.0, "Trk mult"}, + {1000, -0.5, +39999.5, "FV0 amplitude"}}); + rFlattenicity.add( + "hAmpT0AvsVtxBeforeCalibration", "", HistType::kTH2F, + {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); + rFlattenicity.add( + "hAmpT0CvsVtxBeforeCalibration", "", HistType::kTH2F, + {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); + + rFlattenicity.add("hAmpV0vsVtx", "", HistType::kTH2F, + {{30, -15.0, +15.0, "Trk mult"}, + {1000, -0.5, +39999.5, "FV0 amplitude"}}); + rFlattenicity.add( + "hAmpT0AvsVtx", "", HistType::kTH2F, + {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); + rFlattenicity.add( + "hAmpT0CvsVtx", "", HistType::kTH2F, + {{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 ((doprocessRecMC && !doprocessGenMC) || + (!doprocessRecMC && doprocessGenMC)) { + LOGF(fatal, + "MCRec and MCGen are set to opposite switches, try again " + "with both set to either true or false"); + } + } + + int getT0ASector(int i_ch) + { + 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; + break; + } + } + return i_sec_t0a; + } + + int getT0CSector(int i_ch) + { + 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; + break; + } + } + return i_sec_t0c; + } + + int getFV0Ring(int i_ch) + { + 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; + } else { + i_ring = 4; + } + return i_ring; + } + + int getFV0IndexPhi(int i_ch) + { + int i_ring = -1; + + if (i_ch >= 0 && i_ch < 8) { + if (i_ch < 4) { + i_ring = i_ch; + } 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; + } + } + } else if (i_ch >= 8 && i_ch < 16) { + if (i_ch < 12) { + i_ring = i_ch; + } 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; + } + } + } else if (i_ch >= 16 && i_ch < 24) { + if (i_ch < 20) { + i_ring = i_ch; + } 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; + } + } + } else if (i_ch >= 24 && i_ch < 32) { + if (i_ch < 28) { + i_ring = i_ch; + } 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; + } + } + } 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; + } + + float GetFlatenicity(std::span signals) + { + int entries = signals.size(); + float flat = 9999; + float mRho = 0; + for (int iCell = 0; iCell < entries; ++iCell) { + mRho += 1.0 * signals[iCell]; + } + // average activity per cell + mRho /= (1.0 * entries); + // get sigma + float sRho_tmp = 0; + for (int iCell = 0; iCell < entries; ++iCell) { + sRho_tmp += TMath::Power(1.0 * signals[iCell] - mRho, 2); + } + sRho_tmp /= (1.0 * entries * entries); + float sRho = TMath::Sqrt(sRho_tmp); + if (mRho > 0) { + flat = sRho / mRho; + } + return flat; + } + float pdgmassK0s = 0.497614; + float pdgmassLambda = 1.115683; + // V0A signal and flatenicity calculation + static constexpr float calib[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, + 1.06622, 1.15057, 1.0433, 0.83654, 0.847178, 0.890027, 0.920814, + 0.888271, 1.04662, 0.8869, 0.856348, 0.863181, 0.906312, 0.902166, + 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] = { + 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] = { + 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] = { + -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] = { + 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] = { + 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] = { + 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; + + std::array estimator; + + template + bool isEventSelected(TCollision const& collision) + { + rEventSelection.fill(HIST("hEventsSelected"), 0.5); + + if (Issel8 && !collision.sel8()) { + return false; + } + + rEventSelection.fill(HIST("hEventsSelected"), 1.5); + if (TMath::Abs(collision.posZ()) > cutzvertex) { + return false; + } + + rEventSelection.fill(HIST("hEventsSelected"), 2.5); + + if (IsNoTimeFrameBorder && + !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 3.5); + + if (IsNoITSROFrameBorder && + !collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 4.5); + + if (IsVertexITSTPC && + !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 5.5); + + if (IsNoSameBunchPileup && + !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 6.5); + + if (IsGoodZvtxFT0vsPV && + !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 7.5); + + if (IsTriggerTVX && + !collision.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 8.5); + + if (IsINELgt0 && (collision.isInelGt0() == false)) { + return false; + } + rEventSelection.fill(HIST("hEventsSelected"), 9.5); + + return true; + } + + // ============== Flattenicity estimation begins ===================== // + template + 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}; + + 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]); + } + for (int i_v = 0; i_v < 30; ++i_v) { + gVtx[1]->SetPoint(i_v, biningVtxt[i_v], calibFT0Avtx[i_v]); + } + for (int i_v = 0; i_v < 30; ++i_v) { + gVtx[2]->SetPoint(i_v, biningVtxt[i_v], calibFT0Cvtx[i_v]); + } + + for (int i_d = 0; i_d < nDetVtx; ++i_d) { + gVtx[i_d]->SetName(Form("g%s", nameDet[i_d])); + } + auto vtxZ = collision.posZ(); + + float sumAmpFV0 = 0; + float sumAmpFV01to4Ch = 0; + + ampchannel.fill(0.0); + ampchannelBefore.fill(0.0); + RhoLattice.fill(0); + + if ((isflattenicitywithFV0 || isflattenicitywithFV0FT0C) && + collision.has_foundFV0()) { + + auto fv0 = collision.foundFV0(); + for (std::size_t ich = 0; ich < fv0.amplitude().size(); ich++) { + float phiv0 = -999.0; + float etav0 = -999.0; + int channelv0 = fv0.channel()[ich]; + float ampl_ch = 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); + } else { + phiv0 = ((2.0 * channelv0phi) + 1 - 64.0) * 2.0 * M_PI / (32.0); + } + ampchannelBefore[channelv0phi] = ampl_ch; + if (applyCalibCh) { + ampl_ch *= calib[channelv0phi]; + } + sumAmpFV0 += ampl_ch; + + if (channelv0 >= 8) { // exclude the 1st ch, eta 2.2,4.52 + sumAmpFV01to4Ch += ampl_ch; + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("fEtaPhiFv0"), phiv0, etav0, ampl_ch); + } + ampchannel[channelv0phi] = ampl_ch; + if (channelv0 < innerFV0) { + RhoLattice[channelv0phi] = ampl_ch; + } else { + RhoLattice[channelv0phi] = ampl_ch / 2.0; // two channels per bin + } + } + + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpV0vsVtxBeforeCalibration"), vtxZ, sumAmpFV0); + } + if (applyCalibVtx) { + sumAmpFV0 *= gVtx[0]->Eval(vtxZ); + sumAmpFV01to4Ch *= gVtx[0]->Eval(vtxZ); + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpV0vsVtx"), vtxZ, sumAmpFV0); + } + } + + float flattenicityfv0 = 9999; + if (isflattenicitywithFV0 || isflattenicitywithFV0FT0C) { + flattenicityfv0 = GetFlatenicity({RhoLattice.data(), RhoLattice.size()}); + } + + // global tracks + float ptT = 0.; + int multGlob = 0; + for (auto& track : tracks) { + if (!track.isGlobalTrack()) { + continue; + } + if (track.pt() > ptT) { + ptT = track.pt(); + } + multGlob++; + } + + // FT0 + float sumAmpFT0A = 0.f; + float sumAmpFT0C = 0.f; + + RhoLatticeT0A.fill(0); + RhoLatticeT0C.fill(0); + + if ((isflattenicitywithFT0 || isflattenicitywithFV0FT0C) && + collision.has_foundFT0()) { + auto ft0 = collision.foundFT0(); + if (isflattenicitywithFT0) { + for (std::size_t i_a = 0; i_a < ft0.amplitudeA().size(); i_a++) { + float amplitude = ft0.amplitudeA()[i_a]; + uint8_t channel = ft0.channelA()[i_a]; + int sector = getT0ASector(channel); + if (sector >= 0 && sector < 24) { + RhoLatticeT0A[sector] += amplitude; + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0AVsChBeforeCalibration"), sector, + amplitude); + } + if (applyCalibCh) { + amplitude *= calibT0A[sector]; + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0AVsCh"), sector, amplitude); + } + } + sumAmpFT0A += amplitude; + if (flattenicityQA) { + rFlattenicity.fill(HIST("hFT0A"), amplitude); + } + } + } + + for (std::size_t i_c = 0; i_c < ft0.amplitudeC().size(); i_c++) { + float amplitude = ft0.amplitudeC()[i_c]; + sumAmpFT0C += amplitude; + uint8_t channel = ft0.channelC()[i_c]; + int sector = getT0CSector(channel); + if (sector >= 0 && sector < 28) { + RhoLatticeT0C[sector] += amplitude; + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0CVsChBeforeCalibration"), sector, + amplitude); + } + if (applyCalibCh) { + amplitude *= calibT0C[sector]; + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0CVsCh"), sector, amplitude); + } + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hFT0C"), amplitude); + } + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0AvsVtxBeforeCalibration"), vtxZ, + sumAmpFT0A); + rFlattenicity.fill(HIST("hAmpT0CvsVtxBeforeCalibration"), vtxZ, + sumAmpFT0C); + } + if (applyCalibVtx) { + sumAmpFT0A *= gVtx[1]->Eval(vtxZ); + sumAmpFT0C *= gVtx[2]->Eval(vtxZ); + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hAmpT0AvsVtx"), vtxZ, sumAmpFT0A); + rFlattenicity.fill(HIST("hAmpT0CvsVtx"), vtxZ, sumAmpFT0C); + } + } + float flatenicity_t0a = 9999; + if (isflattenicitywithFT0) { + flatenicity_t0a = + GetFlatenicity({RhoLatticeT0A.data(), RhoLatticeT0A.size()}); + } + float flatenicity_t0c = 9999; + if (isflattenicitywithFT0 || isflattenicitywithFV0FT0C) { + flatenicity_t0c = + GetFlatenicity({RhoLatticeT0C.data(), RhoLatticeT0C.size()}); + } + + bool isOK_estimator5 = false; + bool isOK_estimator6 = false; + float combined_estimator5 = 0; + float combined_estimator6 = 0; + + for (int i_e = 0; i_e < 8; ++i_e) { + estimator[i_e] = 0; + } + + if (collision.has_foundFV0() && collision.has_foundFT0()) { + float all_weights = 0; + // option 5 + ampl5[0] = sumAmpFT0C; + ampl5[1] = sumAmpFT0A; + if (sumAmpFT0C > 0 && sumAmpFT0A > 0) { + isOK_estimator5 = true; + } + if (isOK_estimator5) { + 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]; + } + combined_estimator5 /= all_weights; + } else { + for (int i_5 = 0; i_5 < nEta5; ++i_5) { + combined_estimator5 += ampl5[i_5] * weigthsEta5[i_5]; + } + } + } + // option 6: FT0C + FV0 + ampl6[0] = sumAmpFT0C; + ampl6[1] = sumAmpFV0; + if (sumAmpFT0C > 0 && sumAmpFV0 > 0) { + isOK_estimator6 = true; + } + if (isOK_estimator6) { + 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]; + } + combined_estimator6 /= all_weights; + } else { + for (int i_6 = 0; i_6 < nEta6; ++i_6) { + combined_estimator6 += ampl6[i_6] * weigthsEta6[i_6]; + } + } + } + if (flattenicityQA) { + rFlattenicity.fill(HIST("hFT0Aampl"), sumAmpFT0A); + rFlattenicity.fill(HIST("hFT0Campl"), sumAmpFT0C); + rFlattenicity.fill(HIST("hFV0amplRing1to4"), sumAmpFV01to4Ch); + rFlattenicity.fill(HIST("hEv"), 4); + } + 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[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]); + + // plot pt vs estimators + for (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); + } + + if (isflattenicitywithFV0) { + for (int iCh = 0; iCh < 48; ++iCh) { + rFlattenicity.fill(HIST("hAmpV0VsCh"), iCh, ampchannel[iCh]); + rFlattenicity.fill(HIST("hAmpV0VsChBeforeCalibration"), iCh, + ampchannelBefore[iCh]); + } + } + + rFlattenicity.fill(HIST("fMultFv0"), sumAmpFV0); + rFlattenicity.fill(HIST("hFlatFT0CvsFlatFT0A"), flatenicity_t0c, + flatenicity_t0a); + } + } + float finalflattenicity = estimator[2]; + if (flattenicityforanalysis == 1) { + finalflattenicity = estimator[4]; + } + if (flattenicityforanalysis == 2) { + finalflattenicity = estimator[6]; + } + return finalflattenicity; + } + + template + float EstimateFlattenicityFV0MC(McParticles const& mcParticles) + { + RhoLatticeFV0AMC.fill(0); + float flattenicity = -1; + float etamin, etamax, minphi, maxphi, dphi; + int isegment = 0, nsectors; + for (const auto& mcParticle : mcParticles) { + if (!(mcParticle.isPhysicalPrimary() && mcParticle.pt() > 0)) { + continue; + } + + auto pdgParticle = pdg->GetParticle(mcParticle.pdgCode()); + if (!(pdgParticle && pdgParticle->Charge() > 0.01)) { + continue; + } + + float etap = mcParticle.eta(); + float phip = mcParticle.phi(); + isegment = 0; + for (int ieta = 0; ieta < 5; ieta++) { + etamax = maxEtaFV0 - ieta * detaFV0; + if (ieta == 0) { + etamax = maxEtaFV0; + } + etamin = maxEtaFV0 - (ieta + 1) * detaFV0; + if (ieta == 4) { + etamin = minEtaFV0; + } + 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); + if (etap >= etamin && etap < etamax && phip >= minphi && phip < maxphi) { + RhoLatticeFV0AMC[isegment] += 1.0 / TMath::Abs(dphi * detaFV0); + } + isegment++; + } + } + } + + flattenicity = + 1.0 - GetFlatenicity({RhoLatticeFV0AMC.data(), RhoLatticeFV0AMC.size()}); + return flattenicity; + } + // ====================== Flattenicity estimation ends ===================== + + // 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 trackFilter = + (nabs(aod::track::eta) < cfgTrkEtaCut && aod::track::pt > cfgTrkLowPtCut); + + using TrackCandidates = soa::Filtered< + soa::Join>; + + void processDataRun3( + soa::Join::iterator const& collision, + soa::Filtered const& V0s, TrackCandidates const& tracks, + soa::Join const& /*bcs*/, + aod::MFTTracks const& /*mfttracks*/, 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& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (TMath::Abs(posDaughterTrack.eta()) > cfgTrkEtaCut || + TMath::Abs(negDaughterTrack.eta()) > cfgTrkEtaCut || + negDaughterTrack.pt() < cfgTrkLowPtCut || + posDaughterTrack.pt() < cfgTrkLowPtCut) { + continue; + } + float massK0s = v0.mK0Short(); + float massLambda = v0.mLambda(); + float massAntiLambda = v0.mAntiLambda(); + + rKzeroShort.fill(HIST("hMassK0s"), massK0s); + rLambda.fill(HIST("hMassLambda"), massLambda); + rAntiLambda.fill(HIST("hMassAntiLambda"), massAntiLambda); + + float decayvtxX = v0.x(); + 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 ctauK0s = decaylength * massK0s / v0p; + float ctauLambda = decaylength * massLambda / v0p; + float ctauAntiLambda = decaylength * massAntiLambda / v0p; + + // Cut on dynamic columns for K0s + + 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) { + + rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); + rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); + rKzeroShort.fill(HIST("hV0CosPAK0s"), v0.v0cosPA()); + rKzeroShort.fill(HIST("hrapidityK0s"), v0.rapidity(0)); + rKzeroShort.fill(HIST("hctauK0s"), ctauK0s); + rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); + rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); + rKzeroShort.fill(HIST("hMassK0spTFlat"), massK0s, v0.pt(), flattenicity); + + // Filling the PID of the V0 daughters in the region of the K0s peak + if (0.45 < massK0s && massK0s < 0.55) { + rKzeroShort.fill(HIST("hNSigmaPosPionFromK0s"), + posDaughterTrack.tpcNSigmaPi(), + posDaughterTrack.tpcInnerParam()); + rKzeroShort.fill(HIST("hNSigmaNegPionFromK0s"), + negDaughterTrack.tpcNSigmaPi(), + negDaughterTrack.tpcInnerParam()); + } + } + + // 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) { + + rLambda.fill(HIST("hMassLambdaSelected"), massLambda); + rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); + rLambda.fill(HIST("hV0CosPALambda"), v0.v0cosPA()); + rLambda.fill(HIST("hrapidityLambda"), v0.rapidity(1)); + rLambda.fill(HIST("hctauLambda"), ctauLambda); + rLambda.fill(HIST("h2DdecayRadiusLambda"), v0.v0radius()); + rLambda.fill(HIST("hMassLambdapT"), massLambda, v0.pt()); + rLambda.fill(HIST("hMassLambdapTFlat"), massLambda, v0.pt(), flattenicity); + + // Filling the PID of the V0 daughters in the region of the Lambda peak + if (1.015 < massLambda && massLambda < 1.215) { + rLambda.fill(HIST("hNSigmaPosPionFromLambda"), + posDaughterTrack.tpcNSigmaPr(), + posDaughterTrack.tpcInnerParam()); + rLambda.fill(HIST("hNSigmaNegPionFromLambda"), + negDaughterTrack.tpcNSigmaPi(), + negDaughterTrack.tpcInnerParam()); + } + } + + // 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) { + + rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); + rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), + v0.dcaV0daughters()); + rAntiLambda.fill(HIST("hV0CosPAAntiLambda"), v0.v0cosPA()); + rAntiLambda.fill(HIST("hrapidityAntiLambda"), v0.rapidity(2)); + rAntiLambda.fill(HIST("hctauAntiLambda"), ctauAntiLambda); + rAntiLambda.fill(HIST("h2DdecayRadiusAntiLambda"), v0.v0radius()); + rAntiLambda.fill(HIST("hMassAntiLambdapT"), massAntiLambda, v0.pt()); + + rAntiLambda.fill(HIST("hMassAntiLambdapTFlat"), massAntiLambda, v0.pt(), flattenicity); + // Filling the PID of the V0 daughters in the region of the AntiLambda + // peak + if (1.015 < massAntiLambda && massAntiLambda < 1.215) { + rAntiLambda.fill(HIST("hNSigmaPosPionFromAntiLambda"), + posDaughterTrack.tpcNSigmaPi(), + posDaughterTrack.tpcInnerParam()); + rAntiLambda.fill(HIST("hNSigmaNegPionFromAntiLambda"), + negDaughterTrack.tpcNSigmaPr(), + negDaughterTrack.tpcInnerParam()); + } + } + } + } + + using TrackCandidatesMC = + soa::Filtered>; + + Preslice>> perCol = aod::track::collisionId; + Preslice perMCCol = aod::mcparticle::mcCollisionId; + SliceCache cache1; + + void processRecMC( + 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*/, + aod::FV0As const& /*fv0s*/, aod::McParticles const& mcParticles) + { + for (const auto& collision : collisions) { + if (applyEvSel && + !(isEventSelected(collision))) { // Checking if the event passes the + // selection criteria + continue; + } + + 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 v0sThisCollision = V0s.sliceBy(perCol, collision.globalIndex()); + const auto& mcCollision = collision.mcCollision_as(); + + for (const auto& v0 : v0sThisCollision) { + + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (TMath::Abs(posDaughterTrack.eta()) > cfgTrkEtaCut || + TMath::Abs(negDaughterTrack.eta()) > cfgTrkEtaCut || + negDaughterTrack.pt() < cfgTrkLowPtCut || + posDaughterTrack.pt() < cfgTrkLowPtCut) { + continue; + } + + if (!v0.has_mcParticle()) { + continue; + } + + float massK0s = v0.mK0Short(); + float massLambda = v0.mLambda(); + float massAntiLambda = v0.mAntiLambda(); + + rKzeroShort.fill(HIST("hMassK0s"), massK0s); + rLambda.fill(HIST("hMassLambda"), massLambda); + rAntiLambda.fill(HIST("hMassAntiLambda"), massAntiLambda); + + float decayvtxX = v0.x(); + 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 ctauK0s = decaylength * massK0s / v0p; + float ctauLambda = decaylength * massLambda / v0p; + float ctauAntiLambda = decaylength * massAntiLambda / v0p; + 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) { + + rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); + rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); + rKzeroShort.fill(HIST("hV0CosPAK0s"), v0.v0cosPA()); + rKzeroShort.fill(HIST("hrapidityK0s"), v0.rapidity(0)); + rKzeroShort.fill(HIST("hctauK0s"), ctauK0s); + rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); + rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); + rKzeroShort.fill(HIST("hMassK0spTFlat"), massK0s, v0.pt(), flattenicity); + + // Filling the PID of the V0 daughters in the region of the K0s peak + if (0.45 < massK0s && massK0s < 0.55) { + rKzeroShort.fill(HIST("hNSigmaPosPionFromK0s"), + posDaughterTrack.tpcNSigmaPi(), + posDaughterTrack.tpcInnerParam()); + rKzeroShort.fill(HIST("hNSigmaNegPionFromK0s"), + negDaughterTrack.tpcNSigmaPi(), + negDaughterTrack.tpcInnerParam()); + } + } + + // 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) { + + rLambda.fill(HIST("hMassLambdaSelected"), massLambda); + rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); + rLambda.fill(HIST("hV0CosPALambda"), v0.v0cosPA()); + rLambda.fill(HIST("hrapidityLambda"), v0.rapidity(1)); + rLambda.fill(HIST("hctauLambda"), ctauLambda); + rLambda.fill(HIST("h2DdecayRadiusLambda"), v0.v0radius()); + rLambda.fill(HIST("hMassLambdapT"), massLambda, v0.pt()); + rLambda.fill(HIST("hMassLambdapTFlat"), massLambda, v0.pt(), flattenicity); + + // Filling the PID of the V0 daughters in the region of the Lambda peak + if (1.015 < massLambda && massLambda < 1.215) { + rLambda.fill(HIST("hNSigmaPosPionFromLambda"), + posDaughterTrack.tpcNSigmaPr(), + posDaughterTrack.tpcInnerParam()); + rLambda.fill(HIST("hNSigmaNegPionFromLambda"), + negDaughterTrack.tpcNSigmaPi(), + negDaughterTrack.tpcInnerParam()); + } + } + + // 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) { + + rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); + rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), + v0.dcaV0daughters()); + rAntiLambda.fill(HIST("hV0CosPAAntiLambda"), v0.v0cosPA()); + rAntiLambda.fill(HIST("hrapidityAntiLambda"), v0.rapidity(2)); + rAntiLambda.fill(HIST("hctauAntiLambda"), ctauAntiLambda); + rAntiLambda.fill(HIST("h2DdecayRadiusAntiLambda"), v0.v0radius()); + rAntiLambda.fill(HIST("hMassAntiLambdapT"), massAntiLambda, v0.pt()); + rAntiLambda.fill(HIST("hMassAntiLambdapTFlat"), massAntiLambda, v0.pt(), flattenicity); + + // Filling the PID of the V0 daughters in the region of the AntiLambda + // peak + if (1.015 < massAntiLambda && massAntiLambda < 1.215) { + rAntiLambda.fill(HIST("hNSigmaPosPionFromAntiLambda"), + posDaughterTrack.tpcNSigmaPi(), + posDaughterTrack.tpcInnerParam()); + rAntiLambda.fill(HIST("hNSigmaNegPionFromAntiLambda"), + negDaughterTrack.tpcNSigmaPr(), + negDaughterTrack.tpcInnerParam()); + } + } + } + + const auto particlesInCollision = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache1); + float flattenicityMCGen = EstimateFlattenicityFV0MC(particlesInCollision); + rEventSelection.fill(HIST("hFlattenicityDistributionMCGen_Rec"), flattenicityMCGen); + rEventSelection.fill(HIST("hFlattenicity_Corr_Gen_vs_Rec"), flattenicityMCGen, flattenicity); + + for (auto& mcParticle : particlesInCollision) { + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + + if (std::abs(mcParticle.y()) > 0.5f) { + continue; + } + + if (mcParticle.pdgCode() == 310) { + rKzeroShort.fill(HIST("Generated_MCRecoCollCheck_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s + } + if (mcParticle.pdgCode() == 3122) { + rLambda.fill(HIST("Generated_MCRecoCollCheck_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda + } + if (mcParticle.pdgCode() == -3122) { + rAntiLambda.fill(HIST("Generated_MCRecoCollCheck_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + } + } + } + } + + // Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex); + void processGenMC( + o2::aod::McCollision const& mcCollision, + const soa::SmallGroups>& collisions, + o2::aod::McParticles const& mcParticles) + { + float flattenicity = EstimateFlattenicityFV0MC(mcParticles); + rEventSelection.fill(HIST("hFlattenicityDistributionMCGen"), flattenicity); + //==================================== + //===== Event Loss Denominator ======= + //==================================== + + rEventSelection.fill(HIST("hNEventsMCGen"), 0.5); + + if (TMath::Abs(mcCollision.posZ()) > cutzvertex) { + return; + } + rEventSelection.fill(HIST("hNEventsMCGen"), 1.5); + rEventSelection.fill(HIST("hFlat_GenColl_MC"), flattenicity); + + bool isINELgt0true = false; + + if (pwglf::isINELgtNmc(mcParticles, 0, pdg)) { + isINELgt0true = true; + rEventSelection.fill(HIST("hNEventsMCGen"), 2.5); + rEventSelection.fill(HIST("hFlat_GenColl_MC_INELgt0"), flattenicity); + } + + //===================================== + //===== Signal Loss Denominator ======= + //===================================== + + for (auto& mcParticle : mcParticles) { + + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + if (std::abs(mcParticle.y()) > 0.5f) { + continue; + } + + if (mcParticle.pdgCode() == 310) { + 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) { + 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) { + rAntiLambda.fill(HIST("pGen_MCGenColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + if (isINELgt0true) { + rAntiLambda.fill(HIST("pGen_MCGenColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + } + } + } + + int recoCollIndex_INEL = 0; + int recoCollIndex_INELgt0 = 0; + for (auto& collision : collisions) { // loop on reconstructed collisions + + //===================================== + //====== Event Split Numerator ======== + //===================================== + + rEventSelection.fill(HIST("hNEventsMCReco"), 0.5); + if (applyEvSel && !isEventSelected(collision)) { + continue; + } + rEventSelection.fill(HIST("hEventsSelected"), 10.5); + rEventSelection.fill(HIST("hNEventsMCReco"), 1.5); + rEventSelection.fill(HIST("hFlat_RecoColl_MC"), flattenicity); + + recoCollIndex_INEL++; + + if (collision.isInelGt0() && isINELgt0true) { + rEventSelection.fill(HIST("hNEventsMCReco"), 2.5); + rEventSelection.fill(HIST("hFlat_RecoColl_MC_INELgt0"), flattenicity); + + recoCollIndex_INELgt0++; + } + + //===================================== + //======== Sgn Split Numerator ======== + //===================================== + + for (auto& mcParticle : mcParticles) { + + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + + if (std::abs(mcParticle.y()) > 0.5f) { + continue; + } + + if (mcParticle.pdgCode() == 310) { + rKzeroShort.fill(HIST("Generated_MCRecoColl_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s + if (recoCollIndex_INELgt0 > 0) { + rKzeroShort.fill(HIST("Generated_MCRecoColl_INELgt0_K0Short"), mcParticle.pt(), flattenicity); // K0s + } + } + if (mcParticle.pdgCode() == 3122) { + rLambda.fill(HIST("Generated_MCRecoColl_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda + if (recoCollIndex_INELgt0 > 0) { + rLambda.fill(HIST("Generated_MCRecoColl_INELgt0_Lambda"), mcParticle.pt(), flattenicity); // Lambda + } + } + if (mcParticle.pdgCode() == -3122) { + rAntiLambda.fill(HIST("Generated_MCRecoColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + if (recoCollIndex_INELgt0 > 0) { + rAntiLambda.fill(HIST("Generated_MCRecoColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + } + } + } + } + + // From now on keep only mc collisions with at least one reconstructed collision (INEL) + if (recoCollIndex_INEL < 1) { + return; + } + + //===================================== + //====== Event Loss Numerator ========= + //===================================== + + rEventSelection.fill(HIST("hNEventsMCGenReco"), 0.5); + rEventSelection.fill(HIST("hFlat_GenRecoColl_MC"), flattenicity); + + if (recoCollIndex_INELgt0 > 0) { + rEventSelection.fill(HIST("hNEventsMCGenReco"), 1.5); + rEventSelection.fill(HIST("hFlat_GenRecoColl_MC_INELgt0"), flattenicity); + } + + //===================================== + //===== Signal Loss Numerator ========= + //===================================== + + for (auto& mcParticle : mcParticles) { + + if (!mcParticle.isPhysicalPrimary()) { + continue; + } + + if (std::abs(mcParticle.y()) > 0.5f) { + continue; + } + + if (mcParticle.pdgCode() == 310) { + rKzeroShort.fill(HIST("pGen_MCGenRecoColl_INEL_K0Short"), mcParticle.pt(), flattenicity); // K0s + if (recoCollIndex_INELgt0 > 0) { + rKzeroShort.fill(HIST("pGen_MCGenRecoColl_INELgt0_K0Short"), mcParticle.pt(), flattenicity); // K0s + } + } + if (mcParticle.pdgCode() == 3122) { + rLambda.fill(HIST("pGen_MCGenRecoColl_INEL_Lambda"), mcParticle.pt(), flattenicity); // Lambda + if (recoCollIndex_INELgt0 > 0) { + rLambda.fill(HIST("pGen_MCGenRecoColl_INELgt0_Lambda"), mcParticle.pt(), flattenicity); // Lambda + } + } + if (mcParticle.pdgCode() == -3122) { + rAntiLambda.fill(HIST("pGen_MCGenRecoColl_INEL_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + if (recoCollIndex_INELgt0 > 0) { + rAntiLambda.fill(HIST("pGen_MCGenRecoColl_INELgt0_AntiLambda"), mcParticle.pt(), flattenicity); // AntiLambda + } + } + } + } + + 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); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/lambdapolarization.cxx b/PWGLF/Tasks/Strangeness/lambdapolarization.cxx index e2449cd965a..b2fe709e01e 100644 --- a/PWGLF/Tasks/Strangeness/lambdapolarization.cxx +++ b/PWGLF/Tasks/Strangeness/lambdapolarization.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include "TLorentzVector.h" #include "TRandom3.h" @@ -87,6 +88,12 @@ struct lambdapolarization { Configurable cfgCentSel{"cfgCentSel", 80., "Centrality selection"}; Configurable cfgCentEst{"cfgCentEst", 1, "Centrality estimator, 1: FT0C, 2: FT0M"}; + 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"}; + 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 cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"}; Configurable cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"}; @@ -112,13 +119,23 @@ struct lambdapolarization { 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", "BPos", "The name of detector for reference A"}; - Configurable cfgQvecRefBName{"cfgQvecRefBName", "BNeg", "The name of detector for reference B"}; + Configurable cfgQvecRefAName{"cfgQvecRefAName", "TPCpos", "The name of detector for reference A"}; + Configurable cfgQvecRefBName{"cfgQvecRefBName", "TPCneg", "The name of detector for reference B"}; + + Configurable cfgPhiDepStudy{"cfgPhiDepStudy", false, "cfg for phi dependent study"}; + Configurable cfgPhiDepSig{"cfgPhiDepSig", 0.2, "cfg for significance on phi dependent study"}; Configurable cfgShiftCorr{"cfgShiftCorr", false, "additional shift correction"}; Configurable cfgShiftCorrDef{"cfgShiftCorrDef", false, "additional shift correction definition"}; Configurable cfgShiftPath{"cfgShiftPath", "Users/j/junlee/Qvector/QvecCalib/Shift", "Path for Shift"}; + Configurable cfgEffCor{"cfgEffCor", false, "flag to apply efficiency correction"}; + Configurable cfgEffCorPath{"cfgEffCorPath", "", "path for pseudo efficiency correction"}; + + 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"}; + TF1* fMultPVCutLow = nullptr; TF1* fMultPVCutHigh = nullptr; @@ -138,6 +155,7 @@ struct lambdapolarization { int currentRunNumber = -999; int lastRunNumber = -999; std::vector shiftprofile{}; + TProfile2D* EffMap = nullptr; std::string fullCCDBShiftCorrPath; @@ -152,10 +170,12 @@ struct lambdapolarization { return 2; } else if (name.value == "FV0A") { return 3; - } else if (name.value == "BPos") { + } else if (name.value == "TPCpos") { return 4; - } else if (name.value == "BNeg") { + } else if (name.value == "TPCneg") { return 5; + } else if (name.value == "TPCall") { + return 6; } else { return 0; } @@ -163,11 +183,9 @@ struct lambdapolarization { void init(o2::framework::InitContext&) { - AxisSpec massAxis = {100, 1.065, 1.165}; - AxisSpec ptAxis = {100, 0.0, 10.0}; AxisSpec cosAxis = {110, -1.05, 1.05}; - AxisSpec centAxis = {8, 0.0, 80.0}; AxisSpec centQaAxis = {80, 0.0, 80.0}; + AxisSpec PVzQaAxis = {300, -15.0, 15.0}; AxisSpec epAxis = {6, 0.0, 2.0 * constants::math::PI}; AxisSpec epQaAxis = {100, -1.0 * constants::math::PI, constants::math::PI}; @@ -184,10 +202,20 @@ struct lambdapolarization { 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}}); + + 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}}); + histos.add(Form("psi%d/h_alambda_vnsin", i), "", {HistType::kTHnSparseF, {massAxis, ptAxis, cosAxis, centAxis}}); } + histos.add("QA/ptspec_l", "", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("QA/ptspec_al", "", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("QA/ptspecCor_l", "", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); + histos.add("QA/ptspecCor_al", "", {HistType::kTH3F, {massAxis, ptAxis, centAxis}}); 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}}); @@ -224,7 +252,7 @@ struct lambdapolarization { 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 BPos and BNeg 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; @@ -273,6 +301,15 @@ struct lambdapolarization { 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 @@ -288,7 +325,7 @@ struct lambdapolarization { return false; if (candidate.v0cosPA() < cfgv0CosPA) return false; - if (candidate.dcaV0daughters() > cfgDCAV0Dau) + if (std::abs(candidate.dcaV0daughters()) > cfgDCAV0Dau) return false; if (candidate.pt() < cfgV0PtMin) return false; @@ -368,6 +405,9 @@ struct lambdapolarization { QvecRefAInd = RefAId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; QvecRefBInd = RefBId * 4 + 3 + (nmode - 2) * cfgNQvec * 4; + if (collision.qvecAmp()[DetId] < 1e-5 || collision.qvecAmp()[RefAId] < 1e-5 || collision.qvecAmp()[RefBId] < 1e-5) + return; + if (nmode == 2) { histos.fill(HIST("psi2/QA/EP_Det"), centrality, TMath::ATan2(collision.qvecIm()[QvecDetInd], collision.qvecRe()[QvecDetInd]) / static_cast(nmode)); histos.fill(HIST("psi2/QA/EP_RefA"), centrality, TMath::ATan2(collision.qvecIm()[QvecRefAInd], collision.qvecRe()[QvecRefAInd]) / static_cast(nmode)); @@ -477,7 +517,7 @@ struct lambdapolarization { aLambdaTag = 1; } - if (!LambdaTag && !aLambdaTag) + if (LambdaTag == aLambdaTag) continue; if (!SelectionV0(collision, v0)) @@ -492,6 +532,7 @@ struct lambdapolarization { PionVec = ROOT::Math::PxPyPzMVector(postrack.px(), postrack.py(), postrack.pz(), massPi); } LambdaVec = ProtonVec + PionVec; + LambdaVec.SetM(massLambda); ROOT::Math::Boost boost{LambdaVec.BoostToCM()}; ProtonBoostedVec = boost(ProtonVec); @@ -522,38 +563,71 @@ struct lambdapolarization { relphi = TVector2::Phi_0_2pi(static_cast(nmode) * (LambdaVec.Phi() - psidefFT0C - deltapsiFT0C)); } + if (cfgPhiDepStudy && cfgPhiDepSig * std::abs(TMath::Sin(relphi)) > gRandom->Uniform(0, 1)) { + continue; + } + + if (LambdaTag) { + histos.fill(HIST("QA/ptspec_l"), v0.mLambda(), v0.pt(), centrality); + if (cfgEffCor) { + histos.fill(HIST("QA/ptspecCor_l"), v0.mLambda(), v0.pt(), centrality, + 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality))); + } + } + if (aLambdaTag) { + histos.fill(HIST("QA/ptspec_al"), v0.mAntiLambda(), v0.pt(), centrality); + if (cfgEffCor) { + histos.fill(HIST("QA/ptspecCor_al"), v0.mAntiLambda(), v0.pt(), centrality, + 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality))); + } + } + + double weight = cfgEffCor ? 1.0 / EffMap->GetBinContent(EffMap->GetXaxis()->FindBin(v0.pt()), EffMap->GetYaxis()->FindBin(centrality)) : 1.; + if (nmode == 2) { //////////// if (LambdaTag) { - histos.fill(HIST("psi2/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, 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), centrality); + 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(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi2/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } if (aLambdaTag) { - histos.fill(HIST("psi2/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, 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), centrality); + 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.mLambda(), v0.pt(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi2/h_alambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } } else if (nmode == 3) { if (LambdaTag) { - histos.fill(HIST("psi3/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, 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), centrality); + 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(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi3/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } if (aLambdaTag) { - histos.fill(HIST("psi3/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, centrality, relphi); - histos.fill(HIST("psi3/h_alambda_cos2"), v0.mAntiLambda(), v0.pt(), angle * angle, centrality, relphi); - histos.fill(HIST("psi3/h_alambda_cossin"), v0.mAntiLambda(), v0.pt(), angle * TMath::Sin(relphi), centrality); + histos.fill(HIST("psi3/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, centrality, relphi, weight); + 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.mLambda(), v0.pt(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi3/h_alambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } } else if (nmode == 4) { if (LambdaTag) { - histos.fill(HIST("psi4/h_lambda_cos"), v0.mLambda(), v0.pt(), angle, 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), centrality); + 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(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi4/h_lambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } if (aLambdaTag) { - histos.fill(HIST("psi4/h_alambda_cos"), v0.mAntiLambda(), v0.pt(), angle, 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), centrality); + 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.mLambda(), v0.pt(), TMath::Cos(relphi), centrality, weight); + histos.fill(HIST("psi4/h_alambda_vnsin"), v0.mLambda(), v0.pt(), TMath::Sin(relphi), centrality, weight); } } ////////// FIXME: not possible to get histograms using nmode } @@ -572,6 +646,8 @@ struct lambdapolarization { return; } histos.fill(HIST("QA/CentDist"), centrality, 1.0); + histos.fill(HIST("QA/PVzDist"), collision.posZ(), 1.0); + if (cfgShiftCorr) { auto bc = collision.bc_as(); currentRunNumber = bc.runNumber(); @@ -587,6 +663,10 @@ struct lambdapolarization { lastRunNumber = currentRunNumber; } } + if (cfgEffCor) { + auto bc = collision.bc_as(); + EffMap = ccdb->getForTimeStamp(cfgEffCorPath.value, bc.timestamp()); + } for (int i = 2; i < cfgnMods + 2; i++) { if (cfgShiftCorrDef) { FillShiftCorrection(collision, i); diff --git a/PWGLF/Tasks/Strangeness/lambdapolsp.cxx b/PWGLF/Tasks/Strangeness/lambdapolsp.cxx new file mode 100644 index 00000000000..313a6747148 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdapolsp.cxx @@ -0,0 +1,612 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +// Lambda 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 "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 "Common/DataModel/FT0Corrected.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using std::array; + +struct lambdapolsp { + + int mRunNumber; + int multEstimator; + float d_bz; + Service ccdb; + Service pdg; + + // fill output + Configurable additionalEvSel{"additionalEvSel", false, "additionalEvSel"}; + Configurable additionalEvSel2{"additionalEvSel2", false, "additionalEvSel2"}; + Configurable additionalEvSel3{"additionalEvSel3", false, "additionalEvSel3"}; + Configurable correction{"correction", false, "fill histograms including corrections"}; + 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 globalpt{"globalpt", true, "select tracks based on pt global vs tpc"}; + 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"}; + + // 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"}; + Configurable cfgCutDCAz{"cfgCutDCAz", 0.1f, "DCAz range for tracks"}; + Configurable cfgITScluster{"cfgITScluster", 5, "Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 70, "Number of TPC cluster"}; + Configurable isPVContributor{"isPVContributor", true, "is PV contributor"}; + Configurable checkwithpub{"checkwithpub", true, "checking results with published"}; + // 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"}; + Configurable cSigmaMassKs0{"cSigmaMassKs0", 0.006, "Sigma cut on KS0 mass"}; + Configurable cMinLambdaMass{"cMinLambdaMass", 1.0, "Minimum lambda mass"}; + Configurable cMaxLambdaMass{"cMaxLambdaMass", 1.2, "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"}; + + 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"}; + + 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, 0.4, 0.8}, "Eta"}; + + SliceCache cache; + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + AxisSpec thnAxispT{ptNbins, lbinpt, hbinpt, "#it{p}_{T} (GeV/#it{c})"}; + 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 psiACAxis = {120, -6.28, 6.28, "psiAC"}; + + 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("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); + } 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("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); + } 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("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("hCentrality", "Centrality distribution", kTH1F, {{centAxis}}); + // histos.add("hpsiApsiC", "hpsiApsiC", kTHnSparseF, {psiACAxis, psiACAxis}); + // histos.add("hpsiApsiC", "hpsiApsiC", kTH2F, {psiACAxis, psiACAxis}); + // histos.add("hphiminuspsiA", "hphiminuspisA", kTH1F, {{50, 0, 6.28}}, true); + // histos.add("hphiminuspsiC", "hphiminuspisC", kTH1F, {{50, 0, 6.28}}, true); + // histos.add("hCentrality0", "Centrality distribution0", kTH1F, {{centAxis}}); + // histos.add("hCentrality1", "Centrality distribution1", kTH1F, {{centAxis}}); + // histos.add("hCentrality2", "Centrality distribution2", kTH1F, {{centAxis}}); + // histos.add("hCentrality3", "Centrality distribution3", kTH1F, {{centAxis}}); + + if (!checkwithpub) { + // histos.add("hVtxZ", "Vertex distribution in Z;Z (cm)", kTH1F, {{20, -10.0, 10.0}}); + histos.add("hpRes", "hpRes", HistType::kTHnSparseF, {centAxis, thnAxisres}); + if (QA) { + histos.add("hpResSin", "hpResSin", HistType::kTHnSparseF, {centAxis, thnAxisres}); + histos.add("hpCosPsiA", "hpCosPsiA", HistType::kTHnSparseF, {centAxis, thnAxisres}); + histos.add("hpCosPsiC", "hpCosPsiC", HistType::kTHnSparseF, {centAxis, thnAxisres}); + histos.add("hpSinPsiA", "hpSinPsiA", HistType::kTHnSparseF, {centAxis, thnAxisres}); + histos.add("hpSinPsiC", "hpSinPsiC", HistType::kTHnSparseF, {centAxis, 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 (!correction) { + histos.add("hSparseLambdaPolA", "hSparseLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisPol, centAxis}, true); + histos.add("hSparseLambdaPolC", "hSparseLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisPol, centAxis}, true); + histos.add("hSparseAntiLambdaPolA", "hSparseAntiLambdaPolA", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisPol, centAxis}, true); + histos.add("hSparseAntiLambdaPolC", "hSparseAntiLambdaPolC", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisPol, centAxis}, true); + } + if (correction) { + histos.add("hSparseLambdaPolA_corr", "hSparseLambdaPolA_corr", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisCosThetaStar, thnAxisPol, thnAxisPol, thnAxisPol, centAxis}, true); + histos.add("hSparseLambdaPolC_corr", "hSparseLambdaPolC_corr", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisCosThetaStar, thnAxisPol, thnAxisPol, thnAxisPol, centAxis}, true); + histos.add("hSparseAntiLambdaPolA_corr", "hSparseAntiLambdaPolA_corr", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisCosThetaStar, thnAxisPol, thnAxisPol, thnAxisPol, centAxis}, true); + histos.add("hSparseAntiLambdaPolC_corr", "hSparseAntiLambdaPolC_corr", HistType::kTHnSparseF, {thnAxisInvMass, thnAxispT, thnAxisCosThetaStar, thnAxisPol, thnAxisPol, thnAxisPol, centAxis}, 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; + } + } + return true; + } + + template + bool SelectionV0(Collision const& collision, V0 const& candidate) + { + if (TMath::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 float dcaDaughv0 = TMath::Abs(candidate.dcaV0daughters()); + const float cpav0 = candidate.v0cosPA(); + + float CtauLambda = candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * massLambda; + // 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; + } + 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(); + // 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) { + return false; + } + if (TMath::Abs(eta) > ConfDaughEta) { + return false; + } + if (pt < ConfDaughPt) { + 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; + } + + 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; + } + + ROOT::Math::PxPyPzMVector Lambda, Proton, Pion, fourVecDauCM; + // ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY, eventplaneVec, eventplaneVecNorm, beamvector; + ROOT::Math::XYZVector threeVecDauCM, threeVecDauCMXY; + double phiangle = 0.0; + // double massPi = TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(); + // double massPr = TDatabasePDG::Instance()->GetParticle(kProton)->Mass(); + // double massLambda = TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass(); + 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); + 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 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&) + { + + if (!collision.sel8()) { + return; + } + auto centrality = collision.centFT0C(); + + histos.fill(HIST("hCentrality0"), centrality); + if (!collision.triggereventsp()) { + return; + } + // histos.fill(HIST("hCentrality1"), centrality); + + if (additionalEvSel && (!collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))) { + return; + } + // histos.fill(HIST("hCentrality2"), centrality); + // if (additionalEvSel2 && (!collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard))) { + if (additionalEvSel2 && (collision.trackOccupancyInTimeRange() > cfgMaxOccupancy || collision.trackOccupancyInTimeRange() < cfgMinOccupancy)) { + return; + } + // histos.fill(HIST("hCentrality3"), centrality); + if (additionalEvSel3 && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { + return; + } + + auto qxZDCA = collision.qxZDCA(); + auto qxZDCC = collision.qxZDCC(); + auto qyZDCA = collision.qyZDCA(); + auto qyZDCC = collision.qyZDCC(); + auto psiZDCC = collision.psiZDCC(); + auto psiZDCA = collision.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("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 Qxytp = QxtQxp + QytQyp; + auto QxpQyt = qxZDCA * qyZDCC; + auto QxtQyp = qxZDCC * qyZDCA; + + 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); + + for (auto track : tracks) { + if (!selectionTrack(track)) { + continue; + } + + float sign = track.sign(); + if (sign == 0.0) // removing neutral particles + continue; + + auto ux = TMath::Cos(GetPhiInRange(track.phi())); + auto uy = TMath::Sin(GetPhiInRange(track.phi())); + + auto uxQxp = ux * qxZDCA; + auto uyQyp = uy * qyZDCA; + auto uxyQxyp = uxQxp + uyQyp; + auto uxQxt = ux * qxZDCC; + auto uyQyt = uy * qyZDCC; + 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("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("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 { + 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("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("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) { + + auto postrack = v0.template posTrack_as(); + auto negtrack = v0.template negTrack_as(); + + int LambdaTag = 0; + int aLambdaTag = 0; + + if (isSelectedV0Daughter(postrack, 0) && isSelectedV0Daughter(negtrack, 1)) { + LambdaTag = 1; + } + if (isSelectedV0Daughter(negtrack, 0) && isSelectedV0Daughter(postrack, 1)) { + aLambdaTag = 1; + } + + if (LambdaTag == aLambdaTag) + continue; + + if (!SelectionV0(collision, v0)) { + continue; + } + + if (LambdaTag) { + Proton = ROOT::Math::PxPyPzMVector(postrack.px(), postrack.py(), postrack.pz(), massPr); + Pion = ROOT::Math::PxPyPzMVector(negtrack.px(), negtrack.py(), negtrack.pz(), massPi); + } + if (aLambdaTag) { + Proton = ROOT::Math::PxPyPzMVector(negtrack.px(), negtrack.py(), negtrack.pz(), massPr); + Pion = ROOT::Math::PxPyPzMVector(postrack.px(), postrack.py(), postrack.pz(), massPi); + } + Lambda = Proton + Pion; + Lambda.SetM(massLambda); + + ROOT::Math::Boost boost{Lambda.BoostToCM()}; + fourVecDauCM = boost(Proton); + threeVecDauCM = fourVecDauCM.Vect(); + // beamvector = ROOT::Math::XYZVector(0, 0, 1); + // eventplaneVec = ROOT::Math::XYZVector(collision.qFT0C(), collision.qFT0A(), 0); //this needs to be changed + // eventplaneVecNorm = eventplaneVec.Cross(beamvector); //z' + phiangle = TMath::ATan2(fourVecDauCM.Py(), fourVecDauCM.Px()); + // double phiangledir = fourVecDauCM.Phi(); + + auto phiminuspsiC = GetPhiInRange(phiangle - psiZDCC); + auto phiminuspsiA = GetPhiInRange(phiangle - psiZDCA); + // histos.fill(HIST("hpsiApsiC"), psiZDCA, psiZDCC); + // histos.fill(HIST("hpsiApsiC"), GetPhiInRange(GetPhiInRange(phiangle) - GetPhiInRange(psiZDCA)), phiminuspsiA); + // histos.fill(HIST("hphiminuspsiA"), (phiminuspsiA)); + // histos.fill(HIST("hphiminuspsiC"), (phiminuspsiC)); + // auto cosThetaStar = eventplaneVecNorm.Dot(threeVecDauCM) / std::sqrt(threeVecDauCM.Mag2()) / std::sqrt(eventplaneVecNorm.Mag2()); + auto cosThetaStar = fourVecDauCM.Pz() / fourVecDauCM.P(); // A0 correction + auto PolC = TMath::Sin(phiminuspsiC); + auto PolA = TMath::Sin(phiminuspsiA); + + // needed for corrections + auto sinPhiStar = TMath::Sin(GetPhiInRange(phiangle)); + auto cosPhiStar = TMath::Cos(GetPhiInRange(phiangle)); + // auto sinThetaStarcosphiphiStar=sinThetaStar*TMath::Cos(2* GetPhiInRange((Lambda.Phi()-phiangle))); //A2 correction + + if (LambdaTag) { + if (correction) { + histos.fill(HIST("hSparseLambdaPolA_corr"), v0.mLambda(), v0.pt(), cosThetaStar, sinPhiStar, cosPhiStar, PolA, centrality); + histos.fill(HIST("hSparseLambdaPolC_corr"), v0.mLambda(), v0.pt(), cosThetaStar, sinPhiStar, cosPhiStar, PolC, centrality); + } else { + histos.fill(HIST("hSparseLambdaPolA"), v0.mLambda(), v0.pt(), PolA, centrality); + histos.fill(HIST("hSparseLambdaPolC"), v0.mLambda(), v0.pt(), PolC, centrality); + } + } + if (aLambdaTag) { + if (correction) { + histos.fill(HIST("hSparseAntiLambdaPolA_corr"), v0.mAntiLambda(), v0.pt(), cosThetaStar, sinPhiStar, cosPhiStar, PolA, centrality); + histos.fill(HIST("hSparseAntiLambdaPolC_corr"), v0.mAntiLambda(), v0.pt(), cosThetaStar, sinPhiStar, cosPhiStar, PolC, centrality); + } else { + histos.fill(HIST("hSparseAntiLambdaPolA"), v0.mAntiLambda(), v0.pt(), PolA, centrality); + histos.fill(HIST("hSparseAntiLambdaPolC"), v0.mAntiLambda(), v0.pt(), PolC, centrality); + } + } + } + } + } + PROCESS_SWITCH(lambdapolsp, processData, "Process data", true); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"lambdapolsp"})}; +} diff --git a/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx b/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx index 00cea1295bc..d9b15e16d2a 100644 --- a/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx +++ b/PWGLF/Tasks/Strangeness/nonPromptCascade.cxx @@ -9,6 +9,11 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include +#include +#include +#include + #include "CCDB/BasicCCDBManager.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" @@ -38,7 +43,17 @@ using namespace o2::framework; using namespace o2::framework::expressions; struct NPCascCandidate { - int globalIndex; + int64_t trackGlobID; + int64_t trackITSID; + int64_t collisionID; + float matchingChi2; + float itsClusSize; + bool isGoodMatch; + bool isGoodCascade; + int pdgCodeMom; + int pdgCodeITStrack; + bool isFromBeauty; + bool isFromCharm; float pvX; float pvY; float pvZ; @@ -136,10 +151,12 @@ struct NonPromptCascadeTask { Produces NPCTable; Produces NPCTableMC; + Produces NPCTableGen; using TracksExtData = soa::Join; using TracksExtMC = soa::Join; - using CollisionCandidatesRun3 = soa::Join::iterator; + using CollisionCandidatesRun3 = soa::Join; + using CollisionCandidatesRun3MC = soa::Join; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable propToDCA{"propToDCA", true, "create tracks version propagated to PCA"}; @@ -208,22 +225,22 @@ struct NonPromptCascadeTask { void initCCDB(aod::BCsWithTimestamps::iterator const& bc) { - if (mRunNumber != bc.runNumber()) { - mRunNumber = bc.runNumber(); - auto timestamp = bc.timestamp(); - - if (o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(cfgGRPpath, timestamp)) { - o2::base::Propagator::initFieldFromGRP(grpo); - bz = grpo->getNominalL3Field(); - } else if (o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp(cfgGRPmagPath, timestamp)) { - o2::base::Propagator::initFieldFromGRP(grpmag); - bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); - LOG(debug) << "bz = " << bz; - } else { - LOG(fatal) << "Got nullptr from CCDB for path " << cfgGRPmagPath << " of object GRPMagField and " << cfgGRPpath << " of object GRPObject for timestamp " << timestamp; - } + if (mRunNumber == bc.runNumber()) { + return; + } + mRunNumber = bc.runNumber(); + auto timestamp = bc.timestamp(); + + if (o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp(cfgGRPpath, timestamp)) { + o2::base::Propagator::initFieldFromGRP(grpo); + bz = grpo->getNominalL3Field(); + } else if (o2::parameters::GRPMagField* grpmag = ccdb->getForTimeStamp(cfgGRPmagPath, timestamp)) { + o2::base::Propagator::initFieldFromGRP(grpmag); + bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); + LOG(debug) << "bz = " << bz; + } else { + LOG(fatal) << "Got nullptr from CCDB for path " << cfgGRPmagPath << " of object GRPMagField and " << cfgGRPpath << " of object GRPObject for timestamp " << timestamp; } - return; } void init(InitContext const&) @@ -353,35 +370,53 @@ struct NonPromptCascadeTask { dDCA.pionDCAz = impactParameterPiontrack.getZ(); } - void processTrackedCascadesMC(CollisionCandidatesRun3 const& collision, + void processTrackedCascadesMC(CollisionCandidatesRun3MC const& collisions, aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& /*cascades*/, aod::V0s const& /*v0s*/, TracksExtMC const& /*tracks*/, - aod::McParticles const& mcParticles, aod::BCsWithTimestamps const&) + aod::McParticles const& mcParticles, aod::McCollisions const&, aod::BCsWithTimestamps const&) { - candidates.clear(); - bool isOmega{false}; - auto bc = collision.bc_as(); - initCCDB(bc); + candidates.clear(); + std::vector mcParticleId; - const auto primaryVertex = getPrimaryVertex(collision); + auto isFromHF = [&](auto particle) -> std::tuple { + bool fromBeauty = false; + bool fromCharm = false; + if (particle.has_mothers()) { + auto mom = particle.template mothers_as()[0]; + int pdgCodeMom = mom.pdgCode(); + fromBeauty = std::abs(pdgCodeMom) / 5000 == 1 || std::abs(pdgCodeMom) / 500 == 1 || std::abs(pdgCodeMom) == 5; + fromCharm = std::abs(pdgCodeMom) / 4000 == 1 || std::abs(pdgCodeMom) / 400 == 1 || std::abs(pdgCodeMom) == 4; + while (mom.has_mothers()) { + const auto grandma = mom.template mothers_as()[0]; + int pdgCodeGrandma = std::abs(grandma.pdgCode()); + fromBeauty = fromBeauty || (pdgCodeGrandma / 5000 == 1 || pdgCodeGrandma / 500 == 1 || pdgCodeGrandma == 5); + fromCharm = fromCharm || (pdgCodeGrandma / 4000 == 1 || pdgCodeGrandma / 400 == 1 || pdgCodeGrandma == 4); + mom = grandma; + } + } + return {fromBeauty, fromCharm}; + }; - 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) { + auto collision = trackedCascade.collision_as(); - std::vector mcParticleId; + auto bc = collision.bc_as(); + initCCDB(bc); - for (const auto& trackedCascade : trackedCascades) { + const auto primaryVertex = getPrimaryVertex(collision); - isOmega = false; + 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.track_as(); + const auto& ITStrack = trackedCascade.itsTrack_as(); const auto& casc = trackedCascade.cascade(); const auto& bachelor = casc.bachelor_as(); const auto& v0 = casc.v0(); @@ -442,11 +477,7 @@ struct NonPromptCascadeTask { momenta[1] = {pionTrack.px(), pionTrack.py(), pionTrack.pz()}; const auto v0mass = RecoDecay::m(momenta, masses); - ////Omega hypohesis -> rejecting Xi - if (TMath::Abs(massXi - constants::physics::MassXiMinus) > 0.005) { - isOmega = true; - invMassBCOmega->Fill(massOmega); - } + invMassBCOmega->Fill(massOmega); invMassBCXi->Fill(massXi); invMassBCV0->Fill(v0mass); @@ -458,18 +489,13 @@ struct NonPromptCascadeTask { 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(); // if (!bachelor.hasTOF() && !ptrack.hasTOF() && !ntrack.hasTOF()) { @@ -491,22 +517,13 @@ struct NonPromptCascadeTask { // QA PID float nSigmaTPC[nParticles]{bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi()}; - 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)) { - continue; - } - } - registry.fill(HIST("h_PIDcutsOmega"), 3, massOmega); - } - - if (bachelor.hasTPC()) { + if (bachelor.hasTPC()) { // same cuts for Omega and Xi LOG(debug) << "TPCSignal bachelor " << bachelor.sign() << "/" << bachelor.tpcInnerParam() << "/" << bachelor.tpcSignal(); - if (nSigmaTPC[1] < cfgCutsPID->get(1u, 0u) || nSigmaTPC[1] > cfgCutsPID->get(1u, 1u)) { + if (nSigmaTPC[0] < cfgCutsPID->get(0u, 0u) || nSigmaTPC[0] > cfgCutsPID->get(0u, 1u)) { continue; } } + registry.fill(HIST("h_PIDcutsOmega"), 3, massOmega); registry.fill(HIST("h_PIDcutsXi"), 3, massXi); LOG(debug) << "TPCSignal protonTrack " << protonTrack.sign() << "/" << protonTrack.tpcInnerParam() << "/" << protonTrack.tpcSignal(); @@ -524,11 +541,9 @@ struct NonPromptCascadeTask { registry.fill(HIST("h_PIDcutsXi"), 5, massXi); - if (isOmega) { - registry.fill(HIST("h_PIDcutsOmega"), 5, massOmega); - invMassACOmega->Fill(massOmega); - registry.fill(HIST("h_massvspt_Omega"), massOmega, track.pt()); - } + registry.fill(HIST("h_PIDcutsOmega"), 5, massOmega); + invMassACOmega->Fill(massOmega); + registry.fill(HIST("h_massvspt_Omega"), massOmega, track.pt()); registry.fill(HIST("h_PIDcutsXi"), 5, massXi); @@ -539,7 +554,7 @@ struct NonPromptCascadeTask { registry.fill(HIST("h_massvspt_V0"), v0mass, track.pt()); motherDCA mDCA; - fillCascadeDCA(track, protonTrack, pionTrack, primaryVertex, isOmega, mDCA); + fillCascadeDCA(track, protonTrack, pionTrack, primaryVertex, true, mDCA); // always filling in MC LOGF(debug, "protonTrack (id: %d, pdg: %d) has mother %d", protonTrack.mcParticleId(), protonTrack.mcParticle().pdgCode(), protonTrack.mcParticle().has_mothers() ? protonTrack.mcParticle().mothersIds()[0] : -1); @@ -553,9 +568,39 @@ struct NonPromptCascadeTask { LOG(debug) << "v0 with PDG code: " << v0part.pdgCode(); } daughtersDCA dDCA; - fillDauDCA(trackedCascade, bachelor, protonTrack, pionTrack, primaryVertex, isOmega, dDCA); + fillDauDCA(trackedCascade, bachelor, protonTrack, pionTrack, primaryVertex, true, dDCA); // always filling in MC + + bool isGoodCascade = false; + + int motherParticleID = -1; + + if (protonTrack.mcParticle().has_mothers() && pionTrack.mcParticle().has_mothers() && bachelor.mcParticle().has_mothers()) { + if (protonTrack.mcParticle().mothersIds()[0] == pionTrack.mcParticle().mothersIds()[0]) { + const auto v0part = protonTrack.mcParticle().mothers_first_as(); + if (abs(v0part.pdgCode()) == 3122 && v0part.has_mothers()) { + const auto motherV0 = v0part.mothers_as()[0]; + // const auto motherBach = bachelor.mcParticle().mothers_as()[0]; + if (v0part.mothersIds()[0] == bachelor.mcParticle().mothersIds()[0]) { + if (abs(motherV0.pdgCode()) == 3312 || abs(motherV0.pdgCode()) == 3334) { + isGoodCascade = true; + motherParticleID = v0part.mothersIds()[0]; + } + } + } + } + } + + bool isGoodMatch = ((motherParticleID == ITStrack.mcParticleId())) ? true : false; - candidates.emplace_back(NPCascCandidate{static_cast(track.globalIndex()), + int pdgCodeMom = 0; + std::tuple fromHF{false, false}; + if (isGoodCascade && isGoodMatch) { + fromHF = isFromHF(track.mcParticle()); + pdgCodeMom = track.mcParticle().has_mothers() ? track.mcParticle().mothers_as()[0].pdgCode() : 0; + } + int itsTrackPDG = ITStrack.has_mcParticle() ? ITStrack.mcParticle().pdgCode() : 0; + + candidates.emplace_back(NPCascCandidate{track.globalIndex(), ITStrack.globalIndex(), trackedCascade.collisionId(), trackedCascade.matchingChi2(), trackedCascade.itsClsSize(), isGoodMatch, isGoodCascade, pdgCodeMom, itsTrackPDG, std::get<0>(fromHF), std::get<1>(fromHF), primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), track.pt(), track.eta(), track.phi(), protonTrack.pt(), protonTrack.eta(), pionTrack.pt(), pionTrack.eta(), bachelor.pt(), bachelor.eta(), @@ -581,8 +626,11 @@ struct NonPromptCascadeTask { } auto particle = mcParticles.iteratorAt(mcParticleId[i]); auto& c = candidates[i]; + auto mcCollision = particle.mcCollision_as(); + auto label = collisions.iteratorAt(c.collisionID); - NPCTableMC(c.pvX, c.pvY, c.pvZ, + NPCTableMC(c.matchingChi2, c.itsClusSize, c.isGoodMatch, c.isGoodCascade, c.pdgCodeMom, c.pdgCodeITStrack, c.isFromBeauty, c.isFromCharm, + 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, @@ -593,38 +641,49 @@ struct NonPromptCascadeTask { 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()); + particle.pt(), particle.eta(), particle.phi(), particle.pdgCode(), mcCollision.posX() - particle.vx(), mcCollision.posY() - particle.vy(), mcCollision.posZ() - particle.vz(), mcCollision.globalIndex() == label.mcCollisionId()); + } + + for (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(); + + NPCTableGen(p.pt(), p.eta(), p.phi(), p.pdgCode(), pdgCodeMom, mcCollision.posX() - p.vx(), mcCollision.posY() - p.vy(), mcCollision.posZ() - p.vz(), std::get<0>(fromHF), std::get<1>(fromHF)); } } PROCESS_SWITCH(NonPromptCascadeTask, processTrackedCascadesMC, "process cascades from strangeness tracking: MC analysis", true); - void processTrackedCascadesData(CollisionCandidatesRun3 const& collision, + void processTrackedCascadesData(CollisionCandidatesRun3 const& /*collisions*/, aod::AssignedTrackedCascades const& trackedCascades, aod::Cascades const& /*cascades*/, aod::V0s const& /*v0s*/, TracksExtData const& /*tracks*/, aod::BCsWithTimestamps const&) { candidates.clear(); - bool isOmega{false}; - - auto bc = collision.bc_as(); - initCCDB(bc); - - const auto primaryVertex = getPrimaryVertex(collision); + for (const auto& trackedCascade : trackedCascades) { + bool isOmega{false}; - 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); + auto collision = trackedCascade.collision_as(); + auto bc = collision.bc_as(); + initCCDB(bc); - for (const auto& trackedCascade : trackedCascades) { + const auto primaryVertex = getPrimaryVertex(collision); - isOmega = false; + 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.track_as(); + const auto& ITStrack = trackedCascade.itsTrack_as(); const auto& casc = trackedCascade.cascade(); const auto& bachelor = casc.bachelor_as(); const auto& v0 = casc.v0(); @@ -790,7 +849,7 @@ struct NonPromptCascadeTask { daughtersDCA dDCA; fillDauDCA(trackedCascade, bachelor, protonTrack, pionTrack, primaryVertex, isOmega, dDCA); - candidates.emplace_back(NPCascCandidate{static_cast(track.globalIndex()), + candidates.emplace_back(NPCascCandidate{track.globalIndex(), ITStrack.globalIndex(), trackedCascade.collisionId(), trackedCascade.matchingChi2(), trackedCascade.itsClsSize(), 0, 0, 0, 0, 0, 0, primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ(), track.pt(), track.eta(), track.phi(), protonTrack.pt(), protonTrack.eta(), pionTrack.pt(), pionTrack.eta(), bachelor.pt(), bachelor.eta(), @@ -802,12 +861,12 @@ struct NonPromptCascadeTask { protonTrack.tpcNSigmaPr(), pionTrack.tpcNSigmaPi(), bachelor.tpcNSigmaKa(), bachelor.tpcNSigmaPi(), protonTrack.hasTOF(), pionTrack.hasTOF(), bachKaonHasTOF, bachPionHasTOF, protonTrack.tofNSigmaPr(), pionTrack.tofNSigmaPi(), bachelor.tofNSigmaKa(), bachelor.tofNSigmaPi()}); - - } // end loop over tracked cascades + } for (auto& c : candidates) { - NPCTable(c.pvX, c.pvY, c.pvZ, + NPCTable(c.matchingChi2, c.itsClusSize, + 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, diff --git a/PWGLF/Tasks/Strangeness/phik0sanalysis.cxx b/PWGLF/Tasks/Strangeness/phik0sanalysis.cxx index d4511941998..e9c37b8dc4b 100644 --- a/PWGLF/Tasks/Strangeness/phik0sanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/phik0sanalysis.cxx @@ -24,9 +24,9 @@ #include #include #include +#include #include #include -#include #include #include "Framework/runDataProcessing.h" @@ -44,6 +44,9 @@ #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" using namespace o2; using namespace o2::framework; @@ -51,49 +54,45 @@ using namespace o2::framework::expressions; namespace { -static constexpr int nMultBin = 10; - -constexpr float flowmPhiInc[nMultBin] = {1.01074f, 1.01073f, 1.01072f, 1.01074f, 1.01075f, 1.01074f, 1.01075f, 1.01074f, 1.01073f, 1.01074f}; -constexpr float fupmPhiInc[nMultBin] = {1.02778f, 1.02777f, 1.02776f, 1.02778f, 1.02779f, 1.02778f, 1.02779f, 1.02778f, 1.02777f, 1.02778f}; - -constexpr float flowmPhiFCut[nMultBin] = {1.01072f, 1.01073f, 1.01072f, 1.01074f, 1.01075f, 1.01076f, 1.01076f, 1.01076f, 1.01075f, 1.01073f}; -constexpr float fupmPhiFCut[nMultBin] = {1.02776f, 1.02777f, 1.02776f, 1.02778f, 1.02779f, 1.02778f, 1.02778f, 1.02778f, 1.02779f, 1.02777f}; +const int nMultBin = 10; +constexpr float multBin[nMultBin + 1] = {0.0f, 1.0f, 5.0f, 10.0f, 15.0f, 20.0f, 30.0f, 40.0f, 50.0f, 70.0f, 100.0f}; +auto vecMultBin = std::vector{multBin, multBin + nMultBin + 1}; -constexpr float flowmPhiSCut[nMultBin] = {1.01072f, 1.01074f, 1.01070f, 1.01076f, 1.01075f, 1.01077f, 1.01075f, 1.01075f, 1.01076f, 1.01077f}; -constexpr float fupmPhiSCut[nMultBin] = {1.02776f, 1.02778f, 1.02774f, 1.02780f, 1.02779f, 1.02781f, 1.02779f, 1.02779f, 1.02780f, 1.02774f}; +const int nPtBinK0S = 7; +constexpr float pTBinK0S[nPtBinK0S + 1] = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f}; +auto vecPtBinK0S = std::vector{pTBinK0S, pTBinK0S + nPtBinK0S + 1}; -static constexpr float multBin[nMultBin + 1] = {0.0, 1.0, 5.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 70.0, 100.0}; - -static constexpr std::string_view PhiK0SSEInc[nMultBin] = {"h2PhiK0SSEInc_0_1", "h2PhiK0SSEInc_1_5", "h2PhiK0SSEInc_5_10", "h2PhiK0SSEInc_10_15", "h2PhiK0SSEInc_15_20", - "h2PhiK0SSEInc_20_30", "h2PhiK0SSEInc_30_40", "h2PhiK0SSEInc_40_50", "h2PhiK0SSEInc_50_70", "h2PhiK0SSEInc_70_100"}; -static constexpr std::string_view PhiK0SSEFCut[nMultBin] = {"h2PhiK0SSEFCut_0_1", "h2PhiK0SSEFCut_1_5", "h2PhiK0SSEFCut_5_10", "h2PhiK0SSEFCut_10_15", "h2PhiK0SSEFCut_15_20", - "h2PhiK0SSEFCut_20_30", "h2PhiK0SSEFCut_30_40", "h2PhiK0SSEFCut_40_50", "h2PhiK0SSEFCut_50_70", "h2PhiK0SSEFCut_70_100"}; -static constexpr std::string_view PhiK0SSESCut[nMultBin] = {"h2PhiK0SSESCut_0_1", "h2PhiK0SSESCut_1_5", "h2PhiK0SSESCut_5_10", "h2PhiK0SSESCut_10_15", "h2PhiK0SSESCut_15_20", - "h2PhiK0SSESCut_20_30", "h2PhiK0SSESCut_30_40", "h2PhiK0SSESCut_40_50", "h2PhiK0SSESCut_50_70", "h2PhiK0SSESCut_70_100"}; - -static constexpr std::string_view PhiPiSEInc[nMultBin] = {"h2PhiPiSEInc_0_1", "h2PhiPiSEInc_1_5", "h2PhiPiSEInc_5_10", "h2PhiPiSEInc_10_15", "h2PhiPiSEInc_15_20", - "h2PhiPiSEInc_20_30", "h2PhiPiSEInc_30_40", "h2PhiPiSEInc_40_50", "h2PhiPiSEInc_50_70", "h2PhiPiSEInc_70_100"}; -static constexpr std::string_view PhiPiSEFCut[nMultBin] = {"h2PhiPiSEFCut_0_1", "h2PhiPiSEFCut_1_5", "h2PhiPiSEFCut_5_10", "h2PhiPiSEFCut_10_15", "h2PhiPiSEFCut_15_20", - "h2PhiK0SSEFCut_20_30", "h2PhiK0SSEFCut_30_40", "h2PhiK0SSEFCut_40_50", "h2PhiK0SSEFCut_50_70", "h2PhiK0SSEFCut_70_100"}; -static constexpr std::string_view PhiPiSESCut[nMultBin] = {"h2PhiPiSESCut_0_1", "h2PhiPiSESCut_1_5", "h2PhiPiSESCut_5_10", "h2PhiPiSESCut_10_15", "h2PhiPiSESCut_15_20", - "h2PhiPiSESCut_20_30", "h2PhiPiSESCut_30_40", "h2PhiPiSESCut_40_50", "h2PhiPiSESCut_50_70", "h2PhiPiSESCut_70_100"}; +const int nPtBinPi = 8; +constexpr float pTBinPi[nPtBinPi + 1] = {0.2f, 0.4f, 0.6f, 0.8f, 1.0f, 1.2f, 1.5f, 2.0f, 3.0f}; +auto vecPtBinPi = std::vector{pTBinPi, pTBinPi + nPtBinPi + 1}; } // namespace struct phik0shortanalysis { // Histograms are defined with HistogramRegistry HistogramRegistry eventHist{"eventHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry K0SHist{"K0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry MCeventHist{"MCeventHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry PhicandHist{"PhicandHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry K0SHist{"K0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry PhipurHist{"PhipurHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry MCPhipurHist{"MCPhipurHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry PhiK0SHist{"PhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry MCPhiK0SHist{"MCPhiK0SHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; HistogramRegistry PhiPionHist{"PhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry MCPhiPionHist{"MCPhiPionHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry PhieffHist{"PhieffHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry K0SeffHist{"K0SeffHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry PioneffHist{"PioneffHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry yaccHist{"yaccHist", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; // Configurable for event selection Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + // 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 V0 selection - Configurable minTPCnClsFound{"minTPCnClsFound", 80.0f, "min number of found TPC clusters"}; - Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 80.0f, "min number of TPC crossed rows"}; + 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"}; @@ -108,45 +107,47 @@ struct phik0shortanalysis { Configurable lowmK0S{"lowmK0S", 0.48, "Lower limit on K0Short mass"}; Configurable upmK0S{"upmK0S", 0.52, "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 nBins{"nBins", 50, "N bins in cfgPhimassaxis"}; - Configurable> lowmPhiInc{"lowmPhiInc", std::vector{flowmPhiInc, flowmPhiInc + nMultBin}, "Lower limits on Phi mass Inclusive"}; - Configurable> upmPhiInc{"upmPhiInc", std::vector{fupmPhiInc, fupmPhiInc + nMultBin}, "Upper limits on Phi mass Inclusive"}; - Configurable> lowmPhiFCut{"lowmPhiFCut", std::vector{flowmPhiFCut, flowmPhiFCut + nMultBin}, "Lower limits on Phi mass First Cut"}; - Configurable> upmPhiFCut{"upmPhiFCut", std::vector{fupmPhiFCut, fupmPhiFCut + nMultBin}, "Upper limits on Phi mass First Cut"}; - Configurable> lowmPhiSCut{"lowmPhiSCut", std::vector{flowmPhiSCut, flowmPhiSCut + nMultBin}, "Lower limits on Phi mass Second Cut"}; - Configurable> upmPhiSCut{"upmPhiSCut", std::vector{fupmPhiSCut, fupmPhiSCut + nMultBin}, "Upper limits on Phi mass Second Cut"}; + Configurable nBins{"nBins", 14, "N bins in cfgPhimassaxis"}; + Configurable lowmPhi{"lowmPhiMB", 1.0095, "Upper limits on Phi mass for signal extraction"}; + Configurable upmPhi{"upmPhiMB", 1.029, "Upper limits on Phi mass for signal extraction"}; // Configurables for phi selection - Configurable cMinPtcut{"cMinPtcut", 0.15, "Track minimum pt cut"}; 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 cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; - Configurable cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + 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{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; Configurable nsigmaCutCombinedKa{"nsigmaCutCombined", 3.0, "Value of the TOF Nsigma cut"}; - // Configurables for pions(extra with respect to a few of those defined for V0) - Configurable minITSnCls{"minITSnCls", 4.0f, "min number of ITS clusters"}; + // 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 NSigmaTOFPion{"NSigmaTOFPion", 5.0, "NSigmaTOFPion"}; - // Configurables for invariant mass histograms filling - Configurable cfgFirstCutonDeltay{"cgfFirstCutonDeltay", 0.5, "First upper bound on Deltay selection"}; - Configurable cfgSecondCutonDeltay{"cgfSecondCutonDeltay", 0.2, "Second upper bound on Deltay selection"}; + // Configurable on pion pT bins + Configurable> binspTPi{"binspTPi", {0.2, 0.4, 0.6, 0.8, 1.0f, 1.2, 1.5, 2.0, 3.0}, "pT bin limits for pions"}; - // Configurable for event mixing - Configurable cfgNoMixedEvents{"cfgNoMixedEvents", 5, "Number of mixed events per event"}; + // Configurables for delta y selection + Configurable nBinsy{"nBinsy", 10, "Number of bins in y and deltay axis"}; + Configurable cfgyAcceptance{"cfgyAcceptance", 0.5f, "Rapidity acceptance"}; + Configurable cfgFirstCutonDeltay{"cgfFirstCutonDeltay", 0.5f, "First upper bound on Deltay selection"}; + Configurable cfgSecondCutonDeltay{"cgfSecondCutonDeltay", 0.1f, "Second upper bound on Deltay selection"}; - // Configurable axis - 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"}; + // Configurable for RecMC + Configurable cfgiskNoITSROFrameBorder{"cfgiskNoITSROFrameBorder", false, "kNoITSROFrameBorder request on RecMC collisions"}; // Constants double massKa = o2::constants::physics::MassKPlus; @@ -162,43 +163,52 @@ struct phik0shortanalysis { // Defining the type of the collisions for data and MC using SelCollisions = soa::Join; - using MCCollisions = soa::Join; + using SimCollisions = soa::Join; + using MCCollisions = soa::Join; // Defining the type of the V0s using FullV0s = soa::Filtered; - // Defining the type of the tracks + // Defining the type of the tracks for data and MC using FullTracks = soa::Join; + using FullMCTracks = soa::Join; + using V0DauTracks = soa::Join; + using V0DauMCTracks = soa::Join; // Defining the binning policy for mixed event using BinningTypeVertexContributor = ColumnBinningPolicy; SliceCache cache; + Partition posTracks = aod::track::signed1Pt > cfgCutCharge; Partition negTracks = aod::track::signed1Pt < cfgCutCharge; - void init(InitContext const&) + Partition posMCTracks = aod::track::signed1Pt > cfgCutCharge; + Partition negMCTracks = aod::track::signed1Pt < cfgCutCharge; + + // Necessary to flag INEL>0 events in GenMC + Service pdgDB; + + void init(InitContext&) { // Axes AxisSpec K0SmassAxis = {200, 0.45f, 0.55f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec PhimassAxis = {200, 0.9f, 1.2f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec sigPhimassAxis = {nBins, lowmPhi, upmPhi, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; AxisSpec vertexZAxis = {100, -15.f, 15.f, "vrtx_{Z} [cm]"}; - AxisSpec deltayAxis = {16, 0.0f, 0.8f, "|#it{#Deltay}|"}; + AxisSpec yAxis = {nBinsy, -cfgyAcceptance, cfgyAcceptance, "#it{y}"}; + AxisSpec deltayAxis = {nBinsy, 0.0f, 1.0f, "|#it{#Deltay}|"}; AxisSpec multAxis = {120, 0.0f, 120.0f, "centFT0M"}; - AxisSpec ptAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; - std::vector cfgPhimassAxisInc; - std::vector cfgPhimassAxisFCut; - std::vector cfgPhimassAxisSCut; - for (int i = 0; i < nMultBin; i++) { - cfgPhimassAxisInc.push_back({nBins, lowmPhiInc->at(i), upmPhiInc->at(i), "#it{M}_{inv} [GeV/#it{c}^{2}]"}); - cfgPhimassAxisFCut.push_back({nBins, lowmPhiFCut->at(i), upmPhiFCut->at(i), "#it{M}_{inv} [GeV/#it{c}^{2}]"}); - cfgPhimassAxisSCut.push_back({nBins, lowmPhiSCut->at(i), upmPhiSCut->at(i), "#it{M}_{inv} [GeV/#it{c}^{2}]"}); - } + 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})"}; // Histograms // Number of events per selection - eventHist.add("hEventSelection", "hEVentSelection", kTH1F, {{5, -0.5f, 4.5f}}); + eventHist.add("hEventSelection", "hEventSelection", kTH1F, {{5, -0.5f, 4.5f}}); eventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); eventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(2, "sel8 cut"); eventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(3, "posZ cut"); @@ -206,70 +216,203 @@ struct phik0shortanalysis { eventHist.get(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(5, "With at least a #phi cand"); // Event information - eventHist.add("hVertexZRec", "hVertexZRec", kTH1F, {vertexZAxis}); + eventHist.add("hVertexZ", "hVertexZ", kTH1F, {vertexZAxis}); eventHist.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {multAxis}); - // K0S topological/PID cuts - K0SHist.add("hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {{55, 0.0f, 2.2f}}); - K0SHist.add("hV0CosPA", "hV0CosPA", kTH1F, {{100, 0.95f, 1.f}}); - K0SHist.add("hNSigmaPosPionFromK0S", "hNSigmaPosPionFromK0Short", kTH2F, {ptAxis, {100, -5.f, 5.f}}); - K0SHist.add("hNSigmaNegPionFromK0S", "hNSigmaNegPionFromK0Short", kTH2F, {ptAxis, {100, -5.f, 5.f}}); + // Number of MC events per selection for Rec and Gen + MCeventHist.add("hRecMCEventSelection", "hRecMCEventSelection", kTH1F, {{8, -0.5f, 7.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"); + MCeventHist.get(HIST("hRecMCEventSelection"))->GetXaxis()->SetBinLabel(4, "kNoITSROFrameBorder"); + 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.add("hGenMCEventSelection", "hGenMCEventSelection", kTH1F, {{5, -0.5f, 4.5f}}); + MCeventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions"); + MCeventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(2, "posZ cut"); + MCeventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(3, "INEL>0 cut"); + MCeventHist.get(HIST("hGenMCEventSelection"))->GetXaxis()->SetBinLabel(4, "With at least a #phi"); + 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("hGenMCVertexZ", "hGenMCVertexZ", kTH1F, {vertexZAxis}); + MCeventHist.add("hGenMCMultiplicityPercent", "GenMC Multiplicity Percentile", kTH1F, {binnedmultAxis}); // Phi tpological/PID cuts PhicandHist.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); PhicandHist.add("hDcaxy", "Dcaxy distribution", kTH1F, {{200, -1.0f, 1.0f}}); PhicandHist.add("hDcaz", "Dcaz distribution", kTH1F, {{200, -1.0f, 1.0f}}); - PhicandHist.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH2F, {ptAxis, {100, -10.0f, 10.0f}}); - PhicandHist.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH2F, {ptAxis, {100, -10.0f, 10.0f}}); + PhicandHist.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH2F, {ptK0SAxis, {100, -10.0f, 10.0f}}); + PhicandHist.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH2F, {ptK0SAxis, {100, -10.0f, 10.0f}}); + + // K0S topological/PID cuts + K0SHist.add("hDCAV0Daughters", "hDCAV0Daughters", kTH1F, {{55, 0.0f, 2.2f}}); + K0SHist.add("hV0CosPA", "hV0CosPA", kTH1F, {{100, 0.95f, 1.f}}); + K0SHist.add("hNSigmaPosPionFromK0S", "hNSigmaPosPionFromK0Short", kTH2F, {ptK0SAxis, {100, -5.f, 5.f}}); + K0SHist.add("hNSigmaNegPionFromK0S", "hNSigmaNegPionFromK0Short", kTH2F, {ptK0SAxis, {100, -5.f, 5.f}}); // Phi invariant mass for computing purities and normalisation - PhipurHist.add("h2PhipurInvMass", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH2F, {multAxis, PhimassAxis}); - PhipurHist.add("h2PhipurK0SInvMassInclusive", "Invariant mass of Phi for Purity (K0S) Inclusive", kTH2F, {multAxis, PhimassAxis}); - PhipurHist.add("h2PhipurK0SInvMassFirstCut", "Invariant mass of Phi for Purity (K0S) Deltay < FirstCut", kTH2F, {multAxis, PhimassAxis}); - PhipurHist.add("h2PhipurK0SInvMassSecondCut", "Invariant mass of Phi for Purity (K0S) Deltay < SecondCut", kTH2F, {multAxis, PhimassAxis}); - PhipurHist.add("h3PhipurPiInvMassInclusive", "Invariant mass of Phi for Purity (Pi) Inclusive", kTH3F, {multAxis, ptAxis, PhimassAxis}); - PhipurHist.add("h3PhipurPiInvMassFirstCut", "Invariant mass of Phi for Purity (Pi) Deltay < FirstCut", kTH3F, {multAxis, ptAxis, PhimassAxis}); - PhipurHist.add("h3PhipurPiInvMassSecondCut", "Invariant mass of Phi for Purity (Pi) Deltay < SecondCut", kTH3F, {multAxis, ptAxis, PhimassAxis}); - - // 2D mass for Phi and K0S - for (int i = 0; i < nMultBin; i++) { - PhiK0SHist.add(PhiK0SSEInc[i].data(), "2D Invariant mass of Phi and K0Short for Same Event Inclusive", kTH2F, {K0SmassAxis, cfgPhimassAxisInc.at(i)}); - PhiK0SHist.add(PhiK0SSEFCut[i].data(), "2D Invariant mass of Phi and K0Short for Same Event Deltay < FirstCut", kTH2F, {K0SmassAxis, cfgPhimassAxisFCut.at(i)}); - PhiK0SHist.add(PhiK0SSESCut[i].data(), "2D Invariant mass of Phi and K0Short for Same Event Deltay < SecondCut", kTH2F, {K0SmassAxis, cfgPhimassAxisSCut.at(i)}); - } + PhipurHist.add("h2PhipurInvMass", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH2F, {binnedmultAxis, PhimassAxis}); - PhiK0SHist.add("h3PhiK0SInvMassMixedEventInclusive", "2D Invariant mass of Phi and K0Short for Mixed Event Inclusive", kTH3F, {multAxis, K0SmassAxis, PhimassAxis}); - PhiK0SHist.add("h3PhiK0SInvMassMixedEventFirstCut", "2D Invariant mass of Phi and K0Short for Mixed Event Deltay < FirstCut", kTH3F, {multAxis, K0SmassAxis, PhimassAxis}); - PhiK0SHist.add("h3PhiK0SInvMassMixedEventSecondCut", "2D Invariant mass of Phi and K0Short for Mixed Event Deltay < SecondCut", kTH3F, {multAxis, K0SmassAxis, PhimassAxis}); + PhipurHist.add("h3PhipurK0SInvMassInclusive", "Invariant mass of Phi for Purity (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + PhipurHist.add("h3PhipurK0SInvMassFirstCut", "Invariant mass of Phi for Purity (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + PhipurHist.add("h3PhipurK0SInvMassSecondCut", "Invariant mass of Phi for Purity (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); - // Phi mass vs Pion NSigma dE/dx - for (int i = 0; i < nMultBin; i++) { - PhiPionHist.add(PhiPiSEInc[i].data(), "Phi Invariant mass vs Pion nSigma dE/dx for Same Event Inclusive", kTH3F, {ptAxis, {100, -10.0f, 10.0f}, cfgPhimassAxisInc.at(i)}); - PhiPionHist.add(PhiPiSEFCut[i].data(), "Phi Invariant mass vs Pion nSigma dE/dx for Same Event Deltay < FirstCut", kTH3F, {ptAxis, {100, -10.0f, 10.0f}, cfgPhimassAxisFCut.at(i)}); - PhiPionHist.add(PhiPiSESCut[i].data(), "Phi Invariant mass vs Pion nSigma dE/dx for Same Event Deltay < SecondCut", kTH3F, {ptAxis, {100, -10.0f, 10.0f}, cfgPhimassAxisSCut.at(i)}); - } + PhipurHist.add("h3PhipurPiInvMassInclusive", "Invariant mass of Phi for Purity (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + PhipurHist.add("h3PhipurPiInvMassFirstCut", "Invariant mass of Phi for Purity (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + PhipurHist.add("h3PhipurPiInvMassSecondCut", "Invariant mass of Phi for Purity (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + + // MCPhi invariant mass for computing purities + MCPhipurHist.add("h2MCPhipurInvMass", "Invariant mass of Phi for Purity (no K0S/Pi)", kTH2F, {binnedmultAxis, PhimassAxis}); + + MCPhipurHist.add("h3MCPhipurK0SInvMassInclusive", "Invariant mass of Phi for Purity (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + MCPhipurHist.add("h3MCPhipurK0SInvMassFirstCut", "Invariant mass of Phi for Purity (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + MCPhipurHist.add("h3MCPhipurK0SInvMassSecondCut", "Invariant mass of Phi for Purity (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + + MCPhipurHist.add("h3MCPhipurPiInvMassInclusive", "Invariant mass of Phi for Purity (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + MCPhipurHist.add("h3MCPhipurPiInvMassFirstCut", "Invariant mass of Phi for Purity (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + MCPhipurHist.add("h3MCPhipurPiInvMassSecondCut", "Invariant mass of Phi for Purity (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + + // 2D mass for Phi and K0S for Data + PhiK0SHist.add("h4PhiK0SSEInc", "2D Invariant mass of Phi and K0Short for Same Event Inclusive", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis, sigPhimassAxis}); + PhiK0SHist.add("h4PhiK0SSEFCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < FirstCut", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis, sigPhimassAxis}); + PhiK0SHist.add("h4PhiK0SSESCut", "2D Invariant mass of Phi and K0Short for Same Event Deltay < SecondCut", kTHnSparseF, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis, sigPhimassAxis}); + + // MC 2D mass for Phi and K0S + MCPhiK0SHist.add("h3RecMCPhiK0SSEInc", "2D Invariant mass of Phi and K0Short for RecMC Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis}); + MCPhiK0SHist.add("h3RecMCPhiK0SSEFCut", "2D Invariant mass of Phi and K0Short for RecMC Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis}); + MCPhiK0SHist.add("h3RecMCPhiK0SSESCut", "2D Invariant mass of Phi and K0Short for RecMC Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis}); - PhiPionHist.add("h4PhiInvMassPiNSigmadEdxMixedEventInclusive", "Phi Invariant mass vs Pion nSigma dE/dx for Mixed Event Inclusive", kTHnSparseF, {multAxis, ptAxis, {100, -10.0f, 10.0f}, PhimassAxis}); - PhiPionHist.add("h4PhiInvMassPiNSigmadEdxMixedEventFirstCut", "Phi Invariant mass vs Pion nSigma dE/dx for Mixed Event Deltay < FirstCut", kTHnSparseF, {multAxis, ptAxis, {100, -10.0f, 10.0f}, PhimassAxis}); - PhiPionHist.add("h4PhiInvMassPiNSigmadEdxMixedEventSecondCut", "Phi Invariant mass vs Pion nSigma dE/dx for Mixed Event Deltay < SecondCut", kTHnSparseF, {multAxis, ptAxis, {100, -10.0f, 10.0f}, PhimassAxis}); + // GenMC K0S coupled to Phi + MCPhiK0SHist.add("h2PhiK0SGenMCInclusive", "K0Short coupled to Phi for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + MCPhiK0SHist.add("h2PhiK0SGenMCFirstCut", "K0Short coupled to Phi for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + MCPhiK0SHist.add("h2PhiK0SGenMCSecondCut", "K0Short coupled to Phi for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + + MCPhiK0SHist.add("h2PhiK0SGenMCInclusiveAssocReco", "K0Short coupled to Phi for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + MCPhiK0SHist.add("h2PhiK0SGenMCFirstCutAssocReco", "K0Short coupled to Phi for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + MCPhiK0SHist.add("h2PhiK0SGenMCSecondCutAssocReco", "K0Short coupled to Phi for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + + // Phi mass vs Pion NSigma dE/dx for Data + PhiPionHist.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}, sigPhimassAxis}); + PhiPionHist.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}, sigPhimassAxis}); + PhiPionHist.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}, sigPhimassAxis}); + + // MC Phi mass vs Pion NSigma dE/dx + 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("h2PhiPiGenMCInclusive", "Pion coupled to Phi for GenMC Inclusive", kTH2F, {binnedmultAxis, binnedptPiAxis}); + MCPhiPionHist.add("h2PhiPiGenMCFirstCut", "Pion coupled to Phi for GenMC Deltay < FirstCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); + MCPhiPionHist.add("h2PhiPiGenMCSecondCut", "Pion coupled to Phi for GenMC Deltay < SecondCut", kTH2F, {binnedmultAxis, binnedptPiAxis}); + + MCPhiPionHist.add("h2PhiPiGenMCInclusiveAssocReco", "Pion coupled to Phi for GenMC Inclusive Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); + MCPhiPionHist.add("h2PhiPiGenMCFirstCutAssocReco", "Pion coupled to Phi for GenMC Deltay < FirstCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); + MCPhiPionHist.add("h2PhiPiGenMCSecondCutAssocReco", "Pion coupled to Phi for GenMC Deltay < SecondCut Associated Reco Collision", kTH2F, {binnedmultAxis, binnedptPiAxis}); + + // MCPhi invariant mass for computing efficiencies and MCnormalisation + PhieffHist.add("h2PhieffInvMass", "Invariant mass of Phi for Efficiency (no K0S/Pi)", kTH2F, {binnedmultAxis, PhimassAxis}); + + PhieffHist.add("h3PhieffK0SInvMassInclusive", "Invariant mass of Phi for Efficiency (K0S) Inclusive", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + PhieffHist.add("h3PhieffK0SInvMassFirstCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + PhieffHist.add("h3PhieffK0SInvMassSecondCut", "Invariant mass of Phi for Efficiency (K0S) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptK0SAxis, PhimassAxis}); + + PhieffHist.add("h3PhieffPiInvMassInclusive", "Invariant mass of Phi for Efficiency (Pi) Inclusive", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + PhieffHist.add("h3PhieffPiInvMassFirstCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < FirstCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + PhieffHist.add("h3PhieffPiInvMassSecondCut", "Invariant mass of Phi for Efficiency (Pi) Deltay < SecondCut", kTH3F, {binnedmultAxis, binnedptPiAxis, PhimassAxis}); + + // GenMC Phi and Phi coupled to K0S and Pion + PhieffHist.add("h1PhiGenMC", "Phi for GenMC", kTH1F, {{10, -0.5f, 9.5f}}); + + PhieffHist.add("h2PhieffK0SGenMCInclusive", "Phi coupled to K0Short for GenMC Inclusive", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + PhieffHist.add("h2PhieffK0SGenMCFirstCut", "Phi coupled to K0Short for GenMC Deltay < FirstCut", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + PhieffHist.add("h2PhieffK0SGenMCSecondCut", "Phi coupled to K0Short for GenMC Deltay < SecondCut", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + + PhieffHist.add("h2PhieffK0SGenMCInclusiveAssocReco", "Phi coupled to K0Short for GenMC Inclusive", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + PhieffHist.add("h2PhieffK0SGenMCFirstCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < FirstCut", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + PhieffHist.add("h2PhieffK0SGenMCSecondCutAssocReco", "Phi coupled to K0Short for GenMC Deltay < SecondCut", kTH2F, {{10, -0.5f, 9.5f}, {4, -0.5f, 3.5f}}); + + PhieffHist.add("h2PhieffPiGenMCInclusive", "Phi coupled to Pion for GenMC Inclusive", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + PhieffHist.add("h2PhieffPiGenMCFirstCut", "Phi coupled to Pion for GenMC Deltay < FirstCut", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + PhieffHist.add("h2PhieffPiGenMCSecondCut", "Phi coupled to Pion for GenMC Deltay < SecondCut", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + + PhieffHist.add("h2PhieffPiGenMCInclusiveAssocReco", "Phi coupled to Pion for GenMC Inclusive", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + PhieffHist.add("h2PhieffPiGenMCFirstCutAssocReco", "Phi coupled to Pion for GenMC Deltay < FirstCut", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + PhieffHist.add("h2PhieffPiGenMCSecondCutAssocReco", "Phi coupled to Pion for GenMC Deltay < SecondCut", kTH2F, {{10, -0.5f, 9.5f}, {3, -0.5f, 2.5f}}); + + // MCK0S invariant mass and GenMC K0S for computing efficiencies + K0SeffHist.add("h3K0SeffInvMass", "Invariant mass of K0Short for Efficiency", kTH3F, {binnedmultAxis, binnedptK0SAxis, K0SmassAxis}); + K0SeffHist.add("h2K0SGenMC", "K0Short for GenMC", kTH2F, {binnedmultAxis, binnedptK0SAxis}); + + // MCPion invariant mass and GenMC Pion for computing efficiencies + PioneffHist.add("h4PieffInvMass", "Invariant mass of Pion for Efficiency", kTHnSparseF, {binnedmultAxis, binnedptPiAxis, {100, -10.0f, 10.0f}, {100, -10.0f, 10.0f}}); + PioneffHist.add("h2PiGenMC", "Pion for GenMC", kTH2F, {binnedmultAxis, binnedptPiAxis}); + + // y acceptance studies + yaccHist.add("hyaccK0SRecMC", "K0S y acceptance in RecMC", kTH3F, {binnedmultAxis, binnedptK0SAxis, yAxis}); + yaccHist.add("hyaccK0SGenMC", "K0S y acceptance in GenMC", kTH3F, {binnedmultAxis, binnedptK0SAxis, yAxis}); + + yaccHist.add("hyaccPiRecMC", "Pion y acceptance in RecMC", kTH3F, {binnedmultAxis, binnedptPiAxis, yAxis}); + yaccHist.add("hyaccPiGenMC", "Pion y acceptance in GenMC", kTH3F, {binnedmultAxis, binnedptPiAxis, yAxis}); } // Event selection and QA filling - template - bool acceptEventQA(const T& collision) + template + bool acceptEventQA(const T& collision, bool QA) { - eventHist.fill(HIST("hEventSelection"), 0); // all collisions - if (!collision.sel8()) - return false; - eventHist.fill(HIST("hEventSelection"), 1); // sel8 collisions - if (std::abs(collision.posZ()) > cutzvertex) - return false; - eventHist.fill(HIST("hEventSelection"), 2); // vertex-Z selected - eventHist.fill(HIST("hVertexZRec"), collision.posZ()); - if (!collision.isInelGt0()) - return false; - eventHist.fill(HIST("hEventSelection"), 3); // INEL>0 collisions - return true; + if constexpr (!isMC) { // data event + if (QA) + eventHist.fill(HIST("hEventSelection"), 0); // all collisions + if (!collision.sel8()) + return false; + if (QA) + eventHist.fill(HIST("hEventSelection"), 1); // sel8 collisions + if (std::abs(collision.posZ()) >= cutzvertex) + return false; + if (QA) { + eventHist.fill(HIST("hEventSelection"), 2); // vertex-Z selected + eventHist.fill(HIST("hVertexZ"), collision.posZ()); + } + if (!collision.isInelGt0()) + return false; + if (QA) + eventHist.fill(HIST("hEventSelection"), 3); // INEL>0 collisions + return true; + } else { // RecMC event + if (QA) + MCeventHist.fill(HIST("hRecMCEventSelection"), 0); // all collisions + if (!collision.selection_bit(aod::evsel::kIsTriggerTVX)) + return false; + if (QA) + MCeventHist.fill(HIST("hRecMCEventSelection"), 1); // kIsTriggerTVX collisions + if (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) + return false; + if (QA) + MCeventHist.fill(HIST("hRecMCEventSelection"), 2); // kNoTimeFrameBorder collisions + if (cfgiskNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) + return false; + if (QA) + MCeventHist.fill(HIST("hRecMCEventSelection"), 3); // kNoITSROFrameBorder collisions (by default not requested by the selection) + if (std::abs(collision.posZ()) > cutzvertex) + return false; + if (QA) { + MCeventHist.fill(HIST("hRecMCEventSelection"), 4); // vertex-Z selected + MCeventHist.fill(HIST("hRecMCVertexZ"), collision.posZ()); + } + if (!collision.isInelGt0()) + return false; + if (QA) + MCeventHist.fill(HIST("hRecMCEventSelection"), 5); // INEL>0 collisions + return true; + } } // Single track selection for strangeness sector @@ -310,18 +453,20 @@ struct phik0shortanalysis { template bool selectionTrackResonance(const T& track) { - if (std::abs(track.pt()) < cMinPtcut) + if (cfgPrimaryTrack && !track.isPrimaryTrack()) return false; - if (std::abs(track.dcaXY()) > cMaxDCArToPVcut) + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) return false; - if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) + if (cfgPVContributor && !track.isPVContributor()) return false; - if (cfgPrimaryTrack && !track.isPrimaryTrack()) + if (track.pt() < cMinKaonPtcut) return false; - if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut) return false; - if (cfgPVContributor && !track.isPVContributor()) + if (std::abs(track.dcaXY()) > cMaxDCArToPV1 + (cMaxDCArToPV2 / std::pow(track.pt(), cMaxDCArToPV3))) + return false; + if (track.tpcNClsFound() < minTPCnClsFound) return false; return true; } @@ -339,6 +484,16 @@ struct phik0shortanalysis { return false; } + template + bool selectionPIDKaonpTdependent(const T& candidate) + { + if (candidate.pt() < 0.5 && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa) + return true; + if (candidate.pt() >= 0.5 && candidate.hasTOF() && ((candidate.tofNSigmaKa() * candidate.tofNSigmaKa()) + (candidate.tpcNSigmaKa() * candidate.tpcNSigmaKa())) < (nsigmaCutCombinedKa * nsigmaCutCombinedKa)) + return true; + return false; + } + // Reconstruct the Phi template TLorentzVector recMother(const T1& candidate1, const T2& candidate2, float masscand1, float masscand2) @@ -360,16 +515,28 @@ struct phik0shortanalysis { 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.pt() < 0.2) + 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) + return false; + } + + if (track.pt() >= 0.5) { + if (!track.hasTOF()) + return false; + } + if (std::abs(track.dcaXY()) > dcaxyMax) return false; if (std::abs(track.dcaZ()) > dcazMax) @@ -378,10 +545,11 @@ struct phik0shortanalysis { } // Fill 2D invariant mass histogram for V0 and Phi - template - void fillInvMass2D(TLorentzVector V0, const std::vector listPhi, float multiplicity, double weightInclusive, double weightLtFirstCut, double weightLtSecondCut) + template + void fillInvMass2D(TLorentzVector V0, const std::vector listPhi, float multiplicity, const std::array weights) { double massV0 = V0.M(); + double ptV0 = V0.Pt(); double rapidityV0 = V0.Rapidity(); for (unsigned int phitag = 0; phitag < listPhi.size(); phitag++) { @@ -389,29 +557,29 @@ struct phik0shortanalysis { double rapidityPhi = listPhi[phitag].Rapidity(); double deltay = std::abs(rapidityV0 - rapidityPhi); - if constexpr (!isMix) { // same event - PhiK0SHist.fill(HIST(PhiK0SSEInc[iBin]), massV0, massPhi, weightInclusive); + if constexpr (!isMC) { // same event + PhiK0SHist.fill(HIST("h4PhiK0SSEInc"), multiplicity, ptV0, massV0, massPhi, weights.at(0)); if (deltay > cfgFirstCutonDeltay) continue; - PhiK0SHist.fill(HIST(PhiK0SSEFCut[iBin]), massV0, massPhi, weightLtFirstCut); + PhiK0SHist.fill(HIST("h4PhiK0SSEFCut"), multiplicity, ptV0, massV0, massPhi, weights.at(1)); if (deltay > cfgSecondCutonDeltay) continue; - PhiK0SHist.fill(HIST(PhiK0SSESCut[iBin]), massV0, massPhi, weightLtSecondCut); - } else { // mixed event - PhiK0SHist.fill(HIST("h3PhiK0SInvMassMixedEventInclusive"), multiplicity, massV0, massPhi, weightInclusive); + PhiK0SHist.fill(HIST("h4PhiK0SSESCut"), multiplicity, ptV0, massV0, massPhi, weights.at(2)); + } else { // MC event + MCPhiK0SHist.fill(HIST("h3RecMCPhiK0SSEInc"), multiplicity, ptV0, massV0, weights.at(0)); if (deltay > cfgFirstCutonDeltay) continue; - PhiK0SHist.fill(HIST("h3PhiK0SInvMassMixedEventFirstCut"), multiplicity, massV0, massPhi, weightLtFirstCut); + MCPhiK0SHist.fill(HIST("h3RecMCPhiK0SSEFCut"), multiplicity, ptV0, massV0, weights.at(1)); if (deltay > cfgSecondCutonDeltay) continue; - PhiK0SHist.fill(HIST("h3PhiK0SInvMassMixedEventSecondCut"), multiplicity, massV0, massPhi, weightLtSecondCut); + MCPhiK0SHist.fill(HIST("h3RecMCPhiK0SSESCut"), multiplicity, ptV0, massV0, weights.at(2)); } } } // Fill Phi invariant mass vs Pion nSigmadE/dx histogram - template - void fillInvMassNSigmadEdx(TLorentzVector Pi, float nSigmadEdxPi, const std::vector listPhi, float multiplicity, double weightInclusive, double weightLtFirstCut, double weightLtSecondCut) + template + void fillInvMassNSigma(TLorentzVector Pi, float nSigmaTPCPi, float nSigmaTOFPi, const std::vector listPhi, float multiplicity, const std::array weights) { double rapidityPi = Pi.Rapidity(); double ptPi = Pi.Pt(); @@ -421,22 +589,22 @@ struct phik0shortanalysis { double rapidityPhi = listPhi[phitag].Rapidity(); double deltay = std::abs(rapidityPi - rapidityPhi); - if constexpr (!isMix) { // same event - PhiPionHist.fill(HIST(PhiPiSEInc[iBin]), ptPi, nSigmadEdxPi, massPhi, weightInclusive); + if constexpr (!isMC) { // same event + PhiPionHist.fill(HIST("h5PhiPiSEInc"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, massPhi, weights.at(0)); if (deltay > cfgFirstCutonDeltay) continue; - PhiPionHist.fill(HIST(PhiPiSEFCut[iBin]), ptPi, nSigmadEdxPi, massPhi, weightLtFirstCut); + PhiPionHist.fill(HIST("h5PhiPiSEFCut"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, massPhi, weights.at(1)); if (deltay > cfgSecondCutonDeltay) continue; - PhiPionHist.fill(HIST(PhiPiSESCut[iBin]), ptPi, nSigmadEdxPi, massPhi, weightLtSecondCut); - } else { // mixed event - PhiPionHist.fill(HIST("h4PhiInvMassPiNSigmadEdxMixedEventInclusive"), multiplicity, ptPi, nSigmadEdxPi, massPhi, weightInclusive); + PhiPionHist.fill(HIST("h5PhiPiSESCut"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, massPhi, weights.at(2)); + } else { // MC event + MCPhiPionHist.fill(HIST("h4RecMCPhiPiSEInc"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, weights.at(0)); if (deltay > cfgFirstCutonDeltay) continue; - PhiPionHist.fill(HIST("h4PhiInvMassPiNSigmadEdxMixedEventFirstCut"), multiplicity, ptPi, nSigmadEdxPi, massPhi, weightLtFirstCut); + MCPhiPionHist.fill(HIST("h4RecMCPhiPiSEFCut"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, weights.at(1)); if (deltay > cfgSecondCutonDeltay) continue; - PhiPionHist.fill(HIST("h4PhiInvMassPiNSigmadEdxMixedEventSecondCut"), multiplicity, ptPi, nSigmadEdxPi, massPhi, weightLtSecondCut); + MCPhiPionHist.fill(HIST("h4RecMCPhiPiSESCut"), multiplicity, ptPi, nSigmaTPCPi, nSigmaTOFPi, weights.at(2)); } } } @@ -444,7 +612,7 @@ struct phik0shortanalysis { void processQAPurity(SelCollisions::iterator const& collision, FullTracks const& fullTracks, FullV0s const& V0s, V0DauTracks const&) { // Check if the event selection is passed - if (!acceptEventQA(collision)) + if (!acceptEventQA(collision, true)) return; float multiplicity = collision.centFT0M(); @@ -458,7 +626,7 @@ struct phik0shortanalysis { bool isFilledhV0 = false; for (auto track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaon(track1)) + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection PhicandHist.fill(HIST("hEta"), track1.eta()); @@ -471,7 +639,7 @@ struct phik0shortanalysis { // Loop over all negative candidates for (auto track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaon(track2)) + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); @@ -480,7 +648,7 @@ struct phik0shortanalysis { TLorentzVector recPhi; recPhi = recMother(track1, track2, massKa, massKa); - if (recPhi.Rapidity() > 0.8) + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; if (!isCountedPhi) { @@ -490,9 +658,7 @@ struct phik0shortanalysis { PhipurHist.fill(HIST("h2PhipurInvMass"), multiplicity, recPhi.M()); - bool isCountedK0SInclusive = false; - bool isCountedK0SFirstCut = false; - bool isCountedK0SSecondCut = false; + bool isCountedK0SInclusive[nPtBinK0S] = {false}, isCountedK0SFirstCut[nPtBinK0S] = {false}, isCountedK0SSecondCut[nPtBinK0S] = {false}; // V0 already reconstructed by the builder for (const auto& v0 : V0s) { @@ -517,30 +683,38 @@ struct phik0shortanalysis { TLorentzVector recK0S; recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); - if (recK0S.Rapidity() > 0.8) + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) continue; - if (!isCountedK0SInclusive) { - PhipurHist.fill(HIST("h2PhipurK0SInvMassInclusive"), multiplicity, recPhi.M()); - isCountedK0SInclusive = true; + + int ipTBinK0S = 0; + for (int i = 0; i < nPtBinK0S; i++) { + if (pTBinK0S[i] < recK0S.Pt() && recK0S.Pt() <= pTBinK0S[i + 1]) { + ipTBinK0S = i; + break; + } + } + + if (!isCountedK0SInclusive[ipTBinK0S]) { + PhipurHist.fill(HIST("h3PhipurK0SInvMassInclusive"), multiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SInclusive[ipTBinK0S] = true; } if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) continue; - if (!isCountedK0SFirstCut) { - PhipurHist.fill(HIST("h2PhipurK0SInvMassFirstCut"), multiplicity, recPhi.M()); - isCountedK0SFirstCut = true; + if (!isCountedK0SFirstCut[ipTBinK0S]) { + PhipurHist.fill(HIST("h3PhipurK0SInvMassFirstCut"), multiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SFirstCut[ipTBinK0S] = true; } if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) continue; - if (!isCountedK0SSecondCut) { - PhipurHist.fill(HIST("h2PhipurK0SInvMassSecondCut"), multiplicity, recPhi.M()); - isCountedK0SSecondCut = true; + if (!isCountedK0SSecondCut[ipTBinK0S]) { + PhipurHist.fill(HIST("h3PhipurK0SInvMassSecondCut"), multiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SSecondCut[ipTBinK0S] = true; } } + isFilledhV0 = true; - bool isCountedPiInclusive = false; - bool isCountedPiFirstCut = false; - bool isCountedPiSecondCut = false; + bool isCountedPiInclusive[nPtBinPi] = {false}, isCountedPiFirstCut[nPtBinPi] = {false}, isCountedPiSecondCut[nPtBinPi] = {false}; // Loop over all primary pion candidates for (const auto& track : fullTracks) { @@ -550,23 +724,32 @@ struct phik0shortanalysis { TLorentzVector recPi; recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); - if (recPi.Rapidity() > 0.8) + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) continue; - if (!isCountedPiInclusive) { + + int ipTBinPi = 0; + for (int i = 0; i < nPtBinPi; i++) { + if (pTBinPi[i] < recPi.Pt() && recPi.Pt() <= pTBinPi[i + 1]) { + ipTBinPi = i; + break; + } + } + + if (!isCountedPiInclusive[ipTBinPi]) { PhipurHist.fill(HIST("h3PhipurPiInvMassInclusive"), multiplicity, recPi.Pt(), recPhi.M()); - isCountedPiInclusive = true; + isCountedPiInclusive[ipTBinPi] = true; } if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) continue; - if (!isCountedPiFirstCut) { + if (!isCountedPiFirstCut[ipTBinPi]) { PhipurHist.fill(HIST("h3PhipurPiInvMassFirstCut"), multiplicity, recPi.Pt(), recPhi.M()); - isCountedPiFirstCut = true; + isCountedPiFirstCut[ipTBinPi] = true; } if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) continue; - if (!isCountedPiSecondCut) { + if (!isCountedPiSecondCut[ipTBinPi]) { PhipurHist.fill(HIST("h3PhipurPiInvMassSecondCut"), multiplicity, recPi.Pt(), recPhi.M()); - isCountedPiSecondCut = true; + isCountedPiSecondCut[ipTBinPi] = true; } } } @@ -583,14 +766,6 @@ struct phik0shortanalysis { float multiplicity = collision.centFT0M(); eventHist.fill(HIST("hMultiplicityPercent"), multiplicity); - int iBin = 0; - for (int i = 0; i < nMultBin; i++) { - if (multBin[i] < multiplicity && multiplicity <= multBin[i + 1]) { - iBin = i; - break; - } - } - // 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); @@ -606,23 +781,23 @@ struct phik0shortanalysis { TLorentzVector recK0S; recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); - if (recK0S.Rapidity() > 0.8) + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) continue; std::vector listrecPhi; - int countInclusive = 0, countLtFirstCut = 0, countLtSecondCut = 0; + std::array counts{}; // Phi reconstruction // Loop over positive candidates for (auto track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaon(track1)) + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); // Loop over all negative candidates for (auto track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaon(track2)) + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); @@ -631,72 +806,29 @@ struct phik0shortanalysis { TLorentzVector recPhi; recPhi = recMother(track1, track2, massKa, massKa); - if (recPhi.Rapidity() > 0.8) + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; listrecPhi.push_back(recPhi); - if (lowmPhiInc->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiInc->at(iBin)) - countInclusive++; - if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) - continue; - if (lowmPhiFCut->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiFCut->at(iBin)) - countLtFirstCut++; - if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) - continue; - if (lowmPhiSCut->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiSCut->at(iBin)) - countLtSecondCut++; + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; + } } } - float weightInclusive = 1. / static_cast(countInclusive); - float weightLtFirstCut = 1. / static_cast(countLtFirstCut); - float weightLtSecondCut = 1. / static_cast(countLtSecondCut); - - switch (iBin) { - case 0: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 1: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 2: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 3: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 4: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 5: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 6: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 7: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 8: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 9: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - default: - break; + 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); } + + fillInvMass2D(recK0S, listrecPhi, multiplicity, weights); } } @@ -710,14 +842,6 @@ struct phik0shortanalysis { float multiplicity = collision.centFT0M(); eventHist.fill(HIST("hMultiplicityPercent"), multiplicity); - int iBin = 0; - for (int i = 0; i < nMultBin; i++) { - if (multBin[i] < multiplicity && multiplicity <= multBin[i + 1]) { - iBin = i; - break; - } - } - // 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); @@ -731,23 +855,27 @@ struct phik0shortanalysis { TLorentzVector recPi; recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); - if (recPi.Rapidity() > 0.8) + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) continue; + float nsigmaTPC, nsigmaTOF; + nsigmaTPC = (track.hasTPC() ? track.tpcNSigmaPi() : -9.99); + nsigmaTOF = (track.hasTOF() ? track.tofNSigmaPi() : -9.99); + std::vector listrecPhi; - int countInclusive = 0, countLtFirstCut = 0, countLtSecondCut = 0; + std::array counts{}; // Phi reconstruction // Loop over positive candidates for (auto track1 : posThisColl) { // loop over all selected tracks - if (!selectionTrackResonance(track1) || !selectionPIDKaon(track1)) + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) continue; // topological and PID selection auto track1ID = track1.globalIndex(); // Loop over all negative candidates for (auto track2 : negThisColl) { - if (!selectionTrackResonance(track2) || !selectionPIDKaon(track2)) + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) continue; // topological and PID selection auto track2ID = track2.globalIndex(); @@ -756,305 +884,1094 @@ struct phik0shortanalysis { TLorentzVector recPhi; recPhi = recMother(track1, track2, massKa, massKa); - if (recPhi.Rapidity() > 0.8) + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; listrecPhi.push_back(recPhi); - if (lowmPhiInc->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiInc->at(iBin)) - countInclusive++; - if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) - continue; - if (lowmPhiFCut->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiFCut->at(iBin)) - countLtFirstCut++; - if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) - continue; - if (lowmPhiSCut->at(iBin) <= recPhi.M() && recPhi.M() <= upmPhiSCut->at(iBin)) - countLtSecondCut++; + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; + } } } - float weightInclusive = 1. / static_cast(countInclusive); - float weightLtFirstCut = 1. / static_cast(countLtFirstCut); - float weightLtSecondCut = 1. / static_cast(countLtSecondCut); - - switch (iBin) { - case 0: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 1: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 2: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 3: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 4: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 5: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 6: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 7: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 8: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 9: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - default: - break; + 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); } + + fillInvMassNSigma(recPi, nsigmaTPC, nsigmaTOF, listrecPhi, multiplicity, weights); } } PROCESS_SWITCH(phik0shortanalysis, processSEPhiPion, "Process Same Event for Phi-Pion Analysis", false); - void processMEPhiK0S(soa::Filtered const& collisions, FullTracks const&, FullV0s const& V0s, V0DauTracks const&) + void processRecMCPhiQA(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) { - // Mixing the events with similar vertex z and multiplicity - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; - for (auto const& [collision1, collision2] : o2::soa::selfCombinations(binningOnPositions, cfgNoMixedEvents, -1, collisions, collisions)) { - if (!collision1.isInelGt0() || !collision2.isInelGt0()) + if (!acceptEventQA(collision, true)) + return; + + float multiplicity = collision.centFT0M(); + MCeventHist.fill(HIST("hRecMCMultiplicityPercent"), multiplicity); + + 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("hRecMCGenMultiplicityPercent"), 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; + + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + if (!track1.has_mcParticle()) continue; - float multiplicity = collision1.centFT0M(); + // Loop over all negative candidates + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection - int iBin = 0; - for (int i = 0; i < nMultBin; i++) { - if (multBin[i] < multiplicity && multiplicity <= multBin[i + 1]) { - iBin = i; - break; - } - } + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair - // Defining V0s from collision1 - auto V0ThisColl = V0s.sliceByCached(aod::v0::collisionId, collision1.globalIndex(), cache); + if (!track2.has_mcParticle()) + continue; - // Defining positive and negative tracks for phi reconstruction from collision1 and collision2, respectively - auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + auto MCtrack1 = track1.mcParticle_as(); + auto MCtrack2 = track2.mcParticle_as(); + if (MCtrack1.pdgCode() != 321 || MCtrack2.pdgCode() != -321) + continue; + if (!MCtrack1.has_mothers() || !MCtrack2.has_mothers()) + continue; + if (!MCtrack1.isPhysicalPrimary() || !MCtrack2.isPhysicalPrimary()) + continue; - for (const auto& v0 : V0ThisColl) { - const auto& posDaughterTrack = v0.posTrack_as(); - const auto& negDaughterTrack = v0.negTrack_as(); + int pdgParentPhi = 0; + for (const auto& MotherOfMCtrack1 : MCtrack1.mothers_as()) { + for (const auto& MotherOfMCtrack2 : MCtrack2.mothers_as()) { + if (MotherOfMCtrack1 == MotherOfMCtrack2) { + pdgParentPhi = MotherOfMCtrack1.pdgCode(); + } + } + } - // Cut on V0 dynamic columns - if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + if (pdgParentPhi != 333) continue; - TLorentzVector recK0S; - recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); - if (recK0S.Rapidity() > 0.8) + TLorentzVector recPhi; + recPhi = recMother(track1, track2, massKa, massKa); + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; - std::vector listrecPhi; - int countInclusive = 0, countLtFirstCut = 0, countLtSecondCut = 0; + if (!isCountedPhi) { + MCeventHist.fill(HIST("hRecMCEventSelection"), 7); // at least a Phi in the event + isCountedPhi = true; + } + + PhieffHist.fill(HIST("h2PhieffInvMass"), genmultiplicity, recPhi.M()); - // Combinatorial background simulation - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { - if (!selectionTrackResonance(track1) || !selectionPIDKaon(track1) || !selectionTrackResonance(track2) || !selectionPIDKaon(track2)) - continue; // topological and PID selection + bool isCountedK0SInclusive[nPtBinK0S] = {false}, isCountedK0SFirstCut[nPtBinK0S] = {false}, isCountedK0SSecondCut[nPtBinK0S] = {false}; - TLorentzVector recPhi; - recPhi = recMother(track1, track2, massKa, massKa); - if (recPhi.Rapidity() > 0.8) + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + if (!posDaughterTrack.has_mcParticle() || !negDaughterTrack.has_mcParticle()) continue; - listrecPhi.push_back(recPhi); + auto posMCDaughterTrack = posDaughterTrack.mcParticle_as(); + auto negMCDaughterTrack = negDaughterTrack.mcParticle_as(); + if (posMCDaughterTrack.pdgCode() != 211 || negMCDaughterTrack.pdgCode() != -211) + continue; + if (!posMCDaughterTrack.has_mothers() || !negMCDaughterTrack.has_mothers()) + continue; - countInclusive++; - if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + int pdgParentv0 = 0; + bool isPhysPrim = false; + for (const auto& particleMotherOfNeg : negMCDaughterTrack.mothers_as()) { + for (const auto& particleMotherOfPos : posMCDaughterTrack.mothers_as()) { + if (particleMotherOfNeg == particleMotherOfPos) { + pdgParentv0 = particleMotherOfNeg.pdgCode(); + isPhysPrim = particleMotherOfNeg.isPhysicalPrimary(); + } + } + } + if (pdgParentv0 != 310 || !isPhysPrim) continue; - countLtFirstCut++; - if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + + // Cut on V0 dynamic columns + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) continue; - countLtSecondCut++; - } - float weightInclusive = 1. / static_cast(countInclusive); - float weightLtFirstCut = 1. / static_cast(countLtFirstCut); - float weightLtSecondCut = 1. / static_cast(countLtSecondCut); + TLorentzVector recK0S; + recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); - switch (iBin) { - case 0: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 1: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; - } - case 2: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) + continue; + + int ipTBinK0S = 0; + for (int i = 0; i < nPtBinK0S; i++) { + if (pTBinK0S[i] < recK0S.Pt() && recK0S.Pt() <= pTBinK0S[i + 1]) { + ipTBinK0S = i; + break; + } } - case 3: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + + if (!isCountedK0SInclusive[ipTBinK0S]) { + PhieffHist.fill(HIST("h3PhieffK0SInvMassInclusive"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SInclusive[ipTBinK0S] = true; } - case 4: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + if (!isCountedK0SFirstCut[ipTBinK0S]) { + PhieffHist.fill(HIST("h3PhieffK0SInvMassFirstCut"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SFirstCut[ipTBinK0S] = true; } - case 5: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + if (!isCountedK0SSecondCut[ipTBinK0S]) { + PhieffHist.fill(HIST("h3PhieffK0SInvMassSecondCut"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SSecondCut[ipTBinK0S] = true; } - case 6: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + } + + bool isCountedPiInclusive[nPtBinPi] = {false}, isCountedPiFirstCut[nPtBinPi] = {false}, isCountedPiSecondCut[nPtBinPi] = {false}; + + // Loop over all primary pion candidates + for (const auto& track : fullMCTracks) { + if (!track.has_mcParticle()) + continue; + + auto MCtrack = track.mcParticle_as(); + if (std::abs(MCtrack.pdgCode()) != 211 || !MCtrack.isPhysicalPrimary()) + continue; + + if (!selectionPion(track)) + continue; + + TLorentzVector recPi; + recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); + + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) + continue; + + int ipTBinPi = 0; + for (int i = 0; i < nPtBinPi; i++) { + if (pTBinPi[i] < recPi.Pt() && recPi.Pt() <= pTBinPi[i + 1]) { + ipTBinPi = i; + break; + } } - case 7: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + + if (!isCountedPiInclusive[ipTBinPi]) { + PhieffHist.fill(HIST("h3PhieffPiInvMassInclusive"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiInclusive[ipTBinPi] = true; } - case 8: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + if (!isCountedPiFirstCut[ipTBinPi]) { + PhieffHist.fill(HIST("h3PhieffPiInvMassFirstCut"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiFirstCut[ipTBinPi] = true; } - case 9: { - fillInvMass2D(recK0S, listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + if (!isCountedPiSecondCut[ipTBinPi]) { + PhieffHist.fill(HIST("h3PhieffPiInvMassSecondCut"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiSecondCut[ipTBinPi] = true; } - default: - break; } } } } - PROCESS_SWITCH(phik0shortanalysis, processMEPhiK0S, "Process Mixed Event for Phi-K0S Analysis", false); + PROCESS_SWITCH(phik0shortanalysis, processRecMCPhiQA, "Process for ReCMCQA and Phi in RecMC", false); - void processMEPhiPion(soa::Filtered const& collisions, FullTracks const& fullTracks) + void processRecMCPhiK0S(SimCollisions::iterator const& collision, FullMCTracks const&, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions const&, aod::McParticles const&) { - // Mixing the events with similar vertex z and multiplicity - BinningTypeVertexContributor binningOnPositions{{axisVertex, axisMultiplicity}, true}; - for (auto const& [collision1, collision2] : o2::soa::selfCombinations(binningOnPositions, cfgNoMixedEvents, -1, collisions, collisions)) { - if (!collision1.isInelGt0() || !collision2.isInelGt0()) - continue; - - float multiplicity = collision1.centFT0M(); + if (!acceptEventQA(collision, false)) + return; - int iBin = 0; - for (int i = 0; i < nMultBin; i++) { - if (multBin[i] < multiplicity && multiplicity <= multBin[i + 1]) { - iBin = i; - break; - } - } + if (!collision.has_mcCollision()) + return; - // Defining V0s from collision1 - auto trackThisColl = fullTracks.sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); + const auto& mcCollision = collision.mcCollision_as(); + float genmultiplicity = mcCollision.centFT0M(); - // Defining positive and negative tracks for phi reconstruction from collision1 and collision2, respectively - auto posThisColl = posTracks->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); - auto negThisColl = negTracks->sliceByCached(aod::track::collisionId, collision2.globalIndex(), cache); + // 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& track : trackThisColl) { + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + if (!posDaughterTrack.has_mcParticle() || !negDaughterTrack.has_mcParticle()) + continue; - if (!selectionPion(track)) - continue; + auto posMCDaughterTrack = posDaughterTrack.mcParticle_as(); + auto negMCDaughterTrack = negDaughterTrack.mcParticle_as(); + if (posMCDaughterTrack.pdgCode() != 211 || negMCDaughterTrack.pdgCode() != -211) + continue; + if (!posMCDaughterTrack.has_mothers() || !negMCDaughterTrack.has_mothers()) + continue; - TLorentzVector recPi; - recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); - if (recPi.Rapidity() > 0.8) - continue; + int pdgParentv0 = 0; + bool isPhysPrim = false; + for (const auto& particleMotherOfNeg : negMCDaughterTrack.mothers_as()) { + for (const auto& particleMotherOfPos : posMCDaughterTrack.mothers_as()) { + if (particleMotherOfNeg == particleMotherOfPos) { + pdgParentv0 = particleMotherOfNeg.pdgCode(); + isPhysPrim = particleMotherOfNeg.isPhysicalPrimary(); + } + } + } + if (pdgParentv0 != 310 || !isPhysPrim) + continue; + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; - std::vector listrecPhi; - int countInclusive = 0, countLtFirstCut = 0, countLtSecondCut = 0; + TLorentzVector recK0S; + recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) + continue; - // Combinatorial background simulation - for (auto& [track1, track2] : o2::soa::combinations(o2::soa::CombinationsFullIndexPolicy(posThisColl, negThisColl))) { - if (!selectionTrackResonance(track1) || !selectionPIDKaon(track1) || !selectionTrackResonance(track2) || !selectionPIDKaon(track2)) + K0SeffHist.fill(HIST("h3K0SeffInvMass"), genmultiplicity, recK0S.Pt(), recK0S.M()); + + std::vector listrecPhi; + std::array counts{}; + + bool isCountedPhi = false; + + // Phi reconstruction + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + if (!track1.has_mcParticle()) + continue; + + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !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 MCtrack1 = track1.mcParticle_as(); + auto MCtrack2 = track2.mcParticle_as(); + if (MCtrack1.pdgCode() != 321 || MCtrack2.pdgCode() != -321) + continue; + if (!MCtrack1.has_mothers() || !MCtrack2.has_mothers()) + continue; + if (!MCtrack1.isPhysicalPrimary() || !MCtrack2.isPhysicalPrimary()) + continue; + + int pdgParentPhi = 0; + for (const auto& MotherOfMCtrack1 : MCtrack1.mothers_as()) { + for (const auto& MotherOfMCtrack2 : MCtrack2.mothers_as()) { + if (MotherOfMCtrack1 == MotherOfMCtrack2) { + pdgParentPhi = MotherOfMCtrack1.pdgCode(); + } + } + } + + if (pdgParentPhi != 333) + continue; + TLorentzVector recPhi; recPhi = recMother(track1, track2, massKa, massKa); - if (recPhi.Rapidity() > 0.8) + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; listrecPhi.push_back(recPhi); - countInclusive++; - if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + if (!isCountedPhi) { + yaccHist.fill(HIST("hyaccK0SRecMC"), genmultiplicity, recK0S.Pt(), recK0S.Rapidity()); + isCountedPhi = true; + } + + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; + } + } + } + + 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); + } + + fillInvMass2D(recK0S, listrecPhi, genmultiplicity, weights); + } + } + + PROCESS_SWITCH(phik0shortanalysis, processRecMCPhiK0S, "Process RecMC for Phi-K0S Analysis", false); + + void processRecMCPhiPion(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, MCCollisions const&, aod::McParticles const&) + { + 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); + + // Loop over all primary pion candidates + for (const auto& track : fullMCTracks) { + + if (!track.has_mcParticle()) + continue; + + auto MCtrack = track.mcParticle_as(); + if (std::abs(MCtrack.pdgCode()) != 211 || !MCtrack.isPhysicalPrimary()) + continue; + + // Pion selection + if (!selectionPion(track)) + continue; + + TLorentzVector recPi; + recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) + continue; + + float nsigmaTPC, nsigmaTOF; + nsigmaTPC = (track.hasTPC() ? track.tpcNSigmaPi() : -9.99); + nsigmaTOF = (track.hasTOF() ? track.tofNSigmaPi() : -9.99); + + PioneffHist.fill(HIST("h4PieffInvMass"), genmultiplicity, recPi.Pt(), nsigmaTPC, nsigmaTOF); + + std::vector listrecPhi; + std::array counts{}; + + bool isCountedPhi = false; + + // Phi reconstruction + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + if (!track1.has_mcParticle()) + continue; + + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !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; - countLtFirstCut++; - if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + + auto MCtrack1 = track1.mcParticle_as(); + auto MCtrack2 = track2.mcParticle_as(); + if (MCtrack1.pdgCode() != 321 || MCtrack2.pdgCode() != -321) + continue; + if (!MCtrack1.has_mothers() || !MCtrack2.has_mothers()) + continue; + if (!MCtrack1.isPhysicalPrimary() || !MCtrack2.isPhysicalPrimary()) + continue; + + int pdgParentPhi = 0; + for (const auto& MotherOfMCtrack1 : MCtrack1.mothers_as()) { + for (const auto& MotherOfMCtrack2 : MCtrack2.mothers_as()) { + if (MotherOfMCtrack1 == MotherOfMCtrack2) { + pdgParentPhi = MotherOfMCtrack1.pdgCode(); + } + } + } + + if (pdgParentPhi != 333) + continue; + + TLorentzVector recPhi; + recPhi = recMother(track1, track2, massKa, massKa); + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) continue; - countLtSecondCut++; + + listrecPhi.push_back(recPhi); + + if (!isCountedPhi) { + yaccHist.fill(HIST("hyaccPiRecMC"), genmultiplicity, recPi.Pt(), recPi.Rapidity()); + isCountedPhi = true; + } + + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; + } } + } - float weightInclusive = 1. / static_cast(countInclusive); - float weightLtFirstCut = 1. / static_cast(countLtFirstCut); - float weightLtSecondCut = 1. / static_cast(countLtSecondCut); + 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); + } - switch (iBin) { - case 0: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + fillInvMassNSigma(recPi, nsigmaTPC, nsigmaTOF, listrecPhi, genmultiplicity, weights); + } + } + + PROCESS_SWITCH(phik0shortanalysis, processRecMCPhiPion, "Process RecMC for Phi-Pion Analysis", false); + + void processRecMCClosurePhiQA(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions 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("hRecMCGenMultiplicityPercent"), 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; + + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + // Loop over all negative candidates + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + TLorentzVector recPhi; + recPhi = recMother(track1, track2, massKa, massKa); + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) + continue; + + if (!isCountedPhi) { + MCeventHist.fill(HIST("hRecMCEventSelection"), 7); // at least a Phi in the event + isCountedPhi = true; + } + + MCPhipurHist.fill(HIST("h2MCPhipurInvMass"), genmultiplicity, recPhi.M()); + + bool isCountedK0SInclusive[nPtBinK0S] = {false}, isCountedK0SFirstCut[nPtBinK0S] = {false}, isCountedK0SSecondCut[nPtBinK0S] = {false}; + + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + + TLorentzVector recK0S; + recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); + + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) + continue; + + int ipTBinK0S = 0; + for (int i = 0; i < nPtBinK0S; i++) { + if (pTBinK0S[i] < recK0S.Pt() && recK0S.Pt() <= pTBinK0S[i + 1]) { + ipTBinK0S = i; + break; + } } - case 1: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + + if (!isCountedK0SInclusive[ipTBinK0S]) { + MCPhipurHist.fill(HIST("h3MCPhipurK0SInvMassInclusive"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SInclusive[ipTBinK0S] = true; } - case 2: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + if (!isCountedK0SFirstCut[ipTBinK0S]) { + MCPhipurHist.fill(HIST("h3MCPhipurK0SInvMassFirstCut"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SFirstCut[ipTBinK0S] = true; } - case 3: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + if (!isCountedK0SSecondCut[ipTBinK0S]) { + MCPhipurHist.fill(HIST("h3MCPhipurK0SInvMassSecondCut"), genmultiplicity, recK0S.Pt(), recPhi.M()); + isCountedK0SSecondCut[ipTBinK0S] = true; } - case 4: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + } + + bool isCountedPiInclusive[nPtBinPi] = {false}, isCountedPiFirstCut[nPtBinPi] = {false}, isCountedPiSecondCut[nPtBinPi] = {false}; + + // Loop over all primary pion candidates + for (const auto& track : fullMCTracks) { + + if (!selectionPion(track)) + continue; + + TLorentzVector recPi; + recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); + + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) + continue; + + int ipTBinPi = 0; + for (int i = 0; i < nPtBinPi; i++) { + if (pTBinPi[i] < recPi.Pt() && recPi.Pt() <= pTBinPi[i + 1]) { + ipTBinPi = i; + break; + } } - case 5: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + + if (!isCountedPiInclusive[ipTBinPi]) { + MCPhipurHist.fill(HIST("h3MCPhipurPiInvMassInclusive"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiInclusive[ipTBinPi] = true; } - case 6: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + if (!isCountedPiFirstCut[ipTBinPi]) { + MCPhipurHist.fill(HIST("h3MCPhipurPiInvMassFirstCut"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiFirstCut[ipTBinPi] = true; } - case 7: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + if (!isCountedPiSecondCut[ipTBinPi]) { + MCPhipurHist.fill(HIST("h3MCPhipurPiInvMassSecondCut"), genmultiplicity, recPi.Pt(), recPhi.M()); + isCountedPiSecondCut[ipTBinPi] = true; } - case 8: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); - break; + } + } + } + } + + PROCESS_SWITCH(phik0shortanalysis, processRecMCClosurePhiQA, "Process for ReCMCQA and Phi in RecMCClosure", false); + + void processRecMCClosurePhiK0S(SimCollisions::iterator const& collision, FullMCTracks const&, FullV0s const& V0s, V0DauMCTracks const&, MCCollisions const&) + { + 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); + + // V0 already reconstructed by the builder + for (const auto& v0 : V0s) { + const auto& posDaughterTrack = v0.posTrack_as(); + const auto& negDaughterTrack = v0.negTrack_as(); + + if (!selectionV0(v0, posDaughterTrack, negDaughterTrack)) + continue; + + TLorentzVector recK0S; + recK0S.SetXYZM(v0.px(), v0.py(), v0.pz(), v0.mK0Short()); + if (std::abs(recK0S.Rapidity()) > cfgyAcceptance) + continue; + + std::vector listrecPhi; + std::array counts{}; + + // Phi reconstruction + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + TLorentzVector recPhi; + recPhi = recMother(track1, track2, massKa, massKa); + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) + continue; + + listrecPhi.push_back(recPhi); + + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recK0S.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; + } + } + } + + 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); + } + + fillInvMass2D(recK0S, listrecPhi, genmultiplicity, weights); + } + } + + PROCESS_SWITCH(phik0shortanalysis, processRecMCClosurePhiK0S, "Process RecMC for MCClosure Phi-K0S Analysis", false); + + void processRecMCClosurePhiPion(SimCollisions::iterator const& collision, FullMCTracks const& fullMCTracks, MCCollisions const&) + { + 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); + + // Loop over all primary pion candidates + for (const auto& track : fullMCTracks) { + + // Pion selection + if (!selectionPion(track)) + continue; + + TLorentzVector recPi; + recPi.SetXYZM(track.px(), track.py(), track.pz(), massPi); + if (std::abs(recPi.Rapidity()) > cfgyAcceptance) + continue; + + float nsigmaTPC, nsigmaTOF; + nsigmaTPC = (track.hasTPC() ? track.tpcNSigmaPi() : -9.99); + nsigmaTOF = (track.hasTOF() ? track.tofNSigmaPi() : -9.99); + + std::vector listrecPhi; + std::array counts{}; + + // Phi reconstruction + for (auto track1 : posThisColl) { // loop over all selected tracks + if (!selectionTrackResonance(track1) || !selectionPIDKaonpTdependent(track1)) + continue; // topological and PID selection + + auto track1ID = track1.globalIndex(); + + for (auto track2 : negThisColl) { + if (!selectionTrackResonance(track2) || !selectionPIDKaonpTdependent(track2)) + continue; // topological and PID selection + + auto track2ID = track2.globalIndex(); + if (track2ID == track1ID) + continue; // condition to avoid double counting of pair + + TLorentzVector recPhi; + recPhi = recMother(track1, track2, massKa, massKa); + if (std::abs(recPhi.Rapidity()) > cfgyAcceptance) + continue; + + listrecPhi.push_back(recPhi); + + if (lowmPhi <= recPhi.M() && recPhi.M() <= upmPhi) { + counts.at(0)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgFirstCutonDeltay) + continue; + counts.at(1)++; + if (std::abs(recPi.Rapidity() - recPhi.Rapidity()) > cfgSecondCutonDeltay) + continue; + counts.at(2)++; } - case 9: { - fillInvMassNSigmadEdx(recPi, track.tpcNSigmaPi(), listrecPhi, multiplicity, weightInclusive, weightLtFirstCut, weightLtSecondCut); + } + } + + 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); + } + + fillInvMassNSigma(recPi, nsigmaTPC, nsigmaTOF, listrecPhi, genmultiplicity, weights); + } + } + + PROCESS_SWITCH(phik0shortanalysis, processRecMCClosurePhiPion, "Process RecMC for MCClosure Phi-Pion Analysis", false); + + void processGenMCPhiQA(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) + return; + MCeventHist.fill(HIST("hGenMCEventSelection"), 1); // vertex-Z selected + MCeventHist.fill(HIST("hGenMCVertexZ"), mcCollision.posZ()); + if (!pwglf::isINELgtNmc(mcParticles, 0, pdgDB)) + return; + MCeventHist.fill(HIST("hGenMCEventSelection"), 2); // INEL>0 collisions + + bool isAssocColl = false; + for (auto collision : collisions) { + if (acceptEventQA(collision, false)) { + isAssocColl = true; + break; + } + } + + float multiplicity = mcCollision.centFT0M(); + MCeventHist.fill(HIST("hGenMCMultiplicityPercent"), multiplicity); + + int imultBin = 0; + for (int i = 0; i < nMultBin; i++) { + if (multBin[i] < multiplicity && multiplicity <= multBin[i + 1]) { + imultBin = i; + break; + } + } + + bool isCountedPhi = false; + + for (auto mcParticle1 : mcParticles) { + if (mcParticle1.pdgCode() != 333) + continue; + auto kDaughters = mcParticle1.daughters_as(); + if (kDaughters.size() != 2) + continue; + bool isPosKaon = false, isNegKaon = false; + for (auto kDaughter : kDaughters) { + if (kDaughter.pdgCode() == 321) + isPosKaon = true; + if (kDaughter.pdgCode() == -321) + isNegKaon = true; + } + if (!isPosKaon || !isNegKaon) + continue; + if (std::abs(mcParticle1.y()) > cfgyAcceptance) + continue; + + if (!isCountedPhi) { + MCeventHist.fill(HIST("hGenMCEventSelection"), 3); // at least a Phi in the event + if (isAssocColl) + MCeventHist.fill(HIST("hGenMCEventSelection"), 4); // with at least a reco collision + isCountedPhi = true; + } + + PhieffHist.fill(HIST("h1PhiGenMC"), imultBin); + + bool isCountedK0SInclusive[nPtBinK0S] = {false}, isCountedK0SFirstCut[nPtBinK0S] = {false}, isCountedK0SSecondCut[nPtBinK0S] = {false}; + + for (auto mcParticle2 : mcParticles) { + if (mcParticle2.pdgCode() != 310) + continue; + if (!mcParticle2.isPhysicalPrimary()) + continue; + if (std::abs(mcParticle2.y()) > cfgyAcceptance) + continue; + + int ipTBinK0S = 0; + for (int i = 0; i < nPtBinK0S; i++) { + if (pTBinK0S[i] < mcParticle1.pt() && mcParticle1.pt() <= pTBinK0S[i + 1]) { + ipTBinK0S = i; break; } - default: + } + + if (!isCountedK0SInclusive[ipTBinK0S]) { + PhieffHist.fill(HIST("h2PhieffK0SGenMCInclusive"), imultBin, ipTBinK0S); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffK0SGenMCFirstCutAssocReco"), imultBin, ipTBinK0S); + isCountedK0SInclusive[ipTBinK0S] = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFirstCutonDeltay) + continue; + if (!isCountedK0SFirstCut[ipTBinK0S]) { + PhieffHist.fill(HIST("h2PhieffK0SGenMCFirstCut"), imultBin, ipTBinK0S); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffK0SGenMCFirstCutAssocReco"), imultBin, ipTBinK0S); + isCountedK0SFirstCut[ipTBinK0S] = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSecondCutonDeltay) + continue; + if (!isCountedK0SSecondCut[ipTBinK0S]) { + PhieffHist.fill(HIST("h2PhieffK0SGenMCSecondCut"), imultBin, ipTBinK0S); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffK0SGenMCSecondCutAssocReco"), imultBin, ipTBinK0S); + isCountedK0SSecondCut[ipTBinK0S] = true; + } + } + + bool isCountedPiInclusive[nPtBinPi] = {false}, isCountedPiFirstCut[nPtBinPi] = {false}, isCountedPiSecondCut[nPtBinPi] = {false}; + + for (auto mcParticle2 : mcParticles) { + if (std::abs(mcParticle2.pdgCode()) != 211) + continue; + if (!mcParticle2.isPhysicalPrimary()) + continue; + if (std::abs(mcParticle2.y()) > cfgyAcceptance) + continue; + + int ipTBinPi = 0; + for (int i = 0; i < nPtBinPi; i++) { + if (pTBinPi[i] < mcParticle1.pt() && mcParticle1.pt() <= pTBinPi[i + 1]) { + ipTBinPi = i; break; + } + } + + if (!isCountedPiInclusive[ipTBinPi]) { + PhieffHist.fill(HIST("h2PhieffPiGenMCInclusive"), imultBin, ipTBinPi); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffPiGenMCInclusiveAssocReco"), imultBin, ipTBinPi); + isCountedPiInclusive[ipTBinPi] = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFirstCutonDeltay) + continue; + if (!isCountedPiFirstCut[ipTBinPi]) { + PhieffHist.fill(HIST("h2PhieffPiGenMCFirstCut"), imultBin, ipTBinPi); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffPiGenMCFirstCutAssocReco"), imultBin, ipTBinPi); + isCountedPiFirstCut[ipTBinPi] = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSecondCutonDeltay) + continue; + if (!isCountedPiSecondCut[ipTBinPi]) { + PhieffHist.fill(HIST("h2PhieffPiGenMCSecondCut"), imultBin, ipTBinPi); + if (isAssocColl) + PhieffHist.fill(HIST("h2PhieffPiGenMCSecondCutAssocReco"), imultBin, ipTBinPi); + isCountedPiSecondCut[ipTBinPi] = true; + } + } + } + } + + PROCESS_SWITCH(phik0shortanalysis, processGenMCPhiQA, "Process for ReCMCQA and Phi in RecMC", false); + + void processGenMCPhiK0S(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; + + bool isAssocColl = false; + for (auto collision : collisions) { + if (acceptEventQA(collision, false)) { + isAssocColl = true; + break; + } + } + + float multiplicity = mcCollision.centFT0M(); + MCeventHist.fill(HIST("hGenMCMultiplicityPercent"), multiplicity); + + for (auto mcParticle1 : mcParticles) { + if (mcParticle1.pdgCode() != 310) + continue; + if (!mcParticle1.isPhysicalPrimary()) + continue; + auto kDaughters1 = mcParticle1.daughters_as(); + if (kDaughters1.size() != 2) + continue; + bool isPosPion = false, isNegPion = false; + for (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) + continue; + + K0SeffHist.fill(HIST("h2K0SGenMC"), multiplicity, mcParticle1.pt()); + + bool isCountedPhi = false; + + bool isCountedPhiInclusive = false, isCountedPhiFirstCut = false, isCountedPhiSecondCut = false; + + for (auto mcParticle2 : mcParticles) { + if (mcParticle2.pdgCode() != 333) + continue; + auto kDaughters2 = mcParticle2.daughters_as(); + if (kDaughters2.size() != 2) + continue; + bool isPosKaon = false, isNegKaon = false; + for (auto kDaughter2 : kDaughters2) { + if (kDaughter2.pdgCode() == 321) + isPosKaon = true; + if (kDaughter2.pdgCode() == -321) + isNegKaon = true; + } + if (!isPosKaon || !isNegKaon) + continue; + if (std::abs(mcParticle2.y()) > cfgyAcceptance) + continue; + + if (!isCountedPhi) { + yaccHist.fill(HIST("hyaccK0SGenMC"), multiplicity, mcParticle1.pt(), mcParticle1.y()); + isCountedPhi = true; + } + + if (!isCountedPhiInclusive) { + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCInclusive"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCInclusiveAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiInclusive = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFirstCutonDeltay) + continue; + if (!isCountedPhiFirstCut) { + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCFirstCut"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCFirstCutAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiFirstCut = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSecondCutonDeltay) + continue; + if (!isCountedPhiSecondCut) { + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCSecondCut"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiK0SHist.fill(HIST("h2PhiK0SGenMCSecondCutAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiSecondCut = true; + } + } + } + } + + PROCESS_SWITCH(phik0shortanalysis, processGenMCPhiK0S, "Process GenMC for Phi-K0S Analysis", false); + + void processGenMCPhiPion(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; + + bool isAssocColl = false; + for (auto collision : collisions) { + if (acceptEventQA(collision, false)) { + isAssocColl = true; + break; + } + } + + float multiplicity = mcCollision.centFT0M(); + MCeventHist.fill(HIST("hGenMCMultiplicityPercent"), multiplicity); + + for (auto mcParticle1 : mcParticles) { + if (std::abs(mcParticle1.pdgCode()) != 211) + continue; + if (!mcParticle1.isPhysicalPrimary()) + continue; + if (std::abs(mcParticle1.y()) > cfgyAcceptance) + continue; + + PioneffHist.fill(HIST("h2PiGenMC"), multiplicity, mcParticle1.pt()); + + bool isCountedPhi = false; + + bool isCountedPhiInclusive = false, isCountedPhiFirstCut = false, isCountedPhiSecondCut = false; + + for (auto mcParticle2 : mcParticles) { + if (mcParticle2.pdgCode() != 333) + continue; + auto kDaughters = mcParticle2.daughters_as(); + if (kDaughters.size() != 2) + continue; + bool isPosKaon = false, isNegKaon = false; + for (auto kDaughter : kDaughters) { + if (kDaughter.pdgCode() == 321) + isPosKaon = true; + if (kDaughter.pdgCode() == -321) + isNegKaon = true; + } + if (!isPosKaon || !isNegKaon) + continue; + if (std::abs(mcParticle2.y()) > cfgyAcceptance) + continue; + + if (!isCountedPhi) { + yaccHist.fill(HIST("hyaccPiGenMC"), multiplicity, mcParticle1.pt(), mcParticle1.y()); + isCountedPhi = true; + } + + if (!isCountedPhiInclusive) { + MCPhiPionHist.fill(HIST("h2PhiPiGenMCInclusive"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiPionHist.fill(HIST("h2PhiPiGenMCInclusiveAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiInclusive = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgFirstCutonDeltay) + continue; + if (!isCountedPhiFirstCut) { + MCPhiPionHist.fill(HIST("h2PhiPiGenMCFirstCut"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiPionHist.fill(HIST("h2PhiPiGenMCFirstCutAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiFirstCut = true; + } + if (std::abs(mcParticle1.y() - mcParticle2.y()) > cfgSecondCutonDeltay) + continue; + if (!isCountedPhiSecondCut) { + MCPhiPionHist.fill(HIST("h2PhiPiGenMCSecondCut"), multiplicity, mcParticle1.pt()); + if (isAssocColl) + MCPhiPionHist.fill(HIST("h2PhiPiGenMCSecondCutAssocReco"), multiplicity, mcParticle1.pt()); + isCountedPhiSecondCut = true; } } } } - PROCESS_SWITCH(phik0shortanalysis, processMEPhiPion, "Process Mixed Event for Phi-Pion Analysis", false); + PROCESS_SWITCH(phik0shortanalysis, processGenMCPhiPion, "Process GenMC 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 343c5ba4287..2b07b4c0958 100644 --- a/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/sigmaanalysis.cxx @@ -9,8 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. // -// This is a task that employs the standard V0 tables and attempts to combine -// two V0s into a Sigma0 -> Lambda + gamma candidate. +// This is a task that reads sigma0 tables (from sigma0builder) to perform analysis. // *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* // Sigma0 analysis task // *+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+* @@ -54,21 +53,15 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; using std::array; -using std::cout; -using std::endl; -using V0MCSigmas = soa::Join; -using V0Sigmas = soa::Join; +using V0MCSigmas = soa::Join; +using V0Sigmas = soa::Join; struct sigmaanalysis { HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - // master analysis switches - // Configurable analyseSigma{"analyseSigma", false, "process Sigma-like candidates"}; - // Configurable analyseAntiSigma{"analyseAntiSigma", false, "process AntiSigma-like candidates"}; - // Analysis strategy: - Configurable fUseMLSel{"fUseMLSel", true, "Flag to use ML selection. If False, the standard selection is applied."}; + 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."}; // For ML Selection @@ -81,46 +74,51 @@ struct sigmaanalysis { Configurable LambdaMinDCANegToPv{"LambdaMinDCANegToPv", .05, "min DCA Neg To PV (cm)"}; Configurable LambdaMinDCAPosToPv{"LambdaMinDCAPosToPv", .05, "min DCA Pos To PV (cm)"}; Configurable LambdaMaxDCAV0Dau{"LambdaMaxDCAV0Dau", 2.5, "Max DCA V0 Daughters (cm)"}; - Configurable LambdaMinv0radius{"LambdaMinv0radius", 0.5, "Min V0 radius (cm)"}; - Configurable LambdaMaxv0radius{"LambdaMaxv0radius", 180, "Max V0 radius (cm)"}; + Configurable LambdaMinv0radius{"LambdaMinv0radius", 0.0, "Min V0 radius (cm)"}; + Configurable LambdaMaxv0radius{"LambdaMaxv0radius", 40, "Max V0 radius (cm)"}; Configurable LambdaMinQt{"LambdaMinQt", 0.01, "Min lambda qt value (AP plot) (GeV/c)"}; Configurable LambdaMaxQt{"LambdaMaxQt", 0.17, "Max lambda qt value (AP plot) (GeV/c)"}; - Configurable LambdaMinAlpha{"LambdaMinAlpha", 0.2, "Min lambda alpha absolute value (AP plot)"}; - Configurable LambdaMaxAlpha{"LambdaMaxAlpha", 0.9, "Max lambda alpha absolute value (AP plot)"}; + 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 LambdaWindow{"LambdaWindow", 0.01, "Mass window around expected (in GeV/c2)"}; + Configurable LambdaWindow{"LambdaWindow", 0.015, "Mass window around expected (in GeV/c2)"}; + Configurable LambdaMaxRap{"LambdaMaxRap", 0.8, "Max lambda rapidity"}; + Configurable LambdaMaxTPCNSigmas{"LambdaMaxTPCNSigmas", 1e+9, "Max TPC NSigmas for daughters"}; + Configurable LambdaMaxTOFNSigmas{"LambdaMaxTOFNSigmas", 1e+9, "Max TOF NSigmas for daughters"}; //// Photon standard criteria: - Configurable PhotonMaxDauPseudoRap{"PhotonMaxDauPseudoRap", 0.9, "Max pseudorapidity of daughter tracks"}; - Configurable PhotonDauMinPt{"PhotonDauMinPt", 0.05, "Min daughter pT (GeV/c)"}; - Configurable PhotonMinDCADauToPv{"PhotonMinDCADauToPv", 0.05, "Min DCA daughter To PV (cm)"}; - Configurable PhotonMaxDCAV0Dau{"PhotonMaxDCAV0Dau", 2.5, "Max DCA V0 Daughters (cm)"}; - Configurable PhotonMinTPCCrossedRows{"PhotonMinTPCCrossedRows", 55, "Min daughter TPC Crossed Rows"}; - Configurable PhotonMinTPCNSigmas{"PhotonMinTPCNSigmas", -6, "Min TPC NSigmas for daughters"}; + // Configurable PhotonMaxDauPseudoRap{"PhotonMaxDauPseudoRap", 0.9, "Max pseudorapidity of daughter tracks"}; + 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 PhotonMinTPCNSigmas{"PhotonMinTPCNSigmas", -7, "Min TPC NSigmas for daughters"}; Configurable PhotonMaxTPCNSigmas{"PhotonMaxTPCNSigmas", 7, "Max TPC NSigmas for daughters"}; - Configurable PhotonMinPt{"PhotonMinPt", 0.02, "Min photon pT (GeV/c)"}; + Configurable PhotonMinPt{"PhotonMinPt", 0.0, "Min photon pT (GeV/c)"}; Configurable PhotonMaxPt{"PhotonMaxPt", 50.0, "Max photon pT (GeV/c)"}; - Configurable PhotonMaxPseudoRap{"PhotonMaxPseudoRap", 0.9, "Max photon pseudorapidity"}; - Configurable PhotonMinRadius{"PhotonMinRadius", 0.5, "Min photon conversion radius (cm)"}; - Configurable PhotonMaxRadius{"PhotonMaxRadius", 180, "Max photon conversion radius (cm)"}; + Configurable PhotonMaxRap{"PhotonMaxRap", 0.5, "Max photon rapidity"}; + Configurable PhotonMinRadius{"PhotonMinRadius", 3.0, "Min photon conversion radius (cm)"}; + Configurable PhotonMaxRadius{"PhotonMaxRadius", 115, "Max photon conversion radius (cm)"}; Configurable PhotonMaxZ{"PhotonMaxZ", 240, "Max photon conversion point z value (cm)"}; - Configurable PhotonMaxQt{"PhotonMaxQt", 0.06, "Max photon qt value (AP plot) (GeV/c)"}; + Configurable PhotonMaxQt{"PhotonMaxQt", 0.05, "Max photon qt value (AP plot) (GeV/c)"}; Configurable PhotonMaxAlpha{"PhotonMaxAlpha", 0.95, "Max photon alpha absolute value (AP plot)"}; - Configurable PhotonMinV0cospa{"PhotonMinV0cospa", 0.90, "Min V0 CosPA"}; - Configurable PhotonMaxMass{"PhotonMaxMass", 0.15, "Max photon mass (GeV/c^{2})"}; + Configurable PhotonMinV0cospa{"PhotonMinV0cospa", 0.80, "Min V0 CosPA"}; + Configurable PhotonMaxMass{"PhotonMaxMass", 0.10, "Max photon mass (GeV/c^{2})"}; // TODO: Include PsiPair selection + Configurable SigmaMaxRap{"SigmaMaxRap", 0.5, "Max sigma0 rapidity"}; + Configurable SigmaOPAngle{"SigmaOPAngle", 1.0, "Max sigma0 opening angle between daughters (radians)"}; + // Axis // 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}, "Centrality"}; + 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 axisRadius{"axisRadius", {200, 0.0f, 100.0f}, "V0 radius (cm)"}; - ConfigurableAxis axisRapidity{"axisRapidity", {100, -1.0f, 1.0f}, "Rapidity"}; + ConfigurableAxis axisRapidity{"axisRapidity", {100, -2.0f, 2.0f}, "Rapidity"}; // Invariant Mass - ConfigurableAxis axisSigmaMass{"axisSigmaMass", {200, 1.16f, 1.23f}, "M_{#Sigma^{0}} (GeV/c^{2})"}; - ConfigurableAxis axisLambdaMass{"axisLambdaMass", {200, 1.101f, 1.131f}, "M_{#Lambda} (GeV/c^{2})"}; - ConfigurableAxis axisPhotonMass{"axisPhotonMass", {200, -0.1f, 0.1f}, "M_{#Gamma}"}; + ConfigurableAxis axisSigmaMass{"axisSigmaMass", {1000, 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}"}; // AP plot axes ConfigurableAxis axisAPAlpha{"axisAPAlpha", {220, -1.1f, 1.1f}, "V0 AP alpha"}; @@ -128,13 +126,13 @@ struct sigmaanalysis { // 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"}; // topological variable QA axes - ConfigurableAxis axisDCAtoPV{"axisDCAtoPV", {20, 0.0f, 1.0f}, "DCA (cm)"}; - ConfigurableAxis axisDCAdau{"axisDCAdau", {20, 0.0f, 2.0f}, "DCA (cm)"}; - ConfigurableAxis axisPointingAngle{"axisPointingAngle", {20, 0.0f, 2.0f}, "pointing angle (rad)"}; - ConfigurableAxis axisV0Radius{"axisV0Radius", {20, 0.0f, 60.0f}, "V0 2D radius (cm)"}; + 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"}; // ML ConfigurableAxis MLProb{"MLOutput", {100, 0.0f, 1.0f}, ""}; @@ -144,26 +142,15 @@ struct sigmaanalysis { // Event counter histos.add("hEventCentrality", "hEventCentrality", kTH1F, {axisCentrality}); - // For Signal Extraction - histos.add("h3dMassSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("h3dMassAntiSigma0", "h3dMassAntiSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - // All candidates received - // 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", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/h2dArmenterosSelected", "h2dArmenterosSelected", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/hMassSigma0All", "hMassSigma0All", kTH1F, {axisSigmaMass}); + 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, {{22, -0.5f, +21.5f}}); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(1, "Photon Mass Cut"); - histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(2, "Photon DauEta Cut"); + 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"); @@ -171,7 +158,7 @@ struct sigmaanalysis { 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 Eta 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"); @@ -184,71 +171,138 @@ struct sigmaanalysis { 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, "Sigma OP Angle Cut"); + histos.get(HIST("GeneralQA/hCandidateAnalysisSelection"))->GetXaxis()->SetBinLabel(26, "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}); - // Sigma0 QA + // 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}); - // Sigma0 QA - histos.add("AntiSigma0/hMassSigma0", "hMassSigma0", kTH1F, {axisSigmaMass}); - histos.add("AntiSigma0/hPtSigma0", "hPtSigma0", kTH1F, {axisPt}); - histos.add("AntiSigma0/hRapiditySigma0", "hRapiditySigma0", kTH1F, {axisRapidity}); - - // Gamma QA - histos.add("Gamma/hMassGamma", "hMassGamma", kTH1F, {axisSigmaMass}); - histos.add("Gamma/hPosDCAToPV", "hPosDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("Gamma/hNegDCAToPV", "hNegDCAToPV", kTH1F, {axisDCAtoPV}); - histos.add("Gamma/hDCADaughters", "hDCADaughters", kTH1F, {axisDCAdau}); - histos.add("Gamma/hPointingAngle", "hPointingAngle", kTH1F, {axisPointingAngle}); - histos.add("Gamma/hV0Radius", "hV0Radius", kTH1F, {axisV0Radius}); - histos.add("Gamma/hMLOutputGamma", "hMLOutputGamma", kTH1F, {MLProb}); - histos.add("Gamma/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("Gamma/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("Gamma/h2dPhotonRadiusVsPt", "hPhotonRadiusVsPt", {HistType::kTH2F, {axisPt, axisRadius}}); - histos.add("Gamma/h2dPhotonMassVsMLScore", "h2dPhotonMassVsMLScore", {HistType::kTH2F, {MLProb, axisSigmaMass}}); - - // Lambda QA - histos.add("Lambda/hMassLambda", "hMassLambda", kTH1F, {axisLambdaMass}); - 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/hMLOutputLambda", "hMLOutputLambda", kTH1F, {MLProb}); - histos.add("Lambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("Lambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("Lambda/h2dLambdaRadiusVsPt", "hLambdaRadiusVsPt", {HistType::kTH2F, {axisPt, axisRadius}}); - histos.add("Lambda/h2dLambdaMassVsMLScore", "h2dLambdaMassVsMLScore", {HistType::kTH2F, {MLProb, axisLambdaMass}}); - - // AntiLambda QA - histos.add("AntiLambda/hMassAntiLambda", "hMassAntiLambda", kTH1F, {axisLambdaMass}); - 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/hMLOutputAntiLambda", "hMLOutputAntiLambda", kTH1F, {MLProb}); - histos.add("AntiLambda/h2dPositiveITSvsTPCpts", "h2dPositiveITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("AntiLambda/h2dNegativeITSvsTPCpts", "h2dNegativeITSvsTPCpts", kTH2F, {axisTPCrows, axisITSclus}); - histos.add("AntiLambda/h2dAntiLambdaRadiusVsPt", "h2dAntiLambdaRadiusVsPt", {HistType::kTH2F, {axisPt, axisRadius}}); - histos.add("AntiLambda/h2dAntiLambdaMassVsMLScore", "h2dAntiLambdaMassVsMLScore", {HistType::kTH2F, {MLProb, axisLambdaMass}}); + // 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) { // Event counter - histos.add("hMCEventCentrality", "hMCEventCentrality", kTH1F, {axisCentrality}); + histos.add("MC/hMCEventCentrality", "hMCEventCentrality", kTH1F, {axisCentrality}); - // For Signal Extraction - histos.add("h3dMCMassSigma0", "h3dMCMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + // Kinematic + histos.add("MC/h3dMassSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); + histos.add("MC/h3dMassAntiSigma0", "h3dMassSigma0", kTH3F, {axisCentrality, axisPt, axisSigmaMass}); - histos.add("GeneralQA/h2dMCArmenterosAll", "h2dMCArmenterosAll", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); - histos.add("GeneralQA/h2dMCArmenterosSelected", "h2dMCArmenterosSelected", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); + histos.add("MC/h2dArmenterosBeforeSel", "h2dArmenterosBeforeSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); + histos.add("MC/h2dArmenterosAfterSel", "h2dArmenterosAfterSel", {HistType::kTH2F, {axisAPAlpha, axisAPQt}}); // Sigma0 QA - histos.add("GeneralQA/hMCMassSigma0All", "hMCMassSigma0All", kTH1F, {axisSigmaMass}); - histos.add("GeneralQA/hMCPtSigma0All", "hMCPtSigma0All", kTH1F, {axisPt}); - histos.add("Sigma0/hMCMassSigma0", "hMCMassSigma0", kTH1F, {axisSigmaMass}); - histos.add("Sigma0/hMCPtSigma0", "hMCPtSigma0", kTH1F, {axisPt}); + 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}); + + // Testing New Selections: + //// Opening Angle + histos.add("MC/hPtTrueSigma_AngleSel", "hPtTrueSigma_AngleSel", kTH1F, {axisPt}); + histos.add("MC/hPtSigmaCand_AngleSel", "hPtSigmaCand_AngleSel", kTH1F, {axisPt}); + + //// TPC PID + histos.add("MC/hPtTrueLambda_TPCPID", "hPtTrueLambda_TPCPID", kTH1F, {axisPt}); + histos.add("MC/hPtLambdaCandidates_TPCPID", "hPtLambdaCandidates_TPCPID", kTH1F, {axisPt}); + + //// TOF PID + histos.add("MC/hPtTrueLambda_TOFPID", "hPtTrueLambda_TOFPID", kTH1F, {axisPt}); + histos.add("MC/hPtLambdaCandidates_TOFPID", "hPtLambdaCandidates_TOFPID", kTH1F, {axisPt}); + + //// TPC+TOF PID + histos.add("MC/hPtTrueLambda_TPCTOFPID", "hPtTrueLambda_TPCTOFPID", kTH1F, {axisPt}); + histos.add("MC/hPtLambdaCandidates_TPCTOFPID", "hPtLambdaCandidates_TPCTOFPID", kTH1F, {axisPt}); } } @@ -272,76 +326,110 @@ struct sigmaanalysis { if (cand.antilambdaBDTScore() <= AntiLambda_MLThreshold) return false; } else { - if (TMath::Abs(cand.photonMass()) > PhotonMaxMass) - return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 0.); - if ((TMath::Abs(cand.photonPosEta()) > PhotonMaxDauPseudoRap) || (TMath::Abs(cand.photonNegEta()) > PhotonMaxDauPseudoRap)) - return false; + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 1.); - if ((cand.photonPosPt() < PhotonDauMinPt) || (cand.photonNegPt() < PhotonDauMinPt)) + 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 ((TMath::Abs(cand.photonDCAPosPV()) < PhotonMinDCADauToPv) || (TMath::Abs(cand.photonDCANegPV()) < PhotonMinDCADauToPv)) + 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 (cand.photonDCADau() > PhotonMaxDCAV0Dau) + if ((TMath::Abs(cand.photonDCAPosPV()) < PhotonMinDCADauToPv) || (TMath::Abs(cand.photonDCANegPV()) < PhotonMinDCADauToPv)) return false; histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 4.); - if ((cand.photonPosTPCCrossedRows() < PhotonMinTPCCrossedRows) || (cand.photonNegTPCCrossedRows() < PhotonMinTPCCrossedRows)) + 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.photonPosTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonPosTPCNSigma() > PhotonMaxTPCNSigmas)) + if ((cand.photonPosTPCCrossedRows() < PhotonMinTPCCrossedRows) || (cand.photonNegTPCCrossedRows() < PhotonMinTPCCrossedRows)) return false; + histos.fill(HIST("GeneralQA/hPhotonPosTPCNSigma"), cand.photonPosTPCNSigma()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 6.); - if ((cand.photonNegTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonNegTPCNSigma() > PhotonMaxTPCNSigmas)) + if ((cand.photonPosTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonPosTPCNSigma() > PhotonMaxTPCNSigmas)) return false; + histos.fill(HIST("GeneralQA/hPhotonNegTPCNSigma"), cand.photonNegTPCNSigma()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 7.); - if ((cand.photonPt() < PhotonMinPt) || (cand.photonPt() > PhotonMaxPt)) + if ((cand.photonNegTPCNSigma() < PhotonMinTPCNSigmas) || (cand.photonNegTPCNSigma() > PhotonMaxTPCNSigmas)) return false; + histos.fill(HIST("GeneralQA/hPhotonpT"), cand.photonPt()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 8.); - if (TMath::Abs(cand.photonEta()) > PhotonMaxPseudoRap) + if ((cand.photonPt() < PhotonMinPt) || (cand.photonPt() > PhotonMaxPt)) return false; + histos.fill(HIST("GeneralQA/hPhotonY"), cand.photonY()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 9.); - if ((cand.photonRadius() < PhotonMinRadius) || (cand.photonRadius() > PhotonMaxRadius)) + if ((TMath::Abs(cand.photonY()) > PhotonMaxRap)) return false; + histos.fill(HIST("GeneralQA/hPhotonRadius"), cand.photonRadius()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 10.); - if (TMath::Abs(cand.photonZconv()) > PhotonMaxZ) + if ((cand.photonRadius() < PhotonMinRadius) || (cand.photonRadius() > PhotonMaxRadius)) return false; + histos.fill(HIST("GeneralQA/hPhotonZ"), cand.photonZconv()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 11.); - if (cand.photonQt() > PhotonMaxQt) + if (TMath::Abs(cand.photonZconv()) > PhotonMaxZ) return false; + histos.fill(HIST("GeneralQA/h2dPhotonArmenteros"), cand.photonAlpha(), cand.photonQt()); histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 12.); - if (TMath::Abs(cand.photonAlpha()) > PhotonMaxAlpha) + if (cand.photonQt() > PhotonMaxQt) return false; histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 13.); - if (cand.photonCosPA() < PhotonMinV0cospa) + if (TMath::Abs(cand.photonAlpha()) > PhotonMaxAlpha) return false; histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 14.); + histos.fill(HIST("GeneralQA/hPhotonCosPA"), cand.photonCosPA()); + if (cand.photonCosPA() < PhotonMinV0cospa) + return false; + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 15.); // Lambda selection - if (TMath::Abs(cand.lambdaMass() - 1.115683) > LambdaWindow) + 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/hCandidateAnalysisSelection"), 15.); + histos.fill(HIST("GeneralQA/hLambdaDCANegToPV"), cand.lambdaDCANegPV()); + histos.fill(HIST("GeneralQA/hLambdaDCAPosToPV"), cand.lambdaDCAPosPV()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 16.); if ((TMath::Abs(cand.lambdaDCAPosPV()) < LambdaMinDCAPosToPv) || (TMath::Abs(cand.lambdaDCANegPV()) < LambdaMinDCANegToPv)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 16.); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 17.); + histos.fill(HIST("GeneralQA/hLambdaRadius"), cand.lambdaRadius()); if ((cand.lambdaRadius() < LambdaMinv0radius) || (cand.lambdaRadius() > LambdaMaxv0radius)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 17.); + histos.fill(HIST("GeneralQA/hLambdaDCADau"), cand.lambdaDCADau()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 18.); if (TMath::Abs(cand.lambdaDCADau()) > LambdaMaxDCAV0Dau) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 18.); + histos.fill(HIST("GeneralQA/h2dLambdaArmenteros"), cand.lambdaAlpha(), cand.lambdaQt()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 19.); if ((cand.lambdaQt() < LambdaMinQt) || (cand.lambdaQt() > LambdaMaxQt)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 19.); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 20.); if ((TMath::Abs(cand.lambdaAlpha()) < LambdaMinAlpha) || (TMath::Abs(cand.lambdaAlpha()) > LambdaMaxAlpha)) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 20.); + histos.fill(HIST("GeneralQA/hLambdaCosPA"), cand.lambdaCosPA()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 21.); if (cand.lambdaCosPA() < LambdaMinv0cospa) return false; - histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 21.); + histos.fill(HIST("GeneralQA/hLambdaY"), cand.lambdaY()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 22.); + if (TMath::Abs(cand.lambdaY()) > LambdaMaxRap) + return false; + histos.fill(HIST("GeneralQA/hSigmaY"), cand.sigmaRapidity()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 23.); + if (TMath::Abs(cand.sigmaRapidity()) > SigmaMaxRap) + return false; + histos.fill(HIST("GeneralQA/hSigmaOPAngle"), cand.sigmaOPAngle()); + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 24.); + if (cand.sigmaOPAngle() > SigmaOPAngle) + return false; + histos.fill(HIST("GeneralQA/hCandidateAnalysisSelection"), 25.); } - return true; } @@ -357,24 +445,128 @@ struct sigmaanalysis { void processMonteCarlo(aod::Sigma0Collision const& coll, V0MCSigmas const& v0s) { - histos.fill(HIST("hMCEventCentrality"), coll.centFT0C()); + histos.fill(HIST("MC/hMCEventCentrality"), coll.centFT0C()); for (auto& sigma : v0s) { // selecting Sigma0-like candidates - if (sigma.isSigma()) { - histos.fill(HIST("GeneralQA/h2dMCArmenterosAll"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dMCArmenterosAll"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hMCMassSigma0All"), sigma.sigmaMass()); - histos.fill(HIST("GeneralQA/hMCPtSigma0All"), sigma.sigmapT()); - if (!processSigmaCandidate(sigma)) - continue; + 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()); - histos.fill(HIST("GeneralQA/h2dMCArmenterosSelected"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dMCArmenterosSelected"), sigma.lambdaAlpha(), sigma.lambdaQt()); + 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("Sigma0/hMCMassSigma0"), sigma.sigmaMass()); - histos.fill(HIST("Sigma0/hMCPtSigma0"), 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()); - histos.fill(HIST("h3dMCMassSigma0"), coll.centFT0C(), sigma.sigmapT(), sigma.sigmaMass()); + if (!processSigmaCandidate(sigma)) + continue; + + // Purity Study + PID study: + bool fPassTPCPID = false; + bool fPassTOFPID = false; + + histos.fill(HIST("MC/hPtGammaCand_AfterSel"), sigma.photonPt()); + histos.fill(HIST("MC/hPtSigmaCand_AfterSel"), sigma.sigmapT()); + + if (sigma.photonCandPDGCode() == 22) + histos.fill(HIST("MC/hPtTrueGamma_AfterSel"), sigma.photonPt()); + + // For Lambda PID Studies + if (sigma.lambdaAlpha() > 0) { + histos.fill(HIST("MC/hPtLambdaCand_AfterSel"), sigma.lambdaPt()); + histos.fill(HIST("MC/h3dTPCvsTOFNSigma_LambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma(), sigma.sigmapT()); + histos.fill(HIST("MC/h3dTPCvsTOFNSigma_LambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma(), sigma.sigmapT()); + + if (sigma.lambdaCandPDGCode() == 3122) { + histos.fill(HIST("MC/hPtTrueLambda_AfterSel"), sigma.lambdaPt()); + histos.fill(HIST("MC/h3dTPCvsTOFNSigma_TrueLambdaPr"), sigma.lambdaPosPrTPCNSigma(), sigma.lambdaPrTOFNSigma(), sigma.sigmapT()); + histos.fill(HIST("MC/h3dTPCvsTOFNSigma_TrueLambdaPi"), sigma.lambdaNegPiTPCNSigma(), sigma.lambdaPiTOFNSigma(), sigma.sigmapT()); + } + + // TPC PID: + if ((TMath::Abs(sigma.lambdaPosPrTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaNegPiTPCNSigma()) < LambdaMaxTPCNSigmas)) { + fPassTPCPID = true; + histos.fill(HIST("MC/hPtLambdaCandidates_TPCPID"), sigma.lambdaPt()); + if (sigma.lambdaCandPDGCode() == 3122) + histos.fill(HIST("MC/hPtTrueLambda_TPCPID"), sigma.lambdaPt()); + } + + // TOF PID: + if ((TMath::Abs(sigma.lambdaPrTOFNSigma()) < LambdaMaxTOFNSigmas) && (TMath::Abs(sigma.lambdaPiTOFNSigma()) < LambdaMaxTOFNSigmas)) { + fPassTOFPID = true; + histos.fill(HIST("MC/hPtLambdaCandidates_TOFPID"), sigma.lambdaPt()); + if (sigma.lambdaCandPDGCode() == 3122) + histos.fill(HIST("MC/hPtTrueLambda_TOFPID"), sigma.lambdaPt()); + } + // TPC + TOF PID: + if (fPassTPCPID && fPassTOFPID) { + histos.fill(HIST("MC/hPtLambdaCandidates_TPCTOFPID"), sigma.lambdaPt()); + if (sigma.lambdaCandPDGCode() == 3122) + histos.fill(HIST("MC/hPtTrueLambda_TPCTOFPID"), sigma.lambdaPt()); + } + } + + // For Opening Angle study + if (sigma.sigmaOPAngle() <= SigmaOPAngle) { + histos.fill(HIST("MC/h2dPtVsMassSigma_AfterOPAngleSel"), sigma.sigmapT(), sigma.sigmaMass()); + histos.fill(HIST("MC/hPtSigmaCand_AngleSel"), sigma.sigmapT()); + if (sigma.isSigma() || sigma.isAntiSigma()) + histos.fill(HIST("MC/hPtTrueSigma_AngleSel"), sigma.sigmapT()); + } + + // 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/h2dPtVsOPAngle_SignalOnly"), sigma.sigmapT(), sigma.sigmaOPAngle()); + histos.fill(HIST("MC/hPtTrueSigma_AfterSel"), sigma.sigmapT()); + histos.fill(HIST("GeneralQA/hPhotonMassSelected"), sigma.photonMass()); + if (sigma.isSigma()) { + // PID selections + if ((TMath::Abs(sigma.lambdaPosPrTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaNegPiTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaPrTOFNSigma()) < LambdaMaxTOFNSigmas) && (TMath::Abs(sigma.lambdaPiTOFNSigma()) < LambdaMaxTOFNSigmas)) { + 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"), coll.centFT0C(), sigma.sigmapT(), sigma.sigmaMass()); + } + } else { + // PID selections + if ((TMath::Abs(sigma.lambdaPosPiTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaNegPrTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.aLambdaPrTOFNSigma()) < LambdaMaxTOFNSigmas) && (TMath::Abs(sigma.aLambdaPiTOFNSigma()) < LambdaMaxTOFNSigmas)) { + 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"), coll.centFT0C(), sigma.sigmapT(), sigma.sigmaMass()); + } + } } } } @@ -383,9 +575,9 @@ struct sigmaanalysis { { histos.fill(HIST("hEventCentrality"), coll.centFT0C()); for (auto& sigma : v0s) { // selecting Sigma0-like candidates - histos.fill(HIST("GeneralQA/h2dArmenterosAll"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dArmenterosAll"), sigma.lambdaAlpha(), sigma.lambdaQt()); - histos.fill(HIST("GeneralQA/hMassSigma0All"), sigma.sigmaMass()); + 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) { @@ -394,16 +586,36 @@ struct sigmaanalysis { if (!processSigmaCandidate(sigma)) continue; - histos.fill(HIST("GeneralQA/h2dArmenterosSelected"), sigma.photonAlpha(), sigma.photonQt()); - histos.fill(HIST("GeneralQA/h2dArmenterosSelected"), sigma.lambdaAlpha(), sigma.lambdaQt()); - - histos.fill(HIST("Sigma0/hMassSigma0"), sigma.sigmaMass()); - histos.fill(HIST("Sigma0/hPtSigma0"), sigma.sigmapT()); - histos.fill(HIST("Sigma0/hRapiditySigma0"), sigma.sigmaRapidity()); - histos.fill(HIST("h3dMassSigma0"), coll.centFT0C(), sigma.sigmapT(), sigma.sigmaMass()); - - histos.fill(HIST("Gamma/hMassGamma"), sigma.lambdaMass()); - histos.fill(HIST("Lambda/hMassLambda"), sigma.photonMass()); + 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()); + if ((TMath::Abs(sigma.lambdaPosPrTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaNegPiTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaPrTOFNSigma()) < LambdaMaxTOFNSigmas) && (TMath::Abs(sigma.lambdaPiTOFNSigma()) < LambdaMaxTOFNSigmas)) { + 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"), 26.); + 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"), coll.centFT0C(), 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()); + if ((TMath::Abs(sigma.lambdaPosPiTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.lambdaNegPrTPCNSigma()) < LambdaMaxTPCNSigmas) && (TMath::Abs(sigma.aLambdaPrTOFNSigma()) < LambdaMaxTOFNSigmas) && (TMath::Abs(sigma.aLambdaPiTOFNSigma()) < LambdaMaxTOFNSigmas)) { + 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"), 26.); + 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"), coll.centFT0C(), sigma.sigmapT(), sigma.sigmaMass()); + } + } } } diff --git a/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx b/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx new file mode 100644 index 00000000000..7706fe720bb --- /dev/null +++ b/PWGLF/Tasks/Strangeness/strange-yield-pbpb.cxx @@ -0,0 +1,1572 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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", {40, -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", {20, -0.5f, 19.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/h6dMass", particlenames[partID].data()), "h6dMass", kTHnSparseF, {axisFT0C, axisPt, axisInvMass.at(partID), axisSelGap, axisNchInvMass, axisRap}); + 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("/h6dMass"), centrality, pT, invMass, gap, coll.multAllTracksTPCOnly() + coll.multAllTracksITSTPC(), rapidity); + 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("/h6dMass"), centrality, pT, invMass, gap, coll.multAllTracksTPCOnly() + coll.multAllTracksITSTPC(), rapidity); + 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/strangeness_in_jets.cxx b/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx index 0029bf064fe..6499e3575fc 100644 --- a/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx +++ b/PWGLF/Tasks/Strangeness/strangeness_in_jets.cxx @@ -25,8 +25,8 @@ #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/DataModel/PIDResponse.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" @@ -44,43 +44,25 @@ using std::array; using SelCollisions = soa::Join; using SimCollisions = soa::Join; - -using FullTracks = soa::Join; - -using MCTracks = soa::Join; +using StrHadronDaughterTracks = soa::Join; +using MCTracks = soa::Join; struct strangeness_in_jets { - // Analysis Histograms: Data - HistogramRegistry registryData{ - "registryData", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // MC Histograms - HistogramRegistry registryMC{ - "registryMC", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; - - // QC Histograms - HistogramRegistry registryQC{ - "registryQC", - {}, - OutputObjHandlingPolicy::AnalysisObject, - true, - true}; + 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 ptLeadingMin{"ptLeadingMin", 5.0f, "pt leading min"}; - Configurable Rjet{"Rjet", 0.3f, "jet resolution parameter R"}; - Configurable Rmax{"Rmax", 0.3f, "radius of the jet and UE cones"}; - Configurable zVtx{"zVtx", 10.0f, "z vertex cut"}; + 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"}; @@ -102,8 +84,6 @@ struct strangeness_in_jets { 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 yMin{"yMin", -0.5f, "minimum y"}; - Configurable yMax{"yMax", +0.5f, "maximum y"}; Configurable requireITS{"requireITS", false, "require ITS hit"}; Configurable requireTOF{"requireTOF", false, "require TOF hit"}; @@ -131,9 +111,25 @@ struct strangeness_in_jets { void init(InitContext const&) { // Event Counters - registryData.add("number_of_events_data", "number of events in data", HistType::kTH1F, {{10, 0, 10, "Event Cuts"}}); - registryMC.add("number_of_events_mc", "number of events in mc", HistType::kTH1F, {{10, 0, 10, "Event Cuts"}}); - registryQC.add("deltaPt_leading", "deltaPt leading part", HistType::kTH1F, {{1000, -0.1, 0.1, "#Delta p_{T}"}}); + 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, 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("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}; @@ -198,6 +194,11 @@ struct strangeness_in_jets { 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"}}); @@ -234,29 +235,27 @@ struct strangeness_in_jets { } template - bool passedTrackSelectionForJets(const chargedTrack& track) + bool passedTrackSelectionForJetReconstruction(const chargedTrack& track) { if (!track.hasITS()) return false; - if (track.itsNCls() < 2) + if (track.itsNCls() < 3) return false; if (!track.hasTPC()) return false; - if (track.tpcNClsFound() < 70) - return false; if (track.tpcNClsCrossedRows() < 70) return false; if (track.tpcChi2NCl() > 4) return false; if (track.itsChi2NCl() > 36) return false; - if (abs(track.eta()) > 0.8) + if (track.eta() < -0.8 || track.eta() > 0.8) return false; if (track.pt() < 0.15) return false; - if (TMath::Abs(track.dcaXY()) > 0.5) + if (TMath::Abs(track.dcaXY()) > (par0 + par1 / track.pt())) return false; - if (TMath::Abs(track.dcaZ()) > 0.5) + if (TMath::Abs(track.dcaZ()) > (par0 + par1 / track.pt())) return false; return true; } @@ -282,13 +281,6 @@ struct strangeness_in_jets { return false; if (TMath::Abs(track.dcaZ()) > dcazMax) return false; - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(track.px(), track.py(), track.pz(), 0.13957021); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; - return true; } @@ -322,9 +314,9 @@ struct strangeness_in_jets { return false; if (v0.dcaV0daughters() > dcaV0DaughtersMax) return false; - if (v0.dcapostopv() < dcapostoPVmin) + if (TMath::Abs(v0.dcapostopv()) < dcapostoPVmin) return false; - if (v0.dcanegtopv() < dcanegtoPVmin) + if (TMath::Abs(v0.dcanegtopv()) < dcanegtoPVmin) return false; // PID Selections (TPC) @@ -340,12 +332,6 @@ struct strangeness_in_jets { if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) return false; } - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(v0.px(), v0.py(), v0.pz(), 1.115683); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; return true; } @@ -379,9 +365,9 @@ struct strangeness_in_jets { return false; if (v0.dcaV0daughters() > dcaV0DaughtersMax) return false; - if (v0.dcapostopv() < dcapostoPVmin) + if (TMath::Abs(v0.dcapostopv()) < dcapostoPVmin) return false; - if (v0.dcanegtopv() < dcanegtoPVmin) + if (TMath::Abs(v0.dcanegtopv()) < dcanegtoPVmin) return false; // PID Selections (TPC) @@ -397,12 +383,6 @@ struct strangeness_in_jets { if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) return false; } - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(v0.px(), v0.py(), v0.pz(), 1.115683); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; return true; } @@ -436,9 +416,9 @@ struct strangeness_in_jets { return false; if (v0.dcaV0daughters() > dcaV0DaughtersMax) return false; - if (v0.dcapostopv() < dcapostoPVmin) + if (TMath::Abs(v0.dcapostopv()) < dcapostoPVmin) return false; - if (v0.dcanegtopv() < dcanegtoPVmin) + if (TMath::Abs(v0.dcanegtopv()) < dcanegtoPVmin) return false; // PID Selections (TPC) @@ -454,12 +434,6 @@ struct strangeness_in_jets { if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) return false; } - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(v0.px(), v0.py(), v0.pz(), 0.497614); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; return true; } @@ -559,12 +533,6 @@ struct strangeness_in_jets { if (btrack.tofNSigmaPi() < nsigmaTOFmin || btrack.tofNSigmaPi() > nsigmaTOFmax) return false; } - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(casc.px(), casc.py(), casc.pz(), 1.32171); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; return true; } @@ -664,12 +632,6 @@ struct strangeness_in_jets { if (btrack.tofNSigmaKa() < nsigmaTOFmin || btrack.tofNSigmaKa() > nsigmaTOFmax) return false; } - - // Rapidity Selection - TLorentzVector lorentzVect; - lorentzVect.SetXYZM(casc.px(), casc.py(), casc.pz(), 1.6724); - if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) - return false; return true; } @@ -700,9 +662,9 @@ struct strangeness_in_jets { template bool isHighPurityPion(const pionTrack& track) { - if (track.p() < 0.6 && abs(track.tpcNSigmaPi()) < 3.0) + if (track.p() < 0.6 && TMath::Abs(track.tpcNSigmaPi()) < 3.0) return true; - if (track.p() > 0.6 && abs(track.tpcNSigmaPi()) < 3.0 && abs(track.tofNSigmaPi()) < 3.0) + if (track.p() > 0.6 && TMath::Abs(track.tpcNSigmaPi()) < 3.0 && TMath::Abs(track.tofNSigmaPi()) < 3.0) return true; return false; } @@ -714,14 +676,12 @@ struct strangeness_in_jets { 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 = TMath::Abs(phi1 - phi2); @@ -783,327 +743,508 @@ struct strangeness_in_jets { return; } - void processData(SelCollisions::iterator const& collision, aod::V0Datas const& fullV0s, aod::CascDataExt const& Cascades, aod::V0sLinked const& /*V0linked*/, FullTracks const& tracks) + 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 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); - if (abs(collision.posZ()) > zVtx) + + // 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); - // Find Leading Particle - std::vector particle_ID; - int leading_ID(0); - float ptMax(0); + // List of Tracks + std::vector trk; - // Track Index - int i = -1; for (auto track : tracks) { - i++; - if (!passedTrackSelectionForJets(track)) + if (!passedTrackSelectionForJetReconstruction(track)) continue; - if (track.pt() > ptMax) { - leading_ID = i; - ptMax = track.pt(); - } - particle_ID.push_back(i); + TVector3 momentum(track.px(), track.py(), track.pz()); + trk.push_back(momentum); } - if (ptMax < ptLeadingMin) - return; - registryData.fill(HIST("number_of_events_data"), 3.5); - - auto const& leading_track = tracks.iteratorAt(leading_ID); - TVector3 p_leading(leading_track.px(), leading_track.py(), leading_track.pz()); - int nParticles = static_cast(particle_ID.size()); + // Anti-kt Jet Finder + int n_particles_removed(0); + std::vector jet; + std::vector ue1; + std::vector ue2; - // Jet Finder - int exit(0); - int nPartAssociated(0); do { - // Initialization - float distance_jet_min(1e+08); - float distance_bkg_min(1e+08); - int label_jet_particle(0); - int i_jet_particle(0); - - for (int i = 0; i < nParticles; i++) { - - // Skip Leading Particle & Elements already associated to the Jet - if (particle_ID[i] == leading_ID || particle_ID[i] == -1) + 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; - - // Get Particle Momentum - auto stored_track = tracks.iteratorAt(particle_ID[i]); - TVector3 p_particle(stored_track.px(), stored_track.py(), stored_track.pz()); - - // Variables - float one_over_pt2_part = 1.0 / (p_particle.Pt() * p_particle.Pt()); - float one_over_pt2_lead = 1.0 / (p_leading.Pt() * p_leading.Pt()); - float deltaEta = p_particle.Eta() - p_leading.Eta(); - float deltaPhi = GetDeltaPhi(p_particle.Phi(), p_leading.Phi()); - float min = Minimum(one_over_pt2_part, one_over_pt2_lead); - float Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; - - // Distances - float distance_jet = min * Delta2 / (Rjet * Rjet); - float distance_bkg = one_over_pt2_part; - - // Find Minimum Distance Jet - if (distance_jet < distance_jet_min) { - distance_jet_min = distance_jet; - label_jet_particle = particle_ID[i]; - i_jet_particle = i; + double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); + if (diB < diB_min) { + diB_min = diB; + iB_min = i; } - - // Find Minimum Distance Bkg - if (distance_bkg < distance_bkg_min) { - distance_bkg_min = distance_bkg; + 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 (distance_jet_min <= distance_bkg_min) { + if ((TMath::Abs(jet[i].Eta()) + Rjet) > etaMax) + continue; - // Add Particle to Jet - // jet_particle_ID.push_back(label_jet_particle); + // 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); - // Update Momentum of Leading Particle - auto jet_track = tracks.iteratorAt(label_jet_particle); - TVector3 p_i(jet_track.px(), jet_track.py(), jet_track.pz()); - p_leading = p_leading + p_i; + for (auto track : tracks) { - // Remove Element - particle_ID[i_jet_particle] = -1; - nPartAssociated++; + 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_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 (nPartAssociated >= (nParticles - 1)) - exit = 1; - if (distance_jet_min > distance_bkg_min) - exit = 2; + if (n_jets_selected == 0) + return; + registryData.fill(HIST("number_of_events_data"), 3.5); - } while (exit == 0); + // Overlaps + int nOverlaps(0); + for (int i = 0; i < static_cast(jet.size()); i++) { + if (isSelected[i] == 0) + continue; - // Jet Axis - TVector3 jet_axis(p_leading.X(), p_leading.Y(), p_leading.Z()); + 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); - // Cut events with jet not fully inside acceptance - if ((abs(jet_axis.Eta()) + Rmax) > etaMax) + if (n_jets_selected > n_jets_per_event_max) return; registryData.fill(HIST("number_of_events_data"), 4.5); - // Perpendicular Cones for UE - TVector3 ue_axis1(0.0, 0.0, 0.0); - TVector3 ue_axis2(0.0, 0.0, 0.0); - get_perpendicular_axis(jet_axis, ue_axis1, +1.0); - get_perpendicular_axis(jet_axis, ue_axis2, -1.0); - - // Protection against delta<0 - if (ue_axis1.X() == 0 && ue_axis1.Y() == 0 && ue_axis1.Z() == 0) - return; - if (ue_axis2.X() == 0 && ue_axis2.Y() == 0 && ue_axis2.Z() == 0) + if (requireNoOverlap && nOverlaps > 0) return; registryData.fill(HIST("number_of_events_data"), 5.5); // Event multiplicity float multiplicity = collision.centFT0M(); - // Vzeros - if (particle_of_interest == option::vzeros) { - for (auto& v0 : fullV0s) { + registryData.fill(HIST("number_of_events_vsmultiplicity"), multiplicity); - const auto& pos = v0.posTrack_as(); - const auto& neg = v0.negTrack_as(); - TVector3 v0dir(v0.px(), v0.py(), v0.pz()); + for (int i = 0; i < static_cast(jet.size()); i++) { - float deltaEta_jet = v0dir.Eta() - jet_axis.Eta(); - float deltaPhi_jet = GetDeltaPhi(v0dir.Phi(), jet_axis.Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = v0dir.Eta() - ue_axis1.Eta(); - float deltaPhi_ue1 = GetDeltaPhi(v0dir.Phi(), ue_axis1.Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = v0dir.Eta() - ue_axis2.Eta(); - float deltaPhi_ue2 = GetDeltaPhi(v0dir.Phi(), ue_axis2.Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); + if (isSelected[i] == 0) + continue; - // K0s - if (passedK0ShortSelection(v0, pos, neg)) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("K0s_in_jet"), multiplicity, v0.pt(), v0.mK0Short()); + // Vzeros + if (particle_of_interest == option::vzeros) { + for (auto& v0 : fullV0s) { + + 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 = 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 = 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 = 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()); + } } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - 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()); + } } } - // Lambda - if (passedLambdaSelection(v0, pos, neg)) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("Lambda_in_jet"), multiplicity, v0.pt(), v0.mLambda()); + } + + // Cascades + if (particle_of_interest == option::cascades) { + for (auto& casc : Cascades) { + + 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 = 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 = 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 = 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()); + } } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("Lambda_in_ue"), multiplicity, v0.pt(), v0.mLambda()); + // 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()); + } } - } - // AntiLambda - if (passedAntiLambdaSelection(v0, pos, neg)) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("AntiLambda_in_jet"), multiplicity, v0.pt(), v0.mAntiLambda()); + // 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()); + } } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("AntiLambda_in_ue"), multiplicity, v0.pt(), v0.mAntiLambda()); + // 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()); + } } } } - } - // Cascades - if (particle_of_interest == option::cascades) { - for (auto& casc : Cascades) { - - 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_axis.Eta(); - float deltaPhi_jet = GetDeltaPhi(cascade_dir.Phi(), jet_axis.Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = cascade_dir.Eta() - ue_axis1.Eta(); - float deltaPhi_ue1 = GetDeltaPhi(cascade_dir.Phi(), ue_axis1.Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = cascade_dir.Eta() - ue_axis2.Eta(); - float deltaPhi_ue2 = GetDeltaPhi(cascade_dir.Phi(), ue_axis2.Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); + // Pions + if (particle_of_interest == option::pions) { + for (auto track : tracks) { - // Xi+ - if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() > 0) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("XiPos_in_jet"), multiplicity, casc.pt(), casc.mXi()); + 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 = 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 = 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 = 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 (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("XiPos_in_ue"), multiplicity, casc.pt(), casc.mXi()); + 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()); } - } - // Xi- - if (passedXiSelection(casc, pos, neg, bach, collision) && bach.sign() < 0) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("XiNeg_in_jet"), multiplicity, casc.pt(), casc.mXi()); + + // DCAxy Selection + if (TMath::Abs(track.dcaXY()) > dcaxyMax) + continue; + + // TPC + if (isInJet && track.sign() > 0) { + registryData.fill(HIST("piplus_tpc_in_jet"), multiplicity, track.pt(), track.tpcNSigmaPi()); } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("XiNeg_in_ue"), multiplicity, casc.pt(), casc.mXi()); + if (isInUe && track.sign() > 0) { + registryData.fill(HIST("piplus_tpc_in_ue"), multiplicity, track.pt(), track.tpcNSigmaPi()); } - } - // Omega+ - if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() > 0) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("OmegaPos_in_jet"), multiplicity, casc.pt(), casc.mOmega()); + if (isInJet && track.sign() < 0) { + registryData.fill(HIST("piminus_tpc_in_jet"), multiplicity, track.pt(), track.tpcNSigmaPi()); } - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("OmegaPos_in_ue"), multiplicity, casc.pt(), casc.mOmega()); + if (isInUe && track.sign() < 0) { + registryData.fill(HIST("piminus_tpc_in_ue"), multiplicity, track.pt(), track.tpcNSigmaPi()); } - } - // Omega- - if (passedOmegaSelection(casc, pos, neg, bach, collision) && bach.sign() < 0) { - if (deltaR_jet < Rmax) { - registryData.fill(HIST("OmegaNeg_in_jet"), multiplicity, casc.pt(), casc.mOmega()); + 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 (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) { - registryData.fill(HIST("OmegaNeg_in_ue"), multiplicity, casc.pt(), casc.mOmega()); + 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); - // Pions - if (particle_of_interest == option::pions) { - for (auto track : tracks) { + 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 (TMath::Abs(collision.posZ()) > zVtx) + return; + registryData.fill(HIST("number_of_events_data"), 12.5); - if (!passedTrackSelectionForPions(track)) - continue; + for (auto& v0 : fullV0s) { + const auto& ptrack = v0.posTrack_as(); + const auto& ntrack = v0.negTrack_as(); - TVector3 track_dir(track.px(), track.py(), track.pz()); - float deltaEta_jet = track_dir.Eta() - jet_axis.Eta(); - float deltaPhi_jet = GetDeltaPhi(track_dir.Phi(), jet_axis.Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = track_dir.Eta() - ue_axis1.Eta(); - float deltaPhi_ue1 = GetDeltaPhi(track_dir.Phi(), ue_axis1.Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = track_dir.Eta() - ue_axis2.Eta(); - float deltaPhi_ue2 = GetDeltaPhi(track_dir.Phi(), ue_axis2.Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - bool isInJet = false; - bool isInUe = false; - if (deltaR_jet < Rmax) - isInJet = true; - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) - 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()); - } + registryQC.fill(HIST("survivedK0"), 0.5); - // DCAxy Selection - if (TMath::Abs(track.dcaXY()) > dcaxyMax) - continue; + // Single-Track Selections + if (!passedSingleTrackSelection(ptrack)) + continue; + registryQC.fill(HIST("survivedK0"), 1.5); - // 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()) + 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 (TMath::Abs(v0.dcapostopv()) < dcapostoPVmin) + continue; + registryQC.fill(HIST("survivedK0"), 10.5); + + if (TMath::Abs(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); - // 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()); - } + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + continue; + registryQC.fill(HIST("survivedK0"), 15.5); } } + + for (auto& v0 : fullV0s) { + 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, processData, "Process data", true); + 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, aod::McCollisions const& /*mcCollisions*/, const aod::McParticles& mcParticles) + 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) { registryMC.fill(HIST("number_of_events_mc"), 0.5); @@ -1111,7 +1252,7 @@ struct strangeness_in_jets { continue; registryMC.fill(HIST("number_of_events_mc"), 1.5); - if (abs(collision.posZ()) > 10.0) + if (TMath::Abs(collision.posZ()) > 10.0) continue; registryMC.fill(HIST("number_of_events_mc"), 2.5); @@ -1151,7 +1292,6 @@ struct strangeness_in_jets { if (pdg_parent == 0) continue; - // K0s if (passedK0ShortSelection(v0, pos, neg) && pdg_parent == 310) { registryMC.fill(HIST("K0s_reconstructed_incl"), multiplicity, v0.pt()); } @@ -1164,7 +1304,6 @@ struct strangeness_in_jets { if (!isPhysPrim) continue; - // K0s if (passedK0ShortSelection(v0, pos, neg) && pdg_parent == 310) { registryMC.fill(HIST("K0s_reconstructed"), multiplicity, v0.pt()); } @@ -1205,7 +1344,7 @@ struct strangeness_in_jets { for (auto& particleMotherOfBach : bachParticle.mothers_as()) { if (particleMotherOfNeg != particleMotherOfPos) continue; - if (abs(particleMotherOfNeg.pdgCode()) != 3122) + if (TMath::Abs(particleMotherOfNeg.pdgCode()) != 3122) continue; if (!particleMotherOfBach.isPhysicalPrimary()) continue; @@ -1245,7 +1384,7 @@ struct strangeness_in_jets { continue; const auto particle = track.mcParticle(); - if (abs(particle.pdgCode()) != 211) + if (TMath::Abs(particle.pdgCode()) != 211) continue; if (particle.isPhysicalPrimary()) { @@ -1254,7 +1393,6 @@ struct strangeness_in_jets { 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()); @@ -1289,7 +1427,7 @@ struct strangeness_in_jets { for (auto& mcParticle : mcParticles_per_coll) { - if (mcParticle.y() < yMin || mcParticle.y() > yMax) + if (mcParticle.eta() < etaMin || mcParticle.eta() > etaMax) continue; if (!mcParticle.isPhysicalPrimary()) continue; @@ -1342,215 +1480,257 @@ struct strangeness_in_jets { } PROCESS_SWITCH(strangeness_in_jets, processMCefficiency, "Process MC Efficiency", false); - void processWeights(SimCollisions const& collisions, aod::McParticles const& mcParticles) + void processGen(o2::aod::McCollisions const& mcCollisions, aod::McParticles const& mcParticles) { - // Loop over MC Collisions - for (const auto& collision : collisions) { + for (const auto& mccollision : mcCollisions) { + + registryMC.fill(HIST("number_of_events_mc"), 3.5); // Selection on z_{vertex} - if (abs(collision.posZ()) > 10) + if (TMath::Abs(mccollision.posZ()) > 10) continue; + registryMC.fill(HIST("number_of_events_mc"), 4.5); // MC Particles per Collision - auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, collision.globalIndex()); + auto mcParticles_per_coll = mcParticles.sliceBy(perMCCollision, mccollision.globalIndex()); - std::vector particle_ID; - int leading_ID = 0; - float pt_max(0); - int i = -1; + // List of Tracks + std::vector trk; for (auto& particle : mcParticles_per_coll) { - // Global Index - // int i = particle.globalIndex(); - i++; + int pdg = TMath::Abs(particle.pdgCode()); + + if (particle.isPhysicalPrimary() && pdg == 211) { + registryMC.fill(HIST("Pion_eta_pt_pythia"), particle.pt(), particle.eta()); + } + if (particle.isPhysicalPrimary() && pdg == 310) { + registryMC.fill(HIST("K0s_eta_pt_pythia"), particle.pt(), particle.eta()); + } + if (particle.isPhysicalPrimary() && pdg == 3122) { + registryMC.fill(HIST("Lambda_eta_pt_pythia"), particle.pt(), particle.eta()); + } + if (particle.isPhysicalPrimary() && pdg == 3312) { + registryMC.fill(HIST("Xi_eta_pt_pythia"), particle.pt(), particle.eta()); + } + if (particle.isPhysicalPrimary() && pdg == 3334) { + registryMC.fill(HIST("Omega_eta_pt_pythia"), particle.pt(), particle.eta()); + } // Select Primary Particles - float deltaX = particle.vx() - collision.posX(); - float deltaY = particle.vy() - collision.posY(); - float deltaZ = particle.vz() - collision.posZ(); - float deltaR = sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); - if (deltaR > 0.1) + 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 (particle.pt() < 0.15) continue; - - // Pseudorapidity Selection - if (abs(particle.eta()) > 0.8) + if (dcaxy > (par0 + par1 / particle.pt())) continue; - - if (particle.pt() < 0.15) + if (dcaz > (par0 + par1 / particle.pt())) + continue; + if (TMath::Abs(particle.eta()) > 0.8) continue; // PDG Selection - int pdg = abs(particle.pdgCode()); if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) continue; - // Find pt Leading - if (particle.pt() > pt_max) { - leading_ID = i; - pt_max = particle.pt(); - } - - // Store Array Element - particle_ID.push_back(i); + TVector3 momentum(particle.px(), particle.py(), particle.pz()); + trk.push_back(momentum); } - // Skip Events with pt(particle_ID.size()); + // Anti-kt Jet Finder + int n_particles_removed(0); + std::vector jet; + std::vector ue1; + std::vector ue2; - // Momentum of the Leading Particle - auto const& leading_track = mcParticles_per_coll.iteratorAt(leading_ID); - TVector3 p_leading(leading_track.px(), leading_track.py(), leading_track.pz()); - registryQC.fill(HIST("deltaPt_leading"), pt_max - leading_track.pt()); - - // Labels - int exit(0); - int nPartAssociated(0); - - // Jet Finder do { - // Initialization - float distance_jet_min(1e+08); - float distance_bkg_min(1e+08); - int label_jet_particle(0); - int i_jet_particle(0); - - for (int i = 0; i < nParticles; i++) { - - // Skip Leading Particle & Elements already associated to the Jet - if (particle_ID[i] == leading_ID || particle_ID[i] == -1) + 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; - - // Get Particle Momentum - auto stored_track = mcParticles_per_coll.iteratorAt(particle_ID[i]); - TVector3 p_particle(stored_track.px(), stored_track.py(), stored_track.pz()); - - // Variables - float one_over_pt2_part = 1.0 / (p_particle.Pt() * p_particle.Pt()); - float one_over_pt2_lead = 1.0 / (p_leading.Pt() * p_leading.Pt()); - float deltaEta = p_particle.Eta() - p_leading.Eta(); - float deltaPhi = GetDeltaPhi(p_particle.Phi(), p_leading.Phi()); - float min = Minimum(one_over_pt2_part, one_over_pt2_lead); - float Delta2 = deltaEta * deltaEta + deltaPhi * deltaPhi; - - // Distances - float distance_jet = min * Delta2 / (Rjet * Rjet); - float distance_bkg = one_over_pt2_part; - - // Find Minimum Distance Jet - if (distance_jet < distance_jet_min) { - distance_jet_min = distance_jet; - label_jet_particle = particle_ID[i]; - i_jet_particle = i; + double diB = 1.0 / (trk[i].Pt() * trk[i].Pt()); + if (diB < diB_min) { + diB_min = diB; + iB_min = i; } - - // Find Minimum Distance Bkg - if (distance_bkg < distance_bkg_min) { - distance_bkg_min = distance_bkg; + 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 (distance_jet_min <= distance_bkg_min) { - - // Add Particle to Jet - // jet_particle_ID.push_back(label_jet_particle); - - // Update Momentum of Leading Particle - auto jet_track = mcParticles_per_coll.iteratorAt(label_jet_particle); - TVector3 p_i(jet_track.px(), jet_track.py(), jet_track.pz()); - p_leading = p_leading + p_i; - - // Remove Element - particle_ID[i_jet_particle] = -1; - nPartAssociated++; + 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())); - if (nPartAssociated >= (nParticles - 1)) - exit = 1; - if (distance_jet_min > distance_bkg_min) - exit = 2; - - } while (exit == 0); - - // Jet Axis - TVector3 jet_axis(p_leading.X(), p_leading.Y(), p_leading.Z()); + // Jet Selection + std::vector isSelected; + for (int i = 0; i < static_cast(jet.size()); i++) { + isSelected.push_back(0); + } - if ((abs(jet_axis.Eta()) + Rmax) > etaMax) - return; + int n_jets_selected(0); + for (int i = 0; i < static_cast(jet.size()); i++) { - // Perpendicular Cones for UE - TVector3 ue_axis1(0.0, 0.0, 0.0); - TVector3 ue_axis2(0.0, 0.0, 0.0); - get_perpendicular_axis(jet_axis, ue_axis1, +1.0); - get_perpendicular_axis(jet_axis, ue_axis2, -1.0); + if ((TMath::Abs(jet[i].Eta()) + Rjet) > etaMax) + continue; - // Protection against delta<0 - if (ue_axis1.X() == 0 && ue_axis1.Y() == 0 && ue_axis1.Z() == 0) - return; - if (ue_axis2.X() == 0 && ue_axis2.Y() == 0 && ue_axis2.Z() == 0) - return; + // 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 (particle.pt() < 0.15) + continue; + if (dcaxy > (par0 + par1 / particle.pt())) + continue; + if (dcaz > (par0 + par1 / particle.pt())) + continue; + if (TMath::Abs(particle.eta()) > 0.8) + continue; - // Generated Particles - for (auto& particle : mcParticles_per_coll) { + // PDG Selection + int pdg = TMath::Abs(particle.pdgCode()); + if ((pdg != 11) && (pdg != 211) && (pdg != 321) && (pdg != 2212)) + continue; - // PDG Selection - int pdg = particle.pdgCode(); + 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 (!particle.isPhysicalPrimary()) + if (ptJet < min_jet_pt) continue; - if (particle.y() < yMin || particle.y() > yMax) + if (nPartJetPlusUE < min_nPartInJet) continue; + n_jets_selected++; + isSelected[i] = 1; + } + if (n_jets_selected == 0) + continue; - TVector3 p_particle(particle.px(), particle.py(), particle.pz()); - float deltaEta_jet = p_particle.Eta() - jet_axis.Eta(); - float deltaPhi_jet = GetDeltaPhi(p_particle.Phi(), jet_axis.Phi()); - float deltaR_jet = sqrt(deltaEta_jet * deltaEta_jet + deltaPhi_jet * deltaPhi_jet); - float deltaEta_ue1 = p_particle.Eta() - ue_axis1.Eta(); - float deltaPhi_ue1 = GetDeltaPhi(p_particle.Phi(), ue_axis1.Phi()); - float deltaR_ue1 = sqrt(deltaEta_ue1 * deltaEta_ue1 + deltaPhi_ue1 * deltaPhi_ue1); - float deltaEta_ue2 = p_particle.Eta() - ue_axis2.Eta(); - float deltaPhi_ue2 = GetDeltaPhi(p_particle.Phi(), ue_axis2.Phi()); - float deltaR_ue2 = sqrt(deltaEta_ue2 * deltaEta_ue2 + deltaPhi_ue2 * deltaPhi_ue2); - - // Fill K0s - if (abs(pdg) == 310) { - if (deltaR_jet < Rmax) - registryMC.fill(HIST("K0s_eta_pt_jet"), particle.pt(), particle.eta()); - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) - registryMC.fill(HIST("K0s_eta_pt_ue"), particle.pt(), particle.eta()); - } + for (int i = 0; i < static_cast(jet.size()); i++) { - // Fill Lambda - if (abs(pdg) == 3122) { - if (deltaR_jet < Rmax) - registryMC.fill(HIST("Lambda_eta_pt_jet"), particle.pt(), particle.eta()); - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) - registryMC.fill(HIST("Lambda_eta_pt_ue"), particle.pt(), particle.eta()); - } + if (isSelected[i] == 0) + continue; - // Fill Xi - if (abs(pdg) == 3312) { - if (deltaR_jet < Rmax) - registryMC.fill(HIST("Xi_eta_pt_jet"), particle.pt(), particle.eta()); - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) - registryMC.fill(HIST("Xi_eta_pt_ue"), particle.pt(), particle.eta()); - } + // Generated Particles + for (auto& particle : mcParticles_per_coll) { - // Fill Omega - if (abs(pdg) == 3334) { - if (deltaR_jet < Rmax) - registryMC.fill(HIST("Omega_eta_pt_jet"), particle.pt(), particle.eta()); - if (deltaR_ue1 < Rmax || deltaR_ue2 < Rmax) - registryMC.fill(HIST("Omega_eta_pt_ue"), particle.pt(), particle.eta()); + 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 = 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); + + int pdg = TMath::Abs(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 == 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 == 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()); + } + } } } } } - PROCESS_SWITCH(strangeness_in_jets, processWeights, "Process Weights", false); + PROCESS_SWITCH(strangeness_in_jets, processGen, "Process generated MC", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGLF/Tasks/Strangeness/v0postprocessing.cxx b/PWGLF/Tasks/Strangeness/v0postprocessing.cxx index 1844390a3da..d66f2814e1e 100644 --- a/PWGLF/Tasks/Strangeness/v0postprocessing.cxx +++ b/PWGLF/Tasks/Strangeness/v0postprocessing.cxx @@ -42,11 +42,14 @@ 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 isMC{"isMC", 1, "isMC"}; Configurable evSel{"evSel", 1, "evSel"}; Configurable hasTOF2Leg{"hasTOF2Leg", 0, "hasTOF2Leg"}; Configurable hasTOF1Leg{"hasTOF1Leg", 1, "hasTOF1Leg"}; + Configurable paramArmenterosCut{"paramArmenterosCut", 0.2, "parameter Armenteros Cut"}; + Configurable doArmenterosCut{"doArmenterosCut", 1, "do Armenteros Cut"}; HistogramRegistry registry{"registry"}; @@ -66,14 +69,16 @@ 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}, {200, 0.4f, 0.6f}, {100, 0.f, 100.f}}}); + 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("hMassLambda_MC", "hMassLambda", {HistType::kTH1F, {{200, 1.016f, 1.216f}}}); - registry.add("hMassVsPtLambda_MC", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {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("hMassAntiLambda_MC", "hMassAntiLambda", {HistType::kTH1F, {{200, 1.016f, 1.216f}}}); - registry.add("hMassVsPtAntiLambda_MC", "hMassVsPtAntiLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {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}}}); } // 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}}}); @@ -85,38 +90,34 @@ struct v0postprocessing { 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("hLambdaTPCNSigmaPosPi", "hLambdaTPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hLambdaTPCNSigmaNegPi", "hLambdaTPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hLambdaTPCNSigmaNegPr", "hLambdaTPCNSigmaNegPr", {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("hAntiLambdaTPCNSigmaNegPi", "hAntiLambdaTPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hAntiLambdaTPCNSigmaNegPr", "hAntiLambdaTPCNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); - registry.add("hAntiLambdaTPCNSigmaPosPr", "hAntiLambdaTPCNSigmaPosPr", {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}}}); */ + 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}}}); */ } void process(aod::MyV0Candidates const& myv0s) @@ -136,10 +137,6 @@ struct v0postprocessing { continue; if (candidate.v0dcav0daughters() > dcav0dau) continue; - if (TMath::Abs(candidate.ntpcsigmanegpi()) > ntpcsigma) - continue; - if (TMath::Abs(candidate.ntpcsigmapospi()) > ntpcsigma) - continue; if (evSel && candidate.evflag() < 1) continue; if (hasTOF1Leg && !candidate.poshastof() && !candidate.neghastof()) @@ -152,57 +149,88 @@ struct v0postprocessing { 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) { - - 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()); + 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()); + } } } // Lambda analysis - /* if (candidate.v0cospa() > cospaLambda && - TMath::Abs(candidate.raplambda()) < rap && - candidate.ctaulambda() < ctauK0s && - TMath::Abs(candidate.masslambda() - o2::constants::physics::MassLambda0) < 0.075 && - TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) > v0rejLambda) { - - registry.fill(HIST("hMassLambda"), candidate.masslambda()); - registry.fill(HIST("hMassVsPtLambda"), candidate.v0pt(), candidate.masslambda()); - registry.fill(HIST("hMassVsPtLambdaVsCentFT0M"), candidate.v0pt(), candidate.multft0m(), candidate.masslambda()); - registry.fill(HIST("hMassVsPtLambdaVsCentFV0A"), candidate.v0pt(), candidate.multfv0a(), 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("hLambdaTPCNSigmaPosPi"), candidate.ntpcsigmapospi()); - registry.fill(HIST("hLambdaTPCNSigmaPosPr"), candidate.ntpcsigmapospr()); - registry.fill(HIST("hLambdaTPCNSigmaNegPi"), candidate.ntpcsigmanegpi()); - registry.fill(HIST("hLambdaTPCNSigmaNegPr"), candidate.ntpcsigmanegpr()); - } - } - */ + if (candidate.v0cospa() > cospaLambda && + TMath::Abs(candidate.raplambda()) < rap && + TMath::Abs(candidate.massk0short() - o2::constants::physics::MassK0Short) > v0rejLambda) { + + // Lambda + if (TMath::Abs(candidate.ntpcsigmanegpi()) <= ntpcsigma && TMath::Abs(candidate.ntpcsigmapospr()) <= ntpcsigma && + candidate.ctaulambda() < ctauLambda && + TMath::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()); + } + } + // AntiLambda + if (TMath::Abs(candidate.ntpcsigmanegpr()) <= ntpcsigma && TMath::Abs(candidate.ntpcsigmapospi()) <= ntpcsigma && + candidate.ctauantilambda() < ctauLambda && + TMath::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 (isMC) { if (candidate.isphysprimary() == 0) @@ -214,23 +242,77 @@ struct v0postprocessing { 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("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()); - } - } + 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()); + } + // 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()); + } + } // lambda + } // is MC } } }; diff --git a/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx b/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx new file mode 100644 index 00000000000..10049865bb5 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/v0ptinvmassplots.cxx @@ -0,0 +1,367 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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) + +/*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*/ + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/DataModel/PIDResponse.h" + +// 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; +} // namespace pthistos +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +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}; + + // 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"}; + + // 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 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"}; + + void init(InitContext const&) + { + // 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})"}; + + rPtAnalysis.add("hV0PtAll", "hV0PtAll", {HistType::kTH1F, {{nBins, 0.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}}}); + } + } + // Adding Lambda Histograms + if (lambda_analysis == 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}}}); + } + } + // Adding Antilambda Histograms + if (antilambda_analysis == 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}}}); + } + } + } + + // 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); + + // Defining the type of the daughter tracks + 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) + { + for (const auto& mcParticle : mcParticles) { + if (mcParticle.isPhysicalPrimary()) { + if (TMath::Abs(mcParticle.y()) < 0.5f) { + if (mcParticle.pdgCode() == 310) // kzero matched + { + rPtAnalysis.fill(HIST("hK0ShGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == 3122) // lambda matched + { + rPtAnalysis.fill(HIST("hLambdaGeneratedPtSpectrum"), mcParticle.pt()); + } + if (mcParticle.pdgCode() == -3122) // antilambda matched + { + rPtAnalysis.fill(HIST("hAntilambdaGeneratedPtSpectrum"), mcParticle.pt()); + } + } + } + } + } + // This is the Process for the MC reconstructed Data + void RecMCprocess(soa::Filtered>::iterator const&, + 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) + { + 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(); + 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 + } + } + } + } + } + // 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()); + } + } + } + } + } + // 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()); + } + } + } + } + } + } + } + } + } + // This is the process for Real Data + void Dataprocess(soa::Filtered>::iterator const&, + aod::V0Datas const& V0s) + { + for (const auto& v0 : V0s) { + // 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()); + } + } + } + } + // 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()); + } + } + } + } + // 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()); + } + } + } + } + } + } + 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); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx b/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx new file mode 100644 index 00000000000..6fa5c8a8b82 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/v0topologicalcuts.cxx @@ -0,0 +1,605 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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) + +/*Description +This task creates <=20 histograms (for each of the 5 different V0 topological cuts, namely cosPointingAngle, +DCA[between]V0daughters, v0radius,DCA-positive[daughter]to-primary-vertex and DCA-negative[daughter]to-primary-vertex) +that are filled with the V0 invariant mass under the K0, Lambda and Antilambda mass assumption +(so 20cutsx5parametersx3particles=300 mass invariant plots).It also produces plots of the topological parameters themselves. +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 +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "CommonUtils/StringUtils.h" + +// 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 dcaCut[20]; +static std::vector dcacuts; +std::shared_ptr v0radiusCut[20]; +static std::vector v0radiuscuts; +std::shared_ptr dcapostopCut[20]; +static std::vector dcapostopvcuts; +std::shared_ptr dcanegtopCut[20]; +static std::vector dcanegtopvcuts; +} // namespace cuthistoskzerosh +namespace cuthistoslambda +{ +std::shared_ptr cospaCut[20]; +static std::vector cospacuts; +std::shared_ptr dcaCut[20]; +static std::vector dcacuts; +std::shared_ptr v0radiusCut[20]; +static std::vector v0radiuscuts; +std::shared_ptr dcapostopCut[20]; +static std::vector dcapostopvcuts; +std::shared_ptr dcanegtopCut[20]; +static std::vector dcanegtopvcuts; +} // namespace cuthistoslambda +namespace cuthistosantilambda +{ +std::shared_ptr cospaCut[20]; +static std::vector cospacuts; +std::shared_ptr dcaCut[20]; +static std::vector dcacuts; +std::shared_ptr v0radiusCut[20]; +static std::vector v0radiuscuts; +std::shared_ptr dcapostopCut[20]; +static std::vector dcapostopvcuts; +std::shared_ptr dcanegtopCut[20]; +static std::vector dcanegtopvcuts; +} // namespace cuthistosantilambda +using namespace o2; +using namespace o2::framework; +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}; + // 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}; + // 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}; + // 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}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // 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 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 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"}; + + void init(InitContext const&) + { + // kzero filling namespace with configurable strings + + // 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, ','); + + // 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, ','); + + // 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, ','); + + // 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}]"}; + + // 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::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}}}); + } + 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}}}); + } + 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}}}); + } + 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}}}); + } + 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::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}}}); + } + 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}}}); + } + 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}}}); + } + 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}}}); + } + + 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::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}}}); + } + 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}}}); + } + 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}}}); + } + 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}}}); + } + + // 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}}}); + + // 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}}}); + + // 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}}}); + + // 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}}}); + + // 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}}}); + } + + // Defining filters for events (event selection) + // Processed events will be already fulfilling the event selection requirements + Filter eventFilter = (o2::aod::evsel::sel8 == true); + + // Defining the type of the daughter tracks + using DaughterTracks = soa::Join; + + // This is the Process for the MC reconstructed Data + void RecMCprocess(soa::Filtered>::iterator const&, + soa::Join const& V0s, + DaughterTracks const&, // no need to define a variable for tracks, if we don't access them directly + aod::McParticles const&) + { + for (const auto& v0 : V0s) { + + // 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 + + 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::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()); + } + } + } + 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())); + + // 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 (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()); + } + } + } + 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()); + } + } + 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()); + } + } + } + } + } + } + // 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); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGLF/Utils/collisionCuts.h b/PWGLF/Utils/collisionCuts.h index 7a1a018789d..8d1e563d427 100644 --- a/PWGLF/Utils/collisionCuts.h +++ b/PWGLF/Utils/collisionCuts.h @@ -44,6 +44,7 @@ class CollisonCuts kFlagVertexITSTPC, kFlagBunchPileup, kFlagZvtxFT0vsPV, + kFlagOccupancy, kAllpassed }; @@ -57,7 +58,7 @@ class CollisonCuts /// \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) + void setCuts(float zvtxMax, bool checkTrigger, int trig, bool checkOffline, bool checkRun3, bool triggerTVXsel = false, int trackOccupancyInTimeRangeMax = -1) { mCutsSet = true; mZvtxMax = zvtxMax; @@ -71,6 +72,7 @@ class CollisonCuts mApplyZvertexTimedifference = false; mApplyPileupRejection = false; mApplyNoITSROBorderCut = false; + mtrackOccupancyInTimeRangeMax = trackOccupancyInTimeRangeMax; } /// Initializes histograms for the task @@ -90,27 +92,29 @@ class CollisonCuts mHistogramRegistry->add("Event/CentFT0A", "; vCentT0A; Entries", kTH1F, {{110, 0, 110}}); mHistogramRegistry->add("Event/posZ_ITSOnly", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); mHistogramRegistry->add("Event/posZ_ITSTPC", "; vtx_{z} (cm); Entries", kTH1F, {{250, -12.5, 12.5}}); - mHistogramRegistry->add("CollCutCounts", "; ; Entries", kTH1F, {{10, 0., 10.}}); - 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"); - mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagTimeFrameBorder), "NoTimeFrameBorder"); - mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagITSROFrameBorder), "NoITSROFrameBorder"); - mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagSel8), "sel8"); - mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagVertexITSTPC), "IsVertexITSTPC"); - 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::kAllpassed), "Allpassed"); + mHistogramRegistry->add("Event/trackOccupancyInTimeRange_noCut", "; Occupancy; Entries", kTH1F, {{500, 0., 20000.}}); } else { mHistogramRegistry->add("Event/CentRun2V0M", "; vCentV0M; Entries", kTH1F, {{110, 0, 110}}); } + mHistogramRegistry->add("CollCutCounts", "; ; Entries", kTH1F, {{11, 0., 11.}}); + 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"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagTimeFrameBorder), "NoTimeFrameBorder"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagITSROFrameBorder), "NoITSROFrameBorder"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagSel8), "sel8"); + mHistogramRegistry->get(HIST("CollCutCounts"))->GetXaxis()->SetBinLabel(binLabel(EvtSel::kFlagVertexITSTPC), "IsVertexITSTPC"); + 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::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", - mZvtxMax, mCheckTrigger, mTrigger, mCheckOffline, mCheckIsRun3, mTriggerTVXselection, mApplyTFBorderCut, mApplyITSTPCvertex, mApplyZvertexTimedifference, mApplyPileupRejection, mApplyNoITSROBorderCut); + 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", + mZvtxMax, mCheckTrigger, mTrigger, mCheckOffline, mCheckIsRun3, mTriggerTVXselection, mApplyTFBorderCut, mApplyITSTPCvertex, mApplyZvertexTimedifference, mApplyPileupRejection, mApplyNoITSROBorderCut, mtrackOccupancyInTimeRangeMax); } /// Set MB selection @@ -142,6 +146,9 @@ class CollisonCuts bool isSelected(T const& col) { mHistogramRegistry->fill(HIST("Event/posZ_noCut"), col.posZ()); + if (mCheckIsRun3) { + mHistogramRegistry->fill(HIST("Event/trackOccupancyInTimeRange_noCut"), col.trackOccupancyInTimeRange()); + } mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kAllEvent); if (std::abs(col.posZ()) > mZvtxMax) { LOGF(debug, "Vertex out of range"); @@ -184,11 +191,17 @@ class CollisonCuts return false; } mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagZvtxFT0vsPV); + if (mtrackOccupancyInTimeRangeMax > 0 && col.trackOccupancyInTimeRange() > mtrackOccupancyInTimeRangeMax) { + LOGF(debug, "trackOccupancyInTimeRange selection failed"); + return false; + } + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagOccupancy); } else { // Run2 case if (mCheckOffline && !col.sel7()) { LOGF(debug, "Offline selection failed (sel7)"); return false; } + mHistogramRegistry->fill(HIST("CollCutCounts"), EvtSel::kFlagTrigerTVX); } if (mCheckTrigger && !col.alias_bit(mTrigger)) { LOGF(debug, "Trigger selection failed"); @@ -254,6 +267,7 @@ class CollisonCuts bool mApplyNoITSROBorderCut = false; ///< Apply NoITSRO frame border cut 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) }; } // namespace o2::analysis diff --git a/PWGLF/Utils/inelGt.h b/PWGLF/Utils/inelGt.h index f0a3514adc1..2ed513a902c 100644 --- a/PWGLF/Utils/inelGt.h +++ b/PWGLF/Utils/inelGt.h @@ -137,10 +137,10 @@ struct ParticleCounter { } // is neutral if (requireNeutral) { - if (abs(p->Charge()) > 1e-3) + if (std::abs(p->Charge()) > 1e-3) continue; } else { - if (abs(p->Charge()) <= 1e-3) + if (std::abs(p->Charge()) <= 1e-3) continue; } // in acceptance @@ -154,6 +154,8 @@ struct ParticleCounter { float countFT0A(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, 3.5f, 4.9f); } float countFT0C(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -3.3f, -2.1f); } float countFV0A(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, 2.2f, 5.1f); } + float countV0A(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, 2.8f, 5.1f); } + float countV0C(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -3.7f, -1.7f); } float countFDDA(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, 4.9f, 6.3f); } float countFDDC(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -7.f, -4.9f); } @@ -161,6 +163,8 @@ struct ParticleCounter { float countZNC(const aod::McParticles& mcParticles) { return countEnergyInAcceptance(mcParticles, -100.f, -8.8f, true); } float countITSIB(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -2.f, 2.f); } + float countEta05(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -0.5f, 0.5f); } + float countEta08(const aod::McParticles& mcParticles) { return countMultInAcceptance(mcParticles, -0.8f, 0.8f); } }; } // namespace pwglf diff --git a/PWGLF/Utils/mcParticle.h b/PWGLF/Utils/mcParticle.h index dc0f476cc8a..e85d98ca5f0 100644 --- a/PWGLF/Utils/mcParticle.h +++ b/PWGLF/Utils/mcParticle.h @@ -53,6 +53,8 @@ class PIDExtended static constexpr ID Hyperhydrog4 = 14; static constexpr ID XiMinus = 15; static constexpr ID OmegaMinus = 16; + static constexpr ID HyperHelium4 = 17; + static constexpr ID HyperHelium5 = 18; static_assert(Electron == o2::track::PID::Electron, "PID::Electron mismatch"); static_assert(Muon == o2::track::PID::Muon, "PID::Muon mismatch"); @@ -71,59 +73,60 @@ class PIDExtended static_assert(Hyperhydrog4 == o2::track::PID::Hyperhydrog4, "PID::Hyperhydrog4 mismatch"); static_assert(XiMinus == o2::track::PID::XiMinus, "PID::XiMinus mismatch"); static_assert(OmegaMinus == o2::track::PID::OmegaMinus, "PID::OmegaMinus mismatch"); + // static_assert(HyperHelium4 == o2::track::PID::HyperHelium4, "PID::HyperHelium4 mismatch"); + // static_assert(HyperHelium5 == o2::track::PID::HyperHelium5, "PID::HyperHelium5 mismatch"); static constexpr ID PIDCountsUntilAl = 9; // Number of indices defined in PID.h equivalent to o2::track::PID::NIDs - static_assert(PIDCountsUntilAl == o2::track::PID::NIDs, "PID::NIDs mismatch"); + // static_assert(PIDCountsUntilAl == o2::track::PID::NIDs, "PID::NIDs mismatch"); - static constexpr ID PIDCounts = 17; // Number of indices defined in PID.h - static_assert(PIDCounts == o2::track::PID::NIDsTot, "PID::NIDsTot mismatch"); + static constexpr ID PIDCounts = 19; // Number of indices defined in PID.h + // static_assert(PIDCounts == o2::track::PID::NIDsTot, "PID::NIDsTot mismatch"); // Define an array of IDs static constexpr std::array mIDsUntilAl = {Electron, Muon, Pion, Kaon, Proton, Deuteron, Triton, Helium3, Alpha}; - static constexpr std::array mIDs = {Electron, Muon, Pion, Kaon, Proton, Deuteron, Triton, Helium3, Alpha, PI0, Photon, K0, Lambda, HyperTriton, Hyperhydrog4, XiMinus, OmegaMinus}; + static constexpr std::array mIDs = {Electron, Muon, Pion, Kaon, Proton, Deuteron, Triton, Helium3, Alpha, PI0, Photon, K0, Lambda, HyperTriton, Hyperhydrog4, XiMinus, OmegaMinus, HyperHelium4, HyperHelium5}; // Define the antiparticles - static constexpr ID Positron = 17; - static constexpr ID MuonPlus = 18; - static constexpr ID PionMinus = 19; - static constexpr ID KaonMinus = 20; - static constexpr ID AntiProton = 21; - static constexpr ID AntiDeuteron = 22; - static constexpr ID AntiTriton = 23; - static constexpr ID AntiHelium3 = 24; - static constexpr ID AntiAlpha = 25; - static constexpr ID AntiLambda = 26; - static constexpr ID AntiHyperTriton = 27; - static constexpr ID AntiHyperhydrog4 = 28; - static constexpr ID XiPlus = 29; - static constexpr ID OmegaPlus = 30; + static constexpr ID Positron = PIDCounts; + static constexpr ID MuonPlus = PIDCounts + 1; + static constexpr ID PionMinus = PIDCounts + 2; + static constexpr ID KaonMinus = PIDCounts + 3; + static constexpr ID AntiProton = PIDCounts + 4; + static constexpr ID AntiDeuteron = PIDCounts + 5; + static constexpr ID AntiTriton = PIDCounts + 6; + static constexpr ID AntiHelium3 = PIDCounts + 7; + static constexpr ID AntiAlpha = PIDCounts + 8; + static constexpr ID AntiLambda = PIDCounts + 9; + static constexpr ID AntiHyperTriton = PIDCounts + 10; + static constexpr ID AntiHyperhydrog4 = PIDCounts + 11; + static constexpr ID XiPlus = PIDCounts + 12; + static constexpr ID OmegaPlus = PIDCounts + 13; + static constexpr ID AntiHyperHelium4 = PIDCounts + 14; + static constexpr ID AntiHyperHelium5 = PIDCounts + 15; - static constexpr ID Neutron = 31; - static constexpr ID AntiNeutron = 32; - static constexpr ID HyperHelium4 = 33; - static constexpr ID AntiHyperHelium4 = 34; - static constexpr ID Phi = 35; - - static constexpr ID BZero = 36; - static constexpr ID BPlus = 37; - static constexpr ID BS = 38; - static constexpr ID D0 = 39; - static constexpr ID DPlus = 40; - static constexpr ID DS = 41; - static constexpr ID DStar = 42; - static constexpr ID ChiC1 = 43; - static constexpr ID JPsi = 44; - static constexpr ID LambdaB0 = 45; - static constexpr ID LambdaCPlus = 46; - static constexpr ID OmegaC0 = 47; - static constexpr ID SigmaC0 = 48; - static constexpr ID SigmaCPlusPlus = 49; - static constexpr ID X3872 = 50; - static constexpr ID Xi0 = 51; - static constexpr ID XiB0 = 52; - static constexpr ID XiCCPlusPlus = 53; - static constexpr ID XiCPlus = 54; - static constexpr ID XiC0 = 55; - static constexpr ID NIDsTot = 56; + static constexpr ID Neutron = PIDCounts + 16; + static constexpr ID AntiNeutron = PIDCounts + 17; + static constexpr ID Phi = PIDCounts + 18; + static constexpr ID BZero = PIDCounts + 19; + static constexpr ID BPlus = PIDCounts + 20; + static constexpr ID BS = PIDCounts + 21; + static constexpr ID D0 = PIDCounts + 22; + static constexpr ID DPlus = PIDCounts + 23; + static constexpr ID DS = PIDCounts + 24; + static constexpr ID DStar = PIDCounts + 25; + static constexpr ID ChiC1 = PIDCounts + 26; + static constexpr ID JPsi = PIDCounts + 27; + static constexpr ID LambdaB0 = PIDCounts + 28; + static constexpr ID LambdaCPlus = PIDCounts + 29; + static constexpr ID OmegaC0 = PIDCounts + 30; + static constexpr ID SigmaC0 = PIDCounts + 31; + static constexpr ID SigmaCPlusPlus = PIDCounts + 32; + static constexpr ID X3872 = PIDCounts + 33; + static constexpr ID Xi0 = PIDCounts + 34; + static constexpr ID XiB0 = PIDCounts + 35; + static constexpr ID XiCCPlusPlus = PIDCounts + 36; + static constexpr ID XiCPlus = PIDCounts + 37; + static constexpr ID XiC0 = PIDCounts + 38; + static constexpr ID NIDsTot = PIDCounts + 39; static constexpr const char* sNames[NIDsTot + 1] = { o2::track::pid_constants::sNames[Electron], // Electron @@ -143,6 +146,8 @@ class PIDExtended o2::track::pid_constants::sNames[Hyperhydrog4], // Hyperhydrog4 o2::track::pid_constants::sNames[XiMinus], // XiMinus o2::track::pid_constants::sNames[OmegaMinus], // OmegaMinus + "HyperHelium4", // HyperHelium4 + "HyperHelium5", // HyperHelium5 "Positron", // Positron "MuonPlus", // MuonPlus "PionMinus", // PionMinus @@ -157,10 +162,10 @@ class PIDExtended "AntiHyperhydrog4", // AntiHyperhydrog4 "XiPlus", // XiPlus "OmegaPlus", // OmegaPlus + "AntiHyperHelium4", // AntiHyperHelium4 + "AntiHyperHelium5", // AntiHyperHelium5 "Neutron", // Neutron "AntiNeutron", // AntiNeutron - "HyperHelium4", // HyperHelium4 - "AntiHyperHelium4", // AntiHyperHelium4 "Phi", // Phi "BZero", // BZero "BPlus", // BPlus @@ -244,6 +249,10 @@ class PIDExtended return HyperHelium4; case -o2::constants::physics::Pdg::kHyperHelium4: return AntiHyperHelium4; + case o2::constants::physics::Pdg::kHyperHelium5: + return HyperHelium5; + case -o2::constants::physics::Pdg::kHyperHelium5: + return AntiHyperHelium5; case 111: return PI0; case 22: diff --git a/PWGLF/Utils/strangenessMasks.h b/PWGLF/Utils/strangenessMasks.h new file mode 100644 index 00000000000..7b567218de6 --- /dev/null +++ b/PWGLF/Utils/strangenessMasks.h @@ -0,0 +1,150 @@ +// Copyright 2019-2024 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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, + selV0Radius, + selV0RadiusMax, + selDCANegToPV, + selDCAPosToPV, + selDCAV0Dau, + selK0ShortRapidity, + selLambdaRapidity, + selTPCPIDPositivePion, + selTPCPIDNegativePion, + selTPCPIDPositiveProton, + selTPCPIDNegativeProton, + selTOFDeltaTPositiveProtonLambda, + selTOFDeltaTPositivePionLambda, + selTOFDeltaTPositivePionK0Short, + selTOFDeltaTNegativeProtonLambda, + selTOFDeltaTNegativePionLambda, + selTOFDeltaTNegativePionK0Short, + selTOFNSigmaPositiveProtonLambda, // Nsigma + selTOFNSigmaPositivePionLambda, // Nsigma + selTOFNSigmaPositivePionK0Short, // Nsigma + selTOFNSigmaNegativeProtonLambda, // Nsigma + selTOFNSigmaNegativePionLambda, // Nsigma + selTOFNSigmaNegativePionK0Short, // Nsigma + selK0ShortCTau, + selLambdaCTau, + selK0ShortArmenteros, + selPosGoodTPCTrack, // at least min # TPC rows + selNegGoodTPCTrack, // at least min # TPC rows + selPosGoodITSTrack, // at least min # ITS clusters + selNegGoodITSTrack, // at least min # ITS clusters + selPosItsOnly, + selNegItsOnly, + selPosNotTPCOnly, + selNegNotTPCOnly, + selConsiderK0Short, // for mc tagging + selConsiderLambda, // for mc tagging + selConsiderAntiLambda, // for mc tagging + selPhysPrimK0Short, // for mc tagging + selPhysPrimLambda, // for mc tagging + selPhysPrimAntiLambda, // for mc tagging + selPosEta, + selNegEta, + // cascade selections + selCascCosPA, + selMassWinXi, + selMassWinOmega, + selDCACascDau, + selDCAV0ToPV, + selCascRadius, + selCascRadiusMax, + selBachBaryon, + selRejCompXi, + selRejCompOmega, + selBachToPV, + selMesonToPV, + selBaryonToPV, + selXiRapidity, + selXiCTau, + selConsiderXi, + selConsiderAntiXi, + selPhysPrimXi, + selPhysPrimAntiXi, + selOmegaRapidity, + selOmegaCTau, + selConsiderOmega, + selConsiderAntiOmega, + selPhysPrimOmega, + selPhysPrimAntiOmega, + selBachItsOnly, + selBachNotTPCOnly, + selBachGoodTPCTrack, + selBachGoodITSTrack, + selTPCPIDBachPion, + selTPCPIDBachKaon, + selTOFNSigmaBachPionXi, + selTOFNSigmaBachKaonOmega, + selTOFNSigmaPositiveProtonLambdaXi, + selTOFNSigmaPositiveProtonLambdaOmega, + selTOFNSigmaPositivePionLambdaXi, + selTOFNSigmaPositivePionLambdaOmega, + selTOFNSigmaNegativePionLambdaXi, + selTOFNSigmaNegativePionLambdaOmega, + selTOFNSigmaNegativeProtonLambdaXi, + selTOFNSigmaNegativeProtonLambdaOmega, + selTOFDeltaTPositiveProtonLambdaXi, + selTOFDeltaTPositiveProtonLambdaOmega, + selTOFDeltaTPositivePionLambdaXi, + selTOFDeltaTPositivePionLambdaOmega, + selTOFDeltaTNegativeProtonLambdaXi, + selTOFDeltaTNegativeProtonLambdaOmega, + selTOFDeltaTNegativePionLambdaXi, + selTOFDeltaTNegativePionLambdaOmega, + selTOFDeltaTBachPionXi, + selTOFDeltaTBachKaonOmega, + selBachEta, + selLambdaMassWin, + selCount, +}; + +static constexpr int selNum = static_cast(selectionsCombined::selCount); + +// constants +const float ctauxiPDG = 4.91; // from PDG +const float ctauomegaPDG = 2.461; // from PDG + +// bit masks +std::bitset maskTopologicalV0; +std::bitset maskTopologicalCasc; + +std::bitset maskKinematicV0; +std::bitset maskKinematicCasc; + +std::bitset maskTrackPropertiesV0; +std::bitset maskTrackPropertiesCasc; + +std::bitset maskK0ShortSpecific; +std::bitset maskLambdaSpecific; +std::bitset maskAntiLambdaSpecific; +std::bitset maskXiSpecific; +std::bitset maskAntiXiSpecific; +std::bitset maskOmegaSpecific; +std::bitset maskAntiOmegaSpecific; + +std::bitset maskSelectionK0Short; +std::bitset maskSelectionLambda; +std::bitset maskSelectionAntiLambda; +std::bitset maskSelectionXi; +std::bitset maskSelectionAntiXi; +std::bitset maskSelectionOmega; +std::bitset maskSelectionAntiOmega; + +#endif // PWGLF_UTILS_STRANGENESSMASKS_H_ diff --git a/PWGMM/Lumi/Tasks/lumiStability.cxx b/PWGMM/Lumi/Tasks/lumiStability.cxx index ee2f7b8b497..9a9f134b0fd 100644 --- a/PWGMM/Lumi/Tasks/lumiStability.cxx +++ b/PWGMM/Lumi/Tasks/lumiStability.cxx @@ -13,6 +13,11 @@ /// it is meant to be a blank page for further developments. /// \author everyone +#include +#include +#include +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -23,14 +28,17 @@ #include "DataFormatsFT0/Digit.h" #include "DataFormatsFV0/Digit.h" #include "Framework/ASoA.h" +#include "Common/CCDB/EventSelectionParams.h" +#include "CCDB/BasicCCDBManager.h" +#include "CommonDataFormat/BunchFilling.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" using namespace o2; using namespace o2::framework; using BCsWithTimestamps = soa::Join; -int nBCsPerOrbit = 3564; - struct lumiStabilityTask { // Histogram registry: an object to hold your histograms HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -39,19 +47,64 @@ struct lumiStabilityTask { Configurable myMaxDeltaBCFDD{"myMaxDeltaBCFDD", 5, {"My BC cut"}}; Configurable myMaxDeltaBCFT0{"myMaxDeltaBCFT0", 5, {"My BC cut"}}; Configurable myMaxDeltaBCFV0{"myMaxDeltaBCFV0", 5, {"My BC cut"}}; + Configurable nOrbitsConf{"nOrbits", 972'288'000, "number of orbits"}; + Configurable nOrbitsPerTF{"nOrbitsPerTF", 128, "number of orbits per time frame"}; + Configurable minOrbitConf{"minOrbit", 0, "minimum orbit"}; + Configurable is2022Data{"is2022Data", true, "To 2022 data"}; + + 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 + std::bitset beamPatternA; + std::bitset beamPatternC; + std::bitset bcPatternA; + std::bitset bcPatternC; + std::bitset bcPatternB; + std::bitset bcPatternE; void init(InitContext const&) { - const AxisSpec axisCounts{5, -0.5, 4.5}; - const AxisSpec axisTriggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + 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 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 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), ""}; + + 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("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("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("hOrbitFDDVertexCoinc", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFDDVertex", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits}); + // time 32.766 is dummy time // histo about triggers - histos.add("FDD/hCounts", "0 CountVertexFDD - 1 CountPFPVertexCoincidencesFDD - 2 CountPFPTriggerCoincidencesFDD - 3 CountPPVertexCoincidencesFDD - 4 CountPPTriggerCoincidencesFDD; Number; counts", kTH1F, {axisCounts}); + 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/bcVertexTriggerCoincidencePFP", "vertex trigger per BC (FDD) with coincidences and Past Future Protection;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/bcVertexTriggerBothSidesCoincidencePFP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Future 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}); @@ -61,19 +114,74 @@ struct lumiStabilityTask { 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("FT0/hCounts", "0 CountVertexFT0 - 1 CountPFPVertexCoincidencesFT0 - 2 CountPFPTriggerCoincidencesFT0 - 3 CountPPVertexCoincidencesFT0 - 4 CountPPTriggerCoincidencesFT0; Number; counts", kTH1F, {axisCounts}); + 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/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/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}}}); + histos.add("FDD/timeACbcE", "time bcE ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); + histos.add("FDD/hTimeAVertex", "FDD time A; ns ; count", kTH1F, {axisTimeFDD}); + histos.add("FDD/hTimeCVertex", "FDD time C; ns ; count", kTH1F, {axisTimeFDD}); + histos.add("FDD/hTimeACoinc", "FDD time A; ns ; count", kTH1F, {axisTimeFDD}); + histos.add("FDD/hTimeCCoinc", "FDD time C; ns ; count", kTH1F, {axisTimeFDD}); + 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/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("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/bcVertexTriggerPFP", "vertex trigger per BC (FT0) with Past Future Protection;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/bcVertexTriggerBothSidesPFP", "vertex per BC (FDD) with coincidences, at least one side trigger and Past Future Protection;BC in FDD; 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("FV0/hCounts", "0 CountCentralFV0 - 1 CountPFPCentralFV0 - 2 CountPFPOutInFV0 - 3 CountPPCentralFV0 - 4 CountPPOutInFV0; Number; counts", kTH1F, {axisCounts}); + 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/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}}}); + histos.add("FT0/timeACbcE", "time bcE ; A (ns); C (ns)", {HistType::kTH2F, {{300, -15, 15}, {300, -15, 15}}}); + histos.add("FT0/hTimeA", "FT0 time A; ns ; count", kTH1F, {axisTime}); + histos.add("FT0/hTimeC", "FT0 time C; ns ; count", kTH1F, {axisTime}); + 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("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}); @@ -82,6 +190,14 @@ struct lumiStabilityTask { 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/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}}); + histos.add("FV0/timeAbcE", "time bcE ; A (ns)", kTH1F, {{300, -15, 15}}); } bool checkAnyCoincidence(const std::vector& channels) @@ -101,8 +217,83 @@ struct lumiStabilityTask { return false; } - void processMain(aod::FDDs const& fdds, aod::FT0s const& ft0s, aod::FV0As const& fv0s, aod::BCsWithTimestamps const&) + void processMain(aod::FDDs const& fdds, aod::FT0s const& ft0s, aod::FV0As const& fv0s, aod::BCsWithTimestamps const& bcs) { + int executionCounter = 0; + // uint32_t nOrbitsPerTF = 128; // 128 in 2022, 32 in 2023 + int runNumber = bcs.iteratorAt(0).runNumber(); + // std::string histName = "hOrbitFDDVertexCoinc_" + std::to_string(runNumber); + if (runNumber != lastRunNumber && executionCounter < 1) { + lastRunNumber = runNumber; // do it only once + executionCounter++; + // int64_t tsSOR = 0; + // int64_t tsEOR = 1; + + if (runNumber >= 500000) { // access CCDB for data or anchored MC only + int64_t ts = bcs.iteratorAt(0).timestamp(); + + // access colliding and beam-gas bc patterns + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); + beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0); + beamPatternC = grplhcif->getBunchFilling().getBeamPattern(1); + bcPatternA = beamPatternA & ~beamPatternC; + bcPatternC = ~beamPatternA & beamPatternC; + bcPatternB = beamPatternA & beamPatternC; + bcPatternE = ~beamPatternA & ~beamPatternC; + + for (int i = 0; i < nBCsPerOrbit; i++) { + if (bcPatternA[i]) { + histos.fill(HIST("hBcA"), i); + } + if (bcPatternC[i]) { + histos.fill(HIST("hBcC"), i); + } + if (bcPatternB[i]) { + histos.fill(HIST("hBcB"), i); + } + if (bcPatternE[i]) { + histos.fill(HIST("hBcE"), i); + } + } + + /*EventSelectionParams* par = ccdb->getForTimeStamp("EventSelection/EventSelectionParams", ts); + // access orbit-reset timestamp + auto ctpx = ccdb->getForTimeStamp>("CTP/Calib/OrbitReset", ts); + int64_t tsOrbitReset = (*ctpx)[0]; // us + // access TF duration, start-of-run and end-of-run timestamps from ECS GRP + std::map metadata; + metadata["runNumber"] = Form("%d", runNumber); + auto grpecs = ccdb->getSpecific("GLO/Config/GRPECS", ts, metadata); + nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023 + tsSOR = grpecs->getTimeStart(); // ms + tsEOR = grpecs->getTimeEnd(); // ms + // calculate SOR and EOR orbits + int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; + int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; + // adjust to the nearest TF edge + orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; + orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift; + // set nOrbits and minOrbit used for orbit-axis binning + nOrbits = orbitEOR - orbitSOR; + minOrbit = orbitSOR; + // first bc of the first orbit (should coincide with TF start) + bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches; + // 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); + std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<< Orbits per second: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << nOrbits << std::endl;*/ + } + + // create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available + // otherwise default minOrbit and nOrbits will be used + /*const AxisSpec axisOrbits{static_cast(nOrbits / nOrbitsPerTF), 0., static_cast(nOrbits), ""}; + std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<< Creating histograms >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + histos.add("hOrbitFDDVertexCoinc", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFDDVertex", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFT0vertex", "", kTH1F, {axisOrbits}); + histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits});*/ + } + for (auto const& fdd : fdds) { auto bc = fdd.bc_as(); if (bc.timestamp() == 0) { @@ -111,6 +302,7 @@ struct lumiStabilityTask { Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + uint64_t orbit = globalBC / nBCsPerOrbit; std::bitset<8> fddTriggers = fdd.triggerMask(); bool vertex = fddTriggers[o2::fdd::Triggers::bitVertex]; @@ -133,10 +325,131 @@ struct lumiStabilityTask { bool isCoinA = checkAnyCoincidence(channelA); bool isCoinC = checkAnyCoincidence(channelC); + histos.fill(HIST("FDD/hCounts"), 0); if (vertex) { histos.fill(HIST("FDD/bcVertexTrigger"), localBC); + histos.fill(HIST("FDD/hCounts"), 1); + histos.fill(HIST("hOrbitFDDVertex"), orbit - minOrbit); + + int deltaIndex = 0; // backward move counts + int deltaBC = 0; // current difference wrt globalBC + bool pastActivityFDDVertex = false; + while (deltaBC < myMaxDeltaBCFDD) { + deltaIndex++; + if (fdd.globalIndex() - deltaIndex < 0) { + break; + } + const auto& fdd_past = fdds.iteratorAt(fdd.globalIndex() - deltaIndex); + auto bc_past = fdd_past.bc_as(); + deltaBC = globalBC - bc_past.globalBC(); + + if (deltaBC < myMaxDeltaBCFDD) { + std::bitset<8> fddTriggersPast = fdd_past.triggerMask(); + bool vertexPast = fddTriggersPast[o2::fdd::Triggers::bitVertex]; + pastActivityFDDVertex |= (vertexPast); + } + } + deltaIndex = 0; + deltaBC = 0; + + if (pastActivityFDDVertex == false) { + histos.fill(HIST("FDD/hCounts"), 2); + histos.fill(HIST("FDD/bcVertexTriggerPP"), localBC); + if (bcPatternA[localBC]) { + histos.fill(HIST("FDD/timeACbcAVertex"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcAVertex"), localBC); + } + if (bcPatternC[localBC]) { + histos.fill(HIST("FDD/timeACbcCVertex"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcCVertex"), localBC); + } + if (bcPatternB[localBC]) { + histos.fill(HIST("FDD/timeACbcBVertex"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcBVertex"), localBC); + histos.fill(HIST("FDD/hTimeAVertex"), fdd.timeA()); + histos.fill(HIST("FDD/hTimeCVertex"), fdd.timeC()); + if (is2022Data) { + if (fdd.timeA() > 30) { + histos.fill(HIST("FDD/hCountsTimeA2022"), 0); + histos.fill(HIST("FDD/hInvTimeAvsBC2022"), localBC); + } else { + histos.fill(HIST("FDD/hCountsTimeA2022"), 1); + histos.fill(HIST("FDD/hValidTimeAvsBC2022"), localBC); + } + + if (fdd.timeC() > 30) { + histos.fill(HIST("FDD/hCountsTimeC2022"), 0); + histos.fill(HIST("FDD/hInvTimeCvsBC2022"), localBC); + } else { + histos.fill(HIST("FDD/hCountsTimeC2022"), 1); + histos.fill(HIST("FDD/hValidTimeCvsBC2022"), localBC); + } + + if (fdd.timeA() > 30 || fdd.timeC() > 30) { + histos.fill(HIST("FDD/hCountsTime2022"), 0); + histos.fill(HIST("FDD/hInvTimevsBC2022"), localBC); + } + if (fdd.timeA() < 30 && fdd.timeC() < 30) { + histos.fill(HIST("FDD/hCountsTime2022"), 1); + histos.fill(HIST("FDD/hValidTimevsBC2022"), localBC); + } + } + } + if (bcPatternE[localBC]) { + histos.fill(HIST("FDD/timeACbcEVertex"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcEVertex"), localBC); + } + } + if (isCoinA && isCoinC) { histos.fill(HIST("FDD/bcVertexTriggerCoincidence"), localBC); + histos.fill(HIST("FDD/hCounts"), 3); + histos.fill(HIST("hOrbitFDDVertexCoinc"), orbit - minOrbit); + + if (bcPatternA[localBC]) { + histos.fill(HIST("FDD/timeACbcA"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcA"), localBC); + } + if (bcPatternC[localBC]) { + histos.fill(HIST("FDD/timeACbcC"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcC"), localBC); + } + if (bcPatternB[localBC]) { + histos.fill(HIST("FDD/timeACbcB"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcB"), localBC); + histos.fill(HIST("FDD/hTimeACoinc"), fdd.timeA()); + histos.fill(HIST("FDD/hTimeCCoinc"), fdd.timeC()); + if (!is2022Data) { + if (fdd.timeA() > 30) { + histos.fill(HIST("FDD/hCountsTimeA"), 0); + histos.fill(HIST("FDD/hInvTimeAvsBC"), localBC); + } else { + histos.fill(HIST("FDD/hCountsTimeA"), 1); + histos.fill(HIST("FDD/hValidTimeAvsBC"), localBC); + } + + if (fdd.timeC() > 30) { + histos.fill(HIST("FDD/hCountsTimeC"), 0); + histos.fill(HIST("FDD/hInvTimeCvsBC"), localBC); + } else { + histos.fill(HIST("FDD/hCountsTimeC"), 1); + histos.fill(HIST("FDD/hValidTimeCvsBC"), localBC); + } + + if (fdd.timeA() > 30 || fdd.timeC() > 30) { + histos.fill(HIST("FDD/hCountsTime"), 0); + histos.fill(HIST("FDD/hInvTimevsBC"), localBC); + } + if (fdd.timeA() < 30 && fdd.timeC() < 30) { + histos.fill(HIST("FDD/hCountsTime"), 1); + histos.fill(HIST("FDD/hValidTimevsBC"), localBC); + } + } + } + if (bcPatternE[localBC]) { + histos.fill(HIST("FDD/timeACbcE"), fdd.timeA(), fdd.timeC()); + histos.fill(HIST("FDD/hBcE"), localBC); + } int deltaIndex = 0; // backward move counts int deltaBC = 0; // current difference wrt globalBC @@ -149,7 +462,8 @@ struct lumiStabilityTask { break; } const auto& fdd_past = fdds.iteratorAt(fdd.globalIndex() - deltaIndex); - deltaBC = fdd.bcId() - fdd_past.bcId(); + auto bc_past = fdd_past.bc_as(); + deltaBC = globalBC - bc_past.globalBC(); if (deltaBC < myMaxDeltaBCFDD) { std::bitset<8> fddTriggersPast = fdd_past.triggerMask(); @@ -179,65 +493,16 @@ struct lumiStabilityTask { deltaIndex = 0; deltaBC = 0; - bool futureActivityFDDVertexCoincidences = false; - bool futureActivityFDDTriggerACoincidenceA = false; - bool futureActivityFDDTriggerCCoincidenceC = false; - while (deltaBC < myMaxDeltaBCFDD) { - deltaIndex++; - if (fdd.globalIndex() + deltaIndex >= fdds.size()) { - break; - } - const auto& fdd_future = fdds.iteratorAt(fdd.globalIndex() + deltaIndex); - deltaBC = fdd_future.bcId() - fdd.bcId(); - - if (deltaBC < myMaxDeltaBCFDD) { - std::bitset<8> fddTriggersFuture = fdd_future.triggerMask(); - bool vertexFuture = fddTriggersFuture[o2::fdd::Triggers::bitVertex]; - bool triggerAFuture = fddTriggersFuture[o2::fdd::Triggers::bitA]; - bool triggerCFuture = fddTriggersFuture[o2::fdd::Triggers::bitC]; - auto SideAFuture = fdd_future.chargeA(); - auto SideCFuture = fdd_future.chargeC(); - std::vector channelAFuture; - std::vector channelCFuture; - for (auto i = 0; i < 8; i++) { - if (SideAFuture[i] > 0) { - channelAFuture.push_back(i); - } - if (SideCFuture[i] > 0) { - channelCFuture.push_back(i); - } - } - - bool isCoinAFuture = checkAnyCoincidence(channelAFuture); - bool isCoinCFuture = checkAnyCoincidence(channelCFuture); - futureActivityFDDVertexCoincidences |= (vertexFuture & isCoinAFuture & isCoinCFuture); - futureActivityFDDTriggerACoincidenceA |= (triggerAFuture & isCoinAFuture); - futureActivityFDDTriggerCCoincidenceC |= (triggerCFuture & isCoinCFuture); - } - } - - histos.fill(HIST("FDD/hCounts"), 0); - if ((pastActivityFDDTriggerACoincidenceA || futureActivityFDDTriggerACoincidenceA) == true || (pastActivityFDDTriggerCCoincidenceC || futureActivityFDDTriggerCCoincidenceC) == true) { - histos.fill(HIST("FDD/hCounts"), 2); - } else { - histos.fill(HIST("FDD/bcVertexTriggerBothSidesCoincidencePFP"), localBC); - } - if (pastActivityFDDTriggerACoincidenceA == true || pastActivityFDDTriggerCCoincidenceC == true) { + if (pastActivityFDDVertexCoincidences == false) { histos.fill(HIST("FDD/hCounts"), 4); - } else { - histos.fill(HIST("FDD/bcVertexTriggerBothSidesCoincidencePP"), localBC); - } - if (pastActivityFDDVertexCoincidences == true || futureActivityFDDVertexCoincidences == true) { - histos.fill(HIST("FDD/hCounts"), 1); - } else { - histos.fill(HIST("FDD/bcVertexTriggerCoincidencePFP"), localBC); - } - if (pastActivityFDDVertexCoincidences == true) { - histos.fill(HIST("FDD/hCounts"), 3); - } else { histos.fill(HIST("FDD/bcVertexTriggerCoincidencePP"), localBC); } - } + if (pastActivityFDDTriggerACoincidenceA == false || pastActivityFDDTriggerCCoincidenceC == false) { + histos.fill(HIST("FDD/hCounts"), 5); + histos.fill(HIST("FDD/bcVertexTriggerBothSidesCoincidencePP"), localBC); + } + } // coincidences + } // vertex true if (scentral) { @@ -267,7 +532,7 @@ struct lumiStabilityTask { histos.fill(HIST("FDD/bcVCTriggerCoincidence"), localBC); } } // vertex and scentral true - } // loop over FDD events + } // loop over FDD events for (auto const& ft0 : ft0s) { auto bc = ft0.bc_as(); @@ -277,14 +542,61 @@ struct lumiStabilityTask { Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + uint64_t orbit = globalBC / nBCsPerOrbit; std::bitset<8> fT0Triggers = ft0.triggerMask(); bool vertex = fT0Triggers[o2::ft0::Triggers::bitVertex]; bool sCentral = fT0Triggers[o2::ft0::Triggers::bitSCen]; bool central = fT0Triggers[o2::ft0::Triggers::bitCen]; + histos.fill(HIST("FT0/hCounts"), 0); if (vertex) { histos.fill(HIST("FT0/bcVertexTrigger"), localBC); + histos.fill(HIST("hOrbitFT0vertex"), orbit - minOrbit); + + if (bcPatternA[localBC]) { + histos.fill(HIST("FT0/timeACbcA"), ft0.timeA(), ft0.timeC()); + histos.fill(HIST("FT0/hBcA"), localBC); + } + if (bcPatternC[localBC]) { + histos.fill(HIST("FT0/timeACbcC"), ft0.timeA(), ft0.timeC()); + histos.fill(HIST("FT0/hBcC"), localBC); + } + if (bcPatternB[localBC]) { + histos.fill(HIST("FT0/timeACbcB"), ft0.timeA(), ft0.timeC()); + histos.fill(HIST("FT0/hBcB"), localBC); + histos.fill(HIST("FT0/hTimeA"), ft0.timeA()); + histos.fill(HIST("FT0/hTimeC"), ft0.timeC()); + + if (ft0.timeA() > 30) { + histos.fill(HIST("FT0/hCountsTimeA"), 0); + histos.fill(HIST("FT0/hInvTimeAvsBC"), localBC); + } else { + histos.fill(HIST("FT0/hCountsTimeA"), 1); + histos.fill(HIST("FT0/hValidTimeAvsBC"), localBC); + } + + if (ft0.timeC() > 30) { + histos.fill(HIST("FT0/hCountsTimeC"), 0); + histos.fill(HIST("FT0/hInvTimeCvsBC"), localBC); + } else { + histos.fill(HIST("FT0/hCountsTimeC"), 1); + histos.fill(HIST("FT0/hValidTimeCvsBC"), localBC); + } + + if (ft0.timeA() > 30 || ft0.timeC() > 30) { + histos.fill(HIST("FT0/hCountsTime"), 0); + histos.fill(HIST("FT0/hInvTimevsBC"), localBC); + } + if (ft0.timeA() < 30 && ft0.timeC() < 30) { + histos.fill(HIST("FT0/hCountsTime"), 1); + histos.fill(HIST("FT0/hValidTimevsBC"), localBC); + } + } + if (bcPatternE[localBC]) { + histos.fill(HIST("FT0/timeACbcE"), ft0.timeA(), ft0.timeC()); + histos.fill(HIST("FT0/hBcE"), localBC); + } int deltaIndex = 0; // backward move counts int deltaBC = 0; // current difference wrt globalBC @@ -297,7 +609,8 @@ struct lumiStabilityTask { break; } const auto& ft0_past = ft0s.iteratorAt(ft0.globalIndex() - deltaIndex); - deltaBC = ft0.bcId() - ft0_past.bcId(); + auto bc_past = ft0_past.bc_as(); + deltaBC = globalBC - bc_past.globalBC(); if (deltaBC < myMaxDeltaBCFT0) { std::bitset<8> fT0TriggersPast = ft0_past.triggerMask(); @@ -313,49 +626,14 @@ struct lumiStabilityTask { deltaIndex = 0; deltaBC = 0; - bool futureActivityFT0Vertex = false; - bool futureActivityFT0TriggerA = false; - bool futureActivityFT0TriggerC = false; - while (deltaBC < myMaxDeltaBCFT0) { - deltaIndex++; - if (ft0.globalIndex() + deltaIndex >= ft0s.size()) { - break; - } - const auto& ft0_future = ft0s.iteratorAt(ft0.globalIndex() + deltaIndex); - deltaBC = ft0_future.bcId() - ft0.bcId(); - - if (deltaBC < myMaxDeltaBCFT0) { - std::bitset<8> fT0TriggersFuture = ft0_future.triggerMask(); - bool vertexFuture = fT0TriggersFuture[o2::ft0::Triggers::bitVertex]; - bool triggerAFuture = fT0TriggersFuture[o2::ft0::Triggers::bitA]; - bool triggerCFuture = fT0TriggersFuture[o2::ft0::Triggers::bitC]; - - futureActivityFT0Vertex |= vertexFuture; - futureActivityFT0TriggerA |= triggerAFuture; - futureActivityFT0TriggerC |= triggerCFuture; - } - } - - histos.fill(HIST("FT0/hCounts"), 0); - if ((pastActivityFT0TriggerA || futureActivityFT0TriggerA) == true || (pastActivityFT0TriggerC || futureActivityFT0TriggerC) == true) { + histos.fill(HIST("FT0/hCounts"), 1); + if (pastActivityFT0Vertex == false) { histos.fill(HIST("FT0/hCounts"), 2); - } else { - histos.fill(HIST("FT0/bcVertexTriggerBothSidesPFP"), localBC); - } - if (pastActivityFT0TriggerA == true || pastActivityFT0TriggerC == true) { - histos.fill(HIST("FT0/hCounts"), 4); - } else { - histos.fill(HIST("FT0/bcVertexTriggerBothSidesPP"), localBC); - } - if (pastActivityFT0Vertex == true || futureActivityFT0Vertex == true) { - histos.fill(HIST("FT0/hCounts"), 1); - } else { - histos.fill(HIST("FT0/bcVertexTriggerPFP"), localBC); + histos.fill(HIST("FT0/bcVertexTriggerPP"), localBC); } - if (pastActivityFT0Vertex == true) { + if (pastActivityFT0TriggerA == false || pastActivityFT0TriggerC == false) { histos.fill(HIST("FT0/hCounts"), 3); - } else { - histos.fill(HIST("FT0/bcVertexTriggerPP"), localBC); + histos.fill(HIST("FT0/bcVertexTriggerBothSidesPP"), localBC); } } // vertex true @@ -385,6 +663,7 @@ struct lumiStabilityTask { Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + uint64_t orbit = globalBC / nBCsPerOrbit; std::bitset<8> fv0Triggers = fv0.triggerMask(); bool aOut = fv0Triggers[o2::fv0::Triggers::bitAOut]; @@ -405,8 +684,26 @@ struct lumiStabilityTask { } if (aCen) { + histos.fill(HIST("hOrbitFV0Central"), orbit - minOrbit); histos.fill(HIST("FV0/bcCenTrigger"), localBC); + if (bcPatternA[localBC]) { + histos.fill(HIST("FV0/timeAbcA"), fv0.time()); + histos.fill(HIST("FV0/hBcA"), localBC); + } + if (bcPatternC[localBC]) { + histos.fill(HIST("FV0/timeAbcC"), fv0.time()); + histos.fill(HIST("FV0/hBcC"), localBC); + } + if (bcPatternB[localBC]) { + histos.fill(HIST("FV0/timeAbcB"), fv0.time()); + histos.fill(HIST("FV0/hBcB"), localBC); + } + if (bcPatternE[localBC]) { + histos.fill(HIST("FV0/timeAbcE"), fv0.time()); + histos.fill(HIST("FV0/hBcE"), localBC); + } + int deltaIndex = 0; // backward move counts int deltaBC = 0; // current difference wrt globalBC bool pastActivityFV0Cen = false; @@ -418,7 +715,8 @@ struct lumiStabilityTask { break; } const auto& fv0_past = fv0s.iteratorAt(fv0.globalIndex() - deltaIndex); - deltaBC = fv0.bcId() - fv0_past.bcId(); + auto bc_past = fv0_past.bc_as(); + deltaBC = globalBC - bc_past.globalBC(); if (deltaBC < myMaxDeltaBCFV0) { std::bitset<8> fv0Triggers = fv0_past.triggerMask(); @@ -480,9 +778,21 @@ struct lumiStabilityTask { } } } // loop over V0 events - } // end processMain + } // end processMain PROCESS_SWITCH(lumiStabilityTask, processMain, "Process FDD and FT0 to lumi stability analysis", true); + + void processCollisions(aod::Collision const& collision) + { + histos.fill(HIST("hvertexX"), collision.posX()); + histos.fill(HIST("hvertexY"), collision.posY()); + histos.fill(HIST("hvertexZ"), collision.posZ()); + histos.fill(HIST("hnumContrib"), collision.numContrib()); + histos.fill(HIST("hcollisinTime"), collision.collisionTime()); + histos.fill(HIST("hvertexXvsTime"), collision.posX(), collision.collisionTime()); + } + + PROCESS_SWITCH(lumiStabilityTask, processCollisions, "Process collision to get vertex position", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGMM/Mult/Core/include/Functions.h b/PWGMM/Mult/Core/include/Functions.h index 4cd59894184..a0ef3928fa5 100644 --- a/PWGMM/Mult/Core/include/Functions.h +++ b/PWGMM/Mult/Core/include/Functions.h @@ -11,31 +11,143 @@ #ifndef PWGMM_MULT_CORE_INCLUDE_FUNCTIONS_H_ #define PWGMM_MULT_CORE_INCLUDE_FUNCTIONS_H_ -#include "Common/DataModel/Centrality.h" namespace pwgmm::mult { -using namespace o2; +template +concept has_hepmc_xs = requires(MCC::iterator const& mcc) { + mcc.xsectGen(); +}; -// helper function to determine if collision/mccollison type contains centrality -template -static constexpr bool hasSimCent() +template +concept has_hepmc_pid = requires(MCC::iterator const& mcc) { + mcc.processId(); +}; + +template +concept has_hepmc_pdf = requires(MCC::iterator const& mcc) { + mcc.pdfId1(); + mcc.pdfId2(); +}; + +template +concept has_hepmc_hi = requires(MCC::iterator const& mcc) { + mcc.ncollHard(); + mcc.ncoll(); +}; + +template +concept has_FT0C = requires(C::iterator const& c) { + c.centFT0C(); +}; + +template +concept iterator_with_FT0C = requires(IC const& c) { + c.centFT0C(); +}; + +template +concept iterator_with_FT0M = requires(IC const& c) { + c.centFT0M(); +}; + +template +concept has_FT0M = requires(C::iterator const& c) { + c.centFT0M(); +}; + +template +concept has_genFT0C = requires(C::iterator const& c) { + c.gencentFT0C(); +}; + +template +concept has_genFT0M = requires(C::iterator const& c) { + c.gencentFT0M(); +}; + +template +concept iterator_with_genFT0C = requires(C const& c) { + c.gencentFT0C(); +}; + +template +concept iterator_with_genFT0M = requires(C const& c) { + c.gencentFT0M(); +}; + +template +concept has_reco_cent = has_FT0C || has_FT0M; + +template +concept has_gen_cent = has_genFT0C && has_genFT0M; + +template +concept has_Centrality = requires(MCC::iterator const& mcc) { + mcc.centrality(); +}; + +template +concept iterator_with_Centrality = requires(MCC const& mcc) { + mcc.centrality(); +}; + +template + requires(!(iterator_with_FT0C || iterator_with_FT0M)) +static float getRecoCent(C const&) +{ + return -1; +} + +template +static float getRecoCent(C const& collision) +{ + return collision.centFT0C(); +} + +template +static float getRecoCent(C const& collision) +{ + return collision.centFT0M(); +} + +template + requires(!iterator_with_genFT0C) +static float getGenCentFT0C(MCC const&) +{ + return -1; +} + +template + requires(!iterator_with_genFT0M) +static float getGenCentFT0M(MCC const&) +{ + return -1; +} + +template +static float getGenCentFT0C(MCC const& mccollision) +{ + return mccollision.gencentFT0C(); +} + +template +static float getGenCentFT0M(MCC const& mccollision) +{ + return mccollision.gencentFT0M(); +} + +template + requires(!iterator_with_Centrality) +static float getSimCent(MCC const&) { - if constexpr (!soa::is_soa_join_v) { - return false; - } else { - return T::template contains(); - } + return -1; } -template -static constexpr bool hasRecoCent() +template +static float getSimCent(MCC const& mccollision) { - if constexpr (!soa::is_soa_join_v) { - return false; - } else { - return T::template contains() || T::template contains(); - } + return mccollision.centrality(); } } // namespace pwgmm::mult diff --git a/PWGMM/Mult/Core/include/Histograms.h b/PWGMM/Mult/Core/include/Histograms.h index c47f2a8e315..2b41c9ecefe 100644 --- a/PWGMM/Mult/Core/include/Histograms.h +++ b/PWGMM/Mult/Core/include/Histograms.h @@ -12,6 +12,7 @@ #ifndef PWGMM_MULT_CORE_INCLUDE_HISTOGRAMS_H_ #define PWGMM_MULT_CORE_INCLUDE_HISTOGRAMS_H_ #include "TPDGCode.h" +#include #include namespace pwgmm::mult diff --git a/PWGMM/Mult/DataModel/CMakeLists.txt b/PWGMM/Mult/DataModel/CMakeLists.txt index 14fe4e618af..42f51846fda 100644 --- a/PWGMM/Mult/DataModel/CMakeLists.txt +++ b/PWGMM/Mult/DataModel/CMakeLists.txt @@ -10,4 +10,4 @@ # or submit itself to any jurisdiction. o2physics_add_header_only_library(MultDataModel - HEADERS ReducedTables.h) + HEADERS ReducedTables.h Gencentralities.h) diff --git a/PWGMM/Mult/DataModel/Gencentralities.h b/PWGMM/Mult/DataModel/Gencentralities.h new file mode 100644 index 00000000000..112072fa2c8 --- /dev/null +++ b/PWGMM/Mult/DataModel/Gencentralities.h @@ -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. + +#ifndef PWGMM_MULT_DATAMODEL_GENCENTRALITIES_H_ +#define PWGMM_MULT_DATAMODEL_GENCENTRALITIES_H_ + +#include "Framework/AnalysisDataModel.h" +namespace o2::aod +{ +namespace gencents +{ +DECLARE_SOA_COLUMN(GenCentFT0C, gencentFT0C, float); +DECLARE_SOA_COLUMN(GenCentFT0M, gencentFT0M, float); +} // namespace gencents +DECLARE_SOA_TABLE(GenCents, "AOD", "GENCENT", + gencents::GenCentFT0C, + gencents::GenCentFT0M); +} // namespace o2::aod +#endif // PWGMM_MULT_DATAMODEL_GENCENTRALITIES_H_ diff --git a/PWGMM/Mult/DataModel/ReducedTables.h b/PWGMM/Mult/DataModel/ReducedTables.h index 8b9cdb45ba7..fbdd68b89db 100644 --- a/PWGMM/Mult/DataModel/ReducedTables.h +++ b/PWGMM/Mult/DataModel/ReducedTables.h @@ -25,12 +25,8 @@ namespace o2::aod bc::RunNumber // Reduced BCs as a root index -DECLARE_SOA_TABLE(RBCs, "AOD", "RBC", - BCcols, - soa::Marker<1>); -DECLARE_SOA_TABLE(StoredRBCs, "AOD1", "RBC", - BCcols, - soa::Marker<2>); +DECLARE_SOA_TABLE_STAGED(RBCs, "RBC", + BCcols); namespace rcol { @@ -63,19 +59,11 @@ DECLARE_SOA_COLUMN(MapEtaPhi, mapetaphi, std::vector); cent::CentNTPV // Reduced Collisions -DECLARE_SOA_TABLE(RCollisions, "AOD", "RCOLLISION", - Ccols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRCollisions, "AOD1", "RCOLLISION", - Ccols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RCollisions, "RCOLLISION", + Ccols) -DECLARE_SOA_TABLE(RCents, "AOD", "RCENTS", - CCcols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRCents, "AOD1", "RCENTS", - CCcols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RCents, "RCENTS", + CCcols) // Reduced tracks (is this needed?) namespace rtrack @@ -93,12 +81,8 @@ DECLARE_SOA_COLUMN(Weight, weight, float); track::DcaXY, \ track::DcaZ -DECLARE_SOA_TABLE(RTracks, "AOD", "RTRACK", - Tcols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRTracks, "AOD1", "RTRACK", - Tcols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RTracks, "RTRACK", + Tcols) #define TFcols o2::soa::Index<>, \ rtrack::RCollisionId, \ @@ -110,12 +94,8 @@ DECLARE_SOA_TABLE(StoredRTracks, "AOD1", "RTRACK", fwdtrack::FwdDcaX, \ fwdtrack::FwdDcaY -DECLARE_SOA_TABLE(RFTracks, "AOD", "RFTRACK", - TFcols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRFTracks, "AOD1", "RFTRACK", - TFcols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RFTracks, "RFTRACK", + TFcols) // Reduced MC collisions namespace rmccol @@ -134,12 +114,8 @@ DECLARE_SOA_COLUMN(Weight, weight, float); mult::MultMCNParticlesEta05, \ mult::MultMCNParticlesEta10 -DECLARE_SOA_TABLE(RMCCollisions, "AOD", "RMCCOLLISION", - MCCcols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRMCCollisions, "AOD1", "RMCCOLLISION", - MCCcols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RMCCollisions, "RMCCOLLISION", + MCCcols) // Extra MC tables namespace rhepmc @@ -161,12 +137,8 @@ DECLARE_SOA_INDEX_COLUMN(RMCCollision, rmccollison); hepmcpdfinfo::Pdf1, \ hepmcpdfinfo::Pdf2 -DECLARE_SOA_TABLE(RHepMCinfos, "AOD", "RHEPMCINFO", - HMCcols, - soa::Marker<1>); -DECLARE_SOA_TABLE(StoredRHepMCinfos, "AOD1", "RHEPMCINFO", - HMCcols, - soa::Marker<2>); +DECLARE_SOA_TABLE_STAGED(RHepMCinfos, "RHEPMCINFO", + HMCcols); #define HMCHIcols rhepmc::RMCCollisionId, \ hepmcheavyion::NcollHard, \ @@ -178,12 +150,8 @@ DECLARE_SOA_TABLE(StoredRHepMCinfos, "AOD1", "RHEPMCINFO", hepmcheavyion::SigmaInelNN, \ hepmcheavyion::Centrality -DECLARE_SOA_TABLE(RHepMCHIs, "AOD", "RHEPMCHI", - HMCHIcols, - soa::Marker<1>); -DECLARE_SOA_TABLE(StoredRHepMCHIs, "AOD1", "RHEPMCHI", - HMCHIcols, - soa::Marker<2>); +DECLARE_SOA_TABLE_STAGED(RHepMCHIs, "RHEPMCHI", + HMCHIcols); namespace rparticle { @@ -204,12 +172,8 @@ DECLARE_SOA_INDEX_COLUMN(RMCCollision, rmccollision); mcparticle::E, \ mcparticle::Weight -DECLARE_SOA_TABLE(RMCParticles, "AOD", "RMCPARTICLE", - RMCPcols, - soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRMCParticles, "AOD1", "RMCPARTICLE", - RMCPcols, - soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RMCParticles, "RMCPARTICLE", + RMCPcols) // label tables namespace rlabels @@ -217,15 +181,11 @@ namespace rlabels DECLARE_SOA_INDEX_COLUMN(RMCCollision, rmccollision); DECLARE_SOA_INDEX_COLUMN(RMCParticle, rmcparticle); } // namespace rlabels -DECLARE_SOA_TABLE(RMCTrackLabels, "AOD", "RMCTRKLABEL", - rlabels::RMCParticleId, soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRMCTrackLabels, "AOD1", "RMCTRKLABEL", - rlabels::RMCParticleId, soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RMCTrackLabels, "RMCTRKLABEL", + rlabels::RMCParticleId) -DECLARE_SOA_TABLE(RMCColLabels, "AOD", "RMCCOLLABEL", - rlabels::RMCCollisionId, soa::Marker<1>) -DECLARE_SOA_TABLE(StoredRMCColLabels, "AOD1", "RMCCOLLABEL", - rlabels::RMCCollisionId, soa::Marker<2>) +DECLARE_SOA_TABLE_STAGED(RMCColLabels, "RMCCOLLABEL", + rlabels::RMCCollisionId) namespace features { diff --git a/PWGMM/Mult/TableProducer/CMakeLists.txt b/PWGMM/Mult/TableProducer/CMakeLists.txt index f37c5f106ef..9b1ddb5e997 100644 --- a/PWGMM/Mult/TableProducer/CMakeLists.txt +++ b/PWGMM/Mult/TableProducer/CMakeLists.txt @@ -28,3 +28,8 @@ o2physics_add_dpl_workflow(track-propagation SOURCES trackPropagation.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(percentiles + SOURCES percentiles.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGMM/Mult/TableProducer/percentiles.cxx b/PWGMM/Mult/TableProducer/percentiles.cxx new file mode 100644 index 00000000000..c11fca858f8 --- /dev/null +++ b/PWGMM/Mult/TableProducer/percentiles.cxx @@ -0,0 +1,236 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "Selections.h" + +#include +#include +#include +#include +#include "Common/DataModel/Centrality.h" +#include +#include +#include +#include + +#include "Gencentralities.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using namespace pwgmm::mult; + +constexpr float FT0Alo = -3.3; +constexpr float FT0Ahi = -2.1; +constexpr float FT0Clo = 3.5; +constexpr float FT0Chi = 4.9; + +struct Binner { + Service pdg; + Produces gencents; + HistogramRegistry h{"histograms", {}}; + + using Particles = soa::Filtered; + Preslice perMcCol = aod::mcparticle::mcCollisionId; + Preslice perCol = aod::track::collisionId; + + ConfigurableAxis multBinning{"multBinning", {302, -1.5, 300.5}, ""}; + ConfigurableAxis centBinning{"centBinning", {VARIABLE_WIDTH, 0, 1, 5, 10, 15, 20, 30, 40, 50, 70, 100}, ""}; + + // The objects are uploaded with https://alimonitor.cern.ch/ccdb/upload.jsp + Service ccdb; + Configurable path{"ccdb-path", "Users/a/aalkin/gencentralities", "base path to the ccdb object"}; + Configurable url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + + bool isChargedParticle(int code) const + { + static auto p = pdg->GetParticle(code); + if (p == nullptr) { + return 0; + } + return std::abs(p->Charge()) >= 3.; + } + + template + static inline bool isCollisionSelectedMC(C const& collision) + { + return collision.selection_bit(aod::evsel::kIsTriggerTVX) && + collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && + collision.selection_bit(aod::evsel::kIsVertexITSTPC) && + collision.selection_bit(aod::evsel::kIsVertexTOFmatched); + } + + template + static inline bool isCollisionSelected(C const& collision) + { + return collision.selection_bit(aod::evsel::kIsTriggerTVX) && + collision.selection_bit(aod::evsel::kNoTimeFrameBorder) && + collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && + collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) && + collision.selection_bit(aod::evsel::kIsVertexITSTPC) && + collision.selection_bit(aod::evsel::kIsVertexTOFmatched); + } + + TH1F* multFT0C = nullptr; + TH1F* multFT0M = nullptr; + + void init(InitContext const&) + { + AxisSpec MultAxis = {multBinning}; + h.add({"hFT0M", "; N_{part} in FT0M acc", {HistType::kTH1F, {MultAxis}}}); + h.add({"hFT0C", "; N_{part} in FT0C acc", {HistType::kTH1F, {MultAxis}}}); + if (dobin) { + ccdb->setURL(url.value); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + } + if (docalibrateAdvanced) { + centBinning.value.insert(centBinning.value.begin() + 1, {-2}); + AxisSpec ExtraCentAxis = {centBinning}; + h.add({"hCorrelate", " ; N_{part}^{FT0M}; N_{part}^{FT0C}; N_{trk}^{#eta = 0}", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, ExtraCentAxis}}}); + } + if (dogetData) { + AxisSpec CentAxis = {centBinning}; + h.add({"hTrkAt0vsFT0M", " ; N_{trk}^{#eta = 0}; FT0M percentile", {HistType::kTH2F, {MultAxis, CentAxis}}}); + } + } + + Filter primaries = ncheckbit(aod::mcparticle::flags, (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary); + Partition pFT0M = ((aod::mcparticle::eta > FT0Alo) && (aod::mcparticle::eta < FT0Ahi)) || ((aod::mcparticle::eta > FT0Clo) && (aod::mcparticle::eta < FT0Chi)); + Partition pFT0C = (aod::mcparticle::eta > FT0Clo) && (aod::mcparticle::eta < FT0Chi); + + void calibrate(aod::McCollisions const& mccollisions, Particles const&) + { + for (auto& mcc : mccollisions) { + auto pcFT0M = pFT0M.sliceBy(perMcCol, mcc.globalIndex()); + auto pcFT0C = pFT0C.sliceBy(perMcCol, mcc.globalIndex()); + int nFT0M = 0; + int nFT0C = 0; + for (auto& p : pcFT0M) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0M; + } + } + h.fill(HIST("hFT0M"), nFT0M); + for (auto& p : pcFT0C) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0C; + } + } + h.fill(HIST("hFT0C"), nFT0C); + } + } + + PROCESS_SWITCH(Binner, calibrate, "Create binnings", true); + + using ExColsMCFT0M = soa::Join; + using ExColsCentFT0M = soa::Join; + using Trks = soa::Join; + // require a mix of ITS+TPC and ITS-only tracks (filters on the same table are automatically combined with &&) + 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 = nabs(aod::track::dcaZ) <= 0.2f && ncheckbit(aod::track::trackCutFlag, trackSelectionDCAXYonly); + Filter fTracksEta = nabs(aod::track::eta) < 0.5f; + + void calibrateAdvanced(aod::McCollision const& mcc, + soa::SmallGroups const& collisions, + Particles const&, + soa::Filtered const& tracks) + { + auto pcFT0M = pFT0M.sliceBy(perMcCol, mcc.globalIndex()); + auto pcFT0C = pFT0C.sliceBy(perMcCol, mcc.globalIndex()); + int nFT0M = 0; + int nFT0C = 0; + int nTrkAt0 = 0; + for (auto& p : pcFT0M) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0M; + } + } + h.fill(HIST("hFT0M"), nFT0M); + for (auto& p : pcFT0C) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0C; + } + } + h.fill(HIST("hFT0C"), nFT0C); + + bool selected = false; + float cent = 1.e3; + for (auto& c : collisions) { + if (isCollisionSelectedMC(c)) { + selected = true; + auto sample = tracks.sliceBy(perCol, c.globalIndex()); + nTrkAt0 += sample.size(); + if (c.centFT0M() < cent) { + cent = c.centFT0M(); + } + } + } + if (!selected) { + nTrkAt0 = -1; + cent = -1; + } + h.fill(HIST("hCorrelate"), nFT0M, nFT0C, nTrkAt0, cent); + } + + PROCESS_SWITCH(Binner, calibrateAdvanced, "Create binning matched to dN/deta", false); + + void getData(ExColsCentFT0M::iterator const& collision, + soa::Filtered const& tracks) + { + if (isCollisionSelected(collision)) { + h.fill(HIST("hTrkAt0vsFT0M"), tracks.size(), collision.centFT0M()); + } + } + + PROCESS_SWITCH(Binner, getData, "Get data distribution to match to", false); + + void bin(aod::BCsWithTimestamps const& bcs, aod::McCollisions const& mccollisions, Particles const&) + { + auto bc = bcs.begin(); + multFT0M = ccdb->getForTimeStamp(path.value + "/hFT0M", bc.timestamp()); + multFT0C = ccdb->getForTimeStamp(path.value + "/hFT0C", bc.timestamp()); + if (multFT0C == nullptr && multFT0M == nullptr) { + LOGP(fatal, "Unable to get the distributions from CCDB"); + } + for (auto& mcc : mccollisions) { + auto pcFT0M = pFT0M.sliceBy(perMcCol, mcc.globalIndex()); + auto pcFT0C = pFT0C.sliceBy(perMcCol, mcc.globalIndex()); + int nFT0M = 0; + int nFT0C = 0; + for (auto& p : pcFT0M) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0M; + } + } + h.fill(HIST("hFT0M"), nFT0M); + for (auto& p : pcFT0C) { + if (isChargedParticle(p.pdgCode())) { + ++nFT0C; + } + } + h.fill(HIST("hFT0C"), nFT0C); + float percentileFT0M = 100.f * multFT0M->Integral(multFT0M->FindFixBin(nFT0C), multFT0M->FindLastBinAbove()); + float percentileFT0C = 100.f * multFT0C->Integral(multFT0C->FindFixBin(nFT0C), multFT0C->FindLastBinAbove()); + gencents(percentileFT0C, percentileFT0M); + } + } + + PROCESS_SWITCH(Binner, bin, "Bin collisions", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return {adaptAnalysisTask(cfgc)}; +} diff --git a/PWGMM/Mult/Tasks/CMakeLists.txt b/PWGMM/Mult/Tasks/CMakeLists.txt index 4828a7ea434..9012d14f2c1 100644 --- a/PWGMM/Mult/Tasks/CMakeLists.txt +++ b/PWGMM/Mult/Tasks/CMakeLists.txt @@ -34,6 +34,11 @@ o2physics_add_dpl_workflow(dndeta-mft PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(dndeta-mft-pbpb + SOURCES dndeta-mft-pbpb.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(flatenicity-fv0 SOURCES flatenicityFV0.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore diff --git a/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx b/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx new file mode 100644 index 00000000000..a800b3a1002 --- /dev/null +++ b/PWGMM/Mult/Tasks/dndeta-mft-pbpb.cxx @@ -0,0 +1,1537 @@ +// 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, {{1000, 0, 100}}}, + 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 - collision + Filter filterCollCent = nabs(aod::cent::centFT0C) < cfgCutCent; + Filter filterCollZvtx = nabs(aod::collision::posZ) < cfgCutZvtx; + Filter filterMcCollZvtx = nabs(aod::mccollision::posZ) < cfgCutZvtx; + + /// 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 filtColls = soa::Filtered>; + using filtColl = + soa::Filtered>::iterator; + using filtCollsCent = + soa::Filtered>; + using filtCollCent = soa::Filtered< + soa::Join>::iterator; + using CollsGenCentSmallG = + o2::soa::SmallGroups>; + using filtCollsGenCentSmallG = + soa::SmallGroups>; + using filtCollsGenCent = + soa::Filtered>; + using filtMcGenColls = soa::Filtered; + using filtMcGenColl = soa::Filtered::iterator; + using filtMftTracks = soa::Filtered; + using filtMcMftTracks = soa::Filtered; + using filtBestTracks = soa::Filtered; + using filtBestTracksJ = + 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(filtColls::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(filtCollsCent::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( + filtColls::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( + filtCollsCent::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( + filtMcGenColls::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( + filtMcGenColls::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( + filtMcGenColls::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( + filtMcGenColls::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, + filtMcGenColls 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, + filtMcGenColls 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, + filtMcGenColls 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.cxx b/PWGMM/Mult/Tasks/dndeta.cxx index a68ab572fca..220bdbdebb8 100644 --- a/PWGMM/Mult/Tasks/dndeta.cxx +++ b/PWGMM/Mult/Tasks/dndeta.cxx @@ -21,6 +21,7 @@ #include #include +#include "Gencentralities.h" #include "Index.h" #include "bestCollisionTable.h" @@ -49,8 +50,9 @@ struct MultiplicityCounter { Configurable estimatorEta{"estimatorEta", 1.0, "eta range for INEL>0 sample definition"}; Configurable dcaZ{"dcaZ", 0.2f, "Custom DCA Z cut (ignored if negative)"}; - ConfigurableAxis multBinning{"multBinning", {301, -0.5, 300.5}, ""}; - ConfigurableAxis centBinning{"centBinning", {VARIABLE_WIDTH, 0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, ""}; + ConfigurableAxis multBinning{"multBinning", {301, -0.5, 300.5}, "Multiplicity axis binning"}; + ConfigurableAxis centBinning{"centBinning", {VARIABLE_WIDTH, 0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "Centrality axis binning"}; + ConfigurableAxis occuBinning{"occuBinning", {VARIABLE_WIDTH, 0, 500, 1000, 2000, 5000, 10000}, "Occupancy axis binning"}; // Pb-Pb default Configurable fillResponse{"fillResponse", true, "Fill response matrix"}; Configurable useProcId{"use-process-id", true, "Use process ID from generator"}; @@ -110,10 +112,12 @@ struct MultiplicityCounter { std::vector usedTracksIdsDF; std::vector usedTracksIdsDFMC; std::vector usedTracksIdsDFMCEff; + void init(InitContext&) { AxisSpec MultAxis = {multBinning}; AxisSpec CentAxis = {centBinning, "centrality"}; + AxisSpec OccuAxis = {occuBinning, "occupancy"}; { auto hstat = commonRegistry.get(HIST(BCSelection)); auto* x = hstat->GetXaxis(); @@ -123,17 +127,17 @@ struct MultiplicityCounter { } if (doprocessEventStat) { - inclusiveRegistry.add({EventChi2.data(), " ; #chi^2", {HistType::kTH1F, {{101, -0.1, 10.1}}}}); - inclusiveRegistry.add({EventTimeRes.data(), " ; t (ms)", {HistType::kTH1F, {{1001, -0.1, 100.1}}}}); + inclusiveRegistry.add({EventChi2.data(), " ; #chi^2", {HistType::kTH2F, {{101, -0.1, 10.1}, OccuAxis}}}); + inclusiveRegistry.add({EventTimeRes.data(), " ; t (ms)", {HistType::kTH2F, {{1001, -0.1, 100.1}, OccuAxis}}}); } if (doprocessEventStatCentralityFT0C || doprocessEventStatCentralityFT0M) { - binnedRegistry.add({EventChi2.data(), " ; #chi^2; centrality", {HistType::kTH2F, {{101, -0.1, 10.1}, CentAxis}}}); - binnedRegistry.add({EventTimeRes.data(), " ; t (ms); centrality", {HistType::kTH2F, {{1001, -0.1, 100.1}, CentAxis}}}); + binnedRegistry.add({EventChi2.data(), " ; #chi^2; centrality", {HistType::kTHnSparseF, {{101, -0.1, 10.1}, CentAxis, OccuAxis}}}); + binnedRegistry.add({EventTimeRes.data(), " ; t (ms); centrality", {HistType::kTHnSparseF, {{1001, -0.1, 100.1}, CentAxis, OccuAxis}}}); } if (doprocessCountingAmbiguous || doprocessCounting) { - inclusiveRegistry.add({EventSelection.data(), ";status;events", {HistType::kTH1F, {{static_cast(EvSelBins::kRejected), 0.5, static_cast(EvSelBins::kRejected) + 0.5}}}}); - auto hstat = inclusiveRegistry.get(HIST(EventSelection)); + inclusiveRegistry.add({EventSelection.data(), ";status;occupancy;events", {HistType::kTH2F, {{static_cast(EvSelBins::kRejected), 0.5, static_cast(EvSelBins::kRejected) + 0.5}, OccuAxis}}}); + auto hstat = inclusiveRegistry.get(HIST(EventSelection)); auto* x = hstat->GetXaxis(); x->SetBinLabel(static_cast(EvSelBins::kAll), EvSelBinLabels[static_cast(EvSelBins::kAll)].data()); x->SetBinLabel(static_cast(EvSelBins::kSelected), EvSelBinLabels[static_cast(EvSelBins::kSelected)].data()); @@ -141,57 +145,57 @@ struct MultiplicityCounter { x->SetBinLabel(static_cast(EvSelBins::kSelectedPVgt0), EvSelBinLabels[static_cast(EvSelBins::kSelectedPVgt0)].data()); x->SetBinLabel(static_cast(EvSelBins::kRejected), EvSelBinLabels[static_cast(EvSelBins::kRejected)].data()); - inclusiveRegistry.add({NtrkZvtx.data(), "; N_{trk}; Z_{vtx} (cm); events", {HistType::kTH2F, {MultAxis, ZAxis}}}); - inclusiveRegistry.add({NpvcZvtx.data(), "; N_{PVc}; Z_{vtx} (cm); events", {HistType::kTH2F, {MultAxis, ZAxis}}}); - inclusiveRegistry.add({EtaZvtx.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); - inclusiveRegistry.add({EtaZvtx_gt0.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); - inclusiveRegistry.add({EtaZvtx_PVgt0.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); - inclusiveRegistry.add({PhiEta.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({PtEta.data(), " ; p_{T} (GeV/c); #eta", {HistType::kTH2F, {PtAxis, EtaAxis}}}); - inclusiveRegistry.add({DCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); - inclusiveRegistry.add({DCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); + inclusiveRegistry.add({NtrkZvtx.data(), "; N_{trk}; Z_{vtx} (cm);occupancy; events", {HistType::kTHnSparseF, {MultAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({NpvcZvtx.data(), "; N_{PVc}; Z_{vtx} (cm);occupancy; events", {HistType::kTHnSparseF, {MultAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({EtaZvtx.data(), "; #eta; Z_{vtx} (cm);occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({EtaZvtx_gt0.data(), "; #eta; Z_{vtx} (cm);occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({EtaZvtx_PVgt0.data(), "; #eta; Z_{vtx} (cm);occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({PhiEta.data(), "; #varphi; #eta;occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({PtEta.data(), " ; p_{T} (GeV/c);occupancy; #eta", {HistType::kTHnSparseF, {PtAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({DCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); + inclusiveRegistry.add({DCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); if (doprocessCountingAmbiguous) { - inclusiveRegistry.add({ReassignedDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); - inclusiveRegistry.add({ReassignedDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); - inclusiveRegistry.add({ExtraDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); - inclusiveRegistry.add({ExtraDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm)", {HistType::kTH2F, {PtAxis, DCAAxis}}}); - inclusiveRegistry.add({ExtraEtaZvtx.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); - inclusiveRegistry.add({ExtraPhiEta.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({ReassignedEtaZvtx.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); - inclusiveRegistry.add({ReassignedPhiEta.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({ReassignedZvtxCorr.data(), "; Z_{vtx}^{orig} (cm); Z_{vtx}^{re} (cm)", {HistType::kTH2F, {ZAxis, ZAxis}}}); + inclusiveRegistry.add({ReassignedDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); + inclusiveRegistry.add({ReassignedDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); + inclusiveRegistry.add({ExtraDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); + inclusiveRegistry.add({ExtraDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm);occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, OccuAxis}}}); + inclusiveRegistry.add({ExtraEtaZvtx.data(), "; #eta; Z_{vtx} (cm);occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({ExtraPhiEta.data(), "; #varphi; #eta;occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({ReassignedEtaZvtx.data(), "; #eta; Z_{vtx} (cm);occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({ReassignedPhiEta.data(), "; #varphi; #eta;occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({ReassignedZvtxCorr.data(), "; Z_{vtx}^{orig} (cm); Z_{vtx}^{re} (cm);occupancy", {HistType::kTHnSparseF, {ZAxis, ZAxis, OccuAxis}}}); } } if (doprocessCountingAmbiguousCentralityFT0C || doprocessCountingAmbiguousCentralityFT0M || doprocessCountingCentralityFT0C || doprocessCountingCentralityFT0M) { - binnedRegistry.add({EventSelection.data(), ";status;centrality;events", {HistType::kTH2F, {{static_cast(EvSelBins::kRejected), 0.5, static_cast(EvSelBins::kRejected) + 0.5}, CentAxis}}}); - auto hstat = binnedRegistry.get(HIST(EventSelection)); - auto* x = hstat->GetXaxis(); + binnedRegistry.add({EventSelection.data(), ";status;centrality;occupancy;events", {HistType::kTHnSparseF, {{static_cast(EvSelBins::kRejected), 0.5, static_cast(EvSelBins::kRejected) + 0.5}, CentAxis, OccuAxis}}}); + auto hstat = binnedRegistry.get(HIST(EventSelection)); + auto* x = hstat->GetAxis(0); x->SetBinLabel(static_cast(EvSelBins::kAll), EvSelBinLabels[static_cast(EvSelBins::kAll)].data()); x->SetBinLabel(static_cast(EvSelBins::kSelected), EvSelBinLabels[static_cast(EvSelBins::kSelected)].data()); x->SetBinLabel(static_cast(EvSelBins::kSelectedgt0), EvSelBinLabels[static_cast(EvSelBins::kSelectedgt0)].data()); x->SetBinLabel(static_cast(EvSelBins::kSelectedPVgt0), EvSelBinLabels[static_cast(EvSelBins::kSelectedPVgt0)].data()); x->SetBinLabel(static_cast(EvSelBins::kRejected), EvSelBinLabels[static_cast(EvSelBins::kRejected)].data()); - binnedRegistry.add({NtrkZvtx.data(), "; N_{trk}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({NpvcZvtx.data(), "; N_{PVc}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({EtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({EtaZvtx_gt0.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({EtaZvtx_PVgt0.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({PhiEta.data(), "; #varphi; #eta; centrality", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({PtEta.data(), " ; p_{T} (GeV/c); #eta; centrality", {HistType::kTHnSparseF, {PtAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({DCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); - binnedRegistry.add({DCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); + binnedRegistry.add({NtrkZvtx.data(), "; N_{trk}; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({NpvcZvtx.data(), "; N_{PVc}; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({EtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({EtaZvtx_gt0.data(), "; #eta; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({EtaZvtx_PVgt0.data(), "; #eta; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({PhiEta.data(), "; #varphi; #eta; centrality;occupancy", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEta.data(), " ; p_{T} (GeV/c); #eta; centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({DCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({DCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); if (doprocessCountingAmbiguousCentralityFT0C || doprocessCountingAmbiguousCentralityFT0M) { - binnedRegistry.add({ReassignedDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); - binnedRegistry.add({ReassignedDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); - binnedRegistry.add({ExtraDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); - binnedRegistry.add({ExtraDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis}}}); - binnedRegistry.add({ExtraEtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({ExtraPhiEta.data(), "; #varphi; #eta; centrality", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({ReassignedEtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({ReassignedPhiEta.data(), "; #varphi; #eta; centrality", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({ReassignedZvtxCorr.data(), "; Z_{vtx}^{orig} (cm); Z_{vtx}^{re} (cm); centrality", {HistType::kTHnSparseF, {ZAxis, ZAxis, CentAxis}}}); + binnedRegistry.add({ReassignedDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ReassignedDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ExtraDCAXYPt.data(), " ; p_{T} (GeV/c) ; DCA_{XY} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ExtraDCAZPt.data(), " ; p_{T} (GeV/c) ; DCA_{Z} (cm); centrality;occupancy", {HistType::kTHnSparseF, {PtAxis, DCAAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ExtraEtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ExtraPhiEta.data(), "; #varphi; #eta; centrality;occupancy", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ReassignedEtaZvtx.data(), "; #eta; Z_{vtx} (cm); centrality;occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ReassignedPhiEta.data(), "; #varphi; #eta; centrality;occupancy", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({ReassignedZvtxCorr.data(), "; Z_{vtx}^{orig} (cm); Z_{vtx}^{re} (cm); centrality;occupancy", {HistType::kTHnSparseF, {ZAxis, ZAxis, CentAxis, OccuAxis}}}); } } @@ -202,36 +206,43 @@ struct MultiplicityCounter { effLabels += " ; process ID"; effAxes.push_back(ProcAxis); } - inclusiveRegistry.add({NtrkZvtxGen.data(), "; N_{trk}; Z_{vtx} (cm); events", {HistType::kTH2F, {MultAxis, ZAxis}}}); + inclusiveRegistry.add({NtrkZvtxGen.data(), "; N_{trk}; Z_{vtx} (cm); occupancy; events", {HistType::kTHnSparseF, {MultAxis, ZAxis, OccuAxis}}}); inclusiveRegistry.add({NtrkZvtxGen_t.data(), effLabels.c_str(), {HistType::kTHnSparseF, effAxes}}); - inclusiveRegistry.add({NpvcZvxtGen.data(), "; N_{PVc}; Z_{vtx} (cm); events", {HistType::kTH2F, {MultAxis, ZAxis}}}); - inclusiveRegistry.add({EtaZvtxGen.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); + inclusiveRegistry.add({NpvcZvxtGen.data(), "; N_{PVc}; Z_{vtx} (cm); occupancy; events", {HistType::kTHnSparseF, {MultAxis, ZAxis, OccuAxis}}}); + inclusiveRegistry.add({EtaZvtxGen.data(), "; #eta; Z_{vtx} (cm); occupancy; tracks", {HistType::kTHnSparseF, {EtaAxis, ZAxis, OccuAxis}}}); inclusiveRegistry.add({EtaZvtxGen_t.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); inclusiveRegistry.add({EtaZvtxGen_gt0.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); inclusiveRegistry.add({EtaZvtxGen_PVgt0.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); inclusiveRegistry.add({EtaZvtxGen_gt0t.data(), "; #eta; Z_{vtx} (cm); tracks", {HistType::kTH2F, {EtaAxis, ZAxis}}}); inclusiveRegistry.add({PtEtaGen.data(), " ; p_{T} (GeV/c) ; #eta", {HistType::kTH2F, {PtAxis, EtaAxis}}}); + inclusiveRegistry.add({PhiEtaGen.data(), "; #varphi; #eta; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({PhiEtaGen.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - - inclusiveRegistry.add({Efficiency.data(), "; status; events", {HistType::kTH1F, {{static_cast(EvEffBins::kSelectedPVgt0), 0.5, static_cast(EvEffBins::kSelectedPVgt0) + 0.5}}}}); - inclusiveRegistry.add({NotFoundZvtx.data(), " ; Z_{vtx} (cm)", {HistType::kTH1F, {ZAxis}}}); + inclusiveRegistry.add({Efficiency.data(), "; status; occupancy; events", {HistType::kTH2F, {{static_cast(EvEffBins::kSelectedPVgt0), 0.5, static_cast(EvEffBins::kSelectedPVgt0) + 0.5}, OccuAxis}}}); + inclusiveRegistry.add({NotFoundZvtx.data(), " ; Z_{vtx} (cm) ", {HistType::kTH1F, {ZAxis}}}); if (fillResponse) { inclusiveRegistry.add({EfficiencyMult.data(), effLabels.c_str(), {HistType::kTHnSparseF, effAxes}}); inclusiveRegistry.add({SplitMult.data(), " ; N_{gen} ; Z_{vtx} (cm)", {HistType::kTH2F, {MultAxis, ZAxis}}}); - if (addFT0 && !addFDD) { - inclusiveRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FT0A}; N_{FT0C}; Z_{vtx} (cm)", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FT0AAxis, FT0CAxis, ZAxis}}}); - } else if (addFDD && !addFT0) { - inclusiveRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FDA}; N_{FDC}; Z_{vtx} (cm)", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FDAAxis, FDCAxis, ZAxis}}}); - } else if (addFT0 && addFDD) { - inclusiveRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FT0A}; N_{FT0C}; N_{FDA}; N_{FDC}; Z_{vtx} (cm)", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FT0AAxis, FT0CAxis, FDAAxis, FDCAxis, ZAxis}}}); - } else { - inclusiveRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; Z_{vtx} (cm)", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, ZAxis}}}); + + std::string reLabels{" ; N_{rec}; N_{PV cont}; N_{gen}"}; + std::vector reAxes{MultAxis, MultAxis, MultAxis}; + if (addFT0) { + reLabels += " ; N_{FT0A}; N_{FT0C}"; + reAxes.push_back(FT0AAxis); + reAxes.push_back(FT0CAxis); + } + if (addFDD) { + reLabels += " ; N_{FDA}; N_{FDC}"; + reAxes.push_back(FDAAxis); + reAxes.push_back(FDCAxis); } + reLabels += " ; Z_{vtx} (cm); occupancy"; + reAxes.push_back(ZAxis); + reAxes.push_back(OccuAxis); + inclusiveRegistry.add({Response.data(), reLabels.c_str(), {HistType::kTHnSparseF, reAxes}}); } - auto heff = inclusiveRegistry.get(HIST(Efficiency)); + auto heff = inclusiveRegistry.get(HIST(Efficiency)); auto* x = heff->GetXaxis(); x->SetBinLabel(static_cast(EvEffBins::kGen), EvEffBinLabels[static_cast(EvEffBins::kGen)].data()); x->SetBinLabel(static_cast(EvEffBins::kGengt0), EvEffBinLabels[static_cast(EvEffBins::kGengt0)].data()); @@ -241,8 +252,8 @@ struct MultiplicityCounter { x->SetBinLabel(static_cast(EvEffBins::kSelectedPVgt0), EvEffBinLabels[static_cast(EvEffBins::kSelectedPVgt0)].data()); } - if (doprocessGenAmbiguousFT0C || doprocessGenAmbiguousFT0M || doprocessGenAmbiguousFT0Chi || doprocessGenAmbiguousFT0Mhi || - doprocessGenFT0C || doprocessGenFT0M || doprocessGenFT0Chi || doprocessGenFT0Mhi || doprocessGenAmbiguousExFT0C || doprocessGenAmbiguousExFT0M || + if (doprocessGenAmbiguousFT0C || doprocessGenAmbiguousFT0M || doprocessGenAmbiguousFT0Cplus || doprocessGenAmbiguousFT0Mplus || doprocessGenAmbiguousFT0Chi || doprocessGenAmbiguousFT0Mhi || + doprocessGenFT0C || doprocessGenFT0M || doprocessGenFT0Cplus || doprocessGenFT0Mplus || doprocessGenFT0Chi || doprocessGenFT0Mhi || doprocessGenAmbiguousExFT0C || doprocessGenAmbiguousExFT0M || doprocessGenExFT0C || doprocessGenExFT0M) { std::string effLabels{" ; N_{gen}; Z_{vtx} (cm); centrality"}; std::vector effAxes{MultAxis, ZAxis, CentAxis}; @@ -250,36 +261,45 @@ struct MultiplicityCounter { effLabels += " ; process ID"; effAxes.push_back(ProcAxis); } - binnedRegistry.add({NtrkZvtxGen.data(), "; N_{trk}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({NtrkZvtxGen_t.data(), "; N_{part}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({NpvcZvxtGen.data(), "; N_{PVc}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - binnedRegistry.add({EtaZvtxGen.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); + binnedRegistry.add({NtrkZvtxGen.data(), "; N_{trk}; Z_{vtx} (cm); centrality; occupance", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({NtrkZvtxGen_t.data(), effLabels.c_str(), {HistType::kTHnSparseF, effAxes}}); + binnedRegistry.add({NpvcZvxtGen.data(), "; N_{PVc}; Z_{vtx} (cm); centrality; occupancy", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({EtaZvtxGen.data(), "; #eta; Z_{vtx} (cm); centrality; occupancy", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis, OccuAxis}}}); binnedRegistry.add({EtaZvtxGen_t.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); binnedRegistry.add({EtaZvtxGen_gt0.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); binnedRegistry.add({EtaZvtxGen_PVgt0.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); binnedRegistry.add({EtaZvtxGen_gt0t.data(), "; #eta; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {EtaAxis, ZAxis, CentAxis}}}); binnedRegistry.add({PtEtaGen.data(), " ; p_{T} (GeV/c) ; #eta; centrality", {HistType::kTHnSparseF, {PtAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({PhiEtaGen.data(), "; #varphi; #eta; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({Efficiency.data(), "; status; centrality; events", {HistType::kTH2F, {{static_cast(EvEffBins::kSelectedPVgt0), 0.5, static_cast(EvEffBins::kSelectedPVgt0) + 0.5}, CentAxis}}}); + + binnedRegistry.add({Efficiency.data(), "; status; centrality; occupancy; events", {HistType::kTHnSparseF, {{static_cast(EvEffBins::kSelectedPVgt0), 0.5, static_cast(EvEffBins::kSelectedPVgt0) + 0.5}, CentAxis, OccuAxis}}}); binnedRegistry.add({NotFoundZvtx.data(), " ; Z_{vtx} (cm); centrality; events", {HistType::kTH2F, {ZAxis, CentAxis}}}); if (fillResponse) { binnedRegistry.add({EfficiencyMult.data(), effLabels.c_str(), {HistType::kTHnSparseF, effAxes}}); binnedRegistry.add({SplitMult.data(), " ; N_{gen} ; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, ZAxis, CentAxis}}}); - if (addFT0 && !addFDD) { - binnedRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FT0A}; N_{FT0C}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FT0AAxis, FT0CAxis, ZAxis, CentAxis}}}); - } else if (addFDD && !addFT0) { - binnedRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FDA}; N_{FDC}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FDAAxis, FDCAxis, ZAxis, CentAxis}}}); - } else if (addFT0 && addFDD) { - binnedRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; N_{FT0A}; N_{FT0C}; N_{FDA}; N_{FDC}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, FT0AAxis, FT0CAxis, FDAAxis, FDCAxis, ZAxis, CentAxis}}}); - } else { - binnedRegistry.add({Response.data(), " ; N_{rec}; N_{PV cont}; N_{gen}; Z_{vtx} (cm); centrality", {HistType::kTHnSparseF, {MultAxis, MultAxis, MultAxis, ZAxis, CentAxis}}}); + + std::string reLabels{" ; N_{rec}; N_{PV cont}; N_{gen}"}; + std::vector reAxes{MultAxis, MultAxis, MultAxis}; + if (addFT0) { + reLabels += " ; N_{FT0A}; N_{FT0C}"; + reAxes.push_back(FT0AAxis); + reAxes.push_back(FT0CAxis); + } + if (addFDD) { + reLabels += " ; N_{FDA}; N_{FDC}"; + reAxes.push_back(FDAAxis); + reAxes.push_back(FDCAxis); } + reLabels += " ; Z_{vtx} (cm); centrality; occupancy"; + reAxes.push_back(ZAxis); + reAxes.push_back(CentAxis); + reAxes.push_back(OccuAxis); + binnedRegistry.add({Response.data(), reLabels.c_str(), {HistType::kTHnSparseF, reAxes}}); } - auto heff = binnedRegistry.get(HIST(Efficiency)); - auto* x = heff->GetXaxis(); + auto heff = binnedRegistry.get(HIST(Efficiency)); + auto* x = heff->GetAxis(0); x->SetBinLabel(static_cast(EvEffBins::kGen), EvEffBinLabels[static_cast(EvEffBins::kGen)].data()); x->SetBinLabel(static_cast(EvEffBins::kGengt0), EvEffBinLabels[static_cast(EvEffBins::kGengt0)].data()); x->SetBinLabel(static_cast(EvEffBins::kRec), EvEffBinLabels[static_cast(EvEffBins::kRec)].data()); @@ -289,57 +309,57 @@ struct MultiplicityCounter { } if (doprocessTrackEfficiencyAmbiguous || doprocessTrackEfficiency) { - inclusiveRegistry.add({PtGen.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtGenNoEtaCut.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiency.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencyNoEtaCut.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencyFakes.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); + inclusiveRegistry.add({PtGen.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtGenNoEtaCut.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiency.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencyNoEtaCut.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencyFakes.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); for (auto i = 0u; i < speciesIds.size(); ++i) { - inclusiveRegistry.add({fmt::format(PtGenF.data(), species[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({fmt::format(PtEfficiencyF.data(), species[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); + inclusiveRegistry.add({fmt::format(PtGenF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({fmt::format(PtEfficiencyF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); } } if (doprocessTrackEfficiencyAmbiguousCentralityFT0M || doprocessTrackEfficiencyCentralityFT0M || doprocessTrackEfficiencyAmbiguousCentralityFT0C || doprocessTrackEfficiencyCentralityFT0C) { - binnedRegistry.add({PtGen.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtGenNoEtaCut.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiency.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencyNoEtaCut.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencyFakes.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); + binnedRegistry.add({PtGen.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtGenNoEtaCut.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiency.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencyNoEtaCut.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencyFakes.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); for (auto i = 0u; i < speciesIds.size(); ++i) { - binnedRegistry.add({fmt::format(PtGenF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({fmt::format(PtEfficiencyF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); + binnedRegistry.add({fmt::format(PtGenF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({fmt::format(PtEfficiencyF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); } } if (doprocessTrackEfficiencyIndexed) { - inclusiveRegistry.add({PhiEtaGenDuplicates.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({PhiEtaDuplicates.data(), "; #varphi; #eta; tracks", {HistType::kTH2F, {PhiAxis, EtaAxis}}}); - inclusiveRegistry.add({PtGenIdx.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtGenIdxNoEtaCut.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencyIdx.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencyIdxNoEtaCut.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencySecondariesIdx.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({PtEfficiencySecondariesIdxNoEtaCut.data(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({Mask.data(), " ; bit", {HistType::kTH1F, {{17, -0.5, 16.5}}}}); - inclusiveRegistry.add({ITSlayers.data(), " ; layer", {HistType::kTH1F, {{8, 0.5, 8.5}}}}); + inclusiveRegistry.add({PhiEtaGenDuplicates.data(), "; #varphi; #eta; occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({PhiEtaDuplicates.data(), "; #varphi; #eta; occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, OccuAxis}}}); + inclusiveRegistry.add({PtGenIdx.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtGenIdxNoEtaCut.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencyIdx.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencyIdxNoEtaCut.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencySecondariesIdx.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({PtEfficiencySecondariesIdxNoEtaCut.data(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({Mask.data(), " ; bit; occupancy", {HistType::kTH2F, {{17, -0.5, 16.5}, OccuAxis}}}); + inclusiveRegistry.add({ITSlayers.data(), " ; layer; occupancy", {HistType::kTH2F, {{8, 0.5, 8.5}, OccuAxis}}}); for (auto i = 0u; i < speciesIds.size(); ++i) { - inclusiveRegistry.add({fmt::format(PtGenIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); - inclusiveRegistry.add({fmt::format(PtEfficiencyIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c)", {HistType::kTH1F, {PtAxisEff}}}); + inclusiveRegistry.add({fmt::format(PtGenIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); + inclusiveRegistry.add({fmt::format(PtEfficiencyIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); occupancy", {HistType::kTH2F, {PtAxisEff, OccuAxis}}}); } } if (doprocessTrackEfficiencyIndexedCentralityFT0M || doprocessTrackEfficiencyIndexedCentralityFT0C) { - binnedRegistry.add({PhiEtaGenDuplicates.data(), "; #varphi; #eta; centrality; tracks", {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({PhiEtaDuplicates.data(), "; #varphi; #eta; centrality; tracks", {HistType::kTH3F, {PhiAxis, EtaAxis, CentAxis}}}); - binnedRegistry.add({PtGenIdx.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtGenIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencyIdx.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencyIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencySecondariesIdx.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({PtEfficiencySecondariesIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({Mask.data(), " ; bit; centrality", {HistType::kTH2F, {{17, -0.5, 16.5}, CentAxis}}}); - binnedRegistry.add({ITSlayers.data(), " ; layer; centrality", {HistType::kTH2F, {{8, 0.5, 8.5}, CentAxis}}}); + binnedRegistry.add({PhiEtaGenDuplicates.data(), "; #varphi; #eta; centrality; occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({PhiEtaDuplicates.data(), "; #varphi; #eta; centrality; occupancy; tracks", {HistType::kTHnSparseF, {PhiAxis, EtaAxis, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtGenIdx.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtGenIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencyIdx.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencyIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencySecondariesIdx.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({PtEfficiencySecondariesIdxNoEtaCut.data(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({Mask.data(), " ; bit; centrality; occupancy", {HistType::kTHnSparseF, {{17, -0.5, 16.5}, CentAxis, OccuAxis}}}); + binnedRegistry.add({ITSlayers.data(), " ; layer; centrality; occupancy", {HistType::kTHnSparseF, {{8, 0.5, 8.5}, CentAxis, OccuAxis}}}); for (auto i = 0u; i < speciesIds.size(); ++i) { - binnedRegistry.add({fmt::format(PtGenIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); - binnedRegistry.add({fmt::format(PtEfficiencyIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality", {HistType::kTH2F, {PtAxisEff, CentAxis}}}); + binnedRegistry.add({fmt::format(PtGenIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); + binnedRegistry.add({fmt::format(PtEfficiencyIdxF.data(), species[i]).c_str(), " ; p_{T} (GeV/c); centrality; occupancy", {HistType::kTHnSparseF, {PtAxisEff, CentAxis, OccuAxis}}}); } } } @@ -372,18 +392,13 @@ struct MultiplicityCounter { auto col = collisions.begin(); for (auto& colid : colids) { col.moveByIndex(colid - col.globalIndex()); - if constexpr (hasRecoCent()) { - float c = -1; - if constexpr (C::template contains()) { - c = col.centFT0C(); - } else if constexpr (C::template contains()) { - c = col.centFT0M(); - } - binnedRegistry.fill(HIST(EventChi2), col.chi2(), c); - binnedRegistry.fill(HIST(EventTimeRes), col.collisionTimeRes(), c); + float c = getRecoCent(c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventChi2), col.chi2(), c, col.trackOccupancyInTimeRange()); + binnedRegistry.fill(HIST(EventTimeRes), col.collisionTimeRes(), c, col.trackOccupancyInTimeRange()); } else { - inclusiveRegistry.fill(HIST(EventChi2), col.chi2()); - inclusiveRegistry.fill(HIST(EventTimeRes), col.collisionTimeRes()); + inclusiveRegistry.fill(HIST(EventChi2), col.chi2(), col.trackOccupancyInTimeRange()); + inclusiveRegistry.fill(HIST(EventTimeRes), col.collisionTimeRes(), col.trackOccupancyInTimeRange()); } } } @@ -447,7 +462,7 @@ struct MultiplicityCounter { Partition pvContribTracksIUEta1 = (nabs(aod::track::eta) < 1.0f) && ((aod::track::flags & (uint32_t)o2::aod::track::PVContributor) == (uint32_t)o2::aod::track::PVContributor); template - int countTracks(T const& tracks, float z, float c) + int countTracks(T const& tracks, float z, float c, float o) { auto Ntrks = 0; for (auto& track : tracks) { @@ -455,18 +470,18 @@ struct MultiplicityCounter { ++Ntrks; } if constexpr (fillHistos) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EtaZvtx), track.eta(), z, c); - binnedRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), c); - binnedRegistry.fill(HIST(PtEta), track.pt(), track.eta(), c); - binnedRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), c); - binnedRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EtaZvtx), track.eta(), z, c, o); + binnedRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), c, o); + binnedRegistry.fill(HIST(PtEta), track.pt(), track.eta(), c, o); + binnedRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), c, o); + binnedRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), c, o); } else { - inclusiveRegistry.fill(HIST(EtaZvtx), track.eta(), z); - inclusiveRegistry.fill(HIST(PhiEta), track.phi(), track.eta()); - inclusiveRegistry.fill(HIST(PtEta), track.pt(), track.eta()); - inclusiveRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY()); - inclusiveRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ()); + inclusiveRegistry.fill(HIST(EtaZvtx), track.eta(), z, o); + inclusiveRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), o); + inclusiveRegistry.fill(HIST(PtEta), track.pt(), track.eta(), o); + inclusiveRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), o); + inclusiveRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), o); } } } @@ -478,23 +493,19 @@ struct MultiplicityCounter { typename C::iterator const& collision, FiTracks const& tracks) { - float c = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c = collision.centFT0C(); - } else if (C::template contains()) { - c = collision.centFT0M(); - } - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), c); + float c = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), o); } if (!useEvSel || isCollisionSelected(collision)) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), o); } auto z = collision.posZ(); usedTracksIds.clear(); @@ -502,57 +513,57 @@ struct MultiplicityCounter { auto groupPVContrib = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto INELgt0PV = groupPVContrib.size() > 0; - auto Ntrks = countTracks(tracks, z, c); - if constexpr (hasRecoCent()) { + auto Ntrks = countTracks(tracks, z, c, o); + if constexpr (has_reco_cent) { if (Ntrks > 0 || INELgt0PV) { if (INELgt0PV) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), c); + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), c, o); } if (Ntrks > 0) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), c); + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), c, o); } for (auto& track : tracks) { if (Ntrks > 0) { - binnedRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, c, o); } if (INELgt0PV) { - binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, c, o); } } } - binnedRegistry.fill(HIST(NtrkZvtx), Ntrks, z, c); - binnedRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, c); + binnedRegistry.fill(HIST(NtrkZvtx), Ntrks, z, c, o); + binnedRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, c, o); } else { if (Ntrks > 0 || INELgt0PV) { if (INELgt0PV) { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), o); } if (Ntrks > 0) { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), o); } for (auto& track : tracks) { if (Ntrks > 0) { - inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, o); } if (INELgt0PV) { - inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, o); } } } - inclusiveRegistry.fill(HIST(NtrkZvtx), Ntrks, z); - inclusiveRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z); + inclusiveRegistry.fill(HIST(NtrkZvtx), Ntrks, z, o); + inclusiveRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, o); } } else { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), o); } } } template - int countTracksAmbiguous(T const& tracks, AT const& atracks, float z, float c) + int countTracksAmbiguous(T const& tracks, AT const& atracks, float z, float c, float o) { auto Ntrks = 0; for (auto& track : atracks) { @@ -574,49 +585,49 @@ struct MultiplicityCounter { ++Ntrks; } if (fillHistos) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EtaZvtx), otrack.eta(), z, c); - binnedRegistry.fill(HIST(PhiEta), otrack.phi(), otrack.eta(), c); - binnedRegistry.fill(HIST(PtEta), otrack.pt(), otrack.eta(), c); - binnedRegistry.fill(HIST(DCAXYPt), otrack.pt(), track.bestDCAXY(), c); - binnedRegistry.fill(HIST(DCAZPt), otrack.pt(), track.bestDCAZ(), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EtaZvtx), otrack.eta(), z, c, o); + binnedRegistry.fill(HIST(PhiEta), otrack.phi(), otrack.eta(), c, o); + binnedRegistry.fill(HIST(PtEta), otrack.pt(), otrack.eta(), c, o); + binnedRegistry.fill(HIST(DCAXYPt), otrack.pt(), track.bestDCAXY(), c, o); + binnedRegistry.fill(HIST(DCAZPt), otrack.pt(), track.bestDCAZ(), c, o); } else { - inclusiveRegistry.fill(HIST(EtaZvtx), otrack.eta(), z); - inclusiveRegistry.fill(HIST(PhiEta), otrack.phi(), otrack.eta()); - inclusiveRegistry.fill(HIST(PtEta), otrack.pt(), otrack.eta()); - inclusiveRegistry.fill(HIST(DCAXYPt), otrack.pt(), track.bestDCAXY()); - inclusiveRegistry.fill(HIST(DCAZPt), otrack.pt(), track.bestDCAZ()); + inclusiveRegistry.fill(HIST(EtaZvtx), otrack.eta(), z, o); + inclusiveRegistry.fill(HIST(PhiEta), otrack.phi(), otrack.eta(), o); + inclusiveRegistry.fill(HIST(PtEta), otrack.pt(), otrack.eta(), o); + inclusiveRegistry.fill(HIST(DCAXYPt), otrack.pt(), track.bestDCAXY(), o); + inclusiveRegistry.fill(HIST(DCAZPt), otrack.pt(), track.bestDCAZ(), o); } } if (otrack.has_collision() && otrack.collisionId() != track.bestCollisionId()) { usedTracksIdsDF.emplace_back(track.trackId()); if constexpr (fillHistos) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(ReassignedEtaZvtx), otrack.eta(), z, c); - binnedRegistry.fill(HIST(ReassignedPhiEta), otrack.phi(), otrack.eta(), c); - binnedRegistry.fill(HIST(ReassignedZvtxCorr), otrack.template collision_as().posZ(), z, c); - binnedRegistry.fill(HIST(ReassignedDCAXYPt), otrack.pt(), track.bestDCAXY(), c); - binnedRegistry.fill(HIST(ReassignedDCAZPt), otrack.pt(), track.bestDCAZ(), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(ReassignedEtaZvtx), otrack.eta(), z, c, o); + binnedRegistry.fill(HIST(ReassignedPhiEta), otrack.phi(), otrack.eta(), c, o); + binnedRegistry.fill(HIST(ReassignedZvtxCorr), otrack.template collision_as().posZ(), z, c, o); + binnedRegistry.fill(HIST(ReassignedDCAXYPt), otrack.pt(), track.bestDCAXY(), c, o); + binnedRegistry.fill(HIST(ReassignedDCAZPt), otrack.pt(), track.bestDCAZ(), c, o); } else { - inclusiveRegistry.fill(HIST(ReassignedEtaZvtx), otrack.eta(), z); - inclusiveRegistry.fill(HIST(ReassignedPhiEta), otrack.phi(), otrack.eta()); - inclusiveRegistry.fill(HIST(ReassignedZvtxCorr), otrack.template collision_as().posZ(), z); - inclusiveRegistry.fill(HIST(ReassignedDCAXYPt), otrack.pt(), track.bestDCAXY()); - inclusiveRegistry.fill(HIST(ReassignedDCAZPt), otrack.pt(), track.bestDCAZ()); + inclusiveRegistry.fill(HIST(ReassignedEtaZvtx), otrack.eta(), z, o); + inclusiveRegistry.fill(HIST(ReassignedPhiEta), otrack.phi(), otrack.eta(), o); + inclusiveRegistry.fill(HIST(ReassignedZvtxCorr), otrack.template collision_as().posZ(), z, o); + inclusiveRegistry.fill(HIST(ReassignedDCAXYPt), otrack.pt(), track.bestDCAXY(), o); + inclusiveRegistry.fill(HIST(ReassignedDCAZPt), otrack.pt(), track.bestDCAZ(), o); } } } else if (!otrack.has_collision()) { if constexpr (fillHistos) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(ExtraEtaZvtx), otrack.eta(), z, c); - binnedRegistry.fill(HIST(ExtraPhiEta), otrack.phi(), otrack.eta(), c); - binnedRegistry.fill(HIST(ExtraDCAXYPt), otrack.pt(), track.bestDCAXY(), c); - binnedRegistry.fill(HIST(ExtraDCAZPt), otrack.pt(), track.bestDCAZ(), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(ExtraEtaZvtx), otrack.eta(), z, c, o); + binnedRegistry.fill(HIST(ExtraPhiEta), otrack.phi(), otrack.eta(), c, o); + binnedRegistry.fill(HIST(ExtraDCAXYPt), otrack.pt(), track.bestDCAXY(), c, o); + binnedRegistry.fill(HIST(ExtraDCAZPt), otrack.pt(), track.bestDCAZ(), c, o); } else { - inclusiveRegistry.fill(HIST(ExtraEtaZvtx), otrack.eta(), z); - inclusiveRegistry.fill(HIST(ExtraPhiEta), otrack.phi(), otrack.eta()); - inclusiveRegistry.fill(HIST(ExtraDCAXYPt), otrack.pt(), track.bestDCAXY()); - inclusiveRegistry.fill(HIST(ExtraDCAZPt), otrack.pt(), track.bestDCAZ()); + inclusiveRegistry.fill(HIST(ExtraEtaZvtx), otrack.eta(), z, o); + inclusiveRegistry.fill(HIST(ExtraPhiEta), otrack.phi(), otrack.eta(), o); + inclusiveRegistry.fill(HIST(ExtraDCAXYPt), otrack.pt(), track.bestDCAXY(), o); + inclusiveRegistry.fill(HIST(ExtraDCAZPt), otrack.pt(), track.bestDCAZ(), o); } } } @@ -633,18 +644,18 @@ struct MultiplicityCounter { ++Ntrks; } if constexpr (fillHistos) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EtaZvtx), track.eta(), z, c); - binnedRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), c); - binnedRegistry.fill(HIST(PtEta), track.pt(), track.eta(), c); - binnedRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), c); - binnedRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EtaZvtx), track.eta(), z, c, o); + binnedRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), c, o); + binnedRegistry.fill(HIST(PtEta), track.pt(), track.eta(), c, o); + binnedRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), c, o); + binnedRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), c, o); } else { - inclusiveRegistry.fill(HIST(EtaZvtx), track.eta(), z); - inclusiveRegistry.fill(HIST(PhiEta), track.phi(), track.eta()); - inclusiveRegistry.fill(HIST(PtEta), track.pt(), track.eta()); - inclusiveRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY()); - inclusiveRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ()); + inclusiveRegistry.fill(HIST(EtaZvtx), track.eta(), z, o); + inclusiveRegistry.fill(HIST(PhiEta), track.phi(), track.eta(), o); + inclusiveRegistry.fill(HIST(PtEta), track.pt(), track.eta(), o); + inclusiveRegistry.fill(HIST(DCAXYPt), track.pt(), track.dcaXY(), o); + inclusiveRegistry.fill(HIST(DCAZPt), track.pt(), track.dcaZ(), o); } } } @@ -657,23 +668,19 @@ struct MultiplicityCounter { FiTracks const& tracks, soa::SmallGroups const& atracks) { - float c = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c = collision.centFT0C(); - } else if (C::template contains()) { - c = collision.centFT0M(); - } - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), c); + float c = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kAll), o); } if (!useEvSel || isCollisionSelected(collision)) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelected), o); } auto z = collision.posZ(); usedTracksIds.clear(); @@ -681,21 +688,21 @@ struct MultiplicityCounter { auto groupPVContrib = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); auto INELgt0PV = groupPVContrib.size() > 0; - auto Ntrks = countTracksAmbiguous(tracks, atracks, z, c); - if constexpr (hasRecoCent()) { + auto Ntrks = countTracksAmbiguous(tracks, atracks, z, c, o); + if constexpr (has_reco_cent) { if (Ntrks > 0 || INELgt0PV) { if (INELgt0PV) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), c); + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), c, o); } if (Ntrks > 0) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), c); + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), c, o); } for (auto& track : atracks) { if (Ntrks > 0) { - binnedRegistry.fill(HIST(EtaZvtx_gt0), track.track_as().eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_gt0), track.track_as().eta(), z, c, o); } if (INELgt0PV) { - binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.track_as().eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.track_as().eta(), z, c, o); } } for (auto& track : tracks) { @@ -706,29 +713,29 @@ struct MultiplicityCounter { continue; } if (Ntrks > 0) { - binnedRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, c, o); } if (INELgt0PV) { - binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, c); + binnedRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, c, o); } } } - binnedRegistry.fill(HIST(NtrkZvtx), Ntrks, z, c); - binnedRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, c); + binnedRegistry.fill(HIST(NtrkZvtx), Ntrks, z, c, o); + binnedRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, c, o); } else { if (Ntrks > 0 || INELgt0PV) { if (INELgt0PV) { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedPVgt0), o); } if (Ntrks > 0) { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kSelectedgt0), o); } for (auto& track : atracks) { if (Ntrks > 0) { - inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.track_as().eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.track_as().eta(), z, o); } if (INELgt0PV) { - inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.track_as().eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.track_as().eta(), z, o); } } for (auto& track : tracks) { @@ -739,21 +746,21 @@ struct MultiplicityCounter { continue; } if (Ntrks > 0) { - inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_gt0), track.eta(), z, o); } if (INELgt0PV) { - inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z); + inclusiveRegistry.fill(HIST(EtaZvtx_PVgt0), track.eta(), z, o); } } } - inclusiveRegistry.fill(HIST(NtrkZvtx), Ntrks, z); - inclusiveRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z); + inclusiveRegistry.fill(HIST(NtrkZvtx), Ntrks, z, o); + inclusiveRegistry.fill(HIST(NpvcZvtx), groupPVContrib.size(), z, o); } } else { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), c); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), c, o); } else { - inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected)); + inclusiveRegistry.fill(HIST(EventSelection), static_cast(EvSelBins::kRejected), o); } } } @@ -845,53 +852,46 @@ struct MultiplicityCounter { if (!collision.has_mcCollision()) { return; } - float c_rec = -1; - float c_gen = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } else if (C::template contains()) { - c_rec = collision.centFT0M(); - } - } + float c_rec = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); auto mcCollision = collision.mcCollision(); - if constexpr (hasSimCent()) { - c_gen = mcCollision.centrality(); - } else if constexpr (hasRecoCent()) { + float c_gen = getSimCent(mcCollision); + if (c_gen < 0 && c_rec >= 0) { c_gen = c_rec; } + auto sample = particles.sliceByCached(aod::mcparticle::mcCollisionId, mcCollision.globalIndex(), cache); for (auto& particle : sample) { if (!isChargedParticle(particle.pdgCode())) { continue; } - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtGenIdxNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtGenIdxNoEtaCut), particle.pt(), c_gen, o); if (std::abs(particle.eta()) < estimatorEta) { - binnedRegistry.fill(HIST(PtGenIdx), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtGenIdx), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenIdxSuff), particle.pt(), c_gen, o); } } } else { - inclusiveRegistry.fill(HIST(PtGenIdxNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtGenIdxNoEtaCut), particle.pt(), o); if (std::abs(particle.eta()) < estimatorEta) { - inclusiveRegistry.fill(HIST(PtGenIdx), particle.pt()); + inclusiveRegistry.fill(HIST(PtGenIdx), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenIdxSuff), particle.pt(), o); } } } @@ -903,106 +903,106 @@ struct MultiplicityCounter { auto relatedTracks = particle.template filtered_tracks_as(); for (auto const& track : relatedTracks) { ++counter; - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { if (!countedNoEtaCut) { - binnedRegistry.fill(HIST(PtEfficiencyIdxNoEtaCut), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtEfficiencyIdxNoEtaCut), particle.pt(), c_gen, o); countedNoEtaCut = true; } if (std::abs(track.eta()) < estimatorEta) { if (!counted) { - binnedRegistry.fill(HIST(PtEfficiencyIdx), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtEfficiencyIdx), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffIdxSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffIdxSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffIdxSuff), particle.pt(), c_gen, o); } counted = true; } } if (counter > 1) { - binnedRegistry.fill(HIST(PtEfficiencySecondariesIdxNoEtaCut), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtEfficiencySecondariesIdxNoEtaCut), particle.pt(), c_gen, o); if (std::abs(track.eta()) < estimatorEta) { - binnedRegistry.fill(HIST(PtEfficiencySecondariesIdx), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtEfficiencySecondariesIdx), particle.pt(), c_gen, o); } } } else { if (!countedNoEtaCut) { - inclusiveRegistry.fill(HIST(PtEfficiencyIdxNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyIdxNoEtaCut), particle.pt(), o); countedNoEtaCut = true; } if (std::abs(track.eta()) < estimatorEta) { if (!counted) { - inclusiveRegistry.fill(HIST(PtEfficiencyIdx), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyIdx), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffIdxSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffIdxSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffIdxSuff), particle.pt(), o); } counted = true; } } if (counter > 1) { - inclusiveRegistry.fill(HIST(PtEfficiencySecondariesIdxNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencySecondariesIdxNoEtaCut), particle.pt(), o); if (std::abs(track.eta()) < estimatorEta) { - inclusiveRegistry.fill(HIST(PtEfficiencySecondariesIdx), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencySecondariesIdx), particle.pt(), o); } } } } - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { for (auto const& track : relatedTracks) { for (auto layer = 0; layer < 7; ++layer) { if (track.itsClusterMap() & (uint8_t(1) << layer)) { - binnedRegistry.fill(HIST(ITSlayers), layer + 1, c_gen); + binnedRegistry.fill(HIST(ITSlayers), layer + 1, c_gen, o); } } auto hasbit = false; for (auto bit = 0; bit < 16; ++bit) { if (track.mcMask() & (uint8_t(1) << bit)) { - binnedRegistry.fill(HIST(Mask), bit, c_gen); + binnedRegistry.fill(HIST(Mask), bit, c_gen, o); hasbit = true; } } if (!hasbit) { - binnedRegistry.fill(HIST(Mask), 16, c_gen); + binnedRegistry.fill(HIST(Mask), 16, c_gen, o); } } if (relatedTracks.size() > 1) { - binnedRegistry.fill(HIST(PhiEtaGenDuplicates), particle.phi(), particle.eta(), c_gen); + binnedRegistry.fill(HIST(PhiEtaGenDuplicates), particle.phi(), particle.eta(), c_gen, o); for (auto const& track : relatedTracks) { - binnedRegistry.fill(HIST(PhiEtaDuplicates), track.phi(), track.eta(), c_gen); + binnedRegistry.fill(HIST(PhiEtaDuplicates), track.phi(), track.eta(), c_gen, o); } } } else { for (auto const& track : relatedTracks) { for (auto layer = 0; layer < 7; ++layer) { if (track.itsClusterMap() & (uint8_t(1) << layer)) { - inclusiveRegistry.fill(HIST(ITSlayers), layer + 1); + inclusiveRegistry.fill(HIST(ITSlayers), layer + 1, o); } } auto hasbit = false; for (auto bit = 0; bit < 16; ++bit) { if (track.mcMask() & (uint8_t(1) << bit)) { - inclusiveRegistry.fill(HIST(Mask), bit); + inclusiveRegistry.fill(HIST(Mask), bit, o); hasbit = true; } } if (!hasbit) { - inclusiveRegistry.fill(HIST(Mask), 16); + inclusiveRegistry.fill(HIST(Mask), 16, o); } } if (relatedTracks.size() > 1) { - inclusiveRegistry.fill(HIST(PhiEtaGenDuplicates), particle.phi(), particle.eta()); + inclusiveRegistry.fill(HIST(PhiEtaGenDuplicates), particle.phi(), particle.eta(), o); for (auto const& track : relatedTracks) { - inclusiveRegistry.fill(HIST(PhiEtaDuplicates), track.phi(), track.eta()); + inclusiveRegistry.fill(HIST(PhiEtaDuplicates), track.phi(), track.eta(), o); } } } @@ -1053,19 +1053,11 @@ struct MultiplicityCounter { if (!collision.has_mcCollision()) { return; } - float c_rec = -1; - float c_gen = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } else if (C::template contains()) { - c_rec = collision.centFT0M(); - } - } + float c_rec = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); auto mcCollision = collision.mcCollision(); - if constexpr (hasSimCent()) { - c_gen = mcCollision.centrality(); - } else if constexpr (hasRecoCent()) { + float c_gen = getSimCent(mcCollision); + if (c_gen < 0 && c_rec >= 0) { c_gen = c_rec; } @@ -1080,41 +1072,41 @@ struct MultiplicityCounter { } if (otrack.has_mcParticle()) { auto particle = otrack.mcParticle_as(); - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen, o); } else { - inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), o); } if (std::abs(otrack.eta()) < estimatorEta) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } } else { - inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), o); } } } } else { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyFakes), otrack.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyFakes), otrack.pt(), c_gen, o); } else { - inclusiveRegistry.fill(HIST(PtEfficiencyFakes), otrack.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyFakes), otrack.pt(), o); } } } @@ -1127,41 +1119,41 @@ struct MultiplicityCounter { } if (track.has_mcParticle()) { auto particle = track.template mcParticle_as(); - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen, o); } else { - inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), o); } if (std::abs(track.eta()) < estimatorEta) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } } else { - inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), o); } } } } else { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), c_gen, o); } else { - inclusiveRegistry.fill(HIST(PtEfficiencyFakes), track.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), o); } } } @@ -1170,32 +1162,32 @@ struct MultiplicityCounter { if (!isChargedParticle(particle.pdgCode())) { continue; } - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtGenNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtGenNoEtaCut), particle.pt(), c_gen, o); if (std::abs(particle.eta()) < estimatorEta) { - binnedRegistry.fill(HIST(PtGen), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtGen), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } } } else { inclusiveRegistry.fill(HIST(PtGenNoEtaCut), particle.pt()); if (std::abs(particle.eta()) < estimatorEta) { - inclusiveRegistry.fill(HIST(PtGen), particle.pt()); + inclusiveRegistry.fill(HIST(PtGen), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), o); } } } @@ -1214,19 +1206,11 @@ struct MultiplicityCounter { if (!collision.has_mcCollision()) { return; } - float c_rec = -1; - float c_gen = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } else if (C::template contains()) { - c_rec = collision.centFT0M(); - } - } + float c_rec = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); auto mcCollision = collision.mcCollision(); - if constexpr (hasSimCent()) { - c_gen = mcCollision.centrality(); - } else if constexpr (hasRecoCent()) { + float c_gen = getSimCent(mcCollision); + if (c_gen < 0 && c_rec >= 0) { c_gen = c_rec; } @@ -1236,40 +1220,40 @@ struct MultiplicityCounter { for (auto const& track : tracks) { if (track.has_mcParticle()) { auto particle = track.template mcParticle_as(); - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), c_gen, o); if (std::abs(track.eta()) < estimatorEta) { - binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtEfficiency), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), c_gen, o); } } } else { - inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyNoEtaCut), particle.pt(), o); if (std::abs(track.eta()) < estimatorEta) { - inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt()); + inclusiveRegistry.fill(HIST(PtEfficiency), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtEffSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtEffSuff), particle.pt(), o); } } } } else { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), c_gen, o); } else { - inclusiveRegistry.fill(HIST(PtEfficiencyFakes), track.pt()); + inclusiveRegistry.fill(HIST(PtEfficiencyFakes), track.pt(), o); } } } @@ -1278,32 +1262,32 @@ struct MultiplicityCounter { if (!isChargedParticle(particle.pdgCode())) { continue; } - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(PtGenNoEtaCut), particle.pt(), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(PtGenNoEtaCut), particle.pt(), c_gen, o); if (std::abs(particle.eta()) < estimatorEta) { - binnedRegistry.fill(HIST(PtGen), particle.pt(), c_gen); + binnedRegistry.fill(HIST(PtGen), particle.pt(), c_gen, o); if (particle.pdgCode() == speciesIds[0]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[1]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[2]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } else if (particle.pdgCode() == speciesIds[3]) { - binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), c_gen); + binnedRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), c_gen, o); } } } else { - inclusiveRegistry.fill(HIST(PtGenNoEtaCut), particle.pt()); + inclusiveRegistry.fill(HIST(PtGenNoEtaCut), particle.pt(), o); if (std::abs(particle.eta()) < estimatorEta) { - inclusiveRegistry.fill(HIST(PtGen), particle.pt()); + inclusiveRegistry.fill(HIST(PtGen), particle.pt(), o); if (particle.pdgCode() == speciesIds[0]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[0]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[1]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[1]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[2]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[2]) + HIST(PtGenSuff), particle.pt(), o); } else if (particle.pdgCode() == speciesIds[3]) { - inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt()); + inclusiveRegistry.fill(HIST(prefix) + HIST(species[3]) + HIST(PtGenSuff), particle.pt(), o); } } } @@ -1475,6 +1459,7 @@ struct MultiplicityCounter { std::vector NrecPerCol; std::vector c_recPerCol; + std::vector OccuPerCol; std::vector NPVPerCol; std::vector NFT0APerCol; std::vector NFT0CPerCol; @@ -1488,13 +1473,19 @@ struct MultiplicityCounter { Particles const& particles, FiTracks const& tracks, FiReTracks const& atracks) { float c_gen = -1; - // add generated centrality estimation - if constexpr (hasSimCent()) { - c_gen = mcCollision.centrality(); + if constexpr (has_Centrality) { + c_gen = getSimCent(mcCollision); + } else { + if constexpr (has_FT0C) { + c_gen = getGenCentFT0C(mcCollision); + } else if (has_FT0M) { + c_gen = getGenCentFT0M(mcCollision); + } } NrecPerCol.clear(); c_recPerCol.clear(); + OccuPerCol.clear(); NPVPerCol.clear(); NFT0APerCol.clear(); NFT0CPerCol.clear(); @@ -1507,174 +1498,159 @@ struct MultiplicityCounter { auto moreThanOne = 0; LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(), collisions.size()); - [[maybe_unused]] float min_c_rec = 2e2; - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { + float min_c_rec = 2e2; for (auto& collision : collisions) { if (!useEvSel || isCollisionSelected(collision)) { - float c = -1; - if constexpr (C::template contains()) { - c = collision.centFT0C(); - } else if (C::template contains()) { - c = collision.centFT0M(); - } + float c = getRecoCent(collision); if (c < min_c_rec) { min_c_rec = c; } } } + if constexpr (!has_Centrality) { + if (c_gen < 0) { + c_gen = min_c_rec; // if there is no generator centrality info, fall back to reco (from the largest reco collision) + } + } + } + float o_max = -1; + for (auto& collision : collisions) { + if (!useEvSel || isCollisionSelected(collision)) { + auto o = collision.trackOccupancyInTimeRange(); + if (o > o_max) { + o_max = o; + } + } } for (auto& collision : collisions) { usedTracksIds.clear(); - float c_rec = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } else if (C::template contains()) { - c_rec = collision.centFT0M(); - } - if constexpr (hasSimCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), c_gen); - } else { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), min_c_rec); - } + float c_rec = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), o); } if (!useEvSel || isCollisionSelected(collision)) { c_recPerCol.emplace_back(c_rec); + OccuPerCol.emplace_back(o); auto z = collision.posZ(); ++moreThanOne; - if constexpr (hasRecoCent() && !hasSimCent()) { - if (!atLeastOne) { - c_gen = min_c_rec; // if there is no generator centrality info, fall back to reco (from the largest reco collision) - } - } atLeastOne = true; auto groupPVcontrib = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); if (groupPVcontrib.size() > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), o); } atLeastOne_PVgt0 = true; } auto perCollisionASample = atracks.sliceBy(perColU, collision.globalIndex()); auto perCollisionSample = tracks.sliceBy(perCol, collision.globalIndex()); - auto Nrec = countTracksAmbiguous(perCollisionSample, perCollisionASample, z, c_rec); + auto Nrec = countTracksAmbiguous(perCollisionSample, perCollisionASample, z, c_rec, o); NrecPerCol.emplace_back(Nrec); NPVPerCol.emplace_back(groupPVcontrib.size()); fillFIT(collision, NFT0APerCol, NFT0CPerCol, NFDDAPerCol, NFDDCPerCol); - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), o); } if (Nrec > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), o); } atLeastOne_gt0 = true; } - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ(), c_rec); - binnedRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), c_rec); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ(), c_rec, o); + binnedRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), c_rec, o); } else { inclusiveRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ()); - inclusiveRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ()); + inclusiveRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), o); } } } auto nCharged = countParticles(particles); - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), c_gen); - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), c_gen); + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), c_gen, o_max); } else { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), mcCollision.processId()); - } else { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); - } + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), o_max); + if (useProcId) { + if constexpr (has_hepmc_pid) { + inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), mcCollision.processId()); } else { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); } - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen)); } if (nCharged > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), c_gen, o_max); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), o_max); } } if (fillResponse) { for (auto i = 0U; i < NrecPerCol.size(); ++i) { - if constexpr (hasRecoCent()) { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i], mcCollision.processId()); - } else { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); - } + if constexpr (has_reco_cent) { + if (useProcId) { + if constexpr (has_hepmc_pid) { + binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i], mcCollision.processId()); } else { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); } if (addFT0 && !addFDD) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else if (addFDD && !addFT0) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else if (addFT0 && addFDD) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } } else { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), mcCollision.processId()); - } else { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); - } + if (useProcId) { + if constexpr (has_hepmc_pid) { + inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), mcCollision.processId()); } else { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); } if (addFT0 && !addFDD) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else if (addFDD && !addFT0) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else if (addFT0 && addFDD) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), OccuPerCol[i]); } } } if (moreThanOne > 1) { - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(SplitMult), nCharged, mcCollision.posZ(), c_gen); } else { inclusiveRegistry.fill(HIST(SplitMult), nCharged, mcCollision.posZ()); @@ -1683,7 +1659,7 @@ struct MultiplicityCounter { } if (collisions.size() == 0) { - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(NotFoundZvtx), mcCollision.posZ(), c_gen); } else { inclusiveRegistry.fill(HIST(NotFoundZvtx), mcCollision.posZ()); @@ -1691,7 +1667,7 @@ struct MultiplicityCounter { } auto zmc = mcCollision.posZ(); - fillParticleHistos()>(particles, zmc, nCharged, c_gen, atLeastOne, atLeastOne_gt0, atLeastOne_PVgt0); + fillParticleHistos>(particles, zmc, nCharged, c_gen, atLeastOne, atLeastOne_gt0, atLeastOne_PVgt0); } template @@ -1701,9 +1677,14 @@ struct MultiplicityCounter { Particles const& particles, FiTracks const& tracks) { float c_gen = -1; - // add generated centrality estimation - if constexpr (hasSimCent()) { - c_gen = mcCollision.centrality(); + if constexpr (has_Centrality) { + c_gen = getSimCent(mcCollision); + } else { + if constexpr (has_FT0C) { + c_gen = getGenCentFT0C(mcCollision); + } else if (has_FT0M) { + c_gen = getGenCentFT0M(mcCollision); + } } bool atLeastOne = false; @@ -1714,179 +1695,164 @@ struct MultiplicityCounter { NrecPerCol.clear(); c_recPerCol.clear(); + OccuPerCol.clear(); NPVPerCol.clear(); NFT0APerCol.clear(); NFT0CPerCol.clear(); NFDDAPerCol.clear(); NFDDCPerCol.clear(); - [[maybe_unused]] float min_c_rec = 2e2; - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { + float min_c_rec = 2e2; for (auto& collision : collisions) { if (!useEvSel || isCollisionSelected(collision)) { - float c = -1; - if constexpr (C::template contains()) { - c = collision.centFT0C(); - } else if (C::template contains()) { - c = collision.centFT0M(); - } + float c = getRecoCent(collision); if (c < min_c_rec) { min_c_rec = c; } } } + if constexpr (!has_Centrality) { + if (c_gen < 0) { + c_gen = min_c_rec; // if there is no generator centrality info, fall back to reco (from the largest reco collision) + } + } + } + float o_max = -1; + for (auto& collision : collisions) { + if (!useEvSel || isCollisionSelected(collision)) { + auto o = collision.trackOccupancyInTimeRange(); + if (o > o_max) { + o_max = o; + } + } } for (auto& collision : collisions) { usedTracksIds.clear(); - float c_rec = -1; - if constexpr (hasRecoCent()) { - if constexpr (C::template contains()) { - c_rec = collision.centFT0C(); - } else if (C::template contains()) { - c_rec = collision.centFT0M(); - } - if constexpr (hasSimCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), c_gen); - } else { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), min_c_rec); - } + float c_rec = getRecoCent(collision); + float o = collision.trackOccupancyInTimeRange(); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kRec), o); } if (!useEvSel || isCollisionSelected(collision)) { c_recPerCol.emplace_back(c_rec); auto z = collision.posZ(); ++moreThanOne; - if constexpr (hasRecoCent() && !hasSimCent()) { - if (!atLeastOne) { - c_gen = min_c_rec; // if there is no generator centrality info, fall back to reco (from the largest reco collision) - } - } atLeastOne = true; auto groupPVcontrib = pvContribTracksIUEta1->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); if (groupPVcontrib.size() > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedPVgt0), o); } atLeastOne_PVgt0 = true; } auto perCollisionSample = tracks.sliceBy(perCol, collision.globalIndex()); - auto Nrec = countTracks(perCollisionSample, z, c_rec); + auto Nrec = countTracks(perCollisionSample, z, c_rec, o); NrecPerCol.emplace_back(Nrec); NPVPerCol.emplace_back(groupPVcontrib.size()); fillFIT(collision, NFT0APerCol, NFT0CPerCol, NFDDAPerCol, NFDDCPerCol); - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelected), o); } if (Nrec > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), c_gen, o); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kSelectedgt0), o); } atLeastOne_gt0 = true; } - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ(), c_rec); - binnedRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), c_rec); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ(), c_rec, o); + binnedRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), c_rec, o); } else { - inclusiveRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ()); - inclusiveRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ()); + inclusiveRegistry.fill(HIST(NtrkZvtxGen), Nrec, collision.posZ(), o); + inclusiveRegistry.fill(HIST(NpvcZvxtGen), groupPVcontrib.size(), collision.posZ(), o); } } } auto nCharged = countParticles(particles); - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), c_gen); - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), c_gen); + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), c_gen, o_max); } else { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), mcCollision.processId()); - } else { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); - } + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen), o_max); + if (useProcId) { + if constexpr (has_hepmc_pid) { + inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ(), mcCollision.processId()); } else { - inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { inclusiveRegistry.fill(HIST(NtrkZvtxGen_t), nCharged, mcCollision.posZ()); } - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGen)); } if (nCharged > 0) { - if constexpr (hasRecoCent()) { - binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), c_gen); + if constexpr (has_reco_cent) { + binnedRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), c_gen, o_max); } else { - inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0)); + inclusiveRegistry.fill(HIST(Efficiency), static_cast(EvEffBins::kGengt0), o_max); } } if (fillResponse) { for (auto i = 0U; i < NrecPerCol.size(); ++i) { - if constexpr (hasRecoCent()) { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i], mcCollision.processId()); - } else { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); - } + if constexpr (has_reco_cent) { + if (useProcId) { + if constexpr (has_hepmc_pid) { + binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i], mcCollision.processId()); } else { - binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { binnedRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), c_recPerCol[i]); } if (addFT0 && !addFDD) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else if (addFDD && !addFT0) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else if (addFT0 && addFDD) { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } else { - binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), c_recPerCol[i]); + binnedRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), c_recPerCol[i], OccuPerCol[i]); } } else { - if constexpr (soa::is_soa_join_v) { - if constexpr (MC::template contains()) { - if (useProcId) { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), mcCollision.processId()); - } else { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); - } + if (useProcId) { + if constexpr (has_hepmc_pid) { + inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ(), mcCollision.processId()); } else { - inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); + LOGP(fatal, "useProcId = true, but MC collision does not have HepMC info"); } } else { inclusiveRegistry.fill(HIST(EfficiencyMult), nCharged, mcCollision.posZ()); } if (addFT0 && !addFDD) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else if (addFDD && !addFT0) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else if (addFT0 && addFDD) { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, NFT0APerCol[i], NFT0CPerCol[i], NFDDAPerCol[i], NFDDCPerCol[i], mcCollision.posZ(), OccuPerCol[i]); } else { - inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ()); + inclusiveRegistry.fill(HIST(Response), NrecPerCol[i], NPVPerCol[i], nCharged, mcCollision.posZ(), OccuPerCol[i]); } } } if (moreThanOne > 1) { - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(SplitMult), nCharged, mcCollision.posZ(), c_gen); } else { inclusiveRegistry.fill(HIST(SplitMult), nCharged, mcCollision.posZ()); @@ -1895,14 +1861,14 @@ struct MultiplicityCounter { } if (collisions.size() == 0) { - if constexpr (hasRecoCent()) { + if constexpr (has_reco_cent) { binnedRegistry.fill(HIST(NotFoundZvtx), mcCollision.posZ(), c_gen); } else { inclusiveRegistry.fill(HIST(NotFoundZvtx), mcCollision.posZ()); } } auto zmc = mcCollision.posZ(); - fillParticleHistos()>(particles, zmc, nCharged, c_gen, atLeastOne, atLeastOne_gt0, atLeastOne_PVgt0); + fillParticleHistos>(particles, zmc, nCharged, c_gen, atLeastOne, atLeastOne_gt0, atLeastOne_PVgt0); } using MC = aod::McCollisions; // soa::Join; @@ -1967,6 +1933,26 @@ struct MultiplicityCounter { PROCESS_SWITCH(MultiplicityCounter, processGenFT0C, "Process generator-level info (FT0C centrality) w/o ambiguous", false); + void processGenAmbiguousFT0Cplus( + soa::Join::iterator const& mcCollision, + o2::soa::SmallGroups> const& collisions, + Particles const& particles, FiTracks const& tracks, FiReTracks const& atracks, aod::FT0s const&, aod::FDDs const&) + { + processGenGeneralAmbiguous, ExColsCentFT0C>(mcCollision, collisions, particles, tracks, atracks); + } + + PROCESS_SWITCH(MultiplicityCounter, processGenAmbiguousFT0Cplus, "Process generator-level info (FT0C centrality + gen level)", false); + + void processGenFT0Cplus( + soa::Join::iterator const& mcCollision, + o2::soa::SmallGroups> const& collisions, + Particles const& particles, FiTracks const& tracks, aod::FT0s const&, aod::FDDs const&) + { + processGenGeneral, ExColsCentFT0C>(mcCollision, collisions, particles, tracks); + } + + PROCESS_SWITCH(MultiplicityCounter, processGenFT0Cplus, "Process generator-level info (FT0C centrality + gen level) w/o ambiguous", false); + void processGenAmbiguousExFT0C( MCex::iterator const& mcCollision, o2::soa::SmallGroups> const& collisions, @@ -2007,6 +1993,26 @@ struct MultiplicityCounter { PROCESS_SWITCH(MultiplicityCounter, processGenFT0M, "Process generator-level info (FT0M centrality) w/o ambiguous", false); + void processGenAmbiguousFT0Mplus( + soa::Join::iterator const& mcCollision, + o2::soa::SmallGroups> const& collisions, + Particles const& particles, FiTracks const& tracks, FiReTracks const& atracks, aod::FT0s const&, aod::FDDs const&) + { + processGenGeneralAmbiguous, ExColsCentFT0M>(mcCollision, collisions, particles, tracks, atracks); + } + + PROCESS_SWITCH(MultiplicityCounter, processGenAmbiguousFT0Mplus, "Process generator-level info (FT0M centrality + gen level)", false); + + void processGenFT0Mplus( + soa::Join::iterator const& mcCollision, + o2::soa::SmallGroups> const& collisions, + Particles const& particles, FiTracks const& tracks, aod::FT0s const&, aod::FDDs const&) + { + processGenGeneral, ExColsCentFT0M>(mcCollision, collisions, particles, tracks); + } + + PROCESS_SWITCH(MultiplicityCounter, processGenFT0Mplus, "Process generator-level info (FT0M centrality + gen level) w/o ambiguous", false); + void processGenAmbiguousExFT0M( MCex::iterator const& mcCollision, o2::soa::SmallGroups> const& collisions, diff --git a/PWGMM/Mult/Tasks/heavy-ion-mult.cxx b/PWGMM/Mult/Tasks/heavy-ion-mult.cxx index 61778ff522e..0e0a08568e5 100644 --- a/PWGMM/Mult/Tasks/heavy-ion-mult.cxx +++ b/PWGMM/Mult/Tasks/heavy-ion-mult.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include "bestCollisionTable.h" #include "CCDB/BasicCCDBManager.h" @@ -42,6 +43,9 @@ #include "Framework/runDataProcessing.h" #include "ReconstructionDataFormats/GlobalTrackID.h" #include "ReconstructionDataFormats/Track.h" +#include "Index.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" using namespace o2; using namespace o2::framework; @@ -57,6 +61,7 @@ using TrackMCTrueTable = aod::McParticles; using CollisionMCRecTable = soa::SmallGroups>; using TrackMCRecTable = soa::Join; using FilTrackMCRecTable = soa::Filtered; +using v0trackcandidates = soa::Join; enum { kTrackTypebegin = 0, @@ -74,6 +79,19 @@ enum { 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; @@ -86,7 +104,7 @@ static constexpr TrackSelectionFlags::flagtype trackSelectionDCA = static constexpr TrackSelectionFlags::flagtype trackSelectionDCAXYonly = TrackSelectionFlags::kDCAxy; -AxisSpec axisEvent{9, 0.5, 9.5, "#Event", "EventAxis"}; +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, 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"}; @@ -94,6 +112,9 @@ AxisSpec axisPhi2{629, 0, 2 * M_PI, "#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"}; struct HeavyIonMultiplicity { @@ -105,6 +126,13 @@ struct HeavyIonMultiplicity { Configurable etaRange{"eta-range", 1.0f, "Eta range to consider"}; Configurable VtxRange{"vertex-range", 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"}; ConfigurableAxis multHistBin{"MultDistBinning", {501, -0.5, 500.5}, ""}; ConfigurableAxis PVHistBin{"PVDistBinning", {501, -0.5, 500.5}, ""}; ConfigurableAxis FV0AmultHistBin{"FV0AMultDistBinning", {501, -0.5, 500.5}, ""}; @@ -112,6 +140,7 @@ struct HeavyIonMultiplicity { ConfigurableAxis FT0CmultHistBin{"FT0CMultDistBinning", {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}, ""}; Configurable IsApplySameBunchPileup{"IsApplySameBunchPileup", true, "Enable SameBunchPileup cut"}; Configurable IsApplyGoodZvtxFT0vsPV{"IsApplyGoodZvtxFT0vsPV", true, "Enable GoodZvtxFT0vsPV cut"}; @@ -122,16 +151,19 @@ struct HeavyIonMultiplicity { 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 IsApplyFT0CbasedOccupancy{"IsApplyFT0CbasedOccupancy", true, "Enable FT0CbasedOccupancy cut"}; void init(InitContext const&) { - AxisSpec axisMult = {multHistBin}; - AxisSpec axisPV = {PVHistBin}; - AxisSpec axisFV0AMult = {FV0AmultHistBin}; - AxisSpec axisFT0AMult = {FT0AmultHistBin}; - AxisSpec axisFT0CMult = {FT0CmultHistBin}; + 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}; + AxisSpec axisPT = {pTHistBin, "pT", "pTAxis"}; + AxisSpec axisOccupancy = {OccupancyBin, "occupancy", "OccupancyAxis"}; histos.add("EventHist", "EventHist", kTH1D, {axisEvent}, false); histos.add("VtxZHist", "VtxZHist", kTH1D, {axisVtxZ}, false); @@ -147,29 +179,30 @@ struct HeavyIonMultiplicity { x->SetBinLabel(7, "kIsVertexTRDmatched"); // at least one of vertex contributors is matched to TRD x->SetBinLabel(8, "Centrality"); x->SetBinLabel(9, "ApplyExtraCorrCut"); + x->SetBinLabel(10, "ApplyNoCollInTimeRangeStandard"); if (doprocessData) { histos.add("CentPercentileHist", "CentPercentileHist", kTH1D, {axisCent}, false); - histos.add("CentHistInsideTrackloop", "CentHistInsideTrackloop", kTH1D, {axisCent}, false); histos.add("hdatamult", "hdatamult", kTHnSparseD, {axisVtxZ, axisMult, CentAxis}, false); - histos.add("hdatadndeta", "hdatadndeta", kTHnSparseD, {axisVtxZ, CentAxis, axisEta, axisPhi, axisPT, AxisTrackType}, false); - histos.add("hdatazvtxcent", "hdatazvtxcent", kTH2D, {axisVtxZ, CentAxis}, false); - histos.add("PhiVsEtaHistBeforePhiCut", "PhiVsEtaHistBeforePhiCut", kTH2D, {axisPhi2, axisEta}, false); - histos.add("PhiVsEtaHistAfterPhiCut", "PhiVsEtaHistAfterPhiCut", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hdatadndeta", "hdatadndeta", kTHnSparseD, {axisVtxZ, CentAxis, axisOccupancy, axisEta, axisPhi, AxisTrackType}, false); + histos.add("hdatazvtxcent", "hdatazvtxcent", kTH3D, {axisVtxZ, CentAxis, axisOccupancy}, false); + histos.add("PhiVsEtaHist", "PhiVsEtaHist", kTH2D, {axisPhi2, axisEta}, false); } - if (doprocessMonteCarlo || doprocessMCpTefficiency || doprocessMCcheckFakeTracks) { + if (doprocessMonteCarlo || doprocessMCpTefficiency || doprocessMCcheckFakeTracks || doprocessMCfillspecies) { histos.add("CentPercentileMCRecHist", "CentPercentileMCRecHist", kTH1D, {axisCent}, false); - histos.add("hmczvtxcent", "hmczvtxcent", kTH2D, {axisVtxZ, CentAxis}, false); + histos.add("hmczvtxcent", "hmczvtxcent", kTH3D, {axisVtxZ, CentAxis, axisOccupancy}, false); } if (doprocessMonteCarlo) { - histos.add("MCCentHistInsideTrackloop", "MCCentHistInsideTrackloop", kTH1D, {axisCent}, false); - histos.add("MCrecPhiVsEtaHistBeforePhiCut", "MCrecPhiVsEtaHistBeforePhiCut", kTH2D, {axisPhi2, axisEta}, false); - histos.add("MCrecPhiVsEtaHistAfterPhiCut", "MCrecPhiVsEtaHistAfterPhiCut", kTH2D, {axisPhi2, axisEta}, false); - histos.add("hmcrecdndeta", "hmcrecdndeta", kTHnSparseD, {axisVtxZ, CentAxis, axisEta, axisPhi}, false); + histos.add("MCrecPhiVsEtaHist", "MCrecPhiVsEtaHist", kTH2D, {axisPhi2, axisEta}, false); + histos.add("hmcrecdndeta", "hmcrecdndeta", kTHnSparseD, {axisVtxZ, CentAxis, axisOccupancy, axisEta, axisPhi}, false); histos.add("hmcgendndeta", "hmcgendndeta", kTHnSparseD, {axisVtxZ, CentAxis, axisEta, axisPhi, AxisGenpTVary}, false); - histos.add("hdndeta0_5", "hdndeta0_5", kTH1D, {axisEta}, false); + } + + if (doprocessMCfillspecies) { + histos.add("FillMCrecSpecies", "FillMCrecSpecies", kTHnSparseD, {CentAxis, axisOccupancy, axisEta, AxisSpecies}, false); + histos.add("FillMCgenSpecies", "FillMCgenSpecies", kTHnSparseD, {CentAxis, axisEta, AxisSpecies}, false); } if (doprocessMCpTefficiency) { @@ -195,8 +228,50 @@ struct HeavyIonMultiplicity { 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); + } } + template + bool IsTrackSelected(CheckTrack const& track) + { + if (std::abs(track.eta()) >= etaRange) { + return false; + } + if (IsApplyExtraPhiCut && ((track.phi() > 3.07666 && track.phi() < 3.12661) || track.phi() <= 0.03 || track.phi() >= 6.253)) { + 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()) < 3) { + return false; + } + if (std::abs(track.eta()) >= etaRange) { + return false; + } + if (IsApplyExtraPhiCut && ((track.phi() > 3.07666 && track.phi() < 3.12661) || track.phi() <= 0.03 || track.phi() >= 6.253)) { + return false; + } + return true; + } template bool IsEventSelected(CheckCol const& col) { @@ -242,6 +317,10 @@ struct HeavyIonMultiplicity { } histos.fill(HIST("EventHist"), 9); + if (IsApplyNoCollInTimeRangeStandard && !col.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + return false; + } + histos.fill(HIST("EventHist"), 10); return true; } @@ -254,54 +333,42 @@ struct HeavyIonMultiplicity { void processData(CollisionDataTable::iterator const& collision, FilTrackDataTable const& tracks) { - if (!IsEventSelected(collision)) { return; } - histos.fill(HIST("VtxZHist"), collision.posZ()); histos.fill(HIST("CentPercentileHist"), collision.centFT0C()); - histos.fill(HIST("hdatazvtxcent"), collision.posZ(), collision.centFT0C()); + auto OccupancyValue = IsApplyFT0CbasedOccupancy ? collision.ft0cOccupancyInTimeRange() : collision.trackOccupancyInTimeRange(); + histos.fill(HIST("hdatazvtxcent"), collision.posZ(), collision.centFT0C(), OccupancyValue); auto NchTracks = 0; for (auto& track : tracks) { - if (std::abs(track.eta()) >= etaRange) { + if (!IsTrackSelected(track)) { continue; } - histos.fill(HIST("PhiVsEtaHistBeforePhiCut"), track.phi(), track.eta()); - if (IsApplyExtraPhiCut) { - if ((track.phi() > 3.07666 && track.phi() < 3.12661) || track.phi() <= 0.03 || track.phi() >= 6.253) { - continue; - } - } - histos.fill(HIST("PhiVsEtaHistAfterPhiCut"), track.phi(), track.eta()); + histos.fill(HIST("PhiVsEtaHist"), track.phi(), track.eta()); NchTracks++; - histos.fill(HIST("CentHistInsideTrackloop"), collision.centFT0C()); - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), track.eta(), track.phi(), track.pt(), kGlobalplusITS); - + histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kGlobalplusITS); if (track.hasTPC()) { - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), track.eta(), track.phi(), track.pt(), kGlobalonly); + histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kGlobalonly); } else { - histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), track.eta(), track.phi(), track.pt(), kITSonly); + histos.fill(HIST("hdatadndeta"), collision.posZ(), collision.centFT0C(), OccupancyValue, track.eta(), track.phi(), kITSonly); } } histos.fill(HIST("hdatamult"), collision.posZ(), NchTracks, collision.centFT0C()); } - PROCESS_SWITCH(HeavyIonMultiplicity, processData, "process data CentFT0C", false); void processCorrelation(CollisionDataTable::iterator const& collision, FilTrackDataTable const& tracks) { - if (!IsEventSelected(collision)) { return; } - - if (std::abs(collision.posZ()) > VtxRange) { + if (std::abs(collision.posZ()) >= VtxRange) { return; } - histos.fill(HIST("VtxZHist"), collision.posZ()); + auto NchTracks = 0; for (auto& track : tracks) { if (std::abs(track.eta()) >= etaRange) { @@ -309,77 +376,39 @@ struct HeavyIonMultiplicity { } NchTracks++; } - histos.fill(HIST("GlobalMult_vs_FT0A"), NchTracks, collision.multFT0A()); histos.fill(HIST("GlobalMult_vs_FT0C"), NchTracks, collision.multFT0C()); histos.fill(HIST("NPVtracks_vs_FT0C"), collision.multNTracksPV(), collision.multFT0C()); histos.fill(HIST("GlobalMult_vs_FV0A"), NchTracks, collision.multFV0A()); histos.fill(HIST("NPVtracks_vs_GlobalMult"), collision.multNTracksPV(), NchTracks); } - PROCESS_SWITCH(HeavyIonMultiplicity, processCorrelation, "do correlation study in data", false); void processMonteCarlo(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) { - for (auto& RecCollision : RecCollisions) { - if (!IsEventSelected(RecCollision)) { continue; } - histos.fill(HIST("VtxZHist"), RecCollision.posZ()); histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C()); + auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { - if (std::abs(Rectrack.eta()) >= etaRange) { + if (!IsTrackSelected(Rectrack)) { continue; } - histos.fill(HIST("MCrecPhiVsEtaHistBeforePhiCut"), Rectrack.phi(), Rectrack.eta()); - if (IsApplyExtraPhiCut) { - if ((Rectrack.phi() > 3.07666 && Rectrack.phi() < 3.12661) || Rectrack.phi() <= 0.03 || Rectrack.phi() >= 6.253) { - continue; - } - } - histos.fill(HIST("MCrecPhiVsEtaHistAfterPhiCut"), Rectrack.phi(), Rectrack.eta()); - histos.fill(HIST("MCCentHistInsideTrackloop"), RecCollision.centFT0C()); - histos.fill(HIST("hmcrecdndeta"), RecCollision.posZ(), RecCollision.centFT0C(), Rectrack.eta(), Rectrack.phi()); - if (RecCollision.centFT0C() >= 0 && RecCollision.centFT0C() < 5.0) { - histos.fill(HIST("hdndeta0_5"), Rectrack.eta()); - } + histos.fill(HIST("MCrecPhiVsEtaHist"), Rectrack.phi(), Rectrack.eta()); + histos.fill(HIST("hmcrecdndeta"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Rectrack.phi()); } // track (mcrec) loop for (auto& particle : GenParticles) { - - if (!particle.isPhysicalPrimary()) { + if (!IsGenTrackSelected(particle)) { continue; } - - if (!particle.producedByGenerator()) { - continue; - } - - auto pdgParticle = pdg->GetParticle(particle.pdgCode()); - if (pdgParticle == nullptr) { - continue; - } - - if (std::abs(pdgParticle->Charge()) < 3) { - continue; - } - - if (std::abs(particle.eta()) >= etaRange) { - continue; - } - if (IsApplyExtraPhiCut) { - if ((particle.phi() > 3.07666 && particle.phi() < 3.12661) || particle.phi() <= 0.03 || particle.phi() >= 6.253) { - continue; - } - } histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), 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); @@ -388,27 +417,23 @@ struct HeavyIonMultiplicity { histos.fill(HIST("hmcgendndeta"), RecCollision.posZ(), RecCollision.centFT0C(), particle.eta(), particle.phi(), kGenpTdown); } } // track (mcgen) loop - } // collision loop + } // collision loop } - PROCESS_SWITCH(HeavyIonMultiplicity, processMonteCarlo, "process MC CentFT0C", false); void processMCpTefficiency(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) { - for (auto& RecCollision : RecCollisions) { - if (!IsEventSelected(RecCollision)) { continue; } - - if (std::abs(RecCollision.posZ()) > VtxRange) { + if (std::abs(RecCollision.posZ()) >= VtxRange) { continue; } - histos.fill(HIST("VtxZHist"), RecCollision.posZ()); histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C()); + auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { @@ -424,25 +449,7 @@ struct HeavyIonMultiplicity { } for (auto& particle : GenParticles) { - - if (!particle.isPhysicalPrimary()) { - continue; - } - - if (!particle.producedByGenerator()) { - continue; - } - - auto pdgParticle = pdg->GetParticle(particle.pdgCode()); - if (pdgParticle == nullptr) { - continue; - } - - if (std::abs(pdgParticle->Charge()) < 3) { - continue; - } - - if (std::abs(particle.eta()) >= etaRange) { + if (!IsGenTrackSelected(particle)) { continue; } histos.fill(HIST("hmcgendndpt"), RecCollision.centFT0C(), particle.pt(), kNoGenpTVar); @@ -456,25 +463,21 @@ struct HeavyIonMultiplicity { } } } - PROCESS_SWITCH(HeavyIonMultiplicity, processMCpTefficiency, "process MC pTefficiency", false); void processMCcheckFakeTracks(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCollisions, FilTrackMCRecTable const& RecTracks) { - for (auto& RecCollision : RecCollisions) { - if (!IsEventSelected(RecCollision)) { continue; } - - if (std::abs(RecCollision.posZ()) > VtxRange) { + if (std::abs(RecCollision.posZ()) >= VtxRange) { continue; } - histos.fill(HIST("VtxZHist"), RecCollision.posZ()); histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); - histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C()); + auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); for (auto& Rectrack : Rectrackspart) { @@ -500,8 +503,134 @@ struct HeavyIonMultiplicity { } } } - PROCESS_SWITCH(HeavyIonMultiplicity, processMCcheckFakeTracks, "Check Fake tracks", false); + + void processMCfillspecies(CollisionMCTrueTable::iterator const&, CollisionMCRecTable const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks) + { + for (auto& RecCollision : RecCollisions) { + if (!IsEventSelected(RecCollision)) { + continue; + } + if (std::abs(RecCollision.posZ()) >= VtxRange) { + continue; + } + histos.fill(HIST("VtxZHist"), RecCollision.posZ()); + histos.fill(HIST("CentPercentileMCRecHist"), RecCollision.centFT0C()); + auto OccupancyValue = IsApplyFT0CbasedOccupancy ? RecCollision.ft0cOccupancyInTimeRange() : RecCollision.trackOccupancyInTimeRange(); + histos.fill(HIST("hmczvtxcent"), RecCollision.posZ(), RecCollision.centFT0C(), OccupancyValue); + + auto Rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex()); + std::vector mclabels; + for (auto& Rectrack : Rectrackspart) { + if (!IsTrackSelected(Rectrack)) { + continue; + } + histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(kSpAll)); + if (Rectrack.has_mcParticle()) { + Int_t pid = kBkg; + auto mcpart = Rectrack.template mcParticle_as(); + if (mcpart.isPhysicalPrimary()) { + switch (std::abs(mcpart.pdgCode())) { + case 211: + pid = kSpPion; + break; + case 321: + pid = kSpKaon; + break; + case 2212: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + } else { + pid = kSpNotPrimary; + } + if (mcpart.has_mothers()) { + auto mcpartMother = mcpart.template mothers_as().front(); + if (mcpartMother.pdgCode() == 310 || std::abs(mcpartMother.pdgCode()) == 3122) { + pid = kSpStrangeDecay; + } + } + if (find(mclabels.begin(), mclabels.end(), Rectrack.mcParticleId()) != mclabels.end()) { + pid = kBkg; + } + mclabels.push_back(Rectrack.mcParticleId()); + histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(pid)); + } else { + histos.fill(HIST("FillMCrecSpecies"), RecCollision.centFT0C(), OccupancyValue, Rectrack.eta(), Double_t(kBkg)); + } + } // rec track loop + + for (auto& particle : GenParticles) { + if (!IsGenTrackSelected(particle)) { + continue; + } + histos.fill(HIST("FillMCgenSpecies"), RecCollision.centFT0C(), particle.eta(), Double_t(kSpAll)); + Int_t pid = 0; + switch (std::abs(particle.pdgCode())) { + case 211: + pid = kSpPion; + break; + case 321: + pid = kSpKaon; + break; + case 2212: + pid = kSpProton; + break; + default: + pid = kSpOther; + break; + } + histos.fill(HIST("FillMCgenSpecies"), RecCollision.centFT0C(), particle.eta(), Double_t(pid)); + } // gen track loop + } // collision loop + } + PROCESS_SWITCH(HeavyIonMultiplicity, processMCfillspecies, "Fill particle species in MC", false); + + void processStrangeYield(CollisionDataTable::iterator const& collision, v0trackcandidates const&, aod::V0Datas const& v0data) + { + if (!IsEventSelected(collision)) { + return; + } + if (std::abs(collision.posZ()) >= VtxRange) { + return; + } + histos.fill(HIST("hzvtxcent"), collision.posZ(), collision.centFT0C()); + for (auto& v0track : v0data) { + auto v0pTrack = v0track.template posTrack_as(); + auto v0nTrack = v0track.template negTrack_as(); + if (std::abs(v0pTrack.eta()) > 0.9 || std::abs(v0nTrack.eta()) > 0.9) { + 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"), 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()); + } + } + PROCESS_SWITCH(HeavyIonMultiplicity, processStrangeYield, "Strange particle yield", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGMM/UE/Tasks/CMakeLists.txt b/PWGMM/UE/Tasks/CMakeLists.txt index 19a0ecba60a..9bfee98cbbb 100644 --- a/PWGMM/UE/Tasks/CMakeLists.txt +++ b/PWGMM/UE/Tasks/CMakeLists.txt @@ -18,8 +18,3 @@ o2physics_add_dpl_workflow(ue-zdc-analysis SOURCES ue-zdc-analysys.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) - -o2physics_add_dpl_workflow(ue-lambdak0sflattenicity - SOURCES lambdak0sflattenicity.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore - COMPONENT_NAME Analysis) \ No newline at end of file diff --git a/PWGMM/UE/Tasks/lambdak0sflattenicity.cxx b/PWGMM/UE/Tasks/lambdak0sflattenicity.cxx deleted file mode 100755 index dbe0309c26b..00000000000 --- a/PWGMM/UE/Tasks/lambdak0sflattenicity.cxx +++ /dev/null @@ -1,987 +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. -/// -/// Making modifications to the Strangeness Tutorial code -/// 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) - -#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 "ReconstructionDataFormats/Track.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 - -#include "PWGLF/DataModel/LFStrangenessTables.h" -#include "Common/DataModel/PIDResponse.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -struct lambdak0sflattenicity { - // Histograms are defined with HistogramRegistry - HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rKzeroShort{"kzeroShort", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rLambda{"lambda", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rAntiLambda{"antilambda", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - HistogramRegistry rFlattenicity{"flattenicity", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; - - static constexpr std::string_view nhEst[8] = { - "eGlobaltrack", "eFV0", "e1flatencityFV0", "eFT0", "e1flatencityFT0", "eFV0FT0C", "e1flatencityFV0FT0C", "ePtTrig"}; - static constexpr std::string_view tEst[8] = { - "GlobalTrk", "FV0", "1-flatencity_FV0", "FT0", "1-flatencityFT0", "FV0_FT0C", "1-flatencity_FV0_FT0C", "PtTrig"}; - static constexpr std::string_view nhPtEst[8] = { - "ptVsGlobaltrack", "ptVsFV0", "ptVs1flatencityFV0", "ptVsFT0", "ptVs1flatencityFT0", "ptVsFV0FT0C", "ptVs1flatencityFV0FT0C", "pTVsPtTrig"}; - - // Configurable for histograms - Configurable nBinsVz{"nBinsVz", 100, "N bins in Vz"}; - Configurable nBinsK0sMass{"nBinsK0sMass", 200, "N bins in K0sMass"}; - Configurable nBinsLambdaMass{"nBinsLambdaMass", 200, "N bins in LambdaMass"}; - Configurable nBinspT{"nBinspT", 250, "N bins in pT"}; - - // Configurable for event selection - Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; - - // Configurables for Flattenicity - Configurable applyCalibCh{"applyCalibCh", false, "equalize FV0"}; - Configurable applyCalibVtx{"applyCalibVtx", false, "equalize FV0 vs vtx"}; - Configurable applyNorm{"applyNorm", false, "normalization to eta"}; - - // 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 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 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 parameters for PID selection - Configurable NSigmaTPCPion{"NSigmaTPCPion", 5, "NSigmaTPCPion"}; - Configurable NSigmaTPCProton{"NSigmaTPCProton", 5, "NSigmaTPCProton"}; - - // Configurable v0daughter_etacut{"V0DaughterEtaCut", 0.8, "V0DaughterEtaCut"}; - Configurable v0_etacut{"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"}; - - void init(InitContext const&) - { - // Axes - AxisSpec K0sMassAxis = {nBinsK0sMass, 0.45f, 0.55f, "#it{M}_{#pi^{+}#pi^{-}} [GeV/#it{c}^{2}]"}; - AxisSpec LambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, "#it{M}_{p#pi^{-}} [GeV/#it{c}^{2}]"}; - AxisSpec AntiLambdaMassAxis = {nBinsLambdaMass, 1.015f, 1.215f, "#it{M}_{#pi^{+}#bar{p}} [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})"}; - - int nBinsEst[8] = {100, 500, 102, 500, 102, 500, 102, 150}; - float lowEdgeEst[8] = {-0.5, -0.5, -0.01, -0.5, -0.01, -0.5, -0.01, .0}; - float upEdgeEst[8] = {99.5, 49999.5, 1.01, 499.5, 1.01, 499.5, 1.01, 150.0}; - - // Histograms - // Event selection - rEventSelection.add("hVertexZ", "hVertexZ", {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hVertexZGen", "hVertexZGen", {HistType::kTH1F, {vertexZAxis}}); - rEventSelection.add("hEventsRejected", "hEventsRejected", {HistType::kTH1F, {{11, -0.5, 10.5}}}); - rEventSelection.add("hEventsSelected", "hEventsSelected", {HistType::kTH1F, {{11, -0.5, 10.5}}}); - - // K0s reconstruction - // Mass - rKzeroShort.add("hMassK0s", "hMassK0s", {HistType::kTH1F, {K0sMassAxis}}); - rKzeroShort.add("hMassK0sSelected", "hMassK0sSelected", {HistType::kTH1F, {K0sMassAxis}}); - - // K0s topological/PID cuts - rKzeroShort.add("hrapidityK0s", "hrapidityK0s", {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); - rKzeroShort.add("hctauK0s", "hctauK0s", {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rKzeroShort.add("h2DdecayRadiusK0s", "h2DdecayRadiusK0s", {HistType::kTH1F, {{100, 0.0f, 1.0f, "Decay Radius (cm)"}}}); - rKzeroShort.add("hDCAV0DaughtersK0s", "hDCAV0DaughtersK0s", {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rKzeroShort.add("hV0CosPAK0s", "hV0CosPAK0s", {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); - rKzeroShort.add("hNSigmaPosPionFromK0s", "hNSigmaPosPionFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rKzeroShort.add("hNSigmaNegPionFromK0s", "hNSigmaNegPionFromK0s", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rKzeroShort.add("hMassK0spT", "hMassK0spT", {HistType::kTH2F, {{K0sMassAxis}, {ptAxis}}}); - rKzeroShort.add("hPtK0ShortGen", "hPtK0ShortGen", {HistType::kTH1F, {ptAxis}}); - - // Lambda reconstruction - // Mass - rLambda.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {LambdaMassAxis}}); - rLambda.add("hMassLambdaSelected", "hMassLambdaSelected", {HistType::kTH1F, {LambdaMassAxis}}); - - // Lambda topological/PID cuts - rLambda.add("hDCAV0DaughtersLambda", "hDCAV0DaughtersLambda", {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rLambda.add("hV0CosPALambda", "hV0CosPALambda", {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); - rLambda.add("hNSigmaPosPionFromLambda", "hNSigmaPosPionFromLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rLambda.add("hNSigmaNegPionFromLambda", "hNSigmaNegPionFromLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rLambda.add("hrapidityLambda", "hrapidityLambda", {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); - rLambda.add("hctauLambda", "hctauLambda", {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rLambda.add("h2DdecayRadiusLambda", "h2DdecayRadiusLambda", {HistType::kTH1F, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); - rLambda.add("hMassLambdapT", "hMassLambdapT", {HistType::kTH2F, {{LambdaMassAxis}, {ptAxis}}}); - rLambda.add("hPtLambdaGen", "hPtLambdaGen", {HistType::kTH1F, {ptAxis}}); - - // AntiLambda reconstruction - // Mass - rAntiLambda.add("hMassAntiLambda", "hMassAntiLambda", {HistType::kTH1F, {AntiLambdaMassAxis}}); - rAntiLambda.add("hMassAntiLambdaSelected", "hMassAntiLambdaSelected", {HistType::kTH1F, {AntiLambdaMassAxis}}); - - // AntiLambda topological/PID cuts - rAntiLambda.add("hDCAV0DaughtersAntiLambda", "hDCAV0DaughtersAntiLambda", {HistType::kTH1F, {{55, 0.0f, 2.2f, "DCA Daughters"}}}); - rAntiLambda.add("hV0CosPAAntiLambda", "hV0CosPAAntiLambda", {HistType::kTH1F, {{100, 0.95f, 1.f, "CosPA"}}}); - rAntiLambda.add("hNSigmaPosPionFromAntiLambda", "hNSigmaPosPionFromAntiLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rAntiLambda.add("hNSigmaNegPionFromAntiLambda", "hNSigmaNegPionFromAntiLambda", {HistType::kTH2F, {{100, -5.f, 5.f}, {ptAxis}}}); - rAntiLambda.add("hrapidityAntiLambda", "hrapidityAntiLambda", {HistType::kTH1F, {{40, -2.0f, 2.0f, "y"}}}); - rAntiLambda.add("hctauAntiLambda", "hctauAntiLambda", {HistType::kTH1F, {{40, 0.0f, 40.0f, "c#tau (cm)"}}}); - rAntiLambda.add("h2DdecayRadiusAntiLambda", "h2DdecayRadiusAntiLambda", {HistType::kTH1F, {{100, 0.0f, 1.0f, "c#tau (cm)"}}}); - rAntiLambda.add("hMassAntiLambdapT", "hMassAntiLambdapT", {HistType::kTH2F, {{AntiLambdaMassAxis}, {ptAxis}}}); - rAntiLambda.add("hPtAntiLambdaGen", "hPtAntiLambdaGen", {HistType::kTH1F, {ptAxis}}); - - rFlattenicity.add("hEv", "Ev", HistType::kTH1F, {{6, -0.5, 5.5, "index activated detector"}}); - rFlattenicity.add("hFV0amplRing1to4", "FV01to4", HistType::kTH1F, {{4000, -0.5, +49999.5, "FV0 amplitude"}}); - rFlattenicity.add("hFT0Aampl", "FTAampl", HistType::kTH1F, {{50000, -0.5, +199999.5, "FT0A amplitude"}}); - rFlattenicity.add("hFT0Campl", "FTCampl", HistType::kTH1F, {{10000, -0.5, +4999.5, "FT0C amplitude"}}); - rFlattenicity.add("hFT0C", "FT0C", HistType::kTH1F, {{50000, -0.5, 199999.5, "FT0C amplitudes"}}); - rFlattenicity.add("hFT0A", "FT0A", HistType::kTH1F, {{2000, -0.5, 1999.5, "FT0A amplitudes"}}); - - // estimators - for (int i_e = 0; i_e < 8; ++i_e) { - rFlattenicity.add( - nhEst[i_e].data(), "", HistType::kTH2F, {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}, {100, -0.5, +99.5, "Global track"}}); - } - - // vs pT - for (int i_e = 0; i_e < 8; ++i_e) { - rFlattenicity.add(nhPtEst[i_e].data(), "", HistType::kTProfile, {{nBinsEst[i_e], lowEdgeEst[i_e], upEdgeEst[i_e], tEst[i_e].data()}}); - } - - rFlattenicity.add("fMultFv0", "FV0 amp", HistType::kTH1F, {{5000, -0.5, +199999.5, "FV0 amplitude"}}); - rFlattenicity.add("hAmpV0VsCh", "", HistType::kTH2F, {{48, -0.5, 47.5, "channel"}, {500, -0.5, +19999.5, "FV0 amplitude"}}); - rFlattenicity.add("hAmpV0VsChBeforeCalibration", "", HistType::kTH2F, {{48, -0.5, 47.5, "channel"}, {500, -0.5, +19999.5, "FV0 amplitude"}}); - - rFlattenicity.add("hAmpT0AVsChBeforeCalibration", "", HistType::kTH2F, {{24, -0.5, 23.5, "channel"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); - rFlattenicity.add("hAmpT0CVsChBeforeCalibration", "", HistType::kTH2F, {{28, -0.5, 27.5, "channel"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); - - rFlattenicity.add("hAmpT0AVsCh", "", HistType::kTH2F, {{24, -0.5, 23.5, "channel"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); - rFlattenicity.add("hAmpT0CVsCh", "", HistType::kTH2F, {{28, -0.5, 27.5, "channel"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); - - rFlattenicity.add("hFlatFT0CvsFlatFT0A", "", HistType::kTH2F, {{20, -0.01, +1.01, "flatenicity (FT0C)"}, {20, -0.01, +1.01, "flatenicity (FT0A)"}}); - rFlattenicity.add("fEtaPhiFv0", "eta vs phi", HistType::kTH2F, {{8, 0.0, 2 * M_PI, "#phi (rad)"}, {5, 2.2, 5.1, "#eta"}}); - - rFlattenicity.add("hAmpV0vsVtxBeforeCalibration", "", HistType::kTH2F, {{30, -15.0, +15.0, "Trk mult"}, {1000, -0.5, +39999.5, "FV0 amplitude"}}); - rFlattenicity.add("hAmpT0AvsVtxBeforeCalibration", "", HistType::kTH2F, {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); - rFlattenicity.add("hAmpT0CvsVtxBeforeCalibration", "", HistType::kTH2F, {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0C amplitude"}}); - - rFlattenicity.add("hAmpV0vsVtx", "", HistType::kTH2F, {{30, -15.0, +15.0, "Trk mult"}, {1000, -0.5, +39999.5, "FV0 amplitude"}}); - rFlattenicity.add("hAmpT0AvsVtx", "", HistType::kTH2F, {{30, -15.0, +15.0, "Vtx_z"}, {600, -0.5, +5999.5, "FT0A amplitude"}}); - rFlattenicity.add("hAmpT0CvsVtx", "", HistType::kTH2F, {{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 ((doprocessRecMC && !doprocessGenMC) || (!doprocessRecMC && doprocessGenMC)) { - LOGF(fatal, "MCRec and MCGen are set to opposite switches, try again with both set to either true or false"); - } - } - - int getT0ASector(int i_ch) - { - 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; - break; - } - } - return i_sec_t0a; - } - - int getT0CSector(int i_ch) - { - 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; - break; - } - } - return i_sec_t0c; - } - - int getFV0Ring(int i_ch) - { - 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; - } else { - i_ring = 4; - } - return i_ring; - } - - int getFV0IndexPhi(int i_ch) - { - int i_ring = -1; - - if (i_ch >= 0 && i_ch < 8) { - if (i_ch < 4) { - i_ring = i_ch; - } 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; - } - } - } else if (i_ch >= 8 && i_ch < 16) { - if (i_ch < 12) { - i_ring = i_ch; - } 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; - } - } - } else if (i_ch >= 16 && i_ch < 24) { - if (i_ch < 20) { - i_ring = i_ch; - } 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; - } - } - } else if (i_ch >= 24 && i_ch < 32) { - if (i_ch < 28) { - i_ring = i_ch; - } 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; - } - } - } 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; - } - - float GetFlatenicity(std::span signals) - { - int entries = signals.size(); - float flat = 9999; - float mRho = 0; - for (int iCell = 0; iCell < entries; ++iCell) { - mRho += 1.0 * signals[iCell]; - } - // average activity per cell - mRho /= (1.0 * entries); - // get sigma - float sRho_tmp = 0; - for (int iCell = 0; iCell < entries; ++iCell) { - sRho_tmp += TMath::Power(1.0 * signals[iCell] - mRho, 2); - } - sRho_tmp /= (1.0 * entries * entries); - float sRho = TMath::Sqrt(sRho_tmp); - if (mRho > 0) { - flat = sRho / mRho; - } - return flat; - } - float pdgmassK0s = 0.497614; - float pdgmassLambda = 1.115683; - // V0A signal and flatenicity calculation - static constexpr float calib[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, 1.06622, 1.15057, 1.0433, 0.83654, 0.847178, 0.890027, 0.920814, 0.888271, 1.04662, 0.8869, 0.856348, 0.863181, 0.906312, 0.902166, 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] = {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] = {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] = {-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] = {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] = {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] = {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 ampchannel; - std::array ampchannelBefore; - static constexpr int nCellsT0A = 24; - std::array RhoLatticeT0A; - static constexpr int nCellsT0C = 28; - std::array RhoLatticeT0C; - - std::array estimator; - - template - bool isEventSelected(TCollision const& collision) - { - rEventSelection.fill(HIST("hEventsSelected"), 0); - - if (!collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { - rEventSelection.fill(HIST("hEventsRejected"), 0); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 1); - - if (!collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { - rEventSelection.fill(HIST("hEventsRejected"), 1); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 2); - - if (!collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { - rEventSelection.fill(HIST("hEventsRejected"), 2); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 3); - - if (!collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - rEventSelection.fill(HIST("hEventsRejected"), 3); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 4); - - if (!collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) { - rEventSelection.fill(HIST("hEventsRejected"), 4); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 5); - - if (collision.isInelGt0() == false) { - rEventSelection.fill(HIST("hEventsRejected"), 5); - return false; - } - rEventSelection.fill(HIST("hEventsSelected"), 6); - - return true; - } - - // ============== Flattenicity estimation begins ===================== // - template - void 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}; - - 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]); - } - for (int i_v = 0; i_v < 30; ++i_v) { - gVtx[1]->SetPoint(i_v, biningVtxt[i_v], calibFT0Avtx[i_v]); - } - for (int i_v = 0; i_v < 30; ++i_v) { - gVtx[2]->SetPoint(i_v, biningVtxt[i_v], calibFT0Cvtx[i_v]); - } - - for (int i_d = 0; i_d < nDetVtx; ++i_d) { - gVtx[i_d]->SetName(Form("g%s", nameDet[i_d])); - } - auto vtxZ = collision.posZ(); - - float sumAmpFV0 = 0; - float sumAmpFV01to4Ch = 0; - - ampchannel.fill(0.0); - ampchannelBefore.fill(0.0); - RhoLattice.fill(0); - - if (collision.has_foundFV0()) { - - auto fv0 = collision.foundFV0(); - for (std::size_t ich = 0; ich < fv0.amplitude().size(); ich++) { - float phiv0 = -999.0; - float etav0 = -999.0; - int channelv0 = fv0.channel()[ich]; - float ampl_ch = 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); - } else { - phiv0 = ((2.0 * channelv0phi) + 1 - 64.0) * 2.0 * M_PI / (32.0); - } - ampchannelBefore[channelv0phi] = ampl_ch; - if (applyCalibCh) { - ampl_ch *= calib[channelv0phi]; - } - sumAmpFV0 += ampl_ch; - - if (channelv0 >= 8) { // exclude the 1st ch, eta 2.2,4.52 - sumAmpFV01to4Ch += ampl_ch; - } - rFlattenicity.fill(HIST("fEtaPhiFv0"), phiv0, etav0, ampl_ch); - ampchannel[channelv0phi] = ampl_ch; - if (channelv0 < innerFV0) { - RhoLattice[channelv0phi] = ampl_ch; - } else { - RhoLattice[channelv0phi] = ampl_ch / 2.0; // two channels per bin - } - } - - rFlattenicity.fill(HIST("hAmpV0vsVtxBeforeCalibration"), vtxZ, sumAmpFV0); - if (applyCalibVtx) { - sumAmpFV0 *= gVtx[0]->Eval(vtxZ); - sumAmpFV01to4Ch *= gVtx[0]->Eval(vtxZ); - } - rFlattenicity.fill(HIST("hAmpV0vsVtx"), vtxZ, sumAmpFV0); - } - - float flattenicityfv0 = 9999; - flattenicityfv0 = GetFlatenicity({RhoLattice.data(), RhoLattice.size()}); - - // global tracks - float ptT = 0.; - int multGlob = 0; - for (auto& track : tracks) { - if (!track.isGlobalTrack()) { - continue; - } - if (track.pt() > ptT) { - ptT = track.pt(); - } - multGlob++; - } - - // FT0 - float sumAmpFT0A = 0.f; - float sumAmpFT0C = 0.f; - - RhoLatticeT0A.fill(0); - RhoLatticeT0C.fill(0); - - if (collision.has_foundFT0()) { - auto ft0 = collision.foundFT0(); - for (std::size_t i_a = 0; i_a < ft0.amplitudeA().size(); i_a++) { - float amplitude = ft0.amplitudeA()[i_a]; - uint8_t channel = ft0.channelA()[i_a]; - int sector = getT0ASector(channel); - if (sector >= 0 && sector < 24) { - RhoLatticeT0A[sector] += amplitude; - rFlattenicity.fill(HIST("hAmpT0AVsChBeforeCalibration"), sector, amplitude); - if (applyCalibCh) { - amplitude *= calibT0A[sector]; - } - rFlattenicity.fill(HIST("hAmpT0AVsCh"), sector, amplitude); - } - sumAmpFT0A += amplitude; - rFlattenicity.fill(HIST("hFT0A"), amplitude); - } - - for (std::size_t i_c = 0; i_c < ft0.amplitudeC().size(); i_c++) { - float amplitude = ft0.amplitudeC()[i_c]; - sumAmpFT0C += amplitude; - uint8_t channel = ft0.channelC()[i_c]; - int sector = getT0CSector(channel); - if (sector >= 0 && sector < 28) { - RhoLatticeT0C[sector] += amplitude; - rFlattenicity.fill(HIST("hAmpT0CVsChBeforeCalibration"), sector, amplitude); - if (applyCalibCh) { - amplitude *= calibT0C[sector]; - } - rFlattenicity.fill(HIST("hAmpT0CVsCh"), sector, amplitude); - } - rFlattenicity.fill(HIST("hFT0C"), amplitude); - } - - rFlattenicity.fill(HIST("hAmpT0AvsVtxBeforeCalibration"), vtxZ, sumAmpFT0A); - rFlattenicity.fill(HIST("hAmpT0CvsVtxBeforeCalibration"), vtxZ, sumAmpFT0C); - if (applyCalibVtx) { - sumAmpFT0A *= gVtx[1]->Eval(vtxZ); - sumAmpFT0C *= gVtx[2]->Eval(vtxZ); - } - rFlattenicity.fill(HIST("hAmpT0AvsVtx"), vtxZ, sumAmpFT0A); - rFlattenicity.fill(HIST("hAmpT0CvsVtx"), vtxZ, sumAmpFT0C); - } - float flatenicity_t0a = 9999; - flatenicity_t0a = GetFlatenicity({RhoLatticeT0A.data(), RhoLatticeT0A.size()}); - float flatenicity_t0c = 9999; - flatenicity_t0c = GetFlatenicity({RhoLatticeT0C.data(), RhoLatticeT0C.size()}); - - bool isOK_estimator5 = false; - bool isOK_estimator6 = false; - float combined_estimator5 = 0; - float combined_estimator6 = 0; - - for (int i_e = 0; i_e < 8; ++i_e) { - estimator[i_e] = 0; - } - - if (collision.has_foundFV0() && collision.has_foundFT0()) { - float all_weights = 0; - // option 5 - ampl5[0] = sumAmpFT0C; - ampl5[1] = sumAmpFT0A; - if (sumAmpFT0C > 0 && sumAmpFT0A > 0) { - isOK_estimator5 = true; - } - if (isOK_estimator5) { - 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]; - } - combined_estimator5 /= all_weights; - } else { - for (int i_5 = 0; i_5 < nEta5; ++i_5) { - combined_estimator5 += ampl5[i_5] * weigthsEta5[i_5]; - } - } - } - // option 6: FT0C + FV0 - ampl6[0] = sumAmpFT0C; - ampl6[1] = sumAmpFV0; - if (sumAmpFT0C > 0 && sumAmpFV0 > 0) { - isOK_estimator6 = true; - } - if (isOK_estimator6) { - 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]; - } - combined_estimator6 /= all_weights; - } else { - for (int i_6 = 0; i_6 < nEta6; ++i_6) { - combined_estimator6 += ampl6[i_6] * weigthsEta6[i_6]; - } - } - } - rFlattenicity.fill(HIST("hFT0Aampl"), sumAmpFT0A); - rFlattenicity.fill(HIST("hFT0Campl"), sumAmpFT0C); - rFlattenicity.fill(HIST("hFV0amplRing1to4"), sumAmpFV01to4Ch); - rFlattenicity.fill(HIST("hEv"), 4); - 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[7] = ptT; - - 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]); - - // plot pt vs estimators - for (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); - } - - for (int iCh = 0; iCh < 48; ++iCh) { - rFlattenicity.fill(HIST("hAmpV0VsCh"), iCh, ampchannel[iCh]); - rFlattenicity.fill(HIST("hAmpV0VsChBeforeCalibration"), iCh, - ampchannelBefore[iCh]); - } - rFlattenicity.fill(HIST("fMultFv0"), sumAmpFV0); - rFlattenicity.fill(HIST("hFlatFT0CvsFlatFT0A"), flatenicity_t0c, flatenicity_t0a); - } - } - // ====================== Flattenicity estimation ends ===================== - - // 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); - - // 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 trackFilter = (nabs(aod::track::eta) < cfgTrkEtaCut); - using TrackCandidates = soa::Filtered>; - - void processDataRun3(soa::Filtered>::iterator const& collision, - soa::Filtered const& V0s, TrackCandidates const& tracks, soa::Join const& /*bcs*/, - aod::MFTTracks const& /*mfttracks*/, aod::FT0s const& /*ft0s*/, - aod::FV0As const& /*fv0s*/) - { - if (!(isEventSelected(collision))) { // Checking if the event passes the selection criteria - return; - } - - auto vtxZ = collision.posZ(); - auto vtxY = collision.posY(); - auto vtxX = collision.posX(); - - EstimateFlattenicity(collision, tracks); - - rEventSelection.fill(HIST("hVertexZ"), vtxZ); - - for (const auto& v0 : V0s) { - const auto& posDaughterTrack = v0.posTrack_as(); - const auto& negDaughterTrack = v0.negTrack_as(); - - if (TMath::Abs(posDaughterTrack.eta()) > 0.8 || TMath::Abs(negDaughterTrack.eta()) > 0.8) { - continue; - } - float massK0s = v0.mK0Short(); - float massLambda = v0.mLambda(); - float massAntiLambda = v0.mAntiLambda(); - - rKzeroShort.fill(HIST("hMassK0s"), massK0s); - rLambda.fill(HIST("hMassLambda"), massLambda); - rAntiLambda.fill(HIST("hMassAntiLambda"), massAntiLambda); - - float decayvtxX = v0.x(); - 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 ctauK0s = decaylength * massK0s / v0p; - float ctauLambda = decaylength * massLambda / v0p; - float ctauAntiLambda = decaylength * massAntiLambda / v0p; - - // Cut on dynamic columns for K0s - - 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)) <= 0.5 && TMath::Abs(massLambda - pdgmassLambda) > 0.005 && TMath::Abs(massAntiLambda - pdgmassLambda) > 0.005) { - - rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); - rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); - rKzeroShort.fill(HIST("hV0CosPAK0s"), v0.v0cosPA()); - rKzeroShort.fill(HIST("hrapidityK0s"), v0.rapidity(0)); - rKzeroShort.fill(HIST("hctauK0s"), ctauK0s); - rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); - rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the K0s peak - if (0.45 < massK0s && massK0s < 0.55) { - rKzeroShort.fill(HIST("hNSigmaPosPionFromK0s"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); - rKzeroShort.fill(HIST("hNSigmaNegPionFromK0s"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); - } - } - - // 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)) <= 0.5 && TMath::Abs(massK0s - pdgmassK0s) > 0.01) { - - rLambda.fill(HIST("hMassLambdaSelected"), massLambda); - rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); - rLambda.fill(HIST("hV0CosPALambda"), v0.v0cosPA()); - rLambda.fill(HIST("hrapidityLambda"), v0.rapidity(1)); - rLambda.fill(HIST("hctauLambda"), ctauLambda); - rLambda.fill(HIST("h2DdecayRadiusLambda"), v0.v0radius()); - rLambda.fill(HIST("hMassLambdapT"), massLambda, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the Lambda peak - if (1.015 < massLambda && massLambda < 1.215) { - rLambda.fill(HIST("hNSigmaPosPionFromLambda"), posDaughterTrack.tpcNSigmaPr(), posDaughterTrack.tpcInnerParam()); - rLambda.fill(HIST("hNSigmaNegPionFromLambda"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); - } - } - - // 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)) <= 0.5 && TMath::Abs(massK0s - pdgmassK0s) > 0.01) { - - rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); - rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), v0.dcaV0daughters()); - rAntiLambda.fill(HIST("hV0CosPAAntiLambda"), v0.v0cosPA()); - rAntiLambda.fill(HIST("hrapidityAntiLambda"), v0.rapidity(2)); - rAntiLambda.fill(HIST("hctauAntiLambda"), ctauAntiLambda); - rAntiLambda.fill(HIST("h2DdecayRadiusAntiLambda"), v0.v0radius()); - rAntiLambda.fill(HIST("hMassAntiLambdapT"), massAntiLambda, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the AntiLambda peak - if (1.015 < massAntiLambda && massAntiLambda < 1.215) { - rAntiLambda.fill(HIST("hNSigmaPosPionFromAntiLambda"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); - rAntiLambda.fill(HIST("hNSigmaNegPionFromAntiLambda"), negDaughterTrack.tpcNSigmaPr(), negDaughterTrack.tpcInnerParam()); - } - } - } - } - - using TrackCandidatesMC = soa::Filtered>; - void processRecMC(soa::Filtered>::iterator const& collision, - soa::Filtered> const& V0s, - TrackCandidatesMC const& tracks, - soa::Join const& /*bcs*/, - aod::MFTTracks const& /*mfttracks*/, aod::FT0s const& /*ft0s*/, - aod::FV0As const& /*fv0s*/, aod::McParticles const&) - { - if (!(isEventSelected(collision))) { // Checking if the event passes the selection criteria - return; - } - - auto vtxZ = collision.posZ(); - auto vtxY = collision.posY(); - auto vtxX = collision.posX(); - - EstimateFlattenicity(collision, tracks); - - rEventSelection.fill(HIST("hVertexZ"), vtxZ); - - for (const auto& v0 : V0s) { - - const auto& posDaughterTrack = v0.posTrack_as(); - const auto& negDaughterTrack = v0.negTrack_as(); - - if (!posDaughterTrack.has_mcParticle() || !negDaughterTrack.has_mcParticle()) { - continue; - } - if (TMath::Abs(posDaughterTrack.eta()) > 0.8 || TMath::Abs(negDaughterTrack.eta()) > 0.8) { - continue; - } - - auto mcnegtrack = negDaughterTrack.mcParticle_as(); - auto mcpostrack = posDaughterTrack.mcParticle_as(); - - float massK0s = v0.mK0Short(); - float massLambda = v0.mLambda(); - float massAntiLambda = v0.mAntiLambda(); - - rKzeroShort.fill(HIST("hMassK0s"), massK0s); - rLambda.fill(HIST("hMassLambda"), massLambda); - rAntiLambda.fill(HIST("hMassAntiLambda"), massAntiLambda); - - float decayvtxX = v0.x(); - 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 ctauK0s = decaylength * massK0s / v0p; - float ctauLambda = decaylength * massLambda / v0p; - float ctauAntiLambda = decaylength * massAntiLambda / v0p; - - // Cut on dynamic columns for K0s - - for (auto& particleMotherOfNeg : mcnegtrack.mothers_as()) { - for (auto& particleMotherOfPos : mcpostrack.mothers_as()) { - if (particleMotherOfNeg == particleMotherOfPos && (particleMotherOfNeg.pdgCode() == 3122 || particleMotherOfNeg.pdgCode() == -3122 || particleMotherOfNeg.pdgCode() == 310) && particleMotherOfNeg.isPhysicalPrimary()) { - - if (particleMotherOfNeg.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)) <= 0.5 && TMath::Abs(massLambda - pdgmassLambda) > 0.005 && TMath::Abs(massAntiLambda - pdgmassLambda) > 0.005) { - - rKzeroShort.fill(HIST("hMassK0sSelected"), massK0s); - rKzeroShort.fill(HIST("hDCAV0DaughtersK0s"), v0.dcaV0daughters()); - rKzeroShort.fill(HIST("hV0CosPAK0s"), v0.v0cosPA()); - rKzeroShort.fill(HIST("hrapidityK0s"), v0.rapidity(0)); - rKzeroShort.fill(HIST("hctauK0s"), ctauK0s); - rKzeroShort.fill(HIST("h2DdecayRadiusK0s"), v0.v0radius()); - rKzeroShort.fill(HIST("hMassK0spT"), massK0s, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the K0s peak - if (0.45 < massK0s && massK0s < 0.55) { - rKzeroShort.fill(HIST("hNSigmaPosPionFromK0s"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); - rKzeroShort.fill(HIST("hNSigmaNegPionFromK0s"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); - } - } - - // Cut on dynamic columns for Lambda - if (particleMotherOfNeg.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)) <= 0.5 && TMath::Abs(massK0s - pdgmassK0s) > 0.01) { - - rLambda.fill(HIST("hMassLambdaSelected"), massLambda); - rLambda.fill(HIST("hDCAV0DaughtersLambda"), v0.dcaV0daughters()); - rLambda.fill(HIST("hV0CosPALambda"), v0.v0cosPA()); - rLambda.fill(HIST("hrapidityLambda"), v0.rapidity(1)); - rLambda.fill(HIST("hctauLambda"), ctauLambda); - rLambda.fill(HIST("h2DdecayRadiusLambda"), v0.v0radius()); - rLambda.fill(HIST("hMassLambdapT"), massLambda, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the Lambda peak - if (1.015 < massLambda && massLambda < 1.215) { - rLambda.fill(HIST("hNSigmaPosPionFromLambda"), posDaughterTrack.tpcNSigmaPr(), posDaughterTrack.tpcInnerParam()); - rLambda.fill(HIST("hNSigmaNegPionFromLambda"), negDaughterTrack.tpcNSigmaPi(), negDaughterTrack.tpcInnerParam()); - } - } - - // Cut on dynamic columns for AntiLambda - if (particleMotherOfNeg.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)) <= 0.5 && TMath::Abs(massK0s - pdgmassK0s) > 0.01) { - - rAntiLambda.fill(HIST("hMassAntiLambdaSelected"), massAntiLambda); - rAntiLambda.fill(HIST("hDCAV0DaughtersAntiLambda"), v0.dcaV0daughters()); - rAntiLambda.fill(HIST("hV0CosPAAntiLambda"), v0.v0cosPA()); - rAntiLambda.fill(HIST("hrapidityAntiLambda"), v0.rapidity(2)); - rAntiLambda.fill(HIST("hctauAntiLambda"), ctauAntiLambda); - rAntiLambda.fill(HIST("h2DdecayRadiusAntiLambda"), v0.v0radius()); - rAntiLambda.fill(HIST("hMassAntiLambdapT"), massAntiLambda, v0.pt()); - - // Filling the PID of the V0 daughters in the region of the AntiLambda peak - if (1.015 < massAntiLambda && massAntiLambda < 1.215) { - rAntiLambda.fill(HIST("hNSigmaPosPionFromAntiLambda"), posDaughterTrack.tpcNSigmaPi(), posDaughterTrack.tpcInnerParam()); - rAntiLambda.fill(HIST("hNSigmaNegPionFromAntiLambda"), negDaughterTrack.tpcNSigmaPr(), negDaughterTrack.tpcInnerParam()); - } - } - } - } - } - } - } - - Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex); - void processGenMC(soa::Filtered::iterator const& mcCollision, - const soa::SmallGroups>& collisions, - aod::McParticles const& mcParticles) - { - if (collisions.size() < 1) // to process generated collisions that've been reconstructed at least once - { - return; - } - - rEventSelection.fill(HIST("hVertexZGen"), mcCollision.posZ()); - - for (const auto& mcParticle : mcParticles) { - - if (mcParticle.isPhysicalPrimary() && mcParticle.y() < 0.5) { - - if (mcParticle.pdgCode() == 310) { - rKzeroShort.fill(HIST("hPtK0ShortGen"), mcParticle.pt()); - } - - if (mcParticle.pdgCode() == 3122) { - rLambda.fill(HIST("hPtLambdaGen"), mcParticle.pt()); - } - - if (mcParticle.pdgCode() == -3122) { - rAntiLambda.fill(HIST("hPtAntiLambdaGen"), mcParticle.pt()); - } - } - } - } - - 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); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; -} diff --git a/PWGMM/UE/Tasks/uecharged.cxx b/PWGMM/UE/Tasks/uecharged.cxx index 82457880fe6..3db96c9dbac 100644 --- a/PWGMM/UE/Tasks/uecharged.cxx +++ b/PWGMM/UE/Tasks/uecharged.cxx @@ -730,11 +730,9 @@ void ueCharged::processMeasMC(const C& collision, const T& tracks, const P& part return; } ue.fill(HIST("hCounter"), 1); - if (timeEvsel && (!collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder))) { - return; - } - + // TODO:Implement time frame selection (only if MC includes this effect) ue.fill(HIST("hCounter"), 2); + if (piluprejection && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { return; } diff --git a/PWGUD/Core/DGPIDSelector.cxx b/PWGUD/Core/DGPIDSelector.cxx index afd3ff24b63..04dab87ef7a 100644 --- a/PWGUD/Core/DGPIDSelector.cxx +++ b/PWGUD/Core/DGPIDSelector.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. - +#include #include #include "CommonConstants/PhysicsConstants.h" #include "DGPIDSelector.h" @@ -144,7 +144,7 @@ void DGAnaparHolder::Print() LOGF(info, " max alpha: %f", mMaxAlpha); LOGF(info, " min system pT: %f", mMinptsys); LOGF(info, " max system pT: %f", mMaxptsys); - LOGF(info, " nCombine: %d", mNCombine); + LOGF(info, " nCombine: %zu", mNCombine); LOGF(info, " unlike charges"); for (auto ch : mUnlikeCharges) { LOGF(info, " %i", ch); @@ -236,7 +236,7 @@ void DGAnaparHolder::Setptsys(float min, float max) mMaxptsys = max; } -void DGAnaparHolder::SetnCombine(int nComb) +void DGAnaparHolder::SetnCombine(std::size_t nComb) { mNCombine = nComb; } @@ -300,7 +300,7 @@ void DGAnaparHolder::makeUniquePermutations() auto hash = hasher(std::string(hashstr)); if (std::find(hashes.begin(), hashes.end(), hash) == hashes.end()) { hashes.push_back(hash); - for (auto ii = 0; ii < mNCombine; ii++) { + for (std::size_t ii = 0; ii < mNCombine; ii++) { muniquePerms.push_back(perm[ii]); } } @@ -523,7 +523,7 @@ std::vector> DGPIDSelector::combinations(int nPool) for (auto comb : combs) { for (auto ii = 0u; ii < numUniquePerms; ii++) { std::vector cope(mAnaPars.nCombine(), 0); - for (auto jj = 0; jj < mAnaPars.nCombine(); jj++) { + for (std::size_t jj = 0; jj < mAnaPars.nCombine(); jj++) { auto ind = ii * mAnaPars.nCombine() + jj; cope[uniquePerms[ind]] = comb[jj]; } diff --git a/PWGUD/Core/DGPIDSelector.h b/PWGUD/Core/DGPIDSelector.h index a4b0fcf145b..c130c2094ce 100644 --- a/PWGUD/Core/DGPIDSelector.h +++ b/PWGUD/Core/DGPIDSelector.h @@ -115,7 +115,7 @@ struct DGAnaparHolder { float mineta = -2.0, float maxeta = 2.0, float minalpha = 0.0, float maxalpha = 3.2, float minptsys = 0.0, float maxptsys = 100.0, - int nCombine = 2, + std::size_t nCombine = 2, std::vector netCharges = {0}, std::vector unlikeCharges = {0}, std::vector likeCharges = {-2, 2}, @@ -152,7 +152,7 @@ struct DGAnaparHolder { void Seteta(float, float); void SetAlpha(float, float); void Setptsys(float, float); - void SetnCombine(int); + void SetnCombine(std::size_t); void SetnetCharges(std::vector); void SetunlikeCharges(std::vector); void SetlikeCharges(std::vector); @@ -180,7 +180,7 @@ struct DGAnaparHolder { float maxAlpha() const { return mMaxAlpha; } float minptsys() const { return mMinptsys; } float maxptsys() const { return mMaxptsys; } - int nCombine() const { return mNCombine; } + std::size_t nCombine() const { return mNCombine; } std::vector netCharges() const { return mNetCharges; } std::vector unlikeCharges() const { return mUnlikeCharges; } std::vector likeCharges() const { return mLikeCharges; } @@ -216,7 +216,7 @@ struct DGAnaparHolder { float mMaxAlpha; float mMinptsys; float mMaxptsys; - int mNCombine; + std::size_t mNCombine; std::vector mNetCharges; // all PV tracks std::vector mUnlikeCharges; // selected PV tracks std::vector mLikeCharges; // selected PV tracks diff --git a/PWGUD/Core/UDHelpers.h b/PWGUD/Core/UDHelpers.h index 32349280419..6c77b28f007 100644 --- a/PWGUD/Core/UDHelpers.h +++ b/PWGUD/Core/UDHelpers.h @@ -101,29 +101,31 @@ float rPVtrwTOF(TCs tracks, int nPVTracks) // true BC. // template -T compatibleBCs(uint64_t meanBC, int deltaBC, T const& bcs); +T compatibleBCs(uint64_t const& meanBC, int const& deltaBC, T const& bcs); -template -T compatibleBCs(I& bcIter, uint64_t meanBC, int deltaBC, T const& bcs); +template +T compatibleBCs(B const& bc, uint64_t const& meanBC, int const& deltaBC, T const& bcs); // In this variant of compatibleBCs the bcIter is ideally placed within // [minBC, maxBC], but it does not need to be. The range is given by meanBC +- delatBC. -template -T compatibleBCs(I& bcIter, uint64_t meanBC, int deltaBC, T const& bcs) +template +T compatibleBCs(B const& bc, uint64_t const& meanBC, int const& deltaBC, T const& bcs) { + // get BCs iterator + 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; - LOGF(debug, " minBC %d maxBC %d bcIterator %d (%d)", minBC, maxBC, bcIter.globalBC(), bcIter.globalIndex()); + 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(debug, " No overlap of [%d, %d] and [%d, %d]", minBC, maxBC, bcs.iteratorAt(0).globalBC(), 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}; } // find slice of BCs table with BC in [minBC, maxBC] - int moveCount = 0; int64_t minBCId = bcIter.globalIndex(); int64_t maxBCId = bcIter.globalIndex(); @@ -131,14 +133,12 @@ T compatibleBCs(I& bcIter, uint64_t meanBC, int deltaBC, T const& bcs) if (bcIter.globalBC() < minBC) { while (bcIter != bcs.end() && bcIter.globalBC() < minBC) { ++bcIter; - ++moveCount; minBCId = bcIter.globalIndex(); } } else { while (bcIter.globalIndex() > 0 && bcIter.globalBC() >= minBC) { minBCId = bcIter.globalIndex(); --bcIter; - --moveCount; } } @@ -147,26 +147,19 @@ T compatibleBCs(I& bcIter, uint64_t meanBC, int deltaBC, T const& bcs) while (bcIter != bcs.end() && bcIter.globalBC() <= maxBC) { maxBCId = bcIter.globalIndex(); ++bcIter; - ++moveCount; } - } else { while (bcIter.globalIndex() > 0 && bcIter.globalBC() > maxBC) { --bcIter; - --moveCount; maxBCId = bcIter.globalIndex(); } } - LOGF(debug, " BC range: %d - %d", minBCId, maxBCId); - - // reset bcIter - bcIter.moveByIndex(-moveCount); // create bc slice - T slice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, (uint64_t)minBCId}; - bcs.copyIndexBindings(slice); - LOGF(debug, " size of slice %d", slice.size()); - return slice; + T bcslice{{bcs.asArrowTable()->Slice(minBCId, maxBCId - minBCId + 1)}, (uint64_t)minBCId}; + bcs.copyIndexBindings(bcslice); + LOGF(debug, " size of slice %d", bcslice.size()); + return bcslice; } // In this variant of compatibleBCs the range of compatible BCs is calculated from the @@ -200,7 +193,7 @@ T compatibleBCs(C const& collision, int ndt, T const& bcs, int nMinBCs = 7) // In this variant of compatibleBCs the range of compatible BCs is defined by meanBC +- deltaBC. template -T compatibleBCs(uint64_t meanBC, int deltaBC, T const& bcs) +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); @@ -212,13 +205,13 @@ T compatibleBCs(uint64_t meanBC, int deltaBC, T const& bcs) // ----------------------------------------------------------------------------- // Same as above but for collisions with MC information template -T MCcompatibleBCs(F const& collision, int ndt, T const& bcs, int nMinBCs = 7) +T MCcompatibleBCs(F const& collision, int const& ndt, T const& bcs, int const& nMinBCs = 7) { LOGF(debug, "Collision time / resolution [ns]: %f / %f", collision.collisionTime(), collision.collisionTimeRes()); // return if collisions has no associated BC if (!collision.has_foundBC()) { - LOGF(info, "Collision %i - no BC found!", collision.globalIndex()); + LOGF(debug, "Collision %i - no BC found!", collision.globalIndex()); return T{{bcs.asArrowTable()->Slice(0, 0)}, (uint64_t)0}; } @@ -651,6 +644,9 @@ void fillBGBBFlags(upchelpers::FITInfo& info, uint64_t const& minbc, BCR const& // 0 <= bit <= 31 auto bit = bc.globalBC() - minbc; + if (bit < 0 || bit > 31) + continue; + if (!bc.selection_bit(o2::aod::evsel::kNoBGT0A)) SETBIT(info.BGFT0Apf, bit); if (!bc.selection_bit(o2::aod::evsel::kNoBGT0C)) @@ -676,52 +672,42 @@ void fillBGBBFlags(upchelpers::FITInfo& info, uint64_t const& minbc, BCR const& // ----------------------------------------------------------------------------- // extract FIT information -template -void getFITinfo(upchelpers::FITInfo& info, uint64_t const& bcnum, B const& bcs, aod::FT0s const& ft0s, aod::FV0As const& fv0as, aod::FDDs const& fdds) -{ - // find bc with globalBC = bcnum - Partition selbc = aod::bc::globalBC == bcnum; - selbc.bindTable(bcs); - - // if BC exists then update FIT information for this BC - if (selbc.size() > 0) { - auto bc = selbc.begin(); - - // FV0A - if (bc.has_foundFV0()) { - auto fv0 = fv0as.iteratorAt(bc.foundFV0Id()); - info.timeFV0A = fv0.time(); - info.ampFV0A = FV0AmplitudeA(fv0); - info.triggerMaskFV0A = fv0.triggerMask(); - } +template +void getFITinfo(upchelpers::FITInfo& info, BC& bc, BCS const& bcs, aod::FT0s const& ft0s, aod::FV0As const& fv0as, aod::FDDs const& fdds) +{ + // FV0A + if (bc.has_foundFV0()) { + auto fv0 = fv0as.iteratorAt(bc.foundFV0Id()); + info.timeFV0A = fv0.time(); + info.ampFV0A = FV0AmplitudeA(fv0); + info.triggerMaskFV0A = fv0.triggerMask(); + } - // FT0 - if (bc.has_foundFT0()) { - auto ft0 = ft0s.iteratorAt(bc.foundFT0Id()); - info.timeFT0A = ft0.timeA(); - info.timeFT0C = ft0.timeC(); - info.ampFT0A = FT0AmplitudeA(ft0); - info.ampFT0C = FT0AmplitudeC(ft0); - info.triggerMaskFT0 = ft0.triggerMask(); - } + // FT0 + if (bc.has_foundFT0()) { + auto ft0 = ft0s.iteratorAt(bc.foundFT0Id()); + info.timeFT0A = ft0.timeA(); + info.timeFT0C = ft0.timeC(); + info.ampFT0A = FT0AmplitudeA(ft0); + info.ampFT0C = FT0AmplitudeC(ft0); + info.triggerMaskFT0 = ft0.triggerMask(); + } - // FDD - if (bc.has_foundFDD()) { - auto fdd = fdds.iteratorAt(bc.foundFDDId()); - info.timeFDDA = fdd.timeA(); - info.timeFDDC = fdd.timeC(); - info.ampFDDA = FDDAmplitudeA(fdd); - info.ampFDDC = FDDAmplitudeC(fdd); - info.triggerMaskFDD = fdd.triggerMask(); - } + // FDD + if (bc.has_foundFDD()) { + auto fdd = fdds.iteratorAt(bc.foundFDDId()); + info.timeFDDA = fdd.timeA(); + info.timeFDDC = fdd.timeC(); + info.ampFDDA = FDDAmplitudeA(fdd); + info.ampFDDC = FDDAmplitudeC(fdd); + info.triggerMaskFDD = fdd.triggerMask(); } // fill BG and BB flags - auto minbc = bcnum - 16; - auto maxbc = bcnum + 15; - Partition bcrange = aod::bc::globalBC >= minbc && aod::bc::globalBC <= maxbc; - bcrange.bindTable(bcs); - fillBGBBFlags(info, minbc, bcrange); + auto bcnum = bc.globalBC(); + auto bcrange = compatibleBCs(bc, bcnum, 16, bcs); + LOGF(debug, "size of bcrange %d", bcrange.size()); + fillBGBBFlags(info, bcnum - 16, bcrange); } // ----------------------------------------------------------------------------- diff --git a/PWGUD/DataModel/SGTables.h b/PWGUD/DataModel/SGTables.h new file mode 100644 index 00000000000..e0896459fea --- /dev/null +++ b/PWGUD/DataModel/SGTables.h @@ -0,0 +1,71 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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_DATAMODEL_SGTABLES_H_ +#define PWGUD_DATAMODEL_SGTABLES_H_ + +#include +#include +#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" + +namespace o2::aod +{ +namespace sgevent +{ +DECLARE_SOA_COLUMN(Run, run, int32_t); +DECLARE_SOA_COLUMN(Flag, flag, int); +DECLARE_SOA_COLUMN(GS, gs, int); +DECLARE_SOA_COLUMN(ZNA, zna, float); +DECLARE_SOA_COLUMN(ZNC, znc, float); +DECLARE_SOA_COLUMN(Ntr, ntr, int); +} // namespace sgevent +DECLARE_SOA_TABLE(SGEvents, "AOD", "SGEVENT", // o2::soa::Index<>, + sgevent::Run, sgevent::Flag, sgevent::GS, sgevent::ZNA, sgevent::ZNC, sgevent::Ntr); +// sgevent::Run, sgevent::Flag); +using SGEvent = SGEvents::iterator; +namespace sgtrack +{ +DECLARE_SOA_INDEX_COLUMN(SGEvent, sgEvent); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Phi, phi, float); +DECLARE_SOA_COLUMN(Sign, sign, float); +DECLARE_SOA_COLUMN(TPCpi, tpcpi, float); +DECLARE_SOA_COLUMN(TPCka, tpcka, float); +DECLARE_SOA_COLUMN(TPCpr, tpcpr, float); +DECLARE_SOA_COLUMN(TPCel, tpcel, float); +DECLARE_SOA_COLUMN(TOFpi, tofpi, float); +DECLARE_SOA_COLUMN(TOFka, tofka, float); +DECLARE_SOA_COLUMN(TOFpr, tofpr, float); +DECLARE_SOA_COLUMN(TOFel, tofel, float); +DECLARE_SOA_COLUMN(TPCmu, tpcmu, float); +DECLARE_SOA_COLUMN(TOFmu, tofmu, float); +DECLARE_SOA_COLUMN(TPCde, tpcde, float); +DECLARE_SOA_COLUMN(TPCtr, tpctr, float); +DECLARE_SOA_COLUMN(TPChe, tpche, float); +DECLARE_SOA_COLUMN(TPCal, tpcal, float); +DECLARE_SOA_COLUMN(TOFde, tofde, float); +DECLARE_SOA_COLUMN(TOFtr, toftr, float); +DECLARE_SOA_COLUMN(TOFhe, tofhe, float); +DECLARE_SOA_COLUMN(TOFal, tofal, float); +} // namespace sgtrack +DECLARE_SOA_TABLE(SGTracks, "AOD", "SGTRACK", + o2::soa::Index<>, sgtrack::SGEventId, + sgtrack::Pt, sgtrack::Eta, sgtrack::Phi, sgtrack::Sign, sgtrack::TPCpi, sgtrack::TPCka, sgtrack::TPCpr, sgtrack::TPCel, sgtrack::TOFpi, sgtrack::TOFka, sgtrack::TOFpr, sgtrack::TOFel, sgtrack::TPCmu, sgtrack::TOFmu, sgtrack::TPCde, sgtrack::TPCtr, sgtrack::TPChe, sgtrack::TPCal, sgtrack::TOFde, sgtrack::TOFtr, sgtrack::TOFhe, sgtrack::TOFal); +using SGTrack = SGTracks::iterator; +} // namespace o2::aod + +#endif // PWGUD_DATAMODEL_SGTABLES_H_ diff --git a/PWGUD/DataModel/UDTables.h b/PWGUD/DataModel/UDTables.h index ece6b952678..b24bcdb2b77 100644 --- a/PWGUD/DataModel/UDTables.h +++ b/PWGUD/DataModel/UDTables.h @@ -86,16 +86,21 @@ DECLARE_SOA_COLUMN(TotalFT0AmplitudeC, totalFT0AmplitudeC, float); //! sum of am DECLARE_SOA_COLUMN(TimeFT0A, timeFT0A, float); //! FT0A average time DECLARE_SOA_COLUMN(TimeFT0C, timeFT0C, float); //! FT0C average time DECLARE_SOA_COLUMN(TriggerMaskFT0, triggerMaskFT0, uint8_t); //! FT0 trigger mask +DECLARE_SOA_COLUMN(ChFT0A, chFT0A, uint8_t); //! number of FT0A active channels +DECLARE_SOA_COLUMN(ChFT0C, chFT0C, uint8_t); //! number of FT0C active channels // FDD information DECLARE_SOA_COLUMN(TotalFDDAmplitudeA, totalFDDAmplitudeA, float); //! sum of amplitudes on A side of FDD DECLARE_SOA_COLUMN(TotalFDDAmplitudeC, totalFDDAmplitudeC, float); //! sum of amplitudes on C side of FDD DECLARE_SOA_COLUMN(TimeFDDA, timeFDDA, float); //! FDDA average time DECLARE_SOA_COLUMN(TimeFDDC, timeFDDC, float); //! FDDC average time DECLARE_SOA_COLUMN(TriggerMaskFDD, triggerMaskFDD, uint8_t); //! FDD trigger mask +DECLARE_SOA_COLUMN(ChFDDA, chFDDA, uint8_t); //! number of FDDA active channels +DECLARE_SOA_COLUMN(ChFDDC, chFDDC, uint8_t); //! number of FDDC active channels // FV0A information DECLARE_SOA_COLUMN(TotalFV0AmplitudeA, totalFV0AmplitudeA, float); //! sum of amplitudes on A side of FDD DECLARE_SOA_COLUMN(TimeFV0A, timeFV0A, float); //! FV0A average time DECLARE_SOA_COLUMN(TriggerMaskFV0A, triggerMaskFV0A, uint8_t); //! FV0 trigger mask +DECLARE_SOA_COLUMN(ChFV0A, chFV0A, uint8_t); //! number of FV0A active channels // 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 @@ -151,7 +156,7 @@ DECLARE_SOA_INDEX_COLUMN(UDMcCollision, udMcCollision); } // namespace udcollision -DECLARE_SOA_TABLE(UDCollisions, "AOD", "UDCOLLISION", +DECLARE_SOA_TABLE(UDCollisions_000, "AOD", "UDCOLLISION", o2::soa::Index<>, udcollision::GlobalBC, udcollision::RunNumber, @@ -161,6 +166,18 @@ DECLARE_SOA_TABLE(UDCollisions, "AOD", "UDCOLLISION", collision::NumContrib, udcollision::NetCharge, udcollision::RgtrwTOF); +// Version with UPC Reco Flag +DECLARE_SOA_TABLE_VERSIONED(UDCollisions_001, "AOD", "UDCOLLISION", 1, + o2::soa::Index<>, + udcollision::GlobalBC, + udcollision::RunNumber, + collision::PosX, + collision::PosY, + collision::PosZ, + collision::Flags, + collision::NumContrib, + udcollision::NetCharge, + udcollision::RgtrwTOF); DECLARE_SOA_TABLE(SGCollisions, "AOD", "SGCOLLISION", udcollision::GapSide); @@ -186,6 +203,13 @@ DECLARE_SOA_TABLE(UDCollisionsSels, "AOD", "UDCOLLISIONSEL", udcollision::BBFV0A, udcollision::BGFV0A, udcollision::BBFDDA, udcollision::BBFDDC, udcollision::BGFDDA, udcollision::BGFDDC); +DECLARE_SOA_TABLE(UDCollisionSelExtras, "AOD", "UDCOLSELEXTRA", + 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 + // central barrel-specific selections DECLARE_SOA_TABLE(UDCollisionsSelsCent, "AOD", "UDCOLSELCNT", udcollision::DBcTOR, @@ -208,11 +232,14 @@ DECLARE_SOA_TABLE(UDCollsLabels, "AOD", "UDCOLLSLABEL", DECLARE_SOA_TABLE(UDMcCollsLabels, "AOD", "UDMCCOLLSLABEL", udcollision::UDMcCollisionId); +using UDCollisions = UDCollisions_001; + using UDCollision = UDCollisions::iterator; using SGCollision = SGCollisions::iterator; using UDCollisionsSel = UDCollisionsSels::iterator; using UDCollisionsSelCent = UDCollisionsSelsCent::iterator; using UDCollisionsSelFwd = UDCollisionsSelsFwd::iterator; +using UDCollisionSelExtra = UDCollisionSelExtras::iterator; using UDCollsLabel = UDCollsLabels::iterator; using UDMcCollsLabel = UDMcCollsLabels::iterator; @@ -264,6 +291,10 @@ DECLARE_SOA_TABLE(UDTracksPID, "AOD", "UDTRACKPID", pidtofbeta::Beta, pidtofbeta::BetaError, pidtof::TOFNSigmaEl, pidtof::TOFNSigmaMu, pidtof::TOFNSigmaPi, pidtof::TOFNSigmaKa, pidtof::TOFNSigmaPr); +DECLARE_SOA_TABLE(UDTracksPIDExtra, "AOD", "UDTRACKPIDEXTRA", + pidtpc::TPCNSigmaDe, pidtpc::TPCNSigmaTr, pidtpc::TPCNSigmaHe, pidtpc::TPCNSigmaAl, + pidtof::TOFNSigmaDe, pidtof::TOFNSigmaTr, pidtof::TOFNSigmaHe, pidtof::TOFNSigmaAl); + DECLARE_SOA_TABLE(UDTracksExtra, "AOD", "UDTRACKEXTRA", track::TPCInnerParam, track::ITSClusterSizes, @@ -372,18 +403,32 @@ DECLARE_SOA_TABLE(UDFwdIndices, "AOD", "UDFWDINDEX", udfwdmatchindex::MFTTrackId); // Muon track quality details -DECLARE_SOA_TABLE(UDFwdTracksExtra, "AOD", "UDFWDTRACKEXTRA", - fwdtrack::TrackType, +// Version with only MCH-MID tracks +DECLARE_SOA_TABLE(UDFwdTracksExtra_000, "AOD", "UDFWDTRACKEXTRA", fwdtrack::NClusters, fwdtrack::PDca, fwdtrack::RAtAbsorberEnd, fwdtrack::Chi2, fwdtrack::Chi2MatchMCHMID, - fwdtrack::Chi2MatchMCHMFT, fwdtrack::MCHBitMap, fwdtrack::MIDBitMap, fwdtrack::MIDBoards); +// Version with global tracks +DECLARE_SOA_TABLE_VERSIONED(UDFwdTracksExtra_001, "AOD", "UDFWDTRACKEXTRA", 1, + fwdtrack::TrackType, + fwdtrack::NClusters, + fwdtrack::PDca, + fwdtrack::RAtAbsorberEnd, + fwdtrack::Chi2, + fwdtrack::Chi2MatchMCHMID, + fwdtrack::Chi2MatchMCHMFT, + fwdtrack::MCHBitMap, + fwdtrack::MIDBitMap, + fwdtrack::MIDBoards); + +using UDFwdTracksExtra = UDFwdTracksExtra_001; + using UDFwdTrack = UDFwdTracks::iterator; using UDFwdIndex = UDFwdIndices::iterator; using UDFwdTrackExtra = UDFwdTracksExtra::iterator; diff --git a/PWGUD/TableProducer/CMakeLists.txt b/PWGUD/TableProducer/CMakeLists.txt index 2406868718c..8234d926ef2 100644 --- a/PWGUD/TableProducer/CMakeLists.txt +++ b/PWGUD/TableProducer/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(dgcand-producer SOURCES DGCandProducer.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGCutparHolder diff --git a/PWGUD/TableProducer/Converters/CMakeLists.txt b/PWGUD/TableProducer/Converters/CMakeLists.txt new file mode 100644 index 00000000000..3bcb34f6ac2 --- /dev/null +++ b/PWGUD/TableProducer/Converters/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(fwd-tracks-extra-converter + SOURCES UDFwdTracksExtraConverter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + + +o2physics_add_dpl_workflow(collisions-converter + SOURCES UDCollisionsConverter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + diff --git a/PWGUD/TableProducer/Converters/UDCollisionsConverter.cxx b/PWGUD/TableProducer/Converters/UDCollisionsConverter.cxx new file mode 100644 index 00000000000..8be7bce717b --- /dev/null +++ b/PWGUD/TableProducer/Converters/UDCollisionsConverter.cxx @@ -0,0 +1,58 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 UDCollisionsConverter.cxx +/// \brief Converts UDCollisions table from version 000 to 001 + +/// This task allows for the conversion of the UDCollisions table from the version 000, +/// that is before the introduction of Flags for UPC reconstruction +/// to the version 001, that includes it + +/// executable name o2-analysis-ud-collisions-converter + +/// \author Sasha Bylinkin + +#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 001 +struct UDCollisionsConverter { + Produces udCollisions_001; + + void process(o2::aod::UDCollisions_000 const& collisions) + { + + for (const auto& collision : collisions) { + + udCollisions_001(collision.globalBC(), + collision.runNumber(), + collision.posX(), + collision.posY(), + collision.posZ(), + 0.0f, // dummy UPC reco flag, not available in version 000 + collision.numContrib(), + collision.netCharge(), + collision.rgtrwTOF()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/TableProducer/Converters/UDFwdTracksExtraConverter.cxx b/PWGUD/TableProducer/Converters/UDFwdTracksExtraConverter.cxx new file mode 100644 index 00000000000..f9b1f2d0d22 --- /dev/null +++ b/PWGUD/TableProducer/Converters/UDFwdTracksExtraConverter.cxx @@ -0,0 +1,68 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 UDFwdTracksExtraConverter.cxx +/// \brief Converts UDFwdTracksExtra table from version 000 to 001 + +/// This task allows for the conversion of the UDFwdTracksExtra table from the version 000, +/// that is before the introduction of global tracks (and so contains only MCH-MID and +/// MCH only tracks), to the version 001, that includes global tracks +/// Global tracks introduced here: https://github.com/AliceO2Group/O2Physics/commit/72f673611ddcd7c39978787dbed9f77e6e7c3d6a) + +/// executable name o2-analysis-ud-fwd-tracks-extra-converter + +/// \author Andrea Giovanni Riffero + +#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 UDFwdTracksExtra for version 000 to 001 +// v_000 only MID-MCH and MCH only tracks +// v_001 global tracks +struct UDFwdTracksExtraConverter { + Produces udFwdTracksExtra_001; + + void process(o2::aod::UDFwdTracksExtra_000 const& tracks) + { + int trkType = 3; // trackType of MCH-MID tracks is 3 + + for (const auto& track : tracks) { + + if (track.chi2MatchMCHMID() > 0) + trkType = 3; // trackType of MCH-MID tracks is 3 + if (track.chi2MatchMCHMID() < 0) + trkType = 4; // trackType of MCH only tracks is 4 + + udFwdTracksExtra_001(trkType, + track.nClusters(), + track.pDca(), + track.rAtAbsorberEnd(), + track.chi2(), + track.chi2MatchMCHMID(), + 0.0f, // dummy mchmftChi2, not available in version 000 + track.mchBitMap(), + track.midBitMap(), + track.midBoards()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/TableProducer/DGBCCandProducer.cxx b/PWGUD/TableProducer/DGBCCandProducer.cxx index d765be9afc6..97b60c42c9e 100644 --- a/PWGUD/TableProducer/DGBCCandProducer.cxx +++ b/PWGUD/TableProducer/DGBCCandProducer.cxx @@ -17,6 +17,7 @@ #include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" +#include "ReconstructionDataFormats/Vertex.h" #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/UDHelpers.h" #include "PWGUD/Core/UPCHelpers.h" @@ -279,11 +280,11 @@ struct DGBCCandProducer { // update UDTables template - void updateUDTables(bool onlyPV, int64_t colID, uint64_t bcnum, int rnum, float vx, float vy, float vz, + void updateUDTables(bool onlyPV, int64_t colID, uint64_t bcnum, int rnum, float vx, float vy, float vz, int flag, uint16_t const& ntrks, int8_t const& ncharge, float const& rtrwTOF, TTracks const& tracks, upchelpers::FITInfo const& fitInfo) { - outputCollisions(bcnum, rnum, vx, vy, vz, ntrks, ncharge, rtrwTOF); + outputCollisions(bcnum, rnum, vx, vy, vz, flag, ntrks, ncharge, rtrwTOF); outputCollisionsSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, @@ -380,11 +381,10 @@ struct DGBCCandProducer { // fill FITInfo auto bcnum = tibc.bcnum(); upchelpers::FITInfo fitInfo{}; - udhelpers::getFITinfo(fitInfo, bcnum, bcs, ft0s, fv0as, fdds); // check if DG event // distinguish between cases with and without associated BC - // 1. candidate has associated BC and associated collision -> vertex position: col.[posX(), posY(), posZ()] + // 1. candidate has associated BC and associated collision -> position: col.[posX(), posY(), posZ()] // 2. candidate has associated BC but no associated collision -> [-2., 2., -2.] // 3. candidate has no associated BC -> [-3., 3., -3.] int isDG = -1; @@ -395,6 +395,7 @@ struct DGBCCandProducer { // get associated bc auto bc = tibc.bc_as(); + udhelpers::getFITinfo(fitInfo, bc, bcs, ft0s, fv0as, fdds); // is there an associated collision? Partition colSlize = aod::evsel::foundBCId == bc.globalIndex(); @@ -415,8 +416,11 @@ struct DGBCCandProducer { registry.get(HIST("table/candCase"))->Fill(1, 1.); rtrwTOF = udhelpers::rPVtrwTOF(colTracks, col.numContrib()); nCharge = udhelpers::netCharge(colTracks); - - updateUDTables(false, col.globalIndex(), bc.globalBC(), bc.runNumber(), col.posX(), col.posY(), col.posZ(), + int upc_flag = 0; + ushort flags = col.flags(); + if (flags & dataformats::Vertex>::Flags::UPCMode) + upc_flag = 1; + updateUDTables(false, col.globalIndex(), bc.globalBC(), bc.runNumber(), col.posX(), col.posY(), col.posZ(), upc_flag, col.numContrib(), nCharge, rtrwTOF, colTracks, fitInfo); } } else { @@ -448,7 +452,7 @@ struct DGBCCandProducer { rtrwTOF = udhelpers::rPVtrwTOF(tracksArray, tracksArray.size()); nCharge = udhelpers::netCharge(tracksArray); - updateUDTables(false, -1, bc.globalBC(), bc.runNumber(), -2., 2., -2, + updateUDTables(false, -1, bc.globalBC(), bc.runNumber(), -2., 2., -2, 0, tracksArray.size(), nCharge, rtrwTOF, tracksArray, fitInfo); } } @@ -494,7 +498,7 @@ struct DGBCCandProducer { rtrwTOF = udhelpers::rPVtrwTOF(tracksArray, tracksArray.size()); nCharge = udhelpers::netCharge(tracksArray); - updateUDTables(false, -1, bcnum, tibc.runNumber(), -3., 3., -3, + updateUDTables(false, -1, bcnum, tibc.runNumber(), -3., 3., -3, 0, tracksArray.size(), nCharge, rtrwTOF, tracksArray, fitInfo); } } @@ -611,8 +615,12 @@ struct DGBCCandProducer { auto rtrwTOF = udhelpers::rPVtrwTOF(colTracks, col.numContrib()); auto nCharge = udhelpers::netCharge(colTracks); - udhelpers::getFITinfo(fitInfo, bcnum, bcs, ft0s, fv0as, fdds); - updateUDTables(false, col.globalIndex(), bcnum, bc.runNumber(), col.posX(), col.posY(), col.posZ(), + udhelpers::getFITinfo(fitInfo, bc, bcs, ft0s, fv0as, fdds); + int upc_flag = 0; + ushort flags = col.flags(); + if (flags & dataformats::Vertex>::Flags::UPCMode) + upc_flag = 1; + updateUDTables(false, col.globalIndex(), bcnum, bc.runNumber(), col.posX(), col.posY(), col.posZ(), upc_flag, col.numContrib(), nCharge, rtrwTOF, colTracks, fitInfo); // fill UDZdcs if (bc.has_zdc()) { @@ -661,7 +669,7 @@ struct DGBCCandProducer { auto rtrwTOF = udhelpers::rPVtrwTOF(tracksArray, tracksArray.size()); auto nCharge = udhelpers::netCharge(tracksArray); - udhelpers::getFITinfo(fitInfo, bcnum, bcs, ft0s, fv0as, fdds); + udhelpers::getFITinfo(fitInfo, bc, bcs, ft0s, fv0as, fdds); // distinguish different cases if (bc.globalBC() == bcnum) { @@ -681,7 +689,11 @@ struct DGBCCandProducer { } int64_t colID = withCollision ? col.globalIndex() : -1; - updateUDTables(false, colID, bcnum, tibc.runNumber(), vpos[0], vpos[1], vpos[2], + int upc_flag = 0; + ushort flags = col.flags(); + if (flags & dataformats::Vertex>::Flags::UPCMode) + upc_flag = 1; + updateUDTables(false, colID, bcnum, tibc.runNumber(), vpos[0], vpos[1], vpos[2], upc_flag, tracksArray.size(), nCharge, rtrwTOF, tracksArray, fitInfo); // fill UDZdcs if (bc.globalBC() == bcnum) { diff --git a/PWGUD/TableProducer/DGCandProducer.cxx b/PWGUD/TableProducer/DGCandProducer.cxx index e0a6f5df303..027cfd376ee 100644 --- a/PWGUD/TableProducer/DGCandProducer.cxx +++ b/PWGUD/TableProducer/DGCandProducer.cxx @@ -12,8 +12,12 @@ // \brief Saves relevant information of DG candidates // \author Paul Buehler, paul.buehler@oeaw.ac.at +#include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" +#include "ReconstructionDataFormats/Vertex.h" #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/UPCHelpers.h" #include "PWGUD/Core/DGSelector.h" @@ -136,8 +140,10 @@ struct DGCandProducer { template void fillFIThistograms(TBC const& bc) { + LOGF(debug, ""); std::array triggers{{true, !udhelpers::cleanFIT(bc, diffCuts.maxFITtime(), diffCuts.FITAmpLimits()), udhelpers::TVX(bc), udhelpers::TSC(bc), udhelpers::TCE(bc)}}; + LOGF(debug, "triggers %d %d %d %d %d", triggers[0], triggers[1], triggers[2], triggers[3], triggers[4]); if (bc.has_foundFV0()) { auto fv0 = bc.foundFV0(); auto ampA = udhelpers::FV0AmplitudeA(fv0); @@ -212,11 +218,12 @@ struct DGCandProducer { // 4: TCE 8: no TCE // 9: IsBBXXX 10: !IsBBXXX // 11: kNoBGXXX 12: !kNoBGXXX - registry.add("reco/fv0", "FV0 amplitudes", {HistType::kTH2F, {{20001, -0.5, 20000.5}, {13, -0.5, 12.5}}}); - registry.add("reco/ft0A", "FT0A amplitudes", {HistType::kTH2F, {{20001, -0.5, 20000.5}, {13, -0.5, 12.5}}}); - registry.add("reco/ft0C", "FT0C amplitudes", {HistType::kTH2F, {{20001, -0.5, 20000.5}, {13, -0.5, 12.5}}}); - registry.add("reco/fddA", "FDDA amplitudes", {HistType::kTH2F, {{20001, -0.5, 20000.5}, {13, -0.5, 12.5}}}); - registry.add("reco/fddC", "FDDC amplitudes", {HistType::kTH2F, {{20001, -0.5, 20000.5}, {13, -0.5, 12.5}}}); + 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", @@ -262,12 +269,16 @@ struct DGCandProducer { // fill FITInfo upchelpers::FITInfo fitInfo{}; - udhelpers::getFITinfo(fitInfo, bc.globalBC(), bcs, ft0s, fv0as, fdds); + 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; outputCollisions(bc.globalBC(), bc.runNumber(), - collision.posX(), collision.posY(), collision.posZ(), + collision.posX(), collision.posY(), collision.posZ(), upc_flag, collision.numContrib(), udhelpers::netCharge(tracks), rtrwTOF); outputCollisionsSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, @@ -367,7 +378,8 @@ struct McDGCandProducer { void updateUDMcCollisions(TMcCollision const& mccol) { // save mccol - outputMcCollisions(mccol.bcId(), + auto bc = mccol.template bc_as(); + outputMcCollisions(bc.globalBC(), mccol.generatorsID(), mccol.posX(), mccol.posY(), @@ -406,38 +418,59 @@ struct McDGCandProducer { template void updateUDMcParticles(TMcParticles const& McParts, int64_t McCollisionId, std::map& mcPartIsSaved) { + LOGF(debug, "number of McParticles %d", McParts.size()); // save McParts // new mother and daughter ids std::vector newmids; int32_t newdids[2] = {-1, -1}; int64_t newval = -1; + // Determine the particle indices within the UDMcParticles table + // before filling the table + // This is needed to be able to assign the new daughter indices + std::map oldnew; + auto lastId = outputMcParticles.lastIndex(); + for (auto mcpart : McParts) { + auto oldId = mcpart.globalIndex(); + if (mcPartIsSaved.find(oldId) != mcPartIsSaved.end()) { + oldnew[oldId] = mcPartIsSaved[oldId]; + } else { + lastId++; + oldnew[oldId] = lastId; + } + } + // all particles of the McCollision are saved for (auto mcpart : McParts) { + LOGF(debug, " p (%d) %d", mcpart.pdgCode(), mcpart.globalIndex()); if (mcPartIsSaved.find(mcpart.globalIndex()) == mcPartIsSaved.end()) { - // correct mother and daughter IDs + // mothers newmids.clear(); auto oldmids = mcpart.mothersIds(); - for (uint ii = 0; ii < oldmids.size(); ii++) { - if (mcPartIsSaved.find(oldmids[ii]) != mcPartIsSaved.end()) { - newval = mcPartIsSaved[oldmids[ii]]; - LOGF(debug, " mid %i / %i", oldmids[ii], newval); + for (auto oldmid : oldmids) { + auto m = McParts.rawIteratorAt(oldmid); + LOGF(debug, " m %d", m.globalIndex()); + if (mcPartIsSaved.find(oldmid) != mcPartIsSaved.end()) { + newval = mcPartIsSaved[oldmid]; } else { newval = -1; } + LOGF(debug, " mid o %i n %i", oldmid, newval); newmids.push_back(newval); } + + // daughters auto olddids = mcpart.daughtersIds(); for (uint ii = 0; ii < olddids.size(); ii++) { - if (mcPartIsSaved.find(olddids[ii]) != mcPartIsSaved.end()) { - newval = mcPartIsSaved[olddids[ii]]; - LOGF(debug, " did %i / %i", olddids[ii], newval); + if (oldnew.find(olddids[ii]) != oldnew.end()) { + newval = oldnew[olddids[ii]]; } else { newval = -1; } + LOGF(debug, " did o %i n %i", olddids[ii], newval); newdids[ii] = newval; } - LOGF(debug, " ms %i ds %i", oldmids.size(), olddids.size()); + LOGF(debug, " ms %i ds %i", oldmids.size(), olddids.size()); // update UDMcParticles outputMcParticles(McCollisionId, @@ -452,6 +485,7 @@ struct McDGCandProducer { mcpart.pz(), mcpart.e()); mcPartIsSaved[mcpart.globalIndex()] = outputMcParticles.lastIndex(); + LOGF(debug, " mcpart %d -> udmcpart %d", mcpart.globalIndex(), mcPartIsSaved[mcpart.globalIndex()]); } } } @@ -543,29 +577,33 @@ struct McDGCandProducer { // 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 = true; + bool goon = !dgcandAtEnd || !mccolAtEnd; + while (goon) { - // check if dgcand has an associated McCollision - if (!dgcand.has_collision()) { - mcdgId = -1; - } else { + // check if dgcand has an associated Collision and McCollision + if (dgcand.has_collision()) { auto dgcandCol = dgcand.collision_as(); - if (!dgcandCol.has_mcCollision()) { - mcdgId = -1; - } else { + colId = dgcandCol.globalIndex(); + if (dgcandCol.has_mcCollision()) { mcdgId = dgcandCol.mcCollision().globalIndex(); + } else { + mcdgId = -1; } + } else { + colId = -1; + mcdgId = -1; } - LOGF(info, "\nStart of loop mcdgId %d mccolId %d", mcdgId, mccolId); + LOGF(debug, ""); + LOGF(debug, "dgcand %d mcdgId %d colId %d mccolId %d - UDMcCollsLabels %d UDMcCollisions %d", dgcand.globalIndex(), mcdgId, colId, mccolId, outputMcCollsLabels.lastIndex(), outputMcCollisions.lastIndex()); // two cases to consider - // 1. the event to process is a dgcand. In this case the Mc tables as well as the McLabel tables are updated - // 2. the event to process is an event of interest. In this case only the Mc tables are updated + // 1. mcdgId <= mccolId: the event to process is a dgcand. In this case the Mc tables as well as the McLabel tables are updated + // 2. mccolId < mcdgId: the event to process is an MC event of interest without reconstructed dgcand. In this case only the Mc tables are updated if ((!dgcandAtEnd && !mccolAtEnd && (mcdgId <= mccolId)) || mccolAtEnd) { // this is case 1. - LOGF(info, "Doing case 1 with mcdgId %d", mcdgId); // update UDMcCollisions and UDMcColsLabels (for each UDCollision -> UDMcCollisions) // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) @@ -576,14 +614,15 @@ struct McDGCandProducer { // McParticles are saved if (mcdgId >= 0) { if (mcColIsSaved.find(mcdgId) == mcColIsSaved.end()) { - LOGF(info, " Saving McCollision %d", mcdgId); // update UDMcCollisions + LOGF(debug, " writing mcCollision %d to UDMcCollisions", mcdgId); auto dgcandMcCol = dgcand.collision_as().mcCollision(); updateUDMcCollisions(dgcandMcCol); mcColIsSaved[mcdgId] = outputMcCollisions.lastIndex(); } // update UDMcColsLabels (for each UDCollision -> UDMcCollisions) + LOGF(debug, " writing %d to outputMcCollsLabels", mcColIsSaved[mcdgId]); outputMcCollsLabels(mcColIsSaved[mcdgId]); // update UDMcParticles @@ -596,9 +635,9 @@ struct McDGCandProducer { } else { // If the dgcand has no associated McCollision then only the McParticles which are associated // with the tracks of the dgcand are saved - LOGF(info, " Saving McCollision %d", -1); // update UDMcColsLabels (for each UDCollision -> UDMcCollisions) + LOGF(debug, " writing %d to UDMcCollsLabels", -1); outputMcCollsLabels(-1); // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) @@ -626,12 +665,12 @@ struct McDGCandProducer { } } else { // this is case 2. - LOGF(info, "Doing case 2"); // update UDMcCollisions and UDMcParticles if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { - LOGF(info, " Saving McCollision %d", mccolId); + // update UDMcCollisions + LOGF(debug, " writing mcCollision %d to UDMcCollisions", mccolId); updateUDMcCollisions(mccol); mcColIsSaved[mccolId] = outputMcCollisions.lastIndex(); @@ -648,9 +687,8 @@ struct McDGCandProducer { mccolAtEnd = true; } } - + LOGF(debug, " UDMcCollsLabels %d (of %d) UDMcCollisions %d", outputMcCollsLabels.lastIndex(), dgcands.size() - 1, outputMcCollisions.lastIndex()); goon = !dgcandAtEnd || !mccolAtEnd; - LOGF(info, "End of loop mcdgId %d mccolId %d", mcdgId, mccolId); } } PROCESS_SWITCH(McDGCandProducer, processMC, "Produce MC tables", false); diff --git a/PWGUD/TableProducer/SGCandProducer.cxx b/PWGUD/TableProducer/SGCandProducer.cxx index a38dc6a334c..aabaa4357ae 100644 --- a/PWGUD/TableProducer/SGCandProducer.cxx +++ b/PWGUD/TableProducer/SGCandProducer.cxx @@ -10,8 +10,11 @@ // or submit itself to any jurisdiction. #include +#include +#include #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" +#include "ReconstructionDataFormats/Vertex.h" #include "Common/CCDB/EventSelectionParams.h" #include "Common/DataModel/EventSelection.h" #include "CommonConstants/LHCConstants.h" @@ -38,6 +41,11 @@ 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 + + // 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; @@ -47,11 +55,12 @@ struct SGCandProducer { Produces outputCollisionsSels; Produces outputCollsLabels; Produces outputZdcs; - Produces udZdcsReduced; + Produces udZdcsReduced; Produces outputTracks; Produces outputTracksCov; Produces outputTracksDCA; Produces outputTracksPID; + Produces outputTracksPIDExtra; Produces outputTracksExtra; Produces outputTracksFlag; Produces outputFwdTracks; @@ -70,7 +79,9 @@ struct SGCandProducer { using BC = BCs::iterator; using TCs = soa::Join; using FWs = aod::FwdTracks; @@ -121,6 +132,14 @@ struct SGCandProducer { track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()); + outputTracksPIDExtra(track.tpcNSigmaDe(), + track.tpcNSigmaTr(), + track.tpcNSigmaHe(), + track.tpcNSigmaAl(), + track.tofNSigmaDe(), + track.tofNSigmaTr(), + track.tofNSigmaHe(), + track.tofNSigmaAl()); outputTracksExtra(track.tpcInnerParam(), track.itsClusterSizes(), track.tpcNClsFindable(), @@ -193,7 +212,7 @@ struct SGCandProducer { auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange, bc); // auto isSGEvent = sgSelector.IsSelected(sameCuts, collision, bcRange, tracks); int issgevent = isSGEvent.value; - if (isSGEvent.bc) { + if (isSGEvent.bc && issgevent < 2) { newbc = *(isSGEvent.bc); } else { LOGF(info, "No Newbc %i", bc.globalBC()); @@ -206,12 +225,17 @@ struct SGCandProducer { return; } upchelpers::FITInfo fitInfo{}; - udhelpers::getFITinfo(fitInfo, newbc.globalBC(), bcs, ft0s, fv0as, fdds); + udhelpers::getFITinfo(fitInfo, newbc, bcs, ft0s, fv0as, fdds); // 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(), + collision.posX(), collision.posY(), collision.posZ(), upc_flag, collision.numContrib(), udhelpers::netCharge(tracks), 1.); // rtrwTOF); //omit the calculation to speed up the things while skimming + outputSGCollisions(issgevent); outputCollisionsSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, @@ -229,32 +253,380 @@ struct SGCandProducer { udZdcsReduced(outputCollisions.lastIndex(), -999, -999, -999, -999); } // update SGTracks tables - for (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()); - } else if (saveAllTracks) { - if (track.itsClusterSizes() && track.itsChi2NCl() > 0 && ((track.tpcNClsFindable() == 0 && savenonPVCITSOnlyTracks) || track.tpcNClsFindable() > 50)) + if (fillTrackTables) { + for (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()); - // if (track.isPVContributor()) updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC()); + } else if (saveAllTracks) { + if (track.itsClusterSizes() && track.itsChi2NCl() > 0 && ((track.tpcNClsFindable() == 0 && savenonPVCITSOnlyTracks) || track.tpcNClsFindable() > 50)) + updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC()); + // if (track.isPVContributor()) updateUDTrackTables(outputCollisions.lastIndex(), track, bc.globalBC()); + } } } } // update SGFwdTracks tables - if (sameCuts.withFwdTracks()) { - for (auto& fwdtrack : fwdtracks) { - if (!sgSelector.FwdTrkSelector(fwdtrack)) - updateUDFwdTrackTables(fwdtrack, bc.globalBC()); + if (fillFwdTrackTables) { + if (sameCuts.withFwdTracks()) { + for (auto& fwdtrack : fwdtracks) { + if (!sgSelector.FwdTrkSelector(fwdtrack)) + updateUDFwdTrackTables(fwdtrack, bc.globalBC()); + } + } + } + } + } +}; + +struct McSGCandProducer { + // MC tables + Produces outputMcCollisions; + Produces outputMcParticles; + Produces outputMcCollsLabels; + Produces outputMcTrackLabels; + + using CCs = soa::Join; + using BCs = soa::Join; + using TCs = soa::Join; + using UDCCs = soa::Join; + using UDTCs = soa::Join; + + // prepare slices + SliceCache cache; + PresliceUnsorted mcPartsPerMcCollision = aod::mcparticle::mcCollisionId; + Preslice udtracksPerUDCollision = aod::udtrack::udCollisionId; + + // initialize histogram registry + HistogramRegistry registry{ + "registry", + {}}; + + template + void updateUDMcCollisions(TMcCollision const& mccol, uint64_t globBC) + { + // save mccol + outputMcCollisions(globBC, + mccol.generatorsID(), + mccol.posX(), + mccol.posY(), + mccol.posZ(), + mccol.t(), + mccol.weight(), + mccol.impactParameter()); + } + + template + void updateUDMcParticle(TMcParticle const& McPart, int64_t McCollisionId, std::map& mcPartIsSaved) + { + // save McPart + // mother and daughter indices are set to -1 + // ATTENTION: this can be improved to also include mother and daughter indices + std::vector newmids; + int32_t newdids[2] = {-1, -1}; + + // update UDMcParticles + if (mcPartIsSaved.find(McPart.globalIndex()) == mcPartIsSaved.end()) { + outputMcParticles(McCollisionId, + McPart.pdgCode(), + McPart.statusCode(), + McPart.flags(), + newmids, + newdids, + McPart.weight(), + McPart.px(), + McPart.py(), + McPart.pz(), + McPart.e()); + mcPartIsSaved[McPart.globalIndex()] = outputMcParticles.lastIndex(); + } + } + + template + void updateUDMcParticles(TMcParticles const& McParts, int64_t McCollisionId, std::map& mcPartIsSaved) + { + // save McParts + // new mother and daughter ids + std::vector newmids; + int32_t newdids[2] = {-1, -1}; + int64_t newval = -1; + + // Determine the particle indices within the UDMcParticles table + // before filling the table + // This is needed to be able to assign the new daughter indices + std::map oldnew; + auto lastId = outputMcParticles.lastIndex(); + for (auto mcpart : McParts) { + auto oldId = mcpart.globalIndex(); + if (mcPartIsSaved.find(oldId) != mcPartIsSaved.end()) { + oldnew[oldId] = mcPartIsSaved[oldId]; + } else { + lastId++; + oldnew[oldId] = lastId; + } + } + + // all particles of the McCollision are saved + for (auto mcpart : McParts) { + if (mcPartIsSaved.find(mcpart.globalIndex()) == mcPartIsSaved.end()) { + // mothers + newmids.clear(); + auto oldmids = mcpart.mothersIds(); + for (auto oldmid : oldmids) { + auto m = McParts.rawIteratorAt(oldmid); + LOGF(debug, " m %d", m.globalIndex()); + if (mcPartIsSaved.find(oldmid) != mcPartIsSaved.end()) { + newval = mcPartIsSaved[oldmid]; + } else { + newval = -1; + } + newmids.push_back(newval); + } + // daughters + auto olddids = mcpart.daughtersIds(); + for (uint ii = 0; ii < olddids.size(); ii++) { + if (oldnew.find(olddids[ii]) != oldnew.end()) { + newval = oldnew[olddids[ii]]; + } else { + newval = -1; + } + newdids[ii] = newval; + } + LOGF(debug, " ms %i ds %i", oldmids.size(), olddids.size()); + + // update UDMcParticles + outputMcParticles(McCollisionId, + mcpart.pdgCode(), + mcpart.statusCode(), + mcpart.flags(), + newmids, + newdids, + mcpart.weight(), + mcpart.px(), + mcpart.py(), + mcpart.pz(), + mcpart.e()); + mcPartIsSaved[mcpart.globalIndex()] = outputMcParticles.lastIndex(); + } + } + } + + template + void updateUDMcTrackLabel(TTrack const& udtrack, std::map& mcPartIsSaved) + { + // udtrack (UDTCs) -> track (TCs) -> mcTrack (McParticles) -> udMcTrack (UDMcParticles) + auto trackId = udtrack.trackId(); + if (trackId >= 0) { + auto track = udtrack.template track_as(); + auto mcTrackId = track.mcParticleId(); + if (mcTrackId >= 0) { + if (mcPartIsSaved.find(mcTrackId) != mcPartIsSaved.end()) { + outputMcTrackLabels(mcPartIsSaved[mcTrackId], track.mcMask()); + } else { + outputMcTrackLabels(-1, track.mcMask()); + } + } else { + outputMcTrackLabels(-1, track.mcMask()); + } + } else { + outputMcTrackLabels(-1, -1); + } + } + + template + void updateUDMcTrackLabels(TTrack const& udtracks, std::map& mcPartIsSaved) + { + // loop over all tracks + for (auto udtrack : udtracks) { + // udtrack (UDTCs) -> track (TCs) -> mcTrack (McParticles) -> udMcTrack (UDMcParticles) + auto trackId = udtrack.trackId(); + if (trackId >= 0) { + auto track = udtrack.template track_as(); + auto mcTrackId = track.mcParticleId(); + if (mcTrackId >= 0) { + if (mcPartIsSaved.find(mcTrackId) != mcPartIsSaved.end()) { + outputMcTrackLabels(mcPartIsSaved[mcTrackId], track.mcMask()); + } else { + outputMcTrackLabels(-1, track.mcMask()); + } + } else { + outputMcTrackLabels(-1, track.mcMask()); } + } else { + outputMcTrackLabels(-1, -1); } } } + + 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*/) + { + 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) { + 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 + // {McParticleId : udMcParticleId} + std::map mcColIsSaved; + std::map mcPartIsSaved; + + // loop over McCollisions and UDCCs simultaneously + auto mccol = mccols.iteratorAt(0); + auto sgcand = sgcands.iteratorAt(0); + auto lastmccol = mccols.iteratorAt(mccols.size() - 1); + auto lastsgcand = sgcands.iteratorAt(sgcands.size() - 1); + + // 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; + while (goon) { + auto bcIter = mccol.bc_as(); + uint64_t globBC = bcIter.globalBC(); + // uint64_t globBC = 0; + // check if dgcand has an associated McCollision + if (sgcand.has_collision()) { + auto sgcandCol = sgcand.collision_as(); + // colId = sgcandCol.globalIndex(); + if (sgcandCol.has_mcCollision()) { + mcsgId = sgcandCol.mcCollision().globalIndex(); + } else { + mcsgId = -1; + } + } else { + // colId = -1; + mcsgId = -1; + } + LOGF(info, "\nStart of loop mcsgId %d mccolId %d", mcsgId, mccolId); + + // two cases to consider + // 1. mcdgId <= mccolId: the event to process is a dgcand. In this case the Mc tables as well as the McLabel tables are updated + // 2. mccolId < mcdgId: the event to process is an MC event of interest without reconstructed dgcand. In this case only the Mc tables are updated + if ((!sgcandAtEnd && !mccolAtEnd && (mcsgId <= mccolId)) || mccolAtEnd) { + // this is case 1. + // LOGF(info, "Doing case 1 with mcsgId %d", mcsgId); + + // update UDMcCollisions and UDMcColsLabels (for each UDCollision -> UDMcCollisions) + // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) + // get dgcand tracks + auto sgTracks = udtracks.sliceByCached(aod::udtrack::udCollisionId, sgcand.globalIndex(), cache); + + // If the sgcand has an associated McCollision then the McCollision and all associated + // McParticles are saved + if (mcsgId >= 0) { + if (mcColIsSaved.find(mcsgId) == mcColIsSaved.end()) { + LOGF(info, " Saving McCollision %d", mcsgId); + // update UDMcCollisions + auto sgcandMcCol = sgcand.collision_as().mcCollision(); + updateUDMcCollisions(sgcandMcCol, globBC); + mcColIsSaved[mcsgId] = outputMcCollisions.lastIndex(); + } + + // update UDMcColsLabels (for each UDCollision -> UDMcCollisions) + outputMcCollsLabels(mcColIsSaved[mcsgId]); + + // update UDMcParticles + auto mcPartsSlice = mcparts.sliceBy(mcPartsPerMcCollision, mcsgId); + updateUDMcParticles(mcPartsSlice, mcColIsSaved[mcsgId], mcPartIsSaved); + + // update UDMcTrackLabels (for each UDTrack -> UDMcParticles) + updateUDMcTrackLabels(sgTracks, mcPartIsSaved); + + } else { + // If the sgcand has no associated McCollision then only the McParticles which are associated + // with the tracks of the sgcand are saved + // LOGF(info, " Saving McCollision %d", -1); + + // update UDMcColsLabels (for each UDCollision -> UDMcCollisions) + outputMcCollsLabels(-1); + + // update UDMcParticles and UDMcTrackLabels (for each UDTrack -> UDMcParticles) + // loop over tracks of dgcand + for (auto sgtrack : sgTracks) { + if (sgtrack.has_track()) { + auto track = sgtrack.track_as(); + if (track.has_mcParticle()) { + auto mcPart = track.mcParticle(); + updateUDMcParticle(mcPart, -1, mcPartIsSaved); + updateUDMcTrackLabel(sgtrack, mcPartIsSaved); + } else { + outputMcTrackLabels(-1, track.mcMask()); + } + } else { + outputMcTrackLabels(-1, -1); + } + } + } + // advance sgcand + if (sgcand != lastsgcand) { + sgcand++; + } else { + sgcandAtEnd = true; + } + } else { + // this is case 2. + LOGF(info, "Doing case 2"); + + // update UDMcCollisions and UDMcParticles + if (mcColIsSaved.find(mccolId) == mcColIsSaved.end()) { + 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); + } + + // advance mccol + if (mccol != lastmccol) { + mccol++; + mccolId = mccol.globalIndex(); + } else { + mccolAtEnd = true; + } + } + + goon = !sgcandAtEnd || !mccolAtEnd; + // LOGF(info, "End of loop mcsgId %d mccolId %d", mcsgId, mccolId); + } + } + PROCESS_SWITCH(McSGCandProducer, processMC, "Produce MC tables", false); + void processDummy(aod::Collisions const& /*collisions*/) + { + // do nothing + LOGF(info, "Running dummy process function!"); + } + PROCESS_SWITCH(McSGCandProducer, processDummy, "Dummy function", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { WorkflowSpec workflow{ - adaptAnalysisTask(cfgc, TaskName{"sgcandproducer"})}; - + adaptAnalysisTask(cfgc, TaskName{"sgcandproducer"}), + adaptAnalysisTask(cfgc, TaskName{"mcsgcandproducer"})}; return workflow; } diff --git a/PWGUD/TableProducer/UPCCandidateProducer.cxx b/PWGUD/TableProducer/UPCCandidateProducer.cxx index 47da6d3ffbd..5eba6e0c2ef 100644 --- a/PWGUD/TableProducer/UPCCandidateProducer.cxx +++ b/PWGUD/TableProducer/UPCCandidateProducer.cxx @@ -12,6 +12,13 @@ /// \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" @@ -22,6 +29,7 @@ #include "PWGUD/Core/UPCCutparHolder.h" #include "PWGUD/Core/UPCHelpers.h" #include "PWGUD/DataModel/UDTables.h" +#include "DataFormatsITSMFT/ROFRecord.h" using namespace o2::framework; using namespace o2::framework::expressions; @@ -52,6 +60,7 @@ struct UpcCandProducer { Produces eventCandidatesSels; Produces eventCandidatesSelsCent; Produces eventCandidatesSelsFwd; + Produces eventCandidatesSelExtras; Produces udZdcsReduced; @@ -72,7 +81,7 @@ struct UpcCandProducer { Configurable fFilterTVX{"filterTVX", -1, "Filter candidates by FT0 TVX"}; Configurable fFilterFV0{"filterFV0", -1, "Filter candidates by FV0A"}; - Configurable fBCWindowFITAmps{"bcWindowFITAmps", 20, "BC range for T0A/V0A amplitudes array [-range, +(range-1)]"}; + Configurable fBCWindowFITAmps{"bcWindowFITAmps", 20, "BC range for T0A/V0A amplitudes array [-range, +(range-1)]"}; Configurable fBcWindowMCH{"bcWindowMCH", 20, "Time window for MCH-MID to MCH-only matching for Muon candidates"}; Configurable fBcWindowITSTPC{"bcWindowITSTPC", 20, "Time window for TOF/ITS-TPC to ITS-TPC matching for Central candidates"}; @@ -86,10 +95,13 @@ struct UpcCandProducer { Configurable fSearchITSTPC{"searchITSTPC", 0, "Search for ITS-TPC tracks near candidates"}; Configurable fSearchRangeITSTPC{"searchRangeITSTPC", 50, "BC range for ITS-TPC tracks search wrt TOF tracks"}; + Configurable fMinEtaMFT{"minEtaMFT", -3.6, "Minimum eta for MFT tracks"}; + Configurable fMaxEtaMFT{"maxEtaMFT", -2.5, "Maximum eta for MFT tracks"}; + // QA histograms HistogramRegistry histRegistry{"HistRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; - using BCsWithBcSels = o2::soa::Join; + using BCsWithBcSels = o2::soa::Join; using ForwardTracks = o2::soa::Join; @@ -466,10 +478,11 @@ struct UpcCandProducer { return hasNoFT0; } + template void processFITInfo(upchelpers::FITInfo& fitInfo, uint64_t midbc, std::vector>& v, - BCsWithBcSels const& bcs, + TBCs const& bcs, o2::aod::FT0s const& /*ft0s*/, o2::aod::FDDs const& /*fdds*/, o2::aod::FV0As const& /*fv0as*/) @@ -720,9 +733,10 @@ struct UpcCandProducer { return 0; // found exactly tracksToFind tracks in [midbc - range, midbc + range] } + template void createCandidatesCentral(BarrelTracks const& barrelTracks, o2::aod::AmbiguousTracks const& ambBarrelTracks, - o2::aod::BCs const& bcs, + TBCs const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& /*fdds*/, @@ -737,7 +751,7 @@ struct UpcCandProducer { // trackID -> index in amb. track table std::unordered_map ambBarrelTrBCs; if (upcCuts.getAmbigSwitch() != 1) - collectAmbTrackBCs<0, o2::aod::BCs>(ambBarrelTrBCs, ambBarrelTracks); + collectAmbTrackBCs<0, BCsWithBcSels>(ambBarrelTrBCs, ambBarrelTracks); collectBarrelTracks(bcsMatchedTrIdsTOF, 0, @@ -758,7 +772,7 @@ struct UpcCandProducer { std::map mapGlobalBcWithTVX{}; std::map mapGlobalBcWithTSC{}; for (const auto& ft0 : ft0s) { - uint64_t globalBC = ft0.bc_as().globalBC(); + uint64_t globalBC = ft0.bc_as().globalBC(); int32_t globalIndex = ft0.globalIndex(); if (!(std::abs(ft0.timeA()) > 2.f && std::abs(ft0.timeC()) > 2.f)) mapGlobalBcWithTOR[globalBC] = globalIndex; @@ -779,7 +793,7 @@ struct UpcCandProducer { for (const auto& fv0a : fv0as) { if (std::abs(fv0a.time()) > 15.f) continue; - uint64_t globalBC = fv0a.bc_as().globalBC(); + uint64_t globalBC = fv0a.bc_as().globalBC(); mapGlobalBcWithV0A[globalBC] = fv0a.globalIndex(); } @@ -791,7 +805,7 @@ struct UpcCandProducer { histRegistry.get(HIST("hCountersTrg"))->Fill("ZNA", 1); if (!(std::abs(zdc.timeZNC()) > 2.f)) histRegistry.get(HIST("hCountersTrg"))->Fill("ZNC", 1); - auto globalBC = zdc.bc_as().globalBC(); + auto globalBC = zdc.bc_as().globalBC(); mapGlobalBcWithZdc[globalBC] = zdc.globalIndex(); } @@ -870,7 +884,7 @@ struct UpcCandProducer { for (auto& pair : bcsMatchedTrIdsTOF) { auto globalBC = pair.first; auto& barrelTrackIDs = pair.second; - int32_t nTOFs = barrelTrackIDs.size(); + uint32_t nTOFs = barrelTrackIDs.size(); if (nTOFs > fNBarProngs) // too many tracks continue; auto closestBcITSTPC = std::numeric_limits::max(); @@ -884,7 +898,7 @@ struct UpcCandProducer { if (std::abs(distClosestBcITSTPC) > fBcWindowITSTPC) continue; auto& itstpcTracks = itClosestBcITSTPC->second; - int32_t nITSTPCs = itstpcTracks.size(); + uint32_t nITSTPCs = itstpcTracks.size(); if ((nTOFs + nITSTPCs) != fNBarProngs) continue; barrelTrackIDs.insert(barrelTrackIDs.end(), itstpcTracks.begin(), itstpcTracks.end()); @@ -916,8 +930,12 @@ struct UpcCandProducer { } RgtrwTOF = RgtrwTOF / static_cast(numContrib); // store used tracks + int upc_flag = 0; + // TODO: introduce better check on association of collision and reconstruction mode + if (bcs.iteratorAt(0).flags() == o2::itsmft::ROFRecord::VtxUPCMode) + upc_flag = 1; fillBarrelTracks(barrelTracks, barrelTrackIDs, candID, globalBC, closestBcITSTPC, mcBarrelTrackLabels, ambBarrelTrBCs); - eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); + eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, upc_flag, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, fitInfo.ampFV0A, fitInfo.timeFV0A, fitInfo.triggerMaskFV0A, @@ -935,7 +953,7 @@ struct UpcCandProducer { for (auto& pair : bcsMatchedTrIdsITSTPC) { auto globalBC = pair.first; auto& barrelTrackIDs = pair.second; - int32_t nThisITSTPCs = barrelTrackIDs.size(); + uint32_t nThisITSTPCs = barrelTrackIDs.size(); if (nThisITSTPCs > fNBarProngs || nThisITSTPCs == 0) // too many tracks / already matched to TOF continue; auto closestBcITSTPC = std::numeric_limits::max(); @@ -949,7 +967,7 @@ struct UpcCandProducer { if (std::abs(distClosestBcITSTPC) > fBcWindowITSTPC) continue; auto& itstpcTracks = itClosestBcITSTPC->second; - int32_t nITSTPCs = itstpcTracks.size(); + uint32_t nITSTPCs = itstpcTracks.size(); if ((nThisITSTPCs + nITSTPCs) != fNBarProngs) continue; barrelTrackIDs.insert(barrelTrackIDs.end(), itstpcTracks.begin(), itstpcTracks.end()); @@ -981,8 +999,12 @@ struct UpcCandProducer { } RgtrwTOF = RgtrwTOF / static_cast(numContrib); // store used tracks + int upc_flag = 0; + // TODO: introduce better check on association of collision and reconstruction mode + if (bcs.iteratorAt(0).flags() == o2::itsmft::ROFRecord::VtxUPCMode) + upc_flag = 1; fillBarrelTracks(barrelTracks, barrelTrackIDs, candID, globalBC, closestBcITSTPC, mcBarrelTrackLabels, ambBarrelTrBCs); - eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); + eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, upc_flag, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, fitInfo.ampFV0A, fitInfo.timeFV0A, fitInfo.triggerMaskFV0A, @@ -1002,12 +1024,13 @@ struct UpcCandProducer { bcsMatchedTrIdsTOF.clear(); } + template void createCandidatesSemiFwd(BarrelTracks const& barrelTracks, o2::aod::AmbiguousTracks const& ambBarrelTracks, ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& /*fwdTrkClusters*/, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - BCsWithBcSels const& bcs, + TBCs const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1157,9 +1180,13 @@ struct UpcCandProducer { } RgtrwTOF = RgtrwTOF / static_cast(numContrib); // store used tracks + int upc_flag = 0; + // TODO: introduce better check on association of collision and reconstruction mode + if (bcs.iteratorAt(0).flags() == o2::itsmft::ROFRecord::VtxUPCMode) + upc_flag = 1; fillFwdTracks(fwdTracks, fwdTrackIDs, candID, bc, bc, mcFwdTrackLabels); fillBarrelTracks(barrelTracks, barrelTrackIDs, candID, bc, bc, mcBarrelTrackLabels, ambBarrelTrBCs); - eventCandidates(bc, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); + eventCandidates(bc, runNumber, dummyX, dummyY, dummyZ, upc_flag, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, fitInfo.ampFV0A, fitInfo.timeFV0A, fitInfo.triggerMaskFV0A, @@ -1181,7 +1208,7 @@ struct UpcCandProducer { const std::map& mapBCs, std::vector& amps, std::vector& relBCs, - int64_t gbc) + uint64_t gbc) { auto s = gbc - fBCWindowFITAmps; auto e = gbc + (fBCWindowFITAmps - 1); @@ -1207,13 +1234,14 @@ struct UpcCandProducer { } } + template void createCandidatesFwd(ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& fwdTrkClusters, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - o2::aod::BCs const& bcs, + TBCs const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, - o2::aod::FDDs const& /*fdds*/, + o2::aod::FDDs const& fdds, o2::aod::FV0As const& fv0as, o2::aod::Zdcs const& zdcs, const o2::aod::McFwdTrackLabels* mcFwdTrackLabels) @@ -1224,7 +1252,7 @@ struct UpcCandProducer { // trackID -> index in amb. track table std::unordered_map ambFwdTrBCs; - collectAmbTrackBCs<1, o2::aod::BCs>(ambFwdTrBCs, ambFwdTracks); + collectAmbTrackBCs<1, BCsWithBcSels>(ambFwdTrBCs, ambFwdTracks); collectForwardTracks(bcsMatchedTrIdsMID, o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack, @@ -1251,7 +1279,7 @@ struct UpcCandProducer { } if (std::abs(ft0.timeA()) > 2.f) continue; - uint64_t globalBC = ft0.bc_as().globalBC(); + uint64_t globalBC = ft0.bc_as().globalBC(); mapGlobalBcWithT0A[globalBC] = ft0.globalIndex(); } @@ -1261,7 +1289,7 @@ struct UpcCandProducer { continue; if (std::abs(fv0a.time()) > 15.f) continue; - uint64_t globalBC = fv0a.bc_as().globalBC(); + uint64_t globalBC = fv0a.bc_as().globalBC(); mapGlobalBcWithV0A[globalBC] = fv0a.globalIndex(); } @@ -1273,14 +1301,33 @@ struct UpcCandProducer { histRegistry.get(HIST("hCountersTrg"))->Fill("ZNA", 1); if (!(std::abs(zdc.timeZNC()) > 2.f)) histRegistry.get(HIST("hCountersTrg"))->Fill("ZNC", 1); - auto globalBC = zdc.bc_as().globalBC(); + auto globalBC = zdc.bc_as().globalBC(); mapGlobalBcWithZdc[globalBC] = zdc.globalIndex(); } + std::map mapGlobalBcWithFDD{}; + uint8_t twoLayersA = 0; + uint8_t twoLayersC = 0; + for (const auto& fdd : fdds) { + // get signal coincidence + for (int i = 0; i < 4; i++) { + if (fdd.chargeA()[i + 4] > 0 && fdd.chargeA()[i] > 0) + twoLayersA++; + if (fdd.chargeC()[i + 4] > 0 && fdd.chargeC()[i] > 0) + twoLayersC++; + } + // if no signal, continue + if ((twoLayersA == 0) && (twoLayersC == 0)) + continue; + uint64_t globalBC = fdd.bc_as().globalBC(); + mapGlobalBcWithFDD[globalBC] = fdd.globalIndex(); + } + auto nFT0s = mapGlobalBcWithT0A.size(); auto nFV0As = mapGlobalBcWithV0A.size(); auto nZdcs = mapGlobalBcWithZdc.size(); auto nBcsWithMCH = bcsMatchedTrIdsMCH.size(); + auto nFDDs = mapGlobalBcWithFDD.size(); // todo: calculate position of UD collision? float dummyX = 0.; @@ -1297,7 +1344,7 @@ struct UpcCandProducer { for (auto& pair : bcsMatchedTrIdsMID) { // candidates without MFT auto globalBC = static_cast(pair.first); const auto& fwdTrackIDs = pair.second; // only MID-matched tracks at the moment - int32_t nMIDs = fwdTrackIDs.size(); + uint32_t nMIDs = fwdTrackIDs.size(); if (nMIDs > fNFwdProngs) // too many tracks continue; std::vector trkCandIDs{}; @@ -1312,7 +1359,7 @@ struct UpcCandProducer { if (std::abs(distClosestBcMCH) > fBcWindowMCH) continue; auto& mchTracks = itClosestBcMCH->second; - int32_t nMCHs = mchTracks.size(); + uint32_t nMCHs = mchTracks.size(); if ((nMCHs + nMIDs) != fNFwdProngs) continue; trkCandIDs.insert(trkCandIDs.end(), fwdTrackIDs.begin(), fwdTrackIDs.end()); @@ -1329,6 +1376,8 @@ struct UpcCandProducer { std::vector amplitudesV0A{}; std::vector relBCsT0A{}; std::vector relBCsV0A{}; + uint8_t chFT0A = 0; + uint8_t chFT0C = 0; if (nFT0s > 0) { uint64_t closestBcT0A = findClosestBC(globalBC, mapGlobalBcWithT0A); int64_t distClosestBcT0A = globalBC - static_cast(closestBcT0A); @@ -1343,8 +1392,11 @@ struct UpcCandProducer { const auto& t0AmpsC = ft0.amplitudeC(); fitInfo.ampFT0A = std::accumulate(t0AmpsA.begin(), t0AmpsA.end(), 0.f); fitInfo.ampFT0C = std::accumulate(t0AmpsC.begin(), t0AmpsC.end(), 0.f); + chFT0A = ft0.amplitudeA().size(); + chFT0C = ft0.amplitudeC().size(); fillAmplitudes(ft0s, mapGlobalBcWithT0A, amplitudesT0A, relBCsT0A, globalBC); } + uint8_t chFV0A = 0; if (nFV0As > 0) { uint64_t closestBcV0A = findClosestBC(globalBC, mapGlobalBcWithV0A); int64_t distClosestBcV0A = globalBC - static_cast(closestBcV0A); @@ -1356,8 +1408,32 @@ struct UpcCandProducer { fitInfo.timeFV0A = fv0a.time(); const auto& v0Amps = fv0a.amplitude(); fitInfo.ampFV0A = std::accumulate(v0Amps.begin(), v0Amps.end(), 0.f); + chFV0A = fv0a.amplitude().size(); fillAmplitudes(fv0as, mapGlobalBcWithV0A, amplitudesV0A, relBCsV0A, globalBC); } + uint8_t chFDDA = 0; + uint8_t chFDDC = 0; + if (nFDDs > 0) { + uint64_t closestBcFDD = findClosestBC(globalBC, mapGlobalBcWithFDD); + auto fddId = mapGlobalBcWithFDD.at(closestBcFDD); + auto fdd = fdds.iteratorAt(fddId); + fitInfo.timeFDDA = fdd.timeA(); + fitInfo.timeFDDC = fdd.timeC(); + fitInfo.ampFDDA = 0; + for (int i = 0; i < 8; i++) + fitInfo.ampFDDA += fdd.chargeA()[i]; + fitInfo.ampFDDC = 0; + for (int i = 0; i < 8; i++) + fitInfo.ampFDDC += fdd.chargeC()[i]; + fitInfo.triggerMaskFDD = fdd.triggerMask(); + // get signal coincidence + for (int i = 0; i < 4; i++) { + if (fdd.chargeA()[i + 4] > 0 && fdd.chargeA()[i] > 0) + chFDDA++; + if (fdd.chargeC()[i + 4] > 0 && fdd.chargeC()[i] > 0) + chFDDC++; + } + } if (nZdcs > 0) { auto itZDC = mapGlobalBcWithZdc.find(globalBC); if (itZDC != mapGlobalBcWithZdc.end()) { @@ -1378,14 +1454,19 @@ struct UpcCandProducer { selTrackIds.push_back(id); } // store used tracks + int upc_flag = 0; + // TODO: introduce better check on association of collision and reconstruction mode + if (bcs.iteratorAt(0).flags() == o2::itsmft::ROFRecord::VtxUPCMode) + upc_flag = 1; fillFwdTracks(fwdTracks, trkCandIDs, candID, globalBC, closestBcMCH, mcFwdTrackLabels); - eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); + eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, upc_flag, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, fitInfo.ampFV0A, fitInfo.timeFV0A, fitInfo.triggerMaskFV0A, 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); eventCandidatesSelsFwd(fitInfo.distClosestBcV0A, fitInfo.distClosestBcT0A, amplitudesT0A, @@ -1404,15 +1485,17 @@ struct UpcCandProducer { bcsMatchedTrIdsMCH.clear(); mapGlobalBcWithT0A.clear(); mapGlobalBcWithV0A.clear(); + mapGlobalBcWithFDD.clear(); } + template void createCandidatesFwdGlobal(ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& /*fwdTrkClusters*/, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - o2::aod::BCs const& bcs, + TBCs const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, - o2::aod::FDDs const& /*fdds*/, + o2::aod::FDDs const& fdds, o2::aod::FV0As const& fv0as, o2::aod::Zdcs const& zdcs, const o2::aod::McFwdTrackLabels* mcFwdTrackLabels) @@ -1424,7 +1507,7 @@ struct UpcCandProducer { // trackID -> index in amb. track table std::unordered_map ambFwdTrBCs; - collectAmbTrackBCs<1, o2::aod::BCs>(ambFwdTrBCs, ambFwdTracks); + collectAmbTrackBCs<1, BCsWithBcSels>(ambFwdTrBCs, ambFwdTracks); collectForwardTracks(bcsMatchedTrIdsMID, o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack, @@ -1459,7 +1542,7 @@ struct UpcCandProducer { } if (std::abs(ft0.timeA()) > 2.f) continue; - uint64_t globalBC = ft0.bc_as().globalBC(); + uint64_t globalBC = ft0.bc_as().globalBC(); mapGlobalBcWithT0A[globalBC] = ft0.globalIndex(); } @@ -1469,7 +1552,7 @@ struct UpcCandProducer { continue; if (std::abs(fv0a.time()) > 15.f) continue; - uint64_t globalBC = fv0a.bc_as().globalBC(); + uint64_t globalBC = fv0a.bc_as().globalBC(); mapGlobalBcWithV0A[globalBC] = fv0a.globalIndex(); } @@ -1481,13 +1564,32 @@ struct UpcCandProducer { histRegistry.get(HIST("hCountersTrg"))->Fill("ZNA", 1); if (!(std::abs(zdc.timeZNC()) > 2.f)) histRegistry.get(HIST("hCountersTrg"))->Fill("ZNC", 1); - auto globalBC = zdc.bc_as().globalBC(); + auto globalBC = zdc.bc_as().globalBC(); mapGlobalBcWithZdc[globalBC] = zdc.globalIndex(); } + std::map mapGlobalBcWithFDD{}; + uint8_t twoLayersA = 0; + uint8_t twoLayersC = 0; + for (const auto& fdd : fdds) { + // get signal coincidence + for (int i = 0; i < 4; i++) { + if (fdd.chargeA()[i + 4] > 0 && fdd.chargeA()[i] > 0) + twoLayersA++; + if (fdd.chargeC()[i + 4] > 0 && fdd.chargeC()[i] > 0) + twoLayersC++; + } + // if no signal, continue + if ((twoLayersA == 0) && (twoLayersC == 0)) + continue; + uint64_t globalBC = fdd.bc_as().globalBC(); + mapGlobalBcWithFDD[globalBC] = fdd.globalIndex(); + } + auto nFT0s = mapGlobalBcWithT0A.size(); auto nFV0As = mapGlobalBcWithV0A.size(); auto nZdcs = mapGlobalBcWithZdc.size(); + auto nFDDs = mapGlobalBcWithFDD.size(); // todo: calculate position of UD collision? float dummyX = 0.; @@ -1500,17 +1602,25 @@ struct UpcCandProducer { // storing n-prong matches int32_t candID = 0; - + auto midIt = bcsMatchedTrIdsMID.begin(); for (auto& pair : bcsMatchedTrIdsGlobal) { // candidates with MFT auto globalBC = static_cast(pair.first); const auto& fwdTrackIDs = pair.second; - int32_t nMFTs = fwdTrackIDs.size(); + uint32_t nMFTs = fwdTrackIDs.size(); if (nMFTs > fNFwdProngs) // too many tracks continue; std::vector trkCandIDs{}; - + const auto& midTrackIDs = midIt->second; // to retrieve corresponding MCH-MID tracks if (nMFTs == fNFwdProngs) { - trkCandIDs.insert(trkCandIDs.end(), fwdTrackIDs.begin(), fwdTrackIDs.end()); + for (auto iMft : fwdTrackIDs) { + auto trk = fwdTracks.iteratorAt(iMft); + auto trkEta = trk.eta(); + if (trkEta > fMinEtaMFT && trkEta < fMaxEtaMFT) { // If the track is in the MFT acceptance, store the global track + trkCandIDs.insert(trkCandIDs.end(), fwdTrackIDs.begin(), fwdTrackIDs.end()); + } else { // If the track is not in the MFT acceptance, store the MCH-MID track + trkCandIDs.insert(trkCandIDs.end(), midTrackIDs.begin(), midTrackIDs.end()); + } + } } uint64_t closestBcMCH = 0; upchelpers::FITInfo fitInfo{}; @@ -1524,6 +1634,8 @@ struct UpcCandProducer { std::vector amplitudesV0A{}; std::vector relBCsT0A{}; std::vector relBCsV0A{}; + uint8_t chFT0A = 0; + uint8_t chFT0C = 0; if (nFT0s > 0) { uint64_t closestBcT0A = findClosestBC(globalBC, mapGlobalBcWithT0A); int64_t distClosestBcT0A = globalBC - static_cast(closestBcT0A); @@ -1538,8 +1650,11 @@ struct UpcCandProducer { const auto& t0AmpsC = ft0.amplitudeC(); fitInfo.ampFT0A = std::accumulate(t0AmpsA.begin(), t0AmpsA.end(), 0.f); fitInfo.ampFT0C = std::accumulate(t0AmpsC.begin(), t0AmpsC.end(), 0.f); + chFT0A = ft0.amplitudeA().size(); + chFT0C = ft0.amplitudeC().size(); fillAmplitudes(ft0s, mapGlobalBcWithT0A, amplitudesT0A, relBCsT0A, globalBC); } + uint8_t chFV0A = 0; if (nFV0As > 0) { uint64_t closestBcV0A = findClosestBC(globalBC, mapGlobalBcWithV0A); int64_t distClosestBcV0A = globalBC - static_cast(closestBcV0A); @@ -1551,8 +1666,32 @@ struct UpcCandProducer { fitInfo.timeFV0A = fv0a.time(); const auto& v0Amps = fv0a.amplitude(); fitInfo.ampFV0A = std::accumulate(v0Amps.begin(), v0Amps.end(), 0.f); + chFV0A = fv0a.amplitude().size(); fillAmplitudes(fv0as, mapGlobalBcWithV0A, amplitudesV0A, relBCsV0A, globalBC); } + uint8_t chFDDA = 0; + uint8_t chFDDC = 0; + if (nFDDs > 0) { + uint64_t closestBcFDD = findClosestBC(globalBC, mapGlobalBcWithFDD); + auto fddId = mapGlobalBcWithFDD.at(closestBcFDD); + auto fdd = fdds.iteratorAt(fddId); + fitInfo.timeFDDA = fdd.timeA(); + fitInfo.timeFDDC = fdd.timeC(); + fitInfo.ampFDDA = 0; + for (int i = 0; i < 8; i++) + fitInfo.ampFDDA += fdd.chargeA()[i]; + fitInfo.ampFDDC = 0; + for (int i = 0; i < 8; i++) + fitInfo.ampFDDC += fdd.chargeC()[i]; + fitInfo.triggerMaskFDD = fdd.triggerMask(); + // get signal coincidence + for (int i = 0; i < 4; i++) { + if (fdd.chargeA()[i + 4] > 0 && fdd.chargeA()[i] > 0) + chFDDA++; + if (fdd.chargeC()[i + 4] > 0 && fdd.chargeC()[i] > 0) + chFDDC++; + } + } if (nZdcs > 0) { auto itZDC = mapGlobalBcWithZdc.find(globalBC); if (itZDC != mapGlobalBcWithZdc.end()) { @@ -1573,14 +1712,19 @@ struct UpcCandProducer { selTrackIdsGlobal.push_back(id); } // store used tracks + int upc_flag = 0; + // TODO: introduce better check on association of collision and reconstruction mode + if (bcs.iteratorAt(0).flags() == o2::itsmft::ROFRecord::VtxUPCMode) + upc_flag = 1; fillFwdTracks(fwdTracks, trkCandIDs, candID, globalBC, closestBcMCH, mcFwdTrackLabels); - eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, numContrib, netCharge, RgtrwTOF); + eventCandidates(globalBC, runNumber, dummyX, dummyY, dummyZ, upc_flag, numContrib, netCharge, RgtrwTOF); eventCandidatesSels(fitInfo.ampFT0A, fitInfo.ampFT0C, fitInfo.timeFT0A, fitInfo.timeFT0C, fitInfo.triggerMaskFT0, fitInfo.ampFDDA, fitInfo.ampFDDC, fitInfo.timeFDDA, fitInfo.timeFDDC, fitInfo.triggerMaskFDD, fitInfo.ampFV0A, fitInfo.timeFV0A, fitInfo.triggerMaskFV0A, 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); eventCandidatesSelsFwd(fitInfo.distClosestBcV0A, fitInfo.distClosestBcT0A, amplitudesT0A, @@ -1588,6 +1732,7 @@ struct UpcCandProducer { amplitudesV0A, relBCsV0A); candID++; + midIt++; trkCandIDs.clear(); } @@ -1598,6 +1743,7 @@ struct UpcCandProducer { bcsMatchedTrIdsGlobal.clear(); mapGlobalBcWithT0A.clear(); mapGlobalBcWithV0A.clear(); + mapGlobalBcWithFDD.clear(); } // data processors @@ -1628,7 +1774,7 @@ struct UpcCandProducer { // create candidates for central region void processCentral(BarrelTracks const& barrelTracks, o2::aod::AmbiguousTracks const& ambBarrelTracks, - o2::aod::BCs const& bcs, + BCsWithBcSels const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1674,7 +1820,7 @@ struct UpcCandProducer { // create candidates for central region void processCentralMC(BarrelTracks const& barrelTracks, o2::aod::AmbiguousTracks const& ambBarrelTracks, - o2::aod::BCs const& bcs, + BCsWithBcSels const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1697,7 +1843,7 @@ struct UpcCandProducer { void processForward(ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& fwdTrkClusters, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - o2::aod::BCs const& bcs, + BCsWithBcSels const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1714,7 +1860,7 @@ struct UpcCandProducer { void processForwardMC(ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& fwdTrkClusters, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - o2::aod::BCs const& bcs, + BCsWithBcSels const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1737,7 +1883,7 @@ struct UpcCandProducer { void processForwardGlobal(ForwardTracks const& fwdTracks, o2::aod::FwdTrkCls const& fwdTrkClusters, o2::aod::AmbiguousFwdTracks const& ambFwdTracks, - o2::aod::BCs const& bcs, + BCsWithBcSels const& bcs, o2::aod::Collisions const& collisions, o2::aod::FT0s const& ft0s, o2::aod::FDDs const& fdds, @@ -1751,13 +1897,35 @@ struct UpcCandProducer { (o2::aod::McFwdTrackLabels*)nullptr); } + void processForwardGlobalMC(ForwardTracks const& fwdTracks, + o2::aod::FwdTrkCls const& fwdTrkClusters, + o2::aod::AmbiguousFwdTracks const& ambFwdTracks, + BCsWithBcSels const& bcs, + o2::aod::Collisions const& collisions, + o2::aod::FT0s const& ft0s, + o2::aod::FDDs const& fdds, + o2::aod::FV0As const& fv0as, + o2::aod::Zdcs const& zdcs, + o2::aod::McCollisions const& mcCollisions, o2::aod::McParticles const& mcParticles, + o2::aod::McFwdTrackLabels const& mcFwdTrackLabels) + { + fDoMC = true; + skimMCInfo(mcCollisions, mcParticles, bcs); + createCandidatesFwdGlobal(fwdTracks, fwdTrkClusters, ambFwdTracks, + bcs, collisions, + ft0s, fdds, fv0as, zdcs, + &mcFwdTrackLabels); + fNewPartIDs.clear(); + } + PROCESS_SWITCH(UpcCandProducer, processSemiFwd, "Produce candidates in semiforward/forward region", false); PROCESS_SWITCH(UpcCandProducer, processCentral, "Produce candidates in central region", false); PROCESS_SWITCH(UpcCandProducer, processSemiFwdMC, "Produce candidates in semiforward/forward region with MC information", false); PROCESS_SWITCH(UpcCandProducer, processCentralMC, "Produce candidates in central region with MC information", false); PROCESS_SWITCH(UpcCandProducer, processForward, "Produce candidates in forward region", false); PROCESS_SWITCH(UpcCandProducer, processForwardGlobal, "Produce candidates in forward region with MFT", true); - PROCESS_SWITCH(UpcCandProducer, processForwardMC, "Produce caniddates in forward region with MC information", false); + PROCESS_SWITCH(UpcCandProducer, processForwardMC, "Produce candidates in forward region with MC information", false); + PROCESS_SWITCH(UpcCandProducer, processForwardGlobalMC, "Produce candidates in forward region with MFT and MC information", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGUD/TableProducer/fwdTrackPropagation.cxx b/PWGUD/TableProducer/fwdTrackPropagation.cxx index 20db4b41959..cc6ba621690 100644 --- a/PWGUD/TableProducer/fwdTrackPropagation.cxx +++ b/PWGUD/TableProducer/fwdTrackPropagation.cxx @@ -142,16 +142,16 @@ struct FwdTrackPropagation { float sigPhi = TMath::Sqrt(cov(2, 2)); float sigTgl = TMath::Sqrt(cov(3, 3)); float sig1Pt = TMath::Sqrt(cov(4, 4)); - auto rhoXY = static_cast(128. * cov(0, 1) / (sigX * sigY)); - auto rhoPhiX = static_cast(128. * cov(0, 2) / (sigPhi * sigX)); - auto rhoPhiY = static_cast(128. * cov(1, 2) / (sigPhi * sigY)); - auto rhoTglX = static_cast(128. * cov(0, 3) / (sigTgl * sigX)); - auto rhoTglY = static_cast(128. * cov(1, 3) / (sigTgl * sigY)); - auto rhoTglPhi = static_cast(128. * cov(2, 3) / (sigTgl * sigPhi)); - auto rho1PtX = static_cast(128. * cov(0, 4) / (sig1Pt * sigX)); - auto rho1PtY = static_cast(128. * cov(1, 4) / (sig1Pt * sigY)); - auto rho1PtPhi = static_cast(128. * cov(2, 4) / (sig1Pt * sigPhi)); - auto rho1PtTgl = static_cast(128. * cov(3, 4) / (sig1Pt * sigTgl)); + auto rhoXY = static_cast(128. * cov(0, 1) / (sigX * sigY)); + auto rhoPhiX = static_cast(128. * cov(0, 2) / (sigPhi * sigX)); + auto rhoPhiY = static_cast(128. * cov(1, 2) / (sigPhi * sigY)); + auto rhoTglX = static_cast(128. * cov(0, 3) / (sigTgl * sigX)); + auto rhoTglY = static_cast(128. * cov(1, 3) / (sigTgl * sigY)); + auto rhoTglPhi = static_cast(128. * cov(2, 3) / (sigTgl * sigPhi)); + auto rho1PtX = static_cast(128. * cov(0, 4) / (sig1Pt * sigX)); + auto rho1PtY = static_cast(128. * cov(1, 4) / (sig1Pt * sigY)); + auto rho1PtPhi = static_cast(128. * cov(2, 4) / (sig1Pt * sigPhi)); + auto rho1PtTgl = static_cast(128. * cov(3, 4) / (sig1Pt * sigTgl)); propFwdTracksCov(sigX, sigY, sigTgl, sigPhi, sig1Pt, rhoXY, rhoPhiX, rhoPhiY, rhoTglX, rhoTglY, rhoTglPhi, rho1PtX, rho1PtY, diff --git a/PWGUD/Tasks/CMakeLists.txt b/PWGUD/Tasks/CMakeLists.txt index 521a4bcc53b..a0f1eb17747 100644 --- a/PWGUD/Tasks/CMakeLists.txt +++ b/PWGUD/Tasks/CMakeLists.txt @@ -19,6 +19,16 @@ o2physics_add_dpl_workflow(sg-spectra PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(sg-pid-spectra-table + SOURCES sgPIDSpectraTable.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(sg-pid-analyzer + SOURCES sgPIDAnalyzer.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(sg-pid-spectra SOURCES sgPIDSpectra.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase @@ -153,6 +163,11 @@ o2physics_add_dpl_workflow(exclusive-phi-leptons PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(exclusive-phi-leptons-trees + SOURCES exclusivePhiLeptonsTrees.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(exclusive-pentaquark SOURCES exclusivePentaquark.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector @@ -168,7 +183,32 @@ o2physics_add_dpl_workflow(sg-exclusive-phi PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(sg-exclusive-phi-its + SOURCES sgExclusivePhiITSselections.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector + COMPONENT_NAME Analysis) + o2physics_add_dpl_workflow(upc-pion-analysis SOURCES upcPionAnalysis.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(fwd-muons-upc + SOURCES fwdMuonsUPC.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(upc-event-itsrof-counter + SOURCES upcEventITSROFcounter.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(upc-rho-analysis + SOURCES upcRhoAnalysis.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 + COMPONENT_NAME Analysis) diff --git a/PWGUD/Tasks/dgCandAnalyzer.cxx b/PWGUD/Tasks/dgCandAnalyzer.cxx index d0966dc794d..90d4bd8e011 100644 --- a/PWGUD/Tasks/dgCandAnalyzer.cxx +++ b/PWGUD/Tasks/dgCandAnalyzer.cxx @@ -217,7 +217,11 @@ struct DGCandAnalyzer { } } - void processReco(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks) + // PV contributors + Filter PVContributorFilter = aod::udtrack::isPVContributor == true; + using PVTracks = soa::Filtered; + + void processReco(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks, PVTracks const& PVContributors) { // count collisions registry.fill(HIST("stat/candCaseAll"), 0., 1.); @@ -273,8 +277,8 @@ 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); + // 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/diffMCDataScanner.cxx b/PWGUD/Tasks/diffMCDataScanner.cxx index 05a3e497e17..8ad8d7ae853 100644 --- a/PWGUD/Tasks/diffMCDataScanner.cxx +++ b/PWGUD/Tasks/diffMCDataScanner.cxx @@ -102,9 +102,21 @@ struct collisionsInfo { using MFs = aod::MFTTracks; using FWs = aod::FwdTracks; - void process(CC const& collision, BCs const& bct0s, - TCs& tracks, /* MFs& mfttracks,*/ FWs& fwdtracks, aod::FT0s& /*ft0s*/, aod::FV0As& /*fv0as*/, aod::FDDs& /*fdds*/, - aod::McCollisions& /*McCols*/, aod::McParticles& /*McParts*/) + // filter for global tracks + Filter globalTrackFilter = requireGlobalTrackInFilter(); + using globalTracks = soa::Filtered; + + void process(CC const& collision, + BCs const& bct0s, + TCs& tracks, + /* MFs& mfttracks,*/ + FWs& fwdtracks, + globalTracks& goodTracks, + aod::FT0s& /*ft0s*/, + aod::FV0As& /*fv0as*/, + aod::FDDs& /*fdds*/, + aod::McCollisions& /*McCols*/, + aod::McParticles& /*McParts*/) { // obtain slice of compatible BCs @@ -123,8 +135,6 @@ struct collisionsInfo { } // global tracks - Partition goodTracks = requireGlobalTrackInFilter(); - goodTracks.bindTable(tracks); int cntGlobal = goodTracks.size(); // count tracks diff --git a/PWGUD/Tasks/diffMCQA.cxx b/PWGUD/Tasks/diffMCQA.cxx index 4d199892762..19bf3016a97 100644 --- a/PWGUD/Tasks/diffMCQA.cxx +++ b/PWGUD/Tasks/diffMCQA.cxx @@ -239,12 +239,26 @@ struct DiffMCQA { PROCESS_SWITCH(DiffMCQA, processMCTruth, "Process MC truth", true); // ............................................................................................................... - 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*/, - aod::Zdcs& zdcs, aod::Calos& calos, - aod::V0s const& v0s, aod::Cascades const& cascades, - aod::McCollisions const& /*McCols*/, aod::McParticles const& McParts) + // filter for global tracks + Filter globalTrackFilter = requireGlobalTrackInFilter(); + using globalTracks = soa::Filtered; + + void processMain(CC const& collision, + BCs const& bct0s, + TCs const& tracks, + FWs const& fwdtracks, + globalTracks const& goodTracks, + ATs const& /*ambtracks*/, + AFTs const& /*ambfwdtracks*/, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs& zdcs, + aod::Calos& calos, + aod::V0s const& v0s, + aod::Cascades const& cascades, + aod::McCollisions const& /*McCols*/, + aod::McParticles const& McParts) { bool isDGcandidate = true; @@ -263,10 +277,6 @@ struct DiffMCQA { registry.get(HIST("all/mcCols"))->Fill(0., 1.); } - // global tracks - Partition goodTracks = requireGlobalTrackInFilter(); - goodTracks.bindTable(tracks); - // update collision histograms if (isPythiaDiff) { registry.get(HIST("MBRDiff/Stat"))->Fill(0., 1.); diff --git a/PWGUD/Tasks/diffQA.cxx b/PWGUD/Tasks/diffQA.cxx index f219bc4eccb..a1e9ec34185 100644 --- a/PWGUD/Tasks/diffQA.cxx +++ b/PWGUD/Tasks/diffQA.cxx @@ -218,11 +218,24 @@ struct DiffQA { } // ............................................................................................................... - 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*/, - aod::Zdcs& zdcs, aod::Calos& calos, - aod::V0s const& v0s, aod::Cascades const& cascades) + // filter for global tracks + Filter globalTrackFilter = requireGlobalTrackInFilter(); + using globalTracks = soa::Filtered; + + void processMain(CC const& collision, + BCs const& bct0s, + TCs const& tracks, + FWs const& fwdtracks, + globalTracks const& goodTracks, + ATs const& /*ambtracks*/, + AFTs const& /*ambfwdtracks*/, + aod::FT0s const& /*ft0s*/, + aod::FV0As const& /*fv0as*/, + aod::FDDs const& /*fdds*/, + aod::Zdcs& zdcs, + aod::Calos& calos, + aod::V0s const& v0s, + aod::Cascades const& cascades) { LOGF(debug, " Collision %d", collision.globalIndex()); LOGF(debug, " Start %i", abcrs.size()); @@ -239,8 +252,6 @@ struct DiffQA { // vertex tracks registry.get(HIST("collisions/PVTracks"))->Fill(collision.numContrib()); // global tracks - Partition goodTracks = requireGlobalTrackInFilter(); - goodTracks.bindTable(tracks); registry.get(HIST("collisions/globalTracks"))->Fill(goodTracks.size()); // loop over all tracks diff --git a/PWGUD/Tasks/eventByevent.cxx b/PWGUD/Tasks/eventByevent.cxx new file mode 100644 index 00000000000..3df594af546 --- /dev/null +++ b/PWGUD/Tasks/eventByevent.cxx @@ -0,0 +1,302 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "iostream" +#include "PWGUD/DataModel/UDTables.h" +#include +#include +#include "TLorentzVector.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/SGTrackSelector.h" + +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// \brief Event by event study of pions +/// \author Amrit Gautam +/// \author Anisa Khatun +/// \date 20.07.2024 + +namespace o2::aod +{ +namespace tree +{ +// DECLARE_SOA_COLUMN(GAPSIDE, gapside, int); +// DECLARE_SOA_COLUMN(FT0AAMP, ft0Aamp, float); // namespace udzdc +// DECLARE_SOA_COLUMN(FT0CAMP, ft0Camp, float); +// DECLARE_SOA_COLUMN(FDDAAMP, fddAamp, float); +// DECLARE_SOA_COLUMN(FDDCAMP, fddCamp, float); +// DECLARE_SOA_COLUMN(FV0AAMP, fv0Aamp, float); +// ZDC tables +DECLARE_SOA_COLUMN(ZAENERGY, zaenergy, float); // namespace udzdc +DECLARE_SOA_COLUMN(ZCENERGY, zcenergy, float); +// track tables +// DECLARE_SOA_COLUMN(TRACKID, TrackId,std::vector); +DECLARE_SOA_COLUMN(SIGMAPI, sigmapi, std::vector); +DECLARE_SOA_COLUMN(SIGMAK, sigmak, std::vector); +DECLARE_SOA_COLUMN(SIGMAEL, sigmael, std::vector); +DECLARE_SOA_COLUMN(SIGMAPR, sigmapr, std::vector); +// DECLARE_SOA_COLUMN(SIGMAPI2, sigmapi2,float); +// DECLARE_SOA_COLUMN(SIGMAK2, sigmak2,float); +// DECLARE_SOA_COLUMN(SIGMAEL2, sigmael2,float); +// DECLARE_SOA_COLUMN(SIGMAPI3, sigmapi3,float); +// DECLARE_SOA_COLUMN(SIGMAK3, sigmak3,float); +// DECLARE_SOA_COLUMN(SIGMAEL3, sigmael3,float); +// DECLARE_SOA_COLUMN(SIGMAPI4, sigmapi4,float); +// DECLARE_SOA_COLUMN(SIGMAK4, sigmak4,float); +// DECLARE_SOA_COLUMN(SIGMAEL4, sigmael4,float); +DECLARE_SOA_COLUMN(PT, Pt, float); +DECLARE_SOA_COLUMN(RAP, rap, float); +DECLARE_SOA_COLUMN(PHI, Phi, float); +DECLARE_SOA_COLUMN(TOTSIGN, totsign, int); +DECLARE_SOA_COLUMN(MASS, mass, float); +DECLARE_SOA_COLUMN(NPVTRACK, npvtrack, int); +DECLARE_SOA_COLUMN(PTS, Pts, std::vector); +DECLARE_SOA_COLUMN(ETAS, etas, std::vector); +DECLARE_SOA_COLUMN(PHIS, Phis, std::vector); +DECLARE_SOA_COLUMN(SIGNS, Signs, std::vector); +// DECLARE_SOA_COLUMN(RAWTRACKS, rawtracks, int); +// DECLARE_SOA_COLUMN(PTRACKS, ptracks, int); + +// DECLARE_SOA_COLUMN(NTPCCLS, ntpccls,int); +} // namespace tree + +DECLARE_SOA_TABLE(TREE, "AOD", "Tree", //! ZDC information + // tree::GAPSIDE, + // tree::FT0AAMP, + // tree::FT0CAMP, + // tree::FDDAAMP, + // tree::FDDCAMP, + // tree::FV0AAMP, + tree::ZAENERGY, + tree::ZCENERGY, + tree::PT, + tree::RAP, + tree::PHI, + tree::MASS, + tree::TOTSIGN, + tree::NPVTRACK, + tree::SIGMAPI, + // tree::SIGMAPI2, + // tree::SIGMAPI3, + // tree::SIGMAPI4, + tree::SIGMAK, + // tree::SIGMAK2, + // tree::SIGMAK3, + // tree::SIGMAK4, + tree::SIGMAEL, + // tree::SIGMAEL2, + // tree::SIGMAEL3, + // tree::SIGMAEL4, + tree::SIGMAPR, + tree::PTS, + tree::ETAS, + tree::PHIS, + tree::SIGNS + // tree::RAWTRACKS, + // tree::PTRACKS +); + +} // namespace o2::aod + +struct EventByEvent { + SGSelector sgSelector; + Produces tree; + + Configurable FV0_cut{"FV0", 100., "FV0A threshold"}; + Configurable FT0A_cut{"FT0A", 200., "FT0A threshold"}; + Configurable FT0C_cut{"FT0C", 100., "FT0C threshold"}; + Configurable FDDA_cut{"FDDA", 10000., "FDDA threshold"}; + Configurable FDDC_cut{"FDDC", 10000., "FDDC threshold"}; + Configurable ZDC_cut{"ZDC", 10., "ZDC threshold"}; + Configurable gap_Side{"gap", 2, "gap selection"}; + + // Collision selection + Configurable collcontrib_cut{"collcontrib_cut", 10, "no. of PV contributor per collsion"}; + Configurable Zvtx_cut{"Zvtx_cut", 15, "z-vertex selection"}; + + // 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.1, "Track Pt"}; + Configurable TPC_cluster{"TPC_cluster", 50, "No.of TPC cluster"}; + + // Kinmatic cuts + Configurable PID_cut{"PID_cut", 5, "TPC PID"}; + Configurable Rap_cut{"Rap_cut", 0.9, "Track rapidity"}; + Configurable Mass_Max{"Mass_Max", 10, "Invariant Mass range high"}; + Configurable Mass_Min{"Mass_Min", 0, "Invariant Mass range low"}; + Configurable Pt_coherent{"Pt_coherent", 0.15, "Coherent selection"}; + + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //----------------------------------------------------------------------------------------------------------------------- + void init(o2::framework::InitContext&) + { + + registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{20, 0., 20.}}); + + TString SelectionCuts[18] = {"NoSelection", "gapside", "goodtracks", "truegap", "ncollcontrib ", "zvtx", "2collcontrib", "2goodtrk", "TPCPID", "Rap_cut", "unlikesign", "mass_cut", "coherent", "incoherent", "likesign", "mass_cut", "coherent", "incoherent"}; + // now we can set BinLabel in histogram Registry + + for (int i = 0; i < 18; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + + // tracks + registry.add("hTracks", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracksPions", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("h4TracksPions", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hdEdx", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {100, 0.0, 200.0}}); + registry.add("hdEdxPion", "p_{#pi} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {100, 0.0, 200.0}}); + + // using Angular Correlation method + } + + using udtracks = soa::Join; + using udtracksfull = soa::Join; + using UDCollisionsFull = soa::Join; + //__________________________________________________________________________ + // Main process + void process(UDCollisionsFull::iterator const& collision, udtracksfull const& tracks) + { + registry.fill(HIST("hSelectionCounter"), 0); + // LOGF(info, " BC ID %d",collision.gapSide()); + int gapSide = collision.gapSide(); + if (gapSide < 0 || gapSide > 2) + return; + + registry.fill(HIST("hSelectionCounter"), 1); + + float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; + int truegapSide = sgSelector.trueGap(collision, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + registry.fill(HIST("hSelectionCounter"), 2); + + registry.fill(HIST("GapSide"), gapSide); + registry.fill(HIST("TrueGapSide"), truegapSide); + gapSide = truegapSide; + + registry.fill(HIST("hSelectionCounter"), 3); + //_____________________________________ + // Create pions and apply TPC Pion PID + std::vector allTracks; + std::vector onlyPionTracks; + std::vector onlyPionSigma; + std::vector rawPionTracks; + std::vector trackpt; + std::vector tracketa; + std::vector trackphi; + std::vector tracksign; + std::vector pitpcpid; + std::vector ktpcpid; + std::vector eltpcpid; + std::vector prtpcpid; + + TLorentzVector p; + + if (gapSide == gap_Side) { + + // registry.fill(HIST("hTracks"), tracks.size()); + + if (collision.numContrib() > collcontrib_cut) + return; + + registry.fill(HIST("hSelectionCounter"), 4); + if ((collision.posZ() < -(Zvtx_cut)) || (collision.posZ() > Zvtx_cut)) + return; + registry.fill(HIST("hSelectionCounter"), 5); + + for (auto t : tracks) { + + if (!trackselector(t, parameters)) + continue; + + double dEdx = t.tpcSignal(); + + registry.fill(HIST("hdEdx"), t.tpcInnerParam() / t.sign(), dEdx); + TLorentzVector a; + a.SetXYZM(t.px(), t.py(), t.pz(), o2::constants::physics::MassPionCharged); + allTracks.push_back(a); + auto nSigmaPi = t.tpcNSigmaPi(); + + if (fabs(nSigmaPi) < PID_cut) { + onlyPionTracks.push_back(a); + onlyPionSigma.push_back(nSigmaPi); + rawPionTracks.push_back(t); + registry.fill(HIST("hdEdxPion"), t.tpcInnerParam() / t.sign(), dEdx); + } + } + registry.fill(HIST("hTracksPions"), onlyPionTracks.size()); + + //_____________________________________ + if (collision.numContrib() >= 2) { + // Four pions analysis + registry.fill(HIST("hSelectionCounter"), 6); + if ((rawPionTracks.size() >= 2) && (allTracks.size() >= 2)) { + + for (auto pion : onlyPionTracks) { + p += pion; + } + + registry.fill(HIST("h4TracksPions"), onlyPionTracks.size()); + registry.fill(HIST("hSelectionCounter"), 7); + + for (auto rtrk : rawPionTracks) { + + TLorentzVector itrk; + itrk.SetXYZM(rtrk.px(), rtrk.py(), rtrk.pz(), o2::constants::physics::MassPionCharged); + trackpt.push_back(itrk.Pt()); + tracketa.push_back(itrk.Eta()); + trackphi.push_back(itrk.Phi()); + tracksign.push_back(rtrk.sign()); + pitpcpid.push_back(rtrk.tpcNSigmaPi()); + ktpcpid.push_back(rtrk.tpcNSigmaKa()); + eltpcpid.push_back(rtrk.tpcNSigmaEl()); + prtpcpid.push_back(rtrk.tpcNSigmaPr()); + } + + int sign = 0; + TLorentzVector piplus, piminus; + for (auto rawPion : rawPionTracks) { + sign += rawPion.sign(); + } + + registry.fill(HIST("hTracks"), collision.numContrib()); + + tree(collision.energyCommonZNA(), collision.energyCommonZNC(), p.Pt(), p.Y(), p.Phi(), p.M(), sign, collision.numContrib(), pitpcpid, ktpcpid, eltpcpid, prtpcpid, trackpt, tracketa, trackphi, tracksign); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/exclusivePhi.cxx b/PWGUD/Tasks/exclusivePhi.cxx index eed29b6fdfc..8f764f2bfff 100644 --- a/PWGUD/Tasks/exclusivePhi.cxx +++ b/PWGUD/Tasks/exclusivePhi.cxx @@ -9,6 +9,7 @@ // 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" @@ -626,7 +627,7 @@ struct ExclusivePhi { // auto ksize = allTracksAreITSonlyAndFourITSclusters.size(); registry.fill(HIST("hTracksITSonly"), allTracksAreITSonlyAndFourITSclusters.size()); - for (int kaon = 0; kaon < allTracksAreITSonlyAndFourITSclusters.size(); kaon++) { + for (std::size_t kaon = 0; kaon < allTracksAreITSonlyAndFourITSclusters.size(); kaon++) { int clusterSize[7]; double averageClusterSize = 0.; diff --git a/PWGUD/Tasks/exclusivePhiLeptons.cxx b/PWGUD/Tasks/exclusivePhiLeptons.cxx index 136d9a789f2..ea7e92f61dd 100644 --- a/PWGUD/Tasks/exclusivePhiLeptons.cxx +++ b/PWGUD/Tasks/exclusivePhiLeptons.cxx @@ -8,6 +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. +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -37,7 +38,7 @@ struct ExclusivePhiLeptons { Configurable gap_Side{"gap", 2, "gap selection"}; Configurable pid2d_cut{"PID2D", 2., "PID cut in 2D"}; Configurable pid_cut{"PID", 2., "PID cut in 1D"}; - Configurable electronsInTOF{"eTOF", 2, "electrons in TOF"}; + Configurable electronsInTOF{"eTOF", 2, "electrons in TOF"}; // defining histograms using histogram registry HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; diff --git a/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx b/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx new file mode 100644 index 00000000000..e1ef9b8f3b4 --- /dev/null +++ b/PWGUD/Tasks/exclusivePhiLeptonsTrees.cxx @@ -0,0 +1,310 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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" +#include "iostream" +#include "PWGUD/DataModel/UDTables.h" +#include +#include "TLorentzVector.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGUD/Core/SGSelector.h" +using std::array; +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// \brief Exclusive phi->ee tree producer, for ML applications, DG-based +/// \author Simone Ragoni, Creighton +/// \date 11/11/2024 + +namespace o2::aod +{ +namespace tree +{ +// track tables +DECLARE_SOA_COLUMN(PX1, px1, float); +DECLARE_SOA_COLUMN(PY1, py1, float); +DECLARE_SOA_COLUMN(PZ1, pz1, float); +DECLARE_SOA_COLUMN(PE1, pE1, float); +DECLARE_SOA_COLUMN(PX2, px2, float); +DECLARE_SOA_COLUMN(PY2, py2, float); +DECLARE_SOA_COLUMN(PZ2, pz2, float); +DECLARE_SOA_COLUMN(PE2, pE2, float); +DECLARE_SOA_COLUMN(NCOUNTERPV, nCounterPV, int); +DECLARE_SOA_COLUMN(NELECTRONSTOF, nElectronsTOF, int); +} // namespace tree + +DECLARE_SOA_TABLE(TREE, "AOD", "Tree", tree::PX1, tree::PY1, tree::PZ1, tree::PE1, tree::PX2, tree::PY2, tree::PZ2, tree::PE2, tree::NCOUNTERPV, tree::NELECTRONSTOF); +} // namespace o2::aod + +struct ExclusivePhiLeptonsTrees { + Produces tree; + Configurable gap_Side{"gap", 2, "gap selection"}; + Configurable pid2d_cut{"PID2D", 2., "PID cut in 2D"}; + Configurable pid_cut{"PID", 2., "PID cut in 1D"}; + Configurable electronsInTOF{"eTOF", 2, "electrons in TOF"}; + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //----------------------------------------------------------------------------------------------------------------------- + void init(o2::framework::InitContext&) + { + registry.add("posx", "Vertex position in x", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posy", "Vertex position in y", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posz", "Vertex position in z", kTH1F, {{1000, -100., 100.}}); + registry.add("hITSCluster", "N_{cluster}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hChi2ITSTrkSegment", "N_{cluster}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTPCCluster", "N_{cluster}", kTH1F, {{200, -0.5, 199.5}}); + registry.add("hdEdx", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdx2", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdSigmaElectron", "p vs dE/dx sigma electron", kTH2F, {{100, 0.0, 3.0}, {1000, -500.0, 500.0}}); + registry.add("hdSigmaElectron2", "p vs dE/dx sigma electron", kTH2F, {{100, 0.0, 3.0}, {1000, -500.0, 500.0}}); + registry.add("hdSigmaElectron3", "p vs dE/dx sigma electron", kTH2F, {{100, 0.0, 3.0}, {1000, -500.0, 500.0}}); + registry.add("hNsigEvsKa1", "NSigma(t1) vs NSigma (t2);n#sigma_{1};n#sigma_{2}", kTH2F, {{100, -15., 15.}, {100, -15., 15}}); + registry.add("hNsigEvsKa2", "NSigma(t1) vs NSigma (t2);n#sigma_{1};n#sigma_{2}", kTH2F, {{100, -15., 15.}, {100, -15., 15}}); + registry.add("hMomentum", "p_{#ka};#it{p_{trk}}, GeV/c;", kTH1F, {{100, 0., 3.}}); + registry.add("hEta1", "#eta_{#ka};#it{#eta_{trk}}, GeV/c;", kTH1F, {{100, -2., 2.}}); + registry.add("hPtLikeSignElectron", "Pt;#it{p_{t}}, GeV/c;", kTH1F, {{500, 0., 5.}}); + registry.add("hMassLikeSignElectron", "Raw Inv.M;#it{m_{ee}}, GeV/c^{2};", kTH1F, {{1000, 0., 10.}}); + registry.add("hMassPtLikeSignElectron", "Raw Inv.M;#it{m_{ee}}, GeV/c^{2};Pt;#it{p_{t}}, GeV/c;", kTH2F, {{1000, 0., 10.}, {400, 0., 4.}}); + + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{10, 0., 10.}}); + + TString SelectionCuts[9] = {"NoSelection", "GAPcondition", "PVtracks", "Good TPC-ITS track", "TPC/TOF PID track", "End trk loop", "Exactly 2e", "Like-sign ev", "Unlike-sign ev"}; + // now we can set BinLabel in histogram Registry + + for (int i = 0; i < 9; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + + // Unlike sign pp + registry.add("ee/hRapidity", "Rapidity;#it{y_{ee}};", kTH1F, {{100, -2., 2.}}); + registry.add("ee/hPtElectronVsElectron", "Pt1 vs Pt2;p_{T};p_{T};", kTH2F, {{100, 0., 3.}, {100, 0., 3.}}); + registry.add("ee/hMassPtUnlikeSignElectron", "Raw Inv.M;#it{m_{ee}}, GeV/c^{2};Pt;#it{p_{t}}, GeV/c;", kTH2F, {{400, 0., 4.}, {400, 0., 4.}}); + registry.add("ee/hMassUnlike", "m_{ee} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 10.}}); + registry.add("ee/hUnlikePt", "Pt;#it{p_{t}}, GeV/c;", kTH1F, {{500, 0., 5.}}); + registry.add("ee/hCoherentMass", "Raw Inv.M;#it{m_{ee}}, GeV/c^{2};", kTH1F, {{1000, 0., 10.}}); + registry.add("ee/hIncoherentMass", "Raw Inv.M;#it{m_{ee}}, GeV/c^{2};", kTH1F, {{1000, 0., 10.}}); + } + + using udtracks = soa::Join; + using udtracksfull = soa::Join; + // using UDCollisions = soa::Join; + //__________________________________________________________________________ + // Main process + void process(UDCollisions::iterator const& collision, udtracksfull const& tracks) + { + registry.fill(HIST("hSelectionCounter"), 0); + registry.fill(HIST("posx"), collision.posX()); + registry.fill(HIST("posy"), collision.posY()); + registry.fill(HIST("posz"), collision.posZ()); + TLorentzVector resonance; // lorentz vectors of tracks and the mother + // =================================== + // Task for ee pairs with PID + // Topology: + // - 2 TOF ee + // - 1 TOF e + 1 TPC e + // =================================== + std::vector onlyElectronTracks; + std::vector onlyElectronTracksTOF; + std::vector onlyElectronSigma; + std::vector onlyElectronSigmaTOF; + std::vector rawElectronTracks; + std::vector rawElectronTracksTOF; + + // ------------------------------------------- + // TO BE SAVED: + // - counterPV + // - electronsTOF (0,1,2) = 2 - electronsTPC + // - (px,py,pz,E)1 + // - (px,py,pz,E)2 + int counterPV = 0; + for (auto trk : tracks) { + // ---------------------------------------- + // SELECTIONS: + // - PV track + // - at least 70 TPC clusters + // - at least 6 ITS clusters + // - 0.3 < pT < 0.65 GeV from STARlight + // - DCAxy, DCAz + // - Nsigma^2 < 2^2 + // - |track eta| < 0.8 + if (!trk.isPVContributor()) { + continue; + } + counterPV += 1; + registry.fill(HIST("hSelectionCounter"), 2); + + int NFindable = trk.tpcNClsFindable(); + int NMinusFound = trk.tpcNClsFindableMinusFound(); + int NCluster = NFindable - NMinusFound; + registry.fill(HIST("hTPCCluster"), NCluster); + registry.fill(HIST("hChi2ITSTrkSegment"), trk.itsChi2NCl()); + if (NCluster < 70) { + continue; + } + if (trk.itsNCls() < 6) { + continue; + } + if (trk.pt() < 0.300) { + continue; + } + if (trk.pt() > 0.650) { + continue; + } + if (!(std::abs(trk.dcaZ()) < 2.)) { + continue; + } + double dcaLimit = 0.0105 + 0.035 / pow(trk.pt(), 1.1); + if (!(std::abs(trk.dcaXY()) < dcaLimit)) { + continue; + } + registry.fill(HIST("hSelectionCounter"), 3); + registry.fill(HIST("hITSCluster"), trk.itsNCls()); + + double momentum = TMath::Sqrt(trk.px() * trk.px() + trk.py() * trk.py() + trk.pz() * trk.pz()); + double dEdx = trk.tpcSignal(); + registry.fill(HIST("hdEdx"), momentum, dEdx); + + TLorentzVector electron; + electron.SetXYZM(trk.px(), trk.py(), trk.pz(), o2::constants::physics::MassElectron); + if (fabs(electron.Eta()) > 0.8) { + return; + } + auto nSigmaEl = trk.tpcNSigmaEl(); + auto nSigmaElTOF = trk.tofNSigmaEl(); + + if (trk.hasTOF()) { + registry.fill(HIST("hdSigmaElectron"), momentum, nSigmaElTOF); + } + if (fabs(nSigmaEl) < pid_cut) { + registry.fill(HIST("hdEdx2"), momentum, dEdx); + registry.fill(HIST("hdSigmaElectron2"), momentum, nSigmaEl); + registry.fill(HIST("hMomentum"), momentum); + if (trk.hasTOF() && fabs(nSigmaElTOF) < pid_cut) { + registry.fill(HIST("hdSigmaElectron3"), momentum, nSigmaElTOF); + onlyElectronTracksTOF.push_back(electron); + onlyElectronSigmaTOF.push_back(nSigmaElTOF); + rawElectronTracksTOF.push_back(trk); + } else if (!trk.hasTOF()) { + onlyElectronTracks.push_back(electron); + onlyElectronSigma.push_back(nSigmaEl); + rawElectronTracks.push_back(trk); + } + registry.fill(HIST("hSelectionCounter"), 4); + } + + } // trk loop + + registry.fill(HIST("hSelectionCounter"), 5); + if ((onlyElectronTracksTOF.size() >= electronsInTOF) && (onlyElectronTracks.size() + onlyElectronTracksTOF.size()) == 2) { + registry.fill(HIST("hSelectionCounter"), 6); + + int signSum = -999.; + double sigmaTotal = -999.; + TLorentzVector a, b; + // two electrons in the TPC + if (onlyElectronTracksTOF.size() == 0) { + + registry.fill(HIST("hEta1"), onlyElectronTracks[0].Eta()); + registry.fill(HIST("hEta1"), onlyElectronTracks[1].Eta()); + resonance += onlyElectronTracks[0]; + resonance += onlyElectronTracks[1]; + a += onlyElectronTracks[0]; + b += onlyElectronTracks[1]; + sigmaTotal = 0; + sigmaTotal = onlyElectronSigma[0] * onlyElectronSigma[0] + onlyElectronSigma[1] * onlyElectronSigma[1]; + ; + registry.fill(HIST("hNsigEvsKa1"), onlyElectronSigma[0], onlyElectronSigma[1]); + signSum = rawElectronTracks[0].sign() + rawElectronTracks[1].sign(); + if (signSum == 0) { + registry.fill(HIST("ee/hPtElectronVsElectron"), onlyElectronTracks[0].Pt(), onlyElectronTracks[1].Pt()); + } + + } else if (onlyElectronTracksTOF.size() == 1) { + + registry.fill(HIST("hEta1"), onlyElectronTracks[0].Eta()); + registry.fill(HIST("hEta1"), onlyElectronTracksTOF[0].Eta()); + resonance += onlyElectronTracks[0]; + resonance += onlyElectronTracksTOF[0]; + a += onlyElectronTracks[0]; + b += onlyElectronTracksTOF[0]; + sigmaTotal = 0; + sigmaTotal = onlyElectronSigma[0] * onlyElectronSigma[0] + onlyElectronSigmaTOF[0] * onlyElectronSigmaTOF[0]; + ; + registry.fill(HIST("hNsigEvsKa1"), onlyElectronSigma[0], onlyElectronSigmaTOF[0]); + signSum = rawElectronTracks[0].sign() + rawElectronTracksTOF[0].sign(); + if (signSum == 0) { + registry.fill(HIST("ee/hPtElectronVsElectron"), onlyElectronTracks[0].Pt(), onlyElectronTracksTOF[0].Pt()); + } + + } else if (onlyElectronTracksTOF.size() == 2) { + + registry.fill(HIST("hEta1"), onlyElectronTracksTOF[0].Eta()); + registry.fill(HIST("hEta1"), onlyElectronTracksTOF[1].Eta()); + resonance += onlyElectronTracksTOF[0]; + resonance += onlyElectronTracksTOF[1]; + a += onlyElectronTracksTOF[0]; + b += onlyElectronTracksTOF[1]; + sigmaTotal = 0; + sigmaTotal = onlyElectronSigmaTOF[0] * onlyElectronSigmaTOF[0] + onlyElectronSigmaTOF[1] * onlyElectronSigmaTOF[1]; + ; + registry.fill(HIST("hNsigEvsKa1"), onlyElectronSigmaTOF[0], onlyElectronSigmaTOF[1]); + signSum = rawElectronTracksTOF[0].sign() + rawElectronTracksTOF[1].sign(); + if (signSum == 0) { + registry.fill(HIST("ee/hPtElectronVsElectron"), onlyElectronTracksTOF[0].Pt(), onlyElectronTracksTOF[1].Pt()); + } + } + + if (sigmaTotal > pid2d_cut * pid2d_cut) { + return; + } + if (onlyElectronTracksTOF.size() == 1) { + registry.fill(HIST("hNsigEvsKa2"), onlyElectronSigma[0], onlyElectronSigmaTOF[0]); + } else if (onlyElectronTracksTOF.size() == 2) { + registry.fill(HIST("hNsigEvsKa2"), onlyElectronSigmaTOF[0], onlyElectronSigmaTOF[1]); + } + + if (signSum != 0) { + registry.fill(HIST("hMassPtLikeSignElectron"), resonance.M(), resonance.Pt()); + registry.fill(HIST("hSelectionCounter"), 7); + registry.fill(HIST("hPtLikeSignElectron"), resonance.Pt()); + registry.fill(HIST("hMassLikeSignElectron"), resonance.M()); + } else { + registry.fill(HIST("ee/hMassPtUnlikeSignElectron"), resonance.M(), resonance.Pt()); + registry.fill(HIST("hSelectionCounter"), 8); + registry.fill(HIST("ee/hMassUnlike"), resonance.M()); + registry.fill(HIST("ee/hRapidity"), resonance.Rapidity()); + if (resonance.Pt() > 0.1) { + registry.fill(HIST("ee/hIncoherentMass"), resonance.M()); + } else { + registry.fill(HIST("ee/hCoherentMass"), resonance.M()); + } + if (resonance.M() > 1.01 && resonance.M() < 1.03) { + registry.fill(HIST("ee/hUnlikePt"), resonance.Pt()); + } + } + // Filling tree, make to be consistent with the declared tables + tree(a.Px(), a.Py(), a.Pz(), a.E(), b.Px(), b.Py(), b.Pz(), b.E(), counterPV, onlyElectronTracksTOF.size()); + } + } // end of process + +}; // end of struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/fwdMuonsUPC.cxx b/PWGUD/Tasks/fwdMuonsUPC.cxx new file mode 100644 index 00000000000..34075b7a862 --- /dev/null +++ b/PWGUD/Tasks/fwdMuonsUPC.cxx @@ -0,0 +1,445 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" +#include "PWGUD/DataModel/UDTables.h" + +#include "TLorentzVector.h" +#include "TSystem.h" +#include "TMath.h" + +namespace dimu +{ +// 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); +// 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); +// zn +DECLARE_SOA_COLUMN(Tzna, tzna, float); +DECLARE_SOA_COLUMN(Ezna, ezna, float); +DECLARE_SOA_COLUMN(Tznc, tznc, float); +DECLARE_SOA_COLUMN(Eznc, eznc, float); +DECLARE_SOA_COLUMN(Nclass, nclass, int); +} // namespace dimu + +namespace o2::aod +{ +DECLARE_SOA_TABLE(DiMu, "AOD", "DIMU", + dimu::M, dimu::Pt, dimu::Rap, dimu::Phi, + dimu::Ptp, dimu::Etap, dimu::Phip, + dimu::Ptn, dimu::Etan, dimu::Phin, + dimu::Tzna, dimu::Ezna, dimu::Tznc, dimu::Eznc, dimu::Nclass); +} + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// defining constants +double mMu = 0.10566; // mass of muon + +// constants used in the track selection +const float kRAbsMin = 17.6; +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; +const float kPtMin = 0.; + +struct fwdMuonsUPC { + + using CandidatesFwd = soa::Join; + using ForwardTracks = soa::Join; + + Produces dimuSel; + + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry reg0n0n{"reg0n0n", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry regXn0n{"regXn0n", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry regXnXn{"regXnXn", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // CONFIGURABLES + // pT of muon pairs + Configurable nBinsPt{"nBinsPt", 250, "N bins in pT histo"}; + Configurable lowPt{"lowPt", 0., "lower limit in pT histo"}; + Configurable highPt{"highPt", 0.5, "upper limit in pT histo"}; + // mass of muon pairs + Configurable nBinsMass{"nBinsMass", 500, "N bins in mass histo"}; + Configurable lowMass{"lowMass", 0., "lower limit in mass histo"}; + Configurable highMass{"highMass", 10., "upper limit in mass histo"}; + // eta of muon pairs + Configurable nBinsEta{"nBinsEta", 600, "N bins in eta histo"}; + Configurable lowEta{"lowEta", -10., "lower limit in eta histo"}; + Configurable highEta{"highEta", -2., "upper limit in eta histo"}; + // rapidity of muon pairs + Configurable nBinsRapidity{"nBinsRapidity", 250, "N bins in rapidity histo"}; + Configurable lowRapidity{"lowRapidity", -4.5, "lower limit in rapidity histo"}; + Configurable highRapidity{"highRapidity", -2., "upper limit in rapidity histo"}; + // phi of muon pairs + Configurable nBinsPhi{"nBinsPhi", 600, "N bins in phi histo"}; + Configurable lowPhi{"lowPhi", -TMath::Pi(), "lower limit in phi histo"}; + Configurable highPhi{"highPhi", TMath::Pi(), "upper limit in phi histo"}; + // pT of single muons + Configurable nBinsPtSingle{"nBinsPtSingle", 500, "N bins in pT histo single muon"}; + Configurable lowPtSingle{"lowPtSingle", 0., "lower limit in pT histo single muon"}; + Configurable highPtSingle{"highPtSingle", 2., "upper limit in pT histo single muon"}; + // eta of single muons + Configurable nBinsEtaSingle{"nBinsEtaSingle", 250, "N bins in eta histo single muon"}; + Configurable lowEtaSingle{"lowEtaSingle", -4.5, "lower limit in eta histo single muon"}; + Configurable highEtaSingle{"highEtaSingle", -2., "upper limit in eta histo single muon"}; + // phi of single muons + Configurable nBinsPhiSingle{"nBinsPhiSingle", 600, "N bins in phi histo single muon"}; + Configurable lowPhiSingle{"lowPhiSingle", -TMath::Pi(), "lower limit in phi histo single muon"}; + Configurable highPhiSingle{"highPhiSingle", TMath::Pi(), "upper limit in phi histo single muon"}; + // ZDC + 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"}; + + // configuarble rapidity cuts + Configurable yCutLow{"yCutLow", -4, "Lower cut in pair rapidity"}; + Configurable yCutUp{"yCutUp", -2.5, "Upper cut in pair rapidity"}; + + void init(InitContext&) + { + // binning of pT axis fr fit + std::vector ptFitBinning = { + 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.175, 0.20, 0.25, 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.50, + 3.00, 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 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"}; + const AxisSpec axisPhi{nBinsPhi, lowPhi, highPhi, "#varphi"}; + const AxisSpec axisPtSingle{nBinsPtSingle, lowPtSingle, highPtSingle, "#it{p}_{T}_{ trk} GeV/#it{c}"}; + const AxisSpec axisTimeZN{200, -10, 10, "ZDC time (ns)"}; + const AxisSpec axisEnergyZNA{nBinsZDCen, lowEnZN, highEnZN, "ZNA energy (TeV)"}; + const AxisSpec axisEnergyZNC{nBinsZDCen, lowEnZN, highEnZN, "ZNC energy (TeV)"}; + const AxisSpec axisEtaSingle{nBinsEtaSingle, lowEtaSingle, highEtaSingle, "#eta_{trk}"}; + const AxisSpec axisPhiSingle{nBinsPhiSingle, lowPhiSingle, highPhiSingle, "#varphi_{trk}"}; + + // histos + registry.add("hMass", "Ivariant mass of muon pairs;;#counts", kTH1D, {axisMass}); + registry.add("hPt", "Transverse momentum mass of muon pairs;;#counts", kTH1D, {axisPt}); + registry.add("hPtFit", "Transverse momentum mass of muon pairs;;#counts", kTH1D, {axisPtFit}); + 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}); + registry.add("hCharge", "Charge;#it{charge};;#counts", kTH1D, {{5, -2.5, 2.5}}); + registry.add("hContrib", "hContrib;;#counts", kTH1D, {{6, -0.5, 5.5}}); + registry.add("hEvSign", "Sum of the charges of all the tracks in each event;;#counts", kTH1D, {{5, -2.5, 2.5}}); + registry.add("hPtTrkPos", "Pt of positive muons;;#counts", kTH1D, {axisPtSingle}); + registry.add("hPtTrkNeg", "Pt of negative muons;;#counts", kTH1D, {axisPtSingle}); + registry.add("hEtaTrkPos", "#eta of positive muons;;#counts", kTH1D, {axisEtaSingle}); + registry.add("hEtaTrkNeg", "#eta of negative muons;;#counts", kTH1D, {axisEtaSingle}); + registry.add("hPhiTrkPos", "#varphi of positive muons;;#counts", kTH1D, {axisPhiSingle}); + registry.add("hPhiTrkNeg", "#varphi of negative muons;;#counts", kTH1D, {axisPhiSingle}); + registry.add("hTimeZNA", "ZNA Times;;#counts", kTH1D, {axisTimeZN}); + registry.add("hTimeZNC", "ZNC Times;;#counts", kTH1D, {axisTimeZN}); + registry.add("hEnergyZN", "ZNA vs ZNC energy", kTH2D, {axisEnergyZNA, axisEnergyZNC}); + registry.add("hSameSign", "hSameSign;;#counts", kTH1D, {{6, -0.5, 5.5}}); + + reg0n0n.add("hMass", "Ivariant mass of muon pairs - 0n0n;;#counts", kTH1D, {axisMass}); + reg0n0n.add("hPt", "Transverse momentum mass of muon pairs - 0n0n;;#counts", kTH1D, {axisPt}); + reg0n0n.add("hEta", "Pseudorapidty of muon pairs - 0n0n;;#counts", kTH1D, {axisEta}); + reg0n0n.add("hRapidity", "Rapidty of muon pairs - 0n0n;;#counts", kTH1D, {axisRapidity}); + reg0n0n.add("hPtFit", "Transverse momentum mass of muon pairs - 0n0n;;#counts", kTH1D, {axisPtFit}); + + regXn0n.add("hMass", "Ivariant mass of muon pairs - Xn0n;;#counts", kTH1D, {axisMass}); + regXn0n.add("hPt", "Transverse momentum mass of muon pairs - Xn0n;;#counts", kTH1D, {axisPt}); + regXn0n.add("hEta", "Pseudorapidty of muon pairs - Xn0n;;#counts", kTH1D, {axisEta}); + regXn0n.add("hRapidity", "Rapidty of muon pairs - Xn0n;;#counts", kTH1D, {axisRapidity}); + regXn0n.add("hPtFit", "Transverse momentum mass of muon pairs - Xn0n;;#counts", kTH1D, {axisPtFit}); + + regXnXn.add("hMass", "Ivariant mass of muon pairs - XnXn;;#counts", kTH1D, {axisMass}); + regXnXn.add("hPt", "Transverse momentum mass of muon pairs - XnXn;;#counts", kTH1D, {axisPt}); + regXnXn.add("hEta", "Pseudorapidty of muon pairs - XnXn;;#counts", kTH1D, {axisEta}); + regXnXn.add("hRapidity", "Rapidty of muon pairs - XnXn;;#counts", kTH1D, {axisRapidity}); + regXnXn.add("hPtFit", "Transverse momentum mass of muon pairs - XnXn;;#counts", kTH1D, {axisPtFit}); + } + + // FUNCTIONS + + // template function that fills a map with the collision id of each udcollision as key + // and a vector with the tracks + // map == (key, element) == (udCollisionId, vector of trks) + template + void collectCandIDs(std::unordered_map>& tracksPerCand, TTracks& tracks) + { + for (const auto& tr : tracks) { + int32_t candId = tr.udCollisionId(); + if (candId < 0) { + continue; + } + tracksPerCand[candId].push_back(tr.globalIndex()); + } + } + + // struct used to store the ZDC info in a map + struct ZDCinfo { + float timeA; + float timeC; + float enA; + float enC; + int32_t id; + }; + + // function that fills a map with the collision id of each udcollision as key + // and a ZDCinfo struct with the ZDC information + void collectCandZDCInfo(std::unordered_map& zdcPerCand, o2::aod::UDZdcsReduced& ZDCs) + { + + for (auto& zdc : ZDCs) { + int32_t candId = zdc.udCollisionId(); + if (candId < 0) { + continue; + } + + zdcPerCand[candId].timeA = zdc.timeZNA(); + zdcPerCand[candId].timeC = zdc.timeZNC(); + zdcPerCand[candId].enA = zdc.energyCommonZNA(); + zdcPerCand[candId].enC = zdc.energyCommonZNC(); + + // take care of the infinity + if (std::isinf(zdcPerCand[candId].timeA)) + zdcPerCand[candId].timeA = -999; + if (std::isinf(zdcPerCand[candId].timeC)) + zdcPerCand[candId].timeC = -999; + if (std::isinf(zdcPerCand[candId].enA)) + zdcPerCand[candId].enA = -999; + if (std::isinf(zdcPerCand[candId].enC)) + zdcPerCand[candId].enC = -999; + } + } + + // function to select muon tracks + bool isMuonSelected(const ForwardTracks::iterator& fwdTrack) + { + float rAbs = fwdTrack.rAtAbsorberEnd(); + float pDca = fwdTrack.pDca(); + TLorentzVector p; + p.SetXYZM(fwdTrack.px(), fwdTrack.py(), fwdTrack.pz(), mMu); + float eta = p.Eta(); + float pt = p.Pt(); + float pDcaMax = rAbs < kRAbsMid ? kPDca1 : kPDca2; + + if (eta < kEtaMin || eta > kEtaMax) + return false; + if (pt < kPtMin) + return false; + if (rAbs < kRAbsMin || rAbs > kRAbsMax) + return false; + if (pDca > pDcaMax) + return false; + return true; + } + + // function that processes the candidates: + // it applies V0 selection, trk selection, and fills the histograms + void processCand(CandidatesFwd::iterator const& cand, + const ForwardTracks::iterator& tr1, const ForwardTracks::iterator& tr2, + ZDCinfo& zdc) + { + // 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.) + return; + } + } + + // track selection + TLorentzVector p1, p2; + p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), mMu); + p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), mMu); + TLorentzVector p = p1 + p2; + 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) + return; + + // cuts on pair kinematics + if (!(p.M() > 2 && p.M() < 6 && p.Pt() < 5)) + return; + + // select opposite charge events only + if (cand.netCharge() != 0) { + registry.fill(HIST("hSameSign"), cand.numContrib()); + return; + } + + // select rapidity ranges + if (p.Rapidity() < yCutLow) + return; + if (p.Rapidity() > yCutUp) + return; + + // zdc info + if (TMath::Abs(zdc.timeA) < 10) + registry.fill(HIST("hTimeZNA"), zdc.timeA); + if (TMath::Abs(zdc.timeC) < 10) + registry.fill(HIST("hTimeZNC"), zdc.timeC); + registry.fill(HIST("hEnergyZN"), zdc.enA, zdc.enC); + + // divide the events in neutron classes + bool neutron_A = false; + bool neutron_C = false; + int znClass = -1; + + if (TMath::Abs(zdc.timeA) < 2) + neutron_A = true; + if (TMath::Abs(zdc.timeC) < 2) + neutron_C = true; + + if (std::isinf(zdc.timeC)) + neutron_C = false; + if (std::isinf(zdc.timeA)) + neutron_A = false; + + // fill the histos in neutron classes and assign neutron class label + // 0n0n + if (neutron_C == false && neutron_A == false) { + znClass = 0; + reg0n0n.fill(HIST("hMass"), p.M()); + reg0n0n.fill(HIST("hPt"), p.Pt()); + reg0n0n.fill(HIST("hPtFit"), p.Pt()); + reg0n0n.fill(HIST("hEta"), p.Eta()); + reg0n0n.fill(HIST("hRapidity"), p.Rapidity()); + } else if (neutron_A ^ neutron_C) { // Xn0n + 0nXn + if (neutron_A) + znClass = 1; + else if (neutron_C) + znClass = 2; + regXn0n.fill(HIST("hMass"), p.M()); + regXn0n.fill(HIST("hPt"), p.Pt()); + regXn0n.fill(HIST("hPtFit"), p.Pt()); + regXn0n.fill(HIST("hEta"), p.Eta()); + regXn0n.fill(HIST("hRapidity"), p.Rapidity()); + } else if (neutron_A && neutron_C) { // XnXn + znClass = 3; + regXnXn.fill(HIST("hMass"), p.M()); + regXnXn.fill(HIST("hPt"), p.Pt()); + regXnXn.fill(HIST("hPtFit"), p.Pt()); + regXnXn.fill(HIST("hEta"), p.Eta()); + regXnXn.fill(HIST("hRapidity"), p.Rapidity()); + } + + // fill the histos without looking at neutron emission + registry.fill(HIST("hContrib"), cand.numContrib()); + registry.fill(HIST("hPtTrkPos"), p1.Pt()); + registry.fill(HIST("hPtTrkNeg"), p2.Pt()); + registry.fill(HIST("hEtaTrkPos"), p1.Eta()); + registry.fill(HIST("hEtaTrkNeg"), p2.Eta()); + registry.fill(HIST("hPhiTrkPos"), p1.Phi()); + registry.fill(HIST("hPhiTrkNeg"), p2.Phi()); + registry.fill(HIST("hEvSign"), cand.netCharge()); + registry.fill(HIST("hMass"), p.M()); + registry.fill(HIST("hPt"), p.Pt()); + registry.fill(HIST("hPtFit"), p.Pt()); + registry.fill(HIST("hEta"), p.Eta()); + registry.fill(HIST("hRapidity"), p.Rapidity()); + registry.fill(HIST("hPhi"), p.Phi()); + registry.fill(HIST("hCharge"), tr1.sign()); + registry.fill(HIST("hCharge"), tr2.sign()); + + // store the event to save it into a tree + if (tr1.sign() > 0) { + dimuSel(p.M(), p.Pt(), p.Rapidity(), p.Phi(), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); + } else { + dimuSel(p.M(), p.Pt(), p.Rapidity(), p.Phi(), + p2.Pt(), p2.PseudoRapidity(), p2.Phi(), + p1.Pt(), p1.PseudoRapidity(), p1.Phi(), + zdc.timeA, zdc.enA, zdc.timeC, zdc.enC, znClass); + } + } + + // PROCESS FUNCTION + void process(CandidatesFwd const& eventCandidates, + o2::aod::UDZdcsReduced& ZDCs, + ForwardTracks const& fwdTracks) + { + + // map with the tracks + std::unordered_map> tracksPerCand; + collectCandIDs(tracksPerCand, fwdTracks); + + // map with the ZDC info + std::unordered_map zdcPerCand; + collectCandZDCInfo(zdcPerCand, ZDCs); + + // loop over the candidates + for (const auto& item : tracksPerCand) { + int32_t trId1 = item.second[0]; + int32_t trId2 = item.second[1]; + int32_t candID = item.first; + auto cand = eventCandidates.iteratorAt(candID); + auto tr1 = fwdTracks.iteratorAt(trId1); + auto tr2 = fwdTracks.iteratorAt(trId2); + + ZDCinfo zdc; + + if (zdcPerCand.count(candID) != 0) { + zdc = zdcPerCand.at(candID); + } else { + zdc.timeA = -999; + zdc.timeC = -999; + zdc.enA = -999; + zdc.enC = -999; + } + + processCand(cand, tr1, tr2, zdc); + } + } + + PROCESS_SWITCH(fwdMuonsUPC, process, "", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + }; +} diff --git a/PWGUD/Tasks/sgExclusivePhi.cxx b/PWGUD/Tasks/sgExclusivePhi.cxx index b9840c9b167..679d1677593 100644 --- a/PWGUD/Tasks/sgExclusivePhi.cxx +++ b/PWGUD/Tasks/sgExclusivePhi.cxx @@ -9,6 +9,7 @@ // 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" @@ -679,7 +680,7 @@ struct sgExclusivePhi { // auto ksize = allTracksAreITSonlyAndFourITSclusters.size(); registry.fill(HIST("hTracksITSonly"), allTracksAreITSonlyAndFourITSclusters.size()); - for (int kaon = 0; kaon < allTracksAreITSonlyAndFourITSclusters.size(); kaon++) { + for (std::size_t kaon = 0; kaon < allTracksAreITSonlyAndFourITSclusters.size(); kaon++) { int clusterSize[7]; double averageClusterSize = 0.; diff --git a/PWGUD/Tasks/sgExclusivePhiITSselections.cxx b/PWGUD/Tasks/sgExclusivePhiITSselections.cxx new file mode 100644 index 00000000000..76c56e609f5 --- /dev/null +++ b/PWGUD/Tasks/sgExclusivePhiITSselections.cxx @@ -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. +// +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "iostream" +#include "PWGUD/DataModel/UDTables.h" +#include +#include "TLorentzVector.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGUD/Core/SGSelector.h" + +using std::array; +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// \brief Exclusive phi without PID +/// \author Simone Ragoni, Creighton +/// \date 8/8/2024 + +struct sgExclusivePhiITSselections { + SGSelector sgSelector; + Configurable FV0_cut{"FV0", 100., "FV0A threshold"}; + Configurable FT0A_cut{"FT0A", 200., "FT0A threshold"}; + Configurable FT0C_cut{"FT0C", 100., "FT0C threshold"}; + Configurable ZDC_cut{"ZDC", 10., "ZDC threshold"}; + Configurable gap_Side{"gap", 2, "gap selection"}; + Configurable DGactive{"DGactive", false, "DG active"}; + Configurable SGactive{"SGactive", true, "SG active"}; + // Configurable DGorSG{"DGorSG", 1, "SG = 1, DG = 2"}; + Configurable NofITShits{"NofITShits", 7, "ITS layers hit"}; + Configurable pt_threshold{"pt_threshold", 0.180, "pT threshold"}; + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + //----------------------------------------------------------------------------------------------------------------------- + void init(o2::framework::InitContext&) + { + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{12, 0., 12.}}); + TString SelectionCuts[12] = {"NoSelection", "Trackloop", "PVtracks", "|nsigmaka|<3", "|nsigmapi|>3", "|nsigmael|>3", "|nsigmamu|>3", "two tracks", "Phi-peak", "pt<0.2 GeV/c", "pt>0.2 GeV/c"}; + + for (int i = 0; i < 12; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + + 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("posx", "Vertex position in x", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posy", "Vertex position in y", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posz", "Vertex position in z", kTH1F, {{1000, -100., 100.}}); + + registry.add("hTracks", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracksITSonly", "N_{tracks ITS only}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hITSCluster", "N_{cluster}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hChi2ITSTrkSegment", "N_{cluster}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTPCCluster", "N_{cluster}", kTH1F, {{200, -0.5, 199.5}}); + registry.add("hTracksKaons", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hdEdx", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon1", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon2", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon3", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon4", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon5", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon6", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon7", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon8", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + registry.add("hdEdxKaon9", "p_{#ka} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {1000, 0.0, 2000.0}}); + + registry.add("hNsigEvsKa2", "NSigmaKa(t1) vs NSigmaKa (t2);n#sigma_{1};n#sigma_{2}", kTH2F, {{100, 0., 1000.}, {100, 0., 1000}}); + registry.add("hMomentum", "p_{#ka};#it{p_{trk}}, GeV/c;", kTH1F, {{100, 0., 3.}}); + registry.add("hClusterSizeAllTracks", "ClusterSizeAllTracks;Average cls size in the ITS layers;", kTH1F, {{1000, 0., 100.}}); + registry.add("hClusterSizeMomentumCut", "ClusterSizeMomentumCut;Average cls size in the ITS layers;", kTH1F, {{1000, 0., 100.}}); + registry.add("hClusterSizeOnlyIdentifiedKaons", "ClusterSizeOnlyIdentifiedKaons;Average cls size in the ITS layers;", kTH1F, {{1000, 0., 100.}}); + registry.add("hClusterSizeOnlyITS", "ClusterSizeOnlyITS;Average cls size in the ITS layers;", kTH1F, {{1000, 0., 100.}}); + registry.add("hClusterSizeOnlyITS2", "ClusterSizeOnlyITS;Average cls size in the ITS layers;", kTH1F, {{1000, 0., 100.}}); + registry.add("hClusterSizeAllTracksVsP", "ClusterSizeAllTracks vs p; p; Average cls size in the ITS layers", kTH2F, {{100, 0.0, 10.0}, {1000, 0., 100.}}); + registry.add("hClusterSizeMomentumCutVsP", "hClusterSizeMomentumCut vs p; p; Average cls size in the ITS layers", kTH2F, {{100, 0.0, 10.0}, {1000, 0., 100.}}); + registry.add("hClusterSizeOnlyITSVsP", "hClusterSizeOnlyITS vs p; p; Average cls size in the ITS layers", kTH2F, {{100, 0.0, 10.0}, {1000, 0., 100.}}); + registry.add("hEta1", "#eta_{#ka};#it{#eta_{trk}}, GeV/c;", kTH1F, {{100, -2., 2.}}); + + auto hSelectionCounter2 = registry.add("hSelectionCounter2", "hSelectionCounter;;NEvents", HistType::kTH1I, {{12, 0., 12.}}); + TString SelectionCuts2[12] = {"NoSelection", "Trackloop", "PVtracks", "|nTPCCluster|<50", " track pt<0.180 GeV/c", "Kaon Band", "ITSCluster<6", "two tracks", "Phi-peak", "pt<0.2 GeV/c", "pt>0.2 GeV/c"}; + + for (int i = 0; i < 12; i++) { + hSelectionCounter2->GetXaxis()->SetBinLabel(i + 1, SelectionCuts2[i].Data()); + } + + registry.add("hMassPhiWithoutPID", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};", kTH1F, {{400, 0., 4.}}); + registry.add("hMassPtPhiWithoutPID", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};Pt;#it{p_{t}}, GeV/c;", kTH2F, {{400, 0., 4.}, {400, 0., 4.}}); + + // Phi peak region + registry.add("PHI/hPtPhiWithoutPID", "Pt;#it{p_{t}}, GeV/c;", kTH1F, {{500, 0., 5.}}); + registry.add("PHI/hMassVsPt", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};Pt;#it{p_{t}}, GeV/c;", kTH2F, {{400, 0., 4.}, {400, 0., 4.}}); + registry.add("PHI/hRapidityPhiWithoutPID", "Rapidity;#it{y_{KK}};", kTH1F, {{100, -2., 2.}}); + registry.add("PHI/hPtKaonVsKaon", "Pt1 vs Pt2;p_{T};p_{T};", kTH2F, {{100, 0., 3.}, {100, 0., 3.}}); + + // DIfferent phi topologies, 2 identified kaons, 1 identified kaon + 1 ITS track with correct selections and N ITS clusters + registry.add("KaonBandPHI/hMassPtPhiIdentifiedKaons", "Raw Inv.M;#it{m_{KK}} (GeV/c^{2});Pt;#it{p_{t}}, GeV/c;", kTH2F, {{400, 0., 4.}, {400, 0., 4.}}); + registry.add("KaonBandPHI/hMassPhiIdentifiedKaons", "Raw Inv.M;#it{M_{KK}} (GeV/c^{2});", kTH1F, {{400, 0., 4.}}); + registry.add("KaonBandPHI/hPtPhiIdentifiedKaons", "Pt;#it{p_{t}} (GeV/c);", kTH1F, {{400, 0., 4.}}); + registry.add("KaonBandPHI/hMassPtPhiIdentifiedKaonAndITSkaon", "Raw Inv.M;#it{m_{KK}} (GeV/c^{2});Pt;#it{p_{t}}, GeV/c;", kTH2F, {{400, 0., 4.}, {400, 0., 4.}}); + registry.add("KaonBandPHI/hMassPhiIdentifiedKaonAndITSkaon", "Raw Inv.M;#it{m_{KK}} (GeV/c^{2});", kTH1F, {{400, 0., 4.}}); + registry.add("KaonBandPHI/hPtPhiIdentifiedKaonAndITSkaon", "Pt;#it{p_{t}} (GeV/c);", kTH1F, {{400, 0., 4.}}); + + registry.add("PHI/hMassLike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{400, 0., 4.}}); + registry.add("PHI/hMassUnlike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{400, 0., 4.}}); + registry.add("PHI/hlikePt", "Pt;#it{p_{t}}, GeV/c;", kTH1F, {{500, 0., 5.}}); + registry.add("PHI/hUnlikePt", "Pt;#it{p_{t}}, GeV/c;", kTH1F, {{500, 0., 5.}}); + registry.add("PHI/hCoherentPhiWithoutPID", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};", kTH1F, {{400, 0., 4.}}); + registry.add("PHI/hInCoherentPhiWithoutPID", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};", kTH1F, {{400, 0., 4.}}); + registry.add("PHI/hCoherentMassLike", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};", kTH1F, {{400, 0., 4.}}); + registry.add("PHI/hInCoherentMassLike", "Raw Inv.M;#it{m_{KK}}, GeV/c^{2};", kTH1F, {{400, 0., 4.}}); + } + + using udtracks = soa::Join; + using udtracksfull = soa::Join; + using UDCollisionsFull = soa::Join; + //__________________________________________________________________________ + // Main process + void eventprocessing(int gapSide, udtracksfull const& tracks) + { + registry.fill(HIST("hSelectionCounter"), 0); + + if (gapSide == gap_Side) { + TLorentzVector phi, phiWithoutPID, phiWithKaonPID; // lorentz vectors of tracks and the mother + + // =================================== + // Task for phi WITHOUT PID + // =================================== + + // ==================================== + // Selections for events to be stored + // ------------------------------------ + // - PV: only PV contributors + // - only two PV contributors + // - both PV have t.hasITS() ON + // - only ITS tracks + //_____________________________________ + // Create kaons WITHOUT PID + std::vector onlyTwoTracks; + std::vector onlyKaonBandPID; + std::vector onlyITS; + std::vector allTracksAreKaons; + std::vector allTracksAreKaonsBandPID; + std::vector allTracksAreITSonlyAndFourITSclusters; + for (auto t : tracks) { + registry.fill(HIST("hSelectionCounter2"), 0); + if (!t.isPVContributor()) { + continue; + } + registry.fill(HIST("hSelectionCounter2"), 1); + registry.fill(HIST("hTracks"), t.size()); + + double momentum = TMath::Sqrt(t.px() * t.px() + t.py() * t.py() + t.pz() * t.pz()); + double dEdx = t.tpcSignal(); + + int clusterSize[7]; + double averageClusterSize = 0.; + double activeClusters = 0.; + for (int i = 0; i < 7; i++) { // info stored in 4 bits + clusterSize[i] = (((1 << 4) - 1) & (t.itsClusterSizes() >> 4 * i)); + auto clusterSizeValue = static_cast(clusterSize[i]); + if (clusterSizeValue != 0) { + averageClusterSize += clusterSizeValue; + activeClusters += 1; + } + averageClusterSize += static_cast(clusterSize[i]); + } + if (activeClusters != 0) { + averageClusterSize /= activeClusters; + } else { + averageClusterSize = -999.; + } + registry.fill(HIST("hClusterSizeAllTracks"), averageClusterSize); + registry.fill(HIST("hClusterSizeAllTracksVsP"), momentum, averageClusterSize); + + int NFindable = t.tpcNClsFindable(); + int NMinusFound = t.tpcNClsFindableMinusFound(); + int NCluster = NFindable - NMinusFound; + + if (NCluster > 50) { + continue; + } + registry.fill(HIST("hSelectionCounter2"), 3); + registry.fill(HIST("hdEdxKaon5"), t.tpcInnerParam() / t.sign(), dEdx); + + if (t.pt() > pt_threshold) { + continue; + } + if (!(std::abs(t.dcaZ()) < 2.)) { + continue; + } + double dcaLimit = 0.0105 + 0.035 / pow(t.pt(), 1.1); + if (!(std::abs(t.dcaXY()) < dcaLimit)) { + continue; + } + + registry.fill(HIST("hSelectionCounter2"), 4); + registry.fill(HIST("hMomentum"), momentum); + registry.fill(HIST("hdEdxKaon6"), t.tpcInnerParam() / t.sign(), dEdx); + registry.fill(HIST("hdEdxKaon2"), momentum, dEdx); + registry.fill(HIST("hClusterSizeMomentumCut"), averageClusterSize); + registry.fill(HIST("hClusterSizeMomentumCutVsP"), momentum, averageClusterSize); + + onlyTwoTracks.push_back(t); + + TLorentzVector a; + a.SetXYZM(t.px(), t.py(), t.pz(), o2::constants::physics::MassKaonCharged); + allTracksAreKaons.push_back(a); + + bool kaonBand = false; + if ((momentum < 0.150) && (dEdx > 300)) { + kaonBand = true; + } else if ((momentum > 0.150) && (momentum < 0.220) && (dEdx > 250)) { + kaonBand = true; + } else if ((momentum > 0.220) && (momentum < 0.300) && (dEdx > 180)) { + kaonBand = true; + } else if ((momentum > 0.300) && (momentum < 0.500) && (dEdx > 110)) { + kaonBand = true; + } + + if (kaonBand == true) { + registry.fill(HIST("hSelectionCounter2"), 5); + allTracksAreKaonsBandPID.push_back(a); + onlyKaonBandPID.push_back(t); + registry.fill(HIST("hdEdxKaon7"), t.tpcInnerParam() / t.sign(), dEdx); + registry.fill(HIST("hClusterSizeOnlyIdentifiedKaons"), averageClusterSize); + } + + if (NFindable < 1 && t.itsNCls() < NofITShits) { + allTracksAreITSonlyAndFourITSclusters.push_back(a); + onlyITS.push_back(t); + registry.fill(HIST("hdEdxKaon8"), t.tpcInnerParam() / t.sign(), dEdx); + registry.fill(HIST("hSelectionCounter2"), 6); + registry.fill(HIST("hClusterSizeOnlyITS2"), averageClusterSize); + } + + } // track loop + + //_____________________________________ + // Creating phis and saving all the information + // in the case that there are ONLY 2 PV + if (allTracksAreKaons.size() == 2) { + registry.fill(HIST("hSelectionCounter2"), 7); + for (auto kaon : allTracksAreKaons) { + phiWithoutPID += kaon; + } + registry.fill(HIST("hTracksKaons"), allTracksAreKaons.size()); + registry.fill(HIST("hNsigEvsKa2"), onlyTwoTracks[0].tpcSignal(), onlyTwoTracks[1].tpcSignal()); + registry.fill(HIST("hEta1"), allTracksAreKaons[0].Eta()); + registry.fill(HIST("hEta1"), allTracksAreKaons[1].Eta()); + + // All invariant mass region + registry.fill(HIST("hMassPhiWithoutPID"), phiWithoutPID.M()); + registry.fill(HIST("hMassPtPhiWithoutPID"), phiWithoutPID.M(), phiWithoutPID.Pt()); + + // Phi peak region + registry.fill(HIST("PHI/hMassVsPt"), phiWithoutPID.M(), phiWithoutPID.Pt()); + if ((phiWithoutPID.M() > 0.98) && (phiWithoutPID.M() < 1.05)) { + registry.fill(HIST("PHI/hPtPhiWithoutPID"), phiWithoutPID.Pt()); + registry.fill(HIST("PHI/hRapidityPhiWithoutPID"), phiWithoutPID.Rapidity()); + registry.fill(HIST("PHI/hPtKaonVsKaon"), allTracksAreKaons[0].Pt(), allTracksAreKaons[1].Pt()); + + // unlike-sign + if (onlyTwoTracks[0].sign() != onlyTwoTracks[1].sign()) { + registry.fill(HIST("hSelectionCounter2"), 8); + registry.fill(HIST("PHI/hUnlikePt"), phiWithoutPID.Pt()); + registry.fill(HIST("PHI/hMassUnlike"), phiWithoutPID.M()); + if (phiWithoutPID.Pt() < 0.1) { + registry.fill(HIST("hSelectionCounter2"), 9); + registry.fill(HIST("PHI/hCoherentPhiWithoutPID"), phiWithoutPID.M()); + } else { + registry.fill(HIST("hSelectionCounter2"), 10); + registry.fill(HIST("PHI/hInCoherentPhiWithoutPID"), phiWithoutPID.M()); + } + } else { + // Likesign quantities + registry.fill(HIST("PHI/hMassLike"), phiWithoutPID.M()); + registry.fill(HIST("PHI/hlikePt"), phiWithoutPID.Pt()); + if (phiWithoutPID.Pt() < 0.2) { + registry.fill(HIST("PHI/hCoherentMassLike"), phiWithoutPID.M()); + } else { + registry.fill(HIST("PHI/hInCoherentMassLike"), phiWithoutPID.M()); + } + } + } // Mass cut + } // end of two tracks only loop + + if (allTracksAreKaonsBandPID.size() == 2) { + registry.fill(HIST("hTracksKaons"), allTracksAreKaonsBandPID.size() + 10); + TLorentzVector reallyPhi; + for (auto kaon : allTracksAreKaonsBandPID) { + reallyPhi += kaon; + } + registry.fill(HIST("KaonBandPHI/hPtPhiIdentifiedKaons"), reallyPhi.Pt()); + registry.fill(HIST("KaonBandPHI/hMassPtPhiIdentifiedKaons"), reallyPhi.M(), reallyPhi.Pt()); + if (reallyPhi.Pt() < 0.2) { + registry.fill(HIST("KanonBandPHI/hMassPhiIdentifiedKaons"), reallyPhi.M()); + } + } + + if (allTracksAreKaonsBandPID.size() == 1 && allTracksAreITSonlyAndFourITSclusters.size() > 0) { + + registry.fill(HIST("hTracksKaons"), allTracksAreKaonsBandPID.size() + 20); + registry.fill(HIST("hTracksKaons"), allTracksAreITSonlyAndFourITSclusters.size() + 40); + + double momentum = TMath::Sqrt(onlyKaonBandPID[0].px() * onlyKaonBandPID[0].px() + onlyKaonBandPID[0].py() * onlyKaonBandPID[0].py() + onlyKaonBandPID[0].pz() * onlyKaonBandPID[0].pz()); + double dEdx = onlyKaonBandPID[0].tpcSignal(); + registry.fill(HIST("hdEdxKaon9"), momentum, dEdx); + registry.fill(HIST("hTracksITSonly"), allTracksAreITSonlyAndFourITSclusters.size()); + + for (std::size_t kaon = 0; kaon < allTracksAreITSonlyAndFourITSclusters.size(); kaon++) { + + int clusterSize[7]; + double averageClusterSize = 0.; + double activeClusters = 0.; + for (int i = 0; i < 7; i++) { // info stored in 4 bits + clusterSize[i] = (((1 << 4) - 1) & (onlyITS[kaon].itsClusterSizes() >> 4 * i)); + auto clusterSizeValue = static_cast(clusterSize[i]); + if (clusterSizeValue != 0) { + averageClusterSize += clusterSizeValue; + activeClusters += 1; + } + averageClusterSize += static_cast(clusterSize[i]); + } + if (activeClusters != 0) { + averageClusterSize /= activeClusters; + } else { + averageClusterSize = -999.; + } + registry.fill(HIST("hClusterSizeOnlyITS"), averageClusterSize); + registry.fill(HIST("hClusterSizeOnlyITSVsP"), momentum, averageClusterSize); + + TLorentzVector reallyPhi; + reallyPhi += allTracksAreKaonsBandPID[0]; + reallyPhi += allTracksAreITSonlyAndFourITSclusters[kaon]; + registry.fill(HIST("KaonBandPHI/hMassPtPhiIdentifiedKaonAndITSkaon"), reallyPhi.M(), reallyPhi.Pt()); + registry.fill(HIST("KaonBandPHI/hPtPhiIdentifiedKaonAndITSkaon"), reallyPhi.Pt()); + if (reallyPhi.Pt() < 0.2) { + registry.fill(HIST("KaonBandPHI/hMassPhiIdentifiedKaonAndITSkaon"), reallyPhi.M()); + } + } + } // Kaon Band + + } // double gap + } // end of process + + void processSG(UDCollisionsFull::iterator const& collision, udtracksfull const& tracks) + // process function subscribing to SG data + { + int gapSide = collision.gapSide(); + if (gapSide < 0 || gapSide > 2) + return; + + registry.fill(HIST("posx"), collision.posX()); + registry.fill(HIST("posy"), collision.posY()); + registry.fill(HIST("posz"), collision.posZ()); + int truegapSide = sgSelector.trueGap(collision, FV0_cut, FT0A_cut, FT0C_cut, ZDC_cut); + registry.fill(HIST("GapSide"), gapSide); + registry.fill(HIST("TrueGapSide"), truegapSide); + gapSide = truegapSide; + + eventprocessing(gapSide, tracks); + } + PROCESS_SWITCH(sgExclusivePhiITSselections, processSG, "Process SG data", SGactive); + + void processDG(aod::UDCollisions::iterator const& collision, udtracksfull const& tracks) + // process function subscribing to DG data + { + int gapSide = 2; + registry.fill(HIST("posx"), collision.posX()); + registry.fill(HIST("posy"), collision.posY()); + registry.fill(HIST("posz"), collision.posZ()); + registry.fill(HIST("GapSide"), gapSide); + eventprocessing(gapSide, tracks); + } + PROCESS_SWITCH(sgExclusivePhiITSselections, processDG, "Process DG data", DGactive); + +}; // end of struct + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/sgFITAnalyzer.cxx b/PWGUD/Tasks/sgFITAnalyzer.cxx index 7194937cf6e..73d42421b87 100644 --- a/PWGUD/Tasks/sgFITAnalyzer.cxx +++ b/PWGUD/Tasks/sgFITAnalyzer.cxx @@ -81,6 +81,7 @@ struct SGFITAnalyzer { void init(InitContext&) { const AxisSpec axispt{ptAxis, "p_{T}"}; + const AxisSpec axismeanpt{ptAxis, ""}; const AxisSpec axisBC{BCAxis, "BC"}; const AxisSpec axiseta{etaAxis, "#eta"}; const AxisSpec axismult{multAxis, "N_{tracks}"}; @@ -108,6 +109,12 @@ struct SGFITAnalyzer { registry.add("collisions/multiplicityZ1PVCAC", "Multiplicity of PV contributors AC-side; PV contributors; Tracks", {HistType::kTH1F, {{axismult}}}); registry.add("collisions/GapSide", "Gap Side: A, C, A+C", {HistType::kTH1F, {{3, -0.5, 2.5}}}); registry.add("collisions/TrueGapSide", "Gap Side: A, C, A+C", {HistType::kTH1F, {{4, -1.5, 2.5}}}); + registry.add("collisions/2D/multiplicityVsMeanPtPVCA", "Multiplicity of PV contributors A-side; PV contributors; mean #{p}_{T}", {HistType::kTH2F, {{axismult}, {axismeanpt}}}); + registry.add("collisions/2D/multiplicityVsEtaPVCA", "Multiplicity of PV contributors A-side; PV contributors; #eta", {HistType::kTH2F, {{axismult}, {axiseta}}}); + registry.add("collisions/2D/multiplicityVsMeanPtPVCC", "Multiplicity of PV contributors C-side; PV contributors; mean #{p}_{T}", {HistType::kTH2F, {{axismult}, {axismeanpt}}}); + registry.add("collisions/2D/multiplicityVsEtaPVCC", "Multiplicity of PV contributors C-side; PV contributors; #eta", {HistType::kTH2F, {{axismult}, {axiseta}}}); + registry.add("collisions/2D/multiplicityVsMeanPtPVCAC", "Multiplicity of PV contributors AC-side; PV contributors; mean #{p}_{T}", {HistType::kTH2F, {{axismult}, {axismeanpt}}}); + registry.add("collisions/2D/multiplicityVsEtaPVCAC", "Multiplicity of PV contributors AC-side; PV contributors; #eta", {HistType::kTH2F, {{axismult}, {axiseta}}}); // track histograms registry.add("tracks/QCAll", "Track QC of all tracks; Hit in detector; Tracks", {HistType::kTH1F, {{5, -0.5, 4.5}}}); @@ -418,8 +425,14 @@ struct SGFITAnalyzer { } } int pva = 0; + double avPtPVa = 0; + std::vector vecEtaPVa; int pvc = 0; + double avPtPVc = 0; + std::vector vecEtaPVc; int pvac = 0; + double avPtPVac = 0; + std::vector vecEtaPVac; int z0pva = 0; int z0pvc = 0; int z0pvac = 0; @@ -747,6 +760,9 @@ struct SGFITAnalyzer { registry.get(HIST("tracks/ptPVC"))->Fill(track.pt(), 1.); // registry.get(HIST("tracks/etavsptPVC"))->Fill(vtrk.Eta(), track.pt(), 1.); if (truegapSide == 0) { + pva++; + avPtPVa += track.pt(); + vecEtaPVa.push_back(vtrk.Eta()); registry.get(HIST("tracks/etaApv"))->Fill(vtrk.Eta(), 1.); if (!an) registry.get(HIST("tracks/eta2Apv"))->Fill(vtrk.Eta(), 1.); @@ -754,9 +770,11 @@ struct SGFITAnalyzer { z0pva++; else if (an == 4) z1pva++; - pva++; } if (truegapSide == 1) { + pvc++; + avPtPVc += track.pt(); + vecEtaPVc.push_back(vtrk.Eta()); registry.get(HIST("tracks/etaCpv"))->Fill(vtrk.Eta(), 1.); if (!cn) registry.get(HIST("tracks/eta2Cpv"))->Fill(vtrk.Eta(), 1.); @@ -764,9 +782,11 @@ struct SGFITAnalyzer { z0pvc++; else if (cn == 4) z1pvc++; - pvc++; } if (truegapSide == 2) { + pvac++; + avPtPVac += track.pt(); + vecEtaPVac.push_back(vtrk.Eta()); registry.get(HIST("tracks/etaACpv"))->Fill(vtrk.Eta(), 1.); if (!an && !cn) registry.get(HIST("tracks/eta2ACpv"))->Fill(vtrk.Eta(), 1.); @@ -774,18 +794,29 @@ struct SGFITAnalyzer { z0pvac++; else if (an >= 3 && cn >= 3) z1pvac++; - pvac++; } registry.get(HIST("tracks/TPCSignalvspPVC"))->Fill(vtrk.Mag(), signalTPC, 1.); registry.get(HIST("tracks/TOFSignalvspPVC"))->Fill(vtrk.Mag(), signalTOF, 1.); } } - if (pva) + if (pva) { registry.get(HIST("collisions/multiplicityPVCA"))->Fill(pva, 1.); - if (pvc) + registry.get(HIST("collisions/2D/multiplicityVsMeanPtPVCA"))->Fill(pva, avPtPVa / pva, 1.); + for (auto& element : vecEtaPVa) + registry.get(HIST("collisions/2D/multiplicityVsEtaPVCA"))->Fill(pva, element, 1.); + } + if (pvc) { registry.get(HIST("collisions/multiplicityPVCC"))->Fill(pvc, 1.); - if (pvac) + registry.get(HIST("collisions/2D/multiplicityVsMeanPtPVCC"))->Fill(pvc, avPtPVc / pvc, 1.); + for (auto& element : vecEtaPVc) + registry.get(HIST("collisions/2D/multiplicityVsEtaPVCC"))->Fill(pvc, element, 1.); + } + if (pvac) { registry.get(HIST("collisions/multiplicityPVCAC"))->Fill(pvac, 1.); + registry.get(HIST("collisions/2D/multiplicityVsMeanPtPVCAC"))->Fill(pvac, avPtPVac / pvac, 1.); + for (auto& element : vecEtaPVac) + registry.get(HIST("collisions/2D/multiplicityVsEtaPVCAC"))->Fill(pvac, element, 1.); + } if (pva) registry.get(HIST("collisions/multiplicityZ0PVCA"))->Fill(z0pva, 1.); if (pvc) diff --git a/PWGUD/Tasks/sgPIDAnalyzer.cxx b/PWGUD/Tasks/sgPIDAnalyzer.cxx new file mode 100644 index 00000000000..0d043f546af --- /dev/null +++ b/PWGUD/Tasks/sgPIDAnalyzer.cxx @@ -0,0 +1,220 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Sasha Bylinkin, alexander.bylinkin@gmail.com +// \since April 2023 + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" + +#include "TVector3.h" +#include "TTree.h" +#include "TFile.h" +#include +#include +#include "Common/DataModel/PIDResponse.h" +#include "PWGUD/DataModel/SGTables.h" +#include "PWGUD/Core/UDHelpers.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/SGTrackSelector.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct sgPIDAnalyzer { + HistogramRegistry histos{"Histos", {}}; + + ConfigurableAxis ptAxis{ + "ptAxis", + {200, 0.0, 10.0}, + "Pt binning"}; + + ConfigurableAxis sigmaAxis{"sigmaAxis", {1000, -20, 180}, "nSigma TPC binning"}; + ConfigurableAxis tofAxis{"tofAxis", {200, -10, 10}, "nSigma TOF binning"}; + Configurable eta_min{"eta_min", -0.9, "Track Pseudorapidity"}; + Configurable eta_max{"eta_max", 0.9, "Track Pseudorapidity"}; + + void init(InitContext&) + { + + const AxisSpec ptBins{ptAxis, "p_{T} axis"}; + const AxisSpec nSigmaBins{sigmaAxis, "pseudo rapidity axis"}; + const AxisSpec ntofBins{tofAxis, "pseudo rapidity axis"}; + histos.add("Events", "Selected Events", {HistType::kTH1F, {{3, -.5, 2.5}}}); + histos.add("TPC/pTPC_Pi", "Positive TPC Pi Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pi", "Negative TPC Pi Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Ka", "Positive TPC Ka Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Ka", "Negative TPC Ka Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pr", "Positive TPC Pr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pr", "Negative TPC Pr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_El", "Positive TPC El Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_El", "Negative TPC El Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_De", "Positive TPC De Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_De", "Negative TPC De Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Tr", "Positive TPC Tr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Tr", "Negative TPC Tr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_He", "Positive TPC He Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_He", "Negative TPC He Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Al", "Positive TPC Al Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Al", "Negative TPC Al Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Mu", "Positive TPC Mu Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Mu", "Negative TPC Mu Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); + + histos.add("TPC/pTPC_Pi_Ka", "Positive TPC Pi vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pi_Pr", "Positive TPC Pi vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pi_El", "Positive TPC Pi vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Ka_Pi", "Positive TPC Ka vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Ka_Pr", "Positive TPC Ka vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Ka_El", "Positive TPC Ka vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pr_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pr_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_Pr_El", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_El_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_El_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/pTPC_El_Pr", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + + histos.add("TPC/nTPC_Pi_Ka", "Positive TPC Pi vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pi_Pr", "Positive TPC Pi vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pi_El", "Positive TPC Pi vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Ka_Pi", "Positive TPC Ka vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Ka_Pr", "Positive TPC Ka vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Ka_El", "Positive TPC Ka vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pr_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pr_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_Pr_El", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_El_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_El_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); + histos.add("TPC/nTPC_El_Pr", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); + + histos.add("TOF/pPi", "Positive TPC Pi vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nPi", "Negative TPC Pi vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pKa", "Positive TPC Ka vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nKa", "Negative TPC Ka vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pPr", "Positive TPC Pr vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nPr", "Negative TPC Pr vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pEl", "Positive TPC El vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nEl", "Negative TPC El vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pDe", "Positive TPC De vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nDe", "Negative TPC De vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pTr", "Positive TPC Tr vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nTr", "Negative TPC Tr vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pHe", "Positive TPC He vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nHe", "Negative TPC He vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pAl", "Positive TPC Al vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nAl", "Negative TPC Al vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/pMu", "Positive TPC Mu vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + histos.add("TOF/nMu", "Negative TPC Mu vs TOF El vs pt", {HistType::kTH3F, {ptBins, ntofBins, ntofBins}}); + } + using SGEvent = aod::SGEvents::iterator; + void process(SGEvent const& event, aod::SGTracks const& tracks) + { + histos.fill(HIST("Events"), event.gs()); + for (const auto& track : tracks) { + if (track.eta() < eta_min || track.eta() > eta_max) + continue; + bool isPositive = (track.sign() > 0); + if (track.tofpi() == -999) { + // Directly fill histograms without a local variable for histName + if (isPositive) { + histos.fill(HIST("TPC/pTPC_Pi"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/pTPC_Ka"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/pTPC_Pr"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/pTPC_El"), track.pt(), track.tpcel()); + histos.fill(HIST("TPC/pTPC_De"), track.pt(), track.tpcde()); + histos.fill(HIST("TPC/pTPC_Tr"), track.pt(), track.tpctr()); + histos.fill(HIST("TPC/pTPC_He"), track.pt(), track.tpche()); + histos.fill(HIST("TPC/pTPC_Al"), track.pt(), track.tpcal()); + histos.fill(HIST("TPC/pTPC_Mu"), track.pt(), track.tpcmu()); + if (std::abs(track.tpcpi()) < 1) { + histos.fill(HIST("TPC/pTPC_Ka_Pi"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/pTPC_Pr_Pi"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/pTPC_El_Pi"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcka()) < 1) { + histos.fill(HIST("TPC/pTPC_Pi_Ka"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/pTPC_Pr_Ka"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/pTPC_El_Ka"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcpr()) < 1) { + histos.fill(HIST("TPC/pTPC_Pi_Pr"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/pTPC_Ka_Pr"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/pTPC_El_Pr"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcel()) < 1) { + histos.fill(HIST("TPC/pTPC_Pi_El"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/pTPC_Ka_El"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/pTPC_Pr_El"), track.pt(), track.tpcpr()); + } + } else { + histos.fill(HIST("TPC/nTPC_Pi"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/nTPC_Ka"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/nTPC_Pr"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/nTPC_El"), track.pt(), track.tpcel()); + histos.fill(HIST("TPC/nTPC_De"), track.pt(), track.tpcde()); + histos.fill(HIST("TPC/nTPC_Tr"), track.pt(), track.tpctr()); + histos.fill(HIST("TPC/nTPC_He"), track.pt(), track.tpche()); + histos.fill(HIST("TPC/nTPC_Al"), track.pt(), track.tpcal()); + histos.fill(HIST("TPC/nTPC_Mu"), track.pt(), track.tpcmu()); + if (std::abs(track.tpcpi()) < 1) { + histos.fill(HIST("TPC/nTPC_Ka_Pi"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/nTPC_Pr_Pi"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/nTPC_El_Pi"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcka()) < 1) { + histos.fill(HIST("TPC/nTPC_Pi_Ka"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/nTPC_Pr_Ka"), track.pt(), track.tpcpr()); + histos.fill(HIST("TPC/nTPC_El_Ka"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcpr()) < 1) { + histos.fill(HIST("TPC/nTPC_Pi_Pr"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/nTPC_Ka_Pr"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/nTPC_El_Pr"), track.pt(), track.tpcel()); + } + if (std::abs(track.tpcel()) < 1) { + histos.fill(HIST("TPC/nTPC_Pi_El"), track.pt(), track.tpcpi()); + histos.fill(HIST("TPC/nTPC_Ka_El"), track.pt(), track.tpcka()); + histos.fill(HIST("TPC/nTPC_Pr_El"), track.pt(), track.tpcpr()); + } + } + } else { + if (isPositive) { + histos.fill(HIST("TOF/pPi"), track.pt(), track.tpcpi(), track.tofpi()); + histos.fill(HIST("TOF/pKa"), track.pt(), track.tpcka(), track.tofka()); + histos.fill(HIST("TOF/pPr"), track.pt(), track.tpcpr(), track.tofpr()); + histos.fill(HIST("TOF/pEl"), track.pt(), track.tpcel(), track.tofel()); + histos.fill(HIST("TOF/pDe"), track.pt(), track.tpcpi(), track.tofde()); + histos.fill(HIST("TOF/pTr"), track.pt(), track.tpcka(), track.toftr()); + histos.fill(HIST("TOF/pHe"), track.pt(), track.tpcpr(), track.tofhe()); + histos.fill(HIST("TOF/pAl"), track.pt(), track.tpcel(), track.tofal()); + histos.fill(HIST("TOF/pMu"), track.pt(), track.tpcel(), track.tofmu()); + } else { + histos.fill(HIST("TOF/nPi"), track.pt(), track.tpcpi(), track.tofpi()); + histos.fill(HIST("TOF/nKa"), track.pt(), track.tpcka(), track.tofka()); + histos.fill(HIST("TOF/nPr"), track.pt(), track.tpcpr(), track.tofpr()); + histos.fill(HIST("TOF/nEl"), track.pt(), track.tpcel(), track.tofel()); + histos.fill(HIST("TOF/nDe"), track.pt(), track.tpcpi(), track.tofde()); + histos.fill(HIST("TOF/nTr"), track.pt(), track.tpcka(), track.toftr()); + histos.fill(HIST("TOF/nHe"), track.pt(), track.tpcpr(), track.tofhe()); + histos.fill(HIST("TOF/nAl"), track.pt(), track.tpcel(), track.tofal()); + histos.fill(HIST("TOF/nMu"), track.pt(), track.tpcel(), track.tofmu()); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"sgpidanalyzer"})}; +} diff --git a/PWGUD/Tasks/sgPIDSpectraTable.cxx b/PWGUD/Tasks/sgPIDSpectraTable.cxx new file mode 100644 index 00000000000..e5ad7187a34 --- /dev/null +++ b/PWGUD/Tasks/sgPIDSpectraTable.cxx @@ -0,0 +1,128 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Sasha Bylinkin, alexander.bylinkin@gmail.com +// \since April 2023 +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" + +#include "TVector3.h" +#include "TTree.h" +#include "TFile.h" +#include "Common/DataModel/PIDResponse.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/DataModel/SGTables.h" +#include "PWGUD/Core/UDHelpers.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/SGTrackSelector.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct SGPIDSpectraTable { + Produces SGevents; + Produces SGtracks; + SGSelector sgSelector; + + // configurables + Configurable FV0_cut{"FV0", 50., "FV0A threshold"}; + Configurable ZDC_cut{"ZDC", .1, "ZDC threshold"}; + Configurable FT0A_cut{"FT0A", 100., "FT0A threshold"}; + Configurable FT0C_cut{"FT0C", 50., "FT0C threshold"}; + Configurable FDDA_cut{"FDDA", 10000., "FDDA threshold"}; + Configurable FDDC_cut{"FDDC", 10000., "FDDC threshold"}; + Configurable GS_cut{"GS", 0., "Gap-side A=0, C=1, AC = 2, No Gap = -1, All events = 3"}; + // 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.1, "Track Pt"}; + // initialize histogram registry + HistogramRegistry registry{ + "registry", + {}}; + + void init(InitContext&) + { + // Collision histograms + } + + // define data types + using UDCollisionsFull = soa::Join; // UDCollisions + using UDCollisionFull = UDCollisionsFull::iterator; + using UDTracksFull = soa::Join; + + void process(UDCollisionFull const& coll, UDTracksFull const& tracks) + { + float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; + int truegapSide = sgSelector.trueGap(coll, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + if (GS_cut != 3) { + if (truegapSide != GS_cut) + return; + } + // fill collision histograms + // int truegapSide = sgSelector.trueGap(dgcand, FV0_cut, ZDC_cut); + // select PV contributors + std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + // check rho0 signals + float tpcpi, tpcka, tpcel, tpcpr, tofpi, tofka, tofpr, tofel; + float tpcde, tpctr, tpche, tpcal, tofde, toftr, tofhe, tofal, tpcmu, tofmu; + TVector3 a; + int goodtracks = 0; + for (auto t : tracks) { + if (trackselector(t, parameters)) { + goodtracks++; + } + } + if (!goodtracks) + return; + SGevents(coll.runNumber(), coll.flags(), truegapSide, coll.energyCommonZNA(), coll.energyCommonZNC(), goodtracks); + // SGevents(coll.runNumber(), coll.flags()); + for (auto t : tracks) { + if (trackselector(t, parameters)) { + a.SetXYZ(t.px(), t.py(), t.pz()); + tpcpi = t.hasTPC() ? t.tpcNSigmaPi() : -999; + tpcmu = t.hasTPC() ? t.tpcNSigmaMu() : -999; + tpcka = t.hasTPC() ? t.tpcNSigmaKa() : -999; + tpcpr = t.hasTPC() ? t.tpcNSigmaPr() : -999; + tpcel = t.hasTPC() ? t.tpcNSigmaEl() : -999; + tofpi = t.hasTOF() ? t.tofNSigmaPi() : -999; + tofmu = t.hasTOF() ? t.tofNSigmaMu() : -999; + tofka = t.hasTOF() ? t.tofNSigmaKa() : -999; + tofpr = t.hasTOF() ? t.tofNSigmaPr() : -999; + tofel = t.hasTOF() ? t.tofNSigmaEl() : -999; + tpcde = t.hasTPC() ? t.tpcNSigmaDe() : -999; + tpctr = t.hasTPC() ? t.tpcNSigmaTr() : -999; + tpche = t.hasTPC() ? t.tpcNSigmaHe() : -999; + tpcal = t.hasTPC() ? t.tpcNSigmaAl() : -999; + tofde = t.hasTOF() ? t.tofNSigmaDe() : -999; + toftr = t.hasTOF() ? t.tofNSigmaTr() : -999; + tofhe = t.hasTOF() ? t.tofNSigmaHe() : -999; + tofal = t.hasTOF() ? t.tofNSigmaAl() : -999; + SGtracks(SGevents.lastIndex(), a.Pt(), a.Eta(), a.Phi(), t.sign(), tpcpi, tpcka, tpcpr, tpcel, tofpi, tofka, tofpr, tofel, tpcmu, tofmu, tpcde, tpctr, tpche, tpcal, tofde, toftr, tofhe, tofal); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"sgpidspectratable"}), + }; +} diff --git a/PWGUD/Tasks/sgTwoPiAnalyzer.cxx b/PWGUD/Tasks/sgTwoPiAnalyzer.cxx index a9ff6b9e517..b7015745448 100644 --- a/PWGUD/Tasks/sgTwoPiAnalyzer.cxx +++ b/PWGUD/Tasks/sgTwoPiAnalyzer.cxx @@ -34,7 +34,25 @@ using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; +namespace o2::aod +{ +namespace rho +{ +DECLARE_SOA_COLUMN(Run, run, int32_t); +DECLARE_SOA_COLUMN(Flag, flag, int); +DECLARE_SOA_COLUMN(GS, gs, int); +DECLARE_SOA_COLUMN(ZNA, zna, float); +DECLARE_SOA_COLUMN(ZNC, znc, float); +DECLARE_SOA_COLUMN(Pt, pt, float); +DECLARE_SOA_COLUMN(Eta, eta, float); +DECLARE_SOA_COLUMN(Minv, minv, float); +DECLARE_SOA_COLUMN(Sign, sign, float); +} // namespace rho +DECLARE_SOA_TABLE(Rho, "AOD", "RHO", + rho::Run, rho::Flag, rho::GS, rho::ZNA, rho::ZNC, rho::Pt, rho::Eta, rho::Minv, rho::Sign); +} // namespace o2::aod struct SGTwoPiAnalyzer { + Produces rhoByRun; SGSelector sgSelector; Service pdg; Configurable FV0_cut{"FV0", 50., "FV0A threshold"}; @@ -129,7 +147,7 @@ struct SGTwoPiAnalyzer { } // Apply pion hypothesis and create pairs // Opposite sign pairs - + rhoByRun(collision.runNumber(), collision.flags(), gapSide, collision.energyCommonZNA(), collision.energyCommonZNC(), v01.Pt(), v01.Eta(), v01.M(), sign); if (sign == 0) { registry.fill(HIST("os_2Pi_pT"), v01.Pt()); registry.fill(HIST("os_2Pi_eTa"), v01.Eta()); diff --git a/PWGUD/Tasks/sginclusivePhiKstarSD.cxx b/PWGUD/Tasks/sginclusivePhiKstarSD.cxx index a7b9e859e10..90b692a9af3 100644 --- a/PWGUD/Tasks/sginclusivePhiKstarSD.cxx +++ b/PWGUD/Tasks/sginclusivePhiKstarSD.cxx @@ -16,13 +16,19 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include "iostream" +#include "Framework/ASoA.h" +#include "Framework/ASoAHelpers.h" #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/SGSelector.h" #include "PWGUD/Core/SGTrackSelector.h" #include "Common/DataModel/PIDResponse.h" #include #include "TLorentzVector.h" +#include +#include "Math/Vector4D.h" +#include "Math/Vector3D.h" +#include "Math/GenVector/Boost.h" + using namespace std; using namespace o2; using namespace o2::aod; @@ -71,33 +77,34 @@ struct SGResonanceAnalyzer { Configurable phi{"phi", true, ""}; Configurable rho{"rho", true, ""}; Configurable kstar{"kstar", true, ""}; + Configurable fourpion{"fourpion", true, ""}; void init(InitContext const&) { registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); if (phi) { - registry.add("os_KK_pT_0", "pt kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); - registry.add("os_KK_pT_1", "pt kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); - registry.add("os_KK_pT_2", "pt kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); - registry.add("os_KK_ls_pT_0", "kaon pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); - registry.add("os_KK_ls_pT_1", "kaon pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); - registry.add("os_KK_ls_pT_2", "kaon pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {220, 0.9, 1.12}}); + registry.add("os_KK_pT_0", "pt kaon pair", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_pT_1", "pt kaon pair", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_pT_2", "pt kaon pair", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_ls_pT_0", "kaon pair like sign", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_ls_pT_1", "kaon pair like sign", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_KK_ls_pT_2", "kaon pair like sign", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); } if (rho) { - registry.add("os_pp_pT_0", "pt pion pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); - registry.add("os_pp_pT_1", "pt pion pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); - registry.add("os_pp_pT_2", "pt pion pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); - registry.add("os_pp_ls_pT_0", "pion pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); - registry.add("os_pp_ls_pT_1", "pion pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); - registry.add("os_pp_ls_pT_2", "pion pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {350, 0.0, 3.5}}); + 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}}); } if (kstar) { - registry.add("os_pk_pT_0", "pion-kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); - registry.add("os_pk_pT_1", "pion-kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); - registry.add("os_pk_pT_2", "pion-kaon pair", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); - registry.add("os_pk_ls_pT_0", "pion-kaon pair like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); - registry.add("os_pk_ls_pT_1", "pion-kaon like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); - registry.add("os_pk_ls_pT_2", "pion-kaon like sign", kTH3F, {{100, 0.0, 10.0}, {80, -2.0, 2.0}, {400, 0.0, 2.0}}); + 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_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}}); } // QA plots if (QA) { @@ -131,15 +138,6 @@ struct SGResonanceAnalyzer { 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("mult_0_pt", "mult0_pt", kTH1F, {{150, 0, 150}}); - registry.add("mult_1_pt", "mult1_pt", kTH1F, {{150, 0, 150}}); - registry.add("mult_2_pt", "mult2_pt", kTH1F, {{150, 0, 150}}); - registry.add("mult_0_pt1", "mult0_pt1", kTH1F, {{150, 0, 150}}); - registry.add("mult_1_pt1", "mult1_pt1", kTH1F, {{150, 0, 150}}); - registry.add("mult_2_pt1", "mult2_pt1", kTH1F, {{150, 0, 150}}); - registry.add("mult_0_pt2", "mult0_pt2", kTH1F, {{150, 0, 150}}); - registry.add("mult_1_pt2", "mult1_pt2", kTH1F, {{150, 0, 150}}); - registry.add("mult_2_pt2", "mult2_pt2", kTH1F, {{150, 0, 150}}); 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}}); @@ -157,29 +155,125 @@ struct SGResonanceAnalyzer { registry.add("gap_mult2", "Mult 2", kTH1F, {{100, 0.0, 100.0}}); // Multiplicity plot if (rapidity_gap && phi) { - registry.add("os_kk_mass_rap", "phi mass", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass_rap1", "phi mass", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass_rap2", "phi mass", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass1_rap", "phi mass gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass1_rap1", "phi mass gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass1_rap2", "phi mass gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass2_rap", "phi mass DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass2_rap1", "phi mass DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kk_mass2_rap2", "phi mass DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass_rap", "phi mass1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass_rap1", "phi mass2", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass_rap2", "phi mass3", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass1_rap", "phi mass1 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass1_rap1", "phi mass2 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass1_rap2", "phi mass3 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass2_rap", "phi mass1 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass2_rap1", "phi mass2 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_mass2_rap2", "phi mass3 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + + // like sign bkg + registry.add("os_kk_ls_mass_rap", "phi ls mass1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass_rap1", "phi ls mass2", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass_rap2", "phi ls mass3", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass1_rap", "phi ls mass1 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass1_rap1", "phi ls mass2 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass1_rap2", "phi ls mass3 gap1", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass2_rap", "phi ls mass1 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass2_rap1", "phi ls mass2 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kk_ls_mass2_rap2", "phi ls mass3 DG", kTH3F, {{220, 0.98, 1.12}, {80, -2.0, 2.0}, {100, 0, 10}}); } if (rapidity_gap && kstar) { - registry.add("os_kp_mass_rap", "kstar mass", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass_rap1", "kstar mass", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass_rap2", "kstar mass", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass1_rap", "kstar mass gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass1_rap1", "kstar mass gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass1_rap2", "kstar mass gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass2_rap", "kstar mass DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass2_rap1", "kstar mass DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); - registry.add("os_kp_mass2_rap2", "kstar mass DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + 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}}); + registry.add("os_kp_mass1_rap", "kstar mass1 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_mass1_rap1", "kstar mass2 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_mass1_rap2", "kstar mass3 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_mass2_rap", "kstar mass1 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_mass2_rap1", "kstar mass2 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_mass2_rap2", "kstar mass3 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + + // like sign bkg + + registry.add("os_kp_ls_mass_rap", "kstar ls mass1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass_rap1", "kstar ls mass2", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass_rap2", "kstar ls mass3", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass1_rap", "kstar ls mass1 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass1_rap1", "kstar ls mass2 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass1_rap2", "kstar ls mass3 gap1", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass2_rap", "kstar ls mass1 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass2_rap1", "kstar ls mass2 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + registry.add("os_kp_ls_mass2_rap2", "kstar ls mass3 DG", kTH3F, {{400, 0.0, 2.0}, {80, -2.0, 2.0}, {100, 0, 10}}); + } + if (fourpion) { + registry.add("os_pppp_pT_2", "4 pion pair", kTH3F, {{800, 0.5, 4.5}, {250, 0.0, 5.0}, {30, -1.5, 1.5}}); + registry.add("os_pppp_pT_2_ls", "4 pion pair", kTH3F, {{800, 0.5, 4.5}, {250, 0.0, 5.0}, {30, -1.5, 1.5}}); + registry.add("os_pp_vs_pp_mass", "pair1 vd pair2 ", kTH2F, {{800, 0.5, 4.5}, {800, 0.5, 4.5}}); + registry.add("os_pp_vs_pp_pt", "pair1 pt vs pair2 pt", kTH2F, {{250, 0.0, 5.0}, {250, 0.0, 5.0}}); + registry.add("os_pp_vs_pp_mass1", "pair3 vd pair4 ", kTH2F, {{800, 0.5, 4.5}, {800, 0.5, 4.5}}); + registry.add("os_pp_vs_pp_pt1", "pair3 pt vs pair4 pt", kTH2F, {{250, 0.0, 5.0}, {250, 0.0, 5.0}}); + registry.add("phi_dis", "phi_dis", kTH1F, {{360, 0, 6.28}}); + registry.add("costheta_dis", "costheta_dis", kTH1F, {{40, -1.0, 1.0}}); + registry.add("costheta_vs_phi", "costheta_vs_phi", kTH2F, {{40, -1.0, 1.0}, {360, 0.0, 6.28}}); + registry.add("phi_dis1", "phi_dis1", kTH1F, {{360, 0, 6.28}}); + 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}}); } } + + //_____________________________________________________________________________ + Double_t CosThetaCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, + ROOT::Math::PtEtaPhiMVector pair2, + ROOT::Math::PtEtaPhiMVector fourpion) + { + 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 + + // TVector3 beta = (-1. / fourpion.E()) * fourpion.Vect(); + 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 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()}; + + // Axes + ROOT::Math::XYZVectorF zaxis_CS{((Beam1_CM.Unit() - Beam2_CM.Unit()).Unit())}; + + Double_t CosThetaCS = zaxis_CS.Dot((v1_CM)); + return CosThetaCS; + } + //------------------------------------------------------------------------------------------------------ + Double_t PhiCollinsSoperFrame(ROOT::Math::PtEtaPhiMVector pair1, ROOT::Math::PtEtaPhiMVector pair2, ROOT::Math::PtEtaPhiMVector 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; + // 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()}; + // 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()}; + + Double_t phi = TMath::ATan2(yaxis_CS.Dot(v1_CM), xaxis_CS.Dot(v1_CM)); + return phi; + } + using udtracks = soa::Join; using udtracksfull = soa::Join; using UDCollisionsFull = soa::Join; // @@ -190,6 +284,19 @@ struct SGResonanceAnalyzer { TLorentzVector v0; TLorentzVector v1; TLorentzVector v01; + TLorentzVector v0_1; + ROOT::Math::PtEtaPhiMVector phiv; + ROOT::Math::PtEtaPhiMVector phiv1; + + std::vector onlyPionTracks_p; + std::vector rawPionTracks_p; + + std::vector onlyPionTracks_pm; + std::vector rawPionTracks_pm; + + std::vector onlyPionTracks_n; + std::vector rawPionTracks_n; + 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}; @@ -214,7 +321,6 @@ struct SGResonanceAnalyzer { Int_t mult0 = 0; Int_t mult1 = 0; Int_t mult2 = 0; - Int_t mult_pt[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; Int_t trackgapA = 0; Int_t trackgapC = 0; Int_t trackDG = 0; @@ -224,41 +330,28 @@ struct SGResonanceAnalyzer { if (!trackselector(track1, parameters)) continue; v0.SetXYZM(track1.px(), track1.py(), track1.pz(), o2::constants::physics::MassPionCharged); - if (gapSide == 0) { - mult0++; - if (v0.Pt() < 1.0) { - mult_pt[0]++; + ROOT::Math::PtEtaPhiMVector vv1(v0.Pt(), v0.Eta(), v0.Phi(), o2::constants::physics::MassPionCharged); + if (selectionPIDPion(track1, use_tof, nsigmatpc_cut, nsigmatof_cut)) { + onlyPionTracks_pm.push_back(vv1); + rawPionTracks_pm.push_back(track1); + if (track1.sign() == 1) { + onlyPionTracks_p.push_back(vv1); + rawPionTracks_p.push_back(track1); } - if (v0.Pt() >= 1.0 && v0.Pt() < 3.0) { - mult_pt[1]++; - } - if (v0.Pt() >= 3.0) { - mult_pt[2]++; + if (track1.sign() == -1) { + onlyPionTracks_n.push_back(vv1); + rawPionTracks_n.push_back(track1); } } + + if (gapSide == 0) { + mult0++; + } if (gapSide == 1) { mult1++; - if (v0.Pt() < 1.0) { - mult_pt[3]++; - } - if (v0.Pt() >= 1.0 && v0.Pt() < 3.0) { - mult_pt[4]++; - } - if (v0.Pt() >= 3.0) { - mult_pt[5]++; - } } if (gapSide == 2) { mult2++; - if (v0.Pt() < 1.0) { - mult_pt[6]++; - } - if (v0.Pt() >= 1.0 && v0.Pt() < 3.0) { - mult_pt[7]++; - } - if (v0.Pt() >= 3.0) { - mult_pt[8]++; - } } if (TMath::Abs(v0.Eta()) < EtaDG) { trackDG++; @@ -306,9 +399,6 @@ struct SGResonanceAnalyzer { registry.fill(HIST("ZDC_A_0"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C_0"), collision.energyCommonZNC()); registry.fill(HIST("mult_0"), mult0); - registry.fill(HIST("mult_0_pt"), mult_pt[0]); - registry.fill(HIST("mult_1_pt"), mult_pt[1]); - registry.fill(HIST("mult_2_pt"), mult_pt[2]); } if (gapSide == 1) { registry.fill(HIST("V0A_1"), collision.totalFV0AmplitudeA()); @@ -317,9 +407,6 @@ struct SGResonanceAnalyzer { registry.fill(HIST("ZDC_A_1"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C_1"), collision.energyCommonZNC()); registry.fill(HIST("mult_1"), mult1); - registry.fill(HIST("mult_0_pt1"), mult_pt[3]); - registry.fill(HIST("mult_1_pt1"), mult_pt[4]); - registry.fill(HIST("mult_2_pt1"), mult_pt[5]); } if (gapSide == 2) { registry.fill(HIST("V0A"), collision.totalFV0AmplitudeA()); @@ -328,9 +415,6 @@ struct SGResonanceAnalyzer { registry.fill(HIST("ZDC_A"), collision.energyCommonZNA()); registry.fill(HIST("ZDC_C"), collision.energyCommonZNC()); registry.fill(HIST("mult_2"), mult2); - registry.fill(HIST("mult_0_pt2"), mult_pt[6]); - registry.fill(HIST("mult_1_pt2"), mult_pt[7]); - registry.fill(HIST("mult_2_pt2"), mult_pt[8]); } if (rapidity_gap) { if (trackgapC > 0 && trackgapA == 0 && trackextra == 0) { @@ -400,6 +484,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kk_mass2_rap"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kk_ls_mass_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kk_ls_mass1_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kk_ls_mass2_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } if (kstar && selectionPIDKaon(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t0.tpcNSigmaPi()) > 3.0 && selectionPIDPion(t1, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t1.tpcNSigmaKa()) > 3.0) { // Apply kaon hypothesis and create pairs @@ -418,6 +513,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kp_mass2_rap"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kp_ls_mass_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kp_ls_mass1_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kp_ls_mass2_rap"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } } } @@ -443,6 +549,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kk_mass2_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kk_ls_mass_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kk_ls_mass1_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kk_ls_mass2_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } if (kstar && selectionPIDKaon(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t0.tpcNSigmaPi()) > 3.0 && selectionPIDPion(t1, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t1.tpcNSigmaKa()) > 3.0) { // Apply kaon hypothesis and create pairs @@ -461,6 +578,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kp_mass2_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kp_ls_mass_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kp_ls_mass1_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kp_ls_mass2_rap1"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } } } @@ -485,6 +613,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kk_mass2_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kk_ls_mass_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kk_ls_mass1_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kk_ls_mass2_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } if (kstar && selectionPIDKaon(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t0.tpcNSigmaPi()) > 3.0 && selectionPIDPion(t1, use_tof, nsigmatpc_cut, nsigmatof_cut) && std::abs(t1.tpcNSigmaKa()) > 3.0) { // Apply kaon hypothesis and create pairs @@ -503,6 +642,17 @@ struct SGResonanceAnalyzer { registry.fill(HIST("os_kp_mass2_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); } } + if (t0.sign() == t1.sign()) { + if (gapSide == 0) { + registry.fill(HIST("os_kp_ls_mass_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 1) { + registry.fill(HIST("os_kp_ls_mass1_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + if (gapSide == 2) { + registry.fill(HIST("os_kp_ls_mass2_rap2"), v01.M(), v01.Rapidity(), v01.Pt()); + } + } } } } @@ -519,53 +669,53 @@ struct SGResonanceAnalyzer { // Opposite sign pairs if (t0.sign() != t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_KK_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_KK_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_KK_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } // samesignpair if (t0.sign() == t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_KK_ls_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_ls_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_KK_ls_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_KK_ls_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_KK_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } } - if (rho && selectionPIDPion(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && selectionPIDPion(t1, use_tof, nsigmatpc_cut, nsigmatof_cut)) { - v0.SetXYZM(t0.px(), t0.py(), t0.pz(), o2::constants::physics::MassPionCharged); + if (rho && selectionPIDProton(t0, use_tof, nsigmatpc_cut, nsigmatof_cut) && selectionPIDPion(t1, use_tof, nsigmatpc_cut, nsigmatof_cut)) { + v0.SetXYZM(t0.px(), t0.py(), t0.pz(), mproton); v1.SetXYZM(t1.px(), t1.py(), t1.pz(), o2::constants::physics::MassPionCharged); v01 = v0 + v1; // Opposite sign pairs if (t0.sign() != t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_pp_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_pp_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_pp_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } // same sign pair if (t0.sign() == t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_pp_ls_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_ls_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_pp_ls_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_pp_ls_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pp_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } } @@ -576,28 +726,70 @@ struct SGResonanceAnalyzer { // Opposite sign pairs if (t0.sign() != t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_pk_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_pk_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_pk_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } // same sign pair if (t0.sign() == t1.sign()) { if (gapSide == 0) { - registry.fill(HIST("os_pk_ls_pT_0"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_ls_pT_0"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 1) { - registry.fill(HIST("os_pk_ls_pT_1"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_ls_pT_1"), v01.M(), v01.Rapidity(), v01.Pt()); } if (gapSide == 2) { - registry.fill(HIST("os_pk_ls_pT_2"), v01.Pt(), v01.Rapidity(), v01.M()); + registry.fill(HIST("os_pk_ls_pT_2"), v01.M(), v01.Rapidity(), v01.Pt()); } } } } + 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); + phiv = k1 + k2 + k3 + k4; + pair1 = k1 + k3; + pair2 = k2 + k4; + pair3 = k1 + k4; + pair4 = k2 + k3; + 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); + 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); + 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) + 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); + phiv1 = l1 + l2 + l3 + l4; + registry.fill(HIST("os_pppp_pT_2_ls"), phiv1.M(), phiv1.Pt(), phiv1.Rapidity()); + } + } + } } }; diff --git a/PWGUD/Tasks/upcEventITSROFcounter.cxx b/PWGUD/Tasks/upcEventITSROFcounter.cxx new file mode 100644 index 00000000000..1da6fbfd26c --- /dev/null +++ b/PWGUD/Tasks/upcEventITSROFcounter.cxx @@ -0,0 +1,183 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "ITSMFTBase/DPLAlpideParam.h" +#include "CCDB/BasicCCDBManager.h" + +#include "Common/DataModel/EventSelection.h" + +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/SGSelector.h" + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using BCsWithRun3Matchings = soa::Join; +using CCs = soa::Join; +using FullSGUDCollision = soa::Join::iterator; + +struct UpcEventITSROFcounter { + Service ccdb; + SGSelector sgSelector; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + 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"}; + ConfigurableAxis axisRunNumbers{"axisRunNumbers", {1400, 544000.5, 545400.5}, "Range of run numbers"}; + + void init(InitContext&) + { + + histos.add("Events/hCountCollisionsExactMatching", ";;Number of collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}}); + histos.add("Events/hCountUPCcollisionsExactMatching", ";;Number of UPC (mult < 17) collision (-)", HistType::kTH1D, {{11, -0.5, 10.5}}); + 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("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}); + histos.add("Runs/hUpcModeCollSG1", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); + histos.add("Runs/hStdModeCollSG0", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); + histos.add("Runs/hUpcModeCollSG0", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); + histos.add("Runs/hStdModeCollNG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); + histos.add("Runs/hUpcModeCollNG", ";Run number;Number of events (-)", HistType::kTH1D, {axisRunNumbers}); + + } // end init + + void processCounterPerITSROF(BCsWithRun3Matchings const& bcs, CCs const& collisions) + { + int nAllColls = 0; + int nUPCcolls = 0; + uint16_t previousBCinITSROF = 0; + std::vector> vecITSROFborders; + bool isFirst = true; + uint16_t firstBCglobalIndex = 0; + uint16_t previousBCglobalIndex = 0; + + // extract ITS time frame parameters + int64_t ts = bcs.iteratorAt(0).timestamp(); + auto alppar = ccdb->getForTimeStamp>("ITS/Config/AlpideParam", ts); + + for (auto bc : bcs) { + uint64_t globalBC = bc.globalBC(); + uint64_t globalIndex = bc.globalIndex(); + if (isFirst) { + firstBCglobalIndex = globalIndex; + isFirst = false; + } + uint16_t bcInITSROF = (globalBC + o2::constants::lhc::LHCMaxBunches - alppar->roFrameBiasInBC) % alppar->roFrameLengthInBC; + + if (bcInITSROF - previousBCinITSROF < 0) { + histos.get(HIST("Events/hCountCollisionsExactMatching"))->Fill(nAllColls); + histos.get(HIST("Events/hCountUPCcollisionsExactMatching"))->Fill(nUPCcolls); + nAllColls = 0; + nUPCcolls = 0; + vecITSROFborders.push_back(std::make_pair(firstBCglobalIndex, previousBCglobalIndex)); + firstBCglobalIndex = globalIndex; + } + previousBCinITSROF = bcInITSROF; + previousBCglobalIndex = globalIndex; + // next is based on exact matching of bc and collision + for (auto& collision : collisions) { + if (collision.has_foundBC()) { + if (collision.foundBCId() == bc.globalIndex()) { + nAllColls++; + if (collision.numContrib() < nTracksForUPCevent + 1) { + nUPCcolls++; + } + } + } else if (collision.bcId() == bc.globalIndex()) { + nAllColls++; + if (collision.numContrib() < nTracksForUPCevent + 1) { + nUPCcolls++; + } + } + } // end loop over collisions + } // 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) { + int nAllCollsInROF = 0; + int nUpcCollsInROF = 0; + for (auto& collision : collisions) { + if ((itsrofBorder.first < collision.bcId()) && (collision.bcId() < itsrofBorder.second)) { + nAllCollsInROF++; + if (collision.numContrib() < nTracksForUPCevent + 1) { + nUpcCollsInROF++; + } + } + } // end loop over collisions + arrAllColls[nAllCollsInROF]++; + arrUPCcolls[nUpcCollsInROF]++; + } // end loop over ITSROFs + + for (int ncol = 0; ncol < 12; ncol++) { + histos.get(HIST("Events/hCountCollisionsInROFborderMatching"))->Fill(ncol, arrAllColls[ncol]); + histos.get(HIST("Events/hCountUPCcollisionsInROFborderMatching"))->Fill(ncol, arrUPCcolls[ncol]); + } + } + + void processCounterPerRun(FullSGUDCollision const& coll) + { + + int gapSide = coll.gapSide(); + int trueGapSide = sgSelector.trueGap(coll, cutMyGapSideFV0, cutMyGapSideFT0A, cutMyGapSideFT0C, cutMyGapSideZDC); + if (useTrueGap) { + gapSide = trueGapSide; + } + + if (coll.flags() == 0) { + if (gapSide == 2) { + histos.get(HIST("Runs/hStdModeCollDG"))->Fill(coll.runNumber()); + } else if (gapSide == 1) { + histos.get(HIST("Runs/hStdModeCollSG1"))->Fill(coll.runNumber()); + } else if (gapSide == 0) { + histos.get(HIST("Runs/hStdModeCollSG0"))->Fill(coll.runNumber()); + } else { + histos.get(HIST("Runs/hStdModeCollNG"))->Fill(coll.runNumber()); + } + } else { + if (gapSide == 2) { + histos.get(HIST("Runs/hUpcModeCollDG"))->Fill(coll.runNumber()); + } else if (gapSide == 1) { + histos.get(HIST("Runs/hUpcModeCollSG1"))->Fill(coll.runNumber()); + } else if (gapSide == 0) { + histos.get(HIST("Runs/hUpcModeCollSG0"))->Fill(coll.runNumber()); + } else { + histos.get(HIST("Runs/hUpcModeCollNG"))->Fill(coll.runNumber()); + } + } + } + + PROCESS_SWITCH(UpcEventITSROFcounter, processCounterPerITSROF, "Counts number of collisions per ITSROF", false); + PROCESS_SWITCH(UpcEventITSROFcounter, processCounterPerRun, "Counts number of whatever per RUN", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"upc-event-itsrof-counter"})}; +} diff --git a/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx b/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx index 3c461999f34..8464ead5f1e 100644 --- a/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx +++ b/PWGUD/Tasks/upcJpsiCentralBarrelCorr.cxx @@ -13,6 +13,8 @@ /// \author Sara Haidlova, sara.haidlova@cern.ch /// \since March 2024 +#include + // O2 headers #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" @@ -25,6 +27,7 @@ #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" @@ -34,46 +37,76 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace o2::constants::math; +SGSelector sgSelector; + struct UpcJpsiCentralBarrel { // configurable axes - ConfigurableAxis IVMAxis{"IVMAxis", {350.0f, 2.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; - ConfigurableAxis IVMAxisWide{"IVMAxisWide", {350.0f, 0.0f, 4.5f}, "M_#it{inv} (GeV/#it{c}^{2})"}; - ConfigurableAxis ptAxis{"ptAxis", {250.0f, 0.1f, 3.0f}, "#it{p}_T (GeV/#it{c})"}; - ConfigurableAxis pAxis{"pAxis", {250.0f, 0.1f, 3.0f}, "#it{p} (GeV/#it{c})"}; - ConfigurableAxis etaAxis{"etaAxis", {250.0f, -1.5f, 1.5f}, "#eta (-)"}; - ConfigurableAxis countAxis{"countAxis", {10.0f, 0.0f, 10.0f}, "Number of events (-)"}; - ConfigurableAxis phiAxis{"phiAxis", {250.0f, 0, TwoPI}, "#phi (rad)"}; - ConfigurableAxis accoplAxis{"accoplAxis", {250.0f, -0.2f, 0.2f}, "accAngle"}; - ConfigurableAxis thetaAxis{"thetaAxis", {250.0f, -1.5f, 1.5f}, "cos #theta (-)"}; - ConfigurableAxis sigTPCAxis{"sigTPCAxis", {100.0f, 0, 200.0f}, "TPC d#it{E}/d#it{x}"}; - ConfigurableAxis sigTOFAxis{"sigTOFAxis", {100.0f, 0, 200.0f}, "TOF d#it{E}/d#it{x}"}; - ConfigurableAxis betaTOFAxis{"betaTOFAxis", {100.0f, 0, 1.5}, "TOF #beta"}; - ConfigurableAxis sigmaAxis{"sigmaAxis", {20, -10, 10}, "#sigma"}; + 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 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 axisTOF{"axisTOF", {1000.0f, 0, 200.0f}, "TOF 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", {1000, 0.0, 100.0}, "Chi2"}; + ConfigurableAxis axisIVMSel{"axisIVMSel", {1000, 0.0, 10.0}, "IVM"}; + ConfigurableAxis axisCounterSel{"axisCounterSel", {1000, 0.0, 200.0}, "Selection"}; // configurable cuts (modify in json) + // track quality cuts Configurable TPCNClsCrossedRows{"TPCNClsCrossedRows", 70, "number of crossed rows in TPC"}; - Configurable TOFBothTracks{"TOFBothTracks", false, "both candidate tracks have TOF hits"}; - Configurable TOFAtLeastOneTrack{"TOFAtLeastOneTrack", false, "at least candidate tracks has TOF hits"}; - Configurable TOFOneTrack{"TOFOneTrack", false, "one candidate track has TOF hits"}; 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 TPCNsigmaCut{"TPCNsigmaCut", false, "cut on nSigma"}; - Configurable TPCPIDOnly{"TPCPIDOnly", false, "Only TPC PID"}; - Configurable smallestPID{"smallestPID", false, "Use smallest PID hypo."}; Configurable DCAcut{"DCAcut", false, "DCA cut from run2."}; + Configurable newCutTPC{"newCutTPC", false, "New cuts for TPC quality tracks."}; Configurable TPCNSigmaMu{"TPCNSigmaMu", 3, "PID for TPC Mu track"}; Configurable EtaCut{"EtaCut", 0.9f, "acceptance cut per track"}; - Configurable RapCut{"RapCut", 0.8f, "choose event in midrapidity"}; + 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", @@ -83,6 +116,10 @@ struct UpcJpsiCentralBarrel { "RawData", {}}; + HistogramRegistry Selections{ + "Selections", + {}}; + HistogramRegistry PVContributors{ "PVContributors", {}}; @@ -135,28 +172,15 @@ struct UpcJpsiCentralBarrel { "Asymmetry", {}}; - using UDCollisionsFull = soa::Join; + using UDCollisionsFull = soa::Join; using UDCollisionFull = UDCollisionsFull::iterator; using UDTracksFull = soa::Join; using UDTrackFull = UDTracksFull::iterator; + using SGUDCollisionFull = soa::Join::iterator; void init(InitContext&) { - const AxisSpec axisIVM{IVMAxis, "IVM axis"}; - const AxisSpec axisIVMWide{IVMAxisWide, "IVM axis wide"}; - const AxisSpec axispt{ptAxis, "pt axis"}; - const AxisSpec axiseta{etaAxis, "eta axis"}; - const AxisSpec axisCounter{countAxis, "counter axis"}; - const AxisSpec axisAccAngle{accoplAxis, "accAngle"}; - const AxisSpec axisAngTheta{thetaAxis, "cosTheta"}; - const AxisSpec axisPhi{phiAxis, "phi"}; - const AxisSpec axisp{pAxis, "p axis"}; - const AxisSpec axisTPC{sigTPCAxis, ""}; - const AxisSpec axisTOF{sigTOFAxis, ""}; - const AxisSpec axisBetaTOF{betaTOFAxis, ""}; - const AxisSpec axisSigma{sigmaAxis, ""}; - // statistics histograms for counters Statistics.add("Statistics/hNumberOfCollisions", "hNumberOfCollisions", {HistType::kTH1F, {axisCounter}}); Statistics.add("Statistics/hNumberOfTracks", "hNumberOfTracks", {HistType::kTH1F, {axisCounter}}); @@ -169,314 +193,581 @@ struct UpcJpsiCentralBarrel { Statistics.add("Statistics/hNumberGTmuSigma", "hNumberGTmuSigma", {HistType::kTH1F, {axisCounter}}); Statistics.add("Statistics/hNumberGTpSigma", "hNumberGTpSigma", {HistType::kTH1F, {axisCounter}}); Statistics.add("Statistics/hNumberGTpSigmaTOF", "hNumberGTpSigmaTOF", {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/hTrackPt", "hTrackPt", {HistType::kTH1F, {axisPt}}); + RawData.add("RawData/hTrackEta", "hTrackEta", {HistType::kTH1F, {axisEta}}); RawData.add("RawData/hTrackPhi", "hTrackPhi", {HistType::kTH1F, {axisPhi}}); - RawData.add("RawData/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - RawData.add("RawData/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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", "hITSNCls", {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/hZNATime", "hZNATime", {HistType::kTH1F, {axisZDCTime}}); + RawData.add("RawData/hZNCTime", "hZNCTime", {HistType::kTH1F, {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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - RawData.add("RawData/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - RawData.add("RawData/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + RawData.add("RawData/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + RawData.add("RawData/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + RawData.add("RawData/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + RawData.add("RawData/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); RawData.add("RawData/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - RawData.add("RawData/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + RawData.add("RawData/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); + + // Selection checks + Selections.add("Selections/Electron/Mass/Leading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Leading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Leading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Leading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Leading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Subleading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Subleading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Subleading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Subleading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Electron/Mass/Subleading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + + Selections.add("Selections/Electron/Rapidity/Leading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Leading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Leading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Leading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Leading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Subleading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Subleading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Subleading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Subleading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Electron/Rapidity/Subleading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + + Selections.add("Selections/Electron/Pt/Leading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Leading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Leading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Leading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Leading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Subleading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Subleading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Subleading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Subleading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Electron/Pt/Subleading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + + Selections.add("Selections/Muon/Mass/Leading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Leading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Leading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Leading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Leading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Subleading/hITSNClsVsM", "hITSNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Subleading/hITSChi2NClsVsM", "hITSChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Subleading/hTPCNClsVsM", "hTPCNClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Subleading/hTPCChi2NClsVsM", "hTPCChi2NClsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + Selections.add("Selections/Muon/Mass/Subleading/hTPCNClsCrossedRowsVsM", "hTPCNClsCrossedRowsVsM", {HistType::kTH2F, {axisIVMSel, axisCounterSel}}); + + Selections.add("Selections/Muon/Rapidity/Leading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Leading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Leading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Leading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Leading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Subleading/hITSNClsVsY", "hITSNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Subleading/hITSChi2NClsVsY", "hITSChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Subleading/hTPCNClsVsY", "hTPCNClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Subleading/hTPCChi2NClsVsY", "hTPCChi2NClsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + Selections.add("Selections/Muon/Rapidity/Subleading/hTPCNClsCrossedRowsVsY", "hTPCNClsCrossedRowsVsY", {HistType::kTH2F, {axisEta, axisCounterSel}}); + + Selections.add("Selections/Muon/Pt/Leading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Leading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Leading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Leading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Leading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Subleading/hITSNClsVsPt", "hITSNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Subleading/hITSChi2NClsVsPt", "hITSChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Subleading/hTPCNClsVsPt", "hTPCNClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Subleading/hTPCChi2NClsVsPt", "hTPCChi2NClsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); + Selections.add("Selections/Muon/Pt/Subleading/hTPCNClsCrossedRowsVsPt", "hTPCNClsCrossedRowsVsPt", {HistType::kTH2F, {axisPt, axisCounterSel}}); // PVContributors histograms - PVContributors.add("PVContributors/hTrackPt", "hTrackPt", {HistType::kTH1F, {axispt}}); - PVContributors.add("PVContributors/hTrackEta", "hTrackEta", {HistType::kTH1F, {axiseta}}); + 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/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - PVContributors.add("PVContributors/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - PVContributors.add("PVContributors/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - PVContributors.add("PVContributors/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + PVContributors.add("PVContributors/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + PVContributors.add("PVContributors/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + PVContributors.add("PVContributors/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + PVContributors.add("PVContributors/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); PVContributors.add("PVContributors/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - PVContributors.add("PVContributors/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + PVContributors.add("PVContributors/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TG histograms - TG.add("TG/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TG.add("TG/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TG.add("TG/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TG.add("TG/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); - TG.add("TG/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - TG.add("TG/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TG.add("TG/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TG.add("TG/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TG.add("TG/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TG.add("TG/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TG.add("TG/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TG.add("TG/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TG.add("TG/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TG.add("TG/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TG.add("TG/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); TG.add("TG/TPC/hNsigmaMu", "hNsigmaMu", HistType::kTH1F, {axisSigma}); TG.add("TG/TPC/hNsigmaEl", "hNsigmaEl", HistType::kTH1F, {axisSigma}); TG.add("TG/TPC/hNsigmaPr", "hNsigmaPr", HistType::kTH1F, {axisSigma}); - TG.add("TG/TPC/TPCPosSignal", "TPCPosSignal", HistType::kTH1F, {axisTPC}); - TG.add("TG/TPC/TPCNegSignal", "TPCNegSignal", HistType::kTH1F, {axisTPC}); + TG.add("TG/TPC/TPCNegVsPosSignal", "TPCNegVsPosSignal", HistType::kTH2F, {axisTPC, axisTPC}); TG.add("TG/TOF/hNsigmaMu", "hNsigmaMu", HistType::kTH1F, {axisSigma}); TG.add("TG/TOF/hNsigmaEl", "hNsigmaEl", HistType::kTH1F, {axisSigma}); TG.add("TG/TOF/hNsigmaPr", "hNsigmaPr", HistType::kTH1F, {axisSigma}); // TGmu histograms - TGmu.add("TGmu/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGmu.add("TGmu/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TGmu.add("TGmu/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TGmu.add("TGmu/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); TGmu.add("TGmu/hNsigmaMu", "hNsigmaMu", HistType::kTH1F, {axisSigma}); TGmu.add("TGmu/hNsigmaMuTOF", "hNsigmaMuTOF", HistType::kTH1F, {axisSigma}); - TGmu.add("TGmu/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - TGmu.add("TGmu/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGmu.add("TGmu/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGmu.add("TGmu/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGmu.add("TGmu/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGmu.add("TGmu/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGmu.add("TGmu/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGmu.add("TGmu/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGmu.add("TGmu/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGmu.add("TGmu/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGmu.add("TGmu/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TGmuCand histograms - TGmuCand.add("TGmuCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGmuCand.add("TGmuCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TGmuCand.add("TGmuCand/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TGmuCand.add("TGmuCand/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); TGmuCand.add("TGmuCand/hTrackITSNcls1", "hTrackITSNcls1", {HistType::kTH1F, {axisCounter}}); TGmuCand.add("TGmuCand/hTrackITSNcls2", "hTrackITSNcls2", {HistType::kTH1F, {axisCounter}}); - TGmuCand.add("TGmuCand/hPairPt", "hPairPt", {HistType::kTH1F, {axispt}}); + 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/hJpsiRap", "hJpsiRap", {HistType::kTH1F, {axiseta}}); - TGmuCand.add("TGmuCand/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - TGmuCand.add("TGmuCand/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + TGmuCand.add("TGmuCand/hJpsiPt", "hJpsiPt", {HistType::kTH1F, {axisPt}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGmuCand.add("TGmuCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGmuCand.add("TGmuCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGmuCand.add("TGmuCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGmuCand.add("TGmuCand/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGmuCand.add("TGmuCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGmuCand.add("TGmuCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGmuCand.add("TGmuCand/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGmuCand.add("TGmuCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGmuCand.add("TGmuCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TGel histograms - TGel.add("TGel/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGel.add("TGel/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TGel.add("TGel/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TGel.add("TGel/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); TGel.add("TGel/hNsigmaEl", "hNsigmaEl", HistType::kTH1F, {axisSigma}); TGel.add("TGel/hNsigmaElTOF", "hNsigmaElTOF", HistType::kTH1F, {axisSigma}); - TGel.add("TGel/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - TGel.add("TGel/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGel.add("TGel/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGel.add("TGel/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGel.add("TGel/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGel.add("TGel/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGel.add("TGel/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGel.add("TGel/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGel.add("TGel/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGel.add("TGel/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGel.add("TGel/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TGelCand histograms - TGelCand.add("TGelCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGelCand.add("TGelCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/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/hTrackITSNcls1", "hTrackITSNcls1", {HistType::kTH1F, {axisCounter}}); TGelCand.add("TGelCand/hTrackITSNcls2", "hTrackITSNcls2", {HistType::kTH1F, {axisCounter}}); - TGelCand.add("TGelCand/hPairPt", "hPairPt", {HistType::kTH1F, {axispt}}); + 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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGelCand.add("TGelCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGelCand.add("TGelCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGelCand.add("TGelCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGelCand.add("TGelCand/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGelCand.add("TGelCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGelCand.add("TGelCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGelCand.add("TGelCand/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGelCand.add("TGelCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGelCand.add("TGelCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TGp histograms - TGp.add("TGp/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGp.add("TGp/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TGp.add("TGp/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TGp.add("TGp/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); TGp.add("TGp/hNsigmaMu", "hNsigmaMu", HistType::kTH1F, {axisSigma}); TGp.add("TGp/hNsigmaMuTOF", "hNsigmaMuTOF", HistType::kTH1F, {axisSigma}); - TGp.add("TGp/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - TGp.add("TGp/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGp.add("TGp/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGp.add("TGp/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGp.add("TGp/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGp.add("TGp/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGp.add("TGp/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGp.add("TGp/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGp.add("TGp/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGp.add("TGp/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGp.add("TGp/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // TGpCand histograms - TGpCand.add("TGpCand/hTrackPt1", "hTrackPt1", {HistType::kTH1F, {axispt}}); - TGpCand.add("TGpCand/hTrackEta1", "hTrackEta1", {HistType::kTH1F, {axiseta}}); + 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/hTrackPt2", "hTrackPt2", {HistType::kTH1F, {axisPt}}); + TGpCand.add("TGpCand/hTrackEta2", "hTrackEta2", {HistType::kTH1F, {axisEta}}); TGpCand.add("TGpCand/hTrackPhi2", "hTrackPhi2", {HistType::kTH1F, {axisPhi}}); TGpCand.add("TGpCand/hTrackITSNcls1", "hTrackITSNcls1", {HistType::kTH1F, {axisCounter}}); TGpCand.add("TGpCand/hTrackITSNcls2", "hTrackITSNcls2", {HistType::kTH1F, {axisCounter}}); - TGpCand.add("TGpCand/hPairPt", "hPairPt", {HistType::kTH1F, {axispt}}); + 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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - TGpCand.add("TGpCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - TGpCand.add("TGpCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + TGpCand.add("TGpCand/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + TGpCand.add("TGpCand/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + TGpCand.add("TGpCand/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + TGpCand.add("TGpCand/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); TGpCand.add("TGpCand/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - TGpCand.add("TGpCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + TGpCand.add("TGpCand/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // 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/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/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/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToEl.add("JPsiToEl/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToEl.add("JPsiToEl/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToEl.add("JPsiToEl/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); - 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/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/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/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/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/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/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/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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToEl.add("JPsiToEl/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToEl.add("JPsiToEl/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToEl.add("JPsiToEl/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // 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/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/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/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToMu.add("JPsiToMu/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToMu.add("JPsiToMu/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToMu.add("JPsiToMu/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); - 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/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/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/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/PID/hTPCVsP", "hTPCVsP", {HistType::kTH2F, {axisp, axisTPC}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsPt", "hTPCVsPt", {HistType::kTH2F, {axispt, axisTPC}}); + 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/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/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/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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToMu.add("JPsiToMu/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToMu.add("JPsiToMu/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToMu.add("JPsiToMu/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // 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/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/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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToP.add("JPsiToP/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToP.add("JPsiToP/Coherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToP.add("JPsiToP/Coherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToP.add("JPsiToP/Coherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); - 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/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/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/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/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisp, axisTOF}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisp, axisBetaTOF}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axispt, axisTOF}}); + JPsiToP.add("JPsiToP/Incoherent/PID/hTPCVsEta", "hTPCVsEta", {HistType::kTH2F, {axisEta, axisTPC}}); + JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsP", "hTOFVsP", {HistType::kTH2F, {axisP, axisTOF}}); + JPsiToP.add("JPsiToP/Incoherent/PID/hBetaTOFVsP", "hBetaTOFVsP", {HistType::kTH2F, {axisP, axisBetaTOF}}); + JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsPt", "hTOFVsPt", {HistType::kTH2F, {axisPt, axisTOF}}); JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsPhi", "hTOFVsPhi", {HistType::kTH2F, {axisPhi, axisTOF}}); - JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axiseta, axisTOF}}); + JPsiToP.add("JPsiToP/Incoherent/PID/hTOFVsEta", "hTOFVsEta", {HistType::kTH2F, {axisEta, axisTOF}}); // Correlation histograms Correlation.add("Correlation/Muon/Coherent/AccoplAngle", "AccoplAngle", {HistType::kTH1F, {axisAccAngle}}); @@ -517,44 +808,73 @@ struct UpcJpsiCentralBarrel { template bool GoodTrackCuts(T const& track) { - // kinematics + // 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 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 (track.dcaZ() > dcaZCut) { + if (std::abs(track.dcaZ()) > dcaZCut) { return false; } if (DCAcut) { - float dcaXYCut = 0.0105f + 0.0350f / pow(track.pt(), 1.1f); - if (abs(track.dcaXY()) > dcaXYCut) { + float dcaXYPtCut = 0.0105f + 0.0350f / pow(track.pt(), 1.1f); + if (std::abs(track.dcaXY()) > dcaXYPtCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(4); return false; } } else { - if (track.dcaXY() > dcaXYCut) { + if (std::abs(track.dcaXY()) > dcaXYCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(4); return false; } } // ITS if (!track.hasITS()) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(5); return false; } if (track.itsNCls() < ITSNClsCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(6); return false; } if (track.itsChi2NCl() > ITSChi2NClsCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(7); return false; } // TPC if (!track.hasTPC()) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(8); return false; } if (track.tpcNClsCrossedRows() < TPCNClsCrossedRowsCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(9); return false; } if (track.tpcChi2NCl() > TPCChi2NCls) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(10); return false; // TPC chi2 } + if (newCutTPC) { + if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < TPCMinNCls) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(11); + return false; + } + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < TPCCrossedOverFindable) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(12); + return false; + } + } return true; } @@ -563,19 +883,57 @@ struct UpcJpsiCentralBarrel { bool CandidateCuts(float massJpsi, float rapJpsi) { if (std::abs(rapJpsi) > RapCut) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(13); return false; } if (massJpsi < 2.0f) { + Statistics.get(HIST("Statistics/hCutCounterTracks"))->Fill(14); return false; } return true; } - void process(UDCollisionFull const&, UDTracksFull const& tracks) + template + void fillHistograms(C collision, Ts tracks) { - Statistics.get(HIST("Statistics/hNumberOfCollisions"))->Fill(0); // number of collisions without any cuts + Statistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(0); // number of collisions without any cuts + 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/hZNCTime"))->Fill(collision.timeZNC()); + RawData.get(HIST("RawData/hZNATime"))->Fill(collision.timeZNA()); + + // 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) { @@ -584,6 +942,7 @@ struct UpcJpsiCentralBarrel { 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()); @@ -595,6 +954,8 @@ struct UpcJpsiCentralBarrel { 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()) { @@ -609,6 +970,13 @@ struct UpcJpsiCentralBarrel { 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()); @@ -627,67 +995,37 @@ struct UpcJpsiCentralBarrel { } int countGT = 0; - int countGTselected = 0; - int countGTel = 0; - int countGTmu = 0; - int countGTp = 0; int countGTMuSigma = 0; int countGTElSigma = 0; int countGTPSigma = 0; int countGTPSigmaTOF = 0; std::vector trkIdx; // loop over tracks with selections + if (std::abs(collision.posZ()) > cutVertexZ) { + Statistics.get(HIST("Statistics/hCutCounterCollisions"))->Fill(1); + return; + } + for (auto& track : tracks) { - // select primary vertex contributors - if (track.isPVContributor() != 1) { - continue; - } + // select good tracks if (GoodTrackCuts(track) != 1) { continue; } + countGT++; trkIdx.push_back(track.index()); - if (smallestPID) { - int hypoID; - if (TPCPIDOnly) { - hypoID = testPIDhypoTPC(track); - } else { - hypoID = testPIDhypo(track); - } - if (hypoID == P_ELECTRON || hypoID == P_MUON || hypoID == P_PROTON) { - countGTselected++; - trkIdx.push_back(track.index()); - if (hypoID == P_ELECTRON) { - countGTel++; - } - if (hypoID == P_MUON) { - countGTmu++; - } - if (hypoID == P_PROTON) { - countGTp++; - } - } - - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(3., countGTselected); - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(4., countGTel); - Statistics.get(HIST("Statistics/hNumberOfTracks"))->Fill(5., countGTmu); - Statistics.get(HIST("Statistics/hNumberGTselected"))->Fill(countGTselected); - Statistics.get(HIST("Statistics/hNumberGTel"))->Fill(countGTel); - Statistics.get(HIST("Statistics/hNumberGTmu"))->Fill(countGTmu); - Statistics.get(HIST("Statistics/hNumberGTp"))->Fill(countGTp); - } - if (std::abs(track.tpcNSigmaMu()) < 3) { + if (std::abs(track.tpcNSigmaMu()) <= 3) { countGTMuSigma++; } - if (std::abs(track.tpcNSigmaEl()) < 3) { + if (std::abs(track.tpcNSigmaEl()) <= 3) { countGTElSigma++; } - if (std::abs(track.tpcNSigmaPr()) < 3) { + if (std::abs(track.tpcNSigmaPr()) <= 3) { countGTPSigma++; } - if (std::abs(track.tofNSigmaPr()) < 3) { + if (std::abs(track.tofNSigmaPr()) <= 3) { countGTPSigmaTOF++; } } @@ -705,25 +1043,26 @@ struct UpcJpsiCentralBarrel { if (countGT == 2) { TLorentzVector mom, daughter[2]; - auto trkDaughter1 = tracks.iteratorAt(trkIdx[0]); auto trkDaughter2 = tracks.iteratorAt(trkIdx[1]); - if ((trkDaughter1.sign() * trkDaughter2.sign()) > 0) { + if ((trkDaughter1.sign() * trkDaughter2.sign()) != -1) { return; } - /*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];*/ + 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()}; - // std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + 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)); @@ -739,10 +1078,12 @@ struct UpcJpsiCentralBarrel { TG.get(HIST("TG/TPC/hNsigmaMu"))->Fill(trkDaughter1.tpcNSigmaMu()); TG.get(HIST("TG/TPC/hNsigmaEl"))->Fill(trkDaughter1.tpcNSigmaEl()); TG.get(HIST("TG/TPC/hNsigmaPr"))->Fill(trkDaughter1.tpcNSigmaPr()); - if (trkDaughter1.sign() > 0) { - TG.get(HIST("TG/TPC/TPCPosSignal"))->Fill(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/TPCNegSignal"))->Fill(trkDaughter1.tpcSignal()); + TG.get(HIST("TG/TPC/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); } } if (trkDaughter2.hasTPC()) { @@ -753,11 +1094,8 @@ struct UpcJpsiCentralBarrel { TG.get(HIST("TG/TPC/hNsigmaMu"))->Fill(trkDaughter2.tpcNSigmaMu()); TG.get(HIST("TG/TPC/hNsigmaEl"))->Fill(trkDaughter2.tpcNSigmaEl()); TG.get(HIST("TG/TPC/hNsigmaPr"))->Fill(trkDaughter2.tpcNSigmaPr()); - if (trkDaughter2.sign() > 0) { - TG.get(HIST("TG/TPC/TPCPosSignal"))->Fill(trkDaughter2.tpcSignal()); - } else { - TG.get(HIST("TG/TPC/TPCNegSignal"))->Fill(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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); @@ -778,653 +1116,961 @@ struct UpcJpsiCentralBarrel { TG.get(HIST("TG/TOF/hNsigmaEl"))->Fill(trkDaughter2.tofNSigmaEl()); TG.get(HIST("TG/TOF/hNsigmaPr"))->Fill(trkDaughter2.tofNSigmaPr()); } + 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()); + TGel.get(HIST("TGel/hNsigmaEl"))->Fill(trkDaughter1.tpcNSigmaEl()); + } + 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()); + TGel.get(HIST("TGel/hNsigmaEl"))->Fill(trkDaughter2.tpcNSigmaEl()); + if (trkDaughter1.sign() < 0) { + TGel.get(HIST("TGel/TPCNegVsPosSignal"))->Fill(trkDaughter1.tpcSignal(), trkDaughter2.tpcSignal()); + } else { + TGel.get(HIST("TGel/TPCNegVsPosSignal"))->Fill(trkDaughter2.tpcSignal(), trkDaughter1.tpcSignal()); + } + } + if (trkDaughter1.hasTOF()) { + TGel.get(HIST("TGel/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGel.get(HIST("TGel/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGel.get(HIST("TGel/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGel.get(HIST("TGel/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + TGel.get(HIST("TGel/hNsigmaElTOF"))->Fill(trkDaughter1.tofNSigmaEl()); + } + if (trkDaughter2.hasTOF()) { + TGel.get(HIST("TGel/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGel.get(HIST("TGel/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGel.get(HIST("TGel/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGel.get(HIST("TGel/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGel.get(HIST("TGel/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + TGel.get(HIST("TGel/hNsigmaElTOF"))->Fill(trkDaughter2.tofNSigmaEl()); + } - 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()}; - - if (TOFBothTracks) { - if (!trkDaughter1.hasTOF() || !trkDaughter2.hasTOF()) - return; - } - if (TOFOneTrack) { - if ((trkDaughter1.hasTOF() && trkDaughter2.hasTOF()) || (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF())) - return; - } - if (TOFAtLeastOneTrack) { - if (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF()) + if (CandidateCuts(massJpsi, rapJpsi) != 1) { return; - } - - auto arrMom = std::array{daughter1, daughter2}; - float massJpsi = RecoDecay::m(arrMom, std::array{massEl, massEl}); - float rapJpsi = RecoDecay::y(mother, massJpsi); - - 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)); - - 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()); - TGel.get(HIST("TGel/hNsigmaEl"))->Fill(trkDaughter1.tpcNSigmaEl()); - } - 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()); - TGel.get(HIST("TGel/hNsigmaEl"))->Fill(trkDaughter2.tpcNSigmaEl()); - } - if (trkDaughter1.hasTOF()) { - TGel.get(HIST("TGel/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGel.get(HIST("TGel/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGel.get(HIST("TGel/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGel.get(HIST("TGel/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - TGel.get(HIST("TGel/hNsigmaElTOF"))->Fill(trkDaughter1.tofNSigmaEl()); - } - if (trkDaughter2.hasTOF()) { - TGel.get(HIST("TGel/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGel.get(HIST("TGel/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGel.get(HIST("TGel/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGel.get(HIST("TGel/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGel.get(HIST("TGel/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - TGel.get(HIST("TGel/hNsigmaElTOF"))->Fill(trkDaughter2.tofNSigmaEl()); - } - - 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); - TGelCand.get(HIST("TGelCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); - 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 (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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - TGelCand.get(HIST("TGelCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGelCand.get(HIST("TGelCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } + } - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/hIVM"))->Fill(massJpsi); - } else { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/hIVM"))->Fill(massJpsi); - } + 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); + TGelCand.get(HIST("TGelCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + TGelCand.get(HIST("TGelCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGelCand.get(HIST("TGelCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } - if (massJpsi < maxJpsiMass && massJpsi > minJpsiMass) { - TGelCand.get(HIST("TGelCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); - TGelCand.get(HIST("TGelCand/hJpsiRap"))->Fill(rapJpsi); 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 (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()); - } + JPsiToEl.get(HIST("JPsiToEl/Coherent/hIVM"))->Fill(massJpsi); + } else { + JPsiToEl.get(HIST("JPsiToEl/Incoherent/hIVM"))->Fill(massJpsi); + } - if (trkDaughter1.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - // 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); - - 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); - - 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 (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 ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { + TGelCand.get(HIST("TGelCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); + TGelCand.get(HIST("TGelCand/hJpsiRap"))->Fill(rapJpsi); + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } + // 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); + + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } + // 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); + + 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()); + TGmu.get(HIST("TGmu/hNsigmaMu"))->Fill(trkDaughter1.tpcNSigmaMu()); + 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()); + TGmu.get(HIST("TGmu/hNsigmaMu"))->Fill(trkDaughter2.tpcNSigmaMu()); + } + if (trkDaughter1.hasTOF()) { + TGmu.get(HIST("TGmu/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGmu.get(HIST("TGmu/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGmu.get(HIST("TGmu/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGmu.get(HIST("TGmu/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + TGmu.get(HIST("TGmu/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaMu()); + } + if (trkDaughter2.hasTOF()) { + TGmu.get(HIST("TGmu/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGmu.get(HIST("TGmu/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGmu.get(HIST("TGmu/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGmu.get(HIST("TGmu/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGmu.get(HIST("TGmu/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + TGmu.get(HIST("TGmu/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaMu()); + } - if (trkDaughter1.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - JPsiToEl.get(HIST("JPsiToEl/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - // 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); - - 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); - - delete[] q; - } // end incoherent electrons - } // end mass cut - } // end electrons - 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()}; - if (TOFBothTracks) { - if (!trkDaughter1.hasTOF() || !trkDaughter2.hasTOF()) - return; - } - if (TOFOneTrack) { - if ((trkDaughter1.hasTOF() && trkDaughter2.hasTOF()) || (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF())) - return; - } - if (TOFAtLeastOneTrack) { - if (!trkDaughter1.hasTOF() && !trkDaughter2.hasTOF()) + if (CandidateCuts(massJpsi, rapJpsi) != 1) { return; - } - - auto arrMom = std::array{daughter1, daughter2}; - float massJpsi = RecoDecay::m(arrMom, std::array{massMu, massMu}); - float rapJpsi = RecoDecay::y(mother, massJpsi); - - 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)); - - 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()); - TGmu.get(HIST("TGmu/hNsigmaMu"))->Fill(trkDaughter1.tpcNSigmaMu()); - } - 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()); - TGmu.get(HIST("TGmu/hNsigmaMu"))->Fill(trkDaughter2.tpcNSigmaMu()); - } - if (trkDaughter1.hasTOF()) { - TGmu.get(HIST("TGmu/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGmu.get(HIST("TGmu/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGmu.get(HIST("TGmu/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGmu.get(HIST("TGmu/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - TGmu.get(HIST("TGmu/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaMu()); - } - if (trkDaughter2.hasTOF()) { - TGmu.get(HIST("TGmu/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGmu.get(HIST("TGmu/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGmu.get(HIST("TGmu/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGmu.get(HIST("TGmu/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGmu.get(HIST("TGmu/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - TGmu.get(HIST("TGmu/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaMu()); - } - - 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); - TGmuCand.get(HIST("TGmuCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); - 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/hIVM"))->Fill(massJpsi); - } else { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/hIVM"))->Fill(massJpsi); - } + } - if (massJpsi < maxJpsiMass && massJpsi > minJpsiMass) { - TGmuCand.get(HIST("TGmuCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); - TGmuCand.get(HIST("TGmuCand/hJpsiRap"))->Fill(rapJpsi); + 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); + TGmuCand.get(HIST("TGmuCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); + 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 (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 (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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGmuCand.get(HIST("TGmuCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } if (RecoDecay::pt(mother) < 0.2f) { - // fill track histos - 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 (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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - // 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); - - 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); - - delete[] q; + JPsiToMu.get(HIST("JPsiToMu/Coherent/hIVM"))->Fill(massJpsi); + } else { + JPsiToMu.get(HIST("JPsiToMu/Incoherent/hIVM"))->Fill(massJpsi); } - 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 (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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + + if ((massJpsi < maxJpsiMass) && (massJpsi > minJpsiMass)) { + TGmuCand.get(HIST("TGmuCand/hJpsiPt"))->Fill(RecoDecay::pt(mother)); + TGmuCand.get(HIST("TGmuCand/hJpsiRap"))->Fill(rapJpsi); + + if (RecoDecay::pt(mother) < 0.2f) { + // fill track histos + 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)); + } 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)); + } 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)); + } 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)); + } + + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } + // 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); + + delete[] q; } - if (trkDaughter2.hasTOF()) { - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); - JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tpcSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tpcSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tpcSignal()); + JPsiToMu.get(HIST("JPsiToMu/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tpcSignal()); + } + + // 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); + + delete[] q; } + } + } + } // end muons + if (doProtons) { + if (RecoDecay::sumOfSquares((trkDaughter1.hasTOF() ? trkDaughter1.tofNSigmaPr() : trkDaughter1.tpcNSigmaPr()), (trkDaughter2.hasTOF() ? trkDaughter2.tofNSigmaPr() : trkDaughter2.tpcNSigmaPr()) < 4)) { - // 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); + 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]; - 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]); + std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; - double dp = DeltaPhi(daughter[0], daughter[1]); - Asymmetry.get(HIST("Asymmetry/Muon/Incoherent/DeltaPhi"))->Fill(dp); + 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; + } - delete[] q; + 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()); + TGp.get(HIST("TGp/hNsigmaMu"))->Fill(trkDaughter1.tpcNSigmaPr()); + } + 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()); + TGp.get(HIST("TGp/hNsigmaMu"))->Fill(trkDaughter2.tpcNSigmaPr()); + } + if (trkDaughter1.hasTOF()) { + TGp.get(HIST("TGp/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGp.get(HIST("TGp/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGp.get(HIST("TGp/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGp.get(HIST("TGp/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + TGp.get(HIST("TGp/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaPr()); + } + if (trkDaughter2.hasTOF()) { + TGp.get(HIST("TGp/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGp.get(HIST("TGp/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGp.get(HIST("TGp/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGp.get(HIST("TGp/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGp.get(HIST("TGp/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + TGp.get(HIST("TGp/hNsigmaMuTOF"))->Fill(trkDaughter2.tofNSigmaPr()); } - } - } // end muons - 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]; + if (CandidateCuts(massJpsi, rapJpsi) != 1) { + return; + } - std::array mother = {trkDaughter1.px() + trkDaughter2.px(), trkDaughter1.py() + trkDaughter2.py(), trkDaughter1.pz() + trkDaughter2.pz()}; + 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); + TGpCand.get(HIST("TGpCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + TGpCand.get(HIST("TGpCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + TGpCand.get(HIST("TGpCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } - 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; - } + if (RecoDecay::pt(mother) < 0.2f) { + JPsiToP.get(HIST("JPsiToP/Coherent/hIVM"))->Fill(massJpsi); + } else { + JPsiToP.get(HIST("JPsiToP/Incoherent/hIVM"))->Fill(massJpsi); + } - 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()); - TGp.get(HIST("TGp/hNsigmaMu"))->Fill(trkDaughter1.tpcNSigmaPr()); - } - 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()); - TGp.get(HIST("TGp/hNsigmaMu"))->Fill(trkDaughter2.tpcNSigmaPr()); - } - if (trkDaughter1.hasTOF()) { - TGp.get(HIST("TGp/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGp.get(HIST("TGp/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGp.get(HIST("TGp/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGp.get(HIST("TGp/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - TGp.get(HIST("TGp/hNsigmaMuTOF"))->Fill(trkDaughter1.tofNSigmaPr()); - } - if (trkDaughter2.hasTOF()) { - TGp.get(HIST("TGp/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGp.get(HIST("TGp/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGp.get(HIST("TGp/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGp.get(HIST("TGp/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGp.get(HIST("TGp/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - TGp.get(HIST("TGp/hNsigmaMuTOF"))->Fill(trkDaughter2.tofNSigmaPr()); + 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } + // 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); + } + if (trkDaughter2.hasTOF()) { + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); + JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); + } + // 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 process - if (CandidateCuts(massJpsi, rapJpsi) != 1) { - return; - } + void processDGrecoLevel(UDCollisionFull const& collision, UDTracksFull const& tracks) + { + fillHistograms(collision, tracks); + } // end DG process - 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/hTrackITSNcls1"))->Fill(trkDaughter1.itsNCls()); - TGpCand.get(HIST("TGpCand/hTrackITSNcls2"))->Fill(trkDaughter2.itsNCls()); - 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - TGpCand.get(HIST("TGpCand/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - TGpCand.get(HIST("TGpCand/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } + 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); - if (RecoDecay::pt(mother) < 0.2f) { - JPsiToP.get(HIST("JPsiToP/Coherent/hIVM"))->Fill(massJpsi); - } else { - JPsiToP.get(HIST("JPsiToP/Incoherent/hIVM"))->Fill(massJpsi); - } + } // end SG process - 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Coherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - // 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/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter1.px(), trkDaughter1.py(), trkDaughter1.pz()), trkDaughter1.beta()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter1.pt(), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter1), trkDaughter1.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter1), trkDaughter1.tofSignal()); - } - if (trkDaughter2.hasTOF()) { - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hBetaTOFVsP"))->Fill(RecoDecay::sqrtSumOfSquares(trkDaughter2.px(), trkDaughter2.py(), trkDaughter2.pz()), trkDaughter2.beta()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPt"))->Fill(trkDaughter2.pt(), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsEta"))->Fill(RecoDecay::eta(daughter2), trkDaughter2.tofSignal()); - JPsiToP.get(HIST("JPsiToP/Incoherent/PID/hTOFVsPhi"))->Fill(RecoDecay::phi(daughter2), trkDaughter2.tofSignal()); - } - // 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 process -}; // end struct + PROCESS_SWITCH(UpcJpsiCentralBarrel, processDGrecoLevel, "Iterate over DG skimmed data.", true); + PROCESS_SWITCH(UpcJpsiCentralBarrel, processSGrecoLevel, "Iterate over SG skimmed data.", false); +}; // end struct WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { diff --git a/PWGUD/Tasks/upcPionAnalysis.cxx b/PWGUD/Tasks/upcPionAnalysis.cxx index ceabb9d20ae..2d5d35cd564 100644 --- a/PWGUD/Tasks/upcPionAnalysis.cxx +++ b/PWGUD/Tasks/upcPionAnalysis.cxx @@ -9,7 +9,7 @@ // 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" @@ -42,6 +42,10 @@ struct UPCPionAnalysis { Configurable ZDC_cut{"ZDC", 10., "ZDC threshold"}; Configurable gap_Side{"gap", 2, "gap selection"}; + // Collision selection + Configurable collcontrib_cut{"collcontrib_cut", 10, "no. of PV contributor per collsion"}; + Configurable Zvtx_cut{"Zvtx_cut", 15, "z-vertex selection"}; + // Track Selections Configurable PV_cut{"PV_cut", 1.0, "Use Only PV tracks"}; Configurable dcaZ_cut{"dcaZ_cut", 2.0, "dcaZ cut"}; @@ -55,6 +59,7 @@ struct UPCPionAnalysis { // Kinmatic cuts Configurable PID_cut{"PID_cut", 5, "TPC PID"}; + Configurable Rap_cut{"Rap_cut", 0.9, "Track rapidity"}; Configurable Mass_Max{"Mass_Max", 10, "Invariant Mass range high"}; Configurable Mass_Min{"Mass_Min", 0, "Invariant Mass range low"}; Configurable Pt_coherent{"Pt_coherent", 0.15, "Coherent selection"}; @@ -62,7 +67,7 @@ struct UPCPionAnalysis { // defining histograms using histogram registry HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; - //_____________________________________________________________________________ + //_____________________________________________________________________________________________ Double_t CosThetaHelicityFrame(TLorentzVector pionPositive, TLorentzVector pionNegative, TLorentzVector possibleRhoZero) @@ -295,12 +300,16 @@ struct UPCPionAnalysis { registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); - auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{10, 0., 10.}}); + registry.add("posx", "Vertex position in x", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posy", "Vertex position in y", kTH1F, {{100, -0.5, 0.5}}); + registry.add("posz", "Vertex position in z", kTH1F, {{1000, -100., 100.}}); - TString SelectionCuts[7] = {"NoSelection", "2pioncandidates", "tpcNClsCrossedRows", "opposite_charge", "|nsigmapi|<3", "nsigmael", "track_momenta>0.3GeV/c"}; + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{20, 0., 20.}}); + + TString SelectionCuts[18] = {"NoSelection", "gapside", "goodtracks", "truegap", "ncollcontrib ", "zvtx", "2collcontrib", "2goodtrk", "TPCPID", "Rap_cut", "unlikesign", "mass_cut", "coherent", "incoherent", "likesign", "mass_cut", "coherent", "incoherent"}; // now we can set BinLabel in histogram Registry - for (int i = 0; i < 7; i++) { + for (int i = 0; i < 18; i++) { hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); } // tracks @@ -337,12 +346,12 @@ struct UPCPionAnalysis { registry.add("TwoPion/hP2", "P vs TPC signal;#it{P_{track}}, GeV/c; signal_{TPC} t1", kTH2F, {{100, 0., 2.}, {300, 0, 150}}); registry.add("TwoPion/hTPCsig1", "TPC signal;signal_{TPC} t2; signal_{TPC} t2", kTH2F, {{300, 0., 150.}, {300, 0, 150}}); - registry.add("TwoPion/hMassLike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); - registry.add("TwoPion/hMassUnlike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); - registry.add("TwoPion/Coherent/hMassUnlikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); - registry.add("TwoPion/Coherent/hMassLikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); - registry.add("TwoPion/Incoherent/hMassUnlikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); - registry.add("TwoPion/Incoherent/hMassLikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{1000, 0., 20.}}); + registry.add("TwoPion/hMassLike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/hMassUnlike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Coherent/hMassUnlikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Coherent/hMassLikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Incoherent/hMassUnlikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Incoherent/hMassLikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); registry.add("hMassFourPionsCoherent", "Raw Inv.M;#it{M_{#pi#pi}} (GeV/c^{2});", kTH1D, {{1000, 0., 10.}}); registry.add("hMassSixPionsCoherent", "Raw Inv.M;#it{M_{6#pi}} (GeV/c^{2});", kTH1D, {{1000, 0., 10.}}); registry.add("hMassEightPionsCoherent", "Raw Inv.M;#it{M_{6#pi}} (GeV/c^{2});", kTH1D, {{1000, 0., 10.}}); @@ -396,7 +405,7 @@ struct UPCPionAnalysis { registry.add("hCostheta6Pion", "Costheta;#it{Cos#Theta};", kTH1F, {{300, -1.5, 1.5}}); registry.add("hCostheta8Pion", "Costheta;#it{Cos#Theta};", kTH1F, {{300, -1.5, 1.5}}); - // using Angular Correlation method + // Using Angular Correlation method registry.add("TwoPion/Coherent/AccoplAngle", "AccoplAngle", kTH1F, {{250, -0.2, 0.2}}); registry.add("TwoPion/Coherent/CosTheta", "CosTheta", kTH1F, {{300, -1.5, 1.5}}); @@ -418,7 +427,7 @@ struct UPCPionAnalysis { } using udtracks = soa::Join; - using udtracksfull = soa::Join; + using udtracksfull = soa::Join; using UDCollisionsFull = soa::Join; //__________________________________________________________________________ // Main process @@ -430,15 +439,21 @@ struct UPCPionAnalysis { if (gapSide < 0 || gapSide > 2) return; + registry.fill(HIST("hSelectionCounter"), 1); + float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; // int truegapSide = sgSelector.trueGap(collision, FV0_cut, ZDC_cut); int truegapSide = sgSelector.trueGap(collision, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + registry.fill(HIST("hSelectionCounter"), 2); + registry.fill(HIST("GapSide"), gapSide); registry.fill(HIST("TrueGapSide"), truegapSide); gapSide = truegapSide; if (gapSide == gap_Side) { + + registry.fill(HIST("hSelectionCounter"), 3); //_____________________________________ // Create pions and apply TPC Pion PID std::vector allTracks; @@ -452,30 +467,32 @@ struct UPCPionAnalysis { TLorentzVector p; registry.fill(HIST("hTracks"), tracks.size()); - // if(collision.numContrib() > 10) return; + if (collision.numContrib() > collcontrib_cut) + return; + + registry.fill(HIST("hSelectionCounter"), 4); + if ((collision.posZ() < -(Zvtx_cut)) || (collision.posZ() > Zvtx_cut)) + return; + registry.fill(HIST("hSelectionCounter"), 5); for (auto t : tracks) { - if (!t.isPVContributor()) { - continue; - } - int NFindable = t.tpcNClsFindable(); - int NMinusFound = t.tpcNClsFindableMinusFound(); - int NCluster = NFindable - NMinusFound; + /*if (!t.isPVContributor()) { + continue; + }*/ - if (NCluster < TPC_cluster) { + if (!trackselector(t, parameters)) continue; - } - double dEdx = t.tpcSignal(); + // int NFindable = t.tpcNClsFindable(); + // int NMinusFound = t.tpcNClsFindableMinusFound(); + // int NCluster = NFindable - NMinusFound; - /*if (TMath::Abs(eta(t.px(), t.py(), t.pz()) > 0.9)) { - continue; - } + /*if (NCluster < TPC_cluster) { + continue; + }*/ - if (t.pt() < 0.15) { - continue; - }*/ + double dEdx = t.tpcSignal(); registry.fill(HIST("hdEdx"), t.tpcInnerParam() / t.sign(), dEdx); TLorentzVector a; @@ -544,27 +561,28 @@ struct UPCPionAnalysis { auto phihel = 1. * TMath::Pi() + PhiHelicityFrame(piplus, piminus, p); registry.fill(HIST("hPhi4Pion"), phihel); - if (p.Rapidity() > -0.9 && p.Rapidity() < 0.9) { - if (sign != 0) { - registry.fill(HIST("hMassFourPions"), p.M()); - registry.fill(HIST("hPt4Pion"), p.Pt()); - // LOGF(info, "pt eta phi sign %f %f %f %f", p.Pt(), p.Eta(), p.Phi(), sign); - } - - if (sign == 0) { - registry.fill(HIST("hCharge"), sign); - registry.fill(HIST("h4TracksPions"), onlyPionTracks.size()); - if (p.Pt() < Pt_coherent) { - registry.fill(HIST("hMassFourPionsCoherent"), p.M()); + if ((p.Rapidity() > -Rap_cut) && (p.Rapidity() < Rap_cut)) { + if ((p.M() > 0.8) && (p.M() < 2.5)) { + if (sign != 0) { + registry.fill(HIST("hMassFourPions"), p.M()); + registry.fill(HIST("hPt4Pion"), p.Pt()); } - // if ((p.M() > 0.8) && (p.M() < 2.5)) { - registry.fill(HIST("hPt4PionRightSign"), p.Pt()); - // } - registry.fill(HIST("hMassFourPionsRightSign"), p.M()); - registry.fill(HIST("hMPt1"), p.M(), p.Pt()); - registry.fill(HIST("hRap4Pion"), p.Rapidity()); - registry.fill(HIST("hEta4Pion"), p.Eta()); + if (sign == 0) { + registry.fill(HIST("hCharge"), sign); + registry.fill(HIST("h4TracksPions"), onlyPionTracks.size()); + + if (p.Pt() < Pt_coherent) { + registry.fill(HIST("hMassFourPionsCoherent"), p.M()); + } + + registry.fill(HIST("hPt4PionRightSign"), p.Pt()); + + registry.fill(HIST("hMassFourPionsRightSign"), p.M()); + registry.fill(HIST("hMPt1"), p.M(), p.Pt()); + registry.fill(HIST("hRap4Pion"), p.Rapidity()); + registry.fill(HIST("hEta4Pion"), p.Eta()); + } for (auto pion : onlyPionTracks) { registry.fill(HIST("hPhiEtaFourPionsRightSign"), pion.Phi(), pion.Eta()); } @@ -572,7 +590,7 @@ struct UPCPionAnalysis { } } } - //_____________________________________ + //_____________________________________________________________________________________________________ // Six pions analysis if (collision.numContrib() == 6) { if ((rawPionTracks.size() == 6) && (onlyPionTracks.size() == 6)) { @@ -604,7 +622,7 @@ struct UPCPionAnalysis { auto phihel = 1. * TMath::Pi() + PhiHelicityFrame(piplus, piminus, p); registry.fill(HIST("hPhi6Pion"), phihel); - if (p.Rapidity() > -0.9 && p.Rapidity() < 0.9) { + if ((p.Rapidity() > -Rap_cut) && (p.Rapidity() < Rap_cut)) { if (sign != 0) { registry.fill(HIST("hMassSixPions"), p.M()); registry.fill(HIST("hPt6Pion"), p.Pt()); @@ -663,7 +681,7 @@ struct UPCPionAnalysis { auto phihel = 1. * TMath::Pi() + PhiHelicityFrame(piplus, piminus, p); registry.fill(HIST("hPhi8Pion"), phihel); - if (p.Rapidity() > -0.9 && p.Rapidity() < 0.9) { + if ((p.Rapidity() > -Rap_cut) && (p.Rapidity() < Rap_cut)) { if (sign != 0) { registry.fill(HIST("hMassEightPions"), p.M()); registry.fill(HIST("hPt8Pion"), p.Pt()); @@ -688,115 +706,137 @@ struct UPCPionAnalysis { //_____________________________________ // CUTS if (collision.numContrib() == 2) { - if (onlyPionTracks.size() != 2) { - return; - } - registry.fill(HIST("TwoPion/h2TracksPions"), onlyPionTracks.size()); + registry.fill(HIST("hSelectionCounter"), 6); - if ((onlyPionSigma[0] * onlyPionSigma[0] + onlyPionSigma[1] * onlyPionSigma[1]) > (PID_cut * PID_cut)) { - return; - } + if ((rawPionTracks.size() == 2) && (onlyPionTracks.size() == 2)) { + registry.fill(HIST("hSelectionCounter"), 7); - /*if (onlyPionTracks[0].P() < 0.3 || onlyPionTracks[1].P() < 0.3) { - return; - }*/ - if (p.Rapidity() < -0.9 || p.Rapidity() > 0.9) { - return; - } + registry.fill(HIST("TwoPion/h2TracksPions"), onlyPionTracks.size()); + registry.fill(HIST("TwoPion/hNsigPivsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigPivsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hTPCsig"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); + registry.fill(HIST("TwoPion/hNsigPi1vsPi2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); - // Quality Control - registry.fill(HIST("TwoPion/hEta_t1"), onlyPionTracks[0].Eta()); - registry.fill(HIST("TwoPion/hEta_t2"), onlyPionTracks[1].Eta()); - - registry.fill(HIST("TwoPion/hNsigPi1vsPi2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); - registry.fill(HIST("TwoPion/hNsigEl1vsEl2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); - registry.fill(HIST("TwoPion/hNsigPivsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaPi()); - registry.fill(HIST("TwoPion/hNsigPivsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaPi()); - registry.fill(HIST("TwoPion/hNsigElvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaEl()); - registry.fill(HIST("TwoPion/hNsigElvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaEl()); - - registry.fill(HIST("TwoPion/hNsigMuvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaMu()); - registry.fill(HIST("TwoPion/hNsigMuvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaMu()); - - registry.fill(HIST("TwoPion/hPtsingle_track1"), onlyPionTracks[0].Pt()); - registry.fill(HIST("TwoPion/hPtsingle_track2"), onlyPionTracks[1].Pt()); - registry.fill(HIST("TwoPion/hP1"), onlyPionTracks[0].P(), rawPionTracks[0].tpcSignal()); - registry.fill(HIST("TwoPion/hTPCsig"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); - registry.fill(HIST("TwoPion/hP2"), onlyPionTracks[1].P(), rawPionTracks[1].tpcSignal()); - registry.fill(HIST("TwoPion/hTPCsig1"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); - - if (rawPionTracks[0].sign() == rawPionTracks[1].sign()) { - registry.fill(HIST("TwoPion/hMassLike"), p.M()); - registry.fill(HIST("TwoPion/hPtLike"), p.Pt()); - if (p.Pt() < Pt_coherent) { - registry.fill(HIST("TwoPion/Coherent/hMassLikeCoherent"), p.M()); + if ((onlyPionSigma[0] * onlyPionSigma[0] + onlyPionSigma[1] * onlyPionSigma[1]) > (PID_cut * PID_cut)) { + return; } - if (p.Pt() > Pt_coherent) { - registry.fill(HIST("TwoPion/Incoherent/hMassLikeInCoherent"), p.M()); + registry.fill(HIST("hSelectionCounter"), 8); + if ((p.Rapidity() < -Rap_cut) || (p.Rapidity() > Rap_cut)) { + return; } - } + registry.fill(HIST("hSelectionCounter"), 9); - TLorentzVector tplus, tminus; - if (rawPionTracks[0].sign() > 0) { - tplus = onlyPionTracks[0]; - } else { - tminus = onlyPionTracks[0]; - } - if (rawPionTracks[1].sign() < 0) { - tminus = onlyPionTracks[1]; - } else { - tplus = onlyPionTracks[1]; - } + TLorentzVector tplus, tminus; + if (rawPionTracks[0].sign() > 0) { + tplus = onlyPionTracks[0]; + } else { + tminus = onlyPionTracks[0]; + } + if (rawPionTracks[1].sign() < 0) { + tminus = onlyPionTracks[1]; + } else { + tplus = onlyPionTracks[1]; + } + + auto costheta = CosThetaHelicityFrame(tplus, tminus, p); + auto phihel = 1. * TMath::Pi() + PhiHelicityFrame(tplus, tminus, p); + + // Unlike sign + if (rawPionTracks[0].sign() != rawPionTracks[1].sign()) { + + registry.fill(HIST("hSelectionCounter"), 10); + registry.fill(HIST("TwoPion/hMassUnlike"), p.M()); + + if ((p.M() > Mass_Min) && (p.M() < Mass_Max)) { + + registry.fill(HIST("hSelectionCounter"), 11); + + registry.fill(HIST("TwoPion/hPt"), p.Pt()); + registry.fill(HIST("TwoPion/hEta"), p.Eta()); + registry.fill(HIST("TwoPion/hRap"), p.Rapidity()); + registry.fill(HIST("TwoPion/hPhiSystem"), p.Phi()); + registry.fill(HIST("TwoPion/hMPt"), p.M(), p.Pt()); - auto costheta = CosThetaHelicityFrame(tplus, tminus, p); - // registry.fill(HIST("hCostheta"), costheta); - auto phihel = 1. * TMath::Pi() + PhiHelicityFrame(tplus, tminus, p); - // registry.fill(HIST("hPhi"), phihel); - - if (rawPionTracks[0].sign() != rawPionTracks[1].sign()) { - registry.fill(HIST("TwoPion/hMassUnlike"), p.M()); - - registry.fill(HIST("TwoPion/hPt"), p.Pt()); - registry.fill(HIST("TwoPion/hEta"), p.Eta()); - registry.fill(HIST("TwoPion/hRap"), p.Rapidity()); - registry.fill(HIST("TwoPion/hPhiSystem"), p.Phi()); - registry.fill(HIST("TwoPion/hMPt"), p.M(), p.Pt()); - - if ((p.M() > Mass_Min) && (p.M() < Mass_Max)) { - if (p.Pt() < Pt_coherent) { - registry.fill(HIST("TwoPion/Coherent/hCostheta"), costheta); - registry.fill(HIST("TwoPion/Coherent/hPhi"), phihel); - registry.fill(HIST("TwoPion/Coherent/hMassUnlikeCoherent"), p.M()); - - // angular correlations - float* q = AngCorrelation(&onlyPionTracks[0], &onlyPionTracks[1], &p); - registry.fill(HIST("TwoPion/Coherent/Phi"), q[1], 1.); - registry.fill(HIST("TwoPion/Coherent/Phi1"), RecoDecay::phi(onlyPionTracks[0]), 1.); - registry.fill(HIST("TwoPion/Coherent/Phi2"), RecoDecay::phi(onlyPionTracks[1]), 1.); - registry.fill(HIST("TwoPion/Coherent/CosTheta"), q[2], 1.); - registry.fill(HIST("TwoPion/Coherent/CosThetaPhi"), q[2], q[1]); - registry.fill(HIST("TwoPion/Coherent/AccoplAngle"), q[0], 1.); - - double delphi = DeltaPhi(onlyPionTracks[0], onlyPionTracks[1]); - registry.fill(HIST("TwoPion/Coherent/DeltaPhi"), delphi); + if (p.Pt() < Pt_coherent) { + + registry.fill(HIST("hSelectionCounter"), 12); + + // Quality Control + registry.fill(HIST("TwoPion/hEta_t1"), onlyPionTracks[0].Eta()); + registry.fill(HIST("TwoPion/hEta_t2"), onlyPionTracks[1].Eta()); + registry.fill(HIST("TwoPion/hPtsingle_track1"), onlyPionTracks[0].Pt()); + registry.fill(HIST("TwoPion/hPtsingle_track2"), onlyPionTracks[1].Pt()); + + registry.fill(HIST("TwoPion/hNsigMuvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigMuvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigElvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaEl()); + registry.fill(HIST("TwoPion/hNsigElvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaEl()); + registry.fill(HIST("TwoPion/hNsigEl1vsEl2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); + + registry.fill(HIST("TwoPion/hP1"), onlyPionTracks[0].P(), rawPionTracks[0].tpcSignal()); + registry.fill(HIST("TwoPion/hP2"), onlyPionTracks[1].P(), rawPionTracks[1].tpcSignal()); + registry.fill(HIST("TwoPion/hTPCsig1"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); + + registry.fill(HIST("posx"), collision.posX()); + registry.fill(HIST("posy"), collision.posY()); + registry.fill(HIST("posz"), collision.posZ()); + + registry.fill(HIST("TwoPion/Coherent/hCostheta"), costheta); + registry.fill(HIST("TwoPion/Coherent/hPhi"), phihel); + registry.fill(HIST("TwoPion/Coherent/hMassUnlikeCoherent"), p.M()); + + // angular correlations + float* q = AngCorrelation(&onlyPionTracks[0], &onlyPionTracks[1], &p); + registry.fill(HIST("TwoPion/Coherent/Phi"), q[1], 1.); + registry.fill(HIST("TwoPion/Coherent/Phi1"), RecoDecay::phi(onlyPionTracks[0]), 1.); + registry.fill(HIST("TwoPion/Coherent/Phi2"), RecoDecay::phi(onlyPionTracks[1]), 1.); + registry.fill(HIST("TwoPion/Coherent/CosTheta"), q[2], 1.); + registry.fill(HIST("TwoPion/Coherent/CosThetaPhi"), q[2], q[1]); + registry.fill(HIST("TwoPion/Coherent/AccoplAngle"), q[0], 1.); + + double delphi = DeltaPhi(onlyPionTracks[0], onlyPionTracks[1]); + registry.fill(HIST("TwoPion/Coherent/DeltaPhi"), delphi); + } + + if (p.Pt() > Pt_coherent) { + + registry.fill(HIST("hSelectionCounter"), 13); + + registry.fill(HIST("TwoPion/Incoherent/hCosthetaInCoherent"), costheta); + registry.fill(HIST("TwoPion/Incoherent/hPhiInCoherent"), phihel); + registry.fill(HIST("TwoPion/Incoherent/hMassUnlikeInCoherent"), p.M()); + + // angular correlations + float* q = AngCorrelation(&onlyPionTracks[0], &onlyPionTracks[1], &p); + registry.fill(HIST("TwoPion/Incoherent/Phi"), q[1], 1.); + registry.fill(HIST("TwoPion/Incoherent/Phi1"), RecoDecay::phi(onlyPionTracks[0]), 1.); + registry.fill(HIST("TwoPion/Incoherent/Phi2"), RecoDecay::phi(onlyPionTracks[1]), 1.); + registry.fill(HIST("TwoPion/Incoherent/CosTheta"), q[2], 1.); + registry.fill(HIST("TwoPion/Incoherent/CosThetaPhi"), q[2], q[1]); + registry.fill(HIST("TwoPion/Incoherent/AccoplAngle"), q[0], 1.); + + double delphi = DeltaPhi(onlyPionTracks[0], onlyPionTracks[1]); + registry.fill(HIST("TwoPion/Incoherent/DeltaPhi"), delphi); + } } + } + + // Like sign + if (rawPionTracks[0].sign() == rawPionTracks[1].sign()) { - if (p.Pt() > Pt_coherent) { - registry.fill(HIST("TwoPion/Incoherent/hCosthetaInCoherent"), costheta); - registry.fill(HIST("TwoPion/Incoherent/hPhiInCoherent"), phihel); - registry.fill(HIST("TwoPion/Incoherent/hMassUnlikeInCoherent"), p.M()); - - // angular correlations - float* q = AngCorrelation(&onlyPionTracks[0], &onlyPionTracks[1], &p); - registry.fill(HIST("TwoPion/Incoherent/Phi"), q[1], 1.); - registry.fill(HIST("TwoPion/Incoherent/Phi1"), RecoDecay::phi(onlyPionTracks[0]), 1.); - registry.fill(HIST("TwoPion/Incoherent/Phi2"), RecoDecay::phi(onlyPionTracks[1]), 1.); - registry.fill(HIST("TwoPion/Incoherent/CosTheta"), q[2], 1.); - registry.fill(HIST("TwoPion/Incoherent/CosThetaPhi"), q[2], q[1]); - registry.fill(HIST("TwoPion/Incoherent/AccoplAngle"), q[0], 1.); - - double delphi = DeltaPhi(onlyPionTracks[0], onlyPionTracks[1]); - registry.fill(HIST("TwoPion/Incoherent/DeltaPhi"), delphi); + registry.fill(HIST("hSelectionCounter"), 14); + registry.fill(HIST("TwoPion/hMassLike"), p.M()); + if ((p.M() > Mass_Min) && (p.M() < Mass_Max)) { + registry.fill(HIST("hSelectionCounter"), 15); + registry.fill(HIST("TwoPion/hPtLike"), p.Pt()); + if (p.Pt() < Pt_coherent) { + registry.fill(HIST("hSelectionCounter"), 16); + registry.fill(HIST("TwoPion/Coherent/hMassLikeCoherent"), p.M()); + } + if (p.Pt() > Pt_coherent) { + registry.fill(HIST("hSelectionCounter"), 17); + registry.fill(HIST("TwoPion/Incoherent/hMassLikeInCoherent"), p.M()); + } } } } diff --git a/PWGUD/Tasks/upcRhoAnalysis.cxx b/PWGUD/Tasks/upcRhoAnalysis.cxx new file mode 100644 index 00000000000..68769394a7f --- /dev/null +++ b/PWGUD/Tasks/upcRhoAnalysis.cxx @@ -0,0 +1,1032 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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) +/// 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 + +#include +#include + +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/runDataProcessing.h" + +#include "random" +#include "TLorentzVector.h" + +#include "Common/DataModel/PIDResponse.h" + +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +using FullUdSgCollision = soa::Join::iterator; +using FullUdDgCollision = soa::Join::iterator; +using FullUdTracks = soa::Join; + +namespace o2::aod +{ +namespace dipi +{ +// general +DECLARE_SOA_COLUMN(RunNumber, runNumber, int32_t); +DECLARE_SOA_COLUMN(NeutronClass, neutronClass, int); +DECLARE_SOA_COLUMN(TofClass, tofClass, int); +DECLARE_SOA_COLUMN(TotCharge, charge, int); +DECLARE_SOA_COLUMN(Pt, pt, double); +// system +DECLARE_SOA_COLUMN(M, m, double); +DECLARE_SOA_COLUMN(Rap, y, double); +DECLARE_SOA_COLUMN(PhiRandom, phiRandom, double); +DECLARE_SOA_COLUMN(PhiCharge, phiCharge, double); +DECLARE_SOA_COLUMN(Eta, eta, double); +DECLARE_SOA_COLUMN(Phi, phi, double); +} // namespace dipi +DECLARE_SOA_TABLE(SystemTree, "AOD", "SYSTEMTREE", dipi::RunNumber, dipi::NeutronClass, dipi::TofClass, dipi::TotCharge, dipi::M, dipi::Pt, dipi::Rap, dipi::PhiRandom, dipi::PhiCharge, dipi::Eta, dipi::Phi); +} // namespace o2::aod + +struct upcRhoAnalysis { + Produces systemTree; + + double PcEtaCut = 0.9; // physics coordination recommendation + 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 tracksMinItsNClsCut{"tracksMinItsNClsCut", 6, "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", {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}; + HistogramRegistry QC{"QC", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry Pions{"Pions", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry System{"System", {}, OutputObjHandlingPolicy::AnalysisObject}; + HistogramRegistry MC{"MC", {}, OutputObjHandlingPolicy::AnalysisObject}; + + void init(o2::framework::InitContext&) + { + // QA // + // collisions + QC.add("QC/collisions/hPosXY", ";x (cm);y (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); + QC.add("QC/collisions/hPosZ", ";z (cm);counts", kTH1D, {{400, -20.0, 20.0}}); + QC.add("QC/collisions/hNumContrib", ";number of contributors;counts", kTH1D, {{36, -0.5, 35.5}}); + QC.add("QC/collisions/hZdcCommonEnergy", ";ZNA common energy;ZNC common energy;counts", kTH2D, {{250, -5.0, 20.0}, {250, -5.0, 20.0}}); + QC.add("QC/collisions/hZdcTime", ";ZNA time (ns);ZNC time (ns);counts", kTH2D, {{200, -10.0, 10.0}, {200, -10.0, 10.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}}); + // track quality selections vs system mass + QC.add("QC/tracks/2D/mass/leading/hItsNClsVsM", ";m (GeV/#it{c}^{2});ITS N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/mass/leading/hItsChi2NClVsM", ";m (GeV/#it{c}^{2});ITS #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/mass/leading/hTpcChi2NClVsM", ";m (GeV/#it{c}^{2});TPC #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/mass/leading/hTpcNClsVsM", ";m (GeV/#it{c}^{2});TPC N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/mass/leading/hTpcNClsCrossedRowsVsM", ";m (GeV/#it{c}^{2});TPC crossed rows of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/mass/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsM", ";m (GeV/#it{c}^{2});TPC crossed rows / TPC N_{cls} findable of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 10.0}}); + QC.add("QC/tracks/2D/mass/subleading/hItsNClsVsM", ";m (GeV/#it{c}^{2});ITS N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/mass/subleading/hItsChi2NClVsM", ";m (GeV/#it{c}^{2});ITS #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/mass/subleading/hTpcChi2NClVsM", ";m (GeV/#it{c}^{2});TPC #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/mass/subleading/hTpcNClsVsM", ";m (GeV/#it{c}^{2});TPC N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/mass/subleading/hTpcNClsCrossedRowsVsM", ";m (GeV/#it{c}^{2});TPC crossed rows of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/mass/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsM", ";m (GeV/#it{c}^{2});TPC crossed rows / TPC N_{cls} findable of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 10.0}}); + // track quality selections vs system rapidity + QC.add("QC/tracks/2D/rapidity/leading/hItsNClsVsY", ";y;ITS N_{cls} of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/rapidity/leading/hItsChi2NClVsY", ";y;ITS #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/rapidity/leading/hTpcChi2NClVsY", ";y;TPC #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/rapidity/leading/hTpcNClsVsY", ";y;TPC N_{cls} of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/rapidity/leading/hTpcNClsCrossedRowsVsY", ";y;TPC crossed rows of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/rapidity/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsY", ";y;TPC crossed rows / TPC N_{cls} findable of leading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 10.0}}); + QC.add("QC/tracks/2D/rapidity/subleading/hItsNClsVsY", ";y;ITS N_{cls} of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/rapidity/subleading/hItsChi2NClVsY", ";y;ITS #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/rapidity/subleading/hTpcChi2NClVsY", ";y;TPC #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/rapidity/subleading/hTpcNClsVsY", ";y;TPC N_{cls} of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/rapidity/subleading/hTpcNClsCrossedRowsVsY", ";y;TPC crossed rows of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/rapidity/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsY", ";y;TPC crossed rows / TPC N_{cls} findable of subleading-#it{p} track;counts", kTH2D, {{180, -0.9, 0.9}, {1000, 0.0, 10.0}}); + // track quality selections vs system pT + QC.add("QC/tracks/2D/pT/leading/hItsNClsVsPt", ";p_{T} (GeV/#it{c});ITS N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/pT/leading/hItsChi2NClVsPt", ";p_{T} (GeV/#it{c});ITS #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/pT/leading/hTpcChi2NClVsPt", ";p_{T} (GeV/#it{c});TPC #chi^{2}/N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/pT/leading/hTpcNClsVsPt", ";p_{T} (GeV/#it{c});TPC N_{cls} of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/pT/leading/hTpcNClsCrossedRowsVsPt", ";p_{T} (GeV/#it{c});TPC crossed rows of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/pT/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsPt", ";p_{T} (GeV/#it{c});TPC crossed rows / TPC N_{cls} findable of leading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 10.0}}); + QC.add("QC/tracks/2D/pT/subleading/hItsNClsVsPt", ";p_{T} (GeV/#it{c});ITS N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {11, -0.5, 10.5}}); + QC.add("QC/tracks/2D/pT/subleading/hItsChi2NClVsPt", ";p_{T} (GeV/#it{c});ITS #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/pT/subleading/hTpcChi2NClVsPt", ";p_{T} (GeV/#it{c});TPC #chi^{2}/N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 100.0}}); + QC.add("QC/tracks/2D/pT/subleading/hTpcNClsVsPt", ";p_{T} (GeV/#it{c});TPC N_{cls} of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/pT/subleading/hTpcNClsCrossedRowsVsPt", ";p_{T} (GeV/#it{c});TPC crossed rows of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {200, 0.0, 200.0}}); + QC.add("QC/tracks/2D/pT/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsPt", ";p_{T} (GeV/#it{c});TPC crossed rows / TPC N_{cls} findable of subleading-#it{p} track;counts", kTH2D, {{1000, 0.0, 10.0}, {1000, 0.0, 10.0}}); + // 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}}); + // selection counter + std::vector selectionCounterLabels = {"all tracks", "PV contributor", "ITS hit", "ITS N_{clusters}", "ITS #chi^{2}/N_{clusters}", "TPC hit", "TPC N_{clusters}", "TPC #chi^{2}/N_{clusters}", "TPC crossed rows", + "TPC crossed rows/N_{clusters}" + "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, {etaAxis, etaAxis}); + 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, {etaAxis, etaAxis}); + 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, {etaAxis, etaAxis}); + 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, {etaAxis, etaAxis}); + 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/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/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}); + + // 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/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/unlike-sign/hTofClassVsM", ";m (GeV/#it{c}^{2});TOF class;counts", kTH2D, {mCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/unlike-sign/hTofClassVsPt", ";p_{T} (GeV/#it{c});TOF class;counts", kTH2D, {ptCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/unlike-sign/hTofClassVsY", ";y;TOF class;counts", kTH2D, {yAxis, {4, -0.5, 3.5}}); + + 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/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/positive/hTofClassVsM", ";m (GeV/#it{c}^{2});TOF class;counts", kTH2D, {mCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/like-sign/positive/hTofClassVsPt", ";p_{T} (GeV/#it{c});TOF class;counts", kTH2D, {ptCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/like-sign/positive/hTofClassVsY", ";y;TOF class;counts", kTH2D, {yAxis, {4, -0.5, 3.5}}); + + 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/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}); + System.add("system/cut/no-selection/like-sign/negative/hTofClassVsM", ";m (GeV/#it{c}^{2});TOF class;counts", kTH2D, {mCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/like-sign/negative/hTofClassVsPt", ";p_{T} (GeV/#it{c});TOF class;counts", kTH2D, {ptCutAxis, {4, -0.5, 3.5}}); + System.add("system/cut/no-selection/like-sign/negative/hTofClassVsY", ";y;TOF class;counts", kTH2D, {yAxis, {4, -0.5, 3.5}}); + + // 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/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/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/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/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/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/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/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/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/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/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/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/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}); + + // MC + MC.add("MC/QC/hPosXY", ";x (cm);y (cm);counts", kTH2D, {{2000, -0.1, 0.1}, {2000, -0.1, 0.1}}); + MC.add("MC/QC/hPosZ", ";z (cm);counts", kTH1D, {{400, -20.0, 20.0}}); + MC.add("MC/QC/hPdgCode", ";pdg code;counts", kTH1D, {{2001, -1000.5, 1000.5}}); + MC.add("MC/QC/hProducedByGenerator", ";produced by generator;counts", kTH1D, {{2, -0.5, 1.5}}); + MC.add("MC/QC/hNPions", ";number of pions;counts", kTH1D, {{11, -0.5, 10.5}}); + + MC.add("MC/hM", ";m (GeV/#it{c}^{2});counts", kTH1D, {mAxis}); + MC.add("MC/hPt", ";p_{T} (GeV/#it{c});counts", kTH1D, {ptAxis}); + MC.add("MC/hPt2", ";p_{T}^{2} (GeV^{2}/#it{c}^{2});counts", kTH1D, {pt2Axis}); + MC.add("MC/hPtVsM", ";m (GeV/#it{c}^{2});p_{T} (GeV/#it{c});counts", kTH2D, {mAxis, ptAxis}); + MC.add("MC/hY", ";y;counts", kTH1D, {yAxis}); + MC.add("MC/hPhiRandom", ";#phi;counts", kTH1D, {phiAsymmAxis}); + MC.add("MC/hPhiCharge", ";#phi;counts", kTH1D, {phiAsymmAxis}); + } + + template + bool trackPassesCuts(const T& track) // track cuts (PID done separately) + { + if (!track.isPVContributor()) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 1); + + if (!track.hasITS()) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 2); + + if (track.itsNCls() < tracksMinItsNClsCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 3); + + if (track.itsChi2NCl() > tracksMaxItsChi2NClCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 4); + + if (!track.hasTPC()) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 5); + + if ((track.tpcNClsFindable() - track.tpcNClsFindableMinusFound()) < tracksMinTpcNClsCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 6); + + if (track.tpcChi2NCl() > tracksMaxTpcChi2NClCut || track.tpcChi2NCl() < tracksMinTpcChi2NClCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 7); + + if (track.tpcNClsCrossedRows() < tracksMinTpcNClsCrossedRowsCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 8); + + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < tracksMinTpcNClsCrossedOverFindableCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 9); + + if (requireTof && !track.hasTOF()) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 10); + + if (track.pt() < tracksMinPtCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 11); + + 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); + + if (std::abs(eta(track.px(), track.py(), track.pz())) > PcEtaCut) + return false; + QC.fill(HIST("QC/tracks/hSelectionCounter"), 13); + // if all selections passed + 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 + int tracksTotalCharge(const T& cutTracks) // total charge of selected tracks + { + int charge = 0; + for (const auto& track : cutTracks) + charge += track.sign(); + return charge; + } + + bool systemPassCuts(const TLorentzVector& 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; + } + + TLorentzVector reconstructSystem(const std::vector& cutTracks4Vecs) // reconstruct system from 4-vectors + { + TLorentzVector system; + for (const auto& track4Vec : cutTracks4Vecs) + system += track4Vec; + 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 + // calculate phi + TLorentzVector pOne = cutTracks4Vecs[indices[0]]; + TLorentzVector pTwo = cutTracks4Vecs[indices[1]]; + TLorentzVector pPlus = pOne + pTwo; + TLorentzVector pMinus = pOne - pTwo; + return pPlus.DeltaPhi(pMinus); + } + + template + double getPhiCharge(const T& cutTracks, const std::vector& cutTracks4Vecs) + { // 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); + } + + template + double getPhiChargeMC(const T& cutTracks, const std::vector& cutTracks4Vecs) + { // two possible definitions of phi: charge-based assignment + 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); + } + + template + void processReco(C const& collision, T const& tracks) + { + // QC histograms + QC.fill(HIST("QC/collisions/hPosXY"), collision.posX(), collision.posY()); + QC.fill(HIST("QC/collisions/hPosZ"), collision.posZ()); + QC.fill(HIST("QC/collisions/hZdcCommonEnergy"), collision.energyCommonZNA(), collision.energyCommonZNC()); + QC.fill(HIST("QC/collisions/hZdcTime"), collision.timeZNA(), collision.timeZNC()); + QC.fill(HIST("QC/collisions/hNumContrib"), collision.numContrib()); + + if (std::abs(collision.posZ()) > collisionsPosZMaxCut) + 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; + neutronClass = 0; + } + if (collision.energyCommonZNA() > ZNcommonEnergyCut && std::abs(collision.timeZNA()) < ZNtimeCut && collision.energyCommonZNC() < ZNcommonEnergyCut) { + XnOn = true; + neutronClass = 1; + } + if (collision.energyCommonZNA() < ZNcommonEnergyCut && collision.energyCommonZNC() > ZNcommonEnergyCut && std::abs(collision.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; + neutronClass = 3; + } + // vectors for storing selected tracks and their 4-vectors + std::vector cutTracks; + std::vector cutTracks4Vecs; + + int trackCounter = 0; + for (const auto& track : tracks) { + // double p = momentum(track.px(), track.py(), track.pz()); + 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; + trackCounter++; + 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"), trackCounter); + + if (cutTracks.size() != cutTracks4Vecs.size()) { + LOG(error); + return; + } + + 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()); + + if (!tracksPassPiPID(cutTracks)) + return; + for (int i = 0; i < static_cast(cutTracks.size()); i++) + QC.fill(HIST("QC/tracks/hSelectionCounter"), 15); + QC.fill(HIST("QC/tracks/cut/hTpcNSigmaEl2D"), cutTracks[0].tpcNSigmaEl(), cutTracks[1].tpcNSigmaEl()); + + // 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 phiRandom = getPhiRandom(cutTracks4Vecs); + double phiCharge = getPhiCharge(cutTracks, cutTracks4Vecs); + // 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()); + int tofClass = -1; + if (!leadingMomentumTrack.hasTOF() && !subleadingMomentumTrack.hasTOF()) + tofClass = 0; + else if (leadingMomentumTrack.hasTOF() && !subleadingMomentumTrack.hasTOF()) + tofClass = 1; + else if (!leadingMomentumTrack.hasTOF() && subleadingMomentumTrack.hasTOF()) + tofClass = 2; + else if (leadingMomentumTrack.hasTOF() && subleadingMomentumTrack.hasTOF()) + tofClass = 3; + // fill 2D track QC histograms + // mass + QC.fill(HIST("QC/tracks/2D/mass/leading/hItsNClsVsM"), mass, leadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/mass/leading/hItsChi2NClVsM"), mass, leadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/mass/leading/hTpcChi2NClVsM"), mass, leadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/mass/leading/hTpcNClsVsM"), mass, leadingMomentumTrack.tpcNClsFindable() - leadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/mass/leading/hTpcNClsCrossedRowsVsM"), mass, leadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/mass/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsM"), mass, (static_cast(leadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(leadingMomentumTrack.tpcNClsFindable()))); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hItsNClsVsM"), mass, subleadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hItsChi2NClVsM"), mass, subleadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hTpcChi2NClVsM"), mass, subleadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hTpcNClsVsM"), mass, subleadingMomentumTrack.tpcNClsFindable() - subleadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hTpcNClsCrossedRowsVsM"), mass, subleadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/mass/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsM"), mass, (static_cast(subleadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(subleadingMomentumTrack.tpcNClsFindable()))); + // rapidity + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hItsNClsVsY"), rapidity, leadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hItsChi2NClVsY"), rapidity, leadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hTpcChi2NClVsY"), rapidity, leadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hTpcNClsVsY"), rapidity, leadingMomentumTrack.tpcNClsFindable() - leadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hTpcNClsCrossedRowsVsY"), rapidity, leadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/rapidity/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsY"), rapidity, (static_cast(leadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(leadingMomentumTrack.tpcNClsFindable()))); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hItsNClsVsY"), rapidity, subleadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hItsChi2NClVsY"), rapidity, subleadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hTpcChi2NClVsY"), rapidity, subleadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hTpcNClsVsY"), rapidity, subleadingMomentumTrack.tpcNClsFindable() - subleadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hTpcNClsCrossedRowsVsY"), rapidity, subleadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/rapidity/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsY"), rapidity, (static_cast(subleadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(subleadingMomentumTrack.tpcNClsFindable()))); + // pT + QC.fill(HIST("QC/tracks/2D/pT/leading/hItsNClsVsPt"), pT, leadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/pT/leading/hItsChi2NClVsPt"), pT, leadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/pT/leading/hTpcChi2NClVsPt"), pT, leadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/pT/leading/hTpcNClsVsPt"), pT, leadingMomentumTrack.tpcNClsFindable() - leadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/pT/leading/hTpcNClsCrossedRowsVsPt"), pT, leadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/pT/leading/hTpcNClsCrossedRowsOverTpcNClsFindableVsPt"), pT, (static_cast(leadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(leadingMomentumTrack.tpcNClsFindable()))); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hItsNClsVsPt"), pT, subleadingMomentumTrack.itsNCls()); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hItsChi2NClVsPt"), pT, subleadingMomentumTrack.itsChi2NCl()); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hTpcChi2NClVsPt"), pT, subleadingMomentumTrack.tpcChi2NCl()); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hTpcNClsVsPt"), pT, subleadingMomentumTrack.tpcNClsFindable() - subleadingMomentumTrack.tpcNClsFindableMinusFound()); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hTpcNClsCrossedRowsVsPt"), pT, subleadingMomentumTrack.tpcNClsCrossedRows()); + QC.fill(HIST("QC/tracks/2D/pT/subleading/hTpcNClsCrossedRowsOverTpcNClsFindableVsPt"), pT, (static_cast(subleadingMomentumTrack.tpcNClsCrossedRows()) / static_cast(subleadingMomentumTrack.tpcNClsFindable()))); + // fill tree + systemTree(collision.runNumber(), neutronClass, tofClass, totalCharge, mass, pT, rapidity, phiRandom, phiCharge, system.PseudoRapidity(), system.Phi()); + // fill raw histograms according to the 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); + 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); + 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); + break; + + default: + break; + } + + // apply cuts to system + if (!systemPassCuts(system)) + return; + + // 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/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)); + System.fill(HIST("system/cut/no-selection/unlike-sign/hTofClassVsM"), mass, tofClass); + System.fill(HIST("system/cut/no-selection/unlike-sign/hTofClassVsPt"), pT, tofClass); + System.fill(HIST("system/cut/no-selection/unlike-sign/hTofClassVsY"), rapidity, tofClass); + 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/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/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/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/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)); + } + 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/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)); + System.fill(HIST("system/cut/no-selection/like-sign/positive/hTofClassVsM"), mass, tofClass); + System.fill(HIST("system/cut/no-selection/like-sign/positive/hTofClassVsPt"), pT, tofClass); + System.fill(HIST("system/cut/no-selection/like-sign/positive/hTofClassVsY"), rapidity, tofClass); + 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/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/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/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/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)); + } + 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/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)); + System.fill(HIST("system/cut/no-selection/like-sign/negative/hTofClassVsM"), mass, tofClass); + System.fill(HIST("system/cut/no-selection/like-sign/negative/hTofClassVsPt"), pT, tofClass); + System.fill(HIST("system/cut/no-selection/like-sign/negative/hTofClassVsY"), rapidity, tofClass); + 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/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/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/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/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)); + } + break; + + default: + break; + } + } + + template + void processMC(C const& mcCollision, T const& mcParticles) + { + MC.fill(HIST("MC/QC/hPosXY"), mcCollision.posX(), mcCollision.posY()); + MC.fill(HIST("MC/QC/hPosZ"), mcCollision.posZ()); + + std::vector cutMcParticles; + std::vector mcParticles4Vecs; + + for (auto const& mcParticle : mcParticles) { + MC.fill(HIST("MC/QC/hPdgCode"), mcParticle.pdgCode()); + MC.fill(HIST("MC/QC/hProducedByGenerator"), mcParticle.producedByGenerator()); + if (!mcParticle.producedByGenerator()) + continue; + if (std::abs(mcParticle.pdgCode()) != 211) + continue; + cutMcParticles.push_back(mcParticle); + TLorentzVector pion4Vec; + pion4Vec.SetPxPyPzE(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); + mcParticles4Vecs.push_back(pion4Vec); + } + MC.fill(HIST("MC/QC/hNPions"), cutMcParticles.size()); + + if (mcParticles4Vecs.size() != cutMcParticles.size()) + return; + if (mcParticles4Vecs.size() != 2) + return; + TLorentzVector system = mcParticles4Vecs[0] + mcParticles4Vecs[1]; + + double mass = system.M(); + double pT = system.Pt(); + double pTsquare = pT * pT; + double rapidity = system.Rapidity(); + double phiRandom = getPhiRandom(mcParticles4Vecs); + double phiCharge = getPhiChargeMC(cutMcParticles, mcParticles4Vecs); + + if (std::abs(rapidity) > systemYCut) + return; + + MC.fill(HIST("MC/hM"), mass); + MC.fill(HIST("MC/hPt"), pT); + MC.fill(HIST("MC/hPtVsM"), mass, pT); + MC.fill(HIST("MC/hPt2"), pTsquare); + MC.fill(HIST("MC/hY"), rapidity); + MC.fill(HIST("MC/hPhiRandom"), phiRandom); + MC.fill(HIST("MC/hPhiCharge"), phiCharge); + } + + void processSGdata(FullUdSgCollision const& collision, FullUdTracks const& tracks) + { + if (collision.gapSide() != 2) + return; + processReco(collision, tracks); + } + 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); + + void processMCdata(aod::UDMcCollision const& mcCollision, aod::UDMcParticles const& mcParticles) + { + processMC(mcCollision, mcParticles); + } + PROCESS_SWITCH(upcRhoAnalysis, processMCdata, "analyse MC data", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + o2::framework::adaptAnalysisTask(cfgc)}; +} diff --git a/PWGUD/Tasks/upcTauCentralBarrelRL.cxx b/PWGUD/Tasks/upcTauCentralBarrelRL.cxx index 965bfb6f327..8753acf8c96 100644 --- a/PWGUD/Tasks/upcTauCentralBarrelRL.cxx +++ b/PWGUD/Tasks/upcTauCentralBarrelRL.cxx @@ -19,6 +19,7 @@ // O2 headers #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" #include "Framework/O2DatabasePDGPlugin.h" #include "Framework/runDataProcessing.h" @@ -87,6 +88,7 @@ struct UpcTauCentralBarrelRL { Configurable cutMyGTtpcNClsCrossedRowsMin{"cutMyGTtpcNClsCrossedRowsMin", 70, {"MyGlobalTrack cut"}}; Configurable cutMyGTtpcNClsCrossedRowsOverNClsMin{"cutMyGTtpcNClsCrossedRowsOverNClsMin", 0.8f, {"MyGlobalTrack cut"}}; Configurable cutMyGTtpcChi2NclMax{"cutMyGTtpcChi2NclMax", 4.f, {"MyGlobalTrack cut"}}; + Configurable applyTauEventSelection{"applyTauEventSelection", true, {"Select event"}}; Configurable doMainHistos{"doMainHistos", true, {"Fill main histos"}}; Configurable doPIDhistos{"doPIDhistos", true, {"Fill PID histos"}}; Configurable doTwoTracks{"doTwoTracks", true, {"Define histos for two tracks and allow to fill them"}}; @@ -97,6 +99,30 @@ struct UpcTauCentralBarrelRL { Configurable doFourTrackPsi2S{"doFourTrackPsi2S", true, {"Define histos for Psi2S into four charged tracks (pi/mu) and allow to fill them"}}; Configurable doSixTracks{"doSixTracks", false, {"Define histos for six tracks and allow to fill them"}}; + ConfigurableAxis axisNtracks{"axisNtracks", {30, -0.5, 29.5}, "Number of tracks in collision"}; + ConfigurableAxis axisZvtx{"axisZvtx", {40, -20., 20.}, "Z-vertex position (cm)"}; + ConfigurableAxis axisInvMass{"axisInvMass", {400, 1., 5.}, "Invariant mass (GeV/c^{2})"}; + ConfigurableAxis axisInvMassWide{"axisInvMassWide", {1000, 0., 10.}, "Invariant mass (GeV/c^{2}), wider range"}; + ConfigurableAxis axisMom{"axisMom", {400, 0., 2.}, "Momentum (GeV/c)"}; + ConfigurableAxis axisMomWide{"axisMomWide", {1000, 0., 10.}, "Momentum (GeV/c), wider range"}; + ConfigurableAxis axisMomSigned{"axisMomSigned", {800, -2., 2.}, "Signed momentum (GeV/c)"}; + ConfigurableAxis axisPt{"axisPt", {400, 0., 2.}, "Transversal momentum (GeV/c)"}; + ConfigurableAxis axisPhi{"axisPhi", {64, -2 * o2::constants::math::PI, 2 * o2::constants::math::PI}, "Azimuthal angle (a.y.)"}; + ConfigurableAxis axisModPhi{"axisModPhi", {400, 0., .4}, "Track fmod(#phi,#pi/9)"}; + ConfigurableAxis axisEta{"axisEta", {50, -1.2, 1.2}, "Pseudorapidity (a.u.)"}; + ConfigurableAxis axisRap{"axisRap", {50, -1.2, 1.2}, "Rapidity (a.u.)"}; + ConfigurableAxis axisAcoplanarity{"axisAcoplanarity", {32, 0.0, o2::constants::math::PI}, "Acoplanarity (rad)"}; + ConfigurableAxis axisTPCdEdx{"axisTPCdEdx", {2000, 0., 200.}, "TPC dE/dx (a.u.)"}; + ConfigurableAxis axisTOFsignal{"axisTOFsignal", {2500, -10000., 40000.}, "TOF signal (a.u.)"}; + ConfigurableAxis axisNsigma{"axisNsigma", {200, -10., 10.}, "n sigma"}; + ConfigurableAxis axisDCA{"axisDCA", {100, -0.5, 0.5}, "DCA (cm)"}; + ConfigurableAxis axisAvgITSclsSizes{"axisAvgITSclsSizes", {500, 0., 10.}, "ITS average cluster size"}; + ConfigurableAxis axisITSnCls{"axisITSnCls", {8, -0.5, 7.5}, "ITS n clusters"}; + ConfigurableAxis axisITSchi2{"axisITSchi2", {100, 0, 50}, "UTS chi2"}; + ConfigurableAxis axisTPCnCls{"axisTPCnCls", {165, -0.5, 164.5}, "TPC n clusters"}; + ConfigurableAxis axisTPCxRwsFrac{"axisTPCxRwsFrac", {200, 0.0, 2.0}, "TPC fraction of crossed raws"}; + ConfigurableAxis axisTPCchi2{"axisTPCchi2", {100, 0, 10}, "TPC chi2"}; + using FullUDTracks = soa::Join; using FullUDCollision = soa::Join::iterator; using FullSGUDCollision = soa::Join::iterator; @@ -114,30 +140,6 @@ struct UpcTauCentralBarrelRL { countCollisions = 0; isFirstReconstructedCollisions = true; - const AxisSpec axisNtracks{30, -0.5, 29.5}; - const AxisSpec axisZvtx{40, -20., 20.}; - const AxisSpec axisInvMass{400, 1., 5.}; - const AxisSpec axisInvMassWide{1000, 0., 10.}; - const AxisSpec axisMom{400, 0., 2.}; - const AxisSpec axisMomSigned{800, -2., 2.}; - const AxisSpec axisMomWide{1000, 0., 10.}; - const AxisSpec axisPt{400, 0., 2.}; - const AxisSpec axisPhi{64, -2 * o2::constants::math::PI, 2 * o2::constants::math::PI}; - const AxisSpec axisModPhi{400, 0., .4}; - const AxisSpec axisEta{50, -1.2, 1.2}; - const AxisSpec axisRap{50, -1.2, 1.2}; - const AxisSpec axisAcoplanarity{32, 0.0, o2::constants::math::PI}; - const AxisSpec axisDCA{100, -0.5, 0.5}; - const AxisSpec axisAvgITSclsSizes{500, 0., 10.}; - const AxisSpec axisTPCdEdx{2000, 0., 200.}; - const AxisSpec axisTOFsignal{2500, -10000., 40000.}; - const AxisSpec axisNsigma{200, -10., 10.}; - const AxisSpec axisITSnCls{8, -0.5, 7.5}; - const AxisSpec axisITSchi2{100, 0, 50}; - const AxisSpec axisTPCnCls{165, -0.5, 164.5}; - const AxisSpec axisTPCxRwsFrac{200, 0.0, 2.0}; - const AxisSpec axisTPCchi2{100, 0, 10}; - histos.add("Events/hCountCollisions", ";;Number of analysed collision (-)", HistType::kTH1D, {{1, 0.5, 1.5}}); histos.add("Events/UDtableGapSide", ";GapSide value from UD table (-);Number of events (-)", HistType::kTH1D, {{4, -1.5, 2.5}}); histos.add("Events/TrueGapSideDiffToTableValue", ";Difference trueGapSide from SGselector and gapSide from UD table (-);Number of events (-)", HistType::kTH1D, {{7, -3.5, 3.5}}); @@ -445,6 +447,7 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/ElectronMuPi/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {axisPhi}); histos.add("EventTwoTracks/ElectronMuPi/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {axisRap}); histos.add("EventTwoTracks/ElectronMuPi/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {axisInvMassWide, axisPt}); + histos.add("EventTwoTracks/ElectronMuPi/hElectronPt", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {axisPt}); histos.add("EventTwoTracks/ElectronMuPi/hElectronPtWide", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {axisMomWide}); histos.add("EventTwoTracks/ElectronMuPi/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {axisMom, axisMom}); histos.add("EventTwoTracks/ElectronMuPi/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {axisMomWide, axisMomWide}); @@ -481,6 +484,7 @@ struct UpcTauCentralBarrelRL { histos.add("EventTwoTracks/ElectronOther/hMotherPhi", ";Mother #phi (rad);Number of events (-)", HistType::kTH1D, {axisPhi}); histos.add("EventTwoTracks/ElectronOther/hMotherRapidity", ";Mother #it{y} (-);Number of events (-)", HistType::kTH1D, {axisRap}); histos.add("EventTwoTracks/ElectronOther/hMotherMassVsPt", ";Invariant mass (GeV/c^{2});Mother #it{p_{T}} (GeV/c)", HistType::kTH2D, {axisInvMassWide, axisPt}); + histos.add("EventTwoTracks/ElectronOther/hElectronPt", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {axisPt}); histos.add("EventTwoTracks/ElectronOther/hElectronPtWide", ";Electron #it{p_{T}} (GeV/c);Number of events (-)", HistType::kTH1D, {axisMomWide}); histos.add("EventTwoTracks/ElectronOther/hDaughtersP", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {axisMom, axisMom}); histos.add("EventTwoTracks/ElectronOther/hDaughtersPwide", ";Daughter 1 #it{p} (GeV/c);Daughter 2 #it{p} (GeV/c)", HistType::kTH2D, {axisMomWide, axisMomWide}); @@ -1171,6 +1175,15 @@ struct UpcTauCentralBarrelRL { auto acoplanarity = calculateAcoplanarity(daug[0].Phi(), daug[1].Phi()); auto sign = trkDaug1.sign() * trkDaug2.sign(); bool passAvgITSclsSizesCut = passITSAvgClsSizesLowMomCut(trkDaug1, cutAvgITSclusterSize, cutPtAvgITSclusterSize) && passITSAvgClsSizesLowMomCut(trkDaug2, cutAvgITSclusterSize, cutPtAvgITSclusterSize); + if (applyTauEventSelection) { + if (sign > 0) + return; + if (acoplanarity > 4 * o2::constants::math::PI / 5) + return; // max opening angle 144 degrees (I hope, check) + // if (daug[0].Pt() < 0.2 || daug[1].Pt() < 0.2) return; + // if (motherOfPions.M() > 0.55 || motherOfPions.M() < 1.05) return; + // if (!trkDaug1.hasTOF() || !trkDaug2.hasTOF()) return; + } histos.get(HIST("EventTwoTracks/hInvariantMass"))->Fill(mother.M()); histos.get(HIST("EventTwoTracks/hInvariantMassWide"))->Fill(mother.M()); @@ -1376,6 +1389,7 @@ 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/hElectronPt"))->Fill(electronPt); histos.get(HIST("EventTwoTracks/ElectronMuPi/hElectronPtWide"))->Fill(electronPt); 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()); @@ -1426,6 +1440,7 @@ struct UpcTauCentralBarrelRL { 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()); diff --git a/PWGUD/Tasks/upcTauTau13topo.cxx b/PWGUD/Tasks/upcTauTau13topo.cxx index 61e7feb9fc1..c7d3e870316 100644 --- a/PWGUD/Tasks/upcTauTau13topo.cxx +++ b/PWGUD/Tasks/upcTauTau13topo.cxx @@ -18,8 +18,11 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +// #include "TDatabasePDG.h" // not recommended in o2 +#include "Framework/O2DatabasePDGPlugin.h" -#include "TDatabasePDG.h" #include "TLorentzVector.h" // #include "Common/DataModel/EventSelection.h" // #include "Common/DataModel/TrackSelectionTables.h" @@ -28,21 +31,28 @@ #include "PWGUD/DataModel/UDTables.h" #include "PWGUD/Core/UDHelpers.h" #include "PWGUD/Core/DGPIDSelector.h" +#include "PWGUD/Core/SGSelector.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; struct TauTau13topo { - + SGSelector sgSelector; // configurables - ConfigurableAxis ptAxis{"pAxis", {100, 0., 5.}, "#it{p} (GeV/#it{c})"}; - ConfigurableAxis etaAxis{"etaAxis", {100, -2., 2.}, "#eta"}; + 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"}; + // 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., 2.5}, "M_{inv} (GeV/#it{c}^{2})"}; - ConfigurableAxis phiAxis{"phiAxis", {100, 0., 3.2}, "#phi"}; - ConfigurableAxis vectorAxis{"vectorAxis", {100, 0., 2.}, "A_{V}"}; - ConfigurableAxis scalarAxis{"scalarAxis", {100, -1., 1.}, "A_{S}"}; + 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"}; // cut selection configurables @@ -59,8 +69,23 @@ struct TauTau13topo { 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 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 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 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 DGactive{"DGactive", false, "Switch on DGproducer"}; + // Configurable SGactive{"SGactive", true, "Switch on SGproducer"}; + // a pdg object - TDatabasePDG* pdg = nullptr; + // TDatabasePDG* pdg = nullptr; //not recommended + Service pdg; // initialize histogram registry HistogramRegistry registry{ @@ -69,39 +94,59 @@ struct TauTau13topo { void init(InitContext&) { - pdg = TDatabasePDG::Instance(); + // pdg = TDatabasePDG::Instance(); // dgcandidates histograms const AxisSpec axisp{100, 0., 5., "#it{p} (GeV/#it{c})"}; const AxisSpec axispt{ptAxis, "p_{T} axis"}; - const AxisSpec axiseta{etaAxis, "#eta - pseudo rapidity axis"}; + // const AxisSpec axiseta{etaAxis, "#eta - pseudo rapidity axis"}; + const AxisSpec axiseta{100, -2., 2., "#eta"}; const AxisSpec axisdedx{dedxAxis, "dEdx axis"}; const AxisSpec axisminv{minvAxis, "invariant mass axis"}; const AxisSpec axisphi{phiAxis, "phi axis"}; - const AxisSpec axisav{vectorAxis, "AV axis"}; - const AxisSpec axisas{scalarAxis, "AS axis"}; + // const AxisSpec axisav{vectorAxis, "AV axis"}; + // const AxisSpec axisas{scalarAxis, "AS axis"}; + 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)"}; - 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.05, 0.05}}}); + 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/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/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/hTrackPVTotCharge", "Q_{Tot};Q_{Tot}; Entries", {HistType::kTH1F, {{11, -5, 6}}}); 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, {{55, 0., 55.}}}); + 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, {{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}}); @@ -109,11 +154,27 @@ struct TauTau13topo { 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/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}}); @@ -121,9 +182,10 @@ struct TauTau13topo { 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/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}}}); @@ -131,6 +193,32 @@ struct TauTau13topo { 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 TMath::Pi()) - delta = TMath::TwoPi() - delta; + delta += o2::constants::math::TwoPI; + if (delta > o2::constants::math::PI) + delta = o2::constants::math::TwoPI - delta; return delta; } // fill control histograms per track template - void FillControlHistos(T pi3invMass, float pi3pt, float pi3deltaPhi, float pi3assymav, float pi3vector, float pi3scalar, float pi3etasum) + // 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) { 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", @@ -273,7 +602,8 @@ struct TauTau13topo { 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("/h13EtaSum"))->Fill(pi3etasum); + registry.get(HIST("control/cut") + HIST(histoname[mode]) + HIST("/hTPCnCrossedRows"))->Fill(nCRtpc); } template @@ -316,44 +646,190 @@ struct TauTau13topo { return -1; } - using UDCollisionsFull = soa::Join; - using UDCollisionFull = UDCollisionsFull::iterator; + // using UDCollisionsFull = soa::Join; + // using UDCollisionFull = UDCollisionsFull::iterator; using UDTracksFull = soa::Join; - - void process(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks) + using UDCollisionsFull2 = soa::Join; + using UDCollisionFull2 = UDCollisionsFull2::iterator; + + // PVContributors + Filter PVContributorFilter = aod::udtrack::isPVContributor == true; + using PVTracks = soa::Filtered; + + // void processDG(UDCollisionFull const& dgcand, UDTracksFull const& dgtracks) + // { + // int gapSide = 2; + // mainTask(gapSide,dgtracks); + // } + // 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) { + int gapSide = dgcand.gapSide(); + int truegapSide = sgSelector.trueGap(dgcand, FV0_cut, FT0A_cut, FT0C_cut, ZDC_cut); + registry.fill(HIST("global/GapSide"), gapSide); + registry.fill(HIST("global/GapSideTrue"), truegapSide); + if (gapSide < 0 || gapSide > 2) + return; + gapSide = truegapSide; + // mainTask(gapSide,dgtracks); + // } + // PROCESS_SWITCH(TauTau13topo, processSG, "Process SG data", SGactive); + // + // void mainTask(int gapSide, UDTracksFull const& dgtracks) + // { + if (gapSide != gap_Side) + return; // global checks registry.get(HIST("global/hVertexXY"))->Fill(dgcand.posX(), dgcand.posY()); registry.get(HIST("global/hVertexZ"))->Fill(dgcand.posZ()); - if (TMath::Abs(dgcand.posZ()) < 15) - registry.get(HIST("global/hVertexZ15"))->Fill(dgcand.posZ()); - if (TMath::Abs(dgcand.posZ()) < 10) - registry.get(HIST("global/hVertexZ10"))->Fill(dgcand.posZ()); + // if (TMath::Abs(dgcand.posZ()) < 10) + // registry.get(HIST("global/hVertexZ10"))->Fill(dgcand.posZ()); registry.get(HIST("global/hNTracks"))->Fill(dgtracks.size()); // setup PV tracks partition - Partition PVContributors = aod::udtrack::isPVContributor == true; - PVContributors.bindTable(dgtracks); + // Partition PVContributors = aod::udtrack::isPVContributor == true; + // PVContributors.bindTable(dgtracks); 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); + registry.get(HIST("global/hZNACtime"))->Fill(dgcand.timeZNA(), dgcand.timeZNC()); + uint32_t clusterSizes; + // UChar_t clustermap1; + // bool isInnerITS = false; int nTofTrk = 0; int nEtaIn15 = 0; - int nITSbits = 0; + int nITSbits = -1; + int npT100 = 0; TLorentzVector p; - TParticlePDG* pion = pdg->GetParticle(211); + auto pionMass = pdg->Mass(211); + auto electronMass = pdg->Mass(11); + // TParticlePDG* pion = pdg->GetParticle(211); + // TParticlePDG* electron = pdg->GetParticle(11); + bool flagGlobalCheck = true; + bool isGlobalTrack = true; + int qtot = 0; // loop over PV contributors for (const auto& trk : PVContributors) { - p.SetXYZM(trk.px(), trk.py(), trk.pz(), pion->Mass()); + qtot += trk.sign(); + p.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); registry.get(HIST("global/hTrackPtPV"))->Fill(p.Pt()); - if (TMath::Abs(p.Eta()) < trkEtacut) + if (std::abs(p.Eta()) < trkEtacut) nEtaIn15++; // 1.5 is a default registry.get(HIST("global/hTrackEtaPhiPV"))->Fill(p.Eta(), p.Phi()); - nITSbits = -1; + + if (trk.pt() > 0.1) + 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.); + registry.get(HIST("global/hTrackEtaPhiPVGlobal"))->Fill(p.Eta(), p.Phi()); + } + } // end of flag check global + + // new version if (trk.hasITS()) { // ITS track + nITSbits = -1; clusterSizes = trk.itsClusterSizes(); + // LOGF(info, " clistersize: %d", clusterSizes); for (int layer = 0; layer < 7; layer++) { if ((clusterSizes >> (layer * 4)) & 0xf) { registry.get(HIST("global/hITSbitPVtrk"))->Fill(layer, 1.); @@ -361,13 +837,19 @@ struct TauTau13topo { nITSbits++; } } // end of loop over ITS bits - } // has ITS + // isInnerITS = TESTBIT(clustermap1, 0) || TESTBIT(clustermap1, 1) || TESTBIT(clustermap1, 2); + // if (isInnerITS) { + // registry.get(HIST("global/hTrackEfficiencyPVGlobal"))->Fill(10., 1.); + // } else { + // isGlobalTrack = false; + // } + } // has ITS registry.get(HIST("global/hITSnbitsVsEtaPVtrk"))->Fill(p.Eta(), nITSbits); if (trk.hasTPC()) registry.get(HIST("global/hSignalTPCvsPtPV"))->Fill(p.Pt(), trk.tpcSignal()); if (trk.hasTOF()) nTofTrk++; - } + } // end of loop over PV tracks registry.get(HIST("global/hNtofTrk"))->Fill(nTofTrk); // @@ -376,17 +858,35 @@ struct TauTau13topo { registry.get(HIST("global/hEventEff"))->Fill(0., 1.); // skip events with too few/many tracks - if (dgcand.numContrib() != 4) { + // if (PVContributors.size() != 4 || dgcand.numContrib() != 4) { + if (PVContributors.size() != 4) { if (verbose) { - LOGF(info, " Candidate rejected: Number of PV contributors is %d", dgcand.numContrib()); + LOGF(info, " Candidate rejected: Number of PV contributors is %d, candContriv %d", PVContributors.size(), dgcand.numContrib()); } return; } + // old version in DG producer + // if (dgcand.numContrib() != 4) { + // if (verbose) { + // LOGF(info, " Candidate rejected: Number of PV contributors is %d", dgcand.numContrib()); + // } + // return; + // } + registry.get(HIST("global/hEventEff"))->Fill(1., 1.); - registry.get(HIST("global/hTrackPVTotCharge"))->Fill(dgcand.netCharge()); + // 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); + registry.get(HIST("global1/hTrackPtPV"))->Fill(p.Pt()); + registry.get(HIST("global1/hTrackEtaPhiPV"))->Fill(p.Eta(), p.Phi()); + } // if vz < 15 - if (TMath::Abs(dgcand.posZ()) >= zvertexcut) { // default = 15 + if (std::abs(dgcand.posZ()) >= zvertexcut) { // default = 15 if (verbose) { LOGF(info, " Candidate rejected: VertexZ is %f", dgcand.posZ()); } @@ -405,16 +905,18 @@ struct TauTau13topo { // skip events with net charge != 0 if (!sameSign) { // opposite sign is signal - if (dgcand.netCharge() != 0) { + // if (dgcand.netCharge() != 0) { + if (qtot != 0) { if (verbose) { - LOGF(info, " Candidate rejected: Net charge is %d, while should be 0", dgcand.netCharge()); + LOGF(info, " Candidate rejected: Net charge is %d (dgcand %d), while should be 0", qtot, dgcand.netCharge()); } return; } } else { // same sign is background - if (dgcand.netCharge() == 0) { + // if (dgcand.netCharge() == 0) { + if (qtot == 0) { if (verbose) { - LOGF(info, " Candidate rejected: Net charge is %d, while should be not 0", dgcand.netCharge()); + LOGF(info, " Candidate rejected: Net charge is %d (dgcand %d), while should be not 0", qtot, dgcand.netCharge()); } return; } @@ -463,6 +965,15 @@ struct TauTau13topo { // } // 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(5., 1.); + // // here PID from TPC starts to be // @@ -476,11 +987,12 @@ struct TauTau13topo { float pi3assymav[4]; float pi3vector[4]; float pi3scalar[4]; - float pi3etasum[4]; + // float pi3etasum[4]; float deltaPhiTmp = 0; float scalarPtsum = 0; float nSigmaEl[4]; float nSigmaPi[4]; + float nSigma3Pi[4] = {0., 0., 0., 0.}; float nSigmaPr[4]; float nSigmaKa[4]; float dcaZ[4]; @@ -488,15 +1000,49 @@ struct TauTau13topo { float chi2TPC[4]; float chi2ITS[4]; float nclTPCfind[4]; + float nclTPCcrossedRows[4]; + bool tmpHasTOF[4]; + float mass3pi1e[4]; + double trkTime[4]; + float trkTimeRes[4]; + double trkTimeTot = 0.; + float trkTimeResTot = 10000.; + + // 2 gamma from 4 electrons + // 12 34 | 01 23 |//1 //6 | 0 5 |counter<3?counter:5-counter counter<3?0:1 + // 13 24 | 02 13 |//2 //5 | 1 4 | + // 14 23 | 03 12 |//3 //4 | 2 3 | + TLorentzVector p1, p2; + TLorentzVector gammaPair[3][2]; + float invMass2El[3][2]; + int counterTmp = 0; + bool flagIMGam2ePV[4] = {true, true, true, true}; + + for (const auto& trk : PVContributors) { + p.SetXYZM(trk.px(), trk.py(), trk.pz(), electronMass); + for (const auto& trk1 : PVContributors) { + if (trk.index() >= trk1.index()) + continue; + p1.SetXYZM(trk1.px(), trk1.py(), trk1.pz(), electronMass); + 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()); + counterTmp++; + if ((p + p1).M() < 0.015) { + flagIMGam2ePV[trk.index()] = false; + flagIMGam2ePV[trk1.index()] = false; + } + } // end of loop over PVContributors + } // end of loop over PVContributors // first loop to add all the tracks together - TLorentzVector p1; p = TLorentzVector(0., 0., 0., 0.); for (const auto& trk : PVContributors) { - p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pion->Mass()); + p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); p += p1; scalarPtsum += trk.pt(); - } + } // end of loop over PVContributors + float pttot = p.Pt(); float mass4pi = p.Mag(); @@ -507,12 +1053,17 @@ struct TauTau13topo { bool flagVcalPV[4] = {false, false, false, false}; // second loop to calculate 1 by 1 each combinatorial variable - int counterTmp = 0; + counterTmp = 0; int tmpTrkCheck = -1; for (const auto& trk : PVContributors) { 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); + mass3pi1e[counterTmp] = (p - p1 + p2).Mag(); + v1.SetXYZ(trk.px(), trk.py(), trk.pz()); for (const auto& trk1 : PVContributors) { if (trk.index() == trk1.index()) @@ -523,9 +1074,10 @@ struct TauTau13topo { if (deltaphi < minAnglecut) { // default 0.05 flagVcalPV[counterTmp] = true; } - } + } // end of loop over PVContributors 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(); @@ -533,8 +1085,12 @@ struct TauTau13topo { chi2TPC[counterTmp] = trk.tpcChi2NCl(); chi2ITS[counterTmp] = trk.itsChi2NCl(); nclTPCfind[counterTmp] = trk.tpcNClsFindable(); + nclTPCcrossedRows[counterTmp] = trk.tpcNClsCrossedRows(); + tmpHasTOF[counterTmp] = trk.hasTOF(); + trkTime[counterTmp] = trk.trackTime(); + trkTimeRes[counterTmp] = trk.trackTimeRes(); - p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pion->Mass()); + p1.SetXYZM(trk.px(), trk.py(), trk.pz(), pionMass); tmpMomentum[counterTmp] = p1.P(); tmpPt[counterTmp] = p1.Pt(); tmpDedx[counterTmp] = trk.tpcSignal(); @@ -546,23 +1102,118 @@ struct TauTau13topo { 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(); + // pi3etasum[counterTmp] = (p - p1).Eta() + p1.Eta(); counterTmp++; + } // end of loop over PVContributors + + // calculate trk time and resolution total + // 1. find best resolution + int iTmpBest = -1; + for (int i = 0; i < 4; i++) { + if (trkTimeRes[i] < trkTimeResTot) { + trkTimeResTot = trkTimeRes[i]; + iTmpBest = i; + } } + // 2. use best resol to calculate total time + for (int i = 0; i < 4; i++) { + if (i == iTmpBest) + continue; + trkTimeTot += fabs(trkTime[iTmpBest] - trkTime[i]); + } + trkTimeResTot = std::sqrt(trkTimeRes[0] * trkTimeRes[0] + + trkTimeRes[1] * trkTimeRes[1] + + trkTimeRes[2] * trkTimeRes[2] + + trkTimeRes[3] * trkTimeRes[3]); // 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], pi3etasum[i]); + FillControlHistos<0>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], nclTPCcrossedRows[i]); registry.get(HIST("control/cut0/h3piMassVsPt"))->Fill(pi3invMass[i], pi3pt[i]); registry.get(HIST("pidTPC/hpvsdedxElHipCut0"))->Fill(tmpMomentum[i], tmpDedx[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]); + registry.get(HIST("control/cut0/h3pi1eMass"))->Fill(mass3pi1e[i]); + } // end of loop over 4 tracks + // control, 1 per event registry.get(HIST("control/cut0/h4trkPtTot"))->Fill(pttot); 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); + + if (pttot < 0.150) { + // give all the gg combinations + // 12 34 + // 13 24 + // 14 23 + int nGamPair = 0; + int nGamma = 0; + int whichPair = -1; + float scalarAsym = -1; + float vectorAsym = -1; + bool electronCheck = true; + for (int i = 0; i < 4; i++) { + if (std::abs(nSigmaEl[i]) > 5) + electronCheck = false; + } // end of loop over 4 tracks + + for (int i = 0; i < 3; i++) { + registry.get(HIST("control/cut0/hInvMass2ElCoh"))->Fill(invMass2El[i][0]); + registry.get(HIST("control/cut0/hInvMass2ElCoh"))->Fill(invMass2El[i][1]); + registry.get(HIST("control/cut0/hGamPtCoh"))->Fill(gammaPair[i][0].Pt()); + registry.get(HIST("control/cut0/hGamPtCoh"))->Fill(gammaPair[i][1].Pt()); + if (invMass2El[i][0] < 0.15) { + nGamma++; + registry.get(HIST("control/cut0/hGamPtCohIM0"))->Fill(gammaPair[i][0].Pt()); + } + if (invMass2El[i][1] < 0.15) { + nGamma++; + registry.get(HIST("control/cut0/hGamPtCohIM0"))->Fill(gammaPair[i][1].Pt()); + } + if (invMass2El[i][0] < 0.15 && invMass2El[i][1] < 0.15) { + nGamPair++; + whichPair = i; + } + } // end of loop over 3 tracks + registry.get(HIST("control/cut0/hN2gamma"))->Fill(nGamma); + registry.get(HIST("control/cut0/hN2gamma"))->Fill(10 + nGamPair); + if (nGamPair == 1) { + scalarAsym = std::abs(gammaPair[whichPair][1].Pt() - gammaPair[whichPair][0].Pt()) / (gammaPair[whichPair][1].Pt() + gammaPair[whichPair][0].Pt()); + if ((gammaPair[whichPair][1] - gammaPair[whichPair][0]).Pt() != 0) + vectorAsym = (gammaPair[whichPair][1] + gammaPair[whichPair][0]).Pt() / (gammaPair[whichPair][1] - gammaPair[whichPair][0]).Pt(); + 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])); + 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. && + (gammaPair[whichPair][1] + gammaPair[whichPair][0]).M() < 4.) { + for (int j = 0; j < 4; j++) + registry.get(HIST("pidTPC/hpvsdedxElHipCut0CohPsi2s"))->Fill(tmpMomentum[j], tmpDedx[j]); + } - // remove combinatoric + if (electronCheck) { + registry.get(HIST("control/cut20/hInvMass2ElCoh"))->Fill(gammaPair[whichPair][0].M()); + registry.get(HIST("control/cut20/hInvMass2ElCoh"))->Fill(gammaPair[whichPair][1].M()); + registry.get(HIST("control/cut20/hGamPtCohIM0"))->Fill(gammaPair[whichPair][0].Pt()); + registry.get(HIST("control/cut20/hGamPtCohIM0"))->Fill(gammaPair[whichPair][1].Pt()); + 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])); + } + + } // ngam = 1 + + } // end of check ptot<0.15 + + // remove combinatorics bool flagTotal[4] = {false, false, false, false}; bool flagIM[4] = {false, false, false, false}; bool flagDP[4] = {false, false, false, false}; @@ -571,18 +1222,24 @@ struct TauTau13topo { bool flagPt[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}; // bool flagVcalPV[4]={false,false,false,false}; // float deltaphi=0; for (int i = 0; i < 4; i++) { - if (pi3invMass[i] < 1.8) { - flagIM[i] = true; + if (pi3invMass[i] < invMass3piMaxcut) { // default should be 1.8 + if (invMass3piSignalRegion) { + flagIM[i] = true; + } else { + flagIM[i] = false; + } } else { registry.get(HIST("pidTPC/hpvsdedxElHipCut2"))->Fill(tmpMomentum[i], tmpDedx[i]); } - if (pi3deltaPhi[i] > 1.6) { + if (pi3deltaPhi[i] > deltaPhiMincut) { // default should be 1.6 flagDP[i] = true; } else { registry.get(HIST("pidTPC/hpvsdedxElHipCut3"))->Fill(tmpMomentum[i], tmpDedx[i]); @@ -594,7 +1251,7 @@ struct TauTau13topo { registry.get(HIST("pidTPC/hpvsdedxElHipCut4"))->Fill(tmpMomentum[i], tmpDedx[i]); } - if (TMath::Abs(nSigmaPi[i]) > maxNsigmaPiVetocut) { // default is 4 + if (std::abs(nSigmaPi[i]) > maxNsigmaPiVetocut) { // default is 4 flagPi[i] = true; } else { registry.get(HIST("pidTPC/hpvsdedxElHipCut5"))->Fill(tmpMomentum[i], tmpDedx[i]); @@ -614,20 +1271,36 @@ struct TauTau13topo { registry.get(HIST("pidTPC/hpvsdedxElHipCut8"))->Fill(tmpMomentum[i], tmpDedx[i]); } - if (TMath::Abs(nSigmaPr[i]) > maxNsigmaPrVetocut) { // default is 3 + if (std::abs(nSigmaPr[i]) > maxNsigmaPrVetocut) { // default is 3 flagPr[i] = true; } else { registry.get(HIST("pidTPC/hpvsdedxElHipCut9"))->Fill(tmpMomentum[i], tmpDedx[i]); } - if (TMath::Abs(nSigmaKa[i]) > maxNsigmaKaVetocut) { // default is 3 + if (std::abs(nSigmaKa[i]) > maxNsigmaKaVetocut) { // default is 3 flagKa[i] = true; } else { registry.get(HIST("pidTPC/hpvsdedxElHipCut10"))->Fill(tmpMomentum[i], tmpDedx[i]); } - flagTotal[i] = flagEl[i] && flagPi[i] && flagPt[i] && !flagVcalPV[i] && flagPr[i] && flagKa[i]; - } + if (nclTPCcrossedRows[i] > nTPCcrossedRowsMinCut) { // default is 50 + flagCR[i] = true; + } else { + registry.get(HIST("pidTPC/hpvsdedxElHipCut11"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (nSigma3Pi[i] < nSigma3piMaxCut) { // default is 5 + flagS3pi[i] = true; + } else { + registry.get(HIST("pidTPC/hpvsdedxElHipCut12"))->Fill(tmpMomentum[i], tmpDedx[i]); + } + + if (flagIMGam2ePV[i]) { + registry.get(HIST("pidTPC/hpvsdedxElHipCut13"))->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 counterM3pi = flagIM[0] + flagIM[1] + flagIM[2] + flagIM[3]; int counterDphi = flagDP[0] + flagDP[1] + flagDP[2] + flagDP[3]; @@ -636,7 +1309,9 @@ struct TauTau13topo { int counterPr = flagPr[0] + flagPr[1] + flagPr[2] + flagPr[3]; int counterKa = flagKa[0] + flagKa[1] + flagKa[2] + flagKa[3]; int counterPt = flagPt[0] + flagPt[1] + flagPt[2] + flagPt[3]; + int counterCR = flagCR[0] + flagCR[1] + flagCR[2] + flagCR[3]; int counterVcal = !flagVcalPV[0] + !flagVcalPV[1] + !flagVcalPV[2] + !flagVcalPV[3]; + int counterS3pi = flagS3pi[0] + flagS3pi[1] + flagS3pi[2] + flagS3pi[3]; int counterTotal = flagTotal[0] + flagTotal[1] + flagTotal[2] + flagTotal[3]; registry.get(HIST("global/hNCombAfterCut"))->Fill(5. + counterM3pi, 1.); @@ -647,7 +1322,9 @@ struct TauTau13topo { registry.get(HIST("global/hNCombAfterCut"))->Fill(30. + counterVcal, 1.); registry.get(HIST("global/hNCombAfterCut"))->Fill(35. + counterPr, 1.); registry.get(HIST("global/hNCombAfterCut"))->Fill(40. + counterKa, 1.); - registry.get(HIST("global/hNCombAfterCut"))->Fill(45. + counterTotal, 1.); + registry.get(HIST("global/hNCombAfterCut"))->Fill(45. + counterCR, 1.); + registry.get(HIST("global/hNCombAfterCut"))->Fill(50. + counterS3pi, 1.); + registry.get(HIST("global/hNCombAfterCut"))->Fill(55. + counterTotal, 1.); // draw PID histograms if (counterEl > 0) { // Nelectrons>0, cut20 @@ -655,11 +1332,19 @@ struct TauTau13topo { 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); for (int i = 0; i < 4; i++) { if (flagEl[i]) { registry.get(HIST("pidTPC/hpvsdedxElHipCut20"))->Fill(tmpMomentum[i], tmpDedx[i]); - FillControlHistos<20>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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]); 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]); } } @@ -668,11 +1353,19 @@ struct TauTau13topo { 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]); - FillControlHistos<21>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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]); } } @@ -685,11 +1378,19 @@ struct TauTau13topo { 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]); - FillControlHistos<22>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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]); } } @@ -702,11 +1403,19 @@ struct TauTau13topo { 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]); - FillControlHistos<23>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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]); } } @@ -719,11 +1428,19 @@ struct TauTau13topo { 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]); - FillControlHistos<24>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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]); } } @@ -736,14 +1453,137 @@ struct TauTau13topo { 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]); - FillControlHistos<25>(pi3invMass[i], pi3pt[i], pi3deltaPhi[i], pi3assymav[i], pi3vector[i], pi3scalar[i], pi3etasum[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"); @@ -768,7 +1608,7 @@ struct TauTau13topo { if (verbose) { LOGF(debug, " Candidate rejected: all electrons vetoed by pi PID"); } - } // end of pi veto + } // end of pi veto } else { // no electron if (verbose) { LOGF(debug, " Candidate rejected: no electron PID among 4 tracks"); @@ -782,27 +1622,93 @@ struct TauTau13topo { } return; } - if (counterTotal > 0) - registry.get(HIST("global/hEventEff"))->Fill(12., 1.); + 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); + 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); + for (int i = 0; i < 4; i++) { + if (flagTotal[i]) { + 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("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]); + } + } + } // 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) || - TESTBIT(dgcand.bbFT0Cpf(), bit) || - TESTBIT(dgcand.bbFV0Apf(), bit) || - TESTBIT(dgcand.bbFDDApf(), bit) || - TESTBIT(dgcand.bbFDDCpf(), 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); + 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 (counterTotal > 0) - registry.get(HIST("global/hEventEff"))->Fill(13., 1.); + // n TOF tracks cut + if (nTofTrk < nTofTrkMinCut) { + if (verbose) { + LOGF(info, " Candidate rejected: nTOFtracks is %d", nTofTrk); + } + 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); + 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]); + } + } + } + } + + // electron has TOF hit + + // 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]); @@ -810,24 +1716,119 @@ struct TauTau13topo { 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], pi3etasum[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]); + 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]); + } + + // 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]); + 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]); + } + + int otherTOFtracks = 0; + for (int j = 0; j < 4; j++) { + if (i == j) + continue; + if (tmpHasTOF[j]) + otherTOFtracks++; + } + // 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) + + } // end of one electron with tof hit (cut33) } - } + } // 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 - registry.get(HIST("global/hEventEff"))->Fill(14., 1.); } else { // more than 1 electron candidate if (verbose) { LOGF(debug, " Candidate rejected: more than one electron candidate"); } - } // end of Nelectrons check - } + } // end of 1electrons check + } // end of process + // check ntracks-4PVtracks + // check pt of remaining (ntracks-4PVtracks) tracks }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGUD/Tasks/upcVetoAnalysis.cxx b/PWGUD/Tasks/upcVetoAnalysis.cxx index 4f34a4d0941..45b3844ed51 100644 --- a/PWGUD/Tasks/upcVetoAnalysis.cxx +++ b/PWGUD/Tasks/upcVetoAnalysis.cxx @@ -8,7 +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 +#include +#include +#include +#include +#include #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" @@ -23,6 +28,8 @@ using namespace o2::framework; using namespace o2::framework::expressions; struct UpcVetoAnalysis { + bool fIsCreated = false; + // amplitude axis int fNbAmp = 101; double fMinAmp = 0.; @@ -152,7 +159,8 @@ struct UpcVetoAnalysis { int nZdcs = zdcs.size(); const o2::aod::BCs::iterator& fbc = bcs.begin(); - if (fbc.runNumber() != fRun) { + if (fbc.runNumber() != fRun && !fIsCreated) { + fIsCreated = true; getBcInfo(fbc); for (auto i = 0; i < o2::constants::lhc::LHCMaxBunches; ++i) { @@ -373,12 +381,12 @@ struct UpcVetoAnalysis { for (auto r = 0; r <= 10; ++r) { auto maxAmpV0A = -999.f; auto maxAmpT0A = -999.f; - auto s = gbc - r; - auto e = gbc + r; + int64_t s = gbc - r; + int64_t e = gbc + r; auto lower = std::lower_bound(gbcs.begin(), gbcs.end(), s); if (lower != gbcs.end()) { auto idx = std::distance(gbcs.begin(), lower); - while (gbcs[idx] >= s && gbcs[idx] <= e && idx < gbcs.size()) { + while (gbcs[idx] >= s && gbcs[idx] <= e && idx < std::ssize(gbcs)) { auto aV0A = vBcIdsWithV0A[idx]; auto aT0A = vBcIdsWithT0A[idx]; if (aV0A > maxAmpV0A) diff --git a/Scripts/find_dependencies.py b/Scripts/find_dependencies.py index 98fcbc0b9e2..10bd68ee91e 100755 --- a/Scripts/find_dependencies.py +++ b/Scripts/find_dependencies.py @@ -72,7 +72,7 @@ def load_workflows_from_json(): # Get the workflow name from the JSON file name workflow = os.path.basename(file_json).split(".")[0] try: - with open(file_json, "r") as j: + with open(file_json, "r", encoding="utf8", errors="ignore") as j: specs_wf = json.load(j) db_wf[workflow] = specs_wf["workflow"] except FileNotFoundError: diff --git a/Scripts/o2_linter.py b/Scripts/o2_linter.py new file mode 100644 index 00000000000..f88911d1ee9 --- /dev/null +++ b/Scripts/o2_linter.py @@ -0,0 +1,1520 @@ +#!/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. + +"""! +@brief O2 linter (Find O2-specific issues in O2 code) +@author Vít Kučera , Inha University +@date 2024-07-14 +""" + +import argparse +import os +import re +import sys +from abc import ABC +from typing import Union + +github_mode = False # GitHub mode +prefix_disable = "o2-linter: disable=" # prefix for disabling tests + + +def is_camel_case(name: str) -> bool: + """forExample or ForExample""" + return "_" not in name and "-" not in name and " " not in name + + +def is_upper_camel_case(name: str) -> bool: + """ForExample""" + if not name: + return False + return name[0].isupper() and is_camel_case(name) + + +def is_lower_camel_case(name: str) -> bool: + """forExample""" + if not name: + return False + return name[0].islower() and is_camel_case(name) + + +def is_kebab_case(name: str) -> bool: + """for-example""" + if not name: + return False + return name.islower() and "_" not in name and " " not in name + + +def is_snake_case(name: str) -> bool: + """for_example""" + if not name: + return False + return name.islower() and "-" not in name and " " not in name + + +def is_screaming_snake_case(name: str) -> bool: + """FOR_EXAMPLE""" + if not name: + return False + return name.isupper() and "-" not in name and " " not in name + + +def kebab_case_to_camel_case_u(line: str) -> str: + """Convert kebab-case string to UpperCamelCase string.""" + return "".join([w.title() if w[0].isnumeric() else w.capitalize() for w in line.split("-")]) + + +def kebab_case_to_camel_case_l(line: str) -> str: + """Convert kebab-case string to lowerCamelCase string.""" + new_line = kebab_case_to_camel_case_u(line) + return f"{new_line[0].lower()}{new_line[1:]}" # start with lowercase letter + + +def camel_case_to_kebab_case(line: str) -> str: + """Convert CamelCase string to kebab-case string. + As done in O2/Framework/Foundation/include/Framework/TypeIdHelpers.h:type_to_task_name + """ + if not line.strip(): + return line + new_line = [] + for i, c in enumerate(line): + if i > 0 and c.isupper() and line[i - 1] != "-": + new_line.append("-") + new_line.append(c.lower()) + 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(("//", "/*")) + + +def remove_comment_cpp(line: str) -> str: + """Remove C++ comments from the end of a line.""" + for keyword in ("//", "/*"): + if keyword in line: + line = line[: line.index(keyword)] + return line.strip() + + +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]]" = [] + if not all((line, len(char_open) == 1, len(char_close) == 1)): + return list_ranges + + def direction(char: str) -> int: + if char == char_open: + return 1 + if char == char_close: + return -1 + return 0 + + list_levels = [] # list of block levels (net number of opened blocks) + level_sum = 0 # current block level (sum of previous directions) + for char in line: + list_levels.append(level_sum := level_sum + direction(char)) + level_min = min(list_levels) # minimum level (!= 0 if line has opened blocks) + # Look for openings (level_min + 1) and closings (level_min). + index_start = -1 + is_opened = False + # print(list_levels) + for i, level in enumerate(list_levels): + if not is_opened and level > level_min: + is_opened = True + index_start = i + # print(f"Opening at {i}") + elif is_opened and (level == level_min or i == len(list_levels) - 1): + is_opened = False + list_ranges.append([index_start, i]) + # print(f"Closing at {i}") + # print(f"block_ranges: Found {len(list_ranges)} blocks: {list_ranges}.") + if is_opened: + print("block_ranges: Block left opened.") + return list_ranges + + +class TestSpec(ABC): + """Prototype of a test class""" + + name = "test-template" # short name of the test + message = "Test failed" # error message + suffixes: "list[str]" = [] # suffixes of files to test + per_line = True # Test lines separately one by one. + n_issues = 0 # issue counter + + def file_matches(self, path: str) -> bool: + """Test whether the path matches the pattern for files to test.""" + return path.endswith(tuple(self.suffixes)) if self.suffixes else True + + def is_disabled(self, line: str, prefix_comment="//") -> bool: + """Detect whether the test is explicitly disabled.""" + for prefix in [prefix_comment, prefix_disable]: + if prefix not in line: + return False + line = line[(line.index(prefix) + len(prefix)) :] # Strip away part before prefix. + if self.name in line: + return True + return False + + def test_line(self, line: str) -> bool: + """Test a line.""" + raise NotImplementedError() + + 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: + """Run the test.""" + # print(content) + passed = True + 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. + line = line.strip() + if not line: + continue + # print(i + 1, line) + if self.is_disabled(line): + continue + if not self.test_line(line): + passed = False + self.n_issues += 1 + print_error(path, i + 1, self.name, 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 + + +########################## +# Implementations of tests +########################## + +# Bad practice + + +class TestIOStream(TestSpec): + """Detect included iostream.""" + + name = "include-iostream" + message = "Including iostream is discouraged. Use O2 logging instead." + suffixes = [".h", ".cxx"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + return not line.startswith("#include ") + + +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." + suffixes = [".h"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + return not line.startswith("using std::") + + +class TestUsingDirectives(TestSpec): + """Detect using directives in headers.""" + + name = "using-directive" + message = "Using directives are not allowed in headers." + suffixes = [".h"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + return not line.startswith("using namespace") + + +class TestStdPrefix(TestSpec): + """Detect missing std:: prefix for common names from the std namespace.""" + + name = "std-prefix" + message = "Use std:: prefix for names from the std namespace." + suffixes = [".h", ".cxx", ".C"] + prefix_bad = r"[^\w:\.\"]" + patterns = [ + r"vector<", + r"array[<\{\(]", + r"f?abs\(", + r"sqrt\(", + r"pow\(", + r"min\(", + r"max\(", + r"log(2|10)?\(", + r"exp\(", + r"a?(sin|cos|tan)h?\(", + r"atan2\(", + r"erfc?\(", + r"hypot\(", + ] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + for pattern in self.patterns: + iterators = re.finditer(rf"{self.prefix_bad}{pattern}", line) + matches = [(it.start(), it.group()) for it in iterators] + if not matches: + continue + 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 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 + return True + + +class TestROOT(TestSpec): + """Detect unnecessary use of ROOT entities.""" + + name = "root-entity" + message = "Consider replacing ROOT entities with equivalents from standard C++ or from O2." + 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"TMath::(Abs|Sqrt|Power|Min|Max|Log(2|10)?|Exp|A?(Sin|Cos|Tan)H?|ATan2|Erfc?|Hypot)\(|" + r"(U?(Int|Char|Short)|Double(32)?|Float(16)?|U?Long(64)?|Bool)_t" + ) + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return re.search(pattern, line) is None + + +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." + 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" + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return re.search(pattern, line) is None + + +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." + suffixes = [".h", ".cxx"] + + def test_line(self, line: str) -> bool: + pattern_two_pi = ( + r"(2(\.0*f?)? \* (M_PI|TMath::Pi\(\)|(((o2::)?constants::)?math::)?PI)|" + r"(((o2::)?constants::)?math::)?TwoPI|TMath::TwoPi\(\))" + ) + pattern = rf"[\+-]=? {pattern_two_pi}" + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return re.search(pattern, line) is None + + +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." + 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}" + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return re.search(pattern, line) is None + + +class TestPdgDatabase(TestSpec): + """Detect use of TDatabasePDG.""" + + name = "pdg/database" + message = ( + "Direct use of TDatabasePDG is not allowed. " + "Use o2::constants::physics::Mass... or Service." + ) + 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: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return "TDatabasePDG" not in line + + +class TestPdgCode(TestSpec): + """Detect use of 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." + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + 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) + if match: + code = match.group(1) + if code not in ("0", "1", "999"): + return False + return True + + +class TestPdgMass(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." + ) + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + 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 + + +class TestLogging(TestSpec): + """Detect non-O2 logging.""" + + name = "logging" + message = "Consider using O2 logging (LOG, LOGF, LOGP)." + 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"^([Pp]rintf\(|(std::)?cout <)" + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + return re.search(pattern, line) is None + + +class TestConstRefInForLoop(TestSpec): + """Test const refs in range-based for loops.""" + + name = "const-ref-in-for-loop" + message = "Use constant references for non-modified iterators in range-based for loops." + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + line = remove_comment_cpp(line) + if not re.match(r"for \(.* :", line): + return True + line = line[: line.index(" :")] # keep only the iterator part + return re.search(r"(\w const|const \w+)& ", line) is not None + + +class TestConstRefInSubscription(TestSpec): + """Test const refs in process function subscriptions. + Test only top-level process functions (called process() or has PROCESS_SWITCH). + """ + + name = "const-ref-in-process" + message = "Use constant references for table subscriptions in process functions." + suffixes = [".cxx"] + per_line = False + + def test_file(self, path: str, content) -> bool: + passed = True + n_parens_opened = 0 # number of opened parentheses + arguments = "" # process function arguments + line_process = 0 # line number of the process function + # Find names of all top-level process functions. + names_functions = ["process"] # names of allowed process functions to test + for i, line in enumerate(content): + line = line.strip() + if is_comment_cpp(line): + continue + if not line.startswith("PROCESS_SWITCH"): + continue + words = line.split() + if len(words) < 2: + passed = False + 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]}.") + # Test process functions. + for i, line in enumerate(content): + line = line.strip() + if is_comment_cpp(line): + continue + if self.is_disabled(line): + continue + if "//" in line: # Remove comment. (Ignore /* to avoid truncating at /*parameter*/.) + line = line[: line.index("//")] + if (match := re.match(r"void (process[\w]*)\(", line)) and match.group(1) in names_functions: + line_process = i + 1 + i_closing = line.rfind(")") + i_start = line.index("(") + 1 + i_end = i_closing if i_closing != -1 else len(line) + arguments = line[i_start:i_end] # get arguments between parentheses + n_parens_opened = line.count("(") - line.count(")") + elif n_parens_opened > 0: + i_closing = line.rfind(")") + i_start = 0 + i_end = i_closing if i_closing != -1 else len(line) + arguments += " " + line[i_start:i_end] # get arguments between parentheses + n_parens_opened += line.count("(") - line.count(")") + if line_process > 0 and n_parens_opened == 0: + # Process arguments. + # Sanitise arguments with spaces between <>. + for start, end in block_ranges(arguments, "<", ">"): + arg = arguments[start : (end + 1)] + # print(f"Found argument \"{arg}\" in [{start}, {end}]") + if ", " in arg: + arguments = arguments.replace(arg, arg.replace(", ", "__")) + # Extract arguments. + words = arguments.split(", ") + # Test each argument. + 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&.") + line_process = 0 + return passed + + +class TestWorkflowOptions(TestSpec): + """Detect usage of workflow options in defineDataProcessing. (Not supported on AliHyperloop.)""" + + name = "o2-workflow-options" + message = ( + "Do not use workflow options to customise workflow topology composition in defineDataProcessing. " + "Use process function switches or metadata instead." + ) + 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 + if not line.strip(): + continue + if self.is_disabled(line): + continue + if is_comment_cpp(line): + continue + line = remove_comment_cpp(line) + # Wait for defineDataProcessing. + if not is_inside_define: + if not re.match(r"((o2::)?framework::)?WorkflowSpec defineDataProcessing\(", line): + continue + # print(f"{i + 1}: Entering define.") + is_inside_define = True + # Return at the end of defineDataProcessing. + if is_inside_define and line[0] == "}": + # print(f"{i + 1}: Exiting define.") + break + # Detect options. + if ".options()" in line: + return False + return True + + +# Documentation +# Reference: https://rawgit.com/AliceO2Group/CodingGuidelines/master/comments_guidelines.html + + +class TestDocumentationFile(TestSpec): + """Test mandatory documentation of C++ files.""" + + name = "doc/file" + message = "Provide mandatory file documentation." + suffixes = [".h", ".cxx", ".C"] + per_line = False + + def test_file(self, path: str, content) -> bool: + passed = False + doc_items = [] + doc_items.append({"keyword": "file", "pattern": rf"{os.path.basename(path)}$", "found": False}) + doc_items.append({"keyword": "brief", "pattern": r"\w.* \w", "found": False}) # at least two words + doc_items.append({"keyword": "author", "pattern": r"[\w]+", "found": False}) + doc_prefix = "///" + n_lines_copyright = 11 + last_doc_line = n_lines_copyright + + for i, line in enumerate(content): + if i < n_lines_copyright: # Skip copyright lines. + continue + if line.strip() and not line.startswith(doc_prefix): # Stop at the first non-empty non-doc line. + break + if line.startswith(doc_prefix): + last_doc_line = i + 1 + 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']}.") + break + if all(item["found"] for item in doc_items): # All items have been found. + passed = True + break + if not passed: + for item in doc_items: + if not item["found"]: + print_error( + path, + last_doc_line, + self.name, + f"Documentation for \\{item['keyword']} is missing, incorrect or misplaced.", + ) + return passed + + +# Naming conventions +# Reference: https://rawgit.com/AliceO2Group/CodingGuidelines/master/naming_formatting.html + + +class TestNameFunctionVariable(TestSpec): + """Test names of functions and of most variables. + Might report false positives. + Does not detect multiple variable declarations, i.e. "type name1, name2;" + Does not detect function arguments on the same line as the function declaration. + Does not detect multi-line declarations. + Does not check capitalisation for constexpr because of special rules for constants. See TestNameConstant. + """ + + name = "name/function-variable" + message = "Use lowerCamelCase for names of functions and variables." + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + # Look for declarations of functions and variables. + + # Strip away irrelevant remainders of the line after the object name. + # For functions, stripping after "(" is enough but this way we also identify many declarations of variables. + for keyword in ("(", "{", ";", " = ", "//", "/*"): + if keyword in line: + line = line[: line.index(keyword)] + + # Check the words. + words = line.split() + + # number of words + if len(words) < 2: + return True + + # First word starts with a letter. + if not words[0][0].isalpha(): + return True + + # Reject false positives with same structure. + if words[0] in ( + "return", + "if", + "else", + "new", + "delete", + "delete[]", + "case", + "typename", + "using", + "typedef", + "enum", + "namespace", + "struct", + "class", + ): + return True + if len(words) > 2 and words[1] in ("typename", "class", "struct"): + return True + + # Identify the position of the name for cases "name[n + m]". + funval_name = words[-1] # expecting the name in the last word + if ( + funval_name.endswith("]") and "[" not in funval_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 + index_name = opens_brackets.index(True) # the name is in the first element with "[" + funval_name = words[index_name] + words = words[: (index_name + 1)] # Strip away words after the name. + if len(words) < 2: # Check the adjusted number of words. + return True + + # All words before the name start with an alphanumeric character (underscores not allowed). + # Rejects expressions, e.g. * = += << }, but accepts numbers in array declarations. + if not all(w[0].isalnum() for w in words[:-1]): + return True + + # Extract function/variable name. + if "[" in funval_name: # Remove brackets for arrays. + funval_name = funval_name[: funval_name.index("[")] + if "::" in funval_name: # Remove the class prefix for methods. + funval_name = funval_name.split("::")[-1] + + # Check the name candidate. + + # Names of variables and functions are identifiers. + if not funval_name.isidentifier(): # should be same as ^[\w]+$ + return True + + # print(f"{line} -> {funval_name}") + # return True + # The actual test comes here. + if "constexpr" in words[:-1]: + return is_camel_case(funval_name) + return is_lower_camel_case(funval_name) + + +class TestNameMacro(TestSpec): + """Test macro names.""" + + name = "name/macro" + message = "Use SCREAMING_SNAKE_CASE for names of macros. Leading and double underscores are not allowed." + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + if not line.startswith("#define "): + return True + # Extract macro name. + macro_name = line.split()[1] + if "(" in macro_name: + macro_name = macro_name.split("(")[0] + # The actual test comes here. + if macro_name.startswith("_"): + return False + if "__" in macro_name: + return False + return is_screaming_snake_case(macro_name) + + +class TestNameConstant(TestSpec): + """Test constexpr constant names.""" + + name = "name/constexpr-constant" + message = ( + 'Use UpperCamelCase for names of constexpr constants. Names of special constants may be prefixed with "k".' + ) + suffixes = [".h", ".cxx", ".C"] + + 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: + 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] + # 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" + return is_upper_camel_case(constant_name) + + +class TestNameColumn(TestSpec): + """Test names of O2 columns.""" + + name = "name/o2-column" + message = "Use UpperCamelCase for names of O2 columns and matching lowerCamelCase names for their getters." + suffixes = [".h", ".cxx"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + if not (match := re.match(r"DECLARE(_[A-Z]+)*_COLUMN(_[A-Z]+)*\(", line)): + return True + # Extract names of the column type and getter. + line = remove_comment_cpp(line) + line = line[len(match.group()) :].strip() # Extract part after "(". + if not (match := re.match(r"([^,]+), ([^,\) ]+)", line)): + print(f'Failed to extract column type and getter from "{line}".') + return False + column_type_name = match.group(1) + column_getter_name = match.group(2) + # print(f"Got \"{column_type_name}\" \"{column_getter_name}\"") + # return True + if column_type_name[0] == "_": # probably a macro variable + return True + # The actual test comes here. + if not is_upper_camel_case(column_type_name): + return False + if not is_lower_camel_case(column_getter_name): + return False + return f"{column_type_name[0].lower()}{column_type_name[1:]}" == column_getter_name + + +class TestNameTable(TestSpec): + """Test names of O2 tables.""" + + name = "name/o2-table" + message = "Use UpperCamelCase for names of O2 tables." + suffixes = [".h", ".cxx"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + if not (match := re.match(r"DECLARE(_[A-Z]+)*_TABLES?(_[A-Z]+)*\(", line)): + return True + # Extract names of the table type. + line = remove_comment_cpp(line) + line = line[len(match.group()) :].strip() # Extract part after "(". + if not (match := re.match(r"([^,\) ]+)", line)): + print(f'Failed to extract table type from "{line}".') + return False + table_type_name = match.group(1) + # print(f"Got \"{table_type_name}\"") + # return True + # Check for a version suffix. + if match := re.match(r"(.*)_([0-9]{3})", line): + table_type_name = match.group(1) + # table_version = match.group(2) + # print(f"Got versioned table \"{table_type_name}\", version {table_version}") + if table_type_name[0] == "_": # probably a macro variable + return True + # The actual test comes here. + return is_upper_camel_case(table_type_name) + + +class TestNameNamespace(TestSpec): + """Test names of namespaces.""" + + name = "name/namespace" + message = "Use snake_case for names of namespaces. Double underscores are not allowed." + suffixes = [".h", ".cxx", ".C"] + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + if not line.startswith("namespace "): + return True + # Extract namespace name. + namespace_name = line.split()[1] + if namespace_name == "{": # ignore anonymous namespaces + return True + # The actual test comes here. + if "__" in namespace_name: + return False + return is_snake_case(namespace_name) + + +class TestNameType(TestSpec): + """Test names of defined types.""" + + name = "name/type" + message = "Use UpperCamelCase for names of defined types." + 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)): + return True + # Extract type name. + type_name = match.group(1) + # The actual test comes here. + return is_upper_camel_case(type_name) + + +class TestNameUpperCamelCase(TestSpec): + """Base class for a test of UpperCamelCase names.""" + + keyword = "key" + name = f"name/{keyword}" + message = f"Use UpperCamelCase for names of {keyword}." + 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} "): + 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] + # The actual test comes here. + return is_upper_camel_case(object_name) + + +class TestNameEnum(TestNameUpperCamelCase): + """Test names of enumerators.""" + + keyword = "enum" + name = "name/enum" + message = "Use UpperCamelCase for names of enumerators and their values." + + +class TestNameClass(TestNameUpperCamelCase): + """Test names of classes.""" + + keyword = "class" + name = "name/class" + message = "Use UpperCamelCase for names of classes." + + +class TestNameStruct(TestNameUpperCamelCase): + """Test names of structs.""" + + keyword = "struct" + name = "name/struct" + message = "Use UpperCamelCase for names of structs." + + +class TestNameFileCpp(TestSpec): + """Test names of C++ files.""" + + name = "name/file-cpp" + message = "Use lowerCamelCase or UpperCamelCase for names of C++ files. See the O2 naming conventions for details." + suffixes = [".h", ".cxx", ".C"] + per_line = False + + def test_file(self, path: str, content) -> bool: + file_name = os.path.basename(path) + # workflow file + if re.search(r"(TableProducer|Tasks)/.*\.cxx", path): + return is_lower_camel_case(file_name) + # data model file + if "DataModel/" in path: + return is_upper_camel_case(file_name) + # utility file + if re.search(r"[Uu]til(ity|ities|s)?", file_name): + return is_lower_camel_case(file_name) + return is_camel_case(file_name) + + +class TestNameFilePython(TestSpec): + """Test names of Python files.""" + + name = "name/file-python" + message = "Use snake_case for names of Python files." + suffixes = [".py", ".ipynb"] + per_line = False + + def test_file(self, path: str, content) -> bool: + file_name = os.path.basename(path) + return is_snake_case(file_name) + + +class TestNameWorkflow(TestSpec): + """Test names of O2 workflows.""" + + name = "name/o2-workflow" + message = "Use kebab-case for names of workflows and match the name of the workflow file." + suffixes = ["CMakeLists.txt"] + per_line = False + + def test_file(self, path: str, content) -> bool: + passed = True + workflow_name = "" + for i, line in enumerate(content): + if not line.startswith("o2physics_add_dpl_workflow("): + continue + if self.is_disabled(line, "#"): + continue + # Extract workflow name. + 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}.") + 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}.") + continue + workflow_file_name = os.path.basename(words[1]) # the actual file name + # Generate the file name matching the workflow name. + expected_workflow_file_name = kebab_case_to_camel_case_l(workflow_name) + ".cxx" + # Compare the actual and expected file names. + if expected_workflow_file_name != workflow_file_name: + passed = False + 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}.)", + ) + return passed + + +class TestNameTask(TestSpec): + """Test explicit task names. + Detect usage of TaskName, check whether it is needed and whether the task name matches the struct name.""" + + name = "name/o2-task" + message = "Specify task name only when it cannot be derived from the struct name. Only append to the default name." + suffixes = [".cxx"] + per_line = False + + def test_file(self, path: str, content) -> bool: + is_inside_define = False # Are we inside defineDataProcessing? + is_inside_adapt = False # Are we inside adaptAnalysisTask? + struct_name = "" + struct_templated = False # Is the struct templated? + n_parens_opened = 0 # number of opened parentheses + passed = True + for i, line in enumerate(content): + if not line.strip(): + continue + if self.is_disabled(line): + continue + if is_comment_cpp(line): + continue + line = remove_comment_cpp(line) + # Wait for defineDataProcessing. + if not is_inside_define: + if not re.match(r"((o2::)?framework::)?WorkflowSpec defineDataProcessing\(", line): + continue + # print(f"{i + 1}: Entering define.") + is_inside_define = True + # Return at the end of defineDataProcessing. + if is_inside_define and line[0] == "}": + # print(f"{i + 1}: Exiting define.") + break + # Wait for adaptAnalysisTask. + if not is_inside_adapt: + if (index := line.find("adaptAnalysisTask<")) == -1: + continue + # print(f"{i + 1}: Entering adapt.") + is_inside_adapt = True + 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}".') + return False + struct_name = match.group(1) + if (index := struct_name.find("<")) > -1: + struct_templated = True + # print(f"{i + 1}: Got templated struct name {struct_name}") + struct_name = struct_name[:index] + # print(f"{i + 1}: Got struct name {struct_name}") + line = line[(line.index(struct_name) + len(struct_name)) :] + if is_inside_adapt: + n_parens_opened += line.count("(") - line.count(")") + # print(f"{i + 1}: {n_parens_opened} opened parens") + if n_parens_opened <= 0: + # print(f"{i + 1}: Exiting adapt.") + is_inside_adapt = False + # Find explicit task name. + if "TaskName{" not in line: + continue + 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}".') + return False + task_name = match.group(1) + # print(f"{i + 1}: Got struct \"{struct_name}\" with task name \"{task_name}\".") + # Test explicit task name. + device_name_from_struct_name = camel_case_to_kebab_case( + struct_name + ) # default device name, in absence of TaskName + device_name_from_task_name = camel_case_to_kebab_case( + task_name + ) # actual device name, generated from TaskName + struct_name_from_device_name = kebab_case_to_camel_case_u( + device_name_from_task_name + ) # struct name matching the TaskName + if not is_kebab_case(device_name_from_task_name): + print_error( + path, + i + 1, + self.name, + f"Specified task name {task_name} produces an invalid device name " + f"{device_name_from_task_name}.", + ) + passed = False + 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( + 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.", + ) + passed = False + elif device_name_from_struct_name.replace("-", "") == device_name_from_task_name.replace("-", ""): + # 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( + 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 " + f"to {struct_name_from_device_name} and removing TaskName.", + ) + passed = False + elif device_name_from_task_name.startswith(device_name_from_struct_name): + # If the device name generated from the task name is an extension of the device name generated + # 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( + 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. " + "Is it adapted multiple times?", + ) + passed = False + # else: + # print_error(path, i + 1, self.name, 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( + 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})", + ) + passed = False + return passed + + +class TestNameFileWorkflow(TestSpec): + """Test names of workflow files.""" + + name = "name/workflow-file" + message = ( + "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.)' + ) + suffixes = [".cxx"] + per_line = False + + 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") + 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 + # print(f"For file {file_name} expecting to find {base_struct_name}.") + struct_names = [] # actual struct names in the file + for line in content: + if self.is_disabled(line): + return True + if not line.startswith("struct "): + continue + # Extract struct name. + words = line.split() + if not words[1].isalnum(): # "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 + + +class TestNameConfigurable(TestSpec): + """Test names of configurables.""" + + name = "name/configurable" + message = ( + "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.)" + ) + 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: + if is_comment_cpp(line): + return True + if not line.startswith("Configurable"): + return True + # 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 + if name_json[0] != '"': # JSON name is not a literal string. + return True + name_json = name_json.strip('",') # expecting nameJson + # The actual test comes here. + return is_lower_camel_case(name_cpp) and name_cpp == name_json + + +# 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".' + suffixes = [".h", ".cxx"] + + def file_matches(self, path: str) -> bool: + return super().file_matches(path) and "PWGHF/" in path and "Macros/" not in path + + def test_line(self, line: str) -> bool: + if is_comment_cpp(line): + return True + if not line.startswith(("struct ", "class ")): + return True + line = remove_comment_cpp(line) + # Extract struct/class name. + words = line.split() + if not words[1].isalnum(): # "struct : ..." + return True + struct_name = words[1] + # The actual test comes here. + return struct_name.startswith("Hf") + + +class TestHfNameFileTask(TestSpec): + """PWGHF: Test names of task workflow files.""" + + name = "pwghf/name/task-file" + message = 'Name of a PWGHF task workflow file must start with "task".' + suffixes = [".cxx"] + per_line = False + + def file_matches(self, path: str) -> bool: + return super().file_matches(path) and "PWGHF/" in path and "Macros/" not in path + + 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 + + +class TestHfStructMembers(TestSpec): + """PWGHF: Test order of struct members. + Caveat: Does not see Configurables in ConfigurableGroup.""" + + name = "pwghf/struct-member-order" + message = "Declare struct members in the conventional order. See the PWGHF coding guidelines." + suffixes = [".cxx"] + per_line = False + member_order = [ + "Spawns<", + "Builds<", + "Produces<", + "Configurable<", + "HfHelper ", + "SliceCache ", + "Service<", + "using ", + "Filter ", + "Preslice<", + "PresliceUnsorted<", + "Partition<", + "ConfigurableAxis ", + "AxisSpec ", + "HistogramRegistry ", + "OutputObj<", + "void init(", + "void process", + ] + + def file_matches(self, path: str) -> bool: + return super().file_matches(path) and "PWGHF/" in path + + def test_file(self, path: str, content) -> bool: + passed = True + dic_structs: dict[str, dict] = {} + struct_name = "" + for i, line in enumerate(content): + if is_comment_cpp(line): + continue + if line.startswith("struct "): # expecting no indentation + line = remove_comment_cpp(line) + struct_name = line.strip().split()[1] + dic_structs[struct_name] = {} + continue + if not struct_name: + continue + # Save line numbers of members of the current struct for each category. + for member in self.member_order: + if line.startswith(f" {member}"): # expecting single-level indentation for direct members + if member not in dic_structs[struct_name]: + dic_structs[struct_name][member] = [] + dic_structs[struct_name][member].append(i + 1) # save line number + break + # print(dic_struct) + # Detect members declared in a wrong order. + last_line_last_member = 0 # line number of the last member of the previous member category + index_last_member = 0 # index of the previous member category in the member_order list + for struct_name, dic_struct in dic_structs.items(): + for i_m, member in enumerate(self.member_order): + if member not in dic_struct: + continue + first_line = min(dic_struct[member]) # line number of the first member of this category + last_line = max(dic_struct[member]) # line number of the last member of this category + if ( + first_line < last_line_last_member + ): # The current category starts before the end of the previous category. + passed = False + 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()}).", + ) + last_line_last_member = last_line + index_last_member = i_m + return passed + + +# End of test implementations + + +def main(): + """Main function""" + parser = argparse.ArgumentParser(description="O2 linter (Find O2-specific issues in O2 code)") + parser.add_argument("paths", type=str, nargs="+", help="File path(s)") + parser.add_argument( + "-g", + dest="github", + action="store_true", + help="Print messages also as GitHub annotations", + ) + args = parser.parse_args() + if args.github: + global github_mode # pylint: disable=global-statement + github_mode = True + + tests = [] # list of activated tests + + # Bad practice + enable_bad_practice = True + if enable_bad_practice: + tests.append(TestIOStream()) + tests.append(TestUsingStd()) + tests.append(TestUsingDirectives()) + tests.append(TestStdPrefix()) + tests.append(TestROOT()) + tests.append(TestPi()) + tests.append(TestTwoPiAddSubtract()) + tests.append(TestPiMultipleFraction()) + tests.append(TestPdgDatabase()) + tests.append(TestPdgCode()) + tests.append(TestPdgMass()) + tests.append(TestLogging()) + tests.append(TestConstRefInForLoop()) + tests.append(TestConstRefInSubscription()) + tests.append(TestWorkflowOptions()) + + # Documentation + enable_documentation = True + if enable_documentation: + tests.append(TestDocumentationFile()) + + # Naming conventions + enable_naming = True + if enable_naming: + tests.append(TestNameFunctionVariable()) + tests.append(TestNameMacro()) + tests.append(TestNameConstant()) + tests.append(TestNameColumn()) + tests.append(TestNameTable()) + tests.append(TestNameNamespace()) + tests.append(TestNameType()) + tests.append(TestNameEnum()) + tests.append(TestNameClass()) + tests.append(TestNameStruct()) + tests.append(TestNameFileCpp()) + tests.append(TestNameFilePython()) + tests.append(TestNameWorkflow()) + tests.append(TestNameTask()) + tests.append(TestNameFileWorkflow()) + tests.append(TestNameConfigurable()) + + # PWG-HF + enable_pwghf = True + if enable_pwghf: + tests.append(TestHfNameStructClass()) + tests.append(TestHfNameFileTask()) + tests.append(TestHfStructMembers()) + + 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 + + # Report overview before running. + print(f"Testing {len(args.paths)} files.") + # print(args.paths) + print("Enabled tests:", test_names) + print("Suffixes of tested files:", sorted(suffixes)) + # print(f"Github annotations: {github_mode}.") + + # Test files. + for path in args.paths: + # print(f"Processing path \"{path}\".") + # Skip not tested files. + if not path.endswith(suffixes): + # print(f"Skipping path \"{path}\".") + continue + try: + with open(path, "r", encoding="utf-8") as file: + content = file.readlines() + for test in 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: + 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 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}") + else: + print(f"{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." + ) + if github_mode: + print(f"::error title={title_result}::{msg_result}") + print(f"::notice::{msg_disable}") + else: + print(f"\n{title_result}: {msg_result}") + print(msg_disable) + # Print tips. + print("\nTip: You can run the O2 linter locally with: python3 Scripts/o2_linter.py ") + if not passed: + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/Tools/ML/model.h b/Tools/ML/model.h index bb1ac84a8ae..caca77f1a25 100644 --- a/Tools/ML/model.h +++ b/Tools/ML/model.h @@ -111,6 +111,39 @@ class OnnxModel return evalModel(inputTensors); } + // For 2D inputs + template + T* evalModel(std::vector>& input) + { + std::vector inputTensors; + +#if !__has_include() + Ort::MemoryInfo mem_info = Ort::MemoryInfo::CreateCpu(OrtAllocatorType::OrtArenaAllocator, OrtMemType::OrtMemTypeDefault); +#endif + + for (size_t iinput = 0; iinput < input.size(); iinput++) { + [[maybe_unused]] int totalSize = 1; + int64_t size = input[iinput].size(); + for (size_t idim = 1; idim < mInputShapes[iinput].size(); idim++) { + totalSize *= mInputShapes[iinput][idim]; + } + assert(size % totalSize == 0); + + std::vector inputShape{static_cast(size / totalSize)}; + for (size_t idim = 1; idim < mInputShapes[iinput].size(); idim++) { + 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 + } + + return evalModel(inputTensors); + } + // Reset session #if __has_include() void resetSession() { mSession.reset(new Ort::Experimental::Session{*mEnv, modelPath, sessionOptions}); } diff --git a/Tools/PIDML/CMakeLists.txt b/Tools/PIDML/CMakeLists.txt index cb2f87f4204..8ac36a5c0df 100644 --- a/Tools/PIDML/CMakeLists.txt +++ b/Tools/PIDML/CMakeLists.txt @@ -9,16 +9,22 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -o2physics_add_dpl_workflow(pid-ml-producer-mc - SOURCES pidMLProducerMC.cxx +o2physics_add_dpl_workflow(pid-ml-producer + SOURCES pidMLProducer.cxx JOB_POOL analysis PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) -o2physics_add_dpl_workflow(pid-ml-producer-data - SOURCES pidMLProducerData.cxx +o2physics_add_dpl_workflow(pid-ml-batch-eff-and-pur-producer + SOURCES pidMLBatchEffAndPurProducer.cxx JOB_POOL analysis - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + 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 + JOB_POOL analysis + PUBLIC_LINK_LIBRARIES O2::Framework ONNXRuntime::ONNXRuntime O2::CCDB O2Physics::DataModel COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(simple-apply-pid-onnx-model diff --git a/Tools/PIDML/KaonPidTask.cxx b/Tools/PIDML/KaonPidTask.cxx index 19c0972be4a..acc29e47bee 100644 --- a/Tools/PIDML/KaonPidTask.cxx +++ b/Tools/PIDML/KaonPidTask.cxx @@ -60,7 +60,6 @@ struct KaonPidTask { 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 cfgDetector{"detector", kTPCTOFTRD, "What detectors to use: 0: TPC only, 1: TPC + TOF, 2: TPC + TOF + TRD"}; Configurable cfgTimestamp{"timestamp", 0, "Fixed timestamp"}; Configurable cfgUseCCDB{"useCCDB", false, "Whether to autofetch ML model from CCDB. If false, local file will be used."}; @@ -85,7 +84,7 @@ struct KaonPidTask { 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, static_cast(cfgDetector.value), cfgCertainty.value); + 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}}); diff --git a/Tools/PIDML/README.md b/Tools/PIDML/README.md index 57ada2bb48e..1768ac9e900 100644 --- a/Tools/PIDML/README.md +++ b/Tools/PIDML/README.md @@ -1,6 +1,8 @@ # PID ML in O2 -Particle identification is essential in most of the analyzes. The PID ML interface will help you to make use of the machine learning models to improve purity and efficiency of particle kinds for your analysis. A single model is tailored to a specific particle kind, e.g., pions with PID 211. For each track, the model returns a float value in [0, 1] which measures the ''certainty'' of the model that this track is of given kind. +Particle identification is essential in most of the analyzes. +The PID ML interface will help you to make use of the machine learning models to improve purity and efficiency of particle kinds for your analysis. +A single model is tailored to a specific particle kind, e.g., pions with PID 211. For each track, the model returns a float value in [0, 1] which measures the ''certainty'' of the model that this track is of given kind. ## PidONNXModel @@ -11,12 +13,16 @@ This class represents a single ML model from an ONNX file. It requires the follo - CCDB Api instance created in an analysis task - timestamp of the input analysis data -- neded to choose appropriate model - PID to be checked -- detector setup: what detectors should be used for identification. It is described by enum PidMLDetector. Currently available setups: TPC, TPC+TOF, TPC+TOF+TRD - minimum certainty for accepting a track to be of given PID +- *p* limits array - specifiying p limits for each detector configuration (TPC, TPC+TOF, TPC+TOF+TRD) -Let's assume your `PidONNXModel` instance is named `pidModel`. Then, inside your analysis task `process()` function, you can iterate over tracks and call: `pidModel.applyModel(track);` to get the certainty of the model. You can also use `pidModel.applyModelBoolean(track);` to receive a true/false answer, whether the track can be accepted based on the minimum certainty provided to the `PidONNXModel` constructor. +Let's assume your `PidONNXModel` instance is named `pidModel`. +Then, inside your analysis task `process()` function, you can iterate over tracks and call: `pidModel.applyModel(track);` to get the certainty of the model. +You can also use `pidModel.applyModelBoolean(track);` to receive a true/false answer, whether the track can be accepted based on the minimum certainty provided to the `PidONNXModel` constructor. -You can check [a simple analysis task example](https://github.com/AliceO2Group/O2Physics/blob/master/Tools/PIDML/simpleApplyPidOnnxModel.cxx). It uses configurable parameters and shows how to calculate the data timestamp. Note that the calculation of the timestamp requires subscribing to `aod::Collisions` and `aod::BCsWithTimestamps`. For Hyperloop tests, you can set `cfgUseFixedTimestamp` to true with `cfgTimestamp` set to the default value. +You can check [a simple analysis task example](https://github.com/AliceO2Group/O2Physics/blob/master/Tools/PIDML/simpleApplyPidOnnxModel.cxx). +It uses configurable parameters and shows how to calculate the data timestamp. Note that the calculation of the timestamp requires subscribing to `aod::Collisions` and `aod::BCsWithTimestamps`. +For Hyperloop tests, you can set `cfgUseFixedTimestamp` to true with `cfgTimestamp` set to the default value. On the other hand, it is possible to use locally stored models, and then the timestamp is not used, so it can be a dummy value. `processTracksOnly` presents how to analyze on local-only PID ML models. @@ -31,10 +37,10 @@ This is a wrapper around PidONNXModel that contains several models. It has the p Then, obligatory parameters for the interface: - a vector of int output PIDs -- a 2-dimensional LabeledArray of *p*T limits for each PID, for each detector configuration. It describes the minimum *p*T values at which each next detector should be included for predicting given PID +- a 2-dimensional LabeledArray of *p* limits for each PID, for each detector configuration. It describes the minimum *p* values at which each next detector should be included for predicting given PID - a vector of minimum certainties for each PID for accepting a track to be of this PID - boolean flag: whether to switch on auto mode. If true, then *p*T limits and minimum certainties can be passed as an empty array and an empty vector, and the interface will fill them with default configuration: - - *p*T limits: same values for all PIDs: 0.0 (TPC), 0.5 (TPC + TOF), 0.8 (TPC + TOF + TRD) + - *p* limits: same values for all PIDs: 0.0 (TPC), 0.5 (TPC + TOF), 0.8 (TPC + TOF + TRD) - minimum certainties: 0.5 for all PIDs You can use the interface in the same way as the model, by calling `applyModel(track)` or `applyModelBoolean(track)`. The interface will then call the respective method of the model selected with the aforementioned interface parameters. @@ -48,20 +54,49 @@ There is again [a simple analysis task example](https://github.com/AliceO2Group/ Currently, only models for run 285064 (timestamp interval: 1524176895000 - 1524212953000) are uploaded to CCDB, so you can use hardcoded timestamp 1524176895000 for tests. Both model and interface analysis examples can be run with a script: + +### Script for Run2 Converted to Run3 data +```bash +#!/bin/bash + +config_file="my-config.json" + +o2-analysis-tracks-extra-converter --configuration json://$config_file -b | + o2-analysis-timestamp --configuration json://$config_file -b | + o2-analysis-trackextension --configuration json://$config_file -b | + o2-analysis-trackselection --configuration json://$config_file -b | + o2-analysis-multiplicity-table --configuration json://$config_file -b | + o2-analysis-bc-converter --configuration json://$config_file -b | + o2-analysis-collision-converter --configuration json://$config_file -b | + o2-analysis-zdc-converter --configuration json://$config_file -b | + o2-analysis-pid-tof-base --configuration json://$config_file -b | + o2-analysis-pid-tof-beta --configuration json://$config_file -b | + o2-analysis-pid-tof-full --configuration json://$config_file -b | + o2-analysis-pid-tpc-full --configuration json://$config_file -b | + o2-analysis-pid-tpc-base --configuration json://$config_file -b | + o2-analysis-simple-apply-pid-onnx-model --configuration json://$config_file -b +``` +Remember to set every setting, which states that helper task should process Run2 data to `true`. + +### Script for Run3 data ```bash #!/bin/bash config_file="my-config.json" o2-analysis-timestamp --configuration json://$config_file -b | - o2-analysis-trackextension --configuration json://$config_file -b | - o2-analysis-trackselection --configuration json://$config_file -b | - o2-analysis-multiplicity-table --configuration json://$config_file -b | - o2-analysis-fdd-converter --configuration json://$config_file -b | - o2-analysis-pid-tof-base --configuration json://$config_file -b | - o2-analysis-pid-tof-beta --configuration json://$config_file -b | - o2-analysis-pid-tof-full --configuration json://$config_file -b | - o2-analysis-pid-tpc-full --configuration json://$config_file -b | - o2-analysis-simple-apply-pid-onnx-model --configuration json://$config_file -b + o2-analysis-event-selection --configuration json://$config_file -b | + o2-analysis-trackselection --configuration json://$config_file -b | + o2-analysis-multiplicity-table --configuration json://$config_file -b | + o2-analysis-track-propagation --configuration json://$config_file -b | + o2-analysis-pid-tof-base --configuration json://$config_file -b | + o2-analysis-pid-tof-beta --configuration json://$config_file -b | + o2-analysis-pid-tof-full --configuration json://$config_file -b | + o2-analysis-pid-tpc-full --configuration json://$config_file -b | + o2-analysis-pid-tpc-base --configuration json://$config_file -b | + o2-analysis-simple-apply-pid-onnx-model --configuration json://$config_file -b ``` +Remember to set every setting, which states that helper task should process Run3 data to `true`. + + Replace "model" with "interface" in the last line if you want to run the interface workflow. diff --git a/Tools/PIDML/pidMLBatchEffAndPurProducer.cxx b/Tools/PIDML/pidMLBatchEffAndPurProducer.cxx new file mode 100644 index 00000000000..9a611ded269 --- /dev/null +++ b/Tools/PIDML/pidMLBatchEffAndPurProducer.cxx @@ -0,0 +1,246 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 pidMLBatchEffAndPurProducer +/// \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 +/// +/// \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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace pidml::pidutils; + +namespace o2::aod +{ +namespace effandpurpidresult +{ +DECLARE_SOA_INDEX_COLUMN(Track, track); //! Track index +DECLARE_SOA_COLUMN(Pid, pid, int32_t); //! PDG particle ID to be tested by the model +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 +} // namespace effandpurpidresult + +DECLARE_SOA_TABLE(EffAndPurPidResult, "AOD", "PIDEFFANDPURRES", o2::soa::Index<>, + effandpurpidresult::TrackId, effandpurpidresult::Pid, effandpurpidresult::Pt, effandpurpidresult::MlCertainty, + effandpurpidresult::NSigma, effandpurpidresult::IsPidMC, effandpurpidresult::HasTOF, effandpurpidresult::HasTRD); +} // namespace o2::aod + +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"}; + + 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"}; + + Filter trackFilter = requireGlobalTrackInFilter(); + + using BigTracks = soa::Filtered>; + + 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}); + } + }); + } + + void init(InitContext const&) + { + if (cfgUseCCDB) { + ccdbApi.init(cfgCCDBURL); + } + + initHistos(); + } + + std::optional getPartIndex(int32_t pdgCode) + { + std::optional index; + + if (std::find(cfgPids.value.begin(), cfgPids.value.end(), pdgCode) != cfgPids.value.end()) { + switch (pdgCode) { + case 2212: + index = 0; + break; + case 321: + index = 1; + break; + case 211: + index = 2; + break; + case -211: + index = 3; + break; + case -321: + index = 4; + break; + case -2212: + index = 5; + break; + } + } + + return index; + } + + void fillTrackedHist(int32_t pdgCode, float pt) + { + auto ind = getPartIndex(pdgCode); + if (ind) { + hTracked[ind.value()]->Fill(pt); + } + } + + void fillMCPositiveHist(int32_t pdgCode, float pt) + { + auto ind = getPartIndex(pdgCode); + if (ind) { + hMCPositive[ind.value()]->Fill(pt); + } + } + + typedef struct nSigma_t { + double tpc, tof, composed; + } nSigma_t; + + const nSigma_t getNSigma(const BigTracks::iterator& track, const int32_t& cfgPid) + { + nSigma_t nSigma; + + switch (TMath::Abs(cfgPid)) { + case 11: // electron + nSigma.tof = track.tofNSigmaEl(); + nSigma.tpc = track.tpcNSigmaEl(); + break; + case 13: // muon + nSigma.tof = track.tofNSigmaMu(); + nSigma.tpc = track.tpcNSigmaMu(); + break; + case 211: // pion + nSigma.tof = track.tofNSigmaPi(); + nSigma.tpc = track.tpcNSigmaPi(); + break; + case 321: // kaon + nSigma.tof = track.tofNSigmaKa(); + nSigma.tpc = track.tpcNSigmaKa(); + break; + case 2212: // proton + nSigma.tof = track.tofNSigmaPr(); + nSigma.tpc = track.tpcNSigmaPr(); + break; + } + + if (!inPLimit(track, cfgDetectorsPLimits.value[kTPCTOF]) || tofMissing(track)) { + nSigma.composed = TMath::Abs(nSigma.tpc); + } else { + nSigma.composed = TMath::Hypot(nSigma.tof, nSigma.tpc); + } + + int32_t sign = cfgPid > 0 ? 1 : -1; + if (sign != track.sign()) { + nSigma.composed = std::numeric_limits::max(); + } + + return nSigma; + } + + void process(aod::Collisions const& collisions, BigTracks const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& mcParticles) + { + 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])); + } 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 (auto& mcPart : mcParticles) { + // eta cut is done in requireGlobalTrackInFilter() so we cut it only here + if (mcPart.isPhysicalPrimary() && TMath::Abs(mcPart.eta()) < kGlobalEtaCut) { + fillMCPositiveHist(mcPart.pdgCode(), mcPart.pt()); + } + } + + for (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) { + float mlCertainty = models[i].applyModel(track); + nSigma_t nSigma = getNSigma(track, cfgPids.value[i]); + bool isMCPid = mcPart.pdgCode() == cfgPids.value[i]; + + effAndPurPIDResult(track.index(), cfgPids.value[i], track.pt(), mlCertainty, nSigma.composed, isMCPid, track.hasTOF(), track.hasTRD()); + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tools/PIDML/pidMLEffAndPurProducer.cxx b/Tools/PIDML/pidMLEffAndPurProducer.cxx new file mode 100644 index 00000000000..7e626a8d631 --- /dev/null +++ b/Tools/PIDML/pidMLEffAndPurProducer.cxx @@ -0,0 +1,213 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +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 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"}; + + o2::ccdb::CcdbApi ccdbApi; + int currentRunNumber = -1; + + Filter trackFilter = requireGlobalTrackInFilter(); + + using BigTracks = soa::Filtered>; + + typedef struct nSigma_t { + double tpc, tof; + } nSigma_t; + + nSigma_t GetNSigma(const BigTracks::iterator& track) + { + nSigma_t nSigma; + + switch (TMath::Abs(cfgPid)) { + case 11: // electron + nSigma.tof = track.tofNSigmaEl(); + nSigma.tpc = track.tpcNSigmaEl(); + break; + case 13: // muon + nSigma.tof = track.tofNSigmaMu(); + nSigma.tpc = track.tpcNSigmaMu(); + break; + case 211: // pion + nSigma.tof = track.tofNSigmaPi(); + nSigma.tpc = track.tpcNSigmaPi(); + break; + case 321: // kaon + nSigma.tof = track.tofNSigmaKa(); + nSigma.tpc = track.tpcNSigmaKa(); + break; + case 2212: // proton + nSigma.tof = track.tofNSigmaPr(); + nSigma.tpc = track.tpcNSigmaPr(); + break; + } + + return nSigma; + } + + bool IsNSigmaAccept(const BigTracks::iterator& track, 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; + if (track.sign() != sign) + return false; + + if (!inPLimit(track, cfgDetectorsPLimits.value[kTPCTOF]) || tofMissing(track)) { + if (TMath::Abs(nSigma.tpc) >= cfgNSigmaCut) + return false; + } else { + if (TMath::Hypot(nSigma.tof, nSigma.tpc) >= cfgNSigmaCut) + return false; + } + + return true; + } + + void init(InitContext const&) + { + if (cfgUseCCDB) { + ccdbApi.init(cfgCCDBURL); + } else { + pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, + cfgPid.value, cfgCertainty.value, &cfgDetectorsPLimits.value[0]); + } + + const AxisSpec axisPt{100, 0, 5.0, "pt"}; + const AxisSpec axisP{100, 0, 5.0, "p"}; + const AxisSpec axisBeta{100, 0, 1.0, "beta"}; + const AxisSpec axisTPCSignal{100, 0, 120.0, "dEdx"}; + const AxisSpec axisNSigma{100, -5.0, 5.0, "n-sigma"}; + + // Monte Carlo + histos.add("hPtMCPositive", "hPtMCPositive", kTH1F, {axisPt}); + histos.add("hPtMCTracked", "hPtMCTracked", kTH1F, {axisPt}); + + // Machine learning PID + histos.add("hPtMLPositive", "hPtMLPositive", kTH1F, {axisPt}); + histos.add("hPtMLTruePositive", "hPtMLTruePositive", kTH1F, {axisPt}); + + // NSigma PID + histos.add("hPtNSigmaPositive", "hPtNSigmaPositive", kTH1F, {axisPt}); + histos.add("hPtNSigmaTruePositive", "hPtNSigmaTruePositive", kTH1F, {axisPt}); + + // Context detectors' data + histos.add("full/hPtTOFBeta", "full/hPtTOFBeta", kTH2F, {axisP, axisBeta}); + histos.add("full/hPtTPCSignal", "full/hPtTPCSignal", kTH2F, {axisP, axisTPCSignal}); + histos.add("full/hPtTOFNSigma", "full/hPtTOFNSigma", kTH2F, {axisP, axisNSigma}); + histos.add("full/hPtTPCNSigma", "full/hPtTPCNSigma", kTH2F, {axisP, axisNSigma}); + + histos.add("hPtTOFNSigma", "hPtTOFNSigma", kTH2F, {axisP, axisNSigma}); + histos.add("hPtTPCNSigma", "hPtTPCNSigma", kTH2F, {axisP, axisNSigma}); + } + + 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]); + } + + for (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) { + histos.fill(HIST("hPtMCPositive"), mcPart.pt()); + } + } + + for (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); + + 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()); + + if (mcPart.pdgCode() == pidModel.mPid) { + histos.fill(HIST("full/hPtTOFNSigma"), track.p(), nSigma.tof); + histos.fill(HIST("full/hPtTPCNSigma"), track.p(), nSigma.tpc); + histos.fill(HIST("hPtMCTracked"), track.pt()); + } + + histos.fill(HIST("full/hPtTOFBeta"), track.pt(), track.beta()); + histos.fill(HIST("full/hPtTPCSignal"), track.pt(), track.tpcSignal()); + + if (mlAccepted) { + if (mcPart.pdgCode() == pidModel.mPid) { + histos.fill(HIST("hPtMLTruePositive"), track.pt()); + } + histos.fill(HIST("hPtMLPositive"), track.pt()); + } + + if (nSigmaAccepted) { + histos.fill(HIST("hPtTOFNSigma"), track.p(), nSigma.tof); + histos.fill(HIST("hPtTPCNSigma"), track.p(), nSigma.tpc); + + if (mcPart.pdgCode() == pidModel.mPid) { + histos.fill(HIST("hPtNSigmaTruePositive"), track.pt()); + } + histos.fill(HIST("hPtNSigmaPositive"), track.pt()); + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tools/PIDML/pidMLProducer.cxx b/Tools/PIDML/pidMLProducer.cxx new file mode 100644 index 00000000000..67cf4308a5e --- /dev/null +++ b/Tools/PIDML/pidMLProducer.cxx @@ -0,0 +1,341 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 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 "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Tools/PIDML/pidML.h" +#include "Tools/PIDML/pidUtils.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace pidml::pidutils; + +// Naming convention +// Data: experimental data without simulation +// MC: experimental data with Monte Carlo simulation +// ML: only columns used by Machine Learning network +struct PidMlProducer { + Produces pidTracksTableDataML; + Produces pidTracksTableData; + Produces pidTracksTableMCML; + Produces pidTracksTableMC; + + Filter trackFilter = requireGlobalTrackInFilter(); + + // Data tracks + using BigTracksDataML = soa::Filtered>; + using BigTracksData = soa::Filtered>; + + // MC tracks + using BigTracksMCML = soa::Filtered>; + using BigTracksMC = soa::Filtered>; + + using MyCollisionML = aod::Collisions::iterator; + using MyCollision = soa::Join::iterator; + + static constexpr uint32_t nCharges = 2; + + 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; + + // 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; + + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + static const char* genTagvsP(const char* name) + { + return Form("%s vs #it{p};#it{p} (GeV/#it{c});%s", name, name); + } + + 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.}}); + } + + 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}}); + } + + template + void fillHistSign(const T& track) + { + hTPCSigvsP[prefixInd]->Fill(track.p(), track.tpcSignal()); + hTOFBetavsP[prefixInd]->Fill(track.p(), track.beta()); + hTOFSigvsP[prefixInd]->Fill(track.p(), track.tofSignal()); + if (tofMissing(track)) { + hFilteredTOFSigvsP[prefixInd]->Fill(track.p(), kTOFMissingSignal); + } else { + hFilteredTOFSigvsP[prefixInd]->Fill(track.p(), track.tofSignal()); + } + hTRDPattvsP[prefixInd]->Fill(track.p(), track.trdPattern()); + hTRDSigvsP[prefixInd]->Fill(track.p(), track.trdSignal()); + hP[prefixInd]->Fill(track.p()); + hPt[prefixInd]->Fill(track.pt()); + hPx[prefixInd]->Fill(track.px()); + hPy[prefixInd]->Fill(track.py()); + hPz[prefixInd]->Fill(track.pz()); + hX[prefixInd]->Fill(track.x()); + hY[prefixInd]->Fill(track.y()); + hZ[prefixInd]->Fill(track.z()); + hAlpha[prefixInd]->Fill(track.alpha()); + hTrackType[prefixInd]->Fill(track.trackType()); + hTPCNClsShared[prefixInd]->Fill(track.tpcNClsShared()); + hDcaXY[prefixInd]->Fill(track.dcaXY()); + hDcaZ[prefixInd]->Fill(track.dcaZ()); + } + + template + void fillHistSignMC(const T& track, uint32_t pdgCode, uint8_t isPrimary) + { + fillHistSign(track); + hPdgCode[prefixInd]->Fill(pdgCode); + hIsPrimary[prefixInd]->Fill(isPrimary); + } + + template + void fillHistMC(const T& track, uint32_t pdgCode, uint8_t isPrimary) + { + if (track.sign() < 0) { + fillHistSignMC<0>(track, pdgCode, isPrimary); + } else { + fillHistSignMC<1>(track, pdgCode, isPrimary); + } + } + + template + void fillHist(const T& track) + { + if (track.sign() < 0) { + fillHistSign<0>(track); + } else { + fillHistSign<1>(track); + } + } + + void init(InitContext&) + { + if (doprocessMcMl || doprocessMcAll) { + initHistSignMC<0>(); + initHistSignMC<1>(); + } else { + initHistSign<0>(); + initHistSign<1>(); + } + } + + template + float getTOFSignal(T const& track) + { + return tofMissing(track) ? std::numeric_limits::quiet_NaN() : track.tofSignal(); + } + + template + float getTOFBeta(T const& track) + { + return tofMissing(track) ? std::numeric_limits::quiet_NaN() : track.beta(); + } + + template + float getTRDSignal(T const& track) + { + return trdMissing(track) ? std::numeric_limits::quiet_NaN() : track.trdSignal(); + } + + template + uint8_t getTRDPattern(T const& track) + { + return trdMissing(track) ? static_cast(0U) : track.trdPattern(); + } + + void processDataML(MyCollisionML const& /*collision*/, BigTracksDataML const& tracks) + { + for (const auto& track : tracks) { + pidTracksTableDataML(track.tpcSignal(), getTRDSignal(track), getTRDPattern(track), + getTOFSignal(track), getTOFBeta(track), + track.p(), track.pt(), track.px(), track.py(), track.pz(), + track.sign(), + track.x(), track.y(), track.z(), + track.alpha(), + track.trackType(), + track.tpcNClsShared(), + track.dcaXY(), track.dcaZ()); + + fillHist(track); + } + } + PROCESS_SWITCH(PidMlProducer, processDataML, "Produce only ML real data", true); + + void processDataAll(MyCollision const& collision, BigTracksData const& tracks) + { + for (const auto& track : tracks) { + pidTracksTableData(collision.centRun2V0M(), + collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), + collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), + collision.multZNA(), collision.multZNC(), + collision.multTracklets(), collision.multTPC(), + track.tpcSignal(), getTRDSignal(track), getTRDPattern(track), + track.trackEtaEmcal(), track.trackPhiEmcal(), + getTOFSignal(track), getTOFBeta(track), + track.p(), track.pt(), track.px(), track.py(), track.pz(), + track.sign(), + track.x(), track.y(), track.z(), + track.alpha(), + track.trackType(), + track.tpcNClsShared(), + track.dcaXY(), track.dcaZ(), + track.tpcNSigmaEl(), track.tpcExpSigmaEl(), track.tpcExpSignalDiffEl(), + track.tofNSigmaEl(), track.tofExpSigmaEl(), track.tofExpSignalDiffEl(), + track.tpcNSigmaMu(), track.tpcExpSigmaMu(), track.tpcExpSignalDiffMu(), + track.tofNSigmaMu(), track.tofExpSigmaMu(), track.tofExpSignalDiffMu(), + track.tpcNSigmaPi(), track.tpcExpSigmaPi(), track.tpcExpSignalDiffPi(), + track.tofNSigmaPi(), track.tofExpSigmaPi(), track.tofExpSignalDiffPi(), + track.tpcNSigmaKa(), track.tpcExpSigmaKa(), track.tpcExpSignalDiffKa(), + track.tofNSigmaKa(), track.tofExpSigmaKa(), track.tofExpSignalDiffKa(), + track.tpcNSigmaPr(), track.tpcExpSigmaPr(), track.tpcExpSignalDiffPr(), + track.tofNSigmaPr(), track.tofExpSigmaPr(), track.tofExpSignalDiffPr()); + + fillHist(track); + } + } + PROCESS_SWITCH(PidMlProducer, processDataAll, "Produce all real data", false); + + void processMcMl(MyCollisionML const& /*collision*/, BigTracksMCML const& tracks, aod::McParticles const& /*mctracks*/) + { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + const auto mcParticle = track.mcParticle_as(); + uint8_t isPrimary = static_cast(mcParticle.isPhysicalPrimary()); + uint32_t pdgCode = mcParticle.pdgCode(); + pidTracksTableMCML(track.tpcSignal(), getTRDSignal(track), getTRDPattern(track), + getTOFSignal(track), getTOFBeta(track), + track.p(), track.pt(), track.px(), track.py(), track.pz(), + track.sign(), + track.x(), track.y(), track.z(), + track.alpha(), + track.trackType(), + track.tpcNClsShared(), + track.dcaXY(), track.dcaZ(), + pdgCode, + isPrimary); + + fillHistMC(track, pdgCode, isPrimary); + } + } + PROCESS_SWITCH(PidMlProducer, processMcMl, "Produce only ML MC essential data", false); + + void processMcAll(MyCollision const& collision, BigTracksMC const& tracks, aod::McParticles const& /*mctracks*/) + { + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + 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(), + collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), + collision.multZNA(), collision.multZNC(), + collision.multTracklets(), collision.multTPC(), + track.tpcSignal(), getTRDSignal(track), getTRDPattern(track), + track.trackEtaEmcal(), track.trackPhiEmcal(), + getTOFSignal(track), getTOFBeta(track), + track.p(), track.pt(), track.px(), track.py(), track.pz(), + track.sign(), + track.x(), track.y(), track.z(), + track.alpha(), + track.trackType(), + track.tpcNClsShared(), + track.dcaXY(), track.dcaZ(), + track.tpcNSigmaEl(), track.tpcExpSigmaEl(), track.tpcExpSignalDiffEl(), + track.tofNSigmaEl(), track.tofExpSigmaEl(), track.tofExpSignalDiffEl(), + track.tpcNSigmaMu(), track.tpcExpSigmaMu(), track.tpcExpSignalDiffMu(), + track.tofNSigmaMu(), track.tofExpSigmaMu(), track.tofExpSignalDiffMu(), + track.tpcNSigmaPi(), track.tpcExpSigmaPi(), track.tpcExpSignalDiffPi(), + track.tofNSigmaPi(), track.tofExpSigmaPi(), track.tofExpSignalDiffPi(), + track.tpcNSigmaKa(), track.tpcExpSigmaKa(), track.tpcExpSignalDiffKa(), + track.tofNSigmaKa(), track.tofExpSigmaKa(), track.tofExpSignalDiffKa(), + track.tpcNSigmaPr(), track.tpcExpSigmaPr(), track.tpcExpSignalDiffPr(), + track.tofNSigmaPr(), track.tofExpSigmaPr(), track.tofExpSignalDiffPr(), + pdgCode, + isPrimary); + + fillHistMC(track, pdgCode, isPrimary); + } + } + PROCESS_SWITCH(PidMlProducer, processMcAll, "Produce all MC data", false); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} diff --git a/Tools/PIDML/pidMLProducerData.cxx b/Tools/PIDML/pidMLProducerData.cxx deleted file mode 100644 index 0db70ae821e..00000000000 --- a/Tools/PIDML/pidMLProducerData.cxx +++ /dev/null @@ -1,107 +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 pidMLProducerData.cxx -/// \brief Produce PID ML skimmed data from data files. -/// -/// \author Maja Kabus -/// -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Tools/PIDML/pidML.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -#include "Framework/runDataProcessing.h" - -struct PidMlProducerData { - Produces pidTracksTableML; - Produces pidTracksTable; - - Filter trackFilter = requireGlobalTrackInFilter(); - using BigTracksML = soa::Filtered>; - using MyCollisionML = aod::Collisions::iterator; - using BigTracks = soa::Filtered>; - using MyCollision = soa::Join::iterator; - - HistogramRegistry registry{ - "registry", - {{"hTPCSigvsPt", "TPC signal vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TPC signal", {HistType::kTH2F, {{500, 0., 10.}, {1000, 0., 600.}}}}, - {"hTOFBetavsPt", "TOF beta vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TOF beta", {HistType::kTH2F, {{500, 0., 10.}, {500, 0., 2.}}}}, - {"hTRDSigvsPt", "TRD signal vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TRD signal", {HistType::kTH2F, {{500, 0., 10.}, {2500, 0., 100.}}}}}}; - - void processML(MyCollisionML const& /*collision*/, BigTracksML const& tracks) - { - for (const auto& track : tracks) { - pidTracksTableML(track.tpcSignal(), track.trdSignal(), track.trdPattern(), - track.tofSignal(), track.beta(), - track.p(), track.pt(), track.px(), track.py(), track.pz(), - track.sign(), - track.x(), track.y(), track.z(), - track.alpha(), - track.trackType(), - track.tpcNClsShared(), - track.dcaXY(), track.dcaZ()); - - registry.fill(HIST("hTPCSigvsPt"), track.pt(), track.tpcSignal()); - registry.fill(HIST("hTOFBetavsPt"), track.pt(), track.beta()); - registry.fill(HIST("hTRDSigvsPt"), track.pt(), track.trdSignal()); - } - } - PROCESS_SWITCH(PidMlProducerData, processML, "Produce only ML real data", true); - - void processAll(MyCollision const& collision, BigTracks const& tracks) - { - for (const auto& track : tracks) { - pidTracksTable(collision.centRun2V0M(), - collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), - collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), - collision.multZNA(), collision.multZNC(), - collision.multTracklets(), collision.multTPC(), - track.tpcSignal(), track.trdSignal(), track.trdPattern(), - track.trackEtaEmcal(), track.trackPhiEmcal(), - track.tofSignal(), track.beta(), - track.p(), track.pt(), track.px(), track.py(), track.pz(), - track.sign(), - track.x(), track.y(), track.z(), - track.alpha(), - track.trackType(), - track.tpcNClsShared(), - track.dcaXY(), track.dcaZ(), - track.tpcNSigmaEl(), track.tpcExpSigmaEl(), track.tpcExpSignalDiffEl(), - track.tofNSigmaEl(), track.tofExpSigmaEl(), track.tofExpSignalDiffEl(), - track.tpcNSigmaMu(), track.tpcExpSigmaMu(), track.tpcExpSignalDiffMu(), - track.tofNSigmaMu(), track.tofExpSigmaMu(), track.tofExpSignalDiffMu(), - track.tpcNSigmaPi(), track.tpcExpSigmaPi(), track.tpcExpSignalDiffPi(), - track.tofNSigmaPi(), track.tofExpSigmaPi(), track.tofExpSignalDiffPi(), - track.tpcNSigmaKa(), track.tpcExpSigmaKa(), track.tpcExpSignalDiffKa(), - track.tofNSigmaKa(), track.tofExpSigmaKa(), track.tofExpSignalDiffKa(), - track.tpcNSigmaPr(), track.tpcExpSigmaPr(), track.tpcExpSignalDiffPr(), - track.tofNSigmaPr(), track.tofExpSigmaPr(), track.tofExpSignalDiffPr()); - - registry.fill(HIST("hTPCSigvsPt"), track.pt(), track.tpcSignal()); - registry.fill(HIST("hTOFBetavsPt"), track.pt(), track.beta()); - registry.fill(HIST("hTRDSigvsPt"), track.pt(), track.trdSignal()); - } - } - PROCESS_SWITCH(PidMlProducerData, processAll, "Produce all real data", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/Tools/PIDML/pidMLProducerMC.cxx b/Tools/PIDML/pidMLProducerMC.cxx deleted file mode 100644 index d7362d993a3..00000000000 --- a/Tools/PIDML/pidMLProducerMC.cxx +++ /dev/null @@ -1,122 +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 pidMLProducerMc.cxx -/// \brief Produce PID ML skimmed data from MC files. -/// -/// \author Maja Kabus - -#include "Framework/AnalysisTask.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Tools/PIDML/pidML.h" - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -#include "Framework/runDataProcessing.h" - -struct PidMlProducerMc { - Produces pidTracksTableML; - Produces pidTracksTable; - - Filter trackFilter = requireGlobalTrackInFilter(); - - using BigTracksML = soa::Filtered>; - using MyCollisionML = aod::Collisions::iterator; - using BigTracks = soa::Filtered>; - using MyCollision = soa::Join::iterator; - - HistogramRegistry registry{ - "registry", - {{"hTPCSigvsPt", "TPC signal vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TPC signal", {HistType::kTH2F, {{500, 0., 10.}, {1000, 0., 600.}}}}, - {"hTOFBetavsPt", "TOF beta vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TOF beta", {HistType::kTH2F, {{500, 0., 10.}, {500, 0., 2.}}}}, - {"hTRDSigvsPt", "TRD signal vs #it{p}_{T};#it{p}_{T} (GeV/#it{c});TRD signal", {HistType::kTH2F, {{500, 0., 10.}, {2500, 0., 100.}}}}}}; - - void processML(MyCollisionML const& /*collision*/, BigTracksML const& tracks, aod::McParticles const& /*mctracks*/) - { - for (const auto& track : tracks) { - if (!track.has_mcParticle()) { - continue; - } - const auto mcParticle = track.mcParticle_as(); - uint8_t isPrimary = (uint8_t)mcParticle.isPhysicalPrimary(); - pidTracksTableML(track.tpcSignal(), track.trdSignal(), track.trdPattern(), - track.tofSignal(), track.beta(), - track.p(), track.pt(), track.px(), track.py(), track.pz(), - track.sign(), - track.x(), track.y(), track.z(), - track.alpha(), - track.trackType(), - track.tpcNClsShared(), - track.dcaXY(), track.dcaZ(), - mcParticle.pdgCode(), - isPrimary); - - registry.fill(HIST("hTPCSigvsPt"), track.pt(), track.tpcSignal()); - registry.fill(HIST("hTOFBetavsPt"), track.pt(), track.beta()); - registry.fill(HIST("hTRDSigvsPt"), track.pt(), track.trdSignal()); - } - } - PROCESS_SWITCH(PidMlProducerMc, processML, "Produce only ML MC essential data", true); - - void processAll(MyCollision const& collision, BigTracks const& tracks, aod::McParticles const& /*mctracks*/) - { - for (const auto& track : tracks) { - if (!track.has_mcParticle()) { - continue; - } - const auto mcParticle = track.mcParticle_as(); - uint8_t isPrimary = (uint8_t)mcParticle.isPhysicalPrimary(); - pidTracksTable(collision.centRun2V0M(), - collision.multFV0A(), collision.multFV0C(), collision.multFV0M(), - collision.multFT0A(), collision.multFT0C(), collision.multFT0M(), - collision.multZNA(), collision.multZNC(), - collision.multTracklets(), collision.multTPC(), - track.tpcSignal(), track.trdSignal(), track.trdPattern(), - track.trackEtaEmcal(), track.trackPhiEmcal(), - track.tofSignal(), track.beta(), - track.p(), track.pt(), track.px(), track.py(), track.pz(), - track.sign(), - track.x(), track.y(), track.z(), - track.alpha(), - track.trackType(), - track.tpcNClsShared(), - track.dcaXY(), track.dcaZ(), - track.tpcNSigmaEl(), track.tpcExpSigmaEl(), track.tpcExpSignalDiffEl(), - track.tofNSigmaEl(), track.tofExpSigmaEl(), track.tofExpSignalDiffEl(), - track.tpcNSigmaMu(), track.tpcExpSigmaMu(), track.tpcExpSignalDiffMu(), - track.tofNSigmaMu(), track.tofExpSigmaMu(), track.tofExpSignalDiffMu(), - track.tpcNSigmaPi(), track.tpcExpSigmaPi(), track.tpcExpSignalDiffPi(), - track.tofNSigmaPi(), track.tofExpSigmaPi(), track.tofExpSignalDiffPi(), - track.tpcNSigmaKa(), track.tpcExpSigmaKa(), track.tpcExpSignalDiffKa(), - track.tofNSigmaKa(), track.tofExpSigmaKa(), track.tofExpSignalDiffKa(), - track.tpcNSigmaPr(), track.tpcExpSigmaPr(), track.tpcExpSignalDiffPr(), - track.tofNSigmaPr(), track.tofExpSigmaPr(), track.tofExpSignalDiffPr(), - mcParticle.pdgCode(), - isPrimary); - - registry.fill(HIST("hTPCSigvsPt"), track.pt(), track.tpcSignal()); - registry.fill(HIST("hTOFBetavsPt"), track.pt(), track.beta()); - registry.fill(HIST("hTRDSigvsPt"), track.pt(), track.trdSignal()); - } - } - PROCESS_SWITCH(PidMlProducerMc, processAll, "Produce all MC data", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} diff --git a/Tools/PIDML/pidOnnxInterface.h b/Tools/PIDML/pidOnnxInterface.h index 0cf8b473d4a..03e7bc19146 100644 --- a/Tools/PIDML/pidOnnxInterface.h +++ b/Tools/PIDML/pidOnnxInterface.h @@ -36,17 +36,17 @@ auto certainties_v = 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}}; - // row labels static const std::vector pidLabels = { "211", "321", "2212", "0211", "0321", "02212"}; // column labels static const std::vector cutVarLabels = { "TPC", "TPC + TOF", "TPC + TOF + TRD"}; + } // namespace pidml_pt_cuts 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& pTLimits, std::vector const& minCertainties, bool autoMode) : mNPids{pids.size()}, mPTLimits{pTLimits} + 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) { LOG(fatal) << "PID ML Interface needs at least 1 output pid to predict"; @@ -54,7 +54,7 @@ struct PidONNXInterface { std::set tmp; for (auto& pid : pids) { if (!tmp.insert(pid).second) { - LOG(fatal) << "PID M Interface: output pids cannot repeat!"; + LOG(fatal) << "PID ML Interface: output pids cannot repeat!"; } } @@ -68,9 +68,7 @@ struct PidONNXInterface { minCertaintiesFilled = minCertainties; } for (std::size_t i = 0; i < mNPids; i++) { - for (uint32_t j = 0; j < kNDetectors; j++) { - mModels.emplace_back(localPath, ccdbPath, useCCDB, ccdbApi, timestamp, pids[i], (PidMLDetector)(kTPCOnly + j), minCertaintiesFilled[i]); - } + mModels.emplace_back(localPath, ccdbPath, useCCDB, ccdbApi, timestamp, pids[i], minCertaintiesFilled[i], mPLimits[i]); } } PidONNXInterface() = default; @@ -84,12 +82,8 @@ struct PidONNXInterface { float applyModel(const T& track, int pid) { for (std::size_t i = 0; i < mNPids; i++) { - if (mModels[i * kNDetectors].mPid == pid) { - for (uint32_t j = 0; j < kNDetectors; j++) { - if (track.pt() >= mPTLimits[i][j] && (j == kNDetectors - 1 || track.pt() < mPTLimits[i][j + 1])) { - return mModels[i * kNDetectors + j].applyModel(track); - } - } + if (mModels[i].mPid == pid) { + return mModels[i].applyModel(track); } } LOG(error) << "No suitable PID ML model found for track: " << track.globalIndex() << " from collision: " << track.collision().globalIndex() << " and expected pid: " << pid; @@ -100,12 +94,8 @@ struct PidONNXInterface { bool applyModelBoolean(const T& track, int pid) { for (std::size_t i = 0; i < mNPids; i++) { - if (mModels[i * kNDetectors].mPid == pid) { - for (uint32_t j = 0; j < kNDetectors; j++) { - if (track.pt() >= mPTLimits[i][j] && (j == kNDetectors - 1 || track.pt() < mPTLimits[i][j + 1])) { - return mModels[i * kNDetectors + j].applyModelBoolean(track); - } - } + if (mModels[i].mPid == pid) { + return mModels[i].applyModelBoolean(track); } } LOG(error) << "No suitable PID ML model found for track: " << track.globalIndex() << " from collision: " << track.collision().globalIndex() << " and expected pid: " << pid; @@ -116,12 +106,12 @@ struct PidONNXInterface { void fillDefaultConfiguration(std::vector& minCertainties) { // FIXME: A more sophisticated strategy should be based on pid values as well - mPTLimits = 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; - o2::framework::LabeledArray mPTLimits; + o2::framework::LabeledArray mPLimits; }; #endif // TOOLS_PIDML_PIDONNXINTERFACE_H_ diff --git a/Tools/PIDML/pidOnnxModel.h b/Tools/PIDML/pidOnnxModel.h index 8764496c25c..207bc18cd8e 100644 --- a/Tools/PIDML/pidOnnxModel.h +++ b/Tools/PIDML/pidOnnxModel.h @@ -17,22 +17,27 @@ #ifndef TOOLS_PIDML_PIDONNXMODEL_H_ #define TOOLS_PIDML_PIDONNXMODEL_H_ +#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, @@ -41,6 +46,13 @@ enum PidMLDetector { kNDetectors ///< number of available detectors configurations }; +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}); +} // namespace pidml_pt_cuts + // TODO: Copied from cefpTask, shall we put it in some common utils code? namespace { @@ -63,8 +75,12 @@ bool readJsonFile(const std::string& config, rapidjson::Document& d) struct PidONNXModel { public: - PidONNXModel(std::string& localPath, std::string& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, int pid, PidMLDetector detector, double minCertainty) : mDetector(detector), mPid(pid), mMinCertainty(minCertainty) + PidONNXModel(std::string& localPath, std::string& ccdbPath, bool useCCDB, o2::ccdb::CcdbApi& ccdbApi, uint64_t timestamp, + int pid, double minCertainty, const double* pLimits = &pidml_pt_cuts::defaultModelPLimits[0]) + : mPid(pid), mMinCertainty(minCertainty), mPLimits(pLimits, pLimits + kNDetectors) { + assert(mPLimits.size() == kNDetectors); + std::string modelFile; loadInputFiles(localPath, ccdbPath, useCCDB, ccdbApi, timestamp, pid, modelFile); @@ -131,27 +147,21 @@ struct PidONNXModel { return getModelOutput(track) >= mMinCertainty; } - PidMLDetector mDetector; int mPid; double mMinCertainty; private: void getModelPaths(std::string const& path, std::string& modelDir, std::string& modelFile, std::string& modelPath, int pid, std::string const& ext) { - modelDir = path + "/TPC"; - if (mDetector >= kTPCTOF) { - modelDir += "_TOF"; - } - if (mDetector >= kTPCTOFTRD) { - modelDir += "_TRD"; - } + modelDir = path; + modelFile = "attention_model_"; - modelFile = "simple_model_"; if (pid < 0) { modelFile += "0" + std::to_string(-pid); } else { modelFile += std::to_string(pid); } + modelFile += ext; modelPath = modelDir + "/" + modelFile; } @@ -208,55 +218,64 @@ struct PidONNXModel { { // TODO: Hardcoded for now. Planning to implement RowView extension to get runtime access to selected columns // sign is short, trackType and tpcNClsShared uint8_t - 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 scaledTPCSignal = (track.tpcSignal() - mScalingParams.at("fTPCSignal").first) / mScalingParams.at("fTPCSignal").second; - std::vector inputValues{track.px(), track.py(), track.pz(), static_cast(track.sign()), scaledX, scaledY, scaledZ, scaledAlpha, static_cast(track.trackType()), scaledTPCNClsShared, scaledDcaXY, scaledDcaZ, track.p(), scaledTPCSignal}; + std::vector inputValues{scaledTPCSignal}; + + // 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()); + } - if (mDetector >= kTPCTOF) { + // 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 (mDetector >= kTPCTOFTRD) { - float scaledTRDSignal = (track.trdSignal() - mScalingParams.at("fTRDSignal").first) / mScalingParams.at("fTRDSignal").second; - float scaledTRDPattern = (track.trdPattern() - mScalingParams.at("fTRDPattern").first) / mScalingParams.at("fTRDPattern").second; - inputValues.push_back(scaledTRDSignal); - inputValues.push_back(scaledTRDPattern); - } + 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; - return inputValues; - } + 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}); - // FIXME: Temporary solution, new networks will have sigmoid layer added - float sigmoid(float x) - { - float value = std::max(-100.0f, std::min(100.0f, x)); - return 1.0f / (1.0f + std::exp(-value)); + return inputValues; } template float getModelOutput(const T& 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; + std::vector inputTensorValues = createInputsSingle(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); + 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 // Double-check the dimensions of the input tensor @@ -285,7 +304,7 @@ struct PidONNXModel { LOG(debug) << "output tensor shape: " << printShape(outputTensors[0].GetTensorTypeAndShapeInfo().GetShape()); const float* output_value = outputTensors[0].GetTensorData(); - float certainty = sigmoid(*output_value); // FIXME: Temporary, sigmoid will be added as network layer + float certainty = *output_value; return certainty; } catch (const Ort::Exception& exception) { LOG(error) << "Error running model inference: " << exception.what(); @@ -314,6 +333,7 @@ struct PidONNXModel { std::shared_ptr mSession = nullptr; #endif + std::vector mPLimits; std::vector mInputNames; std::vector> mInputShapes; std::vector mOutputNames; diff --git a/Tools/PIDML/pidUtils.h b/Tools/PIDML/pidUtils.h new file mode 100644 index 00000000000..4c101e30b19 --- /dev/null +++ b/Tools/PIDML/pidUtils.h @@ -0,0 +1,46 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 +/// \brief Common constants and functions for PID. +/// +/// \author Marek Mytkowski + +#ifndef TOOLS_PIDML_PIDUTILS_H_ +#define TOOLS_PIDML_PIDUTILS_H_ + +#include + +namespace pidml::pidutils +{ +constexpr double kTOFMissingSignal = -999.0f; +constexpr double kGlobalEtaCut = 0.8f; + +template +bool trdMissing(const T& track) +{ + return !track.hasTRD(); +} + +template +bool tofMissing(const T& track) +{ + return !track.hasTOF(); +} + +template +bool inPLimit(const T& track, double pLimit) +{ + return track.p() >= pLimit; +} +} // namespace pidml::pidutils + +#endif // TOOLS_PIDML_PIDUTILS_H_ diff --git a/Tools/PIDML/qaPidML.cxx b/Tools/PIDML/qaPidML.cxx index accd055222c..54cafc437ab 100644 --- a/Tools/PIDML/qaPidML.cxx +++ b/Tools/PIDML/qaPidML.cxx @@ -13,6 +13,8 @@ /// \author Łukasz Sawicki /// \since +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/HistogramRegistry.h" @@ -21,13 +23,12 @@ #include "Common/DataModel/PIDResponse.h" #include #include "Tools/PIDML/pidOnnxModel.h" -#include using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -struct pidml { +struct QaPidML { static const int maxP = 5; // nb of bins for TH1 hists static const int binsNb = 100; @@ -47,9 +48,9 @@ struct pidml { // available particles: 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 + // 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 float pSwitchValue[numParticles] = {0.5, 0.8, 0.5}; + 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", @@ -244,34 +245,35 @@ struct pidml { template void fillMcHistos(const T& track, const int pdgCode) { - // pions if (pdgCode == 211) { + // pions histReg.fill(HIST("MC/211"), track.pt()); } else if (pdgCode == -211) { + // antipions histReg.fill(HIST("MC/0211"), track.pt()); - } - // protons - else if (pdgCode == 2212) { + } else if (pdgCode == 2212) { + // protons histReg.fill(HIST("MC/2212"), track.pt()); } else if (pdgCode == -2212) { + // antiprotons histReg.fill(HIST("MC/02212"), track.pt()); - } - // kaons - else if (pdgCode == 321) { + } else if (pdgCode == 321) { + // kaons histReg.fill(HIST("MC/321"), track.pt()); } else if (pdgCode == -321) { + // antikaons histReg.fill(HIST("MC/0321"), track.pt()); - } - // electrons - else if (pdgCode == 11) { + } else if (pdgCode == 11) { + // electrons histReg.fill(HIST("MC/11"), track.pt()); } else if (pdgCode == -11) { + // positrons histReg.fill(HIST("MC/011"), track.pt()); - } - // muons - else if (pdgCode == 13) { + } else if (pdgCode == 13) { + // muons histReg.fill(HIST("MC/13"), track.pt()); } else if (pdgCode == -13) { + // antimuons histReg.fill(HIST("MC/013"), track.pt()); } else { histReg.fill(HIST("MC/else"), track.pt()); @@ -326,15 +328,9 @@ struct pidml { void pidML(const T& track, const int pdgCodeMC) { float pidCertainties[3]; - if (track.p() < pSwitchValue[i]) { - pidCertainties[0] = model211TPC.applyModel(track); - pidCertainties[1] = model2212TPC.applyModel(track); - pidCertainties[2] = model321TPC.applyModel(track); - } else { - pidCertainties[0] = model211All.applyModel(track); - pidCertainties[1] = model2212All.applyModel(track); - pidCertainties[2] = model321All.applyModel(track); - } + pidCertainties[0] = model211.applyModel(track); + pidCertainties[1] = model2212.applyModel(track); + 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) { @@ -346,14 +342,10 @@ struct pidml { } } - // one model for one particle; Model with all TPC and TOF signal - PidONNXModel model211All; - PidONNXModel model2212All; - PidONNXModel model321All; - // Model with only TPC signal model - PidONNXModel model211TPC; - PidONNXModel model2212TPC; - PidONNXModel model321TPC; + // 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"}; @@ -368,13 +360,9 @@ struct pidml { if (cfgUseCCDB) { ccdbApi.init(cfgCCDBURL); } else { - model211All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 211, kTPCTOF, 0.5f); - model2212All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 2211, kTPCTOF, 0.5f); - model321All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 321, kTPCTOF, 0.5f); - - model211TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 211, kTPCOnly, 0.5f); - model2212TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 2211, kTPCOnly, 0.5f); - model321TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, 321, kTPCOnly, 0.5f); + 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]); } } @@ -384,13 +372,9 @@ struct pidml { { auto bc = collisions.iteratorAt(0).bc_as(); if (cfgUseCCDB && bc.runNumber() != currentRunNumber) { - model211All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 211, kTPCTOF, 0.5f); - model2212All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 2211, kTPCTOF, 0.5f); - model321All = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 321, kTPCTOF, 0.5f); - - model211TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 211, kTPCOnly, 0.5f); - model2212TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 2211, kTPCOnly, 0.5f); - model321TPC = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, bc.timestamp(), 321, kTPCOnly, 0.5f); + 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]); } for (auto& track : tracks) { @@ -410,6 +394,6 @@ struct pidml { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), }; } diff --git a/Tools/PIDML/simpleApplyPidOnnxInterface.cxx b/Tools/PIDML/simpleApplyPidOnnxInterface.cxx index 85847320787..82f644103ed 100644 --- a/Tools/PIDML/simpleApplyPidOnnxInterface.cxx +++ b/Tools/PIDML/simpleApplyPidOnnxInterface.cxx @@ -14,6 +14,8 @@ /// /// \author Maja Kabus +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "CCDB/CcdbApi.h" @@ -21,8 +23,6 @@ #include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxInterface.h" -#include - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; diff --git a/Tools/PIDML/simpleApplyPidOnnxModel.cxx b/Tools/PIDML/simpleApplyPidOnnxModel.cxx index 00dc843ca47..e261c1e10bc 100644 --- a/Tools/PIDML/simpleApplyPidOnnxModel.cxx +++ b/Tools/PIDML/simpleApplyPidOnnxModel.cxx @@ -14,6 +14,8 @@ /// /// \author Maja Kabus +#include + #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "CCDB/CcdbApi.h" @@ -21,8 +23,6 @@ #include "Common/DataModel/PIDResponse.h" #include "Tools/PIDML/pidOnnxModel.h" -#include - using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; @@ -40,7 +40,6 @@ DECLARE_SOA_TABLE(MlPidResults, "AOD", "MLPIDRESULTS", o2::soa::Index<>, mlpidre struct SimpleApplyOnnxModel { PidONNXModel pidModel; // One instance per model, e.g., one per each pid to predict - Configurable cfgDetector{"detector", kTPCTOFTRD, "What detectors to use: 0: TPC only, 1: TPC + TOF, 2: TPC + TOF + TRD"}; 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"}; @@ -68,7 +67,7 @@ struct SimpleApplyOnnxModel { if (cfgUseCCDB) { ccdbApi.init(cfgCCDBURL); } else { - pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, cfgPid.value, static_cast(cfgDetector.value), cfgCertainty.value); + pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, -1, cfgPid.value, cfgCertainty.value); } } @@ -77,7 +76,7 @@ struct SimpleApplyOnnxModel { 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, static_cast(cfgDetector.value), cfgCertainty.value); + pidModel = PidONNXModel(cfgPathLocal.value, cfgPathCCDB.value, cfgUseCCDB.value, ccdbApi, timestamp, cfgPid.value, cfgCertainty.value); } for (auto& track : tracks) { diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index 8a77f3dead9..d99c71adc88 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -29,7 +29,7 @@ o2physics_add_dpl_workflow(track-iteration COMPONENT_NAME AnalysisTutorial) o2physics_add_dpl_workflow(pid - SOURCES src/pid.cxx + SOURCES src/pidTpcTof.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME AnalysisTutorial) diff --git a/Tutorials/ML/applyMlSelection.cxx b/Tutorials/ML/applyMlSelection.cxx index d33427e3c2a..dcbfb0f80e9 100644 --- a/Tutorials/ML/applyMlSelection.cxx +++ b/Tutorials/ML/applyMlSelection.cxx @@ -11,7 +11,7 @@ /// \file applyMlSelection.cxx /// \brief Showcase usage of trained ML model exported to ONNX format for candidate selection in analysis -/// \brief This is only the starting point for the tutorial. The complete task is available at https://github.com/AliceO2Group/analysis-tutorials/tree/master/o2at-3/machineLearning/MlInference +/// \brief This is only the starting point for the tutorial. The complete task is available at https://github.com/AliceO2Group/analysis-tutorials/tree/master/o2at-4/machineLearning/MlInference /// /// \author Fabio Catalano , CERN @@ -39,13 +39,13 @@ struct applyMlSelection { Configurable> binsPtMl{"binsPtMl", std::vector{1., 36.}, "pT bin limits for ML application"}; Configurable> cutDirMl{"cutDirMl", std::vector{cuts_ml::CutSmaller, cuts_ml::CutNot, cuts_ml::CutNot}, "Whether to reject score values greater or smaller than the threshold"}; Configurable> cutsMl{"cutsMl", {defaultCutsMl[0], 1, 3, {"pT bin 0"}, {"score prompt", "score non-prompt", "score bkg"}}, "ML selections per pT bin"}; - Configurable nClassesMl{"nClassesMl", (int8_t)3, "Number of classes in ML model"}; + Configurable nClassesMl{"nClassesMl", 3, "Number of classes in ML model"}; // Model file names Configurable> onnxFileNames{"onnxFileNames", std::vector{"model_onnx.onnx"}, "ONNX file names for each pT bin (if not from CCDB full path)"}; // Bonus: CCDB configuration (needed for ML application on the GRID) Configurable loadModelsFromCCDB{"loadModelsFromCCDB", false, "Flag to enable or disable the loading of models from CCDB"}; Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable modelPathsCCDB{"modelPathsCCDB", "Users/f/fcatalan/O2AT3/MlInference", "Path on CCDB"}; + Configurable> modelPathsCCDB{"modelPathsCCDB", std::vector{"Users/c/ciacco/O2AT4/MlInference"}, "Path on CCDB"}; Configurable timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"}; Filter filterDsFlag = (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi))) != static_cast(0); diff --git a/Tutorials/ML/dpl-config_applyMlSelection.json b/Tutorials/ML/dpl-config_applyMlSelection.json index ddb5a42d329..592d2973bf0 100644 --- a/Tutorials/ML/dpl-config_applyMlSelection.json +++ b/Tutorials/ML/dpl-config_applyMlSelection.json @@ -41,124 +41,37 @@ }, "loadModelsFromCCDB": "false", "ccdbUrl": "http://alice-ccdb.cern.ch", - "modelPathsCCDB": "Users/f/fcatalan/O2AT3/MlInference", + "modelPathsCCDB": { + "values": [ + "Users\/c\/ciacco\/O2AT4\/MlInference" + ] + }, "timestampCCDB": "-1" }, - "internal-dpl-aod-reader": { + "aod-file-private": "AO2D_MC_Ds.root", "time-limit": "0", "orbit-offset-enumeration": "0", "orbit-multiplier-enumeration": "0", "start-value-enumeration": "0", "end-value-enumeration": "-1", "step-value-enumeration": "1", - "aod-file": "AO2D.root" - }, - "hf-track-index-skim-creator-cascades": { - "maxDZIni": "4", - "tpcRefitV0Daugh": "1", - "ccdbPathGrpMag": "GLO/Config/GRPMagField", - "processCascades": "0", - "propagateToPCA": "1", - "cutInvMassCascLc": "1", - "ccdbPathGrp": "GLO/GRP/GRP", - "processNoCascades": "1", - "ccdbUrl": "http://alice-ccdb.cern.ch", - "doCutQuality": "1", - "nCrossedRowsMinBach": "50", - "etaMaxV0Daugh": "1.1", - "dcaXYNegToPvMin": "0.1", - "maxR": "200", - "nCrossedRowsMinV0Daugh": "50", - "useAbsDCA": "1", - "minRelChi2Change": "0.9", - "cpaV0Min": "0.995", - "useWeightedFinalPCA": "1", - "cutInvMassV0": "0.05", - "dcaXYPosToPvMin": "0.1", - "minParamChange": "0.001", - "etaMinV0Daugh": "-99999", - "fillHistograms": "1", - "isRun2": "0", - "ptCascCandMin": "-1", - "ccdbPathLut": "GLO/Param/MatLUT", - "tpcRefitBach": "1", - "ptMinV0Daugh": "0.05" - }, - "track-to-collision-association": { - "timeMargin": "500", - "bcWindowForOneSigma": "60", - "usePVAssociation": "1", - "processStandardAssoc": "0", - "processAssocWithTime": "1", - "nSigmaForTimeCompat": "4", - "includeUnassigned": "1", - "fillTableOfCollIdsPerTrack": "0", - "setTrackSelections": "1" - }, - "hf-track-index-skim-creator-lf-cascades": { - "maxDZIni": "4", - "dcaBachToPv": "0.05", - "dcaV0ToPv": "0.05", - "ccdbPathGrpMag": "GLO/Config/GRPMagField", - "v0Radius": "0.9", - "tpcNsigmaBachelor": "4", - "dcaV0Dau": "2", - "processNoLfCascades": "1", - "propagateToPCA": "1", - "ccdbPathGrp": "GLO/GRP/GRP", - "do3Prong": "0", - "v0MassWindow": "0.008", - "ccdbUrl": "http://alice-ccdb.cern.ch", - "rejDiffCollTrack": "1", - "doCutQuality": "1", - "tpcNsigmaPion": "4", - "cascRadius": "0.5", - "tpcNsigmaProton": "4", - "maxR": "200", - "useAbsDCA": "1", - "minRelChi2Change": "0.9", - "dcaPosToPv": "0.05", - "cascCosPA": "0.95", - "dcaNegToPv": "0.05", - "useWeightedFinalPCA": "1", - "dcaCascDau": "1", - "processLfCascades": "0", - "minParamChange": "0.001", - "v0CosPA": "0.95", - "fillHistograms": "1", - "isRun2": "0", - "ccdbPathLut": "GLO/Param/MatLUT" + "aod-parent-access-level": "1" }, "hf-track-index-skim-creator": { - "maxDZIni": "4", - "cutsDplusToPiKPi": { + "thresholdMlScoreDsToPiKK": { "values": [ [ - 1.75, - 2.05, - 0.7, - 0.02 - ], - [ - 1.75, - 2.05, + 0.1, 0.5, - 0.02 + 0.5 ] ] }, - "ccdbPathGrpMag": "GLO/Config/GRPMagField", - "axisNumTracks": { - "values": [ - 250, - -0.5, - 249.5 - ] - }, + "applyProtonPidForXicToPKPi": "1", "binsPtDsToKKPi": { "values": [ - 1, + 0, 5, 1000 ] @@ -167,23 +80,23 @@ "binsPtJpsiToEE": { "values": [ 0, - 0, - 0 + 5, + 1000 ] }, "cutsLcToPKPi": { "values": [ [ - 1.75, - 2.05, + 2.1, + 2.55, 0.7, - 0.02 + 0 ], [ - 1.75, - 2.05, - 0.5, - 0.02 + 2, + 2.6, + 0.85, + 0.01 ] ] }, @@ -191,11 +104,11 @@ "binsPtLcToPKPi": { "values": [ 0, - 0, - 0 + 5, + 1000 ] }, - "process2And3ProngsWithPvRefit": "0", + "minTwoTrackDecayLengthFor3Prongs": "0", "axisPvRefitDeltaY": { "values": [ 1000, @@ -207,16 +120,16 @@ "cutsJpsiToEE": { "values": [ [ - 1.65, - 2.15, - 0.5, - 100 + 0, + 0, + 2, + 0 ], [ - 1.65, - 2.15, - 0.5, - 100 + 0, + 0, + 2, + 0 ] ] }, @@ -227,25 +140,27 @@ 0.5 ] }, - "cutsD0ToPiK": { + "ccdbUrl": "http://alice-ccdb.cern.ch", + "onnxFileNames": { "values": [ [ - 1.65, - 2.15, - 0.5, - 100 + "ModelHandler_onnx_D0ToKPi.onnx" ], [ - 1.65, - 2.15, - 0.5, - 100 + "ModelHandler_onnx_DplusToPiKPi.onnx" + ], + [ + "ModelHandler_onnx_LcToPKPi.onnx" + ], + [ + "ModelHandler_onnx_DsToKKPi.onnx" + ], + [ + "" ] ] }, - "ccdbUrl": "http://alice-ccdb.cern.ch", - "debugPvRefit": "0", - "maxR": "200", + "maxTwoTrackChi2PcaFor3Prongs": "1e+10", "axisPvRefitDeltaX": { "values": [ 1000, @@ -259,372 +174,254 @@ "cutsJpsiToMuMu": { "values": [ [ - 1.65, - 2.15, - 0.5, - 100 + 0, + 0, + 2, + 0 ], [ - 1.65, - 2.15, - 0.5, - 100 + 0, + 0, + 2, + 0 ] ] }, - "debug": "0", "binsPtXicToPKPi": { "values": [ 0, - 0, - 0 - ] - }, - "cutsDsToKKPi": { - "values": [ - [ - 1.78, - 2.18, - 0.95, - 0.01 - ], - [ - 1.78, - 2.18, - 0.98, - 0.02 - ] + 5, + 1000 ] }, - "doDstar": "0", + "doDstar": "1", "binsPtDstarToD0Pi": { "values": [ 0, - 0, - 0 + 5, + 1000 ] }, "binsPtDplusToPiKPi": { "values": [ 0, - 0, - 0 + 5, + 1000 ] }, "useWeightedFinalPCA": "0", - "axisNumCands": { - "values": [ - 200, - -0.5, - 199.5 - ] - }, "cutsDstarToD0Pi": { "values": [ [ 0.17, - 0.05 + 0.12 ], [ 0.17, - 0.08 + 0.4 ] ] }, "binsPtJpsiToMuMu": { "values": [ 0, - 0, - 0 - ] - }, - "binsPtD0ToPiK": { - "values": [ - 0, - 0, - 0 + 5, + 1000 ] }, - "cutsXicToPKPi": { + "loadMlModelsFromCCDB": "1", + "minParamChange": "0.001", + "ptTolerance": "0.1", + "ccdbPathLut": "GLO/Param/MatLUT", + "applyMlForHfFilters": "0", + "maxDZIni": "4", + "cutsDplusToPiKPi": { "values": [ [ - 1.75, + 1.7, 2.05, - 0.7, - 0.02 + 0.85, + 0.01 ], [ - 1.75, - 2.05, - 0.5, + 1.6, + 2.5, + 0.9, 0.02 ] ] }, - "minParamChange": "0.001", - "processNo2And3Prongs": "0", - "ptTolerance": "0.1", - "fillHistograms": "1", - "isRun2": "0", - "ccdbPathLut": "GLO/Param/MatLUT" - }, - "ft0-corrected-table": {}, - "hf-candidate-creator-3prong-expressions": { - "processMc": "1" - }, - "hf-track-index-skim-creator-tag-sel-collisions": { - "zVertexMin": "-10", - "xVertexMax": "1", - "useSel8Trigger": "1", - "axisNumContributors": { + "ccdbPathGrpMag": "GLO/Config/GRPMagField", + "thresholdMlScoreLcToPiKP": { "values": [ - 200, - -0.5, - 199.5 + [ + 0.1, + 0.5, + 0.5 + ] ] }, - "triggerClassName": "kINT7", - "processTrigSel": "1", - "yVertexMax": "1", - "fillHistograms": "1", - "zVertexMax": "10", - "xVertexMin": "-1", - "chi2Max": "0", - "processNoTrigSel": "0", - "nContribMin": "0", - "yVertexMin": "-1" - }, - "hf-track-index-skim-creator-tag-sel-tracks": { - "etaMaxTrack2Prong": "0.8", - "useIsGlobalTrackForSoftPion": "0", - "ccdbPathGrpMag": "GLO/Config/GRPMagField", - "useIsGlobalTrackWoDCAForSoftPion": "0", - "ptMaxSoftPionForDstar": "2", - "ptMinSoftPionForDstar": "0.05", - "cutsTrack3Prong": { + "process2And3ProngsWithPvRefit": "0", + "cutsD0ToPiK": { "values": [ [ - 0, - 10 - ], - [ - 0, - 10 - ], - [ - 0, - 10 + 1.65, + 2.1, + 0.8, + 0.01 ], [ - 0, - 10 - ], + 1.6, + 5, + 0.85, + 0.01 + ] + ] + }, + "debugPvRefit": "0", + "maxR": "200", + "debug": "0", + "cutsDsToKKPi": { + "values": [ [ - 0, - 10 + 1.7, + 2.15, + 0.8, + 0.01, + 0.02 ], [ - 0, - 10 + 1.7, + 2.25, + 0.85, + 0.01, + 0.02 ] ] }, - "binsPtTrack": { + "applyProtonPidForLcToPKPi": "1", + "applyKaonPidIn3Prongs": "0", + "binsPtD0ToPiK": { "values": [ 0, - 0.5, - 1, - 1.5, - 2, - 3, + 5, 1000 ] }, - "ccdbPathGrp": "GLO/GRP/GRP", - "doPvRefit": "0", - "useIsGlobalTrackWoDCA": "1", - "axisPvRefitDeltaY": { - "values": [ - 1000, - -0.5, - 0.5 - ] - }, - "axisPvRefitDeltaZ": { - "values": [ - 1000, - -0.5, - 0.5 - ] - }, - "ptMinTrack3Prong": "0.3", - "etaMinTrack3Prong": "-99999", - "useIsQualityTrackITSForSoftPion": "1", - "ccdbUrl": "http://alice-ccdb.cern.ch", - "doCutQuality": "1", - "debugPvRefit": "0", - "ptMinTrackBach": "0.3", - "useIsGlobalTrack": "0", - "axisPvRefitDeltaX": { - "values": [ - 1000, - -0.5, - 0.5 - ] - }, - "etaMaxTrackBach": "0.8", - "cutsTrack2Prong": { + "mlModelPathCCDB": "EventFiltering/PWGHF/BDTSmeared", + "cutsXicToPKPi": { "values": [ [ - 0, - 10 - ], - [ - 0, - 10 - ], - [ - 0, - 10 - ], - [ - 0, - 10 - ], - [ - 0, - 10 + 2.1, + 2.65, + 0.8, + 0.01 ], [ - 0, - 10 + 2, + 2.7, + 0.85, + 0.01 ] ] }, - "ptMinTrack2Prong": "0.3", - "etaMinTrackBach": "-99999", - "cutsTrackDstar": { + "processNo2And3Prongs": "0", + "fillHistograms": "1", + "isRun2": "0", + "thresholdMlScoreXicToPiKP": { "values": [ [ - 0, - 0 - ], - [ - 0, - 0 - ], - [ - 0, - 0 - ], - [ - 0, - 0 - ], - [ - 0, - 0 - ], - [ - 0, - 0 + 0.1, + 0.5, + 0.5 ] ] }, - "etaMaxSoftPionForDstar": "0.8", - "etaMinTrack2Prong": "-99999", - "tpcNClsFoundMin": "70", - "etaMaxTrack3Prong": "0.8", - "fillHistograms": "1", - "isRun2": "0", - "cutsTrackBach": { + "timestampCcdbForHfFilters": "1657032422771", + "thresholdMlScoreDplusToPiKPi": { "values": [ [ - 10, - 10 - ], - [ - 10, - 10 - ], - [ - 10, - 10 - ], - [ - 10, - 10 - ], - [ - 10, - 10 - ], - [ - 10, - 10 + 0.1, + 0.5, + 0.5 ] ] }, - "etaMinSoftPionForDstar": "-99999", - "ccdbPathLut": "GLO/Param/MatLUT" + "thresholdMlScoreD0ToKPi": { + "values": [ + [ + 0.1, + 0.5, + 0.5 + ] + ] + } }, - "track-selection": { - "ptMax": "1e+10", - "produceTable": "1", - "etaMin": "-0.8", - "isRun3": "1", - "itsMatching": "1", - "etaMax": "0.8", - "compatibilityIU": "0", - "dcaSetup": "0", - "ptMin": "0.1", - "produceFBextendedTable": "-1" + "timestamp-task": { + "fatalOnInvalidTimestamp": "false", + "verbose": "false", + "rct-path": "RCT\/Info\/RunInformation", + "orbit-reset-path": "CTP\/Calib\/OrbitReset", + "ccdb-url": "http:\/\/alice-ccdb.cern.ch", + "isRun2MC": "-1" + }, + "track-propagation": { + "ccdb-url": "http:\/\/alice-ccdb.cern.ch", + "lutPath": "GLO\/Param\/MatLUT", + "geoPath": "GLO\/Config\/GeometryAligned", + "grpmagPath": "GLO\/Config\/GRPMagField", + "mVtxPath": "GLO\/Calib\/MeanVertex", + "minPropagationDistance": "5", + "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=1.5", + "processStandard": "false", + "processStandardWithPID": "false", + "processCovarianceMc": "false", + "processCovariance": "true", + "processCovarianceWithPID": "false" }, "bc-selection-task": { "triggerBcShift": "999", - "processRun3": "1", - "processRun2": "0" + "processRun2": "false", + "processRun3": "true" }, "event-selection-task": { "syst": "pp", - "isMC": "1", - "processRun3": "1", - "processRun2": "0", "muonSelection": "0", - "customDeltaBC": "-1" + "maxDiffZvtxFT0vsPV": "1", + "isMC": "1", + "processRun2": "false", + "processRun3": "true" }, "hf-candidate-creator-3prong": { + "propagateToPCA": "true", + "useAbsDCA": "false", + "useWeightedFinalPCA": "false", + "maxR": "200", "maxDZIni": "4", - "minRelChi2Change": "0.9", - "processNoPvRefit": "1", - "ccdbPathGrpMag": "GLO/Config/GRPMagField", - "useWeightedFinalPCA": "0", - "propagateToPCA": "1", "minParamChange": "0.001", - "ccdbPathGrp": "GLO/GRP/GRP", - "processPvRefit": "0", - "fillHistograms": "1", - "ccdbUrl": "http://alice-ccdb.cern.ch", - "isRun2": "0", - "ccdbPathLut": "GLO/Param/MatLUT", - "maxR": "200", - "useAbsDCA": "0" - }, - "track-propagation": { - "lutPath": "GLO/Param/MatLUT", - "mVtxPath": "GLO/Calib/MeanVertex", - "geoPath": "GLO/Config/GeometryAligned", - "grpmagPath": "GLO/Config/GRPMagField", - "ccdb-url": "http://alice-ccdb.cern.ch", - "minPropagationDistance": "5", - "processStandard": "0", - "processCovariance": "1" + "minRelChi2Change": "0.9", + "fillHistograms": "true", + "isRun2": "false", + "ccdbUrl": "http:\/\/alice-ccdb.cern.ch", + "ccdbPathLut": "GLO\/Param\/MatLUT", + "ccdbPathGrp": "GLO\/GRP\/GRP", + "ccdbPathGrpMag": "GLO\/Config\/GRPMagField", + "createDplus": "true", + "createDs": "true", + "createLc": "false", + "createXic": "false", + "processNoPvRefit": "true" }, - "timestamp-task": { - "rct-path": "RCT/Info/RunInformation", - "orbit-reset-path": "CTP/Calib/OrbitReset", - "ccdb-url": "http://alice-ccdb.cern.ch", - "verbose": "0", - "isRun2MC": "0" + "track-selection": { + "ptMax": "1e+10", + "produceTable": "1", + "etaMin": "-0.8", + "isRun3": "1", + "itsMatching": "1", + "etaMax": "0.8", + "compatibilityIU": "0", + "dcaSetup": "0", + "ptMin": "0.1", + "produceFBextendedTable": "-1" } -} \ No newline at end of file +} diff --git a/Tutorials/PWGCF/CMakeLists.txt b/Tutorials/PWGCF/CMakeLists.txt index 9bf7685cfeb..ad718c5289f 100644 --- a/Tutorials/PWGCF/CMakeLists.txt +++ b/Tutorials/PWGCF/CMakeLists.txt @@ -9,6 +9,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. +add_subdirectory(EventPlane) add_subdirectory(FemtoFramework) add_subdirectory(FlowGenericFramework) add_subdirectory(TwoParticleCorrelations) diff --git a/Tutorials/PWGCF/EventPlane/CMakeLists.txt b/Tutorials/PWGCF/EventPlane/CMakeLists.txt new file mode 100644 index 00000000000..4e0a34d9971 --- /dev/null +++ b/Tutorials/PWGCF/EventPlane/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(src) diff --git a/Tutorials/PWGCF/EventPlane/README.md b/Tutorials/PWGCF/EventPlane/README.md new file mode 100644 index 00000000000..c9610b0b45c --- /dev/null +++ b/Tutorials/PWGCF/EventPlane/README.md @@ -0,0 +1,3 @@ +# O2AT - Second edition - PWG-CF + +## Event Plane hands-on session diff --git a/Tutorials/PWGCF/EventPlane/doc/README.md b/Tutorials/PWGCF/EventPlane/doc/README.md new file mode 100644 index 00000000000..c9610b0b45c --- /dev/null +++ b/Tutorials/PWGCF/EventPlane/doc/README.md @@ -0,0 +1,3 @@ +# O2AT - Second edition - PWG-CF + +## Event Plane hands-on session diff --git a/Tutorials/PWGCF/EventPlane/src/CMakeLists.txt b/Tutorials/PWGCF/EventPlane/src/CMakeLists.txt new file mode 100644 index 00000000000..86e39d138cf --- /dev/null +++ b/Tutorials/PWGCF/EventPlane/src/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(qvectors-tutorial + SOURCES qVectorstutorial.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/Tutorials/PWGCF/EventPlane/src/qVectorstutorial.cxx b/Tutorials/PWGCF/EventPlane/src/qVectorstutorial.cxx new file mode 100644 index 00000000000..b5b01185a49 --- /dev/null +++ b/Tutorials/PWGCF/EventPlane/src/qVectorstutorial.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. + +// C++/ROOT includes. +#include +#include +#include +#include +#include +#include +#include +#include + +// o2Physics includes. +#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 "CommonConstants/PhysicsConstants.h" + +// o2 includes. + +using namespace o2; +using namespace o2::framework; + +using MyCollisions = soa::Join; +using MyTracks = soa::Join; + +struct qVectorstutorial { + 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.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}, ""}; + + 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"}; + + histosQA.add(Form("histQvecV2"), "", {HistType::kTH3F, {axisQvecF, axisQvecF, 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}}); + } + + template + bool SelEvent(const CollType& collision) + { + if (!collision.sel8()) { + return 0; + } + 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.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(const CollType& collision, int nmode) + { + if (nmode == 2) { + histosQA.fill(HIST("histQvecV2"), collision.qvecFT0CReVec()[0], collision.qvecFT0CImVec()[0], 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()); + } + } + + template + void fillHistosFlow(const CollType& collision, const TrackType& track, int nmode) + { + if (collision.sumAmplFT0C() < 1e-4) { + return; + } + for (auto& trk : track) { + if (!SelTrack(trk)) { + continue; + } + if (nmode == 2) { + histosQA.fill(HIST("histCosDetV2"), collision.centFT0C(), 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 (!SelEvent(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/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask1.cxx b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask1.cxx index acb7f799a7c..369e63cbdf6 100644 --- a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask1.cxx +++ b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask1.cxx @@ -37,7 +37,7 @@ struct CFTutorialTask1 { // TODO : // Defining filters for analysis level selections on events and tracks - // on Femto tables defined FemtoDerived.h + // on Femto tables defined in FemtoDerived.h // Filter collisionFilter = ... // Filter trackFilter = ... @@ -50,7 +50,6 @@ struct CFTutorialTask1 { // create analysis objects like histograms void init(o2::framework::InitContext&) { - // Add histograms to histogram registry HistRegistry.add("Event/hZvtx", ";Z (cm)", kTH1F, {{240, -12, 12}}); diff --git a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask2.cxx b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask2.cxx index 8c3adcfd542..ff5fa93aa5b 100644 --- a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask2.cxx +++ b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask2.cxx @@ -92,7 +92,7 @@ struct CFTutorialTask2 { HistRegistry.fill(HIST("Event/hZvtx"), col.posZ()); // TODO - // generate partition of particles 1&2 with sliceByCached method + // generate partition of particles 1 & 2 with sliceByCached method /// TODO: /// loop over particle group 1 diff --git a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask3.cxx b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask3.cxx index 02e7b9d9e14..ca200fd3937 100644 --- a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask3.cxx +++ b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask3.cxx @@ -57,13 +57,11 @@ struct CFTutorialTask3 { // ... Configurable ConfCutPartTwo{"ConfCutPartTwo", 3191978, "Particle 2 - Selection bit"}; - // additional configurables for particle 1 - // ... - - // more configurables for PID selection + // additional configurables for particle 2 // ... - /// Partitions for particle 1 and particle 2 + // Partitions for particle 1 and particle 2 + // add PID selection to partition definition Partition PartsOne = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartOne) == ConfCutPartOne); Partition PartsTwo = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartTwo) == ConfCutPartTwo); @@ -96,40 +94,27 @@ struct CFTutorialTask3 { void process(FilteredFDCollision const& col, FilteredFDParts const& /*parts*/) { - /// event QA + // event QA HistRegistry.fill(HIST("Event/hZvtx"), col.posZ()); // generate partition of particels auto GroupPartsOne = PartsOne->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); auto GroupPartsTwo = PartsTwo->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache); - /// QA for particle 1 + // QA for particle 1 for (auto& part : GroupPartsOne) { - - // TODO: - // add function for PID selection from FemtoUtils - // if (PID cut) { - HistRegistry.fill(HIST("Particle1/hPt"), part.pt()); HistRegistry.fill(HIST("Particle1/hEta"), part.eta()); HistRegistry.fill(HIST("Particle1/hPhi"), part.phi()); - - // } } - /// QA for particle 2 - /// skip QA if particle 1 & 2 are the same + // QA for particle 2 + // skip QA if particle 1 & 2 are the same if (ConfIsSame.value == false) { for (auto& part : GroupPartsTwo) { - // TODO: - // add function for PID selection from FemtoUtils - // if (PID cut) { - HistRegistry.fill(HIST("Particle2/hPt"), part.pt()); HistRegistry.fill(HIST("Particle2/hEta"), part.eta()); HistRegistry.fill(HIST("Particle2/hPhi"), part.phi()); - - // } } } } diff --git a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask4.cxx b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask4.cxx index 943f1e5bc12..90ae5168a78 100644 --- a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask4.cxx +++ b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask4.cxx @@ -50,18 +50,16 @@ struct CFTutorialTask4 { Configurable ConfIsSame{"ConfIsSame", false, "Pairs of the same particle"}; Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 2212, "Particle 1 - PDG code"}; - Configurable ConfCutPartOne{"ConfCutPartOne", 3191978, "Particle 1 - Selection bit from cutCulator"}; - Configurable ConfPIDPartOne{"ConfPIDPartOne", 0, "Particle 1 - Index in ConfTrkPIDspecies of producer task"}; - Configurable ConfPIDValuePartOne{"ConfPIDValuePartOne", 3, "Particle 1 - Read from cutCulator"}; + Configurable ConfCutPartOne{"ConfCutPartOne", 3191978, "Particle 1 - Selection bit"}; + Configurable ConfPIDTPCPartOne{"ConfPIDTPCPartOne", 2, "Particle 1 - TPC PID Selection bit"}; + Configurable ConfPIDTPCTOFPartOne{"ConfPIDTPCTOFPartOne", 4, "Particle 1 - TPCTOF PID Selection bit"}; + Configurable ConfPIDThresholdPartOne{"ConfPIDThresholdPartOne", 0.75, "Particle 1 - Momentum threshold for TPC to TPCTOF PID"}; Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 2212, "Particle 2 - PDG code"}; Configurable ConfCutPartTwo{"ConfCutPartTwo", 3191978, "Particle 2 - Selection bit"}; - Configurable ConfPIDPartTwo{"ConfPIDPartTwo", 0, "Particle 2 - Index in ConfTrkPIDspecies of producer task"}; - Configurable ConfPIDValuePartTwo{"ConfPIDValuePartTwo", 3, "Particle 1 - Read from cutCulator"}; - - Configurable ConfPIDThreshold{"ConfPIDThreshold", 0.75, "Momentum threshold for TPC to TPCTOF PID"}; - Configurable ConfNspecies{"ConfNspecies", 2, "Number of particle spieces with PID info"}; - Configurable> ConfTrkPIDnSigmaMax{"ConfTrkPIDnSigmaMax", std::vector{3.f, 3.5f, 2.5f}, "This configurable needs to be the same as the one used in the producer task"}; + Configurable ConfPIDTPCPartTwo{"ConfPIDTPCPartTwo", 0, "Particle 2 - TPC PID Selection bit"}; + Configurable ConfPIDTPCTOFPartTwo{"ConfPIDTPCTOFPartTwo", 0, "Particle 2 - TPCTOF PID Selection bit"}; + Configurable ConfPIDThresholdPartTwo{"ConfPIDThresholdPartTwo", 0.75, "Particle 2 - Momentum threshold for TPC to TPCTOF PID"}; /// Partitions for particle 1 and particle 2 Partition PartsOne = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartOne) == ConfCutPartOne); @@ -105,38 +103,18 @@ struct CFTutorialTask4 { /// QA for particle 1 for (auto& part : GroupPartsOne) { - /// check PID of particle 1 using function from FemtoUtils using PID bit - if (isFullPIDSelected(part.pidcut(), - part.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value)) { - HistRegistry.fill(HIST("Particle1/hPt"), part.pt()); - HistRegistry.fill(HIST("Particle1/hEta"), part.eta()); - HistRegistry.fill(HIST("Particle1/hPhi"), part.phi()); - } + HistRegistry.fill(HIST("Particle1/hPt"), part.pt()); + HistRegistry.fill(HIST("Particle1/hEta"), part.eta()); + HistRegistry.fill(HIST("Particle1/hPhi"), part.phi()); } /// QA for particle 2 /// skip QA if particle 1 & 2 are the same if (ConfIsSame.value == false) { for (auto& part : GroupPartsTwo) { - /// check PID of particle 1 using function from FemtoUtils using PID bit - if (isFullPIDSelected(part.pidcut(), - part.p(), - ConfPIDThreshold.value, - ConfPIDPartTwo.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartTwo.value, - ConfPIDValuePartTwo.value)) { - HistRegistry.fill(HIST("Particle2/hPt"), part.pt()); - HistRegistry.fill(HIST("Particle2/hEta"), part.eta()); - HistRegistry.fill(HIST("Particle2/hPhi"), part.phi()); - } + HistRegistry.fill(HIST("Particle2/hPt"), part.pt()); + HistRegistry.fill(HIST("Particle2/hEta"), part.eta()); + HistRegistry.fill(HIST("Particle2/hPhi"), part.phi()); } } diff --git a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask5.cxx b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask5.cxx index f7c0c4a815a..d9159c2e3cc 100644 --- a/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask5.cxx +++ b/Tutorials/PWGCF/FemtoFramework/src/CFTutorialTask5.cxx @@ -51,22 +51,21 @@ struct CFTutorialTask5 { Configurable ConfIsSame{"ConfIsSame", false, "Pairs of the same particle"}; Configurable ConfPDGCodePartOne{"ConfPDGCodePartOne", 2212, "Particle 1 - PDG code"}; - Configurable ConfCutPartOne{"ConfCutPartOne", 3191978, "Particle 1 - Selection bit from cutCulator"}; - Configurable ConfPIDPartOne{"ConfPIDPartOne", 0, "Particle 1 - Index in ConfTrkPIDspecies of producer task"}; - Configurable ConfPIDValuePartOne{"ConfPIDValuePartOne", 3, "Particle 1 - Read from cutCulator"}; + Configurable ConfCutPartOne{"ConfCutPartOne", 3191978, "Particle 1 - Selection bit"}; + Configurable ConfPIDTPCPartOne{"ConfPIDTPCPartOne", 2, "Particle 1 - TPC PID Selection bit"}; + Configurable ConfPIDTPCTOFPartOne{"ConfPIDTPCTOFPartOne", 4, "Particle 1 - TPCTOF PID Selection bit"}; + Configurable ConfPIDThresholdPartOne{"ConfPIDThresholdPartOne", 0.75, "Particle 1 - Momentum threshold for TPC to TPCTOF PID"}; Configurable ConfPDGCodePartTwo{"ConfPDGCodePartTwo", 2212, "Particle 2 - PDG code"}; Configurable ConfCutPartTwo{"ConfCutPartTwo", 3191978, "Particle 2 - Selection bit"}; - Configurable ConfPIDPartTwo{"ConfPIDPartTwo", 0, "Particle 2 - Index in ConfTrkPIDspecies of producer task"}; - Configurable ConfPIDValuePartTwo{"ConfPIDValuePartTwo", 3, "Particle 1 - Read from cutCulator"}; - - Configurable ConfPIDThreshold{"ConfPIDThreshold", 0.75, "Momentum threshold for TPC to TPCTOF PID"}; - Configurable ConfNspecies{"ConfNspecies", 2, "Number of particle spieces with PID info"}; - Configurable> ConfTrkPIDnSigmaMax{"ConfTrkPIDnSigmaMax", std::vector{3.f, 3.5f, 2.5f}, "This configurable needs to be the same as the one used in the producer task"}; + Configurable ConfPIDTPCPartTwo{"ConfPIDTPCPartTwo", 0, "Particle 2 - TPC PID Selection bit"}; + Configurable ConfPIDTPCTOFPartTwo{"ConfPIDTPCTOFPartTwo", 0, "Particle 2 - TPCTOF PID Selection bit"}; + Configurable ConfPIDThresholdPartTwo{"ConfPIDThresholdPartTwo", 0.75, "Particle 2 - Momentum threshold for TPC to TPCTOF PID"}; /// Partitions for particle 1 and particle 2 - Partition PartsOne = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartOne) == ConfCutPartOne); - Partition PartsTwo = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartTwo) == ConfCutPartTwo); + Partition PartsOne = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartOne) == ConfCutPartOne) && ifnode(aod::femtodreamparticle::pt < ConfPIDThresholdPartOne, ncheckbit(aod::femtodreamparticle::pidcut, ConfPIDTPCPartOne), ncheckbit(aod::femtodreamparticle::pidcut, ConfPIDTPCTOFPartOne)); + + Partition PartsTwo = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) && ((aod::femtodreamparticle::cut & ConfCutPartTwo) == ConfCutPartTwo) && ifnode(aod::femtodreamparticle::pt < ConfPIDThresholdPartTwo, ncheckbit(aod::femtodreamparticle::pidcut, ConfPIDTPCPartTwo), ncheckbit(aod::femtodreamparticle::pidcut, ConfPIDTPCTOFPartTwo)); HistogramRegistry HistRegistry{"FemtoTutorial", {}, OutputObjHandlingPolicy::AnalysisObject}; @@ -104,7 +103,6 @@ struct CFTutorialTask5 { // process same event void process(FilteredFDCollision const& col, FilteredFDParts const& /*parts*/) { - /// event QA HistRegistry.fill(HIST("Event/hZvtx"), col.posZ()); @@ -114,94 +112,36 @@ struct CFTutorialTask5 { /// QA for particle 1 for (auto& part : GroupPartsOne) { - /// check PID of particle 1 using function from FemtoUtils using PID bit - if (isFullPIDSelected(part.pidcut(), - part.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value)) { - HistRegistry.fill(HIST("Particle1/hPt"), part.pt()); - HistRegistry.fill(HIST("Particle1/hEta"), part.eta()); - HistRegistry.fill(HIST("Particle1/hPhi"), part.phi()); - } + HistRegistry.fill(HIST("Particle1/hPt"), part.pt()); + HistRegistry.fill(HIST("Particle1/hEta"), part.eta()); + HistRegistry.fill(HIST("Particle1/hPhi"), part.phi()); } /// QA for particle 2 /// skip QA if particle 1 & 2 are the same if (ConfIsSame.value == false) { for (auto& part : GroupPartsTwo) { - /// check PID of particle 1 using function from FemtoUtils using PID bit - if (isFullPIDSelected(part.pidcut(), - part.p(), - ConfPIDThreshold.value, - ConfPIDPartTwo.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartTwo.value, - ConfPIDValuePartTwo.value)) { - HistRegistry.fill(HIST("Particle2/hPt"), part.pt()); - HistRegistry.fill(HIST("Particle2/hEta"), part.eta()); - HistRegistry.fill(HIST("Particle2/hPhi"), part.phi()); - } + HistRegistry.fill(HIST("Particle2/hPt"), part.pt()); + HistRegistry.fill(HIST("Particle2/hEta"), part.eta()); + HistRegistry.fill(HIST("Particle2/hPhi"), part.phi()); } } float kstar = 0.; - float m0 = TDatabasePDG::Instance()->GetParticle(ConfPDGCodePartOne.value)->Mass(); - float m1 = TDatabasePDG::Instance()->GetParticle(ConfPDGCodePartTwo.value)->Mass(); + float m0 = o2::analysis::femtoDream::getMass(ConfPDGCodePartOne); + float m1 = o2::analysis::femtoDream::getMass(ConfPDGCodePartTwo); /// particle combinations /// if particles are the same or not determines the combination stratety if (ConfIsSame) { for (auto& [p0, p1] : combinations(soa::CombinationsStrictlyUpperIndexPolicy(GroupPartsOne, GroupPartsTwo))) { - if (isFullPIDSelected(p0.pidcut(), - p0.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value) && - isFullPIDSelected(p1.pidcut(), - p1.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value) - - ) { - kstar = FemtoDreamMath::getkstar(p0, m0, p1, m1); - HistRegistry.fill(HIST("Pair/hSE"), kstar); - } + kstar = FemtoDreamMath::getkstar(p0, m0, p1, m1); + HistRegistry.fill(HIST("Pair/hSE"), kstar); } } else { for (auto& [p0, p1] : combinations(soa::CombinationsFullIndexPolicy(GroupPartsOne, GroupPartsTwo))) { - if (isFullPIDSelected(p0.pidcut(), - p0.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value) && - isFullPIDSelected(p1.pidcut(), - p1.p(), - ConfPIDThreshold.value, - ConfPIDPartOne.value, - ConfNspecies.value, - ConfTrkPIDnSigmaMax.value, - ConfPIDValuePartOne.value, - ConfPIDValuePartOne.value) - - ) { - kstar = FemtoDreamMath::getkstar(p0, m0, p1, m1); - HistRegistry.fill(HIST("Pair/hSE"), kstar); - } + kstar = FemtoDreamMath::getkstar(p0, m0, p1, m1); + HistRegistry.fill(HIST("Pair/hSE"), kstar); } } } diff --git a/Tutorials/PWGHF/DataModelMini.h b/Tutorials/PWGHF/DataModelMini.h index 40a430a4813..7a03f1462b7 100644 --- a/Tutorials/PWGHF/DataModelMini.h +++ b/Tutorials/PWGHF/DataModelMini.h @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file task-mini.cxx +/// \file DataModelMini.h /// \brief Mini version of the HF analysis chain /// /// \author Vít Kučera , Inha University @@ -28,7 +28,7 @@ DECLARE_SOA_COLUMN(IsSelProng, isSelProng, bool); //! prong selection flag } // namespace hf_seltrack // Track selection table -DECLARE_SOA_TABLE(HfSelTrack, "AOD", "HFSELTRACK", //! track selection table +DECLARE_SOA_TABLE(HfTSelTrack, "AOD", "HFTSELTRACK", //! track selection table hf_seltrack::IsSelProng); namespace hf_track_index @@ -39,7 +39,7 @@ DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, Tracks, "_1"); //! prong 1 } // namespace hf_track_index // Track index skim table -DECLARE_SOA_TABLE(HfTrackIndexProng2, "AOD", "HFTRACKIDXP2", //! table with prongs indices +DECLARE_SOA_TABLE(HfT2Prongs, "AOD", "HFT2PRONG", //! table with prongs indices hf_track_index::Prong0Id, hf_track_index::Prong1Id); @@ -79,12 +79,12 @@ DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, //! pz of candidate float, 1.f * pzProng0 + 1.f * pzProng1); DECLARE_SOA_DYNAMIC_COLUMN(M, m, //! invariant mass of candidate [](float px0, float py0, float pz0, float px1, float py1, float pz1, const std::array& m) -> float { return RecoDecay::m(std::array{std::array{px0, py0, pz0}, std::array{px1, py1, pz1}}, m); }); -DECLARE_SOA_DYNAMIC_COLUMN(CPA, cpa, //! cosine of pointing angle of candidate +DECLARE_SOA_DYNAMIC_COLUMN(Cpa, cpa, //! cosine of pointing angle of candidate [](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}); }); } // namespace hf_cand_prong2 // Candidate table -DECLARE_SOA_TABLE(HfCandProng2Base, "AOD", "HFCANDP2BASE", //! 2-prong candidate table +DECLARE_SOA_TABLE(HfTCand2ProngBase, "AOD", "HFTCAND2PBASE", //! 2-prong candidate table hf_cand_prong2::CollisionId, collision::PosX, collision::PosY, collision::PosZ, hf_cand_prong2::XSecondaryVertex, hf_cand_prong2::YSecondaryVertex, hf_cand_prong2::ZSecondaryVertex, @@ -98,14 +98,14 @@ DECLARE_SOA_TABLE(HfCandProng2Base, "AOD", "HFCANDP2BASE", //! 2-prong candidate /* dynamic columns */ hf_cand_prong2::M, /* dynamic columns that use candidate momentum components */ - hf_cand_prong2::CPA, + hf_cand_prong2::Cpa, hf_cand_prong2::Pt); // Extended table with expression columns that can be used as arguments of dynamic columns -DECLARE_SOA_EXTENDED_TABLE_USER(HfCandProng2Ext, HfCandProng2Base, "HFCANDP2EXT", //! extension table for the 2-prong candidate table +DECLARE_SOA_EXTENDED_TABLE_USER(HfTCand2ProngExt, HfTCand2ProngBase, "HFTCAND2PEXT", //! extension table for the 2-prong candidate table hf_cand_prong2::Px, hf_cand_prong2::Py, hf_cand_prong2::Pz); -using HfCandProng2 = HfCandProng2Ext; +using HfTCand2Prong = HfTCand2ProngExt; namespace hf_selcandidate_d0 { @@ -115,7 +115,7 @@ DECLARE_SOA_COLUMN(IsSelD0bar, isSelD0bar, int); //! selection flag for D0 bar } // namespace hf_selcandidate_d0 // Candidate selection table -DECLARE_SOA_TABLE(HfSelCandidateD0, "AOD", "HFSELCANDD0", //! table with D0 selection flags +DECLARE_SOA_TABLE(HfTSelD0, "AOD", "HFTSELD0", //! table with D0 selection flags hf_selcandidate_d0::IsSelD0, hf_selcandidate_d0::IsSelD0bar); } // namespace o2::aod diff --git a/Tutorials/PWGHF/dpl-config_skim.json b/Tutorials/PWGHF/dpl-config_skim.json index 07d172b2c9d..3d78778042e 100644 --- a/Tutorials/PWGHF/dpl-config_skim.json +++ b/Tutorials/PWGHF/dpl-config_skim.json @@ -1,25 +1,27 @@ { "internal-dpl-clock": "", "internal-dpl-aod-reader": { + "aod-file-private": "AO2D.root", + "aod-max-io-rate": "0", "time-limit": "0", "orbit-offset-enumeration": "0", "orbit-multiplier-enumeration": "0", "start-value-enumeration": "0", "end-value-enumeration": "-1", - "step-value-enumeration": "1", - "aod-file": "AO2D.root" + "step-value-enumeration": "1" }, "internal-dpl-aod-spawner": "", "bc-converter": "", "timestamp-task": { + "fatalOnInvalidTimestamp": "false", "verbose": "false", "rct-path": "RCT/Info/RunInformation", "orbit-reset-path": "CTP/Calib/OrbitReset", "ccdb-url": "http://alice-ccdb.cern.ch", - "isRun2MC": "false" + "isRun2MC": "-1" }, "tracks-extra-converter": "", - "zdc-converter": "", + "tracks-extra-spawner": "", "track-propagation": { "ccdb-url": "http://alice-ccdb.cern.ch", "lutPath": "GLO/Param/MatLUT", @@ -27,8 +29,75 @@ "grpmagPath": "GLO/Config/GRPMagField", "mVtxPath": "GLO/Calib/MeanVertex", "minPropagationDistance": "83.0999985", + "useTrackTuner": "false", + "fillTrackTunerTable": "false", + "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.", + "axisPtQA": { + "values": [ + "0", + "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.2", + "2.4", + "2.6", + "2.8", + "3", + "3.2", + "3.4", + "3.6", + "3.8", + "4", + "4.4", + "4.8", + "5.2", + "5.6", + "6", + "6.5", + "7", + "7.5", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "17", + "19", + "21", + "23", + "25", + "30", + "35", + "40", + "50" + ] + }, "processStandard": "false", - "processCovariance": "true" + "processStandardWithPID": "false", + "processCovarianceMc": "false", + "processCovariance": "true", + "processCovarianceWithPID": "false" }, "track-selection": { "isRun3": "true", @@ -42,12 +111,12 @@ "etaMin": "-0.8", "etaMax": "0.8" }, - "hf-track-index-skim-creator-tag-sel-tracks": { + "hf-skim-creator-mini-tag-sel-tracks": { "ptTrackMin": "0.3", "etaTrackMax": "0.8", "dcaTrackMin": "0.0025" }, - "hf-track-index-skim-creator": { + "hf-skim-creator-mini": { "magneticField": "5", "propagateToPCA": "true", "useAbsDCA": "false", diff --git a/Tutorials/PWGHF/dpl-config_task.json b/Tutorials/PWGHF/dpl-config_task.json index 719c8acd000..6418d9b7fc0 100644 --- a/Tutorials/PWGHF/dpl-config_task.json +++ b/Tutorials/PWGHF/dpl-config_task.json @@ -1,13 +1,14 @@ { "internal-dpl-clock": "", "internal-dpl-aod-reader": { + "aod-file-private": "AnalysisResults_trees.root", + "aod-max-io-rate": "0", "time-limit": "0", "orbit-offset-enumeration": "0", "orbit-multiplier-enumeration": "0", "start-value-enumeration": "0", "end-value-enumeration": "-1", "step-value-enumeration": "1", - "aod-file": "AnalysisResults_trees.root", "aod-parent-access-level": "1", "aod-parent-base-path-replacement": "old-path-to-parent;new-path-to-parent" }, @@ -15,38 +16,147 @@ "bc-converter": "", "internal-dpl-aod-index-builder": "", "timestamp-task": { + "fatalOnInvalidTimestamp": "false", "verbose": "false", "rct-path": "RCT/Info/RunInformation", "orbit-reset-path": "CTP/Calib/OrbitReset", "ccdb-url": "http://alice-ccdb.cern.ch", - "isRun2MC": "false" + "isRun2MC": "-1" }, "tracks-extra-converter": "", - "zdc-converter": "", + "bc-selection-task": { + "triggerBcShift": "0", + "ITSROFrameStartBorderMargin": "-1", + "ITSROFrameEndBorderMargin": "-1", + "TimeFrameStartBorderMargin": "-1", + "TimeFrameEndBorderMargin": "-1", + "checkRunDurationLimits": "false", + "processRun2": "false", + "processRun3": "true" + }, + "tracks-extra-spawner": "", "track-propagation": { "ccdb-url": "http://alice-ccdb.cern.ch", "lutPath": "GLO/Param/MatLUT", "geoPath": "GLO/Config/GeometryAligned", "grpmagPath": "GLO/Config/GRPMagField", "mVtxPath": "GLO/Calib/MeanVertex", - "minPropagationDistance": "83.0999985", + "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", + "axisPtQA": { + "values": [ + "0", + "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.2", + "2.4", + "2.6", + "2.8", + "3", + "3.2", + "3.4", + "3.6", + "3.8", + "4", + "4.4", + "4.8", + "5.2", + "5.6", + "6", + "6.5", + "7", + "7.5", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "17", + "19", + "21", + "23", + "25", + "30", + "35", + "40", + "50" + ] + }, "processStandard": "false", - "processCovariance": "true" + "processStandardWithPID": "false", + "processCovarianceMc": "false", + "processCovariance": "true", + "processCovarianceWithPID": "false" }, - "bc-selection-task": { - "triggerBcShift": "999", - "processRun2": "false", - "processRun3": "true" + "tof-signal": { + "ccdb-url": "http://alice-ccdb.cern.ch", + "ccdb-timestamp": "-1", + "timeShiftCCDBPath": "", + "distanceForGoodMatch": "999", + "distanceForGoodMatchLowMult": "999", + "multThreshold": "0", + "enableQaHistograms": "false", + "processRun3": "true", + "processRun2": "false" }, "event-selection-task": { - "syst": "pp", "muonSelection": "0", - "customDeltaBC": "300", - "isMC": "false", + "maxDiffZvtxFT0vsPV": "1", + "isMC": "0", + "TimeIntervalForOccupancyCalculationMin": "-40", + "TimeIntervalForOccupancyCalculationMax": "100", + "TimeBinsForOccupancyCalculation": { + "values": [ + "-40", + "-20", + "0", + "25", + "50", + "75", + "100" + ] + }, + "ReferenceOccupanciesInTimeBins": { + "values": [ + "3000", + "1400", + "750", + "1000", + "1750", + "4000" + ] + }, + "TimeRangeVetoOnCollStandard": "10", + "TimeRangeVetoOnCollNarrow": "4", + "UseWeightsForOccupancyEstimator": "true", "processRun2": "false", "processRun3": "true" }, - "hf-candidate-creator2-prong": { + "hf-task-mini-candidate-creator-2prong": { "magneticField": "5", "propagateToPCA": "true", "useAbsDCA": "false", @@ -56,14 +166,10 @@ "minRelChi2Change": "0.9" }, "pid-multiplicity": { - "processIU": "false", - "processStandard": "true" + "processIU": "true", + "processStandard": "false" }, - "tof-signal": { - "processRun3": "true", - "processRun2": "false" - }, - "tpc-pid-full": { + "tpc-pid": { "param-file": "", "ccdb-url": "http://alice-ccdb.cern.ch", "ccdbPath": "Analysis/PID/TPC/Response", @@ -71,47 +177,155 @@ "ccdb-timestamp": "0", "useNetworkCorrection": "false", "autofetchNetworks": "true", - "skipTPCOnly": "false", + "skipTPCOnly": "true", "networkPathLocally": "network.onnx", "networkPathCCDB": "Analysis/PID/TPC/ML", "enableNetworkOptimizations": "true", "networkSetNumThreads": "0", - "pid-el": "-1", - "pid-mu": "-1", - "pid-pi": "-1", - "pid-ka": "-1", - "pid-pr": "-1", - "pid-de": "-1", - "pid-tr": "-1", - "pid-he": "-1", - "pid-al": "-1" + "pid-full-el": "-1", + "pid-full-mu": "-1", + "pid-full-pi": "-1", + "pid-full-ka": "-1", + "pid-full-pr": "-1", + "pid-full-de": "-1", + "pid-full-tr": "-1", + "pid-full-he": "-1", + "pid-full-al": "-1", + "pid-tiny-el": "-1", + "pid-tiny-mu": "-1", + "pid-tiny-pi": "-1", + "pid-tiny-ka": "-1", + "pid-tiny-pr": "-1", + "pid-tiny-de": "-1", + "pid-tiny-tr": "-1", + "pid-tiny-he": "-1", + "pid-tiny-al": "-1", + "enableTuneOnDataTable": "-1", + "useNetworkEl": "1", + "useNetworkMu": "1", + "useNetworkPi": "1", + "useNetworkKa": "1", + "useNetworkPr": "1", + "useNetworkDe": "1", + "useNetworkTr": "1", + "useNetworkHe": "1", + "useNetworkAl": "1", + "networkBetaGammaCutoff": "0.45", + "processStandard": "true", + "processMcTuneOnData": "false" }, + "multiplicity-table": { + "doVertexZeq": "1", + "fractionOfEvents": "2", + "enabledTables": { + "labels_rows": [ + "FV0Mults", + "FT0Mults", + "FDDMults", + "ZDCMults", + "TrackletMults", + "TPCMults", + "PVMults", + "MultsExtra", + "MultSelections", + "FV0MultZeqs", + "FT0MultZeqs", + "FDDMultZeqs", + "PVMultZeqs", + "MultMCExtras" + ], + "labels_cols": [ + "Enable" + ], + "values": [ + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ], + [ + "-1" + ] + ] + }, + "ccdburl": "http://alice-ccdb.cern.ch", + "ccdbpath": "Centrality/Calibration", + "reconstructionPass": "", + "produceHistograms": "false", + "min_pt_globaltrack": "0.15", + "max_pt_globaltrack": "1e+10", + "min_ncluster_its_globaltrack": "5", + "min_ncluster_itsib_globaltrack": "1", + "processRun2": "false", + "processRun3": "true", + "processGlobalTrackingCounters": "false", + "processMC": "false", + "processMC2Mults": "false" + }, + "ft0-corrected-table": "", + "hf-task-mini-candidate-creator-2prong-expressions": "", "tof-event-time": { + "inheritFromBaseTask": "true", + "ccdb-url": "", + "ccdb-timestamp": "-1", "minMomentum": "0.5", "maxMomentum": "2", "maxEvTimeTOF": "100000", + "sel8TOFEvTime": "false", + "maxNtracksInSet": "10", "paramFileName": "", - "ccdb-url": "http://alice-ccdb.cern.ch", "parametrizationPath": "TOF/Calib/Params", "passName": "", - "ccdb-timestamp": "-1", "loadResponseFromCCDB": "false", + "enableTimeDependentResponse": "false", "fatalOnPassNotAvailable": "true", - "sel8TOFEvTime": "false", - "maxNtracksInSet": "10", "processRun2": "false", - "processNoFT0": "true", - "processFT0": "false", + "processNoFT0": "false", + "processFT0": "true", "processOnlyFT0": "false" }, - "hf-candidate-creator2-prong-expressions": "", "tof-pid-full": { + "inheritFromBaseTask": "true", + "ccdb-url": "", + "ccdb-timestamp": "-1", "paramFileName": "", - "ccdb-url": "http://alice-ccdb.cern.ch", - "parametrizationPath": "TOF/Calib/Params", - "timeShiftCCDBPath": "", + "parametrizationPath": "", "passName": "", - "ccdb-timestamp": "-1", + "timeShiftCCDBPath": "", "loadResponseFromCCDB": "false", "enableTimeDependentResponse": "false", "fatalOnPassNotAvailable": "true", @@ -163,7 +377,7 @@ "processWSlice": "true", "processWoSlice": "false" }, - "hf-candidate-selector-d0": { + "hf-task-mini-candidate-selector-d0": { "ptCandMin": "0", "ptCandMax": "50", "ptPidTpcMin": "0.15", @@ -172,7 +386,7 @@ "cpaMin": "0.98", "massWindow": "0.4" }, - "hf-task-d0": { + "hf-task-mini-d0": { "selectionFlagD0": "1", "selectionFlagD0bar": "1" }, diff --git a/Tutorials/PWGHF/run_skim.sh b/Tutorials/PWGHF/run_skim.sh index 788a2ffd460..fbd33e2b443 100644 --- a/Tutorials/PWGHF/run_skim.sh +++ b/Tutorials/PWGHF/run_skim.sh @@ -28,7 +28,7 @@ DIR_THIS="$(dirname "$(realpath "$0")")" JSON="$DIR_THIS/dpl-config_skim.json" # command line options of O2 workflows -OPTIONS="-b --configuration json://$JSON --aod-memory-rate-limit 2000000000 --shm-segment-size 16000000000 --resources-monitoring 2 --min-failure-level error --aod-writer-keep AOD/HFTRACKIDXP2/0" +OPTIONS="-b --configuration json://$JSON --aod-memory-rate-limit 2000000000 --shm-segment-size 16000000000 --resources-monitoring 2 --aod-writer-keep AOD/HFT2PRONG/0" # execute the mini task workflow and its dependencies # shellcheck disable=SC2086 # Ignore unquoted options. @@ -37,8 +37,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-zdc-converter $OPTIONS \ +o2-analysis-tracks-extra-converter $OPTIONS \ > "$LOGFILE" 2>&1 # report status diff --git a/Tutorials/PWGHF/run_task.sh b/Tutorials/PWGHF/run_task.sh index 096ee292150..73c1c014930 100644 --- a/Tutorials/PWGHF/run_task.sh +++ b/Tutorials/PWGHF/run_task.sh @@ -28,7 +28,7 @@ DIR_THIS="$(dirname "$(realpath "$0")")" JSON="$DIR_THIS/dpl-config_task.json" # command line options of O2 workflows -OPTIONS="-b --configuration json://$JSON --aod-memory-rate-limit 2000000000 --shm-segment-size 16000000000 --resources-monitoring 2 --min-failure-level error" +OPTIONS="-b --configuration json://$JSON --aod-memory-rate-limit 2000000000 --shm-segment-size 16000000000 --resources-monitoring 2" # execute the mini task workflow and its dependencies # shellcheck disable=SC2086 # Ignore unquoted options. @@ -37,9 +37,10 @@ o2-analysis-timestamp $OPTIONS | \ o2-analysis-track-propagation $OPTIONS | \ o2-analysis-event-selection $OPTIONS | \ o2-analysis-pid-tpc-base $OPTIONS | \ -o2-analysis-pid-tpc-full $OPTIONS | \ +o2-analysis-pid-tpc $OPTIONS | \ 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-zdc-converter $OPTIONS \ diff --git a/Tutorials/PWGHF/skimCreatorMini.cxx b/Tutorials/PWGHF/skimCreatorMini.cxx index 6f20d6ac6fb..ac6b12e2004 100644 --- a/Tutorials/PWGHF/skimCreatorMini.cxx +++ b/Tutorials/PWGHF/skimCreatorMini.cxx @@ -38,13 +38,13 @@ using namespace o2::framework::expressions; // Track selection ===================================================================== /// Track selection -struct HfTrackIndexSkimCreatorTagSelTracks { - Produces rowSelectedTrack; +struct HfSkimCreatorMiniTagSelTracks { + Produces rowSelectedTrack; // 2-prong cuts - Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT for 2 prong candidate"}; - Configurable etaTrackMax{"etaTrackMax", 0.8, "max. pseudorapidity for 2 prong candidate"}; - Configurable dcaTrackMin{"dcaTrackMin", 0.0025, "min. DCA for 2 prong candidate"}; + Configurable ptTrackMin{"ptTrackMin", 0.3, "min. track pT for 2 prong candidate"}; + Configurable etaTrackMax{"etaTrackMax", 0.8, "max. pseudorapidity for 2 prong candidate"}; + Configurable dcaTrackMin{"dcaTrackMin", 0.0025, "min. DCA for 2 prong candidate"}; using TracksWDcaSel = soa::Join; @@ -110,21 +110,21 @@ struct HfTrackIndexSkimCreatorTagSelTracks { /// Track index skim creator /// Pre-selection of 2-prong secondary vertices -struct HfTrackIndexSkimCreator { - Produces rowTrackIndexProng2; +struct HfSkimCreatorMini { + Produces rowTrackIndexProng2; // vertexing parameters - Configurable magneticField{"magneticField", 5., "magnetic field [kG]"}; + Configurable magneticField{"magneticField", 5., "magnetic field [kG]"}; Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", false, "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 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"}; o2::vertexing::DCAFitterN<2> fitter; // 2-prong vertex fitter - using SelectedTracks = soa::Filtered>; + using SelectedTracks = soa::Filtered>; Filter filterSelectTracks = aod::hf_seltrack::isSelProng == true; @@ -166,7 +166,12 @@ struct HfTrackIndexSkimCreator { auto trackParVarNeg1 = getTrackParCov(trackNeg1); // secondary vertex reconstruction and further 2-prong selections - if (fitter.process(trackParVarPos1, trackParVarNeg1) == 0) { + int nVtxFromFitter = 0; + try { + nVtxFromFitter = fitter.process(trackParVarPos1, trackParVarNeg1); + } catch (...) { + } + if (nVtxFromFitter == 0) { continue; } // get secondary vertex @@ -197,6 +202,6 @@ struct HfTrackIndexSkimCreator { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGHF/taskMini.cxx b/Tutorials/PWGHF/taskMini.cxx index 800153a4fb9..871fe710581 100644 --- a/Tutorials/PWGHF/taskMini.cxx +++ b/Tutorials/PWGHF/taskMini.cxx @@ -41,17 +41,17 @@ using namespace o2::framework::expressions; /// Candidate creator /// Reconstruction of heavy-flavour 2-prong decay candidates -struct HfCandidateCreator2Prong { - Produces rowCandidateBase; +struct HfTaskMiniCandidateCreator2Prong { + Produces rowCandidateBase; // vertexing parameters - Configurable magneticField{"magneticField", 5., "magnetic field [kG]"}; + Configurable magneticField{"magneticField", 5., "magnetic field [kG]"}; Configurable propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"}; Configurable useAbsDCA{"useAbsDCA", false, "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 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"}; o2::vertexing::DCAFitterN<2> fitter; // 2-prong vertex fitter double massPiK{0.}; @@ -74,7 +74,7 @@ struct HfCandidateCreator2Prong { } void process(aod::Collisions const&, - aod::HfTrackIndexProng2 const& rowsTrackIndexProng2, + aod::HfT2Prongs const& rowsTrackIndexProng2, TracksWithCov const&) { // loop over pairs of track indices @@ -119,27 +119,27 @@ struct HfCandidateCreator2Prong { }; /// Helper extension task -/// Extends the base table with expression columns (see the HfCandProng2Ext table). -struct HfCandidateCreator2ProngExpressions { - Spawns rowCandidateProng2; +/// Extends the base table with expression columns (see the HfTCand2ProngExt table). +struct HfTaskMiniCandidateCreator2ProngExpressions { + Spawns rowCandidateProng2; void init(InitContext const&) {} }; // Candidate selection ===================================================================== /// D0 candidate selector -struct HfCandidateSelectorD0 { - Produces hfSelD0Candidate; +struct HfTaskMiniCandidateSelectorD0 { + Produces hfSelD0Candidate; - Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; - Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; + Configurable ptCandMin{"ptCandMin", 0., "Lower bound of candidate pT"}; + Configurable ptCandMax{"ptCandMax", 50., "Upper bound of candidate pT"}; // TPC - 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 nSigmaTpc{"nSigmaTpc", 3., "Nsigma cut on TPC only"}; + 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 nSigmaTpc{"nSigmaTpc", 3., "Nsigma cut on TPC only"}; // topological cuts - Configurable cpaMin{"cpaMin", 0.98, "Min. cosine of pointing angle"}; - Configurable massWindow{"massWindow", 0.4, "Half-width of the invariant-mass window"}; + Configurable cpaMin{"cpaMin", 0.98, "Min. cosine of pointing angle"}; + Configurable massWindow{"massWindow", 0.4, "Half-width of the invariant-mass window"}; HfHelper hfHelper; TrackSelectorPi selectorPion; @@ -195,7 +195,7 @@ struct HfCandidateSelectorD0 { return true; } - void process(aod::HfCandProng2 const& candidates, + void process(aod::HfTCand2Prong const& candidates, TracksWithPid const&) { // looping over 2-prong candidates @@ -273,13 +273,13 @@ struct HfCandidateSelectorD0 { // Analysis task ===================================================================== /// D0 analysis task -struct HfTaskD0 { +struct HfTaskMiniD0 { Configurable selectionFlagD0{"selectionFlagD0", 1, "Selection flag for D0"}; Configurable selectionFlagD0bar{"selectionFlagD0bar", 1, "Selection flag for D0 bar"}; HfHelper hfHelper; - Partition> selectedD0Candidates = aod::hf_selcandidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_selcandidate_d0::isSelD0bar >= selectionFlagD0bar; + Partition> selectedD0Candidates = aod::hf_selcandidate_d0::isSelD0 >= selectionFlagD0 || aod::hf_selcandidate_d0::isSelD0bar >= selectionFlagD0bar; HistogramRegistry registry{ "registry", @@ -295,7 +295,7 @@ struct HfTaskD0 { registry.add("hCpaVsPtCand", strTitle + ";" + "cosine of pointing angle" + ";" + strPt + ";" + strEntries, {HistType::kTH2F, {{110, -1.1, 1.1}, {100, 0., 10.}}}); } - void process(soa::Join const& /*candidates*/) + void process(soa::Join const& /*candidates*/) { for (const auto& candidate : selectedD0Candidates) { if (candidate.isSelD0() >= selectionFlagD0) { @@ -314,8 +314,8 @@ struct HfTaskD0 { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{ - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc), - adaptAnalysisTask(cfgc)}; + 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), + adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Resonance/CMakeLists.txt b/Tutorials/PWGLF/Resonance/CMakeLists.txt index 36c4b84bf28..6adf9fb3247 100644 --- a/Tutorials/PWGLF/Resonance/CMakeLists.txt +++ b/Tutorials/PWGLF/Resonance/CMakeLists.txt @@ -24,3 +24,23 @@ o2physics_add_dpl_workflow(resonances-step2 SOURCES resonances_step2.cxx PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(resonances-step3 + SOURCES resonances_step3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(resonances-step4 + SOURCES resonances_step4.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(resonances-step5 + SOURCES resonances_step5.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(resonances-step6 + SOURCES resonances_step6.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) diff --git a/Tutorials/PWGLF/Resonance/README.md b/Tutorials/PWGLF/Resonance/README.md index 7e1433bb8bb..19d51c0eced 100644 --- a/Tutorials/PWGLF/Resonance/README.md +++ b/Tutorials/PWGLF/Resonance/README.md @@ -1,6 +1,6 @@ # This is the base for the PWGLF tutorials for the O2AT -The tutorial (6-10 Nov 2023) can be still used and is a reference for the LF analyses. +The tutorial can be still used and is a reference for the LF Resonance analyses. It is built as a set of steps. Each step adds a level of complexity and is built in a separate executable. The executables are defined in the `CMakeLists.txt`. @@ -8,3 +8,9 @@ The executables are defined in the `CMakeLists.txt`. * `README.md` this readme * `CMakeLists.txt` here are defined the source files to compile * `resonance_step0.cxx` Read the resonance table and run basic track loop +* `resonance_step1.cxx` Producing same event invariant mass distribution +* `resonance_step2.cxx` Producing Mixed event invariant mass distribution +* `resonance_step3.cxx` Starting point for MC: loop over all Generated MC particles +* `resonance_step4.cxx` Producing histograms (pt distributions etc.) for Generated MCs +* `resonance_step5.cxx` Loop over all MC Tracks and produce basic QA histograms +* `resonance_step6.cxx` Resonance reconstruction diff --git a/Tutorials/PWGLF/Resonance/resonances_step3.cxx b/Tutorials/PWGLF/Resonance/resonances_step3.cxx new file mode 100644 index 00000000000..f2ef8dbbe67 --- /dev/null +++ b/Tutorials/PWGLF/Resonance/resonances_step3.cxx @@ -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. +/// +/// \brief this is a starting point for the Resonances tutorial for MC part +/// \author Hirak Kumar Koley +/// \since 11/10/2024 + +#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; + +// STEP 3 +// Starting point for MC: loop over all Generated MC particles +struct resonances_tutorial { + 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 minimum pt cut"}; + + // Initialize the ananlysis task + void init(o2::framework::InitContext&) + { + // register histograms + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + } + + // MC particle selection + template + bool ptCut(const ParticleType resoParents) + { + // basic pt cuts + if (std::abs(resoParents.pt()) < cMinPtcut) + return false; + + return true; + } + + // Fill histograms (main function) + template + void fillHistograms(const CollisionType& /*collision*/, const ParticleType& resoParents) + { + for (auto part : resoParents) { // loop over all resoParents + if (!ptCut(part)) + continue; // pt selection + + // QA plots + histos.fill(HIST("hEta"), part.eta()); + } + } + + // Process the MC + void process(aod::ResoCollision& collision, aod::ResoMCParents& resoParents) + { + // Fill the event counter + histos.fill(HIST("hVertexZ"), collision.posZ()); + fillHistograms(collision, resoParents); // Fill histograms, MC + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Resonance/resonances_step4.cxx b/Tutorials/PWGLF/Resonance/resonances_step4.cxx new file mode 100644 index 00000000000..05f7b35f7cf --- /dev/null +++ b/Tutorials/PWGLF/Resonance/resonances_step4.cxx @@ -0,0 +1,109 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 for MC +/// \author Hirak Kumar Koley +/// \since 11/10/2024 + +#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; + +// STEP 4 +// Producing histograms for Generated MCs +struct resonances_tutorial { + 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"}; + + /// 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 binsCent{"binsCent", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Binning of the centrality axis"}; + + // Initialize the ananlysis task + void init(o2::framework::InitContext&) + { + AxisSpec centAxis = {binsCent, "V0M (%)"}; + AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; + + // register histograms + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}}); + + // MC QA + histos.add("hphipt", "pT distribution of True MC phi", kTH1F, {ptAxis}); + histos.add("phiGen", "pT distribution of True MC phi", kTH2F, {ptAxis, centAxis}); + + // Print output histograms statistics + LOG(info) << "Size of the histograms in resonance tutorial step1:"; + histos.print(); + } + + // MC particle selection + template + bool ptCut(const ParticleType resoParents) + { + // basic pt cuts + if (std::abs(resoParents.pt()) < cMinPtcut) + return false; + + return true; + } + + // Fill histograms (main function) + template + void fillHistograms(const CollisionType& collision, const ParticleType& resoParents) + { + auto multiplicity = collision.cent(); + for (auto& part : resoParents) { // loop over all pre-filtered MC particles + if (!ptCut(part)) + continue; // pt selection + + // QA plots + histos.fill(HIST("hEta"), part.eta()); + + if (abs(part.pdgCode()) != 333) // phi(0) + continue; + if (abs(part.y()) > 0.5) { // rapidity cut + continue; + } + if (abs(part.daughterPDG1()) != 321 || abs(part.daughterPDG2()) != 321) { // At least one decay to Kaon + continue; + } + histos.fill(HIST("phiGen"), part.pt(), multiplicity); + histos.fill(HIST("hphipt"), part.pt()); + } + } + + // Process the MC + void process(aod::ResoCollision& collision, aod::ResoMCParents& resoParents) + { + auto multiplicity = collision.cent(); + + // Fill the event counter + histos.fill(HIST("hVertexZ"), collision.posZ()); + histos.fill(HIST("hMultiplicityPercent"), multiplicity); + + fillHistograms(collision, resoParents); // Fill histograms, MC + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Resonance/resonances_step5.cxx b/Tutorials/PWGLF/Resonance/resonances_step5.cxx new file mode 100644 index 00000000000..7d8463b9236 --- /dev/null +++ b/Tutorials/PWGLF/Resonance/resonances_step5.cxx @@ -0,0 +1,136 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Hirak Kumar Koley +/// \since 11/10/2024 + +#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; + +// STEP 5 +// loop over all MC Tracks and produce basic QA histograms +struct resonances_tutorial { + // Define slice per Resocollision + SliceCache cache; + Preslice perResoCollision = aod::resodaughter::resoCollisionId; + Preslice perCollision = aod::track::collisionId; + + 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"}; + + // Track selection + // primary track condition + 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 + + // DCA Selections + // 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"}; + + // PID selection + Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmacutTOF{"nsigmacutTOF", 3.0, "Value /home/hirak/Desktop/LstarTaskTest/run/dpl-config.jsonof the TOF Nsigma cut"}; + + // Initialize the ananlysis task + void init(o2::framework::InitContext&) + { + // register histograms + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{100, -0.5f, 0.5f}}); + histos.add("hDcaz", "Dcaz distribution", kTH1F, {{100, -0.5f, 0.5f}}); + histos.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH1F, {{100, -10.0f, 10.0f}}); + histos.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH1F, {{100, -10.0f, 10.0f}}); + + // Print output histograms statistics + LOG(info) << "Size of the histograms in resonance tutorial step2:"; + histos.print(); + } + + // Track selection + template + bool trackCut(const TrackType track) + { + // 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 (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + return true; + } + + // PID selection TPC +TOF Veto + template + bool selectionPID(const T& candidate) + { + bool tpcPass = std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC; + bool tofPass = (candidate.hasTOF()) ? std::abs(candidate.tofNSigmaKa()) < nsigmacutTOF : true; + if (tpcPass && tofPass) { + return true; + } + return false; + } + + template + void fillHistograms(const CollisionType& /* collision */, const TracksType& dTracks) + { + for (auto track : dTracks) { // loop over all dTracks + if (!trackCut(track) || !selectionPID(track)) { + continue; // track selection and PID selection + } + // QA plots + histos.fill(HIST("hEta"), track.eta()); + histos.fill(HIST("hDcaxy"), track.dcaXY()); + histos.fill(HIST("hDcaz"), track.dcaZ()); + histos.fill(HIST("hNsigmaKaonTPC"), track.tpcNSigmaKa()); + if (track.hasTOF()) { + histos.fill(HIST("hNsigmaKaonTOF"), track.tofNSigmaKa()); + } + } + } + + // Process the data + void process(aod::ResoCollision& collision, + soa::Join const& resotracks) + { + // Fill the event counter + histos.fill(HIST("hVertexZ"), collision.posZ()); + histos.fill(HIST("hMultiplicityPercent"), collision.cent()); + + fillHistograms(collision, resotracks); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Resonance/resonances_step6.cxx b/Tutorials/PWGLF/Resonance/resonances_step6.cxx new file mode 100644 index 00000000000..23ccac6dfd2 --- /dev/null +++ b/Tutorials/PWGLF/Resonance/resonances_step6.cxx @@ -0,0 +1,188 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Hirak Kumar Koley +/// \since 11/10/2024 + +#include + +#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; + +// STEP 6 +// Resonance reconstruction +struct resonances_tutorial { + // Define slice per Resocollision + SliceCache cache; + Preslice perResoCollision = aod::resodaughter::resoCollisionId; + Preslice perCollision = aod::track::collisionId; + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + ///// Configurables + /// 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 binsCent{"binsCent", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Binning of the centrality axis"}; + Configurable cInvMassStart{"cInvMassStart", 0.6, "Invariant mass start"}; + Configurable cInvMassEnd{"cInvMassEnd", 1.5, "Invariant mass end"}; + Configurable cInvMassBins{"cInvMassBins", 900, "Invariant mass binning"}; + + // 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"}; + + // Track selection + // primary track condition + 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 + + // DCA Selections + // 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"}; + + // PID selection + Configurable nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"}; + Configurable nsigmacutTOF{"nsigmacutTOF", 3.0, "Value of the TOF Nsigma cut"}; + + // variables + double massKa = o2::constants::physics::MassKPlus; + + // Initialize the ananlysis task + void init(o2::framework::InitContext&) + { + AxisSpec centAxis = {binsCent, "V0M (%)"}; + AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"}; + AxisSpec invMassAxis = {cInvMassBins, cInvMassStart, cInvMassEnd, "Invariant Mass (GeV/#it{c}^2)"}; + + // register histograms + histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}}); + histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}}); + histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}}); + histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{100, -0.5f, 0.5f}}); + histos.add("hDcaz", "Dcaz distribution", kTH1F, {{100, -0.5f, 0.5f}}); + histos.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH1F, {{100, -10.0f, 10.0f}}); + histos.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH1F, {{100, -10.0f, 10.0f}}); + + // MC QA + histos.add("h3Recphiinvmass", "Invariant mass of Reconstructed MC phi", kTH3F, {centAxis, ptAxis, invMassAxis}); + histos.add("phiRec", "pT distribution of Reconstructed MC phi", kTH2F, {ptAxis, centAxis}); + histos.add("phiRecinvmass", "Inv mass distribution of Reconstructed MC Phi", kTH1F, {invMassAxis}); + + // Print output histograms statistics + LOG(info) << "Size of the histograms in resonance tutorial step2:"; + histos.print(); + } + + // Track selection + template + bool trackCut(const TrackType track) + { + // 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 (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA()) + return false; + if (cfgPVContributor && !track.isPVContributor()) + return false; + return true; + } + + // PID selection TPC +TOF Veto + template + bool selectionPID(const T& candidate) + { + bool tpcPass = std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC; + bool tofPass = (candidate.hasTOF()) ? std::abs(candidate.tofNSigmaKa()) < nsigmacutTOF : true; + if (tpcPass && tofPass) { + return true; + } + return false; + } + + // Fill histograms (main function) + double rapidity, mass, pT, paircharge; + TLorentzVector daughter1, daughter2, lResonance; + template + void fillHistograms(const CollisionType& collision, const TracksType& dTracks1, const TracksType& dTracks2) + { + auto multiplicity = collision.cent(); + for (auto track1 : dTracks1) { // loop over all dTracks1 + if (!trackCut(track1) || !selectionPID(track1)) { + continue; // track selection and PID selection + } + // QA plots + histos.fill(HIST("hEta"), track1.eta()); + histos.fill(HIST("hDcaxy"), track1.dcaXY()); + histos.fill(HIST("hDcaz"), track1.dcaZ()); + histos.fill(HIST("hNsigmaKaonTPC"), track1.tpcNSigmaKa()); + if (track1.hasTOF()) { + histos.fill(HIST("hNsigmaKaonTOF"), track1.tofNSigmaKa()); + } + for (auto track2 : dTracks2) { // loop over all dTracks2 + if (!trackCut(track2) || !selectionPID(track2)) { + continue; // track selection and PID selection + } + if (track2.index() <= track1.index()) { + continue; // condition to avoid double counting of pair + } + daughter1.SetXYZM(track1.px(), track1.py(), track1.pz(), massKa); // set the daughter1 4-momentum + daughter2.SetXYZM(track2.px(), track2.py(), track2.pz(), massKa); // set the daughter2 4-momentum + lResonance = daughter1 + daughter2; // calculate the lResonance 4-momentum + mass = lResonance.M(); + pT = lResonance.Pt(); + rapidity = lResonance.Rapidity(); + + if (abs(track1.pdgCode()) != 321 || abs(track2.pdgCode()) != 321) + continue; + if (track1.motherId() != track2.motherId()) // Same mother + continue; + if (abs(track1.motherPDG()) != 333) + continue; + + // MC histograms + histos.fill(HIST("phiRec"), lResonance.Pt(), multiplicity); + histos.fill(HIST("phiRecinvmass"), lResonance.M()); + histos.fill(HIST("h3Recphiinvmass"), multiplicity, lResonance.Pt(), lResonance.M()); + } + } + } + + // Process the data + void process(aod::ResoCollision& collision, + soa::Join const& resotracks) + { + // Fill the event counter + histos.fill(HIST("hVertexZ"), collision.posZ()); + histos.fill(HIST("hMultiplicityPercent"), collision.cent()); + + fillHistograms(collision, resotracks, resotracks); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/PWGLF/Strangeness/CMakeLists.txt b/Tutorials/PWGLF/Strangeness/CMakeLists.txt index ede23b4c734..39734cb836a 100644 --- a/Tutorials/PWGLF/Strangeness/CMakeLists.txt +++ b/Tutorials/PWGLF/Strangeness/CMakeLists.txt @@ -9,28 +9,6 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -# Strangeness analysis tutorial -o2physics_add_dpl_workflow(strangeness-step0 - SOURCES strangeness_step0.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME AnalysisTutorial) +add_subdirectory(pp) +add_subdirectory(PbPb) -o2physics_add_dpl_workflow(strangeness-step1 - SOURCES strangeness_step1.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME AnalysisTutorial) - -o2physics_add_dpl_workflow(strangeness-step2 - SOURCES strangeness_step2.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME AnalysisTutorial) - -o2physics_add_dpl_workflow(strangeness-step3 - SOURCES strangeness_step3.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME AnalysisTutorial) - -o2physics_add_dpl_workflow(strangeness-step4 - SOURCES strangeness_step4.cxx - PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore - COMPONENT_NAME AnalysisTutorial) diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/CMakeLists.txt b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/CMakeLists.txt new file mode 100644 index 00000000000..d050dc59b47 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/CMakeLists.txt @@ -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. + +o2physics_add_dpl_workflow(strangeness-pbpb-skeleton + SOURCES strangeness_pbpb_skeleton.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-pbpb-step0 + SOURCES strangeness_pbpb_step0.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-pbpb-step1 + SOURCES strangeness_pbpb_step1.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-pbpb-step2 + SOURCES strangeness_pbpb_step2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-pbpb-step3 + SOURCES strangeness_pbpb_step3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-pbpb-step4 + SOURCES strangeness_pbpb_step4.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_skeleton.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_skeleton.sh new file mode 100644 index 00000000000..9327402771f --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_skeleton.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="skeleton" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_skeleton.json" + +o2-analysistutorial-lf-strangeness-pbpb-skeleton "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/${STEP}/${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step0.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step0.sh new file mode 100644 index 00000000000..bcfeb9ab890 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step0.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="0" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_step0.json" + +o2-analysis-lf-cascadespawner "${OPTION}" | o2-analysistutorial-lf-strangeness-pbpb-step0 "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/step${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/step${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/step${STEP}/step${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step1.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step1.sh new file mode 100644 index 00000000000..826f0ea1421 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step1.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="1" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_step1.json" + +o2-analysis-lf-cascadespawner "${OPTION}" | o2-analysistutorial-lf-strangeness-pbpb-step1 "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/step${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/step${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/step${STEP}/step${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step2.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step2.sh new file mode 100644 index 00000000000..aca62bad45e --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step2.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="2" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_step2.json" + +o2-analysis-lf-cascadespawner "${OPTION}" | o2-analysistutorial-lf-strangeness-pbpb-step2 "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/step${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/step${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/step${STEP}/step${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step3.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step3.sh new file mode 100644 index 00000000000..580b3c0c17f --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step3.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="3" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_step3.json" + +o2-analysis-lf-cascadepid "${OPTION}" | o2-analysis-lf-cascadespawner "${OPTION}" | o2-analysistutorial-lf-strangeness-pbpb-step3 "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/step${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/step${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/step${STEP}/step${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step4.sh b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step4.sh new file mode 100644 index 00000000000..08f929b3fa8 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/run_step4.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="4" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration_step4.json" + +o2-analysis-lf-cascadepid "${OPTION}" | o2-analysis-lf-cascadespawner "${OPTION}" | o2-analysistutorial-lf-strangeness-pbpb-step4 "${OPTION}" --aod-file @input_data.txt > "$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/step${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/step${STEP}/AnalysisResults.root" + mv dpl-config.json "${DIR_THIS}/results/step${STEP}/step${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_skeleton.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_skeleton.cxx new file mode 100644 index 00000000000..788aaead7ae --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_skeleton.cxx @@ -0,0 +1,67 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + } + + // 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); + + void process(soa::Filtered>::iterator const& collision) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step0.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step0.cxx new file mode 100644 index 00000000000..b0e595246d7 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step0.cxx @@ -0,0 +1,86 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// STEP 0 +// Starting point: loop over all cascades and fill invariant mass histogram + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rOmega{"omega", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {100, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec OmegaMassAxis = {100, 1.63f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // Xi/Omega reconstruction + rXi.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + + rOmega.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {OmegaMassAxis}}); + } + + // 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); + + void process(soa::Filtered>::iterator const& collision, + aod::CascCores const& Cascades) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + // Cascades + for (const auto& casc : Cascades) { + rXi.fill(HIST("hMassXi"), casc.mXi()); + rOmega.fill(HIST("hMassOmega"), casc.mOmega()); + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step1.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step1.cxx new file mode 100644 index 00000000000..836be98b240 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step1.cxx @@ -0,0 +1,146 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// STEP 0 +// Starting point: loop over all cascades and fill invariant mass histogram +// STEP 1 +// Apply selections on topological variables of Cascades + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rOmega{"omega", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // Configurable parameters for cascade selection + Configurable cascadesetting_cospa{"cascadesetting_cospa", 0.98, "Casc CosPA"}; + Configurable cascadesetting_v0cospa{"cascadesetting_v0cospa", 0.97, "V0 CosPA"}; + Configurable cascadesetting_dcacascdau{"cascadesetting_dcacascdau", 1.0, "DCA cascade daughters"}; + Configurable cascadesetting_dcav0dau{"cascadesetting_dcav0dau", 1.0, "DCA v0 daughters"}; + Configurable cascadesetting_dcabachtopv{"cascadesetting_dcabachtopv", 0.06, "DCA bachelor to PV"}; + Configurable cascadesetting_dcapostopv{"cascadesetting_dcapostopv", 0.06, "DCA positive to PV"}; + Configurable cascadesetting_dcanegtopv{"cascadesetting_dcanegtopv", 0.06, "DCA negative to PV"}; + Configurable cascadesetting_mindcav0topv{"cascadesetting_mindcav0topv", 0.01, "minimum V0 DCA to PV"}; + Configurable cascadesetting_cascradius{"cascadesetting_cascradius", 0.5, "cascradius"}; + Configurable cascadesetting_v0radius{"cascadesetting_v0radius", 1.2, "v0radius"}; + Configurable cascadesetting_v0masswindow{"cascadesetting_v0masswindow", 0.01, "v0 mass window"}; + Configurable cascadesetting_competingmassrej{"cascadesetting_competingmassrej", 0.008, "Competing mass rejection"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {100, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec OmegaMassAxis = {100, 1.63f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // Xi/Omega reconstruction + rXi.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelected", "hMassXiSelected", {HistType::kTH1F, {XiMassAxis}}); + + rOmega.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelected", "hMassOmegaSelected", {HistType::kTH1F, {OmegaMassAxis}}); + + // Xi/Omega topological cuts + rXi.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rXi.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + + rOmega.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rOmega.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + } + + // 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); + + // Filters on Cascades + // Cannot filter on dynamic columns + Filter preFilterCascades = (aod::cascdata::dcaV0daughters < cascadesetting_dcav0dau && + nabs(aod::cascdata::dcapostopv) > cascadesetting_dcapostopv && + nabs(aod::cascdata::dcanegtopv) > cascadesetting_dcanegtopv && + nabs(aod::cascdata::dcabachtopv) > cascadesetting_dcabachtopv && + aod::cascdata::dcacascdaughters < cascadesetting_dcacascdau); + + void process(soa::Filtered>::iterator const& collision, + soa::Filtered> const& Cascades) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + // Cascades + for (const auto& casc : Cascades) { + rXi.fill(HIST("hMassXi"), casc.mXi()); + rOmega.fill(HIST("hMassOmega"), casc.mOmega()); + + // Cut on dynamic columns + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_cospa) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_v0cospa) + continue; + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > cascadesetting_v0masswindow) + continue; + if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_mindcav0topv) + continue; + if (casc.cascradius() < cascadesetting_cascradius) + continue; + if (casc.v0radius() < cascadesetting_v0radius) + continue; + + // Fill histograms! (if possible) + rXi.fill(HIST("hMassXiSelected"), casc.mXi()); + + rXi.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rXi.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascadesetting_competingmassrej) { // competing mass rejection, only in case of Omega + rOmega.fill(HIST("hMassOmegaSelected"), casc.mOmega()); + + rOmega.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rOmega.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step2.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step2.cxx new file mode 100644 index 00000000000..1558bb78052 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step2.cxx @@ -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. +/// +/// \brief Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// STEP 0 +// Starting point: loop over all cascades and fill invariant mass histogram +// STEP 1 +// Apply selections on topological variables of Cascades +// STEP 2 +// Apply TPC PID selections on cascade daughter tracks + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rOmega{"omega", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // Configurable parameters for cascade selection + Configurable cascadesetting_cospa{"cascadesetting_cospa", 0.98, "Casc CosPA"}; + Configurable cascadesetting_v0cospa{"cascadesetting_v0cospa", 0.97, "V0 CosPA"}; + Configurable cascadesetting_dcacascdau{"cascadesetting_dcacascdau", 1.0, "DCA cascade daughters"}; + Configurable cascadesetting_dcav0dau{"cascadesetting_dcav0dau", 1.0, "DCA v0 daughters"}; + Configurable cascadesetting_dcabachtopv{"cascadesetting_dcabachtopv", 0.06, "DCA bachelor to PV"}; + Configurable cascadesetting_dcapostopv{"cascadesetting_dcapostopv", 0.06, "DCA positive to PV"}; + Configurable cascadesetting_dcanegtopv{"cascadesetting_dcanegtopv", 0.06, "DCA negative to PV"}; + Configurable cascadesetting_mindcav0topv{"cascadesetting_mindcav0topv", 0.01, "minimum V0 DCA to PV"}; + Configurable cascadesetting_cascradius{"cascadesetting_cascradius", 0.5, "cascradius"}; + Configurable cascadesetting_v0radius{"cascadesetting_v0radius", 1.2, "v0radius"}; + Configurable cascadesetting_v0masswindow{"cascadesetting_v0masswindow", 0.01, "v0 mass window"}; + Configurable cascadesetting_competingmassrej{"cascadesetting_competingmassrej", 0.008, "Competing mass rejection"}; + + // Configurable parameters for PID selection + Configurable NSigmaTPCPion{"NSigmaTPCPion", 4, "NSigmaTPCPion"}; + Configurable NSigmaTPCKaon{"NSigmaTPCKaon", 4, "NSigmaTPCKaon"}; + Configurable NSigmaTPCProton{"NSigmaTPCProton", 4, "NSigmaTPCProton"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {100, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec OmegaMassAxis = {100, 1.63f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // Xi/Omega reconstruction + rXi.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelected", "hMassXiSelected", {HistType::kTH1F, {XiMassAxis}}); + + rOmega.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelected", "hMassOmegaSelected", {HistType::kTH1F, {OmegaMassAxis}}); + + // Xi/Omega topological cuts + rXi.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rXi.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + + rOmega.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rOmega.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + } + + // 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); + + // Filters on Cascades + // Cannot filter on dynamic columns + Filter preFilterCascades = (aod::cascdata::dcaV0daughters < cascadesetting_dcav0dau && + nabs(aod::cascdata::dcapostopv) > cascadesetting_dcapostopv && + nabs(aod::cascdata::dcanegtopv) > cascadesetting_dcanegtopv && + nabs(aod::cascdata::dcabachtopv) > cascadesetting_dcabachtopv && + aod::cascdata::dcacascdaughters < cascadesetting_dcacascdau); + + // Defining the type of the daughter tracks + using dauTracks = soa::Join; + + void process(soa::Filtered>::iterator const& collision, + soa::Filtered> const& Cascades, + dauTracks const&) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + // Cascades + for (const auto& casc : Cascades) { + const auto& bachDaughterTrackCasc = casc.bachTrackExtra_as(); + const auto& posDaughterTrackCasc = casc.posTrackExtra_as(); + const auto& negDaughterTrackCasc = casc.negTrackExtra_as(); + + rXi.fill(HIST("hMassXi"), casc.mXi()); + rOmega.fill(HIST("hMassOmega"), casc.mOmega()); + + // Cut on dynamic columns + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_cospa) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_v0cospa) + continue; + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > cascadesetting_v0masswindow) + continue; + if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_mindcav0topv) + continue; + if (casc.cascradius() < cascadesetting_cascradius) + continue; + if (casc.v0radius() < cascadesetting_v0radius) + continue; + + // PID selection + if (casc.sign() < 0) { + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } else { + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } + + // Fill histograms! (if possible) + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaPi()) < NSigmaTPCPion) { // Xi case + rXi.fill(HIST("hMassXiSelected"), casc.mXi()); + + rXi.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rXi.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaKa()) < NSigmaTPCKaon) { // Omega case + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascadesetting_competingmassrej) { // competing mass rejection, only in case of Omega + rOmega.fill(HIST("hMassOmegaSelected"), casc.mOmega()); + + rOmega.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rOmega.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step3.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step3.cxx new file mode 100644 index 00000000000..f12a4f02560 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step3.cxx @@ -0,0 +1,243 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// STEP 0 +// Starting point: loop over all cascades and fill invariant mass histogram +// STEP 1 +// Apply selections on topological variables of Cascades +// STEP 2 +// Apply TPC PID selections on cascade daughter tracks +// STEP 3 +// Apply TOF PID selections on cascade daugther tracks (if info is available) + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rOmega{"omega", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // Configurable parameters for cascade selection + Configurable cascadesetting_cospa{"cascadesetting_cospa", 0.98, "Casc CosPA"}; + Configurable cascadesetting_v0cospa{"cascadesetting_v0cospa", 0.97, "V0 CosPA"}; + Configurable cascadesetting_dcacascdau{"cascadesetting_dcacascdau", 1.0, "DCA cascade daughters"}; + Configurable cascadesetting_dcav0dau{"cascadesetting_dcav0dau", 1.0, "DCA v0 daughters"}; + Configurable cascadesetting_dcabachtopv{"cascadesetting_dcabachtopv", 0.06, "DCA bachelor to PV"}; + Configurable cascadesetting_dcapostopv{"cascadesetting_dcapostopv", 0.06, "DCA positive to PV"}; + Configurable cascadesetting_dcanegtopv{"cascadesetting_dcanegtopv", 0.06, "DCA negative to PV"}; + Configurable cascadesetting_mindcav0topv{"cascadesetting_mindcav0topv", 0.01, "minimum V0 DCA to PV"}; + Configurable cascadesetting_cascradius{"cascadesetting_cascradius", 0.5, "cascradius"}; + Configurable cascadesetting_v0radius{"cascadesetting_v0radius", 1.2, "v0radius"}; + Configurable cascadesetting_v0masswindow{"cascadesetting_v0masswindow", 0.01, "v0 mass window"}; + Configurable cascadesetting_competingmassrej{"cascadesetting_competingmassrej", 0.008, "Competing mass rejection"}; + + // Configurable parameters for PID selection + Configurable NSigmaTPCPion{"NSigmaTPCPion", 4, "NSigmaTPCPion"}; + Configurable NSigmaTPCKaon{"NSigmaTPCKaon", 4, "NSigmaTPCKaon"}; + Configurable NSigmaTPCProton{"NSigmaTPCProton", 4, "NSigmaTPCProton"}; + + // Configurable parameters for TOF PID selection + Configurable NSigmaTOFPion{"NSigmaTOFPion", 3, "NSigmaTOFPion"}; + Configurable NSigmaTOFKaon{"NSigmaTOFKaon", 3, "NSigmaTOFKaon"}; + Configurable NSigmaTOFProton{"NSigmaTOFProton", 3, "NSigmaTOFProton"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {100, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec OmegaMassAxis = {100, 1.63f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // Xi/Omega reconstruction + rXi.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelected", "hMassXiSelected", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelectedWithTOF", "hMassXiSelectedWithTOF", {HistType::kTH1F, {XiMassAxis}}); + + rOmega.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelected", "hMassOmegaSelected", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelectedWithTOF", "hMassOmegaSelectedWithTOF", {HistType::kTH1F, {OmegaMassAxis}}); + + // Xi/Omega topological cuts + rXi.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rXi.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + + rOmega.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rOmega.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + } + + // 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); + + // Filters on Cascades + // Cannot filter on dynamic columns + Filter preFilterCascades = (aod::cascdata::dcaV0daughters < cascadesetting_dcav0dau && + nabs(aod::cascdata::dcapostopv) > cascadesetting_dcapostopv && + nabs(aod::cascdata::dcanegtopv) > cascadesetting_dcanegtopv && + nabs(aod::cascdata::dcabachtopv) > cascadesetting_dcabachtopv && + aod::cascdata::dcacascdaughters < cascadesetting_dcacascdau); + + // Defining the type of the daughter tracks + using dauTracks = soa::Join; + + void process(soa::Filtered>::iterator const& collision, + soa::Filtered> const& Cascades, + dauTracks const&) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + // Cascades + for (const auto& casc : Cascades) { + const auto& bachDaughterTrackCasc = casc.bachTrackExtra_as(); + const auto& posDaughterTrackCasc = casc.posTrackExtra_as(); + const auto& negDaughterTrackCasc = casc.negTrackExtra_as(); + + rXi.fill(HIST("hMassXi"), casc.mXi()); + rOmega.fill(HIST("hMassOmega"), casc.mOmega()); + + // Cut on dynamic columns + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_cospa) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_v0cospa) + continue; + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > cascadesetting_v0masswindow) + continue; + if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_mindcav0topv) + continue; + if (casc.cascradius() < cascadesetting_cascradius) + continue; + if (casc.v0radius() < cascadesetting_v0radius) + continue; + + // PID selection + if (casc.sign() < 0) { + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } else { + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } + + // TOF PID check + bool xiPassTOFSelection = true; + bool omegaPassTOFSelection = true; + if (casc.sign() < 0) { + if (posDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > NSigmaTOFProton) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPr()) > NSigmaTOFProton) { + omegaPassTOFSelection &= false; + } + } + if (negDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPi()) > NSigmaTOFPion) { + omegaPassTOFSelection &= false; + } + } + } else { + if (posDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPi()) > NSigmaTOFPion) { + omegaPassTOFSelection &= false; + } + } + if (negDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > NSigmaTOFProton) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPr()) > NSigmaTOFProton) { + omegaPassTOFSelection &= false; + } + } + } + + if (bachDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmKa()) > NSigmaTOFKaon) { + omegaPassTOFSelection &= false; + } + } + + // Fill histograms! (if possible) + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaPi()) < NSigmaTPCPion) { // Xi case + rXi.fill(HIST("hMassXiSelected"), casc.mXi()); + if (xiPassTOFSelection) + rXi.fill(HIST("hMassXiSelectedWithTOF"), casc.mXi()); + + rXi.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rXi.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaKa()) < NSigmaTPCKaon) { // Omega case + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascadesetting_competingmassrej) { // competing mass rejection, only in case of Omega + rOmega.fill(HIST("hMassOmegaSelected"), casc.mOmega()); + if (omegaPassTOFSelection) + rOmega.fill(HIST("hMassOmegaSelectedWithTOF"), casc.mOmega()); + + rOmega.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rOmega.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step4.cxx b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step4.cxx new file mode 100644 index 00000000000..d45ef3c26a1 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/Analysis/strangeness_pbpb_step4.cxx @@ -0,0 +1,324 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 Step4 of the Strangeness tutorial +/// \author Romain Schotter +/// based on the original codes from: +/// \author Nepeivoda Roman (roman.nepeivoda@cern.ch) +/// \author Chiara De Martin (chiara.de.martin@cern.ch) + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessPIDTables.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Framework/O2DatabasePDGPlugin.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +// STEP 0 +// Starting point: loop over all cascades and fill invariant mass histogram +// STEP 1 +// Apply selections on topological variables of Cascades +// STEP 2 +// Apply TPC PID selections on cascade daughter tracks +// STEP 3 +// Apply TOF PID selections on cascade daugther tracks (if info is available) +// STEP 4 +// Check the MC information of the cascades + +struct strangeness_pbpb_tutorial { + // Histograms are defined with HistogramRegistry + HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rXi{"xi", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rOmega{"omega", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + HistogramRegistry rGenParticles{"genParticles", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; + + // Configurable for histograms + Configurable nBins{"nBins", 100, "N bins in all histos"}; + + // Configurable for event selection + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + + // Configurable parameters for cascade selection + Configurable cascadesetting_cospa{"cascadesetting_cospa", 0.98, "Casc CosPA"}; + Configurable cascadesetting_v0cospa{"cascadesetting_v0cospa", 0.97, "V0 CosPA"}; + Configurable cascadesetting_dcacascdau{"cascadesetting_dcacascdau", 1.0, "DCA cascade daughters"}; + Configurable cascadesetting_dcav0dau{"cascadesetting_dcav0dau", 1.0, "DCA v0 daughters"}; + Configurable cascadesetting_dcabachtopv{"cascadesetting_dcabachtopv", 0.06, "DCA bachelor to PV"}; + Configurable cascadesetting_dcapostopv{"cascadesetting_dcapostopv", 0.06, "DCA positive to PV"}; + Configurable cascadesetting_dcanegtopv{"cascadesetting_dcanegtopv", 0.06, "DCA negative to PV"}; + Configurable cascadesetting_mindcav0topv{"cascadesetting_mindcav0topv", 0.01, "minimum V0 DCA to PV"}; + Configurable cascadesetting_cascradius{"cascadesetting_cascradius", 0.5, "cascradius"}; + Configurable cascadesetting_v0radius{"cascadesetting_v0radius", 1.2, "v0radius"}; + Configurable cascadesetting_v0masswindow{"cascadesetting_v0masswindow", 0.01, "v0 mass window"}; + Configurable cascadesetting_competingmassrej{"cascadesetting_competingmassrej", 0.008, "Competing mass rejection"}; + + // Configurable parameters for PID selection + Configurable NSigmaTPCPion{"NSigmaTPCPion", 4, "NSigmaTPCPion"}; + Configurable NSigmaTPCKaon{"NSigmaTPCKaon", 4, "NSigmaTPCKaon"}; + Configurable NSigmaTPCProton{"NSigmaTPCProton", 4, "NSigmaTPCProton"}; + + // Configurable parameters for TOF PID selection + Configurable NSigmaTOFPion{"NSigmaTOFPion", 3, "NSigmaTOFPion"}; + Configurable NSigmaTOFKaon{"NSigmaTOFKaon", 3, "NSigmaTOFKaon"}; + Configurable NSigmaTOFProton{"NSigmaTOFProton", 3, "NSigmaTOFProton"}; + + // PDG data base + Service pdgDB; + + void init(InitContext const&) + { + // Axes + AxisSpec XiMassAxis = {100, 1.28f, 1.36f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec OmegaMassAxis = {100, 1.63f, 1.7f, "#it{M}_{inv} [GeV/#it{c}^{2}]"}; + AxisSpec vertexZAxis = {nBins, -15., 15., "vrtx_{Z} [cm]"}; + AxisSpec ptAxis = {100, 0.0f, 10.0f, "#it{p}_{T} (GeV/#it{c})"}; + + // Histograms + // Event selection + rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}}); + + // Xi/Omega reconstruction + rXi.add("hMassXi", "hMassXi", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelected", "hMassXiSelected", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiSelectedWithTOF", "hMassXiSelectedWithTOF", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hMassXiTrueRec", "hMassXiTrueRec", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hPtXiTrueRec", "hPtXiTrueRec", {HistType::kTH1F, {ptAxis}}); + rXi.add("hMassXiTrueRecWithTOF", "hMassXiTrueRecWithTOF", {HistType::kTH1F, {XiMassAxis}}); + rXi.add("hPtXiTrueRecWithTOF", "hPtXiTrueRecWithTOF", {HistType::kTH1F, {ptAxis}}); + + rOmega.add("hMassOmega", "hMassOmega", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelected", "hMassOmegaSelected", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaSelectedWithTOF", "hMassOmegaSelectedWithTOF", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hMassOmegaTrueRec", "hMassOmegaTrueRec", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hPtOmegaTrueRec", "hPtOmegaTrueRec", {HistType::kTH1F, {ptAxis}}); + rOmega.add("hMassOmegaTrueRecWithTOF", "hMassOmegaTrueRecWithTOF", {HistType::kTH1F, {OmegaMassAxis}}); + rOmega.add("hPtOmegaTrueRecWithTOF", "hPtOmegaTrueRecWithTOF", {HistType::kTH1F, {ptAxis}}); + + // Xi/Omega topological cuts + rXi.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rXi.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + + rOmega.add("hCascDCAV0Daughters", "hCascDCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.2f}}}); + rOmega.add("hCascCosPA", "hCascCosPA", {HistType::kTH1F, {{100, 0.95f, 1.f}}}); + + // Generated level histograms + rEventSelection.add("hVertexZGen", "hVertexZGen", {HistType::kTH1F, {vertexZAxis}}); + rGenParticles.add("hPtXiGen", "hPtXiGen", {HistType::kTH1F, {{ptAxis}}}); + rGenParticles.add("hPtOmegaGen", "hPtOmegaGen", {HistType::kTH1F, {{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 posZFilter = (nabs(o2::aod::collision::posZ) < cutzvertex); + Filter posZFilterMC = (nabs(o2::aod::mccollision::posZ) < cutzvertex); + + // Filters on Cascades + // Cannot filter on dynamic columns + Filter preFilterCascades = (aod::cascdata::dcaV0daughters < cascadesetting_dcav0dau && + nabs(aod::cascdata::dcapostopv) > cascadesetting_dcapostopv && + nabs(aod::cascdata::dcanegtopv) > cascadesetting_dcanegtopv && + nabs(aod::cascdata::dcabachtopv) > cascadesetting_dcabachtopv && + aod::cascdata::dcacascdaughters < cascadesetting_dcacascdau); + + // Defining the type of the daughter tracks + using dauTracks = soa::Join; + + void processRecMC(soa::Filtered>::iterator const& collision, + soa::Filtered> const& Cascades, + dauTracks const&, + aod::CascMCCores const& /*cascmccores*/) + { + // Fill the event counter + rEventSelection.fill(HIST("hVertexZRec"), collision.posZ()); + + // Cascades + for (const auto& casc : Cascades) { + const auto& bachDaughterTrackCasc = casc.bachTrackExtra_as(); + const auto& posDaughterTrackCasc = casc.posTrackExtra_as(); + const auto& negDaughterTrackCasc = casc.negTrackExtra_as(); + + rXi.fill(HIST("hMassXi"), casc.mXi()); + rOmega.fill(HIST("hMassOmega"), casc.mOmega()); + + // Cut on dynamic columns + if (casc.casccosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_cospa) + continue; + if (casc.v0cosPA(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_v0cospa) + continue; + if (TMath::Abs(casc.mLambda() - pdgDB->Mass(3122)) > cascadesetting_v0masswindow) + continue; + if (casc.dcav0topv(collision.posX(), collision.posY(), collision.posZ()) < cascadesetting_mindcav0topv) + continue; + if (casc.cascradius() < cascadesetting_cascradius) + continue; + if (casc.v0radius() < cascadesetting_v0radius) + continue; + + // PID selection + if (casc.sign() < 0) { + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } else { + if (TMath::Abs(negDaughterTrackCasc.tpcNSigmaPr()) > NSigmaTPCProton) { + continue; + } + if (TMath::Abs(posDaughterTrackCasc.tpcNSigmaPi()) > NSigmaTPCPion) { + continue; + } + } + + // TOF PID check + bool xiPassTOFSelection = true; + bool omegaPassTOFSelection = true; + if (casc.sign() < 0) { + if (posDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > NSigmaTOFProton) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPr()) > NSigmaTOFProton) { + omegaPassTOFSelection &= false; + } + } + if (negDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPi()) > NSigmaTOFPion) { + omegaPassTOFSelection &= false; + } + } + } else { + if (posDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPi()) > NSigmaTOFPion) { + omegaPassTOFSelection &= false; + } + } + if (negDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiLaPr()) > NSigmaTOFProton) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmLaPr()) > NSigmaTOFProton) { + omegaPassTOFSelection &= false; + } + } + } + + if (bachDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmKa()) > NSigmaTOFKaon) { + omegaPassTOFSelection &= false; + } + } + + if (bachDaughterTrackCasc.hasTOF()) { + if (TMath::Abs(casc.tofNSigmaXiPi()) > NSigmaTOFPion) { + xiPassTOFSelection &= false; + } + if (TMath::Abs(casc.tofNSigmaOmKa()) > NSigmaTOFKaon) { + omegaPassTOFSelection &= false; + } + } + + // Fill histograms! (if possible) + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaPi()) < NSigmaTPCPion) { // Xi case + rXi.fill(HIST("hMassXiSelected"), casc.mXi()); + if (xiPassTOFSelection) { + rXi.fill(HIST("hMassXiSelectedWithTOF"), casc.mXi()); + } + + rXi.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rXi.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaKa()) < NSigmaTPCKaon) { // Omega case + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascadesetting_competingmassrej) { // competing mass rejection, only in case of Omega + rOmega.fill(HIST("hMassOmegaSelected"), casc.mOmega()); + if (omegaPassTOFSelection) { + rOmega.fill(HIST("hMassOmegaSelectedWithTOF"), casc.mOmega()); + } + + rOmega.fill(HIST("hCascDCAV0Daughters"), casc.dcaV0daughters()); + rOmega.fill(HIST("hCascCosPA"), casc.casccosPA(collision.posX(), collision.posY(), collision.posZ())); + } + } + + // MC truth info + if (!casc.has_cascMCCore()) { + continue; + } + auto cascmccore = casc.cascMCCore_as(); + + // Checking that the cascade is a true Xi + if (TMath::Abs(cascmccore.pdgCode()) == 3312) { + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaPi()) < NSigmaTPCPion) { // Xi case + rXi.fill(HIST("hMassXiTrueRec"), casc.mXi()); + rXi.fill(HIST("hPtXiTrueRec"), casc.pt()); + if (xiPassTOFSelection) { + rXi.fill(HIST("hMassXiTrueRecWithTOF"), casc.mXi()); + rXi.fill(HIST("hPtXiTrueRecWithTOF"), casc.pt()); + } + } + } + if (TMath::Abs(cascmccore.pdgCode()) == 3334) { + if (TMath::Abs(bachDaughterTrackCasc.tpcNSigmaKa()) < NSigmaTPCKaon) { // Omega case + if (TMath::Abs(casc.mXi() - pdgDB->Mass(3312)) > cascadesetting_competingmassrej) { // competing mass rejection, only in case of Omega + rOmega.fill(HIST("hMassOmegaTrueRec"), casc.mOmega()); + rOmega.fill(HIST("hPtOmegaTrueRec"), casc.pt()); + if (omegaPassTOFSelection) { + rOmega.fill(HIST("hMassOmegaTrueRecWithTOF"), casc.mOmega()); + rOmega.fill(HIST("hPtOmegaTrueRecWithTOF"), casc.pt()); + } + } + } + } + } + } + + void processGenMC(soa::Filtered::iterator const& mcCollision, + const soa::SmallGroups>& collisions, + const soa::SmallGroups>& cascMC) + { + if (collisions.size() < 1) // to process generated collisions that've been reconstructed at least once + return; + rEventSelection.fill(HIST("hVertexZGen"), mcCollision.posZ()); + + for (const auto& cascmc : cascMC) { + if (TMath::Abs(cascmc.pdgCode()) == 3312) { + rGenParticles.fill(HIST("hPtXiGen"), cascmc.ptMC()); + } + if (TMath::Abs(cascmc.pdgCode()) == 3334) { + rGenParticles.fill(HIST("hPtOmegaGen"), cascmc.ptMC()); + } + } + } + + PROCESS_SWITCH(strangeness_pbpb_tutorial, processRecMC, "Process Run 3 mc, reconstructed", true); + PROCESS_SWITCH(strangeness_pbpb_tutorial, processGenMC, "Process Run 3 mc, generated", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc)}; +} diff --git a/Tutorials/PWGLF/Strangeness/PbPb/CMakeLists.txt b/Tutorials/PWGLF/Strangeness/PbPb/CMakeLists.txt new file mode 100644 index 00000000000..f593f821726 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does 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(Analysis) +# add_subdirectory(DerivedDataProduction) \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/Data/run.sh b/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/Data/run.sh new file mode 100644 index 00000000000..632f8375470 --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/Data/run.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="deriveddata" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configuration.json" + +o2-analysis-pid-tof-base "${OPTION}" | + o2-analysis-event-selection "${OPTION}" | + o2-analysis-lf-lambdakzerobuilder "${OPTION}" | + o2-analysis-lf-cascadebuilder "${OPTION}" | + o2-analysis-multiplicity-table "${OPTION}" | + o2-analysis-centrality-table "${OPTION}" | + o2-analysis-lf-epvector "${OPTION}" | + o2-analysis-centrality-qa "${OPTION}" | + o2-analysis-ud-sgcand-producer "${OPTION}" | + o2-analysis-timestamp "${OPTION}" | + o2-analysis-ft0-corrected-table "${OPTION}" | + o2-analysis-track-propagation "${OPTION}" | + o2-analysis-pid-tpc-base "${OPTION}" | + o2-analysis-pid-tpc "${OPTION}" | + o2-analysis-trackselection "${OPTION}" | + o2-analysis-pid-tof-full "${OPTION}" | + o2-analysis-pid-tof-beta "${OPTION}" | + o2-analysis-lf-strangederivedbuilder "${OPTION}" --aod-file @input_data.txt --aod-writer-json OutputDirector.json >"$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/${STEP}/AnalysisResults.root" + mv AO2D.root "${DIR_THIS}/results/${STEP}/AO2D.root" + mv dpl-config.json "${DIR_THIS}/results/${STEP}/${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi diff --git a/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/MC/runMC.sh b/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/MC/runMC.sh new file mode 100644 index 00000000000..e9e086e4f4e --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/PbPb/DerivedDataProduction/MC/runMC.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# log file where the terminal output will be saved +STEP="deriveddata" +LOGFILE="log-${STEP}.txt" + +#directory of this script +DIR_THIS=$PWD + +OPTION="-b --configuration json://configurationMC.json" + +o2-analysis-pid-tof-base "${OPTION}" | + o2-analysis-mccollisionextra "${OPTION}" | + o2-analysis-lf-lambdakzerobuilder "${OPTION}" | + o2-analysis-lf-cascadebuilder "${OPTION}" | + o2-analysis-lf-cascademcbuilder "${OPTION}" | + o2-analysis-centrality-table "${OPTION}" | + o2-analysis-lf-lambdakzeromcbuilder "${OPTION}" | + o2-analysis-mccollision-converter "${OPTION}" | + o2-analysis-ud-sgcand-producer "${OPTION}" | + o2-analysis-timestamp "${OPTION}" | + o2-analysis-ft0-corrected-table "${OPTION}" | + o2-analysis-track-propagation "${OPTION}" | + o2-analysis-pid-tpc-base "${OPTION}" | + o2-analysis-pid-tpc "${OPTION}" | + o2-analysis-multiplicity-table "${OPTION}" | + o2-analysis-trackselection "${OPTION}" | + o2-analysis-pid-tof-full "${OPTION}" | + o2-analysis-pid-tof-beta "${OPTION}" | + o2-analysis-event-selection "${OPTION}" | + o2-analysis-lf-strangederivedbuilder "${OPTION}" --aod-file @input_dataMC.txt --aod-writer-json OutputDirectorMC.json >"$LOGFILE" 2>&1 + +# report status +rc=$? +if [ $rc -eq 0 ]; then + echo "No problems!" + mkdir -p "${DIR_THIS}/results/${STEP}" + mv AnalysisResults.root "${DIR_THIS}/results/${STEP}/AnalysisResults.root" + mv AO2D.root "${DIR_THIS}/results/${STEP}/AO2D.root" + mv dpl-config.json "${DIR_THIS}/results/${STEP}/${STEP}.json" +else + echo "Error: Exit code ${rc}" + echo "Check the log file ${LOGFILE}" + exit ${rc} +fi diff --git a/Tutorials/PWGLF/Strangeness/README.md b/Tutorials/PWGLF/Strangeness/README.md index ee28059d0f8..1976051fe3b 100644 --- a/Tutorials/PWGLF/Strangeness/README.md +++ b/Tutorials/PWGLF/Strangeness/README.md @@ -1,13 +1,29 @@ # This is the base for the PWGLF tutorials for the O2AT -The tutorial (17-28 Apr 2023) can be still used and is a reference for the LF analyses. +The tutorial (14-18 Oct 2024) can be used as a reference for the LF analysis. It is built as a set of steps. Each step adds a level of complexity and is built in a separate executable. -The executables are defined in the `CMakeLists.txt`. -## Files -* `README.md` this readme +The tutorial is divided into two directories depending on the collision system: +## pp +This repository contains the codes to analyse V0 and cascade particles in proton-proton collisions: * `CMakeLists.txt` here are defined the source files to compile * `strangeness_step0.cxx` Starting point: loop over all V0s and fill invariant mass histogram * `strangeness_step1.cxx` Apply selections on topological variables of V0s * `strangeness_step2.cxx` Apply PID selections on V0 daughter tracks * `strangeness_step3.cxx` Check the MC information of the V0s and verify with the PID information of daughter tracks + +The introduction and hands-on sessions can be found here: https://indico.cern.ch/event/1326201/ + +## PbPb +This repository contains the code to analyse cascade particles in Pb-Pb collisions. +The tutorial revolves around two aspects: +i) the derived data production in the directory DerivedDataProduction, +ii) the analysis of the derived data in the directory Analysis, containing: +* `CMakeLists.txt` here are defined the source files to compile +* `strangeness_pbpb_step0.cxx` Starting point: loop over all cascades and fill invariant mass histogram +* `strangeness_pbpb_step1.cxx` Apply selections on topological variables of cascades +* `strangeness_pbpb_step2.cxx` Apply TPC PID selections on cascade daughter tracks +* `strangeness_pbpb_step3.cxx` Apply TOF PID selections on cascade daughter tracks (if available) +* `strangeness_pbpb_step4.cxx` Check the MC information of the cascade + +The introduction and hands-on sessions can be found here: https://indico.cern.ch/event/1425820/ \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/pp/CMakeLists.txt b/Tutorials/PWGLF/Strangeness/pp/CMakeLists.txt new file mode 100644 index 00000000000..f46ac1f9e0b --- /dev/null +++ b/Tutorials/PWGLF/Strangeness/pp/CMakeLists.txt @@ -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. + +# Strangeness analysis tutorial +o2physics_add_dpl_workflow(strangeness-step0 + SOURCES strangeness_step0.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-step1 + SOURCES strangeness_step1.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-step2 + SOURCES strangeness_step2.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-step3 + SOURCES strangeness_step3.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) + +o2physics_add_dpl_workflow(strangeness-step4 + SOURCES strangeness_step4.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME AnalysisTutorial) \ No newline at end of file diff --git a/Tutorials/PWGLF/Strangeness/strangeness_step0.cxx b/Tutorials/PWGLF/Strangeness/pp/strangeness_step0.cxx similarity index 100% rename from Tutorials/PWGLF/Strangeness/strangeness_step0.cxx rename to Tutorials/PWGLF/Strangeness/pp/strangeness_step0.cxx diff --git a/Tutorials/PWGLF/Strangeness/strangeness_step1.cxx b/Tutorials/PWGLF/Strangeness/pp/strangeness_step1.cxx similarity index 100% rename from Tutorials/PWGLF/Strangeness/strangeness_step1.cxx rename to Tutorials/PWGLF/Strangeness/pp/strangeness_step1.cxx diff --git a/Tutorials/PWGLF/Strangeness/strangeness_step2.cxx b/Tutorials/PWGLF/Strangeness/pp/strangeness_step2.cxx similarity index 100% rename from Tutorials/PWGLF/Strangeness/strangeness_step2.cxx rename to Tutorials/PWGLF/Strangeness/pp/strangeness_step2.cxx diff --git a/Tutorials/PWGLF/Strangeness/strangeness_step3.cxx b/Tutorials/PWGLF/Strangeness/pp/strangeness_step3.cxx similarity index 100% rename from Tutorials/PWGLF/Strangeness/strangeness_step3.cxx rename to Tutorials/PWGLF/Strangeness/pp/strangeness_step3.cxx diff --git a/Tutorials/PWGLF/Strangeness/strangeness_step4.cxx b/Tutorials/PWGLF/Strangeness/pp/strangeness_step4.cxx similarity index 100% rename from Tutorials/PWGLF/Strangeness/strangeness_step4.cxx rename to Tutorials/PWGLF/Strangeness/pp/strangeness_step4.cxx diff --git a/Tutorials/PWGUD/CMakeLists.txt b/Tutorials/PWGUD/CMakeLists.txt index da52aa07b26..de978b518dc 100644 --- a/Tutorials/PWGUD/CMakeLists.txt +++ b/Tutorials/PWGUD/CMakeLists.txt @@ -39,3 +39,21 @@ o2physics_add_dpl_workflow(udtutorial-04 PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) +o2physics_add_dpl_workflow(udtutorial-05 + SOURCES UDTutorial_05.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(udtutorial-06 + SOURCES UDTutorial_06.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore + COMPONENT_NAME Analysis) + +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 new file mode 100644 index 00000000000..3a9bfb79605 --- /dev/null +++ b/Tutorials/PWGUD/UDTutorial_05.cxx @@ -0,0 +1,318 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "iostream" +#include "TLorentzVector.h" +#include "TDatabasePDG.h" + +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/SGTrackSelector.h" + +// using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// \brief Example task to study two pions candidates using SG derive data +/// \author Anisa Khatun +/// \date 10.10.2024 + +// Struct to define the analysis task +struct UDTutorial05 { + // SGSelector object to manage track and collision selections + SGSelector sgSelector; + + Configurable FV0_cut{"FV0", 100., "FV0A threshold"}; + Configurable FT0A_cut{"FT0A", 100., "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", 10., "ZDC threshold"}; + Configurable gap_Side{"gap", 2, "gap selection"}; + + // 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.01, "Track Pt"}; + Configurable TPC_cluster{"TPC_cluster", 50, "No.of TPC cluster"}; + + // Kinmatic cuts + Configurable PID_cut{"PID_cut", 5, "TPC PID"}; + Configurable Rap_cut{"Rap_cut", 0.9, "Track rapidity"}; + Configurable Mass_Max{"Mass_Max", 10, "Invariant Mass range high"}; + Configurable Mass_Min{"Mass_Min", 0, "Invariant Mass range low"}; + Configurable Pt_coherent{"Pt_coherent", 0.15, "Coherent selection"}; + + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //----------------------------------------------------------------------------------------------------------------------- + void init(o2::framework::InitContext&) + { + + registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + + // Fill counter to see effect of each selection criteria + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{20, 0., 20.}}); + + TString SelectionCuts[16] = {"NoSelection", "gapside", "goodtracks", "truegap", "2collcontrib", "2goodtrk", "TPCPID", "Rap_cut", "unlikesign", "mass_cut", "coherent", "incoherent", "likesign", "mass_cut", "coherent", "incoherent"}; + + for (int i = 0; i < 16; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + // tracks + registry.add("hTracks", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracksPions", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("TwoPion/h2TracksPions", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + + registry.add("hdEdx", "p vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {100, 0.0, 200.0}}); + registry.add("hdEdxPion", "p_{#pi} vs dE/dx Signal", kTH2F, {{100, 0.0, 3.0}, {100, 0.0, 200.0}}); + + registry.add("TwoPion/hNsigPi1vsPi2", "NSigmaPi(t1) vs NSigmapi (t2);n#sigma_{1};n#sigma_{2}", kTH2F, {{100, -15., 15.}, {100, -15., 15}}); + registry.add("TwoPion/hNsigEl1vsEl2", "NSigmaEl(t1) vs NSigmaEl (t2);n#sigma_{1};n#sigma_{2}", kTH2F, {{100, -15., 15.}, {100, -15., 15}}); + registry.add("TwoPion/hNsigPivsPt1", "Pt vs NSigmaPi (t1);#it{p_{t}}, GeV/c;n#sigma_{#pi}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + registry.add("TwoPion/hNsigPivsPt2", "Pt vs NSigmaPi (t2);#it{p_{t}}, GeV/c;n#sigma_{#pi}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + registry.add("TwoPion/hNsigElvsPt1", "Pt vs NSigmaEl (t1);#it{p_{t}}, GeV/c;n#sigma_{#e}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + registry.add("TwoPion/hNsigElvsPt2", "Pt vs NSigmaEl (t2);#it{p_{t}}, GeV/c;n#sigma_{#e}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + registry.add("TwoPion/hNsigMuvsPt1", "Pt vs NSigmaMu (t1);#it{p_{t}}, GeV/c;n#sigma_{#pi}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + registry.add("TwoPion/hNsigMuvsPt2", "Pt vs NSigmaMu (t2);#it{p_{t}}, GeV/c;n#sigma_{#pi}", kTH2F, {{100, 0., 2.5}, {100, -15., 15}}); + + registry.add("TwoPion/hPtsingle_track1", "Pt t1;#it{p_{t}}, GeV/c;", kTH1F, {{600, 0., 3.}}); + registry.add("TwoPion/hPtsingle_track2", "Pt t2;#it{p_{t}}, GeV/c;", kTH1F, {{600, 0., 3.}}); + registry.add("TwoPion/hEta_t1", "Eta of t1;#it{#eta};", kTH1F, {{100, -5., 5.}}); + registry.add("TwoPion/hEta_t2", "Eta of t2;#it{#eta};", kTH1F, {{100, -5., 5.}}); + registry.add("TwoPion/hP1", "P vs TPC signal;#it{P_{track}}, GeV/c; signal_{TPC} t1", kTH2F, {{100, 0., 2.}, {300, 0, 150}}); + registry.add("TwoPion/hTPCsig", "TPC signal;signal_{TPC} t2; signal_{TPC} t2", kTH2F, {{300, 0., 150.}, {300, 0, 150}}); + registry.add("TwoPion/hP2", "P vs TPC signal;#it{P_{track}}, GeV/c; signal_{TPC} t1", kTH2F, {{100, 0., 2.}, {300, 0, 150}}); + registry.add("TwoPion/hTPCsig1", "TPC signal;signal_{TPC} t2; signal_{TPC} t2", kTH2F, {{300, 0., 150.}, {300, 0, 150}}); + + registry.add("TwoPion/hMassLike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/hMassUnlike", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Coherent/hMassUnlikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Coherent/hMassLikeCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Incoherent/hMassUnlikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + registry.add("TwoPion/Incoherent/hMassLikeInCoherent", "m_{#pi#pi} [GeV/#it{c}^{2}]", kTH1F, {{20000, 0., 20.}}); + + registry.add("TwoPion/hPt", "Pt;#it{p_{t}}, GeV/c;", kTH1D, {{1000, 0., 10.}}); + registry.add("TwoPion/hPtLike", "Pt;#it{p_{t}}, GeV/c;", kTH1D, {{1000, 0., 10.}}); + registry.add("TwoPion/hEta", "Eta;#it{#eta};", kTH1F, {{500, -10., 10.}}); + registry.add("TwoPion/hRap", "Rapidity;#it{y};", kTH1F, {{500, -10., 10.}}); + registry.add("TwoPion/hPhiSystem", "Phi;#it{#Phi};", kTH1F, {{250, 0. * TMath::Pi(), 2. * TMath::Pi()}}); + registry.add("TwoPion/hMPt", "Inv.M vs Pt;M, GeV/c^{2};#it{P_{t}}, GeV/c;", kTH2F, {{100, 0., 10.}, {100, 0., 10.}}); + } + + using udtracks = soa::Join; + using udtracksfull = soa::Join; + + using UDCollisionsFull = soa::Join; + + //__________________________________________________________________________ + // Main process + void process(UDCollisionsFull::iterator const& collision, udtracksfull const& tracks) + { + // No selection criteria + registry.fill(HIST("hSelectionCounter"), 0); + + // Accessing gap sides + int gapSide = collision.gapSide(); + if (gapSide < 0 || gapSide > 2) + return; + + registry.fill(HIST("hSelectionCounter"), 1); + + // Accessing FIT information for further exclusivity and/or inclusivity + float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; + int truegapSide = sgSelector.trueGap(collision, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + + // Intiating track parameters to select good tracks, values to be optimized in the configurables, parameters will be taken from SGtrackselector.h task included in the header + std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + + registry.fill(HIST("GapSide"), gapSide); + registry.fill(HIST("TrueGapSide"), truegapSide); + + // Gap side to be selected in the configuables + gapSide = truegapSide; + + if (gapSide == gap_Side) { + + registry.fill(HIST("hSelectionCounter"), 2); + + //____________________________________________________________________________________ + + // Create LorentzVector to store all tracks, Pion tracks and TPC Pion PID + std::vector allTracks; + std::vector onlyPionTracks; + std::vector onlyPionSigma; + std::vector rawPionTracks; + TLorentzVector p; + + registry.fill(HIST("hTracks"), tracks.size()); + + for (auto t : tracks) { + // Apply good track selection criteria + if (!trackselector(t, parameters)) + continue; + + double dEdx = t.tpcSignal(); + + registry.fill(HIST("hdEdx"), t.tpcInnerParam() / t.sign(), dEdx); + + // Creating Lorenz vector to store raw tracks and piontracks + TLorentzVector a; + a.SetXYZM(t.px(), t.py(), t.pz(), o2::constants::physics::MassPionCharged); + allTracks.push_back(a); + + // Apply TPC pion sigma + auto nSigmaPi = t.tpcNSigmaPi(); + if (fabs(nSigmaPi) < PID_cut) { + onlyPionTracks.push_back(a); + onlyPionSigma.push_back(nSigmaPi); + rawPionTracks.push_back(t); + registry.fill(HIST("hdEdxPion"), t.tpcInnerParam() / t.sign(), dEdx); + } + } + + registry.fill(HIST("hTracksPions"), onlyPionTracks.size()); + //_____________________________________ + // Adding all onlypiontracks + for (auto pion : onlyPionTracks) { + p += pion; + } + + //_____________________________________ + // Selecting collisions with Two PV contributors + if (collision.numContrib() == 2) { + + registry.fill(HIST("hSelectionCounter"), 3); + + // Selecting only Two good tracks + if ((rawPionTracks.size() == 2) && (onlyPionTracks.size() == 2)) { + + registry.fill(HIST("hSelectionCounter"), 4); + + registry.fill(HIST("TwoPion/h2TracksPions"), onlyPionTracks.size()); + + registry.fill(HIST("TwoPion/hNsigPivsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigPivsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hTPCsig"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); + registry.fill(HIST("TwoPion/hNsigPi1vsPi2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); + + // Make sure two good tracks are with TPC pion sigma limit + if ((onlyPionSigma[0] * onlyPionSigma[0] + onlyPionSigma[1] * onlyPionSigma[1]) > (PID_cut * PID_cut)) { + return; + } + + registry.fill(HIST("hSelectionCounter"), 5); + + // Rapidity of midrapidity acceptance + if ((p.Rapidity() < -Rap_cut) || (p.Rapidity() > Rap_cut)) { + return; + } + + registry.fill(HIST("hSelectionCounter"), 6); + + // Two oppsotite sign tracks + if (rawPionTracks[0].sign() != rawPionTracks[1].sign()) { + + registry.fill(HIST("hSelectionCounter"), 7); + registry.fill(HIST("TwoPion/hMassUnlike"), p.M()); + + // Flexible mass limits, can be selected in the configurable + if ((p.M() > Mass_Min) && (p.M() < Mass_Max)) { + + registry.fill(HIST("hSelectionCounter"), 8); + + registry.fill(HIST("TwoPion/hPt"), p.Pt()); + registry.fill(HIST("TwoPion/hEta"), p.Eta()); + registry.fill(HIST("TwoPion/hRap"), p.Rapidity()); + registry.fill(HIST("TwoPion/hPhiSystem"), p.Phi()); + registry.fill(HIST("TwoPion/hMPt"), p.M(), p.Pt()); + + // flexible pt limit for selecting coherent Rho(0) + if (p.Pt() < Pt_coherent) { + + registry.fill(HIST("hSelectionCounter"), 9); + + // Quality Control plots after coherent Rho(0) selection + registry.fill(HIST("TwoPion/hEta_t1"), onlyPionTracks[0].Eta()); + registry.fill(HIST("TwoPion/hEta_t2"), onlyPionTracks[1].Eta()); + registry.fill(HIST("TwoPion/hPtsingle_track1"), onlyPionTracks[0].Pt()); + registry.fill(HIST("TwoPion/hPtsingle_track2"), onlyPionTracks[1].Pt()); + + registry.fill(HIST("TwoPion/hNsigMuvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigMuvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaPi()); + registry.fill(HIST("TwoPion/hNsigElvsPt1"), onlyPionTracks[0].Pt(), rawPionTracks[0].tpcNSigmaEl()); + registry.fill(HIST("TwoPion/hNsigElvsPt2"), onlyPionTracks[1].Pt(), rawPionTracks[1].tpcNSigmaEl()); + registry.fill(HIST("TwoPion/hNsigEl1vsEl2"), rawPionTracks[0].tpcNSigmaPi(), rawPionTracks[1].tpcNSigmaPi()); + + registry.fill(HIST("TwoPion/hP1"), onlyPionTracks[0].P(), rawPionTracks[0].tpcSignal()); + registry.fill(HIST("TwoPion/hP2"), onlyPionTracks[1].P(), rawPionTracks[1].tpcSignal()); + registry.fill(HIST("TwoPion/hTPCsig1"), rawPionTracks[0].tpcSignal(), rawPionTracks[1].tpcSignal()); + + registry.fill(HIST("TwoPion/Coherent/hMassUnlikeCoherent"), p.M()); + } + // Incoherent Rho(0) selection + if (p.Pt() > Pt_coherent) { + registry.fill(HIST("hSelectionCounter"), 10); + registry.fill(HIST("TwoPion/Incoherent/hMassUnlikeInCoherent"), p.M()); + } + } + } + + // Same charge particles + if (rawPionTracks[0].sign() == rawPionTracks[1].sign()) { + + registry.fill(HIST("hSelectionCounter"), 11); + registry.fill(HIST("TwoPion/hMassLike"), p.M()); + + // Mass limit + if ((p.M() > Mass_Min) && (p.M() < Mass_Max)) { + + registry.fill(HIST("hSelectionCounter"), 12); + registry.fill(HIST("TwoPion/hPtLike"), p.Pt()); + + // Coherent Rho(0) selection + if (p.Pt() < Pt_coherent) { + + registry.fill(HIST("hSelectionCounter"), 13); + registry.fill(HIST("TwoPion/Coherent/hMassLikeCoherent"), p.M()); + } + // Incoherent Rho(0) selection + if (p.Pt() > Pt_coherent) { + + registry.fill(HIST("hSelectionCounter"), 14); + registry.fill(HIST("TwoPion/Incoherent/hMassLikeInCoherent"), p.M()); + } + } + } + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"udtutorial05"})}; +} diff --git a/Tutorials/PWGUD/UDTutorial_06.cxx b/Tutorials/PWGUD/UDTutorial_06.cxx new file mode 100644 index 00000000000..9b1d1f55895 --- /dev/null +++ b/Tutorials/PWGUD/UDTutorial_06.cxx @@ -0,0 +1,232 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 to compute invariant mass of dimuon at forward rapidity for UPC events. +/// \author Anisa Khatun +/// \date 10.10.2024 + +// O2 headers +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" + +// O2Physics headers +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UDHelpers.h" +#include "CCDB/BasicCCDBManager.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "DataFormatsParameters/GRPECSObject.h" + +// ROOT headers +#include "TSystem.h" +#include "TDatabasePDG.h" +#include "TLorentzVector.h" +#include "TLorentzVector.h" +#include "TMath.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace std; + +struct UDTutorial06 { + + // Histogram registry: an object to hold your histograms + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + Configurable nBinsPt{"nBinsPt", 500, "N bins in pT histo"}; + Configurable nBinsMass{"nBinsMass", 500, "N bins in InvMass histo"}; + + using UDCollisionsFwd = soa::Join; + using fwdtraks = soa::Join; + + void init(InitContext const&) + { + // define axes you want to use + const AxisSpec axisCounter{1, 0, +1, ""}; + const AxisSpec axisEta{80, -5.0, -2.0, "#eta"}; + const AxisSpec axisPt{nBinsPt, 0.0, 10.0, "p_{T}"}; + const AxisSpec axisM{nBinsMass, 0.0, 10.0, "M_{#pi#pi}"}; + const AxisSpec axisPhi{120, -TMath::Pi(), -TMath::Pi(), "#phi"}; + const AxisSpec axisRapidity{80, -5.0, -2.0, "#it{y}"}; + + // create histograms + // Fill counter to see effect of each selection criteria + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{15, 0., 15.}}); + TString SelectionCuts[13] = {"NoSelection", "V0A", "rAbs1", "rAbs2", "trackmatch", "eta1", "eta2", "trackpt", "pair rapidity", "mass_cut", "unlikesign", "likesign"}; + + for (int i = 0; i < 12; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + + registry.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); + registry.add("hnumContrib", "hnumContrib;;#counts", kTH1D, {{100, -0.5, 99.5}}); + registry.add("hTracks1", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracks2", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracksMuons", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + + registry.add("etaMuon1", "etaMuon1", kTH1F, {axisEta}); + registry.add("ptMuon1", "ptMuon1", kTH1F, {axisPt}); + registry.add("phiMuon1", "phiMuon1", kTH1F, {axisPhi}); + + registry.add("etaMuon2", "etaMuon2", kTH1F, {axisEta}); + registry.add("ptMuon2", "ptMuon2", kTH1F, {axisPt}); + registry.add("phiMuon2", "phiMuon2", kTH1F, {axisPhi}); + + registry.add("YJpsi", "YJpsi", kTH1F, {axisRapidity}); + registry.add("PhiJpsi", "PhiJpsi", kTH1F, {axisPhi}); + + registry.add("MJpsiUnlike", "MJpsi", kTH1F, {axisM}); + registry.add("PtJpsiUnlike", "PtJpsi", kTH1F, {axisPt}); + registry.add("MJpsiLike", "MJpsi", kTH1F, {axisM}); + registry.add("PtJpsiLike", "PtJpsi", kTH1F, {axisPt}); + } + + //____________________________________________________________________________________________ + + template + void processCandidate(UDCollisionsFwd::iterator const& collision, TTrack1& tr1, TTrack2& tr2) + { + registry.fill(HIST("eventCounter"), 0.5); + registry.fill(HIST("hnumContrib"), collision.numContrib()); + registry.fill(HIST("hTracks1"), tr1.size()); + registry.fill(HIST("hTracks2"), tr2.size()); + registry.fill(HIST("hSelectionCounter"), 0); + + // V0A selection + const auto& ampsV0A = collision.amplitudesV0A(); + const auto& ampsRelBCsV0A = collision.ampRelBCsV0A(); + for (unsigned int i = 0; i < ampsV0A.size(); ++i) { + if (std::abs(ampsRelBCsV0A[i]) <= 1) { + if (ampsV0A[i] > 100.) + return; + } + } + + // T0A selection + const auto& ampsT0A = collision.amplitudesT0A(); + const auto& ampsRelBCsT0A = collision.ampRelBCsT0A(); + for (unsigned int i = 0; i < ampsT0A.size(); ++i) { + if (std::abs(ampsRelBCsT0A[i]) <= 1) { + if (ampsT0A[i] > 100.) + return; + } + } + + registry.fill(HIST("hSelectionCounter"), 1); + + // absorber end selection + if (tr1.rAtAbsorberEnd() < 17.6 || tr1.rAtAbsorberEnd() > 89.5) + return; + registry.fill(HIST("hSelectionCounter"), 2); + if (tr2.rAtAbsorberEnd() < 17.6 || tr2.rAtAbsorberEnd() > 89.5) + return; + registry.fill(HIST("hSelectionCounter"), 3); + + // MCH-MID match selection + if ((tr1.chi2MatchMCHMID() < 0) || (tr2.chi2MatchMCHMID() < 0)) + return; + registry.fill(HIST("hSelectionCounter"), 4); + + bool isUnlikeSign = (tr1.sign() + tr2.sign()) == 0; + bool isLikeSign = ((tr1.sign() + tr2.sign()) != 0); + + // track selection + TLorentzVector p1, p2; + p1.SetXYZM(tr1.px(), tr1.py(), tr1.pz(), o2::constants::physics::MassMuon); + p2.SetXYZM(tr2.px(), tr2.py(), tr2.pz(), o2::constants::physics::MassMuon); + TLorentzVector p = p1 + p2; + + // eta cut on each track + if (p1.Eta() < -4.0 || p1.Eta() > -2.5) + return; + registry.fill(HIST("hSelectionCounter"), 5); + if (p2.Eta() < -4.0 || p2.Eta() > -2.5) + return; + registry.fill(HIST("hSelectionCounter"), 6); + + // pt cut on track + if ((p1.Pt() < 0.0) || (p2.Pt() < 0.0)) + return; + registry.fill(HIST("hSelectionCounter"), 7); + + if ((p.Rapidity() < -4.0) || (p.Rapidity() > -2.5)) + return; + registry.fill(HIST("hSelectionCounter"), 8); + + // cuts on pair kinematics + if (!(p.M() > 2.5 && p.M() < 5.0)) + return; + registry.fill(HIST("hSelectionCounter"), 9); + + registry.fill(HIST("hTracksMuons"), collision.numContrib()); + registry.fill(HIST("ptMuon1"), p1.Pt()); + registry.fill(HIST("ptMuon2"), p2.Pt()); + registry.fill(HIST("etaMuon1"), p1.Eta()); + registry.fill(HIST("etaMuon2"), p2.Eta()); + registry.fill(HIST("phiMuon1"), p1.Phi()); + registry.fill(HIST("phiMuon2"), p2.Phi()); + registry.fill(HIST("YJpsi"), p.Rapidity()); + registry.fill(HIST("PhiJpsi"), p.Phi()); + + if (isUnlikeSign) { + registry.fill(HIST("hSelectionCounter"), 10); + registry.fill(HIST("MJpsiUnlike"), p.M()); + registry.fill(HIST("PtJpsiUnlike"), p.Pt()); + } + + if (isLikeSign) { + registry.fill(HIST("hSelectionCounter"), 11); + registry.fill(HIST("MJpsiLike"), p.M()); + registry.fill(HIST("PtJpsiLike"), p.Pt()); + } + } + + //____________________________________________________________________________________________ + + // Template that collects all collision IDs and track per collision + template + void collectCandIDs(std::unordered_map>& tracksPerCand, TTracks& tracks) + { + for (const auto& tr : tracks) { + int32_t candId = tr.udCollisionId(); + if (candId < 0) { + continue; + } + tracksPerCand[candId].push_back(tr.globalIndex()); + } + } + + //____________________________________________________________________________________________ + + // process candidates with 2 forward tracks + void process(UDCollisionsFwd const& eventCandidates, + fwdtraks const& fwdTracks) + { + std::unordered_map> tracksPerCand; + collectCandIDs(tracksPerCand, fwdTracks); + + // assuming that candidates have exatly 2 forward tracks + for (const auto& item : tracksPerCand) { + int32_t trId1 = item.second[0]; + int32_t trId2 = item.second[1]; + int32_t candID = item.first; + const auto& collision = eventCandidates.iteratorAt(candID); + const auto& tr1 = fwdTracks.iteratorAt(trId1); + const auto& tr2 = fwdTracks.iteratorAt(trId2); + processCandidate(collision, tr1, tr2); + } + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"udtutorial06"})}; +} diff --git a/Tutorials/PWGUD/UDTutorial_07.cxx b/Tutorials/PWGUD/UDTutorial_07.cxx new file mode 100644 index 00000000000..f2a5616f00d --- /dev/null +++ b/Tutorials/PWGUD/UDTutorial_07.cxx @@ -0,0 +1,230 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does 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 "iostream" +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "PWGUD/DataModel/UDTables.h" +#include "TLorentzVector.h" +#include "PWGUD/Core/SGSelector.h" +#include "PWGUD/Core/SGTrackSelector.h" + +using namespace std; +using namespace o2; +using namespace o2::aod; +using namespace o2::framework; +using namespace o2::framework::expressions; + +/// \brief This is an example to fill outputs in a tree, useful for post processing analysis +/// \author Amrit Gautam +/// \author Anisa Khatun +/// \date 10.10.2024 + +namespace o2::aod +{ +namespace tree +{ +// track tables +DECLARE_SOA_COLUMN(SIGMAPI, sigmapi, std::vector); +DECLARE_SOA_COLUMN(PT, Pt, float); +DECLARE_SOA_COLUMN(RAP, rap, float); +DECLARE_SOA_COLUMN(PHI, Phi, float); +DECLARE_SOA_COLUMN(TOTSIGN, totsign, int); +DECLARE_SOA_COLUMN(MASS, mass, float); +DECLARE_SOA_COLUMN(NPVTRACK, npvtrack, int); +DECLARE_SOA_COLUMN(PTS, Pts, std::vector); +DECLARE_SOA_COLUMN(ETAS, etas, std::vector); +DECLARE_SOA_COLUMN(PHIS, Phis, std::vector); +DECLARE_SOA_COLUMN(SIGNS, Signs, std::vector); +} // namespace tree + +DECLARE_SOA_TABLE(TREE, "AOD", "Tree", + tree::PT, + tree::RAP, + tree::PHI, + tree::MASS, + tree::TOTSIGN, + tree::NPVTRACK, + tree::SIGMAPI, + tree::PTS, + tree::ETAS, + tree::PHIS, + tree::SIGNS); + +} // namespace o2::aod + +struct UDTutorial07 { + SGSelector sgSelector; + Produces tree; + + Configurable FV0_cut{"FV0", 100., "FV0A threshold"}; + Configurable FT0A_cut{"FT0A", 200., "FT0A threshold"}; + Configurable FT0C_cut{"FT0C", 100., "FT0C threshold"}; + Configurable FDDA_cut{"FDDA", 10000., "FDDA threshold"}; + Configurable FDDC_cut{"FDDC", 10000., "FDDC threshold"}; + Configurable ZDC_cut{"ZDC", 10., "ZDC threshold"}; + Configurable gap_Side{"gap", 2, "gap selection"}; + + // 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.1, "Track Pt"}; + Configurable TPC_cluster{"TPC_cluster", 50, "No.of TPC cluster"}; + + // Kinmatic cuts + Configurable PID_cut{"PID_cut", 5, "TPC PID"}; + Configurable Rap_cut{"Rap_cut", 0.9, "Track rapidity"}; + Configurable Mass_Max{"Mass_Max", 10, "Invariant Mass range high"}; + Configurable Mass_Min{"Mass_Min", 0, "Invariant Mass range low"}; + Configurable Pt_coherent{"Pt_coherent", 0.15, "Coherent selection"}; + + // defining histograms using histogram registry + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; + + //----------------------------------------------------------------------------------------------------------------------- + void init(o2::framework::InitContext&) + { + + registry.add("GapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + registry.add("TrueGapSide", "Gap Side; Entries", kTH1F, {{4, -1.5, 2.5}}); + + // Fill counter to see effect of each selection criteria + auto hSelectionCounter = registry.add("hSelectionCounter", "hSelectionCounter;;NEvents", HistType::kTH1I, {{10, 0., 10.}}); + TString SelectionCuts[7] = {"NoSelection", "gapside", "goodtracks", "truegap", "2collcontrib", "2goodtrk"}; + for (int i = 0; i < 7; i++) { + hSelectionCounter->GetXaxis()->SetBinLabel(i + 1, SelectionCuts[i].Data()); + } + + // Fill histograms to cross-check the selected numbers + registry.add("hTracks", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + registry.add("hTracksPions", "N_{tracks}", kTH1F, {{100, -0.5, 99.5}}); + } + + using udtracks = soa::Join; + using udtracksfull = soa::Join; + using UDCollisionsFull = soa::Join; + //__________________________________________________________________________ + // Main process + void process(UDCollisionsFull::iterator const& collision, udtracksfull const& tracks) + { + registry.fill(HIST("hSelectionCounter"), 0); + + // Accessing gap sides + int gapSide = collision.gapSide(); + if (gapSide < 0 || gapSide > 2) + return; + + registry.fill(HIST("hSelectionCounter"), 1); + + // Accessing FIT information for further exclusivity and/or inclusivity + float FIT_cut[5] = {FV0_cut, FT0A_cut, FT0C_cut, FDDA_cut, FDDC_cut}; + int truegapSide = sgSelector.trueGap(collision, FIT_cut[0], FIT_cut[1], FIT_cut[2], ZDC_cut); + + // Intiating track parameters to select good tracks, values to be optimized in the configurables, parameters will be taken from SGtrackselector.h task included in the header + std::vector parameters = {PV_cut, dcaZ_cut, dcaXY_cut, tpcChi2_cut, tpcNClsFindable_cut, itsChi2_cut, eta_cut, pt_cut}; + + registry.fill(HIST("GapSide"), gapSide); + registry.fill(HIST("TrueGapSide"), truegapSide); + + // Gap side to be selected in the configuables + gapSide = truegapSide; + + registry.fill(HIST("hSelectionCounter"), 2); + //_____________________________________ + // Create LorentzVector to store track information + std::vector allTracks; + std::vector onlyPionTracks; + std::vector onlyPionSigma; + std::vector rawPionTracks; + std::vector trackpt; + std::vector tracketa; + std::vector trackphi; + std::vector tracksign; + std::vector pitpcpid; + + TLorentzVector p; + + if (gapSide == gap_Side) { + + registry.fill(HIST("hSelectionCounter"), 3); + + for (auto t : tracks) { + + // Apply good track selection criteria + if (!trackselector(t, parameters)) + continue; + + // Creating Lorenz vector to store raw tracks and piontracks + TLorentzVector a; + a.SetXYZM(t.px(), t.py(), t.pz(), o2::constants::physics::MassPionCharged); + allTracks.push_back(a); + + // Apply TPC pion sigma + auto nSigmaPi = t.tpcNSigmaPi(); + if (fabs(nSigmaPi) < PID_cut) { + onlyPionTracks.push_back(a); + onlyPionSigma.push_back(nSigmaPi); + rawPionTracks.push_back(t); + } + } + registry.fill(HIST("hTracksPions"), onlyPionTracks.size()); + + //_____________________________________ + // Selecting collisions with Two PV contributors + if (collision.numContrib() == 2) { + + registry.fill(HIST("hSelectionCounter"), 4); + + // Selecting only Two good tracks + if ((rawPionTracks.size() == 2) && (allTracks.size() == 2)) { + + registry.fill(HIST("hSelectionCounter"), 4); + + // Creating rhos + for (auto pion : onlyPionTracks) { + p += pion; + } + + for (auto rtrk : rawPionTracks) { + TLorentzVector itrk; + itrk.SetXYZM(rtrk.px(), rtrk.py(), rtrk.pz(), o2::constants::physics::MassPionCharged); + trackpt.push_back(itrk.Pt()); + tracketa.push_back(itrk.Eta()); + trackphi.push_back(itrk.Phi()); + tracksign.push_back(rtrk.sign()); + pitpcpid.push_back(rtrk.tpcNSigmaPi()); + } + + int sign = 0; + for (auto rawPion : rawPionTracks) { + sign += rawPion.sign(); + } + // Filling tree, make to be consistent with the declared tables + tree(p.Pt(), p.Y(), p.Phi(), p.M(), sign, collision.numContrib(), pitpcpid, trackpt, tracketa, trackphi, tracksign); + } + } + } + } +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc, TaskName{"udtutorial07"})}; +} diff --git a/Tutorials/src/TrainingTree.h b/Tutorials/src/TrainingTree.h index 93b4741a951..229b8393193 100644 --- a/Tutorials/src/TrainingTree.h +++ b/Tutorials/src/TrainingTree.h @@ -45,7 +45,7 @@ auto meanPt(Tracks const& tracks) auto apt = 0.f; auto npt = 0; for (auto& track : tracks) { - if (isfinite(track.pt()) && (std::abs(track.pt()) > 1e-3)) { + if (std::isfinite(track.pt()) && (std::abs(track.pt()) > 1e-3)) { ++npt; apt += track.pt(); } diff --git a/Tutorials/src/eventMixing.cxx b/Tutorials/src/eventMixing.cxx index ff5c55da865..676d6ba96e3 100644 --- a/Tutorials/src/eventMixing.cxx +++ b/Tutorials/src/eventMixing.cxx @@ -31,7 +31,7 @@ namespace hash { DECLARE_SOA_COLUMN(Bin, bin, int); } // namespace hash -DECLARE_SOA_TABLE(Hashes, "AOD", "HASH", hash::Bin); +DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin); } // namespace o2::aod @@ -304,7 +304,7 @@ struct MixedEventsTripleVariousKinds { struct HashTask { std::vector xBins{-0.064f, -0.062f, -0.060f, 0.066f, 0.068f, 0.070f, 0.072}; std::vector yBins{-0.320f, -0.301f, -0.300f, 0.330f, 0.340f, 0.350f, 0.360}; - Produces hashes; + Produces hashes; // Calculate hash for an element based on 2 properties and their bins. int getHash(const std::vector& xBins, const std::vector& yBins, float colX, float colY) @@ -341,7 +341,7 @@ struct HashTask { struct MixedEventsWithHashTask { SliceCache cache; - using myCollisions = soa::Join; + using myCollisions = soa::Join; NoBinningPolicy hashBin; SameKindPair> pair{hashBin, 5, -1, &cache}; // indicates that 5 events should be mixed and under/overflow (-1) to be ignored diff --git a/Tutorials/src/pid.cxx b/Tutorials/src/pidTpcTof.cxx similarity index 96% rename from Tutorials/src/pid.cxx rename to Tutorials/src/pidTpcTof.cxx index bc51f07ab4c..777c09c1920 100644 --- a/Tutorials/src/pid.cxx +++ b/Tutorials/src/pidTpcTof.cxx @@ -10,7 +10,7 @@ // or submit itself to any jurisdiction. /// -/// \file pid.cxx +/// \file pidTpcTof.cxx /// \author Nicolò Jacazio nicolo.jacazio@cern.ch /// \brief Task to test the PID features and utilities /// @@ -30,7 +30,7 @@ using namespace o2::framework::expressions; using namespace o2::track; /// Task to produce the response table -struct pid { +struct pidTpcTof { void init(o2::framework::InitContext&) { } @@ -75,5 +75,5 @@ struct pid { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } diff --git a/Tutorials/src/reweighting.cxx b/Tutorials/src/reweighting.cxx index d1c88c22657..72c17a1cb29 100644 --- a/Tutorials/src/reweighting.cxx +++ b/Tutorials/src/reweighting.cxx @@ -37,6 +37,7 @@ #include "Framework/AnalysisTask.h" #include "Common/DataModel/Multiplicity.h" #include "TrainingTree.h" +#include using namespace o2; using namespace o2::framework; @@ -181,7 +182,7 @@ struct ConsumeWeights { /// fill histograms with using BDT scores produced by previous task as weights for (auto& track : tracks) { - if (isfinite(track.pt())) { + if (std::isfinite(track.pt())) { registry.fill(HIST("Weighted/Tracks/Pt"), track.pt(), collision.weight()); } } @@ -201,7 +202,7 @@ struct ConsumeWeights { /// fill histograms without weights for (auto& track : tracks) { - if (isfinite(track.pt())) { + if (std::isfinite(track.pt())) { registry.fill(HIST("Tracks/Pt"), track.pt()); } } diff --git a/Tutorials/src/tracksCombinations.cxx b/Tutorials/src/tracksCombinations.cxx index a61d8daf5aa..413e8399e9b 100644 --- a/Tutorials/src/tracksCombinations.cxx +++ b/Tutorials/src/tracksCombinations.cxx @@ -30,7 +30,7 @@ namespace hash { DECLARE_SOA_COLUMN(Bin, bin, int); } // namespace hash -DECLARE_SOA_TABLE(Hashes, "AOD", "HASH", hash::Bin); +DECLARE_SOA_TABLE(MixingHashes, "AOD", "HASH", hash::Bin); } // namespace o2::aod @@ -116,7 +116,7 @@ struct BinnedTrackPartitionsCombinations { struct HashTask { std::vector xBins{-0.064f, -0.062f, -0.060f, 0.066f, 0.068f, 0.070f, 0.072}; std::vector yBins{-0.320f, -0.301f, -0.300f, 0.330f, 0.340f, 0.350f, 0.360}; - Produces hashes; + Produces hashes; // Calculate hash for an element based on 2 properties and their bins. int getHash(const std::vector& xBins, const std::vector& yBins, float colX, float colY) @@ -154,7 +154,7 @@ struct HashTask { struct BinnedTrackCombinationsWithHashTable { NoBinningPolicy hashBin; - void process(soa::Join const& hashedTracks) + void process(soa::Join const& hashedTracks) { int count = 0; // Strictly upper categorised tracks diff --git a/dependencies/O2PhysicsCompileFlags.cmake b/dependencies/O2PhysicsCompileFlags.cmake index 50967b17ea6..02312bdf601 100644 --- a/dependencies/O2PhysicsCompileFlags.cmake +++ b/dependencies/O2PhysicsCompileFlags.cmake @@ -81,11 +81,11 @@ IF (NOT CMAKE_BUILD_TYPE) ENDIF (NOT CMAKE_BUILD_TYPE) IF(ENABLE_CASSERT) #For the CI, we want to have assertions enabled - set(CMAKE_CXX_FLAGS_RELEASE "-O2") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -pipe") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -pipe") ELSE() - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -pipe") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -pipe") if (CMAKE_BUILD_TYPE STREQUAL "RELEASE" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") set(FAIR_MIN_SEVERITY "info") endif()